core: Fix libdwarf and Qt build failure
[clinton/Virtual-Jaguar-Rx.git] / src / debugger / BreakpointsWin.cpp
1 //
2 // BreakpointsWin.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 // JPM Oct./2018 Added the breakpoints features
12 //
13
14 // STILL TO DO:
15 //
16
17 #include "debugger/BreakpointsWin.h"
18 #include "jaguar.h"
19 #include "debugger/DBGManager.h"
20
21
22 //
23 BreakpointsWindow::BreakpointsWindow(QWidget * parent/*= 0*/) : QWidget(parent, Qt::Dialog),
24 TableView(new QTableView),
25 model(new QStandardItemModel),
26 #ifdef BRK_STATUSBAR
27 statusbar(new QStatusBar),
28 #endif
29 #ifdef BRK_REFRESHBUTTON
30 refresh(new QPushButton(tr("Refresh"))),
31 #endif
32 layout(new QVBoxLayout)
33 {
34 setWindowTitle(tr("Breakpoints"));
35
36 // Refresh feature
37 #ifdef BRK_REFRESH
38 QHBoxLayout *hbox1 = new QHBoxLayout;
39 hbox1->addWidget(refresh);
40 #endif
41
42 // Set the font
43 QFont fixedFont("Lucida Console", 8, QFont::Normal);
44 fixedFont.setStyleHint(QFont::TypeWriter);
45
46 // Set the new layout with proper identation and readibility
47 model->setColumnCount(3);
48 model->setHeaderData(0, Qt::Horizontal, QObject::tr("Status"));
49 model->setHeaderData(1, Qt::Horizontal, QObject::tr("Name"));
50 #ifdef BRK_HITCOUNTS
51 model->setHeaderData(2, Qt::Horizontal, QObject::tr("Hit Count"));
52 #endif
53 // Information table
54 TableView->setModel(model);
55 TableView->setEditTriggers(QAbstractItemView::NoEditTriggers);
56 TableView->setShowGrid(0);
57 TableView->setFont(fixedFont);
58 TableView->verticalHeader()->setDefaultSectionSize(TableView->verticalHeader()->minimumSectionSize());
59 TableView->verticalHeader()->setDefaultAlignment(Qt::AlignRight);
60 layout->addWidget(TableView);
61
62 // Status bar
63 #ifdef BRK_STATUSBAR
64 layout->addWidget(statusbar);
65 #endif
66 // Set layouts
67 #ifdef BRK_REFRESHBUTTON
68 layout->addLayout(hbox1);
69 #endif
70 setLayout(layout);
71 // Event setup
72 #ifdef BRK_REFRESHBUTTON
73 connect(refresh, SIGNAL(clicked()), this, SLOT(RefreshContents()));
74 #endif
75 }
76
77
78 //
79 BreakpointsWindow::~BreakpointsWindow(void)
80 {
81 }
82
83
84 //
85 void BreakpointsWindow::UpdateInfos(void)
86 {
87 char *FuncName;
88 bool ok;
89 char Addresse[100];
90
91 // Display the BPM as first breakpoint
92 model->setItem(0, 0, new QStandardItem(QString("%1").arg(bpmSaveActive ? "BPM On" : "BPM Off")));
93 if (bpmAddress1)
94 {
95 sprintf(Addresse, "0x%06X", bpmAddress1);
96 }
97 else
98 {
99 strcpy(Addresse, "(null)");
100 }
101 model->setItem(0, 1, new QStandardItem(QString("%1").arg((bpmAddress1 && (FuncName = DBGManager_GetSymbolNameFromAdr(bpmAddress1))) ? FuncName : Addresse)));
102 #ifdef BRK_HITCOUNTS
103 model->setItem(0, 2, new QStandardItem(QString("%1").arg(bpmHitCounts)));
104 #endif
105
106 // Display all user breakpoints
107 for (size_t i = 0; i < brkNbr; i++)
108 {
109 if (brkInfo[i].Used)
110 {
111 model->setItem((i + 1), 0, new QStandardItem(QString("%1").arg(brkInfo[i].Active ? "On" : "Off")));
112 sprintf(Addresse, "0x%06X", brkInfo[i].Adr);
113 model->setItem((i + 1), 1, new QStandardItem(QString("%1").arg((FuncName = brkInfo[i].Name) ? FuncName : Addresse)));
114 model->setItem((i + 1), 2, new QStandardItem(QString("%1").arg(brkInfo[i].HitCounts)));
115 }
116 }
117 }
118
119
120 //
121 void BreakpointsWindow::Reset(void)
122 {
123 UpdateTable(true);
124 }
125
126
127 //
128 void BreakpointsWindow::UpdateTable(bool refresh)
129 {
130 if (refresh)
131 {
132 model->setRowCount(0);
133 model->insertRow(brkNbr + 1);
134 }
135 }
136
137
138 //
139 void BreakpointsWindow::RefreshContents(void)
140 {
141 if (isVisible())
142 {
143 UpdateTable(true);
144 UpdateInfos();
145 }
146 }
147
148
149 //
150 void BreakpointsWindow::keyPressEvent(QKeyEvent * e)
151 {
152 if (e->key() == Qt::Key_Escape)
153 {
154 hide();
155 }
156 }
157