This is the mail archive of the
gdb@sources.redhat.com
mailing list for the GDB project.
Debugging with complex numbers
- To: <gcc at gcc dot gnu dot org>, <gdb at sources dot redhat dot com>
- Subject: Debugging with complex numbers
- From: "Joseph S. Myers" <jsm28 at cam dot ac dot uk>
- Date: Sun, 17 Dec 2000 00:02:22 +0000 (GMT)
The GCC manual says (and has since at least 2.5.8), of the complex numbers
extension (now, as applied to complex floating types, part of C99):
GNU CC can allocate complex automatic variables in a noncontiguous
fashion; it's even possible for the real part to be in a register while
the imaginary part is on the stack (or vice-versa). None of the
supported debugging info formats has a way to represent noncontiguous
allocation like this, so GNU CC describes a noncontiguous complex
variable as if it were two separate variables of noncomplex type.
If the variable's actual name is @code{foo}, the two fictitious
variables are named @code{foo$real} and @code{foo$imag}. You can
examine and set these two fictitious variables with your debugger.
A future version of GDB will know how to recognize such pairs and treat
them as a single variable with a complex type.
This reference to a "future version" of GDB has been there since at least
2.5.8, hopefully someone from the GCC side told the GDB people what they
were saying about future GDB :-). However, as of GDB 5.0 it still doesn't
seem to work; foo$real and foo$imag work for automatic variables with
stabs debugging, but with DWARF2 debugging, or for non-automatic
variables, they don't seem to work, and I get, for example, debugging a
trivial program
static __complex__ double x = 2.0 + 3.0i;
int main(void)
{
return 0;
}
(gdb) p x
$1 = Invalid C/C++ type code 20 in symbol table.
(gdb) p x$real
No symbol "x$real" in current context.
(gdb) p x$imag
No symbol "x$imag" in current context.
(gdb) quit
Hopefully someone knows what need to be done to GCC/GDB to get this
working properly - a proper understanding of complex numbers in GDB - with
both stabs and DWARF2?
--
Joseph S. Myers
jsm28@cam.ac.uk