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.sh index 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_TTY if [ -d ${GHIDRA_HOME}/ghidra/.git ] @@ -61,17 +62,31 @@ fi # Give QEMU a moment to open the socket sleep 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-agent-gdb/src/main/py/src/ghidragdb/methods.py b/Ghidra/Debug/Debugger-agent-gdb/src/main/py/src/ghidragdb/methods.py index 7d34d33edb..a019d4b160 100644 --- a/Ghidra/Debug/Debugger-agent-gdb/src/main/py/src/ghidragdb/methods.py +++ b/Ghidra/Debug/Debugger-agent-gdb/src/main/py/src/ghidragdb/methods.py @@ -1,17 +1,17 @@ ## ### -# 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. +# 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. ## from concurrent.futures import Future, Executor from contextlib import contextmanager @@ -388,7 +388,7 @@ def refresh_sections(node: sch.Schema('Module')): switch_inferior(find_inf_by_mod_obj(node)) with commands.open_tracked_tx('Refresh Module and Sections'): modname = find_module_name_by_mod_obj(node) - gdb.execute(f'ghidra trace put-sections {modname}') + gdb.execute(f'ghidra trace put-sections "{modname}"') @REGISTRY.method(action='activate') 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.html index 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
  • QEMU TTY: This works similarly as in GDB, but just runs QEMU in the second Terminal window.
  • + +
  • Pull all section mappings: 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). + Auto-Map by Section must be enabled in the Modules debugger window for this to work. +
  • Wine + GDB