diff options
author | Jason Molenda <jmolenda@apple.com> | 2025-09-04 11:42:26 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-09-04 11:42:26 -0700 |
commit | a0c2d6e369a1fb4d8b3ed46baed7a2de2fb3d882 (patch) | |
tree | f7cc3dede3a76f1bcdca6613119d097836cc2878 /lldb/packages/Python/lldbsuite/test/configuration.py | |
parent | 35b22764e26aa02ef3ad849bb449bf7fda8e6c75 (diff) | |
download | llvm-a0c2d6e369a1fb4d8b3ed46baed7a2de2fb3d882.zip llvm-a0c2d6e369a1fb4d8b3ed46baed7a2de2fb3d882.tar.gz llvm-a0c2d6e369a1fb4d8b3ed46baed7a2de2fb3d882.tar.bz2 |
[lldb] Add utility to create Mach-O corefile from YAML desc (#153911)
I've wanted a utility to create a corefile for test purposes given a bit
of memory and regsters, for a while. I've written a few API tests over
the years that needed exactly this capability -- we have several one-off
Mach-O corefile creator utility in the API testsuite to do this. But
it's a lot of boilerplate when you only want to specify some register
contents and memory contents, to create an API test.
This adds yaml2mach-core, a tool that should build on any system, takes
a yaml description of register values for one or more threads,
optionally memory values for one or more memory regions, and can take a
list of UUIDs that will be added as LC_NOTE "load binary" metadata to
the corefile so binaries can be loaded into virtual address space in a
test scenario.
The format of the yaml file looks like
```
cpu: armv7m
# optionally specify the number of bits used for addressing
# (this line is from a different, 64-bit, yaml file)
addressable-bits:
num-bits: 39
# optionally specify one or more binary UUID and slide/virtual address to be added as an LC_NOTE
# (this line is from a different, 64-bit, yaml file)
binaries:
- name: debug-binary.development
uuid: 67942352-5857-3D3D-90CB-A3F80BA67B04
virtual-address: 0xfffffff01840c000
threads:
- regsets:
- flavor: gpr
registers: [{name: sp, value: 0x2000fe70}, {name: r7, value: 0x2000fe80},
{name: pc, value: 0x0020392c}, {name: lr, value: 0x0020392d}]
memory-regions:
# stack memory
- addr: 0x2000fe70
UInt32: [ 0x0000002a, 0x20010e58, 0x00203923,
0x00000001, 0x2000fe88, 0x00203911,
0x2000ffdc, 0xfffffff9 ]
# instructions of a function
- addr: 0x203910
UInt8: [ 0xf8, 0xb5, 0x04, 0xaf, 0x06, 0x4c, 0x07, 0x49,
0x74, 0xf0, 0x2e, 0xf8, 0x01, 0xac, 0x74, 0xf0 ]
```
and that's all that is needed to specify a corefile where four register
values are specified (the others will be set to 0), and two memory
regions will be emitted.
The memory can be specified as an array of UInt8, UInt32, or UInt64, I
anticipate that some of these corefiles may have stack values
constructed manually and it may be simpler for a human to write them in
a particular grouping of values.
I needed this utility for an upcoming patch for ARM Cortex-M processors,
to create a test for the change. I took the opportunity to remove two of
the "trivial mach-o corefile" creator utilities I've written in the
past, which also restricted the tests to only run on Darwin systems
because I was using the system headers for Mach-O constant values.
rdar://110663219
Diffstat (limited to 'lldb/packages/Python/lldbsuite/test/configuration.py')
-rw-r--r-- | lldb/packages/Python/lldbsuite/test/configuration.py | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/lldb/packages/Python/lldbsuite/test/configuration.py b/lldb/packages/Python/lldbsuite/test/configuration.py index 5e38109..c2c46b9 100644 --- a/lldb/packages/Python/lldbsuite/test/configuration.py +++ b/lldb/packages/Python/lldbsuite/test/configuration.py @@ -64,6 +64,9 @@ filecheck = None # Path to the yaml2obj tool. Not optional. yaml2obj = None +# Path to the yaml2macho-core tool. Not optional. +yaml2macho_core = None + # The arch might dictate some specific CFLAGS to be passed to the toolchain to build # the inferior programs. The global variable cflags_extras provides a hook to do # just that. @@ -174,3 +177,11 @@ def get_yaml2obj_path(): """ if yaml2obj and os.path.lexists(yaml2obj): return yaml2obj + + +def get_yaml2macho_core_path(): + """ + Get the path to the yaml2macho-core tool. + """ + if yaml2macho_core and os.path.lexists(yaml2macho_core): + return yaml2macho_core |