2 // NewFnctBreakpointsWin.cpp - New function breakpoint
6 // JPM = Jean-Paul Mari <djipi.mari@gmail.com>
9 // --- ---------- -----------------------------------------------------------
10 // JPM 10/19/2018 Created this file
11 // JPM March/2021 Breakpoint list window refresh
15 // Set information (name, etc.) for the asm function
16 // Find a way to refresh the breakpoints list window
19 #include "debugger/NewFnctBreakpointWin.h"
21 #include "debugger/DBGManager.h"
22 #include "m68000/m68kinterface.h"
27 NewFnctBreakpointWindow::NewFnctBreakpointWindow(QWidget
* parent
/*= 0*/): QWidget(parent
, Qt::Dialog
),
28 layout(new QVBoxLayout
),
29 address(new QLineEdit
),
30 add(new QPushButton(tr("Add")))
32 setWindowTitle(tr("New function breakpoint"));
34 address
->setPlaceholderText("0x<value>, decimal value or symbol name");
36 QHBoxLayout
* hbox1
= new QHBoxLayout
;
37 hbox1
->addWidget(address
);
38 hbox1
->addWidget(add
);
40 layout
->addLayout(hbox1
);
43 connect(add
, SIGNAL(clicked()), this, SLOT(AddBreakpointAddress()));
44 connect(address
, SIGNAL(cursorPositionChanged(int, int)), this, SLOT(SelectBreakpointAddress()));
49 void NewFnctBreakpointWindow::keyPressEvent(QKeyEvent
* e
)
51 if (e
->key() == Qt::Key_Escape
)
57 if (e
->key() == Qt::Key_Return
)
59 AddBreakpointAddress();
66 void NewFnctBreakpointWindow::SetFnctBreakpointWin(BreakpointsWindow
* BpW
)
72 void NewFnctBreakpointWindow::SelectBreakpointAddress(void)
74 address
->setStyleSheet("color: black");
78 // Add a breakpoint to the address
79 // Address can be an hexa, decimal or a symbol name
80 void NewFnctBreakpointWindow::AddBreakpointAddress(void)
88 memset(&Brk
, 0, sizeof(Brk
));
89 newAddress
= address
->text();
91 if ((len
= newAddress
.size()))
93 if ((len
> 1) && (newAddress
.at(0) == QChar('0')) && (newAddress
.at(1) == QChar('x')))
95 adr
= newAddress
.toUInt(&ok
, 16);
99 if (!(adr
= DBGManager_GetAdrFromSymbolName(newAddress
.toLatin1().data())))
101 adr
= newAddress
.toUInt(&ok
, 10);
109 // Check validity address
110 if (ok
&& (adr
< 0xffffff))
112 // Set information based on address
113 Brk
.Name
= DBGManager_GetSymbolNameFromAdr(adr
);
114 Brk
.Filename
= DBGManager_GetFullSourceFilenameFromAdr(adr
, NULL
);
115 Brk
.NumLine
= DBGManager_GetNumLineFromAdr(adr
, DBG_TAG_subprogram
);
116 Brk
.LineSrc
= DBGManager_GetLineSrcFromAdrNumLine(adr
, Brk
.NumLine
);
118 // In all cases, consider address as valid
121 // Add the breakpoint
122 if (!m68k_brk_add(&Brk
))
124 address
->setStyleSheet("color: green");
128 address
->setText("");
133 // Address is not valid
134 address
->setStyleSheet("color: red");
137 // update the breakpoint functions window
138 BPWin
->RefreshContents();
144 NewFnctBreakpointWindow::~NewFnctBreakpointWindow()