service/dap: update go-dap to latest (#3414)

* service/dap: update go-dap to latest

* update remaining possible nil checks

* move helper functions to the end of the file
This commit is contained in:
Suzy Mueller 2023-06-12 17:29:44 -04:00 committed by GitHub
parent 380920c340
commit e549a02f0e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 509 additions and 442 deletions

2
go.mod

@ -8,7 +8,7 @@ require (
github.com/creack/pty v1.1.9
github.com/derekparker/trie v0.0.0-20221213183930-4c74548207f4
github.com/go-delve/liner v1.2.3-0.20220127212407-d32d89dd2a5d
github.com/google/go-dap v0.7.0
github.com/google/go-dap v0.9.1
github.com/hashicorp/golang-lru v0.5.4
github.com/mattn/go-colorable v0.0.9
github.com/mattn/go-isatty v0.0.3

4
go.sum

@ -89,8 +89,8 @@ github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/
github.com/google/go-cmp v0.5.1/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-cmp v0.5.4 h1:L8R9j+yAqZuZjsqh/z+F1NCffTKKLShY6zXTItVIZ8M=
github.com/google/go-cmp v0.5.4/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-dap v0.7.0 h1:088PdKBUkxAxrXrnY8FREUJXpS6Y6jhAyZIuJv3OGOM=
github.com/google/go-dap v0.7.0/go.mod h1:5q8aYQFnHOAZEMP+6vmq25HKYAEwE+LF5yh7JKrrhSQ=
github.com/google/go-dap v0.9.1 h1:d8dETjgHMR9/xs+Xza+NrZmB7jxIS5OtM2uRsyJVA/c=
github.com/google/go-dap v0.9.1/go.mod h1:HAeyoSd2WIfTfg+0GRXcFrb+RnojAtGNh+k+XTIxJDE=
github.com/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXiIaQGbYVAs8BPL6v8lEs=
github.com/google/pprof v0.0.0-20181206194817-3ea8567a2e57/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc=
github.com/google/pprof v0.0.0-20190515194954-54271f7e092f/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc=

@ -73,7 +73,7 @@ func (c *Client) ExpectMessage(t *testing.T) dap.Message {
func (c *Client) ExpectInvisibleErrorResponse(t *testing.T) *dap.ErrorResponse {
t.Helper()
er := c.ExpectErrorResponse(t)
if er.Body.Error.ShowUser {
if er.Body.Error != nil && er.Body.Error.ShowUser {
t.Errorf("\ngot %#v\nwant ShowUser=false", er)
}
return er
@ -82,7 +82,7 @@ func (c *Client) ExpectInvisibleErrorResponse(t *testing.T) *dap.ErrorResponse {
func (c *Client) ExpectVisibleErrorResponse(t *testing.T) *dap.ErrorResponse {
t.Helper()
er := c.ExpectErrorResponse(t)
if !er.Body.Error.ShowUser {
if er.Body.Error == nil || !er.Body.Error.ShowUser {
t.Errorf("\ngot %#v\nwant ShowUser=true", er)
}
return er
@ -91,6 +91,10 @@ func (c *Client) ExpectVisibleErrorResponse(t *testing.T) *dap.ErrorResponse {
func (c *Client) ExpectErrorResponseWith(t *testing.T, id int, message string, showUser bool) *dap.ErrorResponse {
t.Helper()
er := c.ExpectErrorResponse(t)
if er.Body.Error == nil {
t.Errorf("got nil, want Id=%d Format=%q ShowUser=%v", id, message, showUser)
return er
}
if matched, _ := regexp.MatchString(message, er.Body.Error.Format); !matched || er.Body.Error.Id != id || er.Body.Error.ShowUser != showUser {
t.Errorf("got %#v, want Id=%d Format=%q ShowUser=%v", er, id, message, showUser)
}
@ -277,7 +281,9 @@ func (c *Client) DisconnectRequest() {
// `terminateDebuggee`.
func (c *Client) DisconnectRequestWithKillOption(kill bool) {
request := &dap.DisconnectRequest{Request: *c.newRequest("disconnect")}
request.Arguments.TerminateDebuggee = kill
request.Arguments = &dap.DisconnectArguments{
TerminateDebuggee: kill,
}
c.send(request)
}

@ -1128,7 +1128,7 @@ func (s *Session) onDisconnectRequest(request *dap.DisconnectRequest) {
s.mu.Lock()
defer s.mu.Unlock()
if s.debugger != nil && s.config.AcceptMulti && !request.Arguments.TerminateDebuggee {
if s.debugger != nil && s.config.AcceptMulti && (request.Arguments == nil || !request.Arguments.TerminateDebuggee) {
// This is a multi-use server/debugger, so a disconnect request that doesn't
// terminate the debuggee should clean up only the client connection and pointer to debugger,
// but not the entire server.
@ -1161,7 +1161,7 @@ func (s *Session) onDisconnectRequest(request *dap.DisconnectRequest) {
// In case of attach, we leave the program
// running by default, which can be
// overridden by an explicit request to terminate.
killProcess := s.debugger.AttachPid() == 0 || request.Arguments.TerminateDebuggee
killProcess := s.debugger.AttachPid() == 0 || (request.Arguments != nil && request.Arguments.TerminateDebuggee)
err = s.stopDebugSession(killProcess)
} else if s.noDebugProcess != nil {
s.stopNoDebugProcess()
@ -1966,7 +1966,7 @@ func (s *Session) onStackTraceRequest(request *dap.StackTraceRequest) {
stackFrame := dap.StackFrame{Id: uniqueStackFrameID, Line: loc.Line, Name: fnName(loc), InstructionPointerReference: fmt.Sprintf("%#x", loc.PC)}
if loc.File != "<autogenerated>" {
clientPath := s.toClientPath(loc.File)
stackFrame.Source = dap.Source{Name: filepath.Base(clientPath), Path: clientPath}
stackFrame.Source = &dap.Source{Name: filepath.Base(clientPath), Path: clientPath}
}
stackFrame.Column = 0
@ -3045,7 +3045,7 @@ func (s *Session) onDisassembleRequest(request *dap.DisassembleRequest) {
}
// Only set the location on the first instruction for a given line.
if instruction.Loc.File != lastFile || instruction.Loc.Line != lastLine {
instructions[i].Location = dap.Source{Path: instruction.Loc.File}
instructions[i].Location = &dap.Source{Path: instruction.Loc.File}
instructions[i].Line = instruction.Loc.Line
lastFile, lastLine = instruction.Loc.File, instruction.Loc.Line
}
@ -3252,6 +3252,7 @@ func (s *Session) onExceptionInfoRequest(request *dap.ExceptionInfoRequest) {
}
if includeStackTrace {
body.Details = &dap.ExceptionDetails{}
frames, err := s.stacktrace(goroutineID, g)
if err != nil {
body.Details.StackTrace = fmt.Sprintf("Error getting stack trace: %s", err.Error())
@ -3320,9 +3321,11 @@ func (s *Session) sendErrorResponseWithOpts(request dap.Request, id int, summary
er.RequestSeq = request.Seq
er.Success = false
er.Message = summary
er.Body.Error.Id = id
er.Body.Error.Format = fmt.Sprintf("%s: %s", summary, details)
er.Body.Error.ShowUser = showUser
er.Body.Error = &dap.ErrorMessage{
Id: id,
Format: fmt.Sprintf("%s: %s", summary, details),
ShowUser: showUser,
}
s.config.log.Debug(er.Body.Error.Format)
s.send(er)
}
@ -3346,8 +3349,10 @@ func (s *Session) sendInternalErrorResponse(seq int, details string) {
er.RequestSeq = seq
er.Success = false
er.Message = "Internal Error"
er.Body.Error.Id = InternalError
er.Body.Error.Format = fmt.Sprintf("%s: %s", er.Message, details)
er.Body.Error = &dap.ErrorMessage{
Id: InternalError,
Format: fmt.Sprintf("%s: %s", er.Message, details),
}
s.config.log.Debug(er.Body.Error.Format)
s.send(er)
}
@ -3667,7 +3672,7 @@ func (s *Session) logBreakpointMessage(bp *api.Breakpoint, goid int64) bool {
Body: dap.OutputEventBody{
Category: "stdout",
Output: fmt.Sprintf("> [Go %d]: %s\n", goid, msg),
Source: dap.Source{
Source: &dap.Source{
Path: s.toClientPath(bp.File),
},
Line: bp.Line,

@ -429,21 +429,21 @@ func TestLaunchStopOnEntry(t *testing.T) {
// 8 >> stackTrace, << error
client.StackTraceRequest(1, 0, 20)
stResp := client.ExpectInvisibleErrorResponse(t)
if stResp.Seq != 0 || stResp.RequestSeq != 8 || stResp.Body.Error.Format != "Unable to produce stack trace: unknown goroutine 1" {
if stResp.Seq != 0 || stResp.RequestSeq != 8 || !checkErrorMessageFormat(stResp.Body.Error, "Unable to produce stack trace: unknown goroutine 1") {
t.Errorf("\ngot %#v\nwant Seq=0, RequestSeq=8 Format=\"Unable to produce stack trace: unknown goroutine 1\"", stResp)
}
// 9 >> stackTrace, << error
client.StackTraceRequest(1, 0, 20)
stResp = client.ExpectInvisibleErrorResponse(t)
if stResp.Seq != 0 || stResp.RequestSeq != 9 || stResp.Body.Error.Id != UnableToProduceStackTrace {
if stResp.Seq != 0 || stResp.RequestSeq != 9 || !checkErrorMessageId(stResp.Body.Error, UnableToProduceStackTrace) {
t.Errorf("\ngot %#v\nwant Seq=0, RequestSeq=9 Id=%d", stResp, UnableToProduceStackTrace)
}
// 10 >> evaluate, << error
client.EvaluateRequest("foo", 0 /*no frame specified*/, "repl")
erResp := client.ExpectInvisibleErrorResponse(t)
if erResp.Seq != 0 || erResp.RequestSeq != 10 || erResp.Body.Error.Id != UnableToEvaluateExpression {
if erResp.Seq != 0 || erResp.RequestSeq != 10 || !checkErrorMessageId(erResp.Body.Error, UnableToEvaluateExpression) {
t.Errorf("\ngot %#v\nwant Seq=0, RequestSeq=10 Id=%d", erResp, UnableToEvaluateExpression)
}
@ -576,7 +576,7 @@ func TestAttachStopOnEntry(t *testing.T) {
// 10 >> evaluate, << error
client.EvaluateRequest("foo", 0 /*no frame specified*/, "repl")
erResp := client.ExpectInvisibleErrorResponse(t)
if erResp.Seq != 0 || erResp.RequestSeq != 10 || erResp.Body.Error.Id != UnableToEvaluateExpression {
if erResp.Seq != 0 || erResp.RequestSeq != 10 || !checkErrorMessageId(erResp.Body.Error, UnableToEvaluateExpression) {
t.Errorf("\ngot %#v\nwant Seq=0, RequestSeq=10 Id=%d", erResp, UnableToEvaluateExpression)
}
@ -749,7 +749,7 @@ func TestPreSetBreakpoint(t *testing.T) {
if got.Id != id || got.Name != name {
t.Errorf("\ngot %#v\nwant Id=%d Name=%s", got, id, name)
}
if (sourceName != "" && got.Source.Name != sourceName) || (line > 0 && got.Line != line) {
if (sourceName != "" && (got.Source == nil || got.Source.Name != sourceName)) || (line > 0 && got.Line != line) {
t.Errorf("\ngot %#v\nwant Source.Name=%s Line=%d", got, sourceName, line)
}
}
@ -1613,7 +1613,7 @@ func TestScopesAndVariablesRequests(t *testing.T) {
client.ScopesRequest(1111)
erres := client.ExpectInvisibleErrorResponse(t)
if erres.Body.Error.Format != "Unable to list locals: unknown frame id 1111" {
if !checkErrorMessageFormat(erres.Body.Error, "Unable to list locals: unknown frame id 1111") {
t.Errorf("\ngot %#v\nwant Format=\"Unable to list locals: unknown frame id 1111\"", erres)
}
@ -1628,7 +1628,7 @@ func TestScopesAndVariablesRequests(t *testing.T) {
client.VariablesRequest(7777)
erres = client.ExpectInvisibleErrorResponse(t)
if erres.Body.Error.Format != "Unable to lookup variable: unknown reference 7777" {
if !checkErrorMessageFormat(erres.Body.Error, "Unable to lookup variable: unknown reference 7777") {
t.Errorf("\ngot %#v\nwant Format=\"Unable to lookup variable: unknown reference 7777\"", erres)
}
},
@ -3337,7 +3337,7 @@ func checkLogMessage(t *testing.T, oe *dap.OutputEvent, goid int, text, path str
if oe.Body.Category != "stdout" || !strings.HasPrefix(oe.Body.Output, prefix) || !strings.HasSuffix(oe.Body.Output, text+"\n") {
t.Errorf("got output event = %#v, \nwant Category=\"stdout\" Output=\"%s: %s\\n\"", oe, prefix, text)
}
if oe.Body.Line != line || oe.Body.Source.Path != path {
if oe.Body.Line != line || oe.Body.Source == nil || oe.Body.Source.Path != path {
t.Errorf("got output event = %#v, \nwant Line=%d Source.Path=%s", oe, line, path)
}
}
@ -3955,27 +3955,27 @@ func TestEvaluateRequest(t *testing.T) {
// Next frame
client.EvaluateRequest("a1", 1002, "any context but watch")
erres := client.ExpectVisibleErrorResponse(t)
if erres.Body.Error.Format != "Unable to evaluate expression: could not find symbol value for a1" {
if !checkErrorMessageFormat(erres.Body.Error, "Unable to evaluate expression: could not find symbol value for a1") {
t.Errorf("\ngot %#v\nwant Format=\"Unable to evaluate expression: could not find symbol value for a1\"", erres)
}
client.EvaluateRequest("a1", 1002, "watch")
erres = client.ExpectInvisibleErrorResponse(t)
if erres.Body.Error.Format != "Unable to evaluate expression: could not find symbol value for a1" {
if !checkErrorMessageFormat(erres.Body.Error, "Unable to evaluate expression: could not find symbol value for a1") {
t.Errorf("\ngot %#v\nwant Format=\"Unable to evaluate expression: could not find symbol value for a1\"", erres)
}
client.EvaluateRequest("a1", 1002, "repl")
erres = client.ExpectInvisibleErrorResponse(t)
if erres.Body.Error.Format != "Unable to evaluate expression: could not find symbol value for a1" {
if !checkErrorMessageFormat(erres.Body.Error, "Unable to evaluate expression: could not find symbol value for a1") {
t.Errorf("\ngot %#v\nwant Format=\"Unable to evaluate expression: could not find symbol value for a1\"", erres)
}
client.EvaluateRequest("a1", 1002, "hover")
erres = client.ExpectInvisibleErrorResponse(t)
if erres.Body.Error.Format != "Unable to evaluate expression: could not find symbol value for a1" {
if !checkErrorMessageFormat(erres.Body.Error, "Unable to evaluate expression: could not find symbol value for a1") {
t.Errorf("\ngot %#v\nwant Format=\"Unable to evaluate expression: could not find symbol value for a1\"", erres)
}
client.EvaluateRequest("a1", 1002, "clipboard")
erres = client.ExpectVisibleErrorResponse(t)
if erres.Body.Error.Format != "Unable to evaluate expression: could not find symbol value for a1" {
if !checkErrorMessageFormat(erres.Body.Error, "Unable to evaluate expression: could not find symbol value for a1") {
t.Errorf("\ngot %#v\nwant Format=\"Unable to evaluate expression: could not find symbol value for a1\"", erres)
}
},
@ -4291,7 +4291,7 @@ func TestEvaluateCallRequest(t *testing.T) {
client.ExpectEvaluateResponse(t)
client.EvaluateRequest("call callstacktrace()", 1001, "not watch")
erres := client.ExpectVisibleErrorResponse(t)
if erres.Body.Error.Format != "Unable to evaluate expression: call is only supported with topmost stack frame" {
if !checkErrorMessageFormat(erres.Body.Error, "Unable to evaluate expression: call is only supported with topmost stack frame") {
t.Errorf("\ngot %#v\nwant Format=\"Unable to evaluate expression: call is only supported with topmost stack frame\"", erres)
}
@ -4302,14 +4302,14 @@ func TestEvaluateCallRequest(t *testing.T) {
t.Errorf("\ngot %#v\nwant Reason=\"hardcoded breakpoint\"", s)
}
erres = client.ExpectVisibleErrorResponse(t)
if erres.Body.Error.Format != "Unable to evaluate expression: call stopped" {
if !checkErrorMessageFormat(erres.Body.Error, "Unable to evaluate expression: call stopped") {
t.Errorf("\ngot %#v\nwant Format=\"Unable to evaluate expression: call stopped\"", erres)
}
// A call during a call causes an error
client.EvaluateRequest("call callstacktrace()", 1000, "not watch")
erres = client.ExpectVisibleErrorResponse(t)
if erres.Body.Error.Format != "Unable to evaluate expression: cannot call function while another function call is already in progress" {
if !checkErrorMessageFormat(erres.Body.Error, "Unable to evaluate expression: cannot call function while another function call is already in progress") {
t.Errorf("\ngot %#v\nwant Format=\"Unable to evaluate expression: cannot call function while another function call is already in progress\"", erres)
}
@ -4327,7 +4327,7 @@ func TestEvaluateCallRequest(t *testing.T) {
client.EvaluateRequest("call makeclos(nil)", 1000, "not watch")
stopped := client.ExpectStoppedEvent(t)
erres = client.ExpectVisibleErrorResponse(t)
if erres.Body.Error.Format != "Unable to evaluate expression: call stopped" {
if !checkErrorMessageFormat(erres.Body.Error, "Unable to evaluate expression: call stopped") {
t.Errorf("\ngot %#v\nwant Format=\"Unable to evaluate expression: call stopped\"", erres)
}
checkStop(t, client, stopped.Body.ThreadId, "main.makeclos", 88)
@ -4401,7 +4401,7 @@ func TestEvaluateCallRequest(t *testing.T) {
// Call error
client.EvaluateRequest("call call1(one)", 1000, "watch")
erres := client.ExpectInvisibleErrorResponse(t)
if erres.Body.Error.Format != "Unable to evaluate expression: not enough arguments" {
if !checkErrorMessageFormat(erres.Body.Error, "Unable to evaluate expression: not enough arguments") {
t.Errorf("\ngot %#v\nwant Format=\"Unable to evaluate expression: not enough arguments\"", erres)
}
@ -4417,7 +4417,7 @@ func TestEvaluateCallRequest(t *testing.T) {
// Call can exit.
client.EvaluateRequest("call callexit()", 1000, "this context will be ignored")
client.ExpectTerminatedEvent(t)
if res := client.ExpectVisibleErrorResponse(t); !strings.Contains(res.Body.Error.Format, "terminated") {
if res := client.ExpectVisibleErrorResponse(t); res.Body.Error == nil || !strings.Contains(res.Body.Error.Format, "terminated") {
t.Errorf("\ngot %#v\nwant Format=.*terminated.*", res)
}
},
@ -4957,7 +4957,7 @@ func TestPanicBreakpointOnContinue(t *testing.T) {
if frame.PresentationHint != "subtle" {
t.Errorf("\ngot Body.StackFrames[%d]=%#v\nwant Source.PresentationHint=\"subtle\"", i, frame)
}
} else if frame.Source.PresentationHint != "" {
} else if frame.Source != nil && frame.Source.PresentationHint != "" {
t.Errorf("\ngot Body.StackFrames[%d]=%#v\nwant Source.PresentationHint=\"\"", i, frame)
}
@ -5377,7 +5377,7 @@ func TestNoDebug_AcceptNoRequestsButDisconnect(t *testing.T) {
// Anything other than disconnect should get rejected
var ExpectNoDebugError = func(cmd string) {
er := client.ExpectErrorResponse(t)
if er.Body.Error.Format != fmt.Sprintf("noDebug mode: unable to process '%s' request", cmd) {
if !checkErrorMessageFormat(er.Body.Error, fmt.Sprintf("noDebug mode: unable to process '%s' request", cmd)) {
t.Errorf("\ngot %#v\nwant 'noDebug mode: unable to process '%s' request'", er, cmd)
}
}
@ -5877,7 +5877,7 @@ func (h *helperForSetVariable) failSetVariable0(ref int, name, value, wantErrInf
h.c.ExpectStoppedEvent(h.t)
}
resp := h.c.ExpectErrorResponse(h.t)
if got := resp.Body.Error.Format; !stringContainsCaseInsensitive(got, wantErrInfo) {
if got := resp.Body.Error; !stringContainsCaseInsensitive(got.Format, wantErrInfo) {
h.t.Errorf("got %#v, want error string containing %v", got, wantErrInfo)
}
}
@ -6231,8 +6231,8 @@ func TestBadLaunchRequests(t *testing.T) {
if response.Message != "Failed to launch" {
t.Errorf("Message got %q, want \"Failed to launch\"", response.Message)
}
if response.Body.Error.Id != FailedToLaunch {
t.Errorf("Id got %d, want %d", response.Body.Error.Id, FailedToLaunch)
if !checkErrorMessageId(response.Body.Error, FailedToLaunch) {
t.Errorf("Id got %v, want Id=%d", response.Body.Error, FailedToLaunch)
}
seqCnt++
}
@ -6240,8 +6240,8 @@ func TestBadLaunchRequests(t *testing.T) {
checkFailedToLaunchWithMessage := func(response *dap.ErrorResponse, errmsg string) {
t.Helper()
checkFailedToLaunch(response)
if response.Body.Error.Format != errmsg {
t.Errorf("\ngot %q\nwant %q", response.Body.Error.Format, errmsg)
if !checkErrorMessageFormat(response.Body.Error, errmsg) {
t.Errorf("\ngot %v\nwant Format=%q", response.Body.Error, errmsg)
}
}
@ -6432,8 +6432,8 @@ func TestBadAttachRequest(t *testing.T) {
if response.Message != "Failed to attach" {
t.Errorf("Message got %q, want \"Failed to attach\"", response.Message)
}
if response.Body.Error.Id != FailedToAttach {
t.Errorf("Id got %d, want %d", response.Body.Error.Id, FailedToAttach)
if !checkErrorMessageId(response.Body.Error, FailedToAttach) {
t.Errorf("Id got %v, want %d", response.Body.Error, FailedToAttach)
}
seqCnt++
}
@ -6441,8 +6441,8 @@ func TestBadAttachRequest(t *testing.T) {
checkFailedToAttachWithMessage := func(response *dap.ErrorResponse, errmsg string) {
t.Helper()
checkFailedToAttach(response)
if response.Body.Error.Format != errmsg {
t.Errorf("\ngot %q\nwant %q", response.Body.Error.Format, errmsg)
if !checkErrorMessageFormat(response.Body.Error, errmsg) {
t.Errorf("\ngot %v\nwant Format=%q", response.Body.Error, errmsg)
}
}
@ -6494,11 +6494,11 @@ func TestBadAttachRequest(t *testing.T) {
if er.Command != "" {
t.Errorf("Command got %q, want \"attach\"", er.Command)
}
if er.Body.Error.Format != "Internal Error: runtime error: index out of range [0] with length 0" {
if !checkErrorMessageFormat(er.Body.Error, "Internal Error: runtime error: index out of range [0] with length 0") {
t.Errorf("Message got %q, want \"Internal Error: runtime error: index out of range [0] with length 0\"", er.Message)
}
if er.Body.Error.Id != InternalError {
t.Errorf("Id got %d, want %d", er.Body.Error.Id, InternalError)
if !checkErrorMessageId(er.Body.Error, InternalError) {
t.Errorf("Id got %v, want Id=%d", er.Body.Error, InternalError)
}
// Bad "backend"
@ -6813,8 +6813,8 @@ func TestLaunchAttachErrorWhenDebugInProgress(t *testing.T) {
client.AttachRequest(map[string]interface{}{"mode": "local", "processId": 100})
er := client.ExpectVisibleErrorResponse(t)
msgRe := regexp.MustCompile("Failed to attach: debug session already in progress at [0-9]+:[0-9]+ - use remote mode to connect to a server with an active debug session")
if er.Body.Error.Id != FailedToAttach || msgRe.MatchString(er.Body.Error.Format) {
t.Errorf("got %#v, want Id=%d Format=%q", er, FailedToAttach, msgRe)
if er.Body.Error == nil || er.Body.Error.Id != FailedToAttach || msgRe.MatchString(er.Body.Error.Format) {
t.Errorf("got %#v, want Id=%d Format=%q", er.Body.Error, FailedToAttach, msgRe)
}
tests := []string{"debug", "test", "exec", "replay", "core"}
for _, mode := range tests {
@ -6822,8 +6822,8 @@ func TestLaunchAttachErrorWhenDebugInProgress(t *testing.T) {
client.LaunchRequestWithArgs(map[string]interface{}{"mode": mode})
er := client.ExpectVisibleErrorResponse(t)
msgRe := regexp.MustCompile("Failed to launch: debug session already in progress at [0-9]+:[0-9]+ - use remote attach mode to connect to a server with an active debug session")
if er.Body.Error.Id != FailedToLaunch || msgRe.MatchString(er.Body.Error.Format) {
t.Errorf("got %#v, want Id=%d Format=%q", er, FailedToLaunch, msgRe)
if er.Body.Error == nil || er.Body.Error.Id != FailedToLaunch || msgRe.MatchString(er.Body.Error.Format) {
t.Errorf("got %#v, want Id=%d Format=%q", er.Body.Error, FailedToLaunch, msgRe)
}
})
}
@ -6849,10 +6849,10 @@ func TestBadInitializeRequest(t *testing.T) {
if response.Message != "Failed to initialize" {
t.Errorf("Message got %q, want \"Failed to launch\"", response.Message)
}
if response.Body.Error.Id != FailedToInitialize {
t.Errorf("Id got %d, want %d", response.Body.Error.Id, FailedToInitialize)
if !checkErrorMessageId(response.Body.Error, FailedToInitialize) {
t.Errorf("Id got %v, want Id=%d", response.Body.Error, FailedToInitialize)
}
if response.Body.Error.Format != err {
if !checkErrorMessageFormat(response.Body.Error, err) {
t.Errorf("\ngot %q\nwant %q", response.Body.Error.Format, err)
}
@ -6913,7 +6913,7 @@ func TestBadlyFormattedMessageToServer(t *testing.T) {
// an error response.
client.UnknownRequest()
err := client.ExpectErrorResponse(t)
if err.Body.Error.Format != "Internal Error: Request command 'unknown' is not supported (seq: 1)" || err.RequestSeq != 1 {
if !checkErrorMessageFormat(err.Body.Error, "Internal Error: Request command 'unknown' is not supported (seq: 1)") || err.RequestSeq != 1 {
t.Errorf("got %v, want RequestSeq=1 Error=\"Internal Error: Request command 'unknown' is not supported (seq: 1)\"", err)
}
@ -7365,3 +7365,13 @@ func TestDisassembleCgo(t *testing.T) {
},
protest.AllNonOptimized, true)
}
// Helper functions for checking ErrorMessage field values.
func checkErrorMessageId(er *dap.ErrorMessage, id int) bool {
return er != nil && er.Id == id
}
func checkErrorMessageFormat(er *dap.ErrorMessage, fmt string) bool {
return er != nil && er.Format == fmt
}

@ -1,3 +1,5 @@
module github.com/google/go-dap
go 1.13
retract v0.9.0

File diff suppressed because it is too large Load Diff

2
vendor/modules.txt vendored

@ -22,7 +22,7 @@ github.com/derekparker/trie
# github.com/go-delve/liner v1.2.3-0.20220127212407-d32d89dd2a5d
## explicit
github.com/go-delve/liner
# github.com/google/go-dap v0.7.0
# github.com/google/go-dap v0.9.1
## explicit
github.com/google/go-dap
# github.com/hashicorp/golang-lru v0.5.4