summaryrefslogtreecommitdiff
path: root/lldb/examples/python/templates/scripted_process.py
diff options
context:
space:
mode:
authorMingming Liu <mingmingl@google.com>2025-09-10 15:25:31 -0700
committerGitHub <noreply@github.com>2025-09-10 15:25:31 -0700
commit1417dafa1db9cb1b2b09438aa9f53ea5ab6e36e2 (patch)
tree57f4b1f313c8cf74eed8819870f39c36ea263c68 /lldb/examples/python/templates/scripted_process.py
parent898b813bc8a6d0276bf0f4769f5f2f64b34e632d (diff)
parentb8cefcb601ddaa18482555c4ff363c01a270c2fe (diff)
Merge branch 'main' into users/mingmingl-llvm/samplefdo-profile-formatusers/mingmingl-llvm/samplefdo-profile-format
Diffstat (limited to 'lldb/examples/python/templates/scripted_process.py')
-rw-r--r--lldb/examples/python/templates/scripted_process.py136
1 files changed, 136 insertions, 0 deletions
diff --git a/lldb/examples/python/templates/scripted_process.py b/lldb/examples/python/templates/scripted_process.py
index b6360b851907..49059d533f38 100644
--- a/lldb/examples/python/templates/scripted_process.py
+++ b/lldb/examples/python/templates/scripted_process.py
@@ -383,6 +383,142 @@ class ScriptedThread(metaclass=ABCMeta):
"""
return self.extended_info
+ def get_scripted_frame_plugin(self):
+ """Get scripted frame plugin name.
+
+ Returns:
+ str: Name of the scripted frame plugin.
+ """
+ return None
+
+
+class ScriptedFrame(metaclass=ABCMeta):
+ """
+ The base class for a scripted frame.
+
+ Most of the base class methods are `@abstractmethod` that need to be
+ overwritten by the inheriting class.
+ """
+
+ @abstractmethod
+ def __init__(self, thread, args):
+ """Construct a scripted frame.
+
+ Args:
+ thread (ScriptedThread): The thread owning this frame.
+ args (lldb.SBStructuredData): A Dictionary holding arbitrary
+ key/value pairs used by the scripted frame.
+ """
+ self.target = None
+ self.originating_thread = None
+ self.thread = None
+ self.args = None
+ self.id = None
+ self.name = None
+ self.register_info = None
+ self.register_ctx = {}
+ self.variables = []
+
+ if (
+ isinstance(thread, ScriptedThread)
+ or isinstance(thread, lldb.SBThread)
+ and thread.IsValid()
+ ):
+ self.target = thread.target
+ self.process = thread.process
+ self.originating_thread = thread
+ self.thread = self.process.GetThreadByIndexID(thread.tid)
+ self.get_register_info()
+
+ @abstractmethod
+ def get_id(self):
+ """Get the scripted frame identifier.
+
+ Returns:
+ int: The identifier of the scripted frame in the scripted thread.
+ """
+ pass
+
+ def get_pc(self):
+ """Get the scripted frame address.
+
+ Returns:
+ int: The optional address of the scripted frame in the scripted thread.
+ """
+ return None
+
+ def get_symbol_context(self):
+ """Get the scripted frame symbol context.
+
+ Returns:
+ lldb.SBSymbolContext: The symbol context of the scripted frame in the scripted thread.
+ """
+ return None
+
+ def is_inlined(self):
+ """Check if the scripted frame is inlined.
+
+ Returns:
+ bool: True if scripted frame is inlined. False otherwise.
+ """
+ return False
+
+ def is_artificial(self):
+ """Check if the scripted frame is artificial.
+
+ Returns:
+ bool: True if scripted frame is artificial. False otherwise.
+ """
+ return True
+
+ def is_hidden(self):
+ """Check if the scripted frame is hidden.
+
+ Returns:
+ bool: True if scripted frame is hidden. False otherwise.
+ """
+ return False
+
+ def get_function_name(self):
+ """Get the scripted frame function name.
+
+ Returns:
+ str: The function name of the scripted frame.
+ """
+ return self.name
+
+ def get_display_function_name(self):
+ """Get the scripted frame display function name.
+
+ Returns:
+ str: The display function name of the scripted frame.
+ """
+ return self.get_function_name()
+
+ def get_variables(self, filters):
+ """Get the scripted thread state type.
+
+ Args:
+ filter (lldb.SBVariablesOptions): The filter used to resolve the variables
+ Returns:
+ lldb.SBValueList: The SBValueList containing the SBValue for each resolved variable.
+ Returns None by default.
+ """
+ return None
+
+ def get_register_info(self):
+ if self.register_info is None:
+ self.register_info = self.originating_thread.get_register_info()
+ return self.register_info
+
+ @abstractmethod
+ def get_register_context(self):
+ """Get the scripted thread register context
+
+ Returns:
+ str: A byte representing all register's value.
+ """
+ pass
class PassthroughScriptedProcess(ScriptedProcess):
driving_target = None