Merge remote-tracking branch

'origin/GP-5089_Dan_PR-7118_electricworry_issue-6662' (Closes #7118)
This commit is contained in:
Ryan Kurtz 2024-11-04 07:50:04 -05:00
commit b3e421a162
3 changed files with 50 additions and 28 deletions

View File

@ -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[*]}

View File

@ -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')

View File

@ -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 second
Terminal 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>