* [PATCH] Fix "bad text index 4" error
@ 2009-10-09 3:01 Keith Seitz
0 siblings, 0 replies; only message in thread
From: Keith Seitz @ 2009-10-09 3:01 UTC (permalink / raw)
To: insight
[-- Attachment #1: Type: text/plain, Size: 1311 bytes --]
Hi,
After seeing this bug reported for /ages/, I think I finally developed a
reproducible test case or at least one of them.
I can reproduce this error by changing a previously executable line (at
which insight had a saved breakpoint) to a comment and recompiling. Now
the line was no longer executable, but we had a breakpoint in the
session that said that it was. That combined with a bogus text index
("4" is not a valid text widget index) caused the infamous "bad text
index '4'" error.
The solution is to search for the next nearest executable line, and use
that line number for subsequent deductions/operations/indices. This
appears to work on the test case that I developed.
Insight inserts the breakpoint at the next executable line it finds, and
when gdb actually breaks at the breakpoint, it and insight are in sync
as to where we stopped.
My hope is that this is the last of this accursed bug that I'll see, but
if you do see it again, and you can reproduce it, PLEASE let me know.
Keith
ChangeLog
2009-10-08 Keith Seitz <keiths@redhat.com>
* library/srctextwin.ith (ExecutableLineLimit): Define.
* library/srctextwin.itb (insertBreakTag): Search for next
executable line, just in case they changed.
When there are no tags on a line, the proper index is
line.4, not just 4.
[-- Attachment #2: bad-text-index.patch --]
[-- Type: text/plain, Size: 2555 bytes --]
Index: library/srctextwin.ith
===================================================================
RCS file: /cvs/src/src/gdb/gdbtk/library/srctextwin.ith,v
retrieving revision 1.14
diff -u -p -r1.14 srctextwin.ith
--- library/srctextwin.ith 23 Dec 2005 18:26:50 -0000 1.14
+++ library/srctextwin.ith 9 Oct 2009 02:51:11 -0000
@@ -1,5 +1,5 @@
# SrcTextWin class definition, for Insight
-# Copyright (C) 1997, 1998, 1999, 2001 Red Hat, Inc.
+# Copyright (C) 1997, 1998, 1999, 2001, 2009 Red Hat, Inc.
#
# This program is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License (GPL) as published by
@@ -160,4 +160,8 @@ itcl::class SrcTextWin {
protected common TimeOut 100 ;# The timeout value for variable balloon help
+ # Executabe line search limit: When an executable changes, we might
+ # have a breakpoint at a location that is no longer valid. This variable
+ # limits the search for the "nearest" (next) executable line.
+ protected common ExecutableLineLimit 100
}
Index: library/srctextwin.itb
===================================================================
RCS file: /cvs/src/src/gdb/gdbtk/library/srctextwin.itb,v
retrieving revision 1.44
diff -u -p -r1.44 srctextwin.itb
--- library/srctextwin.itb 16 Dec 2008 09:07:57 -0000 1.44
+++ library/srctextwin.itb 9 Oct 2009 02:51:11 -0000
@@ -1,5 +1,5 @@
# Paned text widget for source code, for Insight
-# Copyright (C) 1997, 1998, 1999, 2001, 2002, 2008 Red Hat, Inc.
+# Copyright (C) 1997, 1998, 1999, 2001, 2002, 2008, 2009 Red Hat, Inc.
#
# This program is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License (GPL) as published by
@@ -1362,6 +1362,14 @@ itcl::body SrcTextWin::insertBreakTag {w
# tag. We will query the length of the previous tag, so we don't have
# to hard code it here.
+ # Find the nearest executable line
+ for {set i 0} {$i < $ExecutableLineLimit} {incr i} {
+ if {[line_is_executable $win [expr {$linenum + $i}]]} {
+ incr linenum $i
+ break
+ }
+ }
+
set tag_list [$win tag names $linenum.0]
set img_name [string range $tag 0 [expr [string length $tag] - 5]]
@@ -1378,7 +1386,7 @@ itcl::body SrcTextWin::insertBreakTag {w
set other_tag [lindex $tag_list \
[lsearch -glob $tag_list {*[bt]p_tag}]]
if {$other_tag == ""} {
- set stop 4
+ set stop "$linenum.4"
} else {
set stop [lindex [$win tag nextrange $other_tag \
$linenum.0 "$linenum.0 lineend"] 1]
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2009-10-09 3:01 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-10-09 3:01 [PATCH] Fix "bad text index 4" error Keith Seitz
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).