Re: [PATCH] Getter and setter for Dwfl's offline_next_address

2024-03-24 Thread Martin Rodriguez Reboredo

On 3/24/24 14:08, Mark Wielaard wrote:

Hi Martin,

On Sun, Mar 24, 2024 at 11:11:21AM -0300, Martin Rodriguez Reboredo wrote:

[...]
So this patch is kinda pointless, but at least I've managed to learn
what I was missing. Anyways, thanks for the heads-up. :)


I don't think it was pointless. Clearly our documentation is not very
good (and given eu-readelf and eu-nm do cheat, maybe our interface/api
isn't really good either).


At least to get the gist of it the header comments were good enough, it
was this particular case that I misunderstood. I could do what I wanted
with the API, so no problem with that.


Maybe you could post your code for that ./report program and what you
had to do to get it to print the correct address/symbols. Then we at
least have some documentation for others which hit the same issue.


#ifdef USE_DEMANGLE
#include 
#endif
#include 
#include 
#include 
#include 
#include 

static const char *symname(const char *name)
{
#ifdef USE_DEMANGLE
  // Require GNU v3 ABI by the "_Z" prefix.
  if (name[0] == '_' && name[1] == 'Z') {
int status = -1;
char *dsymname = __cxa_demangle(name, demangle_buffer,
_buffer_len, );
if (status == 0)
  name = demangle_buffer = dsymname;
  }
#endif
  return name;
}

static int get_addr_width(Dwfl_Module *mod)
{
  // Try to find the address width if possible.
  static int width = 0;
  if (width == 0 && mod != NULL) {
Dwarf_Addr bias;
Elf *elf = dwfl_module_getelf(mod, );
if (elf != NULL) {
  GElf_Ehdr ehdr_mem;
  GElf_Ehdr *ehdr = gelf_getehdr(elf, _mem);
  if (ehdr != NULL)
width = ehdr->e_ident[EI_CLASS] == ELFCLASS32 ?
8 :
16;
}
  }
  if (width == 0)
width = 16;

  return width;
}

int main(int argc, const char **argv)
{
  if (argc != 3)
return 1;

  Dwfl *dwfl = dwfl_begin(_callbacks);
  if (!dwfl)
return 1;
  //dwfl->offline_next_address = 0; // What I thought it was needed

  if (!dwfl_report_offline(dwfl, "", argv[1], -1)) {
dwfl_end(dwfl);
return 1;
  }
  if (dwfl_report_end(dwfl, NULL, NULL)) {
dwfl_end(dwfl);
return 1;
  }

  char *endp = NULL;
  GElf_Addr addr = strtoumax(argv[2], , 16), bias;

  Dwfl_Module *mod = dwfl_addrmodule(dwfl, addr);

  int width = get_addr_width(mod);
  printf("0x%.*" PRIx64 "%s", width, addr, "\n");

  dwfl_module_getdwarf(mod, ); // This line did the trick!

  const char *name = dwfl_module_addrname(mod, addr + bias);
  name = name != NULL ? symname(name) : "??";
  printf("%s%c", name, '\n');

  GElf_Sym s;
  GElf_Off off = 0;
  name = dwfl_module_addrinfo(mod, addr + bias, , , NULL, NULL, NULL);

  Dwfl_Line *line = dwfl_module_getsrc(mod, addr + bias);
  if (!line)
line = dwfl_getsrc(dwfl, addr + bias);
  if (line) {
int nline, column;
const char *filename =
  dwfl_lineinfo(line, , , , NULL, NULL);
printf("%s:%i,%i\n", filename, nline, column);
  } else {
printf("??:0\n");
  }

  dwfl_end(dwfl);

  return 0;
}


Thanks,

Mark


☺ Buildbot (Sourceware): elfutils - build successful (main)

2024-03-24 Thread builder
A restored build has been detected on builder elfutils-fedora-x86_64 while 
building elfutils.

Full details are available at:
https://builder.sourceware.org/buildbot/#/builders/59/builds/308

Build state: build successful
Revision: 8f3818574a6abe1fbab1682698b2cef146522148
Worker: bbo2
Build Reason: (unknown)
Blamelist: Frederik “Freso” S. Olesen , Mark Wielaard 


Steps:

- 0: worker_preparation ( success )

- 1: set package name ( success )

- 2: git checkout ( success )
Logs:
- stdio: 
https://builder.sourceware.org/buildbot/#/builders/59/builds/308/steps/2/logs/stdio

- 3: autoreconf ( success )
Logs:
- stdio: 
https://builder.sourceware.org/buildbot/#/builders/59/builds/308/steps/3/logs/stdio

- 4: configure ( success )
Logs:
- stdio: 
https://builder.sourceware.org/buildbot/#/builders/59/builds/308/steps/4/logs/stdio
- config.log: 
https://builder.sourceware.org/buildbot/#/builders/59/builds/308/steps/4/logs/config_log

- 5: get version ( success )
Logs:
- stdio: 
https://builder.sourceware.org/buildbot/#/builders/59/builds/308/steps/5/logs/stdio
- property changes: 
https://builder.sourceware.org/buildbot/#/builders/59/builds/308/steps/5/logs/property_changes

- 6: make ( warnings )
Logs:
- stdio: 
https://builder.sourceware.org/buildbot/#/builders/59/builds/308/steps/6/logs/stdio
- warnings (3): 
https://builder.sourceware.org/buildbot/#/builders/59/builds/308/steps/6/logs/warnings__3_

- 7: make check ( success )
Logs:
- stdio: 
https://builder.sourceware.org/buildbot/#/builders/59/builds/308/steps/7/logs/stdio
- test-suite.log: 
https://builder.sourceware.org/buildbot/#/builders/59/builds/308/steps/7/logs/test-suite_log

- 8: make distcheck ( warnings )
Logs:
- stdio: 
https://builder.sourceware.org/buildbot/#/builders/59/builds/308/steps/8/logs/stdio
- test-suite.log: 
https://builder.sourceware.org/buildbot/#/builders/59/builds/308/steps/8/logs/test-suite_log
- warnings (6): 
https://builder.sourceware.org/buildbot/#/builders/59/builds/308/steps/8/logs/warnings__6_

- 9: make rpmbuild ( warnings )
Logs:
- stdio: 
https://builder.sourceware.org/buildbot/#/builders/59/builds/308/steps/9/logs/stdio
- warnings (31): 
https://builder.sourceware.org/buildbot/#/builders/59/builds/308/steps/9/logs/warnings__31_

- 10: prep ( success )
Logs:
- stdio: 
https://builder.sourceware.org/buildbot/#/builders/59/builds/308/steps/10/logs/stdio

- 11: build bunsen.cpio.gz ( success )
Logs:
- stdio: 
https://builder.sourceware.org/buildbot/#/builders/59/builds/308/steps/11/logs/stdio

- 12: fetch bunsen.cpio.gz ( success )
Logs:
- stdio: 
https://builder.sourceware.org/buildbot/#/builders/59/builds/308/steps/12/logs/stdio

- 13: unpack bunsen.cpio.gz ( success )
Logs:
- stdio: 
https://builder.sourceware.org/buildbot/#/builders/59/builds/308/steps/13/logs/stdio

- 14: pass .bunsen.source.gitname ( success )
Logs:
- stdio: 
https://builder.sourceware.org/buildbot/#/builders/59/builds/308/steps/14/logs/stdio

- 15: pass .bunsen.source.gitdescribe ( success )
Logs:
- stdio: 
https://builder.sourceware.org/buildbot/#/builders/59/builds/308/steps/15/logs/stdio

- 16: pass .bunsen.source.gitbranch ( success )
Logs:
- stdio: 
https://builder.sourceware.org/buildbot/#/builders/59/builds/308/steps/16/logs/stdio

- 17: pass .bunsen.source.gitrepo ( success )
Logs:
- stdio: 
https://builder.sourceware.org/buildbot/#/builders/59/builds/308/steps/17/logs/stdio

- 18: upload to bunsen ( success )
Logs:
- stdio: 
https://builder.sourceware.org/buildbot/#/builders/59/builds/308/steps/18/logs/stdio

- 19: clean up ( success )
Logs:
- stdio: 
https://builder.sourceware.org/buildbot/#/builders/59/builds/308/steps/19/logs/stdio

- 20: make distclean ( success )
Logs:
- stdio: 
https://builder.sourceware.org/buildbot/#/builders/59/builds/308/steps/20/logs/stdio



Re: ☠ Buildbot (Sourceware): elfutils - failed test (failure) (main)

2024-03-24 Thread Mark Wielaard
On Sun, Mar 24, 2024 at 05:45:57PM +, buil...@sourceware.org wrote:
> A new failure has been detected on builder elfutils-fedora-x86_64 while 
> building elfutils.
> 
> Full details are available at:
> https://builder.sourceware.org/buildbot/#/builders/59/builds/307
> 
> Build state: failed test (failure)
> Revision: 6228e2fedf419a7f1d70dc14a3b53a8a97394b88
> Worker: bb2-1
> Build Reason: (unknown)
> Blamelist: Frederik “Freso” S. Olesen 
> 
> Steps:
> 
> - 9: make rpmbuild ( failure )
> Logs:
> - stdio: 
> https://builder.sourceware.org/buildbot/#/builders/59/builds/307/steps/9/logs/stdio
> - warnings (31): 
> https://builder.sourceware.org/buildbot/#/builders/59/builds/307/steps/9/logs/warnings__31_

Checking for unpackaged file(s): /usr/lib/rpm/check-files 
/home/builder/shared/bb2-1/worker/elfutils-fedora-x86_64/build/rpmbuild/BUILDROOT/elfutils-0.191-1.x86_64
error: Installed (but unpackaged) file(s) found:
   /usr/share/fish/vendor_conf.d/debuginfod.fish
Installed (but unpackaged) file(s) found:
   /usr/share/fish/vendor_conf.d/debuginfod.fish
RPM build errors:
make: *** [Makefile:981: rpmbuild] Error 1

Aha, we forgot to add it to the debuginfod-client package.
That is what the attached patch does. Which I just pushed.

Cheers,

Mark>From 8f3818574a6abe1fbab1682698b2cef146522148 Mon Sep 17 00:00:00 2001
From: Mark Wielaard 
Date: Sun, 24 Mar 2024 18:46:02 +0100
Subject: [PATCH] config: Add debuginfod.fish to elfutils.spec as config file.

* config/elfutils.spec.in (debuginfod-client): %files add
%{_datadir}/fish/vendor_conf.d/debuginfod.fish as config file.

Signed-off-by: Mark Wielaard 
---
 config/elfutils.spec.in | 1 +
 1 file changed, 1 insertion(+)

diff --git a/config/elfutils.spec.in b/config/elfutils.spec.in
index d6621c9de702..4d802a25ad5f 100644
--- a/config/elfutils.spec.in
+++ b/config/elfutils.spec.in
@@ -307,6 +307,7 @@ fi
 %{_mandir}/man1/debuginfod-find.1*
 %{_mandir}/man7/debuginfod*.7*
 %config(noreplace) %{_sysconfdir}/profile.d/*
+%config(noreplace) %{_datadir}/fish/vendor_conf.d/debuginfod.fish
 %config(noreplace) %{_sysconfdir}/debuginfod/*
   
 %files debuginfod-client-devel
-- 
2.39.3



☠ Buildbot (Sourceware): elfutils - failed test (failure) (main)

2024-03-24 Thread builder
A new failure has been detected on builder elfutils-fedora-x86_64 while 
building elfutils.

Full details are available at:
https://builder.sourceware.org/buildbot/#/builders/59/builds/307

Build state: failed test (failure)
Revision: 6228e2fedf419a7f1d70dc14a3b53a8a97394b88
Worker: bb2-1
Build Reason: (unknown)
Blamelist: Frederik “Freso” S. Olesen 

Steps:

- 0: worker_preparation ( success )

- 1: set package name ( success )

- 2: git checkout ( success )
Logs:
- stdio: 
https://builder.sourceware.org/buildbot/#/builders/59/builds/307/steps/2/logs/stdio

- 3: autoreconf ( success )
Logs:
- stdio: 
https://builder.sourceware.org/buildbot/#/builders/59/builds/307/steps/3/logs/stdio

- 4: configure ( success )
Logs:
- stdio: 
https://builder.sourceware.org/buildbot/#/builders/59/builds/307/steps/4/logs/stdio
- config.log: 
https://builder.sourceware.org/buildbot/#/builders/59/builds/307/steps/4/logs/config_log

- 5: get version ( success )
Logs:
- stdio: 
https://builder.sourceware.org/buildbot/#/builders/59/builds/307/steps/5/logs/stdio
- property changes: 
https://builder.sourceware.org/buildbot/#/builders/59/builds/307/steps/5/logs/property_changes

- 6: make ( warnings )
Logs:
- stdio: 
https://builder.sourceware.org/buildbot/#/builders/59/builds/307/steps/6/logs/stdio
- warnings (3): 
https://builder.sourceware.org/buildbot/#/builders/59/builds/307/steps/6/logs/warnings__3_

- 7: make check ( success )
Logs:
- stdio: 
https://builder.sourceware.org/buildbot/#/builders/59/builds/307/steps/7/logs/stdio
- test-suite.log: 
https://builder.sourceware.org/buildbot/#/builders/59/builds/307/steps/7/logs/test-suite_log

- 8: make distcheck ( warnings )
Logs:
- stdio: 
https://builder.sourceware.org/buildbot/#/builders/59/builds/307/steps/8/logs/stdio
- test-suite.log: 
https://builder.sourceware.org/buildbot/#/builders/59/builds/307/steps/8/logs/test-suite_log
- warnings (6): 
https://builder.sourceware.org/buildbot/#/builders/59/builds/307/steps/8/logs/warnings__6_

- 9: make rpmbuild ( failure )
Logs:
- stdio: 
https://builder.sourceware.org/buildbot/#/builders/59/builds/307/steps/9/logs/stdio
- warnings (31): 
https://builder.sourceware.org/buildbot/#/builders/59/builds/307/steps/9/logs/warnings__31_

- 10: prep ( success )
Logs:
- stdio: 
https://builder.sourceware.org/buildbot/#/builders/59/builds/307/steps/10/logs/stdio

- 11: build bunsen.cpio.gz ( success )
Logs:
- stdio: 
https://builder.sourceware.org/buildbot/#/builders/59/builds/307/steps/11/logs/stdio

- 12: fetch bunsen.cpio.gz ( success )
Logs:
- stdio: 
https://builder.sourceware.org/buildbot/#/builders/59/builds/307/steps/12/logs/stdio

- 13: unpack bunsen.cpio.gz ( success )
Logs:
- stdio: 
https://builder.sourceware.org/buildbot/#/builders/59/builds/307/steps/13/logs/stdio

- 14: pass .bunsen.source.gitname ( success )
Logs:
- stdio: 
https://builder.sourceware.org/buildbot/#/builders/59/builds/307/steps/14/logs/stdio

- 15: pass .bunsen.source.gitdescribe ( success )
Logs:
- stdio: 
https://builder.sourceware.org/buildbot/#/builders/59/builds/307/steps/15/logs/stdio

- 16: pass .bunsen.source.gitbranch ( success )
Logs:
- stdio: 
https://builder.sourceware.org/buildbot/#/builders/59/builds/307/steps/16/logs/stdio

- 17: pass .bunsen.source.gitrepo ( success )
Logs:
- stdio: 
https://builder.sourceware.org/buildbot/#/builders/59/builds/307/steps/17/logs/stdio

- 18: upload to bunsen ( success )
Logs:
- stdio: 
https://builder.sourceware.org/buildbot/#/builders/59/builds/307/steps/18/logs/stdio

- 19: clean up ( success )
Logs:
- stdio: 
https://builder.sourceware.org/buildbot/#/builders/59/builds/307/steps/19/logs/stdio

- 20: make distclean ( success )
Logs:
- stdio: 
https://builder.sourceware.org/buildbot/#/builders/59/builds/307/steps/20/logs/stdio



Re: [PATCH] Getter and setter for Dwfl's offline_next_address

2024-03-24 Thread Mark Wielaard
Hi Martin,

On Sun, Mar 24, 2024 at 11:11:21AM -0300, Martin Rodriguez Reboredo wrote:
> On 3/20/24 19:52, Mark Wielaard wrote:
> >Could you show an example of when/where you need it and what address
> >you set it to?
> 
> For example, this test program reports the name and location pointed by
> the passed address.
> 
> $ ./report /home/yakoyoku/.debug/.build-id/.../elf 0x0003281f
> 0x0003281f
> ??
> ??:0
> 
> But due to the mentioned bias both of them are unknown or out of range.
> 
> >The offline_next_address is only relevant for ET_REL files (like
> >object files or kernel modules). In general you will need to check the
> >bias, which various dwfl functions return to know the difference
> >between the addresses in the ELF, Dwarf or the module load address.
> >
> >That said, readelf, nm and dwfl_argp do "cheat" by setting the
> >offline_next_address to zero if they know they are just inspecting a
> >single object file. So maybe this is a functionality we need to
> >expose. But I don't fully understand why you need both a getter and a
> >setter for any arbitrary address.
> 
> I've erroneously thought that setting `offline_next_address` was a
> requirement to obtain what I've needed. But if I use
> `dwfl_module_getelf` or `dwfl_module_getdwarf` I can get the correct
> name and location.
> 
> 0x0003281f
> _ZNSt11__copy_moveILb0ELb0ESt26random_access_iterator_tagE8__copy_mIPcPhEET0_T_S6_S5_
> /usr/include/c++/13.2.1/bits/stl_algobase.h:388,18
> 
> So this patch is kinda pointless, but at least I've managed to learn
> what I was missing. Anyways, thanks for the heads-up. :)

I don't think it was pointless. Clearly our documentation is not very
good (and given eu-readelf and eu-nm do cheat, maybe our interface/api
isn't really good either).

Maybe you could post your code for that ./report program and what you
had to do to get it to print the correct address/symbols. Then we at
least have some documentation for others which hit the same issue.

Thanks,

Mark


Re: [PATCH v2] config: Add profile script for fish shell

2024-03-24 Thread Mark Wielaard
Hi Freso,

On Fri, Mar 22, 2024 at 06:21:04PM +0100, Frederik “Freso” S. Olesen wrote:
> Add support for setting $DEBUGINFOD_URLS automatically in the fish shell
> similar to the profile scripts for POSIX and csh shells.
> 
> Makefile is set to install this into fish’s $XDG_DATA_DIRS vendor
> directory instead of under /etc:
> https://fishshell.com/docs/current/language.html#configuration-files
> 
>   * config/profile.fish.in: Set $DEBUGINFOD_URLS in fish shells.
>   * configure.ac, config/Makefile.am: Include profile.fish in
> install and uninstall targets.

Looks good. Pushed.

Thanks,

Mark



Re: [PATCH] Getter and setter for Dwfl's offline_next_address

2024-03-24 Thread Martin Rodriguez Reboredo

On 3/20/24 19:52, Mark Wielaard wrote:

Hi Martin,

On Wed, Mar 06, 2024 at 04:22:49PM -0300, Martin Rodriguez Reboredo wrote:

Added new functions dwfl_get_offline_next_address and
dwfl_set_offline_next_address which will get plus set said field from
the Dwfl struct. This is a requirement for listing functions from their
addresses when using libdwfl offline, otherwise wrong symbols are going
to be returned.


Could you show an example of when/where you need it and what address
you set it to?


For example, this test program reports the name and location pointed by
the passed address.

$ ./report /home/yakoyoku/.debug/.build-id/.../elf 0x0003281f
0x0003281f
??
??:0

But due to the mentioned bias both of them are unknown or out of range.


The offline_next_address is only relevant for ET_REL files (like
object files or kernel modules). In general you will need to check the
bias, which various dwfl functions return to know the difference
between the addresses in the ELF, Dwarf or the module load address.

That said, readelf, nm and dwfl_argp do "cheat" by setting the
offline_next_address to zero if they know they are just inspecting a
single object file. So maybe this is a functionality we need to
expose. But I don't fully understand why you need both a getter and a
setter for any arbitrary address.


I've erroneously thought that setting `offline_next_address` was a
requirement to obtain what I've needed. But if I use
`dwfl_module_getelf` or `dwfl_module_getdwarf` I can get the correct
name and location.

0x0003281f
_ZNSt11__copy_moveILb0ELb0ESt26random_access_iterator_tagE8__copy_mIPcPhEET0_T_S6_S5_
/usr/include/c++/13.2.1/bits/stl_algobase.h:388,18

So this patch is kinda pointless, but at least I've managed to learn
what I was missing. Anyways, thanks for the heads-up. :)