#
208a08c3 |
| 01-Jul-2024 |
David Spickett <david.spickett@linaro.org> |
Reland "[lldb] Parse and display register field enums" (#97258)" (#97270)
This reverts commit d9e659c538516036e40330b6a98160cbda4ff100.
I could not reproduce the Mac OS ASAN failure locally but I
Reland "[lldb] Parse and display register field enums" (#97258)" (#97270)
This reverts commit d9e659c538516036e40330b6a98160cbda4ff100.
I could not reproduce the Mac OS ASAN failure locally but I narrowed it
down to the test `test_many_fields_same_enum`. This test shares an enum
between x0, which is 64 bit, and cpsr, which is 32 bit.
My theory is that when it does `register read x0`, an enum type is
created where the undlerying enumerators are 64 bit, matching the
register size.
Then it does `register read cpsr` which used the cached enum type, but
this register is 32 bit. This caused lldb to try to read an 8 byte value
out of a 4 byte allocation:
READ of size 8 at 0x60200014b874 thread T0
<...>
=>0x60200014b800: fa fa fd fa fa fa fd fa fa fa fd fa fa fa[04]fa
To fix this I've added the register's size in bytes to the constructed
enum type's name. This means that x0 uses:
__lldb_register_fields_enum_some_enum_8
And cpsr uses:
__lldb_register_fields_enum_some_enum_4
If any other registers use this enum and are read, they will use the
cached type as long as their size matches, otherwise we make a new type.
show more ...
|
#
d9e659c5 |
| 01-Jul-2024 |
David Spickett <david.spickett@linaro.org> |
Revert "[lldb] Parse and display register field enums" (#97258)
Reverts llvm/llvm-project#95768 due to a test failure on macOS with
ASAN:
https://green.lab.llvm.org/job/llvm.org/view/LLDB/job/ll
Revert "[lldb] Parse and display register field enums" (#97258)
Reverts llvm/llvm-project#95768 due to a test failure on macOS with
ASAN:
https://green.lab.llvm.org/job/llvm.org/view/LLDB/job/lldb-cmake-sanitized/425/console
show more ...
|
#
ba60d8a1 |
| 27-Jun-2024 |
David Spickett <david.spickett@linaro.org> |
[lldb] Parse and display register field enums (#95768)
This teaches lldb to parse the enum XML elements sent by lldb-server,
and make use of the information in `register read` and `register info`.
[lldb] Parse and display register field enums (#95768)
This teaches lldb to parse the enum XML elements sent by lldb-server,
and make use of the information in `register read` and `register info`.
The format is described in
https://sourceware.org/gdb/current/onlinedocs/gdb.html/Enum-Target-Types.html.
The target XML parser will drop any invalid enum or evalue. If we find
multiple evalue for the same value, we will use the last one we find.
The order of evalues from the XML is preserved as there may be good
reason they are not in numerical order.
show more ...
|
Revision tags: llvmorg-18.1.8, llvmorg-18.1.7, llvmorg-18.1.6, llvmorg-18.1.5, llvmorg-18.1.4, llvmorg-18.1.3, llvmorg-18.1.2, llvmorg-18.1.1, llvmorg-18.1.0, llvmorg-18.1.0-rc4, llvmorg-18.1.0-rc3, llvmorg-18.1.0-rc2, llvmorg-18.1.0-rc1, llvmorg-19-init, llvmorg-17.0.6, llvmorg-17.0.5, llvmorg-17.0.4 |
|
#
2325b3cf |
| 24-Oct-2023 |
David Spickett <david.spickett@linaro.org> |
[lldb] Add test for reserved XML chars in register field names
Replacements like & were already handled by libXML but we have no tests to confirm that, this adds some.
|
Revision tags: llvmorg-17.0.3, llvmorg-17.0.2, llvmorg-17.0.1, llvmorg-17.0.0, llvmorg-17.0.0-rc4, llvmorg-17.0.0-rc3, llvmorg-17.0.0-rc2 |
|
#
aa278487 |
| 07-Aug-2023 |
Eymen Ünay <eymenunay@outlook.com> |
[lldb] Fix typo in comments and in test
Reviewed By: DavidSpickett
Differential Revision: https://reviews.llvm.org/D157214
|
#
ecbe78c1 |
| 04-Aug-2023 |
Jonas Devlieghere <jonas@devlieghere.com> |
[lldb] Fix Python test formatting (NFC)
All Python files in the LLVM repository were reformatted with Black [1]. Files inside the LLDB subproject were reformatted in 2238dcc39358. This patch updates
[lldb] Fix Python test formatting (NFC)
All Python files in the LLVM repository were reformatted with Black [1]. Files inside the LLDB subproject were reformatted in 2238dcc39358. This patch updates a handful of tests that were added or modified since then and weren't formatted with Black.
[1] https://discourse.llvm.org/t/rfc-document-and-standardize-python-code-style/68257
show more ...
|
Revision tags: llvmorg-17.0.0-rc1, llvmorg-18-init, llvmorg-16.0.6 |
|
#
bcfe5a52 |
| 05-Jun-2023 |
David Spickett <david.spickett@linaro.org> |
[lldb] Add register field tables to the "register info" command
This teaches DumpRegisterInfo to generate a table from the register flags type. It just calls a method on RegisterFlags.
As such, the
[lldb] Add register field tables to the "register info" command
This teaches DumpRegisterInfo to generate a table from the register flags type. It just calls a method on RegisterFlags.
As such, the extra tests are minimal and only show that the intergration works. Exhaustive formatting tests are done with RegisterFlags itself.
Example: ``` (lldb) register info cpsr Name: cpsr Size: 4 bytes (32 bits) In sets: general (index 0)
| 31 | 30 | 29 | 28 | 27-26 | 25 | 24 | 23 | 22 | 21 | 20 | 19-13 | 12 | 11-10 | 9 | 8 | 7 | 6 | 5 | 4 | 3-2 | 1 | 0 | |----|----|----|----|-------|-----|-----|-----|-----|----|----|-------|------|-------|---|---|---|---|---|-----|-----|---|----| | N | Z | C | V | | TCO | DIT | UAO | PAN | SS | IL | | SSBS | | D | A | I | F | | nRW | EL | | SP | ```
LLDB limits the max terminal width to 80 chars by default. So to get that full width output you will need to change the "term-width" setting to something higher.
Reviewed By: jasonmolenda
Differential Revision: https://reviews.llvm.org/D152918
show more ...
|
Revision tags: llvmorg-16.0.5 |
|
#
2238dcc3 |
| 25-May-2023 |
Jonas Devlieghere <jonas@devlieghere.com> |
[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 problem
[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
show more ...
|
Revision tags: llvmorg-16.0.4, llvmorg-16.0.3 |
|
#
c9083bea |
| 20-Apr-2023 |
David Spickett <david.spickett@linaro.org> |
[LLDB] Don't print register fields when asked for a specific format
Previously if a register had fields we would always print them after the value if the register was asked for by name. ``` (lldb) r
[LLDB] Don't print register fields when asked for a specific format
Previously if a register had fields we would always print them after the value if the register was asked for by name. ``` (lldb) register read MDCR_EL3 MDCR_EL3 = 0x00000000 = { ETBAD = 0 <...> RLTE = 0 } ``` This can be quite annoying if there are a whole lot of fields but you want to see the register in a specific format. ``` (lldb) register read MDCR_EL3 -f i MDCR_EL3 = 0x00000000 unknown udf #0x0 = { ETBAD = 0 <...lots of fields...> ``` Since it pushes the interesting bit far up the terminal. To solve this, don't print fields if the user passes --format. If they're doing that then I think it's reasonable to assume they know what they want and only want to see that output.
This also gives users a way to silence fields, but not change the format. By doing `register read foo -f x`. In case they are not useful or perhaps they are trying to work around a crash.
I have customised the help text for --format for register read to explain this: ``` -f <format> ( --format <format> ) Specify a format to be used for display. If this is set, register fields will not be dispayed. ```
Reviewed By: jasonmolenda
Differential Revision: https://reviews.llvm.org/D148790
show more ...
|
#
dbc34e2b |
| 19-Apr-2023 |
David Spickett <david.spickett@linaro.org> |
[LLDB] Discard register flags where the size doesn't match the register
In the particular case I was looking at I autogenerated a 128 bit set of flags that is only 64 bit. This doesn't crash lldb bu
[LLDB] Discard register flags where the size doesn't match the register
In the particular case I was looking at I autogenerated a 128 bit set of flags that is only 64 bit. This doesn't crash lldb but it was certainly not expected.
I suspect that we would have crashed if the top 64 bits weren't marked as unused (or at least invoked some very undefined behaviour).
When this happens, log the details and ignore the flags. Like this: ``` Size of register flags TTBR0_EL1_flags (16 bytes) for register TTBR0_EL1 does not match the register size (8 bytes). Ignoring this set of flags. ```
Turns out a few of the tests relied on this bug so I have updated them and added a specific test for this case.
Reviewed By: jasonmolenda
Differential Revision: https://reviews.llvm.org/D148715
show more ...
|
Revision tags: llvmorg-16.0.2, llvmorg-16.0.1, llvmorg-16.0.0, llvmorg-16.0.0-rc4, llvmorg-16.0.0-rc3, llvmorg-16.0.0-rc2, llvmorg-16.0.0-rc1, llvmorg-17-init |
|
#
e07a421d |
| 13-Jan-2023 |
David Spickett <david.spickett@linaro.org> |
[lldb] Show register fields using bitfield struct types
This change uses the information from target.xml sent by the GDB stub to produce C types that we can use to print register fields.
lldb-serve
[lldb] Show register fields using bitfield struct types
This change uses the information from target.xml sent by the GDB stub to produce C types that we can use to print register fields.
lldb-server *does not* produce this information yet. This will only work with GDB stubs that do. gdbserver or qemu are 2 I know of. Testing is added that uses a mocked lldb-server. ``` (lldb) register read cpsr x0 fpcr fpsr x1 cpsr = 0x60001000 = (N = 0, Z = 1, C = 1, V = 0, TCO = 0, DIT = 0, UAO = 0, PAN = 0, SS = 0, IL = 0, SSBS = 1, BTYPE = 0, D = 0, A = 0, I = 0, F = 0, nRW = 0, EL = 0, SP = 0) ```
Only "register read" will display fields, and only when we are not printing a register block.
For example, cpsr is a 32 bit register. Using the target's scratch type system we construct a type: ``` struct __attribute__((__packed__)) cpsr { uint32_t N : 1; uint32_t Z : 1; ... uint32_t EL : 2; uint32_t SP : 1; }; ```
If this register had unallocated bits in it, those would have been filled in by RegisterFlags as anonymous fields. A new option "SetChildPrintingDecider" is added so we can disable printing those.
Important things about this type: * It is packed so that sizeof(struct cpsr) == sizeof(the real register). (this will hold for all flags types we create) * Each field has the same storage type, which is the same as the type of the raw register value. This prevents fields being spilt over into more storage units, as is allowed by most ABIs. * Each bitfield size matches that of its register field. * The most significant field is first.
The last point is required because the most significant bit (MSB) being on the left/top of a print out matches what you'd expect to see in an architecture manual. In addition, having lldb print a different field order on big/little endian hosts is not acceptable.
As a consequence, if the target is little endian we have to reverse the order of the fields in the value. The value of each field remains the same. For example 0b01 doesn't become 0b10, it just shifts up or down.
This is needed because clang's type system assumes that for a struct like the one above, the least significant bit (LSB) will be first for a little endian target. We need the MSB to be first.
Finally, if lldb's host is a different endian to the target we have to byte swap the host endian value to match the endian of the target's typesystem.
| Host Endian | Target Endian | Field Order Swap | Byte Order Swap | |-------------|---------------|------------------|-----------------| | Little | Little | Yes | No | | Big | Little | Yes | Yes | | Little | Big | No | Yes | | Big | Big | No | No |
Testing was done as follows: * Little -> Little * LE AArch64 native debug. * Big -> Little * s390x lldb running under QEMU, connected to LE AArch64 target. * Little -> Big * LE AArch64 lldb connected to QEMU's GDB stub, which is running an s390x program. * Big -> Big * s390x lldb running under QEMU, connected to another QEMU's GDB stub, which is running an s390x program.
As we are not allowed to link core code to plugins directly, I have added a new plugin RegisterTypeBuilder. There is one implementation of this, RegisterTypeBuilderClang, which uses TypeSystemClang to build the CompilerType from the register fields.
Reviewed By: jasonmolenda
Differential Revision: https://reviews.llvm.org/D145580
show more ...
|