Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Debug: Add support for 32-bit on 32-bit under GDB #493

Merged
merged 1 commit into from
Oct 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ OpenCore Changelog
#### v0.9.6
- Updated builtin firmware versions for SMBIOS and the rest
- Fixed hang while generating boot entries on some systems
- Add `efidebug.tool` support for 32-bit on 32-bit using GDB (in addition to existing 32-bit on 64-bit support)

#### v0.9.5
- Fixed GUID formatting for legacy NVRAM saving
Expand Down
33 changes: 29 additions & 4 deletions Debug/efidebug.tool
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,13 @@
# GDB - path to GDB debugger
# defaults to finding in PATH
# EFI_ARCH - architecture to debug
# defaults to X64
# defaults to X64; use EFI_ARCH=Ia32 to debug 32-bit firmware on 64-bit CPU
# CPU_ARCH - CPU architecture of target
# defaults to X64; use CPU_ARCH=Ia32 to debug 32-bit firmware on 32-bit CPU
# GDB_ARCH - GDB `set arch` value
# defaults to correct value for CPU_ARCH
# EFI_PORT - debugger TCP connection port
# defaults to 8864 for X64 and 8832 for IA32
# defaults to 8864 for X64 and 8832 for Ia32
# EFI_HOST - debugger TCP connection host
# defaults to localhost
# EFI_DEBUGGER - debugger to use
Expand All @@ -24,6 +28,8 @@
# defaults to x86_64-apple-macosx for XCODE5, x86_64-pc-windows-msvc for CLANGDWARF/CLANGPDB,
# x86_64-linux-gnu otherwise.
#
# Note: This script's support for 32-bit UEFI debugging on LLDB is incomplete, GDB is recommended in that case.
#

RUNDIR=$(dirname "$0")
pushd "${RUNDIR}" >/dev/null || exit 1
Expand Down Expand Up @@ -60,8 +66,27 @@ choose_debugger() {
find_gdb
find_lldb

if [ "${CPU_ARCH}" = "IA32" ]; then
CPU_ARCH="Ia32"
elif [ "${CPU_ARCH}" = "" ]; then
CPU_ARCH="X64"
fi

if [ "${GDB_ARCH}" = "" ]; then
if [ "${CPU_ARCH}" = "X64" ]; then
GDB_ARCH="i386:x86-64:intel"
else
GDB_ARCH="i386"
fi
fi

if [ "${EFI_ARCH}" = "" ]; then
EFI_ARCH="X64"
EFI_ARCH="${CPU_ARCH}"
elif [ "${EFI_ARCH}" = "IA32" ]; then
EFI_ARCH="Ia32"
elif [ "${CPU_ARCH}" = "Ia32" ] && [ "${EFI_ARCH}" = "X64" ] ; then
echo "Invalid CPU_ARCH/EFI_ARCH combination!"
exit 1
fi

if [ "${EFI_HOST}" = "" ]; then
Expand Down Expand Up @@ -135,7 +160,7 @@ choose_debugger() {
choose_debugger

if [ "${EFI_DEBUGGER}" = "GDB" ] || [ "${EFI_DEBUGGER}" = "gdb" ]; then
"${GDB}" -ex "set arch i386:x86-64:intel" \
"${GDB}" -ex "set arch ${GDB_ARCH}" \
-ex "target remote ${EFI_HOST}:${EFI_PORT}" \
-ex "source Scripts/gdb_uefi.py" \
-ex "set pagination off" \
Expand Down