Mirror of the gdb mailing list
 help / color / mirror / Atom feed
* access variables in canned command sequences
@ 2007-04-06 18:26 vb
  2007-04-06 18:52 ` Michael Snyder
  2007-04-09 10:19 ` Nick Roberts
  0 siblings, 2 replies; 7+ messages in thread
From: vb @ 2007-04-06 18:26 UTC (permalink / raw)
  To: gdb

Hello all,

I need to be able pass a convenience variable defined in gdb command
file to a shell script from inside a canned sequence, something like
this:

set $offs=0x1ff80000
define xyz
        shell echo offset is  $offs
end

what happens when I run it - the parameter does not get passed to the
shell at all:

(gdb) xyz
offset is
(gdb)


What gives?!

Any help would be highly appreciated,
cheers,
Vadim


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

* Re: access variables in canned command sequences
  2007-04-06 18:26 access variables in canned command sequences vb
@ 2007-04-06 18:52 ` Michael Snyder
  2007-04-08 14:06   ` Daniel Jacobowitz
  2007-04-09 10:19 ` Nick Roberts
  1 sibling, 1 reply; 7+ messages in thread
From: Michael Snyder @ 2007-04-06 18:52 UTC (permalink / raw)
  To: vb; +Cc: gdb

On Fri, 2007-04-06 at 11:26 -0700, vb wrote:
> Hello all,
> 
> I need to be able pass a convenience variable defined in gdb command
> file to a shell script from inside a canned sequence, something like
> this:
> 
> set $offs=0x1ff80000
> define xyz
>         shell echo offset is  $offs
> end
> 
> what happens when I run it - the parameter does not get passed to the
> shell at all:
> 
> (gdb) xyz
> offset is
> (gdb)
> 
> 
> What gives?!

I imagine that the command "echo offset is $offs" is passed directly
to the shell.  The shell doesn't have a variable $offs, so nothing 
gets printed.

I'm not sure how to work around this.


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

* Re: access variables in canned command sequences
  2007-04-06 18:52 ` Michael Snyder
@ 2007-04-08 14:06   ` Daniel Jacobowitz
  0 siblings, 0 replies; 7+ messages in thread
From: Daniel Jacobowitz @ 2007-04-08 14:06 UTC (permalink / raw)
  To: Michael Snyder; +Cc: vb, gdb

On Fri, Apr 06, 2007 at 11:51:59AM -0700, Michael Snyder wrote:
> On Fri, 2007-04-06 at 11:26 -0700, vb wrote:
> > Hello all,
> > 
> > I need to be able pass a convenience variable defined in gdb command
> > file to a shell script from inside a canned sequence, something like
> > this:
> > 
> > set $offs=0x1ff80000
> > define xyz
> >         shell echo offset is  $offs
> > end
> > 
> > what happens when I run it - the parameter does not get passed to the
> > shell at all:
> > 
> > (gdb) xyz
> > offset is
> > (gdb)
> > 
> > 
> > What gives?!
> 
> I imagine that the command "echo offset is $offs" is passed directly
> to the shell.  The shell doesn't have a variable $offs, so nothing 
> gets printed.

That's right.  This would work:
define xyz
       printf "offset is %d", $offs
end

The CLI does not have a lot of ways to manipulate strings.

-- 
Daniel Jacobowitz
CodeSourcery


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

* Re: access variables in canned command sequences
  2007-04-06 18:26 access variables in canned command sequences vb
  2007-04-06 18:52 ` Michael Snyder
@ 2007-04-09 10:19 ` Nick Roberts
  2007-04-09 19:39   ` vb
  1 sibling, 1 reply; 7+ messages in thread
From: Nick Roberts @ 2007-04-09 10:19 UTC (permalink / raw)
  To: vb; +Cc: gdb

 > I need to be able pass a convenience variable defined in gdb command
 > file to a shell script from inside a canned sequence, something like
 > this:
 > 
 > set $offs=0x1ff80000
 > define xyz
 >         shell echo offset is  $offs
 > end

define xyz
  printf "offset is %d\n", $offs
end

-- 
Nick                                           http://www.inet.net.nz/~nickrob


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

* Re: access variables in canned command sequences
  2007-04-09 10:19 ` Nick Roberts
@ 2007-04-09 19:39   ` vb
  2007-04-09 22:09     ` Nick Roberts
  0 siblings, 1 reply; 7+ messages in thread
From: vb @ 2007-04-09 19:39 UTC (permalink / raw)
  To: Nick Roberts; +Cc: gdb

On 4/9/07, Nick Roberts <nickrob@snap.net.nz> wrote:

>
> define xyz
>   printf "offset is %d\n", $offs
> end
>

Yeah, this works as we know, but is there any way of passing an
internal variable value to the shell?

Somebody mentioned setting up an environment variable - this seems
interesting, I tried

set environment offset 0x1000
shell env | grep offset

`offset' does not get set for the shell started from within gdb....

Would there be any other way?

cheers,
/vb


> --
> Nick                                           http://www.inet.net.nz/~nickrob
>


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

* Re: access variables in canned command sequences
  2007-04-09 19:39   ` vb
@ 2007-04-09 22:09     ` Nick Roberts
  2007-04-10 19:05       ` vb
  0 siblings, 1 reply; 7+ messages in thread
From: Nick Roberts @ 2007-04-09 22:09 UTC (permalink / raw)
  To: vb; +Cc: gdb

 > > define xyz
 > >   printf "offset is %d\n", $offs
 > > end
 > >
 > 
 > Yeah, this works as we know, but is there any way of passing an
 > internal variable value to the shell?

It's not clear to me what you want to do but you could write the data to a
file and read that file from the shell script:

 set logging file input.dat

 define xyz
   set logging on
   printf "offset is %d\n", $offs
   set logging off
 end

However, perhaps we know that too.  AFAIK convenience variables are handled in
GDB just like ordinary program variables.  I don't think you can currently
regard the GDB command line as a program language but Daniel Jacobowitz is
working on something more powerful.

 > Somebody mentioned setting up an environment variable - this seems
 > interesting, I tried
 > 
 > set environment offset 0x1000
 > shell env | grep offset
 > 
 > `offset' does not get set for the shell started from within gdb....

(gdb) help set environment
Set environment variable value to give the program.
                                  ^^^^
-- 
Nick                                           http://www.inet.net.nz/~nickrob


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

* Re: access variables in canned command sequences
  2007-04-09 22:09     ` Nick Roberts
@ 2007-04-10 19:05       ` vb
  0 siblings, 0 replies; 7+ messages in thread
From: vb @ 2007-04-10 19:05 UTC (permalink / raw)
  To: Nick Roberts; +Cc: gdb

On 4/9/07, Nick Roberts <nickrob@snap.net.nz> wrote:
>  > > define xyz
>  > >   printf "offset is %d\n", $offs
>  > > end
>  > >
>  >
>  > Yeah, this works as we know, but is there any way of passing an
>  > internal variable value to the shell?
>
> It's not clear to me what you want to do but you could write the data to a
> file and read that file from the shell script:
>
>  set logging file input.dat
>
>  define xyz
>    set logging on
>    printf "offset is %d\n", $offs
>    set logging off
>  end
>
> However, perhaps we know that too.


No, this I did not know, and it probably will do what I need, let me look.

Thanks a lot for the hint, Nick!

cheers
vadim
>  AFAIK convenience variables are handled in
> GDB just like ordinary program variables.  I don't think you can currently
> regard the GDB command line as a program language but Daniel Jacobowitz is
> working on something more powerful.
>
>  > Somebody mentioned setting up an environment variable - this seems
>  > interesting, I tried
>  >
>  > set environment offset 0x1000
>  > shell env | grep offset
>  >
>  > `offset' does not get set for the shell started from within gdb....
>
> (gdb) help set environment
> Set environment variable value to give the program.
>                                   ^^^^
> --
> Nick                                           http://www.inet.net.nz/~nickrob
>


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

end of thread, other threads:[~2007-04-10 19:05 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-04-06 18:26 access variables in canned command sequences vb
2007-04-06 18:52 ` Michael Snyder
2007-04-08 14:06   ` Daniel Jacobowitz
2007-04-09 10:19 ` Nick Roberts
2007-04-09 19:39   ` vb
2007-04-09 22:09     ` Nick Roberts
2007-04-10 19:05       ` vb

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