Description of Problem:
Gdb hangs in the function finish_cv_type() for ever. I was able to work around
the problem by modifying the gdb source as shown below:
/* When reading in a class type, we may have created references to
cv-qualified versions of the type (in method arguments, for
instance). Update everything on the cv ring from the primary
The only reason we do not need to do the same thing for address
spaces is that type readers do not create address space qualified
finish_cv_type (struct type *type)
struct type *ntype, *cv_type, *ptr_type, *ref_type;
gdb_assert (!TYPE_CONST (type) && !TYPE_VOLATILE (type));
ntype = type;
while ((ntype = TYPE_CV_TYPE (ntype)) != type)
/* Save cv_flags. */
cv_flags = TYPE_FLAGS (ntype) & (TYPE_FLAG_VOLATILE | TYPE_FLAG_CONST);
/* If any reference or pointer types were created, save them too. */
ptr_type = TYPE_POINTER_TYPE (ntype);
ref_type = TYPE_REFERENCE_TYPE (ntype);
/* Don't disturb the CV chain. */
cv_type = TYPE_CV_TYPE (ntype);
/* Verify that we haven't added any address-space qualified types,
for the future. */
gdb_assert (ntype == TYPE_AS_TYPE (ntype));
/* Copy original type */
memcpy ((char *) ntype, (char *) type, sizeof (struct type));
/* Restore everything. */
TYPE_POINTER_TYPE (ntype) = ptr_type;
TYPE_REFERENCE_TYPE (ntype) = ref_type;
TYPE_CV_TYPE (ntype) = cv_type;
TYPE_FLAGS (ntype) = TYPE_FLAGS (ntype) | cv_flags;
TYPE_AS_TYPE (ntype) = ntype;
I added the cnt variable and the code to break out of the loop. This makes the
problem go away and does not seem to have any ill effects. Im not suggesting
this as the way to fix the problem, just to point out where it is.
Version-Release number of selected component (if applicable):
It happens with the gdb in 7.2, 7.3, and the gdb-5.2-2 update to 7.3
I can reproduce this but I unfortunatly cant send you the code :-( I have
narrowed it down and found that if I compile one file with out -g the problem
goes away. I am going to attach the resulting dot.o file, compiled with -g,
in case it helps
Created attachment 65844 [details]
the file that gdb dislikes
Any possibility of a reduced testcase?
So far I have only seen it show up when trying to debug a large application. I
can try and see if I can create a stripped down testcase, but I dont know how
long that will take me.
Created attachment 71684 [details]
Patch to GDB for corrupted cv type chains.
Created attachment 71685 [details]
A patch that makes GDB print a warning instead of creating corrupt type structures.
I've attached two patches that fixed a similar problem in the public GDB sources.
Ill give these patches a try
These patches seem to fix everything! Thanks!
The function that produces the infinite loop (finish_cv_type) is no longet in
gdb sources. The problem will be resolved in the next RedHat version of gdb.