From 0d18e0f790fbc10e0f10530557da4c8d282cca00 Mon Sep 17 00:00:00 2001 From: Mike Beaton Date: Thu, 26 Oct 2023 22:44:19 +0100 Subject: [PATCH] Debug: Add support for 32-bit on 32-bit under GDB (#493) In addition to existing support for 32-bit on 64-bit --- Changelog.md | 1 + Debug/efidebug.tool | 33 +++++++++++++++++++++++++++++---- 2 files changed, 30 insertions(+), 4 deletions(-) diff --git a/Changelog.md b/Changelog.md index de3b144acc99..3079f3ac2ec7 100644 --- a/Changelog.md +++ b/Changelog.md @@ -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 diff --git a/Debug/efidebug.tool b/Debug/efidebug.tool index 97a3f2a21d2b..aa73cab663e4 100755 --- a/Debug/efidebug.tool +++ b/Debug/efidebug.tool @@ -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 @@ -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 @@ -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 @@ -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" \