From: Daniel Thompson <daniel.thompson@linaro.org>
To: Douglas Anderson <dianders@chromium.org>
Cc: kgdb-bugreport@lists.sourceforge.net,
Christophe JAILLET <christophe.jaillet@wanadoo.fr>,
Jason Wessel <jason.wessel@windriver.com>,
Thorsten Blum <thorsten.blum@toblux.com>,
Yuran Pereira <yuran.pereira@hotmail.com>,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH 07/13] kdb: Tweak "repeat" handling code for "mdW" and "mdWcN"
Date: Tue, 18 Jun 2024 13:57:10 +0100 [thread overview]
Message-ID: <20240618125710.GE11330@aspen.lan> (raw)
In-Reply-To: <20240617173426.7.Ie8aa2af2df12c2e9dc510f003a301401a1ac97fb@changeid>
On Mon, Jun 17, 2024 at 05:34:41PM -0700, Douglas Anderson wrote:
> In general, "md"-style commands are meant to be "repeated". This is a
> feature of kdb and "md"-style commands get it enabled because they
> have the flag KDB_REPEAT_NO_ARGS. What this means is that if you type
> "md4c2 0xffffff808ef05400" and then keep hitting return on the "kdb>"
> prompt that you'll read more and more memory. For instance:
> [5]kdb> md4c2 0xffffff808ef05400
> 0xffffff808ef05400 00000204 00000000 ........
> [5]kdb>
> 0xffffff808ef05408 8235e000 00000000 ..5.....
> [5]kdb>
> 0xffffff808ef05410 00000003 00000001 ........
>
> As a side effect of the way kdb works is implemented, you can get the
> same behavior as the above by typing the command again with no
> arguments. Though it seems unlikely anyone would do this it shouldn't
> really hurt:
> [5]kdb> md4c2 0xffffff808ef05400
> 0xffffff808ef05400 00000204 00000000 ........
> [5]kdb> md4c2
> 0xffffff808ef05408 8235e000 00000000 ..5.....
> [5]kdb> md4c2
> 0xffffff808ef05410 00000003 00000001 ........
>
> In general supporting "repeat" should be easy. If argc is 0 then we
> just copy the results of the arg parsing from the last time, making
> sure that the address has been updated. This is all handled nicely in
> the "if (argc == 0)" clause in kdb_md().
>
> Oddly, the "mdW" and "mdWcN" code seems to update "last_bytesperword"
> and "last_repeat", which doesn't seem like it should be necessary. It
> appears that this code is needed to make this use case work, though
> it's a bit unclear if this is truly an important feature to support:
> [1]kdb> md2c3 0xffffff80c8e2b280
> 0xffffff80c8e2b280 0200 0000 0000 ...
> [1]kdb> md2c4
> 0xffffff80c8e2b286 0000 e000 8235 0000 ...
>
> In order to abstract the code better, remove the code updating
> "last_bytesperword" and "last_repeat" from the "mdW" and "mdWcN"
> handling. This breaks the above case where the user tweaked "argv[0]"
> and then tried to somehow leverage the "repeat" code to do something
> smart, but that feels like it was a misfeature anyway.
I'm not too keen on "successfully" doing the wrong thing.
In that light I'd view this as a feature that is arguably simpler to
implement than it is to error check *not* implementing it. In other
words by the time you add error checking to the argc == 0 path to
spot mismatches then you are better off honouring the user request
rather then telling them they got it wrong.
Daniel.
PS I have never done so but I also wondered if it is reasonable to use
this feature to manually decompose structures. For example:
md1c1 structure_pointer; md1c7; md8c1; md8c1; md2c2
next prev parent reply other threads:[~2024-06-18 12:57 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-06-18 0:34 [PATCH 00/13] kdb: Add the ability to read iomapped memory via kdb + clean up "md" commands Douglas Anderson
2024-06-18 0:34 ` [PATCH 01/13] kdb: Get rid of "minlen" for the "md" command Douglas Anderson
2024-06-18 0:34 ` [PATCH 02/13] kdb: Document the various "md" commands better Douglas Anderson
2024-06-18 11:24 ` Daniel Thompson
2024-06-18 14:42 ` Doug Anderson
2024-06-18 0:34 ` [PATCH 03/13] kdb: Use "bool" in "md" implementation where appropriate Douglas Anderson
2024-06-18 0:34 ` [PATCH 04/13] kdb: Drop "offset" and "name" args to kdbgetaddrarg() Douglas Anderson
2024-06-18 0:34 ` [PATCH 05/13] kdb: Separate out "mdr" handling Douglas Anderson
2024-06-18 11:29 ` Daniel Thompson
2024-06-18 0:34 ` [PATCH 06/13] kdb: Remove "mdW" and "mdWcN" handling of "W" == 0 Douglas Anderson
2024-06-18 11:37 ` Daniel Thompson
2024-06-18 14:42 ` Doug Anderson
2024-06-18 0:34 ` [PATCH 07/13] kdb: Tweak "repeat" handling code for "mdW" and "mdWcN" Douglas Anderson
2024-06-18 12:57 ` Daniel Thompson [this message]
2024-06-18 14:43 ` Doug Anderson
2024-06-18 0:34 ` [PATCH 08/13] kdb: In kdb_md() make `repeat` and `mdcount` calculations more obvious Douglas Anderson
2024-06-18 0:34 ` [PATCH 09/13] kdb: Use 'unsigned int' in kdb_md() where appropriate Douglas Anderson
2024-06-18 15:26 ` Daniel Thompson
2024-06-18 0:34 ` [PATCH 10/13] kdb: Replease simple_strtoul() with kstrtouint() in kdb_md() Douglas Anderson
2024-06-18 0:34 ` [PATCH 11/13] kdb: Abstract out parsing for mdWcN Douglas Anderson
2024-06-18 21:02 ` kernel test robot
2024-06-18 0:34 ` [PATCH 12/13] kdb: Add mdpW / mdpWcN commands Douglas Anderson
2024-06-18 0:34 ` [PATCH 13/13] kdb: Add mdi, mdiW / mdiWcN commands to show iomapped memory Douglas Anderson
2024-06-18 15:59 ` Daniel Thompson
2024-06-18 19:33 ` Doug Anderson
2024-06-21 15:43 ` Daniel Thompson
2024-06-21 19:52 ` Doug Anderson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240618125710.GE11330@aspen.lan \
--to=daniel.thompson@linaro.org \
--cc=christophe.jaillet@wanadoo.fr \
--cc=dianders@chromium.org \
--cc=jason.wessel@windriver.com \
--cc=kgdb-bugreport@lists.sourceforge.net \
--cc=linux-kernel@vger.kernel.org \
--cc=thorsten.blum@toblux.com \
--cc=yuran.pereira@hotmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox