mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2025-10-05 10:49:34 +02:00
GP-5169: minor edit
GP-5169: stack requires regs update GP-5169: first pass dbgeng GP-5169: fix for gdb GP-5169: fix for lldb
This commit is contained in:
parent
420dd7ce0c
commit
e1f1eb7774
5 changed files with 57 additions and 32 deletions
|
@ -888,7 +888,11 @@ def activate(path=None):
|
||||||
if nthrd is None:
|
if nthrd is None:
|
||||||
path = PROCESS_PATTERN.format(procnum=nproc)
|
path = PROCESS_PATTERN.format(procnum=nproc)
|
||||||
else:
|
else:
|
||||||
path = THREAD_PATTERN.format(procnum=nproc, tnum=nthrd)
|
frame = util.selected_frame()
|
||||||
|
if frame is None:
|
||||||
|
path = THREAD_PATTERN.format(procnum=nproc, tnum=nthrd)
|
||||||
|
else:
|
||||||
|
path = FRAME_PATTERN.format(procnum=nproc, tnum=nthrd, level=frame)
|
||||||
trace.proxy_object_path(path).activate()
|
trace.proxy_object_path(path).activate()
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -140,8 +140,12 @@ def find_thread_by_regs_obj(object):
|
||||||
return find_thread_by_pattern(REGS_PATTERN0, object, "a RegisterValueContainer")
|
return find_thread_by_pattern(REGS_PATTERN0, object, "a RegisterValueContainer")
|
||||||
|
|
||||||
|
|
||||||
|
@util.dbg.eng_thread
|
||||||
def find_frame_by_level(level):
|
def find_frame_by_level(level):
|
||||||
return dbg().backtrace_list()[level]
|
for f in util.dbg._base.backtrace_list():
|
||||||
|
if f.FrameNumber == level:
|
||||||
|
return f
|
||||||
|
#return dbg().backtrace_list()[level]
|
||||||
|
|
||||||
|
|
||||||
def find_frame_by_pattern(pattern, object, err_msg):
|
def find_frame_by_pattern(pattern, object, err_msg):
|
||||||
|
@ -269,13 +273,16 @@ def refresh_threads(node: sch.Schema('ThreadContainer')):
|
||||||
def refresh_stack(node: sch.Schema('Stack')):
|
def refresh_stack(node: sch.Schema('Stack')):
|
||||||
"""Refresh the backtrace for the thread."""
|
"""Refresh the backtrace for the thread."""
|
||||||
tnum = find_thread_by_stack_obj(node)
|
tnum = find_thread_by_stack_obj(node)
|
||||||
|
util.reset_frames()
|
||||||
with commands.open_tracked_tx('Refresh Stack'):
|
with commands.open_tracked_tx('Refresh Stack'):
|
||||||
commands.ghidra_trace_put_frames()
|
commands.ghidra_trace_put_frames()
|
||||||
|
with commands.open_tracked_tx('Refresh Registers'):
|
||||||
|
commands.ghidra_trace_putreg()
|
||||||
|
|
||||||
|
|
||||||
@REGISTRY.method(action='refresh', display='Refresh Registers')
|
@REGISTRY.method(action='refresh', display='Refresh Registers')
|
||||||
def refresh_registers(node: sch.Schema('RegisterValueContainer')):
|
def refresh_registers(node: sch.Schema('RegisterValueContainer')):
|
||||||
"""Refresh the register values for the frame."""
|
"""Refresh the register values for the selected frame"""
|
||||||
tnum = find_thread_by_regs_obj(node)
|
tnum = find_thread_by_regs_obj(node)
|
||||||
with commands.open_tracked_tx('Refresh Registers'):
|
with commands.open_tracked_tx('Refresh Registers'):
|
||||||
commands.ghidra_trace_putreg()
|
commands.ghidra_trace_putreg()
|
||||||
|
@ -314,7 +321,12 @@ def activate_thread(thread: sch.Schema('Thread')):
|
||||||
@REGISTRY.method(action='activate')
|
@REGISTRY.method(action='activate')
|
||||||
def activate_frame(frame: sch.Schema('StackFrame')):
|
def activate_frame(frame: sch.Schema('StackFrame')):
|
||||||
"""Select the frame."""
|
"""Select the frame."""
|
||||||
find_frame_by_obj(frame)
|
f = find_frame_by_obj(frame)
|
||||||
|
util.select_frame(f.FrameNumber)
|
||||||
|
with commands.open_tracked_tx('Refresh Stack'):
|
||||||
|
commands.ghidra_trace_put_frames()
|
||||||
|
with commands.open_tracked_tx('Refresh Registers'):
|
||||||
|
commands.ghidra_trace_putreg()
|
||||||
|
|
||||||
|
|
||||||
@REGISTRY.method(action='delete')
|
@REGISTRY.method(action='delete')
|
||||||
|
|
|
@ -1,17 +1,17 @@
|
||||||
## ###
|
## ###
|
||||||
# IP: GHIDRA
|
# IP: GHIDRA
|
||||||
#
|
#
|
||||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
# you may not use this file except in compliance with the License.
|
# you may not use this file except in compliance with the License.
|
||||||
# You may obtain a copy of the License at
|
# You may obtain a copy of the License at
|
||||||
#
|
#
|
||||||
# http://www.apache.org/licenses/LICENSE-2.0
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
#
|
#
|
||||||
# Unless required by applicable law or agreed to in writing, software
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
# See the License for the specific language governing permissions and
|
# See the License for the specific language governing permissions and
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
##
|
##
|
||||||
from collections import namedtuple
|
from collections import namedtuple
|
||||||
from concurrent.futures import Future
|
from concurrent.futures import Future
|
||||||
|
@ -530,7 +530,12 @@ def select_thread(id: int):
|
||||||
|
|
||||||
@dbg.eng_thread
|
@dbg.eng_thread
|
||||||
def select_frame(id: int):
|
def select_frame(id: int):
|
||||||
return dbg.cmd('.frame 0x{:x}'.format(id))
|
return dbg.cmd('.frame /c {}'.format(id))
|
||||||
|
|
||||||
|
|
||||||
|
@dbg.eng_thread
|
||||||
|
def reset_frames():
|
||||||
|
return dbg.cmd('.cxr')
|
||||||
|
|
||||||
|
|
||||||
@dbg.eng_thread
|
@dbg.eng_thread
|
||||||
|
|
|
@ -1427,6 +1427,8 @@ def put_frames():
|
||||||
f = f.older()
|
f = f.older()
|
||||||
level += 1
|
level += 1
|
||||||
fobj.insert()
|
fobj.insert()
|
||||||
|
robj = STATE.trace.create_object(fpath+".Registers")
|
||||||
|
robj.insert()
|
||||||
STATE.trace.proxy_object_path(STACK_PATTERN.format(
|
STATE.trace.proxy_object_path(STACK_PATTERN.format(
|
||||||
infnum=inf.num, tnum=t.num)).retain_values(keys)
|
infnum=inf.num, tnum=t.num)).retain_values(keys)
|
||||||
|
|
||||||
|
|
|
@ -1,17 +1,17 @@
|
||||||
## ###
|
## ###
|
||||||
# IP: GHIDRA
|
# IP: GHIDRA
|
||||||
#
|
#
|
||||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
# you may not use this file except in compliance with the License.
|
# you may not use this file except in compliance with the License.
|
||||||
# You may obtain a copy of the License at
|
# You may obtain a copy of the License at
|
||||||
#
|
#
|
||||||
# http://www.apache.org/licenses/LICENSE-2.0
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
#
|
#
|
||||||
# Unless required by applicable law or agreed to in writing, software
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
# See the License for the specific language governing permissions and
|
# See the License for the specific language governing permissions and
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
##
|
##
|
||||||
from contextlib import contextmanager
|
from contextlib import contextmanager
|
||||||
import functools
|
import functools
|
||||||
|
@ -26,7 +26,7 @@ import time
|
||||||
try:
|
try:
|
||||||
import psutil
|
import psutil
|
||||||
except ImportError:
|
except ImportError:
|
||||||
print(f"Unable to import 'psutil' - check that it has been installed")
|
print("Unable to import 'psutil' - check that it has been installed")
|
||||||
|
|
||||||
from ghidratrace import sch
|
from ghidratrace import sch
|
||||||
from ghidratrace.client import Client, Address, AddressRange, TraceObject
|
from ghidratrace.client import Client, Address, AddressRange, TraceObject
|
||||||
|
@ -1867,6 +1867,8 @@ def put_frames():
|
||||||
fobj.set_value('Function', str(f.GetFunctionName()))
|
fobj.set_value('Function', str(f.GetFunctionName()))
|
||||||
fobj.set_value('_display', util.get_description(f))
|
fobj.set_value('_display', util.get_description(f))
|
||||||
fobj.insert()
|
fobj.insert()
|
||||||
|
robj = STATE.trace.create_object(fpath+".Registers")
|
||||||
|
robj.insert()
|
||||||
STATE.trace.proxy_object_path(STACK_PATTERN.format(
|
STATE.trace.proxy_object_path(STACK_PATTERN.format(
|
||||||
procnum=proc.GetProcessID(), tnum=t.GetThreadID())).retain_values(keys)
|
procnum=proc.GetProcessID(), tnum=t.GetThreadID())).retain_values(keys)
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue