Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
69ed12f
[lldb] Add utility to create Mach-O corefile from YAML desc
jasonmolenda Aug 16, 2025
11896d8
Whitespace fix.
jasonmolenda Aug 16, 2025
6a272fc
more ws fix
jasonmolenda Aug 16, 2025
9b28021
Revert the ObjectFileJSON changes, will land separately.
jasonmolenda Aug 16, 2025
46c1e91
Correct my cmake details so the `check-lldb-api` target builds the
jasonmolenda Aug 17, 2025
129fb3f
Seems like I need <cstdint> for
jasonmolenda Aug 17, 2025
02d6408
Remove the endian specifier.
jasonmolenda Aug 19, 2025
0dbcf22
Use lldb's UUID class.
jasonmolenda Aug 19, 2025
57e807c
Integrate Jonas' suggestions.
jasonmolenda Aug 26, 2025
28c3d9a
ws fix
jasonmolenda Aug 26, 2025
2822c1d
Add separate methods for writing 32-bit and 64-bit registers,
jasonmolenda Aug 26, 2025
5e924d0
Add the ability to specify a list of UUID & virtual addresses.
jasonmolenda Aug 30, 2025
3080ddb
Merge branch 'main' into add-yaml2macho-core-test-utility
jasonmolenda Aug 30, 2025
f636fec
ws fix
jasonmolenda Aug 30, 2025
5281f5d
Add YAML mappings so the number of addressable bits and binaries
jasonmolenda Sep 2, 2025
e23f26d
ws
jasonmolenda Sep 2, 2025
f461a73
ws fix, David's cleanup suggestion in the rv32 corefile api test.
jasonmolenda Sep 2, 2025
39a7eb2
Need to include <optional> for linux.
jasonmolenda Sep 2, 2025
aa546bc
Make the second thread have unique register values
jasonmolenda Sep 2, 2025
0676c4f
remove newlines between different include types.
jasonmolenda Sep 3, 2025
8d6f539
switch from the standard getopts to the less standard llvm
jasonmolenda Sep 3, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions lldb/packages/Python/lldbsuite/test/configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,9 @@
# 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.
Expand Down Expand Up @@ -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
3 changes: 3 additions & 0 deletions lldb/packages/Python/lldbsuite/test/dotest.py
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,9 @@ def parseOptionsAndInitTestdirs():
configuration.llvm_tools_dir = args.llvm_tools_dir
configuration.filecheck = shutil.which("FileCheck", path=args.llvm_tools_dir)
configuration.yaml2obj = shutil.which("yaml2obj", path=args.llvm_tools_dir)
configuration.yaml2macho_core = shutil.which(
"yaml2macho-core", path=args.llvm_tools_dir
)

if not configuration.get_filecheck_path():
logging.warning("No valid FileCheck executable; some tests may fail...")
Expand Down
27 changes: 26 additions & 1 deletion lldb/packages/Python/lldbsuite/test/lldbtest.py
Original file line number Diff line number Diff line change
Expand Up @@ -1702,6 +1702,29 @@ def yaml2obj(self, yaml_path, obj_path, max_size=None):
command += ["--max-size=%d" % max_size]
self.runBuildCommand(command)

def yaml2macho_core(self, yaml_path, obj_path, uuids=None):
"""
Create a Mach-O corefile at the given path from a yaml file.

Throws subprocess.CalledProcessError if the object could not be created.
"""
yaml2macho_core_bin = configuration.get_yaml2macho_core_path()
if not yaml2macho_core_bin:
self.assertTrue(False, "No valid yaml2macho-core executable specified")
if uuids != None:
command = [
yaml2macho_core_bin,
"-i",
yaml_path,
"-o",
obj_path,
"-u",
uuids,
]
else:
command = [yaml2macho_core_bin, "-i", yaml_path, "-o", obj_path]
self.runBuildCommand(command)

def cleanup(self, dictionary=None):
"""Platform specific way to do cleanup after build."""
module = builder_module()
Expand Down Expand Up @@ -2264,7 +2287,9 @@ def completions_match(self, command, completions, max_completions=-1):
given list of completions"""
interp = self.dbg.GetCommandInterpreter()
match_strings = lldb.SBStringList()
interp.HandleCompletion(command, len(command), 0, max_completions, match_strings)
interp.HandleCompletion(
command, len(command), 0, max_completions, match_strings
)
# match_strings is a 1-indexed list, so we have to slice...
self.assertCountEqual(
completions, list(match_strings)[1:], "List of returned completion is wrong"
Expand Down
6 changes: 0 additions & 6 deletions lldb/test/API/macosx/arm-corefile-regctx/Makefile

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,14 @@
class TestArmMachoCorefileRegctx(TestBase):
NO_DEBUG_INFO_TESTCASE = True

@skipUnlessDarwin
def setUp(self):
TestBase.setUp(self)
self.build()
self.create_corefile = self.getBuildArtifact("a.out")
self.corefile = self.getBuildArtifact("core")

def test_armv7_corefile(self):
### Create corefile
retcode = call(self.create_corefile + " armv7 " + self.corefile, shell=True)
corefile = self.getBuildArtifact("core")
self.yaml2macho_core("armv7m.yaml", corefile)

target = self.dbg.CreateTarget("")
err = lldb.SBError()
process = target.LoadCore(self.corefile)
process = target.LoadCore(corefile)
self.assertTrue(process.IsValid())
thread = process.GetSelectedThread()
frame = thread.GetSelectedFrame()
Expand All @@ -50,11 +44,12 @@ def test_armv7_corefile(self):

def test_arm64_corefile(self):
### Create corefile
retcode = call(self.create_corefile + " arm64 " + self.corefile, shell=True)
corefile = self.getBuildArtifact("core")
self.yaml2macho_core("arm64.yaml", corefile)

target = self.dbg.CreateTarget("")
err = lldb.SBError()
process = target.LoadCore(self.corefile)
process = target.LoadCore(corefile)
self.assertTrue(process.IsValid())
thread = process.GetSelectedThread()
frame = thread.GetSelectedFrame()
Expand Down
30 changes: 30 additions & 0 deletions lldb/test/API/macosx/arm-corefile-regctx/arm64.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
cpu: arm64
threads:
# (lldb) reg read
# % pbpaste | grep = | sed 's, ,,g' | awk -F= '{print "{name: " $1 ", value: " $2 "},"}'
- regsets:
- flavor: gpr
registers: [
{name: x0, value: 0x0000000000000001}, {name: x1, value: 0x000000016fdff3c0},
{name: x2, value: 0x000000016fdff3d0}, {name: x3, value: 0x000000016fdff510},
{name: x4, value: 0x0000000000000000}, {name: x5, value: 0x0000000000000000},
{name: x6, value: 0x0000000000000000}, {name: x7, value: 0x0000000000000000},
{name: x8, value: 0x000000010000d910}, {name: x9, value: 0x0000000000000001},
{name: x10, value: 0xe1e88de000000000}, {name: x11, value: 0x0000000000000003},
{name: x12, value: 0x0000000000000148}, {name: x13, value: 0x0000000000004000},
{name: x14, value: 0x0000000000000008}, {name: x15, value: 0x0000000000000000},
{name: x16, value: 0x0000000000000000}, {name: x17, value: 0x0000000100003f5c},
{name: x18, value: 0x0000000000000000}, {name: x19, value: 0x0000000100003f5c},
{name: x20, value: 0x000000010000c000}, {name: x21, value: 0x000000010000d910},
{name: x22, value: 0x000000016fdff250}, {name: x23, value: 0x000000018ce12366},
{name: x24, value: 0x000000016fdff1d0}, {name: x25, value: 0x0000000000000001},
{name: x26, value: 0x0000000000000000}, {name: x27, value: 0x0000000000000000},
{name: x28, value: 0x0000000000000000}, {name: fp, value: 0x000000016fdff3a0},
{name: lr, value: 0x000000018cd97f28}, {name: sp, value: 0x000000016fdff140},
{name: pc, value: 0x0000000100003f5c}, {name: cpsr, value: 0x80001000}
]
- flavor: exc
registers: [ {name: far, value: 0x0000000100003f5c},
{name: esr, value: 0xf2000000},
{name: exception, value: 0x00000000}
]
36 changes: 36 additions & 0 deletions lldb/test/API/macosx/arm-corefile-regctx/armv7m.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
cpu: armv7m
threads:
# (lldb) reg read
# % pbpaste | grep = | sed 's, ,,g' | awk -F= '{print "{name: " $1 ", value: " $2 "},"}'
- regsets:
- flavor: gpr
registers: [
{name: r0, value: 0x00010000}, {name: r1, value: 0x00020000},
{name: r2, value: 0x00030000}, {name: r3, value: 0x00040000},
{name: r4, value: 0x00050000}, {name: r5, value: 0x00060000},
{name: r6, value: 0x00070000}, {name: r7, value: 0x00080000},
{name: r8, value: 0x00090000}, {name: r9, value: 0x000a0000},
{name: r10, value: 0x000b0000}, {name: r11, value: 0x000c0000},
{name: r12, value: 0x000d0000}, {name: sp, value: 0x000e0000},
{name: lr, value: 0x000f0000}, {name: pc, value: 0x00100000},
{name: cpsr, value: 0x00110000}
]
- flavor: exc
registers: [ {name: far, value: 0x00003f5c},
{name: esr, value: 0xf2000000},
{name: exception, value: 0x00000000}
]

memory-regions:
# $sp is 0x000e0000, have bytes surrounding that address
- addr: 0x000dffe0
UInt8: [
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08,
0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10, 0x11,
0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a,
0x1b, 0x1c, 0x1d, 0x1e, 0x1f, 0x20, 0x21, 0x22, 0x23,
0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2a, 0x2b, 0x2c,
0x2d, 0x2e, 0x2f, 0x30, 0x31, 0x32, 0x33, 0x34, 0x35,
0x36, 0x37, 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e,
0x3f
]
Loading
Loading