MCPcopy
hub / github.com/expr-lang/expr / StartDebugger

Function StartDebugger

debug/debugger.go:16–198  ·  view source on GitHub ↗
(program *Program, env any)

Source from the content-addressed store, hash-verified

14)
15
16func StartDebugger(program *Program, env any) {
17 vm := Debug()
18 app := tview.NewApplication()
19 table := tview.NewTable()
20 stack := tview.NewTable()
21 stack.
22 SetBorder(true).
23 SetTitle("Stack")
24 scope := tview.NewTable()
25 scope.
26 SetBorder(true).
27 SetTitle("Scope")
28 sub := tview.NewFlex().
29 SetDirection(tview.FlexRow).
30 AddItem(stack, 0, 3, false).
31 AddItem(scope, 0, 1, false)
32 flex := tview.NewFlex().
33 AddItem(table, 0, 1, true).
34 AddItem(sub, 0, 1, false)
35 app.SetRoot(flex, true)
36
37 done := false
38 go func() {
39 out, err := vm.Run(program, env)
40 done = true
41 app.QueueUpdateDraw(func() {
42 sub.RemoveItem(stack)
43 sub.RemoveItem(scope)
44 result := tview.NewTextView()
45 result.
46 SetBorder(true).
47 SetTitle("Output")
48 result.SetText(fmt.Sprintf("%#v", out))
49 sub.AddItem(result, 0, 1, false)
50 if err != nil {
51 errorView := tview.NewTextView()
52 errorView.
53 SetBorder(true).
54 SetTitle("Error")
55 errorView.SetText(err.Error())
56 sub.AddItem(errorView, 0, 1, false)
57 }
58 })
59 }()
60
61 index := make(map[int]int)
62 var buf strings.Builder
63 program.DisassembleWriter(&buf)
64
65 for row, line := range strings.Split(buf.String(), "\n") {
66 if line == "" {
67 continue
68 }
69 parts := strings.Split(line, "\t")
70
71 ip, err := strconv.Atoi(parts[0])
72 check(err)
73 index[ip] = row

Callers 1

mainFunction · 0.92

Calls 13

RunFunction · 0.92
DebugFunction · 0.85
checkFunction · 0.85
SprintfMethod · 0.80
DisassembleWriterMethod · 0.80
SplitMethod · 0.80
ClearMethod · 0.80
PositionMethod · 0.80
StepMethod · 0.80
KeyMethod · 0.80
RunMethod · 0.80
StringMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…