Fixes mostly to prevent compilation errors in Linux
[clinton/Virtual-Jaguar-Rx.git] / src / debugger / brkWin.cpp
CommitLineData
cf76e892
JPM
1//
2// brkWin.cpp - Breakpoints
3//
4// by Jean-Paul Mari
5//
6// JPM = Jean-Paul Mari <djipi.mari@gmail.com>
7//
8// Who When What
9// --- ---------- -----------------------------------------------------------
10// JPM 30/08/2017 Created this file
11//
12
13// STILL TO DO:
14//
15
5fe21518 16#include "debugger/brkWin.h"
cf76e892 17//#include "memory.h"
5fe21518 18#include "debugger/DBGManager.h"
cf76e892
JPM
19
20
21//
22BrkWindow::BrkWindow(QWidget * parent/*= 0*/) : QWidget(parent, Qt::Dialog),
23 layout(new QVBoxLayout), text(new QTextBrowser),
24// layout(new QVBoxLayout), text(new QLabel),
25// refresh(new QPushButton(tr("Refresh"))),
26 address(new QLineEdit)
27// go(new QPushButton(tr("Go"))),
28// memBase(0),
29// NbWatch(0),
30// PtrWatchInfo(NULL)
31{
32 setWindowTitle(tr("Breakpoints window"));
33
34#if 0
35// address->setInputMask("hhhhhh");
36// QHBoxLayout * hbox1 = new QHBoxLayout;
37// hbox1->addWidget(refresh);
38// hbox1->addWidget(address);
39// hbox1->addWidget(go);
40
41 // Need to set the size as well...
42// resize(560, 480);
43
44 QFont fixedFont("Lucida Console", 8, QFont::Normal);
45// QFont fixedFont("", 8, QFont::Normal);
46 fixedFont.setStyleHint(QFont::TypeWriter);
47 text->setFont(fixedFont);
48//// layout->setSizeConstraint(QLayout::SetFixedSize);
49 setLayout(layout);
50
51 layout->addWidget(text);
52// layout->addWidget(refresh);
53// layout->addLayout(hbox1);
54
55// connect(refresh, SIGNAL(clicked()), this, SLOT(RefreshContents()));
56// connect(go, SIGNAL(clicked()), this, SLOT(GoToAddress()));
57#endif
58}
59
60
61//
62BrkWindow::~BrkWindow(void)
63{
64#if 0
65 NbWatch = 0;
66 free(PtrWatchInfo);
67#endif
68}
69
70
71//
72void BrkWindow::RefreshContents(void)
73{
74#if 0
75 char string[1024];
76// char buf[64];
77 QString WatchAll;
78
79 if (isVisible())
80 {
81 if (!NbWatch)
82 {
83 if (NbWatch = DBGManager_GetNbExternalVariables())
84 {
85 PtrWatchInfo = (WatchInfo *)calloc(NbWatch, sizeof(WatchInfo));
86#ifdef _MSC_VER
87#pragma message("Warning: !!! Need to check the memory desalocation for PtrWatchInfo !!!")
88#else
89 #warning "!!! Need to do the memory desalocation for PtrWatchInfo !!!"
90#endif // _MSC_VER
91
92 for (uint32_t i = 0; i < NbWatch; i++)
93 {
94 PtrWatchInfo[i].PtrVariableName = DBGManager_GetExternalVariableName(i + 1);
95 PtrWatchInfo[i].addr = DBGManager_GetExternalVariableAdr(i + 1);
96 PtrWatchInfo[i].TypeTag = DBGManager_GetExternalVariableTypeTag(i + 1);
97 if (!strlen(PtrWatchInfo[i].PtrVariableBaseTypeName = DBGManager_GetExternalVariableTypeName(i + 1)))
98 {
99 PtrWatchInfo[i].PtrVariableBaseTypeName = (char *)"<font color='#ff0000'>N/A</font>";
100 }
101 }
102 }
103 }
104
105 for (uint32_t i = 0; i < NbWatch; i++)
106 {
107 if (PtrWatchInfo[i].PtrVariableName && PtrWatchInfo[i].PtrVariableBaseTypeName)
108 {
109 sprintf(string, "%i : %s | %s | 0x%06X | %s", (i + 1), PtrWatchInfo[i].PtrVariableBaseTypeName, PtrWatchInfo[i].PtrVariableName, PtrWatchInfo[i].addr, (PtrWatchInfo[i].TypeTag & 0x8) ? "" : DBGManager_GetExternalVariableValue(i + 1));
110 WatchAll += QString(string);
111 sprintf(string, "<br>");
112 WatchAll += QString(string);
113 }
114 }
115
116 text->clear();
117 text->setText(WatchAll);
118 }
119#endif
120}
121
122
123//
124void BrkWindow::keyPressEvent(QKeyEvent * e)
125{
126 if (e->key() == Qt::Key_Escape)
127 {
128 hide();
129 }
130 else
131 {
132 if (e->key() == Qt::Key_PageUp)
133 {
134#if 0
135 memBase -= 480;
136
137 if (memBase < 0)
138 memBase = 0;
139
140 RefreshContents();
141#endif
142 }
143 else
144 {
145 if (e->key() == Qt::Key_PageDown)
146 {
147#if 0
148 memBase += 480;
149
150 if (memBase > (0x200000 - 480))
151 memBase = 0x200000 - 480;
152
153 RefreshContents();
154#endif
155 }
156 else
157 {
158 if (e->key() == Qt::Key_Up || e->key() == Qt::Key_Minus)
159 {
160#if 0
161 memBase -= 16;
162
163 if (memBase < 0)
164 memBase = 0;
165
166 RefreshContents();
167#endif
168 }
169 else
170 {
171 if (e->key() == Qt::Key_Down || e->key() == Qt::Key_Equal)
172 {
173#if 0
174 memBase += 16;
175
176 if (memBase > (0x200000 - 480))
177 memBase = 0x200000 - 480;
178
179 RefreshContents();
180#endif
181 }
182 else
183 {
184 if (e->key() == Qt::Key_Return)
185 {
186 GoToAddress();
187 }
188 }
189 }
190 }
191 }
192 }
193}
194
195
196//
197void BrkWindow::RefreshBrkList(size_t Address)
198{
199}
200
201
202// Go to the requested address
203// Address can be an hexa, decimal or a symbol name
204void BrkWindow::GoToAddress(void)
205{
206 size_t Address;
207 bool ok;
208 QString newAddress;
209
210 newAddress = address->text();
211
212 if ((newAddress.at(0) == QChar('0')) && (newAddress.at(1) == QChar('x')))
213 {
214 Address = newAddress.toUInt(&ok, 16);
215 }
216 else
217 {
218 if (!(Address = DBGManager_GetAdrFromSymbolName(newAddress.toLatin1().data())))
219 {
220 Address = newAddress.toUInt(&ok, 10);
221 }
222 }
223
224 RefreshBrkList(Address);
225}
226