[all-commits] [llvm/llvm-project] e796c7: [lldb-vscode] Correctly return source mapped break...

walter erquinigo via All-commits all-commits at lists.llvm.org
Wed Apr 8 09:53:07 PDT 2020


  Branch: refs/heads/master
  Home:   https://github.com/llvm/llvm-project
  Commit: e796c77b26acab0b530ac6516f1dda21b8494733
      https://github.com/llvm/llvm-project/commit/e796c77b26acab0b530ac6516f1dda21b8494733
  Author: Walter Erquinigo <waltermelon at fb.com>
  Date:   2020-04-08 (Wed, 08 Apr 2020)

  Changed paths:
    M lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/lldbvscode_testcase.py
    M lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/vscode.py
    M lldb/test/API/tools/lldb-vscode/breakpoint/Makefile
    M lldb/test/API/tools/lldb-vscode/breakpoint/TestVSCode_setBreakpoints.py
    M lldb/test/API/tools/lldb-vscode/breakpoint/main.cpp
    A lldb/test/API/tools/lldb-vscode/breakpoint/other.c
    M lldb/tools/lldb-vscode/JSONUtils.cpp
    M lldb/tools/lldb-vscode/JSONUtils.h
    M lldb/tools/lldb-vscode/lldb-vscode.cpp

  Log Message:
  -----------
  [lldb-vscode] Correctly return source mapped breakpoints for setBreakpoints request

Summary:
When using source maps for a breakpoint, in order to find the actual source that breakpoint has resolved, we
need to use a query similar to what CommandObjectSource::DumpLinesInSymbolContexts does, which is the logic
used by the CLI to display the source line at a given breakpoint. That's necessary because from a breakpoint
location you only have an address, which points to the original source location, not the source mapped one.

in the setBreakpoints request handler, we haven't been doing such query and we were returning the original
source location, which was breaking the UX of VSCode, as many breakpoints were being set but not displayed
in the source file next to each line. Besides, clicking the source path of a breakpoint in the breakpoints
view in the debug tab was not working for this case, as VSCode was trying to open a non-existent file, thus
showing an error to the user.

Ideally, we should do the query mentioned above to find the actual source location to respond to the IDE,
however, that query is expensive and users can have an arbitrary number of breakpoints set. As a simpler fix,
the request sent by VSCode already contains the full source path, which exists because the user set it from
the IDE itself, so we can simply reuse it instead of querying from the SB API.

I wrote a test for this, and found out that I had to move SetSourceMapFromArguments after RunInitCommands in
lldb-vscode.cpp, because an init command used in all tests is `settings clear -all`, which would clear the
source map unless specified after initCommands. And in any case, I think it makes sense to have initCommands
run before anything the debugger would do.

Reviewers: clayborg, kusmour, labath, aadsm

Subscribers: lldb-commits

Tags: #lldb

Differential Revision: https://reviews.llvm.org/D76968




More information about the All-commits mailing list