* c-valprint.c (print_function_pointer_address): New function

to automatically dereference a function pointer for printing
	if necessary.
	(c_val_print):  Use print_function_pointer_address when printing
	function pointer addresses.
This commit is contained in:
Peter Schauer
2000-11-20 20:33:53 +00:00
parent 0c9f8a6941
commit 6e77854511
2 changed files with 31 additions and 3 deletions

View File

@ -1,3 +1,11 @@
2000-11-20 Peter Schauer <pes@regent.e-technik.tu-muenchen.de>
* c-valprint.c (print_function_pointer_address): New function
to automatically dereference a function pointer for printing
if necessary.
(c_val_print): Use print_function_pointer_address when printing
function pointer addresses.
2000-11-20 J.T. Conklin <jtc@redback.com> 2000-11-20 J.T. Conklin <jtc@redback.com>
* gdbserver/low-nbsd.c: Fix typos. * gdbserver/low-nbsd.c: Fix typos.

View File

@ -30,6 +30,26 @@
#include "c-lang.h" #include "c-lang.h"
/* Print function pointer with inferior address ADDRESS onto stdio
stream STREAM. */
static void
print_function_pointer_address (CORE_ADDR address, struct ui_file *stream)
{
CORE_ADDR func_addr = CONVERT_FROM_FUNC_PTR_ADDR (address);
/* If the function pointer is represented by a description, print the
address of the description. */
if (addressprint && func_addr != address)
{
fputs_filtered ("@", stream);
print_address_numeric (address, 1, stream);
fputs_filtered (": ", stream);
}
print_address_demangle (func_addr, stream, demangle);
}
/* Print data of type TYPE located at VALADDR (within GDB), which came from /* Print data of type TYPE located at VALADDR (within GDB), which came from
the inferior at address ADDRESS, onto stdio stream STREAM according to the inferior at address ADDRESS, onto stdio stream STREAM according to
FORMAT (a letter or 0 for natural format). The data at VALADDR is in FORMAT (a letter or 0 for natural format). The data at VALADDR is in
@ -129,7 +149,7 @@ c_val_print (struct type *type, char *valaddr, int embedded_offset,
-fvtable_thunks. (Otherwise, look under TYPE_CODE_STRUCT.) */ -fvtable_thunks. (Otherwise, look under TYPE_CODE_STRUCT.) */
CORE_ADDR addr CORE_ADDR addr
= extract_typed_address (valaddr + embedded_offset, type); = extract_typed_address (valaddr + embedded_offset, type);
print_address_demangle (addr, stream, demangle); print_function_pointer_address (addr, stream);
break; break;
} }
elttype = check_typedef (TYPE_TARGET_TYPE (type)); elttype = check_typedef (TYPE_TARGET_TYPE (type));
@ -152,7 +172,7 @@ c_val_print (struct type *type, char *valaddr, int embedded_offset,
if (TYPE_CODE (elttype) == TYPE_CODE_FUNC) if (TYPE_CODE (elttype) == TYPE_CODE_FUNC)
{ {
/* Try to print what function it points to. */ /* Try to print what function it points to. */
print_address_demangle (addr, stream, demangle); print_function_pointer_address (addr, stream);
/* Return value is irrelevant except for string pointers. */ /* Return value is irrelevant except for string pointers. */
return (0); return (0);
} }
@ -294,7 +314,7 @@ c_val_print (struct type *type, char *valaddr, int embedded_offset,
CORE_ADDR addr CORE_ADDR addr
= extract_typed_address (valaddr + offset, field_type); = extract_typed_address (valaddr + offset, field_type);
print_address_demangle (addr, stream, demangle); print_function_pointer_address (addr, stream);
} }
else else
cp_print_value_fields (type, type, valaddr, embedded_offset, address, stream, format, cp_print_value_fields (type, type, valaddr, embedded_offset, address, stream, format,