Local variables window detects now if a variable is used or not by the code
[clinton/Virtual-Jaguar-Rx.git] / src / debugger / allwatchbrowser.cpp
CommitLineData
0203b5fd
JPM
1//\r
2// allwatchbrowser.cpp - All Watch\r
3//\r
4// by Jean-Paul Mari\r
5//\r
6// JPM = Jean-Paul Mari <djipi.mari@gmail.com>\r
7//\r
8// Who When What\r
9// --- ---------- -----------------------------------------------------------\r
10// JPM 12/07/2017 Created this file\r
11//\r
12\r
13// STILL TO DO:\r
14//\r
15\r
16#include "debugger/allwatchbrowser.h"\r
17#include "memory.h"\r
18#include "debugger/DBGManager.h"\r
19\r
20\r
21AllWatchBrowserWindow::AllWatchBrowserWindow(QWidget * parent/*= 0*/) : QWidget(parent, Qt::Dialog),\r
22 layout(new QVBoxLayout), text(new QTextBrowser),\r
23// layout(new QVBoxLayout), text(new QLabel),\r
24// refresh(new QPushButton(tr("Refresh"))),\r
25// address(new QLineEdit),\r
26// go(new QPushButton(tr("Go"))),\r
27// memBase(0),\r
28 NbWatch(0),\r
29 PtrWatchInfo(NULL)\r
30{\r
31 setWindowTitle(tr("All Watch"));\r
32\r
33// address->setInputMask("hhhhhh");\r
34// QHBoxLayout * hbox1 = new QHBoxLayout;\r
35// hbox1->addWidget(refresh);\r
36// hbox1->addWidget(address);\r
37// hbox1->addWidget(go);\r
38\r
39 // Need to set the size as well...\r
40// resize(560, 480);\r
41\r
42 QFont fixedFont("Lucida Console", 8, QFont::Normal);\r
43// QFont fixedFont("", 8, QFont::Normal);\r
44 fixedFont.setStyleHint(QFont::TypeWriter);\r
45 text->setFont(fixedFont);\r
46//// layout->setSizeConstraint(QLayout::SetFixedSize);\r
47 setLayout(layout);\r
48\r
49 layout->addWidget(text);\r
50// layout->addWidget(refresh);\r
51// layout->addLayout(hbox1);\r
52\r
53// connect(refresh, SIGNAL(clicked()), this, SLOT(RefreshContents()));\r
54// connect(go, SIGNAL(clicked()), this, SLOT(GoToAddress()));\r
55}\r
56\r
57\r
58//\r
59AllWatchBrowserWindow::~AllWatchBrowserWindow(void)\r
60{\r
61 NbWatch = 0;\r
62 free(PtrWatchInfo);\r
63}\r
64\r
65\r
66//\r
67void AllWatchBrowserWindow::RefreshContents(void)\r
68{\r
69 char string[1024];\r
70// char buf[64];\r
71 QString WatchAll;\r
72\r
73 if (isVisible())\r
74 {\r
75 if (!NbWatch)\r
76 {\r
77 if (NbWatch = DBGManager_GetNbGlobalVariables())\r
78 {\r
79 PtrWatchInfo = (WatchInfo *)calloc(NbWatch, sizeof(WatchInfo));\r
80#ifdef _MSC_VER\r
81#pragma message("Warning: !!! Need to check the memory desalocation for PtrWatchInfo !!!")\r
82#else\r
83 #warning "!!! Need to do the memory desalocation for PtrWatchInfo !!!"\r
84#endif // _MSC_VER\r
85 \r
86 for (uint32_t i = 0; i < NbWatch; i++)\r
87 {\r
88 PtrWatchInfo[i].PtrVariableName = DBGManager_GetGlobalVariableName(i + 1);\r
89 PtrWatchInfo[i].addr = DBGManager_GetGlobalVariableAdr(i + 1);\r
90 PtrWatchInfo[i].TypeTag = DBGManager_GetGlobalVariableTypeTag(i + 1);\r
91 if (!strlen(PtrWatchInfo[i].PtrVariableBaseTypeName = DBGManager_GetGlobalVariableTypeName(i + 1)))\r
92 {\r
93 PtrWatchInfo[i].PtrVariableBaseTypeName = (char *)"<font color='#ff0000'>N/A</font>";\r
94 }\r
95 }\r
96 }\r
97 }\r
98\r
99 for (uint32_t i = 0; i < NbWatch; i++)\r
100 {\r
101 if (PtrWatchInfo[i].PtrVariableName && PtrWatchInfo[i].PtrVariableBaseTypeName)\r
102 {\r
103 sprintf(string, "%i : %s | %s | 0x%06X | %s", (i + 1), PtrWatchInfo[i].PtrVariableBaseTypeName, PtrWatchInfo[i].PtrVariableName, (unsigned int)PtrWatchInfo[i].addr, (PtrWatchInfo[i].TypeTag & 0x8) ? "" : DBGManager_GetGlobalVariableValue(i + 1));\r
104 WatchAll += QString(string);\r
105 sprintf(string, "<br>");\r
106 WatchAll += QString(string);\r
107 }\r
108 }\r
109\r
110 text->clear();\r
111 text->setText(WatchAll);\r
112 }\r
113}\r
114\r
115\r
116#if 0\r
117void AllWatchBrowserWindow::keyPressEvent(QKeyEvent * e)\r
118{\r
119 if (e->key() == Qt::Key_Escape)\r
120 hide();\r
121 else if (e->key() == Qt::Key_PageUp)\r
122 {\r
123 memBase -= 480;\r
124\r
125 if (memBase < 0)\r
126 memBase = 0;\r
127\r
128 RefreshContents();\r
129 }\r
130 else if (e->key() == Qt::Key_PageDown)\r
131 {\r
132 memBase += 480;\r
133\r
134 if (memBase > (0x200000 - 480))\r
135 memBase = 0x200000 - 480;\r
136\r
137 RefreshContents();\r
138 }\r
139 else if (e->key() == Qt::Key_Up || e->key() == Qt::Key_Minus)\r
140 {\r
141 memBase -= 16;\r
142\r
143 if (memBase < 0)\r
144 memBase = 0;\r
145\r
146 RefreshContents();\r
147 }\r
148 else if (e->key() == Qt::Key_Down || e->key() == Qt::Key_Equal)\r
149 {\r
150 memBase += 16;\r
151\r
152 if (memBase > (0x200000 - 480))\r
153 memBase = 0x200000 - 480;\r
154\r
155 RefreshContents();\r
156 }\r
157}\r
158#endif\r
159\r
160\r
161#if 0\r
162void AllWatchBrowserWindow::GoToAddress(void)\r
163{\r
164 bool ok;\r
165 QString newAddress = address->text();\r
166 memBase = newAddress.toUInt(&ok, 16);\r
167 RefreshContents();\r
168}\r
169#endif\r
170\r