This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] Fix for PR breakpoints/16297: Fix catch syscall to work with syscall 0


On Monday, December 16 2013, Pedro Alves wrote:

> On 12/16/2013 06:03 PM, Sergio Durigan Junior wrote:
>
>> If it is OK to you, I will wait until my other patch
>> touching catch-syscall.exp is approved, so that I can write a simple
>> extension to the testcase that will test this specific bug.  Then, I can
>> commit both patches (this one and the testcase one) together.
>
> Yes, sounds great.

OK, here's the testsuite patch.  I will commit it along with the code,
and give Krisman the authorship.

This testcase is a little difficult to write.  By doing a quick
inspection at the Linux source, one can see that, in many targets, the
syscall number 0 is restart_syscall, which is forbidden to be called
from userspace.  Therefore, on many targets, there's just no way to test
this safely.

My decision was to take the simpler route and just adds the "read"
syscall on the default test.  Its number on x86_64 is zero, which is
"good enough" since many people here do their tests on x86_64 anyway and
it is a popular architecture.

-- 
Sergio

2013-12-19  Sergio Durigan Junior  <sergiodj@redhat.com>

	* gdb.base/catch-syscall.c (read_syscall): New variable.
	(main): Call dummy read syscall.
	* gdb.base/catch-syscall.exp (all_syscalls): Include "read"
	syscall.
	(fill_all_syscalls_numbers): Get "read" syscall number.  Include
	it in all_syscalls_numbers.

diff --git a/gdb/testsuite/gdb.base/catch-syscall.c b/gdb/testsuite/gdb.base/catch-syscall.c
index 8f94191..6f28f5b 100644
--- a/gdb/testsuite/gdb.base/catch-syscall.c
+++ b/gdb/testsuite/gdb.base/catch-syscall.c
@@ -16,6 +16,8 @@
 
 static int close_syscall = SYS_close;
 static int chroot_syscall = SYS_chroot;
+/* The "read" syscall is zero on x86_64.  */
+static int read_syscall = SYS_read;
 static int exit_group_syscall = SYS_exit_group;
 
 int
@@ -27,6 +29,8 @@ main (void)
 
 	chroot (".");
 
+	read (0, NULL, 0);
+
 	/* The last syscall.  Do not change this.  */
 	_exit (0);
 }
diff --git a/gdb/testsuite/gdb.base/catch-syscall.exp b/gdb/testsuite/gdb.base/catch-syscall.exp
index fd7d2db..4cac454 100644
--- a/gdb/testsuite/gdb.base/catch-syscall.exp
+++ b/gdb/testsuite/gdb.base/catch-syscall.exp
@@ -47,7 +47,7 @@ if  { [prepare_for_testing ${testfile}.exp $testfile ${testfile}.c] } {
 
 # All (but the last) syscalls from the example code
 # They are ordered according to the file, so do not change this.
-set all_syscalls { "close" "chroot" }
+set all_syscalls { "close" "chroot" "read" }
 set all_syscalls_numbers { }
 
 # The last syscall (exit()) does not return, so
@@ -396,7 +396,9 @@ proc fill_all_syscalls_numbers {} {
 
     set close_syscall [get_integer_valueof "close_syscall" -1]
     set chroot_syscall [get_integer_valueof "chroot_syscall" -1]
-    set all_syscalls_numbers [list $close_syscall $chroot_syscall]
+    set read_syscall [get_integer_valueof "read_syscall" -1]
+    set all_syscalls_numbers [list $close_syscall $chroot_syscall \
+				  $read_syscall]
     set last_syscall_number [get_integer_valueof "exit_group_syscall" -1]
 }
 


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]