This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [RFA] gdb_get_line_number on unknown tags


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.
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

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]