##// END OF EJS Templates
ElfFile classes WIP.
jeandet -
r37:b04e90691097 default
parent child
Show More
@@ -1,6 +1,11
1 #include <QObject>
2 #include <QWidget>
1 #include "qhexspinbox.h"
3 #include "qhexspinbox.h"
2 #include "memsizewdgt.h"
4 #include "memsizewdgt.h"
3 #include "qhexedit/qhexedit.h"
5 #include "qhexedit/qhexedit.h"
4 #include "SocExplorerPlot.h"
6 #include "SocExplorerPlot.h"
5 #include "tcp_terminal_client.h"
7 #include "tcp_terminal_client.h"
6 #include "elf/elfparser.h"
8 #include "elf/elfparser.h"
9 #include "elf/abstractexecfile.h"
10 #include "elf/elffile.h"
11 #include "elf/elffilewidget.h"
@@ -21,12 +21,11
21 ----------------------------------------------------------------------------*/
21 ----------------------------------------------------------------------------*/
22 #include "abstractexecfile.h"
22 #include "abstractexecfile.h"
23
23
24 abstractExecFile::abstractExecFile(QObject *parent) :
24 abstractExecFile::abstractExecFile()
25 QObject(parent)
26 {
25 {
27 }
26 }
28
27
29 abstractExecFile::abstractExecFile(const QString &File, QObject *parent)
28 abstractExecFile::abstractExecFile(const QString &File)
30 {
29 {
31
30
32 }
31 }
@@ -33,19 +33,15 public:
33 quint32 address;
33 quint32 address;
34 };
34 };
35
35
36 class abstractExecFile : public QObject
36 class abstractExecFile
37 {
37 {
38 Q_OBJECT
39 public:
38 public:
40 abstractExecFile(QObject *parent = 0);
39 abstractExecFile();
41 abstractExecFile(const QString& File,QObject *parent = 0);
40 abstractExecFile(const QString& File);
42 virtual bool openFile(const QString& File)=0;
41 virtual bool openFile(const QString& File)=0;
43 virtual bool isopened()=0;
42 virtual bool isopened()=0;
44 virtual int closeFile()=0;
43 virtual int closeFile()=0;
45 virtual QList<codeFragment> getFragments()=0;
44 virtual QList<codeFragment> getFragments()=0;
46 signals:
47
48 public slots:
49
45
50 protected:
46 protected:
51 QString p_fileName;
47 QString p_fileName;
@@ -38,6 +38,7 header.files = \
38 elf/elfinfowdgt.h \
38 elf/elfinfowdgt.h \
39 elf/elfparser.h \
39 elf/elfparser.h \
40 elf/elffile.h \
40 elf/elffile.h \
41 elf/elffilewidget.h \
41 qipdialogbox.h \
42 qipdialogbox.h \
42 lppserial/src/RS232.h
43 lppserial/src/RS232.h
43
44
@@ -23,13 +23,13
23 ----------------------------------------------------------------------------*/
23 ----------------------------------------------------------------------------*/
24 #include "elffile.h"
24 #include "elffile.h"
25
25
26 ElfFile::ElfFile(QObject *parent) :
26 ElfFile::ElfFile(QObject *parent)
27 abstractExecFile(parent)
27 :QObject(parent),abstractExecFile(),elfparser()
28 {
28 {
29 }
29 }
30
30
31 ElfFile::ElfFile(const QString &File, QObject *parent)
31 ElfFile::ElfFile(const QString &File, QObject *parent)
32 :abstractExecFile(parent),elfparser()
32 :QObject(parent),abstractExecFile(),elfparser()
33 {
33 {
34 this->p_fileName = File;
34 this->p_fileName = File;
35 setFilename(File);
35 setFilename(File);
@@ -27,7 +27,7
27 #ifndef ELFFILE_H
27 #ifndef ELFFILE_H
28 #define ELFFILE_H
28 #define ELFFILE_H
29
29
30 class ElfFile : public abstractExecFile, public elfparser
30 class ElfFile :public QObject, public abstractExecFile, public elfparser
31 {
31 {
32 Q_OBJECT
32 Q_OBJECT
33 public:
33 public:
@@ -22,5 +22,23 void elfFileWidget::updateElfFile(ElfFil
22 this->ui->VersionLabel->setText(QString::number(p_elf->getVersion()));
22 this->ui->VersionLabel->setText(QString::number(p_elf->getVersion()));
23 this->ui->machineLabel->setText(p_elf->getArchitecture());
23 this->ui->machineLabel->setText(p_elf->getArchitecture());
24 this->ui->endiannesLabel->setText(p_elf->getEndianness());
24 this->ui->endiannesLabel->setText(p_elf->getEndianness());
25 this->ui->abiLabel->setText(p_elf->getABI());
26 this->ui->entryPointLabel->setText("0x"+QString::number(p_elf->getEntryPointAddress(),16,8));
27 this->ui->sectionCountLabel->setText(QString::number(p_elf->getSectioncount()));
25 }
28 }
26 }
29 }
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
@@ -395,6 +395,30 QString elfparser::getEndianness()
395 return "none";
395 return "none";
396 }
396 }
397
397
398 QString elfparser::getABI()
399 {
400 if(this->e!=NULL)
401 {
402 if(this->ehdr.e_ident[EI_OSABI]==ELFOSABI_NONE)return "UNIX System V ABI";
403 if(this->ehdr.e_ident[EI_OSABI]==ELFOSABI_SYSV)return "Alias";
404 if(this->ehdr.e_ident[EI_OSABI]==ELFOSABI_HPUX)return "HP-UX";
405 if(this->ehdr.e_ident[EI_OSABI]==ELFOSABI_NETBSD)return "NetBSD";
406 if(this->ehdr.e_ident[EI_OSABI]==ELFOSABI_GNU)return "Object uses GNU ELF extensions";
407 if(this->ehdr.e_ident[EI_OSABI]==ELFOSABI_LINUX)return "Compatibility alias";
408 if(this->ehdr.e_ident[EI_OSABI]==ELFOSABI_SOLARIS)return "Sun Solaris";
409 if(this->ehdr.e_ident[EI_OSABI]==ELFOSABI_AIX)return "IBM AIX";
410 if(this->ehdr.e_ident[EI_OSABI]==ELFOSABI_IRIX)return "SGI Irix";
411 if(this->ehdr.e_ident[EI_OSABI]==ELFOSABI_FREEBSD)return "FreeBSD";
412 if(this->ehdr.e_ident[EI_OSABI]==ELFOSABI_TRU64)return "Compaq TRU64 UNIX";
413 if(this->ehdr.e_ident[EI_OSABI]==ELFOSABI_MODESTO)return " Novell Modesto";
414 if(this->ehdr.e_ident[EI_OSABI]==ELFOSABI_OPENBSD)return "OpenBSD";
415 if(this->ehdr.e_ident[EI_OSABI]==ELFOSABI_ARM_AEABI)return "ARM EABI";
416 if(this->ehdr.e_ident[EI_OSABI]==ELFOSABI_ARM)return "ARM";
417 if(this->ehdr.e_ident[EI_OSABI]==ELFOSABI_STANDALONE)return "Standalone (embedded) application";
418 }
419 return "none";
420 }
421
398
422
399 int32_t elfparser::getVersion()
423 int32_t elfparser::getVersion()
400 {
424 {
@@ -404,6 +428,14 int32_t elfparser::getVersion()
404 }
428 }
405 }
429 }
406
430
431 int64_t elfparser::getEntryPointAddress()
432 {
433 if(this->e!=NULL)
434 {
435 return this->ehdr.e_entry;
436 }
437 }
438
407
439
408 int elfparser::getSectioncount()
440 int elfparser::getSectioncount()
409 {
441 {
@@ -53,7 +53,9 public:
53 QString getArchitecture();
53 QString getArchitecture();
54 QString getType();
54 QString getType();
55 QString getEndianness();
55 QString getEndianness();
56 QString getABI();
56 int32_t getVersion();
57 int32_t getVersion();
58 int64_t getEntryPointAddress();
57 int getSectioncount();
59 int getSectioncount();
58 int getSegmentcount();
60 int getSegmentcount();
59 QString getSegmentType(int index);
61 QString getSegmentType(int index);
@@ -3,6 +3,32
3 #include <PythonQtMethodInfo.h>
3 #include <PythonQtMethodInfo.h>
4 #include <PythonQtSignalReceiver.h>
4 #include <PythonQtSignalReceiver.h>
5 #include <QVariant>
5 #include <QVariant>
6 #include <elffile.h>
7
8 ElfFile* PythonQtWrapper_ElfFile::new_ElfFile(QObject* parent)
9 {
10 return new ElfFile(parent); }
11
12 ElfFile* PythonQtWrapper_ElfFile::new_ElfFile(const QString& File, QObject* parent)
13 {
14 return new ElfFile(File, parent); }
15
16 int PythonQtWrapper_ElfFile::closeFile(ElfFile* theWrappedObject)
17 {
18 return ( theWrappedObject->closeFile());
19 }
20
21 bool PythonQtWrapper_ElfFile::isopened(ElfFile* theWrappedObject)
22 {
23 return ( theWrappedObject->isopened());
24 }
25
26 bool PythonQtWrapper_ElfFile::openFile(ElfFile* theWrappedObject, const QString& File)
27 {
28 return ( theWrappedObject->openFile(File));
29 }
30
31
6
32
7 MemSizeWdgt* PythonQtWrapper_MemSizeWdgt::new_MemSizeWdgt(QWidget* parent)
33 MemSizeWdgt* PythonQtWrapper_MemSizeWdgt::new_MemSizeWdgt(QWidget* parent)
8 {
34 {
@@ -447,6 +473,12 QString PythonQtWrapper_XByteArray::toR
447
473
448
474
449
475
476 elfFileWidget* PythonQtWrapper_elfFileWidget::new_elfFileWidget(QWidget* parent)
477 {
478 return new elfFileWidget(parent); }
479
480
481
450 elfparser* PythonQtWrapper_elfparser::new_elfparser()
482 elfparser* PythonQtWrapper_elfparser::new_elfparser()
451 {
483 {
452 return new elfparser(); }
484 return new elfparser(); }
@@ -456,11 +488,26 int PythonQtWrapper_elfparser::closeFil
456 return ( theWrappedObject->closeFile());
488 return ( theWrappedObject->closeFile());
457 }
489 }
458
490
491 QString PythonQtWrapper_elfparser::getABI(elfparser* theWrappedObject)
492 {
493 return ( theWrappedObject->getABI());
494 }
495
459 QString PythonQtWrapper_elfparser::getArchitecture(elfparser* theWrappedObject)
496 QString PythonQtWrapper_elfparser::getArchitecture(elfparser* theWrappedObject)
460 {
497 {
461 return ( theWrappedObject->getArchitecture());
498 return ( theWrappedObject->getArchitecture());
462 }
499 }
463
500
501 QString PythonQtWrapper_elfparser::getClass(elfparser* theWrappedObject)
502 {
503 return ( theWrappedObject->getClass());
504 }
505
506 QString PythonQtWrapper_elfparser::getEndianness(elfparser* theWrappedObject)
507 {
508 return ( theWrappedObject->getEndianness());
509 }
510
464 bool PythonQtWrapper_elfparser::getSectionData(elfparser* theWrappedObject, int index, char** buffer)
511 bool PythonQtWrapper_elfparser::getSectionData(elfparser* theWrappedObject, int index, char** buffer)
465 {
512 {
466 return ( theWrappedObject->getSectionData(index, buffer));
513 return ( theWrappedObject->getSectionData(index, buffer));
@@ -2,6 +2,8
2 #include <QObject>
2 #include <QObject>
3 #include <QVariant>
3 #include <QVariant>
4 #include <SocExplorerPlot.h>
4 #include <SocExplorerPlot.h>
5 #include <elffile.h>
6 #include <elffilewidget.h>
5 #include <elfparser.h>
7 #include <elfparser.h>
6 #include <memsizewdgt.h>
8 #include <memsizewdgt.h>
7 #include <qhexedit.h>
9 #include <qhexedit.h>
@@ -11,6 +13,22
11
13
12
14
13
15
16 class PythonQtWrapper_ElfFile : public QObject
17 { Q_OBJECT
18 public:
19 public slots:
20 ElfFile* new_ElfFile(QObject* parent = 0);
21 ElfFile* new_ElfFile(const QString& File, QObject* parent = 0);
22 void delete_ElfFile(ElfFile* obj) { delete obj; }
23 int closeFile(ElfFile* theWrappedObject);
24 bool isopened(ElfFile* theWrappedObject);
25 bool openFile(ElfFile* theWrappedObject, const QString& File);
26 };
27
28
29
30
31
14 class PythonQtWrapper_MemSizeWdgt : public QObject
32 class PythonQtWrapper_MemSizeWdgt : public QObject
15 { Q_OBJECT
33 { Q_OBJECT
16 public:
34 public:
@@ -185,6 +203,18 void delete_XByteArray(XByteArray* obj)
185
203
186
204
187
205
206 class PythonQtWrapper_elfFileWidget : public QObject
207 { Q_OBJECT
208 public:
209 public slots:
210 elfFileWidget* new_elfFileWidget(QWidget* parent = 0);
211 void delete_elfFileWidget(elfFileWidget* obj) { delete obj; }
212 };
213
214
215
216
217
188 class PythonQtWrapper_elfparser : public QObject
218 class PythonQtWrapper_elfparser : public QObject
189 { Q_OBJECT
219 { Q_OBJECT
190 public:
220 public:
@@ -192,7 +222,10 public slots:
192 elfparser* new_elfparser();
222 elfparser* new_elfparser();
193 void delete_elfparser(elfparser* obj) { delete obj; }
223 void delete_elfparser(elfparser* obj) { delete obj; }
194 int closeFile(elfparser* theWrappedObject);
224 int closeFile(elfparser* theWrappedObject);
225 QString getABI(elfparser* theWrappedObject);
195 QString getArchitecture(elfparser* theWrappedObject);
226 QString getArchitecture(elfparser* theWrappedObject);
227 QString getClass(elfparser* theWrappedObject);
228 QString getEndianness(elfparser* theWrappedObject);
196 bool getSectionData(elfparser* theWrappedObject, int index, char** buffer);
229 bool getSectionData(elfparser* theWrappedObject, int index, char** buffer);
197 QString getSectionName(elfparser* theWrappedObject, int index);
230 QString getSectionName(elfparser* theWrappedObject, int index);
198 QString getSectionType(elfparser* theWrappedObject, int index);
231 QString getSectionType(elfparser* theWrappedObject, int index);
@@ -3,12 +3,14
3
3
4
4
5 void PythonQt_init_PySocExplorer(PyObject* module) {
5 void PythonQt_init_PySocExplorer(PyObject* module) {
6 PythonQt::priv()->registerClass(&ElfFile::staticMetaObject, "PySocExplorer", PythonQtCreateObject<PythonQtWrapper_ElfFile>, NULL, module, 0);
6 PythonQt::priv()->registerCPPClass("MemSizeWdgt", "", "PySocExplorer", PythonQtCreateObject<PythonQtWrapper_MemSizeWdgt>, NULL, module, 0);
7 PythonQt::priv()->registerCPPClass("MemSizeWdgt", "", "PySocExplorer", PythonQtCreateObject<PythonQtWrapper_MemSizeWdgt>, NULL, module, 0);
7 PythonQt::priv()->registerCPPClass("QHexEdit", "", "PySocExplorer", PythonQtCreateObject<PythonQtWrapper_QHexEdit>, PythonQtSetInstanceWrapperOnShell<PythonQtShell_QHexEdit>, module, 0);
8 PythonQt::priv()->registerCPPClass("QHexEdit", "", "PySocExplorer", PythonQtCreateObject<PythonQtWrapper_QHexEdit>, PythonQtSetInstanceWrapperOnShell<PythonQtShell_QHexEdit>, module, 0);
8 PythonQt::priv()->registerCPPClass("QHexSpinBox", "", "PySocExplorer", PythonQtCreateObject<PythonQtWrapper_QHexSpinBox>, NULL, module, 0);
9 PythonQt::priv()->registerCPPClass("QHexSpinBox", "", "PySocExplorer", PythonQtCreateObject<PythonQtWrapper_QHexSpinBox>, NULL, module, 0);
9 PythonQt::priv()->registerCPPClass("SocExplorerPlot", "", "PySocExplorer", PythonQtCreateObject<PythonQtWrapper_SocExplorerPlot>, PythonQtSetInstanceWrapperOnShell<PythonQtShell_SocExplorerPlot>, module, 0);
10 PythonQt::priv()->registerCPPClass("SocExplorerPlot", "", "PySocExplorer", PythonQtCreateObject<PythonQtWrapper_SocExplorerPlot>, PythonQtSetInstanceWrapperOnShell<PythonQtShell_SocExplorerPlot>, module, 0);
10 PythonQt::priv()->registerClass(&TCP_Terminal_Client::staticMetaObject, "PySocExplorer", PythonQtCreateObject<PythonQtWrapper_TCP_Terminal_Client>, NULL, module, 0);
11 PythonQt::priv()->registerClass(&TCP_Terminal_Client::staticMetaObject, "PySocExplorer", PythonQtCreateObject<PythonQtWrapper_TCP_Terminal_Client>, NULL, module, 0);
11 PythonQt::priv()->registerCPPClass("XByteArray", "", "PySocExplorer", PythonQtCreateObject<PythonQtWrapper_XByteArray>, NULL, module, 0);
12 PythonQt::priv()->registerCPPClass("XByteArray", "", "PySocExplorer", PythonQtCreateObject<PythonQtWrapper_XByteArray>, NULL, module, 0);
13 PythonQt::priv()->registerCPPClass("elfFileWidget", "", "PySocExplorer", PythonQtCreateObject<PythonQtWrapper_elfFileWidget>, NULL, module, 0);
12 PythonQt::priv()->registerCPPClass("elfparser", "", "PySocExplorer", PythonQtCreateObject<PythonQtWrapper_elfparser>, NULL, module, 0);
14 PythonQt::priv()->registerCPPClass("elfparser", "", "PySocExplorer", PythonQtCreateObject<PythonQtWrapper_elfparser>, NULL, module, 0);
13
15
14 }
16 }
@@ -1,6 +1,6
1 <typesystem package="PySocExplorer" default-superclass="com.trolltech.qt.QtJambiObject">
1 <typesystem package="PySocExplorer" default-superclass="com.trolltech.qt.QtJambiObject">
2 <load-typesystem name=":/trolltech/generator/typesystem_core.txt" generate="no" />
2 <load-typesystem name=":/trolltech/generator/typesystem_core.txt" generate="yes" />
3 <load-typesystem name=":/trolltech/generator/typesystem_gui.txt" generate="no" />
3 <load-typesystem name=":/trolltech/generator/typesystem_gui.txt" generate="yes" />
4 <load-typesystem name=":/trolltech/generator/typesystem_sql.txt" generate="no" />
4 <load-typesystem name=":/trolltech/generator/typesystem_sql.txt" generate="no" />
5 <load-typesystem name=":/trolltech/generator/typesystem_opengl.txt" generate="no" />
5 <load-typesystem name=":/trolltech/generator/typesystem_opengl.txt" generate="no" />
6 <load-typesystem name=":/trolltech/generator/typesystem_svg.txt" generate="no" />
6 <load-typesystem name=":/trolltech/generator/typesystem_svg.txt" generate="no" />
@@ -10,6 +10,7
10 <load-typesystem name=":/trolltech/generator/typesystem_webkit.txt" generate="no" />
10 <load-typesystem name=":/trolltech/generator/typesystem_webkit.txt" generate="no" />
11 <load-typesystem name=":/trolltech/generator/typesystem_phonon.txt" generate="no" />
11 <load-typesystem name=":/trolltech/generator/typesystem_phonon.txt" generate="no" />
12
12
13 <rejection class="abstractExecFile" />
13
14
14 <object-type name="QHexSpinBox" />
15 <object-type name="QHexSpinBox" />
15 <object-type name="MemSizeWdgt" />
16 <object-type name="MemSizeWdgt" />
@@ -18,6 +19,9
18 <object-type name="SocExplorerPlot" />
19 <object-type name="SocExplorerPlot" />
19 <object-type name="TCP_Terminal_Client" />
20 <object-type name="TCP_Terminal_Client" />
20 <object-type name="elfparser" />
21 <object-type name="elfparser" />
22 <object-type name="abstractExecFile" />
23 <object-type name="ElfFile" />
24 <object-type name="elfFileWidget" />
21
25
22 </typesystem>
26 </typesystem>
23
27
@@ -3,4 +3,4
3 #export QTDIR=/usr/include
3 #export QTDIR=/usr/include
4 export QTDIR=/usr/include/qt5
4 export QTDIR=/usr/include/qt5
5
5
6 pythonqt_generator --output-directory=pythonQtOut PySocExplorer.h pythonQtgeneratorCfg.txt
6 pythonqt_generator --dump-object-tree --output-directory=pythonQtOut PySocExplorer.h pythonQtgeneratorCfg.txt
General Comments 0
You need to be logged in to leave comments. Login now