Python源码示例:gdb.selected_frame()
示例1
def get_contents(self):
str = ''
str += Strongdb.border_header('Backtrace')
frame = gdb.selected_frame()
while frame != None:
str += '\t%s -> %s()\n' % (Strongdb.colorize(hex(frame.pc())[:-1], Colors.address_color),
frame.name() if frame.name() != None else '??')
older_frm = frame.older()
if older_frm == None:
str += Strongdb.colorize('\t' + gdb.frame_stop_reason_string(frame.unwind_stop_reason()),
Colors.address_color)
frame = older_frm
str += Strongdb.border_footer()
return str
示例2
def stop(self):
rdi = gdb.selected_frame().read_register('rdi') #XXX
return False
if rdi == 0 or rdi == ZERO_SIZE_PTR or rdi == 0x40000000: #XXX
return False
cache = rdi.cast(gdb.lookup_type('struct kmem_cache').pointer()).dereference()
cache = cache['name'].string()
name, pid = get_task_info()
if apply_filter(name, cache):
trace_info = 'kfree is freeing an object from cache ' + cache + ' on behalf of process "' + name + '", pid ' + str(pid)
salt_print(trace_info)
history.append(('kfree', cache, name, pid))
return False
示例3
def get_selected_frame(cls):
_gdbframe = gdb.selected_frame()
if _gdbframe:
return Frame(_gdbframe)
return None
示例4
def get_selected_frame(cls):
_gdbframe = gdb.selected_frame()
if _gdbframe:
return Frame(_gdbframe)
return None
示例5
def get_selected_frame(cls):
_gdbframe = gdb.selected_frame()
if _gdbframe:
return Frame(_gdbframe)
return None
示例6
def invoke(self, arg, from_tty):
print ("\n********************************************************************************")
print ("Displaying blocking threads using 'blocked' command")
threads = {}
for process in gdb.inferiors():
for thread in process.threads():
trd = Thread()
trd.threadId = thread.ptid[1] #[1] - threadId; [0] - process pid
#print ("Thread: {0}".format(threads[-1].threadId))
thread.switch()
frame = gdb.selected_frame()
while frame:
frame.select()
#print(" {0}".format(frame.name()))
if "pthread_mutex_lock" in frame.name():
trd.waitOnThread = int(gdb.execute("print mutex.__data.__owner", to_string=True).split()[2])
#print(threads[-1].waitOnThread)
trd.frames.append(frame.name())
frame = frame.older()
threads[trd.threadId] = trd
for (tid,thread) in threads.items():
if thread.waitOnThread:
deadlockedText = "" if not threads[thread.waitOnThread].waitOnThread == thread.threadId else "AND DEADLOCKED"
print ("Thread: {0} waits for thread: {1} {2}".format(thread.threadId, thread.waitOnThread, deadlockedText))
print ("********************************************************************************")
示例7
def stop(self):
kfreeFinishBP(internal=True)
#x = gdb.selected_frame().read_var('x')
#trace_info = 'freeing object at address ' + str(x)
return False
示例8
def stop(self):
s = gdb.selected_frame().read_var('s')
name, pid = get_task_info()
cache = s['name'].string()
if apply_filter(name, cache):
trace_info = 'kmem_cache_alloc is accessing cache ' + cache + ' on behalf of process "' + name + '", pid ' + str(pid)
#trace_info += '\nreturning object at address ' + str(tohex(ret, 64))
salt_print(trace_info)
history.append(('kmem_cache_alloc', cache, name, pid))
return False
示例9
def stop(self):
s = gdb.selected_frame().read_var('s')
x = gdb.selected_frame().read_var('x')
name, pid = get_task_info()
cache = s['name'].string()
if apply_filter(name, cache):
trace_info = 'kmem_cache_free is freeing from cache ' + cache + ' on behalf of process "' + name + '", pid ' + str(pid)
#trace_info += '\nfreeing object at address ' + str(x)
salt_print(trace_info)
history.append(('kmem_cache_free', cache, name, pid))
return False
示例10
def stop(self):
s = gdb.selected_frame().read_var('s')
name, pid = get_task_info()
cache = s['name'].string()
if apply_filter(name, cache):
trace_info = 'a new slab is being created for ' + cache + ' on behalf of process "' + name + '", pid ' + str(pid)
salt_print('\033[91m'+trace_info+'\033[0m')
history.append(('new_slab', cache, name, pid))
return False
示例11
def get_contents(self):
str = ""
str += Strongdb.border_header('Assembly')
if Strongdb.is_arm_mode():
length_per_ins = 4
else:
length_per_ins = 2
frame = gdb.selected_frame()
instructions = frame.architecture().disassemble(frame.pc() - 4 * length_per_ins, count=10)
self.load_jni_native_table()
for ins in instructions:
if frame.pc() == ins['addr']:
str += Strongdb.colorize('-->\t' + hex(ins['addr'])[:-1] + ':\t', Colors.address_color)
str += Strongdb.colorize(self.get_machine_code(ins['asm']), Colors.code_highlight_color)
jni_func = ""
# get JNIEnv pointer
jni_env_addr = self.get_jni_env_addr()
# check blx rx
if jni_env_addr != 0 and ins['asm'].lower().startswith('blx\tr'):
reg = ins['asm'][4:]
called_addr = Strongdb.run_cmd('i r $' + reg).split(None)[1]
# if the address is in JniNativeInterface address table
if self.jni_env.func_address[called_addr] != None:
jni_func = "; " + self.jni_env.func_address[called_addr]
str += Strongdb.colorize(ins['asm'] + '\t' + Strongdb.colorize(jni_func, 'yellow'),
Colors.code_highlight_color) + '\n'
else:
str += Strongdb.colorize('\t' + hex(ins['addr'])[:-1] + ':\t', Colors.address_color)
str += Strongdb.colorize(self.get_machine_code(ins['asm']), Colors.code_color)
str += Strongdb.colorize(ins['asm'], Colors.code_color) + '\n'
str += Strongdb.border_footer()
return str