Home » Language IDEs » C / C++ IDE (CDT) » Cannot view typedef'ed array in debugger
Cannot view typedef'ed array in debugger [message #158595] |
Mon, 21 November 2005 07:48  |
Eclipse User |
|
|
|
Originally posted by: rabanerjee.nvidia.com
<snip>
typedef int Matrix[10];
main()
{
int i;
Matrix t;
return 0;
}
</snip>
when i run the above code snippet in Debug mode (using gdb) and try to
click and expand the value of the "t" variable, i get this console message:
"Attempt to take contents of a non-pointer value."
...and the debugger process terminates with a -1 exit value.
(strangely, if the variable is only highlighted, but not expanded fully,
the variable values show up at the bottom line correctly -- its the
expanding operation that causes the crash)
can anybody else reproduce this bug?
i'm using Eclipse 3.1.1 with CDT 3.0.1 running on Sun j2sdk1.4.2_10, all
on RedHat Linux 9 (x86).
--
thanks in advance,
rahul
|
|
| |
Re: Cannot view typedef'ed array in debugger [message #158812 is a reply to message #158629] |
Wed, 23 November 2005 07:28   |
Eclipse User |
|
|
|
Originally posted by: rabanerjee.nvidia.com
I think its partly CDT's fault that gdb crashes -- explanation follows:
<snip>
typedef int Matrix [4];
main()
{
Matrix t;
t[0]=0;
int i;
i=0;
}
</snip>
I dumped logs (from within gdbserver) of the MI input coming from CDT.
There appear to be TWO problems here:
Problem 1.
CDT, when populating its "Variables" view, fires off the following
commands
(I've shown the ones relevant to the variable "Matrix t")
-var-create' - * t
^done,name="var1",numchild="4",type="Matrix"
-var-show-attributes' var1
^done,attr="noneditable"
-var-evaluate-expression' var1
^done,value="[4]"
When the user (single)clicks on "t" in the "Variables" pane, CDT sends
this to gdb:
-data-evaluate-expression' t
^done,value="{0, 1073792608, -1073750152, 134513438}"
--
When you click on the drop-down arrow (or double-click) to see the
_individual_ elements of t, CDT fires off THIS command:
-var-create' - * *((t))@4
&"Attempt to take contents of a non-pointer value.\n"
^done,name="var2",numchild="4",type="int [4]"
[the way i see it, the command should either be
"-var-create' - * *(&(t[0]))@4"
or
"-var-create' - * *((t+0))@4"
...
or something else, but definitely _not_ *((t))
]
Since there are two different actions depending on whether the array is
expanded or not, this explains why it crashes only while stepping through
the code _after_ expanding the array.
That concludes Problem 1
(Remedy: CDT needs fixing in order to correctly resolve the primitive
types of typedef'ed arrays)
Problem 2.
From the GDB project mailing list:
(http://sources.redhat.com/ml/gdb/2005-02/msg00125.html)
<snip>
> -var-create on an expression that's invalid (eg. "(*1)")
> creates a variable and retains a ptr in var->value. That
> gets freed by free_all_values() next command. Later a
> -var-update or -var-evaluate-expression on that variable
> dereferences the freed memory, causing a seg. fault.
</snip>
As soon as CDT tries to get the values for the individual child elements
using the following command:
-var-list-children' var1
gdb instantly segfaults.
Essentially, CDT configures a time bomb inside gdb, ready to go off
anytime (depending on the source code you use, it may not occur right
after the var-list-children, but could occur at any time... with my setup,
the very next MI command sets it off)
The way I see it, if CDT does its job correctly, gdb should never receive
an illegal type inside -var-create and thereby, should never crash. Hence
this _is_ a bug inside CDT.
|
|
|
Re: Cannot view typedef'ed array in debugger [message #158817 is a reply to message #158629] |
Wed, 23 November 2005 07:36   |
Eclipse User |
|
|
|
Originally posted by: rabanerjee.nvidia.com
I think its partly CDT's fault that gdb crashes -- explanation follows:
typedef int Matrix [4];
main() {
Matrix t;
t[0]=0;
int i;
i=0;
}
I dumped logs (from within gdbserver) of the MI input coming from CDT.
There appear to be TWO problems here:
Problem 1.
CDT, when populating its "Variables" view, fires off the following
commands (I've shown the ones relevant to the variable "Matrix t")
-var-create' - * t
^done,name="var1",numchild="4",type="Matrix"
-var-show-attributes' var1
^done,attr="noneditable"
-var-evaluate-expression' var1
^done,value="[4]"
When the user (single)clicks on "t" in the "Variables" pane, CDT sends
this to gdb:
-data-evaluate-expression' t
^done,value="{0, 1073792608, -1073750152, 134513438}"
When you click on the drop-down arrow (or double-click) to see the
_individual_ elements of t, CDT fires off THIS command:
-var-create' - * *((t))@4
&"Attempt to take contents of a non-pointer value.\n"
^done,name="var2",numchild="4",type="int [4]"
[the way i see it, the command should be either
-var-create' - * *(&(t[0]))@4
or
-var-create' - * *((t+0))@4
...
or something else, but definitely _not_ *((t))
]
Since there are two different actions depending on whether the array is
expanded or not, this explains why it crashes only while stepping through
the code _after_ expanding the array. Rest of the explanation follows...
That concludes Problem 1
(Remedy: CDT needs fixing in order to correctly resolve the primitive
types of typedef'ed arrays)
Problem 2. From the GDB project mailing list:
(http://sources.redhat.com/ml/gdb/2005-02/msg00125.html)
"-var-create on an expression that's invalid (eg. "(*1)") creates a
variable and retains a ptr in var->value.
That gets freed by free_all_values() next command.
Later a -var-update or -var-evaluate-expression on that variable
dereferences the freed memory, causing a seg. fault."
As soon as CDT tries to get the values for the individual child elements
using the following command: -var-list-children' var1 gdb instantly
segfaults.
Essentially, CDT configures a time bomb inside gdb, ready to go off
anytime (depending on the source code you use, it may not occur right
after the var-list-children, but could occur at any time... with my setup,
the very next MI command sets it off)
The way I see it, if CDT does its job correctly, gdb should never receive
an illegal type inside -var-create and thereby, should never crash. Hence
this _is_ a bug inside CDT.
(Sorry for the mess inside the previous posting - i think the "snip" tags
made the parser think it was html and it tried to parse it, thereby
removing all extra whitespace)
|
|
|
Re: Cannot view typedef'ed array in debugger [message #159041 is a reply to message #158817] |
Fri, 25 November 2005 16:31  |
Eclipse User |
|
|
|
Originally posted by: mikhailk.qnx.com
I submitted a bug in Bugzilla with your comments -
https://bugs.eclipse.org/bugs/show_bug.cgi?id=118114.
It is easy to fix the first problem, but I haven't had a chance to look at
the gdb code.
Thank you.
"Rahul Banerjee" <rabanerjee@nvidia.com> wrote in message
news:60e271a997231157c3e6f590e5a9adc0$1@www.eclipse.org...
>I think its partly CDT's fault that gdb crashes -- explanation follows:
>
>
> typedef int Matrix [4];
> main() {
> Matrix t;
> t[0]=0;
> int i;
> i=0;
> }
>
> I dumped logs (from within gdbserver) of the MI input coming from CDT.
>
> There appear to be TWO problems here:
>
> Problem 1.
>
> CDT, when populating its "Variables" view, fires off the following
> commands (I've shown the ones relevant to the variable "Matrix t")
>
> -var-create' - * t
> ^done,name="var1",numchild="4",type="Matrix"
> -var-show-attributes' var1
> ^done,attr="noneditable"
>
> -var-evaluate-expression' var1
> ^done,value="[4]"
>
> When the user (single)clicks on "t" in the "Variables" pane, CDT sends
> this to gdb:
>
> -data-evaluate-expression' t
> ^done,value="{0, 1073792608, -1073750152, 134513438}"
>
>
> When you click on the drop-down arrow (or double-click) to see the
> _individual_ elements of t, CDT fires off THIS command:
>
> -var-create' - * *((t))@4
> &"Attempt to take contents of a non-pointer value.\n"
> ^done,name="var2",numchild="4",type="int [4]"
>
>
> [the way i see it, the command should be either
>
> -var-create' - * *(&(t[0]))@4
>
> or
>
> -var-create' - * *((t+0))@4
> ..
> or something else, but definitely _not_ *((t))
> ]
>
>
> Since there are two different actions depending on whether the array is
> expanded or not, this explains why it crashes only while stepping through
> the code _after_ expanding the array. Rest of the explanation follows...
>
> That concludes Problem 1
> (Remedy: CDT needs fixing in order to correctly resolve the primitive
> types of typedef'ed arrays)
>
>
> Problem 2. From the GDB project mailing list:
> (http://sources.redhat.com/ml/gdb/2005-02/msg00125.html)
> "-var-create on an expression that's invalid (eg. "(*1)") creates a
> variable and retains a ptr in var->value.
>
> That gets freed by free_all_values() next command.
>
> Later a -var-update or -var-evaluate-expression on that variable
> dereferences the freed memory, causing a seg. fault."
>
> As soon as CDT tries to get the values for the individual child elements
> using the following command: -var-list-children' var1 gdb instantly
> segfaults.
>
> Essentially, CDT configures a time bomb inside gdb, ready to go off
> anytime (depending on the source code you use, it may not occur right
> after the var-list-children, but could occur at any time... with my setup,
> the very next MI command sets it off)
>
> The way I see it, if CDT does its job correctly, gdb should never receive
> an illegal type inside -var-create and thereby, should never crash. Hence
> this _is_ a bug inside CDT.
>
>
> (Sorry for the mess inside the previous posting - i think the "snip" tags
> made the parser think it was html and it tried to parse it, thereby
> removing all extra whitespace)
>
>
|
|
|
Goto Forum:
Current Time: Thu May 15 13:20:25 EDT 2025
Powered by FUDForum. Page generated in 0.06099 seconds
|