]> git.ipfire.org Git - thirdparty/elfutils.git/log
thirdparty/elfutils.git
21 hours agosrc/stackprof.cxx: fully deal with REVIEW.1 users/fche/eu-stackprof
Serhei Makarov [Thu, 9 Apr 2026 15:21:11 +0000 (11:21 -0400)] 
src/stackprof.cxx: fully deal with REVIEW.1

Satisfied with how the output looks at
- fixed some stray whitespace
- suppress (clearly marked) repeated 'address out of range' after 10th
  time for each given pid
  -- it's just the same uninformative error repeated, which clutters
  output considerably
- keep the 'perf_event_attr configuration' message at all levels
  -- aesthetics arguable, but showing sample_freq is useful

40 hours agosrc/stackprof.cxx: mostly deal with REVIEW.1
Serhei Makarov [Wed, 8 Apr 2026 20:17:24 +0000 (16:17 -0400)] 
src/stackprof.cxx: mostly deal with REVIEW.1

-v now shows only the first sample for each new process
-vv shows one line per sample
-vvv shows one line per frame

2 days agosrc/stackprof.cxx: annoying/possible fix for REVIEW.8, feel free to savagely modify...
Serhei Makarov [Tue, 7 Apr 2026 21:27:50 +0000 (17:27 -0400)] 
src/stackprof.cxx: annoying/possible fix for REVIEW.8, feel free to savagely modify/revert if not to taste

2 days agosrc/stackprof.cxx: fixups in prior
Serhei Makarov [Tue, 7 Apr 2026 21:24:18 +0000 (17:24 -0400)] 
src/stackprof.cxx: fixups in prior

- clog/cerr division is ok
- mainfile can also be null
- if we deliberately limit maxframes<=2, the heuristic
  flagging fewer than 2 frames as a 'lost' sample is inapplicable

and

- opt_maxframes relates to the user deliberately choosing to
  override GprofUnwindSampleConsumer preference with --maxframes
  (which I consider useful sometimes for testing):
  if --maxframes is provided, then use the default of 1.

5 days agostackprof: minor c++ificiation (less C str*)
Frank Ch. Eigler [Sun, 5 Apr 2026 02:19:09 +0000 (22:19 -0400)] 
stackprof: minor c++ificiation (less C str*)

7 days agosrc/stackprof.cxx: more REVIEW, mostly 1 + consistent maxframes
Serhei Makarov [Thu, 2 Apr 2026 20:42:18 +0000 (16:42 -0400)] 
src/stackprof.cxx: more REVIEW, mostly 1 + consistent maxframes

7 days agosrc/stackprof.cxx: more REVIEW TODO_AMEND
Serhei Makarov [Thu, 2 Apr 2026 17:10:30 +0000 (13:10 -0400)] 
src/stackprof.cxx: more REVIEW TODO_AMEND

9 days agoREVIEW.9 REVIEW.12 noop; remove unneeded function
Frank Ch. Eigler [Tue, 31 Mar 2026 23:14:06 +0000 (19:14 -0400)] 
REVIEW.9 REVIEW.12 noop; remove unneeded function

9 days agostackprof REVIEW.7
Frank Ch. Eigler [Tue, 31 Mar 2026 22:35:09 +0000 (18:35 -0400)] 
stackprof REVIEW.7

9 days agohandle REVIEW.5
Frank Ch. Eigler [Tue, 31 Mar 2026 21:36:31 +0000 (17:36 -0400)] 
handle REVIEW.5

9 days agostackprof: c++20ification of comm, file processing, diagnostic formatting
Frank Ch. Eigler [Tue, 31 Mar 2026 21:30:14 +0000 (17:30 -0400)] 
stackprof: c++20ification of comm, file processing, diagnostic formatting

9 days agohandle REVIEW.3
Frank Ch. Eigler [Tue, 31 Mar 2026 20:11:47 +0000 (16:11 -0400)] 
handle REVIEW.3

9 days agosrc/stackprof.cxx: make sure output streams are consistent
Serhei Makarov [Tue, 31 Mar 2026 16:16:18 +0000 (12:16 -0400)] 
src/stackprof.cxx: make sure output streams are consistent

clog is for data, cerr for stuff that says WARNING/ERROR

cout/fprintf are not used

2 weeks agosrc/stackprof.cxx: mark REVIEW issues, still wip
Serhei Makarov [Wed, 25 Mar 2026 22:04:10 +0000 (18:04 -0400)] 
src/stackprof.cxx: mark REVIEW issues, still wip

2 weeks agosrc/stackprof.cxx: ws fixy (separately from review changes)
Serhei Makarov [Mon, 23 Mar 2026 15:53:01 +0000 (11:53 -0400)] 
src/stackprof.cxx: ws fixy (separately from review changes)

Round of whitespace cleanup with M-x tabify to fit elfutils
indentation. Previously was a chaotic tabs/spaces mix.

2 weeks agosrc/stackprof.cxx: one more piece to enable arm
Serhei Makarov [Fri, 20 Mar 2026 18:32:36 +0000 (14:32 -0400)] 
src/stackprof.cxx: one more piece to enable arm

3 weeks agostackprof.cxx: WIP aarch64/armhfp bits
Serhei Makarov [Tue, 17 Mar 2026 20:47:01 +0000 (16:47 -0400)] 
stackprof.cxx: WIP aarch64/armhfp bits

3 weeks agolibdwfl/linux-pid-attach.c PR33974: __libdwfl_set_initial_registers_thread on non...
Serhei Makarov [Fri, 13 Mar 2026 15:06:03 +0000 (11:06 -0400)] 
libdwfl/linux-pid-attach.c PR33974: __libdwfl_set_initial_registers_thread on non-Linux

libdwfl_stacktrace uses __libdwfl_set_initial_registers_thread but it
is wrapped by #ifdef __linux__, causing build errors on non-Linux
platforms.

* linux-pid-attach.c (__libdwfl_set_initial_registers_thread):
  Remove from inside the '#ifdef __linux__'.
* dwfl_frame_regs.c (__libdwfl_set_initial_registers_thread):
  Move here.

3 weeks agoRevert "libdwfl/linux-pid-attach.c PR33974: __libdwfl_set_initial_registers_thread...
Serhei Makarov [Fri, 13 Mar 2026 15:03:01 +0000 (11:03 -0400)] 
Revert "libdwfl/linux-pid-attach.c PR33974: __libdwfl_set_initial_registers_thread on non-Linux"

This reverts commit da0809709ac5d3da820479015e7a9fe81b896c02.

3 weeks agolibdwfl/linux-pid-attach.c PR33974: __libdwfl_set_initial_registers_thread on non...
Serhei Makarov [Fri, 13 Mar 2026 15:00:53 +0000 (11:00 -0400)] 
libdwfl/linux-pid-attach.c PR33974: __libdwfl_set_initial_registers_thread on non-Linux

libdwfl_stacktrace uses __libdwfl_set_initial_registers_thread but it
is wrapped by #ifdef __linux__, causing build errors on non-Linux
platforms.

* linux-pid-attach.c (__libdwfl_set_initial_registers_thread): Unwrap
  from the #ifdef.

6 weeks agosrc/stackprof.cxx: minor oops for pc2 range check
Serhei Makarov [Thu, 26 Feb 2026 17:11:06 +0000 (12:11 -0500)] 
src/stackprof.cxx: minor oops for pc2 range check

6 weeks agosrc/stackprof.cxx: Restrict recorded pcs to mod->low_addr..high_addr
Serhei Makarov [Thu, 26 Feb 2026 17:03:45 +0000 (12:03 -0500)] 
src/stackprof.cxx: Restrict recorded pcs to mod->low_addr..high_addr

This covers the ld-linux.so out-of-range pc. Not seeing the range
check being triggered for any other modules.

8 weeks agostackprof testsuite++
Frank Ch. Eigler [Thu, 12 Feb 2026 18:25:19 +0000 (13:25 -0500)] 
stackprof testsuite++

Now including run-stackprof-system* tests, which only run as root, and
can require several minutes to run (with gprof downloading/processing
large debuginfo files if you happen to be running large gui programs
while this test runs).

8 weeks agostackprof: testsuite++ now with gprof + debuginfod
Frank Ch. Eigler [Thu, 12 Feb 2026 15:53:23 +0000 (10:53 -0500)] 
stackprof: testsuite++ now with gprof + debuginfod

switched back to "even" hashtable splitting mode, fixed an off-by-one

8 weeks agostackprof: start adding test cases
Frank Ch. Eigler [Thu, 12 Feb 2026 03:11:34 +0000 (22:11 -0500)] 
stackprof: start adding test cases

8 weeks agostackprof.cxx snap: misc histogram splitting options
Serhei Makarov [Mon, 9 Feb 2026 20:26:58 +0000 (15:26 -0500)] 
stackprof.cxx snap: misc histogram splitting options

HIST_SPLIT_EVEN is a sketch (WIP / testing in progress) of how to
cover the space with histograms of equal size.

Even if we solve the ld-linux.so stray untranslated addresses, there
may be an argument to save space by splitting histograms when
collecting profiledb data in bulk. Good to have this code for the
record.

8 weeks agostackprof.cxx minor fixes: accumulate at least histogram hit even without callgraph
Serhei Makarov [Mon, 9 Feb 2026 17:24:07 +0000 (12:24 -0500)] 
stackprof.cxx minor fixes: accumulate at least histogram hit even without callgraph

8 weeks agostackprof.cxx minor fixes: tweak the maxframes logic
Serhei Makarov [Mon, 9 Feb 2026 17:14:12 +0000 (12:14 -0500)] 
stackprof.cxx minor fixes: tweak the maxframes logic

Since this is now an intended performance optimization (unwind exactly
N frames) rather than a rough safety tripwire, make sure the number of
frames returned is exact.

2 months agostackprof.cxx snap: pc-relocation investigation still WIP
Serhei Makarov [Fri, 6 Feb 2026 19:51:22 +0000 (14:51 -0500)] 
stackprof.cxx snap: pc-relocation investigation still WIP

2 months agocherrypick PR33854 fix from main branch
Serhei Makarov [Thu, 29 Jan 2026 17:27:50 +0000 (12:27 -0500)] 
cherrypick PR33854 fix from main branch

only difference to draft fix already in branch is in freeing
sample_arg on attach failure

== original commit:

PR33854: fix regression in dwflst_perf_sample_getframes

In commit 3ce0d5ed, I missed the fact that
dwflst_perf_sample_getframes needs to handle the case of an unattached
Dwfl, when dwfl->process->ebl is not yet available to translate the
registers. Thus, it can't be a straightforward wrapper of
dwfl_sample_getframes, but should instead handle the attaching logic
identically to that function.

Also fix a leakage of sample_arg in dwflst_sample_getframes that was
happening on attach failure.

* libdwfl_stacktrace (dwflst_sample_getframes): Fix a leak of
  sample_arg on attach failure.
* libdwfl_stacktrace (dwflst_perf_sample_getframes): Implement
  attaching the Dwfl identically to dwflst_sample_getframes.
  Avoid leaking sample_arg on attach failure.

Signed-off-by: Serhei Makarov <serhei@serhei.io>
2 months agostackprof: remove unused code, add "-f" force output mode
Frank Ch. Eigler [Wed, 4 Feb 2026 14:58:13 +0000 (09:58 -0500)] 
stackprof: remove unused code, add "-f" force output mode

2 months agostackprof: some valgrind fixes
Frank Ch. Eigler [Tue, 3 Feb 2026 23:41:48 +0000 (18:41 -0500)] 
stackprof: some valgrind fixes

2 months agomore c++20 format conversion
Frank Ch. Eigler [Tue, 3 Feb 2026 22:03:55 +0000 (17:03 -0500)] 
more c++20 format conversion

2 months agoc++20 format() conversion for most clog/cerr/stringstream stuff
Frank Ch. Eigler [Tue, 3 Feb 2026 21:45:28 +0000 (16:45 -0500)] 
c++20 format() conversion for most clog/cerr/stringstream stuff

2 months agostackprof: demo c++20 format{}
Frank Ch. Eigler [Tue, 3 Feb 2026 20:47:13 +0000 (15:47 -0500)] 
stackprof: demo c++20 format{}

2 months agosrc/stackprof.cxx snap: basic json metadata, per-file cf fche's suggestion
Serhei Makarov [Tue, 3 Feb 2026 20:42:44 +0000 (15:42 -0500)] 
src/stackprof.cxx snap: basic json metadata, per-file cf fche's suggestion

2 months agojust for fun: require c++20 for c++ application code in elfutils
Frank Ch. Eigler [Tue, 3 Feb 2026 20:27:44 +0000 (15:27 -0500)] 
just for fun: require c++20 for c++ application code in elfutils

2 months agostackprof: add gmon.*.exe symlink sibling for gmon.*.out
Frank Ch. Eigler [Tue, 3 Feb 2026 19:28:08 +0000 (14:28 -0500)] 
stackprof: add gmon.*.exe symlink sibling for gmon.*.out

2 months agostackprof, fprintf--
Frank Ch. Eigler [Tue, 3 Feb 2026 01:18:12 +0000 (20:18 -0500)] 
stackprof, fprintf--

2 months agosrc/stackprof.cxx crackle: address +2 review comments, remove _DwflHack
Serhei Makarov [Tue, 3 Feb 2026 17:42:41 +0000 (12:42 -0500)] 
src/stackprof.cxx crackle: address +2 review comments, remove _DwflHack

The canonical way to check if a dwfl is attached is with dwfl_pid()!=-1.

2 months agosnap
Frank Ch. Eigler [Mon, 2 Feb 2026 17:28:23 +0000 (12:28 -0500)] 
snap

2 months agosrc/stackprof.cxx crackle: obtain/show executable paths in the final report
Serhei Makarov [Fri, 30 Jan 2026 16:20:09 +0000 (11:20 -0500)] 
src/stackprof.cxx crackle: obtain/show executable paths in the final report

Initial step to generating a metadata file with this info for
profiledb use.

2 months agosrc/stackprof.cxx dwfl_module_relocate_address: ship it
Serhei Makarov [Fri, 30 Jan 2026 15:50:54 +0000 (10:50 -0500)] 
src/stackprof.cxx dwfl_module_relocate_address: ship it

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.

2 months agorework gmon.out header/content
Frank Ch. Eigler [Fri, 30 Jan 2026 03:09:21 +0000 (22:09 -0500)] 
rework gmon.out header/content

- matched against gperf and gmon2profdata parsers
- not tested against shared libraries quite, will likely need some address translation (#if-0'd code)

2 months agostackprof.cxx crackle: output mainfile/debugfile for buildid
Serhei Makarov [Mon, 26 Jan 2026 18:50:43 +0000 (13:50 -0500)] 
stackprof.cxx crackle: output mainfile/debugfile for buildid

Without this info, finding the executable matching each gmon.out file
becomes a pain. Looks like there is still debugging to be done.

2 months agostackprof.cxx, snap: getting closer with the histogram generation
Serhei Makarov [Fri, 23 Jan 2026 21:23:14 +0000 (16:23 -0500)] 
stackprof.cxx, snap: getting closer with the histogram generation

A couple more things to doublecheck:
- alignment calculation logic for low_pc..high_pc
- bins.size() sometimes reported as 0, should not happen?

2 months agostackprof.cxx snap: add gmon.out generation, still need to split histograms
Serhei Makarov [Thu, 22 Jan 2026 20:20:03 +0000 (15:20 -0500)] 
stackprof.cxx snap: add gmon.out generation, still need to split histograms

2 months agostackprof.cxx snap: unwind arc gathering for now
Serhei Makarov [Mon, 19 Jan 2026 20:21:26 +0000 (15:21 -0500)] 
stackprof.cxx snap: unwind arc gathering for now

gmon.out format writing still WIP

2 months agostackprof.cxx, snap: print stats table
Serhei Makarov [Fri, 16 Jan 2026 20:34:45 +0000 (15:34 -0500)] 
stackprof.cxx, snap: print stats table

(gmon output still WIP)

2 months agostackprof.cxx, snap: more REVIEW issues, one remains
Serhei Makarov [Fri, 9 Jan 2026 20:36:18 +0000 (15:36 -0500)] 
stackprof.cxx, snap: more REVIEW issues, one remains

3 months agostackprof.cxx, snap: fix some REVIEW issues
Serhei Makarov [Thu, 8 Jan 2026 19:17:25 +0000 (14:17 -0500)] 
stackprof.cxx, snap: fix some REVIEW issues

3 months agostackprof.cxx, snap: initial working unwinder, some cleanup/REVIEW WIP
Serhei Makarov [Wed, 7 Jan 2026 15:21:25 +0000 (10:21 -0500)] 
stackprof.cxx, snap: initial working unwinder, some cleanup/REVIEW WIP

3 months agostackprof.cxx: quick ws fixy
Serhei Makarov [Mon, 5 Jan 2026 17:35:59 +0000 (12:35 -0500)] 
stackprof.cxx: quick ws fixy

3 months agostackprof.cxx: add --event-list option, fix disabled=false init
Frank Ch. Eigler [Tue, 23 Dec 2025 01:51:33 +0000 (20:51 -0500)] 
stackprof.cxx: add --event-list option, fix disabled=false init

3 months agostackprof.cxx: add baby class purpose docs, tweak formatting, move around pure/stats...
Frank Ch. Eigler [Mon, 22 Dec 2025 23:22:06 +0000 (18:22 -0500)] 
stackprof.cxx: add baby class purpose docs, tweak formatting, move around pure/stats stuff

3 months agomore roughing in
Frank Ch. Eigler [Mon, 22 Dec 2025 18:43:36 +0000 (13:43 -0500)] 
more roughing in

3 months agostackprof.cxx: position event type decoding logic & virtual functions better
Frank Ch. Eigler [Mon, 22 Dec 2025 18:36:25 +0000 (13:36 -0500)] 
stackprof.cxx: position event type decoding logic & virtual functions better

No obvious need for a PerfSample POD type, when the decoded event
fields can be passed to purposeful functions.

3 months agoMerge remote-tracking branch 'origin/users/fche/eu-stackprof' into users/fche/eu...
Frank Ch. Eigler [Mon, 22 Dec 2025 18:23:44 +0000 (13:23 -0500)] 
Merge remote-tracking branch 'origin/users/fche/eu-stackprof' into users/fche/eu-stackprof

* origin/users/fche/eu-stackprof:
  oops
  crackle: icebreaker commit pre hook up unwinder

3 months agooops
Serhei Makarov [Thu, 18 Dec 2025 21:21:51 +0000 (16:21 -0500)] 
oops

3 months agocrackle: icebreaker commit pre hook up unwinder
Serhei Makarov [Thu, 18 Dec 2025 21:04:34 +0000 (16:04 -0500)] 
crackle: icebreaker commit pre hook up unwinder

3 months agosnap
Frank Ch. Eigler [Wed, 17 Dec 2025 17:27:41 +0000 (12:27 -0500)] 
snap

3 months agoadd perf event decoding, with drafting help from grok
Frank Ch. Eigler [Tue, 16 Dec 2025 00:36:27 +0000 (19:36 -0500)] 
add perf event decoding, with drafting help from grok

3 months agorough in perf record decoding -> virt functions
Frank Ch. Eigler [Mon, 15 Dec 2025 23:28:37 +0000 (18:28 -0500)] 
rough in perf record decoding -> virt functions

3 months agoMerge remote-tracking branch 'origin/users/serhei/eu-stacktrace-gmon' into users...
Frank Ch. Eigler [Fri, 12 Dec 2025 18:23:52 +0000 (13:23 -0500)] 
Merge remote-tracking branch 'origin/users/serhei/eu-stacktrace-gmon' into users/fche/eu-stackprof

* origin/users/serhei/eu-stacktrace-gmon:
  WIP eu-stacktrace: another error fix, profiling runs now
  WIP eu-stacktrace: another error fixed
  WIP libdwfl_stacktrace: regression in dwflst_perf_sample_getframes ?

3 months agosnap
Frank Ch. Eigler [Fri, 12 Dec 2025 18:23:38 +0000 (13:23 -0500)] 
snap

3 months agoWIP eu-stacktrace: another error fix, profiling runs now users/serhei/eu-stacktrace-gmon
Serhei Makarov [Fri, 12 Dec 2025 17:23:09 +0000 (12:23 -0500)] 
WIP eu-stacktrace: another error fix, profiling runs now

3 months agoWIP eu-stacktrace: another error fixed
Serhei Makarov [Fri, 12 Dec 2025 17:03:53 +0000 (12:03 -0500)] 
WIP eu-stacktrace: another error fixed

3 months agoWIP libdwfl_stacktrace: regression in dwflst_perf_sample_getframes ?
Serhei Makarov [Fri, 12 Dec 2025 16:57:37 +0000 (11:57 -0500)] 
WIP libdwfl_stacktrace: regression in dwflst_perf_sample_getframes ?

3 months agoMerge remote-tracking branch 'origin/users/serhei/eu-stacktrace-gmon' into users...
Frank Ch. Eigler [Wed, 10 Dec 2025 21:23:30 +0000 (16:23 -0500)] 
Merge remote-tracking branch 'origin/users/serhei/eu-stacktrace-gmon' into users/fche/eu-stackprof

* origin/users/serhei/eu-stacktrace-gmon:
  WIP eu-stacktrace: bugfix for PerfSample struct

3 months agoWIP eu-stacktrace: bugfix for PerfSample struct
Serhei Makarov [Wed, 10 Dec 2025 18:25:56 +0000 (13:25 -0500)] 
WIP eu-stacktrace: bugfix for PerfSample struct

3 months agoMerge remote-tracking branch 'origin/users/serhei/eu-stacktrace-gmon' into users...
Frank Ch. Eigler [Wed, 10 Dec 2025 00:23:16 +0000 (19:23 -0500)] 
Merge remote-tracking branch 'origin/users/serhei/eu-stacktrace-gmon' into users/fche/eu-stackprof

* origin/users/serhei/eu-stacktrace-gmon:
  WIP eu-stacktrace: hook up perf_events to unwinding (still errors)

4 months agoWIP eu-stacktrace: hook up perf_events to unwinding (still errors)
Serhei Makarov [Tue, 9 Dec 2025 17:29:47 +0000 (12:29 -0500)] 
WIP eu-stacktrace: hook up perf_events to unwinding (still errors)

4 months agoverbosity perf-attrs
Frank Ch. Eigler [Tue, 9 Dec 2025 03:00:29 +0000 (22:00 -0500)] 
verbosity perf-attrs

4 months agosnap
Frank Ch. Eigler [Tue, 9 Dec 2025 00:22:48 +0000 (19:22 -0500)] 
snap

4 months agostackprof += libpfm
Frank Ch. Eigler [Mon, 8 Dec 2025 23:52:28 +0000 (18:52 -0500)] 
stackprof += libpfm

try   -e PERF_COUNT_SW_CPU_CLOCK:period=1000

4 months agosnap
Frank Ch. Eigler [Sun, 7 Dec 2025 21:01:03 +0000 (16:01 -0500)] 
snap

4 months agosnap
Frank Ch. Eigler [Sun, 7 Dec 2025 20:50:28 +0000 (15:50 -0500)] 
snap

4 months agosnap
Frank Ch. Eigler [Sun, 7 Dec 2025 20:16:17 +0000 (15:16 -0500)] 
snap

4 months agosnap
Frank Ch. Eigler [Sun, 7 Dec 2025 02:26:49 +0000 (21:26 -0500)] 
snap

4 months agosnap
Frank Ch. Eigler [Sat, 6 Dec 2025 19:11:22 +0000 (14:11 -0500)] 
snap

4 months agoWIP eu-stacktrace: perf_copy_event_simple bugfixes
Serhei Makarov [Wed, 3 Dec 2025 17:20:51 +0000 (12:20 -0500)] 
WIP eu-stacktrace: perf_copy_event_simple bugfixes

A bunch of oops when writing this code.

4 months agoWIP eu-stacktrace: perf_events input support
Serhei Makarov [Tue, 2 Dec 2025 20:10:34 +0000 (15:10 -0500)] 
WIP eu-stacktrace: perf_events input support

(Still mid-refactor, but sharing for fche.)

5 months agosrc/stacktrace.c: Add an option to print build-ids. users/serhei/eu-stacktrace
Serhei Makarov [Thu, 6 Nov 2025 17:28:35 +0000 (12:28 -0500)] 
src/stacktrace.c: Add an option to print build-ids.

In preparation for adapting eu-stacktrace to gmon.out generation,
print out per-frame build-ids to sanitycheck the data.

* src/stacktrace.c (show_buildids): New global variable.
  (struct sysprof_unwind_info): Enable sui->last_dwfl.
  (sysprof_unwind_frame_cb): Obtain and print build-id.
  (sysprof_unwind_cb): Enable sui->last_dwfl.
  (parse_opt): Accept --buildid option.
  (main): Accept --buildid option and env var setting.

5 months agolibdwfl_stacktrace + libebl: dwflst_sample_getframes non-perf api
Serhei Makarov [Fri, 12 Sep 2025 20:00:16 +0000 (16:00 -0400)] 
libdwfl_stacktrace + libebl: dwflst_sample_getframes non-perf api

This patch adds a generic dwflst_sample_getframes() API that does not
depend on perf_events concepts, in particular the
linux-kernel-specific enum defining the perf_regs_mask register order.
This involves reworking the register-handling backend to use
regs_mapping arrays rather than perf_regs_mask, and provide a way to
translate perf_regs_mask to regs_mapping.

A regs_mapping array, for each item in a provided regs[] array,
specifies its position in the full register file expected by the DWARF
functionality.

Changes for v3:
- Added dwflst_sample_getframes to libdw.map.

Changes for v2:
- Addressed Aaron Merey's review comments.
- Removed dwflst_sample_frame.c dependency on perf_events abi constants.

* libdwfl_stacktrace/Makefile.am: Rename dwflst_sample_frame.c from
  dwflst_perf_frame.c.
* libdwfl_stacktrace/libdwfl_stacktrace.h (dwflst_sample_getframes):
  New function providing unwinding functionality with a regs_mapping
  array rather than a linux-kernel-dependent perf_regs_mask.
* libdw/libdw.map (ELFUTILS_0.193_EXPERIMENTAL): Add dwflst_sample_getframes.
* libdwfl_stacktrace/dwflst_sample_frame.c: Renamed from
  dwflst_perf_frame.c. Remove linux/perf_event.h dependency.
  (struct sample_info): Rename from perf_sample_info, include
  regs_mapping field, replace abi with elfclass field.
  (sample_next_thread): Renamed struct sample_info.
  (sample_getthread): Renamed struct sample_info.
  (copy_word): Use elfclass instead of perf abi field.
  (elf_memory_read): Renamed struct sample_info, use elfclass.
  (sample_memory_read): Renamed struct sample_info, use elfclass.
  (sample_set_initial_registers): Renamed struct sample_info,
  pass regs_mapping to ebl_set_initial_registers_sample.
  (dwflst_sample_getframes): New function.
  (dwflst_perf_sample_getframes): Reimplement in terms of
  dwflst_sample_getframes and ebl_sample_perf_regs_mapping.
* libebl/ebl-hooks.h (set_initial_registers_sample): Now
  takes regs_mapping instead of regs_mask.
  (sample_base_addr): Removed.
  (sample_pc): Removed.
  (sample_sp_pc): New function combining the removed functions for
  efficiency.
  (sample_perf_regs_mapping): New function translating
  perf_regs_mask to regs_mapping array.
* libebl/eblinitreg_sample.c (ebl_sample_base_addr): Removed.
  (ebl_sample_pc): Removed.
  (ebl_sample_sp_pc): New function.
  (ebl_set_initial_registers_sample): Take regs_mapping, provide
  a default implementation for contiguous dwarf_regs array.
  (ebl_sample_perf_regs_mapping): New function.
* libebl/eblclosebackend.c (ebl_closebackend):
  Free cached_regs_mapping.
* libebl/libebl.h (ebl_set_initial_registers_sample): Now takes
  regs_mapping instead of regs_mask.
  (ebl_sample_base_addr): Removed.
  (ebl_sample_pc): Removed.
  (ebl_sample_sp_pc): New function.
  (ebl_sample_perf_regs_mapping): New function.
* libebl/libeblP.h (struct ebl): Add caching fields to remove the
  need to repeat a sample_perf_regs_mapping() computation for
  every frame when the perf_regs_mask is consistent.
* backends/Makefile.am: Remove no-longer-needed linux-perf-regs.c.
* backends/i386_init.c (i386_init): Renamed sample_* functions,
  added cached_regs_mapping and related fields/functions.
* backends/i386_initreg_sample.c (i386_sample_base_addr): Removed.
  (i386_sample_pc): Removed.
  (i386_sample_sp_pc): New function combining the removed functions.
  (i386_set_initial_registers_sample): Removed.
  (i386_sample_perf_regs_mapping): New function translating
  perf_regs_mask to regs_mapping array.
* backends/linux-perf-regs.c: Removed as perf_sample_find_reg is no
  longer needed.
* backends/x86_64_init.c (x86_64_init): Renamed sample_* functions,
  added cached_regs_mapping and related fields/functions.
* backends/x86_64_initreg_sample.c (x86_64_sample_base_addr): Removed.
  (x86_64_sample_pc): Removed.
  (x86_64_sample_sp_pc): New function combining the removed functions.
  (x86_64_set_initial_registers_sample): Removed.
  (x86_64_sample_perf_regs_mapping): New function translating
  perf_regs_mask to regs_mapping array.
* backends/x86_initreg_sample.c (x86_set_initial_registers_sample):
  Removed.
  (x86_sample_sp_pc): New function.
  (x86_sample_perf_regs_mapping): New function translating
  perf_regs_mask to regs_mapping array.

7 months agolibdwfl_stacktrace: fix non-Linux build dep on PERF_SAMPLE_REGS_ABI
Serhei Makarov [Mon, 8 Sep 2025 16:10:54 +0000 (12:10 -0400)] 
libdwfl_stacktrace: fix non-Linux build dep on PERF_SAMPLE_REGS_ABI

Reported on a GNU Hurd build of elfutils. This is a quick fix pending
my more complex patch to reduce dependency on linux perf concepts for
the libdwfl_stacktrace code.

* libdwfl_stacktrace/dwflst_perf_frame.c (perf_sample_regs_abi):
  Define this Linux enum on non-Linux platforms.

10 months agotests/run-stack-live-test.sh: document buildbot results
Serhei Makarov [Fri, 9 May 2025 13:39:43 +0000 (09:39 -0400)] 
tests/run-stack-live-test.sh: document buildbot results

Gives an idea of how much more flexibility is needed for the munging
to work across a variety of systems. Also concerned that elfutils
certainly runs on non-linux non-GLIBC systems too, worth a brief test
on musl and bsd?

10 months agotests/run-stack-live-test.sh: misc fixes
Serhei Makarov [Fri, 9 May 2025 13:37:55 +0000 (09:37 -0400)] 
tests/run-stack-live-test.sh: misc fixes

* tests/Makefile.am (EXTRA_DIST): Add run-stack-live-test.sh for
  distcheck.
* tests/run-stack-live-test.sh: Fix whitespace.

10 months agotests/run-stack-live-test.sh: prototype 'live' eu-stack testing
Serhei Makarov [Thu, 8 May 2025 22:17:45 +0000 (18:17 -0400)] 
tests/run-stack-live-test.sh: prototype 'live' eu-stack testing

Missing a few pieces, but worth sharing as an RFC. My idea is to
ensure better test coverage for eu-stack and then
eu-stacktrace+libdwfl_stacktrace by running against a live process
with known content, stopped at a known location, and aggressively
scrubbing output that's known to vary from testrun to testrun.

This is a very basic preview of how that might look. If the approach
is sound, I hope to make it more sophisticated/reliable.

Unanswered questions:
- Scrub more data (e.g. libc symvers) from a more known program.
  Scrub stack frame numbers to account for a case where extra frames
  appear / are missing at the bottom of the stack?
- Something better than sed for the scrubbing?
- An equivalent eu-stacktrace test will require privileged perf_events
  access for profiling data and therefore likely to be skipped by
  default. How feasible is it to be enabled on the buildbots, though?

* tests/run-stack-live-test.sh: New test with wild and fuzzy
  testrun_compare variant that scrubs inherently unpredictable parts of
  the data. Needs to scrub even more.
* tests/Makefile.am (TESTS): Add run-stack-live-test.sh.

10 months agoREADME.eu-stacktrace: begin 3nd round of development based on merged code
Serhei Makarov [Fri, 18 Oct 2024 21:02:38 +0000 (17:02 -0400)] 
README.eu-stacktrace: begin 3nd round of development based on merged code

10 months agodoc: Add elf_kind.3
Aaron Merey [Tue, 13 May 2025 00:33:41 +0000 (20:33 -0400)] 
doc: Add elf_kind.3

Signed-off-by: Aaron Merey <amerey@redhat.com>
10 months agodoc: Add elf_hash.3
Aaron Merey [Tue, 13 May 2025 00:33:40 +0000 (20:33 -0400)] 
doc: Add elf_hash.3

Signed-off-by: Aaron Merey <amerey@redhat.com>
10 months agodoc: Add elf_getbase.3
Aaron Merey [Tue, 13 May 2025 00:33:39 +0000 (20:33 -0400)] 
doc: Add elf_getbase.3

Signed-off-by: Aaron Merey <amerey@redhat.com>
10 months agodoc: Add elf_fill.3
Aaron Merey [Tue, 13 May 2025 00:33:38 +0000 (20:33 -0400)] 
doc: Add elf_fill.3

Signed-off-by: Aaron Merey <amerey@redhat.com>
10 months agodoc: Add elf_end.3
Aaron Merey [Tue, 13 May 2025 00:33:37 +0000 (20:33 -0400)] 
doc: Add elf_end.3

Signed-off-by: Aaron Merey <amerey@redhat.com>
10 months agodoc/Makefile.am: Sort manpages in alphabetical order
Aaron Merey [Tue, 13 May 2025 00:33:36 +0000 (20:33 -0400)] 
doc/Makefile.am: Sort manpages in alphabetical order

Signed-off-by: Aaron Merey <amerey@redhat.com>
10 months agotests: Create random test_dir name
Mark Wielaard [Tue, 6 May 2025 09:50:12 +0000 (11:50 +0200)] 
tests: Create random test_dir name

The testsuite relies on there being no files in the test directory
after the test finishes. A test will fail if the test dir cannot be
removed. But the test dir isn't really random, it uses the pid of the
shell script that executes the test. On some of the buildbots that
execute a lot of tests it can happen that the pid number wraps around
and a pid of a previous pid is reused. To prevent that happening
generate a real random number (8 bytes) using od /dev/urandom and
xargs (to trim away spaces left by od).

      * tests/test-subr.sh: Define test_name and random_number and use
      those to define test_dir.

Signed-off-by: Mark Wielaard <mark@klomp.org>
11 months agoRevert "tests/run-stack-live-test.sh: prototype 'live' eu-stack testing"
Serhei Makarov [Thu, 8 May 2025 22:30:49 +0000 (18:30 -0400)] 
Revert "tests/run-stack-live-test.sh: prototype 'live' eu-stack testing"

This reverts commit deca125665a76cf024bd063ff4f477cb675ad41e.

11 months agotests/run-stack-live-test.sh: prototype 'live' eu-stack testing
Serhei Makarov [Thu, 8 May 2025 22:17:45 +0000 (18:17 -0400)] 
tests/run-stack-live-test.sh: prototype 'live' eu-stack testing

Missing a few pieces, but worth sharing as an RFC. My idea is to
ensure better test coverage for eu-stack and then
eu-stacktrace+libdwfl_stacktrace by running against a live process
with known content, stopped at a known location, and aggressively
scrubbing output that's known to vary from testrun to testrun.

This is a very basic preview of how that might look. If the approach
is sound, I hope to make it more sophisticated/reliable.

Unanswered questions:
- Scrub more data (e.g. libc symvers) from a more known program.
  Scrub stack frame numbers to account for a case where extra frames
  appear / are missing at the bottom of the stack?
- Something better than sed for the scrubbing?
- An equivalent eu-stacktrace test will require privileged perf_events
  access for profiling data and therefore likely to be skipped by
  default. How feasible is it to be enabled on the buildbots, though?

* tests/run-stack-live-test.sh: New test with wild and fuzzy
  testrun_compare variant that scrubs inherently unpredictable parts of
  the data. Needs to scrub even more.
* tests/Makefile.am (TESTS): Add run-stack-live-test.sh.

11 months agoPR32930 backends/: guard asm/perf_regs.h include
Serhei Makarov [Mon, 5 May 2025 16:08:55 +0000 (12:08 -0400)] 
PR32930 backends/: guard asm/perf_regs.h include

asm/perf_regs.h is an arch-specific linux include, not present on
architectures like hppa and m68k that lack perf_events support.

Only one place we need to fix; others already guard the include by
architecture, or use architecture-independent headers (e.g.
linux/perf_events.h).

* backends/libebl_PERF_FLAGS.h: Only include asm/perf_regs.h on
  architectures where we use it.

Signed-off-by: Serhei Makarov <serhei@serhei.io>
11 months agolibdw: Add RPATH to MAIN_CHECK programs
Mark Wielaard [Sat, 3 May 2025 00:46:40 +0000 (02:46 +0200)] 
libdw: Add RPATH to MAIN_CHECK programs

We want to test the program against the just build libelf.so not the
system installed one. So add an RPATH to ../libelf.

       * libdw/Makefile.am (CHECK_DEF_FLAGS): Add -Wl,-rpath,../libelf.

https://sourceware.org/bugzilla/show_bug.cgi?id=32929

Signed-off-by: Mark Wielaard <mark@klomp.org>