From patchwork Fri Feb 19 14:36:34 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yao Qi X-Patchwork-Id: 10931 Received: (qmail 115421 invoked by alias); 19 Feb 2016 14:37:09 -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 114999 invoked by uid 89); 19 Feb 2016 14:37:09 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.6 required=5.0 tests=AWL, BAYES_00, FREEMAIL_FROM, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.2 spammy=19415, sk:stepov, sk:step-ov, displaced X-HELO: mail-pf0-f181.google.com Received: from mail-pf0-f181.google.com (HELO mail-pf0-f181.google.com) (209.85.192.181) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-GCM-SHA256 encrypted) ESMTPS; Fri, 19 Feb 2016 14:36:53 +0000 Received: by mail-pf0-f181.google.com with SMTP id x65so52165823pfb.1 for ; Fri, 19 Feb 2016 06:36:53 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=BIxdXNjrQHTWHjc3egphKFFqG2cHFCoMyDeB09ekx34=; b=Oi+yzOKmNCLnBBoNei6itM7dyLJY58sQVNUqcEc0g8WQ8oSMEwZJc2DfQkvbLz9kgV FGhBd+abz2fsGI+lNwMG3sj77iaZVuNDt9Xj0dHG2VlGSFS8rFRa/vXoyqK+LKYlodLa QjCrQkBtx9PJCHUdC0T2jbW20vcAvxx8R/9IoXXO7vOVRaTA2sIN/EJnUfZ6lTxFDksN RpbSn/CHme9LL/ZfwM/aXCmlSQ8I3+Uk1hQbNLD9dE8SnUQ2IejFmF0mR7T3bhownkg3 XYWeT+rZwOsx506TbWeSG1dcc+vkcrE7S6X6Am0sMg6f7g1dYoaYX3ubxF1AqLTHqP8y touw== X-Gm-Message-State: AG10YORYenu4H/aNPoxxiOWjwbXeirK6D96/EmyiSGtG8qj8Hc1E42Uxy5R/R7l0uC600Q== X-Received: by 10.98.31.221 with SMTP id l90mr18616202pfj.92.1455892610977; Fri, 19 Feb 2016 06:36:50 -0800 (PST) Received: from E107787-LIN.cambridge.arm.com (gcc1-power7.osuosl.org. [140.211.15.137]) by smtp.gmail.com with ESMTPSA id kq3sm18452546pab.24.2016.02.19.06.36.49 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 19 Feb 2016 06:36:50 -0800 (PST) From: Yao Qi X-Google-Original-From: Yao Qi To: gdb-patches@sourceware.org Subject: [PATCH 8/8] New test about step over clone syscall Date: Fri, 19 Feb 2016 14:36:34 +0000 Message-Id: <1455892594-2294-9-git-send-email-yao.qi@linaro.org> In-Reply-To: <1455892594-2294-1-git-send-email-yao.qi@linaro.org> References: <1455892594-2294-1-git-send-email-yao.qi@linaro.org> X-IsSubscribed: yes This patch adds a new test for stepping over clone syscall. 2016-02-19 Yao Qi * gdb.base/step-over-syscall.exp (step_over_syscall): Kfail. Invoke step_over_syscall "clone". * gdb.base/step-over-clone.c: New file. --- gdb/testsuite/gdb.base/step-over-clone.c | 53 ++++++++++++++++++++++++++++ gdb/testsuite/gdb.base/step-over-syscall.exp | 17 +++++++++ 2 files changed, 70 insertions(+) create mode 100644 gdb/testsuite/gdb.base/step-over-clone.c diff --git a/gdb/testsuite/gdb.base/step-over-clone.c b/gdb/testsuite/gdb.base/step-over-clone.c new file mode 100644 index 0000000..43b1933 --- /dev/null +++ b/gdb/testsuite/gdb.base/step-over-clone.c @@ -0,0 +1,53 @@ +/* This testcase is part of GDB, the GNU debugger. + + Copyright 2016 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 . */ + +#define _GNU_SOURCE +#include +#include +#include + +static void +marker () {} + +#define STACK_SIZE 0x1000 + +static int +clone_fn (void *unused) +{ + return 0; +} + +int +main (void) +{ + int i, pid; + unsigned char *stack[6]; + + for (i = 0; i < (sizeof (stack) / sizeof (stack[0])); i++) + stack[i] = malloc (STACK_SIZE); + + for (i = 0; i < (sizeof (stack) / sizeof (stack[0])); i++) + { + pid = clone (clone_fn, stack[i] + STACK_SIZE, CLONE_FILES | CLONE_VM, + NULL); + } + + for (i = 0; i < (sizeof (stack) / sizeof (stack[0])); i++) + free (stack[i]); + + marker (); +} diff --git a/gdb/testsuite/gdb.base/step-over-syscall.exp b/gdb/testsuite/gdb.base/step-over-syscall.exp index 863194b..e5a3d55 100644 --- a/gdb/testsuite/gdb.base/step-over-syscall.exp +++ b/gdb/testsuite/gdb.base/step-over-syscall.exp @@ -122,6 +122,13 @@ proc step_over_syscall { syscall } { foreach displaced $disp_step_opts { with_test_prefix "displaced $displaced" { + if { $displaced == "on" && $syscall == "clone" } { + # GDB doesn't support step over clone syscall with + # displaced stepping. + kfail "gdb/19675" "single step over clone" + continue + } + gdb_test "continue" \ "Continuing\\..*Breakpoint \[0-9\]+, (.* in |__libc_|)$syscall \\(\\).*" \ "continue to $syscall (3rd time)" @@ -187,6 +194,15 @@ proc step_over_syscall { syscall } { } } + if { $syscall == "clone" } { + # Create a breakpoint in the child with the condition + # which is false, so that GDBserver can get the + # event from the child but GDB doesn't see it. In + # this way, we don't have to adjust test flow for + # "clone". + gdb_test "break clone_fn if main == 0" + } + gdb_test "continue" "Continuing\\..*Breakpoint \[0-9\]+, (.* in |__libc_|)$syscall \\(\\).*" \ "continue to $syscall again" @@ -206,3 +222,4 @@ proc step_over_syscall { syscall } { step_over_syscall "fork" step_over_syscall "vfork" +step_over_syscall "clone"