本文整理汇总了C++中hash_map::insert方法的典型用法代码示例。如果您正苦于以下问题:C++ hash_map::insert方法的具体用法?C++ hash_map::insert怎么用?C++ hash_map::insert使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类hash_map
的用法示例。
在下文中一共展示了hash_map::insert方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: calc
int calc(char s[])
{
len = strlen(s);
Manacher(s,len);
sum[0] = s[0];
for (int i = 1; i < len; i++)
sum[i] = sum[i-1]*muts+s[i];
int res = 0;
uint tmp;
int nt = 0;
hash.clear();
//odd
for (int i = 0; i < len; i++)
if (Mp[i*2+2]%2 == 0)
{
int pl = Mp[i*2+2]/2;
if (i+pl < nt || pl == 0) continue;
for (int j = i-pl+1; j <= i; j++)
{
tmp = gethashcode(j,i);
if (hash.find(tmp,i-j+1) != -1) break;
hash.insert(tmp,i-j+1);
}
nt = i+pl;
}
res += hash.N;
nt = 0;
hash.clear();
//even
for (int i = 0; i < len; i++)
if (Mp[i*2+3] > 1)
{
int pl = Mp[i*2+3]/2;
if (i+pl < nt || pl == 0) continue;
for (int j = i-pl+1; j <= i; j++)
{
tmp = gethashcode(j,i);
if (hash.find(tmp,i-j+1) != -1) break;
hash.insert(tmp,i-j+1);
}
nt = i+pl;
}
res += hash.N;
return res;
}
示例2: computeIDoms
void computeIDoms(vector<IFR_BasicBlock> &bblist,
hash_map<ADDRINT, set<ADDRINT> > &dom,
hash_map<ADDRINT, ADDRINT> &idom){
for( vector<IFR_BasicBlock>::iterator bi = bblist.begin();
bi != bblist.end();
bi++
){
for( set<ADDRINT>::iterator di = dom[bi->getEntryAddr()].begin();
di != dom[bi->getEntryAddr()].end();
di++
){
if( *di == bi->getEntryAddr() ){ continue; } //only strict dominators are considered
bool iDom = true;
for( set<ADDRINT>::iterator odi = dom[bi->getEntryAddr()].begin();
odi != dom[bi->getEntryAddr()].end();
odi++
){
if( *odi == bi->getEntryAddr() ){ continue; } //bi-> is the one whose idom we're looking for
if( *odi == *di ){ continue; } //only strict dominators are considered
/*If any other dominator in bi's dominator set is dominated by di, then
*di can't be bi's iDom.
*/
if( dom[ *odi ].find( *di ) != dom[ *odi ].end()){
iDom = false;
}
}
if( iDom ){
assert( idom.find(bi->getEntryAddr()) == idom.end() );
idom.insert( std::pair<ADDRINT, ADDRINT>(bi->getEntryAddr(), *di) );
}
}
if( idom.find(bi->getEntryAddr()) == idom.end() ){
/*an immediate dominator of 0 means this node has no immediate dominator*/
idom.insert( std::pair<ADDRINT, ADDRINT>(bi->getEntryAddr(), 0) );
}
}
}
示例3: countPairs
void countPairs(vector<Event*> &events){
for( vector<Event*>::iterator fst = events.begin();
fst != events.end(); fst++){
for( vector<Event*>::iterator snd = fst;
snd != events.end() && snd - fst < THRESHOLD; snd++){
if( (*fst)->thread != (*snd)->thread ){
string fString = (*fst)->btString();
string sString = (*snd)->btString();
bool found = false;
pthread_rwlock_rdlock( &histoLock );
if( histo.find( fString ) != histo.end() ){
if( histo[fString].find( sString ) != histo[fString].end() ){
found = true;
histo[fString][sString][snd-fst]++;
}
}
pthread_rwlock_unlock( &histoLock );
if( !found ){
pthread_rwlock_wrlock( &histoLock );
if( (histo.find( fString )) == histo.end() ){
histo.insert(
std::pair<string,
hash_map<string, vector<unsigned long> > >(fString,
hash_map<string, vector<unsigned long> >()));
}
if( histo[fString].find(sString) == histo[fString].end() ){
histo[fString].insert(std::pair<string,
vector<unsigned long> >(sString,
vector<unsigned long>()));
for(int i = 0; i < THRESHOLD; i++ ){
histo[fString][sString].push_back(0);
}
}
assert(snd - fst < THRESHOLD);
histo[fString][sString][snd-fst]++;
pthread_rwlock_unlock( &histoLock );
}
}
}
}
}
示例4: unparseAndIntern
inline void* unparseAndIntern(SgAsmExpression* e) {
hash_map<SgAsmExpression*, void*>::const_iterator i = unparseAndInternTable.find(e);
if (i == unparseAndInternTable.end()) {
void* sPtr = intern(unparseX86Expression(e, NULL));
unparseAndInternTable.insert(std::make_pair(e, sPtr));
return sPtr;
} else {
return i->second;
}
}
示例5: insert
void _Catalog_locale_map::insert(int key, const locale& L)
{
// Don't bother to do anything unless we're using a non-default ctype facet
try {
typedef ctype<wchar_t> wctype;
if (typeid(use_facet<wctype>(L)) != typeid(const wctype&)) {
if (!M)
M = new hash_map<int, locale>;
if (M->find(key) == M->end())
M->insert(pair<const int, locale>(key, L));
}
}
catch(...) {}
}
示例6: SettingData
void SettingData(vector< InputData*> & inputData, hash_map< string, set< int>> & settingInputData, vector< set< int>*> & saveSetPointer, set< string> & playerIdset){
unsigned int playerCount = playerIdset.size();
for (auto& i = playerIdset.begin(); i != playerIdset.end(); ++i){
string curPlayer = *i;
set< int> * setArr = new set < int > ;
saveSetPointer.push_back(setArr);
settingInputData.insert(hash_map < string, set< int> >::value_type(curPlayer, *setArr));
}
unsigned int dataCount = inputData.size();
for (unsigned int i = 0; i < dataCount; ++i){
set< int> & curSet = settingInputData[inputData[i]->GetPlayerId()];
curSet.insert(inputData[i]->GetDungeonId());
}
}
示例7: CSLTokenizeStringComplex
static void SetupUTMMap(int inZone)
{
if (sUTMProj.find(inZone) != sUTMProj.end()) return;
char ** args;
char argString[512];
projPJ proj;
// sprintf(argString,"+units=m +proj=utm +zone=%d +ellps=WGS84 ", inZone);
sprintf(argString,"+units=m +proj=utm +zone=%d +ellps=clrk66 ", inZone);
args = CSLTokenizeStringComplex(argString, " +", TRUE, FALSE);
proj = pj_init(CSLCount(args), args);
CSLDestroy(args);
if (proj != NULL)
sUTMProj.insert(hash_map<int, projPJ>::value_type(inZone, proj));
// sNADGrid = nad_init("conus.bin");
}
示例8: preOrder
int preOrder(Node* head, int sum, int preSum, int level, int &maxlen, hash_map<int, int> &sumMap)
{
if (head == NULL)
return maxlen;
int curSum = preSum + head->value;
if (sumMap.count(curSum - sum) == 1)
{
maxlen = (level - sumMap[curSum - sum]) > maxlen ? (level - sumMap[curSum - sum]) : maxlen;
}
if (sumMap.count(curSum) == 0)
{
sumMap.insert(make_pair(curSum, level));
}
maxlen = preOrder(head->left, sum, curSum, level + 1, maxlen, sumMap);
maxlen = preOrder(head->right, sum, curSum, level + 1, maxlen, sumMap);
if (level == sumMap[curSum])
{
sumMap.erase(curSum);
}
return maxlen;
}
示例9: findBlocks
void findBlocks(RTN rtn,
vector<IFR_BasicBlock> &bblist,
hash_map<ADDRINT, IFR_BasicBlock> &blocks){
/*Takes a PIN RTN object and returns a set containing the
*addresses of the instructions that are entry points to basic blocks
*"Engineering a Compiler pg 439, Figure 9.1 'Finding Leaders'"
*/
set<ADDRINT> leaders = set<ADDRINT>();
bool first = true;
for (INS ins = RTN_InsHead(rtn); INS_Valid(ins); ins = INS_Next(ins)){
if( first ){
first = false;
leaders.insert( INS_Address(ins) );
}
if( INS_IsBranch(ins) ){
assert( !INS_IsRet(ins) );
if( !INS_IsIndirectBranchOrCall(ins) ){
leaders.insert(INS_DirectBranchOrCallTargetAddress(ins));
leaders.insert(INS_NextAddress(ins));
}/*else{
Calls and Indirect Branches may go anywhere, so we conservatively assume they jump to the moon
}*/
}
}
int ii = 0;
IFR_BasicBlock bb = IFR_BasicBlock();
for (INS ins = RTN_InsHead(rtn); INS_Valid(ins); ins = INS_Next(ins)){
bb.add(ins);
INS next = INS_Next(ins);
if( (INS_Valid(next) && leaders.find(INS_Address(next)) != leaders.end()) || !INS_Valid(next) ){
/*Next is a block leader or end of routine -- End the block here*/
if( INS_IsBranch(ins) ){
/*Block ends with a branch insn*/
assert( !INS_IsRet(ins) );
if( !INS_IsIndirectBranchOrCall(ins) ){
/*End of block with Direct Branch insns*/
bb.setTarget(INS_DirectBranchOrCallTargetAddress(ins));
if( INS_Category(ins) != XED_CATEGORY_UNCOND_BR ){
bb.setFallthrough(INS_NextAddress(ins));
}else{
bb.setFallthrough(0);
}
}
}else{
/*Block ends with a non-branch insn*/
bb.setTarget(0);
bb.setFallthrough(INS_NextAddress(ins));
}
blocks.insert( std::pair<ADDRINT,IFR_BasicBlock>(bb.getEntryAddr(), IFR_BasicBlock(bb)) );
bblist.push_back(IFR_BasicBlock(bb));
bb.clear();
}
}
return;
}
示例10: computeDominators
void computeDominators(RTN rtn,
vector<IFR_BasicBlock> &bblist,
hash_map<ADDRINT, set<ADDRINT> > &pred,
hash_map<ADDRINT, set<ADDRINT> > &dom){
set<ADDRINT> allNodes = set<ADDRINT>();
for( vector<IFR_BasicBlock>::iterator i = bblist.begin(); i != bblist.end(); i++){
allNodes.insert( i->getEntryAddr() );
}
/*Set the dominator set of the entry node to be empty*/
dom.insert(std::pair<ADDRINT,set<ADDRINT> >(bblist.begin()->getEntryAddr(), set<ADDRINT>()));
dom[ bblist.begin()->getEntryAddr() ].insert( bblist.begin()->getEntryAddr() );
/*Set the dominator set for all other nodes to be all nodes*/
bool first = true;
for( vector<IFR_BasicBlock>::iterator i = bblist.begin(); i != bblist.end(); i++){
if( first ){
/*Skip the first block*/
first = false;
continue;
}
dom.insert(std::pair<ADDRINT,set<ADDRINT> >(i->getEntryAddr(), set<ADDRINT>()));
dom[ i->getEntryAddr() ].insert( allNodes.begin(), allNodes.end() );
}
/*Fixed-Point Part: Iteratively remove elems from each nodes dom set until
* no set changes.
*/
int dbg_i = 0;
bool anyChange;
do{
anyChange = false;
dbg_i++;
bool first = true;
for( vector<IFR_BasicBlock>::iterator i = bblist.begin(); i != bblist.end(); i++){
if( first ){
/*Skip the first block*/
first = false;
continue;
}
/*Intersection over all p \in pred(n)( dom(p) ) ... */
set<ADDRINT> intDoms = set<ADDRINT>();
bool firstPred = true;
for(set<ADDRINT>::iterator p = pred[ i->getEntryAddr() ].begin();
p != pred[ i->getEntryAddr() ].end();
p++
){
/*p is a predecessor of i*/
if( firstPred ){
/*If it is the first predecessor, intDoms is empty, so initialize it with p's doms*/
firstPred = false;
intDoms.insert( dom[ *p ].begin(), dom[ *p ].end() );
}else{
/*If p is non-empty, we've seen a predecessor, so we only want the common elems in intDoms and dom(p)*/
set<ADDRINT> intersection = set<ADDRINT>();
std::set_intersection( intDoms.begin(), intDoms.end(),
dom[ *p ].begin(), dom[ *p ].end(),
std::inserter( intersection, intersection.begin() ) );
intDoms.clear();
intDoms.insert(intersection.begin(), intersection.end());
}
}
/*... Unioned with n itself */
intDoms.insert( i->getEntryAddr() );
if( intDoms.size() != dom[ i->getEntryAddr() ].size() ){
anyChange = true;
}
dom[ i->getEntryAddr() ].clear();
dom[ i->getEntryAddr() ].insert( intDoms.begin(), intDoms.end() );
}
}while(anyChange);
}
示例11: Callback
void Callback(string dir,WCHAR* X,vector<data*>& Y,hash_map<string,indx>& Z,int label)
{
std::wstring wstr(X);
char buf[MAX_SIZE];
string file(wstr.begin(),wstr.end());
file=dir+file;
std::ifstream ifs(file,ifstream::in);
string temp;
int pos=0;
int tos=0;
int sum=0;
hash_map<string,indx>::iterator ter;
hash_map<string,int>::iterator iter;
while(ifs.good())
{
if(label==1)
positivecnt++;
else if(label==-1)
negativecnt++;
else
predictcnt++;
sum=0;
data* _dt=new data();
set<attribute,attribute>example;
hash_map<string,int>tempo;
ifs.getline(buf,MAX_SIZE);
temp.assign(buf);
if(temp.length()<=1)
continue;
while((pos=temp.find_first_of(',',tos+1))!=string::npos)
{
if((iter=tempo.find(temp.substr(tos,pos-tos)))!=tempo.end())
{
iter->second++;
sum++;
}
else
{
if(temp.substr(tos,pos-tos)!="")
{
tempo.insert(pair<string,int>(temp.substr(tos,pos-tos),1));
sum++;
}
}
tos=pos+1;
}
if((iter=tempo.find(temp.substr(tos)))!=tempo.end())
{
iter->second++;
sum++;
}
else
{
if(temp.substr(tos,pos-tos)!="")
{
tempo.insert(pair<string,int>(temp.substr(tos),1));
sum++;
}
}
int i;
for(i=0,iter=tempo.begin();iter!=tempo.end();iter++,i++)
{
if(label!=0)
{
if((ter=Z.find(iter->first))!=Z.end())
ter->second.DF++;
else
{
indx i;
i.DF=1;
i.index=Z.size()+1;
Z.insert(pair<string,indx>(iter->first,i));
}
}
attribute a;
a.feature=iter->first;
a.TF=((double)iter->second)/(double)sum;
a.index=((ter=Z.find(iter->first))!=Z.end())?ter->second.index:0;
example.insert(a);
}
_dt->features=example;
if(label==1)
_dt->label=1;
else if(label==-1)
_dt->label=-1;
else
_dt->label=0;
Y.push_back(_dt);
pos=0;
tos=0;
}
}
示例12: mapLoadDefaultColour
void mapLoadDefaultColour()
{
if(g_dayColourUnits.size()&&g_nightColourUnits.size())
{
return;
}
g_dayColourUnits.clear();
g_nightColourUnits.clear();
size_t maxTableSize = sizeof(g_roadColourTable) / sizeof(TMapColourEntry);
for(size_t i = 0; i < maxTableSize; i++){ //load road
ColourUnit cUnit;
cUnit.type = ROAD_ARC_MISC;
RGBCOLOUR colour = g_navDisplay->getColour(g_roadColourTable[i].colourIndex);
cUnit.colour.red = colour.red;
cUnit.colour.green = colour.green;
cUnit.colour.blue = colour.blue;
cUnit.colour.alpha = colour.alpha;
cUnit.typeIndex = i;
if(g_dayColourUnits.find(g_roadColourTable[i].legend) == g_dayColourUnits.end())
{
g_dayColourUnits.insert(ColourPair(g_roadColourTable[i].legend, cUnit));
g_nightColourUnits.insert(ColourPair(g_roadColourTable[i].legend, cUnit));
}
}
TElevationPalette *pElevationPalette = g_navDisplay->getElevationPalette();
for(size_t i = 0; i < numberOfGradients; i++){ //load gradient
ColourUnit cUnit;
if(i < pElevationPalette->elevationThresholdsCount){
cUnit.type = GRADIENT_ENABLE;
TElevationPaletteEntry entry = pElevationPalette->elevationPalette[i];
cUnit.colour.red = entry.r;
cUnit.colour.green = entry.g;
cUnit.colour.blue = entry.b;
cUnit.colour.alpha = entry.elevation;
}else{
cUnit.type = GRADIENT_DISABLE;
}
if(g_dayColourUnits.find(STR_GRADIENT[i]) == g_dayColourUnits.end())
{
g_dayColourUnits.insert(ColourPair(STR_GRADIENT[i], cUnit));
g_nightColourUnits.insert(ColourPair(STR_GRADIENT[i], cUnit));
}
}
maxTableSize = sizeof(g_polyColourTable) /
sizeof(TPolyMapColourEntry) - 1; //last one is elevation, so skip
for(size_t i = 0; i < maxTableSize; i++) { //load poly
ColourUnit cUnit;
cUnit.type = POLY_CITY;
RGBCOLOUR colour = g_navDisplay->getPolygonFillColour(g_polyColourTable[i].polyClass);
cUnit.colour.red = colour.red;
cUnit.colour.green = colour.green;
cUnit.colour.blue = colour.blue;
cUnit.colour.alpha = colour.alpha;
cUnit.typeIndex = i;
if(g_dayColourUnits.find(g_polyColourTable[i].polyName) == g_dayColourUnits.end())
{
g_dayColourUnits.insert(ColourPair(g_polyColourTable[i].polyName, cUnit));
g_nightColourUnits.insert(ColourPair(g_polyColourTable[i].polyName, cUnit));
}
}
g_currentColourType = DAY;
}
示例13: InitMaps
void InitMaps()
{
hash_map<wstring,WORD> slots;
// process boots map file
hash_map<DWORD,wstring> mapFile;
wstring mpath(getPesInfo()->gdbDir);
mpath += L"GDB\\boots\\map.txt";
if (!readMap(mpath.c_str(), mapFile))
{
LOG1S(L"Couldn't open boots map for reading: {%s}",mpath.c_str());
}
else
{
int slot = 0;
for (hash_map<DWORD,wstring>::iterator it = mapFile.begin(); it != mapFile.end(); it++)
{
wstring boot(it->second);
string_strip(boot);
if (!boot.empty())
string_strip_quotes(boot);
if (!boot.empty())
{
// check that the file exists, so that we don't crash
// later, when it's attempted to replace a boot.
wstring filename(getPesInfo()->gdbDir);
filename += L"GDB\\boots\\" + boot;
HANDLE handle;
DWORD size;
if (OpenFileIfExists(filename.c_str(), handle, size))
{
CloseHandle(handle);
if (slot >= MAX_BOOTS)
{
LOG2N(L"ERROR in bootserver map: Too many boots: %d (MAX supported = %d). Aborting map processing", slot, MAX_BOOTS);
break;
}
hash_map<wstring,WORD>::iterator wit = slots.find(boot);
if (wit != slots.end())
{
// boot already has an assigned slot
_boot_slots.insert(pair<DWORD,WORD>(
it->first, wit->second));
}
else
{
_boot_slots.insert(pair<DWORD,WORD>(
it->first, FIRST_EXTRA_BOOT_SLOT + slot));
slots.insert(pair<wstring,WORD>(
boot, FIRST_EXTRA_BOOT_SLOT + slot));
slot++;
}
}
else
LOG1N1S(L"ERROR in bootserver map for ID = %d: FAILED to open boot BIN \"%s\". Skipping", it->first, boot.c_str());
}
}
}
if (_bootserv_config._random_boots)
{
// enumerate all boots and add them to the slots list
wstring dir(getPesInfo()->gdbDir);
dir += L"GDB\\boots\\";
// normalize the path
wchar_t fullpath[MAX_PATH];
GetFullPathName(dir.c_str(), MAX_PATH, fullpath, 0);
dir = fullpath;
int count;
LOG(L"Enumerating all boots in GDB...");
EnumerateBoots(dir, count);
_num_random_boots = count;
LOG1N(L"_num_random_boots = %d", _num_random_boots);
}
// initialize fast bin lookup table
for (hash_map<wstring,WORD>::iterator sit = slots.begin();
sit != slots.end();
sit++)
{
_fast_bin_table[sit->second - FIRST_EXTRA_BOOT_SLOT] =
new wstring(sit->first);
if (k_bootserv.debug)
LOG1N1S(L"slot %d <-- boot {%s}", sit->second, sit->first.c_str());
}
LOG1N(L"Total assigned GDB boots: %d", slots.size());
LOG1N(L"Total random GDB boots: %d", _num_random_boots);
if (slots.size() > 0)
_num_slots = FIRST_EXTRA_BOOT_SLOT + slots.size();
if (_num_random_boots > 0)
_num_slots = FIRST_RANDOM_BOOT_SLOT + _num_random_boots;
LOG1N(L"_num_slots = %d", _num_slots);
}
示例14: AnalyzeBlock
//.........这里部分代码省略.........
is_positive_jmp=TRUE;
}else
{
is_positive_jmp=FALSE;
}
}
vector<ea_t>::iterator cref_list_iter;
//If Split Block
//must be jmp,next block has only one cref_to
if(cref_list.size()==1 && current_itype==NN_jmp && InstructionCount>1)
{
cref_list_iter=cref_list.begin();
ea_t next_block_addr=*cref_list_iter;
//cref_to
int cref_to_count=0;
ea_t cref_to=get_first_cref_to(next_block_addr);
while(cref_to!=BADADDR)
{
if(current_addr!=cref_to)
cref_to_count++;
cref_to=get_next_cref_to(next_block_addr,cref_to);
}
if(cref_to_count==0)
{
//Merge it
if(!FirstBlockEndAddr)
FirstBlockEndAddr=current_addr+current_item_size;
//next_block_addr should not be analyzed again next time.
if(CurrentBlockStart!=StartEA)
{
WriteToLogFile(gLogFile,"%s: [AdditionallyAnalyzedBlocksIter] Set Analyzed %X~%X\n",__FUNCTION__,CurrentBlockStart,current_addr+current_item_size);
AdditionallyAnalyzedBlocks.insert(pair<ea_t,ea_t>(CurrentBlockStart,current_addr+current_item_size));
}
if(CurrentBlockStart!=next_block_addr)
{
CurrentBlockStart=next_block_addr;
WriteToLogFile(gLogFile,"%s: [AdditionallyAnalyzedBlocksIter] Set CurrentBlockStart=%X\n",__FUNCTION__,CurrentBlockStart);
current_addr=next_block_addr;
FoundBranching=FALSE;
cref_list.clear();
continue;
}
}
}
if(is_positive_jmp)
{
for(cref_list_iter=cref_list.begin();
cref_list_iter!=cref_list.end();
cref_list_iter++)
{
map_info.Type=CREF_FROM;
map_info.Dst=*cref_list_iter;
if(!Callback(Context,
MAP_INFO,
(PBYTE)&map_info,
sizeof(map_info)))
{
break;
}
}
}else
{
vector<ea_t>::reverse_iterator cref_list_iter;
for(cref_list_iter=cref_list.rbegin();
示例15: if
///////////////////////////////////////////////////////////
//Save & Trace Variables
void UpdateInstructionMap
(
hash_map <op_t,OperandPosition,OpTHashCompareStr> &OperandsHash,
hash_map <int,ea_t> &FlagsHash,
//Instruction Hash and Map
multimap <OperandPosition,OperandPosition,OperandPositionCompareTrait> &InstructionMap,
hash_map <ea_t,insn_t> &InstructionHash,
insn_t &instruction
)
{
ea_t address=instruction.ea;
InstructionHash.insert(pair<ea_t,insn_t>(address,instruction));
char Features[UA_MAXOP*2];
GetFeatureBits(instruction.itype,Features,sizeof(Features));
if(Debug>0)
WriteToLogFile(gLogFile,"%s(%X) %s\r\n",ph.instruc[instruction.itype].name,instruction.itype,GetFeatureStr(ph.instruc[instruction.itype].feature).c_str());
//Flags Tracing
list <int> Flags=GetRelatedFlags(instruction.itype,true);
list <int>::iterator FlagsIter;
for(FlagsIter=Flags.begin();FlagsIter!=Flags.end();FlagsIter++)
{
//Set Flags: FlagsHash
FlagsHash.insert(pair<int,ea_t>(*FlagsIter,address));
}
Flags=GetRelatedFlags(instruction.itype,false);
for(FlagsIter=Flags.begin();FlagsIter!=Flags.end();FlagsIter++)
{
//Use Flags: FlagsHash
hash_map <int,ea_t>::iterator FlagsHashIter=FlagsHash.find(*FlagsIter);
if(FlagsHashIter!=FlagsHash.end())
{
//FlagsHashIter->first
//FlagsHashIter->second
OperandPosition SrcOperandPosition;
SrcOperandPosition.Address=FlagsHashIter->second;
SrcOperandPosition.Index=0;
OperandPosition DstOperandPosition;
DstOperandPosition.Address=address;
DstOperandPosition.Index=0;
InstructionMap.insert(pair<OperandPosition,OperandPosition>(SrcOperandPosition,DstOperandPosition));
}
}
//Return Value Tracing
//Parameter Tracing
//ARM_blx/ARM_blx1/ARM_blx2
if(
(ph.id==PLFM_ARM && (instruction.itype==ARM_bl || instruction.itype==ARM_blx1 || instruction.itype==ARM_blx2)) ||
(ph.id==PLFM_MIPS && (instruction.itype==MIPS_jal || instruction.itype==MIPS_jalx))
)
{
op_t operand;
operand.type=o_reg;
for(int reg=0;reg<5;reg++)
{
operand.reg=reg;
hash_map <op_t,OperandPosition,OpTHashCompareStr>::iterator iter=OperandsHash.find(operand);
if(iter!=OperandsHash.end())
{
OperandPosition SrcOperandPosition;
SrcOperandPosition.Address=iter->second.Address;
SrcOperandPosition.Index=iter->second.Index;
OperandPosition DstOperandPosition;
DstOperandPosition.Address=address;
DstOperandPosition.Index=0;
InstructionMap.insert(pair<OperandPosition,OperandPosition>(SrcOperandPosition,DstOperandPosition));
}else
{
break;
}
}
}
//Operand Tracing
for(int i=UA_MAXOP-1;i>=0;i--)
{
op_t *pOperand=&instruction.Operands[i];
if(pOperand->type>0)
{
//o_mem,o_displ,o_far,o_near -> addr
//o_reg -> reg
//o_phrase,o_displ -> phrase
//outer displacement (o_displ+OF_OUTER_DISP) -> value
//o_imm -> value
WriteToLogFile(gLogFile,"\tOperand %u: [%s%s] ",i,(Features[i]&CF_CHG)?"CHG":"",(Features[i]&CF_USE)?"USE":"");
if(Features[i]&CF_USE)
{
hash_map <op_t,OperandPosition,OpTHashCompareStr>::iterator iter=OperandsHash.find(*pOperand);
if(iter==OperandsHash.end())
{
//.........这里部分代码省略.........