Factor out enum printing code from generic_val_print

gdb/ChangeLog:

	* valprint.c (generic_val_print): Factor out enum
	printing code to ...
	(generic_val_print_enum): ... this new function.
This commit is contained in:
Simon Marchi 2015-07-27 14:11:21 -04:00
parent fe43fede47
commit ef0bc0dd96
2 changed files with 77 additions and 57 deletions

View File

@ -1,3 +1,9 @@
2015-07-27 Simon Marchi <simon.marchi@ericsson.com>
* valprint.c (generic_val_print): Factor out enum
printing code to ...
(generic_val_print_enum): ... this new function.
2015-07-27 Simon Marchi <simon.marchi@ericsson.com>
* valprint.c (generic_val_print): Factor out reference

View File

@ -509,60 +509,23 @@ generic_val_print_ref (struct type *type, const gdb_byte *valaddr,
}
}
/* A generic val_print that is suitable for use by language
implementations of the la_val_print method. This function can
handle most type codes, though not all, notably exception
TYPE_CODE_UNION and TYPE_CODE_STRUCT, which must be implemented by
the caller.
/* generic_val_print helper for TYPE_CODE_ENUM. */
Most arguments are as to val_print.
The additional DECORATIONS argument can be used to customize the
output in some small, language-specific ways. */
void
generic_val_print (struct type *type, const gdb_byte *valaddr,
int embedded_offset, CORE_ADDR address,
struct ui_file *stream, int recurse,
static void
generic_val_print_enum (struct type *type, const gdb_byte *valaddr,
int embedded_offset, struct ui_file *stream,
const struct value *original_value,
const struct value_print_options *options,
const struct generic_val_print_decorations *decorations)
const struct value_print_options *options)
{
struct gdbarch *gdbarch = get_type_arch (type);
unsigned int i = 0; /* Number of characters printed. */
unsigned len;
struct type *unresolved_type = type;
unsigned int i;
unsigned int len;
LONGEST val;
type = check_typedef (type);
switch (TYPE_CODE (type))
{
case TYPE_CODE_ARRAY:
generic_val_print_array (type, valaddr, embedded_offset, address, stream,
recurse, original_value, options);
break;
case TYPE_CODE_MEMBERPTR:
generic_val_print_memberptr (type, valaddr, embedded_offset, stream,
original_value, options);
break;
case TYPE_CODE_PTR:
generic_val_print_ptr (type, valaddr, embedded_offset, stream,
original_value, options);
break;
case TYPE_CODE_REF:
generic_val_print_ref (type, valaddr, embedded_offset, stream, recurse,
original_value, options);
break;
case TYPE_CODE_ENUM:
if (options->format)
{
val_print_scalar_formatted (type, valaddr, embedded_offset,
original_value, options, 0, stream);
break;
return;
}
len = TYPE_NFIELDS (type);
val = unpack_long (type, valaddr + embedded_offset);
@ -613,6 +576,57 @@ generic_val_print (struct type *type, const gdb_byte *valaddr,
}
else
print_longest (stream, 'd', 0, val);
}
/* A generic val_print that is suitable for use by language
implementations of the la_val_print method. This function can
handle most type codes, though not all, notably exception
TYPE_CODE_UNION and TYPE_CODE_STRUCT, which must be implemented by
the caller.
Most arguments are as to val_print.
The additional DECORATIONS argument can be used to customize the
output in some small, language-specific ways. */
void
generic_val_print (struct type *type, const gdb_byte *valaddr,
int embedded_offset, CORE_ADDR address,
struct ui_file *stream, int recurse,
const struct value *original_value,
const struct value_print_options *options,
const struct generic_val_print_decorations *decorations)
{
struct gdbarch *gdbarch = get_type_arch (type);
struct type *unresolved_type = type;
LONGEST val;
type = check_typedef (type);
switch (TYPE_CODE (type))
{
case TYPE_CODE_ARRAY:
generic_val_print_array (type, valaddr, embedded_offset, address, stream,
recurse, original_value, options);
break;
case TYPE_CODE_MEMBERPTR:
generic_val_print_memberptr (type, valaddr, embedded_offset, stream,
original_value, options);
break;
case TYPE_CODE_PTR:
generic_val_print_ptr (type, valaddr, embedded_offset, stream,
original_value, options);
break;
case TYPE_CODE_REF:
generic_val_print_ref (type, valaddr, embedded_offset, stream, recurse,
original_value, options);
break;
case TYPE_CODE_ENUM:
generic_val_print_enum (type, valaddr, embedded_offset, stream,
original_value, options);
break;
case TYPE_CODE_FLAGS: