From patchwork Fri May 25 08:17:54 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Vivier X-Patchwork-Id: 136794 Delivered-To: patch@linaro.org Received: by 2002:a2e:9706:0:0:0:0:0 with SMTP id r6-v6csp3280888lji; Fri, 25 May 2018 01:21:22 -0700 (PDT) X-Google-Smtp-Source: ADUXVKIH22vSh5Pu48HqVZcG8Ozujtm/3BZNCPXr84uQGz1MNUbfH6VpGdyIsoIBjbZMK7r78uzi X-Received: by 2002:a0c:d911:: with SMTP id p17-v6mr658593qvj.78.1527236482791; Fri, 25 May 2018 01:21:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527236482; cv=none; d=google.com; s=arc-20160816; b=ijGpfVMLO6Pe4qN96Hk+0lRx81zqKQAxk963s3N4gjNRa9Qc6eJfm75YmBon3pPP9k hp3zk3IT1KhsRMO/qFs/bT5z5/lTeg5Hu3jqxWcZZ6Mflr1MpQ6FJYS8F4TwjsqGUeyy 3QbaXq7ixXIw40it+XP/GPV2B9C4JCstiH/An1maWCtOK+xM3iBpuShL5nbA1jiSCLcO 70xi/fRwsI+m/s39PKtS1v3UGe+IU3HA5mVLdBHkxY0PrkN/0KPwuOJsm4JxyVkwq05a 49lfUnnCzQc0l81yuhwrmi2pLXNlnE+TVSWkXc+zMb5kBFSNCJtbljv4upqZoDVUYrQR ytOw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:references:in-reply-to :message-id:date:to:from:arc-authentication-results; bh=IkbwtITmIZhUySvU1guDTEllB8+wXAfPnGcDrwS30QE=; b=FAPShqepW/6ZzwamnaUqG8Vy6peVOcgXA73tNDOz3V/tc0tArHV/OCBBIBwSOgVII5 jAPF2vZLJeqeyIavAxIEnXLS0+neQDhIa/t8jFhsG2SrMJjjqbnJGM3mYrP1mQOoo5Bc Ky1em/j8yHPX7mDZw1DHp21+qeJMeHXPQ8yDkoSLbEn5O5GL7RhsG2Mjz3JnRYfZafiC Znws2GYBmnMx+NhcqAcWaTFq+3a6na3ERj+q/49x9uq6mJidt0b+x2R5Mpz790SN35DR O2LR1ya8x+MCSXwghQDDBZ0V5qL9DBy+zfR/8TSlrcI92VetY69nFMa4SSoawjFe/fjS guMg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id g127-v6si13761361qkc.180.2018.05.25.01.21.22 for (version=TLS1 cipher=AES128-SHA bits=128/128); Fri, 25 May 2018 01:21:22 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org Received: from localhost ([::1]:42381 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fM7yU-00031U-7w for patch@linaro.org; Fri, 25 May 2018 04:21:22 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38438) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fM7vd-0001kC-9x for qemu-devel@nongnu.org; Fri, 25 May 2018 04:18:26 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fM7vc-0008JW-4S for qemu-devel@nongnu.org; Fri, 25 May 2018 04:18:25 -0400 Received: from mout.kundenserver.de ([217.72.192.73]:46505) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fM7vb-0008Ib-Rx for qemu-devel@nongnu.org; Fri, 25 May 2018 04:18:24 -0400 Received: from localhost.localdomain ([78.238.229.36]) by mrelayeu.kundenserver.de (mreue102 [212.227.15.183]) with ESMTPSA (Nemesis) id 0M1WmX-1gEeQI0k0H-00tW0C; Fri, 25 May 2018 10:18:15 +0200 From: Laurent Vivier To: qemu-devel@nongnu.org Date: Fri, 25 May 2018 10:17:54 +0200 Message-Id: <20180525081754.29506-14-laurent@vivier.eu> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180525081754.29506-1-laurent@vivier.eu> References: <20180525081754.29506-1-laurent@vivier.eu> X-Provags-ID: V03:K1:mkqzhbzPzdx4UJnG6BOiGLKTbbO8OLfFPjb/ixsmFJa6OjDRrII EHNoXZ5qF1H3YXyIhSKtG4OfP2MMzKjin0Q9b8Coyp1A1xPTTVG2Q8U+/YKqSaqBLl6loCK AwMgoFo8KpoyrShf+fY46J6MI8eg5GCkmGo+VVCyT+CSsk0HloboOJtLw5jDX4XtfXFF6TF S73A/IR84oSo4WngIvxAg== X-UI-Out-Filterresults: notjunk:1; V01:K0:5/GcwrRraFc=:WU2Hb1CxXaBKns4uoQMxEc CnqrijvKUqB2s7utZQotMk1+X6GNjp5Jm7B8/YAuyI7k/TyxayKX+rRLwYwgSehib2Mb0MNUg bUio2iWSlqb2C1HqYoR1h8IRenH0LRdnp5cLak6qlVIDmW2KeC30h/it6zHyXslyD8aVKVXOM i1vLlXD0KrKOEh96tFZsZTnV67mTretNdN4ab9mOeHVpmmsBzZDztQGKXSSiQtCEWk9cL7l5Q 18WMb319xSwrbXiHDtznb7DSTk84jCF8k3a41kfmQyk1wS6Yb+WaJFkPaKKYxECb/9i8UZUnq 8hg6BHQ5J4lTNgwzJSg+ik/uJ2SVkvsVyF0M+DN9YAWtYpxJphd8ocA1bKBlVYofrrWp3MRD1 RselTdpkmMHewIM1+LKjHQ/o7d4SIMPDvJiAxBjDoXayoVQH6vL84YEAH3M89qQVHY0nlgR53 pqM8kFmW5og68Iiy69QQTcQZpfEw4Bp9emdEB2WP6sqH0njqYVxumtsOU+spHES1YyA9UvSqY lwDSxw+3QPcwXVyuwGV3rUJu21M07huBlLqwnEUxa0YllHzl4thYruYUfgNwrA15rjb9irHYV nE55cQ56HEc2vW2AxjE4PH+dH0UU/nOfmXAfF176vp6wBLU2qfSeMZkT5oLPO3uoPDsblJyic 8TtoRxY0bn+IxFxDj2uy/vViRZrD4I1urMkKqyvjNw5Bf9YDv/Y/o2jPlbOYuBJjh8BE= X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 217.72.192.73 Subject: [Qemu-devel] [PULL 13/13] gdbstub: Clarify what gdb_handlesig() is doing X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Riku Voipio , Laurent Vivier Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Peter Maydell gdb_handlesig()'s behaviour is not entirely obvious at first glance. Add a doc comment for it, and also add a comment explaining why it's ok for gdb_do_syscallv() to ignore gdb_handlesig()'s return value. (Coverity complains about this: CID 1390850.) Signed-off-by: Peter Maydell Message-Id: <20180515181958.25837-1-peter.maydell@linaro.org> Signed-off-by: Laurent Vivier --- gdbstub.c | 6 ++++++ include/exec/gdbstub.h | 15 +++++++++++++++ 2 files changed, 21 insertions(+) -- 2.14.3 diff --git a/gdbstub.c b/gdbstub.c index e4ece2f5bc..6081e719c5 100644 --- a/gdbstub.c +++ b/gdbstub.c @@ -1558,6 +1558,12 @@ void gdb_do_syscallv(gdb_syscall_complete_cb cb, const char *fmt, va_list va) *p = 0; #ifdef CONFIG_USER_ONLY put_packet(s, s->syscall_buf); + /* Return control to gdb for it to process the syscall request. + * Since the protocol requires that gdb hands control back to us + * using a "here are the results" F packet, we don't need to check + * gdb_handlesig's return value (which is the signal to deliver if + * execution was resumed via a continue packet). + */ gdb_handlesig(s->c_cpu, 0); #else /* In this case wait to send the syscall packet until notification that diff --git a/include/exec/gdbstub.h b/include/exec/gdbstub.h index 2e8a4b83b9..08363969c1 100644 --- a/include/exec/gdbstub.h +++ b/include/exec/gdbstub.h @@ -48,6 +48,21 @@ int use_gdb_syscalls(void); void gdb_set_stop_cpu(CPUState *cpu); void gdb_exit(CPUArchState *, int); #ifdef CONFIG_USER_ONLY +/** + * gdb_handlesig: yield control to gdb + * @cpu: CPU + * @sig: if non-zero, the signal number which caused us to stop + * + * This function yields control to gdb, when a user-mode-only target + * needs to stop execution. If @sig is non-zero, then we will send a + * stop packet to tell gdb that we have stopped because of this signal. + * + * This function will block (handling protocol requests from gdb) + * until gdb tells us to continue target execution. When it does + * return, the return value is a signal to deliver to the target, + * or 0 if no signal should be delivered, ie the signal that caused + * us to stop should be ignored. + */ int gdb_handlesig(CPUState *, int); void gdb_signalled(CPUArchState *, int); void gdbserver_fork(CPUState *);