Update the breakpoint feature
[clinton/Virtual-Jaguar-Rx.git] / src / debugger / exceptionvectortablebrowser.cpp
1 //
2 // exceptionvectortable.cpp - Exception Vector Table
3 //
4 // by Jean-Paul Mari
5 //
6 // JPM = Jean-Paul Mari <djipi.mari@gmail.com>
7 //
8 // Who When What
9 // --- ---------- -----------------------------------------------------------
10 // JPM 05/09/2017 Created this file
11 // JPM 09/09/2018 Set information values in a tab
12 // JPM 09/09/2018 Added vectors in the table
13 //
14
15 // STILL TO DO:
16 // To set the information display at the right
17 //
18
19
20 #include "debugger/exceptionvectortablebrowser.h"
21 #include "memory.h"
22 #include "debugger/DBGManager.h"
23
24
25 //
26 struct ExceptionVectorTable
27 {
28 size_t VectorNumber;
29 size_t Address;
30 const char *ExceptionName;
31 }
32 S_ExceptionVectorTable;
33
34 //
35 ExceptionVectorTable TabExceptionVectorTable[] = {
36 { 0, 0x000000, "RESET - Initial SSP" },
37 { 1, 0x000004, "RESET - Initial PC" },
38 { 2, 0x000008, "Bus error" },
39 { 3, 0x00000C, "Address error" },
40 { 4, 0x000010, "Illegal instruction" },
41 { 5, 0x000014, "Division by zero" },
42 { 6, 0x000018, "CHK instruction" },
43 { 7, 0x00001C, "TRAPV instruction" },
44 { 8, 0x000020, "Privilege violation" },
45 { 9, 0x000024, "Trace" },
46 { 10, 0x000028, "Unimplemented instruction" },
47 { 11, 0x00002C, "Unimplemented instruction" },
48 { 12, 0x000030, "Reserved by Motorola" },
49 { 13, 0x000034, "Reserved by Motorola" },
50 { 14, 0x000038, "Reserved by Motorola" },
51 { 15, 0x00003C, "Uninitialised interrupt vector" },
52 { 16, 0x000040, "Reserved by Motorola" },
53 { 17, 0x000044, "Reserved by Motorola" },
54 { 18, 0x000048, "Reserved by Motorola" },
55 { 19, 0x00004C, "Reserved by Motorola" },
56 { 20, 0x000050, "Reserved by Motorola" },
57 { 21, 0x000054, "Reserved by Motorola" },
58 { 22, 0x000058, "Reserved by Motorola" },
59 { 23, 0x00005C, "Reserved by Motorola" },
60 { 24, 0x000060, "Spurious interrupt" },
61 { 25, 0x000064, "Level 1 interrupt autovector" },
62 { 26, 0x000068, "Level 2 interrupt autovector" },
63 { 27, 0x00006C, "Level 3 interrupt autovector" },
64 { 28, 0x000070, "Level 4 interrupt autovector" },
65 { 29, 0x000074, "Level 5 interrupt autovector" },
66 { 30, 0x000078, "Level 6 interrupt autovector" },
67 { 31, 0x00007C, "Level 7 interrupt autovector" },
68 { 32, 0x000080, "TRAP #0 instruction" },
69 { 33, 0x000084, "TRAP #1 instruction" },
70 { 34, 0x000088, "TRAP #2 instruction" },
71 { 35, 0x00008C, "TRAP #3 instruction" },
72 { 36, 0x000090, "TRAP #4 instruction" },
73 { 37, 0x000094, "TRAP #5 instruction" },
74 { 38, 0x000098, "TRAP #6 instruction" },
75 { 39, 0x00009C, "TRAP #7 instruction" },
76 { 40, 0x0000A0, "TRAP #8 instruction" },
77 { 41, 0x0000A4, "TRAP #9 instruction" },
78 { 42, 0x0000A8, "TRAP #10 instruction" },
79 { 43, 0x0000AC, "TRAP #11 instruction" },
80 { 44, 0x0000B0, "TRAP #12 instruction" },
81 { 45, 0x0000B4, "TRAP #13 instruction" },
82 { 46, 0x0000B8, "TRAP #14 instruction" },
83 { 47, 0x0000BC, "TRAP #15 instruction" },
84 { 48, 0x0000C0, "Reserved by Motorola" },
85 { 49, 0x0000C4, "Reserved by Motorola" },
86 { 50, 0x0000C8, "Reserved by Motorola" },
87 { 51, 0x0000CC, "Reserved by Motorola" },
88 { 52, 0x0000D0, "Reserved by Motorola" },
89 { 53, 0x0000D4, "Reserved by Motorola" },
90 { 54, 0x0000D8, "Reserved by Motorola" },
91 { 55, 0x0000DC, "Reserved by Motorola" },
92 { 56, 0x0000E0, "Reserved by Motorola" },
93 { 57, 0x0000E4, "Reserved by Motorola" },
94 { 58, 0x0000E8, "Reserved by Motorola" },
95 { 59, 0x0000EC, "Reserved by Motorola" },
96 { 60, 0x0000F0, "Reserved by Motorola" },
97 { 61, 0x0000F4, "Reserved by Motorola" },
98 { 62, 0x0000F8, "Reserved by Motorola" },
99 { 63, 0x0000FC, "Reserved by Motorola" },
100 { 64, 0x000100, "User interrupt vectors" },
101 { 65, 0x000104, "User interrupt vectors" },
102 { 66, 0x000108, "User interrupt vectors" },
103 { 67, 0x00010C, "User interrupt vectors" },
104 { 68, 0x000200, "User interrupt vectors" },
105 { 69, 0x000204, "User interrupt vectors" },
106 { 70, 0x000208, "User interrupt vectors" },
107 { 71, 0x00020C, "User interrupt vectors" },
108 { 72, 0x000210, "User interrupt vectors" },
109 { 73, 0x000214, "User interrupt vectors" },
110 { 74, 0x000218, "User interrupt vectors" },
111 { 75, 0x00021C, "User interrupt vectors" },
112 { 252, 0x0003F0, "User interrupt vectors" },
113 { 253, 0x0003F4, "User interrupt vectors" },
114 { 254, 0x0003F8, "User interrupt vectors" },
115 { 255, 0x0003FC, "User interrupt vectors" }
116 };
117
118
119 //
120 ExceptionVectorTableBrowserWindow::ExceptionVectorTableBrowserWindow(QWidget * parent/*= 0*/): QWidget(parent, Qt::Dialog),
121 layout(new QVBoxLayout),
122 #ifdef EV_LAYOUTTEXTS
123 text(new QTextBrowser),
124 #else
125 TableView (new QTableView),
126 model (new QStandardItemModel),
127 #endif
128 refresh(new QPushButton(tr("Refresh")))
129 {
130 setWindowTitle(tr("Exception Vector Table"));
131
132 // Refresh feature
133 QHBoxLayout *hbox1 = new QHBoxLayout;
134 hbox1->addWidget(refresh);
135
136 // Setup font
137 QFont fixedFont("Lucida Console", 8, QFont::Normal);
138 fixedFont.setStyleHint(QFont::TypeWriter);
139
140 #ifdef EV_LAYOUTTEXTS
141 text->setFont(fixedFont);
142 layout->addWidget(text);
143 #else
144 // Set the new layout with proper identation and readibility
145 model->setColumnCount(3);
146 model->setHeaderData(0, Qt::Horizontal, QObject::tr("Vector"));
147 model->setHeaderData(1, Qt::Horizontal, QObject::tr("Pointer"));
148 model->setHeaderData(2, Qt::Horizontal, QObject::tr("Use"));
149 // Information table
150 TableView->setModel(model);
151 TableView->setEditTriggers(QAbstractItemView::NoEditTriggers);
152 TableView->setShowGrid(0);
153 TableView->setFont(fixedFont);
154 TableView->verticalHeader()->setDefaultSectionSize(TableView->verticalHeader()->minimumSectionSize());
155 TableView->verticalHeader()->setDefaultAlignment(Qt::AlignRight);
156 layout->addWidget(TableView);
157 #endif
158
159 layout->addWidget(refresh);
160 setLayout(layout);
161
162 // Event setup
163 connect(refresh, SIGNAL(clicked()), this, SLOT(RefreshContents()));
164 }
165
166
167 //
168 ExceptionVectorTableBrowserWindow::~ExceptionVectorTableBrowserWindow(void)
169 {
170 }
171
172
173 //
174 void ExceptionVectorTableBrowserWindow::RefreshContents(void)
175 {
176 char string[1024];
177 #ifdef EV_LAYOUTTEXTS
178 QString ExceptionVector;
179 #endif
180 size_t i;
181
182 if (isVisible())
183 {
184 #ifndef HA_LAYOUTTEXTS
185 model->setRowCount(0);
186 #endif
187 for (i = 0; i < (sizeof(TabExceptionVectorTable) / sizeof(ExceptionVectorTable)); i++)
188 {
189 #ifdef EV_LAYOUTTEXTS
190 if (i)
191 {
192 ExceptionVector += QString("<br>");
193 }
194 sprintf(string, "%03i : 0x%06X | 0x%06X | %s", (unsigned int)TabExceptionVectorTable[i].VectorNumber, (unsigned int)TabExceptionVectorTable[i].Address, GET32(jaguarMainRAM, TabExceptionVectorTable[i].Address), TabExceptionVectorTable[i].ExceptionName);
195 ExceptionVector += QString(string);
196 #else
197 model->insertRow(i);
198 model->setItem(i, 0, new QStandardItem(QString("0x%1").arg(TabExceptionVectorTable[i].Address, 4, 16, QChar('0'))));
199 sprintf(string, "0x%06x", (unsigned int)GET32(jaguarMainRAM, TabExceptionVectorTable[i].Address));
200 model->setItem(i, 1, new QStandardItem(QString("%1").arg(string)));
201 model->setItem(i, 2, new QStandardItem(QString("%1").arg(TabExceptionVectorTable[i].ExceptionName)));
202 #endif
203 }
204 #ifdef EV_LAYOUTTEXTS
205 text->clear();
206 text->setText(ExceptionVector);
207 #endif
208 }
209 }
210
211
212 //
213 void ExceptionVectorTableBrowserWindow::keyPressEvent(QKeyEvent * e)
214 {
215 if (e->key() == Qt::Key_Escape)
216 {
217 hide();
218 }
219 }