From eeb9667726c3fb454982f7f446a6a4e3c00d6170 Mon Sep 17 00:00:00 2001 From: Kingcom Date: Wed, 27 Nov 2013 15:06:41 +0100 Subject: [PATCH] Fix QT build (hopefully) --- Core/Debugger/SymbolMap.cpp | 33 +++++++++++++++++++++++++++++++++ Core/Debugger/SymbolMap.h | 8 ++++++++ Qt/QtHost.cpp | 2 +- Qt/ctrldisasmview.cpp | 28 ++++++++++++++-------------- Qt/ctrlmemview.cpp | 4 ++-- Qt/debugger_disasm.cpp | 16 +++++++--------- Qt/debugger_memory.cpp | 18 ++++++++---------- 7 files changed, 73 insertions(+), 36 deletions(-) diff --git a/Core/Debugger/SymbolMap.cpp b/Core/Debugger/SymbolMap.cpp index eb8179848c..0b4ff43f1b 100644 --- a/Core/Debugger/SymbolMap.cpp +++ b/Core/Debugger/SymbolMap.cpp @@ -315,7 +315,40 @@ const char *SymbolMap::GetDescription(unsigned int address) const return descriptionTemp; } +std::vector SymbolMap::GetAllSymbols(SymbolType symmask) +{ + std::vector result; + if (symmask & ST_FUNCTION) + { + for (auto it = functions.begin(); it != functions.end(); it++) + { + SymbolEntry entry; + entry.address = it->first; + entry.size = GetFunctionSize(entry.address); + const char* name = GetLabelName(entry.address); + if (name != NULL) + entry.name = name; + result.push_back(entry); + } + } + + if (symmask & ST_DATA) + { + for (auto it = data.begin(); it != data.end(); it++) + { + SymbolEntry entry; + entry.address = it->first; + entry.size = GetDataSize(entry.address); + const char* name = GetLabelName(entry.address); + if (name != NULL) + entry.name = name; + result.push_back(entry); + } + } + + return result; +} void SymbolMap::AddFunction(const char* name, u32 address, u32 size) diff --git a/Core/Debugger/SymbolMap.h b/Core/Debugger/SymbolMap.h index 80efc2d297..d086183df4 100644 --- a/Core/Debugger/SymbolMap.h +++ b/Core/Debugger/SymbolMap.h @@ -36,6 +36,13 @@ struct SymbolInfo { u32 size; }; +struct SymbolEntry +{ + std::string name; + u32 address; + u32 size; +}; + enum DataType { DATATYPE_NONE, DATATYPE_BYTE, DATATYPE_HALFWORD, DATATYPE_WORD }; #ifdef _WIN32 @@ -57,6 +64,7 @@ public: bool GetSymbolInfo(SymbolInfo *info, u32 address, SymbolType symmask = ST_FUNCTION) const; u32 GetNextSymbolAddress(u32 address, SymbolType symmask); const char *GetDescription(unsigned int address) const; + std::vector GetAllSymbols(SymbolType symmask); #ifdef _WIN32 void FillSymbolListBox(HWND listbox, SymbolType symType) const; diff --git a/Qt/QtHost.cpp b/Qt/QtHost.cpp index fbe16fb6fc..acc543988b 100644 --- a/Qt/QtHost.cpp +++ b/Qt/QtHost.cpp @@ -144,7 +144,7 @@ void QtHost::PrepareShutdown() void QtHost::AddSymbol(std::string name, u32 addr, u32 size, int type=0) { - symbolMap.AddSymbol(name.c_str(), addr, size, (SymbolType)type); + } bool QtHost::IsDebuggingEnabled() diff --git a/Qt/ctrldisasmview.cpp b/Qt/ctrldisasmview.cpp index d1a7fec5b1..03e73d5cc6 100644 --- a/Qt/ctrldisasmview.cpp +++ b/Qt/ctrldisasmview.cpp @@ -200,20 +200,20 @@ void CtrlDisAsmView::RunToHere() void CtrlDisAsmView::RenameFunction() { - int sym = symbolMap.GetSymbolNum(selection); - if (sym != -1) - { - QString name = symbolMap.GetSymbolName(sym); - bool ok; - QString newname = QInputDialog::getText(this, tr("New function name"), - tr("New function name:"), QLineEdit::Normal, - name, &ok); - if (ok && !newname.isEmpty()) - { - symbolMap.SetSymbolName(sym,newname.toStdString().c_str()); - redraw(); - parentWindow->NotifyMapLoaded(); - } + u32 funcBegin = symbolMap.GetFunctionStart(curAddress); + if (funcBegin != -1) + { + QString name = symbolMap.GetLabelName(funcBegin); + bool ok; + QString newname = QInputDialog::getText(this, tr("New function name"), + tr("New function name:"), QLineEdit::Normal, + name, &ok); + if (ok && !newname.isEmpty()) + { + symbolMap.SetLabelName(newname.toStdString().c_str(),funcBegin); + redraw(); + parentWindow->NotifyMapLoaded(); + } } else { diff --git a/Qt/ctrlmemview.cpp b/Qt/ctrlmemview.cpp index 6e3c9a93b2..3316169667 100644 --- a/Qt/ctrlmemview.cpp +++ b/Qt/ctrlmemview.cpp @@ -145,7 +145,7 @@ void CtrlMemView::paintEvent(QPaintEvent *) case MV_SYMBOLS: { - textPen.setColor(0x0000FF); +/* textPen.setColor(0x0000FF); painter.setPen(textPen); int fn = symbolMap.GetSymbolNum(address); if (fn==-1) @@ -174,7 +174,7 @@ void CtrlMemView::paintEvent(QPaintEvent *) sprintf(temp, "%04x [%s]", value, symbolMap.GetSymbolName(symbolnum)); } - painter.drawText(85,rowY1 - 2 + rowHeight, temp); + painter.drawText(85,rowY1 - 2 + rowHeight, temp);*/ break; } case MV_MAX: break; diff --git a/Qt/debugger_disasm.cpp b/Qt/debugger_disasm.cpp index 7ebef604fa..121cbf6afd 100644 --- a/Qt/debugger_disasm.cpp +++ b/Qt/debugger_disasm.cpp @@ -287,15 +287,13 @@ void Debugger_Disasm::FillFunctions() item->setData(Qt::UserRole, 0x02000000); ui->FuncList->addItem(item); - for(int i = 0; i < symbolMap.GetNumSymbols(); i++) - { - if(symbolMap.GetSymbolType(i) & ST_FUNCTION) - { - QListWidgetItem* item = new QListWidgetItem(); - item->setText(QString("%1 (%2)").arg(symbolMap.GetSymbolName(i)).arg(symbolMap.GetSymbolSize(i))); - item->setData(Qt::UserRole, symbolMap.GetAddress(i)); - ui->FuncList->addItem(item); - } + std::vector symbols = symbolMap.GetAllSymbols(ST_FUNCTION); + for(int i = 0; i < (int)symbols.size(); i++) + { + QListWidgetItem* item = new QListWidgetItem(); + item->setText(QString("%1 (%2)").arg(QString::fromStdString(symbols[i].name)).arg(symbols[i].size)); + item->setData(Qt::UserRole, symbols[i].address); + ui->FuncList->addItem(item); } } diff --git a/Qt/debugger_memory.cpp b/Qt/debugger_memory.cpp index 045ba267df..d6eeb36b60 100644 --- a/Qt/debugger_memory.cpp +++ b/Qt/debugger_memory.cpp @@ -59,16 +59,14 @@ void Debugger_Memory::NotifyMapLoaded() item->setData(Qt::UserRole, 0x80000000); ui->symbols->addItem(item); - for(int i = 0; i < symbolMap.GetNumSymbols(); i++) - { - if(symbolMap.GetSymbolType(i) & ST_DATA) - { - QListWidgetItem* item = new QListWidgetItem(); - item->setText(QString(symbolMap.GetSymbolName(i)) + " ("+ QString::number(symbolMap.GetSymbolSize(i)) +")"); - item->setData(Qt::UserRole, symbolMap.GetAddress(i)); - ui->symbols->addItem(item); - } - } + std::vector symbols = symbolMap.GetAllSymbols(ST_DATA); + for(int i = 0; i < (int)symbols.size(); i++) + { + QListWidgetItem* item = new QListWidgetItem(); + item->setText(QString("%1 (%2)").arg(QString::fromStdString(symbols[i].name)).arg(symbols[i].size)); + item->setData(Qt::UserRole, symbols[i].address); + ui->symbols->addItem(item); + } ui->regions->clear(); /*