Skip to content

Commit

Permalink
replace hash_map used in SymtabCodeSource.C
Browse files Browse the repository at this point in the history
look for duplicates at the same (region, offset) rather than just the same offset.

(cherry picked from commit d4be4e8)
  • Loading branch information
jmellorcrummey authored and Sasha Nicolas committed Sep 12, 2017
1 parent e028234 commit cd5fc64
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions parseAPI/src/SymtabCodeSource.C
Expand Up @@ -447,7 +447,10 @@ SymtabCodeSource::init_hints(dyn_hash_map<void*, CodeRegion*> & rmap,
{
vector<SymtabAPI::Function *> fsyms;
vector<SymtabAPI::Function *>::iterator fsit;
dyn_hash_map<Address,bool> seen;

typedef std::pair<SymtabAPI::Region *, Offset> RegionOffsetPair;
set<RegionOffsetPair> seen;

int dupes = 0;

if(!_symtab->getAllFunctions(fsyms))
Expand Down Expand Up @@ -475,7 +478,9 @@ SymtabCodeSource::init_hints(dyn_hash_map<void*, CodeRegion*> & rmap,
}
/*Achin added code ends*/

if(HASHDEF(seen,(*fsit)->getOffset())) {
SymtabAPI::Region * sr = (*fsit)->getRegion();
Offset so = (*fsit)->getOffset();
if (seen.find(RegionOffsetPair(sr, so)) != seen.end()) {
// XXX it looks as though symtabapi now does de-duplication
// of function symbols automatically, so this code should
// never be reached, except in the case of overlapping
Expand All @@ -486,9 +491,8 @@ SymtabCodeSource::init_hints(dyn_hash_map<void*, CodeRegion*> & rmap,
(*fsit)->getFirstSymbol()->getPrettyName().c_str());
++dupes;
}
seen[(*fsit)->getOffset()] = true;
seen.insert(RegionOffsetPair(sr, so));

SymtabAPI::Region * sr = (*fsit)->getRegion();
if(!sr) {
parsing_printf("[%s:%d] missing Region in function at %lx\n",
FILE__,__LINE__,(*fsit)->getOffset());
Expand Down

0 comments on commit cd5fc64

Please sign in to comment.