diff options
Diffstat (limited to 'gdb/testsuite')
-rw-r--r-- | gdb/testsuite/ChangeLog | 6 | ||||
-rw-r--r-- | gdb/testsuite/gdb.base/break-fun-addr.exp | 84 | ||||
-rw-r--r-- | gdb/testsuite/gdb.base/break-fun-addr1.c | 22 | ||||
-rw-r--r-- | gdb/testsuite/gdb.base/break-fun-addr2.c | 28 |
4 files changed, 140 insertions, 0 deletions
diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog index 7e6da03..3088320 100644 --- a/gdb/testsuite/ChangeLog +++ b/gdb/testsuite/ChangeLog @@ -1,3 +1,9 @@ +2016-01-21 Joel Brobecker <brobecker@adacore.com> + + * gdb.base/break-fun-addr.exp: New file. + * gdb.base/break-fun-addr1.c: New file. + * gdb.base/break-fun-addr2.c: New file. + 2016-01-20 Simon Marchi <simon.marchi@polymtl.ca> * gdb.python/py-pp-maint.exp: Change/add enum flag tests. diff --git a/gdb/testsuite/gdb.base/break-fun-addr.exp b/gdb/testsuite/gdb.base/break-fun-addr.exp new file mode 100644 index 0000000..e8bed3f --- /dev/null +++ b/gdb/testsuite/gdb.base/break-fun-addr.exp @@ -0,0 +1,84 @@ +# Copyright 2016 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/>. + +# The purpose of this testcase is to verify that, when using a breakpoint +# location of the form "*<EXPR>" (Eg: "*main"), GDB is able to start +# the program and stop at the correct location. With programs built +# as PIE, this means that GDB needs to re-evaluate the location once +# the program as started, since PIE ensures that the address of all +# symbols have changed after load. +# +# PIE is not always supported by the target system, so instead of +# creating a testcase building executables with PIE, this testcase +# takes a slightly different approach. It builds a first program, +# breaks on *main, and then runs to that breakpoint. It then builds +# a second program, different from the first one, and loads that +# executable within the same GDB session. Similarly to the PIE case, +# the address of main should be different, and therefore GDB should +# recalculate it. We verify that by checking that running to that +# breakpoint still works, and that we land at the first instruction +# of that function in both cases. + +set testfile1 "break-fun-addr1" +set srcfile1 ${testfile1}.c +set binfile1 [standard_output_file ${testfile1}] + +if { [gdb_compile "${srcdir}/${subdir}/${srcfile1}" "${binfile1}" executable {debug}] != "" } { + untested "Couldn't compile ${srcfile1}" + return -1 +} + +# Start the debugger with the first executable, put a breakpoint +# on the first instruction of function "main" ("*main"), then +# run to that breakpoint. + +clean_restart ${binfile1} + +with_test_prefix "${binfile1}" { + + gdb_test "break *main" \ + "Breakpoint.*at.* file .*$srcfile1, line .*" \ + + gdb_run_cmd + gdb_test "" \ + "Breakpoint.* main \\(\\) at .*$srcfile1:.*" \ + "run to breakpoint at *main" + + # Verify also that we stopped at the start of the function... + gdb_test "p \$pc == main" " = 1" +} + +set testfile2 "break-fun-addr2" +set srcfile2 ${testfile2}.c +set binfile2 [standard_output_file ${testfile2}] + +if { [gdb_compile "${srcdir}/${subdir}/${srcfile2}" "${binfile2}" executable {debug}] != "" } { + untested "Couldn't compile ${srcfile2}" + return -1 +} + +# Now, keeping the same GDB process (so as to keep the same breakpoint), +# start a new debugging session with a different executable. +gdb_load ${binfile2} + +with_test_prefix "${binfile2}" { + + gdb_run_cmd + gdb_test "" \ + "Breakpoint.* main \\(\\) at .*$srcfile2:.*" \ + "run to breakpoint at *main" + + gdb_test "p \$pc == main" " = 1" +} diff --git a/gdb/testsuite/gdb.base/break-fun-addr1.c b/gdb/testsuite/gdb.base/break-fun-addr1.c new file mode 100644 index 0000000..1545b21 --- /dev/null +++ b/gdb/testsuite/gdb.base/break-fun-addr1.c @@ -0,0 +1,22 @@ +/* This testcase is part of GDB, the GNU debugger. + + Copyright 2016 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 (void) +{ + return 0; +} diff --git a/gdb/testsuite/gdb.base/break-fun-addr2.c b/gdb/testsuite/gdb.base/break-fun-addr2.c new file mode 100644 index 0000000..13eec05 --- /dev/null +++ b/gdb/testsuite/gdb.base/break-fun-addr2.c @@ -0,0 +1,28 @@ +/* This testcase is part of GDB, the GNU debugger. + + Copyright 2016 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 +compute_something (int i) +{ + return i - 1; +} + +int +main (void) +{ + return compute_something (1); +} |