From patchwork Fri Apr 24 15:28:56 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yao Qi X-Patchwork-Id: 47569 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-la0-f69.google.com (mail-la0-f69.google.com [209.85.215.69]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 1E6CB20553 for ; Fri, 24 Apr 2015 15:29:16 +0000 (UTC) Received: by laat2 with SMTP id t2sf13020629laa.2 for ; Fri, 24 Apr 2015 08:29:15 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:mailing-list :precedence:list-id:list-unsubscribe:list-subscribe:list-archive :list-post:list-help:sender:delivered-to:from:to:subject:date :message-id:x-original-sender:x-original-authentication-results; bh=ilyZ7MB8EAvRnTI8sHURqc1EHpDbi0EmbWBwTRZbf0c=; b=FjJAuTw40ENQHNRNfcgU9h6+cFFF6YLSWV28drWKhbWOoPD0H0UoDXZ58reMA/CQXq y1qBvb9+Rr37ltu0la1nhRyCa8mY8Gr3qnS1XBWR+evwfokuLoerAsh4IbfHsokzoIux ql0gUI0wJ5ZpIdKSFdbWiNgNcG5s5TzW2lDReL5XrDU9FMUa7SJ8kzq7IIHMAL8uiSQN vy2QIwtf0JjctDMo/Mfas79ib4udSIpUbN+O+5dDyP5HdfA4z7TUzgEcGp66J3f9+xcY lPdyeyekS6og2mYkcG8LcCSWvzoain0Pj9KmhHx0PDp8tA7xt7fc0jzR7pJ/6I5aMIWy 4JoA== X-Gm-Message-State: ALoCoQk0vFFv1V2GW3LR44tNl3llDqeLQCZz0mka98G7ZAeqLhUm/mw/QWrfIwg/tZTD5XJhkSeW X-Received: by 10.112.29.39 with SMTP id g7mr4459972lbh.1.1429889355042; Fri, 24 Apr 2015 08:29:15 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.179.232 with SMTP id dj8ls507700lac.74.gmail; Fri, 24 Apr 2015 08:29:14 -0700 (PDT) X-Received: by 10.112.134.167 with SMTP id pl7mr7363439lbb.50.1429889354837; Fri, 24 Apr 2015 08:29:14 -0700 (PDT) Received: from mail-lb0-x22f.google.com (mail-lb0-x22f.google.com. [2a00:1450:4010:c04::22f]) by mx.google.com with ESMTPS id lj3si8493796lab.101.2015.04.24.08.29.14 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 24 Apr 2015 08:29:14 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 2a00:1450:4010:c04::22f as permitted sender) client-ip=2a00:1450:4010:c04::22f; Received: by lbcga7 with SMTP id ga7so39321682lbc.1 for ; Fri, 24 Apr 2015 08:29:14 -0700 (PDT) X-Received: by 10.152.27.1 with SMTP id p1mr7267981lag.112.1429889354701; Fri, 24 Apr 2015 08:29:14 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.67.65 with SMTP id l1csp1262883lbt; Fri, 24 Apr 2015 08:29:13 -0700 (PDT) X-Received: by 10.69.31.106 with SMTP id kl10mr4096085pbd.155.1429889352851; Fri, 24 Apr 2015 08:29:12 -0700 (PDT) Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id l15si17989907pdm.90.2015.04.24.08.29.11 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 24 Apr 2015 08:29:12 -0700 (PDT) Received-SPF: pass (google.com: domain of gdb-patches-return-122353-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) client-ip=209.132.180.131; Received: (qmail 73562 invoked by alias); 24 Apr 2015 15:29:05 -0000 Mailing-List: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org Precedence: list 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 73549 invoked by uid 89); 24 Apr 2015 15:29:05 -0000 X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.4 required=5.0 tests=AWL, BAYES_00, FREEMAIL_FROM, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.2 X-HELO: mail-pd0-f172.google.com Received: from mail-pd0-f172.google.com (HELO mail-pd0-f172.google.com) (209.85.192.172) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-GCM-SHA256 encrypted) ESMTPS; Fri, 24 Apr 2015 15:29:03 +0000 Received: by pdea3 with SMTP id a3so51908261pde.3 for ; Fri, 24 Apr 2015 08:29:02 -0700 (PDT) X-Received: by 10.66.123.73 with SMTP id ly9mr16150873pab.156.1429889342136; Fri, 24 Apr 2015 08:29:02 -0700 (PDT) Received: from E107787-LIN.cambridge.arm.com (gcc1-power7.osuosl.org. [140.211.15.137]) by mx.google.com with ESMTPSA id sf6sm11394311pbb.82.2015.04.24.08.29.00 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 24 Apr 2015 08:29:01 -0700 (PDT) From: Yao Qi To: gdb-patches@sourceware.org Subject: [rfc] Fix PR 18208: update /proc/pid/coredump_filter by c code Date: Fri, 24 Apr 2015 16:28:56 +0100 Message-Id: <1429889336-12277-1-git-send-email-qiyaoltc@gmail.com> X-IsSubscribed: yes X-Original-Sender: qiyaoltc@gmail.com X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 2a00:1450:4010:c04::22f as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org; dkim=pass header.i=@sourceware.org; dmarc=fail (p=NONE dis=NONE) header.from=gmail.com X-Google-Group-Id: 836684582541 From: Yao Qi Hi, We see some fails in gdb.base/coredump-filter.exp when we do remote gdbserver testing, like what I did for arm/aarch64 linux testing or run it with board file remote-gdbserver-on-localhost $ make check RUNTESTFLAGS='--target_board=remote-gdbserver-on-localhost coredump-filter.exp' we find that this line in the test doesn't work as expected, remote_exec target "sh -c \"echo $filter_flag > /proc/$ipid/coredump_filter\"" although such pattern has been used in gdb testsuite somewhere else, but the special thing here is that we redirect the output to /proc/$ipid/coredump_filter on the remote target. DejaGNU will redirect the output from the remote target to local, and looks tcl gets confused by these two redirection. After trying pass different parameters to remote_exec and hacking remote_exec/rsh_exec/local_exec, I got no success, I decide to give up, and try to update /proc/$ipid/coredump_filter by the c code directly. This patch adds a c function set_coredump_filter to update coredump_filter, and GDB calls it. Now this test passes on boardfile unix, native-gdbserver and remote-gdbserver-on-localhost. It also passes my board files for arm and aarch64 testing. gdb/testsuite: 2015-04-24 Yao Qi PR gdb/18208 * gdb.base/coredump-filter.c (set_coredump_filter): New function. * gdb.base/coredump-filter.exp (do_save_core): Call inferior function set_coredump_filter, and remove remote_exec call. Remove argument ipid. Callers update. (top level): Don't get inferior's PID. --- gdb/testsuite/gdb.base/coredump-filter.c | 16 ++++++++++++++++ gdb/testsuite/gdb.base/coredump-filter.exp | 15 ++++++--------- 2 files changed, 22 insertions(+), 9 deletions(-) diff --git a/gdb/testsuite/gdb.base/coredump-filter.c b/gdb/testsuite/gdb.base/coredump-filter.c index 192c469..18b9d9c 100644 --- a/gdb/testsuite/gdb.base/coredump-filter.c +++ b/gdb/testsuite/gdb.base/coredump-filter.c @@ -59,3 +59,19 @@ main (int argc, char *argv[]) return 0; /* break-here */ } + +/* Write V to /proc/self/coredump_filter. Return 0 on success. */ + +int +set_coredump_filter (int v) +{ + FILE *f = fopen("/proc/self/coredump_filter", "r+"); + + if (f == NULL) + return 1; + + fprintf(f, "%#x", v); + + fclose (f); + return 0; +} diff --git a/gdb/testsuite/gdb.base/coredump-filter.exp b/gdb/testsuite/gdb.base/coredump-filter.exp index f872de0..dbebaf0 100644 --- a/gdb/testsuite/gdb.base/coredump-filter.exp +++ b/gdb/testsuite/gdb.base/coredump-filter.exp @@ -34,10 +34,10 @@ if { ![runto_main] } { gdb_breakpoint [gdb_get_line_number "break-here"] gdb_continue_to_breakpoint "break-here" ".* break-here .*" -proc do_save_core { filter_flag core ipid } { - verbose -log "writing $filter_flag to /proc/$ipid/coredump_filter" +proc do_save_core { filter_flag core } { + verbose -log "writing $filter_flag to /proc//coredump_filter" - remote_exec target "sh -c \"echo $filter_flag > /proc/$ipid/coredump_filter\"" + gdb_test "p set_coredump_filter ($filter_flag)" " = 0" # Generate a corefile. gdb_gcore_cmd "$core" "save corefile" @@ -146,11 +146,8 @@ if { !$core_supported } { return -1 } -# Get the inferior's PID. -set infpid "" gdb_test_multiple "info inferiors" "getting inferior pid" { - -re "process \($decimal\).*\r\n$gdb_prompt $" { - set infpid $expect_out(1,string) + -re "process $decimal.*\r\n$gdb_prompt $" { } -re "Remote target.*$gdb_prompt $" { # If the target does not provide PID information (like usermode QEMU), @@ -184,12 +181,12 @@ foreach item $all_anon_corefiles { # Generate corefiles for the "anon" case. foreach item $all_anon_corefiles { with_test_prefix "saving corefile for [lindex $item 0]" { - do_save_core [lindex $item 1] [subst [lindex $item 2]] $infpid + do_save_core [lindex $item 1] [subst [lindex $item 2]] } } with_test_prefix "saving corefile for non-Private-Shared-Anon-File" { - do_save_core "0x60" $non_private_shared_anon_file_core $infpid + do_save_core "0x60" $non_private_shared_anon_file_core } clean_restart $testfile