binutils-gdb/gdb/doc
Andrew Burgess 8bdc16587e gdb: Add $_cimag and $_creal internal functions
Add two new internal functions $_cimag and $_creal that extract the
imaginary and real parts of a complex value.

These internal functions can take a complex value of any type 'float
complex', 'double complex', or 'long double complex' and return a
suitable floating point value 'float', 'double', or 'long double'.
So we can now do this:

    (gdb) p z1
    $1 = 1.5 + 4.5 * I
    (gdb) p $_cimag (z1)
    $4 = 4.5
    (gdb) p $_creal (z1)
    $4 = 1.5

The components of a complex value are not strictly named types in
DWARF, as the complex type is itself the base type.  However, once we
are able to extract the components it makes sense to be able to ask
what the type of these components is and get a sensible answer back,
rather than the error we would currently get.  Currently GDB says:

    (gdb) ptype z1
    type = complex double
    (gdb) p $_cimag (z1)
    $4 = 4.5
    (gdb) ptype $
    type = <invalid type code 9>

With the changes in dwarf2read.c, GDB now says:

    (gdb) ptype z1
    type = complex double
    (gdb) p $_cimag (z1)
    $4 = 4.5
    (gdb) ptype $
    type = double

Which seems to make more sense.

gdb/ChangeLog:

	* NEWS: Mention new internal functions.
	* dwarf2read.c (dwarf2_init_complex_target_type): New function.
	(read_base_type): Use dwarf2_init_complex_target_type.
	* value.c (creal_internal_fn): New function.
	(cimag_internal_fn): New function.
	(_initialize_values): Register new internal functions.

gdb/doc/ChangeLog:

	* gdb.texinfo (Convenience Funs): Document '$_creal' and
	'$_cimag'.

gdb/testsuite/ChangeLog:

	* gdb.base/complex-parts.c: New file.
	* gdb.base/complex-parts.exp: New file.
2019-04-01 21:41:49 +01:00
..
.gitignore Update and add .gitignore's 2016-09-21 13:12:21 -04:00
ChangeLog gdb: Add $_cimag and $_creal internal functions 2019-04-01 21:41:49 +01:00
Doxyfile-base.in Update copyright year range in all GDB files. 2019-01-01 10:01:51 +04:00
Doxyfile-gdb-api.in Update copyright year range in all GDB files. 2019-01-01 10:01:51 +04:00
Doxyfile-gdb-xref.in Update copyright year range in all GDB files. 2019-01-01 10:01:51 +04:00
Doxyfile-gdbserver.in Update copyright year range in all GDB files. 2019-01-01 10:01:51 +04:00
Makefile.in Update copyright year range in all GDB files. 2019-01-01 10:01:51 +04:00
a4rc.sed
agentexpr.texi Update copyright year range in all GDB files. 2019-01-01 10:01:51 +04:00
all-cfg.texi Update copyright year range in all GDB files. 2019-01-01 10:01:51 +04:00
annotate.texinfo Update copyright year range in all GDB files. 2019-01-01 10:01:51 +04:00
doxy-index.in Update copyright year range in all GDB files. 2019-01-01 10:01:51 +04:00
fdl.texi
filter-for-doxygen Add Doxygen support to GDB 2014-02-10 19:10:34 -08:00
filter-params.pl Add Doxygen support to GDB 2014-02-10 19:10:34 -08:00
gdb.texinfo gdb: Add $_cimag and $_creal internal functions 2019-04-01 21:41:49 +01:00
gpl.texi
guile.texi Update copyright year range in all GDB files. 2019-01-01 10:01:51 +04:00
lpsrc.sed
psrc.sed
python.texi Add gdb.Value.format_string () 2019-04-01 10:00:04 +02:00
refcard.tex Update copyright year range in gdb.texinfo and refcard.tex 2019-02-23 16:19:57 +04:00
stabs.texinfo Update copyright year range in all GDB files. 2019-01-01 10:01:51 +04:00
stack_frame.eps
stack_frame.pdf
stack_frame.png
stack_frame.svg
stack_frame.txt