From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 9236 invoked by alias); 16 Jun 2013 05:56:22 -0000 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 Received: (qmail 9213 invoked by uid 89); 16 Jun 2013 05:56:16 -0000 X-Spam-SWARE-Status: No, score=-6.8 required=5.0 tests=AWL,BAYES_00,RCVD_IN_HOSTKARMA_W,RCVD_IN_HOSTKARMA_WL,RP_MATCHES_RCVD,SPF_HELO_PASS,SPF_PASS autolearn=ham version=3.3.1 Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.84/v0.84-167-ge50287c) with ESMTP; Sun, 16 Jun 2013 05:56:15 +0000 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r5G5uDnd018700 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Sun, 16 Jun 2013 01:56:14 -0400 Received: from psique (ovpn-113-133.phx2.redhat.com [10.3.113.133]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id r5G5uAMo012256 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES128-SHA bits=128 verify=NO); Sun, 16 Jun 2013 01:56:12 -0400 From: Sergio Durigan Junior To: Pedro Alves Cc: GDB Patches Subject: Re: [RFC/PATCH] Add new internal variable $_signo References: <51BB5592.9060502@redhat.com> X-URL: http://www.redhat.com Date: Sun, 16 Jun 2013 05:57:00 -0000 In-Reply-To: <51BB5592.9060502@redhat.com> (Pedro Alves's message of "Fri, 14 Jun 2013 18:40:34 +0100") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-SW-Source: 2013-06/txt/msg00350.txt.bz2 On Friday, June 14 2013, Pedro Alves wrote: > On 06/14/2013 01:37 AM, Sergio Durigan Junior wrote: >> - print_signal_exited_reason (ecs->ws.value.sig); >> + { >> + print_signal_exited_reason (ecs->ws.value.sig); >> + /* Set the value of the internal variable $_signo to hold the >> + signal number received by the inferior. */ >> + set_internalvar_integer (lookup_internalvar ("_signo"), >> + (LONGEST) ecs->ws.value.sig); >> + } > > This bit is actually implementing a counterpart of the existing > $_exitcode. At this point the inferior is gone already, > and $_siginfo couldn't ever work, even if the backend supports it. > > This case is actually a different scenario from $_siginfo. I think > it'd make more sense to call this one $_exitsignal, as sibling > of the existing $_exitcode. $_exitcode records the inferior's exit > code for normal exits, $_exitsignal would record the signal number > for signal exits. Like $_exitcode, $_exitsignal should print the > same signal number until the inferior exits again, no matter which > thread you're looking at. Looked like that, $_exitsignal just > seems like an obvious omission. OK, I have a patch for $_exitcode now, will send soon. I've made some assumptions, will explain them when I send the patch. > Since when debugging a core file you're seeing a snapshot of the > inferior _before_ it exited, I think pedantically it makes more > sense for corelow to _not_ set $_exitsignal. However, should > still be able to get the info from the $_signo of the thread that > exited (the one that gets selected when you load the core). Yes, given the separation you proposed, I agree. > So in sum, here are my suggestions: > > Add $_signo, but make it print the signal of the last event the > thread received. I'd add a last_status field in struct thread_info > to record that info. Don't implement $_signo as a regular > integer convenience variable that gets set whenever a thread > reports an event. That won't work correctly in non-stop mode, > where you can be looking at thread #1, while other threads > could be hitting events (but the user remains with thread #1 > selected). See how the $_thread variable is implemented as lazy > convenience, very similar to what you need. Thanks, I will work on it this Sunday, hope to have something work soon. > If you're willing and I think it'd be a nice addition too, > add $_exitsignal, and make it print the uncaught signal that made > the process die. Document it with something like: > > @item $_exitcode > @vindex $_exitcode@r{, convenience variable} > The variable @code{$_exitcode} is automatically set to the exit code when > -the program being debugged terminates. > +the program being debugged terminates normally. > + > +@item $_exitsignal > +@vindex $_exitsignal@r{, convenience variable} > +The variable @code{$_exitsignal} is automatically set to the > +signal number when the program being debugged dies due to an > +uncaught signal. > > I suggest making $_signo and $_exitsignal separate patches, > even. Yeah, a patch's coming. > BTW, IMO, $_exitcode (and $_exitsignal) should print the exit > code/signal of the selected inferior. It was never adjusted > for multi-inferior, so it always prints the exit code of the > inferior that happened to exit last. Simon's patch for > displaying the inferior's exit-code in MI's -list-thread-groups records > the info in the inferior struct. Once that is in, we'd just need to > make $_exitcode a lazy convenience var too. OK, this paragraph mades sense but made me feel a bit confused. Anyway, I will send the $_exitsignal patch implemented as $_exitcode is implemented now, and if you feel it should be different, you can comment there. >> The patch also contains a testcase and an update to the documentation in >> order to mention the new convenience variable. > > The patch adds code to handle signalled live inferiors, but the > test didn't exercise that. I will add that in the next iteration. >> +@item $_signo >> +@vindex $_signo@r{, convenience variable} >> +The variable @code{$_signo} contains the signal number received by the >> +inferior. > >> +Its purpose is to serve as an auxiliary way of retrieving >> +such information for when the kernel does not provide the necessary >> +support for @code{$_siginfo} to be used. > > IMO, this whole sentence would be better reduced to: "Unlike $_siginfo > below, $_signo is always available in all supported targets." > > $_signo should work on Windows, for example, where there's no > concept of $_siginfo. OK, fair enough. I will update the docs as well. Thanks, -- Sergio