本文整理汇总了C++中Symbol::addr方法的典型用法代码示例。如果您正苦于以下问题:C++ Symbol::addr方法的具体用法?C++ Symbol::addr怎么用?C++ Symbol::addr使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Symbol
的用法示例。
在下文中一共展示了Symbol::addr方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: switch
BPatch_variableExpr *BPatch_image::createVarExprByName(BPatch_module *mod, const char *name)
{
Symbol syminfo;
BPatch_type *type;
type = mod->getModuleTypes()->globalVarsByName[name];
if (!type) {
switch (syminfo.size()) {
case 1:
type = findType("char");
break;
case 2:
type = findType("short");
break;
case 8:
type = findType("integer*8");
break;
case 4:
default:
type = findType("int");
break;
}
}
if (!type) return NULL;
if (!proc->llproc->getSymbolInfo(name, syminfo)) {
return NULL;
}
// Error case.
if (syminfo.addr() == 0)
return NULL;
BPatch_variableExpr *var = AddrToVarExpr->hash[syminfo.addr()];
if (!var) {
var = new BPatch_variableExpr( const_cast<char *>(name), proc,
(void *)syminfo.addr(), type);
AddrToVarExpr->hash[syminfo.addr()] = var;
}
return var;
}
示例2: loadDYNINSTlib
bool process::loadDYNINSTlib() {
/* Look for a function we can hijack to forcibly load dyninstapi_rt.
This is effectively an inferior RPC with the caveat that we're
overwriting code instead of allocating memory from the RT heap.
(So 'hijack' doesn't mean quite what you might think.) */
Address codeBase = findFunctionToHijack(this);
if( !codeBase ) { return false; }
/* glibc 2.3.4 and higher adds a fourth parameter to _dl_open().
While we could probably get away with treating the three and four
-argument functions the same, check the version anyway, since
we'll probably need to later. */
bool useFourArguments = true;
Symbol libcVersionSymbol;
if( getSymbolInfo( "__libc_version", libcVersionSymbol ) ) {
char libcVersion[ sizeof( int ) * libcVersionSymbol.size() + 1 ];
libcVersion[ sizeof( int ) * libcVersionSymbol.size() ] = '\0';
if( ! readDataSpace( (void *) libcVersionSymbol.addr(), libcVersionSymbol.size(), libcVersion, true ) ) {
fprintf( stderr, "%s[%d]: warning, failed to read libc version, assuming 2.3.4+\n", __FILE__, __LINE__ );
}
else {
startup_printf( "%s[%d]: libcVersion: %s\n", __FILE__, __LINE__, libcVersion );
/* We could potentially add a sanity check here to make sure we're looking at 2.3.x. */
int microVersion = ((int)libcVersion[4]) - ((int)'0');
if( microVersion <= 3 ) {
useFourArguments = false;
}
} /* end if we read the version symbol */
} /* end if we found the version symbol */
if( useFourArguments ) { startup_printf( "%s[%d]: using four arguments.\n", __FILE__, __LINE__ ); }
/* Fetch the name of the run-time library. */
const char DyninstEnvVar[]="DYNINSTAPI_RT_LIB";
if( ! dyninstRT_name.length() ) { // we didn't get anything on the command line
if (getenv(DyninstEnvVar) != NULL) {
dyninstRT_name = getenv(DyninstEnvVar);
} else {
pdstring msg = pdstring( "Environment variable " + pdstring( DyninstEnvVar )
+ " has not been defined for process " ) + pdstring( getPid() );
showErrorCallback(101, msg);
return false;
} /* end if enviromental variable not found */
} /* end enviromental variable extraction */
/* Save the (main thread's) current PC.*/
savedPC = getRepresentativeLWP()->getActiveFrame().getPC();
/* _dl_open() takes three arguments: a pointer to the library name,
the DLOPEN_MODE, and the return address of the current frame
(that is, the location of the SIGILL-generating bundle we'll use
to handleIfDueToDyninstLib()). We construct the first here. */
/* Write the string to entry, and then move the PC to the next bundle. */
codeGen gen(BYTES_TO_SAVE);
Address dyninstlib_addr = gen.used() + codeBase;
gen.copy(dyninstRT_name.c_str(), dyninstRT_name.length()+1);
Address dlopencall_addr = gen.used() + codeBase;
/* At this point, we use the generic iRPC headers and trailers
around the call to _dl_open. (Note that pre-1.35 versions
of this file had a simpler mechanism well-suited to boot-
strapping a new port. The current complexity is to handle
the attach() case, where we don't know if execution was stopped
at the entry the entry point to a function. */
bool ok = theRpcMgr->emitInferiorRPCheader(gen);
if( ! ok ) { return false; }
/* Generate the call to _dl_open with a large dummy constant as the
the third argument to make sure we generate the same size code the second
time around, with the correct "return address." (dyninstlib_brk_addr) */
// As a quick note, we want to "return" to the beginning of the restore
// segment, not dyninstlib_brk_addr (or we skip all the restores).
// Of course, we're not sure what this addr represents....
pdvector< AstNode * > dlOpenArguments( 4 );
AstNode * dlOpenCall;
dlOpenArguments[ 0 ] = new AstNode( AstNode::Constant, (void *)dyninstlib_addr );
dlOpenArguments[ 1 ] = new AstNode( AstNode::Constant, (void *)DLOPEN_MODE );
dlOpenArguments[ 2 ] = new AstNode( AstNode::Constant, (void *)0xFFFFFFFFFFFFFFFF );
if( useFourArguments ) {
/* I derived the -2 as follows: from dlfcn/dlopen.c in the glibc sources, line 59,
we find the call to _dl_open(), whose last argument is 'args->file == NULL ? LM_ID_BASE : NS'.
Since the filename we pass in is non-null, this means we (would) pass in NS, which
is defined to be __LM_ID_CALLER in the same file, line 48. (Since glibc must be shared
for us to be calling _dl_open(), we fall into the second case of the #ifdef.) __LM_ID_CALLER
is defined in include/dlfcn.h, where it has the value -2. */
dlOpenArguments[ 3 ] = new AstNode( AstNode::Constant, (void *)(long unsigned int)-2 );
}
dlOpenCall = new AstNode( "_dl_open", dlOpenArguments );
/* Remember where we originally generated the call. */
codeBufIndex_t index = gen.getIndex();
//.........这里部分代码省略.........
示例3: parseStabTypes
//.........这里部分代码省略.........
int funlen = strlen(stabptr->name(currentEntry));
ptr = new char[funlen+1];
strcpy(ptr, stabptr->name(currentEntry));
while(strlen(ptr) != 0 && ptr[strlen(ptr)-1] == '\\'){
ptr[strlen(ptr)-1] = '\0';
currentEntry++;
strcat(ptr,stabptr->name(currentEntry));
}
char* colonPtr = NULL;
if(currentFunctionName) delete currentFunctionName;
if(!ptr || !(colonPtr = strchr(ptr,':')))
currentFunctionName = NULL;
else {
char* tmp = new char[colonPtr-ptr+1];
strncpy(tmp,ptr,colonPtr-ptr);
tmp[colonPtr-ptr] = '\0';
currentFunctionName = new pdstring(tmp);
currentFunctionBase = 0;
Symbol info;
// Shouldn't this be a function name lookup?
if (!proc->llproc->getSymbolInfo(*currentFunctionName,
info))
{
pdstring fortranName = *currentFunctionName + pdstring("_");
if (proc->llproc->getSymbolInfo(fortranName,info))
{
delete currentFunctionName;
currentFunctionName = new pdstring(fortranName);
}
}
currentFunctionBase = info.addr();
delete[] tmp;
// if(currentSourceFile && (currentFunctionBase > 0)){
// lineInformation->insertSourceFileName(
// *currentFunctionName,
// *currentSourceFile,
// ¤tFileInfo,¤tFuncInfo);
//}
}
// used to be a symbol lookup here to find currentFunctionBase, do we need it?
delete[] ptr;
#ifdef TIMED_PARSE
gettimeofday(&t2, NULL);
fun_dur += (t2.tv_sec - t1.tv_sec)*1000.0 + (t2.tv_usec - t1.tv_usec)/1000.0;
//fun_dur += (t2.tv_sec/1000 + t2.tv_usec*1000) - (t1.tv_sec/1000 + t1.tv_usec*1000);
#endif
break;
}
if (!parseActive) continue;
switch(stabptr->type(i)){
case N_BCOMM: {
// begin Fortran named common block
commonBlockName = const_cast<char*>(stabptr->name(i));
// find the variable for the common block
BPatch_image *progam = (BPatch_image *) getObjParent();
commonBlockVar = progam->findVariable(commonBlockName);
if (!commonBlockVar) {
bperr("unable to find variable %s\n", commonBlockName);
} else {