crash/0020-struct-fix-struct-prin...

70 lines
2.1 KiB
Diff

From f7e7d0303f63393cf9e7830d63b7fabfe5c7cb13 Mon Sep 17 00:00:00 2001
From: John Pittman <jpittman@redhat.com>
Date: Mon, 15 Mar 2021 17:07:57 -0400
Subject: [PATCH 01/11] struct: fix struct print member array of list_heads
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@redhat.com>
---
symbols.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/symbols.c b/symbols.c
index 215d523fb325..a2d5c6c6178f 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.29.2