[Crash-utility] [PATCH] struct: fix struct print member array of list_heads

HAGIO KAZUHITO(萩尾 一仁) k-hagio-ab at nec.com
Thu Mar 25 06:10:06 UTC 2021


Queued for the next version:
https://github.com/crash-utility/crash/commit/f7e7d0303f63393cf9e7830d63b7fabfe5c7cb13

Thanks,
Kazu

-----Original Message-----
> Hi, John Pittman
> Thank you for the fix.
> 在 2021年03月16日 05:07, John Pittman 写道:
> > 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>
> > ---
> >  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");
> >
> 
> Acked-by: Lianbo Jiang <lijiang at redhat.com>





More information about the Crash-utility mailing list