From baf68e0e7929796d100da411fda77b60ed3df6a3 Mon Sep 17 00:00:00 2001 From: John Howard Date: Fri, 19 Apr 2024 10:38:01 -0700 Subject: [PATCH] rr: fix gdb parsing (#3705) * rr: fix gdb parsing Attempt to fix https://github.com/go-delve/delve/issues/3704 * Fold into one branch --- pkg/proc/gdbserial/rr.go | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/pkg/proc/gdbserial/rr.go b/pkg/proc/gdbserial/rr.go index e3dfcb74..ecaa8820 100644 --- a/pkg/proc/gdbserial/rr.go +++ b/pkg/proc/gdbserial/rr.go @@ -216,7 +216,8 @@ type rrInit struct { } const ( - rrGdbCommandPrefix = " gdb " + rrGdbCommandLegacyPrefix = " gdb " + rrGdbCommandPrefix = " 'gdb' " rrGdbLaunchPrefix = "Launch gdb with" targetCmd = "target extended-remote " ) @@ -233,8 +234,13 @@ func rrStderrParser(stderr io.ReadCloser, initch chan<- rrInit, quiet bool) { return } - if strings.HasPrefix(line, rrGdbCommandPrefix) { - initch <- rrParseGdbCommand(line[len(rrGdbCommandPrefix):]) + var flags string + var foundPrefix bool + if flags, foundPrefix = strings.CutPrefix(line, rrGdbCommandPrefix); !foundPrefix { + flags, foundPrefix = strings.CutPrefix(line, rrGdbCommandLegacyPrefix) + } + if foundPrefix { + initch <- rrParseGdbCommand(flags) close(initch) break }