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>
if (! attached
&& ! INTUSE(dwfl_attach_state) (dwfl, elf, pid,
&sample_thread_callbacks, sample_arg))
- return -1;
+ {
+ free(sample_arg);
+ return -1;
+ }
Dwfl_Process *process = dwfl->process;
Ebl *ebl = process->ebl;
if (! attached
&& ! INTUSE(dwfl_attach_state) (dwfl, elf, pid,
&sample_thread_callbacks, sample_arg))
- return -1;
+ {
+ free(sample_arg);
+ return -1;
+ }
/* Select the regs_mapping based on architecture. This will be
cached in ebl to avoid having to recompute the regs_mapping array