Commit Graph

847 Commits

Author SHA1 Message Date
Daniel Paoliello
a8138c3d2f [lldb] Fix inline_sites.test
Fixes `lldb/test/Shell/SymbolFile/NativePDB/inline_sites.test` to use the correct line number now that f2f36c9b29 is causing the inline call site info to be taken into account.
2023-09-06 11:20:39 -07:00
Jonas Devlieghere
a69f78b080 [lldb] Add syntax color highlighting for disassembly
Add support for syntax color highlighting disassembly in LLDB. This
patch relies on 77d1032516, which introduces support for syntax
highlighting in MC.

Currently only AArch64 and X86 have color support, but other interested
backends can adopt WithColor in their respective MCInstPrinter.

Differential revision: https://reviews.llvm.org/D159164
2023-09-01 14:47:45 -07:00
Med Ismail Bennani
c9ecaf32f6 [lldb] Fix test failure for breakpoint_function_callback.test
This should fix the test failure in breakpoint_function_callback.test
since SBStructuredData can now display the content of SBStructuredData.

Signed-off-by: Med Ismail Bennani <ismail@bennani.ma>
2023-08-31 22:19:02 +01:00
walter erquinigo
bc0b569906 [LLDB] Fix tab size settings tests
They were reported in https://lab.llvm.org/buildbot/#/builders/68/builds/58956 and the fix is simple.
2023-08-28 17:55:15 -04:00
Med Ismail Bennani
a6c97a1a30 [lldb/test] Fix Crashlog/no-args.test on ASAN builds (NFC)
This should fix the Sanitizer Green Dragon LLDB Bot:
https://green.lab.llvm.org/green/view/LLDB/job/lldb-cmake-sanitized/4633

Signed-off-by: Med Ismail Bennani <ismail@bennani.ma>
2023-08-23 07:32:35 -07:00
Med Ismail Bennani
4c4f0d81f4 [lldb/crashlog] Add support for Last Exception Backtrace
This patch adds support to the "Last Exception Backtrace" to the
`crashlog` command.

This metadata is homologous to the "Application Specific Backtrace",
however the format is closer to a regular stack frame.

Since the thread that "contains" the "Last Exception Backtrace" doesn't
really exist, this information is displayed when requesting an extended
backtrace of the crashed thread, similarly to the "Application Specific
Backtrace".

To achieve that, this patch includes some refactors and fixes to the
existing "Application Specific Backtrace" handling.

rdar://113046509

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

Signed-off-by: Med Ismail Bennani <ismail@bennani.ma>
2023-08-18 20:50:39 +01:00
Med Ismail Bennani
eef5eadbe6 [lldb/crashlog] Replace deprecated optparse by argparse (NFC)
This patch replace the deprecated `optparse` module used for the
`crashlog`& `save_crashlog` commands with the new `argparse` from the
python standard library. This provides many benefits such as showing the
default values for each option in the help description, but also greatly
improve the handling of position arguments.

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

Signed-off-by: Med Ismail Bennani <ismail@bennani.ma>
2023-08-18 20:50:39 +01:00
Med Ismail Bennani
7602641d7b [lldb/crashlog] Add test for 8f75c4d01e (NFC)
Signed-off-by: Med Ismail Bennani <ismail@bennani.ma>
2023-08-18 20:50:39 +01:00
David Spickett
4139461d4e [lldb] Fix REQUIRES for DWO relative path test
This was "x86-registered-target" which seems to be false in this test
suite despite me having the x86 backend enabled. The other tests use just "x86"
and with that the test passes on my AArch64 machine fine.
2023-08-17 14:19:27 +00:00
Jonas Devlieghere
17226c976e [lldb] Make TSan errors fatal when running the test suite
Set the halt_on_error runtime flag to make TSan errors fatal when
running the test suite. For the API tests the environment variables are
set conditionally on whether the TSan is enabled. The Shell and Unit
tests don't have that logic but setting the environment variable is
harmless. For consistency, I've also mirrored the ASAN option
(detect_stack_use_after_return=1) for the Shell tests.

Differential revision: https://reviews.llvm.org/D157152
2023-08-07 13:20:38 -07:00
David Spickett
865b1190e6 [lldb] XFAIL command-disassemble-mixed.c on Windows
Either clang-cl has different assembly output or we're not mapping
source to assembly properly on Windows. We (Linaro) will find out which.

https://lab.llvm.org/buildbot/#/builders/219/builds/4195
2023-07-19 09:04:56 +00:00
Pavel Labath
b71ac7eea4 [lldb/test] Fix command-disassemble-mixed.c
Add it to lit.local.cfg so that it's actually run, and change it to
(properly) use the %clang_host substitution.
2023-07-18 10:17:09 +02:00
Ted Woodward
ded1bad64a Fix mixed disassembly showing source lines for "line 0"
"line 0" in a DWARF linetable means something that doesn't have associated
source. The code for mixed disassembly has a comment indicating that
"line 0" should be skipped, but the wrong value was returned. Fix the return
value and add a test to check that we don't incorrectly show source lines
from the beginning of the file.

Reviewed By: jasonmolenda

Differential Revision: https://reviews.llvm.org/D112931
2023-07-12 11:39:11 -05:00
Jaroslav Sevcik
a18b17b1be [lldb] Make the test for D153043 linux-only 2023-06-20 07:57:47 +02:00
Jaroslav Sevcik
7ac0ff562a [lldb] Make test for D153043 independent of external symbols
This removes dependence on the libc abort function.
2023-06-20 07:28:30 +02:00
Jaroslav Sevcik
af35be55c0 [lldb] Remove unused directive from test for D153043 2023-06-16 12:46:21 +02:00
Jaroslav Sevcik
07b9e6ed0d [lldb] Fix handling of cfi_restore in the unwinder
Currently, lldb's unwinder ignores cfi_restore opcodes for registers
that are not set in the first row of the unwinding info. This prevents
unwinding of failed assertion in Chrome/v8 (https://github.com/v8/v8).
The attached test is an x64 copy of v8's function that failed to unwind
correctly (V8_Fatal).

This patch changes handling of cfi_restore to reset the location if
the first unwind table row does not map the restored register.

Differential Revision: https://reviews.llvm.org/D153043
2023-06-16 08:01:29 +02:00
Adrian Prantl
27fac4a72a Add support for __debug_line_str in Mach-O
This patch resolves an issue that currently accounts for the vast
majority of failures on the matrix bot.

Differential Revision: https://reviews.llvm.org/D152872
2023-06-14 08:37:08 -07:00
Michael Buch
fae704bad9 [lldb][test] Re-XFAIL prefer-debug-over-eh-frame.test
This was un-XFAILed in `83cb2123be487302070562c45e6eb4955b22c2b4`
due to D144999. Since then D152540 fixed emission of eh_frame's
on Darwin, causing this test to fail again.

Differential Revision: https://reviews.llvm.org/D152806
2023-06-13 15:08:21 +01:00
Adrian Prantl
59b5581833 Speculative fix for windows test 2023-06-12 14:51:24 -07:00
Michael Buch
73927d574f [lldb][test] incomplete-tag-type.cpp: fix expected error message
Follow up to 133c3eaac0

Differential Revision: https://reviews.llvm.org/D152590
2023-06-12 19:33:10 +01:00
Vy Nguyen
83cb2123be [lldb][NFC]Update debug (eh-frame) tests to work with new dwarwin MC changes
Details:

D144999 potentially changes the debug format (from compact-unwind to dwarf).
Updated this test to no longer prefer debug-frame over eh-frame to be compatible with the new behaviour

Differential Revision: https://reviews.llvm.org/D152449
2023-06-08 13:11:34 -04:00
Med Ismail Bennani
0dd62ace2e [lldb] Disable variable watchpoints when going out of scope
If we use a variable watchpoint with a condition using a scope variable,
if we go out-of-scope, the watpoint remains active which can the
expression evaluator to fail to parse the watchpoint condition (because
of the missing varible bindings).

This was discovered after `watchpoint_callback.test` started failing on
the green dragon bot.

This patch should address that issue by setting an internal breakpoint
on the return addresss of the current frame when creating a variable
watchpoint. The breakpoint has a callback that will disable the watchpoint
if the the breakpoint execution context matches the watchpoint execution
context.

This is only enabled for local variables.

This patch also re-enables the failing test following e1086384e5.

rdar://109574319

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

Signed-off-by: Med Ismail Bennani <ismail@bennani.ma>
2023-06-07 16:52:11 -07:00
Med Ismail Bennani
bcfd85a258 [lldb/test] Fix target-label.test on Fuchsia
This shell test also checks some SBAPI functionalities and thus requires
python support.

Signed-off-by: Med Ismail Bennani <ismail@bennani.ma>
2023-06-06 17:42:09 -07:00
Med Ismail Bennani
431f082a55 [lldb] Disable some tests on windows
This patch skips both `test_completion_target_create_from_root_dir`
introduced in `e896612` and  `target-label.test` introduced in `1e82b20`
since I don't have a windows machine to try to accomodate the filesystem
path style differences for these tests to pass.

Signed-off-by: Med Ismail Bennani <ismail@bennani.ma>
2023-06-06 16:10:05 -07:00
Jonas Devlieghere
a10019a496 [lldb] Fix "NameError: name 'self' is not defined" when using crashlog -c
This fixes a regression introduced by 27f27d15f6 that results in a
NameError: (name 'self' is not defined) when using crashlog with the -c
option.

rdar://110007391
2023-06-06 15:20:53 -07:00
Med Ismail Bennani
1e82b20118 [lldb/Target] Add ability to set a label to targets
This patch add the ability for the user to set a label for a target.

This can be very useful when debugging targets with the same executables
in the same session.

Labels can be set either at the target creation in the command
interpreter or at any time using the SBAPI.

Target labels show up in the `target list` output, following the target
index, and they also allow the user to switch targets using them.

rdar://105016191

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

Signed-off-by: Med Ismail Bennani <ismail@bennani.ma>
2023-06-06 10:58:34 -07:00
Zequan Wu
cb9a7c22ee [LLDB][PDB] Fix age field in UUID in PDB file.
There are two age fields in a PDB file. One from the PDB Stream and another one
from the DBI stream.

According to https://randomascii.wordpress.com/2011/11/11/source-indexing-is-underused-awesomeness/#comment-34328,
The age in DBI stream is used to against the binary's age. `Pdbstr.exe` is used
to only increment the age from PDB stream without changing the DBI age. I
also verified this by manually changing the DBI age of a PDB file and let
`windbg.exe` to load it. It shows the following logs before and after changing:

Before:
```
SYMSRV:  BYINDEX: 0xA
         c:\symbols*https://msdl.microsoft.com/download/symbols
         nlaapi.pdb
         D72AA69CD5ABE5D28C74FADB17DE3F8C1
SYMSRV:  PATH: c:\symbols\nlaapi.pdb\D72AA69CD5ABE5D28C74FADB17DE3F8C1\nlaapi.pdb
SYMSRV:  RESULT: 0x00000000
*** WARNING: Unable to verify checksum for NLAapi.dll
DBGHELP: NLAapi - public symbols
        c:\symbols\nlaapi.pdb\D72AA69CD5ABE5D28C74FADB17DE3F8C1\nlaapi.pdb
...
```

After:
```
SYMSRV:  BYINDEX: 0xA
         c:\symbols*https://msdl.microsoft.com/download/symbols
         nlaapi.pdb
         D72AA69CD5ABE5D28C74FADB17DE3F8C1
SYMSRV:  PATH: c:\symbols\nlaapi.pdb\D72AA69CD5ABE5D28C74FADB17DE3F8C1\nlaapi.pdb
SYMSRV:  RESULT: 0x00000000
DBGHELP: c:\symbols\nlaapi.pdb\D72AA69CD5ABE5D28C74FADB17DE3F8C1\nlaapi.pdb - mismatched pdb
SYMSRV:  BYINDEX: 0xB
         c:\symbols*https://chromium-browser-symsrv.commondatastorage.googleapis.com
         nlaapi.pdb
         D72AA69CD5ABE5D28C74FADB17DE3F8C1
SYMSRV:  PATH: c:\symbols\nlaapi.pdb\D72AA69CD5ABE5D28C74FADB17DE3F8C1\nlaapi.pdb
SYMSRV:  RESULT: 0x00000000
DBGHELP: c:\symbols\nlaapi.pdb\D72AA69CD5ABE5D28C74FADB17DE3F8C1\nlaapi.pdb - mismatched pdb
SYMSRV:  BYINDEX: 0xC
         c:\src\symbols*https://msdl.microsoft.com/download/symbols
         nlaapi.pdb
         D72AA69CD5ABE5D28C74FADB17DE3F8C1
SYMSRV:  PATH: c:\src\symbols\nlaapi.pdb\D72AA69CD5ABE5D28C74FADB17DE3F8C1\nlaapi.pdb
SYMSRV:  RESULT: 0x00000000
*** WARNING: Unable to verify checksum for NLAapi.dll
DBGHELP: NLAapi - public symbols
        c:\src\symbols\nlaapi.pdb\D72AA69CD5ABE5D28C74FADB17DE3F8C1\nlaapi.pdb
```

So, `windbg.exe` uses the DBI age to detect mismatched pdb, but it still loads
the pdb even if the age mismatched. Probably lldb should do the same and give
some warnings.

This fixes a bug that lldb can't load some windows system pdbs due to mismatched
uuid.

Reviewed By: rnk

Differential Revision: https://reviews.llvm.org/D152189
2023-06-06 11:24:50 -04:00
Med Ismail Bennani
78ecb428d5 [lldb/crashlog] Add test for non-symbolicated report crash
Signed-off-by: Med Ismail Bennani <ismail@bennani.ma>
2023-06-01 17:50:55 -07:00
David Blaikie
ed7be0d4d1 lldb: Fix cross-cu-reference test to explicitly request that feature 2023-06-01 00:35:39 +00:00
Jason Molenda
f32d24d577 Revert "[lldb] Disable variable watchpoints when going out of scope"
Reverting https://reviews.llvm.org/D151366 until Ismail has a chance
to look at the ubuntu CI test failures and can reland.

This reverts commit 7c847ac4bd.
2023-05-26 15:32:10 -07:00
Daniel Thornburgh
b22965df13 [lldb] Pass CMAKE_SYSROOT through to LLDB shell tests
This allows the LLDB Shell tests to succeed in (e.g. CI) environments where
system libraries are provided hermetically as a sysroot.

Reviewed By: JDevlieghere

Differential Revision: https://reviews.llvm.org/D151269
2023-05-26 11:30:33 -07:00
Jonas Devlieghere
e31f994642 [lldb] Improve error message when evaluating expression when not stopped
When trying to run an expression after a process has existed, you
currently are shown the following error message:

  (lldb) p strlen("")
  error: Can't make a function caller while the process is running

This error is wrong and pretty uninformative. After this patch, the
following error message is shown:

  (lldb) p strlen("")
  error: unable to evaluate expression while the process is exited: the
  process must be stopped because the expression might require
  allocating memory.

rdar://109731325

Differential revision: https://reviews.llvm.org/D151497
2023-05-26 08:49:58 -07:00
Med Ismail Bennani
7c847ac4bd [lldb] Disable variable watchpoints when going out of scope
If we use a variable watchpoint with a condition using a scope variable,
if we go out-of-scope, the watpoint remains active which can the
expression evaluator to fail to parse the watchpoint condition (because
of the missing varible bindings).

This was discovered after `watchpoint_callback.test` started failing on
the green dragon bot.

This patch should address that issue by setting an internal breakpoint
on the return addresss of the current frame when creating a variable
watchpoint. The breakpoint has a callback that will disable the watchpoint
if the the breakpoint execution context matches the watchpoint execution
context.

This is only enabled for local variables.

This patch also re-enables the failing test following e1086384e5.

rdar://109574319

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

Signed-off-by: Med Ismail Bennani <ismail@bennani.ma>
2023-05-25 15:07:09 -07:00
Jonas Devlieghere
2238dcc393 [NFC][Py Reformat] Reformat python files in lldb
This is an ongoing series of commits that are reformatting our Python
code. Reformatting is done with `black` (23.1.0).

If you end up having problems merging this commit because you have made
changes to a python file, the best way to handle that is to run `git
checkout --ours <yourfile>` and then reformat it with black.

RFC: https://discourse.llvm.org/t/rfc-document-and-standardize-python-code-style

Differential revision: https://reviews.llvm.org/D151460
2023-05-25 12:54:09 -07:00
Med Ismail Bennani
e1086384e5 [lldb] Disable watchpoint_callback.test temporarily on darwin
This test started failing on the green-dragon bot, but after some
investigation, it doesn't have anything to do with Lua.

If we use a variable watchpoint with a condition using a scope variable,
if we go out-of-scope, the watpoint remains active which can the
expression evaluator to fail to parse the watchpoint condition (because
of the missing varible bindings).

For now, we should disable this test until we come up with a fix for it.

rdar://109574319

Signed-off-by: Med Ismail Bennani <ismail@bennani.ma>
2023-05-24 10:58:40 -07:00
Med Ismail Bennani
dfdd898862 [lldb/crashlog] Load inlined symbol into interactive crashlog
Sometimes, crash reports come with inlined symbols. These provide the
exact stacktrace from the user binary.

However, when investigating a crash, it's very likely that the images related
to the crashed thread are not available on the debugging user system or
that the versions don't match. This causes interactive crashlog to show
a degraded backtrace in lldb.

This patch aims to address that issue, by parsing the inlined symbols
from the crash report and load them into lldb's target.

This patch is a follow-up to 27f27d1, focusing on inlined symbols
loading from legacy (non-json) crash reports.

To do so, it updates the stack frame regular expression to make the
capture groups more granular, to be able to extract the symbol name, the
offset and the source location if available, while making it more
maintainable.

So now, when parsing the crash report, we build a data structure
containing all the symbol information for each stackframe. Then, after
launching the scripted process for interactive mode, we write a JSON
symbol file for each module, only containing the symbols that it contains.

Finally, we load the json symbol file into lldb, before showing the user
the process status and backtrace.

rdar://97345586

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

Signed-off-by: Med Ismail Bennani <ismail@bennani.ma>
2023-05-19 20:08:18 -07:00
Adrian Prantl
85cb7fbc07 Relax test 2023-05-19 10:52:00 -07:00
Stefan Gränitz
0b6264738f [lldb][gnustep] Add minimal GNUstepObjCRuntime plugin for LanguageTypeObjC on non-Apple platforms
This is the next patch after D146058. We can now parse expressions to print instance variables from ObjC classes. Until now the expression parser would bail out with an error like this:
```
error: expression failed to parse:
error: Error [IRForTarget]: Couldn't find Objective-C indirect ivar symbol OBJC_IVAR_$_TestObj._int
```

Reviewed By: aprantl

Differential Revision: https://reviews.llvm.org/D146154
2023-05-17 13:56:01 +02:00
Stefan Gränitz
4241ac542d [lldb][gnustep] Add basic test and infrastructure for GNUstep ObjC runtime
This patch adds test infrastructure to utilize the GNUstep runtime in the LLDB test suite and adds coverage for features that already work on Linux. These seem accidental in parts, but it's a good early baseline. On Windows nothing works yet. Please find the repository for the GNUstep ObjC runtime here: https://github.com/gnustep/libobjc2

GNUstep support is disabled by default. CMake configuration involves two variables:
* `LLDB_TEST_OBJC_GNUSTEP=On` enables GNUstep support in the test suite. It requires the libobjc2 shared library and headers to be found.
* `LLDB_TEST_OBJC_GNUSTEP=Off` disables GNUstep support in the test suite and resets associated cache values if necessary (default).
* `LLDB_TEST_OBJC_GNUSTEP_DIR` allows to pass a custom installation root.

Differential Revision: https://reviews.llvm.org/D146058
2023-05-17 10:37:38 +02:00
Daniel Paoliello
f8499d5709 Emit the correct flags for the PROC CodeView Debug Symbol
The S_LPROC32_ID and S_GPROC32_ID CodeView Debug Symbols have a flags
field which LLVM has had the values for (in the ProcSymFlags enum) but
has never actually set.

These flags are used by Microsoft-internal tooling that leverages debug
information to do binary analysis.

Modified LLVM to set the correct flags:

- ProcSymFlags::HasOptimizedDebugInfo - always set, as this indicates that
debug info is present for optimized builds (if debug info is not emitted
for optimized builds, then LLVM won't emit a debug symbol at all).
- ProcSymFlags::IsNoReturn and ProcSymFlags::IsNoInline - set if the
function has the NoReturn or NoInline attributes respectively.
- ProcSymFlags::HasFP - set if the function requires a frame pointer (per
TargetFrameLowering::hasFP).

Per discussion in review, XFAIL'ing lldb test until someone working on
lldb has a chance to look at it.

Differential Revision: https://reviews.llvm.org/D148761
2023-05-16 10:58:10 -07:00
Benjamin Kramer
5130e049ff [lldb] Don't write to source directory in test 2023-05-12 12:26:29 +02:00
Dave Lee
efbd587040 [lldb] Correct elision of line zero in mixed disassembly
When `disassemble --mixed` is run, do not show source for line zero, as intended.

Differential Revision: https://reviews.llvm.org/D150383
2023-05-11 13:24:32 -07:00
Jim Ingham
7b5dc63fc4 When the Debugger runs HandleProcessEvent it should allow
selecting the "Most relevant" frame.

If you don't do that, then the correct frame gets selected, but it
happens AFTER the frame info gets printed in the stop message, so
you don't see the selected frame.

The test for this hid the issue because it ran `frame info` and
checked the result of that.  That happens after the recognizer selects
the frame, and so it was right.  But if the recognizer is working
correctly it will have already done the same printing in the stop
message, and this way we also verify that the stop message was right.

Differential Revision: https://reviews.llvm.org/D150315
2023-05-10 15:40:40 -07:00
Saleem Abdulrasool
5014830ede ObjectFile: introduce a COFF object file plugin
Windows uses COFF as an object file format and PE/COFF as an executable
file format. They are subtly different and certain elements of a COFF
file may not be present in an executable. Introduce a new plugin to add
support for the COFF object file format which is required to support
loading of modules built with -gmodules. This is motivated by Swift
which serialises debugging information into a PCM which is a COFF object
file.

Differential Revision: https://reviews.llvm.org/D149987
Reviewed By: bulbazord
2023-05-07 12:40:44 -07:00
LU Hongyi
16c2872d7b Reland "[lldb][DWARFExpression] Fix DW_OP_div to use signed division"
This patch resolves an issue where a value
is incorrectly displayed if it is represented
by DW_OP_div.

This issue is caused by lldb evaluating
operands of DW_OP_div as unsigned
and performed unintended unsigned
division.

This issue is resolved by creating two
temporary signed scalar and performing
signed division.

(Addresses GH#61727)

Differential Revision: https://reviews.llvm.org/D147370
2023-05-05 06:45:07 -04:00
Michael Buch
ad74df12b8 Revert "[lldb][DWARFExpression] Fix DW_OP_div to use signed division"
This reverts commit e15d6b520e.

Newly added test fails on Darwin platforms and arm.

Differential Revision: https://reviews.llvm.org/D147370
2023-05-02 15:36:56 -04:00
Adrian Prantl
419bc85675 Revert "Add amissing REQUIRES: to test"
This reverts commit 1f74964b40.

The googles. They do nothing!
2023-05-02 11:41:58 -07:00
Adrian Prantl
1f74964b40 Add amissing REQUIRES: to test 2023-05-02 11:16:04 -07:00
LU Hongyi
e15d6b520e [lldb][DWARFExpression] Fix DW_OP_div to use signed division
This patch resolves an issue where a value
is incorrectly displayed if it is represented
by DW_OP_div.

This issue is caused by lldb evaluating
operands of DW_OP_div as unsigned
and performed unintended unsigned
division.

This issue is resolved by creating two
temporary signed scalar and performing
signed division.

(Addresses GH#61727)

Differential Revision: https://reviews.llvm.org/D147370
2023-05-02 07:38:52 -04:00