]>
git.saurik.com Git - apple/xnu.git/blob - tools/lldbmacros/usertaskdebugging/target.py
6 """Base interface for process being debugged. Provides basic functions for gdbserver to interact.
7 Create a class object for your backing system to provide functionality
9 Here is the list of must implement functions:
10 + please update hinfo['ostype'] and hinfo['vendor'] if its not in (macosx, ios)
11 + please populate threads_ids_list with ids of threads.
14 - getRegisterDataForThread
18 def __init__(self
, cputype
, cpusubtype
, ptrsize
):
19 super(Process
, self
).__init
__()
21 'cputype': cputype
, 'cpusubtype': cpusubtype
,
22 'triple': None, 'vendor': 'apple', 'ostype': 'macosx',
23 'endian': 'little', 'ptrsize': ptrsize
, 'hostname': None, 'os_build': None,
24 'os_kernel': None, 'os_version': None, 'watchpoint_exceptions_received': None,
25 'default_packet_timeout': '10', 'distribution_id': None
28 ## if cputype is arm assume its ios
29 if (cputype
& 0xc) != 0xc:
30 self
.hinfo
['ostype'] = 'ios'
31 self
.ptrsize
= ptrsize
33 self
.threads_ids_list
= []
35 def getHostInfo(self
):
37 for i
in self
.hinfo
.keys():
38 if self
.hinfo
[i
] is None:
40 retval
+= '%s:%s;' % (str(i
), str(self
.hinfo
[i
]))
43 def getRegisterDataForThread(self
, th_id
, reg_num
):
44 logging
.critical("Not Implemented: getRegisterDataForThread")
47 def readMemory(self
, address
, size
):
48 logging
.critical("readMemory: Not Implemented: readMemory")
49 #E08 means read failed
52 def writeMemory(self
, address
, data
, size
):
53 """ Unimplemented. address in ptr to save data to. data is native endian stream of bytes,
57 def getRegisterInfo(regnum
):
59 #"name:x1;bitsize:64;offset:8;encoding:uint;format:hex;gcc:1;dwarf:1;set:General Purpose Registers;"
60 logging
.critical("getRegisterInfo: Not Implemented: getRegisterInfo")
63 def getProcessInfo(self
):
64 logging
.critical("Not Implemented: qProcessInfo")
67 def getFirstThreadInfo(self
):
68 """ describe all thread ids in the process.
70 thinfo_str
= self
.getThreadsInfo()
72 logging
.warning('getFirstThreadInfo: Process has no threads')
74 return 'm' + thinfo_str
76 def getSubsequestThreadInfo(self
):
77 """ return 'l' for last because all threads are listed in getFirstThreadInfo call.
81 def getSharedLibInfoAddress(self
):
82 """ return int data of a hint where shared library is loaded.
84 logging
.critical("Not Implemented: qShlibInfoAddr")
85 raise NotImplementedError('getSharedLibInfoAddress is not Implemented')
87 def getSignalInfo(self
):
88 # return the signal info in required format.
89 return "T02" + "threads:" + self
.getThreadsInfo() + ';'
91 def getThreadsInfo(self
):
92 """ returns ',' separeted values of thread ids """
95 for tid
in self
.threads_ids_list
:
98 retval
+= self
.encodeThreadID(tid
)
100 retval
+= ',%s' % self
.encodeThreadID(tid
)
103 def getCurrentThreadID(self
):
104 """ returns int thread id of the first stopped thread
105 if subclass supports thread switching etc then
106 make sure to re-implement this funciton
108 if self
.threads_ids_list
:
109 return self
.threads_ids_list
[0]
112 def getThreadStopInfo(self
, th_id
):
113 """ returns stop signal and some thread register info.
115 logging
.critical("getThreadStopInfo: Not Implemented. returning basic info.")
117 return 'T02thread:%s' % self
.encodeThreadID(th_id
)
119 def encodeRegisterData(self
, intdata
, bytesize
=None):
120 """ return an encoded string for unsigned int intdata
121 based on the bytesize and endianness value
124 bytesize
= self
.ptrsize
129 packed_data
= struct
.pack(format
, intdata
)
130 return packed_data
.encode('hex')
132 def encodePointerRegisterData(self
, ptrdata
):
133 """ encodes pointer data based on ptrsize defined for the target """
134 return self
.encodeRegisterData(ptrdata
, bytesize
=self
.ptrsize
)
136 def encodeThreadID(self
, intdata
):
138 return struct
.pack(format
, intdata
).encode('hex')
140 def encodeByteString(self
, bytestr
):
141 return bytestr
.encode('hex')