diff options
| author | Jacob Lalonde <jalalonde@fb.com> | 2024-08-02 13:35:05 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-08-02 13:35:05 -0700 |
| commit | 3e4af616334eae532f308605b89ff158dd195180 (patch) | |
| tree | 27fec746e28f08f3ed1756a0fbab91a01beb88be /lldb/test/API/python_api | |
| parent | 5edb49355a37b9e4168c4c07fdc0c6623107a735 (diff) | |
| download | llvm-3e4af616334eae532f308605b89ff158dd195180.zip llvm-3e4af616334eae532f308605b89ff158dd195180.tar.gz llvm-3e4af616334eae532f308605b89ff158dd195180.tar.bz2 | |
[LLDB][SBSaveCore] Implement a selectable threadlist for Core Options. (#100443)
In #98403 I enabled the SBSaveCoreOptions object, which allows users via
the scripting API to define what they want saved into their core file.
As the first option I've added a threadlist, so users can scan and
identify which threads and corresponding stacks they want to save.
In order to support this, I had to add a new method to `Process.h` on
how we identify which threads are to be saved, and I had to change the
book keeping in minidump to ensure we don't double save the stacks.
Important to @jasonmolenda I also changed the MachO coredump to accept
these new APIs.
Diffstat (limited to 'lldb/test/API/python_api')
3 files changed, 106 insertions, 1 deletions
diff --git a/lldb/test/API/python_api/sbsavecoreoptions/TestSBSaveCoreOptions.py b/lldb/test/API/python_api/sbsavecoreoptions/TestSBSaveCoreOptions.py index c509e81..40d0cc7 100644 --- a/lldb/test/API/python_api/sbsavecoreoptions/TestSBSaveCoreOptions.py +++ b/lldb/test/API/python_api/sbsavecoreoptions/TestSBSaveCoreOptions.py @@ -4,8 +4,26 @@ import lldb from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * - class SBSaveCoreOptionsAPICase(TestBase): + basic_minidump = "basic_minidump.yaml" + basic_minidump_different_pid = "basic_minidump_different_pid.yaml" + + def get_process_from_yaml(self, yaml_file): + minidump_path = self.getBuildArtifact(os.path.basename(yaml_file) + ".dmp") + print ("minidump_path: " + minidump_path) + self.yaml2obj(yaml_file, minidump_path) + self.assertTrue(os.path.exists(minidump_path), "yaml2obj did not emit a minidump file") + target = self.dbg.CreateTarget(None) + process = target.LoadCore(minidump_path) + self.assertTrue(process.IsValid(), "Process is not valid") + return process + + def get_basic_process(self): + return self.get_process_from_yaml(self.basic_minidump) + + def get_basic_process_different_pid(self): + return self.get_process_from_yaml(self.basic_minidump_different_pid) + def test_plugin_name_assignment(self): """Test assignment ensuring valid plugin names only.""" options = lldb.SBSaveCoreOptions() @@ -26,3 +44,38 @@ class SBSaveCoreOptionsAPICase(TestBase): """Test that the default core style is unspecified.""" options = lldb.SBSaveCoreOptions() self.assertEqual(options.GetStyle(), lldb.eSaveCoreUnspecified) + + def test_adding_and_removing_thread(self): + """Test adding and removing a thread from save core options.""" + self.assertTrue(self.dbg) + options = lldb.SBSaveCoreOptions() + process = self.get_basic_process() + self.assertTrue(process.IsValid(), "Process is not valid") + thread = process.GetThreadAtIndex(0) + error = options.AddThread(thread) + self.assertTrue(error.Success(), error.GetCString()) + removed_success = options.RemoveThread(thread) + self.assertTrue(removed_success) + removed_success = options.RemoveThread(thread) + self.assertFalse(removed_success) + + + def test_adding_thread_different_process(self): + """Test adding and removing a thread from save core options.""" + options = lldb.SBSaveCoreOptions() + process = self.get_basic_process() + process_2 = self.get_basic_process_different_pid() + thread = process.GetThreadAtIndex(0) + error = options.AddThread(thread) + self.assertTrue(error.Success()) + thread_2 = process_2.GetThreadAtIndex(0) + error = options.AddThread(thread_2) + self.assertTrue(error.Fail()) + options.Clear() + error = options.AddThread(thread_2) + self.assertTrue(error.Success()) + options.SetProcess(process) + error = options.AddThread(thread_2) + self.assertTrue(error.Fail()) + error = options.AddThread(thread) + self.assertTrue(error.Success()) diff --git a/lldb/test/API/python_api/sbsavecoreoptions/basic_minidump.yaml b/lldb/test/API/python_api/sbsavecoreoptions/basic_minidump.yaml new file mode 100644 index 0000000..993c7da --- /dev/null +++ b/lldb/test/API/python_api/sbsavecoreoptions/basic_minidump.yaml @@ -0,0 +1,26 @@ +--- !minidump +Streams: + - Type: SystemInfo + Processor Arch: AMD64 + Processor Level: 6 + Processor Revision: 15876 + Number of Processors: 40 + Platform ID: Linux + CSD Version: 'Linux 3.13.0-91-generic #138-Ubuntu SMP Fri Jun 24 17:00:34 UTC 2016 x86_64' + CPU: + Vendor ID: GenuineIntel + Version Info: 0x00000000 + Feature Info: 0x00000000 + - Type: LinuxProcStatus + Text: | + Name: test-yaml + Umask: 0002 + State: t (tracing stop) + Pid: 8567 + - Type: ThreadList + Threads: + - Thread Id: 0x000074DD + Context: 0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000B0010000000000033000000000000000000000002020100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000040109600000000000100000000000000000000000000000068E7D0C8FF7F000068E7D0C8FF7F000097E6D0C8FF7F000010109600000000000000000000000000020000000000000088E4D0C8FF7F0000603FFF85C77F0000F00340000000000080E7D0C8FF7F000000000000000000000000000000000000E0034000000000007F0300000000000000000000000000000000000000000000801F0000FFFF00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF252525252525252525252525252525250000000000000000000000000000000000000000000000000000000000000000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000FF00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 + Stack: + Start of Memory Range: 0x00007FFFC8D0E000 + Content: 'DEADBEEF' diff --git a/lldb/test/API/python_api/sbsavecoreoptions/basic_minidump_different_pid.yaml b/lldb/test/API/python_api/sbsavecoreoptions/basic_minidump_different_pid.yaml new file mode 100644 index 0000000..7393f1f --- /dev/null +++ b/lldb/test/API/python_api/sbsavecoreoptions/basic_minidump_different_pid.yaml @@ -0,0 +1,26 @@ +--- !minidump +Streams: + - Type: SystemInfo + Processor Arch: AMD64 + Processor Level: 6 + Processor Revision: 15876 + Number of Processors: 40 + Platform ID: Linux + CSD Version: 'Linux 3.13.0-91-generic #138-Ubuntu SMP Fri Jun 24 17:00:34 UTC 2016 x86_64' + CPU: + Vendor ID: GenuineIntel + Version Info: 0x00000000 + Feature Info: 0x00000000 + - Type: LinuxProcStatus + Text: | + Name: test-yaml + Umask: 0002 + State: t (tracing stop) + Pid: 1967 + - Type: ThreadList + Threads: + - Thread Id: 0x000074DD + Context: 0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000B0010000000000033000000000000000000000002020100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000040109600000000000100000000000000000000000000000068E7D0C8FF7F000068E7D0C8FF7F000097E6D0C8FF7F000010109600000000000000000000000000020000000000000088E4D0C8FF7F0000603FFF85C77F0000F00340000000000080E7D0C8FF7F000000000000000000000000000000000000E0034000000000007F0300000000000000000000000000000000000000000000801F0000FFFF00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF252525252525252525252525252525250000000000000000000000000000000000000000000000000000000000000000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000FF00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 + Stack: + Start of Memory Range: 0x00007FFFC8D0E000 + Content: 'DEADBEEF' |
