mirror of
https://github.com/tromey/gdb-gui.git
synced 2026-01-04 23:50:08 +01:00
try to update source window when breakpoints change
this is not tested yet
This commit is contained in:
57
gui/bpcache.py
Normal file
57
gui/bpcache.py
Normal file
@@ -0,0 +1,57 @@
|
||||
# Copyright (C) 2015 Tom Tromey <tom@trolley.com>
|
||||
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import gdb
|
||||
import gui.events
|
||||
import gui.adapt
|
||||
|
||||
# This maps from (FILENAME,LINE) to a set of breakpoints referencing
|
||||
# that file/line. Then we emit events when entries are created or
|
||||
# destroyed.
|
||||
breakpoint_source_map = {}
|
||||
|
||||
def _breakpoint_created(bp):
|
||||
if bp.location is None:
|
||||
return
|
||||
gui.adapt.notify_bug(18385)
|
||||
(rest, locs) = gdb.decode_line(bp.location)
|
||||
if rest is not None:
|
||||
# Let's assume we couldn't reparse for some reason.
|
||||
return
|
||||
for sal in locs:
|
||||
if sal.symtab is None:
|
||||
continue
|
||||
entry = (sal.symtab.fullname(), sal.line)
|
||||
if entry not in breakpoint_source_map:
|
||||
breakpoint_source_map[entry] = set()
|
||||
if bp.number not in breakpoint_source_map[entry]:
|
||||
breakpoint_source_map[entry].add(bp.number)
|
||||
gui.events.location_changed.post(entry, True)
|
||||
else:
|
||||
breakpoint_source_map[entry].add(bp.number)
|
||||
|
||||
def _breakpoint_deleted(bp):
|
||||
num = bp.number
|
||||
for entry in breakpoint_source_map:
|
||||
if num in breakpoint_source_map[entry]:
|
||||
breakpoint_source_map[entry].discard(bp.number)
|
||||
if len(breakpoint_source_map[entry]) == 0:
|
||||
gui.events.location_changed.post(entry, False)
|
||||
|
||||
if not hasattr(gdb.events, 'breakpoint_created'):
|
||||
gui.adapt.notify_bug(15620)
|
||||
else:
|
||||
gdb.events.breakpoint_created.connect(_breakpoint_created)
|
||||
gdb.events.breakpoint_deleted.connect(_breakpoint_deleted)
|
||||
Reference in New Issue
Block a user