Merge remote-tracking branch

'origin/GP-5538_Dan_addImageFieldToRemotes--SQUASHED' (Closes #7955)
This commit is contained in:
Ryan Kurtz
2025-04-04 13:20:28 -04:00
22 changed files with 341 additions and 171 deletions
@@ -4,7 +4,7 @@ Module.manifest||GHIDRA||||END|
README.md||GHIDRA||||END|
data/debugger-launchers/local-gdb.bat||GHIDRA||||END|
data/debugger-launchers/qemu-sys-gdb.bat||GHIDRA||||END|
data/debugger-launchers/remote-gdb.bat||GHIDRA||||END|
data/debugger-launchers/remote-gdb.ps1||GHIDRA||||END|
data/debugger-launchers/ssh-gdb.bat||GHIDRA||||END|
data/debugger-launchers/ssh-gdbserver.bat||GHIDRA||||END|
data/scripts/fallback_info_proc_mappings.gdb||GHIDRA||||END|
@@ -1,4 +1,4 @@
#!/usr/bin/bash
#!/usr/bin/env bash
## ###
# IP: GHIDRA
#
@@ -1,4 +1,4 @@
#!/usr/bin/bash
#!/usr/bin/env bash
## ###
# IP: GHIDRA
#
@@ -1,4 +1,4 @@
#!/usr/bin/bash
#!/usr/bin/env bash
## ###
# IP: GHIDRA
#
@@ -66,32 +66,27 @@ fi
# Give QEMU a moment to open the socket
sleep 0.1
gdb_args=(
-q
-ex "set pagination off"
-ex "set confirm off"
-ex "show version"
-ex "python import ghidragdb"
-ex "set architecture $OPT_ARCH"
-ex "set endian $OPT_ENDIAN"
-ex "file \"$target_image\""
-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"
)
declare -a args
# If using OPT_PULL_ALL_SECTIONS, append instructions to push all sections from qemu
args+=(-q)
args+=(-ex "set pagination off")
args+=(-ex "set confirm off")
args+=(-ex "show version")
args+=(-ex "python import ghidragdb")
args+=(-ex "set architecture $OPT_ARCH")
args+=(-ex "set endian $OPT_ENDIAN")
args+=(-ex "file '$target_image'")
args+=(-ex "ghidra trace connect '$GHIDRA_TRACE_RMI_ADDR'")
args+=(-ex "ghidra trace start")
args+=(-ex "ghidra trace sync-enable")
args+=(-ex "target remote localhost:$QEMU_GDB")
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"
)
args+=(-ex "ghidra trace tx-start put-all-sections")
args+=(-ex "ghidra trace put-sections -all-objects")
args+=(-ex "ghidra trace tx-commit")
fi
args+=(-ex "set confirm on")
args+=(-ex "set pagination on")
IFS=""
"$OPT_GDB_PATH" ${gdb_args[*]}
"$OPT_GDB_PATH" "${args[@]}"
@@ -1,4 +1,4 @@
#!/usr/bin/bash
#!/usr/bin/env bash
## ###
# IP: GHIDRA
#
@@ -1,49 +0,0 @@
::@title remote gdb
::@desc <html><body width="300px">
::@desc <h3>Launch with local <tt>gdb</tt> and connect to a stub (e.g., <tt>gdbserver</tt>)</h3>
::@desc <p>
::@desc This will start <tt>gdb</tt> on the local system and then use it to connect to the remote system.
::@desc For setup instructions, press <b>F1</b>.
::@desc </p>
::@desc </body></html>
::@menu-group remote
::@icon icon.debugger
::@help gdb#remote
::@enum TargetType:str remote extended-remote
::@enum Endian:str auto big little
::@env OPT_TARGET_TYPE:TargetType="remote" "Target" "The type of remote target"
::@env OPT_HOST:str="localhost" "Host" "The hostname of the target"
::@env OPT_PORT:int=9999 "Port" "The host's listening port"
::@env OPT_GDB_PATH:file="gdb" "gdb command" "The path to gdb on the local system. Omit the full path to resolve using the system PATH."
::@env OPT_ARCH:str="auto" "Architecture" "Target architecture override"
::@env OPT_ENDIAN:Endian="auto" "Endian" "Target byte order"
@echo off
set PYTHONPATH0=%GHIDRA_HOME%\Ghidra\Debug\Debugger-agent-gdb\pypkg\src
set PYTHONPATH1=%GHIDRA_HOME%\Ghidra\Debug\Debugger-rmi-trace\pypkg\src
IF EXIST %GHIDRA_HOME%\.git (
set PYTHONPATH0=%GHIDRA_HOME%\Ghidra\Debug\Debugger-agent-gdb\build\pypkg\src
set PYTHONPATH1=%GHIDRA_HOME%\Ghidra\Debug\Debugger-rmi-trace\build\pypkg\src
)
IF EXIST %GHIDRA_HOME%\ghidra\.git (
set PYTHONPATH0=%GHIDRA_HOME%\ghidra\Ghidra\Debug\Debugger-agent-gdb\build\pypkg\src
set PYTHONPATH1=%GHIDRA_HOME%\ghidra\Ghidra\Debug\Debugger-rmi-trace\build\pypkg\src
)
set PYTHONPATH=%PYTHONPATH1%;%PYTHONPATH0%;%PYTHONPATH%
"%OPT_GDB_PATH%" ^
-q ^
-ex "set pagination off" ^
-ex "set confirm off" ^
-ex "show version" ^
-ex "python import ghidragdb" ^
-ex "set architecture %OPT_ARCH%" ^
ex "set endian %OPT_ENDIAN%" ^
-ex "echo Connecting to %OPT_HOST%:%OPT_PORT%... " ^
-ex "target %OPT_TARGET_TYPE% %OPT_HOST%:%OPT_PORT%" ^
-ex "ghidra trace connect '%GHIDRA_TRACE_RMI_ADDR%'" ^
-ex "ghidra trace start" ^
-ex "ghidra trace sync-enable" ^
-ex "ghidra trace sync-synth-stopped" ^
-ex "set confirm on" ^
-ex "set pagination on"
@@ -0,0 +1,61 @@
#@title remote gdb
#@image-opt arg:1
#@desc <html><body width="300px">
#@desc <h3>Launch with local <tt>gdb</tt> and connect to a stub (e.g., <tt>gdbserver</tt>)</h3>
#@desc <p>
#@desc This will start <tt>gdb</tt> on the local system and then use it to connect to the remote system.
#@desc For setup instructions, press <b>F1</b>.
#@desc </p>
#@desc </body></html>
#@menu-group remote
#@icon icon.debugger
#@help gdb#remote
#@enum TargetType:str remote extended-remote
#@enum Endian:str auto big little
#@arg :file "Image" "The target binary executable image (a copy on the local system)"
#@env OPT_TARGET_TYPE:TargetType="remote" "Target" "The type of remote target"
#@env OPT_HOST:str="localhost" "Host" "The hostname of the target"
#@env OPT_PORT:int=9999 "Port" "The host's listening port"
#@env OPT_GDB_PATH:file="gdb" "gdb command" "The path to gdb on the local system. Omit the full path to resolve using the system PATH."
#@env OPT_ARCH:str="auto" "Architecture" "Target architecture override"
#@env OPT_ENDIAN:Endian="auto" "Endian" "Target byte order"
[IO.DirectoryInfo] $repo = "$Env:GHIDRA_HOME\.git"
[IO.DirectoryInfo] $repoParent = "$Env:GHIDRA_HOME\ghidra\.git"
if ($repo.Exists) {
$pypathGdb = "$Env:GHIDRA_HOME\Ghidra\Debug\Debugger-agent-gdb\build\pypkg\src"
$pypathTrace = "$Env:GHIDRA_HOME\Ghidra\Debug\Debugger-rmi-trace\build\pypkg\src"
}
elseif ($repoParent.Exists) {
$pypathGdb = "$Env:GHIDRA_HOME\ghidra\Ghidra\Debug\Debugger-agent-gdb\build\pypkg\src"
$pypathTrace = "$Env:GHIDRA_HOME\ghidra\Ghidra\Debug\Debugger-rmi-trace\build\pypkg\src"
}
else {
$pypathGdb = "$Env:GHIDRA_HOME\Ghidra\Debug\Debugger-agent-gdb\pypkg\src"
$pypathTrace = "$Env:GHIDRA_HOME\Ghidra\Debug\Debugger-rmi-trace\pypkg\src"
}
$Env:PYTHONPATH = "$pypathGdb;$pypathTrace;$Env:PYTHONPATH"
$arglist = @()
$arglist+=("-q")
$arglist+=("-ex", "`"set pagination off`"")
$arglist+=("-ex", "`"set confirm off`"")
$arglist+=("-ex", "`"show version`"")
$arglist+=("-ex", "`"python import ghidragdb`"")
$arglist+=("-ex", "`"set architecture $Env:OPT_ARCH`"")
$arglist+=("-ex", "`"set endian $Env:OPT_ENDIAN`"")
if ("$($args[0])" -ne "") {
$image = $args[0] -replace "\\", "\\\\"
$arglist+=("-ex", "`"file '$image'`"")
}
$arglist+=("-ex", "`"echo Connecting to $Env:OPT_HOST`:$Env:OPT_PORT... `"")
$arglist+=("-ex", "`"target $Env:OPT_TARGET_TYPE $Env:OPT_HOST`:$Env:OPT_PORT`"")
$arglist+=("-ex", "`"ghidra trace connect '$Env:GHIDRA_TRACE_RMI_ADDR'`"")
$arglist+=("-ex", "`"ghidra trace start`"")
$arglist+=("-ex", "`"ghidra trace sync-enable`"")
$arglist+=("-ex", "`"ghidra trace sync-synth-stopped`"")
$arglist+=("-ex", "`"set confirm on`"")
$arglist+=("-ex", "`"set pagination on`"")
Start-Process -FilePath $Env:OPT_GDB_PATH -ArgumentList $arglist -NoNewWindow -Wait
@@ -15,6 +15,7 @@
# limitations under the License.
##
#@title remote gdb
#@image-opt arg:1
#@desc <html><body width="300px">
#@desc <h3>Launch with local <tt>gdb</tt> and connect to a stub (e.g., <tt>gdbserver</tt>)</h3>
#@desc <p>
@@ -27,6 +28,7 @@
#@help gdb#remote
#@enum TargetType:str remote extended-remote
#@enum Endian:str auto big little
#@arg :file "Image" "The target binary executable image (a copy on the local system)"
#@env OPT_TARGET_TYPE:TargetType="remote" "Target" "The type of remote target"
#@env OPT_HOST:str="localhost" "Host" "The hostname of the target"
#@env OPT_PORT:int=9999 "Port" "The host's listening port"
@@ -47,19 +49,26 @@ else
export PYTHONPATH=$GHIDRA_HOME/Ghidra/Debug/Debugger-rmi-trace/pypkg/src:$PYTHONPATH
fi
"$OPT_GDB_PATH" \
-q \
-ex "set pagination off" \
-ex "set confirm off" \
-ex "show version" \
-ex "python import ghidragdb" \
-ex "set architecture $OPT_ARCH" \
-ex "set endian $OPT_ENDIAN" \
-ex "echo Connecting to $OPT_HOST:$OPT_PORT... " \
-ex "target $OPT_TARGET_TYPE $OPT_HOST:$OPT_PORT" \
-ex "ghidra trace connect \"$GHIDRA_TRACE_RMI_ADDR\"" \
-ex "ghidra trace start" \
-ex "ghidra trace sync-enable" \
-ex "ghidra trace sync-synth-stopped" \
-ex "set confirm on" \
-ex "set pagination on"
declare -a args
args+=(-q)
args+=(-ex "set pagination off")
args+=(-ex "set confirmation off")
args+=(-ex "show version")
args+=(-ex "python import ghidragdb")
args+=(-ex "set architecture $OPT_ARCH")
args+=(-ex "set endian $OPT_ENDIAN")
if [ -n "$1" ]
then
args+=(-ex "file '$1'")
fi
args+=(-ex "echo Connecting to $OPT_HOST:$OPT_PORT...")
args+=(-ex "target $OPT_TARGET_TYPE $OPT_HOST:$OPT_PORT")
args+=(-ex "ghidra trace connect '$GHIDRA_TRACE_RMI_ADDR'")
args+=(-ex "ghidra trace start")
args+=(-ex "ghidra trace sync-enable")
args+=(-ex "ghidra trace sync-synth-stopped")
args+=(-ex "set confirm on")
args+=(-ex "set pagination on")
"$OPT_GDB_PATH" "${args[@]}"
@@ -1,4 +1,4 @@
#!/usr/bin/bash
#!/usr/bin/env bash
## ###
# IP: GHIDRA
#
@@ -1,4 +1,4 @@
#!/usr/bin/bash
#!/usr/bin/env bash
## ###
# IP: GHIDRA
#
@@ -1,4 +1,4 @@
#!/usr/bin/bash
#!/usr/bin/env bash
## ###
# IP: GHIDRA
#