Skip to content

Commit b829676

Browse files
committed
Add remaining catchpoint types.
1 parent 899228f commit b829676

8 files changed

+187
-27
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
* Raise Logger or Tracker tab when new variable is added.
2222
* Implment gdb's "checkpoint" feature. As simple time-travel feature.
2323
* Add preliminary support for Undo's udb time-traveling debugger.
24+
* Add support for remaining Catchpoint types.
2425

2526
## [2.5] - 2024-12-24
2627
* Console now supports a subset of ANSI color codes.

src/SeerAdaExceptionsBrowserWidget.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ void SeerAdaExceptionsBrowserWidget::handleAddCatchpointToolButtonClicked () {
160160
QTreeWidgetItem* item = adaExceptionsTreeWidget->currentItem();
161161

162162
if (item != 0) {
163-
dlg.setNameText(item->text(0));
163+
dlg.setArguments(item->text(0));
164164
}
165165

166166
int ret = dlg.exec();

src/SeerCatchpointCreateDialog.cpp

Lines changed: 51 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ SeerCatchpointCreateDialog::SeerCatchpointCreateDialog (QWidget* parent) : QDial
88

99
// Setup the widgets
1010
setType("");
11-
setNameText("");
11+
setArguments("");
1212

1313
setTemporaryEnabled(false);
1414
setDisabledEnabled(false);
@@ -47,6 +47,21 @@ void SeerCatchpointCreateDialog::setType (const QString& text) {
4747
}else if (text == "handlers") {
4848
adaHandlersRadioButton->setChecked(true);
4949

50+
}else if (text == "signal") {
51+
signalRadioButton->setChecked(true);
52+
53+
}else if (text == "fork") {
54+
forkRadioButton->setChecked(true);
55+
56+
}else if (text == "vfork") {
57+
vforkRadioButton->setChecked(true);
58+
59+
}else if (text == "exec") {
60+
execRadioButton->setChecked(true);
61+
62+
}else if (text == "syscall") {
63+
syscallRadioButton->setChecked(true);
64+
5065
}else{
5166
throwRadioButton->setChecked(true);
5267
}
@@ -78,6 +93,21 @@ QString SeerCatchpointCreateDialog::typeText () const {
7893
}else if (adaHandlersRadioButton->isChecked()) {
7994
return "handlers";
8095

96+
}else if (signalRadioButton->isChecked()) {
97+
return "signal";
98+
99+
}else if (forkRadioButton->isChecked()) {
100+
return "fork";
101+
102+
}else if (vforkRadioButton->isChecked()) {
103+
return "vfork";
104+
105+
}else if (execRadioButton->isChecked()) {
106+
return "exec";
107+
108+
}else if (syscallRadioButton->isChecked()) {
109+
return "syscall";
110+
81111
}else{
82112
return "throw";
83113
}
@@ -91,12 +121,12 @@ void SeerCatchpointCreateDialog::setDisabledEnabled (bool flag) {
91121
disabledCheckBox->setChecked(flag);
92122
}
93123

94-
void SeerCatchpointCreateDialog::setNameText (const QString& text) {
95-
nameLineEdit->setText(text);
124+
void SeerCatchpointCreateDialog::setArguments (const QString& text) {
125+
argumentsLineEdit->setText(text);
96126
}
97127

98-
QString SeerCatchpointCreateDialog::nameText () const {
99-
return nameLineEdit->text();
128+
QString SeerCatchpointCreateDialog::arguments () const {
129+
return argumentsLineEdit->text();
100130
}
101131

102132
bool SeerCatchpointCreateDialog::temporaryEnabled () const {
@@ -124,28 +154,36 @@ QString SeerCatchpointCreateDialog::catchpointText () const {
124154

125155
}else if (typeText() == "exception") { // Handle Ada 'exception'.
126156

127-
if (nameText() != "") {
128-
catchpointParameters += " -e " + nameText();
157+
if (arguments() != "") {
158+
catchpointParameters += " -e " + arguments();
129159
}
130160

131161
}else if (typeText() == "handlers") { // Handle Ada 'handlers'.
132162

133-
if (nameText() != "") {
134-
catchpointParameters += " -e " + nameText();
163+
if (arguments() != "") {
164+
catchpointParameters += " -e " + arguments();
135165
}
136166

137167
}else if (typeText() == "load") { // Handle library 'load'. Must have a name.
138168

139-
catchpointParameters += " " + nameText();
169+
catchpointParameters += " " + arguments();
140170

141171
}else if (typeText() == "unload") { // Handle library 'unload'. Must have a name.
142172

143-
catchpointParameters += " " + nameText();
173+
catchpointParameters += " " + arguments();
174+
175+
}else if (typeText() == "signal") { // Handle library 'unload'. Must have a name.
176+
177+
catchpointParameters += " " + arguments();
178+
179+
}else if (typeText() == "syscall") { // Handle library 'unload'. Must have a name.
180+
181+
catchpointParameters += " " + arguments();
144182

145183
}else{ // C++ throw, rethrow, catch. These require '-r', but only if there is a name.
146184

147-
if (nameText() != "") {
148-
catchpointParameters += " -r " + nameText();
185+
if (arguments() != "") {
186+
catchpointParameters += " -r " + arguments();
149187
}
150188
}
151189

src/SeerCatchpointCreateDialog.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ class SeerCatchpointCreateDialog : public QDialog, protected Ui::SeerCatchpointC
2525
void setNameEnabled (bool flag);
2626
bool nameEnabled () const;
2727

28-
void setNameText (const QString& text);
29-
QString nameText () const;
28+
void setArguments (const QString& text);
29+
QString arguments () const;
3030

3131
QString catchpointText () const;
3232

src/SeerCatchpointCreateDialog.ui

Lines changed: 66 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
<rect>
77
<x>0</x>
88
<y>0</y>
9-
<width>538</width>
10-
<height>302</height>
9+
<width>543</width>
10+
<height>403</height>
1111
</rect>
1212
</property>
1313
<property name="windowTitle">
@@ -100,6 +100,56 @@
100100
</attribute>
101101
</widget>
102102
</item>
103+
<item row="3" column="0">
104+
<widget class="QRadioButton" name="signalRadioButton">
105+
<property name="text">
106+
<string>Catch on 'signal'</string>
107+
</property>
108+
<attribute name="buttonGroup">
109+
<string notr="true">typeButtonGroup</string>
110+
</attribute>
111+
</widget>
112+
</item>
113+
<item row="3" column="1">
114+
<widget class="QRadioButton" name="forkRadioButton">
115+
<property name="text">
116+
<string>Catch on 'fork'</string>
117+
</property>
118+
<attribute name="buttonGroup">
119+
<string notr="true">typeButtonGroup</string>
120+
</attribute>
121+
</widget>
122+
</item>
123+
<item row="3" column="2">
124+
<widget class="QRadioButton" name="execRadioButton">
125+
<property name="text">
126+
<string>Catch on 'exec'</string>
127+
</property>
128+
<attribute name="buttonGroup">
129+
<string notr="true">typeButtonGroup</string>
130+
</attribute>
131+
</widget>
132+
</item>
133+
<item row="4" column="0">
134+
<widget class="QRadioButton" name="syscallRadioButton">
135+
<property name="text">
136+
<string>Catch on 'syscall'</string>
137+
</property>
138+
<attribute name="buttonGroup">
139+
<string notr="true">typeButtonGroup</string>
140+
</attribute>
141+
</widget>
142+
</item>
143+
<item row="4" column="1">
144+
<widget class="QRadioButton" name="vforkRadioButton">
145+
<property name="text">
146+
<string>Catch on 'vfork'</string>
147+
</property>
148+
<attribute name="buttonGroup">
149+
<string notr="true">typeButtonGroup</string>
150+
</attribute>
151+
</widget>
152+
</item>
103153
</layout>
104154
</widget>
105155
</item>
@@ -147,16 +197,16 @@
147197
</layout>
148198
</item>
149199
<item row="1" column="0">
150-
<widget class="QLabel" name="nameLabel">
200+
<widget class="QLabel" name="argumentsLabel">
151201
<property name="text">
152-
<string>Name</string>
202+
<string>Arguments</string>
153203
</property>
154204
</widget>
155205
</item>
156206
<item row="1" column="1">
157-
<widget class="QLineEdit" name="nameLineEdit">
207+
<widget class="QLineEdit" name="argumentsLineEdit">
158208
<property name="placeholderText">
159-
<string>Exception/Library name as a regular expression.</string>
209+
<string>Optional arguments for selected Catchpoint type.</string>
160210
</property>
161211
<property name="clearButtonEnabled">
162212
<bool>true</bool>
@@ -187,9 +237,14 @@
187237
<tabstop>adaExceptionRadioButton</tabstop>
188238
<tabstop>catchRadioButton</tabstop>
189239
<tabstop>adaHandlersRadioButton</tabstop>
240+
<tabstop>signalRadioButton</tabstop>
241+
<tabstop>forkRadioButton</tabstop>
242+
<tabstop>execRadioButton</tabstop>
243+
<tabstop>syscallRadioButton</tabstop>
244+
<tabstop>vforkRadioButton</tabstop>
190245
<tabstop>temporaryCheckBox</tabstop>
191246
<tabstop>disabledCheckBox</tabstop>
192-
<tabstop>nameLineEdit</tabstop>
247+
<tabstop>argumentsLineEdit</tabstop>
193248
</tabstops>
194249
<resources/>
195250
<connections>
@@ -200,8 +255,8 @@
200255
<slot>accept()</slot>
201256
<hints>
202257
<hint type="sourcelabel">
203-
<x>248</x>
204-
<y>254</y>
258+
<x>257</x>
259+
<y>393</y>
205260
</hint>
206261
<hint type="destinationlabel">
207262
<x>157</x>
@@ -216,8 +271,8 @@
216271
<slot>reject()</slot>
217272
<hints>
218273
<hint type="sourcelabel">
219-
<x>316</x>
220-
<y>260</y>
274+
<x>325</x>
275+
<y>393</y>
221276
</hint>
222277
<hint type="destinationlabel">
223278
<x>286</x>

src/SeerCatchpointsBrowserWidget.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,17 @@ void SeerCatchpointsBrowserWidget::handleText (const QString& text) {
9696
// times="0"}
9797
// ]
9898
//
99+
// body=[
100+
// bkpt={number="2",
101+
// type="catchpoint",
102+
// disp="keep",
103+
// enabled="y",
104+
// what="<any signal>",
105+
// catch-type="signal",
106+
// thread-groups=["i1"],
107+
// times="1"}
108+
// ]
109+
//
99110

100111
QString newtext = Seer::filterEscapes(text); // Filter escaped characters.
101112

src/resource.qrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@
8484
<file>resources/mi-python/MISkip.py</file>
8585
<file>resources/mi-python/MIKill.py</file>
8686
<file>resources/mi-python/MICheckpoint.py</file>
87+
<file>resources/mi-python/MICatchpoint.py</file>
8788
</qresource>
8889
</RCC>
8990

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
#
2+
# Python MI command to manage gdb's "catchpoint" command..
3+
#
4+
# Gdb has most catchpoint MI commands, but are missing these:
5+
#
6+
# -catch-signal
7+
# -catch-fork
8+
# -catch-vfork
9+
# -catch-syscall
10+
# -catch-exec
11+
#
12+
13+
class MICatchpoint(gdb.MICommand):
14+
"""
15+
Run the 'catchpoint' command.
16+
17+
-catch-signal [signal... | ‘all’] The delivery of a signal.
18+
-catch-fork A call to fork.
19+
-catch-vfork A call to vfork.
20+
-catch-syscall [name | number | group:groupname | g:groupname] ... A call to or return from a system call, a.k.a. syscall.
21+
-catch-exec A call to exec.
22+
23+
See: https://sourceware.org/gdb/current/onlinedocs/gdb.html/Set-Catchpoints.html#Set-Catchpoints
24+
"""
25+
26+
def __init__(self, name, mode):
27+
self._mode = mode
28+
super(MICatchpoint, self).__init__(name)
29+
30+
def invoke(self, argv):
31+
if self._mode == "signal":
32+
gdb.execute ("catch signal " + " ".join(argv), to_string=True)
33+
return None
34+
elif self._mode == "fork":
35+
gdb.execute ("catch fork " + " ".join(argv), to_string=True)
36+
return None
37+
elif self._mode == "vfork":
38+
gdb.execute ("catch vfork " + " ".join(argv), to_string=True)
39+
return None
40+
elif self._mode == "syscall":
41+
gdb.execute ("catch syscall " + " ".join(argv), to_string=True)
42+
return None
43+
elif self._mode == "exec":
44+
gdb.execute ("catch exec " + " ".join(argv), to_string=True)
45+
return None
46+
else:
47+
raise gdb.GdbError("catchpoint: Invalid parameter: %s" % self._mode)
48+
49+
MICatchpoint("-catch-signal", "signal")
50+
MICatchpoint("-catch-fork", "fork")
51+
MICatchpoint("-catch-vfork", "vfork")
52+
MICatchpoint("-catch-syscall", "syscall")
53+
MICatchpoint("-catch-exec", "exec")
54+

0 commit comments

Comments
 (0)