From 61ddeb0617f19d70224f2675217d264ef9445178 Mon Sep 17 00:00:00 2001 From: Luka Skugor Date: Fri, 10 Jan 2025 21:17:43 +0000 Subject: [PATCH] Suspend the breakpoint if file is not found --- pkg/proc/bininfo.go | 4 ++++ service/dap/server.go | 3 +++ 2 files changed, 7 insertions(+) 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..78e810c56 100644 --- a/service/dap/server.go +++ b/service/dap/server.go @@ -1510,6 +1510,9 @@ 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() { + got, err = s.debugger.CreateBreakpoint(bp, "", nil, true) + } } } }