Commit Graph

6909 Commits

Author SHA1 Message Date
Jonas Devlieghere
01263c6c6f
[lldb] Rename lldb-vscode to lldb-dap (#69264)
Rename lldb-vscode to lldb-dap. This change is largely mechanical. The
following substitutions cover the majority of the changes in this
commit:

  s/VSCODE/DAP/
  s/VSCode/DAP/
  s/vscode/dap/
  s/g_vsc/g_dap/

Discourse RFC:
https://discourse.llvm.org/t/rfc-rename-lldb-vscode-to-lldb-dap/74075/
2023-10-19 09:48:54 -07:00
David Spickett
0dca56603b Revert "Detect against invalid variant index for LibStdC++ std::variant data formatters (#69253)"
This reverts commit 659a48f25a.

This caused another test to fail on Windows AArch64 and x86_64, and AArch64 Linux.
2023-10-18 10:25:41 +00:00
jeffreytan81
659a48f25a
Detect against invalid variant index for LibStdC++ std::variant data formatters (#69253)
https://github.com/llvm/llvm-project/pull/68012/files added new data
formatters for LibStdC++ std::variant.

However, this formatter can crash if std::variant's index field has
invalid value (exceeds the number of template arguments).
This can happen if the current IP stops at a place std::variant is not
initialized yet.

This patch fixes the crash by ensuring the index is a valid value.

---------

Co-authored-by: jeffreytan81 <jeffreytan@fb.com>
2023-10-17 17:26:05 -07:00
Vlad Serebrennikov
93229c7bfd
[lldb] Add SBType::FindDirectNestedType() function (#68705)
This patch adds a `SBType::FindDirectNestedType(name)` function which performs a non-recursive search in given class for a type with specified name. The intent is to perform a fast search in debug info, so that it can be used in formatters, and let them remain responsive.

This is driven by my work on formatters for Clang and LLVM types. In particular, by [`PointerIntPairInfo::MaskAndShiftConstants`](cde9f9df79/llvm/include/llvm/ADT/PointerIntPair.h (L174C16-L174C16)), which is required to extract pointer and integer from `PointerIntPair`.

Related Discourse thread: https://discourse.llvm.org/t/traversing-member-types-of-a-type/72452
2023-10-14 10:52:34 +04:00
Michael Buch
0dfcfb53d7
[lldb][DataFormatter] VectorType: fix format for arrays with size not a power-of-2 (#68907)
To get the number of children for a VectorType (i.e.,
a type declared with a `vector_size`/`ext_vector_type` attribute)
LLDB previously did following calculation:
1. Get byte-size of the vector container from Clang (`getTypeInfo`).
2. Get byte-size of the element type we want to interpret the array as.
   (e.g., sometimes we want to interpret an `unsigned char vec[16]`
   as a `float32[]`).
3. `numChildren = containerSize / reinterpretedElementSize`

However, for step 1, clang will return us the *aligned* container
byte-size.
So for a type such as `float __attribute__((ext_vector_type(3)))`
(which is an array of 3 4-byte floats), clang will round up the
byte-width of the array to `16`.
(see
[here](ab6a66dbec/clang/lib/AST/ASTContext.cpp (L1987-L1992)))

This means that for vectors where the size isn't a power-of-2, LLDB
will miscalculate the number of elements.

**Solution**

This patch changes step 1 such that we calculate the container size
as `numElementsInSource * byteSizeOfElement`.
2023-10-13 20:07:41 +01:00
Walter Erquinigo
ed0a14144b
[LLDB] Fix type formatting empty c-strings (#68924)
The type formatter code is effectively considering empty strings as read
errors, which is wrong. The fix is very simple. We should rely on the
error object and stop checking the size. I also added a test.
2023-10-13 14:14:23 -04:00
Pete Lawrence
8e2bd05c4e
[lldb] Fix po alias by printing fix-its to the console. (#68755)
The `po` alias now matches the behavior of the `expression` command when
the it can apply a Fix-It to an expression.
Modifications

- Add has `m_fixed_expression` to the `CommandObjectDWIMPrint` class a
`protected` member that stores the post Fix-It expression, just like the
`CommandObjectExpression` class.
- Converted messages to present tense.
- Add test cases that confirms a Fix-It for a C++ expression for both
`po` and `expressions`

rdar://115317419
2023-10-13 10:06:50 -07:00
Michael Buch
74c5e47404
[lldb][test] Temporarily disable TestQueueFromStdModule.py (#68970)
Started failing since D101206, but root-cause is unclear. It's
definitely not an issue with th libc++ patch itself however. So disable
the test until we know what's going on.
2023-10-13 16:26:51 +01:00
Tom Yang
cd0d478e7c quick fix for TestDumpDwo
PR#66035 introduced a test failure that causes windows build bots to
fail. These unit tests shouldn't be running on Windows.

Summary:

Test Plan:

Reviewers:

Subscribers:

Tasks:

Tags:
2023-10-12 16:28:56 -07:00
Tom Yang
64d78d8b3c
Add target modules dump separate-debug-info (#66035)
Add a new command
```
target modules dump separate-debug-info [-j] [<filename> [<filename> [...]]]
```
or
```
image dump separate-debug-info [-j] [<filename> [<filename> [...]]]
```
(since `image` is an alias for `target modules`).
This lists the separate debug info files and their current status
(loaded or not loaded) for the specified modules. This diff implements
this command for mach-O files with OSO and ELF files with dwo.
Example dwo:
```
(lldb) image dump separate-debug-info
Symbol file: /home/toyang/workspace/dwo-scratch/a.out
Type: "dwo"
Dwo ID             Err Dwo Path
------------------ --- -----------------------------------------
0x9a429da5abb6faae     /home/toyang/workspace/scratch-dwo/a-main.dwo
0xbcc129959e76ff33     /home/toyang/workspace/scratch-dwo/a-foo.dwo

(lldb) image dump separate-debug-info -j
[
  {
    "separate-debug-info-files": [
      {
        "comp_dir": "/home/toyang/workspace/dwo-scratch",
        "dwo_id": 11115620165179865774,
        "dwo_name": "a-main.dwo",
        "loaded": true,
        "resolved_dwo_path": "/home/toyang/workspace/dwo-scratch/a-main.dwo"
      },
      {
        "comp_dir": "/home/toyang/workspace/dwo-scratch",
        "dwo_id": 13601198072221073203,
        "dwo_name": "a-foo.dwo",
        "loaded": true,
        "resolved_dwo_path": "/home/toyang/workspace/dwo-scratch/a-foo.dwo"
      }
    ],
    "symfile": "/home/toyang/workspace/dwo-scratch/a.out",
    "type": "dwo"
  }
]
```
Example dwo with missing dwo:
```
(lldb) image dump separate-debug-info
Symbol file: /home/toyang/workspace/dwo-scratch/a.out
Type: "dwo"
Dwo ID             Err Dwo Path
------------------ --- -----------------------------------------
0x9a429da5abb6faae E   unable to locate .dwo debug file "/home/toyang/workspace/scratch-dwo/b.out-main.dwo" for skeleton DIE 0x0000000000000014
0xbcc129959e76ff33 E   unable to locate .dwo debug file "/home/toyang/workspace/scratch-dwo/b.out-foo.dwo" for skeleton DIE 0x000000000000003c

(lldb) image dump separate-debug-info -j
[
  {
    "separate-debug-info-files": [
      {
        "comp_dir": "/home/toyang/workspace/dwo-scratch",
        "dwo_id": 11115620165179865774,
        "dwo_name": "a-main.dwo",
        "error": "unable to locate .dwo debug file \"/home/toyang/workspace/dwo-scratch/a-main.dwo\" for skeleton DIE 0x0000000000000014",
        "loaded": false
      },
      {
        "comp_dir": "/home/toyang/workspace/dwo-scratch",
        "dwo_id": 13601198072221073203,
        "dwo_name": "a-foo.dwo",
        "error": "unable to locate .dwo debug file \"/home/toyang/workspace/dwo-scratch/a-foo.dwo\" for skeleton DIE 0x000000000000003c",
        "loaded": false
      }
    ],
    "symfile": "/home/toyang/workspace/dwo-scratch/a.out",
    "type": "dwo"
  }
]
```
Example output with dwp:
```
(lldb) image dump separate-debug-info
Symbol file: /home/toyang/workspace/dwo-scratch/a.out
Type: "dwo"
Dwo ID             Err Dwo Path
------------------ --- -----------------------------------------
0x9a429da5abb6faae     /home/toyang/workspace/dwo-scratch/a.out.dwp(a-main.dwo)
0xbcc129959e76ff33     /home/toyang/workspace/dwo-scratch/a.out.dwp(a-foo.dwo)
(lldb) image dump separate-debug-info -j
[
  {
    "separate-debug-info-files": [
      {
        "comp_dir": "/home/toyang/workspace/dwo-scratch",
        "dwo_id": 11115620165179865774,
        "dwo_name": "a-main.dwo",
        "loaded": true,
        "resolved_dwo_path": "/home/toyang/workspace/dwo-scratch/a.out.dwp"
      },
      {
        "comp_dir": "/home/toyang/workspace/dwo-scratch",
        "dwo_id": 13601198072221073203,
        "dwo_name": "a-foo.dwo",
        "loaded": true,
        "resolved_dwo_path": "/home/toyang/workspace/dwo-scratch/a.out.dwp"
      }
    ],
    "symfile": "/home/toyang/workspace/dwo-scratch/a.out",
    "type": "dwo"
  }
]
```
Example oso on my Mac:
```
(lldb) image dump separate-debug-info
Symbol file: /Users/toyang/workspace/scratch/a.out
Type: "oso"
Mod Time           Err Oso Path
------------------ --- ---------------------
0x0000000064e64868     /Users/toyang/workspace/scratch/foo.a(foo.o)
0x0000000064e64868     /Users/toyang/workspace/scratch/foo.a(main.o)

(lldb) image dump separate-debug-info -j
[
  {
    "separate-debug-info-files": [
      {
        "loaded": true,
        "oso_mod_time": 1692813416,
        "oso_path": "/Users/toyang/workspace/scratch/foo.a(foo.o)",
        "so_file": "/Users/toyang/workspace/scratch/foo.cpp"
      },
      {
        "loaded": true,
        "oso_mod_time": 1692813416,
        "oso_path": "/Users/toyang/workspace/scratch/foo.a(main.o)",
        "so_file": "/Users/toyang/workspace/scratch/main.cpp"
      }
    ],
    "symfile": "/Users/toyang/workspace/scratch/a.out",
    "type": "oso"
  }
]
```

Test Plan:
Tested on Mac OS and Linux.
```
lldb-dotest -p TestDumpDwo
lldb-dotest -p TestDumpOso
```

---------

Co-authored-by: Tom Yang <toyang@fb.com>
2023-10-12 11:21:53 -07:00
Adrian Prantl
2e59b7550e Revert "[lldb] Fix po alias by printing fix-its to the console. (#68452)"
This reverts commit 606f89ab7d while investigating bot failures.
2023-10-10 14:56:00 -07:00
Pete Lawrence
606f89ab7d
[lldb] Fix po alias by printing fix-its to the console. (#68452)
The `po` alias now matches the behavior of the `expression` command when
the it can apply a Fix-It to an expression.
Modifications

- Add has `m_fixed_expression` to the `CommandObjectDWIMPrint` class a
`protected` member that stores the post Fix-It expression, just like the
`CommandObjectExpression` class.
- Converted messages to present tense.
- Add test cases that confirms a Fix-It for a C++ expression for both
`po` and `expressions`

rdar://115317419

Co-authored-by: Pete Lawrence <plawrence@apple.com>
2023-10-10 13:59:58 -07:00
José Lira Junior
ac0dda8942
[lldb] add stop-at-user-entry option to process launch (#67019)
## Description
This pull request adds a new `stop-at-user-entry` option to LLDB
`process launch` command, allowing users to launch a process and pause
execution at the entry point of the program (for C-based languages,
`main` function).

## Motivation
This option provides a convenient way to begin debugging a program by
launching it and breaking at the desired entry point.

## Changes Made
- Added `stop-at-user-entry` option to `Options.td` and the
corresponding case in `CommandOptionsProcessLaunch.cpp` (short option is
'm')
- Implemented `GetUserEntryPointName` method in the Language plugins
available at the moment.
- Declared the `CreateBreakpointAtUserEntry` method in the Target API.
- Create Shell test for the command
`command-process-launch-user-entry.test`.

## Usage
`process launch --stop-at-user-entry` or `process launch -m` launches
the process and pauses execution at the entry point of the program.
2023-10-09 16:43:59 -07:00
Jonas Devlieghere
8f378ff7a0
[lldb] Expose SBPlatform::GetAllProcesses to the SB API (#68378)
Add the ability to list all processes through the SB API.

rdar://116188959
2023-10-06 10:43:31 -07:00
Michael Buch
d579a1a24a
[lldb[test] TestCppUnionStaticMembers.py: XFAIL assertions on windows (#68408)
Split out the assertions that fail on Windows in preparation to
XFAILing them.

Drive-by change:
* Add a missing `self.build()` call in `test_union_in_anon_namespace`
* Fix formatting
* Add expectedFailureWindows decorator
2023-10-06 16:05:40 +01:00
Michael Buch
f74aaca632
[lldb][DWARFASTParserClang] Check DW_AT_declaration to determine static data members (#68300)
**Background**

Prior to DWARFv4, there was no clear normative text on how to handle
static data members. Non-normative text suggested that compilers should
use `DW_AT_external` to mark static data members of structrues/unions.
Clang does this consistently. However, GCC doesn't, e.g., when the
structure/union is in an anonymous namespace (which is C++ standard
conformant). Additionally, GCC never emits `DW_AT_data_member_location`s
for union members (regardless of storage linkage and storage duration).

Since DWARFv5 (issue 161118.1), static data members get emitted as
`DW_TAG_variable`.

LLDB used to differentiate between static and non-static members by
checking the `DW_AT_external` flag and the absence of
`DW_AT_data_member_location`. With
[D18008](https://reviews.llvm.org/D18008) LLDB started to pretend that
union members always have a `0` `DW_AT_data_member_location` by default
(because GCC never emits these locations).

In [D124409](https://reviews.llvm.org/D124409) LLDB stopped checking the
`DW_AT_external` flag to account for the case where GCC doesn't emit the
flag for types in anonymous namespaces; instead we only check for
presence of `DW_AT_data_member_location`s.

The combination of these changes then meant that LLDB would never
correctly detect that a union has static data members.

**Solution**

Instead of unconditionally initializing the `member_byte_offset` to `0`
specifically for union members, this patch proposes to check for both
the absence of `DW_AT_data_member_location` and `DW_AT_declaration`,
which consistently gets emitted for static data members on GCC and
Clang.

We initialize the `member_byte_offset` to `0` anyway if we determine it
wasn't a static. So removing the special case for unions makes this code
simpler to reason about.

Long-term, we should just use DWARFv5's new representation for static
data members.

Fixes #68135
2023-10-06 09:07:20 +01:00
David Spickett
ceec9a7874 [lldb][test] Skip platform attach test on Windows
This can pass but every so often times out:
https://lab.llvm.org/buildbot/#/builders/219/builds/6092
2023-10-04 12:46:35 +00:00
antoine moynault
75f295c245
[lldb][test] Remove expected failure marker for TestPlatformAttach on windows (#68193)
Looks like this test passes since #68050.
2023-10-04 12:13:31 +02:00
jeffreytan81
40c1f5b2fb
Fix std::variant test failure on certain buildbot (#68139)
https://github.com/llvm/llvm-project/pull/68012 works on my CentOS Linux
and Macbook but seems to fail for certain build bots. The error log
complains "No Value" check failure for `std::variant` but not very
actionable without a reproduce.

To unblock the build bots, I am commenting out the "No Value" checks.

Co-authored-by: jeffreytan81 <jeffreytan@fb.com>
2023-10-03 15:37:41 -07:00
Jonas Devlieghere
2da99a1119
[lldb] Expose Platform::Attach through the SB API (#68050)
Expose Platform::Attach through the SB API.

rdar://116188959
2023-10-03 10:34:00 -07:00
jeffreytan81
1ec4330f7e
Implement data formatters for LibStdC++ std::variant (#68012)
This patch implements the data formatters for LibStdC++ `std::variant`.

---------

Co-authored-by: jeffreytan81 <jeffreytan@fb.com>
2023-10-02 17:46:41 -07:00
Muhammad Omair Javaid
ec8df0c7e3 [LLDB] Skip TestTlsGlobals.py for Linux Arm/AArch64
Recently added TLS linux support fails on Arm/AArch64. I am skiping test
for now and will investigate the issue later.
2023-09-28 16:16:41 +05:00
Fangrui Song
34ee53c9e3 [lldb][test] Fix TestCallBuiltinFunction.py
A constant __builtin_abs(-14) cannot be evaluated without a running target
as Clang now emits llvm.abs.*
2023-09-27 22:37:24 -07:00
Jim Ingham
0f339e6567 Fix a bug in handling ^C at the "y/n/a" completion prompt.
We just forget to check for interrupt while waiting for the answer to the prompt. But if we are in the interrupt state then the lower
layers of the EditLine code just eat all characters so we never get out of the query prompt. You're pretty much stuck and have to kill lldb.

The solution is to check for the interrupt. The patch is a little bigger because where I needed to check the Interrupt state I only
had the ::EditLine object, but the editor state is held in lldb's EditLine wrapper, so I had to do a little work to get my hands on it.
2023-09-27 17:20:48 -07:00
jeffreytan81
e8ea47602b
[lldb] Implement thread local storage for linux (#67470)
This patch implements the thread local storage support for linux
(https://github.com/llvm/llvm-project/issues/28766).

TLS feature is originally only implemented for Mac. With my previous
patch to enable `fs_base` register for Linux
(https://reviews.llvm.org/D155256), now it is feasible to implement this
feature for Linux.

The major changes are:
* Track the main module's link address during launch
* Fetch thread pointer from `fs_base` register
* Create register alias for thread pointer
* Read pthread metadata from target memory instead of process so that it
works for coredump

With the patch the failing test is passing now. Note: I am only enabling
this test for Mac and Linux because I do not have machine to test for
FreeBSD/NetBSD.

---------

Co-authored-by: jeffreytan81 <jeffreytan@fb.com>
2023-09-27 09:14:40 -07:00
Jason Molenda
5ba239fe2a Remove expected-fail for Linux on TestStepOverWatchpoint.py
With my previous fix, this test now passes on
Linux.
2023-09-22 18:22:02 -07:00
Jason Molenda
4a43ee08e7 Re-enable StepOverWatchpoint test, make it more focused
This is my second recent change to TestStepOverWatchpoint.py,
the first was to change the two global variables it is watching
from 'char' to 'long' so they're more likely to be on separate
words/doublewords of memory that can be watched indepdently.

I believe this removes the need for the MIPS and S390X skips.

The test was testing a combination of read and write watchpoints,
stepping over a function that hits them, and then instruction stepping
over a source line which hits them.  But previously it was
always starting with the read watchpoint in both of them, it
didn't test the instruction-stepping for the read watchpoint.

I now have to tests in TestStepOverWatchpoint.py, one which
runs to the read-watchpoint function, sets that watchpoint,
steps over another function which reads from that global, then
instruction steps over a source line that reads from that global.

The second test runs to the write-watchpoint function, sets that
watchpoint.  Steps over another function which writes to that
global, then instruction steps over a source line that writes to
that global.

These are both xfailed on Darwin systems because watchpoints and
hardware breakpoints are currently disabled by the kernel when
instruction stepping.
2023-09-22 18:11:33 -07:00
David Spickett
bb01fd57bc
[lldb] Require paused process and frame for "register info" command (#67124)
Prior to this the command would simply crash when run on a running
process.

Of the three register commands, "info" was the only one missing these
requirements. On some level it makes sense because you're not going to
read a value or modify anything, but practically I think lldb assumes
any time you're going to access register related stuff, the process
should be paused.

I noticed this debugging with a remote gdb stub, so I've recreated that
scenario using attach in a new test case.
2023-09-22 15:55:27 +01:00
Jason Molenda
35e3939cb0 watch set expression's default type was wrong with new modify type
`watch set expression` was passing the OptionGroupWatchpoint enum
in to Target where the LLDB_WATCH_TYPE_* bitfield was expected.
Modify matched READ|WRITE and resulted in a test failure in
TestWatchTaggedAddress.py.  David temporarily changed the test to
expect this incorrect output; this fixes the bug and updates the
test case to test it for correctness again.
2023-09-21 14:50:34 -07:00
Jim Ingham
b9e08cbf30 I can't make this test fail locally, but it is failing on the macOS
bots as well.  I'll have to figure out a different way to test this.
2023-09-21 13:30:45 -07:00
David Spickett
7e744460e7 Reland "[lldb][AArch64] Linux corefile support for SME"
This reverts commit 3fa5035823.

m_sve_state was not initialised which (I'm guessing) meant that
it could potentially be a value that matched a real SVE state.
Then we'd be acting as if we're streaming mode, for example,
without ever having the data required to back that up.

By sheer luck this only turn up on x86, AArch64 and ARM were fine.
It is UB regardless.
2023-09-21 14:54:51 +01:00
David Spickett
3fa5035823 Revert "[lldb][AArch64] Linux corefile support for SME"
This reverts commit 43812c8c87.

Due to failures on x86_64: https://lab.llvm.org/buildbot/#/builders/68/builds/60416
2023-09-21 12:53:18 +00:00
David Spickett
43812c8c87 [lldb][AArch64] Linux corefile support for SME
This adds the ability to read streaming SVE registers,
ZA, SVCR and SVG from core files.

Streaming SVE is in a new note NT_ARM_SSVE but otherwise
has the same format as SVE. So I've done the same as I
did for live processes and reused the existing SVE state
with an extra state for the mode variable.

ZA is in a note NT_ARM_ZA and again the handling matches
live processes. Except that it gets setup only once. A
disabled ZA reads as 0s as usual.

SVCR and SVG are pseudo registers, generated from the notes.

An important detail is that the notes represent what
you would have got if you read from ptrace at the time of
the crash.

This means that for a corefile in non-streaming mode,
there is still an NT_ARM_SSVE note and we check the header
flags to tell if it is active. We cannot just say if you
have the note you're in streaming mode.

The kernel does not provide register values for the inactive
mode and even if it did, they would be undefined, so if we find
streaming state, we ignore the non-streaming state.

Same for ZA, a disabled ZA still has the header in the note.

The tests do not cover all combinations but enough different
vector lengths, modes and ZA states to be confident.

Reviewed By: omjavaid

Differential Revision: https://reviews.llvm.org/D158500
2023-09-21 13:24:34 +01:00
David Spickett
75e8620778 Reland "[lldb] Add 'modify' type watchpoints, make it default (#66308)"
This reverts commit a7b78cac9a.

With updates to the tests.

TestWatchTaggedAddress.py: Updated the expected watchpoint types,
though I'm not sure there should be a differnt default for the two
ways of setting them, that needs to be confirmed.

TestStepOverWatchpoint.py: Skipped this everywhere because I think
what used to happen is you couldn't put 2 watchpoints on the same
address (after alignment). I guess that this is now allowed because
modify watchpoints aren't accounted for, but likely should be.
Needs investigating.
2023-09-21 10:35:15 +00:00
David Spickett
a7b78cac9a Revert "[lldb] Add 'modify' type watchpoints, make it default (#66308)"
This reverts commit 933ad5c897.

This caused 1 test failure and an unexpected pass on AArch64 Linux:
https://lab.llvm.org/buildbot/#/builders/96/builds/45765

Wasn't reported because the bot was already red at the time.
2023-09-21 09:30:07 +00:00
Jason Molenda
1a784444b3 Temoprarily stop running this test on Intel macs
The test is expecting watchpoint hits that are valid on aarch64
systems but not on Intel.  I need to update this test to match the
actual behavior on Intel macs, and don't want the CI bots to stay
broken while I get that figured out.
2023-09-20 21:49:15 -07:00
Jim Ingham
de94c109b6 The test: test_run_then_attach_wait_interrupt was flakey on Linux & Windows.
I changed the test so I could tell whether the problem was sometimes the
interrupt was failing, or maybe the was just racy.  It failed again, but
in the new failures we waited 20 seconds for the attach-wait to get interrupted
and that never happened.

So there seems to be some real raciness in the feature of interrupting an
attach-wait, but only on Linux & Windows.  The bug fix that this test was
testing was for a bug that would cause us to never try to interrupt in this
case.  So it looks like this test is uncovering some flakiness in the underlying
interrupt support when in this state.  That's a separate bug that needs fixing.

For now, I disabled the test except on macOS where it seems to run reliably.
2023-09-20 17:38:27 -07:00
Daniel Thornburgh
7f3467412e Revert "Remove some raciness from the TestProcessAttach.test_run_then_attach_wait_interrupt"
This reverts commit df93c4ffdf.
This change is breaking the LLDB CI builders, e.g.
https://lab.llvm.org/buildbot/#/builders/68/builds/60350
2023-09-20 14:30:24 -07:00
Jason Molenda
933ad5c897 [lldb] Add 'modify' type watchpoints, make it default (#66308)
Watchpoints in lldb can be either 'read', 'write', or 'read/write'. This
is exposing the actual behavior of hardware watchpoints. gdb has a
different behavior: a "write" type watchpoint only stops when the
watched memory region *changes*.

A user is using a watchpoint for one of three reasons:

1. Want to find what is changing/corrupting this memory.
2. Want to find what is writing to this memory.
3. Want to find what is reading from this memory.

I believe (1) is the most common use case for watchpoints, and it
currently can't be done in lldb -- the user needs to continue every time
the same value is written to the watched-memory manually. I think gdb's
behavior is the correct one. There are some use cases where a developer
wants to find every function that writes/reads to/from a memory region,
regardless of value, I want to still allow that functionality.

This is also a bit of groundwork for my large watchpoint support
proposal
https://discourse.llvm.org/t/rfc-large-watchpoint-support-in-lldb/72116
where I will be adding support for AArch64 MASK watchpoints which watch
power-of-2 memory regions. A user might ask to watch 24 bytes, and a
MASK watchpoint stub can do this with a 32-byte MASK watchpoint if it is
properly aligned. And we need to ignore writes to the final 8 bytes of
that watched region, and not show those hits to the user.

This patch adds a new 'modify' watchpoint type and it is the default.

Re-landing this patch after addressing testsuite failures found in CI on
Linux, Intel machines, and windows.

rdar://108234227
2023-09-20 13:42:16 -07:00
Jim Ingham
df93c4ffdf Remove some raciness from the TestProcessAttach.test_run_then_attach_wait_interrupt
command.

We were reading the command output right after sending the interrupt, but
sometimes that wasn't long enough for the command result text to have been emitted.
I added a poll for the state change to eStateExited, and then added a bit more sleep
to give the command a chance to complete.
2023-09-20 13:08:40 -07:00
Walter Erquinigo
96b1784ac8
[lldb-vscode] Use auto summaries whenever variables don't have a summary (#66551)
Auto summaries were only being used when non-pointer/reference variables
didn't have values nor summaries. Greg pointed out that it should be
better to simply use auto summaries when the variable doesn't have a
summary of its own, regardless of other conditions.

This led to code simplification and correct visualization of auto
summaries for pointer/reference types, as seen in this screenshot.

<img width="310" alt="Screenshot 2023-09-19 at 7 04 55 PM"
src="https://github.com/llvm/llvm-project/assets/1613874/d356d579-13f2-487b-ae3a-f3443dce778f">
2023-09-20 10:23:41 -04:00
David Spickett
3d422c4682 [lldb][API] Remove debug print in TestRunLocker.py 2023-09-20 10:01:32 +00:00
David Spickett
d7fab66695 [lldb][AArch64] Add SME's streaming vector control register
Software can tell if it is in streaming SVE mode by checking
the Streaming Vector Control Register (SVCR).

"E3.1.9 SVCR, Streaming Vector Control Register" in
"Arm® Architecture Reference Manual Supplement, The Scalable Matrix
Extension (SME), for Armv9-A"

https://developer.arm.com/documentation/ddi0616/latest/

This is especially useful for debug because the names of the
SVE registers are the same betweeen non-streaming and streaming mode.

The Linux Kernel chose to not put this register behind ptrace,
and it can be read from EL0. However, this would mean running code
in process to read it. That can be done but we already know all
the information just from ptrace.

So this is a pseudo register that matches the architectural
content. The name is just "svcr", which aligns with GDB's proposed naming,
and it's added to the existing SME register set.

The SVCR register contains two bits:
0 : Whether streaming SVE mode is enabled (SM)
1 : Whether the array storage is enabled (ZA)

Array storage can be active when streaming mode is not, so this register
can have any permutation of those bits.

This register is currently read only. We can emulate the result of
writing to it, using ptrace. However at this point the utility of that
is not obvious.

Existing tests have been updated to check for appropriate SVCR values
at various points.

Given that this register is a read only pseudo, there is no need
to save and restore it around expressions.

Reviewed By: omjavaid

Differential Revision: https://reviews.llvm.org/D154927
2023-09-20 10:20:45 +01:00
David Spickett
1446e3cf76 Revert "Fix a bug with cancelling "attach -w" after you have run a process previously (#65822)"
This reverts commit 7265f792dc.

The new test case is flaky on Linux AArch64 (https://lab.llvm.org/buildbot/#/builders/96)
and more flaky on Windows on Arm (https://lab.llvm.org/buildbot/#/builders/219/builds/5735).
2023-09-20 08:19:53 +00:00
Jim Ingham
74338bfe0c A test was changing directory and then incorrectly restoring the directory
to the "testdir" which is the build directory for that test, not the
original source directory.  That caused subsequent tests to fail.
2023-09-19 16:46:08 -07:00
jimingham
7265f792dc
Fix a bug with cancelling "attach -w" after you have run a process previously (#65822)
The problem is that the when the "attach" command is initiated, the
ExecutionContext for the command has a process - it's the exited one
from the previour run. But the `attach wait` creates a new process for
the attach, and then errors out instead of interrupting when it finds
that its process and the one in the command's ExecutionContext don't
match.

This change checks that if we're returning a target from
GetExecutionContext, we fill the context with it's current process, not
some historical one.
2023-09-19 11:25:53 -07:00
David Spickett
e96adfd0db [lldb][AArch64] Add testing for SME's ZA and SVG registers
An SME enabled program has the following extra state:
* Streaming mode or non-streaming mode.
* ZA enabled or disabled.
* The active vector length.

Covering the transition between all possible states and all other
possible states is not viable, therefore the testing added here is a cross
section of that, all of which found real bugs in LLDB and the Linux
Kernel during development.

Many of those transitions will not be possible via LLDB
(e.g. disabling ZA) and many more are possible but unlikely to be
used in normal use.

Added testing:
* TestSVEThreadedDynamic now checks for correct SVG values.
* New test TestZAThreadedDynamic creates 3 threads with different ZA sizes
  and states and switches between them verifying the register value
  (derived from the existing threaded SVE test).
* New test TestZARegisterSaveRestore starts in a given SME state, runs a
  set of expressions in various orders, then checks that the original
  state has been restored.
* TestArm64DynamicRegsets has ZA and SVG checks added, including writing
  to ZA to enable it.

Running these tests will as usual require QEMU as there is no
real SME hardware available at this time, and a very recent
kernel.

Reviewed By: omjavaid

Differential Revision: https://reviews.llvm.org/D159505
2023-09-19 12:18:23 +00:00
David Spickett
91f46ece9e [lldb][AArch64] Document how to control the SVE/SSVE tests
A lot of these use defines that I made up for this purpose,
which is not obvious at first glance. Document that at the top
of each file.
2023-09-19 08:51:37 +00:00
David Spickett
956860168b [lldb] Correct expected output for variable on 32 bit platforms
710276a250 added settings to control
leading zeros but the initial test case assumed a 64 bit target.
2023-09-19 08:28:34 +00:00
Jason Molenda
44532a9dd4 Revert "[lldb] Add 'modify' type watchpoints, make it default (#66308)"
TestStepOverWatchpoint.py and TestUnalignedWatchpoint.py are failing
on the ubuntu and debian bots
https://lab.llvm.org/buildbot/#/builders/68/builds/60204
https://lab.llvm.org/buildbot/#/builders/96/builds/45623

and the newly added test TestModifyWatchpoint.py does not
work on windows bot
https://lab.llvm.org/buildbot/#/builders/219/builds/5708

I will debug tomorrow morning and reland.

This reverts commit 3692267ca8.
2023-09-18 22:50:39 -07:00