mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2026-06-01 09:15:09 +08:00
Merge remote-tracking branch 'origin/GP-5452_d-millar_rr--SQUASHED'
(Closes #3133)
This commit is contained in:
@@ -0,0 +1,72 @@
|
|||||||
|
#!/usr/bin/bash
|
||||||
|
## ###
|
||||||
|
# IP: GHIDRA
|
||||||
|
#
|
||||||
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
# you may not use this file except in compliance with the License.
|
||||||
|
# You may obtain a copy of the License at
|
||||||
|
#
|
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
# See the License for the specific language governing permissions and
|
||||||
|
# limitations under the License.
|
||||||
|
##
|
||||||
|
#@title gdb-rr
|
||||||
|
#@desc <html><body width="300px">
|
||||||
|
#@desc <h3>Launch with <tt>rr/gdb</tt></h3>
|
||||||
|
#@desc <p>
|
||||||
|
#@desc This will open a trace of a target on the local machine using <tt>rr/gdb</tt>.
|
||||||
|
#@desc For setup instructions, press <b>F1</b>.
|
||||||
|
#@desc </p>
|
||||||
|
#@desc </body></html>
|
||||||
|
#@menu-group local
|
||||||
|
#@icon icon.debugger
|
||||||
|
#@help TraceRmiLauncherServicePlugin#gdb_rr
|
||||||
|
#@enum StartCmd:str run start starti
|
||||||
|
#@enum Endian:str auto big little
|
||||||
|
#@arg :file "Trace Dir" "The target trace directory (e.g. .local/share/rr/trace)"
|
||||||
|
#@env OPT_RR_PATH:file="rr" "rr command" "The path to rr. Omit the full path to resolve using the system PATH."
|
||||||
|
#@env OPT_ARCH:str="i386:x86-64" "Architecture" "Target architecture"
|
||||||
|
#@env OPT_ENDIAN:Endian="auto" "Endian" "Target byte order"
|
||||||
|
#@env OPT_EXTRA_TTY:bool=false "Inferior TTY" "Provide a separate terminal emulator for the target."
|
||||||
|
#@tty TTY_TARGET if env:OPT_EXTRA_TTY
|
||||||
|
|
||||||
|
if [ -d ${GHIDRA_HOME}/ghidra/.git ]
|
||||||
|
then
|
||||||
|
export PYTHONPATH=$GHIDRA_HOME/ghidra/Ghidra/Debug/Debugger-agent-gdb/build/pypkg/src:$PYTHONPATH
|
||||||
|
export PYTHONPATH=$GHIDRA_HOME/ghidra/Ghidra/Debug/Debugger-rmi-trace/build/pypkg/src:$PYTHONPATH
|
||||||
|
elif [ -d ${GHIDRA_HOME}/.git ]
|
||||||
|
then
|
||||||
|
export PYTHONPATH=$GHIDRA_HOME/Ghidra/Debug/Debugger-agent-gdb/build/pypkg/src:$PYTHONPATH
|
||||||
|
export PYTHONPATH=$GHIDRA_HOME/Ghidra/Debug/Debugger-rmi-trace/build/pypkg/src:$PYTHONPATH
|
||||||
|
else
|
||||||
|
export PYTHONPATH=$GHIDRA_HOME/Ghidra/Debug/Debugger-agent-gdb/pypkg/src:$PYTHONPATH
|
||||||
|
export PYTHONPATH=$GHIDRA_HOME/Ghidra/Debug/Debugger-rmi-trace/pypkg/src:$PYTHONPATH
|
||||||
|
fi
|
||||||
|
|
||||||
|
target_image="$1"
|
||||||
|
|
||||||
|
# Ghidra will leave TTY_TARGET empty when OPT_EXTRA_TTY is false. Gdb takes empty to mean the same terminal.
|
||||||
|
|
||||||
|
RRINIT=$(mktemp)
|
||||||
|
echo '
|
||||||
|
set pagination off
|
||||||
|
set confirm off
|
||||||
|
set $use_trace="true"
|
||||||
|
show version
|
||||||
|
python import ghidragdb
|
||||||
|
set architecture ' $OPT_ARCH '
|
||||||
|
set endian ' $OPT_ENDIAN '
|
||||||
|
set inferior-tty ' $TTY_TARGET '
|
||||||
|
ghidra trace connect ' $GHIDRA_TRACE_RMI_ADDR '
|
||||||
|
ghidra trace start
|
||||||
|
ghidra trace sync-enable
|
||||||
|
set confirm on
|
||||||
|
set pagination on
|
||||||
|
' > $RRINIT
|
||||||
|
|
||||||
|
"$OPT_RR_PATH" replay -x $RRINIT "$target_image"
|
||||||
|
|
||||||
@@ -520,6 +520,12 @@ def resume(inferior: sch.Schema('Inferior')):
|
|||||||
gdb.execute('continue')
|
gdb.execute('continue')
|
||||||
|
|
||||||
|
|
||||||
|
@REGISTRY.method(action='step_ext', icon='icon.debugger.resume.back', condition=util.IS_TRACE)
|
||||||
|
def resume_back(thread: sch.Schema('Inferior')):
|
||||||
|
"""Continue execution of the inferior backwards."""
|
||||||
|
gdb.execute('reverse-continue')
|
||||||
|
|
||||||
|
|
||||||
# Technically, inferior is not required, but it hints that the affected object
|
# Technically, inferior is not required, but it hints that the affected object
|
||||||
# is the current inferior. This in turn queues the UI to enable or disable the
|
# is the current inferior. This in turn queues the UI to enable or disable the
|
||||||
# button appropriately
|
# button appropriately
|
||||||
@@ -569,6 +575,18 @@ def step_return(thread: sch.Schema('Thread'), value: int=None):
|
|||||||
gdb.execute(f'return {value}')
|
gdb.execute(f'return {value}')
|
||||||
|
|
||||||
|
|
||||||
|
@REGISTRY.method(action='step_ext', icon='icon.debugger.step.back.into', condition=util.IS_TRACE)
|
||||||
|
def step_back_into(thread: sch.Schema('Thread'), n: ParamDesc(int, display='N')=1):
|
||||||
|
"""Step backwards one instruction exactly (reverse-stepi)."""
|
||||||
|
gdb.execute('reverse-stepi')
|
||||||
|
|
||||||
|
|
||||||
|
@REGISTRY.method(action='step_ext', icon='icon.debugger.step.back.over', condition=util.IS_TRACE)
|
||||||
|
def step_back_over(thread: sch.Schema('Thread'), n: ParamDesc(int, display='N')=1):
|
||||||
|
"""Step one instruction backwards, but proceed through subroutine calls (reverse-nexti)."""
|
||||||
|
gdb.execute('reverse-nexti')
|
||||||
|
|
||||||
|
|
||||||
@REGISTRY.method(action='break_sw_execute')
|
@REGISTRY.method(action='break_sw_execute')
|
||||||
def break_sw_execute_address(inferior: sch.Schema('Inferior'), address: Address):
|
def break_sw_execute_address(inferior: sch.Schema('Inferior'), address: Address):
|
||||||
"""Set a breakpoint (break)."""
|
"""Set a breakpoint (break)."""
|
||||||
|
|||||||
@@ -34,6 +34,7 @@ def _compute_gdb_ver():
|
|||||||
|
|
||||||
|
|
||||||
GDB_VERSION = _compute_gdb_ver()
|
GDB_VERSION = _compute_gdb_ver()
|
||||||
|
IS_TRACE = gdb.convenience_variable('use_trace').string() == "true"
|
||||||
|
|
||||||
MODULES_CMD_V8 = 'maintenance info sections ALLOBJ'
|
MODULES_CMD_V8 = 'maintenance info sections ALLOBJ'
|
||||||
MODULES_CMD_V11 = 'maintenance info sections -all-objects'
|
MODULES_CMD_V11 = 'maintenance info sections -all-objects'
|
||||||
|
|||||||
+16
@@ -525,6 +525,22 @@ target remote [host]:[port]
|
|||||||
<TT>gdb-multiarch</TT>.</LI>
|
<TT>gdb-multiarch</TT>.</LI>
|
||||||
</UL>
|
</UL>
|
||||||
|
|
||||||
|
<H3><A name="gdb_rr"></A>rr + GDB</H3>
|
||||||
|
|
||||||
|
<P>This launcher runs <TT>rr</TT> in a <TT>gdb</TT> session on Linux for replaying rr-generated traces.</P>
|
||||||
|
|
||||||
|
|
||||||
|
<H4>Options</H4>
|
||||||
|
|
||||||
|
<UL>
|
||||||
|
<LI><B>Trace Dir</B>: This is the path to the trace directory, stored by default in the user's home
|
||||||
|
directory in <TT>.local/share/rr/target_name</TT>.</LI>
|
||||||
|
|
||||||
|
<LI><B><TT>rr</TT> command</B>: This is the command or path to <TT>rr</TT>.</LI>
|
||||||
|
|
||||||
|
<LI><B>Other options are the same as in GDB.</LI>
|
||||||
|
</UL>
|
||||||
|
|
||||||
<H2>Stock LLDB Launchers</H2>
|
<H2>Stock LLDB Launchers</H2>
|
||||||
|
|
||||||
<P>The following launchers based on the LLDB Debugger are included out of the box:</P>
|
<P>The following launchers based on the LLDB Debugger are included out of the box:</P>
|
||||||
|
|||||||
Reference in New Issue
Block a user