From patchwork Tue Jul 14 12:38:01 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yao Qi X-Patchwork-Id: 7666 Received: (qmail 117697 invoked by alias); 14 Jul 2015 12:38:24 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 117683 invoked by uid 89); 14 Jul 2015 12:38:23 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.0 required=5.0 tests=AWL, BAYES_00, FREEMAIL_FROM, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.2 X-HELO: mail-pa0-f43.google.com Received: from mail-pa0-f43.google.com (HELO mail-pa0-f43.google.com) (209.85.220.43) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-GCM-SHA256 encrypted) ESMTPS; Tue, 14 Jul 2015 12:38:12 +0000 Received: by pactm7 with SMTP id tm7so5320151pac.2 for ; Tue, 14 Jul 2015 05:38:11 -0700 (PDT) X-Received: by 10.66.186.195 with SMTP id fm3mr13631789pac.91.1436877491093; Tue, 14 Jul 2015 05:38:11 -0700 (PDT) Received: from E107787-LIN.cambridge.arm.com (gcc1-power7.osuosl.org. [140.211.15.137]) by smtp.gmail.com with ESMTPSA id bs3sm1281232pbd.47.2015.07.14.05.38.09 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 14 Jul 2015 05:38:10 -0700 (PDT) From: Yao Qi X-Google-Original-From: Yao Qi To: gdb-patches@sourceware.org Subject: [PATCH] Fix fail in gdb.server/wrapper.exp Date: Tue, 14 Jul 2015 13:38:01 +0100 Message-Id: <1436877481-11495-1-git-send-email-yao.qi@linaro.org> X-IsSubscribed: yes We are testing i686-linux GDB (Fedora-i686) on an x86_64-linux box (fedora-x86-64-4) in buildbot, such configuration causes fails in gdb.server/wrapper.exp like this: spawn /home/gdb-buildbot-2/fedora-x86-64-4/fedora-i686/build/gdb/testsuite/../../gdb/gdbserver/gdbserver --once --wrapper env TEST=1 -- :2346 /home/gdb-buildbot-2/fedora-x86-64-4/fedora-i686/build/gdb/testsuite/outputs/gdb.server/wrapper/wrapper Process /home/gdb-buildbot-2/fedora-x86-64-4/fedora-i686/build/gdb/testsuite/outputs/gdb.server/wrapper/wrapper created; pid = 8795 Can't debug 64-bit process with 32-bit GDBserver Exiting target remote localhost:2346 localhost:2346: Connection timed out. (gdb) FAIL: gdb.server/wrapper.exp: setting breakpoint at marker See https://sourceware.org/ml/gdb-testers/2015-q3/msg01541.html I can reproduce this fail on my ubuntu box as well. "wrapper" is 32-bit, but when GDBserver option --wrapper is used, the wrapper program is executed to launch the program, and the wrapper is /usr/bin/env in this case. In gdbserver/linux-x86-low.c:x86_linux_read_description, GDBserver checks whether the executable is 64-bit or not by means of /proc/PID/exe, which is the symbol-link to the wrapper, instead of the test program. Since 32-bit GDBserver is being used, it refuse to debug 64-bit process (/usr/bin/env) and exit. The fix to this problem is to write a simple "env" in c and it is compiled to 32-bit mode together with wrapper.c. So gdbserver, env and wrapper are all 32-bit. gdb/testsuite: 2015-07-14 Yao Qi * gdb.server/wrapper.exp: Compile env.c. * gdb.server/env.c: New file. --- gdb/testsuite/gdb.server/env.c | 30 ++++++++++++++++++++++++++++++ gdb/testsuite/gdb.server/wrapper.exp | 8 ++++++-- 2 files changed, 36 insertions(+), 2 deletions(-) create mode 100644 gdb/testsuite/gdb.server/env.c diff --git a/gdb/testsuite/gdb.server/env.c b/gdb/testsuite/gdb.server/env.c new file mode 100644 index 0000000..5659f37 --- /dev/null +++ b/gdb/testsuite/gdb.server/env.c @@ -0,0 +1,30 @@ +/* This testcase is part of GDB, the GNU debugger. + + Copyright 2015 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 . */ + +#include +#include + +int +main (int argc, char **argv) +{ + char *new_argv[] = { argv[2], NULL }; + char *new_envp[] = { argv[1], NULL }; + + execve (new_argv[0], &new_argv[0], new_envp); + + return 0; +} diff --git a/gdb/testsuite/gdb.server/wrapper.exp b/gdb/testsuite/gdb.server/wrapper.exp index 17d5abb..44265f6 100644 --- a/gdb/testsuite/gdb.server/wrapper.exp +++ b/gdb/testsuite/gdb.server/wrapper.exp @@ -19,7 +19,7 @@ load_lib gdbserver-support.exp -standard_testfile +standard_testfile .c env.c if { [skip_gdbserver_tests] } { return 0 @@ -31,6 +31,10 @@ if { [istarget *-*-mingw*] return -1 } +set binfile2 [standard_output_file "env"] +if { [gdb_compile "${srcdir}/${subdir}/${srcfile2}" "${binfile2}" executable {debug}] != "" } { + return -1 +} if { [prepare_for_testing $testfile.exp $testfile $srcfile debug] } { return -1 } @@ -41,7 +45,7 @@ gdb_test "disconnect" ".*" set target_exec [gdbserver_download_current_prog] # Start GDBserver with option '--wrapper'. -set res [gdbserver_start "--wrapper env TEST=1 --" $target_exec] +set res [gdbserver_start "--wrapper ${binfile2} TEST=1 --" $target_exec] set gdbserver_protocol [lindex $res 0] set gdbserver_gdbport [lindex $res 1]