From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 9810 invoked by alias); 9 Oct 2009 03:01:37 -0000 Received: (qmail 9422 invoked by uid 22791); 9 Oct 2009 03:01:35 -0000 X-SWARE-Spam-Status: No, hits=-2.4 required=5.0 tests=AWL,BAYES_00,SPF_HELO_PASS,SPF_PASS X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 09 Oct 2009 03:01:30 +0000 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id n9931TP7008089 for ; Thu, 8 Oct 2009 23:01:29 -0400 Received: from [IPv6:::1] (ovpn01.gateway.prod.ext.phx2.redhat.com [10.5.9.1]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id n9931P1a024303 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Thu, 8 Oct 2009 23:01:28 -0400 Message-ID: <4ACEA785.3080305@redhat.com> Date: Fri, 09 Oct 2009 03:01:00 -0000 From: Keith Seitz User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.1) Gecko/20090814 Fedora/3.0-2.6.b3.fc11 Lightning/1.0pre Thunderbird/3.0b3 MIME-Version: 1.0 To: insight Subject: [PATCH] Fix "bad text index 4" error Content-Type: multipart/mixed; boundary="------------000905050402030506020001" X-IsSubscribed: yes Mailing-List: contact insight-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: insight-owner@sourceware.org X-SW-Source: 2009-q4/txt/msg00001.txt.bz2 This is a multi-part message in MIME format. --------------000905050402030506020001 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-length: 1311 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 * 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. --------------000905050402030506020001 Content-Type: text/plain; name="bad-text-index.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="bad-text-index.patch" Content-length: 2555 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] --------------000905050402030506020001--