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
Date: Fri, 24 Aug 2007 18:29:00 -0000	[thread overview]
Message-ID: <46CF22CA.6090708@baymicrosystems.com> (raw)
In-Reply-To: <ur6lsvo1c.fsf@gnu.org>

Eli Zaretskii wrote:
>> Date: Fri, 24 Aug 2007 09:37:25 -0700
>> From: Sheng-Liang Song <ssl@baymicrosystems.com>
>>
>> BTW, Is there a gdb script functional document?
>>     
>
> The GDB scripting commands are documented in the GDB user manual.  See
> the node "Sequences".
>   
Hi,

I am looking for a more detail document.
(just like this vim script doc with examples):
  http://vimdoc.sourceforge.net/htmldoc/usr_41.html


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?

Is a gdb script grammar like this one:
  http://www.nongnu.org/hcb/

$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 would like to write a script like this:

if  isMember($vec,_M_impl)
  //do something
else
  //do something else
end


I have some examples that works on gdb.6.6 only.

define adder
  if $argc == 1
    print $arg0
  end
  if $argc == 2
    print $arg0 + $arg1
  end
  if $argc == 3
    print $arg0 + $arg1 + $arg2
  end
end

define p_stl_vector64
  set $vec = ($arg0)
  set $vec_begin = 0
  set $vec_size = $vec->_M_impl->_M_finish - $vec->_M_impl->_M_start
  set $vec_end = $vec_size - 1
  if $argc == 3  
    set $vec_begin = ($arg1)
  end
  if $argc == 3
    set $vec_end  = ($arg2)
  end
  if ($vec_size != 0)
    set $i = 0
    while ($i <= $vec_end)
      printf "Vector Element %d:  ", $i
      p *($vec->_M_impl->_M_start+$i)
      set $i++
    end
  end
end


GNU gdb Red Hat Linux (6.3.0.0-1.132.EL4rh) 
(DOES NOT WORK!)

(gdb) adder 1 2 3
Invalid type combination in equality test.


GNU gdb 6.6  (works)
(gdb) adder 1 2 3
$1 = 6





  reply	other threads:[~2007-08-24 18:29 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-08-23 21:19 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 [this message]
2007-08-25  9:58         ` Eli Zaretskii
2007-08-27 18:30           ` reference environment variables from gdb scripts (gdb and unix pipe) Sheng-Liang Song
2007-08-28 21:03             ` 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=46CF22CA.6090708@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