mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2025-10-05 02:39:44 +02: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
3 changed files with 24 additions and 8 deletions
|
@ -494,7 +494,7 @@ def putreg():
|
||||||
value = regs._get_register_by_index(i)
|
value = regs._get_register_by_index(i)
|
||||||
try:
|
try:
|
||||||
values.append(mapper.map_value(nproc, name, value))
|
values.append(mapper.map_value(nproc, name, value))
|
||||||
robj.set_value(name, value)
|
robj.set_value(name, hex(value))
|
||||||
except Exception:
|
except Exception:
|
||||||
pass
|
pass
|
||||||
return {'missing': STATE.trace.put_registers(space, values)}
|
return {'missing': STATE.trace.put_registers(space, values)}
|
||||||
|
@ -867,6 +867,12 @@ def put_state(event_process):
|
||||||
state = compute_proc_state(event_process)
|
state = compute_proc_state(event_process)
|
||||||
procobj.set_value('_state', state)
|
procobj.set_value('_state', state)
|
||||||
procobj.insert()
|
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.require_tx().commit()
|
||||||
STATE.reset_tx()
|
STATE.reset_tx()
|
||||||
|
|
||||||
|
@ -1334,7 +1340,7 @@ def repl():
|
||||||
cmd = input().strip()
|
cmd = input().strip()
|
||||||
if not cmd:
|
if not cmd:
|
||||||
continue
|
continue
|
||||||
dbg().cmd(cmd, quiet=False)
|
dbg().cmd(cmd, quiet=True)
|
||||||
stat = dbg().exec_status()
|
stat = dbg().exec_status()
|
||||||
if stat != 'BREAK':
|
if stat != 'BREAK':
|
||||||
dbg().wait()
|
dbg().wait()
|
||||||
|
|
|
@ -36,7 +36,7 @@ class HookState(object):
|
||||||
|
|
||||||
|
|
||||||
class ProcessState(object):
|
class ProcessState(object):
|
||||||
__slots__ = ('first', 'regions', 'modules', 'threads', 'breaks', 'watches', 'visited')
|
__slots__ = ('first', 'regions', 'modules', 'threads', 'breaks', 'watches', 'visited', 'waiting')
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.first = True
|
self.first = True
|
||||||
|
@ -48,8 +48,10 @@ class ProcessState(object):
|
||||||
self.watches = False
|
self.watches = False
|
||||||
# For frames and threads that have already been synced since last stop
|
# For frames and threads that have already been synced since last stop
|
||||||
self.visited = set()
|
self.visited = set()
|
||||||
|
self.waiting = True
|
||||||
|
|
||||||
def record(self, description=None):
|
def record(self, description=None):
|
||||||
|
#print("RECORDING")
|
||||||
first = self.first
|
first = self.first
|
||||||
self.first = False
|
self.first = False
|
||||||
if description is not None:
|
if description is not None:
|
||||||
|
@ -72,7 +74,7 @@ class ProcessState(object):
|
||||||
hashable_frame = (thread, frame)
|
hashable_frame = (thread, frame)
|
||||||
if first or hashable_frame not in self.visited:
|
if first or hashable_frame not in self.visited:
|
||||||
self.visited.add(hashable_frame)
|
self.visited.add(hashable_frame)
|
||||||
if first or self.regions or self.threads or self.modules:
|
if first or self.regions:
|
||||||
commands.put_regions()
|
commands.put_regions()
|
||||||
self.regions = False
|
self.regions = False
|
||||||
if first or self.modules:
|
if first or self.modules:
|
||||||
|
@ -122,7 +124,6 @@ PROC_STATE = {}
|
||||||
|
|
||||||
def on_state_changed(*args):
|
def on_state_changed(*args):
|
||||||
#print("ON_STATE_CHANGED")
|
#print("ON_STATE_CHANGED")
|
||||||
#print(args[0])
|
|
||||||
if args[0] == DbgEng.DEBUG_CES_CURRENT_THREAD:
|
if args[0] == DbgEng.DEBUG_CES_CURRENT_THREAD:
|
||||||
return on_thread_selected(args)
|
return on_thread_selected(args)
|
||||||
elif args[0] == DbgEng.DEBUG_CES_BREAKPOINTS:
|
elif args[0] == DbgEng.DEBUG_CES_BREAKPOINTS:
|
||||||
|
@ -131,8 +132,12 @@ def on_state_changed(*args):
|
||||||
util.set_convenience_variable('output-radix', args[1])
|
util.set_convenience_variable('output-radix', args[1])
|
||||||
return DbgEng.DEBUG_STATUS_GO
|
return DbgEng.DEBUG_STATUS_GO
|
||||||
elif args[0] == DbgEng.DEBUG_CES_EXECUTION_STATUS:
|
elif args[0] == DbgEng.DEBUG_CES_EXECUTION_STATUS:
|
||||||
|
proc = util.selected_process()
|
||||||
if args[1] & DbgEng.DEBUG_STATUS_INSIDE_WAIT:
|
if args[1] & DbgEng.DEBUG_STATUS_INSIDE_WAIT:
|
||||||
|
PROC_STATE[proc].waiting = True
|
||||||
return DbgEng.DEBUG_STATUS_GO
|
return DbgEng.DEBUG_STATUS_GO
|
||||||
|
PROC_STATE[proc].waiting = False
|
||||||
|
commands.put_state(proc)
|
||||||
if args[1] == DbgEng.DEBUG_STATUS_BREAK:
|
if args[1] == DbgEng.DEBUG_STATUS_BREAK:
|
||||||
return on_stop(args)
|
return on_stop(args)
|
||||||
else:
|
else:
|
||||||
|
@ -246,7 +251,12 @@ def on_thread_selected(*args):
|
||||||
return
|
return
|
||||||
with commands.STATE.client.batch():
|
with commands.STATE.client.batch():
|
||||||
with trace.open_tx("Thread {}.{} selected".format(nproc, nthrd)):
|
with trace.open_tx("Thread {}.{} selected".format(nproc, nthrd)):
|
||||||
PROC_STATE[nproc].record()
|
commands.put_state(nproc)
|
||||||
|
state = PROC_STATE[nproc]
|
||||||
|
if state.waiting:
|
||||||
|
state.record_continued()
|
||||||
|
else:
|
||||||
|
state.record()
|
||||||
commands.activate()
|
commands.activate()
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -376,7 +376,7 @@ def _continue(process: sch.Schema('Process')):
|
||||||
|
|
||||||
|
|
||||||
@REGISTRY.method
|
@REGISTRY.method
|
||||||
def interrupt():
|
def interrupt(process: sch.Schema('Process')):
|
||||||
"""Interrupt the execution of the debugged program."""
|
"""Interrupt the execution of the debugged program."""
|
||||||
dbg()._control.SetInterrupt(DbgEng.DEBUG_INTERRUPT_ACTIVE)
|
dbg()._control.SetInterrupt(DbgEng.DEBUG_INTERRUPT_ACTIVE)
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue