Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Keith Seitz <keiths@redhat.com>
To: Joel Brobecker <brobecker@adacore.com>
Cc: Tom Tromey <tromey@redhat.com>,
	       "gdb-patches@sourceware.org ml"
	<gdb-patches@sourceware.org>
Subject: Re: [RFA] gdb_get_line_number on unknown tags
Date: Thu, 08 Mar 2012 23:15:00 -0000	[thread overview]
Message-ID: <4F593D51.6020105@redhat.com> (raw)
In-Reply-To: <20120308222412.GU2853@adacore.com>

[-- Attachment #1: Type: text/plain, Size: 768 bytes --]

On 03/08/2012 02:24 PM, Joel Brobecker wrote:
>>>>>>> "Keith" == Keith Seitz<keiths@redhat.com>  writes:
>>
>> Keith>  This is occurring because the two tests which do it are using
>> Keith>  gdb_get_line_number on a tag which is not defined in the source
>> Keith>  file.
>>
>> I wonder whether this should be an error.
>
> Seems like a good idea...

Well, we three agree, so here it is. It exposed buglets in three other 
tests (which appear to be copies of one common file).

Ok?

Keith

testsuite/ChangeLog
2012-03-08  Keith Seitz  <keiths@redhat.com>

	* lib/gdb.exp (gdb_get_line_number): Throw an
	error instead of returning -1.
	* gdb.base/break.exp: Remove unused variable
	bp_location5.
	* gdb.base/hbreak2.exp: Likewise.
	* gdb.base/sepdebug.exp: Likewise.

[-- Attachment #2: gdb_get_line_number-error.patch --]
[-- Type: text/x-patch, Size: 3376 bytes --]

Index: gdb.base/break.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.base/break.exp,v
retrieving revision 1.53
diff -u -p -r1.53 break.exp
--- gdb.base/break.exp	13 Feb 2012 18:09:59 -0000	1.53
+++ gdb.base/break.exp	8 Mar 2012 23:12:55 -0000
@@ -115,7 +115,6 @@ gdb_test "break multi_line_while_conditi
     "Breakpoint.*at.* file .*$srcfile, line $bp_location4\\." \
     "breakpoint at start of multi line while conditional"
 
-set bp_location5 [gdb_get_line_number "set breakpoint 5 here"]
 set bp_location6 [gdb_get_line_number "set breakpoint 6 here"]
 
 set main_line $bp_location6
Index: gdb.base/hbreak2.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.base/hbreak2.exp,v
retrieving revision 1.1
diff -u -p -r1.1 hbreak2.exp
--- gdb.base/hbreak2.exp	1 Mar 2012 21:01:11 -0000	1.1
+++ gdb.base/hbreak2.exp	8 Mar 2012 23:12:55 -0000
@@ -130,7 +130,6 @@ gdb_test "hbreak multi_line_while_condit
     "Hardware assisted breakpoint.*at.* file .*$srcfile, line $bp_location4\\." \
     "hardware breakpoint at start of multi line while conditional"
 
-set bp_location5 [gdb_get_line_number "set breakpoint 5 here"]
 set bp_location6 [gdb_get_line_number "set breakpoint 6 here"]
 
 set main_line $bp_location6
Index: gdb.base/sepdebug.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.base/sepdebug.exp,v
retrieving revision 1.38
diff -u -p -r1.38 sepdebug.exp
--- gdb.base/sepdebug.exp	21 Feb 2012 22:01:09 -0000	1.38
+++ gdb.base/sepdebug.exp	8 Mar 2012 23:12:55 -0000
@@ -150,7 +150,6 @@ gdb_test "break multi_line_while_conditi
     "Breakpoint.*at.* file .*$srcfile, line $bp_location4\\." \
     "breakpoint at start of multi line while conditional"
 
-set bp_location5 [gdb_get_line_number "set breakpoint 5 here"]
 set bp_location6 [gdb_get_line_number "set breakpoint 6 here"]
 
 set main_line $bp_location6
Index: lib/gdb.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/lib/gdb.exp,v
retrieving revision 1.202
diff -u -p -r1.202 gdb.exp
--- lib/gdb.exp	21 Feb 2012 22:01:10 -0000	1.202
+++ lib/gdb.exp	8 Mar 2012 23:12:56 -0000
@@ -3243,7 +3243,7 @@ proc setup_kfail_for_target { PR target 
 # gdb_get_line_number TEXT [FILE]
 #
 # Search the source file FILE, and return the line number of the
-# first line containing TEXT.  If no match is found, return -1.
+# first line containing TEXT.  If no match is found, an error is thrown.
 # 
 # TEXT is a string literal, not a regular expression.
 #
@@ -3316,15 +3316,13 @@ proc gdb_get_line_number { text { file "
     }
 
     if { [ catch { set fd [open "$file"] } message ] } then {
-	perror "$message"
-	return -1
+	error "$message"
     }
 
     set found -1
     for { set line 1 } { 1 } { incr line } {
 	if { [ catch { set nchar [gets "$fd" body] } message ] } then {
-	    perror "$message"
-	    return -1
+	    error "$message"
 	}
 	if { $nchar < 0 } then {
 	    break
@@ -3336,8 +3334,11 @@ proc gdb_get_line_number { text { file "
     }
 
     if { [ catch { close "$fd" } message ] } then {
-	perror "$message"
-	return -1
+	error "$message"
+    }
+
+    if {$found == -1} {
+        error "undefined tag \"$text\""
     }
 
     return $found

  reply	other threads:[~2012-03-08 23:15 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-03-08 22:02 Keith Seitz
2012-03-08 22:08 ` Tom Tromey
2012-03-08 22:20   ` Keith Seitz
2012-03-08 22:24   ` Joel Brobecker
2012-03-08 23:15     ` Keith Seitz [this message]
2012-03-08 23:30       ` Joel Brobecker
2012-03-09  2:55         ` Tom Tromey
2012-03-09  4:39           ` Keith Seitz

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4F593D51.6020105@redhat.com \
    --to=keiths@redhat.com \
    --cc=brobecker@adacore.com \
    --cc=gdb-patches@sourceware.org \
    --cc=tromey@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox