@@ -243,6 +243,7 @@ def __init__(self, process, args):
243243 key/value pairs used by the scripted thread.
244244 """
245245 self .target = None
246+ self .arch = None
246247 self .originating_process = None
247248 self .process = None
248249 self .args = None
@@ -264,6 +265,9 @@ def __init__(self, process, args):
264265 and process .IsValid ()
265266 ):
266267 self .target = process .target
268+ triple = self .target .triple
269+ if triple :
270+ self .arch = triple .split ("-" )[0 ]
267271 self .originating_process = process
268272 self .process = self .target .GetProcess ()
269273 self .get_register_info ()
@@ -350,17 +354,14 @@ def get_stackframes(self):
350354 def get_register_info (self ):
351355 if self .register_info is None :
352356 self .register_info = dict ()
353- if "x86_64" in self .originating_process . arch :
357+ if "x86_64" in self .arch :
354358 self .register_info ["sets" ] = ["General Purpose Registers" ]
355359 self .register_info ["registers" ] = INTEL64_GPR
356- elif (
357- "arm64" in self .originating_process .arch
358- or self .originating_process .arch == "aarch64"
359- ):
360+ elif "arm64" in self .arch or self .arch == "aarch64" :
360361 self .register_info ["sets" ] = ["General Purpose Registers" ]
361362 self .register_info ["registers" ] = ARM64_GPR
362363 else :
363- raise ValueError ("Unknown architecture" , self .originating_process . arch )
364+ raise ValueError ("Unknown architecture" , self .arch )
364365 return self .register_info
365366
366367 @abstractmethod
@@ -403,11 +404,12 @@ def __init__(self, thread, args):
403404 """Construct a scripted frame.
404405
405406 Args:
406- thread (ScriptedThread): The thread owning this frame.
407+ thread (ScriptedThread/lldb.SBThread ): The thread owning this frame.
407408 args (lldb.SBStructuredData): A Dictionary holding arbitrary
408409 key/value pairs used by the scripted frame.
409410 """
410411 self .target = None
412+ self .arch = None
411413 self .originating_thread = None
412414 self .thread = None
413415 self .args = None
@@ -417,15 +419,17 @@ def __init__(self, thread, args):
417419 self .register_ctx = {}
418420 self .variables = []
419421
420- if (
421- isinstance (thread , ScriptedThread )
422- or isinstance (thread , lldb .SBThread )
423- and thread .IsValid ()
422+ if isinstance (thread , ScriptedThread ) or (
423+ isinstance (thread , lldb .SBThread ) and thread .IsValid ()
424424 ):
425- self .target = thread .target
426425 self .process = thread .process
426+ self .target = self .process .target
427+ triple = self .target .triple
428+ if triple :
429+ self .arch = triple .split ("-" )[0 ]
430+ tid = thread .tid if isinstance (thread , ScriptedThread ) else thread .id
427431 self .originating_thread = thread
428- self .thread = self .process .GetThreadByIndexID (thread . tid )
432+ self .thread = self .process .GetThreadByIndexID (tid )
429433 self .get_register_info ()
430434
431435 @abstractmethod
@@ -506,7 +510,18 @@ def get_variables(self, filters):
506510
507511 def get_register_info (self ):
508512 if self .register_info is None :
509- self .register_info = self .originating_thread .get_register_info ()
513+ if isinstance (self .originating_thread , ScriptedThread ):
514+ self .register_info = self .originating_thread .get_register_info ()
515+ elif isinstance (self .originating_thread , lldb .SBThread ):
516+ self .register_info = dict ()
517+ if "x86_64" in self .arch :
518+ self .register_info ["sets" ] = ["General Purpose Registers" ]
519+ self .register_info ["registers" ] = INTEL64_GPR
520+ elif "arm64" in self .arch or self .arch == "aarch64" :
521+ self .register_info ["sets" ] = ["General Purpose Registers" ]
522+ self .register_info ["registers" ] = ARM64_GPR
523+ else :
524+ raise ValueError ("Unknown architecture" , self .arch )
510525 return self .register_info
511526
512527 @abstractmethod
@@ -640,12 +655,12 @@ def get_stop_reason(self):
640655
641656 # TODO: Passthrough stop reason from driving process
642657 if self .driving_thread .GetStopReason () != lldb .eStopReasonNone :
643- if "arm64" in self .originating_process . arch :
658+ if "arm64" in self .arch :
644659 stop_reason ["type" ] = lldb .eStopReasonException
645660 stop_reason ["data" ]["desc" ] = (
646661 self .driving_thread .GetStopDescription (100 )
647662 )
648- elif self .originating_process . arch == "x86_64" :
663+ elif self .arch == "x86_64" :
649664 stop_reason ["type" ] = lldb .eStopReasonSignal
650665 stop_reason ["data" ]["signal" ] = signal .SIGTRAP
651666 else :
0 commit comments