This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [patch 13/15] PIE: testsuite: Test attaching to PIEs
- From: Jan Kratochvil <jan dot kratochvil at redhat dot com>
- To: Tom Tromey <tromey at redhat dot com>
- Cc: gdb-patches at sourceware dot org
- Date: Thu, 14 Jan 2010 22:12:37 +0100
- Subject: Re: [patch 13/15] PIE: testsuite: Test attaching to PIEs
- References: <20091109210058.GN19138@host0.dyn.jankratochvil.net> <m3aayuayj3.fsf@fleche.redhat.com>
On Tue, 10 Nov 2009 21:57:20 +0100, Tom Tromey wrote:
> >>>>> "Jan" == Jan Kratochvil <jan.kratochvil@redhat.com> writes:
>
> Jan> gdb/testsuite/
> Jan> * gdb.base/break-interp-lib.c: Include unistd.h, assert.h and stdio.h.
> Jan> (libfunc): New parameter action. Implement also selectable "sleep".
> Jan> * gdb.base/break-interp-main.c: Include assert.h.
> Jan> (libfunc): New parameter action.
> Jan> (main): New parameters argc and argv. Assert argc. Pass argv.
> Jan> * gdb.base/break-interp.exp (test_core): Pass the "segv" argument.
> Jan> (test_attach): New proc.
> Jan> (test_ld): Pass new "segv" exec parameter. Call also test_attach.
> Jan> * lib/gdb.exp (core_find): New parameter arg. Pass it to $binfile.
>
> Ok.
Checked-in.
Thanks,
Jan
http://sourceware.org/ml/gdb-cvs/2010-01/msg00124.html
--- src/gdb/testsuite/ChangeLog 2010/01/14 21:09:04 1.2086
+++ src/gdb/testsuite/ChangeLog 2010/01/14 21:11:59 1.2087
@@ -1,5 +1,17 @@
2010-01-14 Jan Kratochvil <jan.kratochvil@redhat.com>
+ * gdb.base/break-interp-lib.c: Include unistd.h, assert.h and stdio.h.
+ (libfunc): New parameter action. Implement also selectable "sleep".
+ * gdb.base/break-interp-main.c: Include assert.h.
+ (libfunc): New parameter action.
+ (main): New parameters argc and argv. Assert argc. Pass argv.
+ * gdb.base/break-interp.exp (test_core): Pass the "segv" argument.
+ (test_attach): New proc.
+ (test_ld): Pass new "segv" exec parameter. Call also test_attach.
+ * lib/gdb.exp (core_find): New parameter arg. Pass it to $binfile.
+
+2010-01-14 Jan Kratochvil <jan.kratochvil@redhat.com>
+
* gdb.base/break-interp.exp (test_core): New proc.
(test_ld): Call it.
--- src/gdb/testsuite/gdb.base/break-interp-lib.c 2010/01/14 21:04:53 1.1
+++ src/gdb/testsuite/gdb.base/break-interp-lib.c 2010/01/14 21:12:00 1.2
@@ -16,9 +16,25 @@
along with this program. If not, see <http://www.gnu.org/licenses/>. */
#include <signal.h>
+#include <unistd.h>
+#include <assert.h>
+#include <stdio.h>
void
-libfunc (void)
+libfunc (const char *action)
{
- raise (SIGSEGV);
+ assert (action != NULL);
+
+ if (strcmp (action, "segv") == 0)
+ raise (SIGSEGV);
+
+ if (strcmp (action, "sleep") == 0)
+ {
+ puts ("sleeping");
+ fflush (stdout);
+
+ sleep (60);
+ }
+
+ assert (0);
}
--- src/gdb/testsuite/gdb.base/break-interp-main.c 2010/01/14 21:04:53 1.1
+++ src/gdb/testsuite/gdb.base/break-interp-main.c 2010/01/14 21:12:00 1.2
@@ -15,12 +15,16 @@
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
-extern void libfunc (void);
+#include <assert.h>
+
+extern void libfunc (const char *action);
int
-main (void)
+main (int argc, char **argv)
{
- libfunc ();
+ assert (argc == 2);
+
+ libfunc (argv[1]);
return 0;
}
--- src/gdb/testsuite/gdb.base/break-interp.exp 2010/01/14 21:09:05 1.4
+++ src/gdb/testsuite/gdb.base/break-interp.exp 2010/01/14 21:12:00 1.5
@@ -240,7 +240,7 @@
proc test_core {file} {
global srcdir subdir gdb_prompt
- set corefile [core_find $file]
+ set corefile [core_find $file {} "segv"]
if {$corefile == ""} {
return
}
@@ -258,6 +258,44 @@
gdb_test "bt" "#\[0-9\]+ +\[^\r\n\]*\\mlibfunc\\M\[^\r\n\]*\r\n#\[0-9\]+ +\[^\r\n\]*\\mmain\\M.*" "core main bt"
}
+proc test_attach {file} {
+ global board_info
+
+ gdb_exit
+
+ set test "sleep function started"
+
+ set command "${file} sleep"
+ set res [remote_spawn host $command];
+ if { $res < 0 || $res == "" } {
+ perror "Spawning $command failed."
+ fail $test
+ return
+ }
+ set pid [exp_pid -i $res]
+ gdb_expect {
+ -re "sleeping\r\n" {
+ pass $test
+ }
+ eof {
+ fail "$test (eof)"
+ return
+ }
+ timeout {
+ fail "$test (timeout)"
+ return
+ }
+ }
+
+ gdb_exit
+ gdb_start
+ gdb_test "attach $pid" "Attaching to process $pid\r\n.*" "attach"
+ gdb_test "bt" "#\[0-9\]+ +\[^\r\n\]*\\mlibfunc\\M\[^\r\n\]*\r\n#\[0-9\]+ +\[^\r\n\]*\\mmain\\M.*" "attach main bt"
+ gdb_exit
+
+ remote_exec host "kill -9 $pid"
+}
+
proc test_ld {file ifmain trynosym} {
global srcdir subdir gdb_prompt
@@ -270,7 +308,7 @@
gdb_reinitialize_dir $srcdir/$subdir
gdb_load $file
- reach "dl_main" run
+ reach "dl_main" "run segv"
gdb_test "bt" "#0 +\[^\r\n\]*\\mdl_main\\M.*" "dl bt"
@@ -282,6 +320,8 @@
gdb_test "bt" "#0 +\[^\r\n\]*\\mlibfunc\\M\[^\r\n\]*\r\n#1 +\[^\r\n\]*\\mmain\\M.*" "main bt"
test_core $file
+
+ test_attach $file
}
if !$trynosym {
--- src/gdb/testsuite/lib/gdb.exp 2010/01/09 00:14:11 1.134
+++ src/gdb/testsuite/lib/gdb.exp 2010/01/14 21:12:00 1.135
@@ -3121,7 +3121,7 @@
}
}
-proc core_find {binfile {deletefiles {}}} {
+proc core_find {binfile {deletefiles {}} {arg ""}} {
global objdir subdir
set destcore "$binfile.core"
@@ -3143,7 +3143,7 @@
set found 0
set coredir "${objdir}/${subdir}/coredir.[getpid]"
file mkdir $coredir
- catch "system \"(cd ${coredir}; ulimit -c unlimited; ${binfile}; true) >/dev/null 2>&1\""
+ catch "system \"(cd ${coredir}; ulimit -c unlimited; ${binfile} ${arg}; true) >/dev/null 2>&1\""
# remote_exec host "${binfile}"
foreach i "${coredir}/core ${coredir}/core.coremaker.c ${binfile}.core" {
if [remote_file build exists $i] {