Line 12... |
Line 12... |
#include "GnssWidgets/MapWidget.h"
|
#include "GnssWidgets/MapWidget.h"
|
#include <QtWidgets/QtWidgets>
|
#include <QtWidgets/QtWidgets>
|
|
|
namespace debugger {
|
namespace debugger {
|
|
|
DbgMainWindow::DbgMainWindow(IGui *igui, event_def *init_done) {
|
DbgMainWindow::DbgMainWindow(IGui *igui) : QMainWindow() {
|
igui_ = igui;
|
igui_ = igui;
|
initDone_ = init_done;
|
//initDone_ = init_done;
|
statusRequested_ = false;
|
statusRequested_ = false;
|
ebreak_ = 0;
|
ebreak_ = 0;
|
|
|
setWindowTitle(tr("RISC-V platform debugger"));
|
setWindowTitle(tr("RISC-V platform debugger"));
|
resize(QDesktopWidget().availableGeometry(this).size() * 0.7);
|
resize(QDesktopWidget().availableGeometry(this).size() * 0.7);
|
Line 42... |
Line 42... |
*/
|
*/
|
addWidgets();
|
addWidgets();
|
|
|
setUnifiedTitleAndToolBarOnMac(true);
|
setUnifiedTitleAndToolBarOnMac(true);
|
|
|
|
ISocInfo *isoc = static_cast<ISocInfo *>(igui_->getSocInfo());
|
|
if (isoc) {
|
|
DsuMapType *dsu = isoc->getpDsu();
|
|
ebreak_ = new EBreakHandler(igui_);
|
|
|
|
ebreak_->setBrAddressFetch(
|
|
reinterpret_cast<uint64_t>(&dsu->udbg.v.br_address_fetch));
|
|
ebreak_->setHwRemoveBreakpoint(
|
|
reinterpret_cast<uint64_t>(&dsu->udbg.v.remove_breakpoint));
|
|
}
|
|
|
/**
|
/**
|
* To use the following type in SIGNAL -> SLOT definitions
|
* To use the following type in SIGNAL -> SLOT definitions
|
* we have to register them using qRegisterMetaType template
|
* we have to register them using qRegisterMetaType template
|
*/
|
*/
|
qRegisterMetaType<uint64_t>("uint64_t");
|
qRegisterMetaType<uint64_t>("uint64_t");
|
qRegisterMetaType<uint32_t>("uint32_t");
|
qRegisterMetaType<uint32_t>("uint32_t");
|
|
|
connect(this, SIGNAL(signalPostInit(AttributeType *)),
|
|
this, SLOT(slotPostInit(AttributeType *)));
|
|
connect(this, SIGNAL(signalExit()), this, SLOT(slotExit()));
|
|
|
|
tmrGlobal_ = new QTimer(this);
|
tmrGlobal_ = new QTimer(this);
|
connect(tmrGlobal_, SIGNAL(timeout()), this, SLOT(slotConfigDone()));
|
connect(tmrGlobal_, SIGNAL(timeout()), this, SLOT(slotUpdateByTimer()));
|
tmrGlobal_->setSingleShot(true);
|
tmrGlobal_->setSingleShot(false);
|
tmrGlobal_->setInterval(1);
|
tmrGlobal_->setInterval(250);
|
tmrGlobal_->start();
|
tmrGlobal_->start();
|
}
|
}
|
|
|
DbgMainWindow::~DbgMainWindow() {
|
DbgMainWindow::~DbgMainWindow() {
|
if (ebreak_) {
|
if (ebreak_) {
|
delete ebreak_;
|
delete ebreak_;
|
}
|
}
|
tmrGlobal_->stop();
|
|
igui_->removeFromQueue(static_cast<IGuiCmdHandler *>(this));
|
igui_->removeFromQueue(static_cast<IGuiCmdHandler *>(this));
|
qApp->quit();
|
|
}
|
}
|
|
|
void DbgMainWindow::closeEvent(QCloseEvent *ev) {
|
void DbgMainWindow::closeEvent(QCloseEvent *ev) {
|
|
tmrGlobal_->stop();
|
|
delete tmrGlobal_;
|
ev->accept();
|
ev->accept();
|
|
emit signalAboutToClose();
|
|
}
|
|
|
|
#ifndef QT_NO_CONTEXTMENU
|
|
void DbgMainWindow::contextMenuEvent(QContextMenuEvent *ev_) {
|
|
QMenu menu(this);
|
|
menu.addAction(actionRegs_);
|
|
menu.exec(ev_->globalPos());
|
}
|
}
|
|
#endif
|
|
|
void DbgMainWindow::handleResponse(AttributeType *req, AttributeType *resp) {
|
void DbgMainWindow::handleResponse(AttributeType *req, AttributeType *resp) {
|
if (req->is_equal(cmdStatus_.to_string())) {
|
if (req->is_equal(cmdStatus_.to_string())) {
|
statusRequested_ = false;
|
statusRequested_ = false;
|
if (resp->is_nil()) {
|
if (resp->is_nil()) {
|
Line 99... |
Line 115... |
CSTATES[ctrl.bits.cstate]);
|
CSTATES[ctrl.bits.cstate]);
|
#endif
|
#endif
|
}
|
}
|
}
|
}
|
|
|
void DbgMainWindow::postInit(AttributeType *cfg) {
|
|
emit signalPostInit(cfg);
|
|
}
|
|
|
|
void DbgMainWindow::getConfiguration(AttributeType &cfg) {
|
|
cfg = config_;
|
|
}
|
|
|
|
void DbgMainWindow::callExit() {
|
|
emit signalExit();
|
|
}
|
|
|
|
void DbgMainWindow::slotExit() {
|
|
close();
|
|
}
|
|
|
|
void DbgMainWindow::createActions() {
|
void DbgMainWindow::createActions() {
|
actionRegs_ = new QAction(QIcon(tr(":/images/cpu_96x96.png")),
|
actionRegs_ = new QAction(QIcon(tr(":/images/cpu_96x96.png")),
|
tr("&Regs"), this);
|
tr("&Regs"), this);
|
actionRegs_->setToolTip(tr("CPU Registers view"));
|
actionRegs_->setToolTip(tr("CPU Registers view"));
|
actionRegs_->setShortcut(QKeySequence("Ctrl+r"));
|
actionRegs_->setShortcut(QKeySequence(tr("Ctrl+r")));
|
actionRegs_->setCheckable(true);
|
actionRegs_->setCheckable(true);
|
actionRegs_->setChecked(false);
|
actionRegs_->setChecked(false);
|
connect(actionRegs_, SIGNAL(triggered(bool)),
|
connect(actionRegs_, SIGNAL(triggered(bool)),
|
this, SLOT(slotActionTriggerRegs(bool)));
|
this, SLOT(slotActionTriggerRegs(bool)));
|
|
|
actionCpuAsm_ = new QAction(QIcon(tr(":/images/asm_96x96.png")),
|
actionCpuAsm_ = new QAction(QIcon(tr(":/images/asm_96x96.png")),
|
tr("&Memory"), this);
|
tr("&Memory"), this);
|
actionCpuAsm_->setToolTip(tr("Disassembler view"));
|
actionCpuAsm_->setToolTip(tr("Disassembler view"));
|
actionCpuAsm_->setShortcut(QKeySequence("Ctrl+d"));
|
actionCpuAsm_->setShortcut(QKeySequence(tr("Ctrl+d")));
|
actionCpuAsm_->setCheckable(true);
|
actionCpuAsm_->setCheckable(true);
|
connect(actionCpuAsm_, SIGNAL(triggered(bool)),
|
connect(actionCpuAsm_, SIGNAL(triggered(bool)),
|
this, SLOT(slotActionTriggerCpuAsmView(bool)));
|
this, SLOT(slotActionTriggerCpuAsmView(bool)));
|
|
|
actionStackTrace_ = new QAction(QIcon(tr(":/images/stack_96x96.png")),
|
actionStackTrace_ = new QAction(QIcon(tr(":/images/stack_96x96.png")),
|
tr("&Stack"), this);
|
tr("&Stack"), this);
|
actionStackTrace_->setToolTip(tr("Stack trace"));
|
actionStackTrace_->setToolTip(tr("Stack trace"));
|
actionStackTrace_->setShortcut(QKeySequence("Ctrl+t"));
|
actionStackTrace_->setShortcut(QKeySequence(tr("Ctrl+t")));
|
actionStackTrace_->setCheckable(true);
|
actionStackTrace_->setCheckable(true);
|
connect(actionStackTrace_, SIGNAL(triggered(bool)),
|
connect(actionStackTrace_, SIGNAL(triggered(bool)),
|
this, SLOT(slotActionTriggerStackTraceView(bool)));
|
this, SLOT(slotActionTriggerStackTraceView(bool)));
|
|
|
actionSymbolBrowser_ = new QAction(QIcon(tr(":/images/info_96x96.png")),
|
actionSymbolBrowser_ = new QAction(QIcon(tr(":/images/info_96x96.png")),
|
tr("&Symbols"), this);
|
tr("&Symbols"), this);
|
actionSymbolBrowser_->setToolTip(tr("Symbol Browser"));
|
actionSymbolBrowser_->setToolTip(tr("Symbol Browser"));
|
actionSymbolBrowser_->setShortcut(QKeySequence("Ctrl+s"));
|
actionSymbolBrowser_->setShortcut(QKeySequence(tr("Ctrl+s")));
|
actionSymbolBrowser_->setCheckable(false);
|
actionSymbolBrowser_->setCheckable(false);
|
connect(actionSymbolBrowser_, SIGNAL(triggered()),
|
connect(actionSymbolBrowser_, SIGNAL(triggered()),
|
this, SLOT(slotActionTriggerSymbolBrowser()));
|
this, SLOT(slotActionTriggerSymbolBrowser()));
|
|
|
actionMem_ = new QAction(QIcon(tr(":/images/mem_96x96.png")),
|
actionMem_ = new QAction(QIcon(tr(":/images/mem_96x96.png")),
|
tr("&Memory"), this);
|
tr("&Memory"), this);
|
actionMem_->setToolTip(tr("Memory view"));
|
actionMem_->setToolTip(tr("Memory view"));
|
actionMem_->setShortcut(QKeySequence("Ctrl+m"));
|
actionMem_->setShortcut(QKeySequence(tr("Ctrl+m")));
|
actionMem_->setCheckable(true);
|
actionMem_->setCheckable(true);
|
actionMem_->setChecked(false);
|
actionMem_->setChecked(false);
|
connect(actionMem_, SIGNAL(triggered(bool)),
|
connect(actionMem_, SIGNAL(triggered(bool)),
|
this, SLOT(slotActionTriggerMemView(bool)));
|
this, SLOT(slotActionTriggerMemView(bool)));
|
|
|
actionPnp_ = new QAction(QIcon(tr(":/images/board_96x96.png")),
|
actionPnp_ = new QAction(QIcon(tr(":/images/board_96x96.png")),
|
tr("&Pnp"), this);
|
tr("&Pnp"), this);
|
actionPnp_->setToolTip(tr("Plug'n'play information view"));
|
actionPnp_->setToolTip(tr("Plug'n'play information view"));
|
actionPnp_->setShortcut(QKeySequence("Ctrl+p"));
|
actionPnp_->setShortcut(QKeySequence(tr("Ctrl+p")));
|
actionPnp_->setCheckable(true);
|
actionPnp_->setCheckable(true);
|
actionPnp_->setChecked(false);
|
actionPnp_->setChecked(false);
|
connect(actionPnp_, SIGNAL(triggered(bool)),
|
connect(actionPnp_, SIGNAL(triggered(bool)),
|
this, SLOT(slotActionTriggerPnp(bool)));
|
this, SLOT(slotActionTriggerPnp(bool)));
|
|
|
Line 183... |
Line 183... |
actionSerial_->setCheckable(true);
|
actionSerial_->setCheckable(true);
|
actionSerial_->setChecked(false);
|
actionSerial_->setChecked(false);
|
connect(actionSerial_, SIGNAL(triggered(bool)),
|
connect(actionSerial_, SIGNAL(triggered(bool)),
|
this, SLOT(slotActionTriggerUart0(bool)));
|
this, SLOT(slotActionTriggerUart0(bool)));
|
|
|
actionGnssMap_ = new QAction(QIcon(tr(":/images/serial_96x96.png")),
|
actionGnssMap_ = new QAction(QIcon(tr(":/images/opmap_96x96.png")),
|
tr("&OpenStreetMap"), this);
|
tr("&OpenStreetMap"), this);
|
actionGnssMap_->setToolTip(tr("Open Street map with GNSS tracks view"));
|
actionGnssMap_->setToolTip(tr("Open Street map with GNSS tracks view"));
|
actionGnssMap_->setCheckable(true);
|
actionGnssMap_->setCheckable(true);
|
actionGnssMap_->setChecked(false);
|
actionGnssMap_->setChecked(false);
|
connect(actionGnssMap_, SIGNAL(triggered(bool)),
|
connect(actionGnssMap_, SIGNAL(triggered(bool)),
|
this, SLOT(slotActionTriggerGnssMap(bool)));
|
this, SLOT(slotActionTriggerGnssMap(bool)));
|
|
|
actionRun_ = new QAction(QIcon(tr(":/images/start_96x96.png")),
|
actionRun_ = new QAction(QIcon(tr(":/images/start_96x96.png")),
|
tr("&Run"), this);
|
tr("&Run"), this);
|
actionRun_->setToolTip(tr("Start Execution (F5)"));
|
actionRun_->setToolTip(tr("Start Execution (F5)"));
|
actionRun_->setShortcut(QKeySequence("F5"));
|
actionRun_->setShortcut(QKeySequence(tr("F5")));
|
actionRun_->setCheckable(true);
|
actionRun_->setCheckable(true);
|
actionRun_->setChecked(false);
|
actionRun_->setChecked(false);
|
connect(actionRun_ , SIGNAL(triggered()),
|
connect(actionRun_ , SIGNAL(triggered()),
|
this, SLOT(slotActionTargetRun()));
|
this, SLOT(slotActionTargetRun()));
|
connect(this, SIGNAL(signalTargetStateChanged(bool)),
|
connect(this, SIGNAL(signalTargetStateChanged(bool)),
|
actionRun_, SLOT(setChecked(bool)));
|
actionRun_, SLOT(setChecked(bool)));
|
|
|
actionHalt_ = new QAction(QIcon(tr(":/images/pause_96x96.png")),
|
actionHalt_ = new QAction(QIcon(tr(":/images/pause_96x96.png")),
|
tr("&Halt"), this);
|
tr("&Halt"), this);
|
actionHalt_->setToolTip(tr("Stop Execution (Ctrl+Alt+F5)"));
|
actionHalt_->setToolTip(tr("Stop Execution (Ctrl+Alt+F5)"));
|
actionHalt_->setShortcut(QKeySequence("Ctrl+Alt+F5"));
|
actionHalt_->setShortcut(QKeySequence(tr("Ctrl+Alt+F5")));
|
connect(actionHalt_ , SIGNAL(triggered()),
|
connect(actionHalt_ , SIGNAL(triggered()),
|
this, SLOT(slotActionTargetHalt()));
|
this, SLOT(slotActionTargetHalt()));
|
|
|
actionStep_ = new QAction(QIcon(tr(":/images/stepinto_96x96.png")),
|
actionStep_ = new QAction(QIcon(tr(":/images/stepinto_96x96.png")),
|
tr("&Step Into"), this);
|
tr("&Step Into"), this);
|
actionStep_->setToolTip(tr("Instruction Step (F11)"));
|
actionStep_->setToolTip(tr("Instruction Step (F11)"));
|
actionStep_->setShortcut(QKeySequence("F11"));
|
actionStep_->setShortcut(QKeySequence(tr("F11")));
|
connect(actionStep_ , SIGNAL(triggered()),
|
connect(actionStep_ , SIGNAL(triggered()),
|
this, SLOT(slotActionTargetStepInto()));
|
this, SLOT(slotActionTargetStepInto()));
|
|
|
|
|
actionQuit_ = new QAction(tr("&Quit"), this);
|
actionQuit_ = new QAction(tr("&Quit"), this);
|
Line 276... |
Line 276... |
/** Docked Widgets: */
|
/** Docked Widgets: */
|
QDockWidget *dock = new QDockWidget(tr("Debugger console"), this);
|
QDockWidget *dock = new QDockWidget(tr("Debugger console"), this);
|
dock->setAllowedAreas(Qt::BottomDockWidgetArea);
|
dock->setAllowedAreas(Qt::BottomDockWidgetArea);
|
addDockWidget(Qt::BottomDockWidgetArea, dock);
|
addDockWidget(Qt::BottomDockWidgetArea, dock);
|
|
|
|
|
ConsoleWidget *consoleWidget = new ConsoleWidget(igui_, this);
|
ConsoleWidget *consoleWidget = new ConsoleWidget(igui_, this);
|
dock->setWidget(consoleWidget);
|
dock->setWidget(consoleWidget);
|
connect(this, SIGNAL(signalPostInit(AttributeType *)),
|
|
consoleWidget, SLOT(slotPostInit(AttributeType *)));
|
|
}
|
}
|
|
|
void DbgMainWindow::addWidgets() {
|
void DbgMainWindow::addWidgets() {
|
slotActionTriggerUart0(true);
|
slotActionTriggerUart0(true);
|
slotActionTriggerCpuAsmView(true);
|
slotActionTriggerCpuAsmView(true);
|
|
|
|
//slotActionTriggerGnssMap(true);
|
}
|
}
|
|
|
void DbgMainWindow::slotActionTriggerUart0(bool val) {
|
void DbgMainWindow::slotActionTriggerUart0(bool val) {
|
if (val) {
|
if (val) {
|
viewUart0_ =
|
viewUart0_ =
|
Line 373... |
Line 372... |
|
|
void DbgMainWindow::slotOpenMemory(uint64_t addr, uint64_t sz) {
|
void DbgMainWindow::slotOpenMemory(uint64_t addr, uint64_t sz) {
|
new MemQMdiSubWindow(igui_, mdiArea_, this, addr, sz);
|
new MemQMdiSubWindow(igui_, mdiArea_, this, addr, sz);
|
}
|
}
|
|
|
void DbgMainWindow::slotPostInit(AttributeType *cfg) {
|
//void DbgMainWindow::slotPostInit(AttributeType *cfg) {
|
config_ = *cfg;
|
// config_ = *cfg;
|
// Enable polling timer:
|
// Enable polling timer:
|
connect(tmrGlobal_, SIGNAL(timeout()), this, SLOT(slotUpdateByTimer()));
|
//connect(tmrGlobal_, SIGNAL(timeout()), this, SLOT(slotUpdateByTimer()));
|
int ms = static_cast<int>(config_["PollingMs"].to_uint64());
|
//int ms = static_cast<int>(config_["PollingMs"].to_uint64());
|
tmrGlobal_->setInterval(ms);
|
//tmrGlobal_->setInterval(ms);
|
tmrGlobal_->setSingleShot(false);
|
//tmrGlobal_->setSingleShot(false);
|
tmrGlobal_->start(ms);
|
//tmrGlobal_->start(ms);
|
|
|
ISocInfo *isoc = static_cast<ISocInfo *>(igui_->getSocInfo());
|
|
if (isoc) {
|
|
DsuMapType *dsu = isoc->getpDsu();
|
|
ebreak_ = new EBreakHandler(igui_);
|
|
|
|
ebreak_->setBrAddressFetch(
|
|
reinterpret_cast<uint64_t>(&dsu->udbg.v.br_address_fetch));
|
|
ebreak_->setHwRemoveBreakpoint(
|
|
reinterpret_cast<uint64_t>(&dsu->udbg.v.remove_breakpoint));
|
|
}
|
|
|
|
// Debug:
|
// Debug:
|
//slotActionTriggerGnssMap(true);
|
//slotActionTriggerGnssMap(true);
|
}
|
//}
|
|
|
void DbgMainWindow::slotConfigDone() {
|
|
RISCV_event_set(initDone_);
|
|
disconnect(tmrGlobal_, SIGNAL(timeout()), this, SLOT(slotConfigDone()));
|
|
tmrGlobal_->stop();
|
|
}
|
|
|
|
|
|
void DbgMainWindow::slotUpdateByTimer() {
|
void DbgMainWindow::slotUpdateByTimer() {
|
if (!statusRequested_) {
|
if (!statusRequested_) {
|
statusRequested_ = true;
|
statusRequested_ = true;
|
igui_->registerCommand(static_cast<IGuiCmdHandler *>(this),
|
igui_->registerCommand(static_cast<IGuiCmdHandler *>(this),
|