# HG changeset patch # User jeandet # Date 2014-05-28 06:08:03 # Node ID b04e90691097997f168e0b4356148c40d0156dfc # Parent df89a9dbf204ae82901193ae1c485b895e610a32 ElfFile classes WIP. diff --git a/src/common/PySocExplorer.h b/src/common/PySocExplorer.h --- a/src/common/PySocExplorer.h +++ b/src/common/PySocExplorer.h @@ -1,6 +1,11 @@ +#include +#include #include "qhexspinbox.h" #include "memsizewdgt.h" #include "qhexedit/qhexedit.h" #include "SocExplorerPlot.h" #include "tcp_terminal_client.h" #include "elf/elfparser.h" +#include "elf/abstractexecfile.h" +#include "elf/elffile.h" +#include "elf/elffilewidget.h" diff --git a/src/common/abstractexecfile.cpp b/src/common/abstractexecfile.cpp --- a/src/common/abstractexecfile.cpp +++ b/src/common/abstractexecfile.cpp @@ -21,12 +21,11 @@ ----------------------------------------------------------------------------*/ #include "abstractexecfile.h" -abstractExecFile::abstractExecFile(QObject *parent) : - QObject(parent) +abstractExecFile::abstractExecFile() { } -abstractExecFile::abstractExecFile(const QString &File, QObject *parent) +abstractExecFile::abstractExecFile(const QString &File) { } diff --git a/src/common/abstractexecfile.h b/src/common/abstractexecfile.h --- a/src/common/abstractexecfile.h +++ b/src/common/abstractexecfile.h @@ -33,19 +33,15 @@ public: quint32 address; }; -class abstractExecFile : public QObject +class abstractExecFile { - Q_OBJECT public: - abstractExecFile(QObject *parent = 0); - abstractExecFile(const QString& File,QObject *parent = 0); + abstractExecFile(); + abstractExecFile(const QString& File); virtual bool openFile(const QString& File)=0; virtual bool isopened()=0; virtual int closeFile()=0; virtual QList getFragments()=0; -signals: - -public slots: protected: QString p_fileName; diff --git a/src/common/common.pro b/src/common/common.pro --- a/src/common/common.pro +++ b/src/common/common.pro @@ -38,6 +38,7 @@ header.files = \ elf/elfinfowdgt.h \ elf/elfparser.h \ elf/elffile.h \ + elf/elffilewidget.h \ qipdialogbox.h \ lppserial/src/RS232.h diff --git a/src/common/elf/elffile.cpp b/src/common/elf/elffile.cpp --- a/src/common/elf/elffile.cpp +++ b/src/common/elf/elffile.cpp @@ -23,13 +23,13 @@ ----------------------------------------------------------------------------*/ #include "elffile.h" -ElfFile::ElfFile(QObject *parent) : - abstractExecFile(parent) +ElfFile::ElfFile(QObject *parent) + :QObject(parent),abstractExecFile(),elfparser() { } ElfFile::ElfFile(const QString &File, QObject *parent) - :abstractExecFile(parent),elfparser() + :QObject(parent),abstractExecFile(),elfparser() { this->p_fileName = File; setFilename(File); diff --git a/src/common/elf/elffile.h b/src/common/elf/elffile.h --- a/src/common/elf/elffile.h +++ b/src/common/elf/elffile.h @@ -27,7 +27,7 @@ #ifndef ELFFILE_H #define ELFFILE_H -class ElfFile : public abstractExecFile, public elfparser +class ElfFile :public QObject, public abstractExecFile, public elfparser { Q_OBJECT public: diff --git a/src/common/elf/elffilewidget.cpp b/src/common/elf/elffilewidget.cpp --- a/src/common/elf/elffilewidget.cpp +++ b/src/common/elf/elffilewidget.cpp @@ -22,5 +22,23 @@ void elfFileWidget::updateElfFile(ElfFil this->ui->VersionLabel->setText(QString::number(p_elf->getVersion())); this->ui->machineLabel->setText(p_elf->getArchitecture()); this->ui->endiannesLabel->setText(p_elf->getEndianness()); + this->ui->abiLabel->setText(p_elf->getABI()); + this->ui->entryPointLabel->setText("0x"+QString::number(p_elf->getEntryPointAddress(),16,8)); + this->ui->sectionCountLabel->setText(QString::number(p_elf->getSectioncount())); } } + + + + + + + + + + + + + + + diff --git a/src/common/elf/elfparser.cpp b/src/common/elf/elfparser.cpp --- a/src/common/elf/elfparser.cpp +++ b/src/common/elf/elfparser.cpp @@ -395,6 +395,30 @@ QString elfparser::getEndianness() return "none"; } +QString elfparser::getABI() +{ + if(this->e!=NULL) + { + if(this->ehdr.e_ident[EI_OSABI]==ELFOSABI_NONE)return "UNIX System V ABI"; + if(this->ehdr.e_ident[EI_OSABI]==ELFOSABI_SYSV)return "Alias"; + if(this->ehdr.e_ident[EI_OSABI]==ELFOSABI_HPUX)return "HP-UX"; + if(this->ehdr.e_ident[EI_OSABI]==ELFOSABI_NETBSD)return "NetBSD"; + if(this->ehdr.e_ident[EI_OSABI]==ELFOSABI_GNU)return "Object uses GNU ELF extensions"; + if(this->ehdr.e_ident[EI_OSABI]==ELFOSABI_LINUX)return "Compatibility alias"; + if(this->ehdr.e_ident[EI_OSABI]==ELFOSABI_SOLARIS)return "Sun Solaris"; + if(this->ehdr.e_ident[EI_OSABI]==ELFOSABI_AIX)return "IBM AIX"; + if(this->ehdr.e_ident[EI_OSABI]==ELFOSABI_IRIX)return "SGI Irix"; + if(this->ehdr.e_ident[EI_OSABI]==ELFOSABI_FREEBSD)return "FreeBSD"; + if(this->ehdr.e_ident[EI_OSABI]==ELFOSABI_TRU64)return "Compaq TRU64 UNIX"; + if(this->ehdr.e_ident[EI_OSABI]==ELFOSABI_MODESTO)return " Novell Modesto"; + if(this->ehdr.e_ident[EI_OSABI]==ELFOSABI_OPENBSD)return "OpenBSD"; + if(this->ehdr.e_ident[EI_OSABI]==ELFOSABI_ARM_AEABI)return "ARM EABI"; + if(this->ehdr.e_ident[EI_OSABI]==ELFOSABI_ARM)return "ARM"; + if(this->ehdr.e_ident[EI_OSABI]==ELFOSABI_STANDALONE)return "Standalone (embedded) application"; + } + return "none"; +} + int32_t elfparser::getVersion() { @@ -404,6 +428,14 @@ int32_t elfparser::getVersion() } } +int64_t elfparser::getEntryPointAddress() +{ + if(this->e!=NULL) + { + return this->ehdr.e_entry; + } +} + int elfparser::getSectioncount() { diff --git a/src/common/elf/elfparser.h b/src/common/elf/elfparser.h --- a/src/common/elf/elfparser.h +++ b/src/common/elf/elfparser.h @@ -53,7 +53,9 @@ public: QString getArchitecture(); QString getType(); QString getEndianness(); + QString getABI(); int32_t getVersion(); + int64_t getEntryPointAddress(); int getSectioncount(); int getSegmentcount(); QString getSegmentType(int index); diff --git a/src/common/pythonQtOut/generated_cpp/PySocExplorer/PySocExplorer0.cpp b/src/common/pythonQtOut/generated_cpp/PySocExplorer/PySocExplorer0.cpp --- a/src/common/pythonQtOut/generated_cpp/PySocExplorer/PySocExplorer0.cpp +++ b/src/common/pythonQtOut/generated_cpp/PySocExplorer/PySocExplorer0.cpp @@ -3,6 +3,32 @@ #include #include #include +#include + +ElfFile* PythonQtWrapper_ElfFile::new_ElfFile(QObject* parent) +{ +return new ElfFile(parent); } + +ElfFile* PythonQtWrapper_ElfFile::new_ElfFile(const QString& File, QObject* parent) +{ +return new ElfFile(File, parent); } + +int PythonQtWrapper_ElfFile::closeFile(ElfFile* theWrappedObject) +{ + return ( theWrappedObject->closeFile()); +} + +bool PythonQtWrapper_ElfFile::isopened(ElfFile* theWrappedObject) +{ + return ( theWrappedObject->isopened()); +} + +bool PythonQtWrapper_ElfFile::openFile(ElfFile* theWrappedObject, const QString& File) +{ + return ( theWrappedObject->openFile(File)); +} + + MemSizeWdgt* PythonQtWrapper_MemSizeWdgt::new_MemSizeWdgt(QWidget* parent) { @@ -447,6 +473,12 @@ QString PythonQtWrapper_XByteArray::toR +elfFileWidget* PythonQtWrapper_elfFileWidget::new_elfFileWidget(QWidget* parent) +{ +return new elfFileWidget(parent); } + + + elfparser* PythonQtWrapper_elfparser::new_elfparser() { return new elfparser(); } @@ -456,11 +488,26 @@ int PythonQtWrapper_elfparser::closeFil return ( theWrappedObject->closeFile()); } +QString PythonQtWrapper_elfparser::getABI(elfparser* theWrappedObject) +{ + return ( theWrappedObject->getABI()); +} + QString PythonQtWrapper_elfparser::getArchitecture(elfparser* theWrappedObject) { return ( theWrappedObject->getArchitecture()); } +QString PythonQtWrapper_elfparser::getClass(elfparser* theWrappedObject) +{ + return ( theWrappedObject->getClass()); +} + +QString PythonQtWrapper_elfparser::getEndianness(elfparser* theWrappedObject) +{ + return ( theWrappedObject->getEndianness()); +} + bool PythonQtWrapper_elfparser::getSectionData(elfparser* theWrappedObject, int index, char** buffer) { return ( theWrappedObject->getSectionData(index, buffer)); diff --git a/src/common/pythonQtOut/generated_cpp/PySocExplorer/PySocExplorer0.h b/src/common/pythonQtOut/generated_cpp/PySocExplorer/PySocExplorer0.h --- a/src/common/pythonQtOut/generated_cpp/PySocExplorer/PySocExplorer0.h +++ b/src/common/pythonQtOut/generated_cpp/PySocExplorer/PySocExplorer0.h @@ -2,6 +2,8 @@ #include #include #include +#include +#include #include #include #include @@ -11,6 +13,22 @@ +class PythonQtWrapper_ElfFile : public QObject +{ Q_OBJECT +public: +public slots: +ElfFile* new_ElfFile(QObject* parent = 0); +ElfFile* new_ElfFile(const QString& File, QObject* parent = 0); +void delete_ElfFile(ElfFile* obj) { delete obj; } + int closeFile(ElfFile* theWrappedObject); + bool isopened(ElfFile* theWrappedObject); + bool openFile(ElfFile* theWrappedObject, const QString& File); +}; + + + + + class PythonQtWrapper_MemSizeWdgt : public QObject { Q_OBJECT public: @@ -185,6 +203,18 @@ void delete_XByteArray(XByteArray* obj) +class PythonQtWrapper_elfFileWidget : public QObject +{ Q_OBJECT +public: +public slots: +elfFileWidget* new_elfFileWidget(QWidget* parent = 0); +void delete_elfFileWidget(elfFileWidget* obj) { delete obj; } +}; + + + + + class PythonQtWrapper_elfparser : public QObject { Q_OBJECT public: @@ -192,7 +222,10 @@ public slots: elfparser* new_elfparser(); void delete_elfparser(elfparser* obj) { delete obj; } int closeFile(elfparser* theWrappedObject); + QString getABI(elfparser* theWrappedObject); QString getArchitecture(elfparser* theWrappedObject); + QString getClass(elfparser* theWrappedObject); + QString getEndianness(elfparser* theWrappedObject); bool getSectionData(elfparser* theWrappedObject, int index, char** buffer); QString getSectionName(elfparser* theWrappedObject, int index); QString getSectionType(elfparser* theWrappedObject, int index); diff --git a/src/common/pythonQtOut/generated_cpp/PySocExplorer/PySocExplorer_init.cpp b/src/common/pythonQtOut/generated_cpp/PySocExplorer/PySocExplorer_init.cpp --- a/src/common/pythonQtOut/generated_cpp/PySocExplorer/PySocExplorer_init.cpp +++ b/src/common/pythonQtOut/generated_cpp/PySocExplorer/PySocExplorer_init.cpp @@ -3,12 +3,14 @@ void PythonQt_init_PySocExplorer(PyObject* module) { +PythonQt::priv()->registerClass(&ElfFile::staticMetaObject, "PySocExplorer", PythonQtCreateObject, NULL, module, 0); PythonQt::priv()->registerCPPClass("MemSizeWdgt", "", "PySocExplorer", PythonQtCreateObject, NULL, module, 0); PythonQt::priv()->registerCPPClass("QHexEdit", "", "PySocExplorer", PythonQtCreateObject, PythonQtSetInstanceWrapperOnShell, module, 0); PythonQt::priv()->registerCPPClass("QHexSpinBox", "", "PySocExplorer", PythonQtCreateObject, NULL, module, 0); PythonQt::priv()->registerCPPClass("SocExplorerPlot", "", "PySocExplorer", PythonQtCreateObject, PythonQtSetInstanceWrapperOnShell, module, 0); PythonQt::priv()->registerClass(&TCP_Terminal_Client::staticMetaObject, "PySocExplorer", PythonQtCreateObject, NULL, module, 0); PythonQt::priv()->registerCPPClass("XByteArray", "", "PySocExplorer", PythonQtCreateObject, NULL, module, 0); +PythonQt::priv()->registerCPPClass("elfFileWidget", "", "PySocExplorer", PythonQtCreateObject, NULL, module, 0); PythonQt::priv()->registerCPPClass("elfparser", "", "PySocExplorer", PythonQtCreateObject, NULL, module, 0); } diff --git a/src/common/pythonQtgeneratorCfg.txt b/src/common/pythonQtgeneratorCfg.txt --- a/src/common/pythonQtgeneratorCfg.txt +++ b/src/common/pythonQtgeneratorCfg.txt @@ -1,6 +1,6 @@ - - + + @@ -10,6 +10,7 @@ + @@ -17,7 +18,10 @@ - + + + + diff --git a/src/common/pythongenerator.sh b/src/common/pythongenerator.sh --- a/src/common/pythongenerator.sh +++ b/src/common/pythongenerator.sh @@ -3,4 +3,4 @@ #export QTDIR=/usr/include export QTDIR=/usr/include/qt5 -pythonqt_generator --output-directory=pythonQtOut PySocExplorer.h pythonQtgeneratorCfg.txt +pythonqt_generator --dump-object-tree --output-directory=pythonQtOut PySocExplorer.h pythonQtgeneratorCfg.txt