[Lldb-commits] [PATCH] D130045: Implement better path matching in FileSpecList::FindFileIndex(...).

Greg Clayton via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Mon Jul 18 15:04:18 PDT 2022


clayborg created this revision.
clayborg added reviewers: labath, JDevlieghere, jingham, aadsm, yinghuitan.
Herald added a subscriber: arphaman.
Herald added a project: All.
clayborg requested review of this revision.
Herald added a reviewer: jdoerfert.
Herald added subscribers: lldb-commits, sstefan1.
Herald added a project: LLDB.

Currently a FileSpecList will only match the specified FileSpec if:

- it has filename and directory and both match exactly
- if has a filename only and any filename in the list matches

Because of this, we modify our breakpoint resolving so it can handle relative paths by doing some extra code that removes the directory from the FileSpec when searching if the path is relative.

This patch is intended to fix breakpoints so they work as users expect them to by adding the following features:

- allow matches to relative paths in the file list to match as long as the relative path is at the end of the specified path
- allow matches to paths to match if the specified path is relative and shorter than the file paths in the list

This allows us to remove the extra logic from BreakpointResolverFileLine.cpp that added support for setting breakpoints with relative paths.

This means we can still set breakpoints with relative paths when the debug info contains full paths. We add the ability to set breakpoints with full paths when the debug info contains relative paths.

Debug info contains "./a/b/c/main.cpp", the following will set breakpoints successfully:

- /build/a/b/c/main.cpp
- a/b/c/main.cpp
- b/c/main.cpp
- c/main.cpp
- main.cpp
- ./c/main.cpp
- ./a/b/c/main.cpp
- ./b/c/main.cpp
- ./main.cpp

This also means that all users of FileSpecList::FindFileIndex(...) will get this extra matching, which currently is used for matching modules, but I believe we want this extra matching ability there as well.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D130045

Files:
  lldb/include/lldb/Breakpoint/BreakpointResolverFileLine.h
  lldb/source/Breakpoint/BreakpointResolverFileLine.cpp
  lldb/source/Core/FileSpecList.cpp
  lldb/test/API/functionalities/breakpoint/breakpoint_command/TestBreakpointCommand.py
  lldb/test/API/functionalities/breakpoint/breakpoint_command/relative.yaml

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D130045.445636.patch
Type: text/x-patch
Size: 23874 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20220718/478b2842/attachment-0001.bin>


More information about the lldb-commits mailing list