From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 20090 invoked by alias); 23 Feb 2007 15:59:42 -0000 Received: (qmail 20078 invoked by uid 22791); 23 Feb 2007 15:59:41 -0000 X-Spam-Check-By: sourceware.org Received: from reserv6.univ-lille1.fr (HELO reserv6.univ-lille1.fr) (193.49.225.20) by sourceware.org (qpsmtpd/0.31) with ESMTP; Fri, 23 Feb 2007 15:59:30 +0000 Received: from malonne.lifl.fr (malonne.lifl.fr [134.206.10.29]) by reserv6.univ-lille1.fr (8.13.7/jtpda-5.3.1) with ESMTP id l1NFx1Lb031602 for ; Fri, 23 Feb 2007 16:59:01 +0100 Received: from [134.206.11.20] (pcsmi2.lifl.fr [134.206.11.20]) by malonne.lifl.fr with ESMTP id l1NFx4709166 for ; Fri, 23 Feb 2007 16:59:04 +0100 (MET) Message-ID: <45DF0F48.60507@inria.fr> Date: Fri, 23 Feb 2007 17:37:00 -0000 From: Christophe Demarey User-Agent: Thunderbird 1.5.0.9 (X11/20070103) MIME-Version: 1.0 To: gdb@sourceware.org Subject: test availability of variables in context from user command Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-2.0.2 (reserv6.univ-lille1.fr [193.49.225.20]); Fri, 23 Feb 2007 16:59:01 +0100 (CET) X-USTL-MailScanner-Information: Please contact the ISP for more information X-USTL-MailScanner: Found to be clean X-USTL-MailScanner-From: christophe.demarey@inria.fr Mailing-List: contact gdb-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-owner@sourceware.org X-SW-Source: 2007-02/txt/msg00248.txt.bz2 Hello, I want to check the availability of a variable (var1 for instance) in the context from an user command but I don't find any way to do this. Here is a (dummy) example of what I want to do : void func1(void) { int var2 = 2; ... } int main(int argc, char **argv) { int var1 = 1; ... func1(); } My gdb command: define myfunc if defined(var1) $res = $var1 else $res = $var2 end ... end If I break into main, res should be equals to 1, else res should be equals to 2. Is there a way to do this with gdb? Thanks, Christophe.