From: Sergio Durigan Junior <sergiodj@redhat.com>
To: Pedro Alves <palves@redhat.com>
Cc: GDB Patches <gdb-patches@sourceware.org>,
Gabriel Krisman Bertazi <gabriel@krisman.be>
Subject: Re: [PATCH 3/3] Testcase
Date: Tue, 18 Nov 2014 03:30:00 -0000 [thread overview]
Message-ID: <87y4r9xk1f.fsf@redhat.com> (raw)
In-Reply-To: <546625C4.5050007@redhat.com>
On Friday, November 14 2014, Pedro Alves wrote:
> On 11/13/2014 12:18 AM, Sergio Durigan Junior wrote:
>> This patch implements the testcase for this fix. The test is very
>> simple: we just have to verify if the syscall number for each
>> architecture has different meanings. I chose to test i386 and x86_64
>> here, but it could be any other architecture supported by the "catch
>> syscall" command.
>
> This only works if the built GDB has these architectures configured
> in.
>
> E.g., an --enable-targets=all build on x86:
>
> (gdb) set architecture aarch64
> The target architecture is assumed to be aarch64
>
> while on a default x86 build:
>
> (gdb) set architecture aarch64
> Undefined item: "aarch64".
>
> From that, you can see that:
>
> (gdb) set architecture i386
>
> would fail on non-x86 builds that don't include x86 in --enable-targets=foo.
True, thanks for catching this. When I tested it in my machine, I made
some confusion and used the same GDB to test both scenarios. Sorry
about that.
>>
>> +proc test_catch_syscall_multi_target {} {
>
> Please make this "multi_arch". Let's leave "multi-target" for
> https://sourceware.org/gdb/wiki/MultiTarget.
Ouch, sorry. Fixed.
>
>> + global decimal binfile
>> +
>> + with_test_prefix "multiple targets" {
>> + clean_restart $binfile
>> +
>> + gdb_test "set architecture i386" \
>> + "The target architecture is assumed to be i386" \
>> + "set arch to i386"
>> +
>> + gdb_test "catch syscall 1" \
>> + "Catchpoint $decimal \\(syscall .exit. \\\[1\\\]\\)" \
>> + "insert catch syscall on syscall 1 -- exit on i386"
>> +
>> + gdb_test "set architecture i386:x86-64" \
>> + "The target architecture is assumed to be i386:x86-64" \
>> + "set arch to x86_64"
>> +
>> + gdb_test "catch syscall 1" \
>> + "Catchpoint $decimal \\(syscall .write. \\\[1\\\]\\)" \
>> + "insert catch syscall on syscall 1 -- exit on i386"
>
> The "exit on i386" part seems stale here.
Fixed.
> I think we should do something like this:
>
> if { [istarget "i*86-*-*"] || [istarget "x86_64-*-*"] } {
> set arch1 "i386"
> set syscall1 "exit"
> set arch2 "i386:x86-64"
> set syscall2 "write"
> } elseif { [istarget "powerpc-*-linux*"] || [istarget "powerpc64-*-linux*"] } {
> ...
> } elseif { [istarget "sparc-*-linux*"] && ![istarget "sparc64-*-linux*"] } {
> ...
> } elseif { [istarget "mips*-linux*"] } {
> ...
> } elseif { [istarget "arm*-linux*"] } {
> ...
> } elseif { [istarget "s390*-linux*"] } {
> ...
> } else {
> error "please port me"
> }
That was my first idea, but I was trying to avoid having yet another set
of if...elseif... on catch-syscall.exp. And due to my mistake when
testing this patch, I thought I wouldn't need to worry about that after
all. Silly me.
Anyway, here is the updated patch. WDYT?
--
Sergio
GPG key ID: 0x65FC5E36
Please send encrypted e-mail if possible
http://sergiodj.net/
gdb/testsuite/
2014-11-18 Sergio Durigan Junior <sergiodj@redhat.com>
PR breakpoints/10737
* gdb.base/catch-syscall.exp (do_syscall_tests): Call
test_catch_syscall_multi_arch.
(test_catch_syscall_multi_arch): New function.
diff --git a/gdb/testsuite/gdb.base/catch-syscall.exp b/gdb/testsuite/gdb.base/catch-syscall.exp
index a70534c..ed87d61 100644
--- a/gdb/testsuite/gdb.base/catch-syscall.exp
+++ b/gdb/testsuite/gdb.base/catch-syscall.exp
@@ -311,6 +311,10 @@ proc do_syscall_tests {} {
# Testing the 'catch' syscall command during a restart of
# the inferior.
if [runto_main] then { test_catch_syscall_restarting_inferior }
+
+ # Testing if the 'catch syscall' command works when switching to
+ # different architectures on-the-fly (PR gdb/10737).
+ if [runto_main] then { test_catch_syscall_multi_arch }
}
proc test_catch_syscall_without_args_noxml {} {
@@ -372,6 +376,73 @@ proc test_catch_syscall_with_wrong_args_noxml {} {
}
}
+proc test_catch_syscall_multi_arch {} {
+ global decimal binfile
+
+ if { [istarget "i*86-*-*"] || [istarget "x86_64-*-*"] } {
+ set arch1 "i386"
+ set arch2 "i386:x86-64"
+ set syscall1_name "exit"
+ set syscall2_name "write"
+ set syscall_number 1
+ } elseif { [istarget "powerpc-*-linux*"] \
+ || [istarget "powerpc64-*-linux*"] } {
+ set arch1 "powerpc:common"
+ set arch2 "powerpc:common64"
+ set syscall1_name "openat"
+ set syscall2_name "unlinkat"
+ set syscall_number 286
+ } elseif { [istarget "sparc-*-linux*"] \
+ || [istarget "sparc64-*-linux*"] } {
+ set arch1 "sparc"
+ set arch2 "sparc:v9"
+ set syscall1_name "setresuid32"
+ set syscall2_name "setresuid"
+ set syscall_number 108
+ } elseif { [istarget "mips*-linux*"] } {
+ # MIPS does not use the same numbers for syscalls on 32 and 64
+ # bits.
+ verbose "Not testing MIPS for multi-arch syscall support"
+ return
+ } elseif { [istarget "arm*-linux*"] } {
+ # catch syscall supports only 32-bit ARM for now.
+ verbose "Not testing ARM for multi-arch syscall support"
+ return
+ } elseif { [istarget "s390*-linux*"] } {
+ set arch1 ""
+ set arch2 "s390:64-bit"
+ set syscall1_name "_newselect"
+ set syscall2_name "select"
+ set syscall_number 142
+ }
+
+ with_test_prefix "multiple targets" {
+ # We are not interested in loading any binary here, and in
+ # some systems (PowerPC, for example), if we load a binary
+ # there is no way to set other architecture.
+ gdb_exit
+ gdb_start
+
+ gdb_test "set architecture $arch1" \
+ "The target architecture is assumed to be $arch1" \
+ "set arch to $arch1"
+
+ gdb_test "catch syscall $syscall_number" \
+ "Catchpoint $decimal \\(syscall .${syscall1_name}. \\\[${syscall_number}\\\]\\)" \
+ "insert catch syscall on syscall $syscall_number -- $syscall1_name on $arch1"
+
+ gdb_test "set architecture $arch2" \
+ "The target architecture is assumed to be $arch2" \
+ "set arch to $arch2"
+
+ gdb_test "catch syscall $syscall_number" \
+ "Catchpoint $decimal \\(syscall .${syscall2_name}. \\\[${syscall_number}\\\]\\)" \
+ "insert catch syscall on syscall $syscall_number -- $syscall2_name on $arch2"
+
+ clean_restart $binfile
+ }
+}
+
proc do_syscall_tests_without_xml {} {
# Make sure GDB doesn't load the syscalls xml from the system data
# directory.
next prev parent reply other threads:[~2014-11-18 3:30 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-11-13 0:18 [PATCH] Partial fix for PR breakpoints/10737: Make syscall info be per-arch instead of global Sergio Durigan Junior
2014-11-13 0:18 ` [PATCH 1/3] Making syscall information be per-arch, " Sergio Durigan Junior
2014-11-14 15:53 ` Pedro Alves
2014-11-14 23:17 ` Sergio Durigan Junior
2014-11-13 0:18 ` [PATCH 2/3] Adjust calls for setting "catch syscall" information Sergio Durigan Junior
2014-11-14 15:53 ` Pedro Alves
2014-11-14 23:18 ` Sergio Durigan Junior
2014-11-13 0:18 ` [PATCH 3/3] Testcase Sergio Durigan Junior
2014-11-14 15:54 ` Pedro Alves
2014-11-18 3:30 ` Sergio Durigan Junior [this message]
2014-11-18 15:13 ` Pedro Alves
2014-11-18 20:20 ` Sergio Durigan Junior
2014-11-19 9:23 ` PowerPC: "set architecture" -> "Architecture not recognized" ? (was: Re: [PATCH 3/3] Testcase) Pedro Alves
2014-11-19 18:46 ` PowerPC: "set architecture" -> "Architecture not recognized" ? Sergio Durigan Junior
2014-11-20 10:48 ` Pedro Alves
2014-11-20 17:20 ` Sergio Durigan Junior
2014-11-20 17:34 ` [PATCH] Partial fix for PR breakpoints/10737: Make syscall info be per-arch instead of global 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=87y4r9xk1f.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