2 // NewFnctBreakpointsWin.cpp - New function breakpoint
6 // JPM = Jean-Paul Mari <djipi.mari@gmail.com>
9 // --- ---------- -----------------------------------------------------------
10 // JPM 10/19/2018 Created this file
14 // Set information (name, etc.) for the asm function
15 // Find a way to refresh the breakpoints list window
18 #include "debugger/NewFnctBreakpointWin.h"
20 #include "debugger/DBGManager.h"
21 #include "m68000/m68kinterface.h"
26 NewFnctBreakpointWindow::NewFnctBreakpointWindow(QWidget
* parent
/*= 0*/): QWidget(parent
, Qt::Dialog
),
27 layout(new QVBoxLayout
),
28 address(new QLineEdit
),
29 add(new QPushButton(tr("Add")))
31 setWindowTitle(tr("New function breakpoint"));
33 address
->setPlaceholderText("0x<value>, decimal value or symbol name");
35 QHBoxLayout
* hbox1
= new QHBoxLayout
;
36 hbox1
->addWidget(address
);
37 hbox1
->addWidget(add
);
39 layout
->addLayout(hbox1
);
42 connect(add
, SIGNAL(clicked()), this, SLOT(AddBreakpointAddress()));
47 void NewFnctBreakpointWindow::keyPressEvent(QKeyEvent
* e
)
49 if (e
->key() == Qt::Key_Escape
)
55 if (e
->key() == Qt::Key_Return
)
57 AddBreakpointAddress();
63 // Add a breakpoint to the address
64 // Address can be an hexa, decimal or a symbol name
65 void NewFnctBreakpointWindow::AddBreakpointAddress(void)
73 memset(&Brk
, 0, sizeof(Brk
));
74 QPalette p
= address
->palette();
75 newAddress
= address
->text();
77 if ((len
= newAddress
.size()))
79 if ((len
> 1) && (newAddress
.at(0) == QChar('0')) && (newAddress
.at(1) == QChar('x')))
81 adr
= newAddress
.toUInt(&ok
, 16);
85 if (!(adr
= DBGManager_GetAdrFromSymbolName(newAddress
.toLatin1().data())))
87 adr
= newAddress
.toUInt(&ok
, 10);
95 // Check validity address
96 if (ok
&& (adr
< 0xffffff))
98 // Set information based on address
99 Brk
.Name
= DBGManager_GetSymbolNameFromAdr(adr
);
100 Brk
.Filename
= DBGManager_GetFullSourceFilenameFromAdr(adr
, NULL
);
101 Brk
.NumLine
= DBGManager_GetNumLineFromAdr(adr
, DBG_TAG_subprogram
);
102 Brk
.LineSrc
= DBGManager_GetLineSrcFromAdrNumLine(adr
, Brk
.NumLine
);
104 // In all cases, consider address as valid
107 // Add the breakpoint
108 if (m68k_brk_add(&Brk
))
110 p
.setColor(QPalette::Text
, Qt::black
);
114 p
.setColor(QPalette::Text
, Qt::darkYellow
);
119 // Address is not valid
120 p
.setColor(QPalette::Text
, Qt::red
);
123 address
->setPalette(p
);