* set $argv = *argv@100
@ 2002-02-11 21:48 Andrew Cagney
2002-02-11 22:22 ` Kevin Buettner
0 siblings, 1 reply; 4+ messages in thread
From: Andrew Cagney @ 2002-02-11 21:48 UTC (permalink / raw)
To: gdb
Consider the sequence:
(top-gdb) print argv
$4 = (char **) 0xbfbfd3cc
(top-gdb) set $argv = *argv@100
(top-gdb) print $argv
$5 = (char **) 0xbfbfd3cc
(top-gdb) print sizeof ($argv)
$6 = 0x4
(top-gdb) print sizeof (*argv@100)
$7 = 0x190
should $argv have been assigned the contents of *argv@100 or just the
address?
Contrast it with:
(top-gdb) print args
$9 = {func = 0x804d498 <captured_main>, func_args = 0xbfbfd8d4}
(top-gdb) set $a = args
(top-gdb) print $a
$10 = {func = 0x804d498 <captured_main>, func_args = 0xbfbfd8d4}
puzzled.
Andrew
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: set $argv = *argv@100
2002-02-11 21:48 set $argv = *argv@100 Andrew Cagney
@ 2002-02-11 22:22 ` Kevin Buettner
2002-02-12 7:32 ` Andrew Cagney
0 siblings, 1 reply; 4+ messages in thread
From: Kevin Buettner @ 2002-02-11 22:22 UTC (permalink / raw)
To: Andrew Cagney, gdb
On Feb 12, 12:47am, Andrew Cagney wrote:
> Consider the sequence:
>
> (top-gdb) print argv
> $4 = (char **) 0xbfbfd3cc
> (top-gdb) set $argv = *argv@100
> (top-gdb) print $argv
> $5 = (char **) 0xbfbfd3cc
> (top-gdb) print sizeof ($argv)
> $6 = 0x4
> (top-gdb) print sizeof (*argv@100)
> $7 = 0x190
>
> should $argv have been assigned the contents of *argv@100 or just the
> address?
I think the address is right. The problem is that $argv isn't the right
type. According to the above, it's ``char **'' when it should be
``char *[100]''.
Try this:
(top-gdb) set $argva = &(*argv@100)
(top-gdb) print $argva
$23 = (char *(*)[100]) 0xbffff99c
(top-gdb) ptype $argva
type = char *(*)[100]
(top-gdb) ptype *$argva
type = char *[100]
Kevin
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: set $argv = *argv@100
2002-02-11 22:22 ` Kevin Buettner
@ 2002-02-12 7:32 ` Andrew Cagney
2002-02-12 8:33 ` Kevin Buettner
0 siblings, 1 reply; 4+ messages in thread
From: Andrew Cagney @ 2002-02-12 7:32 UTC (permalink / raw)
To: Kevin Buettner; +Cc: gdb
>
> I think the address is right. The problem is that $argv isn't the right
> type. According to the above, it's ``char **'' when it should be
> ``char *[100]''.
>
> Try this:
>
> (top-gdb) set $argva = &(*argv@100)
> (top-gdb) print $argva
> $23 = (char *(*)[100]) 0xbffff99c
> (top-gdb) ptype $argva
> type = char *(*)[100]
> (top-gdb) ptype *$argva
> type = char *[100]
>
> Kevin
Yes, C strikes again. You can't copy an array, just its address :-(
sigh,
Andrew
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: set $argv = *argv@100
2002-02-12 7:32 ` Andrew Cagney
@ 2002-02-12 8:33 ` Kevin Buettner
0 siblings, 0 replies; 4+ messages in thread
From: Kevin Buettner @ 2002-02-12 8:33 UTC (permalink / raw)
To: Andrew Cagney; +Cc: gdb
On Feb 12, 10:32am, Andrew Cagney wrote:
> > I think the address is right. The problem is that $argv isn't the right
> > type. According to the above, it's ``char **'' when it should be
> > ``char *[100]''.
> >
> > Try this:
> >
> > (top-gdb) set $argva = &(*argv@100)
> > (top-gdb) print $argva
> > $23 = (char *(*)[100]) 0xbffff99c
> > (top-gdb) ptype $argva
> > type = char *(*)[100]
> > (top-gdb) ptype *$argva
> > type = char *[100]
> >
> > Kevin
>
> Yes, C strikes again. You can't copy an array, just its address :-(
I still think it'd be nice if we could somehow preserve the type
when doing set $argv = *argv@100...
(top-gdb) set $argv = *argv@100
(top-gdb) ptype $argv
type = char **
(top-gdb) ptype *argv@100
type = char *[100]
I.e, it'd be nice if the types of $argv and *argv@100 were the same.
I haven't thought this through though. It could be that a lot of other
stuff would break if we did this.
Kevin
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2002-02-12 16:33 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-02-11 21:48 set $argv = *argv@100 Andrew Cagney
2002-02-11 22:22 ` Kevin Buettner
2002-02-12 7:32 ` Andrew Cagney
2002-02-12 8:33 ` Kevin Buettner
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox