mirror of
https://github.com/go-delve/delve.git
synced 2025-10-29 01:27:16 +08:00
service/dap: implement function breakpoints (#2450)
* service/dap: implement setFunctionBreakpoints request * Fix the errors that would not allow func set * use find locations instead of FindFunctionLocation * add function breakpoint tests * return after sending error response * revert changes to debugger * exclude regexp function names * remove switch statement with one case * remove ReadFile ambiguous test * Remove TODO for multiple locs * remove unnecessary setting of bp.Verified on error * tighten condition for breakpoint name to match function breakpoint * add tests for different loc types, add FindLocationSpec * add test using base name of file * make functionBreakpoint name a constant * update stop reason to function breakpoint * remove comment about optimizing onSetFunctionBreakpoints * respond to review * add comments to test * change functionBpPrefix to const * handle relative paths * fix capabilites check * update function breakpoint tests to check for failure * use negative line number to determine which are errors
This commit is contained in:
@ -1585,9 +1585,28 @@ func (d *Debugger) FindLocation(goid, frame, deferredCall int, locStr string, in
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return d.findLocation(goid, frame, deferredCall, locStr, loc, includeNonExecutableLines, substitutePathRules)
|
||||
}
|
||||
|
||||
// FindLocationSpec will find the location specified by 'locStr' and 'locSpec'.
|
||||
// 'locSpec' should be the result of calling 'locspec.Parse(locStr)'. 'locStr'
|
||||
// is also passed, because it made be used to broaden the search criteria, if
|
||||
// the parsed result did not find anything.
|
||||
func (d *Debugger) FindLocationSpec(goid, frame, deferredCall int, locStr string, locSpec locspec.LocationSpec, includeNonExecutableLines bool, substitutePathRules [][2]string) ([]api.Location, error) {
|
||||
d.targetMutex.Lock()
|
||||
defer d.targetMutex.Unlock()
|
||||
|
||||
if _, err := d.target.Valid(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return d.findLocation(goid, frame, deferredCall, locStr, locSpec, includeNonExecutableLines, substitutePathRules)
|
||||
}
|
||||
|
||||
func (d *Debugger) findLocation(goid, frame, deferredCall int, locStr string, locSpec locspec.LocationSpec, includeNonExecutableLines bool, substitutePathRules [][2]string) ([]api.Location, error) {
|
||||
s, _ := proc.ConvertEvalScope(d.target, goid, frame, deferredCall)
|
||||
|
||||
locs, err := loc.Find(d.target, d.processArgs, s, locStr, includeNonExecutableLines, substitutePathRules)
|
||||
locs, err := locSpec.Find(d.target, d.processArgs, s, locStr, includeNonExecutableLines, substitutePathRules)
|
||||
for i := range locs {
|
||||
if locs[i].PC == 0 {
|
||||
continue
|
||||
|
||||
Reference in New Issue
Block a user