Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Sergio Durigan Junior <sergiodj@redhat.com>
To: Pedro Alves <palves@redhat.com>
Cc: gdb-patches@sourceware.org, Gabriel Krisman Bertazi <gabriel@krisman.be>
Subject: Re: [PATCH] Fix for PR breakpoints/16297: Fix catch syscall to work with syscall 0
Date: Thu, 19 Dec 2013 03:50:00 -0000	[thread overview]
Message-ID: <m3lhzhqz1j.fsf@redhat.com> (raw)
In-Reply-To: <52AF47D5.1040304@redhat.com> (Pedro Alves's message of "Mon, 16	Dec 2013 18:35:01 +0000")

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]
 }
 


  reply	other threads:[~2013-12-19  3:50 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-12-15  3:58 Gabriel Krisman Bertazi
2013-12-15  4:04 ` Sergio Durigan Junior
2013-12-16 17:51   ` Pedro Alves
2013-12-16 17:57     ` Pedro Alves
2013-12-16 18:03       ` Sergio Durigan Junior
2013-12-16 18:35         ` Pedro Alves
2013-12-19  3:50           ` Sergio Durigan Junior [this message]
2013-12-19 16:21             ` Pedro Alves
2013-12-19 19:09               ` Sergio Durigan Junior

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=m3lhzhqz1j.fsf@redhat.com \
    --to=sergiodj@redhat.com \
    --cc=gabriel@krisman.be \
    --cc=gdb-patches@sourceware.org \
    --cc=palves@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox