# HG changeset patch # User Alexis Jeandet # Date 2015-04-16 18:02:45 # Node ID dbbb04783771ee2d825758186a8876b5a6870ce8 # Parent e7cdc214d72a5c133cb9f99272d5ed7e1c8f985f dsu3plugin: -Replaced old ElfParser with new generic class. -Added symbol dump method. diff --git a/dsu3plugin/dsu3plugin.cpp b/dsu3plugin/dsu3plugin.cpp --- a/dsu3plugin/dsu3plugin.cpp +++ b/dsu3plugin/dsu3plugin.cpp @@ -46,20 +46,11 @@ dsu3plugin::dsu3plugin(QWidget *parent): { this->UI = new dsu3pluginui(); this->setWidget((QWidget*)this->UI); - this->elfparserInst = new elfparser(); -// this->pyObject = new dsu3pluginPywrapper(this); -// QObject::connect(((dsu3pluginPywrapper*)this->pyObject),SIGNAL(openFile(QString)),this,SLOT(openFile(QString))); -// QObject::connect(((dsu3pluginPywrapper*)this->pyObject),SIGNAL(loadFile()),this,SLOT(flashTarget())); -// QObject::connect(((dsu3pluginPywrapper*)this->pyObject),SIGNAL(run()),this,SLOT(run())); -// QObject::connect(((dsu3pluginPywrapper*)this->pyObject),SIGNAL(stop()),this,SLOT(stop())); -// QObject::connect(((dsu3pluginPywrapper*)this->pyObject),SIGNAL(cacheEnable()),this,SLOT(cacheEnable())); -// QObject::connect(((dsu3pluginPywrapper*)this->pyObject),SIGNAL(cacheDisable()),this,SLOT(cacheDisable())); -// QObject::connect(((dsu3pluginPywrapper*)this->pyObject),SIGNAL(setCacheEnable(bool)),this,SLOT(setCacheEnable(bool))); - + this->elfFile = new ElfFile(); connect(this->UI,SIGNAL(openFile()),this,SLOT(openFile())); connect(this->UI,SIGNAL(flashTarget()),this,SLOT(flashTarget())); connect(this->UI,SIGNAL(run()),this,SLOT(toggleRun())); - connect(this,SIGNAL(updateInfo(elfparser*)),this->UI,SIGNAL(updateInfo(elfparser*))); + connect(this,SIGNAL(updateInfo(ElfFile*)),this->UI,SLOT(updateInfo(ElfFile*))); this->running = false; } @@ -81,8 +72,8 @@ void dsu3plugin::openFile() void dsu3plugin::openFile(QString fileName) { - this->elfparserInst->setFilename(fileName); - emit this->updateInfo(this->elfparserInst); + this->elfFile->openFile(fileName); + emit this->updateInfo(this->elfFile); } bool dsu3plugin::configureTarget() @@ -242,6 +233,17 @@ void dsu3plugin::toggleRun() this->run(); } +bool dsu3plugin::dumpSymbol(const QString &symbolName, QString file, const QString &format) +{ + if(this->elfFile->isopened()) + { + int symbolIndex=this->elfFile->getSymbolIndex(symbolName); + if(symbolIndex!=-1) + return this->dumpMemory(this->elfFile->getSymbolAddress(symbolIndex),this->elfFile->getSymbolSize(symbolIndex)/4,file,format); + } + return false; +} + void dsu3plugin::WriteRegs(uIntlist Values, unsigned int address) { unsigned int* buff; @@ -265,11 +267,11 @@ void dsu3plugin::writeSection(int index) { char* buffch=NULL; unsigned int* buff; - int size = this->elfparserInst->getSectionDatasz(index); + int size = this->elfFile->getSectionDatasz(index); int sizeInt = size/4; if(parent==NULL) return; - this->elfparserInst->getSectionData(index,&buffch); + this->elfFile->getSectionData(index,&buffch); buff = (unsigned int*)malloc(((size/4)+1)*sizeof(unsigned int)); for(int i=0;iWrite(buff,(unsigned int)sizeInt,(unsigned int)this->elfparserInst->getSectionPaddr(index)); + parent->Write(buff,(unsigned int)sizeInt,(unsigned int)this->elfFile->getSectionPaddr(index)); free(buff); } void dsu3plugin::writeSection(const QString &name) { - for(int i=0;ielfparserInst->getSectioncount();i++) + if(elfFile->isopened()) { - if(!this->elfparserInst->getSectionName(i).compare(name)) - { - printf("about to write section %s @ 0x%x size = %d\n",elfparserInst->getSectionName(i).toStdString().c_str(),elfparserInst->getSectionPaddr(i),elfparserInst->getSectionMemsz(i)); - writeSection(i); - } + writeSection(this->elfFile->getSectionIndex(name)); } } diff --git a/dsu3plugin/dsu3plugin.h b/dsu3plugin/dsu3plugin.h --- a/dsu3plugin/dsu3plugin.h +++ b/dsu3plugin/dsu3plugin.h @@ -28,6 +28,7 @@ #include #include #include "elfparser.h" +#include #include #include @@ -55,15 +56,17 @@ public slots: void toggleRun(); //added for python backward compatibility void loadFile(){this->flashTarget();} + bool dumpSymbol(const QString& symbolName,QString file,const QString& format); + signals: - void updateInfo(elfparser* parser); + void updateInfo(ElfFile* elfFile); private: void WriteRegs(uIntlist Values, unsigned int address); unsigned int ReadReg(unsigned int address); void writeSection(int index); void writeSection(const QString& name); dsu3pluginui* UI; - elfparser* elfparserInst; + ElfFile* elfFile; bool running; }; diff --git a/dsu3plugin/dsu3pluginui.cpp b/dsu3plugin/dsu3pluginui.cpp --- a/dsu3plugin/dsu3pluginui.cpp +++ b/dsu3plugin/dsu3pluginui.cpp @@ -29,16 +29,15 @@ dsu3pluginui::dsu3pluginui(QWidget *pare this->flashTargetQpb = new QPushButton(tr("Flash Target")); this->runQpb = new QPushButton(tr("Run")); this->mainLayout = new QGridLayout(); - this->elfInfoWdgtInst = new elfInfoWdgt; + this->elfFileWidgetInst = new elfFileWidget(); this->mainLayout->addWidget(this->openFileQpb,0,0,1,1); this->mainLayout->addWidget(this->flashTargetQpb,0,1,1,1); this->mainLayout->addWidget(this->runQpb,0,2,1,1); - this->mainLayout->addWidget(this->elfInfoWdgtInst,1,0,1,-1); + this->mainLayout->addWidget(this->elfFileWidgetInst,1,0,1,-1); this->setLayout(this->mainLayout); connect(this->openFileQpb,SIGNAL(clicked()),this,SIGNAL(openFile())); connect(this->flashTargetQpb,SIGNAL(clicked()),this,SIGNAL(flashTarget())); connect(this->runQpb,SIGNAL(clicked()),this,SIGNAL(run())); - connect(this,SIGNAL(updateInfo(elfparser*)),this->elfInfoWdgtInst,SLOT(updateInfo(elfparser*))); } @@ -50,6 +49,11 @@ void dsu3pluginui::setRunning(bool runni this->runQpb->setText("Run"); } +void dsu3pluginui::updateInfo(ElfFile *file) +{ + this->elfFileWidgetInst->setFile(file); +} + diff --git a/dsu3plugin/dsu3pluginui.h b/dsu3plugin/dsu3pluginui.h --- a/dsu3plugin/dsu3pluginui.h +++ b/dsu3plugin/dsu3pluginui.h @@ -30,6 +30,8 @@ #include #include #include "elfinfowdgt.h" +#include +#include class dsu3pluginui : public QWidget { @@ -39,9 +41,9 @@ public: public slots: void setRunning(bool running); + void updateInfo(ElfFile* file); signals: void openFile(); - void updateInfo(elfparser* parser); bool flashTarget(); void run(); private: @@ -49,7 +51,7 @@ private: QPushButton* openFileQpb; QPushButton* flashTargetQpb; QPushButton* runQpb; - elfInfoWdgt* elfInfoWdgtInst; + elfFileWidget* elfFileWidgetInst; }; #endif // DSU3PLUGINUI_H