if CFG is missing Project::createFunction should create one

This commit is contained in:
nemerle 2016-04-29 12:22:42 +02:00
parent 4a6d97c1b1
commit 4682bda8d8
2 changed files with 13 additions and 16 deletions

View File

@ -64,7 +64,7 @@ public:
QString output_name(const char *ext); QString output_name(const char *ext);
ilFunction funcIter(Function *to_find); ilFunction funcIter(Function *to_find);
ilFunction findByEntry(uint32_t entry); ilFunction findByEntry(uint32_t entry);
ilFunction createFunction(FunctionType *f, const QString & name); ilFunction createFunction(FunctionType *f, const QString & name, SegOffAddr addr);
bool valid(ilFunction iter); bool valid(ilFunction iter);
int getSymIdxByAdd(uint32_t adr); int getSymIdxByAdd(uint32_t adr);
@ -86,7 +86,6 @@ public:
void setLoader(DosLoader *ins); void setLoader(DosLoader *ins);
public slots: public slots:
void onCommandStreamFinished(bool state); void onCommandStreamFinished(bool state);
void onNewFunctionDiscovered(SegOffAddr ip,QString name,FunctionType *ft);
signals: signals:
void newFunctionCreated(Function &); void newFunctionCreated(Function &);
void loaderSelected(); void loaderSelected();

View File

@ -58,23 +58,21 @@ ilFunction Project::findByEntry(uint32_t entry)
[entry](const Function &f) { return f.procEntry==entry; }); [entry](const Function &f) { return f.procEntry==entry; });
return iter; return iter;
} }
void Project::onNewFunctionDiscovered(SegOffAddr ip, QString name, FunctionType *ft) { ilFunction Project::createFunction(FunctionType *f,const QString &name,SegOffAddr addr)
FIXME;
auto proc = createFunction(ft,name);
// FIXME: use provided segment addr !
proc->procEntry = ip.addr;
if(name=="main") {
/* In medium and large models, the segment of main may (will?) not be
the same as the initial CS segment (of the startup code) */
m_entry_state.setState(rCS, prog.segMain);
m_entry_state.IP = prog.offMain;
}
}
ilFunction Project::createFunction(FunctionType *f,const QString &name)
{ {
pProcList.push_back(Function::Create(f,0,name,0)); pProcList.push_back(Function::Create(f,0,name,0));
ilFunction iter = (++pProcList.rbegin()).base(); ilFunction iter = (++pProcList.rbegin()).base();
// FIXME: use provided segment addr !
iter->procEntry = addr.addr;
if(!callGraph) {
/* Set up call graph initial node */
callGraph = new CALL_GRAPH;
callGraph->proc = iter;
/* The entry state info is for the first procedure */
iter->state = m_entry_state;
}
emit newFunctionCreated(*iter); emit newFunctionCreated(*iter);
return iter; return iter;
} }