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:
parent
fe43fede47
commit
ef0bc0dd96
|
@ -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>
|
2015-07-27 Simon Marchi <simon.marchi@ericsson.com>
|
||||||
|
|
||||||
* valprint.c (generic_val_print): Factor out reference
|
* valprint.c (generic_val_print): Factor out reference
|
||||||
|
|
104
gdb/valprint.c
104
gdb/valprint.c
|
@ -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
|
/* generic_val_print helper for TYPE_CODE_ENUM. */
|
||||||
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.
|
static void
|
||||||
|
generic_val_print_enum (struct type *type, const gdb_byte *valaddr,
|
||||||
The additional DECORATIONS argument can be used to customize the
|
int embedded_offset, struct ui_file *stream,
|
||||||
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 *original_value,
|
||||||
const struct value_print_options *options,
|
const struct value_print_options *options)
|
||||||
const struct generic_val_print_decorations *decorations)
|
|
||||||
{
|
{
|
||||||
struct gdbarch *gdbarch = get_type_arch (type);
|
unsigned int i;
|
||||||
unsigned int i = 0; /* Number of characters printed. */
|
unsigned int len;
|
||||||
unsigned len;
|
|
||||||
struct type *unresolved_type = type;
|
|
||||||
LONGEST val;
|
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)
|
if (options->format)
|
||||||
{
|
{
|
||||||
val_print_scalar_formatted (type, valaddr, embedded_offset,
|
val_print_scalar_formatted (type, valaddr, embedded_offset,
|
||||||
original_value, options, 0, stream);
|
original_value, options, 0, stream);
|
||||||
break;
|
return;
|
||||||
}
|
}
|
||||||
len = TYPE_NFIELDS (type);
|
len = TYPE_NFIELDS (type);
|
||||||
val = unpack_long (type, valaddr + embedded_offset);
|
val = unpack_long (type, valaddr + embedded_offset);
|
||||||
|
@ -613,6 +576,57 @@ generic_val_print (struct type *type, const gdb_byte *valaddr,
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
print_longest (stream, 'd', 0, val);
|
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;
|
break;
|
||||||
|
|
||||||
case TYPE_CODE_FLAGS:
|
case TYPE_CODE_FLAGS:
|
||||||
|
|
Loading…
Reference in New Issue