From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 30769 invoked by alias); 16 Mar 2006 18:54:36 -0000 Received: (qmail 30760 invoked by uid 22791); 16 Mar 2006 18:54:35 -0000 X-Spam-Check-By: sourceware.org Received: from fra-del-01.spheriq.net (HELO fra-del-01.spheriq.net) (195.46.51.97) by sourceware.org (qpsmtpd/0.31) with ESMTP; Thu, 16 Mar 2006 18:54:34 +0000 Received: from fra-out-02.spheriq.net (fra-out-02.spheriq.net [195.46.51.130]) by fra-del-01.spheriq.net with ESMTP id k2GIsVqO006046 for ; Thu, 16 Mar 2006 18:54:31 GMT Received: from fra-cus-02.spheriq.net (fra-cus-02.spheriq.net [195.46.51.38]) by fra-out-02.spheriq.net with ESMTP id k2GIsT7r029774 for ; Thu, 16 Mar 2006 18:54:29 GMT Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by fra-cus-02.spheriq.net with ESMTP id k2GIsRKn024889 (version=TLSv1/SSLv3 cipher=EDH-RSA-DES-CBC3-SHA bits=168 verify=OK); Thu, 16 Mar 2006 18:54:29 GMT Received: from zeta.dmz-eu.st.com (ns2.st.com [164.129.230.9]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id E7764DCB6; Thu, 16 Mar 2006 18:12:12 +0000 (GMT) Received: from mail1.bri.st.com (mail1.bri.st.com [164.129.8.218]) by zeta.dmz-eu.st.com (STMicroelectronics) with ESMTP id D10CA4747D; Thu, 16 Mar 2006 18:16:01 +0000 (GMT) Received: from [164.129.15.13] (terrorhawk.bri.st.com [164.129.15.13]) by mail1.bri.st.com (MOS 3.5.8-GR) with ESMTP id CHJ07090 (AUTH stubbsa); Thu, 16 Mar 2006 18:12:05 GMT Message-ID: <4419A9E7.3010807@st.com> Date: Thu, 16 Mar 2006 23:09:00 -0000 From: Andrew STUBBS User-Agent: Thunderbird 1.5 (Windows/20051201) MIME-Version: 1.0 To: Alex Bennee , gdb@sources.redhat.com Subject: Re: Fully automating GDB (aka how to make canned command strings see the exit status) References: <1142529081.5372.14.camel@okra.transitives.com> <20060316171829.GA15821@nevyn.them.org> In-Reply-To: <20060316171829.GA15821@nevyn.them.org> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-O-Spoofed: Not Scanned X-O-General-Status: No X-O-Spam1-Status: Not Scanned X-O-Spam2-Status: Not Scanned X-O-URL-Status: Not Scanned X-O-Virus1-Status: No X-O-Virus2-Status: Not Scanned X-O-Virus3-Status: No X-O-Virus4-Status: No X-O-Virus5-Status: Not Scanned X-O-Image-Status: Not Scanned X-O-Attach-Status: Not Scanned X-SpheriQ-Ver: 4.2.01 X-IsSubscribed: yes Mailing-List: contact gdb-help@sourceware.org; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-owner@sourceware.org X-SW-Source: 2006-03/txt/msg00104.txt.bz2 Daniel Jacobowitz wrote: > On Thu, Mar 16, 2006 at 05:11:21PM +0000, Alex Bennee wrote: >> Hi, >> >> I've got a program I'm trying to debug that crashes on a very >> intermittent basis. I suspect the core dumps I'm getting are incomplete >> so I would like to try and catch the the crash live in gdb. >> >> I figure a canned script to run the program is the answer. However how >> do I tell if the program has exited successfully (in which case I can >> run again) to hitting the SEG and staying put for when I come back in >> the morning? > > There's lots of ways you can do this. There's nothing in the GDB > command line scripting language that will work, but you can drive > GDB using something like "expect" instead; have the expect script stop > when it sees a SIGSEGV in the output. Actually, if $_exitcode is not set (or is void) then no program has exited properly. Otherwise, $_exitcode is what it says on the tin. Of course, there's no direct way to test for undefined variables (and anyway as soon as you look as them they are no longer undefined as such), and there is no way to compare void, but there is an indirect way. Use init-if-undefined to set $_exitcode to some unlikely value (999999 perhaps) and then check that. The script might be run init-if-undefined $_exitcode = 999999 if $_exitcode != 999999 quit endif That's untested, and GDB 6.4 only. HTH Andrew