* [testsuite] Add test for setting breakpoints by full path
@ 2004-09-20 0:12 Daniel Jacobowitz
2004-09-20 0:18 ` Daniel Jacobowitz
2004-09-22 20:07 ` Michael Chastain
0 siblings, 2 replies; 4+ messages in thread
From: Daniel Jacobowitz @ 2004-09-20 0:12 UTC (permalink / raw)
To: gdb-patches
This patch adds a test for a bug I found in using the full pathname to a
file to set breakpoints. I'll send along an analysis of the bug with the
patch, in my next message.
I needed to generate unique failure messages for failures that occur in
gdb_breakpoint, so I added an option to suppress its automatic "fail"
case.
This test script depends on how the executable is compiled. Therefore,
it returns "untested" if the host is remote. It copies its source file
into the build directory, and compiles it using:
- an absolute pathname
- a relative pathname to the directory GDB is run in
- a relative pathname from a different directory
The last fails before symbols are loaded, without the patch I'll post.
Test OK?
--
Daniel Jacobowitz
2004-09-19 Daniel Jacobowitz <dan@debian.org>
* gdb.base/fullname.c: New file.
* gdb.base/fullname.exp: New file.
* lib/gdb.exp (gdb_breakpoint): Support no-message option.
Index: testsuite/gdb.base/fullname.c
===================================================================
RCS file: testsuite/gdb.base/fullname.c
diff -N testsuite/gdb.base/fullname.c
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ testsuite/gdb.base/fullname.c 20 Sep 2004 00:07:12 -0000
@@ -0,0 +1,25 @@
+/* This testcase is part of GDB, the GNU debugger.
+
+ Copyright 2004 Free Software Foundation, Inc.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+ USA. */
+
+int
+main (int argc, char **argv, char **envp)
+{
+ printf ("%d\n", 4); /* set breakpoint 1 here */
+ return 0;
+}
Index: testsuite/gdb.base/fullname.exp
===================================================================
RCS file: testsuite/gdb.base/fullname.exp
diff -N testsuite/gdb.base/fullname.exp
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ testsuite/gdb.base/fullname.exp 20 Sep 2004 00:07:12 -0000
@@ -0,0 +1,130 @@
+# Copyright 2004
+# Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+# This file tests setting breakpoints according to the full path of a
+# source file.
+
+set testfile "fullname"
+set srcfile ${testfile}.c
+set binfile ${objdir}/${subdir}/${testfile}
+
+# We rely on being able to copy things around.
+
+if { [is_remote host] } {
+ untested "setting breakpoints by full path"
+ return -1
+}
+
+# Create a temporary file in the build directory. Use a different
+# filename in case ${srcdir} == ${objdir}.
+file copy -force ${srcdir}/${subdir}/${srcfile} ${objdir}/${subdir}/tmp-${srcfile}
+
+# Build the test executable using an absolute path.
+if { [gdb_compile "${objdir}/${subdir}/tmp-${srcfile}" "${binfile}" executable {debug}] != "" } {
+ return -1
+}
+
+# Unlike most GDB tests, we do not use gdb_reinitialize_dir in this script.
+# We're testing GDB's ability to find files in other ways.
+
+# Get the line number.
+
+gdb_exit
+gdb_start
+gdb_load ${binfile}
+
+set line [gdb_get_line_number "set breakpoint 1 here"]
+
+# Reinitialize GDB to make sure symbols aren't loaded.
+
+gdb_exit
+gdb_start
+gdb_load ${binfile}
+
+set msg "set breakpoint by full path before loading symbols - built absolute"
+if { [gdb_breakpoint ${objdir}/${subdir}/tmp-${srcfile}:${line} {no-message}] != 0 } {
+ pass $msg
+} else {
+ fail $msg
+}
+
+gdb_test "break main" \
+ "Breakpoint.*at.*line.*" "set breakpoint at main - built absolute"
+
+set msg "set breakpoint by full path after loading symbols - built absolute"
+if { [gdb_breakpoint ${objdir}/${subdir}/tmp-${srcfile}:${line} {no-message}] != 0 } {
+ pass $msg
+} else {
+ fail $msg
+}
+
+# Build the test executable using a relative path.
+if { [gdb_compile "${subdir}/tmp-${srcfile}" "${binfile}" executable {debug}] != "" } {
+ return -1
+}
+
+gdb_exit
+gdb_start
+gdb_load ${binfile}
+
+set msg "set breakpoint by full path before loading symbols - built relative"
+if { [gdb_breakpoint ${objdir}/${subdir}/tmp-${srcfile}:${line} {no-message}] != 0 } {
+ pass $msg
+} else {
+ fail $msg
+}
+
+gdb_test "break main" \
+ "Breakpoint.*at.*line.*" "set breakpoint at main - built relative"
+
+set msg "set breakpoint by full path after loading symbols - built relative"
+if { [gdb_breakpoint ${objdir}/${subdir}/tmp-${srcfile}:${line} {no-message}] != 0 } {
+ pass $msg
+} else {
+ fail $msg
+}
+
+# Build the test executable using relative paths not relative to the directory
+# we'll run GDB from.
+
+set save_pwd [pwd]
+cd ${subdir}
+if { [gdb_compile "tmp-${srcfile}" "${testfile}" executable {debug}] != "" } {
+ return -1
+}
+cd $save_pwd
+
+gdb_exit
+gdb_start
+gdb_load ${binfile}
+
+set msg "set breakpoint by full path before loading symbols - built other"
+if { [gdb_breakpoint ${objdir}/${subdir}/tmp-${srcfile}:${line} {no-message}] != 0 } {
+ pass $msg
+} else {
+ fail $msg
+}
+
+gdb_test "break main" \
+ "Breakpoint.*at.*line.*" "set breakpoint at main - built other"
+
+set msg "set breakpoint by full path after loading symbols - built other"
+if { [gdb_breakpoint ${objdir}/${subdir}/tmp-${srcfile}:${line} {no-message}] != 0 } {
+ pass $msg
+} else {
+ fail $msg
+}
Index: testsuite/lib/gdb.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/lib/gdb.exp,v
retrieving revision 1.58
diff -u -p -r1.58 gdb.exp
--- testsuite/lib/gdb.exp 10 Sep 2004 01:04:59 -0000 1.58
+++ testsuite/lib/gdb.exp 20 Sep 2004 00:07:13 -0000
@@ -263,7 +263,8 @@ proc gdb_run_cmd {args} {
}
# Set a breakpoint at FUNCTION. If there is an additional argument it is
-# a list of options; the only currently supported option is allow-pending.
+# a list of options; the only currently supported options are
+# allow-pending and no-message.
proc gdb_breakpoint { function args } {
global gdb_prompt
@@ -274,6 +275,11 @@ proc gdb_breakpoint { function args } {
set pending_response y
}
+ set no_message 0
+ if {[lsearch -exact [lindex $args 0] no-message] != -1} {
+ set no_message 1
+ }
+
send_gdb "break $function\n"
# The first two regexps are what we get with -g, the third is without -g.
gdb_expect 30 {
@@ -282,7 +288,9 @@ proc gdb_breakpoint { function args } {
-re "Breakpoint \[0-9\]* at .*$gdb_prompt $" {}
-re "Breakpoint \[0-9\]* \\(.*\\) pending.*$gdb_prompt $" {
if {$pending_response == "n"} {
- fail "setting breakpoint at $function"
+ if { $no_message == 0 } {
+ fail "setting breakpoint at $function"
+ }
return 0
}
}
@@ -290,8 +298,18 @@ proc gdb_breakpoint { function args } {
send_gdb "$pending_response\n"
exp_continue
}
- -re "$gdb_prompt $" { fail "setting breakpoint at $function" ; return 0 }
- timeout { fail "setting breakpoint at $function (timeout)" ; return 0 }
+ -re "$gdb_prompt $" {
+ if { $no_message == 0 } {
+ fail "setting breakpoint at $function"
+ }
+ return 0
+ }
+ timeout {
+ if { $no_message == 0 } {
+ fail "setting breakpoint at $function (timeout)"
+ }
+ return 0
+ }
}
return 1;
}
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [testsuite] Add test for setting breakpoints by full path
2004-09-20 0:12 [testsuite] Add test for setting breakpoints by full path Daniel Jacobowitz
@ 2004-09-20 0:18 ` Daniel Jacobowitz
2004-09-22 20:07 ` Michael Chastain
1 sibling, 0 replies; 4+ messages in thread
From: Daniel Jacobowitz @ 2004-09-20 0:18 UTC (permalink / raw)
To: gdb-patches
On Sun, Sep 19, 2004 at 08:11:59PM -0400, Daniel Jacobowitz wrote:
> This patch adds a test for a bug I found in using the full pathname to a
> file to set breakpoints. I'll send along an analysis of the bug with the
> patch, in my next message.
>
> I needed to generate unique failure messages for failures that occur in
> gdb_breakpoint, so I added an option to suppress its automatic "fail"
> case.
>
> This test script depends on how the executable is compiled. Therefore,
> it returns "untested" if the host is remote. It copies its source file
> into the build directory, and compiles it using:
> - an absolute pathname
> - a relative pathname to the directory GDB is run in
> - a relative pathname from a different directory
>
> The last fails before symbols are loaded, without the patch I'll post.
>
> Test OK?
Bad Dan!
Tested by running the testsuite on i386-pc-linux-gnu, no regressions.
One failure without the corresponding patch to symtab.c. OK?
--
Daniel Jacobowitz
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [testsuite] Add test for setting breakpoints by full path
2004-09-20 0:12 [testsuite] Add test for setting breakpoints by full path Daniel Jacobowitz
2004-09-20 0:18 ` Daniel Jacobowitz
@ 2004-09-22 20:07 ` Michael Chastain
2004-10-04 22:00 ` Daniel Jacobowitz
1 sibling, 1 reply; 4+ messages in thread
From: Michael Chastain @ 2004-09-22 20:07 UTC (permalink / raw)
To: gdb-patches, drow
[I'm back ... hello mailbox backlog!]
Pretty good, but I see some nits:
. fullname.c needs to #include <stdio.h> to avoid a warning with
gcc 4.0.0 about implicit internal function on printf.
. test the return value on "file copy -force ..."
. In the call to gdb_get_line_number, it's not necessary to call
gdb_exit / gdb_start / gdb_load before and after the call to
gdb_get_line_number. The new gdb_get_line_number is pure TCL
code that greps the file without talking to gdb, so you don't
have to initialize gdb before using it.
. In gdb_breakpoint, only allow-pending or no-message can be used,
but not both, because both tests use [lindex $args 0]. Either
document this bit of cheesiness and leave it for the future to fix,
or get in and fix the TCL.
Michael
2004-09-19 Daniel Jacobowitz <dan@debian.org>
* gdb.base/fullname.c: New file.
* gdb.base/fullname.exp: New file.
* lib/gdb.exp (gdb_breakpoint): Support no-message option.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [testsuite] Add test for setting breakpoints by full path
2004-09-22 20:07 ` Michael Chastain
@ 2004-10-04 22:00 ` Daniel Jacobowitz
0 siblings, 0 replies; 4+ messages in thread
From: Daniel Jacobowitz @ 2004-10-04 22:00 UTC (permalink / raw)
To: Michael Chastain; +Cc: gdb-patches
On Wed, Sep 22, 2004 at 04:07:27PM -0400, Michael Chastain wrote:
> [I'm back ... hello mailbox backlog!]
>
> Pretty good, but I see some nits:
>
> . fullname.c needs to #include <stdio.h> to avoid a warning with
> gcc 4.0.0 about implicit internal function on printf.
OK.
> . test the return value on "file copy -force ..."
It doesn't have one. One can "catch" it though.
> . In the call to gdb_get_line_number, it's not necessary to call
> gdb_exit / gdb_start / gdb_load before and after the call to
> gdb_get_line_number. The new gdb_get_line_number is pure TCL
> code that greps the file without talking to gdb, so you don't
> have to initialize gdb before using it.
Cool.
> . In gdb_breakpoint, only allow-pending or no-message can be used,
> but not both, because both tests use [lindex $args 0]. Either
> document this bit of cheesiness and leave it for the future to fix,
> or get in and fix the TCL.
That's not true; args would be { { allow-pending no-message } }.
[lindex $args 0] is a list (makes sense - we pass it to lsearch).
"args" is magic in TCL; it's like "..." in C.
All of the above corrected; retested on i686-pc-linux-gnu using both
gdb and gdbserver. OK?
--
Daniel Jacobowitz
2004-09-19 Daniel Jacobowitz <dan@debian.org>
* gdb.base/fullname.c: New file.
* gdb.base/fullname.exp: New file.
* lib/gdb.exp (gdb_breakpoint): Support no-message option.
Index: testsuite/gdb.base/fullname.c
===================================================================
RCS file: testsuite/gdb.base/fullname.c
diff -N testsuite/gdb.base/fullname.c
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ testsuite/gdb.base/fullname.c 20 Sep 2004 00:07:12 -0000
@@ -0,0 +1,27 @@
+/* This testcase is part of GDB, the GNU debugger.
+
+ Copyright 2004 Free Software Foundation, Inc.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+ USA. */
+
+#include <stdio.h>
+
+int
+main (int argc, char **argv, char **envp)
+{
+ printf ("%d\n", 4); /* set breakpoint 1 here */
+ return 0;
+}
Index: testsuite/gdb.base/fullname.exp
===================================================================
RCS file: testsuite/gdb.base/fullname.exp
diff -N testsuite/gdb.base/fullname.exp
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ testsuite/gdb.base/fullname.exp 20 Sep 2004 00:07:12 -0000
@@ -0,0 +1,131 @@
+# Copyright 2004
+# Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+# This file tests setting breakpoints according to the full path of a
+# source file.
+
+set testfile "fullname"
+set srcfile ${testfile}.c
+set binfile ${objdir}/${subdir}/${testfile}
+
+# We rely on being able to copy things around.
+
+if { [is_remote host] } {
+ untested "setting breakpoints by full path"
+ return -1
+}
+
+# Create a temporary file in the build directory. Use a different
+# filename in case ${srcdir} == ${objdir}.
+if { [catch {file copy -force ${srcdir}/${subdir}/${srcfile} \
+ ${objdir}/${subdir}/tmp-${srcfile}}] != 0 } {
+ error "Could not create temporary file"
+ return -1
+}
+
+# Build the test executable using an absolute path.
+if { [gdb_compile "${objdir}/${subdir}/tmp-${srcfile}" "${binfile}" executable {debug}] != "" } {
+ return -1
+}
+
+# Unlike most GDB tests, we do not use gdb_reinitialize_dir in this script.
+# We're testing GDB's ability to find files in other ways.
+
+# Get the line number.
+
+set line [gdb_get_line_number "set breakpoint 1 here"]
+
+# Initialize GDB after getting the line number, to make sure
+# symbols aren't loaded.
+
+gdb_exit
+gdb_start
+gdb_load ${binfile}
+
+set msg "set breakpoint by full path before loading symbols - built absolute"
+if { [gdb_breakpoint ${objdir}/${subdir}/tmp-${srcfile}:${line} {no-message}] != 0 } {
+ pass $msg
+} else {
+ fail $msg
+}
+
+gdb_test "break main" \
+ "Breakpoint.*at.*line.*" "set breakpoint at main - built absolute"
+
+set msg "set breakpoint by full path after loading symbols - built absolute"
+if { [gdb_breakpoint ${objdir}/${subdir}/tmp-${srcfile}:${line} {no-message}] != 0 } {
+ pass $msg
+} else {
+ fail $msg
+}
+
+# Build the test executable using a relative path.
+if { [gdb_compile "${subdir}/tmp-${srcfile}" "${binfile}" executable {debug}] != "" } {
+ return -1
+}
+
+gdb_exit
+gdb_start
+gdb_load ${binfile}
+
+set msg "set breakpoint by full path before loading symbols - built relative"
+if { [gdb_breakpoint ${objdir}/${subdir}/tmp-${srcfile}:${line} {no-message}] != 0 } {
+ pass $msg
+} else {
+ fail $msg
+}
+
+gdb_test "break main" \
+ "Breakpoint.*at.*line.*" "set breakpoint at main - built relative"
+
+set msg "set breakpoint by full path after loading symbols - built relative"
+if { [gdb_breakpoint ${objdir}/${subdir}/tmp-${srcfile}:${line} {no-message}] != 0 } {
+ pass $msg
+} else {
+ fail $msg
+}
+
+# Build the test executable using relative paths not relative to the directory
+# we'll run GDB from.
+
+set save_pwd [pwd]
+cd ${subdir}
+if { [gdb_compile "tmp-${srcfile}" "${testfile}" executable {debug}] != "" } {
+ return -1
+}
+cd $save_pwd
+
+gdb_exit
+gdb_start
+gdb_load ${binfile}
+
+set msg "set breakpoint by full path before loading symbols - built other"
+if { [gdb_breakpoint ${objdir}/${subdir}/tmp-${srcfile}:${line} {no-message}] != 0 } {
+ pass $msg
+} else {
+ fail $msg
+}
+
+gdb_test "break main" \
+ "Breakpoint.*at.*line.*" "set breakpoint at main - built other"
+
+set msg "set breakpoint by full path after loading symbols - built other"
+if { [gdb_breakpoint ${objdir}/${subdir}/tmp-${srcfile}:${line} {no-message}] != 0 } {
+ pass $msg
+} else {
+ fail $msg
+}
Index: testsuite/lib/gdb.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/lib/gdb.exp,v
retrieving revision 1.58
diff -u -p -r1.58 gdb.exp
--- testsuite/lib/gdb.exp 10 Sep 2004 01:04:59 -0000 1.58
+++ testsuite/lib/gdb.exp 20 Sep 2004 00:07:13 -0000
@@ -263,7 +263,8 @@ proc gdb_run_cmd {args} {
}
# Set a breakpoint at FUNCTION. If there is an additional argument it is
-# a list of options; the only currently supported option is allow-pending.
+# a list of options; the only currently supported options are
+# allow-pending and no-message.
proc gdb_breakpoint { function args } {
global gdb_prompt
@@ -274,6 +275,11 @@ proc gdb_breakpoint { function args } {
set pending_response y
}
+ set no_message 0
+ if {[lsearch -exact [lindex $args 0] no-message] != -1} {
+ set no_message 1
+ }
+
send_gdb "break $function\n"
# The first two regexps are what we get with -g, the third is without -g.
gdb_expect 30 {
@@ -282,7 +288,9 @@ proc gdb_breakpoint { function args } {
-re "Breakpoint \[0-9\]* at .*$gdb_prompt $" {}
-re "Breakpoint \[0-9\]* \\(.*\\) pending.*$gdb_prompt $" {
if {$pending_response == "n"} {
- fail "setting breakpoint at $function"
+ if { $no_message == 0 } {
+ fail "setting breakpoint at $function"
+ }
return 0
}
}
@@ -290,8 +298,18 @@ proc gdb_breakpoint { function args } {
send_gdb "$pending_response\n"
exp_continue
}
- -re "$gdb_prompt $" { fail "setting breakpoint at $function" ; return 0 }
- timeout { fail "setting breakpoint at $function (timeout)" ; return 0 }
+ -re "$gdb_prompt $" {
+ if { $no_message == 0 } {
+ fail "setting breakpoint at $function"
+ }
+ return 0
+ }
+ timeout {
+ if { $no_message == 0 } {
+ fail "setting breakpoint at $function (timeout)"
+ }
+ return 0
+ }
}
return 1;
}
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2004-10-04 22:00 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-09-20 0:12 [testsuite] Add test for setting breakpoints by full path Daniel Jacobowitz
2004-09-20 0:18 ` Daniel Jacobowitz
2004-09-22 20:07 ` Michael Chastain
2004-10-04 22:00 ` Daniel Jacobowitz
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox