# Re: \[PATCH\] perf unwind: Set userdata for all \_\_report\_module paths

- From: Arnaldo Carvalho de Melo \<acme@kernel.org\>
- Date: 2021-02-18 19:01:07 
- List: linux-perf-users
- Page: https://ratatoskr.run/linux-perf-users/2021/02/15404559
- Thread: https://ratatoskr.run/linux-perf-users/2021/02/15404557/t.md

```text
Em Thu, Feb 18, 2021 at 04:58:44PM +0000, Dave Rigby escreveu:
> I missed adding a link to the bugzilla issue: https://bugzilla.kernel.org/show_bug.cgi?id=211801
> 
> Note sure what the recommended way of tagging that in the patch is…

I'll add a:

Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=211801

tag,

Thanks,

- Arnaldo
 
> 
> DaveR
> 
> > On 18 Feb 2021, at 16:56, d.rigby@me.com wrote:
> > 
> > From: Dave Rigby <redacted>
> > 
> > When locating the dwarf module for a given address, __find_debuginfo()
> > requires a 'struct dso' passed via the userdata argument.
> > 
> > However, this field is only set in __report_module() if the module is
> > found in via dwfl_addrmodule(), not if it is found later via dwfl_report_elf().
> > 
> > Set userdata irrespective of how the dwarf module was found, as long
> > as we found a module.
> > 
> > Fixes: bf53fc6b5f41 ("perf unwind: Fix separate debug info files when using elfutils' libdw's unwinder")
> > Cc: <redacted>
> > Cc: Arnaldo Carvalho de Melo <acme@kernel.org>
> > Cc: Jan Kratochvil <redacted>
> > Cc: Jiri Olsa <redacted>
> > ---
> > tools/perf/util/unwind-libdw.c | 11 ++++++++---
> > 1 file changed, 8 insertions(+), 3 deletions(-)
> > 
> > diff --git a/tools/perf/util/unwind-libdw.c b/tools/perf/util/unwind-libdw.c
> > index 0ada907..a74b517 100644
> > --- a/tools/perf/util/unwind-libdw.c
> > +++ b/tools/perf/util/unwind-libdw.c
> > @@ -60,10 +60,8 @@ static int __report_module(struct addr_location *al, u64 ip,
> > 	mod = dwfl_addrmodule(ui->dwfl, ip);
> > 	if (mod) {
> > 		Dwarf_Addr s;
> > -		void **userdatap;
> > 
> > -		dwfl_module_info(mod, &userdatap, &s, NULL, NULL, NULL, NULL, NULL);
> > -		*userdatap = dso;
> > +		dwfl_module_info(mod, NULL, &s, NULL, NULL, NULL, NULL, NULL);
> > 		if (s != al->map->start - al->map->pgoff)
> > 			mod = 0;
> > 	}
> > @@ -79,6 +77,13 @@ static int __report_module(struct addr_location *al, u64 ip,
> > 					      al->map->start - al->map->pgoff, false);
> > 	}
> > 
> > +	if (mod) {
> > +		void **userdatap;
> > +
> > +		dwfl_module_info(mod, &userdatap, NULL, NULL, NULL, NULL, NULL, NULL);
> > +		*userdatap = dso;
> > +	}
> > +
> > 	return mod && dwfl_addrmodule(ui->dwfl, ip) == mod ? 0 : -1;
> > }
> > 
> > -- 
> > 1.8.3.1
> 

-- 

- Arnaldo
```
