This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Provision for array as debugger variable


On Monday 12 September 2011 15:14:52, Abhijit Halder wrote:
> On Mon, Sep 12, 2011 at 7:12 PM, Pedro Alves <pedro@codesourcery.com> wrote:
> > On Monday 12 September 2011 13:44:15, Abhijit Halder wrote:
> >
> >> in GDB we can do this to define a debugger variable:
> >> (gdb) set $var
> >>
> >> The $var is a scalar variable. Can we define similarly an array?
> >
> > (gdb) set $var1 = {0, 1}
> > (gdb) ptype $var1
> > type = int [2]
> > (gdb) p $var1
> > $1 = {0, 1}
> >
> > (gdb) set $var2 = (char[2]) {0, 1}
> > (gdb) ptype $var2
> > type = char [2]
> > (gdb) p $var2
> > $2 = "\000\001"
> >
> > --
> > Pedro Alves
> >
> 
> Okay I got it. I'm just curious about whether we can have similarly
> dynamic array and associative array along with it, and at the same
> time some functionality on top of this, like push etc. function as in
> perl. This will be an approach towards making gdb in itself as a
> mature scripting language. Just a thought!

This array syntax I've shown is meant to create artificial arrays that
can be passed to the inferior in function calls, and do manipulations
on them as if they came from the inferior in the first place.
If you want better handling of arrays for use in scripts,
a better approach that should work now, would be to use python
instead of the CLI.

-- 
Pedro Alves


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]