Resolve a module symbol.
- Parameters
-
[in] | nm | the symbol name |
[in] | scope | the full scope of the symbol (namespace and/or class) |
- Returns
- the symbol address
- Exceptions
-
- Note
- The modsym_t type is a pointer to a function that takes two void* arguments and returns void. All module entry points should conform to this signature in order to be callable from a plugin object. If scope is NULL, the C ABI is used to resolve the symbol
Definition at line 225 of file plugin.cpp.
References csdbg::string::append(), csdbg::chain< T >::at(), csdbg::string::cstr(), csdbg::string::length(), likely, m_handle, m_path, csdbg::chain< T >::size(), csdbg::string::split(), and unlikely.
Referenced by plugin().
228 throw exception(
"no selected module, this is an inline plugin");
231 throw exception(
"invalid argument: nm (=%p)", nm);
233 string *mangled = NULL;
234 if (
likely(scope == NULL) )
235 mangled =
new string(nm);
240 chain<string> *parts = NULL;
243 mangled =
new string(
"_ZN");
244 parts = tmp.split(
"::");
246 for (
u32 i = 0, sz = parts->size();
likely(i < sz); i++) {
247 string *token = parts->at(i);
248 mangled->append(
"%d%s", token->length(), token->cstr());
251 mangled->append(
"%d%s", strlen(nm), nm);
252 mangled->append(
"EPvS%d_", parts->size() - 1);
267 void *sym = dlsym(
m_handle, mangled->cstr());
273 "failed to resolve symbol %s in object '%s' (%s)",
char i8
8-bit signed integer
#define likely(expr)
Offer a hint (positive) to the pipeline branch predictor.
i8 * m_path
Module file path.
void(* modsym_t)(void *, void *)
Plugin callback.
unsigned int u32
32-bit unsigned integer
void * m_handle
DSO handle (as provided by dlopen)
#define unlikely(expr)
Offer a hint (negative) to the pipeline branch predictor.