Commit Graph

5772 Commits

Author SHA1 Message Date
Med Ismail Bennani 9216baf87d [lldb/test] Add events listener helper function to lldbtest
This patch introduces 2 new lldb utility functions:
- lldbutil.start_listening_from: This can be called in the test setup to
  create a listener and set it up for a specific event mask and add it
  to the user-provided broadcaster's list.
- lldbutil.fetch_next_event: This will use fetch a single event from the
  provided istener and return it if it matches the provided broadcaster.

The motivation behind this is to easily test new kinds of events
(i.e. Swift type-system progress events). However, this patch also
updates `TestProgressReporting.py` and `TestDiagnosticReporting.py`
to make use of these new helper functions.

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

Signed-off-by: Med Ismail Bennani <medismail.bennani@gmail.com>
2022-03-23 12:30:09 -07:00
Jonas Devlieghere f54931865d
[lldb] Set the TERM environment variable for the API tests
Avoid "TERM environment variable not set" by either propagating the TERM
environment variable or defaulting to vt100. All of our CI is already
doing this explicitly through the --env dotest arg, but it's easy to
forget when setting up a new job. I don't see any downside in making it
the default.
2022-03-22 11:01:38 -07:00
Walter Erquinigo a80c6c7d36 [trace] clear any existing tracing sessions before relaunching the binary
There's a bug caused when a process is relaunched: the target, which
doesn't change, keeps the Trace object from the previous process, which
is already defunct, and causes segmentation faults when it's attempted
to be used.
A fix is to clean up the Trace object when the target is disposing of
the previous process during relaunches.

A way to reproduce this:
```
lldb a.out
b main
r
process trace start
c
r
process trace start
```

Differential Revision: https://reviews.llvm.org/D122176
2022-03-21 16:03:37 -07:00
Alisamar Husain ca47011e73 [tests][intelpt] Fix outdated trace load test
Differential Revision: https://reviews.llvm.org/D122114
2022-03-21 13:21:45 +05:30
Pavel Labath 8bf8934666 Revert "[lldb/test] Add events listener helper class to lldbtest"
It removes the "wait-until-event-thread-stops" logic, which makes
TestDiagnosticReporting.py flaky.

This reverts commits 09ff41a087 and
acdd41b459.
2022-03-21 08:32:16 +01:00
Alisamar Husain 37a466dd72 [trace][intelpt] Added total memory usage by decoded trace
This fails currently but the basics are there

Differential Revision: https://reviews.llvm.org/D122093
2022-03-21 12:36:08 +05:30
Alisamar Husain 8271220a99 [trace][intelpt] Instruction count in trace info
Added a line to `thread trace dump info` results which shows total number of instructions executed until now.

Differential Revision: https://reviews.llvm.org/D122076
2022-03-20 11:28:16 +05:30
Med Ismail Bennani 09ff41a087 [lldb/test] Add events listener helper class to lldbtest
This patch introduces a generic helper class that will listen for
event in a background thread and match it against a source broadcaster.

If the event received matches the source broadcaster, the event is
queued up in a list that the user can access later on.

The motivation behind this is to easily test new kinds of events
(i.e. Swift type-system progress events). However, this patch also
updates `TestProgressReporting.py` and `TestDiagnosticReporting.py`
to make use of this new helper class.

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

Signed-off-by: Med Ismail Bennani <medismail.bennani@gmail.com>
2022-03-18 16:35:33 -07:00
Walter Erquinigo b7d525ad38 [trace][intelpt] fix some test failures
Minor fixes needed and now `./bin/lldb-dotest -p TestTrace` passes
correctly.

- There was an incorrect iteration.
- Some error messages changed.
- The way repeat commands are handled changed a bit, so I had to create
a new --continue arg in "thread trace dump instructions" to handle this
correctly.

Differential Revision: https://reviews.llvm.org/D122023
2022-03-18 10:35:34 -07:00
David Spickett 9f052f3dd2 [lldb] Require x86 target for NativePDB test
This test would fail if you only build for example,
just the AArch64 backend, due to the x86 triple.
2022-03-18 12:31:03 +00:00
Pavel Labath af4da4f995 [lldb] Increase timeout in TestProcessIOHandlerInterrupt
The small value was not meant to be checked in.
2022-03-18 12:14:10 +01:00
Pavel Labath a4d6de2031 [lldb] Fix TestProcessIOHandlerInterrupt.py for macos
On darwin, we don't completely suppress the signal used to interrupt the
inferior. The underlying read syscall returns EINTR, which causes premature
termination of the input loop.

Work around that by hand-rolling an EINTR-resistant version of getline.
2022-03-18 11:51:55 +01:00
Pavel Labath 14bd14f9f9 [lldb] Fix ^C handling in IOHandlerProcessSTDIO
D120762 accidentally moved the interrupt check into the block which was
reading stdio. This meant that a ^C only took effect after a regular
character has been pressed.

This patch fixes that and adds a (pexpect) test.

Differential Revision: https://reviews.llvm.org/D121912
2022-03-18 08:58:30 +01:00
Jonas Devlieghere 7ed1abd4a6
[lldb] Skip invalid-condition.test on Windows
This test is making the Windows bot unhappy. Unfortunately the output
doesn't tell me much about what exactly is wrong.
2022-03-17 08:34:12 -07:00
Jonas Devlieghere d10c0c7b18
[lldb] Migrate condition evaluation failure to ReportError
Migrate to using ReportError to report a failure to evaluate a
watchpoint condition. I had already done so for the parallel code for
breakpoints.

In the process, I noticed that I accidentally regressed the error
reporting for breakpoint conditions by dropping the call to
GetDescription. This patch rectifies that and adds a test.

Because the call to GetDescription expects a Stream*, I also switches
from using a raw_string_ostream to a StreamString for both breakpoints
and watchpoints.
2022-03-16 22:54:02 -07:00
Jonas Devlieghere 8212b41b7b
[lldb] Fix flakiness in command-disassemble-process.yaml (2/2)
I split up the test so we could stop redirecting stderr to stdout but I
forgot to include that part in the previous commit.
2022-03-16 22:12:39 -07:00
Jonas Devlieghere 557a0e7b96
[lldb] Fix flakyness in command-disassemble-process.yaml 2022-03-16 21:27:54 -07:00
Jonas Devlieghere 8e893dfed5
[lldb] Fix flakyness in Minidump/no-process-id.yaml 2022-03-16 21:21:11 -07:00
Med Ismail Bennani 0a65112cf7 [lldb/crashlog] Create artificial frames for non-crashed scripted threads
This patch pipes down the `-a|--load-all` crashlog command option to the
Scripted Process initializer to load all the images used by crashed
process instead of only loading the images related to the crashed
thread.

This allows us to recreate artificial frames also for the non-crashed
scripted threads.

rdar://90396265

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

Signed-off-by: Med Ismail Bennani <medismail.bennani@gmail.com>
2022-03-16 15:50:10 -07:00
Jonas Devlieghere ff9e596b10
[lldb] Expose diagnostic events through the SB API
Expose diagnostic events through the SB API. Unlike the progress events,
I opted to use a SBStructuredData so that we can add fields in the
future.

Differential revision: https://reviews.llvm.org/D121818
2022-03-16 15:03:31 -07:00
Jonas Devlieghere 3f0e050842
[lldb] Fix Minidump/no-process-id.yaml
Update warning after 2fc38b2b7b.
2022-03-16 09:32:06 -07:00
Sam McCall 75acad41bc Use lit_config.substitute instead of foo % lit_config.params everywhere
This mechanically applies the same changes from D121427 everywhere.

Differential Revision: https://reviews.llvm.org/D121746
2022-03-16 09:57:41 +01:00
Zequan Wu 384e890dd3 [LLDB][NativePDB] Remove REQUIRES: system-windows for local-variables-regsiters.s 2022-03-15 17:49:46 -07:00
Zequan Wu 583223cd5e [LLDB][NativePDB] Don't complete static members' types when completing a record type.
`UdtRecordCompleter` shouldn't complete static members' types. static members' types are going to be completed when the types are called in `SymbolFile::CompleteType`.

Reviewed By: labath

Differential Revision: https://reviews.llvm.org/D121030
2022-03-15 14:06:54 -07:00
Shafik Yaghmour 6583f01707 [LLDB] Fixing DWARFExpression handling of ValueType::FileAddress case for DW_OP_deref_size
Currently DW_OP_deref_size just drops the ValueType::FileAddress case and does
not attempt to handle it. This adds support for this case and a test that
verifies this support.

I did a little refactoring since DW_OP_deref and DW_OP_deref_size have some
overlap in code.

Also see: rdar://66870821

Differential Revision: https://reviews.llvm.org/D121408
2022-03-15 09:36:20 -07:00
Jonas Devlieghere c22c7a61b6
[lldb] Fix platform selection on Apple Silicon (again)
This patch is another attempt to fix platform selection on Apple
Silicon. It partially undoes D117340 which tried to fix the issue by
always instantiating a remote-ios platform for "iPhone and iPad Apps on
Apple Silicon Macs".

While the previous patch worked for attaching, it broke launching and
everything else that expects the remote platform to be connected. I made
an attempt to work around that, but quickly found out that there were
just too may places that had this assumption baked in.

This patch takes a different approach and reverts back to marking the
host platform compatible with iOS triples. This brings us back to the
original situation where platform selection was broken for remote iOS
debugging on Apple Silicon. To fix that, we now look at the process'
host architecture to differentiate between iOS binaries running remotely
and iOS binaries running locally.

I tested the following scenarios, which now all uses the desired
platform:

  - Launching an iOS binary on macOS: uses the host platform
  - Attaching to an iOS binary on macOS: uses the host platform
  - Attaching to a remote iOS binary: uses the remote-ios platform

rdar://89840215

Differential revision: https://reviews.llvm.org/D121444
2022-03-15 09:06:29 -07:00
Jim Ingham 33f9fc77d1 Don't report memory return values on MacOS_arm64 of SysV_arm64 ABI's.
They don't require that the memory return address be restored prior to
function exit, so there's no guarantee the value is correct.  It's better
to return nothing that something that's not accurate.

Differential Revision: https://reviews.llvm.org/D121348
2022-03-14 15:25:40 -07:00
Stella Stamenova 8bd1988e74 [lldb] Skip Test11588 on Windows
The test was marked as XFAIL on Windows, but recent changes have made it flaky instead
2022-03-14 09:26:41 -07:00
Ayush Sahay d506a9ef2b [lldb] Require native for command-thread-siginfo.test
command-thread-siginfo.test employs a subject with a call to wait, and
thus requires system-linux. However, it's possible to target non-Linux
platforms despite operating on Linux hosts. So, have it require native
too.

Reviewed By: mgorny, labath

Differential Revision: https://reviews.llvm.org/D121487
2022-03-14 21:20:21 +05:30
Petr Hosek 0c0f6cfb7b [CMake] Rename TARGET_TRIPLE to LLVM_TARGET_TRIPLE
This clarifies that this is an LLVM specific variable and avoids
potential conflicts with other projects.

Differential Revision: https://reviews.llvm.org/D119918
2022-03-11 15:43:01 -08:00
Zequan Wu 5e9c9b324a [LLDB][NativePDB] Add support for S_DEFRANGE_REGISTER and S_DEFRANGE_SUBFIELD_REGISTER
Differential Revision: https://reviews.llvm.org/D119508
2022-03-10 12:40:31 -08:00
Med Ismail Bennani 6aa48034f9 [lldb/Plugin] Test that a scripted process blueprint can be loaded for the dSYM
This patch ensures that lldb can automatically load a scripted process
blueprint from a dSYM bundle and launch a scripted process with it.

rdar://74502750

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

Signed-off-by: Med Ismail Bennani <medismail.bennani@gmail.com>
2022-03-10 11:06:59 -08:00
Med Ismail Bennani 8d097a6b93 [lldb/crashlog] Make interactive mode display more user-friendly
This patch makes the crashlog interactive mode show the scripted process
status with the crashed scripted thread backtrace after launching it.

rdar://89634338

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

Signed-off-by: Med Ismail Bennani <medismail.bennani@gmail.com>
2022-03-10 11:06:59 -08:00
Pavel Labath d65e6ff2f1 Revert "[lldb] Remove the global platform list"
It makes module dependencies loopier.

This reverts commits 49cffe3c7f and
ffb9429b6f.
2022-03-09 18:13:45 +01:00
Dave Lee 704001e90b [lldb] Add SBType::IsAggregateType
Add `IsAggregateType` to the SB API.

I'd like to use this from tests, and there are numerous other `Is<X>Type`
predicates on `SBType`.

Differential Revision: https://reviews.llvm.org/D121252
2022-03-09 08:33:08 -08:00
Pavel Labath 49cffe3c7f [lldb] Fix TestDebuggerAPI on windows (broken by D120810) 2022-03-09 16:54:24 +01:00
Pavel Labath ffb9429b6f [lldb] Remove the global platform list
This patch moves the platform creation and selection logic into the
per-debugger platform lists. I've tried to keep functional changes to a
minimum -- the main (only) observable difference in this change is that
APIs, which select a platform by name (e.g.,
Debugger::SetCurrentPlatform) will not automatically pick up a platform
associated with another debugger (or no debugger at all).

I've also added several tests for this functionality -- one of the
pleasant consequences of the debugger isolation is that it is now
possible to test the platform selection and creation logic.

This is a product of the discussion at
<https://discourse.llvm.org/t/multiple-platforms-with-the-same-name/59594>.

Differential Revision: https://reviews.llvm.org/D120810
2022-03-09 16:11:16 +01:00
Pavel Labath acf77bd2fd [lldb] Don't print *trailing* nuls in char arrays
Embedded nul characters are still printed, and they don't terminate the
string. See also D111634.

Differential Revision: https://reviews.llvm.org/D120803
2022-03-09 14:31:17 +01:00
Pavel Labath 4bcadd6686 [lldb/driver] Fix SIGTSTP handling
Our SIGTSTP handler was working, but that was mostly accidental.

The reason it worked is because lldb is multithreaded for most of its
lifetime and the OS is reasonably fast at responding to signals. So,
what happened was that the kill(SIGTSTP) which we sent from inside the
handler was delivered to another thread while the handler was still set
to SIG_DFL (which then correctly put the entire process to sleep).

Sometimes it happened that the other thread got the second signal after
the first thread had already restored the handler, in which case the
signal handler would run again, and it would again attempt to send the
SIGTSTP signal back to itself.

Normally it didn't take many iterations for the signal to be delivered
quickly enough. However, if you were unlucky (or were playing around
with pexpect) you could get SIGTSTP while lldb was single-threaded, and
in that case, lldb would go into an endless loop because the second
SIGTSTP could only be handled on the main thread, and only after the
handler for the first signal returned (and re-installed itself). In that
situation the handler would keep re-sending the signal to itself.

This patch fixes the issue by implementing the handler the way it
supposed to be done:
- before sending the second SIGTSTP, we unblock the signal (it gets
  automatically blocked upon entering the handler)
- we use raise to send the signal, which makes sure it gets delivered to
  the thread which is running the handler

This also means we don't need the SIGCONT handler, as our TSTP handler
resumes right after the entire process is continued, and we can do the
required work there.

I also include a test case for the SIGTSTP flow. It uses pexpect, but it
includes a couple of extra twists. Specifically, I needed to create an
extra process on top of lldb, which will run lldb in a separate process
group and simulate the role of the shell. This is needed because SIGTSTP
is not effective on a session leader (the signal gets delivered, but it
does not cause a stop) -- normally there isn't anyone to notice the
stop.

Differential Revision: https://reviews.llvm.org/D120320
2022-03-09 14:31:17 +01:00
Pavel Labath 8f6ee17f22 [lldb] Warn when we fail to find dwo/dwp files
This ensures that the user is aware that many commands will not work
correctly.

We print the warning only once (per module) to avoid spamming the user
with potentially thousands of error messages.

Differential Revision: https://reviews.llvm.org/D120892
2022-03-09 14:31:17 +01:00
Jonas Devlieghere 8a0fa4db39
[lldb] Add --exists flag to `settings set`
Add a --exists/-e flag to `settings set` that sets the setting if it
exists, but doesn't print an error otherwise. This is useful for example
when setting options in your ~/.lldbinit that might not exist in older
versions of lldb.

Differential revision: https://reviews.llvm.org/D121155
2022-03-08 22:59:26 -08:00
Muhammad Omair Javaid de0b4f4b86 [LLDB] Skip TestIOHandlerProcessSTDIO.py for Arm/AArch64 Linux
This patch disables TestIOHandlerProcessSTDIO.py for Arm/AArch64 Linux
to silence random test failures on buildbots. IO handler tests are known
to randomly fail on arm/aarch64 linux buildbots due to pexpect timeouts.
2022-03-08 14:15:41 +05:00
Jim Ingham 94ec0b6c5a Change "target.save-jit-objects" to "target.save-jit-objects-dir".
The old command wrote to CWD, which doesn't always work, and if it
didn't, there was no workaround (and it crashed on failure).  This
patch changed the setting to provide a directory to save the objects
to.

Differential Revision: https://reviews.llvm.org/D121036
2022-03-07 17:44:51 -08:00
Greg Clayton c41c574689 Fix buildbots after https://reviews.llvm.org/D120755.
This improves this test a lot because before when using the "attachCommands" to run the following commands:

(lldb) target create -d /path/to/a.out
(lldb) process launch

This was racy as it wasn't stopping the program at the entry point, and the process might run to completion before we can even debug it. With the recent changes to the "attachCommands" we were waiting for the process to stop, but the process might be exited already, and that _should_ have caused the attach to fail since there was no process to attach to. By adding "--stop-at-entry" to the process launch, we ensure this should be less racy and give us a valid process to attach to.
2022-03-07 11:46:56 -08:00
Jonas Devlieghere 080635ef27
[lldb] Add a setting to change the autosuggestion ANSI escape codes
I'm a big fan of the autosuggestion feature but my terminal/color scheme
doesn't display faint any differently than regular lldb output, which
makes the feature a little confusing. This patch add a setting to change
the autosuggestion ANSI escape codes.

For example, to display the autosuggestion in italic, you can add this
to your ~/.lldbinit

  settings set show-autosuggestion-ansi-prefix ${ansi.italic}
  setting set show-autosuggestion-ansi-suffix ${ansi.normal}

Differential revision: https://reviews.llvm.org/D121064
2022-03-07 08:54:37 -08:00
Med Ismail Bennani 999e75476e
[lldb/Test] Fix test_launch_scripted_process_stack_frames failure
This should fix the test_launch_scripted_process_stack_frames GreenDragon
test failure : https://green.lab.llvm.org/green/job/lldb-cmake/41901

Signed-off-by: Med Ismail Bennani <medismail.bennani@gmail.com>
2022-03-04 16:22:53 -08:00
Med Ismail Bennani 86e6030ee8 [lldb/Test] Disable test_scripted_process_and_scripted_thread on Windows
This disables TestScriptedProcess.test_scripted_process_and_scripted_thread
on Windows since the inferior binary a linked to a dylib that doesn't
build on Windows.

This should fix https://lab.llvm.org/buildbot/#/builders/83/builds/16100

Signed-off-by: Med Ismail Bennani <medismail.bennani@gmail.com>
2022-03-04 14:56:20 -08:00
Med Ismail Bennani 680ca7f21a [lldb/Plugins] Add ability to load modules to Scripted Processes
This patch introduces a new way to load modules programatically with
Scripted Processes. To do so, the scripted process blueprint holds a
list of dictionary describing the modules to load, which their path or
uuid, load address and eventually a slide offset.

LLDB will fetch that list after launching the ScriptedProcess, and
iterate over each entry to create the module that will be loaded in the
Scripted Process' target.

The patch also refactors the StackCoreScriptedProcess test to stop
inside the `libbaz` module and make sure it's loaded correctly and that
we can fetch some variables from it.

rdar://74520238

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

Signed-off-by: Med Ismail Bennani <medismail.bennani@gmail.com>
2022-03-04 13:35:28 -08:00
Med Ismail Bennani 2a29c3f72e [lldb/test] Re-enable TestEvents.py on Darwin and fix crashes
This patch re-enables TestEvents.py on Darwin and fixes some crashes
that were happening due to an undefined method.

I ran it 100 times locally with the following command and it passed
every the time:

```
for i in {1..100}; do print $i/100; ./bin/lldb-dotest -p TestEvents.py 2>&1 | rg PASSED; if [ "$?" -eq "1" ]; then break; fi; done
```

Let's see if it still fails non-deterministically on the bots and
eventually also re-enable it on linux.

rdar://37037235

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

Signed-off-by: Med Ismail Bennani <medismail.bennani@gmail.com>
2022-03-04 13:35:07 -08:00
Shafik Yaghmour 9bd72b5c25 [LLDB] Remove cases of using namespace std
We had using namespace std; sprinkled around several source files and tests.

Differential Revision: https://reviews.llvm.org/D120966
2022-03-04 12:50:25 -08:00