libcsdbg  1.28
C++ exception (and generic) stack trace debug library
void csdbg::tracer::on_lib_load ( )
staticprotected

Library constructor.

Note
If an exception occurs, the process exits

Definition at line 253 of file tracer.cpp.

References csdbg::process::add_module(), csdbg::util::dbg_info(), csdbg::util::exec_path(), csdbg::g_libs_env, csdbg::g_major, csdbg::g_minor, csdbg::util::getenv(), m_iface, m_proc, on_dso_load(), and tracer().

254 {
255  /* Initialize libbfd internals */
256  bfd_init();
257 
258  try {
259  m_iface = new tracer;
260 
261  /* Load the symbol table of the executable */
262  const i8 *path = util::exec_path();
263  m_iface->m_proc->add_module(path, 0);
264  delete[] path;
265 
266  /* Load the symbol tables of the selected DSO */
267  chain<string> *libs = util::getenv(g_libs_env);
268  dl_iterate_phdr(on_dso_load, libs);
269  delete libs;
270 
271  util::dbg_info("libcsdbg.so.%d.%d initialized", g_major, g_minor);
272  return;
273  }
274 
275  catch (exception &x) {
276  std::cerr << x;
277  }
278 
279  catch (std::exception &x) {
280  std::cerr << x;
281  }
282 
283  exit(EXIT_FAILURE);
284 }
static const i8 * exec_path()
Get the absolute path of the executable.
Definition: util.cpp:87
char i8
8-bit signed integer
Definition: config.hpp:72
static const u16 g_minor
Library version minor.
Definition: config.hpp:195
static i32 on_dso_load(dl_phdr_info *, size_t, void *)
This is a dl_iterate_phdr (libdl) callback, called for each linked shared object. It loads the symbol...
Definition: tracer.cpp:323
static const i8 g_libs_env[]
DSO filtering shell variable.
Definition: config.hpp:185
process * m_proc
Process handle.
Definition: tracer.hpp:45
tracer()
Object default constructor.
Definition: tracer.cpp:454
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...
Definition: process.cpp:236
static chain< string > * getenv(const i8 *)
Parse a shell (environment) variable to its components.
Definition: util.cpp:128
static void dbg_info(const i8 *,...)
Print an informational debug message on the standard error stream.
Definition: util.cpp:680
static const u16 g_major
Library version major.
Definition: config.hpp:190
static tracer * m_iface
Interface object.
Definition: tracer.hpp:40

+ Here is the call graph for this function: