Skip to content

Commit

Permalink
Added extra block locks to remove some more data races; added callbac…
Browse files Browse the repository at this point in the history
…k and method to allow renaming of functions that would by default be "targXXX"
  • Loading branch information
wrwilliams committed Jul 12, 2017
1 parent 24f7a40 commit a462fa1
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 3 deletions.
1 change: 1 addition & 0 deletions parseAPI/h/CFG.h
Expand Up @@ -494,6 +494,7 @@ class PARSER_EXPORT Function : public allocatable, public AnnotatableSparse, pub
virtual ~Function();

virtual const std::string & name() const;
void rename(std::string n) { _name = n; }

Address addr() const { return _start; }
CodeRegion * region() const { return _region; }
Expand Down
3 changes: 2 additions & 1 deletion parseAPI/h/ParseCallback.h
Expand Up @@ -155,6 +155,7 @@ class ParseCallback {
virtual void add_block_cb(Function *, Block *) {};

virtual void modify_edge_cb(Edge *, Block *, ParseCallback::edge_type_t) {};
virtual void function_discovery_cb(Function*) {};

private:
};
Expand Down Expand Up @@ -204,7 +205,7 @@ class ParseCallbackManager {
bool hasWeirdInsns(const Function*);
void foundWeirdInsns(Function*);
void split_block_cb(Block *, Block *);

void discover_function(Function*);

private:
// Named the same as ParseCallback to make the code
Expand Down
5 changes: 5 additions & 0 deletions parseAPI/src/ParseCallback.C
Expand Up @@ -231,6 +231,11 @@ void ParseCallbackManager::split_block_cb(Block *a, Block *b) {
(*iter)->split_block_cb(a, b);
};

void ParseCallbackManager::discover_function(Function* f) {
for (iterator iter = begin(); iter != end(); ++iter)
(*iter)->function_discovery_cb(f);
};

void ParseCallbackManager::destroy_cb(Block *b) {
for (iterator iter = begin(); iter != end(); ++iter)
(*iter)->destroy_cb(b);
Expand Down
6 changes: 4 additions & 2 deletions parseAPI/src/Parser.C
Expand Up @@ -1023,6 +1023,7 @@ Parser::parse_frame(ParseFrame & frame, bool recursive) {
// check for system call FT
Edge* edge = work->edge();
Block::Insns blockInsns;
boost::lock_guard<Block> src_guard(*edge->src());
edge->src()->getInsns(blockInsns);
auto prev = blockInsns.rbegin();
InstructionAPI::InstructionPtr prevInsn = prev->second;
Expand Down Expand Up @@ -1777,6 +1778,7 @@ Parser::bind_call(ParseFrame & frame, Address target, Block * cur, Edge * exist)
FILE__,__LINE__,target);
return pair<Function*,Edge*>((Function *) NULL,exist);
}
_pcb.discover_function(tfunc);

// add an edge
pair<Block*,Edge*> ret = add_edge(frame,tfunc,cur,target,CALL,exist);
Expand Down Expand Up @@ -1886,8 +1888,8 @@ Parser::link(Block *src, Block *dst, EdgeTypeEnum et, bool sink)
assert(et != NOEDGE);
Edge * e = factory()._mkedge(src,dst,et);
e->_type._sink = sink;
src->_trglist.push_back(e);
dst->_srclist.push_back(e);
src->addTarget(e);
dst->addSource(e);
_pcb.addEdge(src, e, ParseCallback::target);
_pcb.addEdge(dst, e, ParseCallback::source);
return e;
Expand Down

0 comments on commit a462fa1

Please sign in to comment.