-
Notifications
You must be signed in to change notification settings - Fork 0
/
mainwindow.cpp
122 lines (93 loc) · 3.53 KB
/
mainwindow.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
#include "mainwindow.h"
#include <QMenuBar>
#include <QApplication>
#include "parameters.h"
#include "debuggermanager.h"
#include "LtDbg/LtDbg/Exceptions.hpp"
MainWindow::MainWindow(QWidget *parent)
: QMainWindow(parent)
{
_initView();
_initMenu();
_initDebuggerManager();
}
MainWindow::~MainWindow()
{
}
void MainWindow::_initView()
{
_window = new QWidget;
_mainLayout = new QVBoxLayout;
_pipeEditLayout = new QHBoxLayout;
/* Connexion layout */
_pipeLineEdit = new QLineEdit;
_pipeLineEdit->setText(QString(Parameters::Instance()->pipeName.c_str()));
_connexionButton = new QPushButton("Connect");
_pipeEditLayout->addWidget(_pipeLineEdit);
_pipeEditLayout->addWidget(_connexionButton);
_mainLayout->addLayout(_pipeEditLayout);
/* Sub windows layout */
_subWindowsArea = new QMdiArea;
_stackTraceTextEdit = new StackTraceWidget;
_asmTextEdit = new AsmWidget;
_cmdWidget = new CmdWidget;
_stackTraceSubWindow = _subWindowsArea->addSubWindow(_stackTraceTextEdit);
_stackTraceSubWindow->setWindowTitle("Stack trace");
_stackTraceSubWindow->setWindowIcon( QIcon(":/icons/iconStack.png") );
_asmSubWindow = _subWindowsArea->addSubWindow(_asmTextEdit);
_asmSubWindow->setWindowTitle("Disassembly");
_asmSubWindow->setWindowIcon( QIcon(":/icons/iconDisassembly.png") );
_consoleSubWindow = _subWindowsArea->addSubWindow(_cmdWidget);
_consoleSubWindow->setWindowTitle("Output");
_consoleSubWindow->setWindowIcon( QIcon(":/icons/iconCmdWidget.png") );
_cmdWidget->show();
_subWindowsArea->tileSubWindows();
_mainLayout->addLayout(_pipeEditLayout);
_mainLayout->addWidget(_subWindowsArea);
_window->setLayout(_mainLayout);
setCentralWidget(_window);
connect(_connexionButton, SIGNAL(clicked()), this, SLOT(connectToLtKernel()));
}
void MainWindow::_initMenu()
{
QMenu * fileMenu = menuBar()->addMenu("File");
_actionSymbols = new QAction("Load symbols...", this);
_actionQuit = new QAction("Quit", this);
_symbolsWindow = new SymbolsWindow;
fileMenu->addAction(_actionSymbols);
fileMenu->addAction(_actionQuit);
connect(_actionSymbols, SIGNAL(triggered()), _symbolsWindow, SLOT(exec()));
connect(_actionQuit, SIGNAL(triggered()), qApp, SLOT(quit()));
}
void MainWindow::_initDebuggerManager()
{
_dbg = new Dbg;
DebuggerManager::Instance()->Initialize(_dbg, _cmdWidget, _stackTraceTextEdit, _asmTextEdit);
DebuggerManager::Instance()->LoadSymbols(Parameters::Instance()->symbolsPaths);
//if (_pipeLineEdit->text().length() > 0)
// connectToLtKernel();
}
void MainWindow::connectToLtKernel()
{
const QString pipeName = _pipeLineEdit->text();
_connexionButton->setDisabled(true);
_cmdWidget->SetEnabled(false);
if (pipeName.length() > 0)
{
try {
_cmdWidget->AddInfo("Trying to connect to LtMicros using pipe '" + pipeName + "'...");
_dbg->Connect(_pipeLineEdit->text().toStdString());
DebuggerManager::Instance()->ConnectToDebugger(Parameters::Instance()->pipeName);
}
catch (const DbgException & exc)
{
_cmdWidget->AddError("An error occured while trying to connect to LtKernel !");
_cmdWidget->AddError(QString(exc.ToString().c_str()));
}
}
else
{
_cmdWidget->AddInfo("No pipe name");
}
_connexionButton->setDisabled(false);
}