From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 3055 invoked by alias); 11 Jul 2008 13:46:58 -0000 Received: (qmail 3042 invoked by uid 22791); 11 Jul 2008 13:46:56 -0000 X-Spam-Check-By: sourceware.org Received: from mail.codesourcery.com (HELO mail.codesourcery.com) (65.74.133.4) by sourceware.org (qpsmtpd/0.31) with ESMTP; Fri, 11 Jul 2008 13:46:39 +0000 Received: (qmail 6541 invoked from network); 11 Jul 2008 13:46:37 -0000 Received: from unknown (HELO orlando.local) (pedro@127.0.0.2) by mail.codesourcery.com with ESMTPA; 11 Jul 2008 13:46:37 -0000 From: Pedro Alves To: gdb-patches@sourceware.org Subject: Re: [MI non-stop 07/11, RFA] Allow all CLI command even if target is executing. Date: Fri, 11 Jul 2008 13:46:00 -0000 User-Agent: KMail/1.9.9 Cc: Vladimir Prus References: <200806282055.45829.vladimir@codesourcery.com> In-Reply-To: <200806282055.45829.vladimir@codesourcery.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200807111446.36378.pedro@codesourcery.com> X-IsSubscribed: yes Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2008-07/txt/msg00199.txt.bz2 A Saturday 28 June 2008 17:55:45, Vladimir Prus escreveu: > There are several strategies to accepting commands when inferior_ptid is > running. One approach is to plain disallow all commands when inferior_ptid > is running. This seems too strict. Clearly, setting ignore count of > a breakpoint does not require any access to the target at all. Another > approach is to document which commands may be allowed when the target is > running. The problem is that each individual command may work or not work > depending on the properties of the target. > > So, it's better to allow all commands up-front, and emit an error if we > try an operation that the current target does not allow. This way, we'll > never mistakenly prevent an operation that the target actually can perform. > In case of error, the frontend may show the error to the user, and user > change either change his mind, or explicitly stop a thread, or ask the > frontend to implicitly interrupt the target, or ask gdb to do same. > > OK? > I think this is the right direction. In many cases, the error that will come out of the target is just plain non-sense, so we should catch the offensive command earlier if possible. E.g., reading registers from a running thread in linux will error out with the same error as if the thread does not exist at all, a very confusing error. I even added the infrun.c:ensure_not_running function and its calls to that effect. Since only non-stop is affected by this, I think it's a sane direction. Then we get to protect commands or make the targets throw more reasonable errors as we find them. Better than releasing GDB to users with non-stop, then having them not being able to execute some command simply because we forgot to that it as "safe". The other perspective is that there will be surelly code paths that may bork as not expecting an exception, hence the cleanups may not be setup correctly. But, those are bugs we should fix anyway. > - Volodya > > * gdb/top.c (execute_command_1): Don't check if the inferiour > is running. > --- > gdb/top.c | 8 -------- > 1 files changed, 0 insertions(+), 8 deletions(-) > > diff --git a/gdb/top.c b/gdb/top.c > index e09ccaa..a891a43 100644 > --- a/gdb/top.c > +++ b/gdb/top.c > @@ -444,14 +444,6 @@ execute_command_1 (char *p, int from_tty, int > internal) && !get_cmd_no_selected_thread_ok (c)) > error (_("\ > Cannot execute this command without a selected thread. See `help > thread'")); - /* If the target is running, we allow only a limited set > of - commands. */ > - else if (target_can_async_p () > - && target_has_execution > - && ((!non_stop && any_running ()) > - || (non_stop && is_running (inferior_ptid))) > - && !get_cmd_async_ok (c)) > - error (_("Cannot execute this command while the target is running.")); > > /* Pass null arg rather than an empty one. */ > arg = *p ? p : 0; -- Pedro Alves