Ghidra is a software reverse engineering (SRE) framework
Fixes #6662: Add qemu-gdb option to get all section mappings for target.
Electric Worryaeddb602d76c
diff --git a/Ghidra/Debug/Debugger-agent-gdb/data/debugger-launchers/qemu-gdb.sh b/Ghidra/Debug/Debugger-agent-gdb/data/debugger-launchers/qemu-gdb.shindex 16b6dc4a46..5aa6ad33da 100755--- a/Ghidra/Debug/Debugger-agent-gdb/data/debugger-launchers/qemu-gdb.sh+++ b/Ghidra/Debug/Debugger-agent-gdb/data/debugger-launchers/qemu-gdb.sh@@ -34,6 +34,7 @@#@env OPT_EXTRA_QEMU_ARGS:str="" "Extra qemu arguments" "Extra arguments to pass to qemu. Use with care."#@env OPT_GDB_PATH:file="gdb-multiarch" "gdb command" "The path to gdb. Omit the full path to resolve using the system PATH."#@env OPT_EXTRA_TTY:bool=false "QEMU TTY" "Provide a separate terminal emulator for the target."+#@env OPT_PULL_ALL_SECTIONS:bool=false "Pull all section mappings" "Force gdb to send all mappings to Ghidra. This can be costly (see help)."#@tty TTY_TARGET if env:OPT_EXTRA_TTYif [ -d ${GHIDRA_HOME}/ghidra/.git ]@@ -61,17 +62,31 @@ fi# Give QEMU a moment to open the socketsleep 0.1-"$OPT_GDB_PATH" \- -q \- -ex "set pagination off" \- -ex "set confirm off" \- -ex "show version" \- -ex "python import ghidragdb" \- -ex "file \"$target_image\"" \- -ex "set args $target_args" \- -ex "ghidra trace connect \"$GHIDRA_TRACE_RMI_ADDR\"" \- -ex "ghidra trace start" \- -ex "ghidra trace sync-enable" \- -ex "target remote localhost:$QEMU_GDB" \- -ex "set confirm on" \- -ex "set pagination on"+gdb_args=(+ -q+ -ex "set pagination off"+ -ex "set confirm off"+ -ex "show version"+ -ex "python import ghidragdb"+ -ex "file \"$target_image\""+ -ex "set args $target_args"+ -ex "ghidra trace connect \"$GHIDRA_TRACE_RMI_ADDR\""+ -ex "ghidra trace start"+ -ex "ghidra trace sync-enable"+ -ex "target remote localhost:$QEMU_GDB"+ -ex "set confirm on"+ -ex "set pagination on"+)++# If using OPT_PULL_ALL_SECTIONS, append instructions to push all sections from qemu+if [ "$OPT_PULL_ALL_SECTIONS" = "true" ]+then+ gdb_args+=(+ -ex "ghidra trace tx-start put-all-sections"+ -ex "ghidra trace put-sections -all-objects"+ -ex "ghidra trace tx-commit"+ )+fi++IFS=""+"$OPT_GDB_PATH" ${gdb_args[*]}diff --git a/Ghidra/Debug/Debugger-rmi-trace/src/main/help/help/topics/TraceRmiLauncherServicePlugin/TraceRmiLauncherServicePlugin.html b/Ghidra/Debug/Debugger-rmi-trace/src/main/help/help/topics/TraceRmiLauncherServicePlugin/TraceRmiLauncherServicePlugin.htmlindex 6dd087a1be..c9914a87df 100644--- a/Ghidra/Debug/Debugger-rmi-trace/src/main/help/help/topics/TraceRmiLauncherServicePlugin/TraceRmiLauncherServicePlugin.html+++ b/Ghidra/Debug/Debugger-rmi-trace/src/main/help/help/topics/TraceRmiLauncherServicePlugin/TraceRmiLauncherServicePlugin.html@@ -373,6 +373,13 @@ target remote | ssh user@host gdbserver - /path/to/image<LI><B>QEMU TTY</B>: This works similarly as in GDB, but just runs QEMU in the secondTerminal window.</LI>++ <LI><B>Pull all section mappings</B>: For some targets the memory mappings for the target+ are not correctly relayed to Ghidra. This setting forces gdb to send the mappings to Ghidra.+ This option is disabled by default because for large targets the action could be expensive,+ so it should only be enabled if required (e.g. unable to correctly place breakpoints).+ <I>Auto-Map by Section</I> must be enabled in the Modules debugger window for this to work.+ </LI></UL><H3><A name="gdb_wine"></A>Wine + GDB</H3>