From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from list by lists.gnu.org with archive (Exim 4.90_1) id 1p63IN-0003Ho-I1 for mharc-grub-devel@gnu.org; Fri, 16 Dec 2022 00:30:07 -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 1p63IM-0003H5-5g for grub-devel@gnu.org; Fri, 16 Dec 2022 00:30:06 -0500 Received: from mail-pl1-x62d.google.com ([2607:f8b0:4864:20::62d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1p63IJ-0003lh-Pk for grub-devel@gnu.org; Fri, 16 Dec 2022 00:30:05 -0500 Received: by mail-pl1-x62d.google.com with SMTP id d7so1247450pll.9 for ; Thu, 15 Dec 2022 21:30:03 -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=vo8KoF2msg3U4MPQJMvuIHshDhfsnfxCEAQxSuaasME=; b=2toKWoiFZ6sEJYmv2PRAP9MVywC/0hNuuF3N9wGKP5qZvoqWRSfGcNYwbCTl1lDXA3 vNGTVu26TaGCLDjJsjv9w7vrK3182YYvIUqQo424Kdl9t6avBRjXOIOzzBPe2Bks0NJ6 CxfDqst/DvXpPWwXuqbydzvLiZ9EvcKgOw9C0WNMl+0+0YTlCNWC2cy/ZEKKF+igBmXY cfU/xdgONgN9jrTuynaFTKtnInLuL6WxWlbRWilOMP/NTtIq4wCrNhJVBe9MebpBZTn+ xHlmG2B/FykRsUyXyXC72juSyQvZsPgWlqF375CgcdNqCCbLB+dojUsZI4mEWWtGPuHh 3EBQ== 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=vo8KoF2msg3U4MPQJMvuIHshDhfsnfxCEAQxSuaasME=; b=xzoh18QK1D9rYbLfVUJ4XDsNkCFkEbjcUg1n6IqeHm9sj/h/FV9xFUB6zFvTGiJo7K sq9cU2P58OcVzIBoxLrA/wWYY0O5t1BlVkFWDCON3LzxwixkQaCDKJh0AWtA47M0tY4k gz+eaVSVAD9BHHgq/wONRwsx9Exu4LzsoDmTgFwG1ouu8LdoZNRRiE1ioqe1KZa3caH7 20VYFyx1uXbw+DBhZzEmSdy+Gw5IEBDXQkEOviupu9QD4VBqPyVah8IiM1FifWtARr+5 yFBV/SpzHbYHUVF37616hTJMNQCgQoE2J9RLZFGTGPoAzkIWR+Zea7CQ687lfp4fDbQR RZdQ== X-Gm-Message-State: ANoB5pk+R6SZlQRBqBjANTu9U+6cK6tKLPVoe7tc1cwiHtqx52s0EFZO Pai5+F/ka+ZkNqENcd3MHI+yWL5L4cR3aj0c X-Google-Smtp-Source: AA0mqf7bYnOFse+7LKty4Im8HhOBknPIaCE45ukavx77rrRsQq+yFheDQyOpdMqLT9AvFv6ko/RBrQ== X-Received: by 2002:a17:902:cf4c:b0:189:d696:63e2 with SMTP id e12-20020a170902cf4c00b00189d69663e2mr36181755plg.39.1671168600875; Thu, 15 Dec 2022 21:30:00 -0800 (PST) Received: from crass-HP-ZBook-15-G2.lan ([37.218.244.251]) by smtp.gmail.com with ESMTPSA id u4-20020a17090341c400b00187033cac81sm577714ple.145.2022.12.15.21.29.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Dec 2022 21:29:59 -0800 (PST) From: Glenn Washburn To: "grub-devel @ gnu . org" , Daniel Kiper Cc: Glenn Washburn Subject: [PATCH v4 00/15] GDB script fixes and improvements Date: Thu, 15 Dec 2022 23:29:23 -0600 Message-Id: <20221216052938.224564-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::62d; envelope-from=development@efficientek.com; helo=mail-pl1-x62d.google.com X-Spam_score_int: 14 X-Spam_score: 1.4 X-Spam_bar: + X-Spam_report: (1.4 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_SBL_CSS=3.335, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no 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: Fri, 16 Dec 2022 05:30:06 -0000 v4 changes: * Fix issue where load_all_modules was only loading the last already loaded module. * Drastically simply runtime_load_module by using hardware break instead of software break. The previous work around didn't seem to be reliable on QEMU either. * Move early initialization symbol loading for i386-pc into its own patch v3 changes: * Rebase on to latest master * Use correct automake macro for target cpu There's been a lot of changes since v1. There are more fixes and more features. The majority of the shell code has been moved to an external file named gdb_helper.sh, instead of being inline in the GDB script. The one (direct) PERL dependency in GRUB has been removed and converted to shell script. Also a section on debugging is added to the developer docs. Glenn Glenn Washburn (15): 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: Reliably load modules in runtime_load_module gdb: Add functions to make loading from dynamically positioned targets easier gdb: Remove Perl dependency for GRUB GDB script gdb: If enabled, print line used to load EFI kernel symbols when using gdb_grub script gdb: Conditionally run GDB script logic for dynamically or statically positioned GRUB gdb: Only connect to remote target once when first sourced gdb: Allow user defined "onload_" command to be run when module is loaded gdb: Allow running user-defined commands at GRUB start gdb: Add extra early initialization symbols for i386-pc gdb: Add ability to turn on shell tracing for gdb helper script docs: Add debugging chapter to development documentation config.h.in | 3 + docs/grub-dev.texi | 191 ++++++++++++++++++++++++++++++++++++ grub-core/Makefile.core.def | 4 +- grub-core/gdb_grub.in | 162 +++++++++++++++++++++++++----- grub-core/gdb_helper.sh.in | 108 ++++++++++++++++++++ grub-core/gmodule.pl.in | 30 ------ grub-core/kern/efi/efi.c | 4 +- grub-core/kern/efi/init.c | 19 +++- include/grub/efi/efi.h | 2 +- 9 files changed, 465 insertions(+), 58 deletions(-) create mode 100644 grub-core/gdb_helper.sh.in delete mode 100644 grub-core/gmodule.pl.in Range-diff against v3: 1: ec2b71c403 ! 1: 9f273b8fa5 gdb: Fix redirection issue in dump_module_sections @@ Commit message which does the redirection and undoes the redirection when it finishes regardless of any errors in the command. + Also, remove .segments.tmp file prior to loading modules in case one was + left from a previous run. + ## grub-core/gdb_grub.in ## @@ ### @@ grub-core/gdb_grub.in: define dump_module_sections - set logging off - # FIXME: restore logging status +define dump_module_sections -+ pipe dump_module_sections_helper $arg0 | sh -c 'cat >.segments.tmp' ++ pipe dump_module_sections_helper $arg0 | sh -c 'cat >>.segments.tmp' end document dump_module_sections Gather information about module whose mod structure was +@@ grub-core/gdb_grub.in: document load_module + end + + define load_all_modules ++ shell rm -f .segments.tmp + set $this = grub_dl_head + while ($this != 0) + dump_module_sections $this 2: f350ddf3c9 ! 2: 85f68a8369 gdb: Prevent wrapping when writing to .segments.tmp @@ grub-core/gdb_grub.in: define dump_module_sections_helper + # to .segments.tmp + with width 0 -- \ + with trace-commands off -- \ - pipe dump_module_sections_helper $arg0 | sh -c 'cat >.segments.tmp' + pipe dump_module_sections_helper $arg0 | sh -c 'cat >>.segments.tmp' end document dump_module_sections 3: 75949e0d8e = 3: 88b3973cdb gdb: If no modules have been loaded, do not try to load module symbols 4: ed5599b842 = 4: c0d7da87a8 gdb: Move runtime module loading into runtime_load_module 5: e00aa463bb < -: ---------- gdb: Get correct mod variable value 6: c1e0439012 < -: ---------- gdb: Do not run load_module if module has already been loaded -: ---------- > 5: 4712465374 gdb: Reliably load modules in runtime_load_module 7: dc8ce82e27 = 6: 283021b7b9 gdb: Add functions to make loading from dynamically positioned targets easier 8: dc7338f00a = 7: 8f4b7c3bbd gdb: Remove Perl dependency for GRUB GDB script 9: 0ee5cb7cc1 = 8: 055e968779 gdb: If enabled, print line used to load EFI kernel symbols when using gdb_grub script 10: 7ec11bff7e = 9: 64eccfc37e gdb: Conditionally run GDB script logic for dynamically or statically positioned GRUB 11: e62defbaa7 = 10: 5064458dfd gdb: Only connect to remote target once when first sourced 12: 0101c41233 = 11: c33e8f57b4 gdb: Allow user defined "onload_" command to be run when module is loaded 13: 94f4707b14 ! 12: f8a26f3a56 gdb: Allow running user-defined commands at GRUB start @@ grub-core/gdb_grub.in: end # We may have been very late to loading the kernel.exec symbols and # and modules may already be loaded. So load symbols for any already # loaded. -@@ grub-core/gdb_grub.in: document num_modules - Given a module name print its address or NULL if not loaded. +@@ grub-core/gdb_grub.in: document runtime_load_module + Load module symbols at runtime as they are loaded. end +define run_on_start @@ grub-core/gdb_grub.in: document num_modules ### set confirm off -@@ grub-core/gdb_grub.in: set confirm off - # fail. - - set $platform_efi = $_streq("@platform@", "efi") -+set $target = "@target_cpu@-@platform@" - - if ! $runonce - if $platform_efi - # Only load the executable file, not the symbols +@@ grub-core/gdb_grub.in: if ! $runonce exec-file kernel.exec else -+ if $_streq($target, "i386-pc") -+ add-symbol-file boot.image -+ add-symbol-file diskboot.image -+ add-symbol-file lzma_decompress.image -+ end file kernel.exec + run_on_start runtime_load_module -: ---------- > 13: fbd217a89c gdb: Add extra early initialization symbols for i386-pc 14: 5fbef49d07 = 14: 973f24a485 gdb: Add ability to turn on shell tracing for gdb helper script 15: b1f6f5861b = 15: d6c6947762 docs: Add debugging chapter to development documentation -- 2.34.1