[Crash-utility] [PATCH] struct: fix struct print member array of list_heads
HAGIO KAZUHITO(萩尾 一仁)
k-hagio-ab at nec.com
Mon Mar 22 08:22:42 UTC 2021
-----Original Message-----
> Due to the way that an array of list_head entries are printed,
> parsing of them fails. Note the difference in spacing between the
> double opening and double closing brackets.
>
> crash> struct blk_mq_ctx.rq_lists ffffc447ffc0f740
> <-->rq_lists = {{
> next = 0xffffc447ffc0f748,
> prev = 0xffffc447ffc0f748
> }, {
> next = 0xffffc447ffc0f758,
> prev = 0xffffc447ffc0f758
> }, {
> next = 0xffffc447ffc0f768,
> prev = 0xffffc447ffc0f768
> <---->}}
>
> As parse_for_member() relies on opening and closing brackets having
> the same spacing, make a condition for these arrays of list_head
> members.
>
> Before:
>
> crash> struct blk_mq_ctx.rq_completed ffffc447ffc0f740
> crash>
>
> After:
>
> crash> struct blk_mq_ctx.rq_completed ffffc447ffc0f740
> rq_completed = {221, 1333}
>
> Signed-off-by: John Pittman <jpittman at redhat.com>
Thanks for catching and fixing this. It looks like only the last
array of list_head in an unnamed structure is affected..
The patch looks good to me.
Acked-by: Kazuhito Hagio <k-hagio-ab at nec.com>
Thanks,
Kazu
> ---
> symbols.c | 8 +++++++-
> 1 file changed, 7 insertions(+), 1 deletion(-)
>
> diff --git a/symbols.c b/symbols.c
> index 215d523..a2d5c6c 100644
> --- a/symbols.c
> +++ b/symbols.c
> @@ -7918,7 +7918,8 @@ parse_for_member(struct datatype_member *dm, ulong flag)
> sprintf(lookfor2, " %s[", s);
> next_item:
> while (fgets(buf, BUFSIZE, pc->tmpfile)) {
> - if (embed && (count_leading_spaces(buf) == embed))
> + if ((embed && (count_leading_spaces(buf) == embed)) ||
> + (strstr(buf, "}}") && embed == count_leading_spaces(buf) - 2))
> embed = 0;
>
> if (!on && !embed && strstr(buf, "= {") && !strstr(buf, lookfor1))
> @@ -7940,6 +7941,11 @@ next_item:
> !strstr(buf, "}")) || (buf[0] == '}')) {
> break;
> }
> + if (indent && (on > 1) && indent == count_leading_spaces(buf) - 2 &&
> + strstr(buf, "}}")) {
> + fprintf(pc->saved_fp, "%s", buf);
> + break;
> + }
> if (!indent) {
> if ((p1 = strstr(buf, ", \n")))
> sprintf(p1, "\n");
> --
> 2.17.2
More information about the Crash-utility
mailing list