From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 17439 invoked by alias); 25 Aug 2007 09:58:21 -0000 Received: (qmail 17268 invoked by uid 22791); 25 Aug 2007 09:58:20 -0000 X-Spam-Check-By: sourceware.org Received: from nitzan.inter.net.il (HELO nitzan.inter.net.il) (213.8.233.22) by sourceware.org (qpsmtpd/0.31) with ESMTP; Sat, 25 Aug 2007 09:58:12 +0000 Received: from HOME-C4E4A596F7 (IGLD-84-228-237-6.inter.net.il [84.228.237.6]) by nitzan.inter.net.il (MOS 3.7.3a-GA) with ESMTP id HPX62145 (AUTH halo1); Sat, 25 Aug 2007 12:51:24 +0300 (IDT) Date: Sat, 25 Aug 2007 09:58:00 -0000 Message-Id: From: Eli Zaretskii To: Sheng-Liang Song CC: gdb@sourceware.org, jan.kratochvil@redhat.com, koling@kchang.net In-reply-to: <46CF22CA.6090708@baymicrosystems.com> (message from Sheng-Liang Song on Fri, 24 Aug 2007 11:26:18 -0700) Subject: Re: reference environment variables from gdb scripts Reply-to: Eli Zaretskii References: <12302351.post@talk.nabble.com> <20070824085740.GA11291@host0.dyn.jankratochvil.net> <46CF0945.8090901@baymicrosystems.com> <46CF22CA.6090708@baymicrosystems.com> X-IsSubscribed: yes 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-08/txt/msg00216.txt.bz2 > Date: Fri, 24 Aug 2007 11:26:18 -0700 > From: Sheng-Liang Song > CC: jan.kratochvil@redhat.com, koling@kchang.net > > Eli Zaretskii wrote: > > The GDB scripting commands are documented in the GDB user manual. See > > the node "Sequences". > > > > I am looking for a more detail document. There isn't one, because I believe everything is described in the user manual. If you find something that isn't there, please tell. > What is the different between "." and "->" operator in gdb script? > (Looks like no difference to me. works the same.) > > What operators does gdb 6.6 support? This is not specific to scripts. GDB uses operators from the source language, with C/C++ operators being supported more thoroughly than those of other languages. See the node "C Operators" in the manual for C/C++, and similar nodes for other languages in language-specific sections under the node "Supported Languages". In general, anything that is not described in the node "Sequences" and its sub-nodes is not specific to scripting, but is just a feature of normal GDB interaction with the user. > Is a gdb script grammar like this one: > http://www.nongnu.org/hcb/ There's no formal description of the script grammar, since the GDB scripting is just a thin add-on to CLI, the command-line interpreter built into GDB, and CLI is for human interactions, not for programs. Humans don't need a formal grammar to interact with programs, only the format of each command. > $vec->_M_impl > STL vector does not have the member var _M_impl. > gdb) will report: There is no member or method named _M_impl. > > How do I check if $vec has the member _M_impl? I don't think you can, but I don't consider myself a GDB scripting guru. Maybe someone else here will be able to help you. > I would like to write a script like this: > > if isMember($vec,_M_impl) > //do something > else > //do something else > end One way of doing that would be to define within $vec a boolean member that has the value TRUE only if _M_impl is a valid member, then you can check for that boolean flag. Another way is to have a function isMember inside the $vec class (or a global function in your program) that would _return_ such a boolean, then you can use what you wrote above almost verbatim, since GDB can call functions within the debuggee. IOW, whatever you want to test must be already present as data in your program, or else GDB scripting and CLI will not be able to use it in the `if' clause. Admittedly, such a scripting is quite limited, which is why there're plans to add an extension language (Python) to GDB.