mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2024-12-03 18:31:46 +00:00
GP-4136: pre review
GP-4136: fix interrupt button GP-4136: fix for duplicates GP-4136: base thread-selected action on last wait status GP-4136: better behavior for dbgeng
This commit is contained in:
parent
1c414dfac5
commit
881dfa2a54
@ -494,7 +494,7 @@ def putreg():
|
||||
value = regs._get_register_by_index(i)
|
||||
try:
|
||||
values.append(mapper.map_value(nproc, name, value))
|
||||
robj.set_value(name, value)
|
||||
robj.set_value(name, hex(value))
|
||||
except Exception:
|
||||
pass
|
||||
return {'missing': STATE.trace.put_registers(space, values)}
|
||||
@ -867,6 +867,12 @@ def put_state(event_process):
|
||||
state = compute_proc_state(event_process)
|
||||
procobj.set_value('_state', state)
|
||||
procobj.insert()
|
||||
tnum = util.selected_thread()
|
||||
if tnum is not None:
|
||||
ipath = THREAD_PATTERN.format(procnum=event_process, tnum=tnum)
|
||||
threadobj = STATE.trace.create_object(ipath)
|
||||
threadobj.set_value('_state', state)
|
||||
threadobj.insert()
|
||||
STATE.require_tx().commit()
|
||||
STATE.reset_tx()
|
||||
|
||||
@ -1334,7 +1340,7 @@ def repl():
|
||||
cmd = input().strip()
|
||||
if not cmd:
|
||||
continue
|
||||
dbg().cmd(cmd, quiet=False)
|
||||
dbg().cmd(cmd, quiet=True)
|
||||
stat = dbg().exec_status()
|
||||
if stat != 'BREAK':
|
||||
dbg().wait()
|
||||
|
@ -36,7 +36,7 @@ class HookState(object):
|
||||
|
||||
|
||||
class ProcessState(object):
|
||||
__slots__ = ('first', 'regions', 'modules', 'threads', 'breaks', 'watches', 'visited')
|
||||
__slots__ = ('first', 'regions', 'modules', 'threads', 'breaks', 'watches', 'visited', 'waiting')
|
||||
|
||||
def __init__(self):
|
||||
self.first = True
|
||||
@ -48,8 +48,10 @@ class ProcessState(object):
|
||||
self.watches = False
|
||||
# For frames and threads that have already been synced since last stop
|
||||
self.visited = set()
|
||||
self.waiting = True
|
||||
|
||||
def record(self, description=None):
|
||||
#print("RECORDING")
|
||||
first = self.first
|
||||
self.first = False
|
||||
if description is not None:
|
||||
@ -72,7 +74,7 @@ class ProcessState(object):
|
||||
hashable_frame = (thread, frame)
|
||||
if first or hashable_frame not in self.visited:
|
||||
self.visited.add(hashable_frame)
|
||||
if first or self.regions or self.threads or self.modules:
|
||||
if first or self.regions:
|
||||
commands.put_regions()
|
||||
self.regions = False
|
||||
if first or self.modules:
|
||||
@ -122,7 +124,6 @@ PROC_STATE = {}
|
||||
|
||||
def on_state_changed(*args):
|
||||
#print("ON_STATE_CHANGED")
|
||||
#print(args[0])
|
||||
if args[0] == DbgEng.DEBUG_CES_CURRENT_THREAD:
|
||||
return on_thread_selected(args)
|
||||
elif args[0] == DbgEng.DEBUG_CES_BREAKPOINTS:
|
||||
@ -131,8 +132,12 @@ def on_state_changed(*args):
|
||||
util.set_convenience_variable('output-radix', args[1])
|
||||
return DbgEng.DEBUG_STATUS_GO
|
||||
elif args[0] == DbgEng.DEBUG_CES_EXECUTION_STATUS:
|
||||
proc = util.selected_process()
|
||||
if args[1] & DbgEng.DEBUG_STATUS_INSIDE_WAIT:
|
||||
PROC_STATE[proc].waiting = True
|
||||
return DbgEng.DEBUG_STATUS_GO
|
||||
PROC_STATE[proc].waiting = False
|
||||
commands.put_state(proc)
|
||||
if args[1] == DbgEng.DEBUG_STATUS_BREAK:
|
||||
return on_stop(args)
|
||||
else:
|
||||
@ -246,8 +251,13 @@ def on_thread_selected(*args):
|
||||
return
|
||||
with commands.STATE.client.batch():
|
||||
with trace.open_tx("Thread {}.{} selected".format(nproc, nthrd)):
|
||||
PROC_STATE[nproc].record()
|
||||
commands.activate()
|
||||
commands.put_state(nproc)
|
||||
state = PROC_STATE[nproc]
|
||||
if state.waiting:
|
||||
state.record_continued()
|
||||
else:
|
||||
state.record()
|
||||
commands.activate()
|
||||
|
||||
|
||||
def on_register_changed(regnum):
|
||||
|
@ -376,7 +376,7 @@ def _continue(process: sch.Schema('Process')):
|
||||
|
||||
|
||||
@REGISTRY.method
|
||||
def interrupt():
|
||||
def interrupt(process: sch.Schema('Process')):
|
||||
"""Interrupt the execution of the debugged program."""
|
||||
dbg()._control.SetInterrupt(DbgEng.DEBUG_INTERRUPT_ACTIVE)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user