GP-4906: Implement @image-opt. Have local-gdb use it. Fix 'null'.

This commit is contained in:
Dan
2024-10-31 11:50:38 -04:00
parent e476b20476
commit d5a25fa6a3
31 changed files with 497 additions and 462 deletions

View File

@@ -1,4 +1,5 @@
::@title lldb
::@image-opt arg:1
::@desc <html><body width="300px">
::@desc <h3>Launch with <tt>lldb</tt></h3>
::@desc <p>
@@ -14,8 +15,6 @@
::@args "Arguments" "Command-line arguments to pass to the target"
::@env OPT_LLDB_PATH:file="lldb" "lldb command" "The path to lldb. Omit the full path to resolve using the system PATH."
::@env OPT_START_CMD:StartCmd="process launch" "Run command" "The lldb command to actually run the target."
::@env OPT_EXTRA_TTY:bool=false "Target TTY" "Provide a separate terminal emulator for the target."
::@tty TTY_TARGET if env:OPT_EXTRA_TTY
@echo off
set PYTHONPATH0=%GHIDRA_HOME%\Ghidra\Debug\Debugger-agent-gdb\pypkg\src
@@ -38,17 +37,21 @@ IF DEFINED target_args (
argspart=-o "settings set target.run-args %target_args%"
)
IF DEFINED TARGET_TTY (
ttypart=-o "settings set target.output-path %TTY_TARGET%" -o "settings set target.input-path $TTY_TARGET"
IF "%target_image%"=="" (
"%OPT_LLDB_PATH%" ^
-o "version" ^
-o "script import ghidralldb" ^
-o "ghidra trace connect %GHIDRA_TRACE_RMI_ADDR%" ^
-o "ghidra trace start" ^
-o "ghidra trace sync-enable" ^
) ELSE (
"%OPT_LLDB_PATH%" ^
-o "version" ^
-o "script import ghidralldb" ^
-o "target create %target_image%" ^
%argspart% ^
-o "ghidra trace connect %GHIDRA_TRACE_RMI_ADDR%" ^
-o "ghidra trace start" ^
-o "ghidra trace sync-enable" ^
-o "%OPT_START_CMD%"
)
"%OPT_LLDB_PATH%" ^
-o "version" ^
-o "script import ghidralldb" ^
-o "target create %target_image%" ^
%argspart% ^
%ttypart% ^
-o "ghidra trace connect %GHIDRA_TRACE_RMI_ADDR%" ^
-o "ghidra trace start" ^
-o "ghidra trace sync-enable" ^
-o "%OPT_START_CMD%"

View File

@@ -1,20 +1,21 @@
#!/usr/bin/env 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.
# 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 lldb
#@image-opt arg:1
#@desc <html><body width="300px">
#@desc <h3>Launch with <tt>lldb</tt></h3>
#@desc <p>
@@ -64,13 +65,24 @@ else
ttypart=-o "settings set target.output-path $TTY_TARGET" -o "settings set target.input-path $TTY_TARGET"
fi
"$OPT_LLDB_PATH" \
-o "version" \
-o "script import ghidralldb" \
-o "target create \"$target_image\"" \
$argspart \
$ttypart \
-o "ghidra trace connect \"$GHIDRA_TRACE_RMI_ADDR\"" \
-o "ghidra trace start" \
-o "ghidra trace sync-enable" \
-o "$OPT_START_CMD"
if [ -z "$target_image" ]
then
"$OPT_LLDB_PATH" \
-o "version" \
-o "script import ghidralldb" \
$ttypart \
-o "ghidra trace connect \"$GHIDRA_TRACE_RMI_ADDR\"" \
-o "ghidra trace start" \
-o "ghidra trace sync-enable"
else
"$OPT_LLDB_PATH" \
-o "version" \
-o "script import ghidralldb" \
-o "target create \"$target_image\"" \
$argspart \
$ttypart \
-o "ghidra trace connect \"$GHIDRA_TRACE_RMI_ADDR\"" \
-o "ghidra trace start" \
-o "ghidra trace sync-enable" \
-o "$OPT_START_CMD"
fi

View File

@@ -1,21 +1,20 @@
#!/usr/bin/env 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.
# 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 remote lldb
#@no-image
#@desc <html><body width="300px">
#@desc <h3>Launch with local <tt>lldb</tt> and connect to a stub (e.g., <tt>gdbserver</tt>)</h3>
#@desc <p>
@@ -59,5 +58,4 @@ fi
-o "ghidra trace connect \"$GHIDRA_TRACE_RMI_ADDR\"" \
-o "ghidra trace start" \
-o "ghidra trace sync-enable" \
-o "ghidra trace sync-synth-stopped"
-o "ghidra trace sync-synth-stopped"