From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from list by lists.gnu.org with archive (Exim 4.90_1) id 1pFMWO-0004Mt-KL for mharc-grub-devel@gnu.org; Tue, 10 Jan 2023 16:51:04 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pFMWM-0004KD-BF for grub-devel@gnu.org; Tue, 10 Jan 2023 16:51:02 -0500 Received: from mail-pl1-x62f.google.com ([2607:f8b0:4864:20::62f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pFMWJ-0002K8-Qa for grub-devel@gnu.org; Tue, 10 Jan 2023 16:51:01 -0500 Received: by mail-pl1-x62f.google.com with SMTP id d3so14631044plr.10 for ; Tue, 10 Jan 2023 13:50:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=efficientek-com.20210112.gappssmtp.com; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=I3xnBUjt+T2PKhp7VQ/P35QMnrAai9g4bXn3mxfqm0s=; b=LeGPVtKqdKSYFtc7We9aKHR4SkJNXz7kLR7DwM3oWEef7fIgHu2sjJdKfFPYyvD4Ub KUMkcPceBp8gAMBwqqhFO6RcVTnw1NvRIFX9ZcZnkilTRlHOEeLsH9oRf0IKDT+HDxTO cn5FOLnj51dLdqb/cHRKLSrTNWRjnprB5195zkJWCL+APjwt2m/oyD8QUceAt4JOVWjE uZI7ioC51xd1f94ogs1cVPNjlZ8SquUx/JBEp1Q2sPybKOmfmvoKz+mkEzBwGPbkt7wp F7634tYcFzrQOGr+E0WVAx8uB5rdQH1EcvQSGqjnMWTNUO9HcqHcUoGtfcNhKIjPOuwy 2CkQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=I3xnBUjt+T2PKhp7VQ/P35QMnrAai9g4bXn3mxfqm0s=; b=c6WaT58S5swVYOGVd/30/TZhpA5YnxnuNPYKeo+C3IPVTZOPPbP4pJfQVInrJyceCE zY347xPDyYhkSCCboV4q/bnU4zCse+oc3sRZzulAiHtHVGGcDhQq+OxO310/a1JHNEhT oEpoLkttfCdELb4I2PzEXSAbawqRujatBJN+fDhrIZIckFqSmwc1la1aHWqtb20fCQGX B+r/Z9aKFn0n+pbaqrWgbm9KYluONConMDG5VrDTKyFBGwgOBvr3ymgUaNBR7Bovzon8 I8QAik1zaSF54JfbNay5iRNpP7DG2EPMiSW4zDD4CB4OvCRSqFt/Afgl2OiN2FWGj58/ /N7g== X-Gm-Message-State: AFqh2kocaz+mF03oa5OYgjH44EYGBLfolRU9T5oMFGGMFpc6wStpird1 kT78dO9CAaixziZB9kZElJJbcZ4gXj1djwGu X-Google-Smtp-Source: AMrXdXuQiEANB9PzFD8NlmmZWoke8Z4CfQCWb1jifSaI5GakY4nerzgu7VVA68iR1h5uqMkAw3nuWw== X-Received: by 2002:a17:902:c102:b0:192:8e05:1505 with SMTP id 2-20020a170902c10200b001928e051505mr53307430pli.31.1673387457503; Tue, 10 Jan 2023 13:50:57 -0800 (PST) Received: from crass-HP-ZBook-15-G2.lan ([199.254.238.56]) by smtp.gmail.com with ESMTPSA id u15-20020a1709026e0f00b00186c3af9644sm7760798plk.273.2023.01.10.13.50.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Jan 2023 13:50:56 -0800 (PST) From: Glenn Washburn To: grub-devel@gnu.org, Daniel Kiper Cc: Robbie Harwood , Peter Jones , Glenn Washburn Subject: [PATCH v6 00/14] GDB script fixes and improvements Date: Tue, 10 Jan 2023 15:50:27 -0600 Message-Id: <20230110215041.1247699-1-development@efficientek.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Received-SPF: pass client-ip=2607:f8b0:4864:20::62f; envelope-from=development@efficientek.com; helo=mail-pl1-x62f.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: The development of GNU GRUB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 10 Jan 2023 21:51:02 -0000 Update since v5: * Need to declare grub_efi_print_gdb_info() as static and inline, which fixes a compiler error. This series has been substantially rewritten since v4, although a large minority of the patches haven't changed much. The biggest change is that the implementation has been converted to Python instead of what was done in shell script. I have always felt it should be done in Python, but it seemed daunting to learn the Python-GDB API, so the shell script seemed the path of least resistance. I decided to give it a second look and was surprised it wasn't as bad as I thought it would be. Because the python API is so tightly integrated into GDB, there are things you can do with it that either aren't possible or which look like ugly hacks when attempting with the native script. The other big change is that there is a new --enable-efi-debug option to configure which enables the printing of the gdb command for loading the GRUB kernel symbols. This is disallowed when booting with Secure Boot on. There are two ways the GDB command is printed: (1) in early EFI setup and (2) on-demand by a user using the gdbinfo command. There are a couple new features to the GDB script, like a trivial one that changes the gdb prompt and another that allows for software breakpoints to be set before the GRUB image is loaded. This series also incorporates suggestions given for v4 and adds more to the documentation. Glenn Glenn Washburn (14): gdb: Fix redirection issue in dump_module_sections gdb: Prevent wrapping when writing to .segments.tmp gdb: If no modules have been loaded, do not try to load module symbols gdb: Move runtime module loading into runtime_load_module gdb: Conditionally run GDB script logic for dynamically or statically positioned GRUB gdb: Only connect to remote target once when first sourced gdb: Replace module symbol loading implementation with Python one gdb: Add functions to make loading from dynamically positioned targets easier gdb: Add more support for debugging on EFI platforms gdb: Allow running user-defined commands at GRUB start gdb: Fix issue with breakpoints defined before the GRUB image is loaded gdb: Add extra early initialization symbols for i386-pc gdb: Modify gdb prompt when running gdb_grub script docs: Add debugging chapter to development documentation config.h.in | 3 + configure.ac | 11 ++ docs/grub-dev.texi | 233 ++++++++++++++++++++++++++++++++++++ grub-core/Makefile.core.def | 5 +- grub-core/gdb_grub.in | 159 +++++++++++++++--------- grub-core/gdb_helper.py.in | 173 ++++++++++++++++++++++++++ grub-core/gmodule.pl.in | 30 ----- grub-core/kern/efi/debug.c | 40 +++++++ grub-core/kern/efi/efi.c | 4 +- grub-core/kern/efi/init.c | 7 +- include/grub/efi/debug.h | 43 +++++++ include/grub/efi/efi.h | 2 +- 12 files changed, 620 insertions(+), 90 deletions(-) create mode 100644 grub-core/gdb_helper.py.in delete mode 100644 grub-core/gmodule.pl.in create mode 100644 grub-core/kern/efi/debug.c create mode 100644 include/grub/efi/debug.h Range-diff against v5: 1: 9f273b8fa5 = 1: ef2b93c7df gdb: Fix redirection issue in dump_module_sections 2: 85f68a8369 = 2: fafc15ba07 gdb: Prevent wrapping when writing to .segments.tmp 3: 88b3973cdb = 3: 9a8bc8c099 gdb: If no modules have been loaded, do not try to load module symbols 4: 3037c1da91 = 4: 81eef1558d gdb: Move runtime module loading into runtime_load_module 5: f6288016f6 = 5: 835f19b2a3 gdb: Conditionally run GDB script logic for dynamically or statically positioned GRUB 6: da13fbe653 = 6: ea32a6d83e gdb: Only connect to remote target once when first sourced 7: 8e6059955a = 7: 13a5e05cd9 gdb: Replace module symbol loading implementation with Python one 8: 878900d69b = 8: c918d24d35 gdb: Add functions to make loading from dynamically positioned targets easier 9: 036549604d ! 9: fd6d2a3ffd gdb: Add more support for debugging on EFI platforms @@ include/grub/efi/debug.h (new) + +void grub_efi_register_debug_commands (void); + -+void ++static inline void +grub_efi_print_gdb_info (void) +{ +#if PRINT_GDB_SYM_LOAD_CMD 10: 0000959b2f = 10: 649bfc0a4d gdb: Allow running user-defined commands at GRUB start 11: ac9f52b1d9 = 11: 8e9148a32b gdb: Fix issue with breakpoints defined before the GRUB image is loaded 12: eac4405ffb = 12: eb5f1b5d89 gdb: Add extra early initialization symbols for i386-pc 13: e58715e227 = 13: 0e85de3667 gdb: Modify gdb prompt when running gdb_grub script 14: 1979dc664e = 14: d78a1b27f0 docs: Add debugging chapter to development documentation -- 2.34.1