GUI work.

This commit is contained in:
nemerle
2016-04-29 15:51:02 +02:00
parent 2452984864
commit 95acbaa7fa
35 changed files with 1564 additions and 466 deletions

View File

@@ -14,10 +14,8 @@ struct PROG /* Loaded program image parameters */
int cProcs; /* Number of procedures so far */
int offMain; /* The offset of the main() proc */
uint16_t segMain; /* The segment of the main() proc */
bool bSigs; /* True if signatures loaded */
int cbImage; /* Length of image in bytes */
uint8_t * Imagez; /* Allocated by loader to hold entire program image */
int addressingMode;
public:
const uint8_t *image() const {return Imagez;}
void displayLoadInfo();

View File

@@ -9,7 +9,6 @@ class DccFrontend : public QObject
public:
explicit DccFrontend(QObject *parent = 0);
bool FrontEnd(); /* frontend.c */
void initializeMachineState(Project & proj);
signals:

View File

@@ -164,6 +164,7 @@ protected:
}
public:
int nStep; // decompilation step number for this function
FunctionType * type;
uint32_t procEntry; /* label number */
QString name; /* Meaningful name for this proc */

View File

@@ -88,7 +88,7 @@ void interactDis(Function *, int initIC); /* disassem.c */
bool JmpInst(llIcode opcode); /* idioms.c */
queue::iterator appendQueue(queue &Q, BB *node); /* reducible.c */
bool SetupLibCheck(void); /* chklib.c */
bool SetupLibCheck(QString pattern_file_id); /* chklib.c */
void CleanupLibCheck(void); /* chklib.c */
bool LibCheck(Function &p); /* chklib.c */

View File

@@ -5,18 +5,20 @@
#include <QtCore/QDir>
#include <llvm/ADT/ilist.h>
class IXmlTarget;
class IStructuredTextTarget;
struct IDcc {
static IDcc *get();
virtual void BaseInit()=0;
virtual void Init(QObject *tgt)=0;
virtual lFunction::iterator GetFirstFuncHandle()=0;
virtual lFunction::iterator GetCurFuncHandle()=0;
virtual ilFunction GetFirstFuncHandle()=0;
virtual ilFunction GetNextFuncHandle(ilFunction iter)=0;
virtual ilFunction GetCurFuncHandle()=0;
virtual bool isValidFuncHandle(ilFunction) = 0;
virtual void analysis_Once()=0;
virtual void load(QString name)=0; // load and preprocess -> find entry point
virtual void prtout_asm(IXmlTarget *,int level=0)=0;
virtual void prtout_cpp(IXmlTarget *,int level=0)=0;
virtual bool load(QString name)=0; // load and preprocess -> find entry point
virtual void prtout_asm(IStructuredTextTarget *,int level=0)=0;
virtual void prtout_cpp(IStructuredTextTarget *,int level=0)=0;
virtual size_t getFuncCount()=0;
virtual const lFunction &validFunctions() const =0;
virtual void SetCurFunc_by_Name(QString )=0;

View File

@@ -25,6 +25,62 @@ struct SegOffAddr {
uint16_t seg;
uint32_t addr;
};
enum CompilerVendor {
eUnknownVendor=0,
eBorland,
eMicrosoft,
eLogitech,
};
enum CompilerLanguage {
eUnknownLanguage=0,
eAnsiCorCPP,
ePascal,
eModula2
};
enum CompilerMemoryModel {
eUnknownMemoryModel=0,
eTiny,
eSmall,
eCompact,
eMedium,
eLarge
};
struct LoaderMetadata {
CompilerVendor compiler_vendor;
CompilerLanguage compiler_language;
CompilerMemoryModel compiler_memory_model;
int compiler_version;
QString compilerId() const {
switch(compiler_vendor) {
case eBorland:
switch(compiler_language) {
case eUnknownLanguage:
return QString("bx") + codeModelChar();
case eAnsiCorCPP:
return QString("b%1%2").arg(compiler_version).arg(codeModelChar());
case ePascal:
return QString("tp%1").arg(compiler_version);
}
case eMicrosoft:
assert(compiler_language==eAnsiCorCPP);
return QString("m%1%2").arg(compiler_version).arg(codeModelChar());
case eLogitech:
assert(compiler_language==eModula2);
return QString("l%1%2").arg(compiler_version).arg(codeModelChar());
}
return "xxx";
}
QChar codeModelChar() const {
switch(compiler_memory_model) {
case eUnknownMemoryModel: return 'x';
case eTiny: return 't';
case eSmall: return 's';
case eCompact: return 'c';
case eMedium: return 'm';
case eLarge: return 'l';
}
}
};
class Project : public QObject
{
Q_OBJECT
@@ -33,8 +89,10 @@ public:
typedef FunctionListType lFunction;
typedef FunctionListType::iterator ilFunction;
DosLoader * m_selected_loader;
public:
public:
DosLoader * m_selected_loader;
bool m_metadata_available=false;
LoaderMetadata m_loader_data;
uint32_t SynthLab; //!< Last snthetic lab idx
SYMTAB symtab; //!< Global symbol table
FunctionListType pProcList; //!< List of located functions
@@ -44,6 +102,7 @@ public:
PROG prog; /* Loaded program image parameters */
CommandStream m_project_command_stream;
bool m_error_state;
struct PatternLocator *m_pattern_locator;
public:
// prevent Project instance copying
Project(const Project&) = delete;
@@ -74,6 +133,8 @@ public:
const QString & symbolName(size_t idx);
const SYM & getSymByIdx(size_t idx) const;
LoaderMetadata &getLoaderMetadata() { assert(m_metadata_available); return m_loader_data; }
void setLoaderMetadata(LoaderMetadata d) { m_loader_data = d; m_metadata_available=true;}
static Project * get();
PROG * binary() {return &prog;}
SourceMachine *machine();
@@ -81,14 +142,16 @@ public:
const FunctionListType &functions() const { return pProcList; }
FunctionListType &functions() { return pProcList; }
bool addCommand(Command *cmd) { return m_project_command_stream.add(cmd); }
bool addCommand(Command *cmd) { return m_project_command_stream.add(cmd); emit commandListChanged(); }
void dumpAllErrors();
void setLoader(DosLoader *ins);
void processCommands(int count=1);
public slots:
void onCommandStreamFinished(bool state);
signals:
void newFunctionCreated(Function &);
void loaderSelected();
void commandListChanged();
protected:
void initialize();
void writeGlobSymTable();