Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [RFA] gdb_get_line_number on unknown tags
@ 2012-03-08 22:02 Keith Seitz
  2012-03-08 22:08 ` Tom Tromey
  0 siblings, 1 reply; 8+ messages in thread
From: Keith Seitz @ 2012-03-08 22:02 UTC (permalink / raw)
  To: gdb-patches@sourceware.org ml

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

Hi,

I noticed that two tests in the test suite attempt to set a breakpoint 
on line -1 of some source file. This is occurring because the two tests 
which do it are using gdb_get_line_number on a tag which is not defined 
in the source file. Consequently, gdb_get_line_number returns -1, and 
gdb_breakpoint does "break srcfile:-1", which currently defaults to line 1.

I think this ambiguity should be avoided in the test suite, and I submit 
the attached trivial patch to correct it.

Tested on x86_64-linux (Fedora 15) with no regressions.

Keith

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

	* gdb.ada/array_bounds.exp: Get breakpoint for line
	with "START", not "STOP".
	* gdb.python/py-infthread.exp: Do not continue to
	line marked "Break here.", which is undefined.

[-- Attachment #2: negative-bp.patch --]
[-- Type: text/x-patch, Size: 1039 bytes --]

diff --git a/gdb/testsuite/gdb.ada/array_bounds.exp b/gdb/testsuite/gdb.ada/array_bounds.exp
index a726e71..493c7c3 100644
--- a/gdb/testsuite/gdb.ada/array_bounds.exp
+++ b/gdb/testsuite/gdb.ada/array_bounds.exp
@@ -27,7 +27,7 @@ if {[gdb_compile_ada "${srcfile}" "${binfile}" executable [list debug ]] != "" }
 
 clean_restart ${testfile}
 
-set bp_location [gdb_get_line_number "STOP" ${testdir}/bar.adb]
+set bp_location [gdb_get_line_number "START" ${testdir}/bar.adb]
 if ![runto "bar.adb:$bp_location" ] then {
   perror "Couldn't run ${testfile}"
   return
diff --git a/gdb/testsuite/gdb.python/py-infthread.exp b/gdb/testsuite/gdb.python/py-infthread.exp
index 5fa508f..491cc41 100644
--- a/gdb/testsuite/gdb.python/py-infthread.exp
+++ b/gdb/testsuite/gdb.python/py-infthread.exp
@@ -37,8 +37,6 @@ if ![runto_main] then {
     return 0
 }
 
-runto [gdb_get_line_number "Break here."]
-
 # Test basic gdb.Inferior attributes and methods.
 
 gdb_py_test_silent_cmd "python t0 = gdb.selected_thread ()" "test gdb.selected_thread" 1

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [RFA] gdb_get_line_number on unknown tags
  2012-03-08 22:02 [RFA] gdb_get_line_number on unknown tags Keith Seitz
@ 2012-03-08 22:08 ` Tom Tromey
  2012-03-08 22:20   ` Keith Seitz
  2012-03-08 22:24   ` Joel Brobecker
  0 siblings, 2 replies; 8+ messages in thread
From: Tom Tromey @ 2012-03-08 22:08 UTC (permalink / raw)
  To: Keith Seitz; +Cc: gdb-patches@sourceware.org ml

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

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

Keith> 	* gdb.ada/array_bounds.exp: Get breakpoint for line
Keith> 	with "START", not "STOP".
Keith> 	* gdb.python/py-infthread.exp: Do not continue to
Keith> 	line marked "Break here.", which is undefined.

Ok.

Tom


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [RFA] gdb_get_line_number on unknown tags
  2012-03-08 22:08 ` Tom Tromey
@ 2012-03-08 22:20   ` Keith Seitz
  2012-03-08 22:24   ` Joel Brobecker
  1 sibling, 0 replies; 8+ messages in thread
From: Keith Seitz @ 2012-03-08 22:20 UTC (permalink / raw)
  To: Tom Tromey; +Cc: gdb-patches@sourceware.org ml

On 03/08/2012 02:08 PM, Tom Tromey 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.

According to gdb.exp, gdb_get_line_number is supposed to return -1, but 
I agree: I think gdb_get_line_number should throw an error. If you would 
like, I can work up a patch for that. Just ping my on IRC.

> Keith>  2012-03-08  Keith Seitz<keiths@redhat.com>
>
> Keith>  	* gdb.ada/array_bounds.exp: Get breakpoint for line
> Keith>  	with "START", not "STOP".
> Keith>  	* gdb.python/py-infthread.exp: Do not continue to
> Keith>  	line marked "Break here.", which is undefined.
>
> Ok.

Committed. Thank you!

Keith


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [RFA] gdb_get_line_number on unknown tags
  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
  1 sibling, 1 reply; 8+ messages in thread
From: Joel Brobecker @ 2012-03-08 22:24 UTC (permalink / raw)
  To: Tom Tromey; +Cc: Keith Seitz, gdb-patches@sourceware.org ml

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

> Keith> 2012-03-08  Keith Seitz  <keiths@redhat.com>
> 
> Keith> 	* gdb.ada/array_bounds.exp: Get breakpoint for line
> Keith> 	with "START", not "STOP".
> Keith> 	* gdb.python/py-infthread.exp: Do not continue to
> Keith> 	line marked "Break here.", which is undefined.

Thanks, Keith.

-- 
Joel


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [RFA] gdb_get_line_number on unknown tags
  2012-03-08 22:24   ` Joel Brobecker
@ 2012-03-08 23:15     ` Keith Seitz
  2012-03-08 23:30       ` Joel Brobecker
  0 siblings, 1 reply; 8+ messages in thread
From: Keith Seitz @ 2012-03-08 23:15 UTC (permalink / raw)
  To: Joel Brobecker; +Cc: Tom Tromey, gdb-patches@sourceware.org ml

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

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [RFA] gdb_get_line_number on unknown tags
  2012-03-08 23:15     ` Keith Seitz
@ 2012-03-08 23:30       ` Joel Brobecker
  2012-03-09  2:55         ` Tom Tromey
  0 siblings, 1 reply; 8+ messages in thread
From: Joel Brobecker @ 2012-03-08 23:30 UTC (permalink / raw)
  To: Keith Seitz; +Cc: Tom Tromey, gdb-patches@sourceware.org ml

> Well, we three agree, so here it is. It exposed buglets in three
> other tests (which appear to be copies of one common file).
[...]
> 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.

Nice! This looks good to me. But perhaps Tom, who know TCL way better
than I do (and most likely you do too), might want to comment too?

The changes in gdb.base can go in as obvious on their own in any case.

-- 
Joel


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [RFA] gdb_get_line_number on unknown tags
  2012-03-08 23:30       ` Joel Brobecker
@ 2012-03-09  2:55         ` Tom Tromey
  2012-03-09  4:39           ` Keith Seitz
  0 siblings, 1 reply; 8+ messages in thread
From: Tom Tromey @ 2012-03-09  2:55 UTC (permalink / raw)
  To: Joel Brobecker; +Cc: Keith Seitz, gdb-patches@sourceware.org ml

>>>>> "Joel" == Joel Brobecker <brobecker@adacore.com> writes:

Joel> Nice! This looks good to me. But perhaps Tom, who know TCL way better
Joel> than I do (and most likely you do too), might want to comment too?

It looks good to me.
Please check it in.

Tom


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [RFA] gdb_get_line_number on unknown tags
  2012-03-09  2:55         ` Tom Tromey
@ 2012-03-09  4:39           ` Keith Seitz
  0 siblings, 0 replies; 8+ messages in thread
From: Keith Seitz @ 2012-03-09  4:39 UTC (permalink / raw)
  To: gdb-patches@sourceware.org ml

On 03/08/2012 06:54 PM, Tom Tromey wrote:
>>>>>> "Joel" == Joel Brobecker<brobecker@adacore.com>  writes:
>
> Joel>  Nice! This looks good to me. But perhaps Tom, who know TCL way better
> Joel>  than I do (and most likely you do too), might want to comment too?
>
> It looks good to me.
> Please check it in.

Committed. Thank you both!

Keith


^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2012-03-09  4:39 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-03-08 22:02 [RFA] gdb_get_line_number on unknown tags 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
2012-03-08 23:30       ` Joel Brobecker
2012-03-09  2:55         ` Tom Tromey
2012-03-09  4:39           ` Keith Seitz

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox