]> git.ipfire.org Git - thirdparty/elfutils.git/commitdiff
src/stackprof.cxx dwfl_module_relocate_address: ship it
authorSerhei Makarov <serhei@serhei.io>
Fri, 30 Jan 2026 15:50:54 +0000 (10:50 -0500)
committerSerhei Makarov <serhei@serhei.io>
Fri, 30 Jan 2026 15:50:57 +0000 (10:50 -0500)
fche was concerned re: whether it works on shared libraries; but
worksforme, and this is the code we need to test, so enabling it.

Without the relocations, not only is the resulting output not
decodable (raw pcs) but systemwide profiles produce a giant histogram.

src/stackprof.cxx

index cbb85d24f24a62963384db438449708024d2a8a7..6c77f926469723b6904af332c22d37aa40769f4a 100644 (file)
@@ -1801,13 +1801,13 @@ void GprofUnwindSampleConsumer::process(const UnwindSample *sample)
   Elf *elf = dwfl_module_getelf (mod, &bias);
   (void)elf;
 #endif
-  
+
   Dwfl_Module *mod2 = dwfl_addrmodule(sample->dwfl, pc2);
   if (mod2 == NULL)
     return;
   // If caller & callee are in different modules, this is a cross-shared-library
   // call, so we can't track it as a call-graph arc.  XXX: at least count them 
-  
+
   // extract buildid for pc (hit callee)
   const unsigned char *desc = nullptr;
   GElf_Addr vaddr;
@@ -1824,9 +1824,10 @@ void GprofUnwindSampleConsumer::process(const UnwindSample *sample)
 
   UnwindModuleStats *buildid_ent = this->stats->buildid_find_or_create(buildid, mod);
 
-  // int i = dwfl_module_relocate_address (mod, &pc);
+  int i = dwfl_module_relocate_address (mod, &pc);
+  (void) i;
   #if 0
-  (void) i; // XXX: for now, ignore relocation-basis section name or whatever
+  // XXX: for now, ignore relocation-basis section name or whatever
   const char *name;
   if (i >= 0)
     name = dwfl_module_relocation_info (mod, i, NULL);
@@ -1835,7 +1836,8 @@ void GprofUnwindSampleConsumer::process(const UnwindSample *sample)
 
   if (mod == mod2) // intra-module call
     {
-      // int j = dwfl_module_relocate_address (mod, &pc2); // map pc2 also
+      int j = dwfl_module_relocate_address (mod, &pc2); // map pc2 also
+      (void) j;
       buildid_ent->record_callgraph_arc(pc2, pc);
     }
 }