mirror of
https://github.com/bminor/binutils-gdb.git
synced 2025-12-13 02:52:53 +00:00
Handle member pointers directly in generic_value_print
TYPE_CODE_MEMBERPTR and TYPE_CODE_METHODPTR are only used for C++, so it seems to me that the generic value-printing code ought to handle these cases -- that way, printing these objects will work even when the current language is not C++. This patch implements this idea. gdb/ChangeLog 2020-09-15 Tom Tromey <tom@tromey.com> * rust-lang.c (rust_value_print_inner): Remove TYPE_CODE_MEMBERPTR and TYPE_CODE_METHODPTR cases. * c-valprint.c (c_value_print_memberptr): Move to valprint.c. (c_value_print_inner): Update. * valprint.c (generic_value_print_memberptr): New function, from c_value_print_memberptr. (generic_value_print): Use it. Call cplus_print_method_ptr.
This commit is contained in:
@@ -1,3 +1,13 @@
|
|||||||
|
2020-09-15 Tom Tromey <tom@tromey.com>
|
||||||
|
|
||||||
|
* rust-lang.c (rust_value_print_inner): Remove TYPE_CODE_MEMBERPTR
|
||||||
|
and TYPE_CODE_METHODPTR cases.
|
||||||
|
* c-valprint.c (c_value_print_memberptr): Move to valprint.c.
|
||||||
|
(c_value_print_inner): Update.
|
||||||
|
* valprint.c (generic_value_print_memberptr): New function, from
|
||||||
|
c_value_print_memberptr.
|
||||||
|
(generic_value_print): Use it. Call cplus_print_method_ptr.
|
||||||
|
|
||||||
2020-09-15 Tom Tromey <tromey@adacore.com>
|
2020-09-15 Tom Tromey <tromey@adacore.com>
|
||||||
|
|
||||||
* python/python-internal.h (PyInt_FromLong): Remove define.
|
* python/python-internal.h (PyInt_FromLong): Remove define.
|
||||||
|
|||||||
@@ -416,23 +416,6 @@ c_value_print_int (struct value *val, struct ui_file *stream,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* c_value_print helper for TYPE_CODE_MEMBERPTR. */
|
|
||||||
|
|
||||||
static void
|
|
||||||
c_value_print_memberptr (struct value *val, struct ui_file *stream,
|
|
||||||
int recurse,
|
|
||||||
const struct value_print_options *options)
|
|
||||||
{
|
|
||||||
if (!options->format)
|
|
||||||
{
|
|
||||||
struct type *type = check_typedef (value_type (val));
|
|
||||||
const gdb_byte *valaddr = value_contents_for_printing (val);
|
|
||||||
cp_print_class_member (valaddr, type, stream, "&");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
generic_value_print (val, stream, recurse, options, &c_decorations);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* See c-lang.h. */
|
/* See c-lang.h. */
|
||||||
|
|
||||||
void
|
void
|
||||||
@@ -440,7 +423,6 @@ c_value_print_inner (struct value *val, struct ui_file *stream, int recurse,
|
|||||||
const struct value_print_options *options)
|
const struct value_print_options *options)
|
||||||
{
|
{
|
||||||
struct type *type = value_type (val);
|
struct type *type = value_type (val);
|
||||||
const gdb_byte *valaddr = value_contents_for_printing (val);
|
|
||||||
|
|
||||||
type = check_typedef (type);
|
type = check_typedef (type);
|
||||||
switch (type->code ())
|
switch (type->code ())
|
||||||
@@ -449,10 +431,6 @@ c_value_print_inner (struct value *val, struct ui_file *stream, int recurse,
|
|||||||
c_value_print_array (val, stream, recurse, options);
|
c_value_print_array (val, stream, recurse, options);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case TYPE_CODE_METHODPTR:
|
|
||||||
cplus_print_method_ptr (valaddr, type, stream);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case TYPE_CODE_PTR:
|
case TYPE_CODE_PTR:
|
||||||
c_value_print_ptr (val, stream, recurse, options);
|
c_value_print_ptr (val, stream, recurse, options);
|
||||||
break;
|
break;
|
||||||
@@ -466,10 +444,8 @@ c_value_print_inner (struct value *val, struct ui_file *stream, int recurse,
|
|||||||
c_value_print_int (val, stream, options);
|
c_value_print_int (val, stream, options);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case TYPE_CODE_METHODPTR:
|
||||||
case TYPE_CODE_MEMBERPTR:
|
case TYPE_CODE_MEMBERPTR:
|
||||||
c_value_print_memberptr (val, stream, recurse, options);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case TYPE_CODE_REF:
|
case TYPE_CODE_REF:
|
||||||
case TYPE_CODE_RVALUE_REF:
|
case TYPE_CODE_RVALUE_REF:
|
||||||
case TYPE_CODE_ENUM:
|
case TYPE_CODE_ENUM:
|
||||||
|
|||||||
@@ -535,11 +535,6 @@ rust_value_print_inner (struct value *val, struct ui_file *stream,
|
|||||||
}
|
}
|
||||||
goto generic_print;
|
goto generic_print;
|
||||||
|
|
||||||
case TYPE_CODE_METHODPTR:
|
|
||||||
case TYPE_CODE_MEMBERPTR:
|
|
||||||
c_value_print_inner (val, stream, recurse, &opts);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case TYPE_CODE_INT:
|
case TYPE_CODE_INT:
|
||||||
/* Recognize the unit type. */
|
/* Recognize the unit type. */
|
||||||
if (type->is_unsigned () && TYPE_LENGTH (type) == 0
|
if (type->is_unsigned () && TYPE_LENGTH (type) == 0
|
||||||
|
|||||||
@@ -40,6 +40,8 @@
|
|||||||
#include "gdbarch.h"
|
#include "gdbarch.h"
|
||||||
#include "cli/cli-style.h"
|
#include "cli/cli-style.h"
|
||||||
#include "count-one-bits.h"
|
#include "count-one-bits.h"
|
||||||
|
#include "c-lang.h"
|
||||||
|
#include "cp-abi.h"
|
||||||
|
|
||||||
/* Maximum number of wchars returned from wchar_iterate. */
|
/* Maximum number of wchars returned from wchar_iterate. */
|
||||||
#define MAX_WCHARS 4
|
#define MAX_WCHARS 4
|
||||||
@@ -811,6 +813,27 @@ generic_value_print_complex (struct value *val, struct ui_file *stream,
|
|||||||
fprintf_filtered (stream, "%s", decorations->complex_suffix);
|
fprintf_filtered (stream, "%s", decorations->complex_suffix);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* generic_value_print helper for TYPE_CODE_MEMBERPTR. */
|
||||||
|
|
||||||
|
static void
|
||||||
|
generic_value_print_memberptr
|
||||||
|
(struct value *val, struct ui_file *stream,
|
||||||
|
int recurse,
|
||||||
|
const struct value_print_options *options,
|
||||||
|
const struct generic_val_print_decorations *decorations)
|
||||||
|
{
|
||||||
|
if (!options->format)
|
||||||
|
{
|
||||||
|
/* Member pointers are essentially specific to C++, and so if we
|
||||||
|
encounter one, we should print it according to C++ rules. */
|
||||||
|
struct type *type = check_typedef (value_type (val));
|
||||||
|
const gdb_byte *valaddr = value_contents_for_printing (val);
|
||||||
|
cp_print_class_member (valaddr, type, stream, "&");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
generic_value_print (val, stream, recurse, options, decorations);
|
||||||
|
}
|
||||||
|
|
||||||
/* See valprint.h. */
|
/* See valprint.h. */
|
||||||
|
|
||||||
void
|
void
|
||||||
@@ -828,7 +851,8 @@ generic_value_print (struct value *val, struct ui_file *stream, int recurse,
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case TYPE_CODE_MEMBERPTR:
|
case TYPE_CODE_MEMBERPTR:
|
||||||
value_print_scalar_formatted (val, options, 0, stream);
|
generic_value_print_memberptr (val, stream, recurse, options,
|
||||||
|
decorations);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case TYPE_CODE_PTR:
|
case TYPE_CODE_PTR:
|
||||||
@@ -914,9 +938,13 @@ generic_value_print (struct value *val, struct ui_file *stream, int recurse,
|
|||||||
generic_value_print_complex (val, stream, options, decorations);
|
generic_value_print_complex (val, stream, options, decorations);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case TYPE_CODE_METHODPTR:
|
||||||
|
cplus_print_method_ptr (value_contents_for_printing (val), type,
|
||||||
|
stream);
|
||||||
|
break;
|
||||||
|
|
||||||
case TYPE_CODE_UNION:
|
case TYPE_CODE_UNION:
|
||||||
case TYPE_CODE_STRUCT:
|
case TYPE_CODE_STRUCT:
|
||||||
case TYPE_CODE_METHODPTR:
|
|
||||||
default:
|
default:
|
||||||
error (_("Unhandled type code %d in symbol table."),
|
error (_("Unhandled type code %d in symbol table."),
|
||||||
type->code ());
|
type->code ());
|
||||||
|
|||||||
Reference in New Issue
Block a user