本文整理匯總了Python中pykd.dbgCommand方法的典型用法代碼示例。如果您正苦於以下問題:Python pykd.dbgCommand方法的具體用法?Python pykd.dbgCommand怎麽用?Python pykd.dbgCommand使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類pykd
的用法示例。
在下文中一共展示了pykd.dbgCommand方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: get_addr_list
# 需要導入模塊: import pykd [as 別名]
# 或者: from pykd import dbgCommand [as 別名]
def get_addr_list():
addr_list = []
addr_list.append(pykd.getContext().ip())
for line in pykd.dbgCommand("k").splitlines()[1:]:
skip = False
try:
_, ret_addr, sym = line.split()
ret_addr = int(ret_addr, 16)
except ValueError:
continue
for noise in BLACKLIST_LIBS:
if sym.startswith(noise):
skip = True
break
if skip:
continue
addr_list.append(ret_addr)
addr_list.pop() # remove 0 from the list
return addr_list
示例2: get_proc_run_time
# 需要導入模塊: import pykd [as 別名]
# 或者: from pykd import dbgCommand [as 別名]
def get_proc_run_time():
#Debug session time: Tue Aug 21 16:27:31.971 2012 (UTC - 4:00)
#System Uptime: 5 days 13:06:34.062
#Process Uptime: 0 days 0:00:02.718
#Kernel time: 0 days 0:00:00.000
#User time: 0 days 0:00:00.000
duration = 0
for line in pykd.dbgCommand(".time").splitlines()[-2:]:
line = line.strip().split()
duration += int(line[2]) * 86400 # days
line = line[-1].split('.')
duration += float("0.%s" % line[-1])
line = line[0].split(':')
duration += int(line[0]) * 3600 # hours
duration += int(line[1]) * 60 # minutes
duration += int(line[2]) # seconds
return duration
示例3: requested_mem_size
# 需要導入模塊: import pykd [as 別名]
# 或者: from pykd import dbgCommand [as 別名]
def requested_mem_size():
possible_bp_syms = ["calloc", "malloc", "realloc"]
sym = None
for line in pykd.dbgCommand("kb").splitlines()[1:]:
try:
_, _, arg0, arg1, _, sym = line.split()
arg0 = int(arg0, 16)
arg1 = int(arg1, 16)
sym = sym.split("!")[1].strip()
except (ValueError, IndexError):
continue
if sym in possible_bp_syms:
break
sym = None
if sym == "calloc":
ret_val = arg0 * arg1
elif sym == "malloc":
ret_val = arg0
elif sym == "realloc":
ret_val = arg1
else:
ret_val = 0
return ret_val
示例4: disasmBackward
# 需要導入模塊: import pykd [as 別名]
# 或者: from pykd import dbgCommand [as 別名]
def disasmBackward(self, address, depth):
while True:
cmd2run = "ub 0x%08x L%d" % (address, depth)
try:
disasmlist = pykd.dbgCommand(cmd2run)
disasmLinesTmp = disasmlist.split("\n")
disasmLines = []
for line in disasmLinesTmp:
if line.replace(" ", "") != "":
disasmLines.append(line)
lineindex = len(disasmLines) - depth
if lineindex > -1:
asmline = disasmLines[lineindex]
pointer = asmline[0:8]
return self.getOpcode(hexStrToInt(pointer))
else:
return self.getOpcode(address)
except:
# probably invalid instruction, so fake by returning itself
# caller should check if address is different than what was provided
if depth == 1:
return self.getOpcode(address)
depth -= 1
示例5: setMemBreakpoint
# 需要導入模塊: import pykd [as 別名]
# 或者: from pykd import dbgCommand [as 別名]
def setMemBreakpoint(self, address, memType):
validtype = False
bpcommand = ""
if memType.upper() == "S":
bpcommand = "ba e 1 0x%08x" % address
validtype = True
if memType.upper() == "R":
bpcommand = "ba r 4 0x%08x" % address
validtype = True
if memType.upper() == "W":
bpcommand = "ba w 4 0x%08x" % address
validtype = True
if validtype:
output = ""
try:
output = pykd.dbgCommand(bpcommand)
except:
if memType.upper() == "S":
bpcommand = "bp 0x%08x" % address
output = pykd.dbgCommand(bpcommand)
else:
self.log("** Unable to set memory breakpoint. Check alignment,")
self.log(" and try to run the following command to get more information:")
self.log(" %s" % bpcommand)
示例6: find_symbol
# 需要導入模塊: import pykd [as 別名]
# 或者: from pykd import dbgCommand [as 別名]
def find_symbol(self, address):
name = ''
if not address in self.address_to_symbols:
self.load_address_symbol(address)
if address in self.address_to_symbols:
name = self.address_to_symbols[address]
else:
if self.use_command_mode:
try:
output = pykd.dbgCommand("u %x L1" % address)
except:
output = ''
if output:
output_lines = output.splitlines()
if len(output_lines) >= 0 and output_lines[0].endswith(':'):
name = output_lines[0]
else:
name = pykd.findSymbol(address)
return name
示例7: get_current_stack
# 需要導入模塊: import pykd [as 別名]
# 或者: from pykd import dbgCommand [as 別名]
def get_current_stack():
call_stack = []
for line in pykd.dbgCommand("k").splitlines()[1:]:
try:
_, ret_addr, sym = line.split()
_ = int(ret_addr, 16)
except ValueError:
continue
call_stack.append(sym)
return call_stack
示例8: get_thread_list
# 需要導入模塊: import pykd [as 別名]
# 或者: from pykd import dbgCommand [as 別名]
def get_thread_list():
return pykd.dbgCommand("!runaway").splitlines()[2:]
示例9: set_thread
# 需要導入模塊: import pykd [as 別名]
# 或者: from pykd import dbgCommand [as 別名]
def set_thread(t_id):
pykd.dbgCommand("~%d s" % t_id)
示例10: is_complete
# 需要導入模塊: import pykd [as 別名]
# 或者: from pykd import dbgCommand [as 別名]
def is_complete():
return pykd.dbgCommand(".lastevent").find("Exit process") != -1
示例11: get_bp_hit
# 需要導入模塊: import pykd [as 別名]
# 或者: from pykd import dbgCommand [as 別名]
def get_bp_hit():
tmp_bp = pykd.dbgCommand(".lastevent")
if tmp_bp.find("Hit breakpoint") != -1:
return int(tmp_bp.splitlines()[0].split()[-1])
return None
示例12: find_next_sym
# 需要導入模塊: import pykd [as 別名]
# 或者: from pykd import dbgCommand [as 別名]
def find_next_sym(next_bp, prev_bp, timeout):
iters = 100
found_sym = False
sample_time = 0
set_bp(next_bp, 0, 1)
set_bp(prev_bp, 1, iters)
while not is_complete():
pykd.go()
curr_bp = get_bp_hit()
target_time = get_proc_run_time()
log.debug("target time %0.2f", target_time)
if curr_bp == 1:
if target_time >= timeout:
break
iter_duration = target_time - sample_time
if iter_duration < 0.5: # optimization
if iters < 25600:
iters *= 2
log.debug("iter duration: %0.2f, (x2) prev_bp iters: %d", iter_duration, iters)
elif iter_duration >= 0.5 and iter_duration < 0.85: # optimization
iters += 100
log.debug("iter duration: %0.2f, (+100) prev_bp iters: %d", iter_duration, iters)
set_bp(prev_bp, 1, iters)
elif curr_bp == 0:
found_sym = True
break
else:
log.debug("break not triggered by breakpoint")
if pykd.dbgCommand(".lastevent").find("(!!! second chance !!!)") != -1:
raise RuntimeError("Expected Timeout found Access violation!")
sample_time = target_time
pykd.removeBp(1)
pykd.removeBp(0)
return found_sym
示例13: get_page_size
# 需要導入模塊: import pykd [as 別名]
# 或者: from pykd import dbgCommand [as 別名]
def get_page_size():
return int(pykd.dbgCommand("r $pagesize").split("=")[-1], 16)
示例14: get_pid
# 需要導入模塊: import pykd [as 別名]
# 或者: from pykd import dbgCommand [as 別名]
def get_pid():
return int(pykd.dbgCommand("|").split()[3], 16)
示例15: disasm_around
# 需要導入模塊: import pykd [as 別名]
# 或者: from pykd import dbgCommand [as 別名]
def disasm_around(self):
try:
lines = pykd.dbgCommand("u %s-c L12" % self.pc_register)
for line in lines.split("\n"):
tmp = re.findall("([a-f0-9]{1,}) ([a-f0-9]{2,}) (.*)", line)
if len(tmp) > 0:
line = tmp[0]
addr = line[0]
dis = line[2]
self.crash_data.add_data("disassembly", int(addr, 16), dis)
except:
log("Error in disasm_around: %s" % str(sys.exc_info()[1]))