Skip to content

Commit

Permalink
more tracing
Browse files Browse the repository at this point in the history
  • Loading branch information
emicklei committed May 29, 2024
1 parent 9579ee9 commit 78a28c1
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 3 deletions.
4 changes: 4 additions & 0 deletions api/dlvflags.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ import (
"strings"
)

func IsTraceEnabled() bool {
return getLogFlag()
}

func flagValueString(f string) string {
if !strings.Contains(f, "=") {
return ""
Expand Down
2 changes: 1 addition & 1 deletion api/listen.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ func ListenAndHandle(adp dap.Handler, opts ListenOptions) {
defer func() { _ = c.Close() }()

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

err = s.Run()
Expand Down
2 changes: 1 addition & 1 deletion cmd/varvoy/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const Version = "0.0.6"
//
// dap --listen=127.0.0.1:52950 --log-dest=3 --log
func main() {
adp := new(internal.ProxyAdapter)
adp := &internal.ProxyAdapter{Trace: api.IsTraceEnabled()}
opts := api.ListenOptions{
BeforeAccept: func(addr string) {
// Line must start with "DAP server listening at:"
Expand Down
4 changes: 4 additions & 0 deletions internal/proxy-adaptor.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ const (
)

type ProxyAdapter struct {
Trace bool // if set then put session in debug mode
session *dap.Session

// for the target program to debug
Expand All @@ -31,6 +32,9 @@ type ProxyAdapter struct {
func (a *ProxyAdapter) Initialize(s *dap.Session, ccaps *dap.InitializeRequestArguments) (*dap.Capabilities, error) {
slog.Debug("Initialize")
a.session = s
if a.Trace {
s.Debug(os.Stdout)
}

// create temporary binary
wd, _ := os.Getwd()
Expand Down
3 changes: 2 additions & 1 deletion todebug/hello/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@ package main
import "fmt"

func main() {
fmt.Println("Hello, World!")
m := map[bool]bool{true: false}
fmt.Println("Hello, World!", m)
}

0 comments on commit 78a28c1

Please sign in to comment.