Commit Graph

26494 Commits

Author SHA1 Message Date
Adrian Prantl 62b4482175 Revert "Adapt LLDB for D120540."
This reverts commit ca73de4374.

That patch was just hiding the problem, instead of fixing it.
2022-06-01 10:33:53 -07:00
Jim Ingham d92f7f790c Fix a copy-paste error in "br com add -s py -o 'some_python' BKPT_NAME"
The function that was supposed to iterate over all the breakpoints sharing
BKPT_NAME stopped after the first one because of a reversed "if success"
condition.

Differential Revision: https://reviews.llvm.org/D126730
2022-05-31 17:24:14 -07:00
Adrian Prantl ca73de4374 Adapt LLDB for D120540.
In https://reviews.llvm.org/D120540 the -fcxx-modules flag changed
semantics and specifying it explicitly seems to no longer be what we
want here.
2022-05-31 16:56:37 -07:00
Jason Molenda 2f23abd6c6 Increase the default maximum stack walk
lldb will only backtrace a fixed number of stack frames, as a
last-ditch attempt to avoid a runaway looping backtrace.  It's
unusual that anyone ends up depending on this final safety net in
years. I picked the original number of 300000 was picked by seeing
how many stack frames I could make in a small recursive function
on Darwin systems before using the default stack space.  Checking
again today on a modern system, I can exceed this limit & lldb will
not show the original invocation of the recursing call.  Double the
old value to cover this larger maximum possible stack frame count,
as a default value.
(`target.process.thread.max-backtrace-depth`)
2022-05-28 13:12:57 -07:00
Martin Storsjö 9191078707 [lldb] Fix cross compiling on macOS
When cross compiling, a separate nested cmake is spawned, for building
host code generation tools such as lldb-tblgen.

When cross compiling on macOS, the nested native build would trigger
the lldb check for libc++, if testing is enabled (which it is by default).
(Even if `LLDB_INCLUDE_TESTS=OFF` is set on the main build, it has to
be passed separately in `CROSS_TOOLCHAIN_FLAGS_NATIVE` to reach the
nested build.)

Skip this check when building the host tools when cross compiling, as
the user won't try to run tests in that nested build.

(Alternatively, we could consider disabling all the `*_INCLUDE_TESTS`
by default in the nested host tools build.)

Differential Revision: https://reviews.llvm.org/D126557
2022-05-28 00:53:25 +03:00
Chelsea Cassanova 5451c4b4fb
[lldb/fuzzer] Moving target fuzzer into separate subdirectory
Moving lldb-target-fuzzer into its own subdirectory for better
organization and modularity.

Differential revision: https://reviews.llvm.org/D126507
2022-05-26 17:05:14 -07:00
Jim Ingham 134d7f9a4b Store a by name list of signals with their actions in the Target
so that they can be used to prime new Process runs.  "process handle"
was also changed to populate the dummy target if there's no selected
target, so that the settings will get copied into new targets.

Differential Revision: https://reviews.llvm.org/D126259
2022-05-26 14:50:33 -07:00
Stella Stamenova 75acec818e [lldb] Fix enums-layout test on Windows
The test was broken by: https://reviews.llvm.org/D125604
2022-05-26 12:16:52 -07:00
Will Hawkins 84b9985f5f
[lldb] Fix broken bad-address-breakpoint test
After changing the "fallback" behavior when a user sets a breakpoint
without specifying a module the bad-address-breakpoint test case failed
incorrectly. This patch updates that test case in order to more
thoroughly discover an illegal address and use that as the means for
testing whether a breakpoint set at an illegal address fails to resolve.

Differential revision: https://reviews.llvm.org/D126109
2022-05-26 12:16:11 -07:00
Jason Molenda ea6d0c4b2a One further tweak for realpathing filepath to match dyld
I missed one place I need to realpath the build artifact path,
to make it match the path we get back from dyld.
2022-05-26 11:24:56 -07:00
Jason Molenda bd67468645 Check that a FileSpec has a Directory component before using
A follow on to my patch for https://reviews.llvm.org/D126435
hit by an x86_64 linux bot; I assumed that a FileSpec had a
directory component and checked if the first character was a
'~'.  This was not a valid assumption.
2022-05-26 11:12:37 -07:00
Jason Molenda 8a467284d5 Defer source path remap tilde expansion until source file use
When reading source path remappings out of a dSYM, lldb currently
does tilde expansion -- expanding the tilde-username and checking
that the destination pathname exists, for each dSYM with the path
remappings.  This cost happens during lldb's initial process launch
/ load, an especially perf-sensitive time.  Inside Apple, we have
dSYMs with source path remappings pointing to NFS directories where
these extra stats for every dSYM can be very expensive if the network
is slow.

This patch instead keeps the source path mapping in the original
tilde-username terms and does the tilde expansion when we need
to read a specific source file from one of the modules.  We'll
be stat'ing all of those inodes to load the source file anyway,
so the fact that we do the tilde expansion on every source file
we load, it doesn't cost us significantly.

Differential Revision: https://reviews.llvm.org/D126435
rdar://77091379

(cherry picked from commit c274b6e583)
2022-05-26 11:12:37 -07:00
Jason Molenda 56ac85a20f Revert "Defer source path remap tilde expansion until source file use"
This reverts commit c274b6e583.

The x86_64 debian bot got a failure with this patch,
https://lab.llvm.org/buildbot#builders/68/builds/33078
where
SymbolFile/DWARF/x86/DW_TAG_variable-DW_AT_decl_file-DW_AT_abstract_origin-crosscu1.s
is crashing here -

 #2 0x0000000000425a9f SignalHandler(int) Signals.cpp:0:0
 #3 0x00007f57160e9140 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x14140)
 #4 0x00007f570d911e43 lldb_private::SourceManager::GetFile(lldb_private::FileSpec const&) crtstuff.c:0:0
 #5 0x00007f570d914270 lldb_private::SourceManager::DisplaySourceLinesWithLineNumbers(lldb_private::FileSpec const&, unsigned int, unsigned int, unsigned int, unsigned int, char const*, lldb_private::Stream*, lldb_private::SymbolContextList const*) crtstuff.c:0:0
 #6 0x00007f570da662c8 lldb_private::StackFrame::GetStatus(lldb_private::Stream&, bool, bool, bool, char const*) crtstuff.c:0:0

I don't get a failure here my mac, I'll review this method more
closely tomorrow.
2022-05-26 00:46:54 -07:00
Jason Molenda c274b6e583 Defer source path remap tilde expansion until source file use
When reading source path remappings out of a dSYM, lldb currently
does tilde expansion -- expanding the tilde-username and checking
that the destination pathname exists, for each dSYM with the path
remappings.  This cost happens during lldb's initial process launch
/ load, an especially perf-sensitive time.  Inside Apple, we have
dSYMs with source path remappings pointing to NFS directories where
these extra stats for every dSYM can be very expensive if the network
is slow.

This patch instead keeps the source path mapping in the original
tilde-username terms and does the tilde expansion when we need
to read a specific source file from one of the modules.  We'll
be stat'ing all of those inodes to load the source file anyway,
so the fact that we do the tilde expansion on every source file
we load, it doesn't cost us significantly.

Differential Revision: https://reviews.llvm.org/D126435
rdar://77091379
2022-05-26 00:30:12 -07:00
Jason Molenda 8ee35c5558 Update three tests to realpath paths that we compare to dyld paths
I get to my work directory through a symlink, so the pathnames the
tests get for their build artifacts etc are via that symlink.  There
are three tests which compare those symlink paths to a directory
received from dyld on macOS, which is the actual real pathname.

These tests have always failed for me on my dekstop but I finally
sat down to figure out why. Easy quick fix.
2022-05-26 00:21:44 -07:00
Jason Molenda bef4da4a6a Skip testing of watchpoint hit-count/ignore-count on multithreaded
Skip all watchpoint hit-count/ignore-count tests for multithreaded
API tests for now on arm64 Darwin.

On AArch64, insns that trigger a WP are rolled back and we are
notified.  lldb needs to disable the WP, insn step, re-enable it,
then report it to the user.  lldb only does this full step action
for the "selected thread", and so when a program stops with
multiple threads hitting a stop reason, some of them watchpoints,
any non-selected-thread will not be completed in this way.  But
all threads with the initial watchpoint exception will have their
hit-count/ignore-counts updated.  When we resume execution, the
other threads sitting at the instruction will again execute &
trigger the WP exceptoin again, repeating until we've gone through
all of the threads.

This bug is being tracked in llvm.org/pr49433 and inside apple
in rdar://93863107
2022-05-25 16:05:51 -07:00
Zequan Wu 5c9f3ec4ad [LLDB][NativePDB] Check for missing type info to avoid crash.
NativePDB often assumes that all debug info are available.
This is one step to make it more pervasive.

Differential Revision: https://reviews.llvm.org/D125844
2022-05-25 13:19:27 -07:00
Thomas Preud'homme 8e757c6b50 Fix conversion error to Expected
On Ubuntu 18.04 with GCC 7.5 Intel trace code fails to build due to
failure to convert from
lldb_private::process_linux::IntelPTPerThreadProcessTraceUP to
Expected<lldb_private::process_linux::IntelPTPerThreadProcessTraceUP>.
This commit explicitely marks those unique_ptr values as being moved
which fixes the conversion error.

Reviewed By: wallace

Differential Revision: https://reviews.llvm.org/D126402
2022-05-25 20:51:14 +01:00
Kazu Hirata 4391625255 [lldb] Fix an unused function warning
This patch fixes:

  .../llvm-project/lldb/source/Host/common/PseudoTerminal.cpp:106:20:
  error: unused function 'use_ptsname' [-Werror,-Wunused-function]
2022-05-25 09:49:05 -07:00
Jonas Devlieghere 436eaf8d32
[lldb] Improve TestAppleSimulatorOSType.py error message
This was inspired by D109336 which got reverted because we didn't want
the test to fail silently. This patch prints a more informative error
message when we fail to parse the simctl output while still failing the
test.

Differential revision: https://reviews.llvm.org/D126217
2022-05-24 17:17:26 -07:00
Jonas Devlieghere f179f403c8
[lldb] Disable modules in Apple-lldb-base
The LLDB website recommends using the CMake caches to build on macOS.
Although modules result in a faster build, this configuration tends to
break occasionally because it's specific to our platform. I don't expect
newcomers to be able to deal with those kind of breakages so don't
enable them by default.
2022-05-24 17:17:14 -07:00
Jeffrey Tan a1d490319a Fix lldb-vscode frame test failure
Previous patch (https://reviews.llvm.org/D126013) added a new "optimized"
attribute to DAP stack frame this caused some tests, like
lldb-vscode/coreFile/TestVSCode_coreFile.py
to fail because the tests explicitly check for all attributes.

To fix the test failure I decided to remove this attribute.

Differential Revision: https://reviews.llvm.org/D126225
2022-05-23 14:04:37 -07:00
Jorge Gorbe Moya f0a61c2ce2 Remove `friend` classes from TypeCategoryMap
As far as I can tell, the only thing those friend classes access is the
`ValueSP` typedef.

Given that this is a map-ish class, with "Map" in its name, it doesn't
seem like a stretch to make `KeyType`, `ValueType` and `ValueSP` public.
More so when the public methods of the class have `KeyType` and
`ValueSP` arguments and clearly `ValueSP` needs to be accessed from the
outside.

`friend` complicates local reasoning about who can access private
members, which is valuable in a class like this that has every method
locking a mutex to prevent concurrent access.

Differential Revision: https://reviews.llvm.org/D126103
2022-05-23 11:31:53 -07:00
Dave Lee 760298adc2 [lldb] Specify aguments of `image list`
Register positional argument details in `CommandObjectTargetModulesList`.

I recently learned that `image list` takes a module name, but the help info
does not indicate this. With this change, `help image list` will show that it
accepts zero or more module names.

This makes it easier to get info about specific modules, without having to
find/grep through the full image list.

Reviewed By: DavidSpickett

Differential Revision: https://reviews.llvm.org/D125154
2022-05-23 11:00:48 -07:00
Dave Lee 0da230ff44 [lldb] Improve formatting of dlopen error messages (NFC)
Ensure there's a space between "utility" and "function", and also makes
it easier to grep/search for "utility function".

While making this change, I also re-formatted the other dlopen error messages
(with clang-format). This fix other instances of spaces missing between words,
and makes each of these strings fit a single line, making them greppable.

Differential Revision: https://reviews.llvm.org/D126078
2022-05-23 10:57:40 -07:00
Jeffrey Tan 0fe220a331 Show error message for optimized variables
This fixes an issue that optimized variable error message is not shown to end
users in lldb-vscode.

Differential Revision: https://reviews.llvm.org/D126014
2022-05-23 10:04:58 -07:00
Jeffrey Tan 46c1f77e16 Add [opt] suffix to optimized stack frame in lldb-vscode
To help user identify optimized code This diff adds a "[opt]" suffix to
optimized stack frames in lldb-vscode. This provides consistent experience
as command line lldb.

It also adds a new "optimized" attribute to DAP stack frame object so that
it is easy to identify from telemetry than parsing trailing "[opt]".

Differential Revision: https://reviews.llvm.org/D126013
2022-05-23 10:03:13 -07:00
Jonas Devlieghere c30a8c8083
[lldb] Fix should_skip_simulator_test decorator
Currently simulator tests get skipped when the reported platform is
macosx rather than darwin. Update the decorator to match both.
2022-05-23 09:33:51 -07:00
Muhammad Omair Javaid b876c23604 Revert "[lldb] Consider binary as module of last resort"
This reverts commit a3c3482ceb.
It broke LLDB API test TestBadAddressBreakpoints.py

Differential revision: https://reviews.llvm.org/D124731
2022-05-23 11:19:48 +05:00
Luboš Luňák 8ba1421432 [lldb] fix 'command container' help text 2022-05-21 12:26:42 +02:00
Jim Ingham b369762beb Convert the test file for TestIgnoredExceptions.py to the mach_vm API.
The previous version of this test uses mprotect, and that seemed to be
flakey on older systems.  I converted the test to use the underlying
mach_vm API's.  The test only runs on Darwin anyway, so this is not a
real limitation, and I'm hoping the lower level API's work more
consistently.
2022-05-20 15:16:24 -07:00
Jonas Devlieghere d252d9231c
[lldb] Fix spurious assertion in PrintCommandOutput
When the string passed to PrintCommandOutput doesn't end with a newline,
`written` will exceed `size` and result in an lldbassert.

After 8e776bb660 we don't really need
written anymore and we can check whether `str` is empty instead. This
patch simplifies the code and removes the assert that's no longer
relevant.

Differential revision: https://reviews.llvm.org/D126081
2022-05-20 14:15:01 -07:00
Will Hawkins a3c3482ceb
[lldb] Consider binary as module of last resort
When setting an address breakpoint using a non-section address in lldb
before having ever run the program, the binary itself is not considered
a module. As a result, the breakpoint is unresolved (and never gets
resolved subsequently).

This patch changes that behavior: as a last resort, the binary is
considered as a module when resolving a non-section address breakpoint.

Differential revision: https://reviews.llvm.org/D124731
2022-05-20 14:01:05 -07:00
Jim Ingham 9385a6d6ea Add some diagnostics to diagnose bot-only failures for TestIgnoredExceptions.py
The test for commit bff4673b41 is failing on the
GreenDragon bot but none of us can repro the failure locally.  Adding some logging
to the test failure to help diagnose the issue.
2022-05-20 11:38:37 -07:00
Adrian Prantl f4570ce442 Adapt C++ std::string dataformatter for D125496
https://reviews.llvm.org/D125496 changed the layout of std::string
without updating the LLDB dataformatter. This patch adds code to
recognize the new format.

Differential Revision: https://reviews.llvm.org/D126080
2022-05-20 11:25:42 -07:00
Jonas Devlieghere a1cf154dd4
[lldb] Set correct register number for cpsr (GENERIC_REGNUM_FLAGS)
Report the correct register number (GENERIC_REGNUM_FLAGS) for cpsr. This
fixes TestLldbGdbServer.py on Apple Silicon.

Differential revision: https://reviews.llvm.org/D126076
2022-05-20 09:36:58 -07:00
Jonas Devlieghere 80c836ec55
[lldb] Disable scripted_crashlog_json.test on Apple Silicon
Disable scripted_crashlog_json.test on Apple Silicon until Ismail has
bandwidth to investigate.

rdar://93655633
2022-05-20 08:24:46 -07:00
Jonas Devlieghere b9a30b69d8
[lldb] Update test_software_breakpoint_set_and_remove_work for AS
On Apple Silicon the platform arch is arm64 rather than AArch64.
2022-05-19 21:40:20 -07:00
Jonas Devlieghere ea4864007c
[lldb] Fix 'ptsname_r' is only available on macOS 10.13.4 or newer
A deployment target less than 10.13.4 causes an error saying that
'ptsname_r' is only available on macOS 10.13.4 or newer. The current
logic only checks if the symbol is available and doesn't account for the
deployment target. This patch fixes that by adding an availability
check.

Differential revision: https://reviews.llvm.org/D125995
2022-05-19 21:39:52 -07:00
Med Ismail Bennani 027499a824
[lldb/test] Fix PExpect.launch issue when disabling color support
This patch should fix a bug in PExpect.launch that happened when color
support is not enabled.

In that case, we need to add the `--no-use-colors` flag to lldb's launch
argument list. However, previously, each character to the string was
appended separately to the `args` list. This patch solves that by adding
the whole string to the list.

This should fix the TestIOHandlerResize failure on GreenDragon.

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

Signed-off-by: Med Ismail Bennani <medismail.bennani@gmail.com>
2022-05-19 14:47:04 -07:00
David Spickett 068f14f1e4 [lldb] Add --show-tags option to "memory find"
This is off by default. If you get a result and that
memory has memory tags, when --show-tags is given you'll
see the tags inline with the memory content.

```
(lldb) memory read mte_buf mte_buf+64 --show-tags
<...>
0xfffff7ff8020: 00 00 00 00 00 00 00 00 0d f0 fe ca 00 00 00 00 ................ (tag: 0x2)
<...>
(lldb) memory find -e 0xcafef00d mte_buf mte_buf+64 --show-tags
data found at location: 0xfffff7ff8028
0xfffff7ff8028: 0d f0 fe ca 00 00 00 00 00 00 00 00 00 00 00 00 ................ (tags: 0x2 0x3)
0xfffff7ff8038: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ (tags: 0x3 0x4)
```

The logic for handling alignments is the same as for memory read
so in the above example because the line starts misaligned to the
granule it covers 2 granules.

Depends on D125089

Reviewed By: omjavaid

Differential Revision: https://reviews.llvm.org/D125090
2022-05-19 14:40:01 +01:00
David Spickett 13e1cf8065 Reland "[lldb] Add --all option to "memory region""
This reverts commit 3e928c4b9d.

This fixes an issue seen on Windows where we did not properly
get the section names of regions if they overlapped. Windows
has regions like:
[0x00007fff928db000-0x00007fff949a0000) ---
[0x00007fff949a0000-0x00007fff949a1000) r-- PECOFF header
[0x00007fff949a0000-0x00007fff94a3d000) r-x .hexpthk
[0x00007fff949a0000-0x00007fff94a85000) r-- .rdata
[0x00007fff949a0000-0x00007fff94a88000) rw- .data
[0x00007fff949a0000-0x00007fff94a94000) r-- .pdata
[0x00007fff94a94000-0x00007fff95250000) ---

I assumed that you could just resolve the address and get the section
name using the start of the region but here you'd always get
"PECOFF header" because they all have the same start point.

The usual command repeating loop used the end address of the previous
region when requesting the next, or getting the section name.
So I've matched this in the --all scenario.

In the example above, somehow asking for the region at
0x00007fff949a1000 would get you a region that starts at
0x00007fff949a0000 but has a different end point. Using the load
address you get (what I assume is) the correct section name.
2022-05-19 13:16:36 +01:00
Med Ismail Bennani 1351a9b19e [lldb/test] Fix failures caused by a previous PExpect.launch change
This should fix the issues introduced by d71d1a9, which skipped all the
test setup commands.

This also fixes the test failures happening in TestAutosuggestion.py.

Signed-off-by: Med Ismail Bennani <medismail.bennani@gmail.com>
2022-05-18 21:12:44 -07:00
Med Ismail Bennani fbf0c42294 Revert "[lldb/test] Make some tests as XFAIL while I investigate the issue"
This reverts commit 80589f272c.
2022-05-18 21:12:43 -07:00
Med Ismail Bennani fd25ad5122 Revert 821ee172cd
This reverts commit 821ee172cd, that
landed by mistake.
2022-05-18 19:07:47 -07:00
Med Ismail Bennani 80589f272c
[lldb/test] Make some tests as XFAIL while I investigate the issue
This is very likely to be caused by d71d1a947b.

Signed-off-by: Med Ismail Bennani <medismail.bennani@gmail.com>
2022-05-18 18:51:10 -07:00
Med Ismail Bennani 821ee172cd dyld patch
Signed-off-by: Med Ismail Bennani <medismail.bennani@gmail.com>
2022-05-18 18:46:00 -07:00
Med Ismail Bennani 3e54ea0cfa [lldb/crashlog] Fix line entries resolution in interactive mode
This patch subtracts 1 to the pc of any frame above frame 0 to get the
previous line entry and display the right line in the debugger.

This also rephrase some old comment from `48d157dd4`.

rdar://92686666

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

Signed-off-by: Med Ismail Bennani <medismail.bennani@gmail.com>
2022-05-18 18:22:47 -07:00
Med Ismail Bennani 051a5ae998 [lldb/Core] Fix "sticky" long progress messages
When the terminal window is too small, lldb would wrap progress messages
accross multiple lines which would break the progress event handling
code that is supposed to clear the message once the progress is completed.

This causes the progress message to remain on the screen, sometimes partially,
which can be confusing for the user.

To fix this issue, this patch trims the progress message to the terminal
width taking into account the progress counter leading the message for
finite progress events and also the trailing `...`.

rdar://91993836

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

Signed-off-by: Med Ismail Bennani <medismail.bennani@gmail.com>
2022-05-18 18:22:46 -07:00
Med Ismail Bennani d71d1a947b [lldb/Test] Add `use_colors` argument to the PExpect.launch wrapper
This patch adds a new `use_colors` argument to the PExpect.launch
method.

As the name suggests, it allows the user to conditionally enable color
support in the debugger, which can be helpful to test functionalities that
rely on that, like progress reporting. It defaults to False.

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

Signed-off-by: Med Ismail Bennani <medismail.bennani@gmail.com>
2022-05-18 18:22:46 -07:00