brintos

brintos / llvm-project-archived public Read only

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