Feature #474
closedMake lttng-ust aware of shared object base addresses
0%
Description
Using the glibc function dl_iterate_phdr we are able to iterate the currently opened shared objects from within the traced exe.
This allows us to resolve:
- Tracepoint call site address to specific line number in the sources (if the tp was emitted from a shared object).
- Compute the absolute vaddress to install uprobes in shared objects.
To also record any changes of the currently opened shared objects during the application runtime we could use the existing ld-audit interface.
(we would need to implement the hooks la_objopen() and la_objclose() to keep informed about shared object loading and unloading)
References:
man dl_iterate_phdr
man rtld-audit
Files
Updated by Paul Woegerer almost 12 years ago
The following code snipped can be used to dump base address info for all shared objects currently loaded:
#define _GNU_SOURCE
#include <link.h>
static int
_dl_iterate_write_memregion( struct dl_phdr_info *info, size_t size, void *data )
{
int j;
for( j = 0; j < info->dlpi_phnum; j++ )
{
if( info->dlpi_phdr[j].p_type == PT_LOAD )
{
uintptr_t base_addr_ptr = info->dlpi_addr + info->dlpi_phdr[j].p_vaddr;
const char* shared_object_name = info->dlpi_name;
// TBD Begin - Emit event with base_addr_ptr and shared_object_name here
// TBD End
break;
}
}
return 0;
}
void
iterate_shared_objects_state()
{
dl_iterate_phdr( _dl_iterate_write_memregion, NULL );
}
Updated by Paul Woegerer almost 12 years ago
#define _GNU_SOURCE #include <link.h> static int _dl_iterate_write_memregion( struct dl_phdr_info *info, size_t size, void *data ) { int j; for( j = 0; j < info->dlpi_phnum; j++ ) { if( info->dlpi_phdr[j].p_type == PT_LOAD ) { uintptr_t base_addr_ptr = info->dlpi_addr + info->dlpi_phdr[j].p_vaddr; const char* shared_object_name = info->dlpi_name; // TBD Begin - Emit event with base_addr_ptr and shared_object_name here // TBD End break; } } return 0; } void iterate_shared_objects_state() { dl_iterate_phdr( _dl_iterate_write_memregion, NULL ); }
Updated by Paul Woegerer over 11 years ago
Provided prototype implementation, detailed explanation and sample traces:
http://lists.lttng.org/pipermail/lttng-dev/2013-August/021264.html
Currently waiting for review.
Updated by Paul Woegerer over 11 years ago
Added pdf document that explains the prototype implementation in simple terms.
Updated by Paul Woegerer over 11 years ago
Reasons are:
- Not compatible with the upcoming dynamic instrumentation usecase (here the argument with including a tp header file does not hold anymore)
- We don't want to introduce hooks specific to tracepoints into something that should be instrumentation-agnostic
I will provide an updated prototype ASOP.
Updated by Mathieu Desnoyers over 9 years ago
- Target version set to 2.8
We have updated this feature, see:
commit 405be6583fc840d2ad298516edb267281bc2c4dc
Author: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Date: Mon Aug 31 16:50:50 2015 -0400
baddr statedump: remove dependency on file streams
None of the rest of UST used by applications use file streams (only the
sessiond uses a file streams for metadata). Therefore, use file
descriptors directly for baddr statedump.
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
commit d34e6761379227cfd49abb6eab184e1e254ee0b2
Author: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Date: Mon Aug 31 16:50:03 2015 -0400
baddr statedump: hold ust lock around allocations
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
commit 22609c7a82c5c8ebc07c19cade9b4d6ff61bd0d0
Author: Antoine Busque <abusque@efficios.com>
Date: Thu Jul 30 16:37:04 2015 -0400
Add unit tests for lttng_ust_elf
This adds unit tests for UST's ELF parser. Also included are test ELF
files for multiple architectures (x86, x86_64, armeb, aarch64_be). The
procedure to generate these test files is described in
`tests/ust-elf/README.md`.
Signed-off-by: Antoine Busque <abusque@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
commit 8e2aed3f18adc14ec586ef717e396bcac4473dd7
Author: Antoine Busque <abusque@efficios.com>
Date: Thu Jul 2 11:55:53 2015 -0400
Add memory size, build id, and debug link info to statedump and dl
Implement a minimal ELF parser allowing to compute an executable's
in-memory size and to read its build id and debug link info, if any,
at runtime. This is performed during base address statedump, and on
dlopen when using the `liblttng-ust-dl.so` helper.
This adds a `memsz` field to `lttng_ust_statedump:soinfo` and
`lttng_ust_dl:dlopen`. Also adds two events to both providers,
`build_id` and `debug_link`, which are only traced when the
corresponding information is found in the executable file. They can be
matched with the corresponding `soinfo` or `dlopen` via the `baddr`
field shared amongst all the events. Build ID and debug link are
standard methods of identifying and retrieving debug information
corresponding to a specific version of an executable.
The fields `size` and `mtime` from the existing `soinfo` and `dlopen`
events have been removed as they provided no valuable information for
analysis, whereas build ID or debug link allow unambiguous retrieval
of the debug information, and the on-disk `size` is superseded by the
in-memory `memsz`.
Signed-off-by: Antoine Busque <abusque@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Updated by Mathieu Desnoyers over 9 years ago
- Status changed from New to Resolved