libcsdbg  1.28
C++ exception (and generic) stack trace debug library
plugin & csdbg::plugin::operator= ( const plugin rval)
virtual

Assignment operator.

Parameters
[in]rvalthe assigned object
Returns
*this
Exceptions
std::bad_alloc
csdbg::exception

Definition at line 172 of file plugin.cpp.

References csdbg::util::dbg_info(), likely, m_begin, m_end, m_handle, m_path, and unlikely.

173 {
174  if ( unlikely(this == &rval) )
175  return *this;
176 
177  m_begin = rval.m_begin;
178  m_end = rval.m_end;
179 
180  /* If this object has called dlopen and holds a handle, close it */
181  if ( likely(m_handle != NULL) ) {
182  dlclose(m_handle);
183  util::dbg_info("plugin '%s' unlinked", m_path);
184 
185  delete[] m_path;
186  m_path = NULL;
187  m_handle = NULL;
188  }
189 
190  if ( unlikely(rval.m_handle == NULL) )
191  return *this;
192 
193  m_path = new i8[strlen(rval.m_path) + 1];
194  strcpy(m_path, rval.m_path);
195 
196  /* Obtain a handle to an already loaded module */
197  dlerror();
198  m_handle = dlopen(m_path, RTLD_LOCAL | RTLD_LAZY | RTLD_NOLOAD);
199  if ( unlikely(m_handle == NULL) )
200  throw exception("failed to link plugin '%s' (%s)", m_path, dlerror());
201 
202  util::dbg_info("plugin '%s' linked", m_path);
203  return *this;
204 }
modsym_t m_end
Instrumentation ending callback.
Definition: plugin.hpp:50
char i8
8-bit signed integer
Definition: config.hpp:72
#define likely(expr)
Offer a hint (positive) to the pipeline branch predictor.
Definition: config.hpp:344
modsym_t m_begin
Instrumentation starting callback.
Definition: plugin.hpp:48
i8 * m_path
Module file path.
Definition: plugin.hpp:52
void * m_handle
DSO handle (as provided by dlopen)
Definition: plugin.hpp:54
#define unlikely(expr)
Offer a hint (negative) to the pipeline branch predictor.
Definition: config.hpp:349
static void dbg_info(const i8 *,...)
Print an informational debug message on the standard error stream.
Definition: util.cpp:680

+ Here is the call graph for this function: