* Problem Assining Values to Arrays in GDB 4.17
[not found] <a0c090600804020928v7e2ae98ey1a359889c5b1abc1@mail.gmail.com>
@ 2008-04-02 16:32 ` JBWeeN
2008-04-02 18:09 ` Michael Snyder
0 siblings, 1 reply; 4+ messages in thread
From: JBWeeN @ 2008-04-02 16:32 UTC (permalink / raw)
To: gdb
First of all, thanks for read my message.
I am having the following problem:
I am using GDB 4.17, I would like to upgrade it to a modern
version, but I am obliged.
In modern GDB releases I can assign directly values to an array
using the following sintax:
(gdb) set var myArray = {1.0, 2.0, 3.0, 4.0, 5.0,6.0}
But in this release (GDB 4.17) If I use the same command, I get the
following error:
(gdb) set var myArray = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0}
Invalid Cast
Looking for information about the problem I found that I could
solve the problem doing a direct cast:
(gdb) set var myArray = {double *} {1.0, 2.0, 3.0, 4.0, 5.0, 6.0}
I do not why, but this solution only works sometimes. Other times,
it appears the following error:
Cannot access memory at address 0x545f98.
It seems that GDB tries to modify myArray pointing to a new memory
address, but it is very strange that this new address not exists.
I know that I have another solution
(gdb) set myArray[0] = ...
(gdb) set myArray[1] = ...
(gdb) set myArray[2] = ...
(gdb) set myArray[3] = ...
But I have a lot of GDB scripts with a lot of arrays assignments
that use this syntax and I have to migrate them to GDB 4.17.
Is there any other way to assign array values directly?
Is there my only option to assing one by one? (I hope it is not)
Thanks for all,
Best Regards
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Problem Assining Values to Arrays in GDB 4.17
2008-04-02 16:32 ` Problem Assining Values to Arrays in GDB 4.17 JBWeeN
@ 2008-04-02 18:09 ` Michael Snyder
2008-04-03 5:33 ` JBWeeN
0 siblings, 1 reply; 4+ messages in thread
From: Michael Snyder @ 2008-04-02 18:09 UTC (permalink / raw)
To: JBWeeN; +Cc: gdb
Perhaps you could use memcpy?
On Wed, 2008-04-02 at 18:31 +0200, JBWeeN wrote:
> First of all, thanks for read my message.
> I am having the following problem:
>
> I am using GDB 4.17, I would like to upgrade it to a modern
> version, but I am obliged.
>
> In modern GDB releases I can assign directly values to an array
> using the following sintax:
> (gdb) set var myArray = {1.0, 2.0, 3.0, 4.0, 5.0,6.0}
>
> But in this release (GDB 4.17) If I use the same command, I get the
> following error:
> (gdb) set var myArray = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0}
> Invalid Cast
>
> Looking for information about the problem I found that I could
> solve the problem doing a direct cast:
> (gdb) set var myArray = {double *} {1.0, 2.0, 3.0, 4.0, 5.0, 6.0}
>
> I do not why, but this solution only works sometimes. Other times,
> it appears the following error:
> Cannot access memory at address 0x545f98.
>
> It seems that GDB tries to modify myArray pointing to a new memory
> address, but it is very strange that this new address not exists.
>
> I know that I have another solution
> (gdb) set myArray[0] = ...
> (gdb) set myArray[1] = ...
> (gdb) set myArray[2] = ...
> (gdb) set myArray[3] = ...
>
> But I have a lot of GDB scripts with a lot of arrays assignments
> that use this syntax and I have to migrate them to GDB 4.17.
>
> Is there any other way to assign array values directly?
>
> Is there my only option to assing one by one? (I hope it is not)
>
> Thanks for all,
>
> Best Regards
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Problem Assining Values to Arrays in GDB 4.17
2008-04-02 18:09 ` Michael Snyder
@ 2008-04-03 5:33 ` JBWeeN
2008-04-03 21:48 ` Michael Snyder
0 siblings, 1 reply; 4+ messages in thread
From: JBWeeN @ 2008-04-03 5:33 UTC (permalink / raw)
To: Michael Snyder; +Cc: gdb
It does not work, If a use a system call gdb says that command is undefined.
I get the following error:
(gdb) memcpy(myArray, {1.2, 2.0, 5.7}, 3*sizeof(double))
Undefined command: "memcpy". Try "help".
On Wed, Apr 2, 2008 at 8:09 PM, Michael Snyder <msnyder@specifix.com> wrote:
> Perhaps you could use memcpy?
>
>
> On Wed, 2008-04-02 at 18:31 +0200, JBWeeN wrote:
> > First of all, thanks for read my message.
> > I am having the following problem:
> >
> > I am using GDB 4.17, I would like to upgrade it to a modern
> > version, but I am obliged.
> >
> > In modern GDB releases I can assign directly values to an array
> > using the following sintax:
> > (gdb) set var myArray = {1.0, 2.0, 3.0, 4.0, 5.0,6.0}
> >
> > But in this release (GDB 4.17) If I use the same command, I get the
> > following error:
> > (gdb) set var myArray = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0}
> > Invalid Cast
> >
> > Looking for information about the problem I found that I could
> > solve the problem doing a direct cast:
> > (gdb) set var myArray = {double *} {1.0, 2.0, 3.0, 4.0, 5.0, 6.0}
> >
> > I do not why, but this solution only works sometimes. Other times,
> > it appears the following error:
> > Cannot access memory at address 0x545f98.
> >
> > It seems that GDB tries to modify myArray pointing to a new memory
> > address, but it is very strange that this new address not exists.
> >
> > I know that I have another solution
> > (gdb) set myArray[0] = ...
> > (gdb) set myArray[1] = ...
> > (gdb) set myArray[2] = ...
> > (gdb) set myArray[3] = ...
> >
> > But I have a lot of GDB scripts with a lot of arrays assignments
> > that use this syntax and I have to migrate them to GDB 4.17.
> >
> > Is there any other way to assign array values directly?
> >
> > Is there my only option to assing one by one? (I hope it is not)
> >
> > Thanks for all,
> >
> > Best Regards
>
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Problem Assining Values to Arrays in GDB 4.17
2008-04-03 5:33 ` JBWeeN
@ 2008-04-03 21:48 ` Michael Snyder
0 siblings, 0 replies; 4+ messages in thread
From: Michael Snyder @ 2008-04-03 21:48 UTC (permalink / raw)
To: JBWeeN; +Cc: gdb
On Thu, 2008-04-03 at 07:32 +0200, JBWeeN wrote:
> It does not work, If a use a system call gdb says that command is undefined.
> I get the following error:
> (gdb) memcpy(myArray, {1.2, 2.0, 5.7}, 3*sizeof(double))
> Undefined command: "memcpy". Try "help".
Ah, well, you see, gdb does not know "memcpy" as a
command, but it understands it as part of an expression.
(gdb) print memcpy (myArray, whatever, 3*sizeof(double))
For this special case of calling a function when you
do not really care to see the return value printed,
there is the command "call". Just substitute "call"
for "print" above.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2008-04-03 17:37 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[not found] <a0c090600804020928v7e2ae98ey1a359889c5b1abc1@mail.gmail.com>
2008-04-02 16:32 ` Problem Assining Values to Arrays in GDB 4.17 JBWeeN
2008-04-02 18:09 ` Michael Snyder
2008-04-03 5:33 ` JBWeeN
2008-04-03 21:48 ` Michael Snyder
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox