libcsdbg
1.28
C++ exception (and generic) stack trace debug library
|
Function instrumentation plugin. More...
#include <plugin.hpp>
Public Member Functions | |
plugin (const i8 *, const i8 *=NULL) | |
Object constructor. More... | |
plugin (modsym_t, modsym_t) | |
Object constructor. More... | |
plugin (const plugin &) | |
Object copy constructor. More... | |
virtual | ~plugin () |
Object destructor. More... | |
virtual plugin * | clone () const |
Object virtual copy constructor. More... | |
virtual const i8 * | path () const |
Get the module file path. More... | |
virtual plugin & | operator= (const plugin &) |
Assignment operator. More... | |
virtual modsym_t | resolve (const i8 *, const i8 *=NULL) const |
Resolve a module symbol. More... | |
virtual plugin & | begin (void *, void *) const |
Begin instrumenting a function. More... | |
virtual plugin & | end (void *, void *) const |
End a function instrumentation. More... | |
Public Member Functions inherited from csdbg::object | |
virtual | ~object ()=0 |
To be implemented. More... | |
virtual const i8 * | class_name () const |
Query the class name of an object descending from csdbg::object. More... | |
Protected Member Functions | |
virtual plugin & | destroy () |
Object deconstruction. More... | |
Protected Attributes | |
modsym_t | m_begin |
Instrumentation starting callback. More... | |
modsym_t | m_end |
Instrumentation ending callback. More... | |
i8 * | m_path |
Module file path. More... | |
void * | m_handle |
DSO handle (as provided by dlopen) More... | |
Function instrumentation plugin.
A plugin object is the way to declare a pair of instrumentation functions and register them with libcsdbg to be run upon function call and return. A plugin can be created by passing it the addresses of the instrumentation functions or by loading a plugin DSO module that implements and exports these two functions. A plugin invokes the system dynamic linker to find, load and link the module, so it must reside in one of the linker search directories.
The names of the instrumentation functions (__cyg_profile_func_enter and __cyg_profile_func_exit) are hard-coded into g++, so only a unique implementation of these can exist at linkage time, therefore only one function profiler can be used at a time. The plugin class is the fix to this g++ shortcoming.
The plugin class supports both C and C++ ABIs. To resolve C++ functions the user must pass the symbol name and its full scope (as a separate argument in the form namespace::class). To resolve C functions omit the scope argument altogether. The module callback functions must be named mod_enter and mod_exit, take two void* arguments and return void for the plugin object to resolve them correctly. All plugin functions (as all libcsdbg functions) must NOT be instrumented by libcsdbg, as this will result in a recurse and a stack overflow
Definition at line 42 of file plugin.hpp.