This is a dl_iterate_phdr (libdl) callback, called for each linked shared object. It loads the symbol table of the DSO (if it's not filtered out) to tracer::m_iface->m_proc.
- Parameters
-
[in] | dso | a dl_phdr_info struct (libdl) that describes the shared object (file path, load address e.t.c) |
[in] | sz | the sizeof dso |
[in] | arg | a chain of POSIX extended regular expressions used to select the shared objects that will participate in the call stack simulation. The absolute path of each DSO is matched against each regexp. If NULL, all linked DSO symbol tables will be loaded. If not NULL but empty, all DSO are filtered out from instrumentation |
- Returns
- 0
- Note
- If an exception occurs, it's caught and handled. 0 is returned, signaling to the iterator (dl_iterate_phdr) to continue with the next DSO
Definition at line 323 of file tracer.cpp.
References csdbg::process::add_module(), csdbg::chain< T >::at(), csdbg::string::cstr(), csdbg::util::dbg_error(), csdbg::util::dbg_warn(), csdbg::string::length(), likely, m_iface, m_proc, csdbg::string::match(), csdbg::exception::msg(), csdbg::chain< T >::size(), and unlikely.
Referenced by on_lib_load().
327 throw exception(
"invalid argument: dso (=%p)", dso);
330 string path(dso->dlpi_name);
332 throw exception(
"undefined DSO path");
335 if (
unlikely(dso->dlpi_phnum == 0) )
336 throw exception(
"'%s' has 0 segments", path.cstr());
340 if (
likely(arg != NULL) ) {
341 chain<string> *filters =
static_cast<chain<string>*
> (arg);
343 for (
u32 i = 0, sz = filters->size();
likely(i < sz); i++) {
344 string *filt = filters->at(i);
345 if (
unlikely(path.match(*filt)) ) {
360 mem_addr_t base = dso->dlpi_addr + dso->dlpi_phdr[0].p_vaddr;
364 catch (exception &x) {
368 catch (std::exception &x) {
process * m_proc
Process handle.
#define likely(expr)
Offer a hint (positive) to the pipeline branch predictor.
static void dbg_warn(const i8 *,...)
Print a warning debug message on the standard error stream.
static void dbg_error(const i8 *,...)
Print an error debug message on the standard error stream.
virtual process & add_module(const i8 *, mem_addr_t)
Add a symbol table to the namespace. The symbol table is loaded from a non stripped objective code fi...
unsigned int u32
32-bit unsigned integer
unsigned long long mem_addr_t
64-bit memory address
#define unlikely(expr)
Offer a hint (negative) to the pipeline branch predictor.
static tracer * m_iface
Interface object.