summaryrefslogtreecommitdiffstats
path: root/gnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/plugins
diff options
context:
space:
mode:
authorpatrick <patrick@openbsd.org>2020-08-03 14:33:06 +0000
committerpatrick <patrick@openbsd.org>2020-08-03 14:33:06 +0000
commit061da546b983eb767bad15e67af1174fb0bcf31c (patch)
tree83c78b820819d70aa40c36d90447978b300078c5 /gnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/plugins
parentImport LLVM 10.0.0 release including clang, lld and lldb. (diff)
downloadwireguard-openbsd-061da546b983eb767bad15e67af1174fb0bcf31c.tar.xz
wireguard-openbsd-061da546b983eb767bad15e67af1174fb0bcf31c.zip
Import LLVM 10.0.0 release including clang, lld and lldb.
ok hackroom tested by plenty
Diffstat (limited to 'gnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/plugins')
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/plugins/command_plugin/Makefile6
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/plugins/command_plugin/TestPluginCommands.py78
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/plugins/command_plugin/plugin.cpp.template53
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/plugins/python_os_plugin/Makefile2
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/plugins/python_os_plugin/TestPythonOSPlugin.py195
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/plugins/python_os_plugin/main.c7
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/plugins/python_os_plugin/operating_system.py128
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/plugins/python_os_plugin/operating_system2.py116
8 files changed, 585 insertions, 0 deletions
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/plugins/command_plugin/Makefile b/gnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/plugins/command_plugin/Makefile
new file mode 100644
index 00000000000..3119c370784
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/plugins/command_plugin/Makefile
@@ -0,0 +1,6 @@
+DYLIB_CXX_SOURCES := plugin.cpp
+DYLIB_NAME := plugin
+DYLIB_ONLY := YES
+MAKE_DSYM := NO
+
+include Makefile.rules
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/plugins/command_plugin/TestPluginCommands.py b/gnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/plugins/command_plugin/TestPluginCommands.py
new file mode 100644
index 00000000000..e81d4076574
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/plugins/command_plugin/TestPluginCommands.py
@@ -0,0 +1,78 @@
+"""
+Test that plugins that load commands work correctly.
+"""
+
+from __future__ import print_function
+
+
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+
+class PluginCommandTestCase(TestBase):
+
+ mydir = TestBase.compute_mydir(__file__)
+
+ def setUp(self):
+ TestBase.setUp(self)
+ self.generateSource('plugin.cpp')
+
+ @skipIfNoSBHeaders
+ # Requires a compatible arch and platform to link against the host's built
+ # lldb lib.
+ @skipIfHostIncompatibleWithRemote
+ @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24778")
+ @no_debug_info_test
+ def test_load_plugin(self):
+ """Test that plugins that load commands work correctly."""
+
+ plugin_name = "plugin"
+ if sys.platform.startswith("darwin"):
+ plugin_lib_name = "lib%s.dylib" % plugin_name
+ else:
+ plugin_lib_name = "lib%s.so" % plugin_name
+
+ # Invoke the library build rule.
+ self.buildLibrary("plugin.cpp", plugin_name)
+
+ debugger = lldb.SBDebugger.Create()
+
+ retobj = lldb.SBCommandReturnObject()
+
+ retval = debugger.GetCommandInterpreter().HandleCommand(
+ "plugin load %s" % self.getBuildArtifact(plugin_lib_name), retobj)
+
+ retobj.Clear()
+
+ retval = debugger.GetCommandInterpreter().HandleCommand(
+ "plugin_loaded_command child abc def ghi", retobj)
+
+ if self.TraceOn():
+ print(retobj.GetOutput())
+
+ self.expect(retobj, substrs=['abc def ghi'], exe=False)
+
+ retobj.Clear()
+
+ # check that abbreviations work correctly in plugin commands.
+ retval = debugger.GetCommandInterpreter().HandleCommand(
+ "plugin_loaded_ ch abc def ghi", retobj)
+
+ if self.TraceOn():
+ print(retobj.GetOutput())
+
+ self.expect(retobj, substrs=['abc def ghi'], exe=False)
+
+ @no_debug_info_test
+ def test_invalid_plugin_invocation(self):
+ self.expect("plugin load a b",
+ error=True, startstr="error: 'plugin load' requires one argument")
+ self.expect("plugin load",
+ error=True, startstr="error: 'plugin load' requires one argument")
+
+ @no_debug_info_test
+ def test_invalid_plugin_target(self):
+ self.expect("plugin load ThisIsNotAValidPluginName",
+ error=True, startstr="error: no such file")
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/plugins/command_plugin/plugin.cpp.template b/gnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/plugins/command_plugin/plugin.cpp.template
new file mode 100644
index 00000000000..1667c0d721e
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/plugins/command_plugin/plugin.cpp.template
@@ -0,0 +1,53 @@
+//===-- plugin.cpp -------------------------------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+/*
+An example plugin for LLDB that provides a new foo command with a child subcommand
+Compile this into a dylib foo.dylib and load by placing in appropriate locations on disk or
+by typing plugin load foo.dylib at the LLDB command line
+*/
+
+%include_SB_APIs%
+
+namespace lldb {
+ bool
+ PluginInitialize (lldb::SBDebugger debugger);
+}
+
+class ChildCommand : public lldb::SBCommandPluginInterface
+{
+public:
+ virtual bool
+ DoExecute (lldb::SBDebugger debugger,
+ char** command,
+ lldb::SBCommandReturnObject &result)
+ {
+ if (command)
+ {
+ const char* arg = *command;
+ while (arg)
+ {
+ result.Printf("%s ",arg);
+ arg = *(++command);
+ }
+ result.Printf("\n");
+ return true;
+ }
+ return false;
+ }
+
+};
+
+bool
+lldb::PluginInitialize (lldb::SBDebugger debugger)
+{
+ lldb::SBCommandInterpreter interpreter = debugger.GetCommandInterpreter();
+ lldb::SBCommand foo = interpreter.AddMultiwordCommand("plugin_loaded_command",NULL);
+ foo.AddCommand("child",new ChildCommand(),"a child of plugin_loaded_command");
+ return true;
+}
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/plugins/python_os_plugin/Makefile b/gnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/plugins/python_os_plugin/Makefile
new file mode 100644
index 00000000000..c9319d6e688
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/plugins/python_os_plugin/Makefile
@@ -0,0 +1,2 @@
+C_SOURCES := main.c
+include Makefile.rules
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/plugins/python_os_plugin/TestPythonOSPlugin.py b/gnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/plugins/python_os_plugin/TestPythonOSPlugin.py
new file mode 100644
index 00000000000..5c4b42084c2
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/plugins/python_os_plugin/TestPythonOSPlugin.py
@@ -0,0 +1,195 @@
+"""
+Test that the Python operating system plugin works correctly
+"""
+
+
+
+import os
+import lldb
+from lldbsuite.test.lldbtest import *
+import lldbsuite.test.lldbutil as lldbutil
+
+
+class PluginPythonOSPlugin(TestBase):
+
+ mydir = TestBase.compute_mydir(__file__)
+ NO_DEBUG_INFO_TESTCASE = True
+
+ def test_python_os_plugin(self):
+ """Test that the Python operating system plugin works correctly"""
+ self.build()
+ self.run_python_os_funcionality()
+
+ def run_python_os_step(self):
+ """Test that the Python operating system plugin works correctly when single stepping a virtual thread"""
+ self.build()
+ self.run_python_os_step()
+
+ def verify_os_thread_registers(self, thread):
+ frame = thread.GetFrameAtIndex(0)
+ registers = frame.GetRegisters().GetValueAtIndex(0)
+ reg_value = thread.GetThreadID() + 1
+ for reg in registers:
+ self.assertTrue(
+ reg.GetValueAsUnsigned() == reg_value,
+ "Verify the registers contains the correct value")
+ reg_value = reg_value + 1
+
+ def run_python_os_funcionality(self):
+ """Test that the Python operating system plugin works correctly"""
+
+ # Set debugger into synchronous mode
+ self.dbg.SetAsync(False)
+
+ # Create a target by the debugger.
+ exe = self.getBuildArtifact("a.out")
+ python_os_plugin_path = os.path.join(self.getSourceDir(),
+ "operating_system.py")
+ target = self.dbg.CreateTarget(exe)
+ self.assertTrue(target, VALID_TARGET)
+
+ # Set breakpoints inside and outside methods that take pointers to the
+ # containing struct.
+ lldbutil.run_break_set_by_source_regexp(self, "// Set breakpoint here")
+
+ # Register our shared libraries for remote targets so they get
+ # automatically uploaded
+ arguments = None
+ environment = None
+
+ # Now launch the process, and do not stop at entry point.
+ process = target.LaunchSimple(
+ arguments, environment, self.get_process_working_directory())
+ self.assertTrue(process, PROCESS_IS_VALID)
+
+ # Make sure there are no OS plug-in created thread when we first stop
+ # at our breakpoint in main
+ thread = process.GetThreadByID(0x111111111)
+ self.assertFalse(
+ thread.IsValid(),
+ "Make sure there is no thread 0x111111111 before we load the python OS plug-in")
+ thread = process.GetThreadByID(0x222222222)
+ self.assertFalse(
+ thread.IsValid(),
+ "Make sure there is no thread 0x222222222 before we load the python OS plug-in")
+ thread = process.GetThreadByID(0x333333333)
+ self.assertFalse(
+ thread.IsValid(),
+ "Make sure there is no thread 0x333333333 before we load the python OS plug-in")
+
+ # Now load the python OS plug-in which should update the thread list and we should have
+ # OS plug-in created threads with the IDs: 0x111111111, 0x222222222,
+ # 0x333333333
+ command = "settings set target.process.python-os-plugin-path '%s'" % python_os_plugin_path
+ self.dbg.HandleCommand(command)
+
+ # Verify our OS plug-in threads showed up
+ thread = process.GetThreadByID(0x111111111)
+ self.assertTrue(
+ thread.IsValid(),
+ "Make sure there is a thread 0x111111111 after we load the python OS plug-in")
+ self.verify_os_thread_registers(thread)
+ thread = process.GetThreadByID(0x222222222)
+ self.assertTrue(
+ thread.IsValid(),
+ "Make sure there is a thread 0x222222222 after we load the python OS plug-in")
+ self.verify_os_thread_registers(thread)
+ thread = process.GetThreadByID(0x333333333)
+ self.assertTrue(
+ thread.IsValid(),
+ "Make sure there is a thread 0x333333333 after we load the python OS plug-in")
+ self.verify_os_thread_registers(thread)
+
+ # Now clear the OS plug-in path to make the OS plug-in created threads
+ # dissappear
+ self.dbg.HandleCommand(
+ "settings clear target.process.python-os-plugin-path")
+
+ # Verify the threads are gone after unloading the python OS plug-in
+ thread = process.GetThreadByID(0x111111111)
+ self.assertFalse(
+ thread.IsValid(),
+ "Make sure there is no thread 0x111111111 after we unload the python OS plug-in")
+ thread = process.GetThreadByID(0x222222222)
+ self.assertFalse(
+ thread.IsValid(),
+ "Make sure there is no thread 0x222222222 after we unload the python OS plug-in")
+ thread = process.GetThreadByID(0x333333333)
+ self.assertFalse(
+ thread.IsValid(),
+ "Make sure there is no thread 0x333333333 after we unload the python OS plug-in")
+
+ def run_python_os_step(self):
+ """Test that the Python operating system plugin works correctly and allows single stepping of a virtual thread that is backed by a real thread"""
+
+ # Set debugger into synchronous mode
+ self.dbg.SetAsync(False)
+
+ # Create a target by the debugger.
+ exe = self.getBuildArtifact("a.out")
+ python_os_plugin_path = os.path.join(self.getSourceDir(),
+ "operating_system2.py")
+ target = self.dbg.CreateTarget(exe)
+ self.assertTrue(target, VALID_TARGET)
+
+ # Set breakpoints inside and outside methods that take pointers to the
+ # containing struct.
+ lldbutil.run_break_set_by_source_regexp(self, "// Set breakpoint here")
+
+ # Register our shared libraries for remote targets so they get
+ # automatically uploaded
+ arguments = None
+ environment = None
+
+ # Now launch the process, and do not stop at entry point.
+ process = target.LaunchSimple(
+ arguments, environment, self.get_process_working_directory())
+ self.assertTrue(process, PROCESS_IS_VALID)
+
+ # Make sure there are no OS plug-in created thread when we first stop
+ # at our breakpoint in main
+ thread = process.GetThreadByID(0x111111111)
+ self.assertFalse(
+ thread.IsValid(),
+ "Make sure there is no thread 0x111111111 before we load the python OS plug-in")
+
+ # Now load the python OS plug-in which should update the thread list and we should have
+ # OS plug-in created threads with the IDs: 0x111111111, 0x222222222,
+ # 0x333333333
+ command = "settings set target.process.python-os-plugin-path '%s'" % python_os_plugin_path
+ self.dbg.HandleCommand(command)
+
+ # Verify our OS plug-in threads showed up
+ thread = process.GetThreadByID(0x111111111)
+ self.assertTrue(
+ thread.IsValid(),
+ "Make sure there is a thread 0x111111111 after we load the python OS plug-in")
+
+ frame = thread.GetFrameAtIndex(0)
+ self.assertTrue(
+ frame.IsValid(),
+ "Make sure we get a frame from thread 0x111111111")
+ line_entry = frame.GetLineEntry()
+
+ self.assertTrue(
+ line_entry.GetFileSpec().GetFilename() == 'main.c',
+ "Make sure we stopped on line 5 in main.c")
+ self.assertTrue(
+ line_entry.GetLine() == 5,
+ "Make sure we stopped on line 5 in main.c")
+
+ # Now single step thread 0x111111111 and make sure it does what we need
+ # it to
+ thread.StepOver()
+
+ frame = thread.GetFrameAtIndex(0)
+ self.assertTrue(
+ frame.IsValid(),
+ "Make sure we get a frame from thread 0x111111111")
+ line_entry = frame.GetLineEntry()
+
+ self.assertTrue(
+ line_entry.GetFileSpec().GetFilename() == 'main.c',
+ "Make sure we stepped from line 5 to line 6 in main.c")
+ self.assertTrue(line_entry.GetLine() == 6,
+ "Make sure we stepped from line 5 to line 6 in main.c")
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/plugins/python_os_plugin/main.c b/gnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/plugins/python_os_plugin/main.c
new file mode 100644
index 00000000000..faa6dd58ecd
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/plugins/python_os_plugin/main.c
@@ -0,0 +1,7 @@
+#include <stdio.h>
+
+int main (int argc, char const *argv[], char const *envp[])
+{
+ puts("stop here"); // Set breakpoint here
+ return 0;
+}
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/plugins/python_os_plugin/operating_system.py b/gnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/plugins/python_os_plugin/operating_system.py
new file mode 100644
index 00000000000..394c24b4a88
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/plugins/python_os_plugin/operating_system.py
@@ -0,0 +1,128 @@
+#!/usr/bin/python
+
+import lldb
+import struct
+
+
+class OperatingSystemPlugIn(object):
+ """Class that provides data for an instance of a LLDB 'OperatingSystemPython' plug-in class"""
+
+ def __init__(self, process):
+ '''Initialization needs a valid.SBProcess object.
+
+ This plug-in will get created after a live process is valid and has stopped for the
+ first time.'''
+ self.process = None
+ self.registers = None
+ self.threads = None
+ if isinstance(process, lldb.SBProcess) and process.IsValid():
+ self.process = process
+ self.threads = None # Will be an dictionary containing info for each thread
+
+ def get_target(self):
+ # NOTE: Don't use "lldb.target" when trying to get your target as the "lldb.target"
+ # tracks the current target in the LLDB command interpreter which isn't the
+ # correct thing to use for this plug-in.
+ return self.process.target
+
+ def create_thread(self, tid, context):
+ if tid == 0x444444444:
+ thread_info = {
+ 'tid': tid,
+ 'name': 'four',
+ 'queue': 'queue4',
+ 'state': 'stopped',
+ 'stop_reason': 'none'}
+ self.threads.append(thread_info)
+ return thread_info
+ return None
+
+ def get_thread_info(self):
+ if not self.threads:
+ # The sample dictionary below shows the values that can be returned for a thread
+ # tid => thread ID (mandatory)
+ # name => thread name (optional key/value pair)
+ # queue => thread dispatch queue name (optional key/value pair)
+ # state => thred state (mandatory, set to 'stopped' for now)
+ # stop_reason => thread stop reason. (mandatory, usually set to 'none')
+ # Possible values include:
+ # 'breakpoint' if the thread is stopped at a breakpoint
+ # 'none' thread is just stopped because the process is stopped
+ # 'trace' the thread just single stepped
+ # The usual value for this while threads are in memory is 'none'
+ # register_data_addr => the address of the register data in memory (optional key/value pair)
+ # Specifying this key/value pair for a thread will avoid a call to get_register_data()
+ # and can be used when your registers are in a thread context structure that is contiguous
+ # in memory. Don't specify this if your register layout in memory doesn't match the layout
+ # described by the dictionary returned from a call to the
+ # get_register_info() method.
+ self.threads = [{'tid': 0x111111111,
+ 'name': 'one',
+ 'queue': 'queue1',
+ 'state': 'stopped',
+ 'stop_reason': 'breakpoint'},
+ {'tid': 0x222222222,
+ 'name': 'two',
+ 'queue': 'queue2',
+ 'state': 'stopped',
+ 'stop_reason': 'none'},
+ {'tid': 0x333333333,
+ 'name': 'three',
+ 'queue': 'queue3',
+ 'state': 'stopped',
+ 'stop_reason': 'trace'}]
+ return self.threads
+
+ def get_register_info(self):
+ if self.registers is None:
+ self.registers = dict()
+ self.registers['sets'] = ['GPR']
+ self.registers['registers'] = [
+ {'name': 'rax', 'bitsize': 64, 'offset': 0, 'encoding': 'uint', 'format': 'hex', 'set': 0, 'gcc': 0, 'dwarf': 0},
+ {'name': 'rbx', 'bitsize': 64, 'offset': 8, 'encoding': 'uint', 'format': 'hex', 'set': 0, 'gcc': 3, 'dwarf': 3},
+ {'name': 'rcx', 'bitsize': 64, 'offset': 16, 'encoding': 'uint', 'format': 'hex', 'set': 0, 'gcc': 2, 'dwarf': 2, 'generic': 'arg4', 'alt-name': 'arg4', },
+ {'name': 'rdx', 'bitsize': 64, 'offset': 24, 'encoding': 'uint', 'format': 'hex', 'set': 0, 'gcc': 1, 'dwarf': 1, 'generic': 'arg3', 'alt-name': 'arg3', },
+ {'name': 'rdi', 'bitsize': 64, 'offset': 32, 'encoding': 'uint', 'format': 'hex', 'set': 0, 'gcc': 5, 'dwarf': 5, 'generic': 'arg1', 'alt-name': 'arg1', },
+ {'name': 'rsi', 'bitsize': 64, 'offset': 40, 'encoding': 'uint', 'format': 'hex', 'set': 0, 'gcc': 4, 'dwarf': 4, 'generic': 'arg2', 'alt-name': 'arg2', },
+ {'name': 'rbp', 'bitsize': 64, 'offset': 48, 'encoding': 'uint', 'format': 'hex', 'set': 0, 'gcc': 6, 'dwarf': 6, 'generic': 'fp', 'alt-name': 'fp', },
+ {'name': 'rsp', 'bitsize': 64, 'offset': 56, 'encoding': 'uint', 'format': 'hex', 'set': 0, 'gcc': 7, 'dwarf': 7, 'generic': 'sp', 'alt-name': 'sp', },
+ {'name': 'r8', 'bitsize': 64, 'offset': 64, 'encoding': 'uint', 'format': 'hex', 'set': 0, 'gcc': 8, 'dwarf': 8, 'generic': 'arg5', 'alt-name': 'arg5', },
+ {'name': 'r9', 'bitsize': 64, 'offset': 72, 'encoding': 'uint', 'format': 'hex', 'set': 0, 'gcc': 9, 'dwarf': 9, 'generic': 'arg6', 'alt-name': 'arg6', },
+ {'name': 'r10', 'bitsize': 64, 'offset': 80, 'encoding': 'uint', 'format': 'hex', 'set': 0, 'gcc': 10, 'dwarf': 10},
+ {'name': 'r11', 'bitsize': 64, 'offset': 88, 'encoding': 'uint', 'format': 'hex', 'set': 0, 'gcc': 11, 'dwarf': 11},
+ {'name': 'r12', 'bitsize': 64, 'offset': 96, 'encoding': 'uint', 'format': 'hex', 'set': 0, 'gcc': 12, 'dwarf': 12},
+ {'name': 'r13', 'bitsize': 64, 'offset': 104, 'encoding': 'uint', 'format': 'hex', 'set': 0, 'gcc': 13, 'dwarf': 13},
+ {'name': 'r14', 'bitsize': 64, 'offset': 112, 'encoding': 'uint', 'format': 'hex', 'set': 0, 'gcc': 14, 'dwarf': 14},
+ {'name': 'r15', 'bitsize': 64, 'offset': 120, 'encoding': 'uint', 'format': 'hex', 'set': 0, 'gcc': 15, 'dwarf': 15},
+ {'name': 'rip', 'bitsize': 64, 'offset': 128, 'encoding': 'uint', 'format': 'hex', 'set': 0, 'gcc': 16, 'dwarf': 16, 'generic': 'pc', 'alt-name': 'pc'},
+ {'name': 'rflags', 'bitsize': 64, 'offset': 136, 'encoding': 'uint', 'format': 'hex', 'set': 0, 'generic': 'flags', 'alt-name': 'flags'},
+ {'name': 'cs', 'bitsize': 64, 'offset': 144, 'encoding': 'uint', 'format': 'hex', 'set': 0},
+ {'name': 'fs', 'bitsize': 64, 'offset': 152, 'encoding': 'uint', 'format': 'hex', 'set': 0},
+ {'name': 'gs', 'bitsize': 64, 'offset': 160, 'encoding': 'uint', 'format': 'hex', 'set': 0},
+ ]
+ return self.registers
+
+ def get_register_data(self, tid):
+ return struct.pack(
+ '21Q',
+ tid + 1,
+ tid + 2,
+ tid + 3,
+ tid + 4,
+ tid + 5,
+ tid + 6,
+ tid + 7,
+ tid + 8,
+ tid + 9,
+ tid + 10,
+ tid + 11,
+ tid + 12,
+ tid + 13,
+ tid + 14,
+ tid + 15,
+ tid + 16,
+ tid + 17,
+ tid + 18,
+ tid + 19,
+ tid + 20,
+ tid + 21)
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/plugins/python_os_plugin/operating_system2.py b/gnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/plugins/python_os_plugin/operating_system2.py
new file mode 100644
index 00000000000..438538ca922
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/plugins/python_os_plugin/operating_system2.py
@@ -0,0 +1,116 @@
+#!/usr/bin/python
+
+import lldb
+import struct
+
+
+class OperatingSystemPlugIn(object):
+ """Class that provides data for an instance of a LLDB 'OperatingSystemPython' plug-in class"""
+
+ def __init__(self, process):
+ '''Initialization needs a valid.SBProcess object.
+
+ This plug-in will get created after a live process is valid and has stopped for the
+ first time.'''
+ self.process = None
+ self.registers = None
+ self.threads = None
+ if isinstance(process, lldb.SBProcess) and process.IsValid():
+ self.process = process
+ self.threads = None # Will be an dictionary containing info for each thread
+
+ def get_target(self):
+ # NOTE: Don't use "lldb.target" when trying to get your target as the "lldb.target"
+ # tracks the current target in the LLDB command interpreter which isn't the
+ # correct thing to use for this plug-in.
+ return self.process.target
+
+ def create_thread(self, tid, context):
+ if tid == 0x444444444:
+ thread_info = {
+ 'tid': tid,
+ 'name': 'four',
+ 'queue': 'queue4',
+ 'state': 'stopped',
+ 'stop_reason': 'none'}
+ self.threads.append(thread_info)
+ return thread_info
+ return None
+
+ def get_thread_info(self):
+ if not self.threads:
+ # The sample dictionary below shows the values that can be returned for a thread
+ # tid => thread ID (mandatory)
+ # name => thread name (optional key/value pair)
+ # queue => thread dispatch queue name (optional key/value pair)
+ # state => thred state (mandatory, set to 'stopped' for now)
+ # stop_reason => thread stop reason. (mandatory, usually set to 'none')
+ # Possible values include:
+ # 'breakpoint' if the thread is stopped at a breakpoint
+ # 'none' thread is just stopped because the process is stopped
+ # 'trace' the thread just single stepped
+ # The usual value for this while threads are in memory is 'none'
+ # register_data_addr => the address of the register data in memory (optional key/value pair)
+ # Specifying this key/value pair for a thread will avoid a call to get_register_data()
+ # and can be used when your registers are in a thread context structure that is contiguous
+ # in memory. Don't specify this if your register layout in memory doesn't match the layout
+ # described by the dictionary returned from a call to the
+ # get_register_info() method.
+ self.threads = [
+ {'tid': 0x111111111, 'core': 0}
+ ]
+ return self.threads
+
+ def get_register_info(self):
+ if self.registers is None:
+ self.registers = dict()
+ self.registers['sets'] = ['GPR']
+ self.registers['registers'] = [
+ {'name': 'rax', 'bitsize': 64, 'offset': 0, 'encoding': 'uint', 'format': 'hex', 'set': 0, 'gcc': 0, 'dwarf': 0},
+ {'name': 'rbx', 'bitsize': 64, 'offset': 8, 'encoding': 'uint', 'format': 'hex', 'set': 0, 'gcc': 3, 'dwarf': 3},
+ {'name': 'rcx', 'bitsize': 64, 'offset': 16, 'encoding': 'uint', 'format': 'hex', 'set': 0, 'gcc': 2, 'dwarf': 2, 'generic': 'arg4', 'alt-name': 'arg4', },
+ {'name': 'rdx', 'bitsize': 64, 'offset': 24, 'encoding': 'uint', 'format': 'hex', 'set': 0, 'gcc': 1, 'dwarf': 1, 'generic': 'arg3', 'alt-name': 'arg3', },
+ {'name': 'rdi', 'bitsize': 64, 'offset': 32, 'encoding': 'uint', 'format': 'hex', 'set': 0, 'gcc': 5, 'dwarf': 5, 'generic': 'arg1', 'alt-name': 'arg1', },
+ {'name': 'rsi', 'bitsize': 64, 'offset': 40, 'encoding': 'uint', 'format': 'hex', 'set': 0, 'gcc': 4, 'dwarf': 4, 'generic': 'arg2', 'alt-name': 'arg2', },
+ {'name': 'rbp', 'bitsize': 64, 'offset': 48, 'encoding': 'uint', 'format': 'hex', 'set': 0, 'gcc': 6, 'dwarf': 6, 'generic': 'fp', 'alt-name': 'fp', },
+ {'name': 'rsp', 'bitsize': 64, 'offset': 56, 'encoding': 'uint', 'format': 'hex', 'set': 0, 'gcc': 7, 'dwarf': 7, 'generic': 'sp', 'alt-name': 'sp', },
+ {'name': 'r8', 'bitsize': 64, 'offset': 64, 'encoding': 'uint', 'format': 'hex', 'set': 0, 'gcc': 8, 'dwarf': 8, 'generic': 'arg5', 'alt-name': 'arg5', },
+ {'name': 'r9', 'bitsize': 64, 'offset': 72, 'encoding': 'uint', 'format': 'hex', 'set': 0, 'gcc': 9, 'dwarf': 9, 'generic': 'arg6', 'alt-name': 'arg6', },
+ {'name': 'r10', 'bitsize': 64, 'offset': 80, 'encoding': 'uint', 'format': 'hex', 'set': 0, 'gcc': 10, 'dwarf': 10},
+ {'name': 'r11', 'bitsize': 64, 'offset': 88, 'encoding': 'uint', 'format': 'hex', 'set': 0, 'gcc': 11, 'dwarf': 11},
+ {'name': 'r12', 'bitsize': 64, 'offset': 96, 'encoding': 'uint', 'format': 'hex', 'set': 0, 'gcc': 12, 'dwarf': 12},
+ {'name': 'r13', 'bitsize': 64, 'offset': 104, 'encoding': 'uint', 'format': 'hex', 'set': 0, 'gcc': 13, 'dwarf': 13},
+ {'name': 'r14', 'bitsize': 64, 'offset': 112, 'encoding': 'uint', 'format': 'hex', 'set': 0, 'gcc': 14, 'dwarf': 14},
+ {'name': 'r15', 'bitsize': 64, 'offset': 120, 'encoding': 'uint', 'format': 'hex', 'set': 0, 'gcc': 15, 'dwarf': 15},
+ {'name': 'rip', 'bitsize': 64, 'offset': 128, 'encoding': 'uint', 'format': 'hex', 'set': 0, 'gcc': 16, 'dwarf': 16, 'generic': 'pc', 'alt-name': 'pc'},
+ {'name': 'rflags', 'bitsize': 64, 'offset': 136, 'encoding': 'uint', 'format': 'hex', 'set': 0, 'generic': 'flags', 'alt-name': 'flags'},
+ {'name': 'cs', 'bitsize': 64, 'offset': 144, 'encoding': 'uint', 'format': 'hex', 'set': 0},
+ {'name': 'fs', 'bitsize': 64, 'offset': 152, 'encoding': 'uint', 'format': 'hex', 'set': 0},
+ {'name': 'gs', 'bitsize': 64, 'offset': 160, 'encoding': 'uint', 'format': 'hex', 'set': 0},
+ ]
+ return self.registers
+
+ def get_register_data(self, tid):
+ return struct.pack(
+ '21Q',
+ tid + 1,
+ tid + 2,
+ tid + 3,
+ tid + 4,
+ tid + 5,
+ tid + 6,
+ tid + 7,
+ tid + 8,
+ tid + 9,
+ tid + 10,
+ tid + 11,
+ tid + 12,
+ tid + 13,
+ tid + 14,
+ tid + 15,
+ tid + 16,
+ tid + 17,
+ tid + 18,
+ tid + 19,
+ tid + 20,
+ tid + 21)