00001 00002 #include <QThread> 00003 #undef NO_ADDRESS 00004 #include "boomerang.h" 00005 00006 class MainWindow; 00007 class FrontEnd; 00008 class Proc; 00009 class UserProc; 00010 class Prog; 00011 class Cluster; 00012 class QTableWidget; 00013 00014 class Decompiler : public QObject, public Watcher 00015 { 00016 Q_OBJECT 00017 00018 public: 00019 Decompiler() : QObject(), debugging(false), waiting(false) { } 00020 00021 virtual void alert_decompile_debug_point(UserProc *p, const char *description); 00022 virtual void alert_considering(Proc *parent, Proc *p); 00023 virtual void alert_decompiling(UserProc *p); 00024 virtual void alert_new(Proc *p); 00025 virtual void alert_remove(Proc *p); 00026 virtual void alert_update_signature(Proc *p); 00027 00028 bool getRtlForProc(const QString &name, QString &rtl); 00029 const char *getSigFile(const QString &name); 00030 const char *getClusterFile(const QString &name); 00031 void renameProc(const QString &oldName, const QString &newName); 00032 void rereadLibSignatures(); 00033 void getCompoundMembers(const QString &name, QTableWidget *tbl); 00034 00035 void setDebugging(bool d) { debugging = d; } 00036 void setUseDFTA(bool d); 00037 void setNoDecodeChildren(bool d); 00038 00039 void addEntryPoint(ADDRESS a, const char *nam); 00040 void removeEntryPoint(ADDRESS a); 00041 00042 public slots: 00043 void changeInputFile(const QString &f); 00044 void changeOutputPath(const QString &path); 00045 void load(); 00046 void decode(); 00047 void decompile(); 00048 void generateCode(); 00049 void stopWaiting(); 00050 00051 signals: 00052 void loading(); 00053 void decoding(); 00054 void decompiling(); 00055 void generatingCode(); 00056 void loadCompleted(); 00057 void decodeCompleted(); 00058 void decompileCompleted(); 00059 void generateCodeCompleted(); 00060 00061 void consideringProc(const QString &parent, const QString &name); 00062 void decompilingProc(const QString &name); 00063 void newUserProc(const QString &name, unsigned int addr); 00064 void newLibProc(const QString &name, const QString ¶ms); 00065 void removeUserProc(const QString &name, unsigned int addr); 00066 void removeLibProc(const QString &name); 00067 void newCluster(const QString &name); 00068 void newProcInCluster(const QString &name, const QString &cluster); 00069 void newEntrypoint(unsigned int addr, const QString &name); 00070 void newSection(const QString &name, unsigned int start, unsigned int end); 00071 00072 void machineType(const QString &machine); 00073 00074 void debuggingPoint(const QString &name, const QString &description); 00075 00076 protected: 00077 00078 bool debugging, waiting; 00079 00080 FrontEnd *fe; 00081 Prog *prog; 00082 00083 QString filename; 00084 00085 const char *procStatus(UserProc *p); 00086 void emitClusterAndChildren(Cluster *root); 00087 00088 std::vector<ADDRESS> user_entrypoints; 00089 }; 00090 00091 class DecompilerThread : public QThread 00092 { 00093 Q_OBJECT 00094 00095 public: 00096 DecompilerThread() : QThread(), decompiler(NULL) { } 00097 00098 Decompiler *getDecompiler(); 00099 00100 protected: 00101 void run(); 00102 00103 Decompiler *decompiler; 00104 };