Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* Provision for array as debugger variable
@ 2011-09-12 13:42 Abhijit Halder
  2011-09-12 14:15 ` Pedro Alves
  0 siblings, 1 reply; 4+ messages in thread
From: Abhijit Halder @ 2011-09-12 13:42 UTC (permalink / raw)
  To: gdb-patches

Hi,

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?

Thanks,
Abhijit Halder


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Provision for array as debugger variable
  2011-09-12 13:42 Provision for array as debugger variable Abhijit Halder
@ 2011-09-12 14:15 ` Pedro Alves
  2011-09-12 14:36   ` Abhijit Halder
  0 siblings, 1 reply; 4+ messages in thread
From: Pedro Alves @ 2011-09-12 14:15 UTC (permalink / raw)
  To: gdb-patches; +Cc: Abhijit Halder

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


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Provision for array as debugger variable
  2011-09-12 14:15 ` Pedro Alves
@ 2011-09-12 14:36   ` Abhijit Halder
  2011-09-12 15:11     ` Pedro Alves
  0 siblings, 1 reply; 4+ messages in thread
From: Abhijit Halder @ 2011-09-12 14:36 UTC (permalink / raw)
  To: Pedro Alves; +Cc: gdb-patches

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!


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Provision for array as debugger variable
  2011-09-12 14:36   ` Abhijit Halder
@ 2011-09-12 15:11     ` Pedro Alves
  0 siblings, 0 replies; 4+ messages in thread
From: Pedro Alves @ 2011-09-12 15:11 UTC (permalink / raw)
  To: Abhijit Halder; +Cc: gdb-patches

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


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2011-09-12 15:08 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-09-12 13:42 Provision for array as debugger variable Abhijit Halder
2011-09-12 14:15 ` Pedro Alves
2011-09-12 14:36   ` Abhijit Halder
2011-09-12 15:11     ` Pedro Alves

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox