Mirror of the gdb mailing list
 help / color / mirror / Atom feed
From: Sheng-Liang Song <ssl@baymicrosystems.com>
To: Eli Zaretskii <eliz@gnu.org>, gdb@sourceware.org
Cc: jan.kratochvil@redhat.com, koling@kchang.net
Subject: Re: reference environment variables from gdb scripts  (gdb and unix  pipe)
Date: Mon, 27 Aug 2007 18:30:00 -0000	[thread overview]
Message-ID: <46D31638.5030200@baymicrosystems.com> (raw)
In-Reply-To: <umywguegu.fsf@gnu.org>

Hi,

Thanks for the info. 

gdb has "shell" command to switch to a unix shell.
After switch to a unix shell, can I call gdb functions/commands?

Does gdb supports "pipe" command? 
Is there a plan to add a "unix pipe" command to gdb debug prompt?

(gdb) p $2
$3 = {<std::_Vector_base<int,std::allocator<int> >> = {
    _M_impl = {<std::allocator<int>> = {<__gnu_cxx::new_allocator<int>> 
= {<No data fields>}, <No data fields>}, _M_start = 0x502010, _M_finish 
= 0x50201c,
      _M_end_of_storage = 0x50201c}}, <No data fields>}

(gdb) p$2 | my_unix_program_to_do_some_data_processing  ( a pipe, "|", 
would be nice to have!)

(gdb)  if ($?)  check the returns end

(gdb) shell
%  gdb p $2  //I lost the control to the gdb environment. 

(gdb) !my_sell_program_take_a_argument  $2   
(It would be nice if I can use "!" to execute my shell program.)

Thanks,

Sheng-Liang

Eli Zaretskii wrote:
>> Date: Fri, 24 Aug 2007 11:26:18 -0700
>> From: Sheng-Liang Song <ssl@baymicrosystems.com>
>> 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.
>   


  reply	other threads:[~2007-08-27 18:30 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-08-23 21:19 reference environment variables from gdb scripts rockwellkc
2007-08-24  8:58 ` Jan Kratochvil
2007-08-24 16:38   ` Sheng-Liang Song
2007-08-24 17:30     ` Eli Zaretskii
2007-08-24 18:29       ` Sheng-Liang Song
2007-08-25  9:58         ` Eli Zaretskii
2007-08-27 18:30           ` Sheng-Liang Song [this message]
2007-08-28 21:03             ` reference environment variables from gdb scripts (gdb and unix pipe) Jim Blandy
2007-08-28 21:08               ` GDB Tool Chains McGuerty, Jay S.
2007-08-28 21:56                 ` Peter Toft
2007-08-28 21:59                 ` Jim Blandy

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=46D31638.5030200@baymicrosystems.com \
    --to=ssl@baymicrosystems.com \
    --cc=eliz@gnu.org \
    --cc=gdb@sourceware.org \
    --cc=jan.kratochvil@redhat.com \
    --cc=koling@kchang.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox