blob: d74ef02dec8591ce603699ae5dbde77bd843e72a [file] [log] [blame]
Yi Kong83283012023-12-13 12:57:00 +09001from abc import ABCMeta, abstractmethod
2
3import lldb
4import json, struct, signal
5
6
7class ScriptedProcess(metaclass=ABCMeta):
8
9 """
10 The base class for a scripted process.
11
12 Most of the base class methods are `@abstractmethod` that need to be
13 overwritten by the inheriting class.
14
15 DISCLAIMER: THIS INTERFACE IS STILL UNDER DEVELOPMENT AND NOT STABLE.
16 THE METHODS EXPOSED MIGHT CHANGE IN THE FUTURE.
17 """
18
19 capabilities = None
20 memory_regions = None
21 loaded_images = None
22 threads = None
23 metadata = None
24
25 @abstractmethod
26 def __init__(self, exe_ctx, args):
27 """Construct a scripted process.
28
29 Args:
30 exe_ctx (lldb.SBExecutionContext): The execution context for the scripted process.
31 args (lldb.SBStructuredData): A Dictionary holding arbitrary
32 key/value pairs used by the scripted process.
33 """
34 target = None
35 self.target = None
36 self.args = None
37 self.arch = None
38 if isinstance(exe_ctx, lldb.SBExecutionContext):
39 target = exe_ctx.target
40 if isinstance(target, lldb.SBTarget) and target.IsValid():
41 self.target = target
42 triple = self.target.triple
43 if triple:
44 self.arch = triple.split("-")[0]
45 self.dbg = target.GetDebugger()
46 if isinstance(args, lldb.SBStructuredData) and args.IsValid():
47 self.args = args
48 self.threads = {}
49 self.loaded_images = []
50 self.metadata = {}
51 self.capabilities = {}
52 self.pid = 42
53
54 def get_capabilities(self):
55 """Get a dictionary containing the process capabilities.
56
57 Returns:
58 Dict[str:bool]: The dictionary of capability, with the capability
59 name as the key and a boolean flag as the value.
60 The dictionary can be empty.
61 """
62 return self.capabilities
63
64 def get_memory_region_containing_address(self, addr):
65 """Get the memory region for the scripted process, containing a
66 specific address.
67
68 Args:
69 addr (int): Address to look for in the scripted process memory
70 regions.
71
72 Returns:
73 lldb.SBMemoryRegionInfo: The memory region containing the address.
74 None if out of bounds.
75 """
76 return None
77
78 def get_threads_info(self):
79 """Get the dictionary describing the process' Scripted Threads.
80
81 Returns:
82 Dict: The dictionary of threads, with the thread ID as the key and
83 a Scripted Thread instance as the value.
84 The dictionary can be empty.
85 """
86 return self.threads
87
88 @abstractmethod
89 def read_memory_at_address(self, addr, size, error):
90 """Get a memory buffer from the scripted process at a certain address,
91 of a certain size.
92
93 Args:
94 addr (int): Address from which we should start reading.
95 size (int): Size of the memory to read.
96 error (lldb.SBError): Error object.
97
98 Returns:
99 lldb.SBData: An `lldb.SBData` buffer with the target byte size and
100 byte order storing the memory read.
101 """
102 pass
103
104 def write_memory_at_address(self, addr, data, error):
105 """Write a buffer to the scripted process memory.
106
107 Args:
108 addr (int): Address from which we should start reading.
109 data (lldb.SBData): An `lldb.SBData` buffer to write to the
110 process memory.
111 error (lldb.SBError): Error object.
112
113 Returns:
114 size (int): Size of the memory to read.
115 """
116 error.SetErrorString(
117 "%s doesn't support memory writes." % self.__class__.__name__
118 )
119 return 0
120
121 def get_loaded_images(self):
122 """Get the list of loaded images for the scripted process.
123
124 ```
125 scripted_image = {
126 uuid = "c6ea2b64-f77c-3d27-9528-74f507b9078b",
127 path = "/usr/lib/dyld"
128 load_addr = 0xbadc0ffee
129 }
130 ```
131
132 Returns:
133 List[scripted_image]: A list of `scripted_image` dictionaries
134 containing for each entry the library UUID or its file path
135 and its load address.
136 None if the list is empty.
137 """
138 return self.loaded_images
139
140 def get_process_id(self):
141 """Get the scripted process identifier.
142
143 Returns:
144 int: The scripted process identifier.
145 """
146 return self.pid
147
148 def launch(self):
149 """Simulate the scripted process launch.
150
151 Returns:
152 lldb.SBError: An `lldb.SBError` with error code 0.
153 """
154 return lldb.SBError()
155
156 def attach(self, attach_info):
157 """Simulate the scripted process attach.
158
159 Args:
160 attach_info (lldb.SBAttachInfo): The information related to the
161 process we're attaching to.
162
163 Returns:
164 lldb.SBError: An `lldb.SBError` with error code 0.
165 """
166 return lldb.SBError()
167
168 def resume(self, should_stop=True):
169 """Simulate the scripted process resume.
170
171 Args:
172 should_stop (bool): If True, resume will also force the process
173 state to stopped after running it.
174
175 Returns:
176 lldb.SBError: An `lldb.SBError` with error code 0.
177 """
178 process = self.target.GetProcess()
179 if not process:
180 error = lldb.SBError()
181 error.SetErrorString("Invalid process.")
182 return error
183
184 process.ForceScriptedState(lldb.eStateRunning)
185 if should_stop:
186 process.ForceScriptedState(lldb.eStateStopped)
187 return lldb.SBError()
188
189 @abstractmethod
190 def is_alive(self):
191 """Check if the scripted process is alive.
192
193 Returns:
194 bool: True if scripted process is alive. False otherwise.
195 """
196 pass
197
198 @abstractmethod
199 def get_scripted_thread_plugin(self):
200 """Get scripted thread plugin name.
201
202 Returns:
203 str: Name of the scripted thread plugin.
204 """
205 return None
206
207 def get_process_metadata(self):
208 """Get some metadata for the scripted process.
209
210 Returns:
211 Dict: A dictionary containing metadata for the scripted process.
212 None if the process as no metadata.
213 """
214 return self.metadata
215
216 def create_breakpoint(self, addr, error):
217 """Create a breakpoint in the scripted process from an address.
218 This is mainly used with interactive scripted process debugging.
219
220 Args:
221 addr (int): Address at which the breakpoint should be set.
222 error (lldb.SBError): Error object.
223
224 Returns:
225 SBBreakpoint: A valid breakpoint object that was created a the specified
226 address. None if the breakpoint creation failed.
227 """
228 error.SetErrorString(
229 "%s doesn't support creating breakpoints." % self.__class__.__name__
230 )
231 return False
232
233
234class ScriptedThread(metaclass=ABCMeta):
235
236 """
237 The base class for a scripted thread.
238
239 Most of the base class methods are `@abstractmethod` that need to be
240 overwritten by the inheriting class.
241
242 DISCLAIMER: THIS INTERFACE IS STILL UNDER DEVELOPMENT AND NOT STABLE.
243 THE METHODS EXPOSED MIGHT CHANGE IN THE FUTURE.
244 """
245
246 @abstractmethod
247 def __init__(self, scripted_process, args):
248 """Construct a scripted thread.
249
250 Args:
251 process (ScriptedProcess): The scripted process owning this thread.
252 args (lldb.SBStructuredData): A Dictionary holding arbitrary
253 key/value pairs used by the scripted thread.
254 """
255 self.target = None
256 self.scripted_process = None
257 self.process = None
258 self.args = None
259 self.idx = 0
260 self.tid = 0
261 self.idx = None
262 self.name = None
263 self.queue = None
264 self.state = None
265 self.stop_reason = None
266 self.register_info = None
267 self.register_ctx = {}
268 self.frames = []
269 self.extended_info = []
270
271 if isinstance(scripted_process, ScriptedProcess):
272 self.target = scripted_process.target
273 self.scripted_process = scripted_process
274 self.process = self.target.GetProcess()
275 self.get_register_info()
276
277 def get_thread_idx(self):
278 """Get the scripted thread index.
279
280 Returns:
281 int: The index of the scripted thread in the scripted process.
282 """
283 return self.idx
284
285 def get_thread_id(self):
286 """Get the scripted thread identifier.
287
288 Returns:
289 int: The identifier of the scripted thread.
290 """
291 return self.tid
292
293 def get_name(self):
294 """Get the scripted thread name.
295
296 Returns:
297 str: The name of the scripted thread.
298 """
299 return self.name
300
301 def get_state(self):
302 """Get the scripted thread state type.
303
304 eStateStopped, ///< Process or thread is stopped and can be examined.
305 eStateRunning, ///< Process or thread is running and can't be examined.
306 eStateStepping, ///< Process or thread is in the process of stepping and can
307 /// not be examined.
308 eStateCrashed, ///< Process or thread has crashed and can be examined.
309
310 Returns:
311 int: The state type of the scripted thread.
312 Returns lldb.eStateStopped by default.
313 """
314 return lldb.eStateStopped
315
316 def get_queue(self):
317 """Get the scripted thread associated queue name.
318 This method is optional.
319
320 Returns:
321 str: The queue name associated with the scripted thread.
322 """
323 return self.queue
324
325 @abstractmethod
326 def get_stop_reason(self):
327 """Get the dictionary describing the stop reason type with some data.
328 This method is optional.
329
330 Returns:
331 Dict: The dictionary holding the stop reason type and the possibly
332 the stop reason data.
333 """
334 pass
335
336 def get_stackframes(self):
337 """Get the list of stack frames for the scripted thread.
338
339 ```
340 scripted_frame = {
341 idx = 0,
342 pc = 0xbadc0ffee
343 }
344 ```
345
346 Returns:
347 List[scripted_frame]: A list of `scripted_frame` dictionaries
348 containing at least for each entry, the frame index and
349 the program counter value for that frame.
350 The list can be empty.
351 """
352 return self.frames
353
354 def get_register_info(self):
355 if self.register_info is None:
356 self.register_info = dict()
357 if self.scripted_process.arch == "x86_64":
358 self.register_info["sets"] = ["General Purpose Registers"]
359 self.register_info["registers"] = INTEL64_GPR
360 elif "arm64" in self.scripted_process.arch:
361 self.register_info["sets"] = ["General Purpose Registers"]
362 self.register_info["registers"] = ARM64_GPR
363 else:
364 raise ValueError("Unknown architecture", self.scripted_process.arch)
365 return self.register_info
366
367 @abstractmethod
368 def get_register_context(self):
369 """Get the scripted thread register context
370
371 Returns:
372 str: A byte representing all register's value.
373 """
374 pass
375
376 def get_extended_info(self):
377 """Get scripted thread extended information.
378
379 Returns:
380 List: A list containing the extended information for the scripted process.
381 None if the thread as no extended information.
382 """
383 return self.extended_info
384
385
386class PassthroughScriptedProcess(ScriptedProcess):
387 driving_target = None
388 driving_process = None
389
390 def __init__(self, exe_ctx, args, launched_driving_process=True):
391 super().__init__(exe_ctx, args)
392
393 self.driving_target = None
394 self.driving_process = None
395
396 self.driving_target_idx = args.GetValueForKey("driving_target_idx")
397 if self.driving_target_idx and self.driving_target_idx.IsValid():
398 idx = self.driving_target_idx.GetUnsignedIntegerValue(42)
399 self.driving_target = self.target.GetDebugger().GetTargetAtIndex(idx)
400
401 if launched_driving_process:
402 self.driving_process = self.driving_target.GetProcess()
403 for driving_thread in self.driving_process:
404 structured_data = lldb.SBStructuredData()
405 structured_data.SetFromJSON(
406 json.dumps(
407 {
408 "driving_target_idx": idx,
409 "thread_idx": driving_thread.GetIndexID(),
410 }
411 )
412 )
413
414 self.threads[
415 driving_thread.GetThreadID()
416 ] = PassthroughScriptedThread(self, structured_data)
417
418 for module in self.driving_target.modules:
419 path = module.file.fullpath
420 load_addr = module.GetObjectFileHeaderAddress().GetLoadAddress(
421 self.driving_target
422 )
423 self.loaded_images.append({"path": path, "load_addr": load_addr})
424
425 def get_memory_region_containing_address(self, addr):
426 mem_region = lldb.SBMemoryRegionInfo()
427 error = self.driving_process.GetMemoryRegionInfo(addr, mem_region)
428 if error.Fail():
429 return None
430 return mem_region
431
432 def read_memory_at_address(self, addr, size, error):
433 data = lldb.SBData()
434 bytes_read = self.driving_process.ReadMemory(addr, size, error)
435
436 if error.Fail():
437 return data
438
439 data.SetDataWithOwnership(
440 error,
441 bytes_read,
442 self.driving_target.GetByteOrder(),
443 self.driving_target.GetAddressByteSize(),
444 )
445
446 return data
447
448 def write_memory_at_address(self, addr, data, error):
449 return self.driving_process.WriteMemory(
450 addr, bytearray(data.uint8.all()), error
451 )
452
453 def get_process_id(self):
454 return self.driving_process.GetProcessID()
455
456 def is_alive(self):
457 return True
458
459 def get_scripted_thread_plugin(self):
460 return f"{PassthroughScriptedThread.__module__}.{PassthroughScriptedThread.__name__}"
461
462
463class PassthroughScriptedThread(ScriptedThread):
464 def __init__(self, process, args):
465 super().__init__(process, args)
466 driving_target_idx = args.GetValueForKey("driving_target_idx")
467 thread_idx = args.GetValueForKey("thread_idx")
468
469 # TODO: Change to Walrus operator (:=) with oneline if assignment
470 # Requires python 3.8
471 val = thread_idx.GetUnsignedIntegerValue()
472 if val is not None:
473 self.idx = val
474
475 self.driving_target = None
476 self.driving_process = None
477 self.driving_thread = None
478
479 # TODO: Change to Walrus operator (:=) with oneline if assignment
480 # Requires python 3.8
481 val = driving_target_idx.GetUnsignedIntegerValue()
482 if val is not None:
483 self.driving_target = self.target.GetDebugger().GetTargetAtIndex(val)
484 self.driving_process = self.driving_target.GetProcess()
485 self.driving_thread = self.driving_process.GetThreadByIndexID(self.idx)
486
487 if self.driving_thread:
488 self.id = self.driving_thread.GetThreadID()
489
490 def get_thread_id(self):
491 return self.id
492
493 def get_name(self):
494 return f"{PassthroughScriptedThread.__name__}.thread-{self.idx}"
495
496 def get_stop_reason(self):
497 stop_reason = {"type": lldb.eStopReasonInvalid, "data": {}}
498
499 if (
500 self.driving_thread
501 and self.driving_thread.IsValid()
502 and self.get_thread_id() == self.driving_thread.GetThreadID()
503 ):
504 stop_reason["type"] = lldb.eStopReasonNone
505
506 # TODO: Passthrough stop reason from driving process
507 if self.driving_thread.GetStopReason() != lldb.eStopReasonNone:
508 if "arm64" in self.scripted_process.arch:
509 stop_reason["type"] = lldb.eStopReasonException
510 stop_reason["data"][
511 "desc"
512 ] = self.driving_thread.GetStopDescription(100)
513 elif self.scripted_process.arch == "x86_64":
514 stop_reason["type"] = lldb.eStopReasonSignal
515 stop_reason["data"]["signal"] = signal.SIGTRAP
516 else:
517 stop_reason["type"] = self.driving_thread.GetStopReason()
518
519 return stop_reason
520
521 def get_register_context(self):
522 if not self.driving_thread or self.driving_thread.GetNumFrames() == 0:
523 return None
524 frame = self.driving_thread.GetFrameAtIndex(0)
525
526 GPRs = None
527 registerSet = frame.registers # Returns an SBValueList.
528 for regs in registerSet:
529 if "general purpose" in regs.name.lower():
530 GPRs = regs
531 break
532
533 if not GPRs:
534 return None
535
536 for reg in GPRs:
537 self.register_ctx[reg.name] = int(reg.value, base=16)
538
539 return struct.pack(f"{len(self.register_ctx)}Q", *self.register_ctx.values())
540
541
542ARM64_GPR = [
543 {
544 "name": "x0",
545 "bitsize": 64,
546 "offset": 0,
547 "encoding": "uint",
548 "format": "hex",
549 "set": 0,
550 "gcc": 0,
551 "dwarf": 0,
552 "generic": "arg0",
553 "alt-name": "arg0",
554 },
555 {
556 "name": "x1",
557 "bitsize": 64,
558 "offset": 8,
559 "encoding": "uint",
560 "format": "hex",
561 "set": 0,
562 "gcc": 1,
563 "dwarf": 1,
564 "generic": "arg1",
565 "alt-name": "arg1",
566 },
567 {
568 "name": "x2",
569 "bitsize": 64,
570 "offset": 16,
571 "encoding": "uint",
572 "format": "hex",
573 "set": 0,
574 "gcc": 2,
575 "dwarf": 2,
576 "generic": "arg2",
577 "alt-name": "arg2",
578 },
579 {
580 "name": "x3",
581 "bitsize": 64,
582 "offset": 24,
583 "encoding": "uint",
584 "format": "hex",
585 "set": 0,
586 "gcc": 3,
587 "dwarf": 3,
588 "generic": "arg3",
589 "alt-name": "arg3",
590 },
591 {
592 "name": "x4",
593 "bitsize": 64,
594 "offset": 32,
595 "encoding": "uint",
596 "format": "hex",
597 "set": 0,
598 "gcc": 4,
599 "dwarf": 4,
600 "generic": "arg4",
601 "alt-name": "arg4",
602 },
603 {
604 "name": "x5",
605 "bitsize": 64,
606 "offset": 40,
607 "encoding": "uint",
608 "format": "hex",
609 "set": 0,
610 "gcc": 5,
611 "dwarf": 5,
612 "generic": "arg5",
613 "alt-name": "arg5",
614 },
615 {
616 "name": "x6",
617 "bitsize": 64,
618 "offset": 48,
619 "encoding": "uint",
620 "format": "hex",
621 "set": 0,
622 "gcc": 6,
623 "dwarf": 6,
624 "generic": "arg6",
625 "alt-name": "arg6",
626 },
627 {
628 "name": "x7",
629 "bitsize": 64,
630 "offset": 56,
631 "encoding": "uint",
632 "format": "hex",
633 "set": 0,
634 "gcc": 7,
635 "dwarf": 7,
636 "generic": "arg7",
637 "alt-name": "arg7",
638 },
639 {
640 "name": "x8",
641 "bitsize": 64,
642 "offset": 64,
643 "encoding": "uint",
644 "format": "hex",
645 "set": 0,
646 "gcc": 8,
647 "dwarf": 8,
648 },
649 {
650 "name": "x9",
651 "bitsize": 64,
652 "offset": 72,
653 "encoding": "uint",
654 "format": "hex",
655 "set": 0,
656 "gcc": 9,
657 "dwarf": 9,
658 },
659 {
660 "name": "x10",
661 "bitsize": 64,
662 "offset": 80,
663 "encoding": "uint",
664 "format": "hex",
665 "set": 0,
666 "gcc": 10,
667 "dwarf": 10,
668 },
669 {
670 "name": "x11",
671 "bitsize": 64,
672 "offset": 88,
673 "encoding": "uint",
674 "format": "hex",
675 "set": 0,
676 "gcc": 11,
677 "dwarf": 11,
678 },
679 {
680 "name": "x12",
681 "bitsize": 64,
682 "offset": 96,
683 "encoding": "uint",
684 "format": "hex",
685 "set": 0,
686 "gcc": 12,
687 "dwarf": 12,
688 },
689 {
690 "name": "x13",
691 "bitsize": 64,
692 "offset": 104,
693 "encoding": "uint",
694 "format": "hex",
695 "set": 0,
696 "gcc": 13,
697 "dwarf": 13,
698 },
699 {
700 "name": "x14",
701 "bitsize": 64,
702 "offset": 112,
703 "encoding": "uint",
704 "format": "hex",
705 "set": 0,
706 "gcc": 14,
707 "dwarf": 14,
708 },
709 {
710 "name": "x15",
711 "bitsize": 64,
712 "offset": 120,
713 "encoding": "uint",
714 "format": "hex",
715 "set": 0,
716 "gcc": 15,
717 "dwarf": 15,
718 },
719 {
720 "name": "x16",
721 "bitsize": 64,
722 "offset": 128,
723 "encoding": "uint",
724 "format": "hex",
725 "set": 0,
726 "gcc": 16,
727 "dwarf": 16,
728 },
729 {
730 "name": "x17",
731 "bitsize": 64,
732 "offset": 136,
733 "encoding": "uint",
734 "format": "hex",
735 "set": 0,
736 "gcc": 17,
737 "dwarf": 17,
738 },
739 {
740 "name": "x18",
741 "bitsize": 64,
742 "offset": 144,
743 "encoding": "uint",
744 "format": "hex",
745 "set": 0,
746 "gcc": 18,
747 "dwarf": 18,
748 },
749 {
750 "name": "x19",
751 "bitsize": 64,
752 "offset": 152,
753 "encoding": "uint",
754 "format": "hex",
755 "set": 0,
756 "gcc": 19,
757 "dwarf": 19,
758 },
759 {
760 "name": "x20",
761 "bitsize": 64,
762 "offset": 160,
763 "encoding": "uint",
764 "format": "hex",
765 "set": 0,
766 "gcc": 20,
767 "dwarf": 20,
768 },
769 {
770 "name": "x21",
771 "bitsize": 64,
772 "offset": 168,
773 "encoding": "uint",
774 "format": "hex",
775 "set": 0,
776 "gcc": 21,
777 "dwarf": 21,
778 },
779 {
780 "name": "x22",
781 "bitsize": 64,
782 "offset": 176,
783 "encoding": "uint",
784 "format": "hex",
785 "set": 0,
786 "gcc": 22,
787 "dwarf": 22,
788 },
789 {
790 "name": "x23",
791 "bitsize": 64,
792 "offset": 184,
793 "encoding": "uint",
794 "format": "hex",
795 "set": 0,
796 "gcc": 23,
797 "dwarf": 23,
798 },
799 {
800 "name": "x24",
801 "bitsize": 64,
802 "offset": 192,
803 "encoding": "uint",
804 "format": "hex",
805 "set": 0,
806 "gcc": 24,
807 "dwarf": 24,
808 },
809 {
810 "name": "x25",
811 "bitsize": 64,
812 "offset": 200,
813 "encoding": "uint",
814 "format": "hex",
815 "set": 0,
816 "gcc": 25,
817 "dwarf": 25,
818 },
819 {
820 "name": "x26",
821 "bitsize": 64,
822 "offset": 208,
823 "encoding": "uint",
824 "format": "hex",
825 "set": 0,
826 "gcc": 26,
827 "dwarf": 26,
828 },
829 {
830 "name": "x27",
831 "bitsize": 64,
832 "offset": 216,
833 "encoding": "uint",
834 "format": "hex",
835 "set": 0,
836 "gcc": 27,
837 "dwarf": 27,
838 },
839 {
840 "name": "x28",
841 "bitsize": 64,
842 "offset": 224,
843 "encoding": "uint",
844 "format": "hex",
845 "set": 0,
846 "gcc": 28,
847 "dwarf": 28,
848 },
849 {
850 "name": "x29",
851 "bitsize": 64,
852 "offset": 232,
853 "encoding": "uint",
854 "format": "hex",
855 "set": 0,
856 "gcc": 29,
857 "dwarf": 29,
858 "generic": "fp",
859 "alt-name": "fp",
860 },
861 {
862 "name": "x30",
863 "bitsize": 64,
864 "offset": 240,
865 "encoding": "uint",
866 "format": "hex",
867 "set": 0,
868 "gcc": 30,
869 "dwarf": 30,
870 "generic": "lr",
871 "alt-name": "lr",
872 },
873 {
874 "name": "sp",
875 "bitsize": 64,
876 "offset": 248,
877 "encoding": "uint",
878 "format": "hex",
879 "set": 0,
880 "gcc": 31,
881 "dwarf": 31,
882 "generic": "sp",
883 "alt-name": "sp",
884 },
885 {
886 "name": "pc",
887 "bitsize": 64,
888 "offset": 256,
889 "encoding": "uint",
890 "format": "hex",
891 "set": 0,
892 "gcc": 32,
893 "dwarf": 32,
894 "generic": "pc",
895 "alt-name": "pc",
896 },
897 {
898 "name": "cpsr",
899 "bitsize": 32,
900 "offset": 264,
901 "encoding": "uint",
902 "format": "hex",
903 "set": 0,
904 "gcc": 33,
905 "dwarf": 33,
906 },
907]
908
909INTEL64_GPR = [
910 {
911 "name": "rax",
912 "bitsize": 64,
913 "offset": 0,
914 "encoding": "uint",
915 "format": "hex",
916 "set": 0,
917 "gcc": 0,
918 "dwarf": 0,
919 },
920 {
921 "name": "rbx",
922 "bitsize": 64,
923 "offset": 8,
924 "encoding": "uint",
925 "format": "hex",
926 "set": 0,
927 "gcc": 3,
928 "dwarf": 3,
929 },
930 {
931 "name": "rcx",
932 "bitsize": 64,
933 "offset": 16,
934 "encoding": "uint",
935 "format": "hex",
936 "set": 0,
937 "gcc": 2,
938 "dwarf": 2,
939 "generic": "arg4",
940 "alt-name": "arg4",
941 },
942 {
943 "name": "rdx",
944 "bitsize": 64,
945 "offset": 24,
946 "encoding": "uint",
947 "format": "hex",
948 "set": 0,
949 "gcc": 1,
950 "dwarf": 1,
951 "generic": "arg3",
952 "alt-name": "arg3",
953 },
954 {
955 "name": "rdi",
956 "bitsize": 64,
957 "offset": 32,
958 "encoding": "uint",
959 "format": "hex",
960 "set": 0,
961 "gcc": 5,
962 "dwarf": 5,
963 "generic": "arg1",
964 "alt-name": "arg1",
965 },
966 {
967 "name": "rsi",
968 "bitsize": 64,
969 "offset": 40,
970 "encoding": "uint",
971 "format": "hex",
972 "set": 0,
973 "gcc": 4,
974 "dwarf": 4,
975 "generic": "arg2",
976 "alt-name": "arg2",
977 },
978 {
979 "name": "rbp",
980 "bitsize": 64,
981 "offset": 48,
982 "encoding": "uint",
983 "format": "hex",
984 "set": 0,
985 "gcc": 6,
986 "dwarf": 6,
987 "generic": "fp",
988 "alt-name": "fp",
989 },
990 {
991 "name": "rsp",
992 "bitsize": 64,
993 "offset": 56,
994 "encoding": "uint",
995 "format": "hex",
996 "set": 0,
997 "gcc": 7,
998 "dwarf": 7,
999 "generic": "sp",
1000 "alt-name": "sp",
1001 },
1002 {
1003 "name": "r8",
1004 "bitsize": 64,
1005 "offset": 64,
1006 "encoding": "uint",
1007 "format": "hex",
1008 "set": 0,
1009 "gcc": 8,
1010 "dwarf": 8,
1011 "generic": "arg5",
1012 "alt-name": "arg5",
1013 },
1014 {
1015 "name": "r9",
1016 "bitsize": 64,
1017 "offset": 72,
1018 "encoding": "uint",
1019 "format": "hex",
1020 "set": 0,
1021 "gcc": 9,
1022 "dwarf": 9,
1023 "generic": "arg6",
1024 "alt-name": "arg6",
1025 },
1026 {
1027 "name": "r10",
1028 "bitsize": 64,
1029 "offset": 80,
1030 "encoding": "uint",
1031 "format": "hex",
1032 "set": 0,
1033 "gcc": 10,
1034 "dwarf": 10,
1035 },
1036 {
1037 "name": "r11",
1038 "bitsize": 64,
1039 "offset": 88,
1040 "encoding": "uint",
1041 "format": "hex",
1042 "set": 0,
1043 "gcc": 11,
1044 "dwarf": 11,
1045 },
1046 {
1047 "name": "r12",
1048 "bitsize": 64,
1049 "offset": 96,
1050 "encoding": "uint",
1051 "format": "hex",
1052 "set": 0,
1053 "gcc": 12,
1054 "dwarf": 12,
1055 },
1056 {
1057 "name": "r13",
1058 "bitsize": 64,
1059 "offset": 104,
1060 "encoding": "uint",
1061 "format": "hex",
1062 "set": 0,
1063 "gcc": 13,
1064 "dwarf": 13,
1065 },
1066 {
1067 "name": "r14",
1068 "bitsize": 64,
1069 "offset": 112,
1070 "encoding": "uint",
1071 "format": "hex",
1072 "set": 0,
1073 "gcc": 14,
1074 "dwarf": 14,
1075 },
1076 {
1077 "name": "r15",
1078 "bitsize": 64,
1079 "offset": 120,
1080 "encoding": "uint",
1081 "format": "hex",
1082 "set": 0,
1083 "gcc": 15,
1084 "dwarf": 15,
1085 },
1086 {
1087 "name": "rip",
1088 "bitsize": 64,
1089 "offset": 128,
1090 "encoding": "uint",
1091 "format": "hex",
1092 "set": 0,
1093 "gcc": 16,
1094 "dwarf": 16,
1095 "generic": "pc",
1096 "alt-name": "pc",
1097 },
1098 {
1099 "name": "rflags",
1100 "bitsize": 64,
1101 "offset": 136,
1102 "encoding": "uint",
1103 "format": "hex",
1104 "set": 0,
1105 "generic": "flags",
1106 "alt-name": "flags",
1107 },
1108 {
1109 "name": "cs",
1110 "bitsize": 64,
1111 "offset": 144,
1112 "encoding": "uint",
1113 "format": "hex",
1114 "set": 0,
1115 },
1116 {
1117 "name": "fs",
1118 "bitsize": 64,
1119 "offset": 152,
1120 "encoding": "uint",
1121 "format": "hex",
1122 "set": 0,
1123 },
1124 {
1125 "name": "gs",
1126 "bitsize": 64,
1127 "offset": 160,
1128 "encoding": "uint",
1129 "format": "hex",
1130 "set": 0,
1131 },
1132]
1133
1134ARM64_GPR = [
1135 {
1136 "name": "x0",
1137 "bitsize": 64,
1138 "offset": 0,
1139 "encoding": "uint",
1140 "format": "hex",
1141 "set": 0,
1142 "gcc": 0,
1143 "dwarf": 0,
1144 "generic": "arg0",
1145 "alt-name": "arg0",
1146 },
1147 {
1148 "name": "x1",
1149 "bitsize": 64,
1150 "offset": 8,
1151 "encoding": "uint",
1152 "format": "hex",
1153 "set": 0,
1154 "gcc": 1,
1155 "dwarf": 1,
1156 "generic": "arg1",
1157 "alt-name": "arg1",
1158 },
1159 {
1160 "name": "x2",
1161 "bitsize": 64,
1162 "offset": 16,
1163 "encoding": "uint",
1164 "format": "hex",
1165 "set": 0,
1166 "gcc": 2,
1167 "dwarf": 2,
1168 "generic": "arg2",
1169 "alt-name": "arg2",
1170 },
1171 {
1172 "name": "x3",
1173 "bitsize": 64,
1174 "offset": 24,
1175 "encoding": "uint",
1176 "format": "hex",
1177 "set": 0,
1178 "gcc": 3,
1179 "dwarf": 3,
1180 "generic": "arg3",
1181 "alt-name": "arg3",
1182 },
1183 {
1184 "name": "x4",
1185 "bitsize": 64,
1186 "offset": 32,
1187 "encoding": "uint",
1188 "format": "hex",
1189 "set": 0,
1190 "gcc": 4,
1191 "dwarf": 4,
1192 "generic": "arg4",
1193 "alt-name": "arg4",
1194 },
1195 {
1196 "name": "x5",
1197 "bitsize": 64,
1198 "offset": 40,
1199 "encoding": "uint",
1200 "format": "hex",
1201 "set": 0,
1202 "gcc": 5,
1203 "dwarf": 5,
1204 "generic": "arg5",
1205 "alt-name": "arg5",
1206 },
1207 {
1208 "name": "x6",
1209 "bitsize": 64,
1210 "offset": 48,
1211 "encoding": "uint",
1212 "format": "hex",
1213 "set": 0,
1214 "gcc": 6,
1215 "dwarf": 6,
1216 "generic": "arg6",
1217 "alt-name": "arg6",
1218 },
1219 {
1220 "name": "x7",
1221 "bitsize": 64,
1222 "offset": 56,
1223 "encoding": "uint",
1224 "format": "hex",
1225 "set": 0,
1226 "gcc": 7,
1227 "dwarf": 7,
1228 "generic": "arg7",
1229 "alt-name": "arg7",
1230 },
1231 {
1232 "name": "x8",
1233 "bitsize": 64,
1234 "offset": 64,
1235 "encoding": "uint",
1236 "format": "hex",
1237 "set": 0,
1238 "gcc": 8,
1239 "dwarf": 8,
1240 },
1241 {
1242 "name": "x9",
1243 "bitsize": 64,
1244 "offset": 72,
1245 "encoding": "uint",
1246 "format": "hex",
1247 "set": 0,
1248 "gcc": 9,
1249 "dwarf": 9,
1250 },
1251 {
1252 "name": "x10",
1253 "bitsize": 64,
1254 "offset": 80,
1255 "encoding": "uint",
1256 "format": "hex",
1257 "set": 0,
1258 "gcc": 10,
1259 "dwarf": 10,
1260 },
1261 {
1262 "name": "x11",
1263 "bitsize": 64,
1264 "offset": 88,
1265 "encoding": "uint",
1266 "format": "hex",
1267 "set": 0,
1268 "gcc": 11,
1269 "dwarf": 11,
1270 },
1271 {
1272 "name": "x12",
1273 "bitsize": 64,
1274 "offset": 96,
1275 "encoding": "uint",
1276 "format": "hex",
1277 "set": 0,
1278 "gcc": 12,
1279 "dwarf": 12,
1280 },
1281 {
1282 "name": "x13",
1283 "bitsize": 64,
1284 "offset": 104,
1285 "encoding": "uint",
1286 "format": "hex",
1287 "set": 0,
1288 "gcc": 13,
1289 "dwarf": 13,
1290 },
1291 {
1292 "name": "x14",
1293 "bitsize": 64,
1294 "offset": 112,
1295 "encoding": "uint",
1296 "format": "hex",
1297 "set": 0,
1298 "gcc": 14,
1299 "dwarf": 14,
1300 },
1301 {
1302 "name": "x15",
1303 "bitsize": 64,
1304 "offset": 120,
1305 "encoding": "uint",
1306 "format": "hex",
1307 "set": 0,
1308 "gcc": 15,
1309 "dwarf": 15,
1310 },
1311 {
1312 "name": "x16",
1313 "bitsize": 64,
1314 "offset": 128,
1315 "encoding": "uint",
1316 "format": "hex",
1317 "set": 0,
1318 "gcc": 16,
1319 "dwarf": 16,
1320 },
1321 {
1322 "name": "x17",
1323 "bitsize": 64,
1324 "offset": 136,
1325 "encoding": "uint",
1326 "format": "hex",
1327 "set": 0,
1328 "gcc": 17,
1329 "dwarf": 17,
1330 },
1331 {
1332 "name": "x18",
1333 "bitsize": 64,
1334 "offset": 144,
1335 "encoding": "uint",
1336 "format": "hex",
1337 "set": 0,
1338 "gcc": 18,
1339 "dwarf": 18,
1340 },
1341 {
1342 "name": "x19",
1343 "bitsize": 64,
1344 "offset": 152,
1345 "encoding": "uint",
1346 "format": "hex",
1347 "set": 0,
1348 "gcc": 19,
1349 "dwarf": 19,
1350 },
1351 {
1352 "name": "x20",
1353 "bitsize": 64,
1354 "offset": 160,
1355 "encoding": "uint",
1356 "format": "hex",
1357 "set": 0,
1358 "gcc": 20,
1359 "dwarf": 20,
1360 },
1361 {
1362 "name": "x21",
1363 "bitsize": 64,
1364 "offset": 168,
1365 "encoding": "uint",
1366 "format": "hex",
1367 "set": 0,
1368 "gcc": 21,
1369 "dwarf": 21,
1370 },
1371 {
1372 "name": "x22",
1373 "bitsize": 64,
1374 "offset": 176,
1375 "encoding": "uint",
1376 "format": "hex",
1377 "set": 0,
1378 "gcc": 22,
1379 "dwarf": 22,
1380 },
1381 {
1382 "name": "x23",
1383 "bitsize": 64,
1384 "offset": 184,
1385 "encoding": "uint",
1386 "format": "hex",
1387 "set": 0,
1388 "gcc": 23,
1389 "dwarf": 23,
1390 },
1391 {
1392 "name": "x24",
1393 "bitsize": 64,
1394 "offset": 192,
1395 "encoding": "uint",
1396 "format": "hex",
1397 "set": 0,
1398 "gcc": 24,
1399 "dwarf": 24,
1400 },
1401 {
1402 "name": "x25",
1403 "bitsize": 64,
1404 "offset": 200,
1405 "encoding": "uint",
1406 "format": "hex",
1407 "set": 0,
1408 "gcc": 25,
1409 "dwarf": 25,
1410 },
1411 {
1412 "name": "x26",
1413 "bitsize": 64,
1414 "offset": 208,
1415 "encoding": "uint",
1416 "format": "hex",
1417 "set": 0,
1418 "gcc": 26,
1419 "dwarf": 26,
1420 },
1421 {
1422 "name": "x27",
1423 "bitsize": 64,
1424 "offset": 216,
1425 "encoding": "uint",
1426 "format": "hex",
1427 "set": 0,
1428 "gcc": 27,
1429 "dwarf": 27,
1430 },
1431 {
1432 "name": "x28",
1433 "bitsize": 64,
1434 "offset": 224,
1435 "encoding": "uint",
1436 "format": "hex",
1437 "set": 0,
1438 "gcc": 28,
1439 "dwarf": 28,
1440 },
1441 {
1442 "name": "x29",
1443 "bitsize": 64,
1444 "offset": 232,
1445 "encoding": "uint",
1446 "format": "hex",
1447 "set": 0,
1448 "gcc": 29,
1449 "dwarf": 29,
1450 "generic": "fp",
1451 "alt-name": "fp",
1452 },
1453 {
1454 "name": "x30",
1455 "bitsize": 64,
1456 "offset": 240,
1457 "encoding": "uint",
1458 "format": "hex",
1459 "set": 0,
1460 "gcc": 30,
1461 "dwarf": 30,
1462 "generic": "lr",
1463 "alt-name": "lr",
1464 },
1465 {
1466 "name": "sp",
1467 "bitsize": 64,
1468 "offset": 248,
1469 "encoding": "uint",
1470 "format": "hex",
1471 "set": 0,
1472 "gcc": 31,
1473 "dwarf": 31,
1474 "generic": "sp",
1475 "alt-name": "sp",
1476 },
1477 {
1478 "name": "pc",
1479 "bitsize": 64,
1480 "offset": 256,
1481 "encoding": "uint",
1482 "format": "hex",
1483 "set": 0,
1484 "gcc": 32,
1485 "dwarf": 32,
1486 "generic": "pc",
1487 "alt-name": "pc",
1488 },
1489 {
1490 "name": "cpsr",
1491 "bitsize": 32,
1492 "offset": 264,
1493 "encoding": "uint",
1494 "format": "hex",
1495 "set": 0,
1496 "gcc": 33,
1497 "dwarf": 33,
1498 },
1499]
1500
1501INTEL64_GPR = [
1502 {
1503 "name": "rax",
1504 "bitsize": 64,
1505 "offset": 0,
1506 "encoding": "uint",
1507 "format": "hex",
1508 "set": 0,
1509 "gcc": 0,
1510 "dwarf": 0,
1511 },
1512 {
1513 "name": "rbx",
1514 "bitsize": 64,
1515 "offset": 8,
1516 "encoding": "uint",
1517 "format": "hex",
1518 "set": 0,
1519 "gcc": 3,
1520 "dwarf": 3,
1521 },
1522 {
1523 "name": "rcx",
1524 "bitsize": 64,
1525 "offset": 16,
1526 "encoding": "uint",
1527 "format": "hex",
1528 "set": 0,
1529 "gcc": 2,
1530 "dwarf": 2,
1531 "generic": "arg4",
1532 "alt-name": "arg4",
1533 },
1534 {
1535 "name": "rdx",
1536 "bitsize": 64,
1537 "offset": 24,
1538 "encoding": "uint",
1539 "format": "hex",
1540 "set": 0,
1541 "gcc": 1,
1542 "dwarf": 1,
1543 "generic": "arg3",
1544 "alt-name": "arg3",
1545 },
1546 {
1547 "name": "rdi",
1548 "bitsize": 64,
1549 "offset": 32,
1550 "encoding": "uint",
1551 "format": "hex",
1552 "set": 0,
1553 "gcc": 5,
1554 "dwarf": 5,
1555 "generic": "arg1",
1556 "alt-name": "arg1",
1557 },
1558 {
1559 "name": "rsi",
1560 "bitsize": 64,
1561 "offset": 40,
1562 "encoding": "uint",
1563 "format": "hex",
1564 "set": 0,
1565 "gcc": 4,
1566 "dwarf": 4,
1567 "generic": "arg2",
1568 "alt-name": "arg2",
1569 },
1570 {
1571 "name": "rbp",
1572 "bitsize": 64,
1573 "offset": 48,
1574 "encoding": "uint",
1575 "format": "hex",
1576 "set": 0,
1577 "gcc": 6,
1578 "dwarf": 6,
1579 "generic": "fp",
1580 "alt-name": "fp",
1581 },
1582 {
1583 "name": "rsp",
1584 "bitsize": 64,
1585 "offset": 56,
1586 "encoding": "uint",
1587 "format": "hex",
1588 "set": 0,
1589 "gcc": 7,
1590 "dwarf": 7,
1591 "generic": "sp",
1592 "alt-name": "sp",
1593 },
1594 {
1595 "name": "r8",
1596 "bitsize": 64,
1597 "offset": 64,
1598 "encoding": "uint",
1599 "format": "hex",
1600 "set": 0,
1601 "gcc": 8,
1602 "dwarf": 8,
1603 "generic": "arg5",
1604 "alt-name": "arg5",
1605 },
1606 {
1607 "name": "r9",
1608 "bitsize": 64,
1609 "offset": 72,
1610 "encoding": "uint",
1611 "format": "hex",
1612 "set": 0,
1613 "gcc": 9,
1614 "dwarf": 9,
1615 "generic": "arg6",
1616 "alt-name": "arg6",
1617 },
1618 {
1619 "name": "r10",
1620 "bitsize": 64,
1621 "offset": 80,
1622 "encoding": "uint",
1623 "format": "hex",
1624 "set": 0,
1625 "gcc": 10,
1626 "dwarf": 10,
1627 },
1628 {
1629 "name": "r11",
1630 "bitsize": 64,
1631 "offset": 88,
1632 "encoding": "uint",
1633 "format": "hex",
1634 "set": 0,
1635 "gcc": 11,
1636 "dwarf": 11,
1637 },
1638 {
1639 "name": "r12",
1640 "bitsize": 64,
1641 "offset": 96,
1642 "encoding": "uint",
1643 "format": "hex",
1644 "set": 0,
1645 "gcc": 12,
1646 "dwarf": 12,
1647 },
1648 {
1649 "name": "r13",
1650 "bitsize": 64,
1651 "offset": 104,
1652 "encoding": "uint",
1653 "format": "hex",
1654 "set": 0,
1655 "gcc": 13,
1656 "dwarf": 13,
1657 },
1658 {
1659 "name": "r14",
1660 "bitsize": 64,
1661 "offset": 112,
1662 "encoding": "uint",
1663 "format": "hex",
1664 "set": 0,
1665 "gcc": 14,
1666 "dwarf": 14,
1667 },
1668 {
1669 "name": "r15",
1670 "bitsize": 64,
1671 "offset": 120,
1672 "encoding": "uint",
1673 "format": "hex",
1674 "set": 0,
1675 "gcc": 15,
1676 "dwarf": 15,
1677 },
1678 {
1679 "name": "rip",
1680 "bitsize": 64,
1681 "offset": 128,
1682 "encoding": "uint",
1683 "format": "hex",
1684 "set": 0,
1685 "gcc": 16,
1686 "dwarf": 16,
1687 "generic": "pc",
1688 "alt-name": "pc",
1689 },
1690 {
1691 "name": "rflags",
1692 "bitsize": 64,
1693 "offset": 136,
1694 "encoding": "uint",
1695 "format": "hex",
1696 "set": 0,
1697 "generic": "flags",
1698 "alt-name": "flags",
1699 },
1700 {
1701 "name": "cs",
1702 "bitsize": 64,
1703 "offset": 144,
1704 "encoding": "uint",
1705 "format": "hex",
1706 "set": 0,
1707 },
1708 {
1709 "name": "fs",
1710 "bitsize": 64,
1711 "offset": 152,
1712 "encoding": "uint",
1713 "format": "hex",
1714 "set": 0,
1715 },
1716 {
1717 "name": "gs",
1718 "bitsize": 64,
1719 "offset": 160,
1720 "encoding": "uint",
1721 "format": "hex",
1722 "set": 0,
1723 },
1724]