Update the breakpoint feature
[clinton/Virtual-Jaguar-Rx.git] / src / debugger / NewFnctBreakpointWin.cpp
CommitLineData
1081a838
JPM
1//
2// NewFnctBreakpointsWin.cpp - New function breakpoint
3//
4// by Jean-Paul Mari
5//
6// JPM = Jean-Paul Mari <djipi.mari@gmail.com>
7//
8// Who When What
9// --- ---------- -----------------------------------------------------------
10// JPM 10/19/2018 Created this file
cbd79f66 11// JPM March/2021 Breakpoint list window refresh
1081a838
JPM
12//
13
14// STILL TO DO:
15// Set information (name, etc.) for the asm function
16// Find a way to refresh the breakpoints list window
17//
18
19#include "debugger/NewFnctBreakpointWin.h"
20#include "jaguar.h"
21#include "debugger/DBGManager.h"
22#include "m68000/m68kinterface.h"
23#include "settings.h"
24
25
26//
27NewFnctBreakpointWindow::NewFnctBreakpointWindow(QWidget * parent/*= 0*/): QWidget(parent, Qt::Dialog),
28layout(new QVBoxLayout),
29address(new QLineEdit),
30add(new QPushButton(tr("Add")))
31{
32 setWindowTitle(tr("New function breakpoint"));
33
34 address->setPlaceholderText("0x<value>, decimal value or symbol name");
35
36 QHBoxLayout * hbox1 = new QHBoxLayout;
37 hbox1->addWidget(address);
38 hbox1->addWidget(add);
39
40 layout->addLayout(hbox1);
41 setLayout(layout);
42
43 connect(add, SIGNAL(clicked()), this, SLOT(AddBreakpointAddress()));
cbd79f66 44 connect(address, SIGNAL(cursorPositionChanged(int, int)), this, SLOT(SelectBreakpointAddress()));
1081a838
JPM
45}
46
47
48//
49void NewFnctBreakpointWindow::keyPressEvent(QKeyEvent * e)
50{
51 if (e->key() == Qt::Key_Escape)
52 {
53 hide();
54 }
55 else
56 {
57 if (e->key() == Qt::Key_Return)
58 {
59 AddBreakpointAddress();
60 }
61 }
62}
63
64
cbd79f66
JPM
65//
66void NewFnctBreakpointWindow::SetFnctBreakpointWin(BreakpointsWindow* BpW)
67{
68 BPWin = BpW;
69}
70
71
72void NewFnctBreakpointWindow::SelectBreakpointAddress(void)
73{
74 address->setStyleSheet("color: black");
75}
76
77
1081a838
JPM
78// Add a breakpoint to the address
79// Address can be an hexa, decimal or a symbol name
80void NewFnctBreakpointWindow::AddBreakpointAddress(void)
81{
82 bool ok;
83 size_t len;
84 QString newAddress;
85 size_t adr;
86 S_BrkInfo Brk;
87
88 memset(&Brk, 0, sizeof(Brk));
1081a838
JPM
89 newAddress = address->text();
90
91 if ((len = newAddress.size()))
92 {
93 if ((len > 1) && (newAddress.at(0) == QChar('0')) && (newAddress.at(1) == QChar('x')))
94 {
95 adr = newAddress.toUInt(&ok, 16);
96 }
97 else
98 {
99 if (!(adr = DBGManager_GetAdrFromSymbolName(newAddress.toLatin1().data())))
100 {
101 adr = newAddress.toUInt(&ok, 10);
102 }
103 else
104 {
105 ok = true;
106 }
107 }
108
109 // Check validity address
110 if (ok && (adr < 0xffffff))
111 {
112 // Set information based on address
113 Brk.Name = DBGManager_GetSymbolNameFromAdr(adr);
009df4d7 114 Brk.Filename = DBGManager_GetFullSourceFilenameFromAdr(adr, NULL);
1081a838
JPM
115 Brk.NumLine = DBGManager_GetNumLineFromAdr(adr, DBG_TAG_subprogram);
116 Brk.LineSrc = DBGManager_GetLineSrcFromAdrNumLine(adr, Brk.NumLine);
117
118 // In all cases, consider address as valid
119 Brk.Adr = adr;
120
121 // Add the breakpoint
cbd79f66 122 if (!m68k_brk_add(&Brk))
1081a838 123 {
cbd79f66 124 address->setStyleSheet("color: green");
1081a838
JPM
125 }
126 else
127 {
cbd79f66 128 address->setText("");
1081a838
JPM
129 }
130 }
131 else
132 {
133 // Address is not valid
cbd79f66 134 address->setStyleSheet("color: red");
1081a838
JPM
135 }
136
cbd79f66
JPM
137 // update the breakpoint functions window
138 BPWin->RefreshContents();
1081a838
JPM
139 }
140}
cbd79f66
JPM
141
142
143//
144NewFnctBreakpointWindow::~NewFnctBreakpointWindow()
145{
146}