Skip to content

Commit

Permalink
use new adapter
Browse files Browse the repository at this point in the history
  • Loading branch information
emicklei committed May 29, 2024
1 parent f26471e commit 9579ee9
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
8 changes: 5 additions & 3 deletions api/debug.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"fmt"
"log/slog"
"os"
"path/filepath"
"reflect"

dbg "github.com/traefik-contrib/yaegi-debug-adapter"
Expand All @@ -31,7 +32,8 @@ func Debug(mainDir string, symbols map[string]map[string]reflect.Value) {
i.Use(stdlib.Symbols)
i.Use(symbols)
_, err := i.CompilePackage(mainDir)
if err != nil {
if err != nil { // TODO
fmt.Println("CompilePackage failed", "err", err)
slog.Error("CompilePackage failed", "err", err)
return nil, err
}
Expand All @@ -49,9 +51,9 @@ func Debug(mainDir string, symbols map[string]map[string]reflect.Value) {
StopAtEntry: false,
NewInterpreter: newInterp,
Errors: errch,
SrcPath: mainDir,
SrcPath: filepath.Join(mainDir, "main.go"), // TODO
}
adp := dbg.NewAdapter(mainDir, (*interp.Interpreter).CompilePackage, debugOpts)
adp := dbg.NewAdapter((*interp.Interpreter).CompilePackage, mainDir, debugOpts)
ListenAndHandle(adp, ListenOptions{})
}

Expand Down
4 changes: 4 additions & 0 deletions api/listen.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,10 @@ func ListenAndHandle(adp dap.Handler, opts ListenOptions) {
}
defer func() { _ = c.Close() }()

if verbose {
s.Debug(os.Stdout)
}

err = s.Run()
if err != nil {
log.Fatal(err)
Expand Down

0 comments on commit 9579ee9

Please sign in to comment.