本文整理汇总了C++中pdvector类的典型用法代码示例。如果您正苦于以下问题:C++ pdvector类的具体用法?C++ pdvector怎么用?C++ pdvector使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了pdvector类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: buildDyninstSymbols
// Build a list of symbols describing instrumentation and relocated functions.
// To keep this list (somewhat) short, we're doing one symbol per extent of
// instrumentation + relocation for a particular function.
// New: do this for one mapped object.
void BinaryEdit::buildDyninstSymbols(pdvector<Symbol *> &newSyms,
Region *newSec,
Module *newMod) {
for (std::vector<SymtabAPI::Symbol *>::iterator iter = newDyninstSyms_.begin();
iter != newDyninstSyms_.end(); ++iter) {
(*iter)->setModule(newMod);
(*iter)->setRegion(newSec);
newSyms.push_back(*iter);
}
for (CodeTrackers::iterator i = relocatedCode_.begin();
i != relocatedCode_.end(); ++i) {
Relocation::CodeTracker *CT = *i;
func_instance *currFunc = NULL;
Address start = 0;
unsigned size = 0;
for (Relocation::CodeTracker::TrackerList::const_iterator iter = CT->trackers().begin();
iter != CT->trackers().end(); ++iter) {
const Relocation::TrackerElement *tracker = *iter;
func_instance *tfunc = tracker->func();
if (currFunc != tfunc) {
// Starting a new function
if (currFunc) {
// Record the old one
// currfunc set
// start set
size = tracker->reloc() - start;
std::string name = currFunc->prettyName();
name.append("_dyninst");
Symbol *newSym = new Symbol(name.c_str(),
Symbol::ST_FUNCTION,
Symbol::SL_GLOBAL,
Symbol::SV_DEFAULT,
start,
newMod,
newSec,
size);
newSyms.push_back(newSym);
}
currFunc = tfunc;
start = tracker->reloc();
size = 0;
}
else {
// Accumulate size
size = tracker->reloc() - start;
}
}
}
}
示例2: find_data_region
// Attempt to find the largest contiguous (in virtual address space) region.
// This region must include ".data", and may include the other data like regions
static inline bool find_data_region(pdvector<Address>& all_addr,
pdvector<long>& all_size,
pdvector<long>& all_disk,
unsigned long& data_len, Address& data_off) {
// Start at data and work back
assert(all_addr[K_D_INDEX]); assert(all_size[K_D_INDEX]);
assert(all_addr.size() == all_size.size());
Address current = all_addr[K_D_INDEX];
Address min_adr = current;
Address max_adr = current + all_size[K_D_INDEX];
unsigned index, max=all_addr.size();
bool updated=true;
while (updated) {
updated = false;
for (index=0; index<max; index++) {
if (all_addr[index] && all_size[index] && all_disk[index] &&
((all_addr[index] + all_size[index]) == current)) {
current = all_addr[index];
updated = true;
}
}
}
min_adr = current;
// Start at data and work forward
current = max_adr;
updated=true;
while (updated) {
updated = false;
for (index=0; index<max; index++) {
if (all_addr[index] && all_size[index] && all_disk[index] &&
(all_addr[index] == current)) {
current = all_addr[index] + all_size[index];
updated = true;
}
}
}
max_adr = current;
data_len = (max_adr - min_adr);
data_off = min_adr;
assert(min_adr <= all_addr[K_D_INDEX]);
assert(max_adr >= all_addr[K_D_INDEX] + all_size[K_D_INDEX]);
return true;
}
示例3: checkInst
// Return false if the PC is within the jump range of any of our
// multiTramps
bool instPoint::checkInst(pdvector<Address> &checkPCs) {
for (unsigned sI = 0; sI < checkPCs.size(); sI++) {
Address pc = checkPCs[sI];
for (unsigned iI = 0; iI < instances.size(); iI++) {
multiTramp *mt = instances[iI]->multi();
// No multi -> not installed.
if (!mt) continue;
if ((pc > mt->instAddr()) &&
(pc < (mt->instAddr() + mt->instSize()))) {
// We have a conflict. Now, we may still be able to make this
// work; if we're not conflicting on the actual branch, we
// may have trap-filled the remainder which allows us to
// catch and transfer.
if (pc < (mt->instAddr() + mt->branchSize())) {
// We're in the jump area, conflict.
fprintf(stderr, "MT conflict (MT from 0x%p to 0x%p, 0x%p to 0x%p dangerous), PC 0x%p\n",
(void *)mt->instAddr(),
(void *)(mt->instAddr() + mt->instSize()),
(void *)mt->instAddr(),
(void *)(mt->instAddr() + mt->branchSize()),
(void *)pc);
return false;
}
}
}
}
#if defined(cap_relocation)
// Yay check relocation
if (!func()->relocationCheck(checkPCs))
return false;
#endif
return true;
}
示例4: getAS
/*
* BPatch_addressSpace::findModuleByAddr
*
* Returns the module that contains the specified address, or NULL if the
* address is not within a module. Does NOT trigger parsing
*
* addr The address to use for the lookup.
*/
BPatch_module *BPatch_addressSpace::findModuleByAddr(Address addr)
{
std::vector<AddressSpace *> as;
getAS(as);
assert(as.size());
mapped_object *obj = as[0]->findObject(addr);
if ( ! obj )
return NULL;
const pdvector<mapped_module*> mods = obj->getModules();
if (mods.size()) {
return getImage()->findOrCreateModule(mods[0]);
}
return NULL;
}
示例5: getSharedObjects
bool dynamic_linking::getSharedObjects(pdvector<mapped_object *> &mapped_objects)
{
pdvector<fileDescriptor> descs;
if (!processLinkMaps(descs))
return false;
// Skip first entry: always the a.out
for (unsigned i = 0; i < descs.size(); i++) {
if (descs[i] != proc->getAOut()->getFileDesc()) {
#if 0
fprintf(stderr, "DEBUG: match pattern %d, %d, %d, %d, %d\n",
descs[i].file() == proc->getAOut()->getFileDesc().file(),
descs[i].code() == proc->getAOut()->getFileDesc().code(),
descs[i].data() == proc->getAOut()->getFileDesc().data(),
descs[i].member() == proc->getAOut()->getFileDesc().member(),
descs[i].pid() == proc->getAOut()->getFileDesc().pid());
#endif
mapped_object *newobj = mapped_object::createMappedObject(descs[i], proc);
if (newobj == NULL) continue;
mapped_objects.push_back(newobj);
#if defined(cap_save_the_world)
setlowestSObaseaddr(descs[i].code());
#endif
}
}
return true;
} /* end getSharedObjects() */
示例6: obj
bool mapped_module::findFuncVectorByPretty(const pdstring &funcname,
pdvector<int_function *> &funcs)
{
// For efficiency sake, we grab the image vector and strip out the
// functions we want.
// We could also keep them all in modules and ditch the image-wide search;
// the problem is that BPatch goes by module and internal goes by image.
unsigned orig_size = funcs.size();
const pdvector<int_function *> *obj_funcs = obj()->findFuncVectorByPretty(funcname);
if (!obj_funcs) return false;
for (unsigned i = 0; i < obj_funcs->size(); i++) {
if ((*obj_funcs)[i]->mod() == this)
funcs.push_back((*obj_funcs)[i]);
}
return funcs.size() > orig_size;
}
示例7: didLinkMapsChange
bool dynamic_linking::didLinkMapsChange(u_int &change_type, pdvector<fileDescriptor> &new_descs)
{
// get list of current shared objects
const pdvector<mapped_object *> &curr_list = proc->mappedObjects();
if((change_type == SHAREDOBJECT_REMOVED) && (curr_list.size() == 0)) {
return false;
}
// get the list from the process via /proc
if (!processLinkMaps(new_descs)) {
return false;
}
unsigned curr_size = curr_list.size();
unsigned descs_size = new_descs.size();
#if defined(os_linux)
// The current mapped object list contains the a.out, the
// result from processLinkMaps does not. Correct this
// when accounting for size.
for (unsigned i = 0; i < curr_list.size(); i++) {
if (curr_list[i] == proc->getAOut()) {
curr_size--;
break;
}
}
//Also make sure that we don't start accidently counting the a.out
for (unsigned i = 0; i < new_descs.size(); i++) {
if (!new_descs[i].isSharedObject()) {
descs_size--;
break;
}
}
#endif
// override change_type if we have definite evidence of a size chanage
// in the link maps
if (curr_size > descs_size)
change_type = SHAREDOBJECT_REMOVED;
else if (curr_size < descs_size)
change_type = SHAREDOBJECT_ADDED;
return true;
}
示例8: read_data_region
// Read in from the contiguous data regions, put the data in 'buffer'
static inline bool read_data_region(pdvector<Address>& all_addr,
pdvector<long>& all_size,
pdvector<long>& all_disk,
unsigned long& data_len, Address& data_off,
Word *buffer, LDFILE *ldptr) {
unsigned index, max = all_disk.size();
Address max_adr = data_off + data_len;
assert(all_size.size() == all_addr.size());
assert(all_disk.size() == all_addr.size());
for (index=0; index<max; index++) {
if ((all_addr[index] >= data_off) &&
((all_addr[index] + all_size[index]) <= max_adr)) {
if (ldfseek(ldptr, all_disk[index], SEEK_SET) == -1) return false;
Word *buf_temp = buffer + (all_addr[index] - data_off);
if (ldfread((void*) buf_temp, 1, all_size[index], ldptr) != all_size[index])
return false;
}
}
return true;
}
示例9: emitNeededCallRestores
static void emitNeededCallRestores(codeGen &gen, pdvector<Register> &saves)
{
for (unsigned i=0; i<saves.size(); i++) {
switch (saves[i]) {
case REGNUM_EAX:
emitSimpleInsn(POP_EAX, gen);
break;
case REGNUM_EBX:
emitSimpleInsn(POP_EBX, gen);
break;
case REGNUM_ECX:
emitSimpleInsn(POP_ECX, gen);
break;
case REGNUM_EDX:
emitSimpleInsn(POP_EDX, gen);
break;
case REGNUM_EDI:
emitSimpleInsn(POP_EDI, gen);
break;
}
}
saves.clear();
}
示例10: result
pdvector< pdvector<resourceHandle> >
callGraphDisplay::getSelections(bool &wholeProgram,
pdvector<unsigned> &wholeProgramFocus) const {
// returns a vector[num-hierarchies] of vector of selections.
// The number of hierarchies is defined as the number of children of the
// root node. If "Whole Program" was selection, it isn't returned with
// the main result; it's returned by modifying the 2 params
const unsigned numHierarchies = rootPtr->getNumChildren();
pdvector < pdvector<resourceHandle> > result(numHierarchies);
bool wholeProgramImplicit = true; // so far...
for (unsigned i=0; i < numHierarchies; i++) {
where4tree<callGraphRootNode> *hierarchyRoot = rootPtr->getChildTree(i);
pdvector <const callGraphRootNode *> thisHierarchySelections =
hierarchyRoot->getSelections();
if (thisHierarchySelections.size()==0)
// add hierarchy's root item
thisHierarchySelections += &hierarchyRoot->getNodeData();
else
// since the hierarchy selection was not empty, we do _not_
// want to implicitly select whole-program
wholeProgramImplicit = false;
result[i].resize(thisHierarchySelections.size());
for (unsigned j=0; j < thisHierarchySelections.size(); j++)
result[i][j] = thisHierarchySelections[j]->getUniqueId();
}
wholeProgram = wholeProgramImplicit || rootPtr->isHighlighted();
if (wholeProgram) {
// write to wholeProgramFocus:
wholeProgramFocus.resize(numHierarchies);
for (unsigned i=0; i < numHierarchies; i++) {
where4tree<callGraphRootNode> *hierarchyRoot = rootPtr->getChildTree(i);
const callGraphRootNode &hierarchyRootData = hierarchyRoot->getNodeData();
unsigned hierarchyRootUniqueId = hierarchyRootData.getUniqueId();
wholeProgramFocus[i] = hierarchyRootUniqueId;
}
}
return result;
}
示例11: prepareForSampling
void instrCodeNode::prepareForSampling(
const pdvector<threadMetFocusNode *> &thrNodes)
{
if(! instrLoaded()) return;
for(unsigned i=0; i<thrNodes.size(); i++) {
threadMetFocusNode *curThrNode = thrNodes[i];
V.sampledDataNode->prepareForSampling(curThrNode->getThreadIndex(),
curThrNode->getValuePtr());
}
#ifdef PAPI
if (V.hwEvent != NULL) {
V.hwEvent->enable();
}
#endif
}
示例12: createRegSpaceInt
void registerSpace::createRegSpaceInt(pdvector<registerSlot *> ®isters,
registerSpace *rs) {
for (unsigned i = 0; i < registers.size(); i++) {
Register reg = registers[i]->number;
rs->registers_[reg] = registers[i];
rs->registersByName[registers[i]->name] = registers[i]->number;
switch (registers[i]->type) {
case registerSlot::GPR: {
bool physical = true;
#if defined(arch_x86) || defined(arch_x86_64)
if (rs->addr_width == 4)
physical = false;
#endif
if (physical) rs->physicalRegisters_[reg] = registers[i];
rs->GPRs_.push_back(registers[i]);
break;
}
case registerSlot::FPR:
rs->FPRs_.push_back(registers[i]);
break;
case registerSlot::SPR:
rs->SPRs_.push_back(registers[i]);
break;
case registerSlot::realReg:
rs->physicalRegisters_[reg] = registers[i];
rs->realRegisters_.push_back(registers[i]);
break;
default:
fprintf(stderr, "Error: no match for %d\n", registers[i]->type);
assert(0);
break;
}
}
}
示例13: emitNeededCallSaves
static void emitNeededCallSaves(codeGen &gen, Register regi,
pdvector<Register> &extra_saves)
{
extra_saves.push_back(regi);
switch (regi) {
case REGNUM_EAX:
emitSimpleInsn(PUSHEAX, gen);
break;
case REGNUM_EBX:
emitSimpleInsn(PUSHEBX, gen);
break;
case REGNUM_ECX:
emitSimpleInsn(PUSHECX, gen);
break;
case REGNUM_EDX:
emitSimpleInsn(PUSHEDX, gen);
break;
case REGNUM_EDI:
emitSimpleInsn(PUSHEDI, gen);
break;
}
}
示例14: waitForEvent
bool SignalHandler::waitForEvent(pdvector<EventRecord> &events_to_handle)
{
assert(waitLock);
signal_printf("%s[%d]: waitForEvent, events_to_handle(%d), idle_flag %d\n",
FILE__, __LINE__, events_to_handle.size(), idle());
while (idle()) {
// Our eventlocks are paired mutexes and condition variables; this
// is actually _not_ what we want because we want to be able to
// wait on different things but have the same global mutex. So we fake it
// by carefully unlocking and relocking things.
// We now wait until _we_ are signalled by the generator; so we grab
// our signal lock, give up the global mutex lock, and then wait; after
// we're signalled we take the global mutex before giving up our own
// waitLock.
waitingForWakeup_ = true;
signal_printf("%s[%d]: acquiring waitLock lock...\n", FILE__, __LINE__);
waitLock->_Lock(FILE__, __LINE__);
signal_printf("%s[%d]: releasing global mutex...\n", FILE__, __LINE__);
assert(eventlock->depth() == 1);
eventlock->_Unlock(FILE__, __LINE__);
signal_printf("%s[%d]: sleeping for activation\n", FILE__, __LINE__);
waitLock->_WaitForSignal(FILE__, __LINE__);
signal_printf("%s[%d]: woken, reacquiring global lock...\n", FILE__, __LINE__);
eventlock->_Lock(FILE__, __LINE__);
signal_printf("%s[%d]: woken, releasing waitLock...\n", FILE__, __LINE__);
waitLock->_Unlock(FILE__, __LINE__);
waitingForWakeup_ = false;
}
return true;
}
示例15: findChangeToLinkMaps
// findChangeToLinkMaps: This routine returns a vector of shared objects
// that have been deleted or added to the link maps as indicated by
// change_type. If an error occurs it sets error_occured to true.
bool dynamic_linking::findChangeToLinkMaps(u_int &change_type,
pdvector<mapped_object *> &changed_objects)
{
pdvector<fileDescriptor> new_descs;
if (!didLinkMapsChange(change_type, new_descs)) {
return false;
}
const pdvector<mapped_object *> &curr_list = proc->mappedObjects();
#if 0
fprintf(stderr, "CURR_LIST:\n");
for (unsigned foo = 0; foo < curr_list.size(); foo++) {
fprintf(stderr, "%d: %s\0x%x\n",
foo, curr_list[foo]->fileName().c_str(), curr_list[foo]->codeBase());
}
#endif
// if change_type is add then figure out what has been added
if(change_type == SHAREDOBJECT_ADDED) {
// Look for the one that doesn't match
for (unsigned int i=0; i < new_descs.size(); i++) {
bool found = false;
for (unsigned int j = 0; j < curr_list.size(); j++) {
#if 0
fprintf(stderr, "Comparing %s/0x%x/0x%x/%s/%d to %s/0x%x/0x%x/%s/%d\n",
new_descs[i].file().c_str(),
new_descs[i].code(),
new_descs[i].data(),
new_descs[i].member().c_str(),
new_descs[i].pid(),
curr_list[j]->getFileDesc().file().c_str(),
curr_list[j]->getFileDesc().code(),
curr_list[j]->getFileDesc().data(),
curr_list[j]->getFileDesc().member().c_str(),
curr_list[j]->getFileDesc().pid());
#endif
if (new_descs[i] == curr_list[j]->getFileDesc()) {
found = true;
break;
}
}
if (!found) {
#if 0
fprintf(stderr, "Adding %s/%s\n",
new_descs[i].file().c_str(),
new_descs[i].member().c_str());
#endif
mapped_object *newobj = mapped_object::createMappedObject(new_descs[i],
proc);
if (!newobj) continue;
changed_objects.push_back(newobj);
// SaveTheWorld bookkeeping
#if defined(cap_save_the_world)
char *tmpStr = new char[1+strlen(newobj->fileName().c_str())];
strcpy(tmpStr, newobj->fileName().c_str());
if( !strstr(tmpStr, "libdyninstAPI_RT.so") &&
!strstr(tmpStr, "libelf.so")){
//bperr(" dlopen: %s \n", tmpStr);
newobj->openedWithdlopen();
}
setlowestSObaseaddr(newobj->codeBase());
delete [] tmpStr;
// SaveTheWorld bookkeeping
#endif
}
}
}
// if change_type is remove then figure out what has been removed
else if((change_type == SHAREDOBJECT_REMOVED) && (curr_list.size())) {
// Look for the one that's not in descs
bool stillThere[curr_list.size()];
for (unsigned k = 0; k < curr_list.size(); k++)
stillThere[k] = false;
#if defined(os_linux) || defined(os_solaris)
// Linux never includes the a.out in its list of libraries. This makes a
// certain amount of sense, but is still annoying.
// Solaris throws it away; so hey.
stillThere[0] = true;
#endif
for (unsigned int i=0; i < new_descs.size(); i++) {
for (unsigned int j = 0; j < curr_list.size(); j++) {
if (new_descs[i] == curr_list[j]->getFileDesc()) {
stillThere[j] = true;
break;
}
}
}
for (unsigned l = 0; l < curr_list.size(); l++) {
if (!stillThere[l]) {
//.........这里部分代码省略.........