[Crash-utility] [PATCH] symbol: fix offset print for function pointers that return pointers

HAGIO KAZUHITO(萩尾 一仁) k-hagio-ab at nec.com
Tue Apr 13 01:58:05 UTC 2021


-----Original Message-----
> 在 2021年04月13日 07:34, HAGIO KAZUHITO(萩尾 一仁) 写道:
> > Hi Lianbo,
> >
> > -----Original Message-----
> >> 在 2021年04月02日 15:02, HAGIO KAZUHITO(萩尾 一仁) 写道:
> >>> -----Original Message-----
> >>>> In the show_member_offset() function, when trying to handle function
> >>>> pointers, the case for "(*" is handled.  However, if the function
> >>>> pointer returns a pointer or a pointer to a pointer, then the
> >>>> condition is unhandled.  This results in the offset not being printed.
> >>>>
> >>>> Fix by first checking if the member is potentially a function pointer,
> >>>> then checking if it returns a pointer or a pointer to a pointer.
> >>>>
> >>>> Signed-off-by: John Pittman <jpittman at redhat.com>
> >>>
> >>> Good catch... I've confirmed that the patch works as expected with RHEL7's
> >>> struct offload_callbacks:
> >>>
> >>> crash> struct -o offload_callbacks
> >>> struct offload_callbacks {
> >>>    [0] struct sk_buff *(*gso_segment)(struct sk_buff *, netdev_features_t);
> >>>    [8] struct sk_buff **(*gro_receive)(struct sk_buff **, struct sk_buff *);
> >
> > This output is the one with the patch, and
> >
> >>>   [16] int (*gro_complete)(struct sk_buff *, int);
> >>> }
> >>> SIZE: 24
> >>
> >> This should be a good example for the case described in patch log. But I didn't
> >> reproduce it on rhel7 before applying this patch, it's strange.
> >> ...
> >>       KERNEL: /usr/lib/debug/lib/modules/3.10.0-1160.24.1.el7.x86_64/vmlinux
> >> ...
> >>      RELEASE: 3.10.0-1160.24.1.el7.x86_64
> >>      VERSION: #1 SMP Thu Mar 25 21:21:56 UTC 2021
> >>      MACHINE: x86_64  (2892 Mhz)
> >>       MEMORY: 4 GB
> >>          PID: 7815
> >>      COMMAND: "crash"
> >>         TASK: ffffa10210512100  [THREAD_INFO: ffffa10189b34000]
> >>          CPU: 1
> >>        STATE: TASK_RUNNING (ACTIVE)
> >>
> >> crash> struct -o offload_callbacks
> >> struct offload_callbacks {
> >>        struct sk_buff *(*gso_segment)(struct sk_buff *, netdev_features_t);
> >>        struct sk_buff **(*gro_receive)(struct sk_buff **, struct sk_buff *);
> >     ^^^^
> > There are no offsets here, you're reproducing the issue, I think?
> >
> 
> That's right, I ignored the offset.
> 
> Thank you for the explanation in detail. Kazu and John Pittman.
> 
> Acked-by: Lianbo Jiang <lijiang at redhat.com>

OK, added the output as an example to the commit log and applied:
https://github.com/crash-utility/crash/commit/8dfc228

Thanks,
Kazu

> 
> > Thanks,
> > Kazu
> >
> >>   [16] int (*gro_complete)(struct sk_buff *, int);
> >> }
> >> SIZE: 24
> >>
> >> Do you happen to know how to reproduce this issue? John Pittman.
> >>
> >> Thanks.
> >> Lianbo
> >>
> >>>
> >>> Acked-by: Kazuhito Hagio <k-hagio-ab at nec.com>
> >>>
> >>> Thanks,
> >>> Kazu
> >>>
> >>>> ---
> >>>>  symbols.c | 11 +++++++++--
> >>>>  1 file changed, 9 insertions(+), 2 deletions(-)
> >>>>
> >>>> diff --git a/symbols.c b/symbols.c
> >>>> index a2d5c6c..5d7da6e 100644
> >>>> --- a/symbols.c
> >>>> +++ b/symbols.c
> >>>> @@ -8356,8 +8356,15 @@ show_member_offset(FILE *ofp, struct datatype_member *dm, char *inbuf)
> >>>>  		}
> >>>>  	} else if (c) {
> >>>>  		for (i = 0; i < c; i++) {
> >>>> -			if (STRNEQ(arglist[i], "(*")) {
> >>>> -				target = arglist[i]+2;
> >>>> +			if (strstr(inbuf, "(*")) {
> >>>> +				if (STRNEQ(arglist[i], "(*"))
> >>>> +					target = arglist[i]+2;
> >>>> +				else if (STRNEQ(arglist[i], "*(*"))
> >>>> +					target = arglist[i]+3;
> >>>> +				else if (STRNEQ(arglist[i], "**(*"))
> >>>> +					target = arglist[i]+4;
> >>>> +				else
> >>>> +					continue;
> >>>>  				if (!(t1 = strstr(target, ")")))
> >>>>  					continue;
> >>>>  				*t1 = NULLCHAR;
> >>>> --
> >>>> 2.17.2
> >>>
> >





More information about the Crash-utility mailing list