Skip to content

Commit 72ca40b

Browse files
ZofiaZementacyrus-and
authored andcommitted
Added support for catch breakpoints
fixes #269
1 parent 2b107b2 commit 72ca40b

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

.gdbinit

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -327,6 +327,7 @@ def format_value(value, compact=None):
327327
def fetch_breakpoints(watchpoints=False, pending=False):
328328
# fetch breakpoints addresses
329329
parsed_breakpoints = dict()
330+
catch_what_regex = re.compile(r'([^,]+".*")?[^,]*')
330331
for line in run('info breakpoints').split('\n'):
331332
# just keep numbered lines
332333
if not line or not line[0].isdigit():
@@ -342,7 +343,11 @@ def fetch_breakpoints(watchpoints=False, pending=False):
342343
address = None if is_multiple or is_pending else int(fields[4], 16)
343344
is_enabled = fields[3] == 'y'
344345
address_info = address, is_enabled
345-
parsed_breakpoints[number] = [address_info], is_pending
346+
parsed_breakpoints[number] = [address_info], is_pending, ''
347+
elif len(fields) >= 5 and fields[1] == 'catchpoint':
348+
# only take before comma, but ignore commas in quotes
349+
what = catch_what_regex.search(' '.join(fields[4:]))[0].strip()
350+
parsed_breakpoints[number] = [], False, what
346351
elif len(fields) >= 3 and number in parsed_breakpoints:
347352
# add this address to the list of multiple locations
348353
address = int(fields[2], 16)
@@ -351,7 +356,7 @@ def fetch_breakpoints(watchpoints=False, pending=False):
351356
parsed_breakpoints[number][0].append(address_info)
352357
else:
353358
# watchpoints
354-
parsed_breakpoints[number] = [], False
359+
parsed_breakpoints[number] = [], False, ''
355360
except ValueError:
356361
pass
357362
# fetch breakpoints from the API and complement with address and source
@@ -362,7 +367,7 @@ def fetch_breakpoints(watchpoints=False, pending=False):
362367
# skip internal breakpoints
363368
if gdb_breakpoint.number < 0:
364369
continue
365-
addresses, is_pending = parsed_breakpoints[gdb_breakpoint.number]
370+
addresses, is_pending, what = parsed_breakpoints[gdb_breakpoint.number]
366371
is_pending = getattr(gdb_breakpoint, 'pending', is_pending)
367372
if not pending and is_pending:
368373
continue
@@ -379,6 +384,7 @@ def fetch_breakpoints(watchpoints=False, pending=False):
379384
breakpoint['temporary'] = gdb_breakpoint.temporary
380385
breakpoint['hit_count'] = gdb_breakpoint.hit_count
381386
breakpoint['pending'] = is_pending
387+
breakpoint['what'] = what
382388
# add addresses and source information
383389
breakpoint['addresses'] = []
384390
for address, is_enabled in addresses:
@@ -2223,7 +2229,8 @@ class Breakpoints(Dashboard.Module):
22232229
gdb.BP_WATCHPOINT: 'watch',
22242230
gdb.BP_HARDWARE_WATCHPOINT: 'write watch',
22252231
gdb.BP_READ_WATCHPOINT: 'read watch',
2226-
gdb.BP_ACCESS_WATCHPOINT: 'access watch'
2232+
gdb.BP_ACCESS_WATCHPOINT: 'access watch',
2233+
gdb.BP_CATCHPOINT: 'catch'
22272234
}
22282235

22292236
def label(self):
@@ -2273,6 +2280,9 @@ class Breakpoints(Dashboard.Module):
22732280
# format user location
22742281
location = breakpoint['location']
22752282
line += ' for {}'.format(ansi(location, style))
2283+
elif breakpoint['type'] == gdb.BP_CATCHPOINT:
2284+
what = breakpoint['what']
2285+
line += ' {}'.format(ansi(what, style))
22762286
else:
22772287
# format user expression
22782288
expression = breakpoint['expression']

0 commit comments

Comments
 (0)