diff options
-rw-r--r-- | gdb/testsuite/ChangeLog | 6 | ||||
-rw-r--r-- | gdb/testsuite/gdb.base/fullname.c | 22 | ||||
-rw-r--r-- | gdb/testsuite/gdb.base/fullname.exp | 130 | ||||
-rw-r--r-- | gdb/testsuite/lib/gdb.exp | 26 |
4 files changed, 180 insertions, 4 deletions
diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog index 78454ce..e7aadde 100644 --- a/gdb/testsuite/ChangeLog +++ b/gdb/testsuite/ChangeLog @@ -1,3 +1,9 @@ +2008-05-04 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. + 2008-05-03 Pedro Alves <pedro@codesourcery.com> * gdb.base/macscp.exp, gdb.base/macscp1.c: Add test for printing diff --git a/gdb/testsuite/gdb.base/fullname.c b/gdb/testsuite/gdb.base/fullname.c new file mode 100644 index 0000000..5948bba --- /dev/null +++ b/gdb/testsuite/gdb.base/fullname.c @@ -0,0 +1,22 @@ +/* This testcase is part of GDB, the GNU debugger. + + Copyright 2008 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 3 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, see <http://www.gnu.org/licenses/>. */ + +int +main (int argc, char **argv) +{ + return 0; /* set breakpoint 1 here */ +} diff --git a/gdb/testsuite/gdb.base/fullname.exp b/gdb/testsuite/gdb.base/fullname.exp new file mode 100644 index 0000000..8467467 --- /dev/null +++ b/gdb/testsuite/gdb.base/fullname.exp @@ -0,0 +1,130 @@ +# Copyright 2008 +# 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 3 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, see <http://www.gnu.org/licenses/>. + +# 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 +} diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp index bb9bd24..99d69ab9 100644 --- a/gdb/testsuite/lib/gdb.exp +++ b/gdb/testsuite/lib/gdb.exp @@ -325,7 +325,8 @@ proc gdb_start_cmd {args} { } # Set a breakpoint at FUNCTION. If there is an additional argument it is -# a list of options; the supported options are allow-pending and temporary. +# a list of options; the supported options are allow-pending, temporary, +# and no-message. proc gdb_breakpoint { function args } { global gdb_prompt @@ -343,6 +344,11 @@ proc gdb_breakpoint { function args } { set break_message "Temporary breakpoint" } + set no_message 0 + if {[lsearch -exact [lindex $args 0] no-message] != -1} { + set no_message 1 + } + send_gdb "$break_command $function\n" # The first two regexps are what we get with -g, the third is without -g. gdb_expect 30 { @@ -351,7 +357,9 @@ proc gdb_breakpoint { function args } { -re "$break_message \[0-9\]* at .*$gdb_prompt $" {} -re "$break_message \[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 } } @@ -359,8 +367,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; } |