diff --git a/pkg/proc/bininfo.go b/pkg/proc/bininfo.go index 46ece47c3..b52a89257 100644 --- a/pkg/proc/bininfo.go +++ b/pkg/proc/bininfo.go @@ -930,6 +930,10 @@ func (err *ErrCouldNotFindLine) Error() string { return fmt.Sprintf("could not find file %s", err.filename) } +func (err *ErrCouldNotFindLine) IsFileFound() bool { + return err.fileFound +} + // AllPCsForFileLines returns a map providing all PC addresses for filename and each line in linenos func (bi *BinaryInfo) AllPCsForFileLines(filename string, linenos []int) map[int][]uint64 { r := make(map[int][]uint64) diff --git a/service/dap/server.go b/service/dap/server.go index 2f65f91bc..318c83931 100644 --- a/service/dap/server.go +++ b/service/dap/server.go @@ -1510,6 +1510,10 @@ func (s *Session) setBreakpoints(prefix string, totalBps int, metadataFunc func( if err == nil { // Create new breakpoints. got, err = s.debugger.CreateBreakpoint(bp, "", nil, false) + if createBpError, isCouldNotFindLine := err.(*proc.ErrCouldNotFindLine); isCouldNotFindLine && !createBpError.IsFileFound() { + // try to create a suspended breakpoint instead + got, _ = s.debugger.CreateBreakpoint(bp, "", nil, true) + } } } }