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: 920289 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=vivier.eu Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 40sfL23WR3z9s19 for ; Fri, 25 May 2018 18:19:21 +1000 (AEST) Received: from localhost ([::1]:42378 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fM7wR-0001n3-K7 for incoming@patchwork.ozlabs.org; Fri, 25 May 2018 04:19:15 -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+incoming=patchwork.ozlabs.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(+) 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 *);