This is the mail archive of the
insight@sources.redhat.com
mailing list for the Insight project.
PATCH : Ghost breakpoints
- From: elmer dot elmer at free dot fr
- To: insight at sources dot redhat dot com
- Date: Wed, 20 Apr 2005 16:16:35 +0200
- Subject: PATCH : Ghost breakpoints
Hi,
When restarting a debug session one the same application, Insight tries to
restore breakpoints from the last session.
It is a nice feature !!!
But it is a little brawback :
If you discover a bug, fix it, and then restart a debug session, line numbers in
your file may have changed !!
Insight records breakpoints as file:line
When you restart a new debug session, Insight tries to set breakpoints at the
previous location.
Generally, its works (your breakpoints are shifted up or down by few lines).
But if the file:line does not correspond any more to code (a comment for
example), gdb accepts to set the breakpoint (at the next code line), but
Insight keeps the old location ...
As result, the gdb breakpoint is effective, but Insight does not display it any
more in the source window (it can be seen in mixed or assembly mode).
Moreover it causes error when clicking on this breakpoint from the breakpoint
window.
The following patch ensures that a breakpoint is valid (on a real code line)
before restoring it ...
I'm sure there is better solution (try to record the content of a source line,
and then locate this line when restoring breakpoints, but it is much more
difficult)...
.../gdb/gdbtk/library/session.tcl
proc _recreate_bps {specs} {
! set invalid_breakpoints ""
foreach spec $specs {
lassign $spec create enabled condition commands
! # Check the breakpoint
! set gdb_pos ""
! #debug "$create"
! catch {set name_number [lindex [split $create] 1]}
! catch {set gdb_pos [gdb_cmd "info line $name_number"]}
! if {![string match "*starts at*" $gdb_pos]} {
! # breakpoint cannot be set
! #debug "cannot restore breakpoint at $name_number (file changed ?)"
! set invalid_breakpoints "$name_number \n $invalid_breakpoints"
! continue
! }
# Create the breakpoint
.................
! if {$invalid_breakpoints != ""} {
! tk_messageBox -type ok -icon warning -title "Breakpoints" \
! -message "cannot restore old breakpoints at:\n
$invalid_breakpoints"
! }
}
I you have a better idea...