@@ -245,6 +245,7 @@ def __init__(self, process, args):
245245 key/value pairs used by the scripted thread.
246246 """
247247 self .target = None
248+ self .arch = None
248249 self .originating_process = None
249250 self .process = None
250251 self .args = None
@@ -266,6 +267,9 @@ def __init__(self, process, args):
266267 and process .IsValid ()
267268 ):
268269 self .target = process .target
270+ triple = self .target .triple
271+ if triple :
272+ self .arch = triple .split ("-" )[0 ]
269273 self .originating_process = process
270274 self .process = self .target .GetProcess ()
271275 self .get_register_info ()
@@ -352,17 +356,14 @@ def get_stackframes(self):
352356 def get_register_info (self ):
353357 if self .register_info is None :
354358 self .register_info = dict ()
355- if "x86_64" in self .originating_process . arch :
359+ if "x86_64" in self .arch :
356360 self .register_info ["sets" ] = ["General Purpose Registers" ]
357361 self .register_info ["registers" ] = INTEL64_GPR
358- elif (
359- "arm64" in self .originating_process .arch
360- or self .originating_process .arch == "aarch64"
361- ):
362+ elif "arm64" in self .arch or self .arch == "aarch64" :
362363 self .register_info ["sets" ] = ["General Purpose Registers" ]
363364 self .register_info ["registers" ] = ARM64_GPR
364365 else :
365- raise ValueError ("Unknown architecture" , self .originating_process . arch )
366+ raise ValueError ("Unknown architecture" , self .arch )
366367 return self .register_info
367368
368369 @abstractmethod
@@ -405,11 +406,12 @@ def __init__(self, thread, args):
405406 """Construct a scripted frame.
406407
407408 Args:
408- thread (ScriptedThread): The thread owning this frame.
409+ thread (ScriptedThread/lldb.SBThread ): The thread owning this frame.
409410 args (lldb.SBStructuredData): A Dictionary holding arbitrary
410411 key/value pairs used by the scripted frame.
411412 """
412413 self .target = None
414+ self .arch = None
413415 self .originating_thread = None
414416 self .thread = None
415417 self .args = None
@@ -419,15 +421,17 @@ def __init__(self, thread, args):
419421 self .register_ctx = {}
420422 self .variables = []
421423
422- if (
423- isinstance (thread , ScriptedThread )
424- or isinstance (thread , lldb .SBThread )
425- and thread .IsValid ()
424+ if isinstance (thread , ScriptedThread ) or (
425+ isinstance (thread , lldb .SBThread ) and thread .IsValid ()
426426 ):
427- self .target = thread .target
428427 self .process = thread .process
428+ self .target = self .process .target
429+ triple = self .target .triple
430+ if triple :
431+ self .arch = triple .split ("-" )[0 ]
432+ tid = thread .tid if isinstance (thread , ScriptedThread ) else thread .id
429433 self .originating_thread = thread
430- self .thread = self .process .GetThreadByIndexID (thread . tid )
434+ self .thread = self .process .GetThreadByIndexID (tid )
431435 self .get_register_info ()
432436
433437 @abstractmethod
@@ -508,7 +512,18 @@ def get_variables(self, filters):
508512
509513 def get_register_info (self ):
510514 if self .register_info is None :
511- self .register_info = self .originating_thread .get_register_info ()
515+ if isinstance (self .originating_thread , ScriptedThread ):
516+ self .register_info = self .originating_thread .get_register_info ()
517+ elif isinstance (self .originating_thread , lldb .SBThread ):
518+ self .register_info = dict ()
519+ if "x86_64" in self .arch :
520+ self .register_info ["sets" ] = ["General Purpose Registers" ]
521+ self .register_info ["registers" ] = INTEL64_GPR
522+ elif "arm64" in self .arch or self .arch == "aarch64" :
523+ self .register_info ["sets" ] = ["General Purpose Registers" ]
524+ self .register_info ["registers" ] = ARM64_GPR
525+ else :
526+ raise ValueError ("Unknown architecture" , self .arch )
512527 return self .register_info
513528
514529 @abstractmethod
@@ -642,12 +657,12 @@ def get_stop_reason(self):
642657
643658 # TODO: Passthrough stop reason from driving process
644659 if self .driving_thread .GetStopReason () != lldb .eStopReasonNone :
645- if "arm64" in self .originating_process . arch :
660+ if "arm64" in self .arch :
646661 stop_reason ["type" ] = lldb .eStopReasonException
647662 stop_reason ["data" ]["desc" ] = (
648663 self .driving_thread .GetStopDescription (100 )
649664 )
650- elif self .originating_process . arch == "x86_64" :
665+ elif self .arch == "x86_64" :
651666 stop_reason ["type" ] = lldb .eStopReasonSignal
652667 stop_reason ["data" ]["signal" ] = signal .SIGTRAP
653668 else :
0 commit comments