Skip to content

Commit

Permalink
Suspend the breakpoint if file is not found
Browse files Browse the repository at this point in the history
  • Loading branch information
LittleChimera committed Jan 11, 2025
1 parent c4ab92e commit 61ddeb0
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
4 changes: 4 additions & 0 deletions pkg/proc/bininfo.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
3 changes: 3 additions & 0 deletions service/dap/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
}
}
Expand Down

0 comments on commit 61ddeb0

Please sign in to comment.