Received: from list by lists.gnu.org with archive (Exim 4.90_1) id 1qCZYT-0005Yu-PF for mharc-grub-devel@gnu.org; Fri, 23 Jun 2023 01:42:03 -0400 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 1qCZYK-0005Wn-Js for grub-devel@gnu.org; Fri, 23 Jun 2023 01:41:52 -0400 Received: from mail-lf1-x12d.google.com ([2a00:1450:4864:20::12d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qCZYH-00049W-I7 for grub-devel@gnu.org; Fri, 23 Jun 2023 01:41:47 -0400 Received: by mail-lf1-x12d.google.com with SMTP id 2adb3069b0e04-4f883420152so186806e87.1 for ; Thu, 22 Jun 2023 22:41:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1687498903; x=1690090903; h=in-reply-to:content-disposition:mime-version:references :mail-followup-to:message-id:subject:cc:to:from:date:from:to:cc :subject:date:message-id:reply-to; bh=8GSU4Qun/s7jrAWlCLI5nJ4TDGA5aLuqb9vNEGCbSiM=; b=kjTgapaEpF+vb/bdzbEPvHioezfI31Aunataxrp1/lwRmbZmJZBjmKdHpEjVxxkOKl ckrjkU9jid4X6+dnaJkJco6CcOfAkIzae28c23HOkUFMyxLPvAXoFmbbJwOE7aVkSKsi oEkmdIB+b6evIqEj6MWBplC5yOcdKAnMwXzsTgLQeAlWPfB8/kgQwTIBLM6y3mH4EfEZ SQ+Q+dGW/+Zcpqj48dJLtcLYBImu3KXtFpFyCdtw63XGX1tSCADzwHFEGDID0KWX+Mae Q+LIZbshwuD3i0GjYMCbQTMOOYQpK1NWUStt021aiRwkijl6roylmA7iffBOXNutavuY KQEQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1687498903; x=1690090903; h=in-reply-to:content-disposition:mime-version:references :mail-followup-to:message-id:subject:cc:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=8GSU4Qun/s7jrAWlCLI5nJ4TDGA5aLuqb9vNEGCbSiM=; b=Xi4o0i3/NMLD8A1DYHbg+I1LR6E3zM1XChUCQ6fDyLZWMn5BqZ4VzPTNGN3+v8jPsi sHgix1+nPsoksIAJ4QGqw1MbEdjHRfTwiqmCMoe53XawIIHt03gBVyicKIycAQzHPvXv ODyWt79QoqmfOJV8WJj7HhERM+XlPG+YXoR5ZD7+eTEAhnktHA5lfCSd8GD83nIIOtB6 RnzPt6R05JKrvETUFXkGmguqBK9YqYc/x0ZBmKmP07Bfh+cXkJV0paCF20WTtpG/OglJ 9PZlW5WP0IklkGKMgIhvwIV1keb0G8T3VGxx8zBscrkpnDbu6K+nELWOKQM8xitPVh53 P9JA== X-Gm-Message-State: AC+VfDy/NMapdYIvGaU+H9eqRD7kgnLl+kU7oEKEc+rQOwS2hdZe4a5F U9LGmSYF8Hjex7btRr2H8GM= X-Google-Smtp-Source: ACHHUZ4y7LR1ZobqCBODH4HKyeS8GfIZAvFuzjh/OIHn1BmqdqZih6helfN/jXGbByekBIO5/1Gxww== X-Received: by 2002:a19:6547:0:b0:4f8:7807:a612 with SMTP id c7-20020a196547000000b004f87807a612mr6884408lfj.61.1687498902930; Thu, 22 Jun 2023 22:41:42 -0700 (PDT) Received: from dj3ntoo (220.sub-97-147-16.myvzw.com. [97.147.16.220]) by smtp.gmail.com with ESMTPSA id 7-20020a05600c230700b003fa7b39f13esm985818wmo.12.2023.06.22.22.41.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Jun 2023 22:41:42 -0700 (PDT) Date: Fri, 23 Jun 2023 00:41:24 -0500 From: Oskari Pirhonen To: Glenn Washburn Cc: grub-devel@gnu.org, dkiper@net-space.pl Subject: Re: [PATCH] docs: Minor edits to debugging chapter Message-ID: Mail-Followup-To: Glenn Washburn , grub-devel@gnu.org, dkiper@net-space.pl References: <20230622110740.30c15b91@crass-HP-ZBook-15-G2> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="vnIlyf3acsbPTZ/m" Content-Disposition: inline In-Reply-To: <20230622110740.30c15b91@crass-HP-ZBook-15-G2> Received-SPF: pass client-ip=2a00:1450:4864:20::12d; envelope-from=xxc3ncoredxx@gmail.com; helo=mail-lf1-x12d.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 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: Fri, 23 Jun 2023 05:41:53 -0000 --vnIlyf3acsbPTZ/m Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Thu, Jun 22, 2023 at 11:07:40 -0500, Glenn Washburn wrote: > On Sun, 18 Jun 2023 22:56:31 -0500 > Oskari Pirhonen wrote: >=20 > > Small set of wording and grammatical edits which did not make it in time > > for the original review of the chapter. > >=20 > > Signed-off-by: Oskari Pirhonen > > --- > > docs/grub-dev.texi | 39 +++++++++++++++++++-------------------- > > 1 file changed, 19 insertions(+), 20 deletions(-) > >=20 > > diff --git a/docs/grub-dev.texi b/docs/grub-dev.texi > > index 72470b42c..05a19c26d 100644 > > --- a/docs/grub-dev.texi > > +++ b/docs/grub-dev.texi > > @@ -658,11 +658,11 @@ command must be used. We also need to load a bina= ry image, preferably with > > symbols. This can be done using the GDB command @code{file kernel.exec= }, if > > GDB is started from the @file{grub-core} directory in the GRUB2 build > > directory. GRUB2 developers have made this more simple by including a = GDB > > -script which does much of the setup. This file at @file{grub-core/gdb_= grub} > > -of the build directory and is also installed via @command{make install= }. > > +script which does much of the setup. This file is at @file{grub-core/g= db_grub} > > +in the build directory and is also installed via @command{make install= }. > > If not building GRUB, the distribution may have a package which instal= ls > > this GDB script along with debug symbol binaries, such as Debian's > > -@samp{grub-pc-dbg} package. The GDB scripts is intended to by used > > +@samp{grub-pc-dbg} package. The GDB script is intended to be used > > like so, assuming: > > =20 > > @example > > @@ -719,14 +719,13 @@ expected when breaking on functions, but, for ins= tance, global variables > > will point to the wrong address in memory and thus give incorrect valu= es > > (which can be difficult to debug). > > =20 > > -The calculating of the correct offsets for sections when loading symbol > > -files are taken care of when loading the kernel symbols via the user-d= efined > > -GDB command @command{dynamic_load_kernel_exec_symbols}, which takes one > > -argument, the address where the text section is loaded, as determined = by > > -one of the methods above. Alternatively, the command @command{dynamic_= load_symbols} > > -with the text section address as an agrument can be called to load the > > -kernel symbols and setup loading the module symbols as they are loaded= at > > -runtime. > > +Calculating the correct offsets for sections is taken care of automati= cally > > +when loading the kernel symbols via the user-defined GDB command > > +@command{dynamic_load_kernel_exec_symbols}, which takes one argument, = the > > +address where the text section is loaded as determined by one of the m= ethods > > +above. Alternatively, the command @command{dynamic_load_symbols} with = the text > > +section address as an agrument can be called to load the kernel symbol= s and set > > +up loading the module symbols as they are loaded at runtime. > > =20 > > In the author's experience, when debugging with QEMU and OVMF, to have > > debugging symbols loaded at the start of GRUB2 execution the GRUB2 EFI > > @@ -736,7 +735,7 @@ two subsections below. Generally speaking, the load= address does not change > > between QEMU runs. There are exceptions to this, namely that different > > GRUB2 EFI applications can be run at different addresses. Also, it has= been > > observed that after running the EFI application for the first time, the > > -second run will some times have a different load address, but subseque= nt > > +second run will sometimes have a different load address, but subsequent > > runs of the same EFI application will have the same load address as the > > second run. And it's a near certainty that if the GRUB EFI binary has = changed, > > eg. been recompiled, the load address will also be different. > > @@ -752,7 +751,7 @@ gdb -x gdb_grub -ex 'dynamic_load_symbols @var{addr= ess of .text section}' > > @end example > > =20 > > If you load the symbols in this manner and, after continuing execution= , do > > -not see output showing the loading of modules symbol, then it is very = likely > > +not see output showing the module symbols loading, then it is very lik= ely > > that the load address was incorrect. > > =20 > > Another thing to be aware of is how the loading of the GRUB image by t= he > > @@ -767,8 +766,8 @@ be loading the GRUB image into memory where every b= yte is already set to 0. > > This means that if a breakpoint is set before GRUB is loaded, GDB will= save > > the 0-byte(s) where the the special instruction will go. Then when the= firmware > > loads the GRUB image and because it is unaware of the debugger, it will > > -write the GRUB image to memory, overwriting anything that was there pr= eviously, > > -notably in this case the instruction that implements the software brea= kpoint. > > +write the GRUB image to memory, overwriting anything that was there pr= eviously. > > +Notably in this case the instruction that implements the software brea= kpoint. >=20 > This is not a complete sentence (where is the verb?). The sentence is > kind of long, which be what you're trying to change. The phrase > starting with "notably" is a parenthetical phrase. Perhaps it would > be more readable to replace the comma (which is nonetheless correct) > with an emdash (my preference) or put in parenthesis (other ways of > denoting parenthetical phrases). >=20 You are correct. Shortening it was the goal. I can figure out how to do: ... previously [EMDASH] notably in this case ... in texinfo. > > This will be confusing for the person using GDB because GDB will show = the > > breakpoint as set, but the brekapoint will never be hit. Furthermore, = GDB > > then becomes confused, such that even deleting an recreating the break= point > > @@ -783,10 +782,10 @@ implemented by having the breakpoint address in s= pecial debug registers on > > the CPU. So they can always be set freely without regard to whether GR= UB has > > been loaded or not. The reason that hardware breakpoints aren't always= used > > is because there are a limited number of them, usually around 4 on var= ious > > -CPUs, and specifically exactly 4 for x86 CPUs. The @file{gdb_grub} scr= ipt > > -goes out of its way to not use hardware breakpoints internally and when > > -needed use them as short a time as possible, thus allowing the user to= have a > > -maximal number at their disposal. > > +CPUs, and specifically exactly 4 for x86 CPUs. The @file{gdb_grub} scr= ipt goes > > +out of its way to avoid using hardware breakpoints internally, and whe= n needed, >=20 > s/, and when/and, when/ would be correct. >=20 > The "when needed" is a dependent clause and should be grouped > accordingly for clarity. The comma before the and is optional and > uneeded for this conjunction. >=20 > > +uses them as briefly as possible, thus allowing the user to have a max= imal > > +number at their disposal. >=20 > Perhaps to be more clear the "when needed" should come after "possible" > with no commas. >=20 I can change it to say: The gdb_grub script goes out of its way to avoid using hardware breakpoints internally and uses them as briefly as possible when needed, thus allowing the user to have a maximal number at their disposal. > > =20 > > @node OVMF debug log > > @subsection OVMF debug log > > @@ -797,7 +796,7 @@ here is one} which is not officially recommended). = OVMF will output debug > > messages to a special serial device, which we must add to QEMU. The fo= llowing > > QEMU command will run the debug OVMF and write the debug messages to a > > file named @file{debug.log}. It is assumed that @file{disk.img} is a d= isk > > -image or block device that is setup to boot GRUB2 EFI. > > +image or block device that is set up to boot GRUB2 EFI. > > =20 > > @example > > qemu-system-x86_64 -bios /path/to/debug/OVMF.fd \ >=20 > There's a couple of changes that are a matter of personal preference, > but I'm okay with those changes. Thanks for proof reading this. >=20 Thank you to you too :) - Oskari PS: Once this is done, and when you get the chance, I think you left out what the assumption is in this bit here from the i386-pc section: @samp{grub-pc-dbg} package. The GDB script is intended to be used like so, assuming: =20 @example cd $(dirname /path/to/script/gdb_grub) gdb -x gdb_grub @end example --vnIlyf3acsbPTZ/m Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iHUEABYIAB0WIQQfOU+JeXjo4uxN6vCp8he9GGIfEQUCZJUwfgAKCRCp8he9GGIf EQRUAP9EMVWWRCPCDDCz7TIcAajZ5ikeFAGfCJzbHHe24lEhyAD9GylSVMO6CjA3 0WVqdpdwNQKWBafKjCmglwsT76zUJQo= =kcuv -----END PGP SIGNATURE----- --vnIlyf3acsbPTZ/m--