This is the mail archive of the
gdb-prs@sourceware.org
mailing list for the GDB project.
[Bug varobj/10687] New: Printing c++ class with static array (of same type) can produce infinite output in gdb 6.8
- From: "linde at acc dot umu dot se" <sourceware-bugzilla at sourceware dot org>
- To: gdb-prs at sourceware dot org
- Date: 23 Sep 2009 08:00:32 -0000
- Subject: [Bug varobj/10687] New: Printing c++ class with static array (of same type) can produce infinite output in gdb 6.8
- Reply-to: sourceware-bugzilla at sourceware dot org
How to reproduce:
Test program (v2.cpp):
---clip--
class vec2
{
public:
vec2() { _v[0] = _v[1] = 0; }
vec2(int x, int y) { _v[0] = x; _v[1] = y; }
static vec2 axis[2];
private:
int _v[2];
};
vec2 vec2::axis[2] = { vec2(1,0), vec2(0,1) };
int main(int argc, char*argv[])
{
vec2 a;
return 0;
}
--clip--
Compile: "g++ -g -o v2 v2.cpp" (I used gcc 4.3.3)
GNU gdb 6.8
....
(gdb) break main
Breakpoint 1 at 0x400563: file v2.cpp, line 16.
(gdb) r
Starting program: /home/linde/v2
Breakpoint 1, main (argc=1, argv=0x7fff734e7018) at v2.cpp:16
16 vec2 a;
(gdb) p a
$1 = {static axis = {{static axis = {{static axis = {{static axis = {{static
axis = {{static axis = { ....
If using gdb directly one will get
---Type <return> to continue, or q <return> to quit---
after a certain amount of output. However, if using gdb through a frontend
such as cgdb or ddd, gdb will crash with segfault.
IF the array is removed and the following is added to the class:
static vec2 t;
and futher down
vec2 vec2::t = vec2(1,1);
Then gdb will show the following when printing a:
{static t = {static t = <same as static member of an already seen type>, _v =
{1, 1}}, _v = {0, 0}}
(after a:s constructor has ran).
So the problem seems to be that gdb can not detect that it's an already seen
type when there is an array involved. And if the type is not recognized, the
recursion will not break and the type vec2 kept being expanded because of "axis".
--
Summary: Printing c++ class with static array (of same type) can
produce infinite output in gdb 6.8
Product: gdb
Version: 6.8
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: varobj
AssignedTo: unassigned at sourceware dot org
ReportedBy: linde at acc dot umu dot se
CC: gdb-prs at sourceware dot org
http://sourceware.org/bugzilla/show_bug.cgi?id=10687
------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.