1999-04-16 03:35:26 +02:00
|
|
|
|
/* Support for printing C and C++ types for GDB, the GNU debugger.
|
2018-01-01 05:43:02 +01:00
|
|
|
|
Copyright (C) 1986-2018 Free Software Foundation, Inc.
|
1999-04-16 03:35:26 +02:00
|
|
|
|
|
1999-07-07 22:19:36 +02:00
|
|
|
|
This file is part of GDB.
|
1999-04-16 03:35:26 +02:00
|
|
|
|
|
1999-07-07 22:19:36 +02:00
|
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
|
|
|
it under the terms of the GNU General Public License as published by
|
2007-08-23 20:08:50 +02:00
|
|
|
|
the Free Software Foundation; either version 3 of the License, or
|
1999-07-07 22:19:36 +02:00
|
|
|
|
(at your option) any later version.
|
1999-04-16 03:35:26 +02:00
|
|
|
|
|
1999-07-07 22:19:36 +02:00
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
GNU General Public License for more details.
|
1999-04-16 03:35:26 +02:00
|
|
|
|
|
1999-07-07 22:19:36 +02:00
|
|
|
|
You should have received a copy of the GNU General Public License
|
2007-08-23 20:08:50 +02:00
|
|
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
1999-04-16 03:35:26 +02:00
|
|
|
|
|
|
|
|
|
#include "defs.h"
|
2002-07-29 Andrew Cagney <ac131313@redhat.com>
* gdb_obstack.h: New file.
* symtab.h: Include "gdb_obstack.h" instead of "obstack.h".
(obstack_chunk_alloc, obstack_chunk_free): Delete macros.
* objfiles.h: Include "gdb_obstack.h".
* Makefile.in (gdb_obstack_h): Define.
(symtab_h): Add $(gdb_obstack_h).
(objfiles_h): Add $(gdb_obstack_h).
* objfiles.c: Include "gdb_obstack.h" instead of "obstack.h".
* macrotab.c, cp-valprint.c, dbxread.c: Ditto.
* ch-typeprint.c, ch-valprint.c, dstread.c: Ditto.
* macroexp.c, p-typeprint.c, stabsread.c: Ditto.
* symtab.c, f-typeprint.c, mdebugread.c: Ditto.
* p-valprint.c, symmisc.c, typeprint.c: Ditto.
* symfile.c, coffread.c, c-typeprint.c: Ditto.
* buildsym.c, bcache.c, ada-typeprint.c: Ditto.
* Makefile.in (bcache.o): Update dependencies.
(buildsym.o, c-typeprint.o, ch-typeprint.o): Ditto.
(ch-valprint.o, coffread.o, cp-valprint.o): Ditto.
(dbxread.o, dstread.o, f-typeprint.o): Ditto.
(objfiles.o, p-typeprint.o, p-valprint.o): Ditto.
(stabsread.o, symfile.o, symmisc.o): Ditto.
(symtab.o, typeprint.o, macroexp.o): Ditto.
(macrotab.o, mdebugread.o): Ditto.
(f_lang_h, coff_sym_h, coff_symconst_h): Define.
(coff_ecoff_h, aout_aout64_h): Define.
(aout_stabs_gnu_h, libaout_h): Define.
2002-07-30 00:55:26 +02:00
|
|
|
|
#include "gdb_obstack.h"
|
2010-12-31 23:59:52 +01:00
|
|
|
|
#include "bfd.h" /* Binary File Description. */
|
1999-04-16 03:35:26 +02:00
|
|
|
|
#include "symtab.h"
|
|
|
|
|
#include "gdbtypes.h"
|
|
|
|
|
#include "expression.h"
|
|
|
|
|
#include "value.h"
|
|
|
|
|
#include "gdbcore.h"
|
|
|
|
|
#include "target.h"
|
|
|
|
|
#include "language.h"
|
|
|
|
|
#include "demangle.h"
|
|
|
|
|
#include "c-lang.h"
|
|
|
|
|
#include "typeprint.h"
|
(Changes from Daniel Berlin, with revisions by Jim Blandy.)
Abstract out operations specific to particular C++ ABI's, and
invoke them through a function table. This removes the C++ ABI
dependencies scattered throughout the code, and allows us to
cleanly add support for new C++ ABI's.
* cp-abi.h, cp-abi.h, gnu-v2-abi.c, hpacc-abi.c: New files.
* c-typeprint.c, c-valprint.c, dbxread.c, eval.c, gdbtypes.c,
jv-typeprint.c, linespec.c, symtab.c, typeprint.c, valops.c:
#include "cp-abi.h". These files all use functions now declared
there.
* symtab.h (OPNAME_PREFIX_P, VTBL_PREFIX_P, DESTRUCTOR_PREFIX_P):
Deleted. These services are now provided by functions declared in
cp-abi.h.
* value.h (value_rtti_type, value_virtual_fn_field): Same.
* values.c (value_virtual_fn_field): Same, for this definition.
* valops.c (value_rtti_type): Same.
* c-typeprint.c (c_type_print_base): Use the functions from
"cp-abi.h", instead of the old macros, or hard-coded ABI-specific
tests.
* dbxread.c (record_minimal_symbol): Same.
* gdbtypes.c (get_destructor_fn_field, virtual_base_index,
virtual_base_index_skip_primaries): Same.
* jv-typeprint.c (java_type_print_base): Same.
* linespec.c (find_methods, decode_line_1): Same.
* symtab.c (gdb_mangle_name): Same.
* Makefile.in (SFILES): Add the new .c files mentioned above.
(cp_abi_h): New variable.
(COMMON_OBS): Add gnu-v2-abi.o, hpacc-abi.o, and cp-abi.o.
(cp-abi.o, gnu-v2-abi.o, hpacc-abi.o): New targets.
(c-typeprint.o, c-valprint.o, dbxread.o, eval.o, gdbtypes.o,
jv-typeprint.o, symtab.o, linespec.o, typeprint.o, valops.o): Add
dependency on $(cp_abi_h).
2001-04-27 02:19:09 +02:00
|
|
|
|
#include "cp-abi.h"
|
* c-typeprint.c (find_typedef_for_canonicalize,
print_name_maybe_canonical): New functions.
(c_print_type): Look up type name.
(cp_type_print_derivation_info): Add flags argument. Use
print_name_maybe_canonical.
(cp_type_print_method_args): Add wrapping.
(c_type_print_varspec_prefix): Use print_name_maybe_canonical.
(c_type_print_template_args): New function.
(c_type_print_base): Change wrapping. Use
print_name_maybe_canonical.
<TYPE_CODE_STRUCT>: Possibly create a typedef hash, and do
type name lookups.
* gdbtypes.c (types_equal): No longer static.
* gdbtypes.h (types_equal): Declare.
* typeprint.c (type_print_raw_options, default_ptype_flags):
Update.
(struct typedef_hash_table): New.
(hash_typedef_field, eq_typedef_field,
recursively_update_typedef_hash, add_template_parameters,
create_typedef_hash, free_typedef_hash, do_free_typedef_hash,
make_cleanup_free_typedef_hash, copy_typedef_hash_element,
copy_typedef_hash, find_typedef_in_hash): New functions.
* typeprint.h (struct type_print_options) <local_typedefs>:
New field.
(recursively_update_typedef_hash, add_template_parameters,
create_typedef_hash, free_typedef_hash,
make_cleanup_free_typedef_hash, copy_typedef_hash,
find_typedef_in_hash): Declare.
testsuite
* gdb.base/call-sc.exp: Use "ptype/r".
* gdb.base/volatile.exp: Don't expect "int".
* gdb.cp/ptype-flags.cc: New file.
* gdb.cp/ptype-flags.exp: New file.
* gdb.cp/templates.exp: Use ptype/r.
(test_ptype_of_templates, test_template_typedef): Likewise.
* lib/cp-support.exp (cp_test_ptype_class): Add in_ptype_arg
argument. Handle template names and template parameters.
* gdb.mi/mi-var-cmd.exp: Accept "long".
* gdb.mi/mi-var-child.exp: Accept "long".
* gdb.mi/mi-var-display.exp: Accept "long".
* gdb.mi/mi2-var-child.exp: Accept "long".
2012-11-12 18:37:38 +01:00
|
|
|
|
#include "cp-support.h"
|
1999-04-16 03:35:26 +02:00
|
|
|
|
|
2017-10-17 02:19:29 +02:00
|
|
|
|
/* A list of access specifiers used for printing. */
|
|
|
|
|
|
|
|
|
|
enum access_specifier
|
|
|
|
|
{
|
|
|
|
|
s_none,
|
|
|
|
|
s_public,
|
|
|
|
|
s_private,
|
|
|
|
|
s_protected
|
|
|
|
|
};
|
|
|
|
|
|
2018-04-17 21:51:22 +02:00
|
|
|
|
static void c_type_print_varspec_suffix (struct type *, struct ui_file *, int,
|
|
|
|
|
int, int,
|
2018-04-17 21:51:23 +02:00
|
|
|
|
enum language,
|
2018-04-17 21:51:22 +02:00
|
|
|
|
const struct type_print_options *);
|
|
|
|
|
|
2010-12-31 23:59:52 +01:00
|
|
|
|
static void c_type_print_varspec_prefix (struct type *,
|
|
|
|
|
struct ui_file *,
|
* ada-lang.c (user_select_syms, ada_print_subexp): Pass flags
to type-printing functions.
* ada-lang.h (ada_print_type): Add argument.
* ada-typeprint.c (print_array_type, print_variant_clauses,
print_variant_part, print_selected_record_field_types,
print_record_field_types, print_unchecked_union_type,
print_func_type, ada_print_type): Add flags argument.
(ada_print_typedef): Update.
* c-exp.y (OPERATOR conversion_type_id): Update.
* c-lang.h (c_print_type, c_type_print_base): Update.
* c-typeprint.c (c_print_type, c_type_print_varspec_prefix,
c_type_print_modifier, c_type_print_args,
c_type_print_varspec_suffix, c_type_print_base): Add flags
argument.
* cp-valprint.c (cp_print_class_member): Update.
* dwarf2read.c (dwarf2_compute_name): Update.
* f-lang.h (f_print_type): Add argument.
* f-typeprint.c (f_print_type): Add flags argument.
* gnu-v3-abi.c (gnuv3_print_method_ptr): Update.
* go-lang.h (go_print_type): Add argument.
* go-typeprint.c (go_print_type): Add flags argument.
* jv-lang.h (java_print_type): Add argument.
* jv-typeprint.c (java_type_print_base, java_print_type): Add
flags argument.
* language.c (unk_lang_print_type): Add flags argument.
* language.h (struct language_defn) <la_print_type>: Add flags
argument.
(LA_PRINT_TYPE): Likewise.
* m2-lang.h (m2_print_type): Add argument.
* m2-typeprint.c (m2_print_type, m2_range, m2_typedef,
m2_array, m2_pointer, m2_ref, m2_procedure, m2_long_set,
m2_unbounded_array, m2_record_fields): Add flags argument.
* p-lang.h (pascal_print_type, pascal_type_print_base,
pascal_type_print_varspec_prefix): Add argument.
* p-typeprint.c (pascal_print_type,
pascal_type_print_varspec_prefix, pascal_print_func_args,
pascal_type_print_varspec_suffix, pascal_type_print_base): Add
flags argument.
* symmisc.c (print_symbol): Update.
* typeprint.c (type_print_raw_options, default_ptype_flags):
New globals.
(type_print): Update.
* typeprint.h (struct type_print_options): New.
(type_print_raw_options): Declare.
(c_type_print_varspec_suffix, c_type_print_args): Add argument.
2012-11-12 18:14:55 +01:00
|
|
|
|
int, int, int,
|
2018-04-17 21:51:23 +02:00
|
|
|
|
enum language,
|
Implement pahole-like 'ptype /o' option
This commit implements the pahole-like '/o' option for 'ptype', which
prints the offsets and sizes of struct fields, reporting whenever
there is a hole found.
The output is heavily based on pahole(1), with a few modifications
here and there to adjust it to our reality. Here's an example:
/* offset | size */ type = struct wer : public tuv {
public:
/* 32 | 24 */ struct tyu {
/* 32:31 | 4 */ int a1 : 1;
/* 32:28 | 4 */ int a2 : 3;
/* 32: 5 | 4 */ int a3 : 23;
/* 35: 3 | 1 */ char a4 : 2;
/* XXX 3-bit hole */
/* XXX 4-byte hole */
/* 40 | 8 */ int64_t a5;
/* 48:27 | 4 */ int a6 : 5;
/* 48:56 | 8 */ int64_t a7 : 3;
/* total size (bytes): 24 */
} a1;
/* total size (bytes): 56 */
}
A big part of this patch handles the formatting logic of 'ptype',
which is a bit messy. The code to handle bitfield offsets, however,
took some time to craft. My thanks to Pedro Alves for figuring things
out and pointing me to the right direction, as well as coming up with
a way to inspect the layout of structs with bitfields (see testcase
for comments).
After many discussions both on IRC and at the mailing list, I tried to
implement printing vtables and inherited classes. Unfortunately the
code grew too complex and there were still a few corner cases failing
so I had to drop the attempt. This should be implemented in a future
patch.
This patch is the start of a long-term work I'll do to flush the local
patches we carry for Fedora GDB. In this specific case, I'm aiming at
upstreaming the feature implemented by the 'pahole.py' script that is
shipped with Fedora GDB:
<https://src.fedoraproject.org/rpms/gdb/blob/master/f/gdb-archer.patch#_311>
This has been regression-tested on the BuildBot. There's a new
testcase for it, along with an update to the documentation. I also
thought it was worth mentioning this feature in the NEWS file.
gdb/ChangeLog:
2017-12-15 Sergio Durigan Junior <sergiodj@redhat.com>
Pedro Alves <palves@redhat.com>
PR cli/16224
* NEWS (Changes since GDB 8.0): Mention new '/o' flag.
* c-typeprint.c (OFFSET_SPC_LEN): New define.
(c_type_print_varspec_prefix): New argument 'struct
print_offset_data *'.
(c_type_print_base_1): New function and prototype.
(c_print_type_1): New function, with code from 'c_print_type'.
(c_print_type): Use 'c_print_type_1'.
(c_type_print_varspec_prefix): New argument 'struct
print_offset_data *'. Use it. Call 'c_type_print_base_1'
instead of 'c_print_type_base'.
(print_spaces_filtered_with_print_options): New function.
(output_access_specifier): Take new argument FLAGS. Modify
function to call 'print_spaces_filtered_with_print_options'.
(c_print_type_vtable_offset_marker): New function.
(c_print_type_union_field_offset): New function.
(c_print_type_struct_field_offset): New function.
(c_print_type_no_offsets): New function.
(c_type_print_base_struct_union): New argument 'struct
print_offset_data *'. Print offsets and sizes for
struct/union/class fields.
* typeprint.c (const struct type_print_options
type_print_raw_options): Initialize 'print_offsets'.
(static struct type_print_options default_ptype_flags):
Likewise.
(struct print_offset_data print_offset_default_data): New
variable.
(whatis_exp): Handle '/o' option.
(_initialize_typeprint): Add '/o' flag to ptype's help.
* typeprint.h (struct print_offset_data): New struct.
(struct type_print_options) <print_offsets>: New field.
gdb/testsuite/ChangeLog:
2017-12-15 Sergio Durigan Junior <sergiodj@redhat.com>
PR cli/16224
* gdb.base/ptype-offsets.cc: New file.
* gdb.base/ptype-offsets.exp: New file.
gdb/doc/ChangeLog:
2017-12-15 Sergio Durigan Junior <sergiodj@redhat.com>
PR cli/16224
* gdb.texinfo (ptype): Add documentation for new flag '/o'.
2017-11-20 22:34:59 +01:00
|
|
|
|
const struct type_print_options *,
|
|
|
|
|
struct print_offset_data *);
|
1999-04-16 03:35:26 +02:00
|
|
|
|
|
2010-12-31 23:59:52 +01:00
|
|
|
|
/* Print "const", "volatile", or address space modifiers. */
|
|
|
|
|
static void c_type_print_modifier (struct type *,
|
|
|
|
|
struct ui_file *,
|
2001-11-15 02:55:59 +01:00
|
|
|
|
int, int);
|
Implement pahole-like 'ptype /o' option
This commit implements the pahole-like '/o' option for 'ptype', which
prints the offsets and sizes of struct fields, reporting whenever
there is a hole found.
The output is heavily based on pahole(1), with a few modifications
here and there to adjust it to our reality. Here's an example:
/* offset | size */ type = struct wer : public tuv {
public:
/* 32 | 24 */ struct tyu {
/* 32:31 | 4 */ int a1 : 1;
/* 32:28 | 4 */ int a2 : 3;
/* 32: 5 | 4 */ int a3 : 23;
/* 35: 3 | 1 */ char a4 : 2;
/* XXX 3-bit hole */
/* XXX 4-byte hole */
/* 40 | 8 */ int64_t a5;
/* 48:27 | 4 */ int a6 : 5;
/* 48:56 | 8 */ int64_t a7 : 3;
/* total size (bytes): 24 */
} a1;
/* total size (bytes): 56 */
}
A big part of this patch handles the formatting logic of 'ptype',
which is a bit messy. The code to handle bitfield offsets, however,
took some time to craft. My thanks to Pedro Alves for figuring things
out and pointing me to the right direction, as well as coming up with
a way to inspect the layout of structs with bitfields (see testcase
for comments).
After many discussions both on IRC and at the mailing list, I tried to
implement printing vtables and inherited classes. Unfortunately the
code grew too complex and there were still a few corner cases failing
so I had to drop the attempt. This should be implemented in a future
patch.
This patch is the start of a long-term work I'll do to flush the local
patches we carry for Fedora GDB. In this specific case, I'm aiming at
upstreaming the feature implemented by the 'pahole.py' script that is
shipped with Fedora GDB:
<https://src.fedoraproject.org/rpms/gdb/blob/master/f/gdb-archer.patch#_311>
This has been regression-tested on the BuildBot. There's a new
testcase for it, along with an update to the documentation. I also
thought it was worth mentioning this feature in the NEWS file.
gdb/ChangeLog:
2017-12-15 Sergio Durigan Junior <sergiodj@redhat.com>
Pedro Alves <palves@redhat.com>
PR cli/16224
* NEWS (Changes since GDB 8.0): Mention new '/o' flag.
* c-typeprint.c (OFFSET_SPC_LEN): New define.
(c_type_print_varspec_prefix): New argument 'struct
print_offset_data *'.
(c_type_print_base_1): New function and prototype.
(c_print_type_1): New function, with code from 'c_print_type'.
(c_print_type): Use 'c_print_type_1'.
(c_type_print_varspec_prefix): New argument 'struct
print_offset_data *'. Use it. Call 'c_type_print_base_1'
instead of 'c_print_type_base'.
(print_spaces_filtered_with_print_options): New function.
(output_access_specifier): Take new argument FLAGS. Modify
function to call 'print_spaces_filtered_with_print_options'.
(c_print_type_vtable_offset_marker): New function.
(c_print_type_union_field_offset): New function.
(c_print_type_struct_field_offset): New function.
(c_print_type_no_offsets): New function.
(c_type_print_base_struct_union): New argument 'struct
print_offset_data *'. Print offsets and sizes for
struct/union/class fields.
* typeprint.c (const struct type_print_options
type_print_raw_options): Initialize 'print_offsets'.
(static struct type_print_options default_ptype_flags):
Likewise.
(struct print_offset_data print_offset_default_data): New
variable.
(whatis_exp): Handle '/o' option.
(_initialize_typeprint): Add '/o' flag to ptype's help.
* typeprint.h (struct print_offset_data): New struct.
(struct type_print_options) <print_offsets>: New field.
gdb/testsuite/ChangeLog:
2017-12-15 Sergio Durigan Junior <sergiodj@redhat.com>
PR cli/16224
* gdb.base/ptype-offsets.cc: New file.
* gdb.base/ptype-offsets.exp: New file.
gdb/doc/ChangeLog:
2017-12-15 Sergio Durigan Junior <sergiodj@redhat.com>
PR cli/16224
* gdb.texinfo (ptype): Add documentation for new flag '/o'.
2017-11-20 22:34:59 +01:00
|
|
|
|
|
|
|
|
|
static void c_type_print_base_1 (struct type *type, struct ui_file *stream,
|
2018-04-17 21:51:23 +02:00
|
|
|
|
int show, int level, enum language language,
|
Implement pahole-like 'ptype /o' option
This commit implements the pahole-like '/o' option for 'ptype', which
prints the offsets and sizes of struct fields, reporting whenever
there is a hole found.
The output is heavily based on pahole(1), with a few modifications
here and there to adjust it to our reality. Here's an example:
/* offset | size */ type = struct wer : public tuv {
public:
/* 32 | 24 */ struct tyu {
/* 32:31 | 4 */ int a1 : 1;
/* 32:28 | 4 */ int a2 : 3;
/* 32: 5 | 4 */ int a3 : 23;
/* 35: 3 | 1 */ char a4 : 2;
/* XXX 3-bit hole */
/* XXX 4-byte hole */
/* 40 | 8 */ int64_t a5;
/* 48:27 | 4 */ int a6 : 5;
/* 48:56 | 8 */ int64_t a7 : 3;
/* total size (bytes): 24 */
} a1;
/* total size (bytes): 56 */
}
A big part of this patch handles the formatting logic of 'ptype',
which is a bit messy. The code to handle bitfield offsets, however,
took some time to craft. My thanks to Pedro Alves for figuring things
out and pointing me to the right direction, as well as coming up with
a way to inspect the layout of structs with bitfields (see testcase
for comments).
After many discussions both on IRC and at the mailing list, I tried to
implement printing vtables and inherited classes. Unfortunately the
code grew too complex and there were still a few corner cases failing
so I had to drop the attempt. This should be implemented in a future
patch.
This patch is the start of a long-term work I'll do to flush the local
patches we carry for Fedora GDB. In this specific case, I'm aiming at
upstreaming the feature implemented by the 'pahole.py' script that is
shipped with Fedora GDB:
<https://src.fedoraproject.org/rpms/gdb/blob/master/f/gdb-archer.patch#_311>
This has been regression-tested on the BuildBot. There's a new
testcase for it, along with an update to the documentation. I also
thought it was worth mentioning this feature in the NEWS file.
gdb/ChangeLog:
2017-12-15 Sergio Durigan Junior <sergiodj@redhat.com>
Pedro Alves <palves@redhat.com>
PR cli/16224
* NEWS (Changes since GDB 8.0): Mention new '/o' flag.
* c-typeprint.c (OFFSET_SPC_LEN): New define.
(c_type_print_varspec_prefix): New argument 'struct
print_offset_data *'.
(c_type_print_base_1): New function and prototype.
(c_print_type_1): New function, with code from 'c_print_type'.
(c_print_type): Use 'c_print_type_1'.
(c_type_print_varspec_prefix): New argument 'struct
print_offset_data *'. Use it. Call 'c_type_print_base_1'
instead of 'c_print_type_base'.
(print_spaces_filtered_with_print_options): New function.
(output_access_specifier): Take new argument FLAGS. Modify
function to call 'print_spaces_filtered_with_print_options'.
(c_print_type_vtable_offset_marker): New function.
(c_print_type_union_field_offset): New function.
(c_print_type_struct_field_offset): New function.
(c_print_type_no_offsets): New function.
(c_type_print_base_struct_union): New argument 'struct
print_offset_data *'. Print offsets and sizes for
struct/union/class fields.
* typeprint.c (const struct type_print_options
type_print_raw_options): Initialize 'print_offsets'.
(static struct type_print_options default_ptype_flags):
Likewise.
(struct print_offset_data print_offset_default_data): New
variable.
(whatis_exp): Handle '/o' option.
(_initialize_typeprint): Add '/o' flag to ptype's help.
* typeprint.h (struct print_offset_data): New struct.
(struct type_print_options) <print_offsets>: New field.
gdb/testsuite/ChangeLog:
2017-12-15 Sergio Durigan Junior <sergiodj@redhat.com>
PR cli/16224
* gdb.base/ptype-offsets.cc: New file.
* gdb.base/ptype-offsets.exp: New file.
gdb/doc/ChangeLog:
2017-12-15 Sergio Durigan Junior <sergiodj@redhat.com>
PR cli/16224
* gdb.texinfo (ptype): Add documentation for new flag '/o'.
2017-11-20 22:34:59 +01:00
|
|
|
|
const struct type_print_options *flags,
|
|
|
|
|
struct print_offset_data *podata);
|
1999-07-07 22:19:36 +02:00
|
|
|
|
|
* c-typeprint.c (find_typedef_for_canonicalize,
print_name_maybe_canonical): New functions.
(c_print_type): Look up type name.
(cp_type_print_derivation_info): Add flags argument. Use
print_name_maybe_canonical.
(cp_type_print_method_args): Add wrapping.
(c_type_print_varspec_prefix): Use print_name_maybe_canonical.
(c_type_print_template_args): New function.
(c_type_print_base): Change wrapping. Use
print_name_maybe_canonical.
<TYPE_CODE_STRUCT>: Possibly create a typedef hash, and do
type name lookups.
* gdbtypes.c (types_equal): No longer static.
* gdbtypes.h (types_equal): Declare.
* typeprint.c (type_print_raw_options, default_ptype_flags):
Update.
(struct typedef_hash_table): New.
(hash_typedef_field, eq_typedef_field,
recursively_update_typedef_hash, add_template_parameters,
create_typedef_hash, free_typedef_hash, do_free_typedef_hash,
make_cleanup_free_typedef_hash, copy_typedef_hash_element,
copy_typedef_hash, find_typedef_in_hash): New functions.
* typeprint.h (struct type_print_options) <local_typedefs>:
New field.
(recursively_update_typedef_hash, add_template_parameters,
create_typedef_hash, free_typedef_hash,
make_cleanup_free_typedef_hash, copy_typedef_hash,
find_typedef_in_hash): Declare.
testsuite
* gdb.base/call-sc.exp: Use "ptype/r".
* gdb.base/volatile.exp: Don't expect "int".
* gdb.cp/ptype-flags.cc: New file.
* gdb.cp/ptype-flags.exp: New file.
* gdb.cp/templates.exp: Use ptype/r.
(test_ptype_of_templates, test_template_typedef): Likewise.
* lib/cp-support.exp (cp_test_ptype_class): Add in_ptype_arg
argument. Handle template names and template parameters.
* gdb.mi/mi-var-cmd.exp: Accept "long".
* gdb.mi/mi-var-child.exp: Accept "long".
* gdb.mi/mi-var-display.exp: Accept "long".
* gdb.mi/mi2-var-child.exp: Accept "long".
2012-11-12 18:37:38 +01:00
|
|
|
|
|
|
|
|
|
/* A callback function for cp_canonicalize_string_full that uses
|
2018-03-14 23:38:02 +01:00
|
|
|
|
typedef_hash_table::find_typedef. */
|
* c-typeprint.c (find_typedef_for_canonicalize,
print_name_maybe_canonical): New functions.
(c_print_type): Look up type name.
(cp_type_print_derivation_info): Add flags argument. Use
print_name_maybe_canonical.
(cp_type_print_method_args): Add wrapping.
(c_type_print_varspec_prefix): Use print_name_maybe_canonical.
(c_type_print_template_args): New function.
(c_type_print_base): Change wrapping. Use
print_name_maybe_canonical.
<TYPE_CODE_STRUCT>: Possibly create a typedef hash, and do
type name lookups.
* gdbtypes.c (types_equal): No longer static.
* gdbtypes.h (types_equal): Declare.
* typeprint.c (type_print_raw_options, default_ptype_flags):
Update.
(struct typedef_hash_table): New.
(hash_typedef_field, eq_typedef_field,
recursively_update_typedef_hash, add_template_parameters,
create_typedef_hash, free_typedef_hash, do_free_typedef_hash,
make_cleanup_free_typedef_hash, copy_typedef_hash_element,
copy_typedef_hash, find_typedef_in_hash): New functions.
* typeprint.h (struct type_print_options) <local_typedefs>:
New field.
(recursively_update_typedef_hash, add_template_parameters,
create_typedef_hash, free_typedef_hash,
make_cleanup_free_typedef_hash, copy_typedef_hash,
find_typedef_in_hash): Declare.
testsuite
* gdb.base/call-sc.exp: Use "ptype/r".
* gdb.base/volatile.exp: Don't expect "int".
* gdb.cp/ptype-flags.cc: New file.
* gdb.cp/ptype-flags.exp: New file.
* gdb.cp/templates.exp: Use ptype/r.
(test_ptype_of_templates, test_template_typedef): Likewise.
* lib/cp-support.exp (cp_test_ptype_class): Add in_ptype_arg
argument. Handle template names and template parameters.
* gdb.mi/mi-var-cmd.exp: Accept "long".
* gdb.mi/mi-var-child.exp: Accept "long".
* gdb.mi/mi-var-display.exp: Accept "long".
* gdb.mi/mi2-var-child.exp: Accept "long".
2012-11-12 18:37:38 +01:00
|
|
|
|
|
|
|
|
|
static const char *
|
|
|
|
|
find_typedef_for_canonicalize (struct type *t, void *data)
|
|
|
|
|
{
|
2018-03-14 23:38:02 +01:00
|
|
|
|
return typedef_hash_table::find_typedef
|
|
|
|
|
((const struct type_print_options *) data, t);
|
* c-typeprint.c (find_typedef_for_canonicalize,
print_name_maybe_canonical): New functions.
(c_print_type): Look up type name.
(cp_type_print_derivation_info): Add flags argument. Use
print_name_maybe_canonical.
(cp_type_print_method_args): Add wrapping.
(c_type_print_varspec_prefix): Use print_name_maybe_canonical.
(c_type_print_template_args): New function.
(c_type_print_base): Change wrapping. Use
print_name_maybe_canonical.
<TYPE_CODE_STRUCT>: Possibly create a typedef hash, and do
type name lookups.
* gdbtypes.c (types_equal): No longer static.
* gdbtypes.h (types_equal): Declare.
* typeprint.c (type_print_raw_options, default_ptype_flags):
Update.
(struct typedef_hash_table): New.
(hash_typedef_field, eq_typedef_field,
recursively_update_typedef_hash, add_template_parameters,
create_typedef_hash, free_typedef_hash, do_free_typedef_hash,
make_cleanup_free_typedef_hash, copy_typedef_hash_element,
copy_typedef_hash, find_typedef_in_hash): New functions.
* typeprint.h (struct type_print_options) <local_typedefs>:
New field.
(recursively_update_typedef_hash, add_template_parameters,
create_typedef_hash, free_typedef_hash,
make_cleanup_free_typedef_hash, copy_typedef_hash,
find_typedef_in_hash): Declare.
testsuite
* gdb.base/call-sc.exp: Use "ptype/r".
* gdb.base/volatile.exp: Don't expect "int".
* gdb.cp/ptype-flags.cc: New file.
* gdb.cp/ptype-flags.exp: New file.
* gdb.cp/templates.exp: Use ptype/r.
(test_ptype_of_templates, test_template_typedef): Likewise.
* lib/cp-support.exp (cp_test_ptype_class): Add in_ptype_arg
argument. Handle template names and template parameters.
* gdb.mi/mi-var-cmd.exp: Accept "long".
* gdb.mi/mi-var-child.exp: Accept "long".
* gdb.mi/mi-var-display.exp: Accept "long".
* gdb.mi/mi2-var-child.exp: Accept "long".
2012-11-12 18:37:38 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Print NAME on STREAM. If the 'raw' field of FLAGS is not set,
|
|
|
|
|
canonicalize NAME using the local typedefs first. */
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
print_name_maybe_canonical (const char *name,
|
|
|
|
|
const struct type_print_options *flags,
|
|
|
|
|
struct ui_file *stream)
|
|
|
|
|
{
|
Use ui_file_as_string throughout more
This replaces most of the remaining ui_file_xstrdup calls with
ui_file_as_string calls. Whenever a call was replaced, that led to a
cascade of other necessary adjustments throughout, to make the code
use std::string instead of raw pointers. And then whenever I added a
std::string as member of a struct, I needed to adjust
allocation/destruction of said struct to use new/delete instead of
xmalloc/xfree.
The stopping point was once gdb built again. These doesn't seem to be
a way to reasonably split this out further.
Maybe-not-obvious changes:
- demangle_for_lookup returns a cleanup today. To get rid of that,
and avoid unnecessary string dupping/copying, this introduces a
demangle_result_storage type that the caller instantiates and
passes to demangle_for_lookup.
- Many methods returned a "char *" to indicate that the caller owns
the memory and must free it. Those are switched to return a
std::string instead. Methods that return a "view" into some
internal string return a "const char *" instead. I.e., we only
copy/allocate when necessary.
gdb/ChangeLog:
2016-11-08 Pedro Alves <palves@redhat.com>
* ada-lang.c (ada_name_for_lookup, type_as_string): Use and return
std::string.
(type_as_string_and_cleanup): Delete.
(ada_lookup_struct_elt_type): Use type_as_string.
* ada-lang.h (ada_name_for_lookup): Now returns std::string.
* ada-varobj.c (ada_varobj_scalar_image): Return a std::string.
(ada_varobj_describe_child): Make 'child_name' and
'child_path_expr' parameters std::string pointers.
(ada_varobj_describe_struct_child, ada_varobj_describe_ptr_child):
Likewise, and use string_printf.
(ada_varobj_describe_simple_array_child)
(ada_varobj_describe_child): Likewise.
(ada_varobj_get_name_of_child, ada_varobj_get_path_expr_of_child)
(ada_varobj_get_value_image)
(ada_varobj_get_value_of_array_variable)
(ada_varobj_get_value_of_variable, ada_name_of_variable)
(ada_name_of_child, ada_path_expr_of_child)
(ada_value_of_variable): Now returns std::string. Use
string_printf.
(ada_value_of_child): Adjust.
* break-catch-throw.c (check_status_exception_catchpoint): Adjust
to use std::string.
* breakpoint.c (watch_command_1): Adjust to use std::string.
* c-lang.c (c_get_string): Adjust to use std::string.
* c-typeprint.c (print_name_maybe_canonical): Use std::string.
* c-varobj.c (varobj_is_anonymous_child): Use ==/!= std::string
operators.
(c_name_of_variable): Now returns a std::string.
(c_describe_child): The 'cname' and 'cfull_expression' output
parameters are now std::string pointers. Adjust.
(c_name_of_child, c_path_expr_of_child, c_value_of_variable)
(cplus_number_of_children): Adjust to use std::string and
string_printf.
(cplus_name_of_variable): Now returns a std::string.
(cplus_describe_child): The 'cname' and 'cfull_expression' output
parameters are now std::string pointers. Adjust.
(cplus_name_of_child, cplus_path_expr_of_child)
(cplus_value_of_variable): Now returns a std::string.
* cp-abi.c (cplus_typename_from_type_info): Return std::string.
* cp-abi.h (cplus_typename_from_type_info): Return std::string.
(struct cp_abi_ops) <get_typename_from_type_info>: Return
std::string.
* cp-support.c (inspect_type): Use std::string.
(cp_canonicalize_string_full, cp_canonicalize_string_no_typedefs)
(cp_canonicalize_string): Return std::string and adjust.
* cp-support.h (cp_canonicalize_string)
(cp_canonicalize_string_no_typedefs, cp_canonicalize_string_full):
Return std::string.
* dbxread.c (read_dbx_symtab): Use std::string.
* dwarf2read.c (dwarf2_canonicalize_name): Adjust to use std::string.
* gdbcmd.h (lookup_struct_elt_type): Adjust to use std::string.
* gnu-v3-abi.c (gnuv3_get_typeid): Use std::string.
(gnuv3_get_typename_from_type_info): Return a std::string and
adjust.
(gnuv3_get_type_from_type_info): Adjust to use std::string.
* guile/guile.c (gdbscm_execute_gdb_command): Adjust to use
std::string.
* infcmd.c (print_return_value_1): Adjust to use std::string.
* linespec.c (find_linespec_symbols): Adjust to
demangle_for_lookup API change. Use std::string.
* mi/mi-cmd-var.c (print_varobj, mi_cmd_var_set_format)
(mi_cmd_var_info_type, mi_cmd_var_info_path_expression)
(mi_cmd_var_info_expression, mi_cmd_var_evaluate_expression)
(mi_cmd_var_assign, varobj_update_one): Adjust to use std::string.
* minsyms.c (lookup_minimal_symbol): Use std::string.
* python/py-varobj.c (py_varobj_iter_next): Use new instead of
XNEW. vitem->name is a std::string now, adjust.
* rust-exp.y (convert_ast_to_type, convert_name): Adjust to use
std::string.
* stabsread.c (define_symbol): Adjust to use std::string.
* symtab.c (demangle_for_lookup): Now returns 'const char *'. Add
a demangle_result_storage parameter. Use it for storage.
(lookup_symbol_in_language)
(lookup_symbol_in_objfile_from_linkage_name): Adjust to new
demangle_for_lookup API.
* symtab.h (struct demangle_result_storage): New type.
(demangle_for_lookup): Now returns 'const char *'. Add a
demangle_result_storage parameter.
* typeprint.c (type_to_string): Return std::string and use
ui_file_as_string.
* value.h (type_to_string): Change return type to std::string.
* varobj-iter.h (struct varobj_item) <name>: Now a std::string.
(varobj_iter_delete): Use delete instead of xfree.
* varobj.c (create_child): Return std::string instead of char * in
output parameter.
(name_of_variable, name_of_child, my_value_of_variable): Return
std::string instead of char *.
(varobj_create, varobj_get_handle): Constify 'objname' parameter.
Adjust to std::string fields.
(varobj_get_objname): Return a const char * instead of a char *.
(varobj_get_expression): Return a std::string.
(varobj_list_children): Adjust to use std::string.
(varobj_get_type): Return a std::string.
(varobj_get_path_expr): Return a const char * instead of a char *.
Adjust to std::string fields.
(varobj_get_formatted_value, varobj_get_value): Return a
std::string.
(varobj_set_value): Change type of 'expression' parameter to
std::string. Use std::string.
(install_new_value): Use std::string.
(delete_variable_1): Adjust to use std::string.
(create_child): Change the 'name' parameter to a std::string
reference. Swap it into the new item's name.
(create_child_with_value): Swap item's name into the new child's
name. Use string_printf.
(new_variable): Use new instead of XNEW.
(free_variable): Don't xfree fields that are now std::string.
(name_of_variable, name_of_child): Now returns std::string.
(value_of_root): Adjust to use std::string.
(my_value_of_variable, varobj_value_get_print_value): Return
and use std::string.
(varobj_value_get_print_value): Adjust to use ui_file_as_string
and std::string.
* varobj.h (struct varobj) <name, path_expr, obj_name,
print_value>: Now std::string's.
<name_of_variable, name_of_child, path_expr_of_child,
value_of_variable>: Return std::string.
(varobj_create, varobj_get_handle): Constify 'objname' parameter.
(varobj_get_objname): Return a const char * instead of a char *.
(varobj_get_expression, varobj_get_type): Return a std::string.
(varobj_get_path_expr): Return a const char * instead of a char *.
(varobj_get_formatted_value, varobj_get_value): Return a
std::string.
(varobj_set_value): Constify 'expression' parameter.
(varobj_value_get_print_value): Return a std::string.
2016-11-08 16:26:47 +01:00
|
|
|
|
std::string s;
|
* c-typeprint.c (find_typedef_for_canonicalize,
print_name_maybe_canonical): New functions.
(c_print_type): Look up type name.
(cp_type_print_derivation_info): Add flags argument. Use
print_name_maybe_canonical.
(cp_type_print_method_args): Add wrapping.
(c_type_print_varspec_prefix): Use print_name_maybe_canonical.
(c_type_print_template_args): New function.
(c_type_print_base): Change wrapping. Use
print_name_maybe_canonical.
<TYPE_CODE_STRUCT>: Possibly create a typedef hash, and do
type name lookups.
* gdbtypes.c (types_equal): No longer static.
* gdbtypes.h (types_equal): Declare.
* typeprint.c (type_print_raw_options, default_ptype_flags):
Update.
(struct typedef_hash_table): New.
(hash_typedef_field, eq_typedef_field,
recursively_update_typedef_hash, add_template_parameters,
create_typedef_hash, free_typedef_hash, do_free_typedef_hash,
make_cleanup_free_typedef_hash, copy_typedef_hash_element,
copy_typedef_hash, find_typedef_in_hash): New functions.
* typeprint.h (struct type_print_options) <local_typedefs>:
New field.
(recursively_update_typedef_hash, add_template_parameters,
create_typedef_hash, free_typedef_hash,
make_cleanup_free_typedef_hash, copy_typedef_hash,
find_typedef_in_hash): Declare.
testsuite
* gdb.base/call-sc.exp: Use "ptype/r".
* gdb.base/volatile.exp: Don't expect "int".
* gdb.cp/ptype-flags.cc: New file.
* gdb.cp/ptype-flags.exp: New file.
* gdb.cp/templates.exp: Use ptype/r.
(test_ptype_of_templates, test_template_typedef): Likewise.
* lib/cp-support.exp (cp_test_ptype_class): Add in_ptype_arg
argument. Handle template names and template parameters.
* gdb.mi/mi-var-cmd.exp: Accept "long".
* gdb.mi/mi-var-child.exp: Accept "long".
* gdb.mi/mi-var-display.exp: Accept "long".
* gdb.mi/mi2-var-child.exp: Accept "long".
2012-11-12 18:37:38 +01:00
|
|
|
|
|
|
|
|
|
if (!flags->raw)
|
|
|
|
|
s = cp_canonicalize_string_full (name,
|
|
|
|
|
find_typedef_for_canonicalize,
|
|
|
|
|
(void *) flags);
|
|
|
|
|
|
Use ui_file_as_string throughout more
This replaces most of the remaining ui_file_xstrdup calls with
ui_file_as_string calls. Whenever a call was replaced, that led to a
cascade of other necessary adjustments throughout, to make the code
use std::string instead of raw pointers. And then whenever I added a
std::string as member of a struct, I needed to adjust
allocation/destruction of said struct to use new/delete instead of
xmalloc/xfree.
The stopping point was once gdb built again. These doesn't seem to be
a way to reasonably split this out further.
Maybe-not-obvious changes:
- demangle_for_lookup returns a cleanup today. To get rid of that,
and avoid unnecessary string dupping/copying, this introduces a
demangle_result_storage type that the caller instantiates and
passes to demangle_for_lookup.
- Many methods returned a "char *" to indicate that the caller owns
the memory and must free it. Those are switched to return a
std::string instead. Methods that return a "view" into some
internal string return a "const char *" instead. I.e., we only
copy/allocate when necessary.
gdb/ChangeLog:
2016-11-08 Pedro Alves <palves@redhat.com>
* ada-lang.c (ada_name_for_lookup, type_as_string): Use and return
std::string.
(type_as_string_and_cleanup): Delete.
(ada_lookup_struct_elt_type): Use type_as_string.
* ada-lang.h (ada_name_for_lookup): Now returns std::string.
* ada-varobj.c (ada_varobj_scalar_image): Return a std::string.
(ada_varobj_describe_child): Make 'child_name' and
'child_path_expr' parameters std::string pointers.
(ada_varobj_describe_struct_child, ada_varobj_describe_ptr_child):
Likewise, and use string_printf.
(ada_varobj_describe_simple_array_child)
(ada_varobj_describe_child): Likewise.
(ada_varobj_get_name_of_child, ada_varobj_get_path_expr_of_child)
(ada_varobj_get_value_image)
(ada_varobj_get_value_of_array_variable)
(ada_varobj_get_value_of_variable, ada_name_of_variable)
(ada_name_of_child, ada_path_expr_of_child)
(ada_value_of_variable): Now returns std::string. Use
string_printf.
(ada_value_of_child): Adjust.
* break-catch-throw.c (check_status_exception_catchpoint): Adjust
to use std::string.
* breakpoint.c (watch_command_1): Adjust to use std::string.
* c-lang.c (c_get_string): Adjust to use std::string.
* c-typeprint.c (print_name_maybe_canonical): Use std::string.
* c-varobj.c (varobj_is_anonymous_child): Use ==/!= std::string
operators.
(c_name_of_variable): Now returns a std::string.
(c_describe_child): The 'cname' and 'cfull_expression' output
parameters are now std::string pointers. Adjust.
(c_name_of_child, c_path_expr_of_child, c_value_of_variable)
(cplus_number_of_children): Adjust to use std::string and
string_printf.
(cplus_name_of_variable): Now returns a std::string.
(cplus_describe_child): The 'cname' and 'cfull_expression' output
parameters are now std::string pointers. Adjust.
(cplus_name_of_child, cplus_path_expr_of_child)
(cplus_value_of_variable): Now returns a std::string.
* cp-abi.c (cplus_typename_from_type_info): Return std::string.
* cp-abi.h (cplus_typename_from_type_info): Return std::string.
(struct cp_abi_ops) <get_typename_from_type_info>: Return
std::string.
* cp-support.c (inspect_type): Use std::string.
(cp_canonicalize_string_full, cp_canonicalize_string_no_typedefs)
(cp_canonicalize_string): Return std::string and adjust.
* cp-support.h (cp_canonicalize_string)
(cp_canonicalize_string_no_typedefs, cp_canonicalize_string_full):
Return std::string.
* dbxread.c (read_dbx_symtab): Use std::string.
* dwarf2read.c (dwarf2_canonicalize_name): Adjust to use std::string.
* gdbcmd.h (lookup_struct_elt_type): Adjust to use std::string.
* gnu-v3-abi.c (gnuv3_get_typeid): Use std::string.
(gnuv3_get_typename_from_type_info): Return a std::string and
adjust.
(gnuv3_get_type_from_type_info): Adjust to use std::string.
* guile/guile.c (gdbscm_execute_gdb_command): Adjust to use
std::string.
* infcmd.c (print_return_value_1): Adjust to use std::string.
* linespec.c (find_linespec_symbols): Adjust to
demangle_for_lookup API change. Use std::string.
* mi/mi-cmd-var.c (print_varobj, mi_cmd_var_set_format)
(mi_cmd_var_info_type, mi_cmd_var_info_path_expression)
(mi_cmd_var_info_expression, mi_cmd_var_evaluate_expression)
(mi_cmd_var_assign, varobj_update_one): Adjust to use std::string.
* minsyms.c (lookup_minimal_symbol): Use std::string.
* python/py-varobj.c (py_varobj_iter_next): Use new instead of
XNEW. vitem->name is a std::string now, adjust.
* rust-exp.y (convert_ast_to_type, convert_name): Adjust to use
std::string.
* stabsread.c (define_symbol): Adjust to use std::string.
* symtab.c (demangle_for_lookup): Now returns 'const char *'. Add
a demangle_result_storage parameter. Use it for storage.
(lookup_symbol_in_language)
(lookup_symbol_in_objfile_from_linkage_name): Adjust to new
demangle_for_lookup API.
* symtab.h (struct demangle_result_storage): New type.
(demangle_for_lookup): Now returns 'const char *'. Add a
demangle_result_storage parameter.
* typeprint.c (type_to_string): Return std::string and use
ui_file_as_string.
* value.h (type_to_string): Change return type to std::string.
* varobj-iter.h (struct varobj_item) <name>: Now a std::string.
(varobj_iter_delete): Use delete instead of xfree.
* varobj.c (create_child): Return std::string instead of char * in
output parameter.
(name_of_variable, name_of_child, my_value_of_variable): Return
std::string instead of char *.
(varobj_create, varobj_get_handle): Constify 'objname' parameter.
Adjust to std::string fields.
(varobj_get_objname): Return a const char * instead of a char *.
(varobj_get_expression): Return a std::string.
(varobj_list_children): Adjust to use std::string.
(varobj_get_type): Return a std::string.
(varobj_get_path_expr): Return a const char * instead of a char *.
Adjust to std::string fields.
(varobj_get_formatted_value, varobj_get_value): Return a
std::string.
(varobj_set_value): Change type of 'expression' parameter to
std::string. Use std::string.
(install_new_value): Use std::string.
(delete_variable_1): Adjust to use std::string.
(create_child): Change the 'name' parameter to a std::string
reference. Swap it into the new item's name.
(create_child_with_value): Swap item's name into the new child's
name. Use string_printf.
(new_variable): Use new instead of XNEW.
(free_variable): Don't xfree fields that are now std::string.
(name_of_variable, name_of_child): Now returns std::string.
(value_of_root): Adjust to use std::string.
(my_value_of_variable, varobj_value_get_print_value): Return
and use std::string.
(varobj_value_get_print_value): Adjust to use ui_file_as_string
and std::string.
* varobj.h (struct varobj) <name, path_expr, obj_name,
print_value>: Now std::string's.
<name_of_variable, name_of_child, path_expr_of_child,
value_of_variable>: Return std::string.
(varobj_create, varobj_get_handle): Constify 'objname' parameter.
(varobj_get_objname): Return a const char * instead of a char *.
(varobj_get_expression, varobj_get_type): Return a std::string.
(varobj_get_path_expr): Return a const char * instead of a char *.
(varobj_get_formatted_value, varobj_get_value): Return a
std::string.
(varobj_set_value): Constify 'expression' parameter.
(varobj_value_get_print_value): Return a std::string.
2016-11-08 16:26:47 +01:00
|
|
|
|
fputs_filtered (!s.empty () ? s.c_str () : name, stream);
|
* c-typeprint.c (find_typedef_for_canonicalize,
print_name_maybe_canonical): New functions.
(c_print_type): Look up type name.
(cp_type_print_derivation_info): Add flags argument. Use
print_name_maybe_canonical.
(cp_type_print_method_args): Add wrapping.
(c_type_print_varspec_prefix): Use print_name_maybe_canonical.
(c_type_print_template_args): New function.
(c_type_print_base): Change wrapping. Use
print_name_maybe_canonical.
<TYPE_CODE_STRUCT>: Possibly create a typedef hash, and do
type name lookups.
* gdbtypes.c (types_equal): No longer static.
* gdbtypes.h (types_equal): Declare.
* typeprint.c (type_print_raw_options, default_ptype_flags):
Update.
(struct typedef_hash_table): New.
(hash_typedef_field, eq_typedef_field,
recursively_update_typedef_hash, add_template_parameters,
create_typedef_hash, free_typedef_hash, do_free_typedef_hash,
make_cleanup_free_typedef_hash, copy_typedef_hash_element,
copy_typedef_hash, find_typedef_in_hash): New functions.
* typeprint.h (struct type_print_options) <local_typedefs>:
New field.
(recursively_update_typedef_hash, add_template_parameters,
create_typedef_hash, free_typedef_hash,
make_cleanup_free_typedef_hash, copy_typedef_hash,
find_typedef_in_hash): Declare.
testsuite
* gdb.base/call-sc.exp: Use "ptype/r".
* gdb.base/volatile.exp: Don't expect "int".
* gdb.cp/ptype-flags.cc: New file.
* gdb.cp/ptype-flags.exp: New file.
* gdb.cp/templates.exp: Use ptype/r.
(test_ptype_of_templates, test_template_typedef): Likewise.
* lib/cp-support.exp (cp_test_ptype_class): Add in_ptype_arg
argument. Handle template names and template parameters.
* gdb.mi/mi-var-cmd.exp: Accept "long".
* gdb.mi/mi-var-child.exp: Accept "long".
* gdb.mi/mi-var-display.exp: Accept "long".
* gdb.mi/mi2-var-child.exp: Accept "long".
2012-11-12 18:37:38 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Implement pahole-like 'ptype /o' option
This commit implements the pahole-like '/o' option for 'ptype', which
prints the offsets and sizes of struct fields, reporting whenever
there is a hole found.
The output is heavily based on pahole(1), with a few modifications
here and there to adjust it to our reality. Here's an example:
/* offset | size */ type = struct wer : public tuv {
public:
/* 32 | 24 */ struct tyu {
/* 32:31 | 4 */ int a1 : 1;
/* 32:28 | 4 */ int a2 : 3;
/* 32: 5 | 4 */ int a3 : 23;
/* 35: 3 | 1 */ char a4 : 2;
/* XXX 3-bit hole */
/* XXX 4-byte hole */
/* 40 | 8 */ int64_t a5;
/* 48:27 | 4 */ int a6 : 5;
/* 48:56 | 8 */ int64_t a7 : 3;
/* total size (bytes): 24 */
} a1;
/* total size (bytes): 56 */
}
A big part of this patch handles the formatting logic of 'ptype',
which is a bit messy. The code to handle bitfield offsets, however,
took some time to craft. My thanks to Pedro Alves for figuring things
out and pointing me to the right direction, as well as coming up with
a way to inspect the layout of structs with bitfields (see testcase
for comments).
After many discussions both on IRC and at the mailing list, I tried to
implement printing vtables and inherited classes. Unfortunately the
code grew too complex and there were still a few corner cases failing
so I had to drop the attempt. This should be implemented in a future
patch.
This patch is the start of a long-term work I'll do to flush the local
patches we carry for Fedora GDB. In this specific case, I'm aiming at
upstreaming the feature implemented by the 'pahole.py' script that is
shipped with Fedora GDB:
<https://src.fedoraproject.org/rpms/gdb/blob/master/f/gdb-archer.patch#_311>
This has been regression-tested on the BuildBot. There's a new
testcase for it, along with an update to the documentation. I also
thought it was worth mentioning this feature in the NEWS file.
gdb/ChangeLog:
2017-12-15 Sergio Durigan Junior <sergiodj@redhat.com>
Pedro Alves <palves@redhat.com>
PR cli/16224
* NEWS (Changes since GDB 8.0): Mention new '/o' flag.
* c-typeprint.c (OFFSET_SPC_LEN): New define.
(c_type_print_varspec_prefix): New argument 'struct
print_offset_data *'.
(c_type_print_base_1): New function and prototype.
(c_print_type_1): New function, with code from 'c_print_type'.
(c_print_type): Use 'c_print_type_1'.
(c_type_print_varspec_prefix): New argument 'struct
print_offset_data *'. Use it. Call 'c_type_print_base_1'
instead of 'c_print_type_base'.
(print_spaces_filtered_with_print_options): New function.
(output_access_specifier): Take new argument FLAGS. Modify
function to call 'print_spaces_filtered_with_print_options'.
(c_print_type_vtable_offset_marker): New function.
(c_print_type_union_field_offset): New function.
(c_print_type_struct_field_offset): New function.
(c_print_type_no_offsets): New function.
(c_type_print_base_struct_union): New argument 'struct
print_offset_data *'. Print offsets and sizes for
struct/union/class fields.
* typeprint.c (const struct type_print_options
type_print_raw_options): Initialize 'print_offsets'.
(static struct type_print_options default_ptype_flags):
Likewise.
(struct print_offset_data print_offset_default_data): New
variable.
(whatis_exp): Handle '/o' option.
(_initialize_typeprint): Add '/o' flag to ptype's help.
* typeprint.h (struct print_offset_data): New struct.
(struct type_print_options) <print_offsets>: New field.
gdb/testsuite/ChangeLog:
2017-12-15 Sergio Durigan Junior <sergiodj@redhat.com>
PR cli/16224
* gdb.base/ptype-offsets.cc: New file.
* gdb.base/ptype-offsets.exp: New file.
gdb/doc/ChangeLog:
2017-12-15 Sergio Durigan Junior <sergiodj@redhat.com>
PR cli/16224
* gdb.texinfo (ptype): Add documentation for new flag '/o'.
2017-11-20 22:34:59 +01:00
|
|
|
|
/* Helper function for c_print_type. */
|
1999-04-16 03:35:26 +02:00
|
|
|
|
|
Implement pahole-like 'ptype /o' option
This commit implements the pahole-like '/o' option for 'ptype', which
prints the offsets and sizes of struct fields, reporting whenever
there is a hole found.
The output is heavily based on pahole(1), with a few modifications
here and there to adjust it to our reality. Here's an example:
/* offset | size */ type = struct wer : public tuv {
public:
/* 32 | 24 */ struct tyu {
/* 32:31 | 4 */ int a1 : 1;
/* 32:28 | 4 */ int a2 : 3;
/* 32: 5 | 4 */ int a3 : 23;
/* 35: 3 | 1 */ char a4 : 2;
/* XXX 3-bit hole */
/* XXX 4-byte hole */
/* 40 | 8 */ int64_t a5;
/* 48:27 | 4 */ int a6 : 5;
/* 48:56 | 8 */ int64_t a7 : 3;
/* total size (bytes): 24 */
} a1;
/* total size (bytes): 56 */
}
A big part of this patch handles the formatting logic of 'ptype',
which is a bit messy. The code to handle bitfield offsets, however,
took some time to craft. My thanks to Pedro Alves for figuring things
out and pointing me to the right direction, as well as coming up with
a way to inspect the layout of structs with bitfields (see testcase
for comments).
After many discussions both on IRC and at the mailing list, I tried to
implement printing vtables and inherited classes. Unfortunately the
code grew too complex and there were still a few corner cases failing
so I had to drop the attempt. This should be implemented in a future
patch.
This patch is the start of a long-term work I'll do to flush the local
patches we carry for Fedora GDB. In this specific case, I'm aiming at
upstreaming the feature implemented by the 'pahole.py' script that is
shipped with Fedora GDB:
<https://src.fedoraproject.org/rpms/gdb/blob/master/f/gdb-archer.patch#_311>
This has been regression-tested on the BuildBot. There's a new
testcase for it, along with an update to the documentation. I also
thought it was worth mentioning this feature in the NEWS file.
gdb/ChangeLog:
2017-12-15 Sergio Durigan Junior <sergiodj@redhat.com>
Pedro Alves <palves@redhat.com>
PR cli/16224
* NEWS (Changes since GDB 8.0): Mention new '/o' flag.
* c-typeprint.c (OFFSET_SPC_LEN): New define.
(c_type_print_varspec_prefix): New argument 'struct
print_offset_data *'.
(c_type_print_base_1): New function and prototype.
(c_print_type_1): New function, with code from 'c_print_type'.
(c_print_type): Use 'c_print_type_1'.
(c_type_print_varspec_prefix): New argument 'struct
print_offset_data *'. Use it. Call 'c_type_print_base_1'
instead of 'c_print_type_base'.
(print_spaces_filtered_with_print_options): New function.
(output_access_specifier): Take new argument FLAGS. Modify
function to call 'print_spaces_filtered_with_print_options'.
(c_print_type_vtable_offset_marker): New function.
(c_print_type_union_field_offset): New function.
(c_print_type_struct_field_offset): New function.
(c_print_type_no_offsets): New function.
(c_type_print_base_struct_union): New argument 'struct
print_offset_data *'. Print offsets and sizes for
struct/union/class fields.
* typeprint.c (const struct type_print_options
type_print_raw_options): Initialize 'print_offsets'.
(static struct type_print_options default_ptype_flags):
Likewise.
(struct print_offset_data print_offset_default_data): New
variable.
(whatis_exp): Handle '/o' option.
(_initialize_typeprint): Add '/o' flag to ptype's help.
* typeprint.h (struct print_offset_data): New struct.
(struct type_print_options) <print_offsets>: New field.
gdb/testsuite/ChangeLog:
2017-12-15 Sergio Durigan Junior <sergiodj@redhat.com>
PR cli/16224
* gdb.base/ptype-offsets.cc: New file.
* gdb.base/ptype-offsets.exp: New file.
gdb/doc/ChangeLog:
2017-12-15 Sergio Durigan Junior <sergiodj@redhat.com>
PR cli/16224
* gdb.texinfo (ptype): Add documentation for new flag '/o'.
2017-11-20 22:34:59 +01:00
|
|
|
|
static void
|
|
|
|
|
c_print_type_1 (struct type *type,
|
|
|
|
|
const char *varstring,
|
|
|
|
|
struct ui_file *stream,
|
|
|
|
|
int show, int level,
|
2018-04-17 21:51:23 +02:00
|
|
|
|
enum language language,
|
Implement pahole-like 'ptype /o' option
This commit implements the pahole-like '/o' option for 'ptype', which
prints the offsets and sizes of struct fields, reporting whenever
there is a hole found.
The output is heavily based on pahole(1), with a few modifications
here and there to adjust it to our reality. Here's an example:
/* offset | size */ type = struct wer : public tuv {
public:
/* 32 | 24 */ struct tyu {
/* 32:31 | 4 */ int a1 : 1;
/* 32:28 | 4 */ int a2 : 3;
/* 32: 5 | 4 */ int a3 : 23;
/* 35: 3 | 1 */ char a4 : 2;
/* XXX 3-bit hole */
/* XXX 4-byte hole */
/* 40 | 8 */ int64_t a5;
/* 48:27 | 4 */ int a6 : 5;
/* 48:56 | 8 */ int64_t a7 : 3;
/* total size (bytes): 24 */
} a1;
/* total size (bytes): 56 */
}
A big part of this patch handles the formatting logic of 'ptype',
which is a bit messy. The code to handle bitfield offsets, however,
took some time to craft. My thanks to Pedro Alves for figuring things
out and pointing me to the right direction, as well as coming up with
a way to inspect the layout of structs with bitfields (see testcase
for comments).
After many discussions both on IRC and at the mailing list, I tried to
implement printing vtables and inherited classes. Unfortunately the
code grew too complex and there were still a few corner cases failing
so I had to drop the attempt. This should be implemented in a future
patch.
This patch is the start of a long-term work I'll do to flush the local
patches we carry for Fedora GDB. In this specific case, I'm aiming at
upstreaming the feature implemented by the 'pahole.py' script that is
shipped with Fedora GDB:
<https://src.fedoraproject.org/rpms/gdb/blob/master/f/gdb-archer.patch#_311>
This has been regression-tested on the BuildBot. There's a new
testcase for it, along with an update to the documentation. I also
thought it was worth mentioning this feature in the NEWS file.
gdb/ChangeLog:
2017-12-15 Sergio Durigan Junior <sergiodj@redhat.com>
Pedro Alves <palves@redhat.com>
PR cli/16224
* NEWS (Changes since GDB 8.0): Mention new '/o' flag.
* c-typeprint.c (OFFSET_SPC_LEN): New define.
(c_type_print_varspec_prefix): New argument 'struct
print_offset_data *'.
(c_type_print_base_1): New function and prototype.
(c_print_type_1): New function, with code from 'c_print_type'.
(c_print_type): Use 'c_print_type_1'.
(c_type_print_varspec_prefix): New argument 'struct
print_offset_data *'. Use it. Call 'c_type_print_base_1'
instead of 'c_print_type_base'.
(print_spaces_filtered_with_print_options): New function.
(output_access_specifier): Take new argument FLAGS. Modify
function to call 'print_spaces_filtered_with_print_options'.
(c_print_type_vtable_offset_marker): New function.
(c_print_type_union_field_offset): New function.
(c_print_type_struct_field_offset): New function.
(c_print_type_no_offsets): New function.
(c_type_print_base_struct_union): New argument 'struct
print_offset_data *'. Print offsets and sizes for
struct/union/class fields.
* typeprint.c (const struct type_print_options
type_print_raw_options): Initialize 'print_offsets'.
(static struct type_print_options default_ptype_flags):
Likewise.
(struct print_offset_data print_offset_default_data): New
variable.
(whatis_exp): Handle '/o' option.
(_initialize_typeprint): Add '/o' flag to ptype's help.
* typeprint.h (struct print_offset_data): New struct.
(struct type_print_options) <print_offsets>: New field.
gdb/testsuite/ChangeLog:
2017-12-15 Sergio Durigan Junior <sergiodj@redhat.com>
PR cli/16224
* gdb.base/ptype-offsets.cc: New file.
* gdb.base/ptype-offsets.exp: New file.
gdb/doc/ChangeLog:
2017-12-15 Sergio Durigan Junior <sergiodj@redhat.com>
PR cli/16224
* gdb.texinfo (ptype): Add documentation for new flag '/o'.
2017-11-20 22:34:59 +01:00
|
|
|
|
const struct type_print_options *flags,
|
|
|
|
|
struct print_offset_data *podata)
|
1999-04-16 03:35:26 +02:00
|
|
|
|
{
|
2003-09-14 Andrew Cagney <cagney@redhat.com>
* alpha-nat.c: Remove some occurances of "register".
* alpha-tdep.c, arm-tdep.c, blockframe.c, breakpoint.c: Ditto.
* buildsym.c, c-typeprint.c, c-valprint.c, coffread.c: Ditto.
* corefile.c, cp-support.c, cp-valprint.c, cris-tdep.c: Ditto.
* dbxread.c, dcache.c, dwarf2read.c, elfread.c: Ditto.
* environ.c, eval.c, event-top.c, f-typeprint.c: Ditto.
* f-valprint.c, findvar.c, frame.c, gdbtypes.c: Ditto.
* h8300-tdep.c, hppa-tdep.c, hppab-nat.c, hppah-nat.c: Ditto.
* hppam3-nat.c, hpread.c, ia64-aix-nat.c, ia64-linux-nat.c: Ditto.
* infcall.c, infcmd.c, inflow.c, infptrace.c, infrun.c: Ditto.
* infttrace.c, irix5-nat.c, jv-typeprint.c: Ditto.
* jv-valprint.c, m68k-tdep.c, m68klinux-nat.c, main.c: Ditto.
* mdebugread.c, minsyms.c, mips-linux-tdep.c: Ditto.
* mips-nat.c, mips-tdep.c, mipsread.c, mipsv4-nat.c: Ditto.
* ns32k-tdep.c, objfiles.c, p-typeprint.c: Ditto.
* p-valprint.c, ppc-linux-nat.c, printcmd.c: Ditto.
* remote-mips.c, remote-vx.c, rs6000-nat.c: Ditto.
* rs6000-tdep.c, scm-exp.c, sh-tdep.c, sh64-tdep.c: Ditto.
* solib.c, somread.c, source.c, sparc-tdep.c: Ditto.
* stabsread.c, stack.c, standalone.c, symfile.c: Ditto.
* symmisc.c, symtab.c, top.c, tracepoint.c: Ditto.
* typeprint.c, utils.c, valarith.c, valops.c: Ditto.
* values.c, vax-tdep.c, xcoffread.c: Ditto.
2003-09-14 18:32:14 +02:00
|
|
|
|
enum type_code code;
|
1999-04-16 03:35:26 +02:00
|
|
|
|
int demangled_args;
|
2002-10-15 00:58:28 +02:00
|
|
|
|
int need_post_space;
|
* c-typeprint.c (find_typedef_for_canonicalize,
print_name_maybe_canonical): New functions.
(c_print_type): Look up type name.
(cp_type_print_derivation_info): Add flags argument. Use
print_name_maybe_canonical.
(cp_type_print_method_args): Add wrapping.
(c_type_print_varspec_prefix): Use print_name_maybe_canonical.
(c_type_print_template_args): New function.
(c_type_print_base): Change wrapping. Use
print_name_maybe_canonical.
<TYPE_CODE_STRUCT>: Possibly create a typedef hash, and do
type name lookups.
* gdbtypes.c (types_equal): No longer static.
* gdbtypes.h (types_equal): Declare.
* typeprint.c (type_print_raw_options, default_ptype_flags):
Update.
(struct typedef_hash_table): New.
(hash_typedef_field, eq_typedef_field,
recursively_update_typedef_hash, add_template_parameters,
create_typedef_hash, free_typedef_hash, do_free_typedef_hash,
make_cleanup_free_typedef_hash, copy_typedef_hash_element,
copy_typedef_hash, find_typedef_in_hash): New functions.
* typeprint.h (struct type_print_options) <local_typedefs>:
New field.
(recursively_update_typedef_hash, add_template_parameters,
create_typedef_hash, free_typedef_hash,
make_cleanup_free_typedef_hash, copy_typedef_hash,
find_typedef_in_hash): Declare.
testsuite
* gdb.base/call-sc.exp: Use "ptype/r".
* gdb.base/volatile.exp: Don't expect "int".
* gdb.cp/ptype-flags.cc: New file.
* gdb.cp/ptype-flags.exp: New file.
* gdb.cp/templates.exp: Use ptype/r.
(test_ptype_of_templates, test_template_typedef): Likewise.
* lib/cp-support.exp (cp_test_ptype_class): Add in_ptype_arg
argument. Handle template names and template parameters.
* gdb.mi/mi-var-cmd.exp: Accept "long".
* gdb.mi/mi-var-child.exp: Accept "long".
* gdb.mi/mi-var-display.exp: Accept "long".
* gdb.mi/mi2-var-child.exp: Accept "long".
2012-11-12 18:37:38 +01:00
|
|
|
|
const char *local_name;
|
1999-04-16 03:35:26 +02:00
|
|
|
|
|
|
|
|
|
if (show > 0)
|
2015-07-06 22:05:06 +02:00
|
|
|
|
type = check_typedef (type);
|
1999-04-16 03:35:26 +02:00
|
|
|
|
|
2018-03-14 23:38:02 +01:00
|
|
|
|
local_name = typedef_hash_table::find_typedef (flags, type);
|
* c-typeprint.c (find_typedef_for_canonicalize,
print_name_maybe_canonical): New functions.
(c_print_type): Look up type name.
(cp_type_print_derivation_info): Add flags argument. Use
print_name_maybe_canonical.
(cp_type_print_method_args): Add wrapping.
(c_type_print_varspec_prefix): Use print_name_maybe_canonical.
(c_type_print_template_args): New function.
(c_type_print_base): Change wrapping. Use
print_name_maybe_canonical.
<TYPE_CODE_STRUCT>: Possibly create a typedef hash, and do
type name lookups.
* gdbtypes.c (types_equal): No longer static.
* gdbtypes.h (types_equal): Declare.
* typeprint.c (type_print_raw_options, default_ptype_flags):
Update.
(struct typedef_hash_table): New.
(hash_typedef_field, eq_typedef_field,
recursively_update_typedef_hash, add_template_parameters,
create_typedef_hash, free_typedef_hash, do_free_typedef_hash,
make_cleanup_free_typedef_hash, copy_typedef_hash_element,
copy_typedef_hash, find_typedef_in_hash): New functions.
* typeprint.h (struct type_print_options) <local_typedefs>:
New field.
(recursively_update_typedef_hash, add_template_parameters,
create_typedef_hash, free_typedef_hash,
make_cleanup_free_typedef_hash, copy_typedef_hash,
find_typedef_in_hash): Declare.
testsuite
* gdb.base/call-sc.exp: Use "ptype/r".
* gdb.base/volatile.exp: Don't expect "int".
* gdb.cp/ptype-flags.cc: New file.
* gdb.cp/ptype-flags.exp: New file.
* gdb.cp/templates.exp: Use ptype/r.
(test_ptype_of_templates, test_template_typedef): Likewise.
* lib/cp-support.exp (cp_test_ptype_class): Add in_ptype_arg
argument. Handle template names and template parameters.
* gdb.mi/mi-var-cmd.exp: Accept "long".
* gdb.mi/mi-var-child.exp: Accept "long".
* gdb.mi/mi-var-display.exp: Accept "long".
* gdb.mi/mi2-var-child.exp: Accept "long".
2012-11-12 18:37:38 +01:00
|
|
|
|
if (local_name != NULL)
|
|
|
|
|
{
|
|
|
|
|
fputs_filtered (local_name, stream);
|
|
|
|
|
if (varstring != NULL && *varstring != '\0')
|
|
|
|
|
fputs_filtered (" ", stream);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2018-04-17 21:51:23 +02:00
|
|
|
|
c_type_print_base_1 (type, stream, show, level, language, flags, podata);
|
* c-typeprint.c (find_typedef_for_canonicalize,
print_name_maybe_canonical): New functions.
(c_print_type): Look up type name.
(cp_type_print_derivation_info): Add flags argument. Use
print_name_maybe_canonical.
(cp_type_print_method_args): Add wrapping.
(c_type_print_varspec_prefix): Use print_name_maybe_canonical.
(c_type_print_template_args): New function.
(c_type_print_base): Change wrapping. Use
print_name_maybe_canonical.
<TYPE_CODE_STRUCT>: Possibly create a typedef hash, and do
type name lookups.
* gdbtypes.c (types_equal): No longer static.
* gdbtypes.h (types_equal): Declare.
* typeprint.c (type_print_raw_options, default_ptype_flags):
Update.
(struct typedef_hash_table): New.
(hash_typedef_field, eq_typedef_field,
recursively_update_typedef_hash, add_template_parameters,
create_typedef_hash, free_typedef_hash, do_free_typedef_hash,
make_cleanup_free_typedef_hash, copy_typedef_hash_element,
copy_typedef_hash, find_typedef_in_hash): New functions.
* typeprint.h (struct type_print_options) <local_typedefs>:
New field.
(recursively_update_typedef_hash, add_template_parameters,
create_typedef_hash, free_typedef_hash,
make_cleanup_free_typedef_hash, copy_typedef_hash,
find_typedef_in_hash): Declare.
testsuite
* gdb.base/call-sc.exp: Use "ptype/r".
* gdb.base/volatile.exp: Don't expect "int".
* gdb.cp/ptype-flags.cc: New file.
* gdb.cp/ptype-flags.exp: New file.
* gdb.cp/templates.exp: Use ptype/r.
(test_ptype_of_templates, test_template_typedef): Likewise.
* lib/cp-support.exp (cp_test_ptype_class): Add in_ptype_arg
argument. Handle template names and template parameters.
* gdb.mi/mi-var-cmd.exp: Accept "long".
* gdb.mi/mi-var-child.exp: Accept "long".
* gdb.mi/mi-var-display.exp: Accept "long".
* gdb.mi/mi2-var-child.exp: Accept "long".
2012-11-12 18:37:38 +01:00
|
|
|
|
code = TYPE_CODE (type);
|
|
|
|
|
if ((varstring != NULL && *varstring != '\0')
|
|
|
|
|
/* Need a space if going to print stars or brackets;
|
|
|
|
|
but not if we will print just a type name. */
|
|
|
|
|
|| ((show > 0 || TYPE_NAME (type) == 0)
|
|
|
|
|
&& (code == TYPE_CODE_PTR || code == TYPE_CODE_FUNC
|
|
|
|
|
|| code == TYPE_CODE_METHOD
|
|
|
|
|
|| (code == TYPE_CODE_ARRAY
|
|
|
|
|
&& !TYPE_VECTOR (type))
|
|
|
|
|
|| code == TYPE_CODE_MEMBERPTR
|
|
|
|
|
|| code == TYPE_CODE_METHODPTR
|
2017-03-20 21:47:48 +01:00
|
|
|
|
|| TYPE_IS_REFERENCE (type))))
|
* c-typeprint.c (find_typedef_for_canonicalize,
print_name_maybe_canonical): New functions.
(c_print_type): Look up type name.
(cp_type_print_derivation_info): Add flags argument. Use
print_name_maybe_canonical.
(cp_type_print_method_args): Add wrapping.
(c_type_print_varspec_prefix): Use print_name_maybe_canonical.
(c_type_print_template_args): New function.
(c_type_print_base): Change wrapping. Use
print_name_maybe_canonical.
<TYPE_CODE_STRUCT>: Possibly create a typedef hash, and do
type name lookups.
* gdbtypes.c (types_equal): No longer static.
* gdbtypes.h (types_equal): Declare.
* typeprint.c (type_print_raw_options, default_ptype_flags):
Update.
(struct typedef_hash_table): New.
(hash_typedef_field, eq_typedef_field,
recursively_update_typedef_hash, add_template_parameters,
create_typedef_hash, free_typedef_hash, do_free_typedef_hash,
make_cleanup_free_typedef_hash, copy_typedef_hash_element,
copy_typedef_hash, find_typedef_in_hash): New functions.
* typeprint.h (struct type_print_options) <local_typedefs>:
New field.
(recursively_update_typedef_hash, add_template_parameters,
create_typedef_hash, free_typedef_hash,
make_cleanup_free_typedef_hash, copy_typedef_hash,
find_typedef_in_hash): Declare.
testsuite
* gdb.base/call-sc.exp: Use "ptype/r".
* gdb.base/volatile.exp: Don't expect "int".
* gdb.cp/ptype-flags.cc: New file.
* gdb.cp/ptype-flags.exp: New file.
* gdb.cp/templates.exp: Use ptype/r.
(test_ptype_of_templates, test_template_typedef): Likewise.
* lib/cp-support.exp (cp_test_ptype_class): Add in_ptype_arg
argument. Handle template names and template parameters.
* gdb.mi/mi-var-cmd.exp: Accept "long".
* gdb.mi/mi-var-child.exp: Accept "long".
* gdb.mi/mi-var-display.exp: Accept "long".
* gdb.mi/mi2-var-child.exp: Accept "long".
2012-11-12 18:37:38 +01:00
|
|
|
|
fputs_filtered (" ", stream);
|
|
|
|
|
need_post_space = (varstring != NULL && strcmp (varstring, "") != 0);
|
|
|
|
|
c_type_print_varspec_prefix (type, stream, show, 0, need_post_space,
|
2018-04-17 21:51:23 +02:00
|
|
|
|
language, flags, podata);
|
* c-typeprint.c (find_typedef_for_canonicalize,
print_name_maybe_canonical): New functions.
(c_print_type): Look up type name.
(cp_type_print_derivation_info): Add flags argument. Use
print_name_maybe_canonical.
(cp_type_print_method_args): Add wrapping.
(c_type_print_varspec_prefix): Use print_name_maybe_canonical.
(c_type_print_template_args): New function.
(c_type_print_base): Change wrapping. Use
print_name_maybe_canonical.
<TYPE_CODE_STRUCT>: Possibly create a typedef hash, and do
type name lookups.
* gdbtypes.c (types_equal): No longer static.
* gdbtypes.h (types_equal): Declare.
* typeprint.c (type_print_raw_options, default_ptype_flags):
Update.
(struct typedef_hash_table): New.
(hash_typedef_field, eq_typedef_field,
recursively_update_typedef_hash, add_template_parameters,
create_typedef_hash, free_typedef_hash, do_free_typedef_hash,
make_cleanup_free_typedef_hash, copy_typedef_hash_element,
copy_typedef_hash, find_typedef_in_hash): New functions.
* typeprint.h (struct type_print_options) <local_typedefs>:
New field.
(recursively_update_typedef_hash, add_template_parameters,
create_typedef_hash, free_typedef_hash,
make_cleanup_free_typedef_hash, copy_typedef_hash,
find_typedef_in_hash): Declare.
testsuite
* gdb.base/call-sc.exp: Use "ptype/r".
* gdb.base/volatile.exp: Don't expect "int".
* gdb.cp/ptype-flags.cc: New file.
* gdb.cp/ptype-flags.exp: New file.
* gdb.cp/templates.exp: Use ptype/r.
(test_ptype_of_templates, test_template_typedef): Likewise.
* lib/cp-support.exp (cp_test_ptype_class): Add in_ptype_arg
argument. Handle template names and template parameters.
* gdb.mi/mi-var-cmd.exp: Accept "long".
* gdb.mi/mi-var-child.exp: Accept "long".
* gdb.mi/mi-var-display.exp: Accept "long".
* gdb.mi/mi2-var-child.exp: Accept "long".
2012-11-12 18:37:38 +01:00
|
|
|
|
}
|
1999-04-16 03:35:26 +02:00
|
|
|
|
|
|
|
|
|
if (varstring != NULL)
|
|
|
|
|
{
|
|
|
|
|
fputs_filtered (varstring, stream);
|
|
|
|
|
|
2010-12-31 23:59:52 +01:00
|
|
|
|
/* For demangled function names, we have the arglist as part of
|
2011-01-07 20:36:19 +01:00
|
|
|
|
the name, so don't print an additional pair of ()'s. */
|
* c-typeprint.c (find_typedef_for_canonicalize,
print_name_maybe_canonical): New functions.
(c_print_type): Look up type name.
(cp_type_print_derivation_info): Add flags argument. Use
print_name_maybe_canonical.
(cp_type_print_method_args): Add wrapping.
(c_type_print_varspec_prefix): Use print_name_maybe_canonical.
(c_type_print_template_args): New function.
(c_type_print_base): Change wrapping. Use
print_name_maybe_canonical.
<TYPE_CODE_STRUCT>: Possibly create a typedef hash, and do
type name lookups.
* gdbtypes.c (types_equal): No longer static.
* gdbtypes.h (types_equal): Declare.
* typeprint.c (type_print_raw_options, default_ptype_flags):
Update.
(struct typedef_hash_table): New.
(hash_typedef_field, eq_typedef_field,
recursively_update_typedef_hash, add_template_parameters,
create_typedef_hash, free_typedef_hash, do_free_typedef_hash,
make_cleanup_free_typedef_hash, copy_typedef_hash_element,
copy_typedef_hash, find_typedef_in_hash): New functions.
* typeprint.h (struct type_print_options) <local_typedefs>:
New field.
(recursively_update_typedef_hash, add_template_parameters,
create_typedef_hash, free_typedef_hash,
make_cleanup_free_typedef_hash, copy_typedef_hash,
find_typedef_in_hash): Declare.
testsuite
* gdb.base/call-sc.exp: Use "ptype/r".
* gdb.base/volatile.exp: Don't expect "int".
* gdb.cp/ptype-flags.cc: New file.
* gdb.cp/ptype-flags.exp: New file.
* gdb.cp/templates.exp: Use ptype/r.
(test_ptype_of_templates, test_template_typedef): Likewise.
* lib/cp-support.exp (cp_test_ptype_class): Add in_ptype_arg
argument. Handle template names and template parameters.
* gdb.mi/mi-var-cmd.exp: Accept "long".
* gdb.mi/mi-var-child.exp: Accept "long".
* gdb.mi/mi-var-display.exp: Accept "long".
* gdb.mi/mi2-var-child.exp: Accept "long".
2012-11-12 18:37:38 +01:00
|
|
|
|
if (local_name == NULL)
|
|
|
|
|
{
|
|
|
|
|
demangled_args = strchr (varstring, '(') != NULL;
|
|
|
|
|
c_type_print_varspec_suffix (type, stream, show,
|
|
|
|
|
0, demangled_args,
|
2018-04-17 21:51:23 +02:00
|
|
|
|
language, flags);
|
* c-typeprint.c (find_typedef_for_canonicalize,
print_name_maybe_canonical): New functions.
(c_print_type): Look up type name.
(cp_type_print_derivation_info): Add flags argument. Use
print_name_maybe_canonical.
(cp_type_print_method_args): Add wrapping.
(c_type_print_varspec_prefix): Use print_name_maybe_canonical.
(c_type_print_template_args): New function.
(c_type_print_base): Change wrapping. Use
print_name_maybe_canonical.
<TYPE_CODE_STRUCT>: Possibly create a typedef hash, and do
type name lookups.
* gdbtypes.c (types_equal): No longer static.
* gdbtypes.h (types_equal): Declare.
* typeprint.c (type_print_raw_options, default_ptype_flags):
Update.
(struct typedef_hash_table): New.
(hash_typedef_field, eq_typedef_field,
recursively_update_typedef_hash, add_template_parameters,
create_typedef_hash, free_typedef_hash, do_free_typedef_hash,
make_cleanup_free_typedef_hash, copy_typedef_hash_element,
copy_typedef_hash, find_typedef_in_hash): New functions.
* typeprint.h (struct type_print_options) <local_typedefs>:
New field.
(recursively_update_typedef_hash, add_template_parameters,
create_typedef_hash, free_typedef_hash,
make_cleanup_free_typedef_hash, copy_typedef_hash,
find_typedef_in_hash): Declare.
testsuite
* gdb.base/call-sc.exp: Use "ptype/r".
* gdb.base/volatile.exp: Don't expect "int".
* gdb.cp/ptype-flags.cc: New file.
* gdb.cp/ptype-flags.exp: New file.
* gdb.cp/templates.exp: Use ptype/r.
(test_ptype_of_templates, test_template_typedef): Likewise.
* lib/cp-support.exp (cp_test_ptype_class): Add in_ptype_arg
argument. Handle template names and template parameters.
* gdb.mi/mi-var-cmd.exp: Accept "long".
* gdb.mi/mi-var-child.exp: Accept "long".
* gdb.mi/mi-var-display.exp: Accept "long".
* gdb.mi/mi2-var-child.exp: Accept "long".
2012-11-12 18:37:38 +01:00
|
|
|
|
}
|
1999-04-16 03:35:26 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
1999-07-07 22:19:36 +02:00
|
|
|
|
|
Implement pahole-like 'ptype /o' option
This commit implements the pahole-like '/o' option for 'ptype', which
prints the offsets and sizes of struct fields, reporting whenever
there is a hole found.
The output is heavily based on pahole(1), with a few modifications
here and there to adjust it to our reality. Here's an example:
/* offset | size */ type = struct wer : public tuv {
public:
/* 32 | 24 */ struct tyu {
/* 32:31 | 4 */ int a1 : 1;
/* 32:28 | 4 */ int a2 : 3;
/* 32: 5 | 4 */ int a3 : 23;
/* 35: 3 | 1 */ char a4 : 2;
/* XXX 3-bit hole */
/* XXX 4-byte hole */
/* 40 | 8 */ int64_t a5;
/* 48:27 | 4 */ int a6 : 5;
/* 48:56 | 8 */ int64_t a7 : 3;
/* total size (bytes): 24 */
} a1;
/* total size (bytes): 56 */
}
A big part of this patch handles the formatting logic of 'ptype',
which is a bit messy. The code to handle bitfield offsets, however,
took some time to craft. My thanks to Pedro Alves for figuring things
out and pointing me to the right direction, as well as coming up with
a way to inspect the layout of structs with bitfields (see testcase
for comments).
After many discussions both on IRC and at the mailing list, I tried to
implement printing vtables and inherited classes. Unfortunately the
code grew too complex and there were still a few corner cases failing
so I had to drop the attempt. This should be implemented in a future
patch.
This patch is the start of a long-term work I'll do to flush the local
patches we carry for Fedora GDB. In this specific case, I'm aiming at
upstreaming the feature implemented by the 'pahole.py' script that is
shipped with Fedora GDB:
<https://src.fedoraproject.org/rpms/gdb/blob/master/f/gdb-archer.patch#_311>
This has been regression-tested on the BuildBot. There's a new
testcase for it, along with an update to the documentation. I also
thought it was worth mentioning this feature in the NEWS file.
gdb/ChangeLog:
2017-12-15 Sergio Durigan Junior <sergiodj@redhat.com>
Pedro Alves <palves@redhat.com>
PR cli/16224
* NEWS (Changes since GDB 8.0): Mention new '/o' flag.
* c-typeprint.c (OFFSET_SPC_LEN): New define.
(c_type_print_varspec_prefix): New argument 'struct
print_offset_data *'.
(c_type_print_base_1): New function and prototype.
(c_print_type_1): New function, with code from 'c_print_type'.
(c_print_type): Use 'c_print_type_1'.
(c_type_print_varspec_prefix): New argument 'struct
print_offset_data *'. Use it. Call 'c_type_print_base_1'
instead of 'c_print_type_base'.
(print_spaces_filtered_with_print_options): New function.
(output_access_specifier): Take new argument FLAGS. Modify
function to call 'print_spaces_filtered_with_print_options'.
(c_print_type_vtable_offset_marker): New function.
(c_print_type_union_field_offset): New function.
(c_print_type_struct_field_offset): New function.
(c_print_type_no_offsets): New function.
(c_type_print_base_struct_union): New argument 'struct
print_offset_data *'. Print offsets and sizes for
struct/union/class fields.
* typeprint.c (const struct type_print_options
type_print_raw_options): Initialize 'print_offsets'.
(static struct type_print_options default_ptype_flags):
Likewise.
(struct print_offset_data print_offset_default_data): New
variable.
(whatis_exp): Handle '/o' option.
(_initialize_typeprint): Add '/o' flag to ptype's help.
* typeprint.h (struct print_offset_data): New struct.
(struct type_print_options) <print_offsets>: New field.
gdb/testsuite/ChangeLog:
2017-12-15 Sergio Durigan Junior <sergiodj@redhat.com>
PR cli/16224
* gdb.base/ptype-offsets.cc: New file.
* gdb.base/ptype-offsets.exp: New file.
gdb/doc/ChangeLog:
2017-12-15 Sergio Durigan Junior <sergiodj@redhat.com>
PR cli/16224
* gdb.texinfo (ptype): Add documentation for new flag '/o'.
2017-11-20 22:34:59 +01:00
|
|
|
|
/* LEVEL is the depth to indent lines by. */
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
c_print_type (struct type *type,
|
|
|
|
|
const char *varstring,
|
|
|
|
|
struct ui_file *stream,
|
|
|
|
|
int show, int level,
|
|
|
|
|
const struct type_print_options *flags)
|
|
|
|
|
{
|
|
|
|
|
struct print_offset_data podata;
|
|
|
|
|
|
2018-04-17 21:51:23 +02:00
|
|
|
|
c_print_type_1 (type, varstring, stream, show, level,
|
|
|
|
|
current_language->la_language, flags, &podata);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* See c-lang.h. */
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
c_print_type (struct type *type,
|
|
|
|
|
const char *varstring,
|
|
|
|
|
struct ui_file *stream,
|
|
|
|
|
int show, int level,
|
|
|
|
|
enum language language,
|
|
|
|
|
const struct type_print_options *flags)
|
|
|
|
|
{
|
|
|
|
|
struct print_offset_data podata;
|
|
|
|
|
|
|
|
|
|
c_print_type_1 (type, varstring, stream, show, level, language, flags,
|
|
|
|
|
&podata);
|
Implement pahole-like 'ptype /o' option
This commit implements the pahole-like '/o' option for 'ptype', which
prints the offsets and sizes of struct fields, reporting whenever
there is a hole found.
The output is heavily based on pahole(1), with a few modifications
here and there to adjust it to our reality. Here's an example:
/* offset | size */ type = struct wer : public tuv {
public:
/* 32 | 24 */ struct tyu {
/* 32:31 | 4 */ int a1 : 1;
/* 32:28 | 4 */ int a2 : 3;
/* 32: 5 | 4 */ int a3 : 23;
/* 35: 3 | 1 */ char a4 : 2;
/* XXX 3-bit hole */
/* XXX 4-byte hole */
/* 40 | 8 */ int64_t a5;
/* 48:27 | 4 */ int a6 : 5;
/* 48:56 | 8 */ int64_t a7 : 3;
/* total size (bytes): 24 */
} a1;
/* total size (bytes): 56 */
}
A big part of this patch handles the formatting logic of 'ptype',
which is a bit messy. The code to handle bitfield offsets, however,
took some time to craft. My thanks to Pedro Alves for figuring things
out and pointing me to the right direction, as well as coming up with
a way to inspect the layout of structs with bitfields (see testcase
for comments).
After many discussions both on IRC and at the mailing list, I tried to
implement printing vtables and inherited classes. Unfortunately the
code grew too complex and there were still a few corner cases failing
so I had to drop the attempt. This should be implemented in a future
patch.
This patch is the start of a long-term work I'll do to flush the local
patches we carry for Fedora GDB. In this specific case, I'm aiming at
upstreaming the feature implemented by the 'pahole.py' script that is
shipped with Fedora GDB:
<https://src.fedoraproject.org/rpms/gdb/blob/master/f/gdb-archer.patch#_311>
This has been regression-tested on the BuildBot. There's a new
testcase for it, along with an update to the documentation. I also
thought it was worth mentioning this feature in the NEWS file.
gdb/ChangeLog:
2017-12-15 Sergio Durigan Junior <sergiodj@redhat.com>
Pedro Alves <palves@redhat.com>
PR cli/16224
* NEWS (Changes since GDB 8.0): Mention new '/o' flag.
* c-typeprint.c (OFFSET_SPC_LEN): New define.
(c_type_print_varspec_prefix): New argument 'struct
print_offset_data *'.
(c_type_print_base_1): New function and prototype.
(c_print_type_1): New function, with code from 'c_print_type'.
(c_print_type): Use 'c_print_type_1'.
(c_type_print_varspec_prefix): New argument 'struct
print_offset_data *'. Use it. Call 'c_type_print_base_1'
instead of 'c_print_type_base'.
(print_spaces_filtered_with_print_options): New function.
(output_access_specifier): Take new argument FLAGS. Modify
function to call 'print_spaces_filtered_with_print_options'.
(c_print_type_vtable_offset_marker): New function.
(c_print_type_union_field_offset): New function.
(c_print_type_struct_field_offset): New function.
(c_print_type_no_offsets): New function.
(c_type_print_base_struct_union): New argument 'struct
print_offset_data *'. Print offsets and sizes for
struct/union/class fields.
* typeprint.c (const struct type_print_options
type_print_raw_options): Initialize 'print_offsets'.
(static struct type_print_options default_ptype_flags):
Likewise.
(struct print_offset_data print_offset_default_data): New
variable.
(whatis_exp): Handle '/o' option.
(_initialize_typeprint): Add '/o' flag to ptype's help.
* typeprint.h (struct print_offset_data): New struct.
(struct type_print_options) <print_offsets>: New field.
gdb/testsuite/ChangeLog:
2017-12-15 Sergio Durigan Junior <sergiodj@redhat.com>
PR cli/16224
* gdb.base/ptype-offsets.cc: New file.
* gdb.base/ptype-offsets.exp: New file.
gdb/doc/ChangeLog:
2017-12-15 Sergio Durigan Junior <sergiodj@redhat.com>
PR cli/16224
* gdb.texinfo (ptype): Add documentation for new flag '/o'.
2017-11-20 22:34:59 +01:00
|
|
|
|
}
|
|
|
|
|
|
2008-09-27 23:29:30 +02:00
|
|
|
|
/* Print a typedef using C syntax. TYPE is the underlying type.
|
|
|
|
|
NEW_SYMBOL is the symbol naming the type. STREAM is the stream on
|
|
|
|
|
which to print. */
|
|
|
|
|
|
|
|
|
|
void
|
2010-12-31 23:59:52 +01:00
|
|
|
|
c_print_typedef (struct type *type,
|
|
|
|
|
struct symbol *new_symbol,
|
2008-09-27 23:29:30 +02:00
|
|
|
|
struct ui_file *stream)
|
|
|
|
|
{
|
2015-07-06 22:05:06 +02:00
|
|
|
|
type = check_typedef (type);
|
2008-09-27 23:29:30 +02:00
|
|
|
|
fprintf_filtered (stream, "typedef ");
|
|
|
|
|
type_print (type, "", stream, 0);
|
|
|
|
|
if (TYPE_NAME ((SYMBOL_TYPE (new_symbol))) == 0
|
|
|
|
|
|| strcmp (TYPE_NAME ((SYMBOL_TYPE (new_symbol))),
|
2010-06-25 09:32:25 +02:00
|
|
|
|
SYMBOL_LINKAGE_NAME (new_symbol)) != 0
|
|
|
|
|
|| TYPE_CODE (SYMBOL_TYPE (new_symbol)) == TYPE_CODE_TYPEDEF)
|
2008-09-27 23:29:30 +02:00
|
|
|
|
fprintf_filtered (stream, " %s", SYMBOL_PRINT_NAME (new_symbol));
|
|
|
|
|
fprintf_filtered (stream, ";\n");
|
|
|
|
|
}
|
|
|
|
|
|
1999-04-16 03:35:26 +02:00
|
|
|
|
/* If TYPE is a derived type, then print out derivation information.
|
2010-12-31 23:59:52 +01:00
|
|
|
|
Print only the actual base classes of this type, not the base
|
|
|
|
|
classes of the base classes. I.e. for the derivation hierarchy:
|
1999-04-16 03:35:26 +02:00
|
|
|
|
|
1999-07-07 22:19:36 +02:00
|
|
|
|
class A { int a; };
|
|
|
|
|
class B : public A {int b; };
|
|
|
|
|
class C : public B {int c; };
|
1999-04-16 03:35:26 +02:00
|
|
|
|
|
|
|
|
|
Print the type of class C as:
|
|
|
|
|
|
1999-07-07 22:19:36 +02:00
|
|
|
|
class C : public B {
|
|
|
|
|
int c;
|
|
|
|
|
}
|
1999-04-16 03:35:26 +02:00
|
|
|
|
|
2010-12-31 23:59:52 +01:00
|
|
|
|
Not as the following (like gdb used to), which is not legal C++
|
|
|
|
|
syntax for derived types and may be confused with the multiple
|
|
|
|
|
inheritance form:
|
1999-04-16 03:35:26 +02:00
|
|
|
|
|
1999-07-07 22:19:36 +02:00
|
|
|
|
class C : public B : public A {
|
|
|
|
|
int c;
|
|
|
|
|
}
|
1999-04-16 03:35:26 +02:00
|
|
|
|
|
2010-12-31 23:59:52 +01:00
|
|
|
|
In general, gdb should try to print the types as closely as
|
2012-09-21 19:33:17 +02:00
|
|
|
|
possible to the form that they appear in the source code. */
|
1999-04-16 03:35:26 +02:00
|
|
|
|
|
|
|
|
|
static void
|
2010-12-31 23:59:52 +01:00
|
|
|
|
cp_type_print_derivation_info (struct ui_file *stream,
|
* c-typeprint.c (find_typedef_for_canonicalize,
print_name_maybe_canonical): New functions.
(c_print_type): Look up type name.
(cp_type_print_derivation_info): Add flags argument. Use
print_name_maybe_canonical.
(cp_type_print_method_args): Add wrapping.
(c_type_print_varspec_prefix): Use print_name_maybe_canonical.
(c_type_print_template_args): New function.
(c_type_print_base): Change wrapping. Use
print_name_maybe_canonical.
<TYPE_CODE_STRUCT>: Possibly create a typedef hash, and do
type name lookups.
* gdbtypes.c (types_equal): No longer static.
* gdbtypes.h (types_equal): Declare.
* typeprint.c (type_print_raw_options, default_ptype_flags):
Update.
(struct typedef_hash_table): New.
(hash_typedef_field, eq_typedef_field,
recursively_update_typedef_hash, add_template_parameters,
create_typedef_hash, free_typedef_hash, do_free_typedef_hash,
make_cleanup_free_typedef_hash, copy_typedef_hash_element,
copy_typedef_hash, find_typedef_in_hash): New functions.
* typeprint.h (struct type_print_options) <local_typedefs>:
New field.
(recursively_update_typedef_hash, add_template_parameters,
create_typedef_hash, free_typedef_hash,
make_cleanup_free_typedef_hash, copy_typedef_hash,
find_typedef_in_hash): Declare.
testsuite
* gdb.base/call-sc.exp: Use "ptype/r".
* gdb.base/volatile.exp: Don't expect "int".
* gdb.cp/ptype-flags.cc: New file.
* gdb.cp/ptype-flags.exp: New file.
* gdb.cp/templates.exp: Use ptype/r.
(test_ptype_of_templates, test_template_typedef): Likewise.
* lib/cp-support.exp (cp_test_ptype_class): Add in_ptype_arg
argument. Handle template names and template parameters.
* gdb.mi/mi-var-cmd.exp: Accept "long".
* gdb.mi/mi-var-child.exp: Accept "long".
* gdb.mi/mi-var-display.exp: Accept "long".
* gdb.mi/mi2-var-child.exp: Accept "long".
2012-11-12 18:37:38 +01:00
|
|
|
|
struct type *type,
|
|
|
|
|
const struct type_print_options *flags)
|
1999-04-16 03:35:26 +02:00
|
|
|
|
{
|
* gdbtypes.h (struct main_type): Change type of name,tag_name,
and fields.name members from char * to const char *. All uses updated.
(struct cplus_struct_type): Change type of fn_fieldlists.name member
from char * to const char *. All uses updated.
(type_name_no_tag): Update.
(lookup_unsigned_typename, lookup_signed_typename): Update.
* gdbtypes.c (type_name_no_tag): Change result type
from char * to const char *. All callers updated.
(lookup_unsigned_typename, lookup_signed_typename): Change type of
name parameter from char * to const char *.
* symtab.h (struct cplus_specific): Change type of demangled_name
member from char * to const char *. All uses updated.
(struct general_symbol_info): Change type of name and
mangled_lang.demangled_name members from char * to const char *.
All uses updated.
(symbol_get_demangled_name, symbol_natural_name): Update.
(symbol_demangled_name, symbol_search_name): Update.
* symtab.c (symbol_get_demangled_name): Change result type
from char * to const char *. All callers updated.
(symbol_natural_name, symbol_demangled_name): Ditto.
(symbol_search_name): Ditto.
(completion_list_add_name): Change type of symname,sym_text,
text,word parameters from char * to const char *.
(completion_list_objc_symbol): Change type of sym_text,
text,word parameters from char * to const char *.
* ada-lang.c (find_struct_field): Change type of name parameter
from char * to const char *.
(encoded_ordered_before): Similarly for N0,N1 parameters.
(old_renaming_is_invisible): Similarly for function_name parameter.
(ada_type_name): Change result type from char * to const char *.
All callers updated.
* ada-lang.h (ada_type_name): Update.
* buildsym.c (hashname): Change type of name parameter
from char * to const char *.
* buildsym.h (hashname): Update.
* dbxread.c (end_psymtab): Change type of include_list parameter
from char ** to const char **.
* dwarf2read.c (determine_prefix): Change result type
from char * to const char *. All callers updated.
* f-lang.c (find_common_for_function): Change type of name, funcname
parameters from char * to const char *.
* f-lang.c (find_common_for_function): Update.
* f-valprint.c (list_all_visible_commons): Change type of funcname
parameters from char * to const char *.
* gdbarch.sh (static_transform_name): Change type of name parameter
and result from char * to const char *.
* gdbarch.c: Regenerate.
* gdbarch.h: Regenerate.
* i386-sol2-tdep.c (i386_sol2_static_transform_name): Change type
of name parameter from char * to const char *.
* jv-lang.c (java_primitive_type_from_name): Ditto.
(java_demangled_signature_length): Similarly for signature parameter.
(java_demangled_signature_copy): Ditto.
(java_demangle_type_signature): Ditto.
* jv-lang.h (java_primitive_type_from_name): Update.
(java_demangle_type_signature): Update.
* objc-lang.c (specialcmp): Change type of a,b parameters
from char * to const char *.
* p-lang.c (is_pascal_string_type): Change type of arrayname parameter
from char * to const char *. All callers updated.
* p-lang.h (is_pascal_string_type): Update.
* solib-frv.c (find_canonical_descriptor_in_load_object): Change type
of name parameter from char * to const char *.
* sparc-sol2-tdep.c (sparc_sol2_static_transform_name): Ditto.
* utils.c (fprintf_symbol_filtered): Ditto.
* defs.h (fprintf_symbol_filtered): Update.
* sparc-tdep.h (sparc_sol2_static_transform_name): Update.
* stabsread.h (end_psymtab): Update.
* stack.c (find_frame_funname): Change type of funname parameter
from char ** to const char **.
* stack.h (find_frame_funname): Update.
* typeprint.c (type_print): Change type of varstring parameter
from char * to const char *.
* value.h (type_print): Update.
* xcoffread.c (xcoff_start_psymtab): Change type of filename parameter
from char * to const char *. All callers updated.
(xcoff_end_psymtab): Change type of include_list parameter
from char ** to const char **. All callers updated.
(swap_sym): Similarly for name parameter. All callers updated.
* coffread.c (patch_type): Add (char*) cast to xfree parameter.
Use xstrdup.
(process_coff_symbol): Use xstrdup.
* stabsread.c (stabs_method_name_from_physname): Renamed from
update_method_name_from_physname. Change result type from void
to char *. All callers updated.
(read_member_functions): In has_destructor case, store name in objfile
obstack instead of malloc space. In !has_stub case, fix mem leak.
2012-02-07 05:48:23 +01:00
|
|
|
|
const char *name;
|
1999-04-16 03:35:26 +02:00
|
|
|
|
int i;
|
|
|
|
|
|
|
|
|
|
for (i = 0; i < TYPE_N_BASECLASSES (type); i++)
|
|
|
|
|
{
|
* c-typeprint.c (find_typedef_for_canonicalize,
print_name_maybe_canonical): New functions.
(c_print_type): Look up type name.
(cp_type_print_derivation_info): Add flags argument. Use
print_name_maybe_canonical.
(cp_type_print_method_args): Add wrapping.
(c_type_print_varspec_prefix): Use print_name_maybe_canonical.
(c_type_print_template_args): New function.
(c_type_print_base): Change wrapping. Use
print_name_maybe_canonical.
<TYPE_CODE_STRUCT>: Possibly create a typedef hash, and do
type name lookups.
* gdbtypes.c (types_equal): No longer static.
* gdbtypes.h (types_equal): Declare.
* typeprint.c (type_print_raw_options, default_ptype_flags):
Update.
(struct typedef_hash_table): New.
(hash_typedef_field, eq_typedef_field,
recursively_update_typedef_hash, add_template_parameters,
create_typedef_hash, free_typedef_hash, do_free_typedef_hash,
make_cleanup_free_typedef_hash, copy_typedef_hash_element,
copy_typedef_hash, find_typedef_in_hash): New functions.
* typeprint.h (struct type_print_options) <local_typedefs>:
New field.
(recursively_update_typedef_hash, add_template_parameters,
create_typedef_hash, free_typedef_hash,
make_cleanup_free_typedef_hash, copy_typedef_hash,
find_typedef_in_hash): Declare.
testsuite
* gdb.base/call-sc.exp: Use "ptype/r".
* gdb.base/volatile.exp: Don't expect "int".
* gdb.cp/ptype-flags.cc: New file.
* gdb.cp/ptype-flags.exp: New file.
* gdb.cp/templates.exp: Use ptype/r.
(test_ptype_of_templates, test_template_typedef): Likewise.
* lib/cp-support.exp (cp_test_ptype_class): Add in_ptype_arg
argument. Handle template names and template parameters.
* gdb.mi/mi-var-cmd.exp: Accept "long".
* gdb.mi/mi-var-child.exp: Accept "long".
* gdb.mi/mi-var-display.exp: Accept "long".
* gdb.mi/mi2-var-child.exp: Accept "long".
2012-11-12 18:37:38 +01:00
|
|
|
|
wrap_here (" ");
|
1999-04-16 03:35:26 +02:00
|
|
|
|
fputs_filtered (i == 0 ? ": " : ", ", stream);
|
|
|
|
|
fprintf_filtered (stream, "%s%s ",
|
2010-12-31 23:59:52 +01:00
|
|
|
|
BASETYPE_VIA_PUBLIC (type, i)
|
|
|
|
|
? "public" : (TYPE_FIELD_PROTECTED (type, i)
|
|
|
|
|
? "protected" : "private"),
|
1999-07-07 22:19:36 +02:00
|
|
|
|
BASETYPE_VIA_VIRTUAL (type, i) ? " virtual" : "");
|
Remove type_name_no_tag and rename type_name_no_tag_or_error
type_name_no_tag is just a plain wrapper for TYPE_NAME now, so this
patch removes it. And, because tag names no longer exist, this
renames type_name_no_tag_or_error to type_name_or_error.
gdb/ChangeLog
2018-06-01 Tom Tromey <tom@tromey.com>
* valops.c (value_cast_structs, destructor_name_p): Update.
* symtab.c (gdb_mangle_name): Update.
* stabsread.c (define_symbol, read_cpp_abbrev, read_baseclasses):
Update.
* p-valprint.c (pascal_object_is_vtbl_ptr_type)
(pascal_object_print_value_fields, pascal_object_print_value):
Update.
* p-typeprint.c (pascal_type_print_derivation_info): Update.
* linespec.c (find_methods): Update.
* gdbtypes.h (type_name_no_tag): Remove.
(type_name_or_error): Rename from type_name_no_tag_or_error.
* gdbtypes.c (type_name_no_tag): Remove.
(type_name_or_error): Rename from type_name_no_tag_or_error.
(lookup_struct_elt_type, check_typedef): Update.
* expprint.c (print_subexp_standard): Update.
* dwarf2read.c (dwarf2_add_field, load_partial_dies): Update.
* d-namespace.c (d_lookup_nested_symbol): Update.
* cp-valprint.c (cp_is_vtbl_ptr_type, cp_print_value_fields)
(cp_print_class_member): Update.
* cp-namespace.c (cp_lookup_nested_symbol): Update.
* completer.c (add_struct_fields): Update.
* c-typeprint.c (cp_type_print_derivation_info)
(c_type_print_varspec_prefix, c_type_print_base_struct_union):
Update.
* ada-lang.c (parse_old_style_renaming, xget_renaming_scope)
(ada_prefer_type, ada_is_exception_sym): Update.
2018-04-17 21:51:25 +02:00
|
|
|
|
name = TYPE_NAME (TYPE_BASECLASS (type, i));
|
* c-typeprint.c (find_typedef_for_canonicalize,
print_name_maybe_canonical): New functions.
(c_print_type): Look up type name.
(cp_type_print_derivation_info): Add flags argument. Use
print_name_maybe_canonical.
(cp_type_print_method_args): Add wrapping.
(c_type_print_varspec_prefix): Use print_name_maybe_canonical.
(c_type_print_template_args): New function.
(c_type_print_base): Change wrapping. Use
print_name_maybe_canonical.
<TYPE_CODE_STRUCT>: Possibly create a typedef hash, and do
type name lookups.
* gdbtypes.c (types_equal): No longer static.
* gdbtypes.h (types_equal): Declare.
* typeprint.c (type_print_raw_options, default_ptype_flags):
Update.
(struct typedef_hash_table): New.
(hash_typedef_field, eq_typedef_field,
recursively_update_typedef_hash, add_template_parameters,
create_typedef_hash, free_typedef_hash, do_free_typedef_hash,
make_cleanup_free_typedef_hash, copy_typedef_hash_element,
copy_typedef_hash, find_typedef_in_hash): New functions.
* typeprint.h (struct type_print_options) <local_typedefs>:
New field.
(recursively_update_typedef_hash, add_template_parameters,
create_typedef_hash, free_typedef_hash,
make_cleanup_free_typedef_hash, copy_typedef_hash,
find_typedef_in_hash): Declare.
testsuite
* gdb.base/call-sc.exp: Use "ptype/r".
* gdb.base/volatile.exp: Don't expect "int".
* gdb.cp/ptype-flags.cc: New file.
* gdb.cp/ptype-flags.exp: New file.
* gdb.cp/templates.exp: Use ptype/r.
(test_ptype_of_templates, test_template_typedef): Likewise.
* lib/cp-support.exp (cp_test_ptype_class): Add in_ptype_arg
argument. Handle template names and template parameters.
* gdb.mi/mi-var-cmd.exp: Accept "long".
* gdb.mi/mi-var-child.exp: Accept "long".
* gdb.mi/mi-var-display.exp: Accept "long".
* gdb.mi/mi2-var-child.exp: Accept "long".
2012-11-12 18:37:38 +01:00
|
|
|
|
if (name)
|
|
|
|
|
print_name_maybe_canonical (name, flags, stream);
|
|
|
|
|
else
|
|
|
|
|
fprintf_filtered (stream, "(null)");
|
1999-04-16 03:35:26 +02:00
|
|
|
|
}
|
|
|
|
|
if (i > 0)
|
|
|
|
|
{
|
|
|
|
|
fputs_filtered (" ", stream);
|
|
|
|
|
}
|
|
|
|
|
}
|
2002-06-14 16:34:26 +02:00
|
|
|
|
|
1999-04-16 03:35:26 +02:00
|
|
|
|
/* Print the C++ method arguments ARGS to the file STREAM. */
|
1999-07-07 22:19:36 +02:00
|
|
|
|
|
1999-05-25 20:09:09 +02:00
|
|
|
|
static void
|
* gdbtypes.h (struct main_type): Change type of name,tag_name,
and fields.name members from char * to const char *. All uses updated.
(struct cplus_struct_type): Change type of fn_fieldlists.name member
from char * to const char *. All uses updated.
(type_name_no_tag): Update.
(lookup_unsigned_typename, lookup_signed_typename): Update.
* gdbtypes.c (type_name_no_tag): Change result type
from char * to const char *. All callers updated.
(lookup_unsigned_typename, lookup_signed_typename): Change type of
name parameter from char * to const char *.
* symtab.h (struct cplus_specific): Change type of demangled_name
member from char * to const char *. All uses updated.
(struct general_symbol_info): Change type of name and
mangled_lang.demangled_name members from char * to const char *.
All uses updated.
(symbol_get_demangled_name, symbol_natural_name): Update.
(symbol_demangled_name, symbol_search_name): Update.
* symtab.c (symbol_get_demangled_name): Change result type
from char * to const char *. All callers updated.
(symbol_natural_name, symbol_demangled_name): Ditto.
(symbol_search_name): Ditto.
(completion_list_add_name): Change type of symname,sym_text,
text,word parameters from char * to const char *.
(completion_list_objc_symbol): Change type of sym_text,
text,word parameters from char * to const char *.
* ada-lang.c (find_struct_field): Change type of name parameter
from char * to const char *.
(encoded_ordered_before): Similarly for N0,N1 parameters.
(old_renaming_is_invisible): Similarly for function_name parameter.
(ada_type_name): Change result type from char * to const char *.
All callers updated.
* ada-lang.h (ada_type_name): Update.
* buildsym.c (hashname): Change type of name parameter
from char * to const char *.
* buildsym.h (hashname): Update.
* dbxread.c (end_psymtab): Change type of include_list parameter
from char ** to const char **.
* dwarf2read.c (determine_prefix): Change result type
from char * to const char *. All callers updated.
* f-lang.c (find_common_for_function): Change type of name, funcname
parameters from char * to const char *.
* f-lang.c (find_common_for_function): Update.
* f-valprint.c (list_all_visible_commons): Change type of funcname
parameters from char * to const char *.
* gdbarch.sh (static_transform_name): Change type of name parameter
and result from char * to const char *.
* gdbarch.c: Regenerate.
* gdbarch.h: Regenerate.
* i386-sol2-tdep.c (i386_sol2_static_transform_name): Change type
of name parameter from char * to const char *.
* jv-lang.c (java_primitive_type_from_name): Ditto.
(java_demangled_signature_length): Similarly for signature parameter.
(java_demangled_signature_copy): Ditto.
(java_demangle_type_signature): Ditto.
* jv-lang.h (java_primitive_type_from_name): Update.
(java_demangle_type_signature): Update.
* objc-lang.c (specialcmp): Change type of a,b parameters
from char * to const char *.
* p-lang.c (is_pascal_string_type): Change type of arrayname parameter
from char * to const char *. All callers updated.
* p-lang.h (is_pascal_string_type): Update.
* solib-frv.c (find_canonical_descriptor_in_load_object): Change type
of name parameter from char * to const char *.
* sparc-sol2-tdep.c (sparc_sol2_static_transform_name): Ditto.
* utils.c (fprintf_symbol_filtered): Ditto.
* defs.h (fprintf_symbol_filtered): Update.
* sparc-tdep.h (sparc_sol2_static_transform_name): Update.
* stabsread.h (end_psymtab): Update.
* stack.c (find_frame_funname): Change type of funname parameter
from char ** to const char **.
* stack.h (find_frame_funname): Update.
* typeprint.c (type_print): Change type of varstring parameter
from char * to const char *.
* value.h (type_print): Update.
* xcoffread.c (xcoff_start_psymtab): Change type of filename parameter
from char * to const char *. All callers updated.
(xcoff_end_psymtab): Change type of include_list parameter
from char ** to const char **. All callers updated.
(swap_sym): Similarly for name parameter. All callers updated.
* coffread.c (patch_type): Add (char*) cast to xfree parameter.
Use xstrdup.
(process_coff_symbol): Use xstrdup.
* stabsread.c (stabs_method_name_from_physname): Renamed from
update_method_name_from_physname. Change result type from void
to char *. All callers updated.
(read_member_functions): In has_destructor case, store name in objfile
obstack instead of malloc space. In !has_stub case, fix mem leak.
2012-02-07 05:48:23 +01:00
|
|
|
|
cp_type_print_method_args (struct type *mtype, const char *prefix,
|
|
|
|
|
const char *varstring, int staticp,
|
2012-11-12 18:20:39 +01:00
|
|
|
|
struct ui_file *stream,
|
2018-04-17 21:51:23 +02:00
|
|
|
|
enum language language,
|
2012-11-12 18:20:39 +01:00
|
|
|
|
const struct type_print_options *flags)
|
1999-04-16 03:35:26 +02:00
|
|
|
|
{
|
2002-06-14 16:34:26 +02:00
|
|
|
|
struct field *args = TYPE_FIELDS (mtype);
|
|
|
|
|
int nargs = TYPE_NFIELDS (mtype);
|
|
|
|
|
int varargs = TYPE_VARARGS (mtype);
|
1999-04-16 03:35:26 +02:00
|
|
|
|
int i;
|
1999-07-07 22:19:36 +02:00
|
|
|
|
|
2010-12-31 23:59:52 +01:00
|
|
|
|
fprintf_symbol_filtered (stream, prefix,
|
|
|
|
|
language_cplus, DMGL_ANSI);
|
|
|
|
|
fprintf_symbol_filtered (stream, varstring,
|
|
|
|
|
language_cplus, DMGL_ANSI);
|
1999-04-16 03:35:26 +02:00
|
|
|
|
fputs_filtered ("(", stream);
|
2002-06-14 16:34:26 +02:00
|
|
|
|
|
2017-03-10 19:32:09 +01:00
|
|
|
|
/* Skip the class variable. We keep this here to accommodate older
|
|
|
|
|
compilers and debug formats which may not support artificial
|
|
|
|
|
parameters. */
|
2002-06-14 16:34:26 +02:00
|
|
|
|
i = staticp ? 0 : 1;
|
|
|
|
|
if (nargs > i)
|
1999-04-16 03:35:26 +02:00
|
|
|
|
{
|
2002-06-14 16:34:26 +02:00
|
|
|
|
while (i < nargs)
|
1999-07-07 22:19:36 +02:00
|
|
|
|
{
|
2017-03-10 19:32:09 +01:00
|
|
|
|
struct field arg = args[i++];
|
|
|
|
|
|
|
|
|
|
/* Skip any artificial arguments. */
|
|
|
|
|
if (FIELD_ARTIFICIAL (arg))
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
c_print_type (arg.type, "", stream, 0, 0, flags);
|
2002-06-14 16:34:26 +02:00
|
|
|
|
|
|
|
|
|
if (i == nargs && varargs)
|
|
|
|
|
fprintf_filtered (stream, ", ...");
|
|
|
|
|
else if (i < nargs)
|
* c-typeprint.c (find_typedef_for_canonicalize,
print_name_maybe_canonical): New functions.
(c_print_type): Look up type name.
(cp_type_print_derivation_info): Add flags argument. Use
print_name_maybe_canonical.
(cp_type_print_method_args): Add wrapping.
(c_type_print_varspec_prefix): Use print_name_maybe_canonical.
(c_type_print_template_args): New function.
(c_type_print_base): Change wrapping. Use
print_name_maybe_canonical.
<TYPE_CODE_STRUCT>: Possibly create a typedef hash, and do
type name lookups.
* gdbtypes.c (types_equal): No longer static.
* gdbtypes.h (types_equal): Declare.
* typeprint.c (type_print_raw_options, default_ptype_flags):
Update.
(struct typedef_hash_table): New.
(hash_typedef_field, eq_typedef_field,
recursively_update_typedef_hash, add_template_parameters,
create_typedef_hash, free_typedef_hash, do_free_typedef_hash,
make_cleanup_free_typedef_hash, copy_typedef_hash_element,
copy_typedef_hash, find_typedef_in_hash): New functions.
* typeprint.h (struct type_print_options) <local_typedefs>:
New field.
(recursively_update_typedef_hash, add_template_parameters,
create_typedef_hash, free_typedef_hash,
make_cleanup_free_typedef_hash, copy_typedef_hash,
find_typedef_in_hash): Declare.
testsuite
* gdb.base/call-sc.exp: Use "ptype/r".
* gdb.base/volatile.exp: Don't expect "int".
* gdb.cp/ptype-flags.cc: New file.
* gdb.cp/ptype-flags.exp: New file.
* gdb.cp/templates.exp: Use ptype/r.
(test_ptype_of_templates, test_template_typedef): Likewise.
* lib/cp-support.exp (cp_test_ptype_class): Add in_ptype_arg
argument. Handle template names and template parameters.
* gdb.mi/mi-var-cmd.exp: Accept "long".
* gdb.mi/mi-var-child.exp: Accept "long".
* gdb.mi/mi-var-display.exp: Accept "long".
* gdb.mi/mi2-var-child.exp: Accept "long".
2012-11-12 18:37:38 +01:00
|
|
|
|
{
|
|
|
|
|
fprintf_filtered (stream, ", ");
|
|
|
|
|
wrap_here (" ");
|
|
|
|
|
}
|
1999-07-07 22:19:36 +02:00
|
|
|
|
}
|
1999-04-16 03:35:26 +02:00
|
|
|
|
}
|
2002-06-14 16:34:26 +02:00
|
|
|
|
else if (varargs)
|
|
|
|
|
fprintf_filtered (stream, "...");
|
2018-04-17 21:51:23 +02:00
|
|
|
|
else if (language == language_cplus)
|
2002-06-14 16:34:26 +02:00
|
|
|
|
fprintf_filtered (stream, "void");
|
1999-07-07 22:19:36 +02:00
|
|
|
|
|
1999-04-16 03:35:26 +02:00
|
|
|
|
fprintf_filtered (stream, ")");
|
dwarf2_physname patchset:
Based on work from Daniel Jacobowitz <dan@codesourcery.com>
* c-typeprint.c (cp_type_print_method_args): For non-static methods,
print out const or volatile qualifiers, too.
(c_type_print_args): Add parameters show_artificial and language.
Skip artificial parameters when requested.
Use the appropriate language printer.
(c_type_print_varspec): Tell c_type_print_args to skip artificial
parameters and pass language_c.
* dwarf2read.c (die_list): New file global.
(struct partial_die_info): Update comments for name field.
(pdi_needs_namespace): Renamed to ...
(die_needs_namespace): ... this. Rewrite.
(dwarf2_linkage_name): Remove.
(add_partial_symbol): Do not predicate the call to
partial_die_full_name based on pdi_needs_namespace.
Remove call to cp_check_possible_namespace_symbols and associated
outdated comments.
(guess_structure_name): Do not inspect child subprogram DIEs.
(dwarf2_fullname): Update comments.
Use die_needs_namespace to assist in computing the name.
(read_func_scope): Use dwarf2_name to get the DIE's name.
Use dwarf2_physname to get the "linkage name" of the DIE.
(dwarf2_add_member_field): Use dwarf2_physname instead of
dwarf2_linkage_name.
(read_structure_type): For structs and classes, set TYPE_NAME, too.
(determine_class): Remove.
(read_partial_die): Ignore DW_AT_MIPS_linkage_name for all languages
except Ada.
(new_symbol): Unconditionally call dwarf2_name.
Compute the "linkage name" using dwarf2_physname.
Use dwarf2_name instead of dwarf2_full_name for enumerator DIEs.
When determining to scan for anonymous C++ namespaces, ignore
the linkage name.
(dwarf2_physname): New function.
(dwarf2_full_name): Move content to new function and call
that.
(dwarf2_compute_name): "New" function.
(_initialize_dwarf2_read): Initialize die_list.
* gnu-v3-eabi.c (gnu_v3_find_method_in): Remove unused variable
physname.
(gnu_v3_print_method_ptr): Use the physname for virtual methods
without a demangled name.
Print out type information for non-virtual methods.
* linespec.c (decode_line_1): Force ANY string using "::" (or
"." for java) to use decode_compound, and clean up any stray quoting.
If we found a file symtab, re-evaluate whether the remainder is_quoted.
(decode_compound): Stop consuming at an open parenthesis.
Keep template parameters.
Keep any overload information.
Keep keywords like "const".
Remove paren_pointer.
Move is_quoted check from set_flags to here.
Remove #if 0 code from 2000. Ten years is long enough.
(find_method): Before comparing symbol names, canonicalize the string
from the user.
If a specific overload is requested, find it. Otherwise throw an error.
(find_method_overload_end): New function.
(set_flags): Remove.
(decode_compound): Assume that parentheses are matched.
It's a lot easier.
* symtab.c (symbol_find_demangled_name): Add DMGL_VERBOSE flag
to cplus_demangle.
* linespec.c (decode_line_1): Keep important keywords like
"const" and "volatile".
* symtab.h (SYMBOL_CPLUS_DEMANGLED_NAME): Remove.
* typeprint.h (c_type_print_args): Add declaration.
* ui-file.c (do_ui_file_obsavestring): New function.
(ui_file_obsavestring): New function.
* ui-file.h (ui_file_obsavestring): Add declaration.
* valops.c (find_overload_match): Resolve the object to
a non-pointer type.
If the object is a data member, search the object for the member
and return with staticp set.
Use SYMBOL_NATURAL_NAME instead of SYMBOL_CPLUS_DEMANGLED_NAME.
Do not attempt to extract a function name from non-function types.
If the extracted function name and the original name are the same,
we don't have a C++ method.
From Jan Kratochvil <jan.kratochvil@redhat.com>:
* dwarf2read.c (new_symbol <DW_TAG_enumerator>): Call dwarf2_full_name.
* ada-lang.c (ada_lookup_symbol): Remove linkage_name parameters
and arguments from symbol lookups.
* ax-gdb.c (gen_expr): Likewise.
* cp-namespace.c (cp_lookup_symbol_nonlocal, lookup_namespace_scope,
cp_lookup_symbol_namespace, lookup_symbol_file, lookup_nested_type,
lookup_possible_namespace_symbol): Likewise.
* cp-support.c (read_in_psymtabs): Likewise.
* cp-support.h (cp_lookup_symbol_nonlocal): Likewise.
* language.h (la_lookup_symbol_nonlocal): Likewise.
* scm-valprint.c (scm_inferior_print): Likewise.
* solib-darwin.c (darwin_relocate_section_addresses): Likewise.
* solib-svr.c (elf_lookup_lib): Likewise.
* solib.c (show_auto_solib_add): Likewise.
* solist.h (lookup_lib_global, solib_global_lookup): Likewise.
* symmisc.c (maintenance_check_symtabs): Likewise.
* symtab.c (lookup_symbol_in_language, lookup_symbol_aux,
lookup_symbol_aux_local, lookup_symbol_aux_block,
lookup_symbol_from_objfile, lookup_symbol_aux_symtabs,
lookup_symbol_aux_psymtabs,basic_lookup_symbol_nonlocal,
lookup_symbol_static, lookup_symbol_global, symbol_matches_domain,
basic_lookup_transparent_type, find_main_psymtab,
lookup_block_symbol): Likewise.
* symtab.h (basic_lookp_symbol_nonlocal, lookup_symbol_static,
lookup_symbol_global, lookup_symbol_aux_block,
lookup_symbol_partial_symbol, lookup_block_symbol,
lookup_global_symbol, value_maybe_namespace_elt): Likewise.
2010-03-09 19:09:08 +01:00
|
|
|
|
|
|
|
|
|
/* For non-static methods, read qualifiers from the type of
|
|
|
|
|
THIS. */
|
|
|
|
|
if (!staticp)
|
|
|
|
|
{
|
|
|
|
|
struct type *domain;
|
|
|
|
|
|
|
|
|
|
gdb_assert (nargs > 0);
|
|
|
|
|
gdb_assert (TYPE_CODE (args[0].type) == TYPE_CODE_PTR);
|
|
|
|
|
domain = TYPE_TARGET_TYPE (args[0].type);
|
|
|
|
|
|
|
|
|
|
if (TYPE_CONST (domain))
|
|
|
|
|
fprintf_filtered (stream, " const");
|
|
|
|
|
|
|
|
|
|
if (TYPE_VOLATILE (domain))
|
|
|
|
|
fprintf_filtered (stream, " volatile");
|
2013-01-14 21:59:27 +01:00
|
|
|
|
|
|
|
|
|
if (TYPE_RESTRICT (domain))
|
|
|
|
|
fprintf_filtered (stream, " restrict");
|
2015-02-09 14:58:25 +01:00
|
|
|
|
|
|
|
|
|
if (TYPE_ATOMIC (domain))
|
|
|
|
|
fprintf_filtered (stream, " _Atomic");
|
dwarf2_physname patchset:
Based on work from Daniel Jacobowitz <dan@codesourcery.com>
* c-typeprint.c (cp_type_print_method_args): For non-static methods,
print out const or volatile qualifiers, too.
(c_type_print_args): Add parameters show_artificial and language.
Skip artificial parameters when requested.
Use the appropriate language printer.
(c_type_print_varspec): Tell c_type_print_args to skip artificial
parameters and pass language_c.
* dwarf2read.c (die_list): New file global.
(struct partial_die_info): Update comments for name field.
(pdi_needs_namespace): Renamed to ...
(die_needs_namespace): ... this. Rewrite.
(dwarf2_linkage_name): Remove.
(add_partial_symbol): Do not predicate the call to
partial_die_full_name based on pdi_needs_namespace.
Remove call to cp_check_possible_namespace_symbols and associated
outdated comments.
(guess_structure_name): Do not inspect child subprogram DIEs.
(dwarf2_fullname): Update comments.
Use die_needs_namespace to assist in computing the name.
(read_func_scope): Use dwarf2_name to get the DIE's name.
Use dwarf2_physname to get the "linkage name" of the DIE.
(dwarf2_add_member_field): Use dwarf2_physname instead of
dwarf2_linkage_name.
(read_structure_type): For structs and classes, set TYPE_NAME, too.
(determine_class): Remove.
(read_partial_die): Ignore DW_AT_MIPS_linkage_name for all languages
except Ada.
(new_symbol): Unconditionally call dwarf2_name.
Compute the "linkage name" using dwarf2_physname.
Use dwarf2_name instead of dwarf2_full_name for enumerator DIEs.
When determining to scan for anonymous C++ namespaces, ignore
the linkage name.
(dwarf2_physname): New function.
(dwarf2_full_name): Move content to new function and call
that.
(dwarf2_compute_name): "New" function.
(_initialize_dwarf2_read): Initialize die_list.
* gnu-v3-eabi.c (gnu_v3_find_method_in): Remove unused variable
physname.
(gnu_v3_print_method_ptr): Use the physname for virtual methods
without a demangled name.
Print out type information for non-virtual methods.
* linespec.c (decode_line_1): Force ANY string using "::" (or
"." for java) to use decode_compound, and clean up any stray quoting.
If we found a file symtab, re-evaluate whether the remainder is_quoted.
(decode_compound): Stop consuming at an open parenthesis.
Keep template parameters.
Keep any overload information.
Keep keywords like "const".
Remove paren_pointer.
Move is_quoted check from set_flags to here.
Remove #if 0 code from 2000. Ten years is long enough.
(find_method): Before comparing symbol names, canonicalize the string
from the user.
If a specific overload is requested, find it. Otherwise throw an error.
(find_method_overload_end): New function.
(set_flags): Remove.
(decode_compound): Assume that parentheses are matched.
It's a lot easier.
* symtab.c (symbol_find_demangled_name): Add DMGL_VERBOSE flag
to cplus_demangle.
* linespec.c (decode_line_1): Keep important keywords like
"const" and "volatile".
* symtab.h (SYMBOL_CPLUS_DEMANGLED_NAME): Remove.
* typeprint.h (c_type_print_args): Add declaration.
* ui-file.c (do_ui_file_obsavestring): New function.
(ui_file_obsavestring): New function.
* ui-file.h (ui_file_obsavestring): Add declaration.
* valops.c (find_overload_match): Resolve the object to
a non-pointer type.
If the object is a data member, search the object for the member
and return with staticp set.
Use SYMBOL_NATURAL_NAME instead of SYMBOL_CPLUS_DEMANGLED_NAME.
Do not attempt to extract a function name from non-function types.
If the extracted function name and the original name are the same,
we don't have a C++ method.
From Jan Kratochvil <jan.kratochvil@redhat.com>:
* dwarf2read.c (new_symbol <DW_TAG_enumerator>): Call dwarf2_full_name.
* ada-lang.c (ada_lookup_symbol): Remove linkage_name parameters
and arguments from symbol lookups.
* ax-gdb.c (gen_expr): Likewise.
* cp-namespace.c (cp_lookup_symbol_nonlocal, lookup_namespace_scope,
cp_lookup_symbol_namespace, lookup_symbol_file, lookup_nested_type,
lookup_possible_namespace_symbol): Likewise.
* cp-support.c (read_in_psymtabs): Likewise.
* cp-support.h (cp_lookup_symbol_nonlocal): Likewise.
* language.h (la_lookup_symbol_nonlocal): Likewise.
* scm-valprint.c (scm_inferior_print): Likewise.
* solib-darwin.c (darwin_relocate_section_addresses): Likewise.
* solib-svr.c (elf_lookup_lib): Likewise.
* solib.c (show_auto_solib_add): Likewise.
* solist.h (lookup_lib_global, solib_global_lookup): Likewise.
* symmisc.c (maintenance_check_symtabs): Likewise.
* symtab.c (lookup_symbol_in_language, lookup_symbol_aux,
lookup_symbol_aux_local, lookup_symbol_aux_block,
lookup_symbol_from_objfile, lookup_symbol_aux_symtabs,
lookup_symbol_aux_psymtabs,basic_lookup_symbol_nonlocal,
lookup_symbol_static, lookup_symbol_global, symbol_matches_domain,
basic_lookup_transparent_type, find_main_psymtab,
lookup_block_symbol): Likewise.
* symtab.h (basic_lookp_symbol_nonlocal, lookup_symbol_static,
lookup_symbol_global, lookup_symbol_aux_block,
lookup_symbol_partial_symbol, lookup_block_symbol,
lookup_global_symbol, value_maybe_namespace_elt): Likewise.
2010-03-09 19:09:08 +01:00
|
|
|
|
}
|
1999-04-16 03:35:26 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Print any asterisks or open-parentheses needed before the
|
|
|
|
|
variable name (to describe its type).
|
|
|
|
|
|
|
|
|
|
On outermost call, pass 0 for PASSED_A_PTR.
|
|
|
|
|
On outermost call, SHOW > 0 means should ignore
|
|
|
|
|
any typename for TYPE and show its details.
|
2002-10-15 00:58:28 +02:00
|
|
|
|
SHOW is always zero on recursive calls.
|
|
|
|
|
|
|
|
|
|
NEED_POST_SPACE is non-zero when a space will be be needed
|
|
|
|
|
between a trailing qualifier and a field, variable, or function
|
|
|
|
|
name. */
|
1999-04-16 03:35:26 +02:00
|
|
|
|
|
2010-10-13 17:10:10 +02:00
|
|
|
|
static void
|
2010-12-31 23:59:52 +01:00
|
|
|
|
c_type_print_varspec_prefix (struct type *type,
|
|
|
|
|
struct ui_file *stream,
|
|
|
|
|
int show, int passed_a_ptr,
|
* ada-lang.c (user_select_syms, ada_print_subexp): Pass flags
to type-printing functions.
* ada-lang.h (ada_print_type): Add argument.
* ada-typeprint.c (print_array_type, print_variant_clauses,
print_variant_part, print_selected_record_field_types,
print_record_field_types, print_unchecked_union_type,
print_func_type, ada_print_type): Add flags argument.
(ada_print_typedef): Update.
* c-exp.y (OPERATOR conversion_type_id): Update.
* c-lang.h (c_print_type, c_type_print_base): Update.
* c-typeprint.c (c_print_type, c_type_print_varspec_prefix,
c_type_print_modifier, c_type_print_args,
c_type_print_varspec_suffix, c_type_print_base): Add flags
argument.
* cp-valprint.c (cp_print_class_member): Update.
* dwarf2read.c (dwarf2_compute_name): Update.
* f-lang.h (f_print_type): Add argument.
* f-typeprint.c (f_print_type): Add flags argument.
* gnu-v3-abi.c (gnuv3_print_method_ptr): Update.
* go-lang.h (go_print_type): Add argument.
* go-typeprint.c (go_print_type): Add flags argument.
* jv-lang.h (java_print_type): Add argument.
* jv-typeprint.c (java_type_print_base, java_print_type): Add
flags argument.
* language.c (unk_lang_print_type): Add flags argument.
* language.h (struct language_defn) <la_print_type>: Add flags
argument.
(LA_PRINT_TYPE): Likewise.
* m2-lang.h (m2_print_type): Add argument.
* m2-typeprint.c (m2_print_type, m2_range, m2_typedef,
m2_array, m2_pointer, m2_ref, m2_procedure, m2_long_set,
m2_unbounded_array, m2_record_fields): Add flags argument.
* p-lang.h (pascal_print_type, pascal_type_print_base,
pascal_type_print_varspec_prefix): Add argument.
* p-typeprint.c (pascal_print_type,
pascal_type_print_varspec_prefix, pascal_print_func_args,
pascal_type_print_varspec_suffix, pascal_type_print_base): Add
flags argument.
* symmisc.c (print_symbol): Update.
* typeprint.c (type_print_raw_options, default_ptype_flags):
New globals.
(type_print): Update.
* typeprint.h (struct type_print_options): New.
(type_print_raw_options): Declare.
(c_type_print_varspec_suffix, c_type_print_args): Add argument.
2012-11-12 18:14:55 +01:00
|
|
|
|
int need_post_space,
|
2018-04-17 21:51:23 +02:00
|
|
|
|
enum language language,
|
Implement pahole-like 'ptype /o' option
This commit implements the pahole-like '/o' option for 'ptype', which
prints the offsets and sizes of struct fields, reporting whenever
there is a hole found.
The output is heavily based on pahole(1), with a few modifications
here and there to adjust it to our reality. Here's an example:
/* offset | size */ type = struct wer : public tuv {
public:
/* 32 | 24 */ struct tyu {
/* 32:31 | 4 */ int a1 : 1;
/* 32:28 | 4 */ int a2 : 3;
/* 32: 5 | 4 */ int a3 : 23;
/* 35: 3 | 1 */ char a4 : 2;
/* XXX 3-bit hole */
/* XXX 4-byte hole */
/* 40 | 8 */ int64_t a5;
/* 48:27 | 4 */ int a6 : 5;
/* 48:56 | 8 */ int64_t a7 : 3;
/* total size (bytes): 24 */
} a1;
/* total size (bytes): 56 */
}
A big part of this patch handles the formatting logic of 'ptype',
which is a bit messy. The code to handle bitfield offsets, however,
took some time to craft. My thanks to Pedro Alves for figuring things
out and pointing me to the right direction, as well as coming up with
a way to inspect the layout of structs with bitfields (see testcase
for comments).
After many discussions both on IRC and at the mailing list, I tried to
implement printing vtables and inherited classes. Unfortunately the
code grew too complex and there were still a few corner cases failing
so I had to drop the attempt. This should be implemented in a future
patch.
This patch is the start of a long-term work I'll do to flush the local
patches we carry for Fedora GDB. In this specific case, I'm aiming at
upstreaming the feature implemented by the 'pahole.py' script that is
shipped with Fedora GDB:
<https://src.fedoraproject.org/rpms/gdb/blob/master/f/gdb-archer.patch#_311>
This has been regression-tested on the BuildBot. There's a new
testcase for it, along with an update to the documentation. I also
thought it was worth mentioning this feature in the NEWS file.
gdb/ChangeLog:
2017-12-15 Sergio Durigan Junior <sergiodj@redhat.com>
Pedro Alves <palves@redhat.com>
PR cli/16224
* NEWS (Changes since GDB 8.0): Mention new '/o' flag.
* c-typeprint.c (OFFSET_SPC_LEN): New define.
(c_type_print_varspec_prefix): New argument 'struct
print_offset_data *'.
(c_type_print_base_1): New function and prototype.
(c_print_type_1): New function, with code from 'c_print_type'.
(c_print_type): Use 'c_print_type_1'.
(c_type_print_varspec_prefix): New argument 'struct
print_offset_data *'. Use it. Call 'c_type_print_base_1'
instead of 'c_print_type_base'.
(print_spaces_filtered_with_print_options): New function.
(output_access_specifier): Take new argument FLAGS. Modify
function to call 'print_spaces_filtered_with_print_options'.
(c_print_type_vtable_offset_marker): New function.
(c_print_type_union_field_offset): New function.
(c_print_type_struct_field_offset): New function.
(c_print_type_no_offsets): New function.
(c_type_print_base_struct_union): New argument 'struct
print_offset_data *'. Print offsets and sizes for
struct/union/class fields.
* typeprint.c (const struct type_print_options
type_print_raw_options): Initialize 'print_offsets'.
(static struct type_print_options default_ptype_flags):
Likewise.
(struct print_offset_data print_offset_default_data): New
variable.
(whatis_exp): Handle '/o' option.
(_initialize_typeprint): Add '/o' flag to ptype's help.
* typeprint.h (struct print_offset_data): New struct.
(struct type_print_options) <print_offsets>: New field.
gdb/testsuite/ChangeLog:
2017-12-15 Sergio Durigan Junior <sergiodj@redhat.com>
PR cli/16224
* gdb.base/ptype-offsets.cc: New file.
* gdb.base/ptype-offsets.exp: New file.
gdb/doc/ChangeLog:
2017-12-15 Sergio Durigan Junior <sergiodj@redhat.com>
PR cli/16224
* gdb.texinfo (ptype): Add documentation for new flag '/o'.
2017-11-20 22:34:59 +01:00
|
|
|
|
const struct type_print_options *flags,
|
|
|
|
|
struct print_offset_data *podata)
|
1999-04-16 03:35:26 +02:00
|
|
|
|
{
|
* gdbtypes.h (struct main_type): Change type of name,tag_name,
and fields.name members from char * to const char *. All uses updated.
(struct cplus_struct_type): Change type of fn_fieldlists.name member
from char * to const char *. All uses updated.
(type_name_no_tag): Update.
(lookup_unsigned_typename, lookup_signed_typename): Update.
* gdbtypes.c (type_name_no_tag): Change result type
from char * to const char *. All callers updated.
(lookup_unsigned_typename, lookup_signed_typename): Change type of
name parameter from char * to const char *.
* symtab.h (struct cplus_specific): Change type of demangled_name
member from char * to const char *. All uses updated.
(struct general_symbol_info): Change type of name and
mangled_lang.demangled_name members from char * to const char *.
All uses updated.
(symbol_get_demangled_name, symbol_natural_name): Update.
(symbol_demangled_name, symbol_search_name): Update.
* symtab.c (symbol_get_demangled_name): Change result type
from char * to const char *. All callers updated.
(symbol_natural_name, symbol_demangled_name): Ditto.
(symbol_search_name): Ditto.
(completion_list_add_name): Change type of symname,sym_text,
text,word parameters from char * to const char *.
(completion_list_objc_symbol): Change type of sym_text,
text,word parameters from char * to const char *.
* ada-lang.c (find_struct_field): Change type of name parameter
from char * to const char *.
(encoded_ordered_before): Similarly for N0,N1 parameters.
(old_renaming_is_invisible): Similarly for function_name parameter.
(ada_type_name): Change result type from char * to const char *.
All callers updated.
* ada-lang.h (ada_type_name): Update.
* buildsym.c (hashname): Change type of name parameter
from char * to const char *.
* buildsym.h (hashname): Update.
* dbxread.c (end_psymtab): Change type of include_list parameter
from char ** to const char **.
* dwarf2read.c (determine_prefix): Change result type
from char * to const char *. All callers updated.
* f-lang.c (find_common_for_function): Change type of name, funcname
parameters from char * to const char *.
* f-lang.c (find_common_for_function): Update.
* f-valprint.c (list_all_visible_commons): Change type of funcname
parameters from char * to const char *.
* gdbarch.sh (static_transform_name): Change type of name parameter
and result from char * to const char *.
* gdbarch.c: Regenerate.
* gdbarch.h: Regenerate.
* i386-sol2-tdep.c (i386_sol2_static_transform_name): Change type
of name parameter from char * to const char *.
* jv-lang.c (java_primitive_type_from_name): Ditto.
(java_demangled_signature_length): Similarly for signature parameter.
(java_demangled_signature_copy): Ditto.
(java_demangle_type_signature): Ditto.
* jv-lang.h (java_primitive_type_from_name): Update.
(java_demangle_type_signature): Update.
* objc-lang.c (specialcmp): Change type of a,b parameters
from char * to const char *.
* p-lang.c (is_pascal_string_type): Change type of arrayname parameter
from char * to const char *. All callers updated.
* p-lang.h (is_pascal_string_type): Update.
* solib-frv.c (find_canonical_descriptor_in_load_object): Change type
of name parameter from char * to const char *.
* sparc-sol2-tdep.c (sparc_sol2_static_transform_name): Ditto.
* utils.c (fprintf_symbol_filtered): Ditto.
* defs.h (fprintf_symbol_filtered): Update.
* sparc-tdep.h (sparc_sol2_static_transform_name): Update.
* stabsread.h (end_psymtab): Update.
* stack.c (find_frame_funname): Change type of funname parameter
from char ** to const char **.
* stack.h (find_frame_funname): Update.
* typeprint.c (type_print): Change type of varstring parameter
from char * to const char *.
* value.h (type_print): Update.
* xcoffread.c (xcoff_start_psymtab): Change type of filename parameter
from char * to const char *. All callers updated.
(xcoff_end_psymtab): Change type of include_list parameter
from char ** to const char **. All callers updated.
(swap_sym): Similarly for name parameter. All callers updated.
* coffread.c (patch_type): Add (char*) cast to xfree parameter.
Use xstrdup.
(process_coff_symbol): Use xstrdup.
* stabsread.c (stabs_method_name_from_physname): Renamed from
update_method_name_from_physname. Change result type from void
to char *. All callers updated.
(read_member_functions): In has_destructor case, store name in objfile
obstack instead of malloc space. In !has_stub case, fix mem leak.
2012-02-07 05:48:23 +01:00
|
|
|
|
const char *name;
|
2010-05-14 01:53:32 +02:00
|
|
|
|
|
1999-04-16 03:35:26 +02:00
|
|
|
|
if (type == 0)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
if (TYPE_NAME (type) && show <= 0)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
QUIT;
|
|
|
|
|
|
|
|
|
|
switch (TYPE_CODE (type))
|
|
|
|
|
{
|
|
|
|
|
case TYPE_CODE_PTR:
|
2010-12-31 23:59:52 +01:00
|
|
|
|
c_type_print_varspec_prefix (TYPE_TARGET_TYPE (type),
|
2018-04-17 21:51:23 +02:00
|
|
|
|
stream, show, 1, 1, language, flags,
|
|
|
|
|
podata);
|
1999-04-16 03:35:26 +02:00
|
|
|
|
fprintf_filtered (stream, "*");
|
2002-10-15 00:58:28 +02:00
|
|
|
|
c_type_print_modifier (type, stream, 1, need_post_space);
|
1999-04-16 03:35:26 +02:00
|
|
|
|
break;
|
|
|
|
|
|
* NEWS: Mention pointer to member improvements.
* Makefile.in (gnu-v3-abi.o): Delete special rule.
(eval.o, gnu-v3-abi.o, ia64-tdep.o): Update.
* ada-valprint.c (ada_print_scalar): Update for new type codes.
* c-typeprint.c (c_print_type): Update for new type codes.
(c_type_print_varspec_prefix, c_type_print_varspec_suffix)
(c_type_print_base): Likewise.
(c_type_print_args): Rewrite.
* c-valprint.c (c_val_print): Update for new type codes. Remove
support for references to members. Treat methods like functions.
* cp-abi.c (cplus_print_method_ptr, cplus_method_ptr_size)
(cplus_make_method_ptr, cplus_method_ptr_to_value): New.
* cp-abi.h (cplus_print_method_ptr, cplus_method_ptr_size)
(cplus_make_method_ptr, cplus_method_ptr_to_value): New prototypes.
(struct cp_abi_ops): Add corresponding members.
* cp-valprint.c (cp_print_class_method): Delete.
(cp_find_class_member): New function.
(cp_print_class_member): Use it. Simplify support for bogus
member pointers.
* dwarf2read.c (quirk_gcc_member_function_pointer): Use
lookup_methodptr_type.
(read_tag_ptr_to_member_type): Likewise, and lookup_memberptr_type.
* eval.c (evaluate_subexp_standard): Implement EVAL_SKIP for
OP_SCOPE. Update call to value_aggregate_elt. Rewrite member
pointer support.
(evaluate_subexp_for_address): Handle OP_SCOPE explicitly. Handle
references returned by user defined operators.
* f-typeprint.c (f_print_type, f_type_print_varspec_prefix)
(f_type_print_varspec_suffix): Remove support for member pointers.
* gdbtypes.c (lookup_memberptr_type): Renamed from lookup_member_type
and adjusted.
(smash_to_memberptr_type): Likewise, from smash_to_member_type.
(lookup_methodptr_type): New.
(rank_one_type): Adjust for TYPE_CODE_MEMBERPTR.
(recursive_dump_type): Update for new types.
* gdbtypes.h (enum type_code): Replace TYPE_CODE_MEMBER with
TYPE_CODE_MEMBERPTR and TYPE_CODE_METHODPTR.
(lookup_memberptr_type, lookup_methodptr_type)
(smash_to_memberptr_type): New prototypes.
(smash_to_method_type): Formatting fix.
(lookup_member_type, smash_to_member_type): Delete prototypes.
* gnu-v3-abi.c (gnuv3_get_vtable, gnuv3_get_virtual_fn): New.
Do not rely on debug information for the vptr or the method's
enclosing type. Handle function descriptors for IA64.
(gnuv3_virtual_fn_field): Rewrite using the new functions.
(gnuv3_find_method_in, gnuv3_print_method_ptr)
(gnuv3_method_ptr_size, gnuv3_make_method_ptr)
(gnuv3_method_ptr_to_value): New.
(init_gnuv3_ops): Set new members of gnu_v3_abi_ops.
* hpread.c (hpread_type_lookup): Update for new types.
* infcall.c (value_arg_coerce): Likewise.
* m2-typeprint.c (m2_print_type): Remove explicit support
for member pointers.
* m2-valprint.c (m2_val_print): Likewise.
* p-typeprint.c (pascal_type_print_varspec_prefix)
(pascal_type_print_varspec_suffix, pascal_type_print_base): Likewise.
* p-valprint.c (pascal_val_print): Likewise.
(pascal_object_print_class_method, pascal_object_print_class_member):
Delete.
* p-lang.h (pascal_object_print_class_method)
(pascal_object_print_class_member): Delete prototypes.
* stabsread.c (read_type): Update for new types.
* typeprint.c (print_type_scalar): Likewise.
* valops.c (value_struct_elt_for_reference, value_namespace_elt)
(value_maybe_namespace_elt, value_aggregate_elt): Add want_address
argument. Construct a pointer to member if the address of a
function or data member is requested.
(value_cast_pointers): Don't modify the input value.
(value_cast): Adjust pointer to member handling for new types.
Allow null pointer to member constants. Don't modify the input
value.
(value_ind): Remove pointer to member check. Handle function
descriptors for function pointers.
(value_struct_elt, value_find_oload_method_list, check_field):
Remove pointer to member checks.
* value.c (unpack_long): Allow pointers to data members.
(value_from_longest): Allow member pointers.
* value.h (value_aggregate_elt): Add want_address.
* varobj.c (c_variable_editable): Remove check for members.
* gdbarch.sh: Add vtable_function_descriptors and vbit_in_delta.
* ia64-tdep.c (ia64_convert_from_func_ptr_addr): Handle descriptors
in virtual tables.
(ia64_gdbarch_init): Call set_gdbarch_vtable_function_descriptors.
* c-lang.h (cp_print_class_method): Delete prototype.
* arm-tdep.c (arm_gdbarch_init): Call set_gdbarch_vbit_in_delta.
* mips-tdep.c (mips_gdbarch_init): Likewise.
* gdbarch.c, gdbarch.h: Regenerated.
* gdb.cp/classes.exp (test_pointers_to_class_members): Update expected
output. Test the types of members and member pointers.
* gdb.cp/inherit.exp (test_print_mi_member_types): Remove KFAILs for
gdb/2092.
* gdb.cp/member-ptr.exp: Search for a comment instead of a
statement. Enable for GCC. Update expected output for some tests
and add new tests. Remove obsolete GCC KFAILs. Allow GCC's class
layout.
* gdb.cp/member-ptr.cc (Padding, Padding::vspacer, Base, Base::get_x)
(Base::vget_base, Left, Left::vget, Right, Right::vget, Diamond)
(Diamond::vget_base): New.
(main): Add new tests.
* gdb.cp/printmethod.exp: Update expected output for member functions.
* gdb.cp/virtfunc.exp (test_virtual_calls): Add a KFAIL for
print pEe->D::vg().
2007-01-03 19:05:45 +01:00
|
|
|
|
case TYPE_CODE_MEMBERPTR:
|
2010-12-31 23:59:52 +01:00
|
|
|
|
c_type_print_varspec_prefix (TYPE_TARGET_TYPE (type),
|
Remove type_name_no_tag and rename type_name_no_tag_or_error
type_name_no_tag is just a plain wrapper for TYPE_NAME now, so this
patch removes it. And, because tag names no longer exist, this
renames type_name_no_tag_or_error to type_name_or_error.
gdb/ChangeLog
2018-06-01 Tom Tromey <tom@tromey.com>
* valops.c (value_cast_structs, destructor_name_p): Update.
* symtab.c (gdb_mangle_name): Update.
* stabsread.c (define_symbol, read_cpp_abbrev, read_baseclasses):
Update.
* p-valprint.c (pascal_object_is_vtbl_ptr_type)
(pascal_object_print_value_fields, pascal_object_print_value):
Update.
* p-typeprint.c (pascal_type_print_derivation_info): Update.
* linespec.c (find_methods): Update.
* gdbtypes.h (type_name_no_tag): Remove.
(type_name_or_error): Rename from type_name_no_tag_or_error.
* gdbtypes.c (type_name_no_tag): Remove.
(type_name_or_error): Rename from type_name_no_tag_or_error.
(lookup_struct_elt_type, check_typedef): Update.
* expprint.c (print_subexp_standard): Update.
* dwarf2read.c (dwarf2_add_field, load_partial_dies): Update.
* d-namespace.c (d_lookup_nested_symbol): Update.
* cp-valprint.c (cp_is_vtbl_ptr_type, cp_print_value_fields)
(cp_print_class_member): Update.
* cp-namespace.c (cp_lookup_nested_symbol): Update.
* completer.c (add_struct_fields): Update.
* c-typeprint.c (cp_type_print_derivation_info)
(c_type_print_varspec_prefix, c_type_print_base_struct_union):
Update.
* ada-lang.c (parse_old_style_renaming, xget_renaming_scope)
(ada_prefer_type, ada_is_exception_sym): Update.
2018-04-17 21:51:25 +02:00
|
|
|
|
stream, show, 0, 0, language, flags, podata);
|
|
|
|
|
name = TYPE_NAME (TYPE_SELF_TYPE (type));
|
1999-04-16 03:35:26 +02:00
|
|
|
|
if (name)
|
* c-typeprint.c (find_typedef_for_canonicalize,
print_name_maybe_canonical): New functions.
(c_print_type): Look up type name.
(cp_type_print_derivation_info): Add flags argument. Use
print_name_maybe_canonical.
(cp_type_print_method_args): Add wrapping.
(c_type_print_varspec_prefix): Use print_name_maybe_canonical.
(c_type_print_template_args): New function.
(c_type_print_base): Change wrapping. Use
print_name_maybe_canonical.
<TYPE_CODE_STRUCT>: Possibly create a typedef hash, and do
type name lookups.
* gdbtypes.c (types_equal): No longer static.
* gdbtypes.h (types_equal): Declare.
* typeprint.c (type_print_raw_options, default_ptype_flags):
Update.
(struct typedef_hash_table): New.
(hash_typedef_field, eq_typedef_field,
recursively_update_typedef_hash, add_template_parameters,
create_typedef_hash, free_typedef_hash, do_free_typedef_hash,
make_cleanup_free_typedef_hash, copy_typedef_hash_element,
copy_typedef_hash, find_typedef_in_hash): New functions.
* typeprint.h (struct type_print_options) <local_typedefs>:
New field.
(recursively_update_typedef_hash, add_template_parameters,
create_typedef_hash, free_typedef_hash,
make_cleanup_free_typedef_hash, copy_typedef_hash,
find_typedef_in_hash): Declare.
testsuite
* gdb.base/call-sc.exp: Use "ptype/r".
* gdb.base/volatile.exp: Don't expect "int".
* gdb.cp/ptype-flags.cc: New file.
* gdb.cp/ptype-flags.exp: New file.
* gdb.cp/templates.exp: Use ptype/r.
(test_ptype_of_templates, test_template_typedef): Likewise.
* lib/cp-support.exp (cp_test_ptype_class): Add in_ptype_arg
argument. Handle template names and template parameters.
* gdb.mi/mi-var-cmd.exp: Accept "long".
* gdb.mi/mi-var-child.exp: Accept "long".
* gdb.mi/mi-var-display.exp: Accept "long".
* gdb.mi/mi2-var-child.exp: Accept "long".
2012-11-12 18:37:38 +01:00
|
|
|
|
print_name_maybe_canonical (name, flags, stream);
|
1999-04-16 03:35:26 +02:00
|
|
|
|
else
|
Implement pahole-like 'ptype /o' option
This commit implements the pahole-like '/o' option for 'ptype', which
prints the offsets and sizes of struct fields, reporting whenever
there is a hole found.
The output is heavily based on pahole(1), with a few modifications
here and there to adjust it to our reality. Here's an example:
/* offset | size */ type = struct wer : public tuv {
public:
/* 32 | 24 */ struct tyu {
/* 32:31 | 4 */ int a1 : 1;
/* 32:28 | 4 */ int a2 : 3;
/* 32: 5 | 4 */ int a3 : 23;
/* 35: 3 | 1 */ char a4 : 2;
/* XXX 3-bit hole */
/* XXX 4-byte hole */
/* 40 | 8 */ int64_t a5;
/* 48:27 | 4 */ int a6 : 5;
/* 48:56 | 8 */ int64_t a7 : 3;
/* total size (bytes): 24 */
} a1;
/* total size (bytes): 56 */
}
A big part of this patch handles the formatting logic of 'ptype',
which is a bit messy. The code to handle bitfield offsets, however,
took some time to craft. My thanks to Pedro Alves for figuring things
out and pointing me to the right direction, as well as coming up with
a way to inspect the layout of structs with bitfields (see testcase
for comments).
After many discussions both on IRC and at the mailing list, I tried to
implement printing vtables and inherited classes. Unfortunately the
code grew too complex and there were still a few corner cases failing
so I had to drop the attempt. This should be implemented in a future
patch.
This patch is the start of a long-term work I'll do to flush the local
patches we carry for Fedora GDB. In this specific case, I'm aiming at
upstreaming the feature implemented by the 'pahole.py' script that is
shipped with Fedora GDB:
<https://src.fedoraproject.org/rpms/gdb/blob/master/f/gdb-archer.patch#_311>
This has been regression-tested on the BuildBot. There's a new
testcase for it, along with an update to the documentation. I also
thought it was worth mentioning this feature in the NEWS file.
gdb/ChangeLog:
2017-12-15 Sergio Durigan Junior <sergiodj@redhat.com>
Pedro Alves <palves@redhat.com>
PR cli/16224
* NEWS (Changes since GDB 8.0): Mention new '/o' flag.
* c-typeprint.c (OFFSET_SPC_LEN): New define.
(c_type_print_varspec_prefix): New argument 'struct
print_offset_data *'.
(c_type_print_base_1): New function and prototype.
(c_print_type_1): New function, with code from 'c_print_type'.
(c_print_type): Use 'c_print_type_1'.
(c_type_print_varspec_prefix): New argument 'struct
print_offset_data *'. Use it. Call 'c_type_print_base_1'
instead of 'c_print_type_base'.
(print_spaces_filtered_with_print_options): New function.
(output_access_specifier): Take new argument FLAGS. Modify
function to call 'print_spaces_filtered_with_print_options'.
(c_print_type_vtable_offset_marker): New function.
(c_print_type_union_field_offset): New function.
(c_print_type_struct_field_offset): New function.
(c_print_type_no_offsets): New function.
(c_type_print_base_struct_union): New argument 'struct
print_offset_data *'. Print offsets and sizes for
struct/union/class fields.
* typeprint.c (const struct type_print_options
type_print_raw_options): Initialize 'print_offsets'.
(static struct type_print_options default_ptype_flags):
Likewise.
(struct print_offset_data print_offset_default_data): New
variable.
(whatis_exp): Handle '/o' option.
(_initialize_typeprint): Add '/o' flag to ptype's help.
* typeprint.h (struct print_offset_data): New struct.
(struct type_print_options) <print_offsets>: New field.
gdb/testsuite/ChangeLog:
2017-12-15 Sergio Durigan Junior <sergiodj@redhat.com>
PR cli/16224
* gdb.base/ptype-offsets.cc: New file.
* gdb.base/ptype-offsets.exp: New file.
gdb/doc/ChangeLog:
2017-12-15 Sergio Durigan Junior <sergiodj@redhat.com>
PR cli/16224
* gdb.texinfo (ptype): Add documentation for new flag '/o'.
2017-11-20 22:34:59 +01:00
|
|
|
|
c_type_print_base_1 (TYPE_SELF_TYPE (type),
|
2018-04-17 21:51:23 +02:00
|
|
|
|
stream, -1, passed_a_ptr, language, flags,
|
|
|
|
|
podata);
|
* NEWS: Mention pointer to member improvements.
* Makefile.in (gnu-v3-abi.o): Delete special rule.
(eval.o, gnu-v3-abi.o, ia64-tdep.o): Update.
* ada-valprint.c (ada_print_scalar): Update for new type codes.
* c-typeprint.c (c_print_type): Update for new type codes.
(c_type_print_varspec_prefix, c_type_print_varspec_suffix)
(c_type_print_base): Likewise.
(c_type_print_args): Rewrite.
* c-valprint.c (c_val_print): Update for new type codes. Remove
support for references to members. Treat methods like functions.
* cp-abi.c (cplus_print_method_ptr, cplus_method_ptr_size)
(cplus_make_method_ptr, cplus_method_ptr_to_value): New.
* cp-abi.h (cplus_print_method_ptr, cplus_method_ptr_size)
(cplus_make_method_ptr, cplus_method_ptr_to_value): New prototypes.
(struct cp_abi_ops): Add corresponding members.
* cp-valprint.c (cp_print_class_method): Delete.
(cp_find_class_member): New function.
(cp_print_class_member): Use it. Simplify support for bogus
member pointers.
* dwarf2read.c (quirk_gcc_member_function_pointer): Use
lookup_methodptr_type.
(read_tag_ptr_to_member_type): Likewise, and lookup_memberptr_type.
* eval.c (evaluate_subexp_standard): Implement EVAL_SKIP for
OP_SCOPE. Update call to value_aggregate_elt. Rewrite member
pointer support.
(evaluate_subexp_for_address): Handle OP_SCOPE explicitly. Handle
references returned by user defined operators.
* f-typeprint.c (f_print_type, f_type_print_varspec_prefix)
(f_type_print_varspec_suffix): Remove support for member pointers.
* gdbtypes.c (lookup_memberptr_type): Renamed from lookup_member_type
and adjusted.
(smash_to_memberptr_type): Likewise, from smash_to_member_type.
(lookup_methodptr_type): New.
(rank_one_type): Adjust for TYPE_CODE_MEMBERPTR.
(recursive_dump_type): Update for new types.
* gdbtypes.h (enum type_code): Replace TYPE_CODE_MEMBER with
TYPE_CODE_MEMBERPTR and TYPE_CODE_METHODPTR.
(lookup_memberptr_type, lookup_methodptr_type)
(smash_to_memberptr_type): New prototypes.
(smash_to_method_type): Formatting fix.
(lookup_member_type, smash_to_member_type): Delete prototypes.
* gnu-v3-abi.c (gnuv3_get_vtable, gnuv3_get_virtual_fn): New.
Do not rely on debug information for the vptr or the method's
enclosing type. Handle function descriptors for IA64.
(gnuv3_virtual_fn_field): Rewrite using the new functions.
(gnuv3_find_method_in, gnuv3_print_method_ptr)
(gnuv3_method_ptr_size, gnuv3_make_method_ptr)
(gnuv3_method_ptr_to_value): New.
(init_gnuv3_ops): Set new members of gnu_v3_abi_ops.
* hpread.c (hpread_type_lookup): Update for new types.
* infcall.c (value_arg_coerce): Likewise.
* m2-typeprint.c (m2_print_type): Remove explicit support
for member pointers.
* m2-valprint.c (m2_val_print): Likewise.
* p-typeprint.c (pascal_type_print_varspec_prefix)
(pascal_type_print_varspec_suffix, pascal_type_print_base): Likewise.
* p-valprint.c (pascal_val_print): Likewise.
(pascal_object_print_class_method, pascal_object_print_class_member):
Delete.
* p-lang.h (pascal_object_print_class_method)
(pascal_object_print_class_member): Delete prototypes.
* stabsread.c (read_type): Update for new types.
* typeprint.c (print_type_scalar): Likewise.
* valops.c (value_struct_elt_for_reference, value_namespace_elt)
(value_maybe_namespace_elt, value_aggregate_elt): Add want_address
argument. Construct a pointer to member if the address of a
function or data member is requested.
(value_cast_pointers): Don't modify the input value.
(value_cast): Adjust pointer to member handling for new types.
Allow null pointer to member constants. Don't modify the input
value.
(value_ind): Remove pointer to member check. Handle function
descriptors for function pointers.
(value_struct_elt, value_find_oload_method_list, check_field):
Remove pointer to member checks.
* value.c (unpack_long): Allow pointers to data members.
(value_from_longest): Allow member pointers.
* value.h (value_aggregate_elt): Add want_address.
* varobj.c (c_variable_editable): Remove check for members.
* gdbarch.sh: Add vtable_function_descriptors and vbit_in_delta.
* ia64-tdep.c (ia64_convert_from_func_ptr_addr): Handle descriptors
in virtual tables.
(ia64_gdbarch_init): Call set_gdbarch_vtable_function_descriptors.
* c-lang.h (cp_print_class_method): Delete prototype.
* arm-tdep.c (arm_gdbarch_init): Call set_gdbarch_vbit_in_delta.
* mips-tdep.c (mips_gdbarch_init): Likewise.
* gdbarch.c, gdbarch.h: Regenerated.
* gdb.cp/classes.exp (test_pointers_to_class_members): Update expected
output. Test the types of members and member pointers.
* gdb.cp/inherit.exp (test_print_mi_member_types): Remove KFAILs for
gdb/2092.
* gdb.cp/member-ptr.exp: Search for a comment instead of a
statement. Enable for GCC. Update expected output for some tests
and add new tests. Remove obsolete GCC KFAILs. Allow GCC's class
layout.
* gdb.cp/member-ptr.cc (Padding, Padding::vspacer, Base, Base::get_x)
(Base::vget_base, Left, Left::vget, Right, Right::vget, Diamond)
(Diamond::vget_base): New.
(main): Add new tests.
* gdb.cp/printmethod.exp: Update expected output for member functions.
* gdb.cp/virtfunc.exp (test_virtual_calls): Add a KFAIL for
print pEe->D::vg().
2007-01-03 19:05:45 +01:00
|
|
|
|
fprintf_filtered (stream, "::*");
|
1999-04-16 03:35:26 +02:00
|
|
|
|
break;
|
|
|
|
|
|
* NEWS: Mention pointer to member improvements.
* Makefile.in (gnu-v3-abi.o): Delete special rule.
(eval.o, gnu-v3-abi.o, ia64-tdep.o): Update.
* ada-valprint.c (ada_print_scalar): Update for new type codes.
* c-typeprint.c (c_print_type): Update for new type codes.
(c_type_print_varspec_prefix, c_type_print_varspec_suffix)
(c_type_print_base): Likewise.
(c_type_print_args): Rewrite.
* c-valprint.c (c_val_print): Update for new type codes. Remove
support for references to members. Treat methods like functions.
* cp-abi.c (cplus_print_method_ptr, cplus_method_ptr_size)
(cplus_make_method_ptr, cplus_method_ptr_to_value): New.
* cp-abi.h (cplus_print_method_ptr, cplus_method_ptr_size)
(cplus_make_method_ptr, cplus_method_ptr_to_value): New prototypes.
(struct cp_abi_ops): Add corresponding members.
* cp-valprint.c (cp_print_class_method): Delete.
(cp_find_class_member): New function.
(cp_print_class_member): Use it. Simplify support for bogus
member pointers.
* dwarf2read.c (quirk_gcc_member_function_pointer): Use
lookup_methodptr_type.
(read_tag_ptr_to_member_type): Likewise, and lookup_memberptr_type.
* eval.c (evaluate_subexp_standard): Implement EVAL_SKIP for
OP_SCOPE. Update call to value_aggregate_elt. Rewrite member
pointer support.
(evaluate_subexp_for_address): Handle OP_SCOPE explicitly. Handle
references returned by user defined operators.
* f-typeprint.c (f_print_type, f_type_print_varspec_prefix)
(f_type_print_varspec_suffix): Remove support for member pointers.
* gdbtypes.c (lookup_memberptr_type): Renamed from lookup_member_type
and adjusted.
(smash_to_memberptr_type): Likewise, from smash_to_member_type.
(lookup_methodptr_type): New.
(rank_one_type): Adjust for TYPE_CODE_MEMBERPTR.
(recursive_dump_type): Update for new types.
* gdbtypes.h (enum type_code): Replace TYPE_CODE_MEMBER with
TYPE_CODE_MEMBERPTR and TYPE_CODE_METHODPTR.
(lookup_memberptr_type, lookup_methodptr_type)
(smash_to_memberptr_type): New prototypes.
(smash_to_method_type): Formatting fix.
(lookup_member_type, smash_to_member_type): Delete prototypes.
* gnu-v3-abi.c (gnuv3_get_vtable, gnuv3_get_virtual_fn): New.
Do not rely on debug information for the vptr or the method's
enclosing type. Handle function descriptors for IA64.
(gnuv3_virtual_fn_field): Rewrite using the new functions.
(gnuv3_find_method_in, gnuv3_print_method_ptr)
(gnuv3_method_ptr_size, gnuv3_make_method_ptr)
(gnuv3_method_ptr_to_value): New.
(init_gnuv3_ops): Set new members of gnu_v3_abi_ops.
* hpread.c (hpread_type_lookup): Update for new types.
* infcall.c (value_arg_coerce): Likewise.
* m2-typeprint.c (m2_print_type): Remove explicit support
for member pointers.
* m2-valprint.c (m2_val_print): Likewise.
* p-typeprint.c (pascal_type_print_varspec_prefix)
(pascal_type_print_varspec_suffix, pascal_type_print_base): Likewise.
* p-valprint.c (pascal_val_print): Likewise.
(pascal_object_print_class_method, pascal_object_print_class_member):
Delete.
* p-lang.h (pascal_object_print_class_method)
(pascal_object_print_class_member): Delete prototypes.
* stabsread.c (read_type): Update for new types.
* typeprint.c (print_type_scalar): Likewise.
* valops.c (value_struct_elt_for_reference, value_namespace_elt)
(value_maybe_namespace_elt, value_aggregate_elt): Add want_address
argument. Construct a pointer to member if the address of a
function or data member is requested.
(value_cast_pointers): Don't modify the input value.
(value_cast): Adjust pointer to member handling for new types.
Allow null pointer to member constants. Don't modify the input
value.
(value_ind): Remove pointer to member check. Handle function
descriptors for function pointers.
(value_struct_elt, value_find_oload_method_list, check_field):
Remove pointer to member checks.
* value.c (unpack_long): Allow pointers to data members.
(value_from_longest): Allow member pointers.
* value.h (value_aggregate_elt): Add want_address.
* varobj.c (c_variable_editable): Remove check for members.
* gdbarch.sh: Add vtable_function_descriptors and vbit_in_delta.
* ia64-tdep.c (ia64_convert_from_func_ptr_addr): Handle descriptors
in virtual tables.
(ia64_gdbarch_init): Call set_gdbarch_vtable_function_descriptors.
* c-lang.h (cp_print_class_method): Delete prototype.
* arm-tdep.c (arm_gdbarch_init): Call set_gdbarch_vbit_in_delta.
* mips-tdep.c (mips_gdbarch_init): Likewise.
* gdbarch.c, gdbarch.h: Regenerated.
* gdb.cp/classes.exp (test_pointers_to_class_members): Update expected
output. Test the types of members and member pointers.
* gdb.cp/inherit.exp (test_print_mi_member_types): Remove KFAILs for
gdb/2092.
* gdb.cp/member-ptr.exp: Search for a comment instead of a
statement. Enable for GCC. Update expected output for some tests
and add new tests. Remove obsolete GCC KFAILs. Allow GCC's class
layout.
* gdb.cp/member-ptr.cc (Padding, Padding::vspacer, Base, Base::get_x)
(Base::vget_base, Left, Left::vget, Right, Right::vget, Diamond)
(Diamond::vget_base): New.
(main): Add new tests.
* gdb.cp/printmethod.exp: Update expected output for member functions.
* gdb.cp/virtfunc.exp (test_virtual_calls): Add a KFAIL for
print pEe->D::vg().
2007-01-03 19:05:45 +01:00
|
|
|
|
case TYPE_CODE_METHODPTR:
|
2010-12-31 23:59:52 +01:00
|
|
|
|
c_type_print_varspec_prefix (TYPE_TARGET_TYPE (type),
|
2018-04-17 21:51:23 +02:00
|
|
|
|
stream, show, 0, 0, language, flags,
|
|
|
|
|
podata);
|
* NEWS: Mention pointer to member improvements.
* Makefile.in (gnu-v3-abi.o): Delete special rule.
(eval.o, gnu-v3-abi.o, ia64-tdep.o): Update.
* ada-valprint.c (ada_print_scalar): Update for new type codes.
* c-typeprint.c (c_print_type): Update for new type codes.
(c_type_print_varspec_prefix, c_type_print_varspec_suffix)
(c_type_print_base): Likewise.
(c_type_print_args): Rewrite.
* c-valprint.c (c_val_print): Update for new type codes. Remove
support for references to members. Treat methods like functions.
* cp-abi.c (cplus_print_method_ptr, cplus_method_ptr_size)
(cplus_make_method_ptr, cplus_method_ptr_to_value): New.
* cp-abi.h (cplus_print_method_ptr, cplus_method_ptr_size)
(cplus_make_method_ptr, cplus_method_ptr_to_value): New prototypes.
(struct cp_abi_ops): Add corresponding members.
* cp-valprint.c (cp_print_class_method): Delete.
(cp_find_class_member): New function.
(cp_print_class_member): Use it. Simplify support for bogus
member pointers.
* dwarf2read.c (quirk_gcc_member_function_pointer): Use
lookup_methodptr_type.
(read_tag_ptr_to_member_type): Likewise, and lookup_memberptr_type.
* eval.c (evaluate_subexp_standard): Implement EVAL_SKIP for
OP_SCOPE. Update call to value_aggregate_elt. Rewrite member
pointer support.
(evaluate_subexp_for_address): Handle OP_SCOPE explicitly. Handle
references returned by user defined operators.
* f-typeprint.c (f_print_type, f_type_print_varspec_prefix)
(f_type_print_varspec_suffix): Remove support for member pointers.
* gdbtypes.c (lookup_memberptr_type): Renamed from lookup_member_type
and adjusted.
(smash_to_memberptr_type): Likewise, from smash_to_member_type.
(lookup_methodptr_type): New.
(rank_one_type): Adjust for TYPE_CODE_MEMBERPTR.
(recursive_dump_type): Update for new types.
* gdbtypes.h (enum type_code): Replace TYPE_CODE_MEMBER with
TYPE_CODE_MEMBERPTR and TYPE_CODE_METHODPTR.
(lookup_memberptr_type, lookup_methodptr_type)
(smash_to_memberptr_type): New prototypes.
(smash_to_method_type): Formatting fix.
(lookup_member_type, smash_to_member_type): Delete prototypes.
* gnu-v3-abi.c (gnuv3_get_vtable, gnuv3_get_virtual_fn): New.
Do not rely on debug information for the vptr or the method's
enclosing type. Handle function descriptors for IA64.
(gnuv3_virtual_fn_field): Rewrite using the new functions.
(gnuv3_find_method_in, gnuv3_print_method_ptr)
(gnuv3_method_ptr_size, gnuv3_make_method_ptr)
(gnuv3_method_ptr_to_value): New.
(init_gnuv3_ops): Set new members of gnu_v3_abi_ops.
* hpread.c (hpread_type_lookup): Update for new types.
* infcall.c (value_arg_coerce): Likewise.
* m2-typeprint.c (m2_print_type): Remove explicit support
for member pointers.
* m2-valprint.c (m2_val_print): Likewise.
* p-typeprint.c (pascal_type_print_varspec_prefix)
(pascal_type_print_varspec_suffix, pascal_type_print_base): Likewise.
* p-valprint.c (pascal_val_print): Likewise.
(pascal_object_print_class_method, pascal_object_print_class_member):
Delete.
* p-lang.h (pascal_object_print_class_method)
(pascal_object_print_class_member): Delete prototypes.
* stabsread.c (read_type): Update for new types.
* typeprint.c (print_type_scalar): Likewise.
* valops.c (value_struct_elt_for_reference, value_namespace_elt)
(value_maybe_namespace_elt, value_aggregate_elt): Add want_address
argument. Construct a pointer to member if the address of a
function or data member is requested.
(value_cast_pointers): Don't modify the input value.
(value_cast): Adjust pointer to member handling for new types.
Allow null pointer to member constants. Don't modify the input
value.
(value_ind): Remove pointer to member check. Handle function
descriptors for function pointers.
(value_struct_elt, value_find_oload_method_list, check_field):
Remove pointer to member checks.
* value.c (unpack_long): Allow pointers to data members.
(value_from_longest): Allow member pointers.
* value.h (value_aggregate_elt): Add want_address.
* varobj.c (c_variable_editable): Remove check for members.
* gdbarch.sh: Add vtable_function_descriptors and vbit_in_delta.
* ia64-tdep.c (ia64_convert_from_func_ptr_addr): Handle descriptors
in virtual tables.
(ia64_gdbarch_init): Call set_gdbarch_vtable_function_descriptors.
* c-lang.h (cp_print_class_method): Delete prototype.
* arm-tdep.c (arm_gdbarch_init): Call set_gdbarch_vbit_in_delta.
* mips-tdep.c (mips_gdbarch_init): Likewise.
* gdbarch.c, gdbarch.h: Regenerated.
* gdb.cp/classes.exp (test_pointers_to_class_members): Update expected
output. Test the types of members and member pointers.
* gdb.cp/inherit.exp (test_print_mi_member_types): Remove KFAILs for
gdb/2092.
* gdb.cp/member-ptr.exp: Search for a comment instead of a
statement. Enable for GCC. Update expected output for some tests
and add new tests. Remove obsolete GCC KFAILs. Allow GCC's class
layout.
* gdb.cp/member-ptr.cc (Padding, Padding::vspacer, Base, Base::get_x)
(Base::vget_base, Left, Left::vget, Right, Right::vget, Diamond)
(Diamond::vget_base): New.
(main): Add new tests.
* gdb.cp/printmethod.exp: Update expected output for member functions.
* gdb.cp/virtfunc.exp (test_virtual_calls): Add a KFAIL for
print pEe->D::vg().
2007-01-03 19:05:45 +01:00
|
|
|
|
fprintf_filtered (stream, "(");
|
Remove type_name_no_tag and rename type_name_no_tag_or_error
type_name_no_tag is just a plain wrapper for TYPE_NAME now, so this
patch removes it. And, because tag names no longer exist, this
renames type_name_no_tag_or_error to type_name_or_error.
gdb/ChangeLog
2018-06-01 Tom Tromey <tom@tromey.com>
* valops.c (value_cast_structs, destructor_name_p): Update.
* symtab.c (gdb_mangle_name): Update.
* stabsread.c (define_symbol, read_cpp_abbrev, read_baseclasses):
Update.
* p-valprint.c (pascal_object_is_vtbl_ptr_type)
(pascal_object_print_value_fields, pascal_object_print_value):
Update.
* p-typeprint.c (pascal_type_print_derivation_info): Update.
* linespec.c (find_methods): Update.
* gdbtypes.h (type_name_no_tag): Remove.
(type_name_or_error): Rename from type_name_no_tag_or_error.
* gdbtypes.c (type_name_no_tag): Remove.
(type_name_or_error): Rename from type_name_no_tag_or_error.
(lookup_struct_elt_type, check_typedef): Update.
* expprint.c (print_subexp_standard): Update.
* dwarf2read.c (dwarf2_add_field, load_partial_dies): Update.
* d-namespace.c (d_lookup_nested_symbol): Update.
* cp-valprint.c (cp_is_vtbl_ptr_type, cp_print_value_fields)
(cp_print_class_member): Update.
* cp-namespace.c (cp_lookup_nested_symbol): Update.
* completer.c (add_struct_fields): Update.
* c-typeprint.c (cp_type_print_derivation_info)
(c_type_print_varspec_prefix, c_type_print_base_struct_union):
Update.
* ada-lang.c (parse_old_style_renaming, xget_renaming_scope)
(ada_prefer_type, ada_is_exception_sym): Update.
2018-04-17 21:51:25 +02:00
|
|
|
|
name = TYPE_NAME (TYPE_SELF_TYPE (type));
|
* NEWS: Mention pointer to member improvements.
* Makefile.in (gnu-v3-abi.o): Delete special rule.
(eval.o, gnu-v3-abi.o, ia64-tdep.o): Update.
* ada-valprint.c (ada_print_scalar): Update for new type codes.
* c-typeprint.c (c_print_type): Update for new type codes.
(c_type_print_varspec_prefix, c_type_print_varspec_suffix)
(c_type_print_base): Likewise.
(c_type_print_args): Rewrite.
* c-valprint.c (c_val_print): Update for new type codes. Remove
support for references to members. Treat methods like functions.
* cp-abi.c (cplus_print_method_ptr, cplus_method_ptr_size)
(cplus_make_method_ptr, cplus_method_ptr_to_value): New.
* cp-abi.h (cplus_print_method_ptr, cplus_method_ptr_size)
(cplus_make_method_ptr, cplus_method_ptr_to_value): New prototypes.
(struct cp_abi_ops): Add corresponding members.
* cp-valprint.c (cp_print_class_method): Delete.
(cp_find_class_member): New function.
(cp_print_class_member): Use it. Simplify support for bogus
member pointers.
* dwarf2read.c (quirk_gcc_member_function_pointer): Use
lookup_methodptr_type.
(read_tag_ptr_to_member_type): Likewise, and lookup_memberptr_type.
* eval.c (evaluate_subexp_standard): Implement EVAL_SKIP for
OP_SCOPE. Update call to value_aggregate_elt. Rewrite member
pointer support.
(evaluate_subexp_for_address): Handle OP_SCOPE explicitly. Handle
references returned by user defined operators.
* f-typeprint.c (f_print_type, f_type_print_varspec_prefix)
(f_type_print_varspec_suffix): Remove support for member pointers.
* gdbtypes.c (lookup_memberptr_type): Renamed from lookup_member_type
and adjusted.
(smash_to_memberptr_type): Likewise, from smash_to_member_type.
(lookup_methodptr_type): New.
(rank_one_type): Adjust for TYPE_CODE_MEMBERPTR.
(recursive_dump_type): Update for new types.
* gdbtypes.h (enum type_code): Replace TYPE_CODE_MEMBER with
TYPE_CODE_MEMBERPTR and TYPE_CODE_METHODPTR.
(lookup_memberptr_type, lookup_methodptr_type)
(smash_to_memberptr_type): New prototypes.
(smash_to_method_type): Formatting fix.
(lookup_member_type, smash_to_member_type): Delete prototypes.
* gnu-v3-abi.c (gnuv3_get_vtable, gnuv3_get_virtual_fn): New.
Do not rely on debug information for the vptr or the method's
enclosing type. Handle function descriptors for IA64.
(gnuv3_virtual_fn_field): Rewrite using the new functions.
(gnuv3_find_method_in, gnuv3_print_method_ptr)
(gnuv3_method_ptr_size, gnuv3_make_method_ptr)
(gnuv3_method_ptr_to_value): New.
(init_gnuv3_ops): Set new members of gnu_v3_abi_ops.
* hpread.c (hpread_type_lookup): Update for new types.
* infcall.c (value_arg_coerce): Likewise.
* m2-typeprint.c (m2_print_type): Remove explicit support
for member pointers.
* m2-valprint.c (m2_val_print): Likewise.
* p-typeprint.c (pascal_type_print_varspec_prefix)
(pascal_type_print_varspec_suffix, pascal_type_print_base): Likewise.
* p-valprint.c (pascal_val_print): Likewise.
(pascal_object_print_class_method, pascal_object_print_class_member):
Delete.
* p-lang.h (pascal_object_print_class_method)
(pascal_object_print_class_member): Delete prototypes.
* stabsread.c (read_type): Update for new types.
* typeprint.c (print_type_scalar): Likewise.
* valops.c (value_struct_elt_for_reference, value_namespace_elt)
(value_maybe_namespace_elt, value_aggregate_elt): Add want_address
argument. Construct a pointer to member if the address of a
function or data member is requested.
(value_cast_pointers): Don't modify the input value.
(value_cast): Adjust pointer to member handling for new types.
Allow null pointer to member constants. Don't modify the input
value.
(value_ind): Remove pointer to member check. Handle function
descriptors for function pointers.
(value_struct_elt, value_find_oload_method_list, check_field):
Remove pointer to member checks.
* value.c (unpack_long): Allow pointers to data members.
(value_from_longest): Allow member pointers.
* value.h (value_aggregate_elt): Add want_address.
* varobj.c (c_variable_editable): Remove check for members.
* gdbarch.sh: Add vtable_function_descriptors and vbit_in_delta.
* ia64-tdep.c (ia64_convert_from_func_ptr_addr): Handle descriptors
in virtual tables.
(ia64_gdbarch_init): Call set_gdbarch_vtable_function_descriptors.
* c-lang.h (cp_print_class_method): Delete prototype.
* arm-tdep.c (arm_gdbarch_init): Call set_gdbarch_vbit_in_delta.
* mips-tdep.c (mips_gdbarch_init): Likewise.
* gdbarch.c, gdbarch.h: Regenerated.
* gdb.cp/classes.exp (test_pointers_to_class_members): Update expected
output. Test the types of members and member pointers.
* gdb.cp/inherit.exp (test_print_mi_member_types): Remove KFAILs for
gdb/2092.
* gdb.cp/member-ptr.exp: Search for a comment instead of a
statement. Enable for GCC. Update expected output for some tests
and add new tests. Remove obsolete GCC KFAILs. Allow GCC's class
layout.
* gdb.cp/member-ptr.cc (Padding, Padding::vspacer, Base, Base::get_x)
(Base::vget_base, Left, Left::vget, Right, Right::vget, Diamond)
(Diamond::vget_base): New.
(main): Add new tests.
* gdb.cp/printmethod.exp: Update expected output for member functions.
* gdb.cp/virtfunc.exp (test_virtual_calls): Add a KFAIL for
print pEe->D::vg().
2007-01-03 19:05:45 +01:00
|
|
|
|
if (name)
|
* c-typeprint.c (find_typedef_for_canonicalize,
print_name_maybe_canonical): New functions.
(c_print_type): Look up type name.
(cp_type_print_derivation_info): Add flags argument. Use
print_name_maybe_canonical.
(cp_type_print_method_args): Add wrapping.
(c_type_print_varspec_prefix): Use print_name_maybe_canonical.
(c_type_print_template_args): New function.
(c_type_print_base): Change wrapping. Use
print_name_maybe_canonical.
<TYPE_CODE_STRUCT>: Possibly create a typedef hash, and do
type name lookups.
* gdbtypes.c (types_equal): No longer static.
* gdbtypes.h (types_equal): Declare.
* typeprint.c (type_print_raw_options, default_ptype_flags):
Update.
(struct typedef_hash_table): New.
(hash_typedef_field, eq_typedef_field,
recursively_update_typedef_hash, add_template_parameters,
create_typedef_hash, free_typedef_hash, do_free_typedef_hash,
make_cleanup_free_typedef_hash, copy_typedef_hash_element,
copy_typedef_hash, find_typedef_in_hash): New functions.
* typeprint.h (struct type_print_options) <local_typedefs>:
New field.
(recursively_update_typedef_hash, add_template_parameters,
create_typedef_hash, free_typedef_hash,
make_cleanup_free_typedef_hash, copy_typedef_hash,
find_typedef_in_hash): Declare.
testsuite
* gdb.base/call-sc.exp: Use "ptype/r".
* gdb.base/volatile.exp: Don't expect "int".
* gdb.cp/ptype-flags.cc: New file.
* gdb.cp/ptype-flags.exp: New file.
* gdb.cp/templates.exp: Use ptype/r.
(test_ptype_of_templates, test_template_typedef): Likewise.
* lib/cp-support.exp (cp_test_ptype_class): Add in_ptype_arg
argument. Handle template names and template parameters.
* gdb.mi/mi-var-cmd.exp: Accept "long".
* gdb.mi/mi-var-child.exp: Accept "long".
* gdb.mi/mi-var-display.exp: Accept "long".
* gdb.mi/mi2-var-child.exp: Accept "long".
2012-11-12 18:37:38 +01:00
|
|
|
|
print_name_maybe_canonical (name, flags, stream);
|
* NEWS: Mention pointer to member improvements.
* Makefile.in (gnu-v3-abi.o): Delete special rule.
(eval.o, gnu-v3-abi.o, ia64-tdep.o): Update.
* ada-valprint.c (ada_print_scalar): Update for new type codes.
* c-typeprint.c (c_print_type): Update for new type codes.
(c_type_print_varspec_prefix, c_type_print_varspec_suffix)
(c_type_print_base): Likewise.
(c_type_print_args): Rewrite.
* c-valprint.c (c_val_print): Update for new type codes. Remove
support for references to members. Treat methods like functions.
* cp-abi.c (cplus_print_method_ptr, cplus_method_ptr_size)
(cplus_make_method_ptr, cplus_method_ptr_to_value): New.
* cp-abi.h (cplus_print_method_ptr, cplus_method_ptr_size)
(cplus_make_method_ptr, cplus_method_ptr_to_value): New prototypes.
(struct cp_abi_ops): Add corresponding members.
* cp-valprint.c (cp_print_class_method): Delete.
(cp_find_class_member): New function.
(cp_print_class_member): Use it. Simplify support for bogus
member pointers.
* dwarf2read.c (quirk_gcc_member_function_pointer): Use
lookup_methodptr_type.
(read_tag_ptr_to_member_type): Likewise, and lookup_memberptr_type.
* eval.c (evaluate_subexp_standard): Implement EVAL_SKIP for
OP_SCOPE. Update call to value_aggregate_elt. Rewrite member
pointer support.
(evaluate_subexp_for_address): Handle OP_SCOPE explicitly. Handle
references returned by user defined operators.
* f-typeprint.c (f_print_type, f_type_print_varspec_prefix)
(f_type_print_varspec_suffix): Remove support for member pointers.
* gdbtypes.c (lookup_memberptr_type): Renamed from lookup_member_type
and adjusted.
(smash_to_memberptr_type): Likewise, from smash_to_member_type.
(lookup_methodptr_type): New.
(rank_one_type): Adjust for TYPE_CODE_MEMBERPTR.
(recursive_dump_type): Update for new types.
* gdbtypes.h (enum type_code): Replace TYPE_CODE_MEMBER with
TYPE_CODE_MEMBERPTR and TYPE_CODE_METHODPTR.
(lookup_memberptr_type, lookup_methodptr_type)
(smash_to_memberptr_type): New prototypes.
(smash_to_method_type): Formatting fix.
(lookup_member_type, smash_to_member_type): Delete prototypes.
* gnu-v3-abi.c (gnuv3_get_vtable, gnuv3_get_virtual_fn): New.
Do not rely on debug information for the vptr or the method's
enclosing type. Handle function descriptors for IA64.
(gnuv3_virtual_fn_field): Rewrite using the new functions.
(gnuv3_find_method_in, gnuv3_print_method_ptr)
(gnuv3_method_ptr_size, gnuv3_make_method_ptr)
(gnuv3_method_ptr_to_value): New.
(init_gnuv3_ops): Set new members of gnu_v3_abi_ops.
* hpread.c (hpread_type_lookup): Update for new types.
* infcall.c (value_arg_coerce): Likewise.
* m2-typeprint.c (m2_print_type): Remove explicit support
for member pointers.
* m2-valprint.c (m2_val_print): Likewise.
* p-typeprint.c (pascal_type_print_varspec_prefix)
(pascal_type_print_varspec_suffix, pascal_type_print_base): Likewise.
* p-valprint.c (pascal_val_print): Likewise.
(pascal_object_print_class_method, pascal_object_print_class_member):
Delete.
* p-lang.h (pascal_object_print_class_method)
(pascal_object_print_class_member): Delete prototypes.
* stabsread.c (read_type): Update for new types.
* typeprint.c (print_type_scalar): Likewise.
* valops.c (value_struct_elt_for_reference, value_namespace_elt)
(value_maybe_namespace_elt, value_aggregate_elt): Add want_address
argument. Construct a pointer to member if the address of a
function or data member is requested.
(value_cast_pointers): Don't modify the input value.
(value_cast): Adjust pointer to member handling for new types.
Allow null pointer to member constants. Don't modify the input
value.
(value_ind): Remove pointer to member check. Handle function
descriptors for function pointers.
(value_struct_elt, value_find_oload_method_list, check_field):
Remove pointer to member checks.
* value.c (unpack_long): Allow pointers to data members.
(value_from_longest): Allow member pointers.
* value.h (value_aggregate_elt): Add want_address.
* varobj.c (c_variable_editable): Remove check for members.
* gdbarch.sh: Add vtable_function_descriptors and vbit_in_delta.
* ia64-tdep.c (ia64_convert_from_func_ptr_addr): Handle descriptors
in virtual tables.
(ia64_gdbarch_init): Call set_gdbarch_vtable_function_descriptors.
* c-lang.h (cp_print_class_method): Delete prototype.
* arm-tdep.c (arm_gdbarch_init): Call set_gdbarch_vbit_in_delta.
* mips-tdep.c (mips_gdbarch_init): Likewise.
* gdbarch.c, gdbarch.h: Regenerated.
* gdb.cp/classes.exp (test_pointers_to_class_members): Update expected
output. Test the types of members and member pointers.
* gdb.cp/inherit.exp (test_print_mi_member_types): Remove KFAILs for
gdb/2092.
* gdb.cp/member-ptr.exp: Search for a comment instead of a
statement. Enable for GCC. Update expected output for some tests
and add new tests. Remove obsolete GCC KFAILs. Allow GCC's class
layout.
* gdb.cp/member-ptr.cc (Padding, Padding::vspacer, Base, Base::get_x)
(Base::vget_base, Left, Left::vget, Right, Right::vget, Diamond)
(Diamond::vget_base): New.
(main): Add new tests.
* gdb.cp/printmethod.exp: Update expected output for member functions.
* gdb.cp/virtfunc.exp (test_virtual_calls): Add a KFAIL for
print pEe->D::vg().
2007-01-03 19:05:45 +01:00
|
|
|
|
else
|
Implement pahole-like 'ptype /o' option
This commit implements the pahole-like '/o' option for 'ptype', which
prints the offsets and sizes of struct fields, reporting whenever
there is a hole found.
The output is heavily based on pahole(1), with a few modifications
here and there to adjust it to our reality. Here's an example:
/* offset | size */ type = struct wer : public tuv {
public:
/* 32 | 24 */ struct tyu {
/* 32:31 | 4 */ int a1 : 1;
/* 32:28 | 4 */ int a2 : 3;
/* 32: 5 | 4 */ int a3 : 23;
/* 35: 3 | 1 */ char a4 : 2;
/* XXX 3-bit hole */
/* XXX 4-byte hole */
/* 40 | 8 */ int64_t a5;
/* 48:27 | 4 */ int a6 : 5;
/* 48:56 | 8 */ int64_t a7 : 3;
/* total size (bytes): 24 */
} a1;
/* total size (bytes): 56 */
}
A big part of this patch handles the formatting logic of 'ptype',
which is a bit messy. The code to handle bitfield offsets, however,
took some time to craft. My thanks to Pedro Alves for figuring things
out and pointing me to the right direction, as well as coming up with
a way to inspect the layout of structs with bitfields (see testcase
for comments).
After many discussions both on IRC and at the mailing list, I tried to
implement printing vtables and inherited classes. Unfortunately the
code grew too complex and there were still a few corner cases failing
so I had to drop the attempt. This should be implemented in a future
patch.
This patch is the start of a long-term work I'll do to flush the local
patches we carry for Fedora GDB. In this specific case, I'm aiming at
upstreaming the feature implemented by the 'pahole.py' script that is
shipped with Fedora GDB:
<https://src.fedoraproject.org/rpms/gdb/blob/master/f/gdb-archer.patch#_311>
This has been regression-tested on the BuildBot. There's a new
testcase for it, along with an update to the documentation. I also
thought it was worth mentioning this feature in the NEWS file.
gdb/ChangeLog:
2017-12-15 Sergio Durigan Junior <sergiodj@redhat.com>
Pedro Alves <palves@redhat.com>
PR cli/16224
* NEWS (Changes since GDB 8.0): Mention new '/o' flag.
* c-typeprint.c (OFFSET_SPC_LEN): New define.
(c_type_print_varspec_prefix): New argument 'struct
print_offset_data *'.
(c_type_print_base_1): New function and prototype.
(c_print_type_1): New function, with code from 'c_print_type'.
(c_print_type): Use 'c_print_type_1'.
(c_type_print_varspec_prefix): New argument 'struct
print_offset_data *'. Use it. Call 'c_type_print_base_1'
instead of 'c_print_type_base'.
(print_spaces_filtered_with_print_options): New function.
(output_access_specifier): Take new argument FLAGS. Modify
function to call 'print_spaces_filtered_with_print_options'.
(c_print_type_vtable_offset_marker): New function.
(c_print_type_union_field_offset): New function.
(c_print_type_struct_field_offset): New function.
(c_print_type_no_offsets): New function.
(c_type_print_base_struct_union): New argument 'struct
print_offset_data *'. Print offsets and sizes for
struct/union/class fields.
* typeprint.c (const struct type_print_options
type_print_raw_options): Initialize 'print_offsets'.
(static struct type_print_options default_ptype_flags):
Likewise.
(struct print_offset_data print_offset_default_data): New
variable.
(whatis_exp): Handle '/o' option.
(_initialize_typeprint): Add '/o' flag to ptype's help.
* typeprint.h (struct print_offset_data): New struct.
(struct type_print_options) <print_offsets>: New field.
gdb/testsuite/ChangeLog:
2017-12-15 Sergio Durigan Junior <sergiodj@redhat.com>
PR cli/16224
* gdb.base/ptype-offsets.cc: New file.
* gdb.base/ptype-offsets.exp: New file.
gdb/doc/ChangeLog:
2017-12-15 Sergio Durigan Junior <sergiodj@redhat.com>
PR cli/16224
* gdb.texinfo (ptype): Add documentation for new flag '/o'.
2017-11-20 22:34:59 +01:00
|
|
|
|
c_type_print_base_1 (TYPE_SELF_TYPE (type),
|
2018-04-17 21:51:23 +02:00
|
|
|
|
stream, -1, passed_a_ptr, language, flags,
|
|
|
|
|
podata);
|
* NEWS: Mention pointer to member improvements.
* Makefile.in (gnu-v3-abi.o): Delete special rule.
(eval.o, gnu-v3-abi.o, ia64-tdep.o): Update.
* ada-valprint.c (ada_print_scalar): Update for new type codes.
* c-typeprint.c (c_print_type): Update for new type codes.
(c_type_print_varspec_prefix, c_type_print_varspec_suffix)
(c_type_print_base): Likewise.
(c_type_print_args): Rewrite.
* c-valprint.c (c_val_print): Update for new type codes. Remove
support for references to members. Treat methods like functions.
* cp-abi.c (cplus_print_method_ptr, cplus_method_ptr_size)
(cplus_make_method_ptr, cplus_method_ptr_to_value): New.
* cp-abi.h (cplus_print_method_ptr, cplus_method_ptr_size)
(cplus_make_method_ptr, cplus_method_ptr_to_value): New prototypes.
(struct cp_abi_ops): Add corresponding members.
* cp-valprint.c (cp_print_class_method): Delete.
(cp_find_class_member): New function.
(cp_print_class_member): Use it. Simplify support for bogus
member pointers.
* dwarf2read.c (quirk_gcc_member_function_pointer): Use
lookup_methodptr_type.
(read_tag_ptr_to_member_type): Likewise, and lookup_memberptr_type.
* eval.c (evaluate_subexp_standard): Implement EVAL_SKIP for
OP_SCOPE. Update call to value_aggregate_elt. Rewrite member
pointer support.
(evaluate_subexp_for_address): Handle OP_SCOPE explicitly. Handle
references returned by user defined operators.
* f-typeprint.c (f_print_type, f_type_print_varspec_prefix)
(f_type_print_varspec_suffix): Remove support for member pointers.
* gdbtypes.c (lookup_memberptr_type): Renamed from lookup_member_type
and adjusted.
(smash_to_memberptr_type): Likewise, from smash_to_member_type.
(lookup_methodptr_type): New.
(rank_one_type): Adjust for TYPE_CODE_MEMBERPTR.
(recursive_dump_type): Update for new types.
* gdbtypes.h (enum type_code): Replace TYPE_CODE_MEMBER with
TYPE_CODE_MEMBERPTR and TYPE_CODE_METHODPTR.
(lookup_memberptr_type, lookup_methodptr_type)
(smash_to_memberptr_type): New prototypes.
(smash_to_method_type): Formatting fix.
(lookup_member_type, smash_to_member_type): Delete prototypes.
* gnu-v3-abi.c (gnuv3_get_vtable, gnuv3_get_virtual_fn): New.
Do not rely on debug information for the vptr or the method's
enclosing type. Handle function descriptors for IA64.
(gnuv3_virtual_fn_field): Rewrite using the new functions.
(gnuv3_find_method_in, gnuv3_print_method_ptr)
(gnuv3_method_ptr_size, gnuv3_make_method_ptr)
(gnuv3_method_ptr_to_value): New.
(init_gnuv3_ops): Set new members of gnu_v3_abi_ops.
* hpread.c (hpread_type_lookup): Update for new types.
* infcall.c (value_arg_coerce): Likewise.
* m2-typeprint.c (m2_print_type): Remove explicit support
for member pointers.
* m2-valprint.c (m2_val_print): Likewise.
* p-typeprint.c (pascal_type_print_varspec_prefix)
(pascal_type_print_varspec_suffix, pascal_type_print_base): Likewise.
* p-valprint.c (pascal_val_print): Likewise.
(pascal_object_print_class_method, pascal_object_print_class_member):
Delete.
* p-lang.h (pascal_object_print_class_method)
(pascal_object_print_class_member): Delete prototypes.
* stabsread.c (read_type): Update for new types.
* typeprint.c (print_type_scalar): Likewise.
* valops.c (value_struct_elt_for_reference, value_namespace_elt)
(value_maybe_namespace_elt, value_aggregate_elt): Add want_address
argument. Construct a pointer to member if the address of a
function or data member is requested.
(value_cast_pointers): Don't modify the input value.
(value_cast): Adjust pointer to member handling for new types.
Allow null pointer to member constants. Don't modify the input
value.
(value_ind): Remove pointer to member check. Handle function
descriptors for function pointers.
(value_struct_elt, value_find_oload_method_list, check_field):
Remove pointer to member checks.
* value.c (unpack_long): Allow pointers to data members.
(value_from_longest): Allow member pointers.
* value.h (value_aggregate_elt): Add want_address.
* varobj.c (c_variable_editable): Remove check for members.
* gdbarch.sh: Add vtable_function_descriptors and vbit_in_delta.
* ia64-tdep.c (ia64_convert_from_func_ptr_addr): Handle descriptors
in virtual tables.
(ia64_gdbarch_init): Call set_gdbarch_vtable_function_descriptors.
* c-lang.h (cp_print_class_method): Delete prototype.
* arm-tdep.c (arm_gdbarch_init): Call set_gdbarch_vbit_in_delta.
* mips-tdep.c (mips_gdbarch_init): Likewise.
* gdbarch.c, gdbarch.h: Regenerated.
* gdb.cp/classes.exp (test_pointers_to_class_members): Update expected
output. Test the types of members and member pointers.
* gdb.cp/inherit.exp (test_print_mi_member_types): Remove KFAILs for
gdb/2092.
* gdb.cp/member-ptr.exp: Search for a comment instead of a
statement. Enable for GCC. Update expected output for some tests
and add new tests. Remove obsolete GCC KFAILs. Allow GCC's class
layout.
* gdb.cp/member-ptr.cc (Padding, Padding::vspacer, Base, Base::get_x)
(Base::vget_base, Left, Left::vget, Right, Right::vget, Diamond)
(Diamond::vget_base): New.
(main): Add new tests.
* gdb.cp/printmethod.exp: Update expected output for member functions.
* gdb.cp/virtfunc.exp (test_virtual_calls): Add a KFAIL for
print pEe->D::vg().
2007-01-03 19:05:45 +01:00
|
|
|
|
fprintf_filtered (stream, "::*");
|
1999-04-16 03:35:26 +02:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case TYPE_CODE_REF:
|
2017-03-20 21:47:48 +01:00
|
|
|
|
case TYPE_CODE_RVALUE_REF:
|
2010-12-31 23:59:52 +01:00
|
|
|
|
c_type_print_varspec_prefix (TYPE_TARGET_TYPE (type),
|
2018-04-17 21:51:23 +02:00
|
|
|
|
stream, show, 1, 0, language, flags,
|
|
|
|
|
podata);
|
2017-03-20 21:47:48 +01:00
|
|
|
|
fprintf_filtered (stream, TYPE_CODE(type) == TYPE_CODE_REF ? "&" : "&&");
|
2002-10-15 00:58:28 +02:00
|
|
|
|
c_type_print_modifier (type, stream, 1, need_post_space);
|
1999-04-16 03:35:26 +02:00
|
|
|
|
break;
|
|
|
|
|
|
* NEWS: Mention pointer to member improvements.
* Makefile.in (gnu-v3-abi.o): Delete special rule.
(eval.o, gnu-v3-abi.o, ia64-tdep.o): Update.
* ada-valprint.c (ada_print_scalar): Update for new type codes.
* c-typeprint.c (c_print_type): Update for new type codes.
(c_type_print_varspec_prefix, c_type_print_varspec_suffix)
(c_type_print_base): Likewise.
(c_type_print_args): Rewrite.
* c-valprint.c (c_val_print): Update for new type codes. Remove
support for references to members. Treat methods like functions.
* cp-abi.c (cplus_print_method_ptr, cplus_method_ptr_size)
(cplus_make_method_ptr, cplus_method_ptr_to_value): New.
* cp-abi.h (cplus_print_method_ptr, cplus_method_ptr_size)
(cplus_make_method_ptr, cplus_method_ptr_to_value): New prototypes.
(struct cp_abi_ops): Add corresponding members.
* cp-valprint.c (cp_print_class_method): Delete.
(cp_find_class_member): New function.
(cp_print_class_member): Use it. Simplify support for bogus
member pointers.
* dwarf2read.c (quirk_gcc_member_function_pointer): Use
lookup_methodptr_type.
(read_tag_ptr_to_member_type): Likewise, and lookup_memberptr_type.
* eval.c (evaluate_subexp_standard): Implement EVAL_SKIP for
OP_SCOPE. Update call to value_aggregate_elt. Rewrite member
pointer support.
(evaluate_subexp_for_address): Handle OP_SCOPE explicitly. Handle
references returned by user defined operators.
* f-typeprint.c (f_print_type, f_type_print_varspec_prefix)
(f_type_print_varspec_suffix): Remove support for member pointers.
* gdbtypes.c (lookup_memberptr_type): Renamed from lookup_member_type
and adjusted.
(smash_to_memberptr_type): Likewise, from smash_to_member_type.
(lookup_methodptr_type): New.
(rank_one_type): Adjust for TYPE_CODE_MEMBERPTR.
(recursive_dump_type): Update for new types.
* gdbtypes.h (enum type_code): Replace TYPE_CODE_MEMBER with
TYPE_CODE_MEMBERPTR and TYPE_CODE_METHODPTR.
(lookup_memberptr_type, lookup_methodptr_type)
(smash_to_memberptr_type): New prototypes.
(smash_to_method_type): Formatting fix.
(lookup_member_type, smash_to_member_type): Delete prototypes.
* gnu-v3-abi.c (gnuv3_get_vtable, gnuv3_get_virtual_fn): New.
Do not rely on debug information for the vptr or the method's
enclosing type. Handle function descriptors for IA64.
(gnuv3_virtual_fn_field): Rewrite using the new functions.
(gnuv3_find_method_in, gnuv3_print_method_ptr)
(gnuv3_method_ptr_size, gnuv3_make_method_ptr)
(gnuv3_method_ptr_to_value): New.
(init_gnuv3_ops): Set new members of gnu_v3_abi_ops.
* hpread.c (hpread_type_lookup): Update for new types.
* infcall.c (value_arg_coerce): Likewise.
* m2-typeprint.c (m2_print_type): Remove explicit support
for member pointers.
* m2-valprint.c (m2_val_print): Likewise.
* p-typeprint.c (pascal_type_print_varspec_prefix)
(pascal_type_print_varspec_suffix, pascal_type_print_base): Likewise.
* p-valprint.c (pascal_val_print): Likewise.
(pascal_object_print_class_method, pascal_object_print_class_member):
Delete.
* p-lang.h (pascal_object_print_class_method)
(pascal_object_print_class_member): Delete prototypes.
* stabsread.c (read_type): Update for new types.
* typeprint.c (print_type_scalar): Likewise.
* valops.c (value_struct_elt_for_reference, value_namespace_elt)
(value_maybe_namespace_elt, value_aggregate_elt): Add want_address
argument. Construct a pointer to member if the address of a
function or data member is requested.
(value_cast_pointers): Don't modify the input value.
(value_cast): Adjust pointer to member handling for new types.
Allow null pointer to member constants. Don't modify the input
value.
(value_ind): Remove pointer to member check. Handle function
descriptors for function pointers.
(value_struct_elt, value_find_oload_method_list, check_field):
Remove pointer to member checks.
* value.c (unpack_long): Allow pointers to data members.
(value_from_longest): Allow member pointers.
* value.h (value_aggregate_elt): Add want_address.
* varobj.c (c_variable_editable): Remove check for members.
* gdbarch.sh: Add vtable_function_descriptors and vbit_in_delta.
* ia64-tdep.c (ia64_convert_from_func_ptr_addr): Handle descriptors
in virtual tables.
(ia64_gdbarch_init): Call set_gdbarch_vtable_function_descriptors.
* c-lang.h (cp_print_class_method): Delete prototype.
* arm-tdep.c (arm_gdbarch_init): Call set_gdbarch_vbit_in_delta.
* mips-tdep.c (mips_gdbarch_init): Likewise.
* gdbarch.c, gdbarch.h: Regenerated.
* gdb.cp/classes.exp (test_pointers_to_class_members): Update expected
output. Test the types of members and member pointers.
* gdb.cp/inherit.exp (test_print_mi_member_types): Remove KFAILs for
gdb/2092.
* gdb.cp/member-ptr.exp: Search for a comment instead of a
statement. Enable for GCC. Update expected output for some tests
and add new tests. Remove obsolete GCC KFAILs. Allow GCC's class
layout.
* gdb.cp/member-ptr.cc (Padding, Padding::vspacer, Base, Base::get_x)
(Base::vget_base, Left, Left::vget, Right, Right::vget, Diamond)
(Diamond::vget_base): New.
(main): Add new tests.
* gdb.cp/printmethod.exp: Update expected output for member functions.
* gdb.cp/virtfunc.exp (test_virtual_calls): Add a KFAIL for
print pEe->D::vg().
2007-01-03 19:05:45 +01:00
|
|
|
|
case TYPE_CODE_METHOD:
|
1999-04-16 03:35:26 +02:00
|
|
|
|
case TYPE_CODE_FUNC:
|
2010-12-31 23:59:52 +01:00
|
|
|
|
c_type_print_varspec_prefix (TYPE_TARGET_TYPE (type),
|
2018-04-17 21:51:23 +02:00
|
|
|
|
stream, show, 0, 0, language, flags,
|
|
|
|
|
podata);
|
1999-04-16 03:35:26 +02:00
|
|
|
|
if (passed_a_ptr)
|
|
|
|
|
fprintf_filtered (stream, "(");
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case TYPE_CODE_ARRAY:
|
2010-12-31 23:59:52 +01:00
|
|
|
|
c_type_print_varspec_prefix (TYPE_TARGET_TYPE (type),
|
2018-04-17 21:51:23 +02:00
|
|
|
|
stream, show, 0, 0, language, flags,
|
|
|
|
|
podata);
|
1999-04-16 03:35:26 +02:00
|
|
|
|
if (passed_a_ptr)
|
|
|
|
|
fprintf_filtered (stream, "(");
|
|
|
|
|
break;
|
|
|
|
|
|
2003-01-04 22:51:53 +01:00
|
|
|
|
case TYPE_CODE_TYPEDEF:
|
2010-12-31 23:59:52 +01:00
|
|
|
|
c_type_print_varspec_prefix (TYPE_TARGET_TYPE (type),
|
2018-04-17 21:51:23 +02:00
|
|
|
|
stream, show, passed_a_ptr, 0,
|
|
|
|
|
language, flags, podata);
|
2003-01-04 22:51:53 +01:00
|
|
|
|
break;
|
|
|
|
|
|
1999-04-16 03:35:26 +02:00
|
|
|
|
case TYPE_CODE_UNDEF:
|
|
|
|
|
case TYPE_CODE_STRUCT:
|
|
|
|
|
case TYPE_CODE_UNION:
|
|
|
|
|
case TYPE_CODE_ENUM:
|
2016-03-15 22:37:29 +01:00
|
|
|
|
case TYPE_CODE_FLAGS:
|
1999-04-16 03:35:26 +02:00
|
|
|
|
case TYPE_CODE_INT:
|
|
|
|
|
case TYPE_CODE_FLT:
|
|
|
|
|
case TYPE_CODE_VOID:
|
|
|
|
|
case TYPE_CODE_ERROR:
|
|
|
|
|
case TYPE_CODE_CHAR:
|
|
|
|
|
case TYPE_CODE_BOOL:
|
|
|
|
|
case TYPE_CODE_SET:
|
|
|
|
|
case TYPE_CODE_RANGE:
|
|
|
|
|
case TYPE_CODE_STRING:
|
|
|
|
|
case TYPE_CODE_COMPLEX:
|
2003-09-11 David Carlton <carlton@kealia.com>
* gdbtypes.h: Add TYPE_CODE_NAMESPACE.
* gdbtypes.c (init_type): Handle TYPE_CODE_NAMESPACE.
(recursive_dump_type): Ditto.
* printcmd.c (print_formatted): Ditto.
* typeprint.c (print_type_scalar): Ditto.
* c-typeprint.c (c_type_print_varspec_prefix): Ditto.
(c_type_print_varspec_suffix, c_type_print_base): Ditto.
* cp-support.h: Declare cp_check_possible_namespace_symbols,
maint_cplus_cmd_list.
* cp-support.c: Make maint_cplus_cmd_list extern.
* cp-namespace.c: Include objfiles.h, gdbtypes.h, dictionary.h,
command.h.
(lookup_symbol_file): Look in possible namespace blocks when
appropriate.
(initialize_namespace_symtab): New.
(get_possible_namespace_block, free_namespace_block)
(check_possible_namespace_symbols)
(check_possible_namespace_symbols_loop)
(check_one_possible_namespace_symbol)
(lookup_possible_namespace_symbol, maintenance_cplus_namespace)
(_initialize_cp_namespace): Ditto.
* block.h: Declare allocate_block.
* block.c (allocate_block): New.
* jv-lang.c (get_java_class_symtab): Allocate blocks via
allocate_block.
* symfile.h: Update declaration of add_psymbol_to_list.
* symfile.c (add_psymbol_to_list): Return the partial symbol in
question.
* dwarf2read.c (dwarf2_build_psymtabs_hard): Add argument to
scan_partial_symbols_call.
(scan_partial_symbols): Add NAMESPACE argument; update calls to
helper functions.
(add_partial_symbol): If necessary, scan mangled names for names
of namespaces.
(add_partial_namespace): Add NAMESPACE argument; generate partial
symbols associated to namespaces.
(add_partial_enumeration): Add NAMESPACE argument.
(new_symbol): Allow namespace syms.
(read_namespace): Generate namespace syms.
* objfiles.h: Add opaque declaration of struct symtab.
(struct objfile): Add cp_namespace_symtab member.
* objfiles.c (allocate_objfile): Set
objfile->cp_namespace_symtab.
* Makefile.in (cp-namespace.o): Depend on objfiles_h, gdbtypes_h,
dictionary_h, command_h.
2003-09-11 David Carlton <carlton@kealia.com>
* gdb.c++/namespace.exp: Add tests for namespace types.
* gdb.c++/maint.exp (test_help): Test 'help maint cp namespace'.
(test_namespace): New.
2003-09-11 21:49:20 +02:00
|
|
|
|
case TYPE_CODE_NAMESPACE:
|
2007-10-25 19:57:34 +02:00
|
|
|
|
case TYPE_CODE_DECFLOAT:
|
1999-04-16 03:35:26 +02:00
|
|
|
|
/* These types need no prefix. They are listed here so that
|
1999-07-07 22:19:36 +02:00
|
|
|
|
gcc -Wall will reveal any types that haven't been handled. */
|
1999-04-16 03:35:26 +02:00
|
|
|
|
break;
|
1999-12-14 02:06:04 +01:00
|
|
|
|
default:
|
2005-01-29 Baurzhan Ismagulov <ibr@radix50.net>
* ax-gdb.c, ax-general.c, bcache.c, bfd-target.c, bsd-kvm.c,
* buildsym.c, c-lang.c, c-typeprint.c, c-valprint.c, charset.c,
* coff-pe-read.c, coffread.c, complaints.c, copying.c: I18n markup.
2005-01-29 18:53:26 +01:00
|
|
|
|
error (_("type not handled in c_type_print_varspec_prefix()"));
|
1999-12-14 02:06:04 +01:00
|
|
|
|
break;
|
1999-04-16 03:35:26 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2010-10-11 21:24:52 +02:00
|
|
|
|
/* Print out "const" and "volatile" attributes,
|
|
|
|
|
and address space id if present.
|
1999-04-16 03:35:26 +02:00
|
|
|
|
TYPE is a pointer to the type being printed out.
|
|
|
|
|
STREAM is the output destination.
|
2010-10-13 17:10:10 +02:00
|
|
|
|
NEED_PRE_SPACE = 1 indicates an initial white space is needed.
|
|
|
|
|
NEED_POST_SPACE = 1 indicates a final white space is needed. */
|
1999-04-16 03:35:26 +02:00
|
|
|
|
|
|
|
|
|
static void
|
2001-11-15 02:55:59 +01:00
|
|
|
|
c_type_print_modifier (struct type *type, struct ui_file *stream,
|
|
|
|
|
int need_pre_space, int need_post_space)
|
1999-04-16 03:35:26 +02:00
|
|
|
|
{
|
2001-11-15 02:55:59 +01:00
|
|
|
|
int did_print_modifier = 0;
|
2002-12-11 21:19:39 +01:00
|
|
|
|
const char *address_space_id;
|
1999-07-07 22:19:36 +02:00
|
|
|
|
|
2001-04-25 01:12:50 +02:00
|
|
|
|
/* We don't print `const' qualifiers for references --- since all
|
|
|
|
|
operators affect the thing referenced, not the reference itself,
|
|
|
|
|
every reference is `const'. */
|
2017-03-20 21:47:48 +01:00
|
|
|
|
if (TYPE_CONST (type) && !TYPE_IS_REFERENCE (type))
|
1999-04-16 03:35:26 +02:00
|
|
|
|
{
|
|
|
|
|
if (need_pre_space)
|
1999-07-07 22:19:36 +02:00
|
|
|
|
fprintf_filtered (stream, " ");
|
1999-04-16 03:35:26 +02:00
|
|
|
|
fprintf_filtered (stream, "const");
|
2001-11-15 02:55:59 +01:00
|
|
|
|
did_print_modifier = 1;
|
1999-04-16 03:35:26 +02:00
|
|
|
|
}
|
1999-07-07 22:19:36 +02:00
|
|
|
|
|
1999-04-16 03:35:26 +02:00
|
|
|
|
if (TYPE_VOLATILE (type))
|
|
|
|
|
{
|
2001-11-15 02:55:59 +01:00
|
|
|
|
if (did_print_modifier || need_pre_space)
|
1999-07-07 22:19:36 +02:00
|
|
|
|
fprintf_filtered (stream, " ");
|
1999-04-16 03:35:26 +02:00
|
|
|
|
fprintf_filtered (stream, "volatile");
|
2001-11-15 02:55:59 +01:00
|
|
|
|
did_print_modifier = 1;
|
1999-04-16 03:35:26 +02:00
|
|
|
|
}
|
|
|
|
|
|
2013-01-14 21:59:27 +01:00
|
|
|
|
if (TYPE_RESTRICT (type))
|
|
|
|
|
{
|
|
|
|
|
if (did_print_modifier || need_pre_space)
|
|
|
|
|
fprintf_filtered (stream, " ");
|
|
|
|
|
fprintf_filtered (stream, "restrict");
|
|
|
|
|
did_print_modifier = 1;
|
|
|
|
|
}
|
|
|
|
|
|
2015-02-09 14:58:25 +01:00
|
|
|
|
if (TYPE_ATOMIC (type))
|
|
|
|
|
{
|
|
|
|
|
if (did_print_modifier || need_pre_space)
|
|
|
|
|
fprintf_filtered (stream, " ");
|
|
|
|
|
fprintf_filtered (stream, "_Atomic");
|
|
|
|
|
did_print_modifier = 1;
|
|
|
|
|
}
|
|
|
|
|
|
* gdbtypes.c (make_pointer_type, make_reference_type,
smash_to_memberptr_type, lookup_array_range_type, check_stub_method):
Use type architecture instead of current_gdbarch.
* gdbtypes.h (address_space_name_to_int, address_space_int_to_name):
Add GDBARCH paramter.
* gdbtypes.c (address_space_name_to_int, address_space_int_to_name):
Add GDBARCH parameter. Use it instead of current_gdbarch.
* c-typeprint.c (c_type_print_modifier): Update call.
* parse.c (push_type_address_space): Likewise.
* findvar.c (extract_typed_address, store_typed_address): Use type
architecture instead of current_gdbarch.
* value.c (value_as_address, unpack_field_as_long): Use type architecture
instead of current_gdbarch.
* doublest.c (floatformat_from_length): Add GDBARCH argument. Use it
instead of current_gdbarch.
(floatformat_from_type): Pass type architecture.
* infcall.c (find_function_addr): Use type architecture instead
of current_gdbarch.
* valarith.c (value_bitstring_subscript, value_x_binop, value_neg,
value_bit_index): Use type architecture instead of current_gdbarch.
* valops.c (value_cast, value_slice): Likewise.
* value.h (modify_field): Add TYPE argument.
* value.c (modify_field): Add TYPE argument. Use type architecture
instead of current_gdbarch.
(set_internalvar_component): Likewise.
* eval.c (evaluate_struct_tuple): Update call.
* valops.c (value_assign): Likewise.
* ada-lang.c (modify_general_field): Likewise. Add TYPE argument.
(make_array_descriptor): Update calls.
(move_bits): Add BITS_BIG_ENDIAN_P argument. Use it instead of
current_gdbarch.
(ada_value_assign, value_assign_to_component): Update calls.
(decode_packed_array, ada_value_primitive_packed_val, ada_value_assign,
value_assign_to_component): Use type arch instead of current_gdbarch.
* printcmd.c (float_type_from_length): Remove GDBARCH argument,
use type architecture instead.
(print_scalar_formatted, printf_command): Update calls. Use type
architecture instead of current_gdbarch.
* valprint.c (val_print_type_code_int): Use type architecture
instead of current_gdbarch.
* varobj.c (value_get_print_value): Likewise.
* python/python-prettyprint.c (print_string_repr): Add GDBARCH
argument. Use it instead of current_gdbarch.
(apply_val_pretty_printer): Update call.
* ada-valprint.c (ada_val_print_1): Use type architecture instead
of current_gdbarch.
* c-valprint.c (print_function_pointer_address): Add GDBARCH argument.
Use it instead of current_gdbarch.
(c_val_print): Update calls passing type architecture.
* f-valprint.c (f_val_print): Use type architecture instead of
current_gdbarch.
* jv-valprint (java_value_print): Likewise.
* m2-valprint.c (print_function_pointer_address): Add GDBARCH argument.
Use it instead of current_gdbarch.
(print_unpacked_pointer): Update calls passing type architecture.
* scm-valprint.c (scm_scmval_print): Use type architecture instead of
current_gdbarch.
* gnu-v3-abi.c (get_class_arch): Remove.
(gnuv3_rtti_type): Use get_type_arch instead of get_class_arch. Remove
special-case check for Java classes.
(gnuv3_virtual_fn_field, gnuv3_baseclass_offset, gnuv3_print_method_ptr,
gnuv3_method_ptr_size, gnuv3_make_method_ptr, gnuv3_method_ptr_to_value):
Use get_type_arch instead of get_class_arch.
2009-07-02 14:57:14 +02:00
|
|
|
|
address_space_id = address_space_int_to_name (get_type_arch (type),
|
|
|
|
|
TYPE_INSTANCE_FLAGS (type));
|
2001-11-15 02:55:59 +01:00
|
|
|
|
if (address_space_id)
|
|
|
|
|
{
|
|
|
|
|
if (did_print_modifier || need_pre_space)
|
|
|
|
|
fprintf_filtered (stream, " ");
|
|
|
|
|
fprintf_filtered (stream, "@%s", address_space_id);
|
|
|
|
|
did_print_modifier = 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (did_print_modifier && need_post_space)
|
1999-04-16 03:35:26 +02:00
|
|
|
|
fprintf_filtered (stream, " ");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
* NEWS: Mention pointer to member improvements.
* Makefile.in (gnu-v3-abi.o): Delete special rule.
(eval.o, gnu-v3-abi.o, ia64-tdep.o): Update.
* ada-valprint.c (ada_print_scalar): Update for new type codes.
* c-typeprint.c (c_print_type): Update for new type codes.
(c_type_print_varspec_prefix, c_type_print_varspec_suffix)
(c_type_print_base): Likewise.
(c_type_print_args): Rewrite.
* c-valprint.c (c_val_print): Update for new type codes. Remove
support for references to members. Treat methods like functions.
* cp-abi.c (cplus_print_method_ptr, cplus_method_ptr_size)
(cplus_make_method_ptr, cplus_method_ptr_to_value): New.
* cp-abi.h (cplus_print_method_ptr, cplus_method_ptr_size)
(cplus_make_method_ptr, cplus_method_ptr_to_value): New prototypes.
(struct cp_abi_ops): Add corresponding members.
* cp-valprint.c (cp_print_class_method): Delete.
(cp_find_class_member): New function.
(cp_print_class_member): Use it. Simplify support for bogus
member pointers.
* dwarf2read.c (quirk_gcc_member_function_pointer): Use
lookup_methodptr_type.
(read_tag_ptr_to_member_type): Likewise, and lookup_memberptr_type.
* eval.c (evaluate_subexp_standard): Implement EVAL_SKIP for
OP_SCOPE. Update call to value_aggregate_elt. Rewrite member
pointer support.
(evaluate_subexp_for_address): Handle OP_SCOPE explicitly. Handle
references returned by user defined operators.
* f-typeprint.c (f_print_type, f_type_print_varspec_prefix)
(f_type_print_varspec_suffix): Remove support for member pointers.
* gdbtypes.c (lookup_memberptr_type): Renamed from lookup_member_type
and adjusted.
(smash_to_memberptr_type): Likewise, from smash_to_member_type.
(lookup_methodptr_type): New.
(rank_one_type): Adjust for TYPE_CODE_MEMBERPTR.
(recursive_dump_type): Update for new types.
* gdbtypes.h (enum type_code): Replace TYPE_CODE_MEMBER with
TYPE_CODE_MEMBERPTR and TYPE_CODE_METHODPTR.
(lookup_memberptr_type, lookup_methodptr_type)
(smash_to_memberptr_type): New prototypes.
(smash_to_method_type): Formatting fix.
(lookup_member_type, smash_to_member_type): Delete prototypes.
* gnu-v3-abi.c (gnuv3_get_vtable, gnuv3_get_virtual_fn): New.
Do not rely on debug information for the vptr or the method's
enclosing type. Handle function descriptors for IA64.
(gnuv3_virtual_fn_field): Rewrite using the new functions.
(gnuv3_find_method_in, gnuv3_print_method_ptr)
(gnuv3_method_ptr_size, gnuv3_make_method_ptr)
(gnuv3_method_ptr_to_value): New.
(init_gnuv3_ops): Set new members of gnu_v3_abi_ops.
* hpread.c (hpread_type_lookup): Update for new types.
* infcall.c (value_arg_coerce): Likewise.
* m2-typeprint.c (m2_print_type): Remove explicit support
for member pointers.
* m2-valprint.c (m2_val_print): Likewise.
* p-typeprint.c (pascal_type_print_varspec_prefix)
(pascal_type_print_varspec_suffix, pascal_type_print_base): Likewise.
* p-valprint.c (pascal_val_print): Likewise.
(pascal_object_print_class_method, pascal_object_print_class_member):
Delete.
* p-lang.h (pascal_object_print_class_method)
(pascal_object_print_class_member): Delete prototypes.
* stabsread.c (read_type): Update for new types.
* typeprint.c (print_type_scalar): Likewise.
* valops.c (value_struct_elt_for_reference, value_namespace_elt)
(value_maybe_namespace_elt, value_aggregate_elt): Add want_address
argument. Construct a pointer to member if the address of a
function or data member is requested.
(value_cast_pointers): Don't modify the input value.
(value_cast): Adjust pointer to member handling for new types.
Allow null pointer to member constants. Don't modify the input
value.
(value_ind): Remove pointer to member check. Handle function
descriptors for function pointers.
(value_struct_elt, value_find_oload_method_list, check_field):
Remove pointer to member checks.
* value.c (unpack_long): Allow pointers to data members.
(value_from_longest): Allow member pointers.
* value.h (value_aggregate_elt): Add want_address.
* varobj.c (c_variable_editable): Remove check for members.
* gdbarch.sh: Add vtable_function_descriptors and vbit_in_delta.
* ia64-tdep.c (ia64_convert_from_func_ptr_addr): Handle descriptors
in virtual tables.
(ia64_gdbarch_init): Call set_gdbarch_vtable_function_descriptors.
* c-lang.h (cp_print_class_method): Delete prototype.
* arm-tdep.c (arm_gdbarch_init): Call set_gdbarch_vbit_in_delta.
* mips-tdep.c (mips_gdbarch_init): Likewise.
* gdbarch.c, gdbarch.h: Regenerated.
* gdb.cp/classes.exp (test_pointers_to_class_members): Update expected
output. Test the types of members and member pointers.
* gdb.cp/inherit.exp (test_print_mi_member_types): Remove KFAILs for
gdb/2092.
* gdb.cp/member-ptr.exp: Search for a comment instead of a
statement. Enable for GCC. Update expected output for some tests
and add new tests. Remove obsolete GCC KFAILs. Allow GCC's class
layout.
* gdb.cp/member-ptr.cc (Padding, Padding::vspacer, Base, Base::get_x)
(Base::vget_base, Left, Left::vget, Right, Right::vget, Diamond)
(Diamond::vget_base): New.
(main): Add new tests.
* gdb.cp/printmethod.exp: Update expected output for member functions.
* gdb.cp/virtfunc.exp (test_virtual_calls): Add a KFAIL for
print pEe->D::vg().
2007-01-03 19:05:45 +01:00
|
|
|
|
/* Print out the arguments of TYPE, which should have TYPE_CODE_METHOD
|
|
|
|
|
or TYPE_CODE_FUNC, to STREAM. Artificial arguments, such as "this"
|
2011-03-22 18:35:22 +01:00
|
|
|
|
in non-static methods, are displayed if LINKAGE_NAME is zero. If
|
|
|
|
|
LINKAGE_NAME is non-zero and LANGUAGE is language_cplus the topmost
|
|
|
|
|
parameter types get removed their possible const and volatile qualifiers to
|
|
|
|
|
match demangled linkage name parameters part of such function type.
|
|
|
|
|
LANGUAGE is the language in which TYPE was defined. This is a necessary
|
Remove Java support
This patch removes the Java support from gdb. gcj has not seen much
development or use for years now, and was recently removed from GCC.
This patch changes gdb to follow; in the unlikely event that there are
still users using gcj, they can continue to use an older gdb to debug.
Or, they can debug in C++ mode.
Built and regtested on x86-64 Fedora 24.
2016-10-06 Tom Tromey <tom@tromey.com>
* MAINTAINERS: Remove Java test maintainer.
* varobj.h (java_varobj_ops): Don't declare.
* valprint.h (struct value_print_options)
<pascal_static_field_print>: Update comment.
* utils.c (producer_is_gcc): Remove java reference.
* symtab.h (struct general_symbol_info): Remove java references.
(SYMBOL_SEARCH_NAME): Likewise.
* objfiles.c (allocate_objfile): Update comment.
* linespec.c (find_linespec_symbols): Remove java references.
* gnu-v3-abi.c (gnuv3_rtti_type, gnuv3_baseclass_offset): Remove
java references.
* gdbtypes.h (struct cplus_struct_type) <is_java>: Remove.
(TYPE_CPLUS_REALLY_JAVA): Remove.
* c-varobj.c (enum vsections): Update comment.
* symtab.c (symbol_set_language, symbol_set_names)
(symbol_natural_name, symbol_demangled_name)
(demangle_for_lookup, symbol_matches_domain)
(default_make_symbol_completion_list_break_on_1): Remove java
references.
(JAVA_PREFIX, JAVA_PREFIX_LEN): Remove.
* psymtab.c (match_partial_symbol, psymtab_search_name)
(lookup_partial_symbol): Remove java references.
* dwarf2read.c (find_slot_in_mapped_hash): Remove java references.
(add_partial_symbol, dwarf2_compute_name, dwarf2_physname)
(dwarf2_add_member_fn, is_vtable_name, read_structure_type)
(process_structure_scope, read_subroutine_type)
(read_subrange_type, load_partial_dies)
(new_symbol_full, determine_prefix, typename_concat)
(dwarf2_name): Remove java references.
(set_cu_language): Treat Java as C++.
* c-typeprint.c (c_type_print_args): Remove java reference.
* defs.h (enum language) <language_java>: Remove.
* Makefile.in (SFILES, HFILES_NO_SRCDIR, COMMON_OBS, YYFILES)
(YYOBJ, local-maintainer-clean): Don't mention java files.
* jv-exp.y, jv-lang.c, jv-lang.h, jv-typeprint.c, jv-valprint.c,
jv-varobj.c: Remove.
2016-10-06 Tom Tromey <tom@tromey.com>
* guile.texi (Types In Guile): Remove Java mentions.
* python.texi (Types In Python): Remove Java mentions.
* gdb.texinfo (Address Locations, Supported Languages)
(Index Section Format): Remove Java mentions.
2016-10-06 Tom Tromey <tom@tromey.com>
* gdb.compile/compile.exp: Change java tests to rust.
* gdb.base/setshow.exp: Change java tests to rust.
* gdb.base/default.exp: Remove java from language list.
* README (Examples): Update language example.
* gdb.python/py-lookup-type.exp (test_lookup_type): Remove java
test.
* lib/gdb.exp (skip_java_tests): Remove.
* lib/java.exp: Remove.
* gdb.java: Remove.
2016-10-05 16:44:34 +02:00
|
|
|
|
evil since this code is used by the C and C++. */
|
1999-04-16 03:35:26 +02:00
|
|
|
|
|
dwarf2_physname patchset:
Based on work from Daniel Jacobowitz <dan@codesourcery.com>
* c-typeprint.c (cp_type_print_method_args): For non-static methods,
print out const or volatile qualifiers, too.
(c_type_print_args): Add parameters show_artificial and language.
Skip artificial parameters when requested.
Use the appropriate language printer.
(c_type_print_varspec): Tell c_type_print_args to skip artificial
parameters and pass language_c.
* dwarf2read.c (die_list): New file global.
(struct partial_die_info): Update comments for name field.
(pdi_needs_namespace): Renamed to ...
(die_needs_namespace): ... this. Rewrite.
(dwarf2_linkage_name): Remove.
(add_partial_symbol): Do not predicate the call to
partial_die_full_name based on pdi_needs_namespace.
Remove call to cp_check_possible_namespace_symbols and associated
outdated comments.
(guess_structure_name): Do not inspect child subprogram DIEs.
(dwarf2_fullname): Update comments.
Use die_needs_namespace to assist in computing the name.
(read_func_scope): Use dwarf2_name to get the DIE's name.
Use dwarf2_physname to get the "linkage name" of the DIE.
(dwarf2_add_member_field): Use dwarf2_physname instead of
dwarf2_linkage_name.
(read_structure_type): For structs and classes, set TYPE_NAME, too.
(determine_class): Remove.
(read_partial_die): Ignore DW_AT_MIPS_linkage_name for all languages
except Ada.
(new_symbol): Unconditionally call dwarf2_name.
Compute the "linkage name" using dwarf2_physname.
Use dwarf2_name instead of dwarf2_full_name for enumerator DIEs.
When determining to scan for anonymous C++ namespaces, ignore
the linkage name.
(dwarf2_physname): New function.
(dwarf2_full_name): Move content to new function and call
that.
(dwarf2_compute_name): "New" function.
(_initialize_dwarf2_read): Initialize die_list.
* gnu-v3-eabi.c (gnu_v3_find_method_in): Remove unused variable
physname.
(gnu_v3_print_method_ptr): Use the physname for virtual methods
without a demangled name.
Print out type information for non-virtual methods.
* linespec.c (decode_line_1): Force ANY string using "::" (or
"." for java) to use decode_compound, and clean up any stray quoting.
If we found a file symtab, re-evaluate whether the remainder is_quoted.
(decode_compound): Stop consuming at an open parenthesis.
Keep template parameters.
Keep any overload information.
Keep keywords like "const".
Remove paren_pointer.
Move is_quoted check from set_flags to here.
Remove #if 0 code from 2000. Ten years is long enough.
(find_method): Before comparing symbol names, canonicalize the string
from the user.
If a specific overload is requested, find it. Otherwise throw an error.
(find_method_overload_end): New function.
(set_flags): Remove.
(decode_compound): Assume that parentheses are matched.
It's a lot easier.
* symtab.c (symbol_find_demangled_name): Add DMGL_VERBOSE flag
to cplus_demangle.
* linespec.c (decode_line_1): Keep important keywords like
"const" and "volatile".
* symtab.h (SYMBOL_CPLUS_DEMANGLED_NAME): Remove.
* typeprint.h (c_type_print_args): Add declaration.
* ui-file.c (do_ui_file_obsavestring): New function.
(ui_file_obsavestring): New function.
* ui-file.h (ui_file_obsavestring): Add declaration.
* valops.c (find_overload_match): Resolve the object to
a non-pointer type.
If the object is a data member, search the object for the member
and return with staticp set.
Use SYMBOL_NATURAL_NAME instead of SYMBOL_CPLUS_DEMANGLED_NAME.
Do not attempt to extract a function name from non-function types.
If the extracted function name and the original name are the same,
we don't have a C++ method.
From Jan Kratochvil <jan.kratochvil@redhat.com>:
* dwarf2read.c (new_symbol <DW_TAG_enumerator>): Call dwarf2_full_name.
* ada-lang.c (ada_lookup_symbol): Remove linkage_name parameters
and arguments from symbol lookups.
* ax-gdb.c (gen_expr): Likewise.
* cp-namespace.c (cp_lookup_symbol_nonlocal, lookup_namespace_scope,
cp_lookup_symbol_namespace, lookup_symbol_file, lookup_nested_type,
lookup_possible_namespace_symbol): Likewise.
* cp-support.c (read_in_psymtabs): Likewise.
* cp-support.h (cp_lookup_symbol_nonlocal): Likewise.
* language.h (la_lookup_symbol_nonlocal): Likewise.
* scm-valprint.c (scm_inferior_print): Likewise.
* solib-darwin.c (darwin_relocate_section_addresses): Likewise.
* solib-svr.c (elf_lookup_lib): Likewise.
* solib.c (show_auto_solib_add): Likewise.
* solist.h (lookup_lib_global, solib_global_lookup): Likewise.
* symmisc.c (maintenance_check_symtabs): Likewise.
* symtab.c (lookup_symbol_in_language, lookup_symbol_aux,
lookup_symbol_aux_local, lookup_symbol_aux_block,
lookup_symbol_from_objfile, lookup_symbol_aux_symtabs,
lookup_symbol_aux_psymtabs,basic_lookup_symbol_nonlocal,
lookup_symbol_static, lookup_symbol_global, symbol_matches_domain,
basic_lookup_transparent_type, find_main_psymtab,
lookup_block_symbol): Likewise.
* symtab.h (basic_lookp_symbol_nonlocal, lookup_symbol_static,
lookup_symbol_global, lookup_symbol_aux_block,
lookup_symbol_partial_symbol, lookup_block_symbol,
lookup_global_symbol, value_maybe_namespace_elt): Likewise.
2010-03-09 19:09:08 +01:00
|
|
|
|
void
|
|
|
|
|
c_type_print_args (struct type *type, struct ui_file *stream,
|
* ada-lang.c (user_select_syms, ada_print_subexp): Pass flags
to type-printing functions.
* ada-lang.h (ada_print_type): Add argument.
* ada-typeprint.c (print_array_type, print_variant_clauses,
print_variant_part, print_selected_record_field_types,
print_record_field_types, print_unchecked_union_type,
print_func_type, ada_print_type): Add flags argument.
(ada_print_typedef): Update.
* c-exp.y (OPERATOR conversion_type_id): Update.
* c-lang.h (c_print_type, c_type_print_base): Update.
* c-typeprint.c (c_print_type, c_type_print_varspec_prefix,
c_type_print_modifier, c_type_print_args,
c_type_print_varspec_suffix, c_type_print_base): Add flags
argument.
* cp-valprint.c (cp_print_class_member): Update.
* dwarf2read.c (dwarf2_compute_name): Update.
* f-lang.h (f_print_type): Add argument.
* f-typeprint.c (f_print_type): Add flags argument.
* gnu-v3-abi.c (gnuv3_print_method_ptr): Update.
* go-lang.h (go_print_type): Add argument.
* go-typeprint.c (go_print_type): Add flags argument.
* jv-lang.h (java_print_type): Add argument.
* jv-typeprint.c (java_type_print_base, java_print_type): Add
flags argument.
* language.c (unk_lang_print_type): Add flags argument.
* language.h (struct language_defn) <la_print_type>: Add flags
argument.
(LA_PRINT_TYPE): Likewise.
* m2-lang.h (m2_print_type): Add argument.
* m2-typeprint.c (m2_print_type, m2_range, m2_typedef,
m2_array, m2_pointer, m2_ref, m2_procedure, m2_long_set,
m2_unbounded_array, m2_record_fields): Add flags argument.
* p-lang.h (pascal_print_type, pascal_type_print_base,
pascal_type_print_varspec_prefix): Add argument.
* p-typeprint.c (pascal_print_type,
pascal_type_print_varspec_prefix, pascal_print_func_args,
pascal_type_print_varspec_suffix, pascal_type_print_base): Add
flags argument.
* symmisc.c (print_symbol): Update.
* typeprint.c (type_print_raw_options, default_ptype_flags):
New globals.
(type_print): Update.
* typeprint.h (struct type_print_options): New.
(type_print_raw_options): Declare.
(c_type_print_varspec_suffix, c_type_print_args): Add argument.
2012-11-12 18:14:55 +01:00
|
|
|
|
int linkage_name, enum language language,
|
|
|
|
|
const struct type_print_options *flags)
|
1999-04-16 03:35:26 +02:00
|
|
|
|
{
|
2013-01-31 Aleksandar Ristovski <aristovski@qnx.com>
* c-exp.y (classify_inner_name): Remove unused type.
* c-lang.c (c_printstr): Remove unused byte_order, i, things_printed,
in_quotes, need_comma, wchar_buf, output, cleanup, iter, finished,
need_escape.
(c_get_string): Remove unused kind.
* c-typeprint.c (c_type_print_args): Remove unused i, len, args, table2.
Reference: http://sourceware.org/ml/gdb-patches/2013-01/msg00759.html
2013-01-31 19:46:11 +01:00
|
|
|
|
int i;
|
* NEWS: Mention pointer to member improvements.
* Makefile.in (gnu-v3-abi.o): Delete special rule.
(eval.o, gnu-v3-abi.o, ia64-tdep.o): Update.
* ada-valprint.c (ada_print_scalar): Update for new type codes.
* c-typeprint.c (c_print_type): Update for new type codes.
(c_type_print_varspec_prefix, c_type_print_varspec_suffix)
(c_type_print_base): Likewise.
(c_type_print_args): Rewrite.
* c-valprint.c (c_val_print): Update for new type codes. Remove
support for references to members. Treat methods like functions.
* cp-abi.c (cplus_print_method_ptr, cplus_method_ptr_size)
(cplus_make_method_ptr, cplus_method_ptr_to_value): New.
* cp-abi.h (cplus_print_method_ptr, cplus_method_ptr_size)
(cplus_make_method_ptr, cplus_method_ptr_to_value): New prototypes.
(struct cp_abi_ops): Add corresponding members.
* cp-valprint.c (cp_print_class_method): Delete.
(cp_find_class_member): New function.
(cp_print_class_member): Use it. Simplify support for bogus
member pointers.
* dwarf2read.c (quirk_gcc_member_function_pointer): Use
lookup_methodptr_type.
(read_tag_ptr_to_member_type): Likewise, and lookup_memberptr_type.
* eval.c (evaluate_subexp_standard): Implement EVAL_SKIP for
OP_SCOPE. Update call to value_aggregate_elt. Rewrite member
pointer support.
(evaluate_subexp_for_address): Handle OP_SCOPE explicitly. Handle
references returned by user defined operators.
* f-typeprint.c (f_print_type, f_type_print_varspec_prefix)
(f_type_print_varspec_suffix): Remove support for member pointers.
* gdbtypes.c (lookup_memberptr_type): Renamed from lookup_member_type
and adjusted.
(smash_to_memberptr_type): Likewise, from smash_to_member_type.
(lookup_methodptr_type): New.
(rank_one_type): Adjust for TYPE_CODE_MEMBERPTR.
(recursive_dump_type): Update for new types.
* gdbtypes.h (enum type_code): Replace TYPE_CODE_MEMBER with
TYPE_CODE_MEMBERPTR and TYPE_CODE_METHODPTR.
(lookup_memberptr_type, lookup_methodptr_type)
(smash_to_memberptr_type): New prototypes.
(smash_to_method_type): Formatting fix.
(lookup_member_type, smash_to_member_type): Delete prototypes.
* gnu-v3-abi.c (gnuv3_get_vtable, gnuv3_get_virtual_fn): New.
Do not rely on debug information for the vptr or the method's
enclosing type. Handle function descriptors for IA64.
(gnuv3_virtual_fn_field): Rewrite using the new functions.
(gnuv3_find_method_in, gnuv3_print_method_ptr)
(gnuv3_method_ptr_size, gnuv3_make_method_ptr)
(gnuv3_method_ptr_to_value): New.
(init_gnuv3_ops): Set new members of gnu_v3_abi_ops.
* hpread.c (hpread_type_lookup): Update for new types.
* infcall.c (value_arg_coerce): Likewise.
* m2-typeprint.c (m2_print_type): Remove explicit support
for member pointers.
* m2-valprint.c (m2_val_print): Likewise.
* p-typeprint.c (pascal_type_print_varspec_prefix)
(pascal_type_print_varspec_suffix, pascal_type_print_base): Likewise.
* p-valprint.c (pascal_val_print): Likewise.
(pascal_object_print_class_method, pascal_object_print_class_member):
Delete.
* p-lang.h (pascal_object_print_class_method)
(pascal_object_print_class_member): Delete prototypes.
* stabsread.c (read_type): Update for new types.
* typeprint.c (print_type_scalar): Likewise.
* valops.c (value_struct_elt_for_reference, value_namespace_elt)
(value_maybe_namespace_elt, value_aggregate_elt): Add want_address
argument. Construct a pointer to member if the address of a
function or data member is requested.
(value_cast_pointers): Don't modify the input value.
(value_cast): Adjust pointer to member handling for new types.
Allow null pointer to member constants. Don't modify the input
value.
(value_ind): Remove pointer to member check. Handle function
descriptors for function pointers.
(value_struct_elt, value_find_oload_method_list, check_field):
Remove pointer to member checks.
* value.c (unpack_long): Allow pointers to data members.
(value_from_longest): Allow member pointers.
* value.h (value_aggregate_elt): Add want_address.
* varobj.c (c_variable_editable): Remove check for members.
* gdbarch.sh: Add vtable_function_descriptors and vbit_in_delta.
* ia64-tdep.c (ia64_convert_from_func_ptr_addr): Handle descriptors
in virtual tables.
(ia64_gdbarch_init): Call set_gdbarch_vtable_function_descriptors.
* c-lang.h (cp_print_class_method): Delete prototype.
* arm-tdep.c (arm_gdbarch_init): Call set_gdbarch_vbit_in_delta.
* mips-tdep.c (mips_gdbarch_init): Likewise.
* gdbarch.c, gdbarch.h: Regenerated.
* gdb.cp/classes.exp (test_pointers_to_class_members): Update expected
output. Test the types of members and member pointers.
* gdb.cp/inherit.exp (test_print_mi_member_types): Remove KFAILs for
gdb/2092.
* gdb.cp/member-ptr.exp: Search for a comment instead of a
statement. Enable for GCC. Update expected output for some tests
and add new tests. Remove obsolete GCC KFAILs. Allow GCC's class
layout.
* gdb.cp/member-ptr.cc (Padding, Padding::vspacer, Base, Base::get_x)
(Base::vget_base, Left, Left::vget, Right, Right::vget, Diamond)
(Diamond::vget_base): New.
(main): Add new tests.
* gdb.cp/printmethod.exp: Update expected output for member functions.
* gdb.cp/virtfunc.exp (test_virtual_calls): Add a KFAIL for
print pEe->D::vg().
2007-01-03 19:05:45 +01:00
|
|
|
|
int printed_any = 0;
|
1999-04-16 03:35:26 +02:00
|
|
|
|
|
|
|
|
|
fprintf_filtered (stream, "(");
|
2002-06-14 16:34:26 +02:00
|
|
|
|
|
* NEWS: Mention pointer to member improvements.
* Makefile.in (gnu-v3-abi.o): Delete special rule.
(eval.o, gnu-v3-abi.o, ia64-tdep.o): Update.
* ada-valprint.c (ada_print_scalar): Update for new type codes.
* c-typeprint.c (c_print_type): Update for new type codes.
(c_type_print_varspec_prefix, c_type_print_varspec_suffix)
(c_type_print_base): Likewise.
(c_type_print_args): Rewrite.
* c-valprint.c (c_val_print): Update for new type codes. Remove
support for references to members. Treat methods like functions.
* cp-abi.c (cplus_print_method_ptr, cplus_method_ptr_size)
(cplus_make_method_ptr, cplus_method_ptr_to_value): New.
* cp-abi.h (cplus_print_method_ptr, cplus_method_ptr_size)
(cplus_make_method_ptr, cplus_method_ptr_to_value): New prototypes.
(struct cp_abi_ops): Add corresponding members.
* cp-valprint.c (cp_print_class_method): Delete.
(cp_find_class_member): New function.
(cp_print_class_member): Use it. Simplify support for bogus
member pointers.
* dwarf2read.c (quirk_gcc_member_function_pointer): Use
lookup_methodptr_type.
(read_tag_ptr_to_member_type): Likewise, and lookup_memberptr_type.
* eval.c (evaluate_subexp_standard): Implement EVAL_SKIP for
OP_SCOPE. Update call to value_aggregate_elt. Rewrite member
pointer support.
(evaluate_subexp_for_address): Handle OP_SCOPE explicitly. Handle
references returned by user defined operators.
* f-typeprint.c (f_print_type, f_type_print_varspec_prefix)
(f_type_print_varspec_suffix): Remove support for member pointers.
* gdbtypes.c (lookup_memberptr_type): Renamed from lookup_member_type
and adjusted.
(smash_to_memberptr_type): Likewise, from smash_to_member_type.
(lookup_methodptr_type): New.
(rank_one_type): Adjust for TYPE_CODE_MEMBERPTR.
(recursive_dump_type): Update for new types.
* gdbtypes.h (enum type_code): Replace TYPE_CODE_MEMBER with
TYPE_CODE_MEMBERPTR and TYPE_CODE_METHODPTR.
(lookup_memberptr_type, lookup_methodptr_type)
(smash_to_memberptr_type): New prototypes.
(smash_to_method_type): Formatting fix.
(lookup_member_type, smash_to_member_type): Delete prototypes.
* gnu-v3-abi.c (gnuv3_get_vtable, gnuv3_get_virtual_fn): New.
Do not rely on debug information for the vptr or the method's
enclosing type. Handle function descriptors for IA64.
(gnuv3_virtual_fn_field): Rewrite using the new functions.
(gnuv3_find_method_in, gnuv3_print_method_ptr)
(gnuv3_method_ptr_size, gnuv3_make_method_ptr)
(gnuv3_method_ptr_to_value): New.
(init_gnuv3_ops): Set new members of gnu_v3_abi_ops.
* hpread.c (hpread_type_lookup): Update for new types.
* infcall.c (value_arg_coerce): Likewise.
* m2-typeprint.c (m2_print_type): Remove explicit support
for member pointers.
* m2-valprint.c (m2_val_print): Likewise.
* p-typeprint.c (pascal_type_print_varspec_prefix)
(pascal_type_print_varspec_suffix, pascal_type_print_base): Likewise.
* p-valprint.c (pascal_val_print): Likewise.
(pascal_object_print_class_method, pascal_object_print_class_member):
Delete.
* p-lang.h (pascal_object_print_class_method)
(pascal_object_print_class_member): Delete prototypes.
* stabsread.c (read_type): Update for new types.
* typeprint.c (print_type_scalar): Likewise.
* valops.c (value_struct_elt_for_reference, value_namespace_elt)
(value_maybe_namespace_elt, value_aggregate_elt): Add want_address
argument. Construct a pointer to member if the address of a
function or data member is requested.
(value_cast_pointers): Don't modify the input value.
(value_cast): Adjust pointer to member handling for new types.
Allow null pointer to member constants. Don't modify the input
value.
(value_ind): Remove pointer to member check. Handle function
descriptors for function pointers.
(value_struct_elt, value_find_oload_method_list, check_field):
Remove pointer to member checks.
* value.c (unpack_long): Allow pointers to data members.
(value_from_longest): Allow member pointers.
* value.h (value_aggregate_elt): Add want_address.
* varobj.c (c_variable_editable): Remove check for members.
* gdbarch.sh: Add vtable_function_descriptors and vbit_in_delta.
* ia64-tdep.c (ia64_convert_from_func_ptr_addr): Handle descriptors
in virtual tables.
(ia64_gdbarch_init): Call set_gdbarch_vtable_function_descriptors.
* c-lang.h (cp_print_class_method): Delete prototype.
* arm-tdep.c (arm_gdbarch_init): Call set_gdbarch_vbit_in_delta.
* mips-tdep.c (mips_gdbarch_init): Likewise.
* gdbarch.c, gdbarch.h: Regenerated.
* gdb.cp/classes.exp (test_pointers_to_class_members): Update expected
output. Test the types of members and member pointers.
* gdb.cp/inherit.exp (test_print_mi_member_types): Remove KFAILs for
gdb/2092.
* gdb.cp/member-ptr.exp: Search for a comment instead of a
statement. Enable for GCC. Update expected output for some tests
and add new tests. Remove obsolete GCC KFAILs. Allow GCC's class
layout.
* gdb.cp/member-ptr.cc (Padding, Padding::vspacer, Base, Base::get_x)
(Base::vget_base, Left, Left::vget, Right, Right::vget, Diamond)
(Diamond::vget_base): New.
(main): Add new tests.
* gdb.cp/printmethod.exp: Update expected output for member functions.
* gdb.cp/virtfunc.exp (test_virtual_calls): Add a KFAIL for
print pEe->D::vg().
2007-01-03 19:05:45 +01:00
|
|
|
|
for (i = 0; i < TYPE_NFIELDS (type); i++)
|
|
|
|
|
{
|
2011-02-13 10:15:54 +01:00
|
|
|
|
struct type *param_type;
|
|
|
|
|
|
2011-03-22 18:35:22 +01:00
|
|
|
|
if (TYPE_FIELD_ARTIFICIAL (type, i) && linkage_name)
|
dwarf2_physname patchset:
Based on work from Daniel Jacobowitz <dan@codesourcery.com>
* c-typeprint.c (cp_type_print_method_args): For non-static methods,
print out const or volatile qualifiers, too.
(c_type_print_args): Add parameters show_artificial and language.
Skip artificial parameters when requested.
Use the appropriate language printer.
(c_type_print_varspec): Tell c_type_print_args to skip artificial
parameters and pass language_c.
* dwarf2read.c (die_list): New file global.
(struct partial_die_info): Update comments for name field.
(pdi_needs_namespace): Renamed to ...
(die_needs_namespace): ... this. Rewrite.
(dwarf2_linkage_name): Remove.
(add_partial_symbol): Do not predicate the call to
partial_die_full_name based on pdi_needs_namespace.
Remove call to cp_check_possible_namespace_symbols and associated
outdated comments.
(guess_structure_name): Do not inspect child subprogram DIEs.
(dwarf2_fullname): Update comments.
Use die_needs_namespace to assist in computing the name.
(read_func_scope): Use dwarf2_name to get the DIE's name.
Use dwarf2_physname to get the "linkage name" of the DIE.
(dwarf2_add_member_field): Use dwarf2_physname instead of
dwarf2_linkage_name.
(read_structure_type): For structs and classes, set TYPE_NAME, too.
(determine_class): Remove.
(read_partial_die): Ignore DW_AT_MIPS_linkage_name for all languages
except Ada.
(new_symbol): Unconditionally call dwarf2_name.
Compute the "linkage name" using dwarf2_physname.
Use dwarf2_name instead of dwarf2_full_name for enumerator DIEs.
When determining to scan for anonymous C++ namespaces, ignore
the linkage name.
(dwarf2_physname): New function.
(dwarf2_full_name): Move content to new function and call
that.
(dwarf2_compute_name): "New" function.
(_initialize_dwarf2_read): Initialize die_list.
* gnu-v3-eabi.c (gnu_v3_find_method_in): Remove unused variable
physname.
(gnu_v3_print_method_ptr): Use the physname for virtual methods
without a demangled name.
Print out type information for non-virtual methods.
* linespec.c (decode_line_1): Force ANY string using "::" (or
"." for java) to use decode_compound, and clean up any stray quoting.
If we found a file symtab, re-evaluate whether the remainder is_quoted.
(decode_compound): Stop consuming at an open parenthesis.
Keep template parameters.
Keep any overload information.
Keep keywords like "const".
Remove paren_pointer.
Move is_quoted check from set_flags to here.
Remove #if 0 code from 2000. Ten years is long enough.
(find_method): Before comparing symbol names, canonicalize the string
from the user.
If a specific overload is requested, find it. Otherwise throw an error.
(find_method_overload_end): New function.
(set_flags): Remove.
(decode_compound): Assume that parentheses are matched.
It's a lot easier.
* symtab.c (symbol_find_demangled_name): Add DMGL_VERBOSE flag
to cplus_demangle.
* linespec.c (decode_line_1): Keep important keywords like
"const" and "volatile".
* symtab.h (SYMBOL_CPLUS_DEMANGLED_NAME): Remove.
* typeprint.h (c_type_print_args): Add declaration.
* ui-file.c (do_ui_file_obsavestring): New function.
(ui_file_obsavestring): New function.
* ui-file.h (ui_file_obsavestring): Add declaration.
* valops.c (find_overload_match): Resolve the object to
a non-pointer type.
If the object is a data member, search the object for the member
and return with staticp set.
Use SYMBOL_NATURAL_NAME instead of SYMBOL_CPLUS_DEMANGLED_NAME.
Do not attempt to extract a function name from non-function types.
If the extracted function name and the original name are the same,
we don't have a C++ method.
From Jan Kratochvil <jan.kratochvil@redhat.com>:
* dwarf2read.c (new_symbol <DW_TAG_enumerator>): Call dwarf2_full_name.
* ada-lang.c (ada_lookup_symbol): Remove linkage_name parameters
and arguments from symbol lookups.
* ax-gdb.c (gen_expr): Likewise.
* cp-namespace.c (cp_lookup_symbol_nonlocal, lookup_namespace_scope,
cp_lookup_symbol_namespace, lookup_symbol_file, lookup_nested_type,
lookup_possible_namespace_symbol): Likewise.
* cp-support.c (read_in_psymtabs): Likewise.
* cp-support.h (cp_lookup_symbol_nonlocal): Likewise.
* language.h (la_lookup_symbol_nonlocal): Likewise.
* scm-valprint.c (scm_inferior_print): Likewise.
* solib-darwin.c (darwin_relocate_section_addresses): Likewise.
* solib-svr.c (elf_lookup_lib): Likewise.
* solib.c (show_auto_solib_add): Likewise.
* solist.h (lookup_lib_global, solib_global_lookup): Likewise.
* symmisc.c (maintenance_check_symtabs): Likewise.
* symtab.c (lookup_symbol_in_language, lookup_symbol_aux,
lookup_symbol_aux_local, lookup_symbol_aux_block,
lookup_symbol_from_objfile, lookup_symbol_aux_symtabs,
lookup_symbol_aux_psymtabs,basic_lookup_symbol_nonlocal,
lookup_symbol_static, lookup_symbol_global, symbol_matches_domain,
basic_lookup_transparent_type, find_main_psymtab,
lookup_block_symbol): Likewise.
* symtab.h (basic_lookp_symbol_nonlocal, lookup_symbol_static,
lookup_symbol_global, lookup_symbol_aux_block,
lookup_symbol_partial_symbol, lookup_block_symbol,
lookup_global_symbol, value_maybe_namespace_elt): Likewise.
2010-03-09 19:09:08 +01:00
|
|
|
|
continue;
|
|
|
|
|
|
* NEWS: Mention pointer to member improvements.
* Makefile.in (gnu-v3-abi.o): Delete special rule.
(eval.o, gnu-v3-abi.o, ia64-tdep.o): Update.
* ada-valprint.c (ada_print_scalar): Update for new type codes.
* c-typeprint.c (c_print_type): Update for new type codes.
(c_type_print_varspec_prefix, c_type_print_varspec_suffix)
(c_type_print_base): Likewise.
(c_type_print_args): Rewrite.
* c-valprint.c (c_val_print): Update for new type codes. Remove
support for references to members. Treat methods like functions.
* cp-abi.c (cplus_print_method_ptr, cplus_method_ptr_size)
(cplus_make_method_ptr, cplus_method_ptr_to_value): New.
* cp-abi.h (cplus_print_method_ptr, cplus_method_ptr_size)
(cplus_make_method_ptr, cplus_method_ptr_to_value): New prototypes.
(struct cp_abi_ops): Add corresponding members.
* cp-valprint.c (cp_print_class_method): Delete.
(cp_find_class_member): New function.
(cp_print_class_member): Use it. Simplify support for bogus
member pointers.
* dwarf2read.c (quirk_gcc_member_function_pointer): Use
lookup_methodptr_type.
(read_tag_ptr_to_member_type): Likewise, and lookup_memberptr_type.
* eval.c (evaluate_subexp_standard): Implement EVAL_SKIP for
OP_SCOPE. Update call to value_aggregate_elt. Rewrite member
pointer support.
(evaluate_subexp_for_address): Handle OP_SCOPE explicitly. Handle
references returned by user defined operators.
* f-typeprint.c (f_print_type, f_type_print_varspec_prefix)
(f_type_print_varspec_suffix): Remove support for member pointers.
* gdbtypes.c (lookup_memberptr_type): Renamed from lookup_member_type
and adjusted.
(smash_to_memberptr_type): Likewise, from smash_to_member_type.
(lookup_methodptr_type): New.
(rank_one_type): Adjust for TYPE_CODE_MEMBERPTR.
(recursive_dump_type): Update for new types.
* gdbtypes.h (enum type_code): Replace TYPE_CODE_MEMBER with
TYPE_CODE_MEMBERPTR and TYPE_CODE_METHODPTR.
(lookup_memberptr_type, lookup_methodptr_type)
(smash_to_memberptr_type): New prototypes.
(smash_to_method_type): Formatting fix.
(lookup_member_type, smash_to_member_type): Delete prototypes.
* gnu-v3-abi.c (gnuv3_get_vtable, gnuv3_get_virtual_fn): New.
Do not rely on debug information for the vptr or the method's
enclosing type. Handle function descriptors for IA64.
(gnuv3_virtual_fn_field): Rewrite using the new functions.
(gnuv3_find_method_in, gnuv3_print_method_ptr)
(gnuv3_method_ptr_size, gnuv3_make_method_ptr)
(gnuv3_method_ptr_to_value): New.
(init_gnuv3_ops): Set new members of gnu_v3_abi_ops.
* hpread.c (hpread_type_lookup): Update for new types.
* infcall.c (value_arg_coerce): Likewise.
* m2-typeprint.c (m2_print_type): Remove explicit support
for member pointers.
* m2-valprint.c (m2_val_print): Likewise.
* p-typeprint.c (pascal_type_print_varspec_prefix)
(pascal_type_print_varspec_suffix, pascal_type_print_base): Likewise.
* p-valprint.c (pascal_val_print): Likewise.
(pascal_object_print_class_method, pascal_object_print_class_member):
Delete.
* p-lang.h (pascal_object_print_class_method)
(pascal_object_print_class_member): Delete prototypes.
* stabsread.c (read_type): Update for new types.
* typeprint.c (print_type_scalar): Likewise.
* valops.c (value_struct_elt_for_reference, value_namespace_elt)
(value_maybe_namespace_elt, value_aggregate_elt): Add want_address
argument. Construct a pointer to member if the address of a
function or data member is requested.
(value_cast_pointers): Don't modify the input value.
(value_cast): Adjust pointer to member handling for new types.
Allow null pointer to member constants. Don't modify the input
value.
(value_ind): Remove pointer to member check. Handle function
descriptors for function pointers.
(value_struct_elt, value_find_oload_method_list, check_field):
Remove pointer to member checks.
* value.c (unpack_long): Allow pointers to data members.
(value_from_longest): Allow member pointers.
* value.h (value_aggregate_elt): Add want_address.
* varobj.c (c_variable_editable): Remove check for members.
* gdbarch.sh: Add vtable_function_descriptors and vbit_in_delta.
* ia64-tdep.c (ia64_convert_from_func_ptr_addr): Handle descriptors
in virtual tables.
(ia64_gdbarch_init): Call set_gdbarch_vtable_function_descriptors.
* c-lang.h (cp_print_class_method): Delete prototype.
* arm-tdep.c (arm_gdbarch_init): Call set_gdbarch_vbit_in_delta.
* mips-tdep.c (mips_gdbarch_init): Likewise.
* gdbarch.c, gdbarch.h: Regenerated.
* gdb.cp/classes.exp (test_pointers_to_class_members): Update expected
output. Test the types of members and member pointers.
* gdb.cp/inherit.exp (test_print_mi_member_types): Remove KFAILs for
gdb/2092.
* gdb.cp/member-ptr.exp: Search for a comment instead of a
statement. Enable for GCC. Update expected output for some tests
and add new tests. Remove obsolete GCC KFAILs. Allow GCC's class
layout.
* gdb.cp/member-ptr.cc (Padding, Padding::vspacer, Base, Base::get_x)
(Base::vget_base, Left, Left::vget, Right, Right::vget, Diamond)
(Diamond::vget_base): New.
(main): Add new tests.
* gdb.cp/printmethod.exp: Update expected output for member functions.
* gdb.cp/virtfunc.exp (test_virtual_calls): Add a KFAIL for
print pEe->D::vg().
2007-01-03 19:05:45 +01:00
|
|
|
|
if (printed_any)
|
1999-04-16 03:35:26 +02:00
|
|
|
|
{
|
* NEWS: Mention pointer to member improvements.
* Makefile.in (gnu-v3-abi.o): Delete special rule.
(eval.o, gnu-v3-abi.o, ia64-tdep.o): Update.
* ada-valprint.c (ada_print_scalar): Update for new type codes.
* c-typeprint.c (c_print_type): Update for new type codes.
(c_type_print_varspec_prefix, c_type_print_varspec_suffix)
(c_type_print_base): Likewise.
(c_type_print_args): Rewrite.
* c-valprint.c (c_val_print): Update for new type codes. Remove
support for references to members. Treat methods like functions.
* cp-abi.c (cplus_print_method_ptr, cplus_method_ptr_size)
(cplus_make_method_ptr, cplus_method_ptr_to_value): New.
* cp-abi.h (cplus_print_method_ptr, cplus_method_ptr_size)
(cplus_make_method_ptr, cplus_method_ptr_to_value): New prototypes.
(struct cp_abi_ops): Add corresponding members.
* cp-valprint.c (cp_print_class_method): Delete.
(cp_find_class_member): New function.
(cp_print_class_member): Use it. Simplify support for bogus
member pointers.
* dwarf2read.c (quirk_gcc_member_function_pointer): Use
lookup_methodptr_type.
(read_tag_ptr_to_member_type): Likewise, and lookup_memberptr_type.
* eval.c (evaluate_subexp_standard): Implement EVAL_SKIP for
OP_SCOPE. Update call to value_aggregate_elt. Rewrite member
pointer support.
(evaluate_subexp_for_address): Handle OP_SCOPE explicitly. Handle
references returned by user defined operators.
* f-typeprint.c (f_print_type, f_type_print_varspec_prefix)
(f_type_print_varspec_suffix): Remove support for member pointers.
* gdbtypes.c (lookup_memberptr_type): Renamed from lookup_member_type
and adjusted.
(smash_to_memberptr_type): Likewise, from smash_to_member_type.
(lookup_methodptr_type): New.
(rank_one_type): Adjust for TYPE_CODE_MEMBERPTR.
(recursive_dump_type): Update for new types.
* gdbtypes.h (enum type_code): Replace TYPE_CODE_MEMBER with
TYPE_CODE_MEMBERPTR and TYPE_CODE_METHODPTR.
(lookup_memberptr_type, lookup_methodptr_type)
(smash_to_memberptr_type): New prototypes.
(smash_to_method_type): Formatting fix.
(lookup_member_type, smash_to_member_type): Delete prototypes.
* gnu-v3-abi.c (gnuv3_get_vtable, gnuv3_get_virtual_fn): New.
Do not rely on debug information for the vptr or the method's
enclosing type. Handle function descriptors for IA64.
(gnuv3_virtual_fn_field): Rewrite using the new functions.
(gnuv3_find_method_in, gnuv3_print_method_ptr)
(gnuv3_method_ptr_size, gnuv3_make_method_ptr)
(gnuv3_method_ptr_to_value): New.
(init_gnuv3_ops): Set new members of gnu_v3_abi_ops.
* hpread.c (hpread_type_lookup): Update for new types.
* infcall.c (value_arg_coerce): Likewise.
* m2-typeprint.c (m2_print_type): Remove explicit support
for member pointers.
* m2-valprint.c (m2_val_print): Likewise.
* p-typeprint.c (pascal_type_print_varspec_prefix)
(pascal_type_print_varspec_suffix, pascal_type_print_base): Likewise.
* p-valprint.c (pascal_val_print): Likewise.
(pascal_object_print_class_method, pascal_object_print_class_member):
Delete.
* p-lang.h (pascal_object_print_class_method)
(pascal_object_print_class_member): Delete prototypes.
* stabsread.c (read_type): Update for new types.
* typeprint.c (print_type_scalar): Likewise.
* valops.c (value_struct_elt_for_reference, value_namespace_elt)
(value_maybe_namespace_elt, value_aggregate_elt): Add want_address
argument. Construct a pointer to member if the address of a
function or data member is requested.
(value_cast_pointers): Don't modify the input value.
(value_cast): Adjust pointer to member handling for new types.
Allow null pointer to member constants. Don't modify the input
value.
(value_ind): Remove pointer to member check. Handle function
descriptors for function pointers.
(value_struct_elt, value_find_oload_method_list, check_field):
Remove pointer to member checks.
* value.c (unpack_long): Allow pointers to data members.
(value_from_longest): Allow member pointers.
* value.h (value_aggregate_elt): Add want_address.
* varobj.c (c_variable_editable): Remove check for members.
* gdbarch.sh: Add vtable_function_descriptors and vbit_in_delta.
* ia64-tdep.c (ia64_convert_from_func_ptr_addr): Handle descriptors
in virtual tables.
(ia64_gdbarch_init): Call set_gdbarch_vtable_function_descriptors.
* c-lang.h (cp_print_class_method): Delete prototype.
* arm-tdep.c (arm_gdbarch_init): Call set_gdbarch_vbit_in_delta.
* mips-tdep.c (mips_gdbarch_init): Likewise.
* gdbarch.c, gdbarch.h: Regenerated.
* gdb.cp/classes.exp (test_pointers_to_class_members): Update expected
output. Test the types of members and member pointers.
* gdb.cp/inherit.exp (test_print_mi_member_types): Remove KFAILs for
gdb/2092.
* gdb.cp/member-ptr.exp: Search for a comment instead of a
statement. Enable for GCC. Update expected output for some tests
and add new tests. Remove obsolete GCC KFAILs. Allow GCC's class
layout.
* gdb.cp/member-ptr.cc (Padding, Padding::vspacer, Base, Base::get_x)
(Base::vget_base, Left, Left::vget, Right, Right::vget, Diamond)
(Diamond::vget_base): New.
(main): Add new tests.
* gdb.cp/printmethod.exp: Update expected output for member functions.
* gdb.cp/virtfunc.exp (test_virtual_calls): Add a KFAIL for
print pEe->D::vg().
2007-01-03 19:05:45 +01:00
|
|
|
|
fprintf_filtered (stream, ", ");
|
|
|
|
|
wrap_here (" ");
|
1999-04-16 03:35:26 +02:00
|
|
|
|
}
|
* NEWS: Mention pointer to member improvements.
* Makefile.in (gnu-v3-abi.o): Delete special rule.
(eval.o, gnu-v3-abi.o, ia64-tdep.o): Update.
* ada-valprint.c (ada_print_scalar): Update for new type codes.
* c-typeprint.c (c_print_type): Update for new type codes.
(c_type_print_varspec_prefix, c_type_print_varspec_suffix)
(c_type_print_base): Likewise.
(c_type_print_args): Rewrite.
* c-valprint.c (c_val_print): Update for new type codes. Remove
support for references to members. Treat methods like functions.
* cp-abi.c (cplus_print_method_ptr, cplus_method_ptr_size)
(cplus_make_method_ptr, cplus_method_ptr_to_value): New.
* cp-abi.h (cplus_print_method_ptr, cplus_method_ptr_size)
(cplus_make_method_ptr, cplus_method_ptr_to_value): New prototypes.
(struct cp_abi_ops): Add corresponding members.
* cp-valprint.c (cp_print_class_method): Delete.
(cp_find_class_member): New function.
(cp_print_class_member): Use it. Simplify support for bogus
member pointers.
* dwarf2read.c (quirk_gcc_member_function_pointer): Use
lookup_methodptr_type.
(read_tag_ptr_to_member_type): Likewise, and lookup_memberptr_type.
* eval.c (evaluate_subexp_standard): Implement EVAL_SKIP for
OP_SCOPE. Update call to value_aggregate_elt. Rewrite member
pointer support.
(evaluate_subexp_for_address): Handle OP_SCOPE explicitly. Handle
references returned by user defined operators.
* f-typeprint.c (f_print_type, f_type_print_varspec_prefix)
(f_type_print_varspec_suffix): Remove support for member pointers.
* gdbtypes.c (lookup_memberptr_type): Renamed from lookup_member_type
and adjusted.
(smash_to_memberptr_type): Likewise, from smash_to_member_type.
(lookup_methodptr_type): New.
(rank_one_type): Adjust for TYPE_CODE_MEMBERPTR.
(recursive_dump_type): Update for new types.
* gdbtypes.h (enum type_code): Replace TYPE_CODE_MEMBER with
TYPE_CODE_MEMBERPTR and TYPE_CODE_METHODPTR.
(lookup_memberptr_type, lookup_methodptr_type)
(smash_to_memberptr_type): New prototypes.
(smash_to_method_type): Formatting fix.
(lookup_member_type, smash_to_member_type): Delete prototypes.
* gnu-v3-abi.c (gnuv3_get_vtable, gnuv3_get_virtual_fn): New.
Do not rely on debug information for the vptr or the method's
enclosing type. Handle function descriptors for IA64.
(gnuv3_virtual_fn_field): Rewrite using the new functions.
(gnuv3_find_method_in, gnuv3_print_method_ptr)
(gnuv3_method_ptr_size, gnuv3_make_method_ptr)
(gnuv3_method_ptr_to_value): New.
(init_gnuv3_ops): Set new members of gnu_v3_abi_ops.
* hpread.c (hpread_type_lookup): Update for new types.
* infcall.c (value_arg_coerce): Likewise.
* m2-typeprint.c (m2_print_type): Remove explicit support
for member pointers.
* m2-valprint.c (m2_val_print): Likewise.
* p-typeprint.c (pascal_type_print_varspec_prefix)
(pascal_type_print_varspec_suffix, pascal_type_print_base): Likewise.
* p-valprint.c (pascal_val_print): Likewise.
(pascal_object_print_class_method, pascal_object_print_class_member):
Delete.
* p-lang.h (pascal_object_print_class_method)
(pascal_object_print_class_member): Delete prototypes.
* stabsread.c (read_type): Update for new types.
* typeprint.c (print_type_scalar): Likewise.
* valops.c (value_struct_elt_for_reference, value_namespace_elt)
(value_maybe_namespace_elt, value_aggregate_elt): Add want_address
argument. Construct a pointer to member if the address of a
function or data member is requested.
(value_cast_pointers): Don't modify the input value.
(value_cast): Adjust pointer to member handling for new types.
Allow null pointer to member constants. Don't modify the input
value.
(value_ind): Remove pointer to member check. Handle function
descriptors for function pointers.
(value_struct_elt, value_find_oload_method_list, check_field):
Remove pointer to member checks.
* value.c (unpack_long): Allow pointers to data members.
(value_from_longest): Allow member pointers.
* value.h (value_aggregate_elt): Add want_address.
* varobj.c (c_variable_editable): Remove check for members.
* gdbarch.sh: Add vtable_function_descriptors and vbit_in_delta.
* ia64-tdep.c (ia64_convert_from_func_ptr_addr): Handle descriptors
in virtual tables.
(ia64_gdbarch_init): Call set_gdbarch_vtable_function_descriptors.
* c-lang.h (cp_print_class_method): Delete prototype.
* arm-tdep.c (arm_gdbarch_init): Call set_gdbarch_vbit_in_delta.
* mips-tdep.c (mips_gdbarch_init): Likewise.
* gdbarch.c, gdbarch.h: Regenerated.
* gdb.cp/classes.exp (test_pointers_to_class_members): Update expected
output. Test the types of members and member pointers.
* gdb.cp/inherit.exp (test_print_mi_member_types): Remove KFAILs for
gdb/2092.
* gdb.cp/member-ptr.exp: Search for a comment instead of a
statement. Enable for GCC. Update expected output for some tests
and add new tests. Remove obsolete GCC KFAILs. Allow GCC's class
layout.
* gdb.cp/member-ptr.cc (Padding, Padding::vspacer, Base, Base::get_x)
(Base::vget_base, Left, Left::vget, Right, Right::vget, Diamond)
(Diamond::vget_base): New.
(main): Add new tests.
* gdb.cp/printmethod.exp: Update expected output for member functions.
* gdb.cp/virtfunc.exp (test_virtual_calls): Add a KFAIL for
print pEe->D::vg().
2007-01-03 19:05:45 +01:00
|
|
|
|
|
2011-02-13 10:15:54 +01:00
|
|
|
|
param_type = TYPE_FIELD_TYPE (type, i);
|
|
|
|
|
|
2011-03-22 18:35:22 +01:00
|
|
|
|
if (language == language_cplus && linkage_name)
|
2011-02-13 10:15:54 +01:00
|
|
|
|
{
|
|
|
|
|
/* C++ standard, 13.1 Overloadable declarations, point 3, item:
|
|
|
|
|
- Parameter declarations that differ only in the presence or
|
|
|
|
|
absence of const and/or volatile are equivalent.
|
|
|
|
|
|
|
|
|
|
And the const/volatile qualifiers are not present in the mangled
|
|
|
|
|
names as produced by GCC. */
|
|
|
|
|
|
|
|
|
|
param_type = make_cv_type (0, 0, param_type, NULL);
|
|
|
|
|
}
|
|
|
|
|
|
2018-04-17 21:51:23 +02:00
|
|
|
|
c_print_type (param_type, "", stream, -1, 0, language, flags);
|
* NEWS: Mention pointer to member improvements.
* Makefile.in (gnu-v3-abi.o): Delete special rule.
(eval.o, gnu-v3-abi.o, ia64-tdep.o): Update.
* ada-valprint.c (ada_print_scalar): Update for new type codes.
* c-typeprint.c (c_print_type): Update for new type codes.
(c_type_print_varspec_prefix, c_type_print_varspec_suffix)
(c_type_print_base): Likewise.
(c_type_print_args): Rewrite.
* c-valprint.c (c_val_print): Update for new type codes. Remove
support for references to members. Treat methods like functions.
* cp-abi.c (cplus_print_method_ptr, cplus_method_ptr_size)
(cplus_make_method_ptr, cplus_method_ptr_to_value): New.
* cp-abi.h (cplus_print_method_ptr, cplus_method_ptr_size)
(cplus_make_method_ptr, cplus_method_ptr_to_value): New prototypes.
(struct cp_abi_ops): Add corresponding members.
* cp-valprint.c (cp_print_class_method): Delete.
(cp_find_class_member): New function.
(cp_print_class_member): Use it. Simplify support for bogus
member pointers.
* dwarf2read.c (quirk_gcc_member_function_pointer): Use
lookup_methodptr_type.
(read_tag_ptr_to_member_type): Likewise, and lookup_memberptr_type.
* eval.c (evaluate_subexp_standard): Implement EVAL_SKIP for
OP_SCOPE. Update call to value_aggregate_elt. Rewrite member
pointer support.
(evaluate_subexp_for_address): Handle OP_SCOPE explicitly. Handle
references returned by user defined operators.
* f-typeprint.c (f_print_type, f_type_print_varspec_prefix)
(f_type_print_varspec_suffix): Remove support for member pointers.
* gdbtypes.c (lookup_memberptr_type): Renamed from lookup_member_type
and adjusted.
(smash_to_memberptr_type): Likewise, from smash_to_member_type.
(lookup_methodptr_type): New.
(rank_one_type): Adjust for TYPE_CODE_MEMBERPTR.
(recursive_dump_type): Update for new types.
* gdbtypes.h (enum type_code): Replace TYPE_CODE_MEMBER with
TYPE_CODE_MEMBERPTR and TYPE_CODE_METHODPTR.
(lookup_memberptr_type, lookup_methodptr_type)
(smash_to_memberptr_type): New prototypes.
(smash_to_method_type): Formatting fix.
(lookup_member_type, smash_to_member_type): Delete prototypes.
* gnu-v3-abi.c (gnuv3_get_vtable, gnuv3_get_virtual_fn): New.
Do not rely on debug information for the vptr or the method's
enclosing type. Handle function descriptors for IA64.
(gnuv3_virtual_fn_field): Rewrite using the new functions.
(gnuv3_find_method_in, gnuv3_print_method_ptr)
(gnuv3_method_ptr_size, gnuv3_make_method_ptr)
(gnuv3_method_ptr_to_value): New.
(init_gnuv3_ops): Set new members of gnu_v3_abi_ops.
* hpread.c (hpread_type_lookup): Update for new types.
* infcall.c (value_arg_coerce): Likewise.
* m2-typeprint.c (m2_print_type): Remove explicit support
for member pointers.
* m2-valprint.c (m2_val_print): Likewise.
* p-typeprint.c (pascal_type_print_varspec_prefix)
(pascal_type_print_varspec_suffix, pascal_type_print_base): Likewise.
* p-valprint.c (pascal_val_print): Likewise.
(pascal_object_print_class_method, pascal_object_print_class_member):
Delete.
* p-lang.h (pascal_object_print_class_method)
(pascal_object_print_class_member): Delete prototypes.
* stabsread.c (read_type): Update for new types.
* typeprint.c (print_type_scalar): Likewise.
* valops.c (value_struct_elt_for_reference, value_namespace_elt)
(value_maybe_namespace_elt, value_aggregate_elt): Add want_address
argument. Construct a pointer to member if the address of a
function or data member is requested.
(value_cast_pointers): Don't modify the input value.
(value_cast): Adjust pointer to member handling for new types.
Allow null pointer to member constants. Don't modify the input
value.
(value_ind): Remove pointer to member check. Handle function
descriptors for function pointers.
(value_struct_elt, value_find_oload_method_list, check_field):
Remove pointer to member checks.
* value.c (unpack_long): Allow pointers to data members.
(value_from_longest): Allow member pointers.
* value.h (value_aggregate_elt): Add want_address.
* varobj.c (c_variable_editable): Remove check for members.
* gdbarch.sh: Add vtable_function_descriptors and vbit_in_delta.
* ia64-tdep.c (ia64_convert_from_func_ptr_addr): Handle descriptors
in virtual tables.
(ia64_gdbarch_init): Call set_gdbarch_vtable_function_descriptors.
* c-lang.h (cp_print_class_method): Delete prototype.
* arm-tdep.c (arm_gdbarch_init): Call set_gdbarch_vbit_in_delta.
* mips-tdep.c (mips_gdbarch_init): Likewise.
* gdbarch.c, gdbarch.h: Regenerated.
* gdb.cp/classes.exp (test_pointers_to_class_members): Update expected
output. Test the types of members and member pointers.
* gdb.cp/inherit.exp (test_print_mi_member_types): Remove KFAILs for
gdb/2092.
* gdb.cp/member-ptr.exp: Search for a comment instead of a
statement. Enable for GCC. Update expected output for some tests
and add new tests. Remove obsolete GCC KFAILs. Allow GCC's class
layout.
* gdb.cp/member-ptr.cc (Padding, Padding::vspacer, Base, Base::get_x)
(Base::vget_base, Left, Left::vget, Right, Right::vget, Diamond)
(Diamond::vget_base): New.
(main): Add new tests.
* gdb.cp/printmethod.exp: Update expected output for member functions.
* gdb.cp/virtfunc.exp (test_virtual_calls): Add a KFAIL for
print pEe->D::vg().
2007-01-03 19:05:45 +01:00
|
|
|
|
printed_any = 1;
|
1999-04-16 03:35:26 +02:00
|
|
|
|
}
|
* NEWS: Mention pointer to member improvements.
* Makefile.in (gnu-v3-abi.o): Delete special rule.
(eval.o, gnu-v3-abi.o, ia64-tdep.o): Update.
* ada-valprint.c (ada_print_scalar): Update for new type codes.
* c-typeprint.c (c_print_type): Update for new type codes.
(c_type_print_varspec_prefix, c_type_print_varspec_suffix)
(c_type_print_base): Likewise.
(c_type_print_args): Rewrite.
* c-valprint.c (c_val_print): Update for new type codes. Remove
support for references to members. Treat methods like functions.
* cp-abi.c (cplus_print_method_ptr, cplus_method_ptr_size)
(cplus_make_method_ptr, cplus_method_ptr_to_value): New.
* cp-abi.h (cplus_print_method_ptr, cplus_method_ptr_size)
(cplus_make_method_ptr, cplus_method_ptr_to_value): New prototypes.
(struct cp_abi_ops): Add corresponding members.
* cp-valprint.c (cp_print_class_method): Delete.
(cp_find_class_member): New function.
(cp_print_class_member): Use it. Simplify support for bogus
member pointers.
* dwarf2read.c (quirk_gcc_member_function_pointer): Use
lookup_methodptr_type.
(read_tag_ptr_to_member_type): Likewise, and lookup_memberptr_type.
* eval.c (evaluate_subexp_standard): Implement EVAL_SKIP for
OP_SCOPE. Update call to value_aggregate_elt. Rewrite member
pointer support.
(evaluate_subexp_for_address): Handle OP_SCOPE explicitly. Handle
references returned by user defined operators.
* f-typeprint.c (f_print_type, f_type_print_varspec_prefix)
(f_type_print_varspec_suffix): Remove support for member pointers.
* gdbtypes.c (lookup_memberptr_type): Renamed from lookup_member_type
and adjusted.
(smash_to_memberptr_type): Likewise, from smash_to_member_type.
(lookup_methodptr_type): New.
(rank_one_type): Adjust for TYPE_CODE_MEMBERPTR.
(recursive_dump_type): Update for new types.
* gdbtypes.h (enum type_code): Replace TYPE_CODE_MEMBER with
TYPE_CODE_MEMBERPTR and TYPE_CODE_METHODPTR.
(lookup_memberptr_type, lookup_methodptr_type)
(smash_to_memberptr_type): New prototypes.
(smash_to_method_type): Formatting fix.
(lookup_member_type, smash_to_member_type): Delete prototypes.
* gnu-v3-abi.c (gnuv3_get_vtable, gnuv3_get_virtual_fn): New.
Do not rely on debug information for the vptr or the method's
enclosing type. Handle function descriptors for IA64.
(gnuv3_virtual_fn_field): Rewrite using the new functions.
(gnuv3_find_method_in, gnuv3_print_method_ptr)
(gnuv3_method_ptr_size, gnuv3_make_method_ptr)
(gnuv3_method_ptr_to_value): New.
(init_gnuv3_ops): Set new members of gnu_v3_abi_ops.
* hpread.c (hpread_type_lookup): Update for new types.
* infcall.c (value_arg_coerce): Likewise.
* m2-typeprint.c (m2_print_type): Remove explicit support
for member pointers.
* m2-valprint.c (m2_val_print): Likewise.
* p-typeprint.c (pascal_type_print_varspec_prefix)
(pascal_type_print_varspec_suffix, pascal_type_print_base): Likewise.
* p-valprint.c (pascal_val_print): Likewise.
(pascal_object_print_class_method, pascal_object_print_class_member):
Delete.
* p-lang.h (pascal_object_print_class_method)
(pascal_object_print_class_member): Delete prototypes.
* stabsread.c (read_type): Update for new types.
* typeprint.c (print_type_scalar): Likewise.
* valops.c (value_struct_elt_for_reference, value_namespace_elt)
(value_maybe_namespace_elt, value_aggregate_elt): Add want_address
argument. Construct a pointer to member if the address of a
function or data member is requested.
(value_cast_pointers): Don't modify the input value.
(value_cast): Adjust pointer to member handling for new types.
Allow null pointer to member constants. Don't modify the input
value.
(value_ind): Remove pointer to member check. Handle function
descriptors for function pointers.
(value_struct_elt, value_find_oload_method_list, check_field):
Remove pointer to member checks.
* value.c (unpack_long): Allow pointers to data members.
(value_from_longest): Allow member pointers.
* value.h (value_aggregate_elt): Add want_address.
* varobj.c (c_variable_editable): Remove check for members.
* gdbarch.sh: Add vtable_function_descriptors and vbit_in_delta.
* ia64-tdep.c (ia64_convert_from_func_ptr_addr): Handle descriptors
in virtual tables.
(ia64_gdbarch_init): Call set_gdbarch_vtable_function_descriptors.
* c-lang.h (cp_print_class_method): Delete prototype.
* arm-tdep.c (arm_gdbarch_init): Call set_gdbarch_vbit_in_delta.
* mips-tdep.c (mips_gdbarch_init): Likewise.
* gdbarch.c, gdbarch.h: Regenerated.
* gdb.cp/classes.exp (test_pointers_to_class_members): Update expected
output. Test the types of members and member pointers.
* gdb.cp/inherit.exp (test_print_mi_member_types): Remove KFAILs for
gdb/2092.
* gdb.cp/member-ptr.exp: Search for a comment instead of a
statement. Enable for GCC. Update expected output for some tests
and add new tests. Remove obsolete GCC KFAILs. Allow GCC's class
layout.
* gdb.cp/member-ptr.cc (Padding, Padding::vspacer, Base, Base::get_x)
(Base::vget_base, Left, Left::vget, Right, Right::vget, Diamond)
(Diamond::vget_base): New.
(main): Add new tests.
* gdb.cp/printmethod.exp: Update expected output for member functions.
* gdb.cp/virtfunc.exp (test_virtual_calls): Add a KFAIL for
print pEe->D::vg().
2007-01-03 19:05:45 +01:00
|
|
|
|
|
|
|
|
|
if (printed_any && TYPE_VARARGS (type))
|
1999-04-16 03:35:26 +02:00
|
|
|
|
{
|
* NEWS: Mention pointer to member improvements.
* Makefile.in (gnu-v3-abi.o): Delete special rule.
(eval.o, gnu-v3-abi.o, ia64-tdep.o): Update.
* ada-valprint.c (ada_print_scalar): Update for new type codes.
* c-typeprint.c (c_print_type): Update for new type codes.
(c_type_print_varspec_prefix, c_type_print_varspec_suffix)
(c_type_print_base): Likewise.
(c_type_print_args): Rewrite.
* c-valprint.c (c_val_print): Update for new type codes. Remove
support for references to members. Treat methods like functions.
* cp-abi.c (cplus_print_method_ptr, cplus_method_ptr_size)
(cplus_make_method_ptr, cplus_method_ptr_to_value): New.
* cp-abi.h (cplus_print_method_ptr, cplus_method_ptr_size)
(cplus_make_method_ptr, cplus_method_ptr_to_value): New prototypes.
(struct cp_abi_ops): Add corresponding members.
* cp-valprint.c (cp_print_class_method): Delete.
(cp_find_class_member): New function.
(cp_print_class_member): Use it. Simplify support for bogus
member pointers.
* dwarf2read.c (quirk_gcc_member_function_pointer): Use
lookup_methodptr_type.
(read_tag_ptr_to_member_type): Likewise, and lookup_memberptr_type.
* eval.c (evaluate_subexp_standard): Implement EVAL_SKIP for
OP_SCOPE. Update call to value_aggregate_elt. Rewrite member
pointer support.
(evaluate_subexp_for_address): Handle OP_SCOPE explicitly. Handle
references returned by user defined operators.
* f-typeprint.c (f_print_type, f_type_print_varspec_prefix)
(f_type_print_varspec_suffix): Remove support for member pointers.
* gdbtypes.c (lookup_memberptr_type): Renamed from lookup_member_type
and adjusted.
(smash_to_memberptr_type): Likewise, from smash_to_member_type.
(lookup_methodptr_type): New.
(rank_one_type): Adjust for TYPE_CODE_MEMBERPTR.
(recursive_dump_type): Update for new types.
* gdbtypes.h (enum type_code): Replace TYPE_CODE_MEMBER with
TYPE_CODE_MEMBERPTR and TYPE_CODE_METHODPTR.
(lookup_memberptr_type, lookup_methodptr_type)
(smash_to_memberptr_type): New prototypes.
(smash_to_method_type): Formatting fix.
(lookup_member_type, smash_to_member_type): Delete prototypes.
* gnu-v3-abi.c (gnuv3_get_vtable, gnuv3_get_virtual_fn): New.
Do not rely on debug information for the vptr or the method's
enclosing type. Handle function descriptors for IA64.
(gnuv3_virtual_fn_field): Rewrite using the new functions.
(gnuv3_find_method_in, gnuv3_print_method_ptr)
(gnuv3_method_ptr_size, gnuv3_make_method_ptr)
(gnuv3_method_ptr_to_value): New.
(init_gnuv3_ops): Set new members of gnu_v3_abi_ops.
* hpread.c (hpread_type_lookup): Update for new types.
* infcall.c (value_arg_coerce): Likewise.
* m2-typeprint.c (m2_print_type): Remove explicit support
for member pointers.
* m2-valprint.c (m2_val_print): Likewise.
* p-typeprint.c (pascal_type_print_varspec_prefix)
(pascal_type_print_varspec_suffix, pascal_type_print_base): Likewise.
* p-valprint.c (pascal_val_print): Likewise.
(pascal_object_print_class_method, pascal_object_print_class_member):
Delete.
* p-lang.h (pascal_object_print_class_method)
(pascal_object_print_class_member): Delete prototypes.
* stabsread.c (read_type): Update for new types.
* typeprint.c (print_type_scalar): Likewise.
* valops.c (value_struct_elt_for_reference, value_namespace_elt)
(value_maybe_namespace_elt, value_aggregate_elt): Add want_address
argument. Construct a pointer to member if the address of a
function or data member is requested.
(value_cast_pointers): Don't modify the input value.
(value_cast): Adjust pointer to member handling for new types.
Allow null pointer to member constants. Don't modify the input
value.
(value_ind): Remove pointer to member check. Handle function
descriptors for function pointers.
(value_struct_elt, value_find_oload_method_list, check_field):
Remove pointer to member checks.
* value.c (unpack_long): Allow pointers to data members.
(value_from_longest): Allow member pointers.
* value.h (value_aggregate_elt): Add want_address.
* varobj.c (c_variable_editable): Remove check for members.
* gdbarch.sh: Add vtable_function_descriptors and vbit_in_delta.
* ia64-tdep.c (ia64_convert_from_func_ptr_addr): Handle descriptors
in virtual tables.
(ia64_gdbarch_init): Call set_gdbarch_vtable_function_descriptors.
* c-lang.h (cp_print_class_method): Delete prototype.
* arm-tdep.c (arm_gdbarch_init): Call set_gdbarch_vbit_in_delta.
* mips-tdep.c (mips_gdbarch_init): Likewise.
* gdbarch.c, gdbarch.h: Regenerated.
* gdb.cp/classes.exp (test_pointers_to_class_members): Update expected
output. Test the types of members and member pointers.
* gdb.cp/inherit.exp (test_print_mi_member_types): Remove KFAILs for
gdb/2092.
* gdb.cp/member-ptr.exp: Search for a comment instead of a
statement. Enable for GCC. Update expected output for some tests
and add new tests. Remove obsolete GCC KFAILs. Allow GCC's class
layout.
* gdb.cp/member-ptr.cc (Padding, Padding::vspacer, Base, Base::get_x)
(Base::vget_base, Left, Left::vget, Right, Right::vget, Diamond)
(Diamond::vget_base): New.
(main): Add new tests.
* gdb.cp/printmethod.exp: Update expected output for member functions.
* gdb.cp/virtfunc.exp (test_virtual_calls): Add a KFAIL for
print pEe->D::vg().
2007-01-03 19:05:45 +01:00
|
|
|
|
/* Print out a trailing ellipsis for varargs functions. Ignore
|
|
|
|
|
TYPE_VARARGS if the function has no named arguments; that
|
|
|
|
|
represents unprototyped (K&R style) C functions. */
|
|
|
|
|
if (printed_any && TYPE_VARARGS (type))
|
|
|
|
|
{
|
|
|
|
|
fprintf_filtered (stream, ", ");
|
|
|
|
|
wrap_here (" ");
|
|
|
|
|
fprintf_filtered (stream, "...");
|
|
|
|
|
}
|
1999-04-16 03:35:26 +02:00
|
|
|
|
}
|
* NEWS: Mention pointer to member improvements.
* Makefile.in (gnu-v3-abi.o): Delete special rule.
(eval.o, gnu-v3-abi.o, ia64-tdep.o): Update.
* ada-valprint.c (ada_print_scalar): Update for new type codes.
* c-typeprint.c (c_print_type): Update for new type codes.
(c_type_print_varspec_prefix, c_type_print_varspec_suffix)
(c_type_print_base): Likewise.
(c_type_print_args): Rewrite.
* c-valprint.c (c_val_print): Update for new type codes. Remove
support for references to members. Treat methods like functions.
* cp-abi.c (cplus_print_method_ptr, cplus_method_ptr_size)
(cplus_make_method_ptr, cplus_method_ptr_to_value): New.
* cp-abi.h (cplus_print_method_ptr, cplus_method_ptr_size)
(cplus_make_method_ptr, cplus_method_ptr_to_value): New prototypes.
(struct cp_abi_ops): Add corresponding members.
* cp-valprint.c (cp_print_class_method): Delete.
(cp_find_class_member): New function.
(cp_print_class_member): Use it. Simplify support for bogus
member pointers.
* dwarf2read.c (quirk_gcc_member_function_pointer): Use
lookup_methodptr_type.
(read_tag_ptr_to_member_type): Likewise, and lookup_memberptr_type.
* eval.c (evaluate_subexp_standard): Implement EVAL_SKIP for
OP_SCOPE. Update call to value_aggregate_elt. Rewrite member
pointer support.
(evaluate_subexp_for_address): Handle OP_SCOPE explicitly. Handle
references returned by user defined operators.
* f-typeprint.c (f_print_type, f_type_print_varspec_prefix)
(f_type_print_varspec_suffix): Remove support for member pointers.
* gdbtypes.c (lookup_memberptr_type): Renamed from lookup_member_type
and adjusted.
(smash_to_memberptr_type): Likewise, from smash_to_member_type.
(lookup_methodptr_type): New.
(rank_one_type): Adjust for TYPE_CODE_MEMBERPTR.
(recursive_dump_type): Update for new types.
* gdbtypes.h (enum type_code): Replace TYPE_CODE_MEMBER with
TYPE_CODE_MEMBERPTR and TYPE_CODE_METHODPTR.
(lookup_memberptr_type, lookup_methodptr_type)
(smash_to_memberptr_type): New prototypes.
(smash_to_method_type): Formatting fix.
(lookup_member_type, smash_to_member_type): Delete prototypes.
* gnu-v3-abi.c (gnuv3_get_vtable, gnuv3_get_virtual_fn): New.
Do not rely on debug information for the vptr or the method's
enclosing type. Handle function descriptors for IA64.
(gnuv3_virtual_fn_field): Rewrite using the new functions.
(gnuv3_find_method_in, gnuv3_print_method_ptr)
(gnuv3_method_ptr_size, gnuv3_make_method_ptr)
(gnuv3_method_ptr_to_value): New.
(init_gnuv3_ops): Set new members of gnu_v3_abi_ops.
* hpread.c (hpread_type_lookup): Update for new types.
* infcall.c (value_arg_coerce): Likewise.
* m2-typeprint.c (m2_print_type): Remove explicit support
for member pointers.
* m2-valprint.c (m2_val_print): Likewise.
* p-typeprint.c (pascal_type_print_varspec_prefix)
(pascal_type_print_varspec_suffix, pascal_type_print_base): Likewise.
* p-valprint.c (pascal_val_print): Likewise.
(pascal_object_print_class_method, pascal_object_print_class_member):
Delete.
* p-lang.h (pascal_object_print_class_method)
(pascal_object_print_class_member): Delete prototypes.
* stabsread.c (read_type): Update for new types.
* typeprint.c (print_type_scalar): Likewise.
* valops.c (value_struct_elt_for_reference, value_namespace_elt)
(value_maybe_namespace_elt, value_aggregate_elt): Add want_address
argument. Construct a pointer to member if the address of a
function or data member is requested.
(value_cast_pointers): Don't modify the input value.
(value_cast): Adjust pointer to member handling for new types.
Allow null pointer to member constants. Don't modify the input
value.
(value_ind): Remove pointer to member check. Handle function
descriptors for function pointers.
(value_struct_elt, value_find_oload_method_list, check_field):
Remove pointer to member checks.
* value.c (unpack_long): Allow pointers to data members.
(value_from_longest): Allow member pointers.
* value.h (value_aggregate_elt): Add want_address.
* varobj.c (c_variable_editable): Remove check for members.
* gdbarch.sh: Add vtable_function_descriptors and vbit_in_delta.
* ia64-tdep.c (ia64_convert_from_func_ptr_addr): Handle descriptors
in virtual tables.
(ia64_gdbarch_init): Call set_gdbarch_vtable_function_descriptors.
* c-lang.h (cp_print_class_method): Delete prototype.
* arm-tdep.c (arm_gdbarch_init): Call set_gdbarch_vbit_in_delta.
* mips-tdep.c (mips_gdbarch_init): Likewise.
* gdbarch.c, gdbarch.h: Regenerated.
* gdb.cp/classes.exp (test_pointers_to_class_members): Update expected
output. Test the types of members and member pointers.
* gdb.cp/inherit.exp (test_print_mi_member_types): Remove KFAILs for
gdb/2092.
* gdb.cp/member-ptr.exp: Search for a comment instead of a
statement. Enable for GCC. Update expected output for some tests
and add new tests. Remove obsolete GCC KFAILs. Allow GCC's class
layout.
* gdb.cp/member-ptr.cc (Padding, Padding::vspacer, Base, Base::get_x)
(Base::vget_base, Left, Left::vget, Right, Right::vget, Diamond)
(Diamond::vget_base): New.
(main): Add new tests.
* gdb.cp/printmethod.exp: Update expected output for member functions.
* gdb.cp/virtfunc.exp (test_virtual_calls): Add a KFAIL for
print pEe->D::vg().
2007-01-03 19:05:45 +01:00
|
|
|
|
else if (!printed_any
|
Remove Java support
This patch removes the Java support from gdb. gcj has not seen much
development or use for years now, and was recently removed from GCC.
This patch changes gdb to follow; in the unlikely event that there are
still users using gcj, they can continue to use an older gdb to debug.
Or, they can debug in C++ mode.
Built and regtested on x86-64 Fedora 24.
2016-10-06 Tom Tromey <tom@tromey.com>
* MAINTAINERS: Remove Java test maintainer.
* varobj.h (java_varobj_ops): Don't declare.
* valprint.h (struct value_print_options)
<pascal_static_field_print>: Update comment.
* utils.c (producer_is_gcc): Remove java reference.
* symtab.h (struct general_symbol_info): Remove java references.
(SYMBOL_SEARCH_NAME): Likewise.
* objfiles.c (allocate_objfile): Update comment.
* linespec.c (find_linespec_symbols): Remove java references.
* gnu-v3-abi.c (gnuv3_rtti_type, gnuv3_baseclass_offset): Remove
java references.
* gdbtypes.h (struct cplus_struct_type) <is_java>: Remove.
(TYPE_CPLUS_REALLY_JAVA): Remove.
* c-varobj.c (enum vsections): Update comment.
* symtab.c (symbol_set_language, symbol_set_names)
(symbol_natural_name, symbol_demangled_name)
(demangle_for_lookup, symbol_matches_domain)
(default_make_symbol_completion_list_break_on_1): Remove java
references.
(JAVA_PREFIX, JAVA_PREFIX_LEN): Remove.
* psymtab.c (match_partial_symbol, psymtab_search_name)
(lookup_partial_symbol): Remove java references.
* dwarf2read.c (find_slot_in_mapped_hash): Remove java references.
(add_partial_symbol, dwarf2_compute_name, dwarf2_physname)
(dwarf2_add_member_fn, is_vtable_name, read_structure_type)
(process_structure_scope, read_subroutine_type)
(read_subrange_type, load_partial_dies)
(new_symbol_full, determine_prefix, typename_concat)
(dwarf2_name): Remove java references.
(set_cu_language): Treat Java as C++.
* c-typeprint.c (c_type_print_args): Remove java reference.
* defs.h (enum language) <language_java>: Remove.
* Makefile.in (SFILES, HFILES_NO_SRCDIR, COMMON_OBS, YYFILES)
(YYOBJ, local-maintainer-clean): Don't mention java files.
* jv-exp.y, jv-lang.c, jv-lang.h, jv-typeprint.c, jv-valprint.c,
jv-varobj.c: Remove.
2016-10-06 Tom Tromey <tom@tromey.com>
* guile.texi (Types In Guile): Remove Java mentions.
* python.texi (Types In Python): Remove Java mentions.
* gdb.texinfo (Address Locations, Supported Languages)
(Index Section Format): Remove Java mentions.
2016-10-06 Tom Tromey <tom@tromey.com>
* gdb.compile/compile.exp: Change java tests to rust.
* gdb.base/setshow.exp: Change java tests to rust.
* gdb.base/default.exp: Remove java from language list.
* README (Examples): Update language example.
* gdb.python/py-lookup-type.exp (test_lookup_type): Remove java
test.
* lib/gdb.exp (skip_java_tests): Remove.
* lib/java.exp: Remove.
* gdb.java: Remove.
2016-10-05 16:44:34 +02:00
|
|
|
|
&& (TYPE_PROTOTYPED (type) || language == language_cplus))
|
* NEWS: Mention pointer to member improvements.
* Makefile.in (gnu-v3-abi.o): Delete special rule.
(eval.o, gnu-v3-abi.o, ia64-tdep.o): Update.
* ada-valprint.c (ada_print_scalar): Update for new type codes.
* c-typeprint.c (c_print_type): Update for new type codes.
(c_type_print_varspec_prefix, c_type_print_varspec_suffix)
(c_type_print_base): Likewise.
(c_type_print_args): Rewrite.
* c-valprint.c (c_val_print): Update for new type codes. Remove
support for references to members. Treat methods like functions.
* cp-abi.c (cplus_print_method_ptr, cplus_method_ptr_size)
(cplus_make_method_ptr, cplus_method_ptr_to_value): New.
* cp-abi.h (cplus_print_method_ptr, cplus_method_ptr_size)
(cplus_make_method_ptr, cplus_method_ptr_to_value): New prototypes.
(struct cp_abi_ops): Add corresponding members.
* cp-valprint.c (cp_print_class_method): Delete.
(cp_find_class_member): New function.
(cp_print_class_member): Use it. Simplify support for bogus
member pointers.
* dwarf2read.c (quirk_gcc_member_function_pointer): Use
lookup_methodptr_type.
(read_tag_ptr_to_member_type): Likewise, and lookup_memberptr_type.
* eval.c (evaluate_subexp_standard): Implement EVAL_SKIP for
OP_SCOPE. Update call to value_aggregate_elt. Rewrite member
pointer support.
(evaluate_subexp_for_address): Handle OP_SCOPE explicitly. Handle
references returned by user defined operators.
* f-typeprint.c (f_print_type, f_type_print_varspec_prefix)
(f_type_print_varspec_suffix): Remove support for member pointers.
* gdbtypes.c (lookup_memberptr_type): Renamed from lookup_member_type
and adjusted.
(smash_to_memberptr_type): Likewise, from smash_to_member_type.
(lookup_methodptr_type): New.
(rank_one_type): Adjust for TYPE_CODE_MEMBERPTR.
(recursive_dump_type): Update for new types.
* gdbtypes.h (enum type_code): Replace TYPE_CODE_MEMBER with
TYPE_CODE_MEMBERPTR and TYPE_CODE_METHODPTR.
(lookup_memberptr_type, lookup_methodptr_type)
(smash_to_memberptr_type): New prototypes.
(smash_to_method_type): Formatting fix.
(lookup_member_type, smash_to_member_type): Delete prototypes.
* gnu-v3-abi.c (gnuv3_get_vtable, gnuv3_get_virtual_fn): New.
Do not rely on debug information for the vptr or the method's
enclosing type. Handle function descriptors for IA64.
(gnuv3_virtual_fn_field): Rewrite using the new functions.
(gnuv3_find_method_in, gnuv3_print_method_ptr)
(gnuv3_method_ptr_size, gnuv3_make_method_ptr)
(gnuv3_method_ptr_to_value): New.
(init_gnuv3_ops): Set new members of gnu_v3_abi_ops.
* hpread.c (hpread_type_lookup): Update for new types.
* infcall.c (value_arg_coerce): Likewise.
* m2-typeprint.c (m2_print_type): Remove explicit support
for member pointers.
* m2-valprint.c (m2_val_print): Likewise.
* p-typeprint.c (pascal_type_print_varspec_prefix)
(pascal_type_print_varspec_suffix, pascal_type_print_base): Likewise.
* p-valprint.c (pascal_val_print): Likewise.
(pascal_object_print_class_method, pascal_object_print_class_member):
Delete.
* p-lang.h (pascal_object_print_class_method)
(pascal_object_print_class_member): Delete prototypes.
* stabsread.c (read_type): Update for new types.
* typeprint.c (print_type_scalar): Likewise.
* valops.c (value_struct_elt_for_reference, value_namespace_elt)
(value_maybe_namespace_elt, value_aggregate_elt): Add want_address
argument. Construct a pointer to member if the address of a
function or data member is requested.
(value_cast_pointers): Don't modify the input value.
(value_cast): Adjust pointer to member handling for new types.
Allow null pointer to member constants. Don't modify the input
value.
(value_ind): Remove pointer to member check. Handle function
descriptors for function pointers.
(value_struct_elt, value_find_oload_method_list, check_field):
Remove pointer to member checks.
* value.c (unpack_long): Allow pointers to data members.
(value_from_longest): Allow member pointers.
* value.h (value_aggregate_elt): Add want_address.
* varobj.c (c_variable_editable): Remove check for members.
* gdbarch.sh: Add vtable_function_descriptors and vbit_in_delta.
* ia64-tdep.c (ia64_convert_from_func_ptr_addr): Handle descriptors
in virtual tables.
(ia64_gdbarch_init): Call set_gdbarch_vtable_function_descriptors.
* c-lang.h (cp_print_class_method): Delete prototype.
* arm-tdep.c (arm_gdbarch_init): Call set_gdbarch_vbit_in_delta.
* mips-tdep.c (mips_gdbarch_init): Likewise.
* gdbarch.c, gdbarch.h: Regenerated.
* gdb.cp/classes.exp (test_pointers_to_class_members): Update expected
output. Test the types of members and member pointers.
* gdb.cp/inherit.exp (test_print_mi_member_types): Remove KFAILs for
gdb/2092.
* gdb.cp/member-ptr.exp: Search for a comment instead of a
statement. Enable for GCC. Update expected output for some tests
and add new tests. Remove obsolete GCC KFAILs. Allow GCC's class
layout.
* gdb.cp/member-ptr.cc (Padding, Padding::vspacer, Base, Base::get_x)
(Base::vget_base, Left, Left::vget, Right, Right::vget, Diamond)
(Diamond::vget_base): New.
(main): Add new tests.
* gdb.cp/printmethod.exp: Update expected output for member functions.
* gdb.cp/virtfunc.exp (test_virtual_calls): Add a KFAIL for
print pEe->D::vg().
2007-01-03 19:05:45 +01:00
|
|
|
|
fprintf_filtered (stream, "void");
|
1999-07-07 22:19:36 +02:00
|
|
|
|
|
1999-04-16 03:35:26 +02:00
|
|
|
|
fprintf_filtered (stream, ")");
|
|
|
|
|
}
|
|
|
|
|
|
2000-02-05 08:30:26 +01:00
|
|
|
|
/* Return true iff the j'th overloading of the i'th method of TYPE
|
|
|
|
|
is a type conversion operator, like `operator int () { ... }'.
|
|
|
|
|
When listing a class's methods, we don't print the return type of
|
|
|
|
|
such operators. */
|
2010-10-13 17:10:10 +02:00
|
|
|
|
|
2000-02-05 08:30:26 +01:00
|
|
|
|
static int
|
|
|
|
|
is_type_conversion_operator (struct type *type, int i, int j)
|
|
|
|
|
{
|
|
|
|
|
/* I think the whole idea of recognizing type conversion operators
|
|
|
|
|
by their name is pretty terrible. But I don't think our present
|
|
|
|
|
data structure gives us any other way to tell. If you know of
|
|
|
|
|
some other way, feel free to rewrite this function. */
|
* gdbtypes.h (struct main_type): Change type of name,tag_name,
and fields.name members from char * to const char *. All uses updated.
(struct cplus_struct_type): Change type of fn_fieldlists.name member
from char * to const char *. All uses updated.
(type_name_no_tag): Update.
(lookup_unsigned_typename, lookup_signed_typename): Update.
* gdbtypes.c (type_name_no_tag): Change result type
from char * to const char *. All callers updated.
(lookup_unsigned_typename, lookup_signed_typename): Change type of
name parameter from char * to const char *.
* symtab.h (struct cplus_specific): Change type of demangled_name
member from char * to const char *. All uses updated.
(struct general_symbol_info): Change type of name and
mangled_lang.demangled_name members from char * to const char *.
All uses updated.
(symbol_get_demangled_name, symbol_natural_name): Update.
(symbol_demangled_name, symbol_search_name): Update.
* symtab.c (symbol_get_demangled_name): Change result type
from char * to const char *. All callers updated.
(symbol_natural_name, symbol_demangled_name): Ditto.
(symbol_search_name): Ditto.
(completion_list_add_name): Change type of symname,sym_text,
text,word parameters from char * to const char *.
(completion_list_objc_symbol): Change type of sym_text,
text,word parameters from char * to const char *.
* ada-lang.c (find_struct_field): Change type of name parameter
from char * to const char *.
(encoded_ordered_before): Similarly for N0,N1 parameters.
(old_renaming_is_invisible): Similarly for function_name parameter.
(ada_type_name): Change result type from char * to const char *.
All callers updated.
* ada-lang.h (ada_type_name): Update.
* buildsym.c (hashname): Change type of name parameter
from char * to const char *.
* buildsym.h (hashname): Update.
* dbxread.c (end_psymtab): Change type of include_list parameter
from char ** to const char **.
* dwarf2read.c (determine_prefix): Change result type
from char * to const char *. All callers updated.
* f-lang.c (find_common_for_function): Change type of name, funcname
parameters from char * to const char *.
* f-lang.c (find_common_for_function): Update.
* f-valprint.c (list_all_visible_commons): Change type of funcname
parameters from char * to const char *.
* gdbarch.sh (static_transform_name): Change type of name parameter
and result from char * to const char *.
* gdbarch.c: Regenerate.
* gdbarch.h: Regenerate.
* i386-sol2-tdep.c (i386_sol2_static_transform_name): Change type
of name parameter from char * to const char *.
* jv-lang.c (java_primitive_type_from_name): Ditto.
(java_demangled_signature_length): Similarly for signature parameter.
(java_demangled_signature_copy): Ditto.
(java_demangle_type_signature): Ditto.
* jv-lang.h (java_primitive_type_from_name): Update.
(java_demangle_type_signature): Update.
* objc-lang.c (specialcmp): Change type of a,b parameters
from char * to const char *.
* p-lang.c (is_pascal_string_type): Change type of arrayname parameter
from char * to const char *. All callers updated.
* p-lang.h (is_pascal_string_type): Update.
* solib-frv.c (find_canonical_descriptor_in_load_object): Change type
of name parameter from char * to const char *.
* sparc-sol2-tdep.c (sparc_sol2_static_transform_name): Ditto.
* utils.c (fprintf_symbol_filtered): Ditto.
* defs.h (fprintf_symbol_filtered): Update.
* sparc-tdep.h (sparc_sol2_static_transform_name): Update.
* stabsread.h (end_psymtab): Update.
* stack.c (find_frame_funname): Change type of funname parameter
from char ** to const char **.
* stack.h (find_frame_funname): Update.
* typeprint.c (type_print): Change type of varstring parameter
from char * to const char *.
* value.h (type_print): Update.
* xcoffread.c (xcoff_start_psymtab): Change type of filename parameter
from char * to const char *. All callers updated.
(xcoff_end_psymtab): Change type of include_list parameter
from char ** to const char **. All callers updated.
(swap_sym): Similarly for name parameter. All callers updated.
* coffread.c (patch_type): Add (char*) cast to xfree parameter.
Use xstrdup.
(process_coff_symbol): Use xstrdup.
* stabsread.c (stabs_method_name_from_physname): Renamed from
update_method_name_from_physname. Change result type from void
to char *. All callers updated.
(read_member_functions): In has_destructor case, store name in objfile
obstack instead of malloc space. In !has_stub case, fix mem leak.
2012-02-07 05:48:23 +01:00
|
|
|
|
const char *name = TYPE_FN_FIELDLIST_NAME (type, i);
|
2000-02-05 08:30:26 +01:00
|
|
|
|
|
2017-07-17 16:51:55 +02:00
|
|
|
|
if (!startswith (name, CP_OPERATOR_STR))
|
2000-02-05 08:30:26 +01:00
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
|
|
name += 8;
|
|
|
|
|
if (! strchr (" \t\f\n\r", *name))
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
|
|
while (strchr (" \t\f\n\r", *name))
|
|
|
|
|
name++;
|
|
|
|
|
|
2002-01-16 03:43:38 +01:00
|
|
|
|
if (!('a' <= *name && *name <= 'z')
|
|
|
|
|
&& !('A' <= *name && *name <= 'Z')
|
|
|
|
|
&& *name != '_')
|
|
|
|
|
/* If this doesn't look like the start of an identifier, then it
|
|
|
|
|
isn't a type conversion operator. */
|
|
|
|
|
return 0;
|
2015-03-06 10:42:06 +01:00
|
|
|
|
else if (startswith (name, "new"))
|
2000-02-05 08:30:26 +01:00
|
|
|
|
name += 3;
|
2015-03-06 10:42:06 +01:00
|
|
|
|
else if (startswith (name, "delete"))
|
2000-02-05 08:30:26 +01:00
|
|
|
|
name += 6;
|
|
|
|
|
else
|
2002-01-10 01:06:02 +01:00
|
|
|
|
/* If it doesn't look like new or delete, it's a type conversion
|
|
|
|
|
operator. */
|
|
|
|
|
return 1;
|
2000-02-05 08:30:26 +01:00
|
|
|
|
|
|
|
|
|
/* Is that really the end of the name? */
|
|
|
|
|
if (('a' <= *name && *name <= 'z')
|
|
|
|
|
|| ('A' <= *name && *name <= 'Z')
|
|
|
|
|
|| ('0' <= *name && *name <= '9')
|
|
|
|
|
|| *name == '_')
|
|
|
|
|
/* No, so the identifier following "operator" must be a type name,
|
|
|
|
|
and this is a type conversion operator. */
|
|
|
|
|
return 1;
|
|
|
|
|
|
|
|
|
|
/* That was indeed the end of the name, so it was `operator new' or
|
2010-12-31 23:59:52 +01:00
|
|
|
|
`operator delete', neither of which are type conversion
|
|
|
|
|
operators. */
|
2000-02-05 08:30:26 +01:00
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Given a C++ qualified identifier QID, strip off the qualifiers,
|
|
|
|
|
yielding the unqualified name. The return value is a pointer into
|
|
|
|
|
the original string.
|
|
|
|
|
|
|
|
|
|
It's a pity we don't have this information in some more structured
|
|
|
|
|
form. Even the author of this function feels that writing little
|
|
|
|
|
parsers like this everywhere is stupid. */
|
2010-10-13 17:10:10 +02:00
|
|
|
|
|
2000-02-05 08:30:26 +01:00
|
|
|
|
static char *
|
|
|
|
|
remove_qualifiers (char *qid)
|
|
|
|
|
{
|
2011-01-07 20:36:19 +01:00
|
|
|
|
int quoted = 0; /* Zero if we're not in quotes;
|
2010-12-31 23:59:52 +01:00
|
|
|
|
'"' if we're in a double-quoted string;
|
|
|
|
|
'\'' if we're in a single-quoted string. */
|
2011-01-07 20:36:19 +01:00
|
|
|
|
int depth = 0; /* Number of unclosed parens we've seen. */
|
2000-02-05 08:30:26 +01:00
|
|
|
|
char *parenstack = (char *) alloca (strlen (qid));
|
|
|
|
|
char *scan;
|
2010-12-31 23:59:52 +01:00
|
|
|
|
char *last = 0; /* The character after the rightmost
|
|
|
|
|
`::' token we've seen so far. */
|
2000-02-05 08:30:26 +01:00
|
|
|
|
|
|
|
|
|
for (scan = qid; *scan; scan++)
|
|
|
|
|
{
|
|
|
|
|
if (quoted)
|
|
|
|
|
{
|
|
|
|
|
if (*scan == quoted)
|
|
|
|
|
quoted = 0;
|
|
|
|
|
else if (*scan == '\\' && *(scan + 1))
|
|
|
|
|
scan++;
|
|
|
|
|
}
|
|
|
|
|
else if (scan[0] == ':' && scan[1] == ':')
|
|
|
|
|
{
|
|
|
|
|
/* If we're inside parenthesis (i.e., an argument list) or
|
|
|
|
|
angle brackets (i.e., a list of template arguments), then
|
|
|
|
|
we don't record the position of this :: token, since it's
|
2010-12-31 23:59:52 +01:00
|
|
|
|
not relevant to the top-level structure we're trying to
|
|
|
|
|
operate on. */
|
2000-02-05 08:30:26 +01:00
|
|
|
|
if (depth == 0)
|
|
|
|
|
{
|
|
|
|
|
last = scan + 2;
|
|
|
|
|
scan++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if (*scan == '"' || *scan == '\'')
|
|
|
|
|
quoted = *scan;
|
|
|
|
|
else if (*scan == '(')
|
|
|
|
|
parenstack[depth++] = ')';
|
|
|
|
|
else if (*scan == '[')
|
|
|
|
|
parenstack[depth++] = ']';
|
|
|
|
|
/* We're going to treat <> as a pair of matching characters,
|
|
|
|
|
since we're more likely to see those in template id's than
|
|
|
|
|
real less-than characters. What a crock. */
|
|
|
|
|
else if (*scan == '<')
|
|
|
|
|
parenstack[depth++] = '>';
|
|
|
|
|
else if (*scan == ')' || *scan == ']' || *scan == '>')
|
|
|
|
|
{
|
|
|
|
|
if (depth > 0 && parenstack[depth - 1] == *scan)
|
|
|
|
|
depth--;
|
|
|
|
|
else
|
|
|
|
|
{
|
2010-12-31 23:59:52 +01:00
|
|
|
|
/* We're going to do a little error recovery here. If
|
|
|
|
|
we don't find a match for *scan on the paren stack,
|
|
|
|
|
but there is something lower on the stack that does
|
|
|
|
|
match, we pop the stack to that point. */
|
2000-02-05 08:30:26 +01:00
|
|
|
|
int i;
|
|
|
|
|
|
|
|
|
|
for (i = depth - 1; i >= 0; i--)
|
|
|
|
|
if (parenstack[i] == *scan)
|
|
|
|
|
{
|
|
|
|
|
depth = i;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (last)
|
|
|
|
|
return last;
|
|
|
|
|
else
|
|
|
|
|
/* We didn't find any :: tokens at the top level, so declare the
|
|
|
|
|
whole thing an unqualified identifier. */
|
|
|
|
|
return qid;
|
|
|
|
|
}
|
|
|
|
|
|
1999-04-16 03:35:26 +02:00
|
|
|
|
/* Print any array sizes, function arguments or close parentheses
|
|
|
|
|
needed after the variable name (to describe its type).
|
|
|
|
|
Args work like c_type_print_varspec_prefix. */
|
|
|
|
|
|
2018-04-17 21:51:22 +02:00
|
|
|
|
static void
|
2010-12-31 23:59:52 +01:00
|
|
|
|
c_type_print_varspec_suffix (struct type *type,
|
|
|
|
|
struct ui_file *stream,
|
|
|
|
|
int show, int passed_a_ptr,
|
* ada-lang.c (user_select_syms, ada_print_subexp): Pass flags
to type-printing functions.
* ada-lang.h (ada_print_type): Add argument.
* ada-typeprint.c (print_array_type, print_variant_clauses,
print_variant_part, print_selected_record_field_types,
print_record_field_types, print_unchecked_union_type,
print_func_type, ada_print_type): Add flags argument.
(ada_print_typedef): Update.
* c-exp.y (OPERATOR conversion_type_id): Update.
* c-lang.h (c_print_type, c_type_print_base): Update.
* c-typeprint.c (c_print_type, c_type_print_varspec_prefix,
c_type_print_modifier, c_type_print_args,
c_type_print_varspec_suffix, c_type_print_base): Add flags
argument.
* cp-valprint.c (cp_print_class_member): Update.
* dwarf2read.c (dwarf2_compute_name): Update.
* f-lang.h (f_print_type): Add argument.
* f-typeprint.c (f_print_type): Add flags argument.
* gnu-v3-abi.c (gnuv3_print_method_ptr): Update.
* go-lang.h (go_print_type): Add argument.
* go-typeprint.c (go_print_type): Add flags argument.
* jv-lang.h (java_print_type): Add argument.
* jv-typeprint.c (java_type_print_base, java_print_type): Add
flags argument.
* language.c (unk_lang_print_type): Add flags argument.
* language.h (struct language_defn) <la_print_type>: Add flags
argument.
(LA_PRINT_TYPE): Likewise.
* m2-lang.h (m2_print_type): Add argument.
* m2-typeprint.c (m2_print_type, m2_range, m2_typedef,
m2_array, m2_pointer, m2_ref, m2_procedure, m2_long_set,
m2_unbounded_array, m2_record_fields): Add flags argument.
* p-lang.h (pascal_print_type, pascal_type_print_base,
pascal_type_print_varspec_prefix): Add argument.
* p-typeprint.c (pascal_print_type,
pascal_type_print_varspec_prefix, pascal_print_func_args,
pascal_type_print_varspec_suffix, pascal_type_print_base): Add
flags argument.
* symmisc.c (print_symbol): Update.
* typeprint.c (type_print_raw_options, default_ptype_flags):
New globals.
(type_print): Update.
* typeprint.h (struct type_print_options): New.
(type_print_raw_options): Declare.
(c_type_print_varspec_suffix, c_type_print_args): Add argument.
2012-11-12 18:14:55 +01:00
|
|
|
|
int demangled_args,
|
2018-04-17 21:51:23 +02:00
|
|
|
|
enum language language,
|
* ada-lang.c (user_select_syms, ada_print_subexp): Pass flags
to type-printing functions.
* ada-lang.h (ada_print_type): Add argument.
* ada-typeprint.c (print_array_type, print_variant_clauses,
print_variant_part, print_selected_record_field_types,
print_record_field_types, print_unchecked_union_type,
print_func_type, ada_print_type): Add flags argument.
(ada_print_typedef): Update.
* c-exp.y (OPERATOR conversion_type_id): Update.
* c-lang.h (c_print_type, c_type_print_base): Update.
* c-typeprint.c (c_print_type, c_type_print_varspec_prefix,
c_type_print_modifier, c_type_print_args,
c_type_print_varspec_suffix, c_type_print_base): Add flags
argument.
* cp-valprint.c (cp_print_class_member): Update.
* dwarf2read.c (dwarf2_compute_name): Update.
* f-lang.h (f_print_type): Add argument.
* f-typeprint.c (f_print_type): Add flags argument.
* gnu-v3-abi.c (gnuv3_print_method_ptr): Update.
* go-lang.h (go_print_type): Add argument.
* go-typeprint.c (go_print_type): Add flags argument.
* jv-lang.h (java_print_type): Add argument.
* jv-typeprint.c (java_type_print_base, java_print_type): Add
flags argument.
* language.c (unk_lang_print_type): Add flags argument.
* language.h (struct language_defn) <la_print_type>: Add flags
argument.
(LA_PRINT_TYPE): Likewise.
* m2-lang.h (m2_print_type): Add argument.
* m2-typeprint.c (m2_print_type, m2_range, m2_typedef,
m2_array, m2_pointer, m2_ref, m2_procedure, m2_long_set,
m2_unbounded_array, m2_record_fields): Add flags argument.
* p-lang.h (pascal_print_type, pascal_type_print_base,
pascal_type_print_varspec_prefix): Add argument.
* p-typeprint.c (pascal_print_type,
pascal_type_print_varspec_prefix, pascal_print_func_args,
pascal_type_print_varspec_suffix, pascal_type_print_base): Add
flags argument.
* symmisc.c (print_symbol): Update.
* typeprint.c (type_print_raw_options, default_ptype_flags):
New globals.
(type_print): Update.
* typeprint.h (struct type_print_options): New.
(type_print_raw_options): Declare.
(c_type_print_varspec_suffix, c_type_print_args): Add argument.
2012-11-12 18:14:55 +01:00
|
|
|
|
const struct type_print_options *flags)
|
1999-04-16 03:35:26 +02:00
|
|
|
|
{
|
|
|
|
|
if (type == 0)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
if (TYPE_NAME (type) && show <= 0)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
QUIT;
|
|
|
|
|
|
|
|
|
|
switch (TYPE_CODE (type))
|
|
|
|
|
{
|
|
|
|
|
case TYPE_CODE_ARRAY:
|
2010-11-03 15:21:58 +01:00
|
|
|
|
{
|
|
|
|
|
LONGEST low_bound, high_bound;
|
2012-09-14 23:23:45 +02:00
|
|
|
|
int is_vector = TYPE_VECTOR (type);
|
1999-07-07 22:19:36 +02:00
|
|
|
|
|
2010-11-03 15:21:58 +01:00
|
|
|
|
if (passed_a_ptr)
|
|
|
|
|
fprintf_filtered (stream, ")");
|
1999-07-07 22:19:36 +02:00
|
|
|
|
|
2012-09-14 23:23:45 +02:00
|
|
|
|
fprintf_filtered (stream, (is_vector ?
|
2012-10-31 10:26:22 +01:00
|
|
|
|
" __attribute__ ((vector_size(" : "["));
|
2013-11-14 10:55:52 +01:00
|
|
|
|
/* Bounds are not yet resolved, print a bounds placeholder instead. */
|
|
|
|
|
if (TYPE_HIGH_BOUND_KIND (TYPE_INDEX_TYPE (type)) == PROP_LOCEXPR
|
|
|
|
|
|| TYPE_HIGH_BOUND_KIND (TYPE_INDEX_TYPE (type)) == PROP_LOCLIST)
|
|
|
|
|
fprintf_filtered (stream, "variable length");
|
|
|
|
|
else if (get_array_bounds (type, &low_bound, &high_bound))
|
2012-09-25 14:20:42 +02:00
|
|
|
|
fprintf_filtered (stream, "%s",
|
|
|
|
|
plongest (high_bound - low_bound + 1));
|
2012-09-14 23:23:45 +02:00
|
|
|
|
fprintf_filtered (stream, (is_vector ? ")))" : "]"));
|
2010-11-03 15:21:58 +01:00
|
|
|
|
|
2010-12-31 23:59:52 +01:00
|
|
|
|
c_type_print_varspec_suffix (TYPE_TARGET_TYPE (type), stream,
|
2018-04-17 21:51:23 +02:00
|
|
|
|
show, 0, 0, language, flags);
|
2010-11-03 15:21:58 +01:00
|
|
|
|
}
|
1999-04-16 03:35:26 +02:00
|
|
|
|
break;
|
|
|
|
|
|
* NEWS: Mention pointer to member improvements.
* Makefile.in (gnu-v3-abi.o): Delete special rule.
(eval.o, gnu-v3-abi.o, ia64-tdep.o): Update.
* ada-valprint.c (ada_print_scalar): Update for new type codes.
* c-typeprint.c (c_print_type): Update for new type codes.
(c_type_print_varspec_prefix, c_type_print_varspec_suffix)
(c_type_print_base): Likewise.
(c_type_print_args): Rewrite.
* c-valprint.c (c_val_print): Update for new type codes. Remove
support for references to members. Treat methods like functions.
* cp-abi.c (cplus_print_method_ptr, cplus_method_ptr_size)
(cplus_make_method_ptr, cplus_method_ptr_to_value): New.
* cp-abi.h (cplus_print_method_ptr, cplus_method_ptr_size)
(cplus_make_method_ptr, cplus_method_ptr_to_value): New prototypes.
(struct cp_abi_ops): Add corresponding members.
* cp-valprint.c (cp_print_class_method): Delete.
(cp_find_class_member): New function.
(cp_print_class_member): Use it. Simplify support for bogus
member pointers.
* dwarf2read.c (quirk_gcc_member_function_pointer): Use
lookup_methodptr_type.
(read_tag_ptr_to_member_type): Likewise, and lookup_memberptr_type.
* eval.c (evaluate_subexp_standard): Implement EVAL_SKIP for
OP_SCOPE. Update call to value_aggregate_elt. Rewrite member
pointer support.
(evaluate_subexp_for_address): Handle OP_SCOPE explicitly. Handle
references returned by user defined operators.
* f-typeprint.c (f_print_type, f_type_print_varspec_prefix)
(f_type_print_varspec_suffix): Remove support for member pointers.
* gdbtypes.c (lookup_memberptr_type): Renamed from lookup_member_type
and adjusted.
(smash_to_memberptr_type): Likewise, from smash_to_member_type.
(lookup_methodptr_type): New.
(rank_one_type): Adjust for TYPE_CODE_MEMBERPTR.
(recursive_dump_type): Update for new types.
* gdbtypes.h (enum type_code): Replace TYPE_CODE_MEMBER with
TYPE_CODE_MEMBERPTR and TYPE_CODE_METHODPTR.
(lookup_memberptr_type, lookup_methodptr_type)
(smash_to_memberptr_type): New prototypes.
(smash_to_method_type): Formatting fix.
(lookup_member_type, smash_to_member_type): Delete prototypes.
* gnu-v3-abi.c (gnuv3_get_vtable, gnuv3_get_virtual_fn): New.
Do not rely on debug information for the vptr or the method's
enclosing type. Handle function descriptors for IA64.
(gnuv3_virtual_fn_field): Rewrite using the new functions.
(gnuv3_find_method_in, gnuv3_print_method_ptr)
(gnuv3_method_ptr_size, gnuv3_make_method_ptr)
(gnuv3_method_ptr_to_value): New.
(init_gnuv3_ops): Set new members of gnu_v3_abi_ops.
* hpread.c (hpread_type_lookup): Update for new types.
* infcall.c (value_arg_coerce): Likewise.
* m2-typeprint.c (m2_print_type): Remove explicit support
for member pointers.
* m2-valprint.c (m2_val_print): Likewise.
* p-typeprint.c (pascal_type_print_varspec_prefix)
(pascal_type_print_varspec_suffix, pascal_type_print_base): Likewise.
* p-valprint.c (pascal_val_print): Likewise.
(pascal_object_print_class_method, pascal_object_print_class_member):
Delete.
* p-lang.h (pascal_object_print_class_method)
(pascal_object_print_class_member): Delete prototypes.
* stabsread.c (read_type): Update for new types.
* typeprint.c (print_type_scalar): Likewise.
* valops.c (value_struct_elt_for_reference, value_namespace_elt)
(value_maybe_namespace_elt, value_aggregate_elt): Add want_address
argument. Construct a pointer to member if the address of a
function or data member is requested.
(value_cast_pointers): Don't modify the input value.
(value_cast): Adjust pointer to member handling for new types.
Allow null pointer to member constants. Don't modify the input
value.
(value_ind): Remove pointer to member check. Handle function
descriptors for function pointers.
(value_struct_elt, value_find_oload_method_list, check_field):
Remove pointer to member checks.
* value.c (unpack_long): Allow pointers to data members.
(value_from_longest): Allow member pointers.
* value.h (value_aggregate_elt): Add want_address.
* varobj.c (c_variable_editable): Remove check for members.
* gdbarch.sh: Add vtable_function_descriptors and vbit_in_delta.
* ia64-tdep.c (ia64_convert_from_func_ptr_addr): Handle descriptors
in virtual tables.
(ia64_gdbarch_init): Call set_gdbarch_vtable_function_descriptors.
* c-lang.h (cp_print_class_method): Delete prototype.
* arm-tdep.c (arm_gdbarch_init): Call set_gdbarch_vbit_in_delta.
* mips-tdep.c (mips_gdbarch_init): Likewise.
* gdbarch.c, gdbarch.h: Regenerated.
* gdb.cp/classes.exp (test_pointers_to_class_members): Update expected
output. Test the types of members and member pointers.
* gdb.cp/inherit.exp (test_print_mi_member_types): Remove KFAILs for
gdb/2092.
* gdb.cp/member-ptr.exp: Search for a comment instead of a
statement. Enable for GCC. Update expected output for some tests
and add new tests. Remove obsolete GCC KFAILs. Allow GCC's class
layout.
* gdb.cp/member-ptr.cc (Padding, Padding::vspacer, Base, Base::get_x)
(Base::vget_base, Left, Left::vget, Right, Right::vget, Diamond)
(Diamond::vget_base): New.
(main): Add new tests.
* gdb.cp/printmethod.exp: Update expected output for member functions.
* gdb.cp/virtfunc.exp (test_virtual_calls): Add a KFAIL for
print pEe->D::vg().
2007-01-03 19:05:45 +01:00
|
|
|
|
case TYPE_CODE_MEMBERPTR:
|
2010-12-31 23:59:52 +01:00
|
|
|
|
c_type_print_varspec_suffix (TYPE_TARGET_TYPE (type), stream,
|
2018-04-17 21:51:23 +02:00
|
|
|
|
show, 0, 0, language, flags);
|
1999-04-16 03:35:26 +02:00
|
|
|
|
break;
|
|
|
|
|
|
* NEWS: Mention pointer to member improvements.
* Makefile.in (gnu-v3-abi.o): Delete special rule.
(eval.o, gnu-v3-abi.o, ia64-tdep.o): Update.
* ada-valprint.c (ada_print_scalar): Update for new type codes.
* c-typeprint.c (c_print_type): Update for new type codes.
(c_type_print_varspec_prefix, c_type_print_varspec_suffix)
(c_type_print_base): Likewise.
(c_type_print_args): Rewrite.
* c-valprint.c (c_val_print): Update for new type codes. Remove
support for references to members. Treat methods like functions.
* cp-abi.c (cplus_print_method_ptr, cplus_method_ptr_size)
(cplus_make_method_ptr, cplus_method_ptr_to_value): New.
* cp-abi.h (cplus_print_method_ptr, cplus_method_ptr_size)
(cplus_make_method_ptr, cplus_method_ptr_to_value): New prototypes.
(struct cp_abi_ops): Add corresponding members.
* cp-valprint.c (cp_print_class_method): Delete.
(cp_find_class_member): New function.
(cp_print_class_member): Use it. Simplify support for bogus
member pointers.
* dwarf2read.c (quirk_gcc_member_function_pointer): Use
lookup_methodptr_type.
(read_tag_ptr_to_member_type): Likewise, and lookup_memberptr_type.
* eval.c (evaluate_subexp_standard): Implement EVAL_SKIP for
OP_SCOPE. Update call to value_aggregate_elt. Rewrite member
pointer support.
(evaluate_subexp_for_address): Handle OP_SCOPE explicitly. Handle
references returned by user defined operators.
* f-typeprint.c (f_print_type, f_type_print_varspec_prefix)
(f_type_print_varspec_suffix): Remove support for member pointers.
* gdbtypes.c (lookup_memberptr_type): Renamed from lookup_member_type
and adjusted.
(smash_to_memberptr_type): Likewise, from smash_to_member_type.
(lookup_methodptr_type): New.
(rank_one_type): Adjust for TYPE_CODE_MEMBERPTR.
(recursive_dump_type): Update for new types.
* gdbtypes.h (enum type_code): Replace TYPE_CODE_MEMBER with
TYPE_CODE_MEMBERPTR and TYPE_CODE_METHODPTR.
(lookup_memberptr_type, lookup_methodptr_type)
(smash_to_memberptr_type): New prototypes.
(smash_to_method_type): Formatting fix.
(lookup_member_type, smash_to_member_type): Delete prototypes.
* gnu-v3-abi.c (gnuv3_get_vtable, gnuv3_get_virtual_fn): New.
Do not rely on debug information for the vptr or the method's
enclosing type. Handle function descriptors for IA64.
(gnuv3_virtual_fn_field): Rewrite using the new functions.
(gnuv3_find_method_in, gnuv3_print_method_ptr)
(gnuv3_method_ptr_size, gnuv3_make_method_ptr)
(gnuv3_method_ptr_to_value): New.
(init_gnuv3_ops): Set new members of gnu_v3_abi_ops.
* hpread.c (hpread_type_lookup): Update for new types.
* infcall.c (value_arg_coerce): Likewise.
* m2-typeprint.c (m2_print_type): Remove explicit support
for member pointers.
* m2-valprint.c (m2_val_print): Likewise.
* p-typeprint.c (pascal_type_print_varspec_prefix)
(pascal_type_print_varspec_suffix, pascal_type_print_base): Likewise.
* p-valprint.c (pascal_val_print): Likewise.
(pascal_object_print_class_method, pascal_object_print_class_member):
Delete.
* p-lang.h (pascal_object_print_class_method)
(pascal_object_print_class_member): Delete prototypes.
* stabsread.c (read_type): Update for new types.
* typeprint.c (print_type_scalar): Likewise.
* valops.c (value_struct_elt_for_reference, value_namespace_elt)
(value_maybe_namespace_elt, value_aggregate_elt): Add want_address
argument. Construct a pointer to member if the address of a
function or data member is requested.
(value_cast_pointers): Don't modify the input value.
(value_cast): Adjust pointer to member handling for new types.
Allow null pointer to member constants. Don't modify the input
value.
(value_ind): Remove pointer to member check. Handle function
descriptors for function pointers.
(value_struct_elt, value_find_oload_method_list, check_field):
Remove pointer to member checks.
* value.c (unpack_long): Allow pointers to data members.
(value_from_longest): Allow member pointers.
* value.h (value_aggregate_elt): Add want_address.
* varobj.c (c_variable_editable): Remove check for members.
* gdbarch.sh: Add vtable_function_descriptors and vbit_in_delta.
* ia64-tdep.c (ia64_convert_from_func_ptr_addr): Handle descriptors
in virtual tables.
(ia64_gdbarch_init): Call set_gdbarch_vtable_function_descriptors.
* c-lang.h (cp_print_class_method): Delete prototype.
* arm-tdep.c (arm_gdbarch_init): Call set_gdbarch_vbit_in_delta.
* mips-tdep.c (mips_gdbarch_init): Likewise.
* gdbarch.c, gdbarch.h: Regenerated.
* gdb.cp/classes.exp (test_pointers_to_class_members): Update expected
output. Test the types of members and member pointers.
* gdb.cp/inherit.exp (test_print_mi_member_types): Remove KFAILs for
gdb/2092.
* gdb.cp/member-ptr.exp: Search for a comment instead of a
statement. Enable for GCC. Update expected output for some tests
and add new tests. Remove obsolete GCC KFAILs. Allow GCC's class
layout.
* gdb.cp/member-ptr.cc (Padding, Padding::vspacer, Base, Base::get_x)
(Base::vget_base, Left, Left::vget, Right, Right::vget, Diamond)
(Diamond::vget_base): New.
(main): Add new tests.
* gdb.cp/printmethod.exp: Update expected output for member functions.
* gdb.cp/virtfunc.exp (test_virtual_calls): Add a KFAIL for
print pEe->D::vg().
2007-01-03 19:05:45 +01:00
|
|
|
|
case TYPE_CODE_METHODPTR:
|
|
|
|
|
fprintf_filtered (stream, ")");
|
2010-12-31 23:59:52 +01:00
|
|
|
|
c_type_print_varspec_suffix (TYPE_TARGET_TYPE (type), stream,
|
2018-04-17 21:51:23 +02:00
|
|
|
|
show, 0, 0, language, flags);
|
1999-04-16 03:35:26 +02:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case TYPE_CODE_PTR:
|
|
|
|
|
case TYPE_CODE_REF:
|
2017-03-20 21:47:48 +01:00
|
|
|
|
case TYPE_CODE_RVALUE_REF:
|
2010-12-31 23:59:52 +01:00
|
|
|
|
c_type_print_varspec_suffix (TYPE_TARGET_TYPE (type), stream,
|
2018-04-17 21:51:23 +02:00
|
|
|
|
show, 1, 0, language, flags);
|
1999-04-16 03:35:26 +02:00
|
|
|
|
break;
|
|
|
|
|
|
* NEWS: Mention pointer to member improvements.
* Makefile.in (gnu-v3-abi.o): Delete special rule.
(eval.o, gnu-v3-abi.o, ia64-tdep.o): Update.
* ada-valprint.c (ada_print_scalar): Update for new type codes.
* c-typeprint.c (c_print_type): Update for new type codes.
(c_type_print_varspec_prefix, c_type_print_varspec_suffix)
(c_type_print_base): Likewise.
(c_type_print_args): Rewrite.
* c-valprint.c (c_val_print): Update for new type codes. Remove
support for references to members. Treat methods like functions.
* cp-abi.c (cplus_print_method_ptr, cplus_method_ptr_size)
(cplus_make_method_ptr, cplus_method_ptr_to_value): New.
* cp-abi.h (cplus_print_method_ptr, cplus_method_ptr_size)
(cplus_make_method_ptr, cplus_method_ptr_to_value): New prototypes.
(struct cp_abi_ops): Add corresponding members.
* cp-valprint.c (cp_print_class_method): Delete.
(cp_find_class_member): New function.
(cp_print_class_member): Use it. Simplify support for bogus
member pointers.
* dwarf2read.c (quirk_gcc_member_function_pointer): Use
lookup_methodptr_type.
(read_tag_ptr_to_member_type): Likewise, and lookup_memberptr_type.
* eval.c (evaluate_subexp_standard): Implement EVAL_SKIP for
OP_SCOPE. Update call to value_aggregate_elt. Rewrite member
pointer support.
(evaluate_subexp_for_address): Handle OP_SCOPE explicitly. Handle
references returned by user defined operators.
* f-typeprint.c (f_print_type, f_type_print_varspec_prefix)
(f_type_print_varspec_suffix): Remove support for member pointers.
* gdbtypes.c (lookup_memberptr_type): Renamed from lookup_member_type
and adjusted.
(smash_to_memberptr_type): Likewise, from smash_to_member_type.
(lookup_methodptr_type): New.
(rank_one_type): Adjust for TYPE_CODE_MEMBERPTR.
(recursive_dump_type): Update for new types.
* gdbtypes.h (enum type_code): Replace TYPE_CODE_MEMBER with
TYPE_CODE_MEMBERPTR and TYPE_CODE_METHODPTR.
(lookup_memberptr_type, lookup_methodptr_type)
(smash_to_memberptr_type): New prototypes.
(smash_to_method_type): Formatting fix.
(lookup_member_type, smash_to_member_type): Delete prototypes.
* gnu-v3-abi.c (gnuv3_get_vtable, gnuv3_get_virtual_fn): New.
Do not rely on debug information for the vptr or the method's
enclosing type. Handle function descriptors for IA64.
(gnuv3_virtual_fn_field): Rewrite using the new functions.
(gnuv3_find_method_in, gnuv3_print_method_ptr)
(gnuv3_method_ptr_size, gnuv3_make_method_ptr)
(gnuv3_method_ptr_to_value): New.
(init_gnuv3_ops): Set new members of gnu_v3_abi_ops.
* hpread.c (hpread_type_lookup): Update for new types.
* infcall.c (value_arg_coerce): Likewise.
* m2-typeprint.c (m2_print_type): Remove explicit support
for member pointers.
* m2-valprint.c (m2_val_print): Likewise.
* p-typeprint.c (pascal_type_print_varspec_prefix)
(pascal_type_print_varspec_suffix, pascal_type_print_base): Likewise.
* p-valprint.c (pascal_val_print): Likewise.
(pascal_object_print_class_method, pascal_object_print_class_member):
Delete.
* p-lang.h (pascal_object_print_class_method)
(pascal_object_print_class_member): Delete prototypes.
* stabsread.c (read_type): Update for new types.
* typeprint.c (print_type_scalar): Likewise.
* valops.c (value_struct_elt_for_reference, value_namespace_elt)
(value_maybe_namespace_elt, value_aggregate_elt): Add want_address
argument. Construct a pointer to member if the address of a
function or data member is requested.
(value_cast_pointers): Don't modify the input value.
(value_cast): Adjust pointer to member handling for new types.
Allow null pointer to member constants. Don't modify the input
value.
(value_ind): Remove pointer to member check. Handle function
descriptors for function pointers.
(value_struct_elt, value_find_oload_method_list, check_field):
Remove pointer to member checks.
* value.c (unpack_long): Allow pointers to data members.
(value_from_longest): Allow member pointers.
* value.h (value_aggregate_elt): Add want_address.
* varobj.c (c_variable_editable): Remove check for members.
* gdbarch.sh: Add vtable_function_descriptors and vbit_in_delta.
* ia64-tdep.c (ia64_convert_from_func_ptr_addr): Handle descriptors
in virtual tables.
(ia64_gdbarch_init): Call set_gdbarch_vtable_function_descriptors.
* c-lang.h (cp_print_class_method): Delete prototype.
* arm-tdep.c (arm_gdbarch_init): Call set_gdbarch_vbit_in_delta.
* mips-tdep.c (mips_gdbarch_init): Likewise.
* gdbarch.c, gdbarch.h: Regenerated.
* gdb.cp/classes.exp (test_pointers_to_class_members): Update expected
output. Test the types of members and member pointers.
* gdb.cp/inherit.exp (test_print_mi_member_types): Remove KFAILs for
gdb/2092.
* gdb.cp/member-ptr.exp: Search for a comment instead of a
statement. Enable for GCC. Update expected output for some tests
and add new tests. Remove obsolete GCC KFAILs. Allow GCC's class
layout.
* gdb.cp/member-ptr.cc (Padding, Padding::vspacer, Base, Base::get_x)
(Base::vget_base, Left, Left::vget, Right, Right::vget, Diamond)
(Diamond::vget_base): New.
(main): Add new tests.
* gdb.cp/printmethod.exp: Update expected output for member functions.
* gdb.cp/virtfunc.exp (test_virtual_calls): Add a KFAIL for
print pEe->D::vg().
2007-01-03 19:05:45 +01:00
|
|
|
|
case TYPE_CODE_METHOD:
|
1999-04-16 03:35:26 +02:00
|
|
|
|
case TYPE_CODE_FUNC:
|
|
|
|
|
if (passed_a_ptr)
|
|
|
|
|
fprintf_filtered (stream, ")");
|
|
|
|
|
if (!demangled_args)
|
2018-04-17 21:51:23 +02:00
|
|
|
|
c_type_print_args (type, stream, 0, language, flags);
|
2010-12-31 23:59:52 +01:00
|
|
|
|
c_type_print_varspec_suffix (TYPE_TARGET_TYPE (type), stream,
|
2018-04-17 21:51:23 +02:00
|
|
|
|
show, passed_a_ptr, 0, language, flags);
|
2003-01-04 22:51:53 +01:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case TYPE_CODE_TYPEDEF:
|
2010-12-31 23:59:52 +01:00
|
|
|
|
c_type_print_varspec_suffix (TYPE_TARGET_TYPE (type), stream,
|
2018-04-17 21:51:23 +02:00
|
|
|
|
show, passed_a_ptr, 0, language, flags);
|
1999-04-16 03:35:26 +02:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case TYPE_CODE_UNDEF:
|
|
|
|
|
case TYPE_CODE_STRUCT:
|
|
|
|
|
case TYPE_CODE_UNION:
|
2016-03-15 22:37:29 +01:00
|
|
|
|
case TYPE_CODE_FLAGS:
|
1999-04-16 03:35:26 +02:00
|
|
|
|
case TYPE_CODE_ENUM:
|
|
|
|
|
case TYPE_CODE_INT:
|
|
|
|
|
case TYPE_CODE_FLT:
|
|
|
|
|
case TYPE_CODE_VOID:
|
|
|
|
|
case TYPE_CODE_ERROR:
|
|
|
|
|
case TYPE_CODE_CHAR:
|
|
|
|
|
case TYPE_CODE_BOOL:
|
|
|
|
|
case TYPE_CODE_SET:
|
|
|
|
|
case TYPE_CODE_RANGE:
|
|
|
|
|
case TYPE_CODE_STRING:
|
|
|
|
|
case TYPE_CODE_COMPLEX:
|
2003-09-11 David Carlton <carlton@kealia.com>
* gdbtypes.h: Add TYPE_CODE_NAMESPACE.
* gdbtypes.c (init_type): Handle TYPE_CODE_NAMESPACE.
(recursive_dump_type): Ditto.
* printcmd.c (print_formatted): Ditto.
* typeprint.c (print_type_scalar): Ditto.
* c-typeprint.c (c_type_print_varspec_prefix): Ditto.
(c_type_print_varspec_suffix, c_type_print_base): Ditto.
* cp-support.h: Declare cp_check_possible_namespace_symbols,
maint_cplus_cmd_list.
* cp-support.c: Make maint_cplus_cmd_list extern.
* cp-namespace.c: Include objfiles.h, gdbtypes.h, dictionary.h,
command.h.
(lookup_symbol_file): Look in possible namespace blocks when
appropriate.
(initialize_namespace_symtab): New.
(get_possible_namespace_block, free_namespace_block)
(check_possible_namespace_symbols)
(check_possible_namespace_symbols_loop)
(check_one_possible_namespace_symbol)
(lookup_possible_namespace_symbol, maintenance_cplus_namespace)
(_initialize_cp_namespace): Ditto.
* block.h: Declare allocate_block.
* block.c (allocate_block): New.
* jv-lang.c (get_java_class_symtab): Allocate blocks via
allocate_block.
* symfile.h: Update declaration of add_psymbol_to_list.
* symfile.c (add_psymbol_to_list): Return the partial symbol in
question.
* dwarf2read.c (dwarf2_build_psymtabs_hard): Add argument to
scan_partial_symbols_call.
(scan_partial_symbols): Add NAMESPACE argument; update calls to
helper functions.
(add_partial_symbol): If necessary, scan mangled names for names
of namespaces.
(add_partial_namespace): Add NAMESPACE argument; generate partial
symbols associated to namespaces.
(add_partial_enumeration): Add NAMESPACE argument.
(new_symbol): Allow namespace syms.
(read_namespace): Generate namespace syms.
* objfiles.h: Add opaque declaration of struct symtab.
(struct objfile): Add cp_namespace_symtab member.
* objfiles.c (allocate_objfile): Set
objfile->cp_namespace_symtab.
* Makefile.in (cp-namespace.o): Depend on objfiles_h, gdbtypes_h,
dictionary_h, command_h.
2003-09-11 David Carlton <carlton@kealia.com>
* gdb.c++/namespace.exp: Add tests for namespace types.
* gdb.c++/maint.exp (test_help): Test 'help maint cp namespace'.
(test_namespace): New.
2003-09-11 21:49:20 +02:00
|
|
|
|
case TYPE_CODE_NAMESPACE:
|
2007-10-25 19:57:34 +02:00
|
|
|
|
case TYPE_CODE_DECFLOAT:
|
1999-04-16 03:35:26 +02:00
|
|
|
|
/* These types do not need a suffix. They are listed so that
|
2010-12-31 23:59:52 +01:00
|
|
|
|
gcc -Wall will report types that may not have been
|
|
|
|
|
considered. */
|
1999-04-16 03:35:26 +02:00
|
|
|
|
break;
|
1999-12-14 02:06:04 +01:00
|
|
|
|
default:
|
2005-01-29 Baurzhan Ismagulov <ibr@radix50.net>
* ax-gdb.c, ax-general.c, bcache.c, bfd-target.c, bsd-kvm.c,
* buildsym.c, c-lang.c, c-typeprint.c, c-valprint.c, charset.c,
* coff-pe-read.c, coffread.c, complaints.c, copying.c: I18n markup.
2005-01-29 18:53:26 +01:00
|
|
|
|
error (_("type not handled in c_type_print_varspec_suffix()"));
|
1999-12-14 02:06:04 +01:00
|
|
|
|
break;
|
1999-04-16 03:35:26 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
* c-typeprint.c (find_typedef_for_canonicalize,
print_name_maybe_canonical): New functions.
(c_print_type): Look up type name.
(cp_type_print_derivation_info): Add flags argument. Use
print_name_maybe_canonical.
(cp_type_print_method_args): Add wrapping.
(c_type_print_varspec_prefix): Use print_name_maybe_canonical.
(c_type_print_template_args): New function.
(c_type_print_base): Change wrapping. Use
print_name_maybe_canonical.
<TYPE_CODE_STRUCT>: Possibly create a typedef hash, and do
type name lookups.
* gdbtypes.c (types_equal): No longer static.
* gdbtypes.h (types_equal): Declare.
* typeprint.c (type_print_raw_options, default_ptype_flags):
Update.
(struct typedef_hash_table): New.
(hash_typedef_field, eq_typedef_field,
recursively_update_typedef_hash, add_template_parameters,
create_typedef_hash, free_typedef_hash, do_free_typedef_hash,
make_cleanup_free_typedef_hash, copy_typedef_hash_element,
copy_typedef_hash, find_typedef_in_hash): New functions.
* typeprint.h (struct type_print_options) <local_typedefs>:
New field.
(recursively_update_typedef_hash, add_template_parameters,
create_typedef_hash, free_typedef_hash,
make_cleanup_free_typedef_hash, copy_typedef_hash,
find_typedef_in_hash): Declare.
testsuite
* gdb.base/call-sc.exp: Use "ptype/r".
* gdb.base/volatile.exp: Don't expect "int".
* gdb.cp/ptype-flags.cc: New file.
* gdb.cp/ptype-flags.exp: New file.
* gdb.cp/templates.exp: Use ptype/r.
(test_ptype_of_templates, test_template_typedef): Likewise.
* lib/cp-support.exp (cp_test_ptype_class): Add in_ptype_arg
argument. Handle template names and template parameters.
* gdb.mi/mi-var-cmd.exp: Accept "long".
* gdb.mi/mi-var-child.exp: Accept "long".
* gdb.mi/mi-var-display.exp: Accept "long".
* gdb.mi/mi2-var-child.exp: Accept "long".
2012-11-12 18:37:38 +01:00
|
|
|
|
/* A helper for c_type_print_base that displays template
|
|
|
|
|
parameters and their bindings, if needed.
|
|
|
|
|
|
|
|
|
|
TABLE is the local bindings table to use. If NULL, no printing is
|
|
|
|
|
done. Note that, at this point, TABLE won't have any useful
|
|
|
|
|
information in it -- but it is also used as a flag to
|
|
|
|
|
print_name_maybe_canonical to activate searching the global typedef
|
|
|
|
|
table.
|
|
|
|
|
|
|
|
|
|
TYPE is the type whose template arguments are being displayed.
|
|
|
|
|
|
|
|
|
|
STREAM is the stream on which to print. */
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
c_type_print_template_args (const struct type_print_options *flags,
|
|
|
|
|
struct type *type, struct ui_file *stream)
|
|
|
|
|
{
|
|
|
|
|
int first = 1, i;
|
|
|
|
|
|
|
|
|
|
if (flags->raw)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
for (i = 0; i < TYPE_N_TEMPLATE_ARGUMENTS (type); ++i)
|
|
|
|
|
{
|
|
|
|
|
struct symbol *sym = TYPE_TEMPLATE_ARGUMENT (type, i);
|
|
|
|
|
|
|
|
|
|
if (SYMBOL_CLASS (sym) != LOC_TYPEDEF)
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
if (first)
|
|
|
|
|
{
|
|
|
|
|
wrap_here (" ");
|
|
|
|
|
fprintf_filtered (stream, _("[with %s = "),
|
|
|
|
|
SYMBOL_LINKAGE_NAME (sym));
|
|
|
|
|
first = 0;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
fputs_filtered (", ", stream);
|
|
|
|
|
wrap_here (" ");
|
|
|
|
|
fprintf_filtered (stream, "%s = ", SYMBOL_LINKAGE_NAME (sym));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
c_print_type (SYMBOL_TYPE (sym), "", stream, -1, 0, flags);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!first)
|
|
|
|
|
fputs_filtered (_("] "), stream);
|
|
|
|
|
}
|
|
|
|
|
|
Implement pahole-like 'ptype /o' option
This commit implements the pahole-like '/o' option for 'ptype', which
prints the offsets and sizes of struct fields, reporting whenever
there is a hole found.
The output is heavily based on pahole(1), with a few modifications
here and there to adjust it to our reality. Here's an example:
/* offset | size */ type = struct wer : public tuv {
public:
/* 32 | 24 */ struct tyu {
/* 32:31 | 4 */ int a1 : 1;
/* 32:28 | 4 */ int a2 : 3;
/* 32: 5 | 4 */ int a3 : 23;
/* 35: 3 | 1 */ char a4 : 2;
/* XXX 3-bit hole */
/* XXX 4-byte hole */
/* 40 | 8 */ int64_t a5;
/* 48:27 | 4 */ int a6 : 5;
/* 48:56 | 8 */ int64_t a7 : 3;
/* total size (bytes): 24 */
} a1;
/* total size (bytes): 56 */
}
A big part of this patch handles the formatting logic of 'ptype',
which is a bit messy. The code to handle bitfield offsets, however,
took some time to craft. My thanks to Pedro Alves for figuring things
out and pointing me to the right direction, as well as coming up with
a way to inspect the layout of structs with bitfields (see testcase
for comments).
After many discussions both on IRC and at the mailing list, I tried to
implement printing vtables and inherited classes. Unfortunately the
code grew too complex and there were still a few corner cases failing
so I had to drop the attempt. This should be implemented in a future
patch.
This patch is the start of a long-term work I'll do to flush the local
patches we carry for Fedora GDB. In this specific case, I'm aiming at
upstreaming the feature implemented by the 'pahole.py' script that is
shipped with Fedora GDB:
<https://src.fedoraproject.org/rpms/gdb/blob/master/f/gdb-archer.patch#_311>
This has been regression-tested on the BuildBot. There's a new
testcase for it, along with an update to the documentation. I also
thought it was worth mentioning this feature in the NEWS file.
gdb/ChangeLog:
2017-12-15 Sergio Durigan Junior <sergiodj@redhat.com>
Pedro Alves <palves@redhat.com>
PR cli/16224
* NEWS (Changes since GDB 8.0): Mention new '/o' flag.
* c-typeprint.c (OFFSET_SPC_LEN): New define.
(c_type_print_varspec_prefix): New argument 'struct
print_offset_data *'.
(c_type_print_base_1): New function and prototype.
(c_print_type_1): New function, with code from 'c_print_type'.
(c_print_type): Use 'c_print_type_1'.
(c_type_print_varspec_prefix): New argument 'struct
print_offset_data *'. Use it. Call 'c_type_print_base_1'
instead of 'c_print_type_base'.
(print_spaces_filtered_with_print_options): New function.
(output_access_specifier): Take new argument FLAGS. Modify
function to call 'print_spaces_filtered_with_print_options'.
(c_print_type_vtable_offset_marker): New function.
(c_print_type_union_field_offset): New function.
(c_print_type_struct_field_offset): New function.
(c_print_type_no_offsets): New function.
(c_type_print_base_struct_union): New argument 'struct
print_offset_data *'. Print offsets and sizes for
struct/union/class fields.
* typeprint.c (const struct type_print_options
type_print_raw_options): Initialize 'print_offsets'.
(static struct type_print_options default_ptype_flags):
Likewise.
(struct print_offset_data print_offset_default_data): New
variable.
(whatis_exp): Handle '/o' option.
(_initialize_typeprint): Add '/o' flag to ptype's help.
* typeprint.h (struct print_offset_data): New struct.
(struct type_print_options) <print_offsets>: New field.
gdb/testsuite/ChangeLog:
2017-12-15 Sergio Durigan Junior <sergiodj@redhat.com>
PR cli/16224
* gdb.base/ptype-offsets.cc: New file.
* gdb.base/ptype-offsets.exp: New file.
gdb/doc/ChangeLog:
2017-12-15 Sergio Durigan Junior <sergiodj@redhat.com>
PR cli/16224
* gdb.texinfo (ptype): Add documentation for new flag '/o'.
2017-11-20 22:34:59 +01:00
|
|
|
|
/* Use 'print_spaces_filtered', but take into consideration the
|
|
|
|
|
type_print_options FLAGS in order to determine how many whitespaces
|
|
|
|
|
will be printed. */
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
print_spaces_filtered_with_print_options
|
|
|
|
|
(int level, struct ui_file *stream, const struct type_print_options *flags)
|
|
|
|
|
{
|
|
|
|
|
if (!flags->print_offsets)
|
|
|
|
|
print_spaces_filtered (level, stream);
|
|
|
|
|
else
|
2018-06-08 20:43:47 +02:00
|
|
|
|
print_spaces_filtered (level + print_offset_data::indentation, stream);
|
Implement pahole-like 'ptype /o' option
This commit implements the pahole-like '/o' option for 'ptype', which
prints the offsets and sizes of struct fields, reporting whenever
there is a hole found.
The output is heavily based on pahole(1), with a few modifications
here and there to adjust it to our reality. Here's an example:
/* offset | size */ type = struct wer : public tuv {
public:
/* 32 | 24 */ struct tyu {
/* 32:31 | 4 */ int a1 : 1;
/* 32:28 | 4 */ int a2 : 3;
/* 32: 5 | 4 */ int a3 : 23;
/* 35: 3 | 1 */ char a4 : 2;
/* XXX 3-bit hole */
/* XXX 4-byte hole */
/* 40 | 8 */ int64_t a5;
/* 48:27 | 4 */ int a6 : 5;
/* 48:56 | 8 */ int64_t a7 : 3;
/* total size (bytes): 24 */
} a1;
/* total size (bytes): 56 */
}
A big part of this patch handles the formatting logic of 'ptype',
which is a bit messy. The code to handle bitfield offsets, however,
took some time to craft. My thanks to Pedro Alves for figuring things
out and pointing me to the right direction, as well as coming up with
a way to inspect the layout of structs with bitfields (see testcase
for comments).
After many discussions both on IRC and at the mailing list, I tried to
implement printing vtables and inherited classes. Unfortunately the
code grew too complex and there were still a few corner cases failing
so I had to drop the attempt. This should be implemented in a future
patch.
This patch is the start of a long-term work I'll do to flush the local
patches we carry for Fedora GDB. In this specific case, I'm aiming at
upstreaming the feature implemented by the 'pahole.py' script that is
shipped with Fedora GDB:
<https://src.fedoraproject.org/rpms/gdb/blob/master/f/gdb-archer.patch#_311>
This has been regression-tested on the BuildBot. There's a new
testcase for it, along with an update to the documentation. I also
thought it was worth mentioning this feature in the NEWS file.
gdb/ChangeLog:
2017-12-15 Sergio Durigan Junior <sergiodj@redhat.com>
Pedro Alves <palves@redhat.com>
PR cli/16224
* NEWS (Changes since GDB 8.0): Mention new '/o' flag.
* c-typeprint.c (OFFSET_SPC_LEN): New define.
(c_type_print_varspec_prefix): New argument 'struct
print_offset_data *'.
(c_type_print_base_1): New function and prototype.
(c_print_type_1): New function, with code from 'c_print_type'.
(c_print_type): Use 'c_print_type_1'.
(c_type_print_varspec_prefix): New argument 'struct
print_offset_data *'. Use it. Call 'c_type_print_base_1'
instead of 'c_print_type_base'.
(print_spaces_filtered_with_print_options): New function.
(output_access_specifier): Take new argument FLAGS. Modify
function to call 'print_spaces_filtered_with_print_options'.
(c_print_type_vtable_offset_marker): New function.
(c_print_type_union_field_offset): New function.
(c_print_type_struct_field_offset): New function.
(c_print_type_no_offsets): New function.
(c_type_print_base_struct_union): New argument 'struct
print_offset_data *'. Print offsets and sizes for
struct/union/class fields.
* typeprint.c (const struct type_print_options
type_print_raw_options): Initialize 'print_offsets'.
(static struct type_print_options default_ptype_flags):
Likewise.
(struct print_offset_data print_offset_default_data): New
variable.
(whatis_exp): Handle '/o' option.
(_initialize_typeprint): Add '/o' flag to ptype's help.
* typeprint.h (struct print_offset_data): New struct.
(struct type_print_options) <print_offsets>: New field.
gdb/testsuite/ChangeLog:
2017-12-15 Sergio Durigan Junior <sergiodj@redhat.com>
PR cli/16224
* gdb.base/ptype-offsets.cc: New file.
* gdb.base/ptype-offsets.exp: New file.
gdb/doc/ChangeLog:
2017-12-15 Sergio Durigan Junior <sergiodj@redhat.com>
PR cli/16224
* gdb.texinfo (ptype): Add documentation for new flag '/o'.
2017-11-20 22:34:59 +01:00
|
|
|
|
}
|
|
|
|
|
|
2017-10-17 02:19:29 +02:00
|
|
|
|
/* Output an access specifier to STREAM, if needed. LAST_ACCESS is the
|
|
|
|
|
last access specifier output (typically returned by this function). */
|
|
|
|
|
|
|
|
|
|
static enum access_specifier
|
|
|
|
|
output_access_specifier (struct ui_file *stream,
|
|
|
|
|
enum access_specifier last_access,
|
Implement pahole-like 'ptype /o' option
This commit implements the pahole-like '/o' option for 'ptype', which
prints the offsets and sizes of struct fields, reporting whenever
there is a hole found.
The output is heavily based on pahole(1), with a few modifications
here and there to adjust it to our reality. Here's an example:
/* offset | size */ type = struct wer : public tuv {
public:
/* 32 | 24 */ struct tyu {
/* 32:31 | 4 */ int a1 : 1;
/* 32:28 | 4 */ int a2 : 3;
/* 32: 5 | 4 */ int a3 : 23;
/* 35: 3 | 1 */ char a4 : 2;
/* XXX 3-bit hole */
/* XXX 4-byte hole */
/* 40 | 8 */ int64_t a5;
/* 48:27 | 4 */ int a6 : 5;
/* 48:56 | 8 */ int64_t a7 : 3;
/* total size (bytes): 24 */
} a1;
/* total size (bytes): 56 */
}
A big part of this patch handles the formatting logic of 'ptype',
which is a bit messy. The code to handle bitfield offsets, however,
took some time to craft. My thanks to Pedro Alves for figuring things
out and pointing me to the right direction, as well as coming up with
a way to inspect the layout of structs with bitfields (see testcase
for comments).
After many discussions both on IRC and at the mailing list, I tried to
implement printing vtables and inherited classes. Unfortunately the
code grew too complex and there were still a few corner cases failing
so I had to drop the attempt. This should be implemented in a future
patch.
This patch is the start of a long-term work I'll do to flush the local
patches we carry for Fedora GDB. In this specific case, I'm aiming at
upstreaming the feature implemented by the 'pahole.py' script that is
shipped with Fedora GDB:
<https://src.fedoraproject.org/rpms/gdb/blob/master/f/gdb-archer.patch#_311>
This has been regression-tested on the BuildBot. There's a new
testcase for it, along with an update to the documentation. I also
thought it was worth mentioning this feature in the NEWS file.
gdb/ChangeLog:
2017-12-15 Sergio Durigan Junior <sergiodj@redhat.com>
Pedro Alves <palves@redhat.com>
PR cli/16224
* NEWS (Changes since GDB 8.0): Mention new '/o' flag.
* c-typeprint.c (OFFSET_SPC_LEN): New define.
(c_type_print_varspec_prefix): New argument 'struct
print_offset_data *'.
(c_type_print_base_1): New function and prototype.
(c_print_type_1): New function, with code from 'c_print_type'.
(c_print_type): Use 'c_print_type_1'.
(c_type_print_varspec_prefix): New argument 'struct
print_offset_data *'. Use it. Call 'c_type_print_base_1'
instead of 'c_print_type_base'.
(print_spaces_filtered_with_print_options): New function.
(output_access_specifier): Take new argument FLAGS. Modify
function to call 'print_spaces_filtered_with_print_options'.
(c_print_type_vtable_offset_marker): New function.
(c_print_type_union_field_offset): New function.
(c_print_type_struct_field_offset): New function.
(c_print_type_no_offsets): New function.
(c_type_print_base_struct_union): New argument 'struct
print_offset_data *'. Print offsets and sizes for
struct/union/class fields.
* typeprint.c (const struct type_print_options
type_print_raw_options): Initialize 'print_offsets'.
(static struct type_print_options default_ptype_flags):
Likewise.
(struct print_offset_data print_offset_default_data): New
variable.
(whatis_exp): Handle '/o' option.
(_initialize_typeprint): Add '/o' flag to ptype's help.
* typeprint.h (struct print_offset_data): New struct.
(struct type_print_options) <print_offsets>: New field.
gdb/testsuite/ChangeLog:
2017-12-15 Sergio Durigan Junior <sergiodj@redhat.com>
PR cli/16224
* gdb.base/ptype-offsets.cc: New file.
* gdb.base/ptype-offsets.exp: New file.
gdb/doc/ChangeLog:
2017-12-15 Sergio Durigan Junior <sergiodj@redhat.com>
PR cli/16224
* gdb.texinfo (ptype): Add documentation for new flag '/o'.
2017-11-20 22:34:59 +01:00
|
|
|
|
int level, bool is_protected, bool is_private,
|
|
|
|
|
const struct type_print_options *flags)
|
2017-10-17 02:19:29 +02:00
|
|
|
|
{
|
|
|
|
|
if (is_protected)
|
|
|
|
|
{
|
|
|
|
|
if (last_access != s_protected)
|
|
|
|
|
{
|
|
|
|
|
last_access = s_protected;
|
Implement pahole-like 'ptype /o' option
This commit implements the pahole-like '/o' option for 'ptype', which
prints the offsets and sizes of struct fields, reporting whenever
there is a hole found.
The output is heavily based on pahole(1), with a few modifications
here and there to adjust it to our reality. Here's an example:
/* offset | size */ type = struct wer : public tuv {
public:
/* 32 | 24 */ struct tyu {
/* 32:31 | 4 */ int a1 : 1;
/* 32:28 | 4 */ int a2 : 3;
/* 32: 5 | 4 */ int a3 : 23;
/* 35: 3 | 1 */ char a4 : 2;
/* XXX 3-bit hole */
/* XXX 4-byte hole */
/* 40 | 8 */ int64_t a5;
/* 48:27 | 4 */ int a6 : 5;
/* 48:56 | 8 */ int64_t a7 : 3;
/* total size (bytes): 24 */
} a1;
/* total size (bytes): 56 */
}
A big part of this patch handles the formatting logic of 'ptype',
which is a bit messy. The code to handle bitfield offsets, however,
took some time to craft. My thanks to Pedro Alves for figuring things
out and pointing me to the right direction, as well as coming up with
a way to inspect the layout of structs with bitfields (see testcase
for comments).
After many discussions both on IRC and at the mailing list, I tried to
implement printing vtables and inherited classes. Unfortunately the
code grew too complex and there were still a few corner cases failing
so I had to drop the attempt. This should be implemented in a future
patch.
This patch is the start of a long-term work I'll do to flush the local
patches we carry for Fedora GDB. In this specific case, I'm aiming at
upstreaming the feature implemented by the 'pahole.py' script that is
shipped with Fedora GDB:
<https://src.fedoraproject.org/rpms/gdb/blob/master/f/gdb-archer.patch#_311>
This has been regression-tested on the BuildBot. There's a new
testcase for it, along with an update to the documentation. I also
thought it was worth mentioning this feature in the NEWS file.
gdb/ChangeLog:
2017-12-15 Sergio Durigan Junior <sergiodj@redhat.com>
Pedro Alves <palves@redhat.com>
PR cli/16224
* NEWS (Changes since GDB 8.0): Mention new '/o' flag.
* c-typeprint.c (OFFSET_SPC_LEN): New define.
(c_type_print_varspec_prefix): New argument 'struct
print_offset_data *'.
(c_type_print_base_1): New function and prototype.
(c_print_type_1): New function, with code from 'c_print_type'.
(c_print_type): Use 'c_print_type_1'.
(c_type_print_varspec_prefix): New argument 'struct
print_offset_data *'. Use it. Call 'c_type_print_base_1'
instead of 'c_print_type_base'.
(print_spaces_filtered_with_print_options): New function.
(output_access_specifier): Take new argument FLAGS. Modify
function to call 'print_spaces_filtered_with_print_options'.
(c_print_type_vtable_offset_marker): New function.
(c_print_type_union_field_offset): New function.
(c_print_type_struct_field_offset): New function.
(c_print_type_no_offsets): New function.
(c_type_print_base_struct_union): New argument 'struct
print_offset_data *'. Print offsets and sizes for
struct/union/class fields.
* typeprint.c (const struct type_print_options
type_print_raw_options): Initialize 'print_offsets'.
(static struct type_print_options default_ptype_flags):
Likewise.
(struct print_offset_data print_offset_default_data): New
variable.
(whatis_exp): Handle '/o' option.
(_initialize_typeprint): Add '/o' flag to ptype's help.
* typeprint.h (struct print_offset_data): New struct.
(struct type_print_options) <print_offsets>: New field.
gdb/testsuite/ChangeLog:
2017-12-15 Sergio Durigan Junior <sergiodj@redhat.com>
PR cli/16224
* gdb.base/ptype-offsets.cc: New file.
* gdb.base/ptype-offsets.exp: New file.
gdb/doc/ChangeLog:
2017-12-15 Sergio Durigan Junior <sergiodj@redhat.com>
PR cli/16224
* gdb.texinfo (ptype): Add documentation for new flag '/o'.
2017-11-20 22:34:59 +01:00
|
|
|
|
print_spaces_filtered_with_print_options (level + 2, stream, flags);
|
|
|
|
|
fprintf_filtered (stream, "protected:\n");
|
2017-10-17 02:19:29 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if (is_private)
|
|
|
|
|
{
|
|
|
|
|
if (last_access != s_private)
|
|
|
|
|
{
|
|
|
|
|
last_access = s_private;
|
Implement pahole-like 'ptype /o' option
This commit implements the pahole-like '/o' option for 'ptype', which
prints the offsets and sizes of struct fields, reporting whenever
there is a hole found.
The output is heavily based on pahole(1), with a few modifications
here and there to adjust it to our reality. Here's an example:
/* offset | size */ type = struct wer : public tuv {
public:
/* 32 | 24 */ struct tyu {
/* 32:31 | 4 */ int a1 : 1;
/* 32:28 | 4 */ int a2 : 3;
/* 32: 5 | 4 */ int a3 : 23;
/* 35: 3 | 1 */ char a4 : 2;
/* XXX 3-bit hole */
/* XXX 4-byte hole */
/* 40 | 8 */ int64_t a5;
/* 48:27 | 4 */ int a6 : 5;
/* 48:56 | 8 */ int64_t a7 : 3;
/* total size (bytes): 24 */
} a1;
/* total size (bytes): 56 */
}
A big part of this patch handles the formatting logic of 'ptype',
which is a bit messy. The code to handle bitfield offsets, however,
took some time to craft. My thanks to Pedro Alves for figuring things
out and pointing me to the right direction, as well as coming up with
a way to inspect the layout of structs with bitfields (see testcase
for comments).
After many discussions both on IRC and at the mailing list, I tried to
implement printing vtables and inherited classes. Unfortunately the
code grew too complex and there were still a few corner cases failing
so I had to drop the attempt. This should be implemented in a future
patch.
This patch is the start of a long-term work I'll do to flush the local
patches we carry for Fedora GDB. In this specific case, I'm aiming at
upstreaming the feature implemented by the 'pahole.py' script that is
shipped with Fedora GDB:
<https://src.fedoraproject.org/rpms/gdb/blob/master/f/gdb-archer.patch#_311>
This has been regression-tested on the BuildBot. There's a new
testcase for it, along with an update to the documentation. I also
thought it was worth mentioning this feature in the NEWS file.
gdb/ChangeLog:
2017-12-15 Sergio Durigan Junior <sergiodj@redhat.com>
Pedro Alves <palves@redhat.com>
PR cli/16224
* NEWS (Changes since GDB 8.0): Mention new '/o' flag.
* c-typeprint.c (OFFSET_SPC_LEN): New define.
(c_type_print_varspec_prefix): New argument 'struct
print_offset_data *'.
(c_type_print_base_1): New function and prototype.
(c_print_type_1): New function, with code from 'c_print_type'.
(c_print_type): Use 'c_print_type_1'.
(c_type_print_varspec_prefix): New argument 'struct
print_offset_data *'. Use it. Call 'c_type_print_base_1'
instead of 'c_print_type_base'.
(print_spaces_filtered_with_print_options): New function.
(output_access_specifier): Take new argument FLAGS. Modify
function to call 'print_spaces_filtered_with_print_options'.
(c_print_type_vtable_offset_marker): New function.
(c_print_type_union_field_offset): New function.
(c_print_type_struct_field_offset): New function.
(c_print_type_no_offsets): New function.
(c_type_print_base_struct_union): New argument 'struct
print_offset_data *'. Print offsets and sizes for
struct/union/class fields.
* typeprint.c (const struct type_print_options
type_print_raw_options): Initialize 'print_offsets'.
(static struct type_print_options default_ptype_flags):
Likewise.
(struct print_offset_data print_offset_default_data): New
variable.
(whatis_exp): Handle '/o' option.
(_initialize_typeprint): Add '/o' flag to ptype's help.
* typeprint.h (struct print_offset_data): New struct.
(struct type_print_options) <print_offsets>: New field.
gdb/testsuite/ChangeLog:
2017-12-15 Sergio Durigan Junior <sergiodj@redhat.com>
PR cli/16224
* gdb.base/ptype-offsets.cc: New file.
* gdb.base/ptype-offsets.exp: New file.
gdb/doc/ChangeLog:
2017-12-15 Sergio Durigan Junior <sergiodj@redhat.com>
PR cli/16224
* gdb.texinfo (ptype): Add documentation for new flag '/o'.
2017-11-20 22:34:59 +01:00
|
|
|
|
print_spaces_filtered_with_print_options (level + 2, stream, flags);
|
|
|
|
|
fprintf_filtered (stream, "private:\n");
|
2017-10-17 02:19:29 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if (last_access != s_public)
|
|
|
|
|
{
|
|
|
|
|
last_access = s_public;
|
Implement pahole-like 'ptype /o' option
This commit implements the pahole-like '/o' option for 'ptype', which
prints the offsets and sizes of struct fields, reporting whenever
there is a hole found.
The output is heavily based on pahole(1), with a few modifications
here and there to adjust it to our reality. Here's an example:
/* offset | size */ type = struct wer : public tuv {
public:
/* 32 | 24 */ struct tyu {
/* 32:31 | 4 */ int a1 : 1;
/* 32:28 | 4 */ int a2 : 3;
/* 32: 5 | 4 */ int a3 : 23;
/* 35: 3 | 1 */ char a4 : 2;
/* XXX 3-bit hole */
/* XXX 4-byte hole */
/* 40 | 8 */ int64_t a5;
/* 48:27 | 4 */ int a6 : 5;
/* 48:56 | 8 */ int64_t a7 : 3;
/* total size (bytes): 24 */
} a1;
/* total size (bytes): 56 */
}
A big part of this patch handles the formatting logic of 'ptype',
which is a bit messy. The code to handle bitfield offsets, however,
took some time to craft. My thanks to Pedro Alves for figuring things
out and pointing me to the right direction, as well as coming up with
a way to inspect the layout of structs with bitfields (see testcase
for comments).
After many discussions both on IRC and at the mailing list, I tried to
implement printing vtables and inherited classes. Unfortunately the
code grew too complex and there were still a few corner cases failing
so I had to drop the attempt. This should be implemented in a future
patch.
This patch is the start of a long-term work I'll do to flush the local
patches we carry for Fedora GDB. In this specific case, I'm aiming at
upstreaming the feature implemented by the 'pahole.py' script that is
shipped with Fedora GDB:
<https://src.fedoraproject.org/rpms/gdb/blob/master/f/gdb-archer.patch#_311>
This has been regression-tested on the BuildBot. There's a new
testcase for it, along with an update to the documentation. I also
thought it was worth mentioning this feature in the NEWS file.
gdb/ChangeLog:
2017-12-15 Sergio Durigan Junior <sergiodj@redhat.com>
Pedro Alves <palves@redhat.com>
PR cli/16224
* NEWS (Changes since GDB 8.0): Mention new '/o' flag.
* c-typeprint.c (OFFSET_SPC_LEN): New define.
(c_type_print_varspec_prefix): New argument 'struct
print_offset_data *'.
(c_type_print_base_1): New function and prototype.
(c_print_type_1): New function, with code from 'c_print_type'.
(c_print_type): Use 'c_print_type_1'.
(c_type_print_varspec_prefix): New argument 'struct
print_offset_data *'. Use it. Call 'c_type_print_base_1'
instead of 'c_print_type_base'.
(print_spaces_filtered_with_print_options): New function.
(output_access_specifier): Take new argument FLAGS. Modify
function to call 'print_spaces_filtered_with_print_options'.
(c_print_type_vtable_offset_marker): New function.
(c_print_type_union_field_offset): New function.
(c_print_type_struct_field_offset): New function.
(c_print_type_no_offsets): New function.
(c_type_print_base_struct_union): New argument 'struct
print_offset_data *'. Print offsets and sizes for
struct/union/class fields.
* typeprint.c (const struct type_print_options
type_print_raw_options): Initialize 'print_offsets'.
(static struct type_print_options default_ptype_flags):
Likewise.
(struct print_offset_data print_offset_default_data): New
variable.
(whatis_exp): Handle '/o' option.
(_initialize_typeprint): Add '/o' flag to ptype's help.
* typeprint.h (struct print_offset_data): New struct.
(struct type_print_options) <print_offsets>: New field.
gdb/testsuite/ChangeLog:
2017-12-15 Sergio Durigan Junior <sergiodj@redhat.com>
PR cli/16224
* gdb.base/ptype-offsets.cc: New file.
* gdb.base/ptype-offsets.exp: New file.
gdb/doc/ChangeLog:
2017-12-15 Sergio Durigan Junior <sergiodj@redhat.com>
PR cli/16224
* gdb.texinfo (ptype): Add documentation for new flag '/o'.
2017-11-20 22:34:59 +01:00
|
|
|
|
print_spaces_filtered_with_print_options (level + 2, stream, flags);
|
|
|
|
|
fprintf_filtered (stream, "public:\n");
|
2017-10-17 02:19:29 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return last_access;
|
|
|
|
|
}
|
|
|
|
|
|
Implement pahole-like 'ptype /o' option
This commit implements the pahole-like '/o' option for 'ptype', which
prints the offsets and sizes of struct fields, reporting whenever
there is a hole found.
The output is heavily based on pahole(1), with a few modifications
here and there to adjust it to our reality. Here's an example:
/* offset | size */ type = struct wer : public tuv {
public:
/* 32 | 24 */ struct tyu {
/* 32:31 | 4 */ int a1 : 1;
/* 32:28 | 4 */ int a2 : 3;
/* 32: 5 | 4 */ int a3 : 23;
/* 35: 3 | 1 */ char a4 : 2;
/* XXX 3-bit hole */
/* XXX 4-byte hole */
/* 40 | 8 */ int64_t a5;
/* 48:27 | 4 */ int a6 : 5;
/* 48:56 | 8 */ int64_t a7 : 3;
/* total size (bytes): 24 */
} a1;
/* total size (bytes): 56 */
}
A big part of this patch handles the formatting logic of 'ptype',
which is a bit messy. The code to handle bitfield offsets, however,
took some time to craft. My thanks to Pedro Alves for figuring things
out and pointing me to the right direction, as well as coming up with
a way to inspect the layout of structs with bitfields (see testcase
for comments).
After many discussions both on IRC and at the mailing list, I tried to
implement printing vtables and inherited classes. Unfortunately the
code grew too complex and there were still a few corner cases failing
so I had to drop the attempt. This should be implemented in a future
patch.
This patch is the start of a long-term work I'll do to flush the local
patches we carry for Fedora GDB. In this specific case, I'm aiming at
upstreaming the feature implemented by the 'pahole.py' script that is
shipped with Fedora GDB:
<https://src.fedoraproject.org/rpms/gdb/blob/master/f/gdb-archer.patch#_311>
This has been regression-tested on the BuildBot. There's a new
testcase for it, along with an update to the documentation. I also
thought it was worth mentioning this feature in the NEWS file.
gdb/ChangeLog:
2017-12-15 Sergio Durigan Junior <sergiodj@redhat.com>
Pedro Alves <palves@redhat.com>
PR cli/16224
* NEWS (Changes since GDB 8.0): Mention new '/o' flag.
* c-typeprint.c (OFFSET_SPC_LEN): New define.
(c_type_print_varspec_prefix): New argument 'struct
print_offset_data *'.
(c_type_print_base_1): New function and prototype.
(c_print_type_1): New function, with code from 'c_print_type'.
(c_print_type): Use 'c_print_type_1'.
(c_type_print_varspec_prefix): New argument 'struct
print_offset_data *'. Use it. Call 'c_type_print_base_1'
instead of 'c_print_type_base'.
(print_spaces_filtered_with_print_options): New function.
(output_access_specifier): Take new argument FLAGS. Modify
function to call 'print_spaces_filtered_with_print_options'.
(c_print_type_vtable_offset_marker): New function.
(c_print_type_union_field_offset): New function.
(c_print_type_struct_field_offset): New function.
(c_print_type_no_offsets): New function.
(c_type_print_base_struct_union): New argument 'struct
print_offset_data *'. Print offsets and sizes for
struct/union/class fields.
* typeprint.c (const struct type_print_options
type_print_raw_options): Initialize 'print_offsets'.
(static struct type_print_options default_ptype_flags):
Likewise.
(struct print_offset_data print_offset_default_data): New
variable.
(whatis_exp): Handle '/o' option.
(_initialize_typeprint): Add '/o' flag to ptype's help.
* typeprint.h (struct print_offset_data): New struct.
(struct type_print_options) <print_offsets>: New field.
gdb/testsuite/ChangeLog:
2017-12-15 Sergio Durigan Junior <sergiodj@redhat.com>
PR cli/16224
* gdb.base/ptype-offsets.cc: New file.
* gdb.base/ptype-offsets.exp: New file.
gdb/doc/ChangeLog:
2017-12-15 Sergio Durigan Junior <sergiodj@redhat.com>
PR cli/16224
* gdb.texinfo (ptype): Add documentation for new flag '/o'.
2017-11-20 22:34:59 +01:00
|
|
|
|
/* Return true if an access label (i.e., "public:", "private:",
|
2017-12-11 17:57:19 +01:00
|
|
|
|
"protected:") needs to be printed for TYPE. */
|
|
|
|
|
|
|
|
|
|
static bool
|
|
|
|
|
need_access_label_p (struct type *type)
|
|
|
|
|
{
|
|
|
|
|
if (TYPE_DECLARED_CLASS (type))
|
|
|
|
|
{
|
|
|
|
|
QUIT;
|
|
|
|
|
for (int i = TYPE_N_BASECLASSES (type); i < TYPE_NFIELDS (type); i++)
|
|
|
|
|
if (!TYPE_FIELD_PRIVATE (type, i))
|
|
|
|
|
return true;
|
|
|
|
|
QUIT;
|
|
|
|
|
for (int j = 0; j < TYPE_NFN_FIELDS (type); j++)
|
|
|
|
|
for (int i = 0; i < TYPE_FN_FIELDLIST_LENGTH (type, j); i++)
|
|
|
|
|
if (!TYPE_FN_FIELD_PRIVATE (TYPE_FN_FIELDLIST1 (type,
|
|
|
|
|
j), i))
|
|
|
|
|
return true;
|
|
|
|
|
QUIT;
|
|
|
|
|
for (int i = 0; i < TYPE_TYPEDEF_FIELD_COUNT (type); ++i)
|
|
|
|
|
if (!TYPE_TYPEDEF_FIELD_PRIVATE (type, i))
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
QUIT;
|
|
|
|
|
for (int i = TYPE_N_BASECLASSES (type); i < TYPE_NFIELDS (type); i++)
|
|
|
|
|
if (TYPE_FIELD_PRIVATE (type, i) || TYPE_FIELD_PROTECTED (type, i))
|
|
|
|
|
return true;
|
|
|
|
|
QUIT;
|
|
|
|
|
for (int j = 0; j < TYPE_NFN_FIELDS (type); j++)
|
|
|
|
|
{
|
|
|
|
|
QUIT;
|
|
|
|
|
for (int i = 0; i < TYPE_FN_FIELDLIST_LENGTH (type, j); i++)
|
|
|
|
|
if (TYPE_FN_FIELD_PROTECTED (TYPE_FN_FIELDLIST1 (type,
|
|
|
|
|
j), i)
|
|
|
|
|
|| TYPE_FN_FIELD_PRIVATE (TYPE_FN_FIELDLIST1 (type,
|
|
|
|
|
j),
|
|
|
|
|
i))
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
QUIT;
|
|
|
|
|
for (int i = 0; i < TYPE_TYPEDEF_FIELD_COUNT (type); ++i)
|
|
|
|
|
if (TYPE_TYPEDEF_FIELD_PROTECTED (type, i)
|
|
|
|
|
|| TYPE_TYPEDEF_FIELD_PRIVATE (type, i))
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
Implement pahole-like 'ptype /o' option
This commit implements the pahole-like '/o' option for 'ptype', which
prints the offsets and sizes of struct fields, reporting whenever
there is a hole found.
The output is heavily based on pahole(1), with a few modifications
here and there to adjust it to our reality. Here's an example:
/* offset | size */ type = struct wer : public tuv {
public:
/* 32 | 24 */ struct tyu {
/* 32:31 | 4 */ int a1 : 1;
/* 32:28 | 4 */ int a2 : 3;
/* 32: 5 | 4 */ int a3 : 23;
/* 35: 3 | 1 */ char a4 : 2;
/* XXX 3-bit hole */
/* XXX 4-byte hole */
/* 40 | 8 */ int64_t a5;
/* 48:27 | 4 */ int a6 : 5;
/* 48:56 | 8 */ int64_t a7 : 3;
/* total size (bytes): 24 */
} a1;
/* total size (bytes): 56 */
}
A big part of this patch handles the formatting logic of 'ptype',
which is a bit messy. The code to handle bitfield offsets, however,
took some time to craft. My thanks to Pedro Alves for figuring things
out and pointing me to the right direction, as well as coming up with
a way to inspect the layout of structs with bitfields (see testcase
for comments).
After many discussions both on IRC and at the mailing list, I tried to
implement printing vtables and inherited classes. Unfortunately the
code grew too complex and there were still a few corner cases failing
so I had to drop the attempt. This should be implemented in a future
patch.
This patch is the start of a long-term work I'll do to flush the local
patches we carry for Fedora GDB. In this specific case, I'm aiming at
upstreaming the feature implemented by the 'pahole.py' script that is
shipped with Fedora GDB:
<https://src.fedoraproject.org/rpms/gdb/blob/master/f/gdb-archer.patch#_311>
This has been regression-tested on the BuildBot. There's a new
testcase for it, along with an update to the documentation. I also
thought it was worth mentioning this feature in the NEWS file.
gdb/ChangeLog:
2017-12-15 Sergio Durigan Junior <sergiodj@redhat.com>
Pedro Alves <palves@redhat.com>
PR cli/16224
* NEWS (Changes since GDB 8.0): Mention new '/o' flag.
* c-typeprint.c (OFFSET_SPC_LEN): New define.
(c_type_print_varspec_prefix): New argument 'struct
print_offset_data *'.
(c_type_print_base_1): New function and prototype.
(c_print_type_1): New function, with code from 'c_print_type'.
(c_print_type): Use 'c_print_type_1'.
(c_type_print_varspec_prefix): New argument 'struct
print_offset_data *'. Use it. Call 'c_type_print_base_1'
instead of 'c_print_type_base'.
(print_spaces_filtered_with_print_options): New function.
(output_access_specifier): Take new argument FLAGS. Modify
function to call 'print_spaces_filtered_with_print_options'.
(c_print_type_vtable_offset_marker): New function.
(c_print_type_union_field_offset): New function.
(c_print_type_struct_field_offset): New function.
(c_print_type_no_offsets): New function.
(c_type_print_base_struct_union): New argument 'struct
print_offset_data *'. Print offsets and sizes for
struct/union/class fields.
* typeprint.c (const struct type_print_options
type_print_raw_options): Initialize 'print_offsets'.
(static struct type_print_options default_ptype_flags):
Likewise.
(struct print_offset_data print_offset_default_data): New
variable.
(whatis_exp): Handle '/o' option.
(_initialize_typeprint): Add '/o' flag to ptype's help.
* typeprint.h (struct print_offset_data): New struct.
(struct type_print_options) <print_offsets>: New field.
gdb/testsuite/ChangeLog:
2017-12-15 Sergio Durigan Junior <sergiodj@redhat.com>
PR cli/16224
* gdb.base/ptype-offsets.cc: New file.
* gdb.base/ptype-offsets.exp: New file.
gdb/doc/ChangeLog:
2017-12-15 Sergio Durigan Junior <sergiodj@redhat.com>
PR cli/16224
* gdb.texinfo (ptype): Add documentation for new flag '/o'.
2017-11-20 22:34:59 +01:00
|
|
|
|
/* Helper function that temporarily disables FLAGS->PRINT_OFFSETS,
|
|
|
|
|
calls 'c_print_type_1', and then reenables FLAGS->PRINT_OFFSETS if
|
|
|
|
|
applicable. */
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
c_print_type_no_offsets (struct type *type,
|
|
|
|
|
const char *varstring,
|
|
|
|
|
struct ui_file *stream,
|
|
|
|
|
int show, int level,
|
2018-04-17 21:51:23 +02:00
|
|
|
|
enum language language,
|
Implement pahole-like 'ptype /o' option
This commit implements the pahole-like '/o' option for 'ptype', which
prints the offsets and sizes of struct fields, reporting whenever
there is a hole found.
The output is heavily based on pahole(1), with a few modifications
here and there to adjust it to our reality. Here's an example:
/* offset | size */ type = struct wer : public tuv {
public:
/* 32 | 24 */ struct tyu {
/* 32:31 | 4 */ int a1 : 1;
/* 32:28 | 4 */ int a2 : 3;
/* 32: 5 | 4 */ int a3 : 23;
/* 35: 3 | 1 */ char a4 : 2;
/* XXX 3-bit hole */
/* XXX 4-byte hole */
/* 40 | 8 */ int64_t a5;
/* 48:27 | 4 */ int a6 : 5;
/* 48:56 | 8 */ int64_t a7 : 3;
/* total size (bytes): 24 */
} a1;
/* total size (bytes): 56 */
}
A big part of this patch handles the formatting logic of 'ptype',
which is a bit messy. The code to handle bitfield offsets, however,
took some time to craft. My thanks to Pedro Alves for figuring things
out and pointing me to the right direction, as well as coming up with
a way to inspect the layout of structs with bitfields (see testcase
for comments).
After many discussions both on IRC and at the mailing list, I tried to
implement printing vtables and inherited classes. Unfortunately the
code grew too complex and there were still a few corner cases failing
so I had to drop the attempt. This should be implemented in a future
patch.
This patch is the start of a long-term work I'll do to flush the local
patches we carry for Fedora GDB. In this specific case, I'm aiming at
upstreaming the feature implemented by the 'pahole.py' script that is
shipped with Fedora GDB:
<https://src.fedoraproject.org/rpms/gdb/blob/master/f/gdb-archer.patch#_311>
This has been regression-tested on the BuildBot. There's a new
testcase for it, along with an update to the documentation. I also
thought it was worth mentioning this feature in the NEWS file.
gdb/ChangeLog:
2017-12-15 Sergio Durigan Junior <sergiodj@redhat.com>
Pedro Alves <palves@redhat.com>
PR cli/16224
* NEWS (Changes since GDB 8.0): Mention new '/o' flag.
* c-typeprint.c (OFFSET_SPC_LEN): New define.
(c_type_print_varspec_prefix): New argument 'struct
print_offset_data *'.
(c_type_print_base_1): New function and prototype.
(c_print_type_1): New function, with code from 'c_print_type'.
(c_print_type): Use 'c_print_type_1'.
(c_type_print_varspec_prefix): New argument 'struct
print_offset_data *'. Use it. Call 'c_type_print_base_1'
instead of 'c_print_type_base'.
(print_spaces_filtered_with_print_options): New function.
(output_access_specifier): Take new argument FLAGS. Modify
function to call 'print_spaces_filtered_with_print_options'.
(c_print_type_vtable_offset_marker): New function.
(c_print_type_union_field_offset): New function.
(c_print_type_struct_field_offset): New function.
(c_print_type_no_offsets): New function.
(c_type_print_base_struct_union): New argument 'struct
print_offset_data *'. Print offsets and sizes for
struct/union/class fields.
* typeprint.c (const struct type_print_options
type_print_raw_options): Initialize 'print_offsets'.
(static struct type_print_options default_ptype_flags):
Likewise.
(struct print_offset_data print_offset_default_data): New
variable.
(whatis_exp): Handle '/o' option.
(_initialize_typeprint): Add '/o' flag to ptype's help.
* typeprint.h (struct print_offset_data): New struct.
(struct type_print_options) <print_offsets>: New field.
gdb/testsuite/ChangeLog:
2017-12-15 Sergio Durigan Junior <sergiodj@redhat.com>
PR cli/16224
* gdb.base/ptype-offsets.cc: New file.
* gdb.base/ptype-offsets.exp: New file.
gdb/doc/ChangeLog:
2017-12-15 Sergio Durigan Junior <sergiodj@redhat.com>
PR cli/16224
* gdb.texinfo (ptype): Add documentation for new flag '/o'.
2017-11-20 22:34:59 +01:00
|
|
|
|
struct type_print_options *flags,
|
|
|
|
|
struct print_offset_data *podata)
|
|
|
|
|
{
|
|
|
|
|
unsigned int old_po = flags->print_offsets;
|
|
|
|
|
|
|
|
|
|
/* Temporarily disable print_offsets, because it would mess with
|
|
|
|
|
indentation. */
|
|
|
|
|
flags->print_offsets = 0;
|
2018-04-17 21:51:23 +02:00
|
|
|
|
c_print_type_1 (type, varstring, stream, show, level, language, flags,
|
|
|
|
|
podata);
|
Implement pahole-like 'ptype /o' option
This commit implements the pahole-like '/o' option for 'ptype', which
prints the offsets and sizes of struct fields, reporting whenever
there is a hole found.
The output is heavily based on pahole(1), with a few modifications
here and there to adjust it to our reality. Here's an example:
/* offset | size */ type = struct wer : public tuv {
public:
/* 32 | 24 */ struct tyu {
/* 32:31 | 4 */ int a1 : 1;
/* 32:28 | 4 */ int a2 : 3;
/* 32: 5 | 4 */ int a3 : 23;
/* 35: 3 | 1 */ char a4 : 2;
/* XXX 3-bit hole */
/* XXX 4-byte hole */
/* 40 | 8 */ int64_t a5;
/* 48:27 | 4 */ int a6 : 5;
/* 48:56 | 8 */ int64_t a7 : 3;
/* total size (bytes): 24 */
} a1;
/* total size (bytes): 56 */
}
A big part of this patch handles the formatting logic of 'ptype',
which is a bit messy. The code to handle bitfield offsets, however,
took some time to craft. My thanks to Pedro Alves for figuring things
out and pointing me to the right direction, as well as coming up with
a way to inspect the layout of structs with bitfields (see testcase
for comments).
After many discussions both on IRC and at the mailing list, I tried to
implement printing vtables and inherited classes. Unfortunately the
code grew too complex and there were still a few corner cases failing
so I had to drop the attempt. This should be implemented in a future
patch.
This patch is the start of a long-term work I'll do to flush the local
patches we carry for Fedora GDB. In this specific case, I'm aiming at
upstreaming the feature implemented by the 'pahole.py' script that is
shipped with Fedora GDB:
<https://src.fedoraproject.org/rpms/gdb/blob/master/f/gdb-archer.patch#_311>
This has been regression-tested on the BuildBot. There's a new
testcase for it, along with an update to the documentation. I also
thought it was worth mentioning this feature in the NEWS file.
gdb/ChangeLog:
2017-12-15 Sergio Durigan Junior <sergiodj@redhat.com>
Pedro Alves <palves@redhat.com>
PR cli/16224
* NEWS (Changes since GDB 8.0): Mention new '/o' flag.
* c-typeprint.c (OFFSET_SPC_LEN): New define.
(c_type_print_varspec_prefix): New argument 'struct
print_offset_data *'.
(c_type_print_base_1): New function and prototype.
(c_print_type_1): New function, with code from 'c_print_type'.
(c_print_type): Use 'c_print_type_1'.
(c_type_print_varspec_prefix): New argument 'struct
print_offset_data *'. Use it. Call 'c_type_print_base_1'
instead of 'c_print_type_base'.
(print_spaces_filtered_with_print_options): New function.
(output_access_specifier): Take new argument FLAGS. Modify
function to call 'print_spaces_filtered_with_print_options'.
(c_print_type_vtable_offset_marker): New function.
(c_print_type_union_field_offset): New function.
(c_print_type_struct_field_offset): New function.
(c_print_type_no_offsets): New function.
(c_type_print_base_struct_union): New argument 'struct
print_offset_data *'. Print offsets and sizes for
struct/union/class fields.
* typeprint.c (const struct type_print_options
type_print_raw_options): Initialize 'print_offsets'.
(static struct type_print_options default_ptype_flags):
Likewise.
(struct print_offset_data print_offset_default_data): New
variable.
(whatis_exp): Handle '/o' option.
(_initialize_typeprint): Add '/o' flag to ptype's help.
* typeprint.h (struct print_offset_data): New struct.
(struct type_print_options) <print_offsets>: New field.
gdb/testsuite/ChangeLog:
2017-12-15 Sergio Durigan Junior <sergiodj@redhat.com>
PR cli/16224
* gdb.base/ptype-offsets.cc: New file.
* gdb.base/ptype-offsets.exp: New file.
gdb/doc/ChangeLog:
2017-12-15 Sergio Durigan Junior <sergiodj@redhat.com>
PR cli/16224
* gdb.texinfo (ptype): Add documentation for new flag '/o'.
2017-11-20 22:34:59 +01:00
|
|
|
|
flags->print_offsets = old_po;
|
|
|
|
|
}
|
|
|
|
|
|
2017-12-11 17:57:19 +01:00
|
|
|
|
/* Helper for 'c_type_print_base' that handles structs and unions.
|
|
|
|
|
For a description of the arguments, see 'c_type_print_base'. */
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
c_type_print_base_struct_union (struct type *type, struct ui_file *stream,
|
|
|
|
|
int show, int level,
|
2018-04-17 21:51:23 +02:00
|
|
|
|
enum language language,
|
Implement pahole-like 'ptype /o' option
This commit implements the pahole-like '/o' option for 'ptype', which
prints the offsets and sizes of struct fields, reporting whenever
there is a hole found.
The output is heavily based on pahole(1), with a few modifications
here and there to adjust it to our reality. Here's an example:
/* offset | size */ type = struct wer : public tuv {
public:
/* 32 | 24 */ struct tyu {
/* 32:31 | 4 */ int a1 : 1;
/* 32:28 | 4 */ int a2 : 3;
/* 32: 5 | 4 */ int a3 : 23;
/* 35: 3 | 1 */ char a4 : 2;
/* XXX 3-bit hole */
/* XXX 4-byte hole */
/* 40 | 8 */ int64_t a5;
/* 48:27 | 4 */ int a6 : 5;
/* 48:56 | 8 */ int64_t a7 : 3;
/* total size (bytes): 24 */
} a1;
/* total size (bytes): 56 */
}
A big part of this patch handles the formatting logic of 'ptype',
which is a bit messy. The code to handle bitfield offsets, however,
took some time to craft. My thanks to Pedro Alves for figuring things
out and pointing me to the right direction, as well as coming up with
a way to inspect the layout of structs with bitfields (see testcase
for comments).
After many discussions both on IRC and at the mailing list, I tried to
implement printing vtables and inherited classes. Unfortunately the
code grew too complex and there were still a few corner cases failing
so I had to drop the attempt. This should be implemented in a future
patch.
This patch is the start of a long-term work I'll do to flush the local
patches we carry for Fedora GDB. In this specific case, I'm aiming at
upstreaming the feature implemented by the 'pahole.py' script that is
shipped with Fedora GDB:
<https://src.fedoraproject.org/rpms/gdb/blob/master/f/gdb-archer.patch#_311>
This has been regression-tested on the BuildBot. There's a new
testcase for it, along with an update to the documentation. I also
thought it was worth mentioning this feature in the NEWS file.
gdb/ChangeLog:
2017-12-15 Sergio Durigan Junior <sergiodj@redhat.com>
Pedro Alves <palves@redhat.com>
PR cli/16224
* NEWS (Changes since GDB 8.0): Mention new '/o' flag.
* c-typeprint.c (OFFSET_SPC_LEN): New define.
(c_type_print_varspec_prefix): New argument 'struct
print_offset_data *'.
(c_type_print_base_1): New function and prototype.
(c_print_type_1): New function, with code from 'c_print_type'.
(c_print_type): Use 'c_print_type_1'.
(c_type_print_varspec_prefix): New argument 'struct
print_offset_data *'. Use it. Call 'c_type_print_base_1'
instead of 'c_print_type_base'.
(print_spaces_filtered_with_print_options): New function.
(output_access_specifier): Take new argument FLAGS. Modify
function to call 'print_spaces_filtered_with_print_options'.
(c_print_type_vtable_offset_marker): New function.
(c_print_type_union_field_offset): New function.
(c_print_type_struct_field_offset): New function.
(c_print_type_no_offsets): New function.
(c_type_print_base_struct_union): New argument 'struct
print_offset_data *'. Print offsets and sizes for
struct/union/class fields.
* typeprint.c (const struct type_print_options
type_print_raw_options): Initialize 'print_offsets'.
(static struct type_print_options default_ptype_flags):
Likewise.
(struct print_offset_data print_offset_default_data): New
variable.
(whatis_exp): Handle '/o' option.
(_initialize_typeprint): Add '/o' flag to ptype's help.
* typeprint.h (struct print_offset_data): New struct.
(struct type_print_options) <print_offsets>: New field.
gdb/testsuite/ChangeLog:
2017-12-15 Sergio Durigan Junior <sergiodj@redhat.com>
PR cli/16224
* gdb.base/ptype-offsets.cc: New file.
* gdb.base/ptype-offsets.exp: New file.
gdb/doc/ChangeLog:
2017-12-15 Sergio Durigan Junior <sergiodj@redhat.com>
PR cli/16224
* gdb.texinfo (ptype): Add documentation for new flag '/o'.
2017-11-20 22:34:59 +01:00
|
|
|
|
const struct type_print_options *flags,
|
|
|
|
|
struct print_offset_data *podata)
|
2017-12-11 17:57:19 +01:00
|
|
|
|
{
|
|
|
|
|
struct type_print_options local_flags = *flags;
|
|
|
|
|
local_flags.local_typedefs = NULL;
|
|
|
|
|
|
2018-03-14 23:38:02 +01:00
|
|
|
|
std::unique_ptr<typedef_hash_table> hash_holder;
|
2017-12-11 17:57:19 +01:00
|
|
|
|
if (!flags->raw)
|
|
|
|
|
{
|
|
|
|
|
if (flags->local_typedefs)
|
|
|
|
|
local_flags.local_typedefs
|
2018-03-14 23:38:02 +01:00
|
|
|
|
= new typedef_hash_table (*flags->local_typedefs);
|
2017-12-11 17:57:19 +01:00
|
|
|
|
else
|
2018-03-14 23:38:02 +01:00
|
|
|
|
local_flags.local_typedefs = new typedef_hash_table ();
|
2017-12-11 17:57:19 +01:00
|
|
|
|
|
2018-03-14 23:38:02 +01:00
|
|
|
|
hash_holder.reset (local_flags.local_typedefs);
|
2017-12-11 17:57:19 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
c_type_print_modifier (type, stream, 0, 1);
|
|
|
|
|
if (TYPE_CODE (type) == TYPE_CODE_UNION)
|
|
|
|
|
fprintf_filtered (stream, "union ");
|
|
|
|
|
else if (TYPE_DECLARED_CLASS (type))
|
|
|
|
|
fprintf_filtered (stream, "class ");
|
|
|
|
|
else
|
|
|
|
|
fprintf_filtered (stream, "struct ");
|
|
|
|
|
|
|
|
|
|
/* Print the tag if it exists. The HP aCC compiler emits a
|
|
|
|
|
spurious "{unnamed struct}"/"{unnamed union}"/"{unnamed
|
|
|
|
|
enum}" tag for unnamed struct/union/enum's, which we don't
|
|
|
|
|
want to print. */
|
Remove TYPE_TAG_NAME
TYPE_TAG_NAME has been an occasional source of confusion and bugs. It
seems to me that it is only useful for C and C++ -- but even there,
not so much, because at least with DWARF there doesn't seem to be any
way to wind up with a type where the name and the tag name are both
non-NULL and different.
So, this patch removes TYPE_TAG_NAME entirely. This should save a
little memory, but more importantly, it simplifies this part of gdb.
A few minor test suite adjustments were needed. In some situations
the new code does not yield identical output to the old code.
gdb/ChangeLog
2018-06-01 Tom Tromey <tom@tromey.com>
* valops.c (enum_constant_from_type, value_namespace_elt)
(value_maybe_namespace_elt): Update.
* valarith.c (find_size_for_pointer_math): Update.
* target-descriptions.c (make_gdb_type): Update.
* symmisc.c (print_symbol): Update.
* stabsread.c (define_symbol, read_type)
(complain_about_struct_wipeout, add_undefined_type)
(cleanup_undefined_types_1): Update.
* rust-lang.c (rust_tuple_type_p, rust_slice_type_p)
(rust_range_type_p, val_print_struct, rust_print_struct_def)
(rust_internal_print_type, rust_composite_type)
(rust_evaluate_funcall, rust_evaluate_subexp)
(rust_inclusive_range_type_p): Update.
* python/py-type.c (typy_get_tag): Update.
* p-typeprint.c (pascal_type_print_base): Update.
* mdebugread.c (parse_symbol, parse_type): Update.
* m2-typeprint.c (m2_long_set, m2_record_fields, m2_enum):
Update.
* guile/scm-type.c (gdbscm_type_tag): Update.
* go-lang.c (sixg_string_p): Update.
* gnu-v3-abi.c (build_gdb_vtable_type, build_std_type_info_type):
Update.
* gdbtypes.h (struct main_type) <tag_name>: Remove.
(TYPE_TAG_NAME): Remove.
* gdbtypes.c (type_name_no_tag): Simplify.
(check_typedef, check_types_equal, recursive_dump_type)
(copy_type_recursive, arch_composite_type): Update.
* f-typeprint.c (f_type_print_base): Update. Print "Type" prefix
in summary mode when needed.
* eval.c (evaluate_funcall): Update.
* dwarf2read.c (fixup_go_packaging, read_structure_type)
(process_structure_scope, read_enumeration_type)
(read_namespace_type, read_module_type, determine_prefix): Update.
* cp-support.c (inspect_type): Update.
* coffread.c (process_coff_symbol, decode_base_type): Update.
* c-varobj.c (c_is_path_expr_parent): Update.
* c-typeprint.c (c_type_print_base_struct_union): Update.
(c_type_print_base_1): Update. Print struct/class/union/enum in
summary when using C language.
* ax-gdb.c (gen_struct_ref, gen_namespace_elt)
(gen_maybe_namespace_elt): Update.
* ada-lang.c (ada_type_name): Simplify.
(empty_record, ada_template_to_fixed_record_type_1)
(template_to_static_fixed_type)
(to_record_with_fixed_variant_part, ada_check_typedef): Update.
gdb/testsuite/ChangeLog
2018-06-01 Tom Tromey <tom@tromey.com>
* gdb.xml/tdesc-regs.exp (load_description): Update expected
results.
* gdb.dwarf2/method-ptr.exp: Set language to C++.
* gdb.dwarf2/member-ptr-forwardref.exp: Set language to C++.
* gdb.cp/typeid.exp (do_typeid_tests): Update type_re.
* gdb.base/maint.exp (maint_pass_if): Update.
2018-04-17 21:51:24 +02:00
|
|
|
|
if (TYPE_NAME (type) != NULL
|
|
|
|
|
&& !startswith (TYPE_NAME (type), "{unnamed"))
|
2017-12-11 17:57:19 +01:00
|
|
|
|
{
|
|
|
|
|
/* When printing the tag name, we are still effectively
|
|
|
|
|
printing in the outer context, hence the use of FLAGS
|
|
|
|
|
here. */
|
Remove TYPE_TAG_NAME
TYPE_TAG_NAME has been an occasional source of confusion and bugs. It
seems to me that it is only useful for C and C++ -- but even there,
not so much, because at least with DWARF there doesn't seem to be any
way to wind up with a type where the name and the tag name are both
non-NULL and different.
So, this patch removes TYPE_TAG_NAME entirely. This should save a
little memory, but more importantly, it simplifies this part of gdb.
A few minor test suite adjustments were needed. In some situations
the new code does not yield identical output to the old code.
gdb/ChangeLog
2018-06-01 Tom Tromey <tom@tromey.com>
* valops.c (enum_constant_from_type, value_namespace_elt)
(value_maybe_namespace_elt): Update.
* valarith.c (find_size_for_pointer_math): Update.
* target-descriptions.c (make_gdb_type): Update.
* symmisc.c (print_symbol): Update.
* stabsread.c (define_symbol, read_type)
(complain_about_struct_wipeout, add_undefined_type)
(cleanup_undefined_types_1): Update.
* rust-lang.c (rust_tuple_type_p, rust_slice_type_p)
(rust_range_type_p, val_print_struct, rust_print_struct_def)
(rust_internal_print_type, rust_composite_type)
(rust_evaluate_funcall, rust_evaluate_subexp)
(rust_inclusive_range_type_p): Update.
* python/py-type.c (typy_get_tag): Update.
* p-typeprint.c (pascal_type_print_base): Update.
* mdebugread.c (parse_symbol, parse_type): Update.
* m2-typeprint.c (m2_long_set, m2_record_fields, m2_enum):
Update.
* guile/scm-type.c (gdbscm_type_tag): Update.
* go-lang.c (sixg_string_p): Update.
* gnu-v3-abi.c (build_gdb_vtable_type, build_std_type_info_type):
Update.
* gdbtypes.h (struct main_type) <tag_name>: Remove.
(TYPE_TAG_NAME): Remove.
* gdbtypes.c (type_name_no_tag): Simplify.
(check_typedef, check_types_equal, recursive_dump_type)
(copy_type_recursive, arch_composite_type): Update.
* f-typeprint.c (f_type_print_base): Update. Print "Type" prefix
in summary mode when needed.
* eval.c (evaluate_funcall): Update.
* dwarf2read.c (fixup_go_packaging, read_structure_type)
(process_structure_scope, read_enumeration_type)
(read_namespace_type, read_module_type, determine_prefix): Update.
* cp-support.c (inspect_type): Update.
* coffread.c (process_coff_symbol, decode_base_type): Update.
* c-varobj.c (c_is_path_expr_parent): Update.
* c-typeprint.c (c_type_print_base_struct_union): Update.
(c_type_print_base_1): Update. Print struct/class/union/enum in
summary when using C language.
* ax-gdb.c (gen_struct_ref, gen_namespace_elt)
(gen_maybe_namespace_elt): Update.
* ada-lang.c (ada_type_name): Simplify.
(empty_record, ada_template_to_fixed_record_type_1)
(template_to_static_fixed_type)
(to_record_with_fixed_variant_part, ada_check_typedef): Update.
gdb/testsuite/ChangeLog
2018-06-01 Tom Tromey <tom@tromey.com>
* gdb.xml/tdesc-regs.exp (load_description): Update expected
results.
* gdb.dwarf2/method-ptr.exp: Set language to C++.
* gdb.dwarf2/member-ptr-forwardref.exp: Set language to C++.
* gdb.cp/typeid.exp (do_typeid_tests): Update type_re.
* gdb.base/maint.exp (maint_pass_if): Update.
2018-04-17 21:51:24 +02:00
|
|
|
|
print_name_maybe_canonical (TYPE_NAME (type), flags, stream);
|
2017-12-11 17:57:19 +01:00
|
|
|
|
if (show > 0)
|
|
|
|
|
fputs_filtered (" ", stream);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (show < 0)
|
|
|
|
|
{
|
|
|
|
|
/* If we just printed a tag name, no need to print anything
|
|
|
|
|
else. */
|
Remove TYPE_TAG_NAME
TYPE_TAG_NAME has been an occasional source of confusion and bugs. It
seems to me that it is only useful for C and C++ -- but even there,
not so much, because at least with DWARF there doesn't seem to be any
way to wind up with a type where the name and the tag name are both
non-NULL and different.
So, this patch removes TYPE_TAG_NAME entirely. This should save a
little memory, but more importantly, it simplifies this part of gdb.
A few minor test suite adjustments were needed. In some situations
the new code does not yield identical output to the old code.
gdb/ChangeLog
2018-06-01 Tom Tromey <tom@tromey.com>
* valops.c (enum_constant_from_type, value_namespace_elt)
(value_maybe_namespace_elt): Update.
* valarith.c (find_size_for_pointer_math): Update.
* target-descriptions.c (make_gdb_type): Update.
* symmisc.c (print_symbol): Update.
* stabsread.c (define_symbol, read_type)
(complain_about_struct_wipeout, add_undefined_type)
(cleanup_undefined_types_1): Update.
* rust-lang.c (rust_tuple_type_p, rust_slice_type_p)
(rust_range_type_p, val_print_struct, rust_print_struct_def)
(rust_internal_print_type, rust_composite_type)
(rust_evaluate_funcall, rust_evaluate_subexp)
(rust_inclusive_range_type_p): Update.
* python/py-type.c (typy_get_tag): Update.
* p-typeprint.c (pascal_type_print_base): Update.
* mdebugread.c (parse_symbol, parse_type): Update.
* m2-typeprint.c (m2_long_set, m2_record_fields, m2_enum):
Update.
* guile/scm-type.c (gdbscm_type_tag): Update.
* go-lang.c (sixg_string_p): Update.
* gnu-v3-abi.c (build_gdb_vtable_type, build_std_type_info_type):
Update.
* gdbtypes.h (struct main_type) <tag_name>: Remove.
(TYPE_TAG_NAME): Remove.
* gdbtypes.c (type_name_no_tag): Simplify.
(check_typedef, check_types_equal, recursive_dump_type)
(copy_type_recursive, arch_composite_type): Update.
* f-typeprint.c (f_type_print_base): Update. Print "Type" prefix
in summary mode when needed.
* eval.c (evaluate_funcall): Update.
* dwarf2read.c (fixup_go_packaging, read_structure_type)
(process_structure_scope, read_enumeration_type)
(read_namespace_type, read_module_type, determine_prefix): Update.
* cp-support.c (inspect_type): Update.
* coffread.c (process_coff_symbol, decode_base_type): Update.
* c-varobj.c (c_is_path_expr_parent): Update.
* c-typeprint.c (c_type_print_base_struct_union): Update.
(c_type_print_base_1): Update. Print struct/class/union/enum in
summary when using C language.
* ax-gdb.c (gen_struct_ref, gen_namespace_elt)
(gen_maybe_namespace_elt): Update.
* ada-lang.c (ada_type_name): Simplify.
(empty_record, ada_template_to_fixed_record_type_1)
(template_to_static_fixed_type)
(to_record_with_fixed_variant_part, ada_check_typedef): Update.
gdb/testsuite/ChangeLog
2018-06-01 Tom Tromey <tom@tromey.com>
* gdb.xml/tdesc-regs.exp (load_description): Update expected
results.
* gdb.dwarf2/method-ptr.exp: Set language to C++.
* gdb.dwarf2/member-ptr-forwardref.exp: Set language to C++.
* gdb.cp/typeid.exp (do_typeid_tests): Update type_re.
* gdb.base/maint.exp (maint_pass_if): Update.
2018-04-17 21:51:24 +02:00
|
|
|
|
if (TYPE_NAME (type) == NULL)
|
2017-12-11 17:57:19 +01:00
|
|
|
|
fprintf_filtered (stream, "{...}");
|
|
|
|
|
}
|
Remove TYPE_TAG_NAME
TYPE_TAG_NAME has been an occasional source of confusion and bugs. It
seems to me that it is only useful for C and C++ -- but even there,
not so much, because at least with DWARF there doesn't seem to be any
way to wind up with a type where the name and the tag name are both
non-NULL and different.
So, this patch removes TYPE_TAG_NAME entirely. This should save a
little memory, but more importantly, it simplifies this part of gdb.
A few minor test suite adjustments were needed. In some situations
the new code does not yield identical output to the old code.
gdb/ChangeLog
2018-06-01 Tom Tromey <tom@tromey.com>
* valops.c (enum_constant_from_type, value_namespace_elt)
(value_maybe_namespace_elt): Update.
* valarith.c (find_size_for_pointer_math): Update.
* target-descriptions.c (make_gdb_type): Update.
* symmisc.c (print_symbol): Update.
* stabsread.c (define_symbol, read_type)
(complain_about_struct_wipeout, add_undefined_type)
(cleanup_undefined_types_1): Update.
* rust-lang.c (rust_tuple_type_p, rust_slice_type_p)
(rust_range_type_p, val_print_struct, rust_print_struct_def)
(rust_internal_print_type, rust_composite_type)
(rust_evaluate_funcall, rust_evaluate_subexp)
(rust_inclusive_range_type_p): Update.
* python/py-type.c (typy_get_tag): Update.
* p-typeprint.c (pascal_type_print_base): Update.
* mdebugread.c (parse_symbol, parse_type): Update.
* m2-typeprint.c (m2_long_set, m2_record_fields, m2_enum):
Update.
* guile/scm-type.c (gdbscm_type_tag): Update.
* go-lang.c (sixg_string_p): Update.
* gnu-v3-abi.c (build_gdb_vtable_type, build_std_type_info_type):
Update.
* gdbtypes.h (struct main_type) <tag_name>: Remove.
(TYPE_TAG_NAME): Remove.
* gdbtypes.c (type_name_no_tag): Simplify.
(check_typedef, check_types_equal, recursive_dump_type)
(copy_type_recursive, arch_composite_type): Update.
* f-typeprint.c (f_type_print_base): Update. Print "Type" prefix
in summary mode when needed.
* eval.c (evaluate_funcall): Update.
* dwarf2read.c (fixup_go_packaging, read_structure_type)
(process_structure_scope, read_enumeration_type)
(read_namespace_type, read_module_type, determine_prefix): Update.
* cp-support.c (inspect_type): Update.
* coffread.c (process_coff_symbol, decode_base_type): Update.
* c-varobj.c (c_is_path_expr_parent): Update.
* c-typeprint.c (c_type_print_base_struct_union): Update.
(c_type_print_base_1): Update. Print struct/class/union/enum in
summary when using C language.
* ax-gdb.c (gen_struct_ref, gen_namespace_elt)
(gen_maybe_namespace_elt): Update.
* ada-lang.c (ada_type_name): Simplify.
(empty_record, ada_template_to_fixed_record_type_1)
(template_to_static_fixed_type)
(to_record_with_fixed_variant_part, ada_check_typedef): Update.
gdb/testsuite/ChangeLog
2018-06-01 Tom Tromey <tom@tromey.com>
* gdb.xml/tdesc-regs.exp (load_description): Update expected
results.
* gdb.dwarf2/method-ptr.exp: Set language to C++.
* gdb.dwarf2/member-ptr-forwardref.exp: Set language to C++.
* gdb.cp/typeid.exp (do_typeid_tests): Update type_re.
* gdb.base/maint.exp (maint_pass_if): Update.
2018-04-17 21:51:24 +02:00
|
|
|
|
else if (show > 0 || TYPE_NAME (type) == NULL)
|
2017-12-11 17:57:19 +01:00
|
|
|
|
{
|
|
|
|
|
struct type *basetype;
|
|
|
|
|
int vptr_fieldno;
|
|
|
|
|
|
|
|
|
|
c_type_print_template_args (&local_flags, type, stream);
|
|
|
|
|
|
|
|
|
|
/* Add in template parameters when printing derivation info. */
|
2018-03-14 23:38:02 +01:00
|
|
|
|
if (local_flags.local_typedefs != NULL)
|
|
|
|
|
local_flags.local_typedefs->add_template_parameters (type);
|
2017-12-11 17:57:19 +01:00
|
|
|
|
cp_type_print_derivation_info (stream, type, &local_flags);
|
|
|
|
|
|
|
|
|
|
/* This holds just the global typedefs and the template
|
|
|
|
|
parameters. */
|
2018-03-14 23:38:02 +01:00
|
|
|
|
struct type_print_options semi_local_flags = *flags;
|
|
|
|
|
semi_local_flags.local_typedefs = NULL;
|
2017-12-11 17:57:19 +01:00
|
|
|
|
|
2018-03-14 23:38:02 +01:00
|
|
|
|
std::unique_ptr<typedef_hash_table> semi_holder;
|
|
|
|
|
if (local_flags.local_typedefs != nullptr)
|
|
|
|
|
{
|
|
|
|
|
semi_local_flags.local_typedefs
|
|
|
|
|
= new typedef_hash_table (*local_flags.local_typedefs);
|
|
|
|
|
semi_holder.reset (semi_local_flags.local_typedefs);
|
|
|
|
|
|
|
|
|
|
/* Now add in the local typedefs. */
|
|
|
|
|
local_flags.local_typedefs->recursively_update (type);
|
|
|
|
|
}
|
2017-12-11 17:57:19 +01:00
|
|
|
|
|
|
|
|
|
fprintf_filtered (stream, "{\n");
|
Implement pahole-like 'ptype /o' option
This commit implements the pahole-like '/o' option for 'ptype', which
prints the offsets and sizes of struct fields, reporting whenever
there is a hole found.
The output is heavily based on pahole(1), with a few modifications
here and there to adjust it to our reality. Here's an example:
/* offset | size */ type = struct wer : public tuv {
public:
/* 32 | 24 */ struct tyu {
/* 32:31 | 4 */ int a1 : 1;
/* 32:28 | 4 */ int a2 : 3;
/* 32: 5 | 4 */ int a3 : 23;
/* 35: 3 | 1 */ char a4 : 2;
/* XXX 3-bit hole */
/* XXX 4-byte hole */
/* 40 | 8 */ int64_t a5;
/* 48:27 | 4 */ int a6 : 5;
/* 48:56 | 8 */ int64_t a7 : 3;
/* total size (bytes): 24 */
} a1;
/* total size (bytes): 56 */
}
A big part of this patch handles the formatting logic of 'ptype',
which is a bit messy. The code to handle bitfield offsets, however,
took some time to craft. My thanks to Pedro Alves for figuring things
out and pointing me to the right direction, as well as coming up with
a way to inspect the layout of structs with bitfields (see testcase
for comments).
After many discussions both on IRC and at the mailing list, I tried to
implement printing vtables and inherited classes. Unfortunately the
code grew too complex and there were still a few corner cases failing
so I had to drop the attempt. This should be implemented in a future
patch.
This patch is the start of a long-term work I'll do to flush the local
patches we carry for Fedora GDB. In this specific case, I'm aiming at
upstreaming the feature implemented by the 'pahole.py' script that is
shipped with Fedora GDB:
<https://src.fedoraproject.org/rpms/gdb/blob/master/f/gdb-archer.patch#_311>
This has been regression-tested on the BuildBot. There's a new
testcase for it, along with an update to the documentation. I also
thought it was worth mentioning this feature in the NEWS file.
gdb/ChangeLog:
2017-12-15 Sergio Durigan Junior <sergiodj@redhat.com>
Pedro Alves <palves@redhat.com>
PR cli/16224
* NEWS (Changes since GDB 8.0): Mention new '/o' flag.
* c-typeprint.c (OFFSET_SPC_LEN): New define.
(c_type_print_varspec_prefix): New argument 'struct
print_offset_data *'.
(c_type_print_base_1): New function and prototype.
(c_print_type_1): New function, with code from 'c_print_type'.
(c_print_type): Use 'c_print_type_1'.
(c_type_print_varspec_prefix): New argument 'struct
print_offset_data *'. Use it. Call 'c_type_print_base_1'
instead of 'c_print_type_base'.
(print_spaces_filtered_with_print_options): New function.
(output_access_specifier): Take new argument FLAGS. Modify
function to call 'print_spaces_filtered_with_print_options'.
(c_print_type_vtable_offset_marker): New function.
(c_print_type_union_field_offset): New function.
(c_print_type_struct_field_offset): New function.
(c_print_type_no_offsets): New function.
(c_type_print_base_struct_union): New argument 'struct
print_offset_data *'. Print offsets and sizes for
struct/union/class fields.
* typeprint.c (const struct type_print_options
type_print_raw_options): Initialize 'print_offsets'.
(static struct type_print_options default_ptype_flags):
Likewise.
(struct print_offset_data print_offset_default_data): New
variable.
(whatis_exp): Handle '/o' option.
(_initialize_typeprint): Add '/o' flag to ptype's help.
* typeprint.h (struct print_offset_data): New struct.
(struct type_print_options) <print_offsets>: New field.
gdb/testsuite/ChangeLog:
2017-12-15 Sergio Durigan Junior <sergiodj@redhat.com>
PR cli/16224
* gdb.base/ptype-offsets.cc: New file.
* gdb.base/ptype-offsets.exp: New file.
gdb/doc/ChangeLog:
2017-12-15 Sergio Durigan Junior <sergiodj@redhat.com>
PR cli/16224
* gdb.texinfo (ptype): Add documentation for new flag '/o'.
2017-11-20 22:34:59 +01:00
|
|
|
|
|
2017-12-11 17:57:19 +01:00
|
|
|
|
if (TYPE_NFIELDS (type) == 0 && TYPE_NFN_FIELDS (type) == 0
|
|
|
|
|
&& TYPE_TYPEDEF_FIELD_COUNT (type) == 0)
|
|
|
|
|
{
|
|
|
|
|
if (TYPE_STUB (type))
|
|
|
|
|
fprintfi_filtered (level + 4, stream,
|
|
|
|
|
_("<incomplete type>\n"));
|
|
|
|
|
else
|
|
|
|
|
fprintfi_filtered (level + 4, stream,
|
|
|
|
|
_("<no data fields>\n"));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Start off with no specific section type, so we can print
|
|
|
|
|
one for the first field we find, and use that section type
|
|
|
|
|
thereafter until we find another type. */
|
|
|
|
|
|
|
|
|
|
enum access_specifier section_type = s_none;
|
|
|
|
|
|
|
|
|
|
/* For a class, if all members are private, there's no need
|
|
|
|
|
for a "private:" label; similarly, for a struct or union
|
|
|
|
|
masquerading as a class, if all members are public, there's
|
|
|
|
|
no need for a "public:" label. */
|
|
|
|
|
bool need_access_label = need_access_label_p (type);
|
|
|
|
|
|
|
|
|
|
/* If there is a base class for this type,
|
|
|
|
|
do not print the field that it occupies. */
|
|
|
|
|
|
|
|
|
|
int len = TYPE_NFIELDS (type);
|
|
|
|
|
vptr_fieldno = get_vptr_fieldno (type, &basetype);
|
Implement pahole-like 'ptype /o' option
This commit implements the pahole-like '/o' option for 'ptype', which
prints the offsets and sizes of struct fields, reporting whenever
there is a hole found.
The output is heavily based on pahole(1), with a few modifications
here and there to adjust it to our reality. Here's an example:
/* offset | size */ type = struct wer : public tuv {
public:
/* 32 | 24 */ struct tyu {
/* 32:31 | 4 */ int a1 : 1;
/* 32:28 | 4 */ int a2 : 3;
/* 32: 5 | 4 */ int a3 : 23;
/* 35: 3 | 1 */ char a4 : 2;
/* XXX 3-bit hole */
/* XXX 4-byte hole */
/* 40 | 8 */ int64_t a5;
/* 48:27 | 4 */ int a6 : 5;
/* 48:56 | 8 */ int64_t a7 : 3;
/* total size (bytes): 24 */
} a1;
/* total size (bytes): 56 */
}
A big part of this patch handles the formatting logic of 'ptype',
which is a bit messy. The code to handle bitfield offsets, however,
took some time to craft. My thanks to Pedro Alves for figuring things
out and pointing me to the right direction, as well as coming up with
a way to inspect the layout of structs with bitfields (see testcase
for comments).
After many discussions both on IRC and at the mailing list, I tried to
implement printing vtables and inherited classes. Unfortunately the
code grew too complex and there were still a few corner cases failing
so I had to drop the attempt. This should be implemented in a future
patch.
This patch is the start of a long-term work I'll do to flush the local
patches we carry for Fedora GDB. In this specific case, I'm aiming at
upstreaming the feature implemented by the 'pahole.py' script that is
shipped with Fedora GDB:
<https://src.fedoraproject.org/rpms/gdb/blob/master/f/gdb-archer.patch#_311>
This has been regression-tested on the BuildBot. There's a new
testcase for it, along with an update to the documentation. I also
thought it was worth mentioning this feature in the NEWS file.
gdb/ChangeLog:
2017-12-15 Sergio Durigan Junior <sergiodj@redhat.com>
Pedro Alves <palves@redhat.com>
PR cli/16224
* NEWS (Changes since GDB 8.0): Mention new '/o' flag.
* c-typeprint.c (OFFSET_SPC_LEN): New define.
(c_type_print_varspec_prefix): New argument 'struct
print_offset_data *'.
(c_type_print_base_1): New function and prototype.
(c_print_type_1): New function, with code from 'c_print_type'.
(c_print_type): Use 'c_print_type_1'.
(c_type_print_varspec_prefix): New argument 'struct
print_offset_data *'. Use it. Call 'c_type_print_base_1'
instead of 'c_print_type_base'.
(print_spaces_filtered_with_print_options): New function.
(output_access_specifier): Take new argument FLAGS. Modify
function to call 'print_spaces_filtered_with_print_options'.
(c_print_type_vtable_offset_marker): New function.
(c_print_type_union_field_offset): New function.
(c_print_type_struct_field_offset): New function.
(c_print_type_no_offsets): New function.
(c_type_print_base_struct_union): New argument 'struct
print_offset_data *'. Print offsets and sizes for
struct/union/class fields.
* typeprint.c (const struct type_print_options
type_print_raw_options): Initialize 'print_offsets'.
(static struct type_print_options default_ptype_flags):
Likewise.
(struct print_offset_data print_offset_default_data): New
variable.
(whatis_exp): Handle '/o' option.
(_initialize_typeprint): Add '/o' flag to ptype's help.
* typeprint.h (struct print_offset_data): New struct.
(struct type_print_options) <print_offsets>: New field.
gdb/testsuite/ChangeLog:
2017-12-15 Sergio Durigan Junior <sergiodj@redhat.com>
PR cli/16224
* gdb.base/ptype-offsets.cc: New file.
* gdb.base/ptype-offsets.exp: New file.
gdb/doc/ChangeLog:
2017-12-15 Sergio Durigan Junior <sergiodj@redhat.com>
PR cli/16224
* gdb.texinfo (ptype): Add documentation for new flag '/o'.
2017-11-20 22:34:59 +01:00
|
|
|
|
|
|
|
|
|
struct print_offset_data local_podata;
|
|
|
|
|
|
2017-12-11 17:57:19 +01:00
|
|
|
|
for (int i = TYPE_N_BASECLASSES (type); i < len; i++)
|
|
|
|
|
{
|
|
|
|
|
QUIT;
|
|
|
|
|
|
|
|
|
|
/* If we have a virtual table pointer, omit it. Even if
|
|
|
|
|
virtual table pointers are not specifically marked in
|
|
|
|
|
the debug info, they should be artificial. */
|
|
|
|
|
if ((i == vptr_fieldno && type == basetype)
|
|
|
|
|
|| TYPE_FIELD_ARTIFICIAL (type, i))
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
if (need_access_label)
|
|
|
|
|
{
|
|
|
|
|
section_type = output_access_specifier
|
|
|
|
|
(stream, section_type, level,
|
|
|
|
|
TYPE_FIELD_PROTECTED (type, i),
|
Implement pahole-like 'ptype /o' option
This commit implements the pahole-like '/o' option for 'ptype', which
prints the offsets and sizes of struct fields, reporting whenever
there is a hole found.
The output is heavily based on pahole(1), with a few modifications
here and there to adjust it to our reality. Here's an example:
/* offset | size */ type = struct wer : public tuv {
public:
/* 32 | 24 */ struct tyu {
/* 32:31 | 4 */ int a1 : 1;
/* 32:28 | 4 */ int a2 : 3;
/* 32: 5 | 4 */ int a3 : 23;
/* 35: 3 | 1 */ char a4 : 2;
/* XXX 3-bit hole */
/* XXX 4-byte hole */
/* 40 | 8 */ int64_t a5;
/* 48:27 | 4 */ int a6 : 5;
/* 48:56 | 8 */ int64_t a7 : 3;
/* total size (bytes): 24 */
} a1;
/* total size (bytes): 56 */
}
A big part of this patch handles the formatting logic of 'ptype',
which is a bit messy. The code to handle bitfield offsets, however,
took some time to craft. My thanks to Pedro Alves for figuring things
out and pointing me to the right direction, as well as coming up with
a way to inspect the layout of structs with bitfields (see testcase
for comments).
After many discussions both on IRC and at the mailing list, I tried to
implement printing vtables and inherited classes. Unfortunately the
code grew too complex and there were still a few corner cases failing
so I had to drop the attempt. This should be implemented in a future
patch.
This patch is the start of a long-term work I'll do to flush the local
patches we carry for Fedora GDB. In this specific case, I'm aiming at
upstreaming the feature implemented by the 'pahole.py' script that is
shipped with Fedora GDB:
<https://src.fedoraproject.org/rpms/gdb/blob/master/f/gdb-archer.patch#_311>
This has been regression-tested on the BuildBot. There's a new
testcase for it, along with an update to the documentation. I also
thought it was worth mentioning this feature in the NEWS file.
gdb/ChangeLog:
2017-12-15 Sergio Durigan Junior <sergiodj@redhat.com>
Pedro Alves <palves@redhat.com>
PR cli/16224
* NEWS (Changes since GDB 8.0): Mention new '/o' flag.
* c-typeprint.c (OFFSET_SPC_LEN): New define.
(c_type_print_varspec_prefix): New argument 'struct
print_offset_data *'.
(c_type_print_base_1): New function and prototype.
(c_print_type_1): New function, with code from 'c_print_type'.
(c_print_type): Use 'c_print_type_1'.
(c_type_print_varspec_prefix): New argument 'struct
print_offset_data *'. Use it. Call 'c_type_print_base_1'
instead of 'c_print_type_base'.
(print_spaces_filtered_with_print_options): New function.
(output_access_specifier): Take new argument FLAGS. Modify
function to call 'print_spaces_filtered_with_print_options'.
(c_print_type_vtable_offset_marker): New function.
(c_print_type_union_field_offset): New function.
(c_print_type_struct_field_offset): New function.
(c_print_type_no_offsets): New function.
(c_type_print_base_struct_union): New argument 'struct
print_offset_data *'. Print offsets and sizes for
struct/union/class fields.
* typeprint.c (const struct type_print_options
type_print_raw_options): Initialize 'print_offsets'.
(static struct type_print_options default_ptype_flags):
Likewise.
(struct print_offset_data print_offset_default_data): New
variable.
(whatis_exp): Handle '/o' option.
(_initialize_typeprint): Add '/o' flag to ptype's help.
* typeprint.h (struct print_offset_data): New struct.
(struct type_print_options) <print_offsets>: New field.
gdb/testsuite/ChangeLog:
2017-12-15 Sergio Durigan Junior <sergiodj@redhat.com>
PR cli/16224
* gdb.base/ptype-offsets.cc: New file.
* gdb.base/ptype-offsets.exp: New file.
gdb/doc/ChangeLog:
2017-12-15 Sergio Durigan Junior <sergiodj@redhat.com>
PR cli/16224
* gdb.texinfo (ptype): Add documentation for new flag '/o'.
2017-11-20 22:34:59 +01:00
|
|
|
|
TYPE_FIELD_PRIVATE (type, i), flags);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool is_static = field_is_static (&TYPE_FIELD (type, i));
|
|
|
|
|
|
|
|
|
|
if (flags->print_offsets)
|
2018-06-08 20:43:47 +02:00
|
|
|
|
podata->update (type, i, stream);
|
2017-12-11 17:57:19 +01:00
|
|
|
|
|
|
|
|
|
print_spaces_filtered (level + 4, stream);
|
Implement pahole-like 'ptype /o' option
This commit implements the pahole-like '/o' option for 'ptype', which
prints the offsets and sizes of struct fields, reporting whenever
there is a hole found.
The output is heavily based on pahole(1), with a few modifications
here and there to adjust it to our reality. Here's an example:
/* offset | size */ type = struct wer : public tuv {
public:
/* 32 | 24 */ struct tyu {
/* 32:31 | 4 */ int a1 : 1;
/* 32:28 | 4 */ int a2 : 3;
/* 32: 5 | 4 */ int a3 : 23;
/* 35: 3 | 1 */ char a4 : 2;
/* XXX 3-bit hole */
/* XXX 4-byte hole */
/* 40 | 8 */ int64_t a5;
/* 48:27 | 4 */ int a6 : 5;
/* 48:56 | 8 */ int64_t a7 : 3;
/* total size (bytes): 24 */
} a1;
/* total size (bytes): 56 */
}
A big part of this patch handles the formatting logic of 'ptype',
which is a bit messy. The code to handle bitfield offsets, however,
took some time to craft. My thanks to Pedro Alves for figuring things
out and pointing me to the right direction, as well as coming up with
a way to inspect the layout of structs with bitfields (see testcase
for comments).
After many discussions both on IRC and at the mailing list, I tried to
implement printing vtables and inherited classes. Unfortunately the
code grew too complex and there were still a few corner cases failing
so I had to drop the attempt. This should be implemented in a future
patch.
This patch is the start of a long-term work I'll do to flush the local
patches we carry for Fedora GDB. In this specific case, I'm aiming at
upstreaming the feature implemented by the 'pahole.py' script that is
shipped with Fedora GDB:
<https://src.fedoraproject.org/rpms/gdb/blob/master/f/gdb-archer.patch#_311>
This has been regression-tested on the BuildBot. There's a new
testcase for it, along with an update to the documentation. I also
thought it was worth mentioning this feature in the NEWS file.
gdb/ChangeLog:
2017-12-15 Sergio Durigan Junior <sergiodj@redhat.com>
Pedro Alves <palves@redhat.com>
PR cli/16224
* NEWS (Changes since GDB 8.0): Mention new '/o' flag.
* c-typeprint.c (OFFSET_SPC_LEN): New define.
(c_type_print_varspec_prefix): New argument 'struct
print_offset_data *'.
(c_type_print_base_1): New function and prototype.
(c_print_type_1): New function, with code from 'c_print_type'.
(c_print_type): Use 'c_print_type_1'.
(c_type_print_varspec_prefix): New argument 'struct
print_offset_data *'. Use it. Call 'c_type_print_base_1'
instead of 'c_print_type_base'.
(print_spaces_filtered_with_print_options): New function.
(output_access_specifier): Take new argument FLAGS. Modify
function to call 'print_spaces_filtered_with_print_options'.
(c_print_type_vtable_offset_marker): New function.
(c_print_type_union_field_offset): New function.
(c_print_type_struct_field_offset): New function.
(c_print_type_no_offsets): New function.
(c_type_print_base_struct_union): New argument 'struct
print_offset_data *'. Print offsets and sizes for
struct/union/class fields.
* typeprint.c (const struct type_print_options
type_print_raw_options): Initialize 'print_offsets'.
(static struct type_print_options default_ptype_flags):
Likewise.
(struct print_offset_data print_offset_default_data): New
variable.
(whatis_exp): Handle '/o' option.
(_initialize_typeprint): Add '/o' flag to ptype's help.
* typeprint.h (struct print_offset_data): New struct.
(struct type_print_options) <print_offsets>: New field.
gdb/testsuite/ChangeLog:
2017-12-15 Sergio Durigan Junior <sergiodj@redhat.com>
PR cli/16224
* gdb.base/ptype-offsets.cc: New file.
* gdb.base/ptype-offsets.exp: New file.
gdb/doc/ChangeLog:
2017-12-15 Sergio Durigan Junior <sergiodj@redhat.com>
PR cli/16224
* gdb.texinfo (ptype): Add documentation for new flag '/o'.
2017-11-20 22:34:59 +01:00
|
|
|
|
if (is_static)
|
2017-12-11 17:57:19 +01:00
|
|
|
|
fprintf_filtered (stream, "static ");
|
Implement pahole-like 'ptype /o' option
This commit implements the pahole-like '/o' option for 'ptype', which
prints the offsets and sizes of struct fields, reporting whenever
there is a hole found.
The output is heavily based on pahole(1), with a few modifications
here and there to adjust it to our reality. Here's an example:
/* offset | size */ type = struct wer : public tuv {
public:
/* 32 | 24 */ struct tyu {
/* 32:31 | 4 */ int a1 : 1;
/* 32:28 | 4 */ int a2 : 3;
/* 32: 5 | 4 */ int a3 : 23;
/* 35: 3 | 1 */ char a4 : 2;
/* XXX 3-bit hole */
/* XXX 4-byte hole */
/* 40 | 8 */ int64_t a5;
/* 48:27 | 4 */ int a6 : 5;
/* 48:56 | 8 */ int64_t a7 : 3;
/* total size (bytes): 24 */
} a1;
/* total size (bytes): 56 */
}
A big part of this patch handles the formatting logic of 'ptype',
which is a bit messy. The code to handle bitfield offsets, however,
took some time to craft. My thanks to Pedro Alves for figuring things
out and pointing me to the right direction, as well as coming up with
a way to inspect the layout of structs with bitfields (see testcase
for comments).
After many discussions both on IRC and at the mailing list, I tried to
implement printing vtables and inherited classes. Unfortunately the
code grew too complex and there were still a few corner cases failing
so I had to drop the attempt. This should be implemented in a future
patch.
This patch is the start of a long-term work I'll do to flush the local
patches we carry for Fedora GDB. In this specific case, I'm aiming at
upstreaming the feature implemented by the 'pahole.py' script that is
shipped with Fedora GDB:
<https://src.fedoraproject.org/rpms/gdb/blob/master/f/gdb-archer.patch#_311>
This has been regression-tested on the BuildBot. There's a new
testcase for it, along with an update to the documentation. I also
thought it was worth mentioning this feature in the NEWS file.
gdb/ChangeLog:
2017-12-15 Sergio Durigan Junior <sergiodj@redhat.com>
Pedro Alves <palves@redhat.com>
PR cli/16224
* NEWS (Changes since GDB 8.0): Mention new '/o' flag.
* c-typeprint.c (OFFSET_SPC_LEN): New define.
(c_type_print_varspec_prefix): New argument 'struct
print_offset_data *'.
(c_type_print_base_1): New function and prototype.
(c_print_type_1): New function, with code from 'c_print_type'.
(c_print_type): Use 'c_print_type_1'.
(c_type_print_varspec_prefix): New argument 'struct
print_offset_data *'. Use it. Call 'c_type_print_base_1'
instead of 'c_print_type_base'.
(print_spaces_filtered_with_print_options): New function.
(output_access_specifier): Take new argument FLAGS. Modify
function to call 'print_spaces_filtered_with_print_options'.
(c_print_type_vtable_offset_marker): New function.
(c_print_type_union_field_offset): New function.
(c_print_type_struct_field_offset): New function.
(c_print_type_no_offsets): New function.
(c_type_print_base_struct_union): New argument 'struct
print_offset_data *'. Print offsets and sizes for
struct/union/class fields.
* typeprint.c (const struct type_print_options
type_print_raw_options): Initialize 'print_offsets'.
(static struct type_print_options default_ptype_flags):
Likewise.
(struct print_offset_data print_offset_default_data): New
variable.
(whatis_exp): Handle '/o' option.
(_initialize_typeprint): Add '/o' flag to ptype's help.
* typeprint.h (struct print_offset_data): New struct.
(struct type_print_options) <print_offsets>: New field.
gdb/testsuite/ChangeLog:
2017-12-15 Sergio Durigan Junior <sergiodj@redhat.com>
PR cli/16224
* gdb.base/ptype-offsets.cc: New file.
* gdb.base/ptype-offsets.exp: New file.
gdb/doc/ChangeLog:
2017-12-15 Sergio Durigan Junior <sergiodj@redhat.com>
PR cli/16224
* gdb.texinfo (ptype): Add documentation for new flag '/o'.
2017-11-20 22:34:59 +01:00
|
|
|
|
|
|
|
|
|
int newshow = show - 1;
|
|
|
|
|
|
|
|
|
|
if (flags->print_offsets
|
|
|
|
|
&& (TYPE_CODE (TYPE_FIELD_TYPE (type, i)) == TYPE_CODE_STRUCT
|
|
|
|
|
|| TYPE_CODE (TYPE_FIELD_TYPE (type, i)) == TYPE_CODE_UNION))
|
|
|
|
|
{
|
|
|
|
|
/* If we're printing offsets and this field's type is
|
|
|
|
|
either a struct or an union, then we're interested in
|
|
|
|
|
expanding it. */
|
|
|
|
|
++newshow;
|
|
|
|
|
|
|
|
|
|
/* Make sure we carry our offset when we expand the
|
|
|
|
|
struct/union. */
|
|
|
|
|
local_podata.offset_bitpos
|
|
|
|
|
= podata->offset_bitpos + TYPE_FIELD_BITPOS (type, i);
|
|
|
|
|
/* We're entering a struct/union. Right now,
|
|
|
|
|
PODATA->END_BITPOS points right *after* the
|
|
|
|
|
struct/union. However, when printing the first field
|
|
|
|
|
of this inner struct/union, the end_bitpos we're
|
|
|
|
|
expecting is exactly at the beginning of the
|
|
|
|
|
struct/union. Therefore, we subtract the length of
|
|
|
|
|
the whole struct/union. */
|
|
|
|
|
local_podata.end_bitpos
|
|
|
|
|
= podata->end_bitpos
|
|
|
|
|
- TYPE_LENGTH (TYPE_FIELD_TYPE (type, i)) * TARGET_CHAR_BIT;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
c_print_type_1 (TYPE_FIELD_TYPE (type, i),
|
|
|
|
|
TYPE_FIELD_NAME (type, i),
|
|
|
|
|
stream, newshow, level + 4,
|
2018-04-17 21:51:23 +02:00
|
|
|
|
language, &local_flags, &local_podata);
|
Implement pahole-like 'ptype /o' option
This commit implements the pahole-like '/o' option for 'ptype', which
prints the offsets and sizes of struct fields, reporting whenever
there is a hole found.
The output is heavily based on pahole(1), with a few modifications
here and there to adjust it to our reality. Here's an example:
/* offset | size */ type = struct wer : public tuv {
public:
/* 32 | 24 */ struct tyu {
/* 32:31 | 4 */ int a1 : 1;
/* 32:28 | 4 */ int a2 : 3;
/* 32: 5 | 4 */ int a3 : 23;
/* 35: 3 | 1 */ char a4 : 2;
/* XXX 3-bit hole */
/* XXX 4-byte hole */
/* 40 | 8 */ int64_t a5;
/* 48:27 | 4 */ int a6 : 5;
/* 48:56 | 8 */ int64_t a7 : 3;
/* total size (bytes): 24 */
} a1;
/* total size (bytes): 56 */
}
A big part of this patch handles the formatting logic of 'ptype',
which is a bit messy. The code to handle bitfield offsets, however,
took some time to craft. My thanks to Pedro Alves for figuring things
out and pointing me to the right direction, as well as coming up with
a way to inspect the layout of structs with bitfields (see testcase
for comments).
After many discussions both on IRC and at the mailing list, I tried to
implement printing vtables and inherited classes. Unfortunately the
code grew too complex and there were still a few corner cases failing
so I had to drop the attempt. This should be implemented in a future
patch.
This patch is the start of a long-term work I'll do to flush the local
patches we carry for Fedora GDB. In this specific case, I'm aiming at
upstreaming the feature implemented by the 'pahole.py' script that is
shipped with Fedora GDB:
<https://src.fedoraproject.org/rpms/gdb/blob/master/f/gdb-archer.patch#_311>
This has been regression-tested on the BuildBot. There's a new
testcase for it, along with an update to the documentation. I also
thought it was worth mentioning this feature in the NEWS file.
gdb/ChangeLog:
2017-12-15 Sergio Durigan Junior <sergiodj@redhat.com>
Pedro Alves <palves@redhat.com>
PR cli/16224
* NEWS (Changes since GDB 8.0): Mention new '/o' flag.
* c-typeprint.c (OFFSET_SPC_LEN): New define.
(c_type_print_varspec_prefix): New argument 'struct
print_offset_data *'.
(c_type_print_base_1): New function and prototype.
(c_print_type_1): New function, with code from 'c_print_type'.
(c_print_type): Use 'c_print_type_1'.
(c_type_print_varspec_prefix): New argument 'struct
print_offset_data *'. Use it. Call 'c_type_print_base_1'
instead of 'c_print_type_base'.
(print_spaces_filtered_with_print_options): New function.
(output_access_specifier): Take new argument FLAGS. Modify
function to call 'print_spaces_filtered_with_print_options'.
(c_print_type_vtable_offset_marker): New function.
(c_print_type_union_field_offset): New function.
(c_print_type_struct_field_offset): New function.
(c_print_type_no_offsets): New function.
(c_type_print_base_struct_union): New argument 'struct
print_offset_data *'. Print offsets and sizes for
struct/union/class fields.
* typeprint.c (const struct type_print_options
type_print_raw_options): Initialize 'print_offsets'.
(static struct type_print_options default_ptype_flags):
Likewise.
(struct print_offset_data print_offset_default_data): New
variable.
(whatis_exp): Handle '/o' option.
(_initialize_typeprint): Add '/o' flag to ptype's help.
* typeprint.h (struct print_offset_data): New struct.
(struct type_print_options) <print_offsets>: New field.
gdb/testsuite/ChangeLog:
2017-12-15 Sergio Durigan Junior <sergiodj@redhat.com>
PR cli/16224
* gdb.base/ptype-offsets.cc: New file.
* gdb.base/ptype-offsets.exp: New file.
gdb/doc/ChangeLog:
2017-12-15 Sergio Durigan Junior <sergiodj@redhat.com>
PR cli/16224
* gdb.texinfo (ptype): Add documentation for new flag '/o'.
2017-11-20 22:34:59 +01:00
|
|
|
|
|
|
|
|
|
if (!is_static && TYPE_FIELD_PACKED (type, i))
|
2017-12-11 17:57:19 +01:00
|
|
|
|
{
|
|
|
|
|
/* It is a bitfield. This code does not attempt
|
|
|
|
|
to look at the bitpos and reconstruct filler,
|
|
|
|
|
unnamed fields. This would lead to misleading
|
|
|
|
|
results if the compiler does not put out fields
|
|
|
|
|
for such things (I don't know what it does). */
|
|
|
|
|
fprintf_filtered (stream, " : %d",
|
|
|
|
|
TYPE_FIELD_BITSIZE (type, i));
|
|
|
|
|
}
|
|
|
|
|
fprintf_filtered (stream, ";\n");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* If there are both fields and methods, put a blank line
|
|
|
|
|
between them. Make sure to count only method that we
|
|
|
|
|
will display; artificial methods will be hidden. */
|
|
|
|
|
len = TYPE_NFN_FIELDS (type);
|
|
|
|
|
if (!flags->print_methods)
|
|
|
|
|
len = 0;
|
|
|
|
|
int real_len = 0;
|
|
|
|
|
for (int i = 0; i < len; i++)
|
|
|
|
|
{
|
|
|
|
|
struct fn_field *f = TYPE_FN_FIELDLIST1 (type, i);
|
|
|
|
|
int len2 = TYPE_FN_FIELDLIST_LENGTH (type, i);
|
|
|
|
|
int j;
|
|
|
|
|
|
|
|
|
|
for (j = 0; j < len2; j++)
|
|
|
|
|
if (!TYPE_FN_FIELD_ARTIFICIAL (f, j))
|
|
|
|
|
real_len++;
|
|
|
|
|
}
|
|
|
|
|
if (real_len > 0 && section_type != s_none)
|
|
|
|
|
fprintf_filtered (stream, "\n");
|
|
|
|
|
|
|
|
|
|
/* C++: print out the methods. */
|
|
|
|
|
for (int i = 0; i < len; i++)
|
|
|
|
|
{
|
|
|
|
|
struct fn_field *f = TYPE_FN_FIELDLIST1 (type, i);
|
|
|
|
|
int j, len2 = TYPE_FN_FIELDLIST_LENGTH (type, i);
|
|
|
|
|
const char *method_name = TYPE_FN_FIELDLIST_NAME (type, i);
|
Remove type_name_no_tag and rename type_name_no_tag_or_error
type_name_no_tag is just a plain wrapper for TYPE_NAME now, so this
patch removes it. And, because tag names no longer exist, this
renames type_name_no_tag_or_error to type_name_or_error.
gdb/ChangeLog
2018-06-01 Tom Tromey <tom@tromey.com>
* valops.c (value_cast_structs, destructor_name_p): Update.
* symtab.c (gdb_mangle_name): Update.
* stabsread.c (define_symbol, read_cpp_abbrev, read_baseclasses):
Update.
* p-valprint.c (pascal_object_is_vtbl_ptr_type)
(pascal_object_print_value_fields, pascal_object_print_value):
Update.
* p-typeprint.c (pascal_type_print_derivation_info): Update.
* linespec.c (find_methods): Update.
* gdbtypes.h (type_name_no_tag): Remove.
(type_name_or_error): Rename from type_name_no_tag_or_error.
* gdbtypes.c (type_name_no_tag): Remove.
(type_name_or_error): Rename from type_name_no_tag_or_error.
(lookup_struct_elt_type, check_typedef): Update.
* expprint.c (print_subexp_standard): Update.
* dwarf2read.c (dwarf2_add_field, load_partial_dies): Update.
* d-namespace.c (d_lookup_nested_symbol): Update.
* cp-valprint.c (cp_is_vtbl_ptr_type, cp_print_value_fields)
(cp_print_class_member): Update.
* cp-namespace.c (cp_lookup_nested_symbol): Update.
* completer.c (add_struct_fields): Update.
* c-typeprint.c (cp_type_print_derivation_info)
(c_type_print_varspec_prefix, c_type_print_base_struct_union):
Update.
* ada-lang.c (parse_old_style_renaming, xget_renaming_scope)
(ada_prefer_type, ada_is_exception_sym): Update.
2018-04-17 21:51:25 +02:00
|
|
|
|
const char *name = TYPE_NAME (type);
|
2017-12-11 17:57:19 +01:00
|
|
|
|
int is_constructor = name && strcmp (method_name,
|
|
|
|
|
name) == 0;
|
|
|
|
|
|
|
|
|
|
for (j = 0; j < len2; j++)
|
|
|
|
|
{
|
|
|
|
|
const char *mangled_name;
|
|
|
|
|
gdb::unique_xmalloc_ptr<char> mangled_name_holder;
|
|
|
|
|
char *demangled_name;
|
|
|
|
|
const char *physname = TYPE_FN_FIELD_PHYSNAME (f, j);
|
|
|
|
|
int is_full_physname_constructor =
|
|
|
|
|
TYPE_FN_FIELD_CONSTRUCTOR (f, j)
|
|
|
|
|
|| is_constructor_name (physname)
|
|
|
|
|
|| is_destructor_name (physname)
|
|
|
|
|
|| method_name[0] == '~';
|
|
|
|
|
|
|
|
|
|
/* Do not print out artificial methods. */
|
|
|
|
|
if (TYPE_FN_FIELD_ARTIFICIAL (f, j))
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
QUIT;
|
|
|
|
|
section_type = output_access_specifier
|
|
|
|
|
(stream, section_type, level,
|
|
|
|
|
TYPE_FN_FIELD_PROTECTED (f, j),
|
Implement pahole-like 'ptype /o' option
This commit implements the pahole-like '/o' option for 'ptype', which
prints the offsets and sizes of struct fields, reporting whenever
there is a hole found.
The output is heavily based on pahole(1), with a few modifications
here and there to adjust it to our reality. Here's an example:
/* offset | size */ type = struct wer : public tuv {
public:
/* 32 | 24 */ struct tyu {
/* 32:31 | 4 */ int a1 : 1;
/* 32:28 | 4 */ int a2 : 3;
/* 32: 5 | 4 */ int a3 : 23;
/* 35: 3 | 1 */ char a4 : 2;
/* XXX 3-bit hole */
/* XXX 4-byte hole */
/* 40 | 8 */ int64_t a5;
/* 48:27 | 4 */ int a6 : 5;
/* 48:56 | 8 */ int64_t a7 : 3;
/* total size (bytes): 24 */
} a1;
/* total size (bytes): 56 */
}
A big part of this patch handles the formatting logic of 'ptype',
which is a bit messy. The code to handle bitfield offsets, however,
took some time to craft. My thanks to Pedro Alves for figuring things
out and pointing me to the right direction, as well as coming up with
a way to inspect the layout of structs with bitfields (see testcase
for comments).
After many discussions both on IRC and at the mailing list, I tried to
implement printing vtables and inherited classes. Unfortunately the
code grew too complex and there were still a few corner cases failing
so I had to drop the attempt. This should be implemented in a future
patch.
This patch is the start of a long-term work I'll do to flush the local
patches we carry for Fedora GDB. In this specific case, I'm aiming at
upstreaming the feature implemented by the 'pahole.py' script that is
shipped with Fedora GDB:
<https://src.fedoraproject.org/rpms/gdb/blob/master/f/gdb-archer.patch#_311>
This has been regression-tested on the BuildBot. There's a new
testcase for it, along with an update to the documentation. I also
thought it was worth mentioning this feature in the NEWS file.
gdb/ChangeLog:
2017-12-15 Sergio Durigan Junior <sergiodj@redhat.com>
Pedro Alves <palves@redhat.com>
PR cli/16224
* NEWS (Changes since GDB 8.0): Mention new '/o' flag.
* c-typeprint.c (OFFSET_SPC_LEN): New define.
(c_type_print_varspec_prefix): New argument 'struct
print_offset_data *'.
(c_type_print_base_1): New function and prototype.
(c_print_type_1): New function, with code from 'c_print_type'.
(c_print_type): Use 'c_print_type_1'.
(c_type_print_varspec_prefix): New argument 'struct
print_offset_data *'. Use it. Call 'c_type_print_base_1'
instead of 'c_print_type_base'.
(print_spaces_filtered_with_print_options): New function.
(output_access_specifier): Take new argument FLAGS. Modify
function to call 'print_spaces_filtered_with_print_options'.
(c_print_type_vtable_offset_marker): New function.
(c_print_type_union_field_offset): New function.
(c_print_type_struct_field_offset): New function.
(c_print_type_no_offsets): New function.
(c_type_print_base_struct_union): New argument 'struct
print_offset_data *'. Print offsets and sizes for
struct/union/class fields.
* typeprint.c (const struct type_print_options
type_print_raw_options): Initialize 'print_offsets'.
(static struct type_print_options default_ptype_flags):
Likewise.
(struct print_offset_data print_offset_default_data): New
variable.
(whatis_exp): Handle '/o' option.
(_initialize_typeprint): Add '/o' flag to ptype's help.
* typeprint.h (struct print_offset_data): New struct.
(struct type_print_options) <print_offsets>: New field.
gdb/testsuite/ChangeLog:
2017-12-15 Sergio Durigan Junior <sergiodj@redhat.com>
PR cli/16224
* gdb.base/ptype-offsets.cc: New file.
* gdb.base/ptype-offsets.exp: New file.
gdb/doc/ChangeLog:
2017-12-15 Sergio Durigan Junior <sergiodj@redhat.com>
PR cli/16224
* gdb.texinfo (ptype): Add documentation for new flag '/o'.
2017-11-20 22:34:59 +01:00
|
|
|
|
TYPE_FN_FIELD_PRIVATE (f, j), flags);
|
2017-12-11 17:57:19 +01:00
|
|
|
|
|
Implement pahole-like 'ptype /o' option
This commit implements the pahole-like '/o' option for 'ptype', which
prints the offsets and sizes of struct fields, reporting whenever
there is a hole found.
The output is heavily based on pahole(1), with a few modifications
here and there to adjust it to our reality. Here's an example:
/* offset | size */ type = struct wer : public tuv {
public:
/* 32 | 24 */ struct tyu {
/* 32:31 | 4 */ int a1 : 1;
/* 32:28 | 4 */ int a2 : 3;
/* 32: 5 | 4 */ int a3 : 23;
/* 35: 3 | 1 */ char a4 : 2;
/* XXX 3-bit hole */
/* XXX 4-byte hole */
/* 40 | 8 */ int64_t a5;
/* 48:27 | 4 */ int a6 : 5;
/* 48:56 | 8 */ int64_t a7 : 3;
/* total size (bytes): 24 */
} a1;
/* total size (bytes): 56 */
}
A big part of this patch handles the formatting logic of 'ptype',
which is a bit messy. The code to handle bitfield offsets, however,
took some time to craft. My thanks to Pedro Alves for figuring things
out and pointing me to the right direction, as well as coming up with
a way to inspect the layout of structs with bitfields (see testcase
for comments).
After many discussions both on IRC and at the mailing list, I tried to
implement printing vtables and inherited classes. Unfortunately the
code grew too complex and there were still a few corner cases failing
so I had to drop the attempt. This should be implemented in a future
patch.
This patch is the start of a long-term work I'll do to flush the local
patches we carry for Fedora GDB. In this specific case, I'm aiming at
upstreaming the feature implemented by the 'pahole.py' script that is
shipped with Fedora GDB:
<https://src.fedoraproject.org/rpms/gdb/blob/master/f/gdb-archer.patch#_311>
This has been regression-tested on the BuildBot. There's a new
testcase for it, along with an update to the documentation. I also
thought it was worth mentioning this feature in the NEWS file.
gdb/ChangeLog:
2017-12-15 Sergio Durigan Junior <sergiodj@redhat.com>
Pedro Alves <palves@redhat.com>
PR cli/16224
* NEWS (Changes since GDB 8.0): Mention new '/o' flag.
* c-typeprint.c (OFFSET_SPC_LEN): New define.
(c_type_print_varspec_prefix): New argument 'struct
print_offset_data *'.
(c_type_print_base_1): New function and prototype.
(c_print_type_1): New function, with code from 'c_print_type'.
(c_print_type): Use 'c_print_type_1'.
(c_type_print_varspec_prefix): New argument 'struct
print_offset_data *'. Use it. Call 'c_type_print_base_1'
instead of 'c_print_type_base'.
(print_spaces_filtered_with_print_options): New function.
(output_access_specifier): Take new argument FLAGS. Modify
function to call 'print_spaces_filtered_with_print_options'.
(c_print_type_vtable_offset_marker): New function.
(c_print_type_union_field_offset): New function.
(c_print_type_struct_field_offset): New function.
(c_print_type_no_offsets): New function.
(c_type_print_base_struct_union): New argument 'struct
print_offset_data *'. Print offsets and sizes for
struct/union/class fields.
* typeprint.c (const struct type_print_options
type_print_raw_options): Initialize 'print_offsets'.
(static struct type_print_options default_ptype_flags):
Likewise.
(struct print_offset_data print_offset_default_data): New
variable.
(whatis_exp): Handle '/o' option.
(_initialize_typeprint): Add '/o' flag to ptype's help.
* typeprint.h (struct print_offset_data): New struct.
(struct type_print_options) <print_offsets>: New field.
gdb/testsuite/ChangeLog:
2017-12-15 Sergio Durigan Junior <sergiodj@redhat.com>
PR cli/16224
* gdb.base/ptype-offsets.cc: New file.
* gdb.base/ptype-offsets.exp: New file.
gdb/doc/ChangeLog:
2017-12-15 Sergio Durigan Junior <sergiodj@redhat.com>
PR cli/16224
* gdb.texinfo (ptype): Add documentation for new flag '/o'.
2017-11-20 22:34:59 +01:00
|
|
|
|
print_spaces_filtered_with_print_options (level + 4, stream,
|
|
|
|
|
flags);
|
2017-12-11 17:57:19 +01:00
|
|
|
|
if (TYPE_FN_FIELD_VIRTUAL_P (f, j))
|
|
|
|
|
fprintf_filtered (stream, "virtual ");
|
|
|
|
|
else if (TYPE_FN_FIELD_STATIC_P (f, j))
|
|
|
|
|
fprintf_filtered (stream, "static ");
|
|
|
|
|
if (TYPE_TARGET_TYPE (TYPE_FN_FIELD_TYPE (f, j)) == 0)
|
|
|
|
|
{
|
|
|
|
|
/* Keep GDB from crashing here. */
|
|
|
|
|
fprintf_filtered (stream,
|
|
|
|
|
_("<undefined type> %s;\n"),
|
|
|
|
|
TYPE_FN_FIELD_PHYSNAME (f, j));
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
else if (!is_constructor /* Constructors don't
|
|
|
|
|
have declared
|
|
|
|
|
types. */
|
|
|
|
|
&& !is_full_physname_constructor /* " " */
|
|
|
|
|
&& !is_type_conversion_operator (type, i, j))
|
|
|
|
|
{
|
Implement pahole-like 'ptype /o' option
This commit implements the pahole-like '/o' option for 'ptype', which
prints the offsets and sizes of struct fields, reporting whenever
there is a hole found.
The output is heavily based on pahole(1), with a few modifications
here and there to adjust it to our reality. Here's an example:
/* offset | size */ type = struct wer : public tuv {
public:
/* 32 | 24 */ struct tyu {
/* 32:31 | 4 */ int a1 : 1;
/* 32:28 | 4 */ int a2 : 3;
/* 32: 5 | 4 */ int a3 : 23;
/* 35: 3 | 1 */ char a4 : 2;
/* XXX 3-bit hole */
/* XXX 4-byte hole */
/* 40 | 8 */ int64_t a5;
/* 48:27 | 4 */ int a6 : 5;
/* 48:56 | 8 */ int64_t a7 : 3;
/* total size (bytes): 24 */
} a1;
/* total size (bytes): 56 */
}
A big part of this patch handles the formatting logic of 'ptype',
which is a bit messy. The code to handle bitfield offsets, however,
took some time to craft. My thanks to Pedro Alves for figuring things
out and pointing me to the right direction, as well as coming up with
a way to inspect the layout of structs with bitfields (see testcase
for comments).
After many discussions both on IRC and at the mailing list, I tried to
implement printing vtables and inherited classes. Unfortunately the
code grew too complex and there were still a few corner cases failing
so I had to drop the attempt. This should be implemented in a future
patch.
This patch is the start of a long-term work I'll do to flush the local
patches we carry for Fedora GDB. In this specific case, I'm aiming at
upstreaming the feature implemented by the 'pahole.py' script that is
shipped with Fedora GDB:
<https://src.fedoraproject.org/rpms/gdb/blob/master/f/gdb-archer.patch#_311>
This has been regression-tested on the BuildBot. There's a new
testcase for it, along with an update to the documentation. I also
thought it was worth mentioning this feature in the NEWS file.
gdb/ChangeLog:
2017-12-15 Sergio Durigan Junior <sergiodj@redhat.com>
Pedro Alves <palves@redhat.com>
PR cli/16224
* NEWS (Changes since GDB 8.0): Mention new '/o' flag.
* c-typeprint.c (OFFSET_SPC_LEN): New define.
(c_type_print_varspec_prefix): New argument 'struct
print_offset_data *'.
(c_type_print_base_1): New function and prototype.
(c_print_type_1): New function, with code from 'c_print_type'.
(c_print_type): Use 'c_print_type_1'.
(c_type_print_varspec_prefix): New argument 'struct
print_offset_data *'. Use it. Call 'c_type_print_base_1'
instead of 'c_print_type_base'.
(print_spaces_filtered_with_print_options): New function.
(output_access_specifier): Take new argument FLAGS. Modify
function to call 'print_spaces_filtered_with_print_options'.
(c_print_type_vtable_offset_marker): New function.
(c_print_type_union_field_offset): New function.
(c_print_type_struct_field_offset): New function.
(c_print_type_no_offsets): New function.
(c_type_print_base_struct_union): New argument 'struct
print_offset_data *'. Print offsets and sizes for
struct/union/class fields.
* typeprint.c (const struct type_print_options
type_print_raw_options): Initialize 'print_offsets'.
(static struct type_print_options default_ptype_flags):
Likewise.
(struct print_offset_data print_offset_default_data): New
variable.
(whatis_exp): Handle '/o' option.
(_initialize_typeprint): Add '/o' flag to ptype's help.
* typeprint.h (struct print_offset_data): New struct.
(struct type_print_options) <print_offsets>: New field.
gdb/testsuite/ChangeLog:
2017-12-15 Sergio Durigan Junior <sergiodj@redhat.com>
PR cli/16224
* gdb.base/ptype-offsets.cc: New file.
* gdb.base/ptype-offsets.exp: New file.
gdb/doc/ChangeLog:
2017-12-15 Sergio Durigan Junior <sergiodj@redhat.com>
PR cli/16224
* gdb.texinfo (ptype): Add documentation for new flag '/o'.
2017-11-20 22:34:59 +01:00
|
|
|
|
c_print_type_no_offsets
|
|
|
|
|
(TYPE_TARGET_TYPE (TYPE_FN_FIELD_TYPE (f, j)),
|
2018-04-17 21:51:23 +02:00
|
|
|
|
"", stream, -1, 0, language, &local_flags, podata);
|
Implement pahole-like 'ptype /o' option
This commit implements the pahole-like '/o' option for 'ptype', which
prints the offsets and sizes of struct fields, reporting whenever
there is a hole found.
The output is heavily based on pahole(1), with a few modifications
here and there to adjust it to our reality. Here's an example:
/* offset | size */ type = struct wer : public tuv {
public:
/* 32 | 24 */ struct tyu {
/* 32:31 | 4 */ int a1 : 1;
/* 32:28 | 4 */ int a2 : 3;
/* 32: 5 | 4 */ int a3 : 23;
/* 35: 3 | 1 */ char a4 : 2;
/* XXX 3-bit hole */
/* XXX 4-byte hole */
/* 40 | 8 */ int64_t a5;
/* 48:27 | 4 */ int a6 : 5;
/* 48:56 | 8 */ int64_t a7 : 3;
/* total size (bytes): 24 */
} a1;
/* total size (bytes): 56 */
}
A big part of this patch handles the formatting logic of 'ptype',
which is a bit messy. The code to handle bitfield offsets, however,
took some time to craft. My thanks to Pedro Alves for figuring things
out and pointing me to the right direction, as well as coming up with
a way to inspect the layout of structs with bitfields (see testcase
for comments).
After many discussions both on IRC and at the mailing list, I tried to
implement printing vtables and inherited classes. Unfortunately the
code grew too complex and there were still a few corner cases failing
so I had to drop the attempt. This should be implemented in a future
patch.
This patch is the start of a long-term work I'll do to flush the local
patches we carry for Fedora GDB. In this specific case, I'm aiming at
upstreaming the feature implemented by the 'pahole.py' script that is
shipped with Fedora GDB:
<https://src.fedoraproject.org/rpms/gdb/blob/master/f/gdb-archer.patch#_311>
This has been regression-tested on the BuildBot. There's a new
testcase for it, along with an update to the documentation. I also
thought it was worth mentioning this feature in the NEWS file.
gdb/ChangeLog:
2017-12-15 Sergio Durigan Junior <sergiodj@redhat.com>
Pedro Alves <palves@redhat.com>
PR cli/16224
* NEWS (Changes since GDB 8.0): Mention new '/o' flag.
* c-typeprint.c (OFFSET_SPC_LEN): New define.
(c_type_print_varspec_prefix): New argument 'struct
print_offset_data *'.
(c_type_print_base_1): New function and prototype.
(c_print_type_1): New function, with code from 'c_print_type'.
(c_print_type): Use 'c_print_type_1'.
(c_type_print_varspec_prefix): New argument 'struct
print_offset_data *'. Use it. Call 'c_type_print_base_1'
instead of 'c_print_type_base'.
(print_spaces_filtered_with_print_options): New function.
(output_access_specifier): Take new argument FLAGS. Modify
function to call 'print_spaces_filtered_with_print_options'.
(c_print_type_vtable_offset_marker): New function.
(c_print_type_union_field_offset): New function.
(c_print_type_struct_field_offset): New function.
(c_print_type_no_offsets): New function.
(c_type_print_base_struct_union): New argument 'struct
print_offset_data *'. Print offsets and sizes for
struct/union/class fields.
* typeprint.c (const struct type_print_options
type_print_raw_options): Initialize 'print_offsets'.
(static struct type_print_options default_ptype_flags):
Likewise.
(struct print_offset_data print_offset_default_data): New
variable.
(whatis_exp): Handle '/o' option.
(_initialize_typeprint): Add '/o' flag to ptype's help.
* typeprint.h (struct print_offset_data): New struct.
(struct type_print_options) <print_offsets>: New field.
gdb/testsuite/ChangeLog:
2017-12-15 Sergio Durigan Junior <sergiodj@redhat.com>
PR cli/16224
* gdb.base/ptype-offsets.cc: New file.
* gdb.base/ptype-offsets.exp: New file.
gdb/doc/ChangeLog:
2017-12-15 Sergio Durigan Junior <sergiodj@redhat.com>
PR cli/16224
* gdb.texinfo (ptype): Add documentation for new flag '/o'.
2017-11-20 22:34:59 +01:00
|
|
|
|
|
2017-12-11 17:57:19 +01:00
|
|
|
|
fputs_filtered (" ", stream);
|
|
|
|
|
}
|
|
|
|
|
if (TYPE_FN_FIELD_STUB (f, j))
|
|
|
|
|
{
|
|
|
|
|
/* Build something we can demangle. */
|
|
|
|
|
mangled_name_holder.reset (gdb_mangle_name (type, i, j));
|
|
|
|
|
mangled_name = mangled_name_holder.get ();
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
mangled_name = TYPE_FN_FIELD_PHYSNAME (f, j);
|
|
|
|
|
|
|
|
|
|
demangled_name =
|
|
|
|
|
gdb_demangle (mangled_name,
|
|
|
|
|
DMGL_ANSI | DMGL_PARAMS);
|
|
|
|
|
if (demangled_name == NULL)
|
|
|
|
|
{
|
|
|
|
|
/* In some cases (for instance with the HP
|
|
|
|
|
demangling), if a function has more than 10
|
|
|
|
|
arguments, the demangling will fail.
|
|
|
|
|
Let's try to reconstruct the function
|
|
|
|
|
signature from the symbol information. */
|
|
|
|
|
if (!TYPE_FN_FIELD_STUB (f, j))
|
|
|
|
|
{
|
|
|
|
|
int staticp = TYPE_FN_FIELD_STATIC_P (f, j);
|
|
|
|
|
struct type *mtype = TYPE_FN_FIELD_TYPE (f, j);
|
|
|
|
|
|
|
|
|
|
cp_type_print_method_args (mtype,
|
|
|
|
|
"",
|
|
|
|
|
method_name,
|
|
|
|
|
staticp,
|
2018-04-17 21:51:23 +02:00
|
|
|
|
stream, language,
|
|
|
|
|
&local_flags);
|
2017-12-11 17:57:19 +01:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
fprintf_filtered (stream,
|
|
|
|
|
_("<badly mangled name '%s'>"),
|
|
|
|
|
mangled_name);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
char *p;
|
|
|
|
|
char *demangled_no_class
|
|
|
|
|
= remove_qualifiers (demangled_name);
|
|
|
|
|
|
|
|
|
|
/* Get rid of the `static' appended by the
|
|
|
|
|
demangler. */
|
|
|
|
|
p = strstr (demangled_no_class, " static");
|
|
|
|
|
if (p != NULL)
|
|
|
|
|
{
|
|
|
|
|
int length = p - demangled_no_class;
|
|
|
|
|
char *demangled_no_static;
|
|
|
|
|
|
|
|
|
|
demangled_no_static
|
|
|
|
|
= (char *) xmalloc (length + 1);
|
|
|
|
|
strncpy (demangled_no_static,
|
|
|
|
|
demangled_no_class, length);
|
|
|
|
|
*(demangled_no_static + length) = '\0';
|
|
|
|
|
fputs_filtered (demangled_no_static, stream);
|
|
|
|
|
xfree (demangled_no_static);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
fputs_filtered (demangled_no_class, stream);
|
|
|
|
|
xfree (demangled_name);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fprintf_filtered (stream, ";\n");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Print out nested types. */
|
|
|
|
|
if (TYPE_NESTED_TYPES_COUNT (type) != 0
|
|
|
|
|
&& semi_local_flags.print_nested_type_limit != 0)
|
|
|
|
|
{
|
|
|
|
|
if (semi_local_flags.print_nested_type_limit > 0)
|
|
|
|
|
--semi_local_flags.print_nested_type_limit;
|
|
|
|
|
|
|
|
|
|
if (TYPE_NFIELDS (type) != 0 || TYPE_NFN_FIELDS (type) != 0)
|
|
|
|
|
fprintf_filtered (stream, "\n");
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < TYPE_NESTED_TYPES_COUNT (type); ++i)
|
|
|
|
|
{
|
Implement pahole-like 'ptype /o' option
This commit implements the pahole-like '/o' option for 'ptype', which
prints the offsets and sizes of struct fields, reporting whenever
there is a hole found.
The output is heavily based on pahole(1), with a few modifications
here and there to adjust it to our reality. Here's an example:
/* offset | size */ type = struct wer : public tuv {
public:
/* 32 | 24 */ struct tyu {
/* 32:31 | 4 */ int a1 : 1;
/* 32:28 | 4 */ int a2 : 3;
/* 32: 5 | 4 */ int a3 : 23;
/* 35: 3 | 1 */ char a4 : 2;
/* XXX 3-bit hole */
/* XXX 4-byte hole */
/* 40 | 8 */ int64_t a5;
/* 48:27 | 4 */ int a6 : 5;
/* 48:56 | 8 */ int64_t a7 : 3;
/* total size (bytes): 24 */
} a1;
/* total size (bytes): 56 */
}
A big part of this patch handles the formatting logic of 'ptype',
which is a bit messy. The code to handle bitfield offsets, however,
took some time to craft. My thanks to Pedro Alves for figuring things
out and pointing me to the right direction, as well as coming up with
a way to inspect the layout of structs with bitfields (see testcase
for comments).
After many discussions both on IRC and at the mailing list, I tried to
implement printing vtables and inherited classes. Unfortunately the
code grew too complex and there were still a few corner cases failing
so I had to drop the attempt. This should be implemented in a future
patch.
This patch is the start of a long-term work I'll do to flush the local
patches we carry for Fedora GDB. In this specific case, I'm aiming at
upstreaming the feature implemented by the 'pahole.py' script that is
shipped with Fedora GDB:
<https://src.fedoraproject.org/rpms/gdb/blob/master/f/gdb-archer.patch#_311>
This has been regression-tested on the BuildBot. There's a new
testcase for it, along with an update to the documentation. I also
thought it was worth mentioning this feature in the NEWS file.
gdb/ChangeLog:
2017-12-15 Sergio Durigan Junior <sergiodj@redhat.com>
Pedro Alves <palves@redhat.com>
PR cli/16224
* NEWS (Changes since GDB 8.0): Mention new '/o' flag.
* c-typeprint.c (OFFSET_SPC_LEN): New define.
(c_type_print_varspec_prefix): New argument 'struct
print_offset_data *'.
(c_type_print_base_1): New function and prototype.
(c_print_type_1): New function, with code from 'c_print_type'.
(c_print_type): Use 'c_print_type_1'.
(c_type_print_varspec_prefix): New argument 'struct
print_offset_data *'. Use it. Call 'c_type_print_base_1'
instead of 'c_print_type_base'.
(print_spaces_filtered_with_print_options): New function.
(output_access_specifier): Take new argument FLAGS. Modify
function to call 'print_spaces_filtered_with_print_options'.
(c_print_type_vtable_offset_marker): New function.
(c_print_type_union_field_offset): New function.
(c_print_type_struct_field_offset): New function.
(c_print_type_no_offsets): New function.
(c_type_print_base_struct_union): New argument 'struct
print_offset_data *'. Print offsets and sizes for
struct/union/class fields.
* typeprint.c (const struct type_print_options
type_print_raw_options): Initialize 'print_offsets'.
(static struct type_print_options default_ptype_flags):
Likewise.
(struct print_offset_data print_offset_default_data): New
variable.
(whatis_exp): Handle '/o' option.
(_initialize_typeprint): Add '/o' flag to ptype's help.
* typeprint.h (struct print_offset_data): New struct.
(struct type_print_options) <print_offsets>: New field.
gdb/testsuite/ChangeLog:
2017-12-15 Sergio Durigan Junior <sergiodj@redhat.com>
PR cli/16224
* gdb.base/ptype-offsets.cc: New file.
* gdb.base/ptype-offsets.exp: New file.
gdb/doc/ChangeLog:
2017-12-15 Sergio Durigan Junior <sergiodj@redhat.com>
PR cli/16224
* gdb.texinfo (ptype): Add documentation for new flag '/o'.
2017-11-20 22:34:59 +01:00
|
|
|
|
print_spaces_filtered_with_print_options (level + 4, stream,
|
|
|
|
|
flags);
|
|
|
|
|
c_print_type_no_offsets (TYPE_NESTED_TYPES_FIELD_TYPE (type, i),
|
|
|
|
|
"", stream, show, level + 4,
|
2018-04-17 21:51:23 +02:00
|
|
|
|
language, &semi_local_flags, podata);
|
2017-12-11 17:57:19 +01:00
|
|
|
|
fprintf_filtered (stream, ";\n");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Print typedefs defined in this class. */
|
|
|
|
|
|
|
|
|
|
if (TYPE_TYPEDEF_FIELD_COUNT (type) != 0 && flags->print_typedefs)
|
|
|
|
|
{
|
|
|
|
|
if (TYPE_NFIELDS (type) != 0 || TYPE_NFN_FIELDS (type) != 0
|
|
|
|
|
|| TYPE_NESTED_TYPES_COUNT (type) != 0)
|
|
|
|
|
fprintf_filtered (stream, "\n");
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < TYPE_TYPEDEF_FIELD_COUNT (type); i++)
|
|
|
|
|
{
|
|
|
|
|
struct type *target = TYPE_TYPEDEF_FIELD_TYPE (type, i);
|
|
|
|
|
|
|
|
|
|
/* Dereference the typedef declaration itself. */
|
|
|
|
|
gdb_assert (TYPE_CODE (target) == TYPE_CODE_TYPEDEF);
|
|
|
|
|
target = TYPE_TARGET_TYPE (target);
|
|
|
|
|
|
|
|
|
|
if (need_access_label)
|
|
|
|
|
{
|
|
|
|
|
section_type = output_access_specifier
|
|
|
|
|
(stream, section_type, level,
|
|
|
|
|
TYPE_TYPEDEF_FIELD_PROTECTED (type, i),
|
Implement pahole-like 'ptype /o' option
This commit implements the pahole-like '/o' option for 'ptype', which
prints the offsets and sizes of struct fields, reporting whenever
there is a hole found.
The output is heavily based on pahole(1), with a few modifications
here and there to adjust it to our reality. Here's an example:
/* offset | size */ type = struct wer : public tuv {
public:
/* 32 | 24 */ struct tyu {
/* 32:31 | 4 */ int a1 : 1;
/* 32:28 | 4 */ int a2 : 3;
/* 32: 5 | 4 */ int a3 : 23;
/* 35: 3 | 1 */ char a4 : 2;
/* XXX 3-bit hole */
/* XXX 4-byte hole */
/* 40 | 8 */ int64_t a5;
/* 48:27 | 4 */ int a6 : 5;
/* 48:56 | 8 */ int64_t a7 : 3;
/* total size (bytes): 24 */
} a1;
/* total size (bytes): 56 */
}
A big part of this patch handles the formatting logic of 'ptype',
which is a bit messy. The code to handle bitfield offsets, however,
took some time to craft. My thanks to Pedro Alves for figuring things
out and pointing me to the right direction, as well as coming up with
a way to inspect the layout of structs with bitfields (see testcase
for comments).
After many discussions both on IRC and at the mailing list, I tried to
implement printing vtables and inherited classes. Unfortunately the
code grew too complex and there were still a few corner cases failing
so I had to drop the attempt. This should be implemented in a future
patch.
This patch is the start of a long-term work I'll do to flush the local
patches we carry for Fedora GDB. In this specific case, I'm aiming at
upstreaming the feature implemented by the 'pahole.py' script that is
shipped with Fedora GDB:
<https://src.fedoraproject.org/rpms/gdb/blob/master/f/gdb-archer.patch#_311>
This has been regression-tested on the BuildBot. There's a new
testcase for it, along with an update to the documentation. I also
thought it was worth mentioning this feature in the NEWS file.
gdb/ChangeLog:
2017-12-15 Sergio Durigan Junior <sergiodj@redhat.com>
Pedro Alves <palves@redhat.com>
PR cli/16224
* NEWS (Changes since GDB 8.0): Mention new '/o' flag.
* c-typeprint.c (OFFSET_SPC_LEN): New define.
(c_type_print_varspec_prefix): New argument 'struct
print_offset_data *'.
(c_type_print_base_1): New function and prototype.
(c_print_type_1): New function, with code from 'c_print_type'.
(c_print_type): Use 'c_print_type_1'.
(c_type_print_varspec_prefix): New argument 'struct
print_offset_data *'. Use it. Call 'c_type_print_base_1'
instead of 'c_print_type_base'.
(print_spaces_filtered_with_print_options): New function.
(output_access_specifier): Take new argument FLAGS. Modify
function to call 'print_spaces_filtered_with_print_options'.
(c_print_type_vtable_offset_marker): New function.
(c_print_type_union_field_offset): New function.
(c_print_type_struct_field_offset): New function.
(c_print_type_no_offsets): New function.
(c_type_print_base_struct_union): New argument 'struct
print_offset_data *'. Print offsets and sizes for
struct/union/class fields.
* typeprint.c (const struct type_print_options
type_print_raw_options): Initialize 'print_offsets'.
(static struct type_print_options default_ptype_flags):
Likewise.
(struct print_offset_data print_offset_default_data): New
variable.
(whatis_exp): Handle '/o' option.
(_initialize_typeprint): Add '/o' flag to ptype's help.
* typeprint.h (struct print_offset_data): New struct.
(struct type_print_options) <print_offsets>: New field.
gdb/testsuite/ChangeLog:
2017-12-15 Sergio Durigan Junior <sergiodj@redhat.com>
PR cli/16224
* gdb.base/ptype-offsets.cc: New file.
* gdb.base/ptype-offsets.exp: New file.
gdb/doc/ChangeLog:
2017-12-15 Sergio Durigan Junior <sergiodj@redhat.com>
PR cli/16224
* gdb.texinfo (ptype): Add documentation for new flag '/o'.
2017-11-20 22:34:59 +01:00
|
|
|
|
TYPE_TYPEDEF_FIELD_PRIVATE (type, i), flags);
|
2017-12-11 17:57:19 +01:00
|
|
|
|
}
|
Implement pahole-like 'ptype /o' option
This commit implements the pahole-like '/o' option for 'ptype', which
prints the offsets and sizes of struct fields, reporting whenever
there is a hole found.
The output is heavily based on pahole(1), with a few modifications
here and there to adjust it to our reality. Here's an example:
/* offset | size */ type = struct wer : public tuv {
public:
/* 32 | 24 */ struct tyu {
/* 32:31 | 4 */ int a1 : 1;
/* 32:28 | 4 */ int a2 : 3;
/* 32: 5 | 4 */ int a3 : 23;
/* 35: 3 | 1 */ char a4 : 2;
/* XXX 3-bit hole */
/* XXX 4-byte hole */
/* 40 | 8 */ int64_t a5;
/* 48:27 | 4 */ int a6 : 5;
/* 48:56 | 8 */ int64_t a7 : 3;
/* total size (bytes): 24 */
} a1;
/* total size (bytes): 56 */
}
A big part of this patch handles the formatting logic of 'ptype',
which is a bit messy. The code to handle bitfield offsets, however,
took some time to craft. My thanks to Pedro Alves for figuring things
out and pointing me to the right direction, as well as coming up with
a way to inspect the layout of structs with bitfields (see testcase
for comments).
After many discussions both on IRC and at the mailing list, I tried to
implement printing vtables and inherited classes. Unfortunately the
code grew too complex and there were still a few corner cases failing
so I had to drop the attempt. This should be implemented in a future
patch.
This patch is the start of a long-term work I'll do to flush the local
patches we carry for Fedora GDB. In this specific case, I'm aiming at
upstreaming the feature implemented by the 'pahole.py' script that is
shipped with Fedora GDB:
<https://src.fedoraproject.org/rpms/gdb/blob/master/f/gdb-archer.patch#_311>
This has been regression-tested on the BuildBot. There's a new
testcase for it, along with an update to the documentation. I also
thought it was worth mentioning this feature in the NEWS file.
gdb/ChangeLog:
2017-12-15 Sergio Durigan Junior <sergiodj@redhat.com>
Pedro Alves <palves@redhat.com>
PR cli/16224
* NEWS (Changes since GDB 8.0): Mention new '/o' flag.
* c-typeprint.c (OFFSET_SPC_LEN): New define.
(c_type_print_varspec_prefix): New argument 'struct
print_offset_data *'.
(c_type_print_base_1): New function and prototype.
(c_print_type_1): New function, with code from 'c_print_type'.
(c_print_type): Use 'c_print_type_1'.
(c_type_print_varspec_prefix): New argument 'struct
print_offset_data *'. Use it. Call 'c_type_print_base_1'
instead of 'c_print_type_base'.
(print_spaces_filtered_with_print_options): New function.
(output_access_specifier): Take new argument FLAGS. Modify
function to call 'print_spaces_filtered_with_print_options'.
(c_print_type_vtable_offset_marker): New function.
(c_print_type_union_field_offset): New function.
(c_print_type_struct_field_offset): New function.
(c_print_type_no_offsets): New function.
(c_type_print_base_struct_union): New argument 'struct
print_offset_data *'. Print offsets and sizes for
struct/union/class fields.
* typeprint.c (const struct type_print_options
type_print_raw_options): Initialize 'print_offsets'.
(static struct type_print_options default_ptype_flags):
Likewise.
(struct print_offset_data print_offset_default_data): New
variable.
(whatis_exp): Handle '/o' option.
(_initialize_typeprint): Add '/o' flag to ptype's help.
* typeprint.h (struct print_offset_data): New struct.
(struct type_print_options) <print_offsets>: New field.
gdb/testsuite/ChangeLog:
2017-12-15 Sergio Durigan Junior <sergiodj@redhat.com>
PR cli/16224
* gdb.base/ptype-offsets.cc: New file.
* gdb.base/ptype-offsets.exp: New file.
gdb/doc/ChangeLog:
2017-12-15 Sergio Durigan Junior <sergiodj@redhat.com>
PR cli/16224
* gdb.texinfo (ptype): Add documentation for new flag '/o'.
2017-11-20 22:34:59 +01:00
|
|
|
|
print_spaces_filtered_with_print_options (level + 4, stream,
|
|
|
|
|
flags);
|
2017-12-11 17:57:19 +01:00
|
|
|
|
fprintf_filtered (stream, "typedef ");
|
|
|
|
|
|
|
|
|
|
/* We want to print typedefs with substitutions
|
|
|
|
|
from the template parameters or globally-known
|
|
|
|
|
typedefs but not local typedefs. */
|
Implement pahole-like 'ptype /o' option
This commit implements the pahole-like '/o' option for 'ptype', which
prints the offsets and sizes of struct fields, reporting whenever
there is a hole found.
The output is heavily based on pahole(1), with a few modifications
here and there to adjust it to our reality. Here's an example:
/* offset | size */ type = struct wer : public tuv {
public:
/* 32 | 24 */ struct tyu {
/* 32:31 | 4 */ int a1 : 1;
/* 32:28 | 4 */ int a2 : 3;
/* 32: 5 | 4 */ int a3 : 23;
/* 35: 3 | 1 */ char a4 : 2;
/* XXX 3-bit hole */
/* XXX 4-byte hole */
/* 40 | 8 */ int64_t a5;
/* 48:27 | 4 */ int a6 : 5;
/* 48:56 | 8 */ int64_t a7 : 3;
/* total size (bytes): 24 */
} a1;
/* total size (bytes): 56 */
}
A big part of this patch handles the formatting logic of 'ptype',
which is a bit messy. The code to handle bitfield offsets, however,
took some time to craft. My thanks to Pedro Alves for figuring things
out and pointing me to the right direction, as well as coming up with
a way to inspect the layout of structs with bitfields (see testcase
for comments).
After many discussions both on IRC and at the mailing list, I tried to
implement printing vtables and inherited classes. Unfortunately the
code grew too complex and there were still a few corner cases failing
so I had to drop the attempt. This should be implemented in a future
patch.
This patch is the start of a long-term work I'll do to flush the local
patches we carry for Fedora GDB. In this specific case, I'm aiming at
upstreaming the feature implemented by the 'pahole.py' script that is
shipped with Fedora GDB:
<https://src.fedoraproject.org/rpms/gdb/blob/master/f/gdb-archer.patch#_311>
This has been regression-tested on the BuildBot. There's a new
testcase for it, along with an update to the documentation. I also
thought it was worth mentioning this feature in the NEWS file.
gdb/ChangeLog:
2017-12-15 Sergio Durigan Junior <sergiodj@redhat.com>
Pedro Alves <palves@redhat.com>
PR cli/16224
* NEWS (Changes since GDB 8.0): Mention new '/o' flag.
* c-typeprint.c (OFFSET_SPC_LEN): New define.
(c_type_print_varspec_prefix): New argument 'struct
print_offset_data *'.
(c_type_print_base_1): New function and prototype.
(c_print_type_1): New function, with code from 'c_print_type'.
(c_print_type): Use 'c_print_type_1'.
(c_type_print_varspec_prefix): New argument 'struct
print_offset_data *'. Use it. Call 'c_type_print_base_1'
instead of 'c_print_type_base'.
(print_spaces_filtered_with_print_options): New function.
(output_access_specifier): Take new argument FLAGS. Modify
function to call 'print_spaces_filtered_with_print_options'.
(c_print_type_vtable_offset_marker): New function.
(c_print_type_union_field_offset): New function.
(c_print_type_struct_field_offset): New function.
(c_print_type_no_offsets): New function.
(c_type_print_base_struct_union): New argument 'struct
print_offset_data *'. Print offsets and sizes for
struct/union/class fields.
* typeprint.c (const struct type_print_options
type_print_raw_options): Initialize 'print_offsets'.
(static struct type_print_options default_ptype_flags):
Likewise.
(struct print_offset_data print_offset_default_data): New
variable.
(whatis_exp): Handle '/o' option.
(_initialize_typeprint): Add '/o' flag to ptype's help.
* typeprint.h (struct print_offset_data): New struct.
(struct type_print_options) <print_offsets>: New field.
gdb/testsuite/ChangeLog:
2017-12-15 Sergio Durigan Junior <sergiodj@redhat.com>
PR cli/16224
* gdb.base/ptype-offsets.cc: New file.
* gdb.base/ptype-offsets.exp: New file.
gdb/doc/ChangeLog:
2017-12-15 Sergio Durigan Junior <sergiodj@redhat.com>
PR cli/16224
* gdb.texinfo (ptype): Add documentation for new flag '/o'.
2017-11-20 22:34:59 +01:00
|
|
|
|
c_print_type_no_offsets (target,
|
|
|
|
|
TYPE_TYPEDEF_FIELD_NAME (type, i),
|
|
|
|
|
stream, show - 1, level + 4,
|
2018-04-17 21:51:23 +02:00
|
|
|
|
language, &semi_local_flags, podata);
|
2017-12-11 17:57:19 +01:00
|
|
|
|
fprintf_filtered (stream, ";\n");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
Implement pahole-like 'ptype /o' option
This commit implements the pahole-like '/o' option for 'ptype', which
prints the offsets and sizes of struct fields, reporting whenever
there is a hole found.
The output is heavily based on pahole(1), with a few modifications
here and there to adjust it to our reality. Here's an example:
/* offset | size */ type = struct wer : public tuv {
public:
/* 32 | 24 */ struct tyu {
/* 32:31 | 4 */ int a1 : 1;
/* 32:28 | 4 */ int a2 : 3;
/* 32: 5 | 4 */ int a3 : 23;
/* 35: 3 | 1 */ char a4 : 2;
/* XXX 3-bit hole */
/* XXX 4-byte hole */
/* 40 | 8 */ int64_t a5;
/* 48:27 | 4 */ int a6 : 5;
/* 48:56 | 8 */ int64_t a7 : 3;
/* total size (bytes): 24 */
} a1;
/* total size (bytes): 56 */
}
A big part of this patch handles the formatting logic of 'ptype',
which is a bit messy. The code to handle bitfield offsets, however,
took some time to craft. My thanks to Pedro Alves for figuring things
out and pointing me to the right direction, as well as coming up with
a way to inspect the layout of structs with bitfields (see testcase
for comments).
After many discussions both on IRC and at the mailing list, I tried to
implement printing vtables and inherited classes. Unfortunately the
code grew too complex and there were still a few corner cases failing
so I had to drop the attempt. This should be implemented in a future
patch.
This patch is the start of a long-term work I'll do to flush the local
patches we carry for Fedora GDB. In this specific case, I'm aiming at
upstreaming the feature implemented by the 'pahole.py' script that is
shipped with Fedora GDB:
<https://src.fedoraproject.org/rpms/gdb/blob/master/f/gdb-archer.patch#_311>
This has been regression-tested on the BuildBot. There's a new
testcase for it, along with an update to the documentation. I also
thought it was worth mentioning this feature in the NEWS file.
gdb/ChangeLog:
2017-12-15 Sergio Durigan Junior <sergiodj@redhat.com>
Pedro Alves <palves@redhat.com>
PR cli/16224
* NEWS (Changes since GDB 8.0): Mention new '/o' flag.
* c-typeprint.c (OFFSET_SPC_LEN): New define.
(c_type_print_varspec_prefix): New argument 'struct
print_offset_data *'.
(c_type_print_base_1): New function and prototype.
(c_print_type_1): New function, with code from 'c_print_type'.
(c_print_type): Use 'c_print_type_1'.
(c_type_print_varspec_prefix): New argument 'struct
print_offset_data *'. Use it. Call 'c_type_print_base_1'
instead of 'c_print_type_base'.
(print_spaces_filtered_with_print_options): New function.
(output_access_specifier): Take new argument FLAGS. Modify
function to call 'print_spaces_filtered_with_print_options'.
(c_print_type_vtable_offset_marker): New function.
(c_print_type_union_field_offset): New function.
(c_print_type_struct_field_offset): New function.
(c_print_type_no_offsets): New function.
(c_type_print_base_struct_union): New argument 'struct
print_offset_data *'. Print offsets and sizes for
struct/union/class fields.
* typeprint.c (const struct type_print_options
type_print_raw_options): Initialize 'print_offsets'.
(static struct type_print_options default_ptype_flags):
Likewise.
(struct print_offset_data print_offset_default_data): New
variable.
(whatis_exp): Handle '/o' option.
(_initialize_typeprint): Add '/o' flag to ptype's help.
* typeprint.h (struct print_offset_data): New struct.
(struct type_print_options) <print_offsets>: New field.
gdb/testsuite/ChangeLog:
2017-12-15 Sergio Durigan Junior <sergiodj@redhat.com>
PR cli/16224
* gdb.base/ptype-offsets.cc: New file.
* gdb.base/ptype-offsets.exp: New file.
gdb/doc/ChangeLog:
2017-12-15 Sergio Durigan Junior <sergiodj@redhat.com>
PR cli/16224
* gdb.texinfo (ptype): Add documentation for new flag '/o'.
2017-11-20 22:34:59 +01:00
|
|
|
|
if (flags->print_offsets)
|
|
|
|
|
{
|
|
|
|
|
if (show > 0)
|
2018-06-08 20:43:47 +02:00
|
|
|
|
podata->finish (type, level, stream);
|
Implement pahole-like 'ptype /o' option
This commit implements the pahole-like '/o' option for 'ptype', which
prints the offsets and sizes of struct fields, reporting whenever
there is a hole found.
The output is heavily based on pahole(1), with a few modifications
here and there to adjust it to our reality. Here's an example:
/* offset | size */ type = struct wer : public tuv {
public:
/* 32 | 24 */ struct tyu {
/* 32:31 | 4 */ int a1 : 1;
/* 32:28 | 4 */ int a2 : 3;
/* 32: 5 | 4 */ int a3 : 23;
/* 35: 3 | 1 */ char a4 : 2;
/* XXX 3-bit hole */
/* XXX 4-byte hole */
/* 40 | 8 */ int64_t a5;
/* 48:27 | 4 */ int a6 : 5;
/* 48:56 | 8 */ int64_t a7 : 3;
/* total size (bytes): 24 */
} a1;
/* total size (bytes): 56 */
}
A big part of this patch handles the formatting logic of 'ptype',
which is a bit messy. The code to handle bitfield offsets, however,
took some time to craft. My thanks to Pedro Alves for figuring things
out and pointing me to the right direction, as well as coming up with
a way to inspect the layout of structs with bitfields (see testcase
for comments).
After many discussions both on IRC and at the mailing list, I tried to
implement printing vtables and inherited classes. Unfortunately the
code grew too complex and there were still a few corner cases failing
so I had to drop the attempt. This should be implemented in a future
patch.
This patch is the start of a long-term work I'll do to flush the local
patches we carry for Fedora GDB. In this specific case, I'm aiming at
upstreaming the feature implemented by the 'pahole.py' script that is
shipped with Fedora GDB:
<https://src.fedoraproject.org/rpms/gdb/blob/master/f/gdb-archer.patch#_311>
This has been regression-tested on the BuildBot. There's a new
testcase for it, along with an update to the documentation. I also
thought it was worth mentioning this feature in the NEWS file.
gdb/ChangeLog:
2017-12-15 Sergio Durigan Junior <sergiodj@redhat.com>
Pedro Alves <palves@redhat.com>
PR cli/16224
* NEWS (Changes since GDB 8.0): Mention new '/o' flag.
* c-typeprint.c (OFFSET_SPC_LEN): New define.
(c_type_print_varspec_prefix): New argument 'struct
print_offset_data *'.
(c_type_print_base_1): New function and prototype.
(c_print_type_1): New function, with code from 'c_print_type'.
(c_print_type): Use 'c_print_type_1'.
(c_type_print_varspec_prefix): New argument 'struct
print_offset_data *'. Use it. Call 'c_type_print_base_1'
instead of 'c_print_type_base'.
(print_spaces_filtered_with_print_options): New function.
(output_access_specifier): Take new argument FLAGS. Modify
function to call 'print_spaces_filtered_with_print_options'.
(c_print_type_vtable_offset_marker): New function.
(c_print_type_union_field_offset): New function.
(c_print_type_struct_field_offset): New function.
(c_print_type_no_offsets): New function.
(c_type_print_base_struct_union): New argument 'struct
print_offset_data *'. Print offsets and sizes for
struct/union/class fields.
* typeprint.c (const struct type_print_options
type_print_raw_options): Initialize 'print_offsets'.
(static struct type_print_options default_ptype_flags):
Likewise.
(struct print_offset_data print_offset_default_data): New
variable.
(whatis_exp): Handle '/o' option.
(_initialize_typeprint): Add '/o' flag to ptype's help.
* typeprint.h (struct print_offset_data): New struct.
(struct type_print_options) <print_offsets>: New field.
gdb/testsuite/ChangeLog:
2017-12-15 Sergio Durigan Junior <sergiodj@redhat.com>
PR cli/16224
* gdb.base/ptype-offsets.cc: New file.
* gdb.base/ptype-offsets.exp: New file.
gdb/doc/ChangeLog:
2017-12-15 Sergio Durigan Junior <sergiodj@redhat.com>
PR cli/16224
* gdb.texinfo (ptype): Add documentation for new flag '/o'.
2017-11-20 22:34:59 +01:00
|
|
|
|
|
2018-06-08 20:43:47 +02:00
|
|
|
|
print_spaces_filtered (print_offset_data::indentation, stream);
|
Implement pahole-like 'ptype /o' option
This commit implements the pahole-like '/o' option for 'ptype', which
prints the offsets and sizes of struct fields, reporting whenever
there is a hole found.
The output is heavily based on pahole(1), with a few modifications
here and there to adjust it to our reality. Here's an example:
/* offset | size */ type = struct wer : public tuv {
public:
/* 32 | 24 */ struct tyu {
/* 32:31 | 4 */ int a1 : 1;
/* 32:28 | 4 */ int a2 : 3;
/* 32: 5 | 4 */ int a3 : 23;
/* 35: 3 | 1 */ char a4 : 2;
/* XXX 3-bit hole */
/* XXX 4-byte hole */
/* 40 | 8 */ int64_t a5;
/* 48:27 | 4 */ int a6 : 5;
/* 48:56 | 8 */ int64_t a7 : 3;
/* total size (bytes): 24 */
} a1;
/* total size (bytes): 56 */
}
A big part of this patch handles the formatting logic of 'ptype',
which is a bit messy. The code to handle bitfield offsets, however,
took some time to craft. My thanks to Pedro Alves for figuring things
out and pointing me to the right direction, as well as coming up with
a way to inspect the layout of structs with bitfields (see testcase
for comments).
After many discussions both on IRC and at the mailing list, I tried to
implement printing vtables and inherited classes. Unfortunately the
code grew too complex and there were still a few corner cases failing
so I had to drop the attempt. This should be implemented in a future
patch.
This patch is the start of a long-term work I'll do to flush the local
patches we carry for Fedora GDB. In this specific case, I'm aiming at
upstreaming the feature implemented by the 'pahole.py' script that is
shipped with Fedora GDB:
<https://src.fedoraproject.org/rpms/gdb/blob/master/f/gdb-archer.patch#_311>
This has been regression-tested on the BuildBot. There's a new
testcase for it, along with an update to the documentation. I also
thought it was worth mentioning this feature in the NEWS file.
gdb/ChangeLog:
2017-12-15 Sergio Durigan Junior <sergiodj@redhat.com>
Pedro Alves <palves@redhat.com>
PR cli/16224
* NEWS (Changes since GDB 8.0): Mention new '/o' flag.
* c-typeprint.c (OFFSET_SPC_LEN): New define.
(c_type_print_varspec_prefix): New argument 'struct
print_offset_data *'.
(c_type_print_base_1): New function and prototype.
(c_print_type_1): New function, with code from 'c_print_type'.
(c_print_type): Use 'c_print_type_1'.
(c_type_print_varspec_prefix): New argument 'struct
print_offset_data *'. Use it. Call 'c_type_print_base_1'
instead of 'c_print_type_base'.
(print_spaces_filtered_with_print_options): New function.
(output_access_specifier): Take new argument FLAGS. Modify
function to call 'print_spaces_filtered_with_print_options'.
(c_print_type_vtable_offset_marker): New function.
(c_print_type_union_field_offset): New function.
(c_print_type_struct_field_offset): New function.
(c_print_type_no_offsets): New function.
(c_type_print_base_struct_union): New argument 'struct
print_offset_data *'. Print offsets and sizes for
struct/union/class fields.
* typeprint.c (const struct type_print_options
type_print_raw_options): Initialize 'print_offsets'.
(static struct type_print_options default_ptype_flags):
Likewise.
(struct print_offset_data print_offset_default_data): New
variable.
(whatis_exp): Handle '/o' option.
(_initialize_typeprint): Add '/o' flag to ptype's help.
* typeprint.h (struct print_offset_data): New struct.
(struct type_print_options) <print_offsets>: New field.
gdb/testsuite/ChangeLog:
2017-12-15 Sergio Durigan Junior <sergiodj@redhat.com>
PR cli/16224
* gdb.base/ptype-offsets.cc: New file.
* gdb.base/ptype-offsets.exp: New file.
gdb/doc/ChangeLog:
2017-12-15 Sergio Durigan Junior <sergiodj@redhat.com>
PR cli/16224
* gdb.texinfo (ptype): Add documentation for new flag '/o'.
2017-11-20 22:34:59 +01:00
|
|
|
|
if (level == 0)
|
|
|
|
|
print_spaces_filtered (2, stream);
|
|
|
|
|
}
|
|
|
|
|
|
2017-12-11 17:57:19 +01:00
|
|
|
|
fprintfi_filtered (level, stream, "}");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
1999-04-16 03:35:26 +02:00
|
|
|
|
/* Print the name of the type (or the ultimate pointer target,
|
2010-12-31 23:59:52 +01:00
|
|
|
|
function value or array element), or the description of a structure
|
|
|
|
|
or union.
|
|
|
|
|
|
|
|
|
|
SHOW positive means print details about the type (e.g. enum
|
|
|
|
|
values), and print structure elements passing SHOW - 1 for show.
|
|
|
|
|
|
|
|
|
|
SHOW negative means just print the type name or struct tag if there
|
|
|
|
|
is one. If there is no name, print something sensible but concise
|
|
|
|
|
like "struct {...}".
|
|
|
|
|
|
|
|
|
|
SHOW zero means just print the type name or struct tag if there is
|
|
|
|
|
one. If there is no name, print something sensible but not as
|
|
|
|
|
concise like "struct {int x; int y;}".
|
1999-04-16 03:35:26 +02:00
|
|
|
|
|
|
|
|
|
LEVEL is the number of spaces to indent by.
|
|
|
|
|
We increase it for some recursive calls. */
|
|
|
|
|
|
Implement pahole-like 'ptype /o' option
This commit implements the pahole-like '/o' option for 'ptype', which
prints the offsets and sizes of struct fields, reporting whenever
there is a hole found.
The output is heavily based on pahole(1), with a few modifications
here and there to adjust it to our reality. Here's an example:
/* offset | size */ type = struct wer : public tuv {
public:
/* 32 | 24 */ struct tyu {
/* 32:31 | 4 */ int a1 : 1;
/* 32:28 | 4 */ int a2 : 3;
/* 32: 5 | 4 */ int a3 : 23;
/* 35: 3 | 1 */ char a4 : 2;
/* XXX 3-bit hole */
/* XXX 4-byte hole */
/* 40 | 8 */ int64_t a5;
/* 48:27 | 4 */ int a6 : 5;
/* 48:56 | 8 */ int64_t a7 : 3;
/* total size (bytes): 24 */
} a1;
/* total size (bytes): 56 */
}
A big part of this patch handles the formatting logic of 'ptype',
which is a bit messy. The code to handle bitfield offsets, however,
took some time to craft. My thanks to Pedro Alves for figuring things
out and pointing me to the right direction, as well as coming up with
a way to inspect the layout of structs with bitfields (see testcase
for comments).
After many discussions both on IRC and at the mailing list, I tried to
implement printing vtables and inherited classes. Unfortunately the
code grew too complex and there were still a few corner cases failing
so I had to drop the attempt. This should be implemented in a future
patch.
This patch is the start of a long-term work I'll do to flush the local
patches we carry for Fedora GDB. In this specific case, I'm aiming at
upstreaming the feature implemented by the 'pahole.py' script that is
shipped with Fedora GDB:
<https://src.fedoraproject.org/rpms/gdb/blob/master/f/gdb-archer.patch#_311>
This has been regression-tested on the BuildBot. There's a new
testcase for it, along with an update to the documentation. I also
thought it was worth mentioning this feature in the NEWS file.
gdb/ChangeLog:
2017-12-15 Sergio Durigan Junior <sergiodj@redhat.com>
Pedro Alves <palves@redhat.com>
PR cli/16224
* NEWS (Changes since GDB 8.0): Mention new '/o' flag.
* c-typeprint.c (OFFSET_SPC_LEN): New define.
(c_type_print_varspec_prefix): New argument 'struct
print_offset_data *'.
(c_type_print_base_1): New function and prototype.
(c_print_type_1): New function, with code from 'c_print_type'.
(c_print_type): Use 'c_print_type_1'.
(c_type_print_varspec_prefix): New argument 'struct
print_offset_data *'. Use it. Call 'c_type_print_base_1'
instead of 'c_print_type_base'.
(print_spaces_filtered_with_print_options): New function.
(output_access_specifier): Take new argument FLAGS. Modify
function to call 'print_spaces_filtered_with_print_options'.
(c_print_type_vtable_offset_marker): New function.
(c_print_type_union_field_offset): New function.
(c_print_type_struct_field_offset): New function.
(c_print_type_no_offsets): New function.
(c_type_print_base_struct_union): New argument 'struct
print_offset_data *'. Print offsets and sizes for
struct/union/class fields.
* typeprint.c (const struct type_print_options
type_print_raw_options): Initialize 'print_offsets'.
(static struct type_print_options default_ptype_flags):
Likewise.
(struct print_offset_data print_offset_default_data): New
variable.
(whatis_exp): Handle '/o' option.
(_initialize_typeprint): Add '/o' flag to ptype's help.
* typeprint.h (struct print_offset_data): New struct.
(struct type_print_options) <print_offsets>: New field.
gdb/testsuite/ChangeLog:
2017-12-15 Sergio Durigan Junior <sergiodj@redhat.com>
PR cli/16224
* gdb.base/ptype-offsets.cc: New file.
* gdb.base/ptype-offsets.exp: New file.
gdb/doc/ChangeLog:
2017-12-15 Sergio Durigan Junior <sergiodj@redhat.com>
PR cli/16224
* gdb.texinfo (ptype): Add documentation for new flag '/o'.
2017-11-20 22:34:59 +01:00
|
|
|
|
static void
|
|
|
|
|
c_type_print_base_1 (struct type *type, struct ui_file *stream,
|
|
|
|
|
int show, int level,
|
2018-04-17 21:51:23 +02:00
|
|
|
|
enum language language,
|
Implement pahole-like 'ptype /o' option
This commit implements the pahole-like '/o' option for 'ptype', which
prints the offsets and sizes of struct fields, reporting whenever
there is a hole found.
The output is heavily based on pahole(1), with a few modifications
here and there to adjust it to our reality. Here's an example:
/* offset | size */ type = struct wer : public tuv {
public:
/* 32 | 24 */ struct tyu {
/* 32:31 | 4 */ int a1 : 1;
/* 32:28 | 4 */ int a2 : 3;
/* 32: 5 | 4 */ int a3 : 23;
/* 35: 3 | 1 */ char a4 : 2;
/* XXX 3-bit hole */
/* XXX 4-byte hole */
/* 40 | 8 */ int64_t a5;
/* 48:27 | 4 */ int a6 : 5;
/* 48:56 | 8 */ int64_t a7 : 3;
/* total size (bytes): 24 */
} a1;
/* total size (bytes): 56 */
}
A big part of this patch handles the formatting logic of 'ptype',
which is a bit messy. The code to handle bitfield offsets, however,
took some time to craft. My thanks to Pedro Alves for figuring things
out and pointing me to the right direction, as well as coming up with
a way to inspect the layout of structs with bitfields (see testcase
for comments).
After many discussions both on IRC and at the mailing list, I tried to
implement printing vtables and inherited classes. Unfortunately the
code grew too complex and there were still a few corner cases failing
so I had to drop the attempt. This should be implemented in a future
patch.
This patch is the start of a long-term work I'll do to flush the local
patches we carry for Fedora GDB. In this specific case, I'm aiming at
upstreaming the feature implemented by the 'pahole.py' script that is
shipped with Fedora GDB:
<https://src.fedoraproject.org/rpms/gdb/blob/master/f/gdb-archer.patch#_311>
This has been regression-tested on the BuildBot. There's a new
testcase for it, along with an update to the documentation. I also
thought it was worth mentioning this feature in the NEWS file.
gdb/ChangeLog:
2017-12-15 Sergio Durigan Junior <sergiodj@redhat.com>
Pedro Alves <palves@redhat.com>
PR cli/16224
* NEWS (Changes since GDB 8.0): Mention new '/o' flag.
* c-typeprint.c (OFFSET_SPC_LEN): New define.
(c_type_print_varspec_prefix): New argument 'struct
print_offset_data *'.
(c_type_print_base_1): New function and prototype.
(c_print_type_1): New function, with code from 'c_print_type'.
(c_print_type): Use 'c_print_type_1'.
(c_type_print_varspec_prefix): New argument 'struct
print_offset_data *'. Use it. Call 'c_type_print_base_1'
instead of 'c_print_type_base'.
(print_spaces_filtered_with_print_options): New function.
(output_access_specifier): Take new argument FLAGS. Modify
function to call 'print_spaces_filtered_with_print_options'.
(c_print_type_vtable_offset_marker): New function.
(c_print_type_union_field_offset): New function.
(c_print_type_struct_field_offset): New function.
(c_print_type_no_offsets): New function.
(c_type_print_base_struct_union): New argument 'struct
print_offset_data *'. Print offsets and sizes for
struct/union/class fields.
* typeprint.c (const struct type_print_options
type_print_raw_options): Initialize 'print_offsets'.
(static struct type_print_options default_ptype_flags):
Likewise.
(struct print_offset_data print_offset_default_data): New
variable.
(whatis_exp): Handle '/o' option.
(_initialize_typeprint): Add '/o' flag to ptype's help.
* typeprint.h (struct print_offset_data): New struct.
(struct type_print_options) <print_offsets>: New field.
gdb/testsuite/ChangeLog:
2017-12-15 Sergio Durigan Junior <sergiodj@redhat.com>
PR cli/16224
* gdb.base/ptype-offsets.cc: New file.
* gdb.base/ptype-offsets.exp: New file.
gdb/doc/ChangeLog:
2017-12-15 Sergio Durigan Junior <sergiodj@redhat.com>
PR cli/16224
* gdb.texinfo (ptype): Add documentation for new flag '/o'.
2017-11-20 22:34:59 +01:00
|
|
|
|
const struct type_print_options *flags,
|
|
|
|
|
struct print_offset_data *podata)
|
1999-04-16 03:35:26 +02:00
|
|
|
|
{
|
2002-01-20 20:20:16 +01:00
|
|
|
|
int i;
|
2017-12-11 17:57:19 +01:00
|
|
|
|
int len;
|
1999-04-16 03:35:26 +02:00
|
|
|
|
|
|
|
|
|
QUIT;
|
|
|
|
|
|
|
|
|
|
if (type == NULL)
|
|
|
|
|
{
|
2005-01-29 Baurzhan Ismagulov <ibr@radix50.net>
* ax-gdb.c, ax-general.c, bcache.c, bfd-target.c, bsd-kvm.c,
* buildsym.c, c-lang.c, c-typeprint.c, c-valprint.c, charset.c,
* coff-pe-read.c, coffread.c, complaints.c, copying.c: I18n markup.
2005-01-29 18:53:26 +01:00
|
|
|
|
fputs_filtered (_("<type unknown>"), stream);
|
1999-04-16 03:35:26 +02:00
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2010-12-31 23:59:52 +01:00
|
|
|
|
/* When SHOW is zero or less, and there is a valid type name, then
|
|
|
|
|
always just print the type name directly from the type. */
|
1999-04-16 03:35:26 +02:00
|
|
|
|
|
|
|
|
|
if (show <= 0
|
|
|
|
|
&& TYPE_NAME (type) != NULL)
|
|
|
|
|
{
|
2001-11-15 02:55:59 +01:00
|
|
|
|
c_type_print_modifier (type, stream, 0, 1);
|
Remove TYPE_TAG_NAME
TYPE_TAG_NAME has been an occasional source of confusion and bugs. It
seems to me that it is only useful for C and C++ -- but even there,
not so much, because at least with DWARF there doesn't seem to be any
way to wind up with a type where the name and the tag name are both
non-NULL and different.
So, this patch removes TYPE_TAG_NAME entirely. This should save a
little memory, but more importantly, it simplifies this part of gdb.
A few minor test suite adjustments were needed. In some situations
the new code does not yield identical output to the old code.
gdb/ChangeLog
2018-06-01 Tom Tromey <tom@tromey.com>
* valops.c (enum_constant_from_type, value_namespace_elt)
(value_maybe_namespace_elt): Update.
* valarith.c (find_size_for_pointer_math): Update.
* target-descriptions.c (make_gdb_type): Update.
* symmisc.c (print_symbol): Update.
* stabsread.c (define_symbol, read_type)
(complain_about_struct_wipeout, add_undefined_type)
(cleanup_undefined_types_1): Update.
* rust-lang.c (rust_tuple_type_p, rust_slice_type_p)
(rust_range_type_p, val_print_struct, rust_print_struct_def)
(rust_internal_print_type, rust_composite_type)
(rust_evaluate_funcall, rust_evaluate_subexp)
(rust_inclusive_range_type_p): Update.
* python/py-type.c (typy_get_tag): Update.
* p-typeprint.c (pascal_type_print_base): Update.
* mdebugread.c (parse_symbol, parse_type): Update.
* m2-typeprint.c (m2_long_set, m2_record_fields, m2_enum):
Update.
* guile/scm-type.c (gdbscm_type_tag): Update.
* go-lang.c (sixg_string_p): Update.
* gnu-v3-abi.c (build_gdb_vtable_type, build_std_type_info_type):
Update.
* gdbtypes.h (struct main_type) <tag_name>: Remove.
(TYPE_TAG_NAME): Remove.
* gdbtypes.c (type_name_no_tag): Simplify.
(check_typedef, check_types_equal, recursive_dump_type)
(copy_type_recursive, arch_composite_type): Update.
* f-typeprint.c (f_type_print_base): Update. Print "Type" prefix
in summary mode when needed.
* eval.c (evaluate_funcall): Update.
* dwarf2read.c (fixup_go_packaging, read_structure_type)
(process_structure_scope, read_enumeration_type)
(read_namespace_type, read_module_type, determine_prefix): Update.
* cp-support.c (inspect_type): Update.
* coffread.c (process_coff_symbol, decode_base_type): Update.
* c-varobj.c (c_is_path_expr_parent): Update.
* c-typeprint.c (c_type_print_base_struct_union): Update.
(c_type_print_base_1): Update. Print struct/class/union/enum in
summary when using C language.
* ax-gdb.c (gen_struct_ref, gen_namespace_elt)
(gen_maybe_namespace_elt): Update.
* ada-lang.c (ada_type_name): Simplify.
(empty_record, ada_template_to_fixed_record_type_1)
(template_to_static_fixed_type)
(to_record_with_fixed_variant_part, ada_check_typedef): Update.
gdb/testsuite/ChangeLog
2018-06-01 Tom Tromey <tom@tromey.com>
* gdb.xml/tdesc-regs.exp (load_description): Update expected
results.
* gdb.dwarf2/method-ptr.exp: Set language to C++.
* gdb.dwarf2/member-ptr-forwardref.exp: Set language to C++.
* gdb.cp/typeid.exp (do_typeid_tests): Update type_re.
* gdb.base/maint.exp (maint_pass_if): Update.
2018-04-17 21:51:24 +02:00
|
|
|
|
|
|
|
|
|
/* If we have "typedef struct foo {. . .} bar;" do we want to
|
|
|
|
|
print it as "struct foo" or as "bar"? Pick the latter for
|
|
|
|
|
C++, because C++ folk tend to expect things like "class5
|
|
|
|
|
*foo" rather than "struct class5 *foo". We rather
|
|
|
|
|
arbitrarily choose to make language_minimal work in a C-like
|
|
|
|
|
way. */
|
|
|
|
|
if (language == language_c || language == language_minimal)
|
|
|
|
|
{
|
|
|
|
|
if (TYPE_CODE (type) == TYPE_CODE_UNION)
|
|
|
|
|
fprintf_filtered (stream, "union ");
|
|
|
|
|
else if (TYPE_CODE (type) == TYPE_CODE_STRUCT)
|
|
|
|
|
{
|
|
|
|
|
if (TYPE_DECLARED_CLASS (type))
|
|
|
|
|
fprintf_filtered (stream, "class ");
|
|
|
|
|
else
|
|
|
|
|
fprintf_filtered (stream, "struct ");
|
|
|
|
|
}
|
|
|
|
|
else if (TYPE_CODE (type) == TYPE_CODE_ENUM)
|
|
|
|
|
fprintf_filtered (stream, "enum ");
|
|
|
|
|
}
|
|
|
|
|
|
* c-typeprint.c (find_typedef_for_canonicalize,
print_name_maybe_canonical): New functions.
(c_print_type): Look up type name.
(cp_type_print_derivation_info): Add flags argument. Use
print_name_maybe_canonical.
(cp_type_print_method_args): Add wrapping.
(c_type_print_varspec_prefix): Use print_name_maybe_canonical.
(c_type_print_template_args): New function.
(c_type_print_base): Change wrapping. Use
print_name_maybe_canonical.
<TYPE_CODE_STRUCT>: Possibly create a typedef hash, and do
type name lookups.
* gdbtypes.c (types_equal): No longer static.
* gdbtypes.h (types_equal): Declare.
* typeprint.c (type_print_raw_options, default_ptype_flags):
Update.
(struct typedef_hash_table): New.
(hash_typedef_field, eq_typedef_field,
recursively_update_typedef_hash, add_template_parameters,
create_typedef_hash, free_typedef_hash, do_free_typedef_hash,
make_cleanup_free_typedef_hash, copy_typedef_hash_element,
copy_typedef_hash, find_typedef_in_hash): New functions.
* typeprint.h (struct type_print_options) <local_typedefs>:
New field.
(recursively_update_typedef_hash, add_template_parameters,
create_typedef_hash, free_typedef_hash,
make_cleanup_free_typedef_hash, copy_typedef_hash,
find_typedef_in_hash): Declare.
testsuite
* gdb.base/call-sc.exp: Use "ptype/r".
* gdb.base/volatile.exp: Don't expect "int".
* gdb.cp/ptype-flags.cc: New file.
* gdb.cp/ptype-flags.exp: New file.
* gdb.cp/templates.exp: Use ptype/r.
(test_ptype_of_templates, test_template_typedef): Likewise.
* lib/cp-support.exp (cp_test_ptype_class): Add in_ptype_arg
argument. Handle template names and template parameters.
* gdb.mi/mi-var-cmd.exp: Accept "long".
* gdb.mi/mi-var-child.exp: Accept "long".
* gdb.mi/mi-var-display.exp: Accept "long".
* gdb.mi/mi2-var-child.exp: Accept "long".
2012-11-12 18:37:38 +01:00
|
|
|
|
print_name_maybe_canonical (TYPE_NAME (type), flags, stream);
|
1999-04-16 03:35:26 +02:00
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2015-07-06 22:05:06 +02:00
|
|
|
|
type = check_typedef (type);
|
1999-07-07 22:19:36 +02:00
|
|
|
|
|
1999-04-16 03:35:26 +02:00
|
|
|
|
switch (TYPE_CODE (type))
|
|
|
|
|
{
|
|
|
|
|
case TYPE_CODE_TYPEDEF:
|
2010-12-31 23:59:52 +01:00
|
|
|
|
/* If we get here, the typedef doesn't have a name, and we
|
|
|
|
|
couldn't resolve TYPE_TARGET_TYPE. Not much we can do. */
|
2010-10-19 06:22:20 +02:00
|
|
|
|
gdb_assert (TYPE_NAME (type) == NULL);
|
|
|
|
|
gdb_assert (TYPE_TARGET_TYPE (type) == NULL);
|
|
|
|
|
fprintf_filtered (stream, _("<unnamed typedef>"));
|
|
|
|
|
break;
|
|
|
|
|
|
Stop assuming no-debug-info functions return int
The fact that GDB defaults to assuming that functions return int, when
it has no debug info for the function has been a recurring source of
user confusion. Recently this came up on the errno pretty printer
discussions. Shortly after, it came up again on IRC, with someone
wondering why does getenv() in GDB return a negative int:
(gdb) p getenv("PATH")
$1 = -6185
This question (with s/getenv/random-other-C-runtime-function) is a FAQ
on IRC.
The reason for the above is:
(gdb) p getenv
$2 = {<text variable, no debug info>} 0x7ffff7751d80 <getenv>
(gdb) ptype getenv
type = int ()
... which means that GDB truncated the 64-bit pointer that is actually
returned from getent to 32-bit, and then sign-extended it:
(gdb) p /x -6185
$6 = 0xffffe7d7
The workaround is to cast the function to the right type, like:
(gdb) p ((char *(*) (const char *)) getenv) ("PATH")
$3 = 0x7fffffffe7d7 "/usr/local/bin:/"...
IMO, we should do better than this.
I see the "assume-int" issue the same way I see printing bogus values
for optimized-out variables instead of "<optimized out>" -- I'd much
rather that the debugger tells me "I don't know" and tells me how to
fix it than showing me bogus misleading results, making me go around
tilting at windmills.
If GDB prints a signed integer when you're expecting a pointer or
aggregate, you at least have some sense that something is off, but
consider the case of the function actually returning a 64-bit integer.
For example, compile this without debug info:
unsigned long long
function ()
{
return 0x7fffffffffffffff;
}
Currently, with pristine GDB, you get:
(gdb) p function ()
$1 = -1 # incorrect
(gdb) p /x function ()
$2 = 0xffffffff # incorrect
maybe after spending a few hours debugging you suspect something is
wrong with that -1, and do:
(gdb) ptype function
type = int ()
and maybe, just maybe, you realize that the function actually returns
unsigned long long. And you try to fix it with:
(gdb) p /x (unsigned long long) function ()
$3 = 0xffffffffffffffff # incorrect
... which still produces the wrong result, because GDB simply applied
int to unsigned long long conversion. Meaning, it sign-extended the
integer that it extracted from the return of the function, to 64-bits.
and then maybe, after asking around on IRC, you realize you have to
cast the function to a pointer of the right type, and call that. It
won't be easy, but after a few missteps, you'll get to it:
..... (gdb) p /x ((unsigned long long(*) ()) function) ()
$666 = 0x7fffffffffffffff # finally! :-)
So to improve on the user experience, this patch does the following
(interrelated) things:
- makes no-debug-info functions no longer default to "int" as return
type. Instead, they're left with NULL/"<unknown return type>"
return type.
(gdb) ptype getenv
type = <unknown return type> ()
- makes calling a function with unknown return type an error.
(gdb) p getenv ("PATH")
'getenv' has unknown return type; cast the call to its declared return type
- and then to make it easier to call the function, makes it possible
to _only_ cast the return of the function to the right type,
instead of having to cast the function to a function pointer:
(gdb) p (char *) getenv ("PATH") # now Just Works
$3 = 0x7fffffffe7d7 "/usr/local/bin:/"...
(gdb) p ((char *(*) (const char *)) getenv) ("PATH") # continues working
$4 = 0x7fffffffe7d7 "/usr/local/bin:/"...
I.e., it makes GDB default the function's return type to the type
of the cast, and the function's parameters to the type of the
arguments passed down.
After this patch, here's what you'll get for the "unsigned long long"
example above:
(gdb) p function ()
'function' has unknown return type; cast the call to its declared return type
(gdb) p /x (unsigned long long) function ()
$4 = 0x7fffffffffffffff # correct!
Note that while with "print" GDB shows the name of the function that
has the problem:
(gdb) p getenv ("PATH")
'getenv' has unknown return type; cast the call to its declared return type
which can by handy in more complicated expressions, "ptype" does not:
(gdb) ptype getenv ("PATH")
function has unknown return type; cast the call to its declared return type
This will be fixed in the next patch.
gdb/ChangeLog:
2017-09-04 Pedro Alves <palves@redhat.com>
* ada-lang.c (ada_evaluate_subexp) <TYPE_CODE_FUNC>: Don't handle
TYPE_GNU_IFUNC specially here. Throw error if return type is
unknown.
* ada-typeprint.c (print_func_type): Handle functions with unknown
return type.
* c-typeprint.c (c_type_print_base): Handle functions and methods
with unknown return type.
* compile/compile-c-symbols.c (convert_symbol_bmsym)
<mst_text_gnu_ifunc>: Use nodebug_text_gnu_ifunc_symbol.
* compile/compile-c-types.c: Include "objfiles.h".
(convert_func): For functions with unknown return type, warn and
default to int.
* compile/compile-object-run.c (compile_object_run): Adjust call
to call_function_by_hand_dummy.
* elfread.c (elf_gnu_ifunc_resolve_addr): Adjust call to
call_function_by_hand.
* eval.c (evaluate_subexp_standard): Adjust calls to
call_function_by_hand. Handle functions and methods with unknown
return type. Pass expect_type to call_function_by_hand.
* f-typeprint.c (f_type_print_base): Handle functions with unknown
return type.
* gcore.c (call_target_sbrk): Adjust call to
call_function_by_hand.
* gdbtypes.c (objfile_type): Leave nodebug text symbol with NULL
return type instead of int. Make nodebug_text_gnu_ifunc_symbol be
an integer address type instead of nodebug.
* guile/scm-value.c (gdbscm_value_call): Adjust call to
call_function_by_hand.
* infcall.c (error_call_unknown_return_type): New function.
(call_function_by_hand): New "default_return_type" parameter.
Pass it down.
(call_function_by_hand_dummy): New "default_return_type"
parameter. Use it instead of defaulting to int. If there's no
default and the return type is unknown, throw an error. If
there's a default return type, and the called function has no
debug info, then assume the function is prototyped.
* infcall.h (call_function_by_hand, call_function_by_hand_dummy):
New "default_return_type" parameter.
(error_call_unknown_return_type): New declaration.
* linux-fork.c (call_lseek): Cast return type of lseek.
(inferior_call_waitpid, checkpoint_command): Adjust calls to
call_function_by_hand.
* linux-tdep.c (linux_infcall_mmap, linux_infcall_munmap): Adjust
calls to call_function_by_hand.
* m2-typeprint.c (m2_procedure): Handle functions with unknown
return type.
* objc-lang.c (lookup_objc_class, lookup_child_selector)
(value_nsstring, print_object_command): Adjust calls to
call_function_by_hand.
* p-typeprint.c (pascal_type_print_varspec_prefix): Handle
functions with unknown return type.
(pascal_type_print_func_varspec_suffix): New function.
(pascal_type_print_varspec_suffix) <TYPE_CODE_FUNC,
TYPE_CODE_METHOD>: Use it.
* python/py-value.c (valpy_call): Adjust call to
call_function_by_hand.
* rust-lang.c (rust_evaluate_funcall): Adjust call to
call_function_by_hand.
* valarith.c (value_x_binop, value_x_unop): Adjust calls to
call_function_by_hand.
* valops.c (value_allocate_space_in_inferior): Adjust call to
call_function_by_hand.
* typeprint.c (type_print_unknown_return_type): New function.
* typeprint.h (type_print_unknown_return_type): New declaration.
gdb/testsuite/ChangeLog:
2017-09-04 Pedro Alves <palves@redhat.com>
* gdb.base/break-main-file-remove-fail.exp (test_remove_bp): Cast
return type of munmap in infcall.
* gdb.base/break-probes.exp: Cast return type of foo in infcall.
* gdb.base/checkpoint.exp: Simplify using for loop. Cast return
type of ftell in infcall.
* gdb.base/dprintf-detach.exp (dprintf_detach_test): Cast return
type of getpid in infcall.
* gdb.base/infcall-exec.exp: Cast return type of execlp in
infcall.
* gdb.base/info-os.exp: Cast return type of getpid in infcall.
Bail on failure to extract the pid.
* gdb.base/nodebug.c: #include <stdint.h>.
(multf, multf_noproto, mult, mult_noproto, add8, add8_noproto):
New functions.
* gdb.base/nodebug.exp (test_call_promotion): New procedure.
Change expected output of print/whatis/ptype with functions with
no debug info. Test all supported languages. Call
test_call_promotion.
* gdb.compile/compile.exp: Adjust expected output to expect
warning.
* gdb.threads/siginfo-threads.exp: Likewise.
2017-09-04 21:21:13 +02:00
|
|
|
|
case TYPE_CODE_FUNC:
|
|
|
|
|
case TYPE_CODE_METHOD:
|
|
|
|
|
if (TYPE_TARGET_TYPE (type) == NULL)
|
|
|
|
|
type_print_unknown_return_type (stream);
|
|
|
|
|
else
|
Implement pahole-like 'ptype /o' option
This commit implements the pahole-like '/o' option for 'ptype', which
prints the offsets and sizes of struct fields, reporting whenever
there is a hole found.
The output is heavily based on pahole(1), with a few modifications
here and there to adjust it to our reality. Here's an example:
/* offset | size */ type = struct wer : public tuv {
public:
/* 32 | 24 */ struct tyu {
/* 32:31 | 4 */ int a1 : 1;
/* 32:28 | 4 */ int a2 : 3;
/* 32: 5 | 4 */ int a3 : 23;
/* 35: 3 | 1 */ char a4 : 2;
/* XXX 3-bit hole */
/* XXX 4-byte hole */
/* 40 | 8 */ int64_t a5;
/* 48:27 | 4 */ int a6 : 5;
/* 48:56 | 8 */ int64_t a7 : 3;
/* total size (bytes): 24 */
} a1;
/* total size (bytes): 56 */
}
A big part of this patch handles the formatting logic of 'ptype',
which is a bit messy. The code to handle bitfield offsets, however,
took some time to craft. My thanks to Pedro Alves for figuring things
out and pointing me to the right direction, as well as coming up with
a way to inspect the layout of structs with bitfields (see testcase
for comments).
After many discussions both on IRC and at the mailing list, I tried to
implement printing vtables and inherited classes. Unfortunately the
code grew too complex and there were still a few corner cases failing
so I had to drop the attempt. This should be implemented in a future
patch.
This patch is the start of a long-term work I'll do to flush the local
patches we carry for Fedora GDB. In this specific case, I'm aiming at
upstreaming the feature implemented by the 'pahole.py' script that is
shipped with Fedora GDB:
<https://src.fedoraproject.org/rpms/gdb/blob/master/f/gdb-archer.patch#_311>
This has been regression-tested on the BuildBot. There's a new
testcase for it, along with an update to the documentation. I also
thought it was worth mentioning this feature in the NEWS file.
gdb/ChangeLog:
2017-12-15 Sergio Durigan Junior <sergiodj@redhat.com>
Pedro Alves <palves@redhat.com>
PR cli/16224
* NEWS (Changes since GDB 8.0): Mention new '/o' flag.
* c-typeprint.c (OFFSET_SPC_LEN): New define.
(c_type_print_varspec_prefix): New argument 'struct
print_offset_data *'.
(c_type_print_base_1): New function and prototype.
(c_print_type_1): New function, with code from 'c_print_type'.
(c_print_type): Use 'c_print_type_1'.
(c_type_print_varspec_prefix): New argument 'struct
print_offset_data *'. Use it. Call 'c_type_print_base_1'
instead of 'c_print_type_base'.
(print_spaces_filtered_with_print_options): New function.
(output_access_specifier): Take new argument FLAGS. Modify
function to call 'print_spaces_filtered_with_print_options'.
(c_print_type_vtable_offset_marker): New function.
(c_print_type_union_field_offset): New function.
(c_print_type_struct_field_offset): New function.
(c_print_type_no_offsets): New function.
(c_type_print_base_struct_union): New argument 'struct
print_offset_data *'. Print offsets and sizes for
struct/union/class fields.
* typeprint.c (const struct type_print_options
type_print_raw_options): Initialize 'print_offsets'.
(static struct type_print_options default_ptype_flags):
Likewise.
(struct print_offset_data print_offset_default_data): New
variable.
(whatis_exp): Handle '/o' option.
(_initialize_typeprint): Add '/o' flag to ptype's help.
* typeprint.h (struct print_offset_data): New struct.
(struct type_print_options) <print_offsets>: New field.
gdb/testsuite/ChangeLog:
2017-12-15 Sergio Durigan Junior <sergiodj@redhat.com>
PR cli/16224
* gdb.base/ptype-offsets.cc: New file.
* gdb.base/ptype-offsets.exp: New file.
gdb/doc/ChangeLog:
2017-12-15 Sergio Durigan Junior <sergiodj@redhat.com>
PR cli/16224
* gdb.texinfo (ptype): Add documentation for new flag '/o'.
2017-11-20 22:34:59 +01:00
|
|
|
|
c_type_print_base_1 (TYPE_TARGET_TYPE (type),
|
2018-04-17 21:51:23 +02:00
|
|
|
|
stream, show, level, language, flags, podata);
|
Stop assuming no-debug-info functions return int
The fact that GDB defaults to assuming that functions return int, when
it has no debug info for the function has been a recurring source of
user confusion. Recently this came up on the errno pretty printer
discussions. Shortly after, it came up again on IRC, with someone
wondering why does getenv() in GDB return a negative int:
(gdb) p getenv("PATH")
$1 = -6185
This question (with s/getenv/random-other-C-runtime-function) is a FAQ
on IRC.
The reason for the above is:
(gdb) p getenv
$2 = {<text variable, no debug info>} 0x7ffff7751d80 <getenv>
(gdb) ptype getenv
type = int ()
... which means that GDB truncated the 64-bit pointer that is actually
returned from getent to 32-bit, and then sign-extended it:
(gdb) p /x -6185
$6 = 0xffffe7d7
The workaround is to cast the function to the right type, like:
(gdb) p ((char *(*) (const char *)) getenv) ("PATH")
$3 = 0x7fffffffe7d7 "/usr/local/bin:/"...
IMO, we should do better than this.
I see the "assume-int" issue the same way I see printing bogus values
for optimized-out variables instead of "<optimized out>" -- I'd much
rather that the debugger tells me "I don't know" and tells me how to
fix it than showing me bogus misleading results, making me go around
tilting at windmills.
If GDB prints a signed integer when you're expecting a pointer or
aggregate, you at least have some sense that something is off, but
consider the case of the function actually returning a 64-bit integer.
For example, compile this without debug info:
unsigned long long
function ()
{
return 0x7fffffffffffffff;
}
Currently, with pristine GDB, you get:
(gdb) p function ()
$1 = -1 # incorrect
(gdb) p /x function ()
$2 = 0xffffffff # incorrect
maybe after spending a few hours debugging you suspect something is
wrong with that -1, and do:
(gdb) ptype function
type = int ()
and maybe, just maybe, you realize that the function actually returns
unsigned long long. And you try to fix it with:
(gdb) p /x (unsigned long long) function ()
$3 = 0xffffffffffffffff # incorrect
... which still produces the wrong result, because GDB simply applied
int to unsigned long long conversion. Meaning, it sign-extended the
integer that it extracted from the return of the function, to 64-bits.
and then maybe, after asking around on IRC, you realize you have to
cast the function to a pointer of the right type, and call that. It
won't be easy, but after a few missteps, you'll get to it:
..... (gdb) p /x ((unsigned long long(*) ()) function) ()
$666 = 0x7fffffffffffffff # finally! :-)
So to improve on the user experience, this patch does the following
(interrelated) things:
- makes no-debug-info functions no longer default to "int" as return
type. Instead, they're left with NULL/"<unknown return type>"
return type.
(gdb) ptype getenv
type = <unknown return type> ()
- makes calling a function with unknown return type an error.
(gdb) p getenv ("PATH")
'getenv' has unknown return type; cast the call to its declared return type
- and then to make it easier to call the function, makes it possible
to _only_ cast the return of the function to the right type,
instead of having to cast the function to a function pointer:
(gdb) p (char *) getenv ("PATH") # now Just Works
$3 = 0x7fffffffe7d7 "/usr/local/bin:/"...
(gdb) p ((char *(*) (const char *)) getenv) ("PATH") # continues working
$4 = 0x7fffffffe7d7 "/usr/local/bin:/"...
I.e., it makes GDB default the function's return type to the type
of the cast, and the function's parameters to the type of the
arguments passed down.
After this patch, here's what you'll get for the "unsigned long long"
example above:
(gdb) p function ()
'function' has unknown return type; cast the call to its declared return type
(gdb) p /x (unsigned long long) function ()
$4 = 0x7fffffffffffffff # correct!
Note that while with "print" GDB shows the name of the function that
has the problem:
(gdb) p getenv ("PATH")
'getenv' has unknown return type; cast the call to its declared return type
which can by handy in more complicated expressions, "ptype" does not:
(gdb) ptype getenv ("PATH")
function has unknown return type; cast the call to its declared return type
This will be fixed in the next patch.
gdb/ChangeLog:
2017-09-04 Pedro Alves <palves@redhat.com>
* ada-lang.c (ada_evaluate_subexp) <TYPE_CODE_FUNC>: Don't handle
TYPE_GNU_IFUNC specially here. Throw error if return type is
unknown.
* ada-typeprint.c (print_func_type): Handle functions with unknown
return type.
* c-typeprint.c (c_type_print_base): Handle functions and methods
with unknown return type.
* compile/compile-c-symbols.c (convert_symbol_bmsym)
<mst_text_gnu_ifunc>: Use nodebug_text_gnu_ifunc_symbol.
* compile/compile-c-types.c: Include "objfiles.h".
(convert_func): For functions with unknown return type, warn and
default to int.
* compile/compile-object-run.c (compile_object_run): Adjust call
to call_function_by_hand_dummy.
* elfread.c (elf_gnu_ifunc_resolve_addr): Adjust call to
call_function_by_hand.
* eval.c (evaluate_subexp_standard): Adjust calls to
call_function_by_hand. Handle functions and methods with unknown
return type. Pass expect_type to call_function_by_hand.
* f-typeprint.c (f_type_print_base): Handle functions with unknown
return type.
* gcore.c (call_target_sbrk): Adjust call to
call_function_by_hand.
* gdbtypes.c (objfile_type): Leave nodebug text symbol with NULL
return type instead of int. Make nodebug_text_gnu_ifunc_symbol be
an integer address type instead of nodebug.
* guile/scm-value.c (gdbscm_value_call): Adjust call to
call_function_by_hand.
* infcall.c (error_call_unknown_return_type): New function.
(call_function_by_hand): New "default_return_type" parameter.
Pass it down.
(call_function_by_hand_dummy): New "default_return_type"
parameter. Use it instead of defaulting to int. If there's no
default and the return type is unknown, throw an error. If
there's a default return type, and the called function has no
debug info, then assume the function is prototyped.
* infcall.h (call_function_by_hand, call_function_by_hand_dummy):
New "default_return_type" parameter.
(error_call_unknown_return_type): New declaration.
* linux-fork.c (call_lseek): Cast return type of lseek.
(inferior_call_waitpid, checkpoint_command): Adjust calls to
call_function_by_hand.
* linux-tdep.c (linux_infcall_mmap, linux_infcall_munmap): Adjust
calls to call_function_by_hand.
* m2-typeprint.c (m2_procedure): Handle functions with unknown
return type.
* objc-lang.c (lookup_objc_class, lookup_child_selector)
(value_nsstring, print_object_command): Adjust calls to
call_function_by_hand.
* p-typeprint.c (pascal_type_print_varspec_prefix): Handle
functions with unknown return type.
(pascal_type_print_func_varspec_suffix): New function.
(pascal_type_print_varspec_suffix) <TYPE_CODE_FUNC,
TYPE_CODE_METHOD>: Use it.
* python/py-value.c (valpy_call): Adjust call to
call_function_by_hand.
* rust-lang.c (rust_evaluate_funcall): Adjust call to
call_function_by_hand.
* valarith.c (value_x_binop, value_x_unop): Adjust calls to
call_function_by_hand.
* valops.c (value_allocate_space_in_inferior): Adjust call to
call_function_by_hand.
* typeprint.c (type_print_unknown_return_type): New function.
* typeprint.h (type_print_unknown_return_type): New declaration.
gdb/testsuite/ChangeLog:
2017-09-04 Pedro Alves <palves@redhat.com>
* gdb.base/break-main-file-remove-fail.exp (test_remove_bp): Cast
return type of munmap in infcall.
* gdb.base/break-probes.exp: Cast return type of foo in infcall.
* gdb.base/checkpoint.exp: Simplify using for loop. Cast return
type of ftell in infcall.
* gdb.base/dprintf-detach.exp (dprintf_detach_test): Cast return
type of getpid in infcall.
* gdb.base/infcall-exec.exp: Cast return type of execlp in
infcall.
* gdb.base/info-os.exp: Cast return type of getpid in infcall.
Bail on failure to extract the pid.
* gdb.base/nodebug.c: #include <stdint.h>.
(multf, multf_noproto, mult, mult_noproto, add8, add8_noproto):
New functions.
* gdb.base/nodebug.exp (test_call_promotion): New procedure.
Change expected output of print/whatis/ptype with functions with
no debug info. Test all supported languages. Call
test_call_promotion.
* gdb.compile/compile.exp: Adjust expected output to expect
warning.
* gdb.threads/siginfo-threads.exp: Likewise.
2017-09-04 21:21:13 +02:00
|
|
|
|
break;
|
1999-04-16 03:35:26 +02:00
|
|
|
|
case TYPE_CODE_ARRAY:
|
|
|
|
|
case TYPE_CODE_PTR:
|
* NEWS: Mention pointer to member improvements.
* Makefile.in (gnu-v3-abi.o): Delete special rule.
(eval.o, gnu-v3-abi.o, ia64-tdep.o): Update.
* ada-valprint.c (ada_print_scalar): Update for new type codes.
* c-typeprint.c (c_print_type): Update for new type codes.
(c_type_print_varspec_prefix, c_type_print_varspec_suffix)
(c_type_print_base): Likewise.
(c_type_print_args): Rewrite.
* c-valprint.c (c_val_print): Update for new type codes. Remove
support for references to members. Treat methods like functions.
* cp-abi.c (cplus_print_method_ptr, cplus_method_ptr_size)
(cplus_make_method_ptr, cplus_method_ptr_to_value): New.
* cp-abi.h (cplus_print_method_ptr, cplus_method_ptr_size)
(cplus_make_method_ptr, cplus_method_ptr_to_value): New prototypes.
(struct cp_abi_ops): Add corresponding members.
* cp-valprint.c (cp_print_class_method): Delete.
(cp_find_class_member): New function.
(cp_print_class_member): Use it. Simplify support for bogus
member pointers.
* dwarf2read.c (quirk_gcc_member_function_pointer): Use
lookup_methodptr_type.
(read_tag_ptr_to_member_type): Likewise, and lookup_memberptr_type.
* eval.c (evaluate_subexp_standard): Implement EVAL_SKIP for
OP_SCOPE. Update call to value_aggregate_elt. Rewrite member
pointer support.
(evaluate_subexp_for_address): Handle OP_SCOPE explicitly. Handle
references returned by user defined operators.
* f-typeprint.c (f_print_type, f_type_print_varspec_prefix)
(f_type_print_varspec_suffix): Remove support for member pointers.
* gdbtypes.c (lookup_memberptr_type): Renamed from lookup_member_type
and adjusted.
(smash_to_memberptr_type): Likewise, from smash_to_member_type.
(lookup_methodptr_type): New.
(rank_one_type): Adjust for TYPE_CODE_MEMBERPTR.
(recursive_dump_type): Update for new types.
* gdbtypes.h (enum type_code): Replace TYPE_CODE_MEMBER with
TYPE_CODE_MEMBERPTR and TYPE_CODE_METHODPTR.
(lookup_memberptr_type, lookup_methodptr_type)
(smash_to_memberptr_type): New prototypes.
(smash_to_method_type): Formatting fix.
(lookup_member_type, smash_to_member_type): Delete prototypes.
* gnu-v3-abi.c (gnuv3_get_vtable, gnuv3_get_virtual_fn): New.
Do not rely on debug information for the vptr or the method's
enclosing type. Handle function descriptors for IA64.
(gnuv3_virtual_fn_field): Rewrite using the new functions.
(gnuv3_find_method_in, gnuv3_print_method_ptr)
(gnuv3_method_ptr_size, gnuv3_make_method_ptr)
(gnuv3_method_ptr_to_value): New.
(init_gnuv3_ops): Set new members of gnu_v3_abi_ops.
* hpread.c (hpread_type_lookup): Update for new types.
* infcall.c (value_arg_coerce): Likewise.
* m2-typeprint.c (m2_print_type): Remove explicit support
for member pointers.
* m2-valprint.c (m2_val_print): Likewise.
* p-typeprint.c (pascal_type_print_varspec_prefix)
(pascal_type_print_varspec_suffix, pascal_type_print_base): Likewise.
* p-valprint.c (pascal_val_print): Likewise.
(pascal_object_print_class_method, pascal_object_print_class_member):
Delete.
* p-lang.h (pascal_object_print_class_method)
(pascal_object_print_class_member): Delete prototypes.
* stabsread.c (read_type): Update for new types.
* typeprint.c (print_type_scalar): Likewise.
* valops.c (value_struct_elt_for_reference, value_namespace_elt)
(value_maybe_namespace_elt, value_aggregate_elt): Add want_address
argument. Construct a pointer to member if the address of a
function or data member is requested.
(value_cast_pointers): Don't modify the input value.
(value_cast): Adjust pointer to member handling for new types.
Allow null pointer to member constants. Don't modify the input
value.
(value_ind): Remove pointer to member check. Handle function
descriptors for function pointers.
(value_struct_elt, value_find_oload_method_list, check_field):
Remove pointer to member checks.
* value.c (unpack_long): Allow pointers to data members.
(value_from_longest): Allow member pointers.
* value.h (value_aggregate_elt): Add want_address.
* varobj.c (c_variable_editable): Remove check for members.
* gdbarch.sh: Add vtable_function_descriptors and vbit_in_delta.
* ia64-tdep.c (ia64_convert_from_func_ptr_addr): Handle descriptors
in virtual tables.
(ia64_gdbarch_init): Call set_gdbarch_vtable_function_descriptors.
* c-lang.h (cp_print_class_method): Delete prototype.
* arm-tdep.c (arm_gdbarch_init): Call set_gdbarch_vbit_in_delta.
* mips-tdep.c (mips_gdbarch_init): Likewise.
* gdbarch.c, gdbarch.h: Regenerated.
* gdb.cp/classes.exp (test_pointers_to_class_members): Update expected
output. Test the types of members and member pointers.
* gdb.cp/inherit.exp (test_print_mi_member_types): Remove KFAILs for
gdb/2092.
* gdb.cp/member-ptr.exp: Search for a comment instead of a
statement. Enable for GCC. Update expected output for some tests
and add new tests. Remove obsolete GCC KFAILs. Allow GCC's class
layout.
* gdb.cp/member-ptr.cc (Padding, Padding::vspacer, Base, Base::get_x)
(Base::vget_base, Left, Left::vget, Right, Right::vget, Diamond)
(Diamond::vget_base): New.
(main): Add new tests.
* gdb.cp/printmethod.exp: Update expected output for member functions.
* gdb.cp/virtfunc.exp (test_virtual_calls): Add a KFAIL for
print pEe->D::vg().
2007-01-03 19:05:45 +01:00
|
|
|
|
case TYPE_CODE_MEMBERPTR:
|
1999-04-16 03:35:26 +02:00
|
|
|
|
case TYPE_CODE_REF:
|
2017-03-20 21:47:48 +01:00
|
|
|
|
case TYPE_CODE_RVALUE_REF:
|
* NEWS: Mention pointer to member improvements.
* Makefile.in (gnu-v3-abi.o): Delete special rule.
(eval.o, gnu-v3-abi.o, ia64-tdep.o): Update.
* ada-valprint.c (ada_print_scalar): Update for new type codes.
* c-typeprint.c (c_print_type): Update for new type codes.
(c_type_print_varspec_prefix, c_type_print_varspec_suffix)
(c_type_print_base): Likewise.
(c_type_print_args): Rewrite.
* c-valprint.c (c_val_print): Update for new type codes. Remove
support for references to members. Treat methods like functions.
* cp-abi.c (cplus_print_method_ptr, cplus_method_ptr_size)
(cplus_make_method_ptr, cplus_method_ptr_to_value): New.
* cp-abi.h (cplus_print_method_ptr, cplus_method_ptr_size)
(cplus_make_method_ptr, cplus_method_ptr_to_value): New prototypes.
(struct cp_abi_ops): Add corresponding members.
* cp-valprint.c (cp_print_class_method): Delete.
(cp_find_class_member): New function.
(cp_print_class_member): Use it. Simplify support for bogus
member pointers.
* dwarf2read.c (quirk_gcc_member_function_pointer): Use
lookup_methodptr_type.
(read_tag_ptr_to_member_type): Likewise, and lookup_memberptr_type.
* eval.c (evaluate_subexp_standard): Implement EVAL_SKIP for
OP_SCOPE. Update call to value_aggregate_elt. Rewrite member
pointer support.
(evaluate_subexp_for_address): Handle OP_SCOPE explicitly. Handle
references returned by user defined operators.
* f-typeprint.c (f_print_type, f_type_print_varspec_prefix)
(f_type_print_varspec_suffix): Remove support for member pointers.
* gdbtypes.c (lookup_memberptr_type): Renamed from lookup_member_type
and adjusted.
(smash_to_memberptr_type): Likewise, from smash_to_member_type.
(lookup_methodptr_type): New.
(rank_one_type): Adjust for TYPE_CODE_MEMBERPTR.
(recursive_dump_type): Update for new types.
* gdbtypes.h (enum type_code): Replace TYPE_CODE_MEMBER with
TYPE_CODE_MEMBERPTR and TYPE_CODE_METHODPTR.
(lookup_memberptr_type, lookup_methodptr_type)
(smash_to_memberptr_type): New prototypes.
(smash_to_method_type): Formatting fix.
(lookup_member_type, smash_to_member_type): Delete prototypes.
* gnu-v3-abi.c (gnuv3_get_vtable, gnuv3_get_virtual_fn): New.
Do not rely on debug information for the vptr or the method's
enclosing type. Handle function descriptors for IA64.
(gnuv3_virtual_fn_field): Rewrite using the new functions.
(gnuv3_find_method_in, gnuv3_print_method_ptr)
(gnuv3_method_ptr_size, gnuv3_make_method_ptr)
(gnuv3_method_ptr_to_value): New.
(init_gnuv3_ops): Set new members of gnu_v3_abi_ops.
* hpread.c (hpread_type_lookup): Update for new types.
* infcall.c (value_arg_coerce): Likewise.
* m2-typeprint.c (m2_print_type): Remove explicit support
for member pointers.
* m2-valprint.c (m2_val_print): Likewise.
* p-typeprint.c (pascal_type_print_varspec_prefix)
(pascal_type_print_varspec_suffix, pascal_type_print_base): Likewise.
* p-valprint.c (pascal_val_print): Likewise.
(pascal_object_print_class_method, pascal_object_print_class_member):
Delete.
* p-lang.h (pascal_object_print_class_method)
(pascal_object_print_class_member): Delete prototypes.
* stabsread.c (read_type): Update for new types.
* typeprint.c (print_type_scalar): Likewise.
* valops.c (value_struct_elt_for_reference, value_namespace_elt)
(value_maybe_namespace_elt, value_aggregate_elt): Add want_address
argument. Construct a pointer to member if the address of a
function or data member is requested.
(value_cast_pointers): Don't modify the input value.
(value_cast): Adjust pointer to member handling for new types.
Allow null pointer to member constants. Don't modify the input
value.
(value_ind): Remove pointer to member check. Handle function
descriptors for function pointers.
(value_struct_elt, value_find_oload_method_list, check_field):
Remove pointer to member checks.
* value.c (unpack_long): Allow pointers to data members.
(value_from_longest): Allow member pointers.
* value.h (value_aggregate_elt): Add want_address.
* varobj.c (c_variable_editable): Remove check for members.
* gdbarch.sh: Add vtable_function_descriptors and vbit_in_delta.
* ia64-tdep.c (ia64_convert_from_func_ptr_addr): Handle descriptors
in virtual tables.
(ia64_gdbarch_init): Call set_gdbarch_vtable_function_descriptors.
* c-lang.h (cp_print_class_method): Delete prototype.
* arm-tdep.c (arm_gdbarch_init): Call set_gdbarch_vbit_in_delta.
* mips-tdep.c (mips_gdbarch_init): Likewise.
* gdbarch.c, gdbarch.h: Regenerated.
* gdb.cp/classes.exp (test_pointers_to_class_members): Update expected
output. Test the types of members and member pointers.
* gdb.cp/inherit.exp (test_print_mi_member_types): Remove KFAILs for
gdb/2092.
* gdb.cp/member-ptr.exp: Search for a comment instead of a
statement. Enable for GCC. Update expected output for some tests
and add new tests. Remove obsolete GCC KFAILs. Allow GCC's class
layout.
* gdb.cp/member-ptr.cc (Padding, Padding::vspacer, Base, Base::get_x)
(Base::vget_base, Left, Left::vget, Right, Right::vget, Diamond)
(Diamond::vget_base): New.
(main): Add new tests.
* gdb.cp/printmethod.exp: Update expected output for member functions.
* gdb.cp/virtfunc.exp (test_virtual_calls): Add a KFAIL for
print pEe->D::vg().
2007-01-03 19:05:45 +01:00
|
|
|
|
case TYPE_CODE_METHODPTR:
|
Implement pahole-like 'ptype /o' option
This commit implements the pahole-like '/o' option for 'ptype', which
prints the offsets and sizes of struct fields, reporting whenever
there is a hole found.
The output is heavily based on pahole(1), with a few modifications
here and there to adjust it to our reality. Here's an example:
/* offset | size */ type = struct wer : public tuv {
public:
/* 32 | 24 */ struct tyu {
/* 32:31 | 4 */ int a1 : 1;
/* 32:28 | 4 */ int a2 : 3;
/* 32: 5 | 4 */ int a3 : 23;
/* 35: 3 | 1 */ char a4 : 2;
/* XXX 3-bit hole */
/* XXX 4-byte hole */
/* 40 | 8 */ int64_t a5;
/* 48:27 | 4 */ int a6 : 5;
/* 48:56 | 8 */ int64_t a7 : 3;
/* total size (bytes): 24 */
} a1;
/* total size (bytes): 56 */
}
A big part of this patch handles the formatting logic of 'ptype',
which is a bit messy. The code to handle bitfield offsets, however,
took some time to craft. My thanks to Pedro Alves for figuring things
out and pointing me to the right direction, as well as coming up with
a way to inspect the layout of structs with bitfields (see testcase
for comments).
After many discussions both on IRC and at the mailing list, I tried to
implement printing vtables and inherited classes. Unfortunately the
code grew too complex and there were still a few corner cases failing
so I had to drop the attempt. This should be implemented in a future
patch.
This patch is the start of a long-term work I'll do to flush the local
patches we carry for Fedora GDB. In this specific case, I'm aiming at
upstreaming the feature implemented by the 'pahole.py' script that is
shipped with Fedora GDB:
<https://src.fedoraproject.org/rpms/gdb/blob/master/f/gdb-archer.patch#_311>
This has been regression-tested on the BuildBot. There's a new
testcase for it, along with an update to the documentation. I also
thought it was worth mentioning this feature in the NEWS file.
gdb/ChangeLog:
2017-12-15 Sergio Durigan Junior <sergiodj@redhat.com>
Pedro Alves <palves@redhat.com>
PR cli/16224
* NEWS (Changes since GDB 8.0): Mention new '/o' flag.
* c-typeprint.c (OFFSET_SPC_LEN): New define.
(c_type_print_varspec_prefix): New argument 'struct
print_offset_data *'.
(c_type_print_base_1): New function and prototype.
(c_print_type_1): New function, with code from 'c_print_type'.
(c_print_type): Use 'c_print_type_1'.
(c_type_print_varspec_prefix): New argument 'struct
print_offset_data *'. Use it. Call 'c_type_print_base_1'
instead of 'c_print_type_base'.
(print_spaces_filtered_with_print_options): New function.
(output_access_specifier): Take new argument FLAGS. Modify
function to call 'print_spaces_filtered_with_print_options'.
(c_print_type_vtable_offset_marker): New function.
(c_print_type_union_field_offset): New function.
(c_print_type_struct_field_offset): New function.
(c_print_type_no_offsets): New function.
(c_type_print_base_struct_union): New argument 'struct
print_offset_data *'. Print offsets and sizes for
struct/union/class fields.
* typeprint.c (const struct type_print_options
type_print_raw_options): Initialize 'print_offsets'.
(static struct type_print_options default_ptype_flags):
Likewise.
(struct print_offset_data print_offset_default_data): New
variable.
(whatis_exp): Handle '/o' option.
(_initialize_typeprint): Add '/o' flag to ptype's help.
* typeprint.h (struct print_offset_data): New struct.
(struct type_print_options) <print_offsets>: New field.
gdb/testsuite/ChangeLog:
2017-12-15 Sergio Durigan Junior <sergiodj@redhat.com>
PR cli/16224
* gdb.base/ptype-offsets.cc: New file.
* gdb.base/ptype-offsets.exp: New file.
gdb/doc/ChangeLog:
2017-12-15 Sergio Durigan Junior <sergiodj@redhat.com>
PR cli/16224
* gdb.texinfo (ptype): Add documentation for new flag '/o'.
2017-11-20 22:34:59 +01:00
|
|
|
|
c_type_print_base_1 (TYPE_TARGET_TYPE (type),
|
2018-04-17 21:51:23 +02:00
|
|
|
|
stream, show, level, language, flags, podata);
|
1999-04-16 03:35:26 +02:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case TYPE_CODE_STRUCT:
|
2012-09-21 19:37:47 +02:00
|
|
|
|
case TYPE_CODE_UNION:
|
2018-04-17 21:51:23 +02:00
|
|
|
|
c_type_print_base_struct_union (type, stream, show, level,
|
|
|
|
|
language, flags, podata);
|
1999-04-16 03:35:26 +02:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case TYPE_CODE_ENUM:
|
2001-11-15 02:55:59 +01:00
|
|
|
|
c_type_print_modifier (type, stream, 0, 1);
|
1999-07-07 22:19:36 +02:00
|
|
|
|
fprintf_filtered (stream, "enum ");
|
2014-03-27 19:24:27 +01:00
|
|
|
|
if (TYPE_DECLARED_CLASS (type))
|
|
|
|
|
fprintf_filtered (stream, "class ");
|
1999-04-16 03:35:26 +02:00
|
|
|
|
/* Print the tag name if it exists.
|
|
|
|
|
The aCC compiler emits a spurious
|
|
|
|
|
"{unnamed struct}"/"{unnamed union}"/"{unnamed enum}"
|
|
|
|
|
tag for unnamed struct/union/enum's, which we don't
|
2010-12-31 23:59:52 +01:00
|
|
|
|
want to print. */
|
Remove TYPE_TAG_NAME
TYPE_TAG_NAME has been an occasional source of confusion and bugs. It
seems to me that it is only useful for C and C++ -- but even there,
not so much, because at least with DWARF there doesn't seem to be any
way to wind up with a type where the name and the tag name are both
non-NULL and different.
So, this patch removes TYPE_TAG_NAME entirely. This should save a
little memory, but more importantly, it simplifies this part of gdb.
A few minor test suite adjustments were needed. In some situations
the new code does not yield identical output to the old code.
gdb/ChangeLog
2018-06-01 Tom Tromey <tom@tromey.com>
* valops.c (enum_constant_from_type, value_namespace_elt)
(value_maybe_namespace_elt): Update.
* valarith.c (find_size_for_pointer_math): Update.
* target-descriptions.c (make_gdb_type): Update.
* symmisc.c (print_symbol): Update.
* stabsread.c (define_symbol, read_type)
(complain_about_struct_wipeout, add_undefined_type)
(cleanup_undefined_types_1): Update.
* rust-lang.c (rust_tuple_type_p, rust_slice_type_p)
(rust_range_type_p, val_print_struct, rust_print_struct_def)
(rust_internal_print_type, rust_composite_type)
(rust_evaluate_funcall, rust_evaluate_subexp)
(rust_inclusive_range_type_p): Update.
* python/py-type.c (typy_get_tag): Update.
* p-typeprint.c (pascal_type_print_base): Update.
* mdebugread.c (parse_symbol, parse_type): Update.
* m2-typeprint.c (m2_long_set, m2_record_fields, m2_enum):
Update.
* guile/scm-type.c (gdbscm_type_tag): Update.
* go-lang.c (sixg_string_p): Update.
* gnu-v3-abi.c (build_gdb_vtable_type, build_std_type_info_type):
Update.
* gdbtypes.h (struct main_type) <tag_name>: Remove.
(TYPE_TAG_NAME): Remove.
* gdbtypes.c (type_name_no_tag): Simplify.
(check_typedef, check_types_equal, recursive_dump_type)
(copy_type_recursive, arch_composite_type): Update.
* f-typeprint.c (f_type_print_base): Update. Print "Type" prefix
in summary mode when needed.
* eval.c (evaluate_funcall): Update.
* dwarf2read.c (fixup_go_packaging, read_structure_type)
(process_structure_scope, read_enumeration_type)
(read_namespace_type, read_module_type, determine_prefix): Update.
* cp-support.c (inspect_type): Update.
* coffread.c (process_coff_symbol, decode_base_type): Update.
* c-varobj.c (c_is_path_expr_parent): Update.
* c-typeprint.c (c_type_print_base_struct_union): Update.
(c_type_print_base_1): Update. Print struct/class/union/enum in
summary when using C language.
* ax-gdb.c (gen_struct_ref, gen_namespace_elt)
(gen_maybe_namespace_elt): Update.
* ada-lang.c (ada_type_name): Simplify.
(empty_record, ada_template_to_fixed_record_type_1)
(template_to_static_fixed_type)
(to_record_with_fixed_variant_part, ada_check_typedef): Update.
gdb/testsuite/ChangeLog
2018-06-01 Tom Tromey <tom@tromey.com>
* gdb.xml/tdesc-regs.exp (load_description): Update expected
results.
* gdb.dwarf2/method-ptr.exp: Set language to C++.
* gdb.dwarf2/member-ptr-forwardref.exp: Set language to C++.
* gdb.cp/typeid.exp (do_typeid_tests): Update type_re.
* gdb.base/maint.exp (maint_pass_if): Update.
2018-04-17 21:51:24 +02:00
|
|
|
|
if (TYPE_NAME (type) != NULL
|
|
|
|
|
&& !startswith (TYPE_NAME (type), "{unnamed"))
|
1999-04-16 03:35:26 +02:00
|
|
|
|
{
|
Remove TYPE_TAG_NAME
TYPE_TAG_NAME has been an occasional source of confusion and bugs. It
seems to me that it is only useful for C and C++ -- but even there,
not so much, because at least with DWARF there doesn't seem to be any
way to wind up with a type where the name and the tag name are both
non-NULL and different.
So, this patch removes TYPE_TAG_NAME entirely. This should save a
little memory, but more importantly, it simplifies this part of gdb.
A few minor test suite adjustments were needed. In some situations
the new code does not yield identical output to the old code.
gdb/ChangeLog
2018-06-01 Tom Tromey <tom@tromey.com>
* valops.c (enum_constant_from_type, value_namespace_elt)
(value_maybe_namespace_elt): Update.
* valarith.c (find_size_for_pointer_math): Update.
* target-descriptions.c (make_gdb_type): Update.
* symmisc.c (print_symbol): Update.
* stabsread.c (define_symbol, read_type)
(complain_about_struct_wipeout, add_undefined_type)
(cleanup_undefined_types_1): Update.
* rust-lang.c (rust_tuple_type_p, rust_slice_type_p)
(rust_range_type_p, val_print_struct, rust_print_struct_def)
(rust_internal_print_type, rust_composite_type)
(rust_evaluate_funcall, rust_evaluate_subexp)
(rust_inclusive_range_type_p): Update.
* python/py-type.c (typy_get_tag): Update.
* p-typeprint.c (pascal_type_print_base): Update.
* mdebugread.c (parse_symbol, parse_type): Update.
* m2-typeprint.c (m2_long_set, m2_record_fields, m2_enum):
Update.
* guile/scm-type.c (gdbscm_type_tag): Update.
* go-lang.c (sixg_string_p): Update.
* gnu-v3-abi.c (build_gdb_vtable_type, build_std_type_info_type):
Update.
* gdbtypes.h (struct main_type) <tag_name>: Remove.
(TYPE_TAG_NAME): Remove.
* gdbtypes.c (type_name_no_tag): Simplify.
(check_typedef, check_types_equal, recursive_dump_type)
(copy_type_recursive, arch_composite_type): Update.
* f-typeprint.c (f_type_print_base): Update. Print "Type" prefix
in summary mode when needed.
* eval.c (evaluate_funcall): Update.
* dwarf2read.c (fixup_go_packaging, read_structure_type)
(process_structure_scope, read_enumeration_type)
(read_namespace_type, read_module_type, determine_prefix): Update.
* cp-support.c (inspect_type): Update.
* coffread.c (process_coff_symbol, decode_base_type): Update.
* c-varobj.c (c_is_path_expr_parent): Update.
* c-typeprint.c (c_type_print_base_struct_union): Update.
(c_type_print_base_1): Update. Print struct/class/union/enum in
summary when using C language.
* ax-gdb.c (gen_struct_ref, gen_namespace_elt)
(gen_maybe_namespace_elt): Update.
* ada-lang.c (ada_type_name): Simplify.
(empty_record, ada_template_to_fixed_record_type_1)
(template_to_static_fixed_type)
(to_record_with_fixed_variant_part, ada_check_typedef): Update.
gdb/testsuite/ChangeLog
2018-06-01 Tom Tromey <tom@tromey.com>
* gdb.xml/tdesc-regs.exp (load_description): Update expected
results.
* gdb.dwarf2/method-ptr.exp: Set language to C++.
* gdb.dwarf2/member-ptr-forwardref.exp: Set language to C++.
* gdb.cp/typeid.exp (do_typeid_tests): Update type_re.
* gdb.base/maint.exp (maint_pass_if): Update.
2018-04-17 21:51:24 +02:00
|
|
|
|
print_name_maybe_canonical (TYPE_NAME (type), flags, stream);
|
1999-04-16 03:35:26 +02:00
|
|
|
|
if (show > 0)
|
|
|
|
|
fputs_filtered (" ", stream);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
wrap_here (" ");
|
|
|
|
|
if (show < 0)
|
|
|
|
|
{
|
2010-12-31 23:59:52 +01:00
|
|
|
|
/* If we just printed a tag name, no need to print anything
|
|
|
|
|
else. */
|
Remove TYPE_TAG_NAME
TYPE_TAG_NAME has been an occasional source of confusion and bugs. It
seems to me that it is only useful for C and C++ -- but even there,
not so much, because at least with DWARF there doesn't seem to be any
way to wind up with a type where the name and the tag name are both
non-NULL and different.
So, this patch removes TYPE_TAG_NAME entirely. This should save a
little memory, but more importantly, it simplifies this part of gdb.
A few minor test suite adjustments were needed. In some situations
the new code does not yield identical output to the old code.
gdb/ChangeLog
2018-06-01 Tom Tromey <tom@tromey.com>
* valops.c (enum_constant_from_type, value_namespace_elt)
(value_maybe_namespace_elt): Update.
* valarith.c (find_size_for_pointer_math): Update.
* target-descriptions.c (make_gdb_type): Update.
* symmisc.c (print_symbol): Update.
* stabsread.c (define_symbol, read_type)
(complain_about_struct_wipeout, add_undefined_type)
(cleanup_undefined_types_1): Update.
* rust-lang.c (rust_tuple_type_p, rust_slice_type_p)
(rust_range_type_p, val_print_struct, rust_print_struct_def)
(rust_internal_print_type, rust_composite_type)
(rust_evaluate_funcall, rust_evaluate_subexp)
(rust_inclusive_range_type_p): Update.
* python/py-type.c (typy_get_tag): Update.
* p-typeprint.c (pascal_type_print_base): Update.
* mdebugread.c (parse_symbol, parse_type): Update.
* m2-typeprint.c (m2_long_set, m2_record_fields, m2_enum):
Update.
* guile/scm-type.c (gdbscm_type_tag): Update.
* go-lang.c (sixg_string_p): Update.
* gnu-v3-abi.c (build_gdb_vtable_type, build_std_type_info_type):
Update.
* gdbtypes.h (struct main_type) <tag_name>: Remove.
(TYPE_TAG_NAME): Remove.
* gdbtypes.c (type_name_no_tag): Simplify.
(check_typedef, check_types_equal, recursive_dump_type)
(copy_type_recursive, arch_composite_type): Update.
* f-typeprint.c (f_type_print_base): Update. Print "Type" prefix
in summary mode when needed.
* eval.c (evaluate_funcall): Update.
* dwarf2read.c (fixup_go_packaging, read_structure_type)
(process_structure_scope, read_enumeration_type)
(read_namespace_type, read_module_type, determine_prefix): Update.
* cp-support.c (inspect_type): Update.
* coffread.c (process_coff_symbol, decode_base_type): Update.
* c-varobj.c (c_is_path_expr_parent): Update.
* c-typeprint.c (c_type_print_base_struct_union): Update.
(c_type_print_base_1): Update. Print struct/class/union/enum in
summary when using C language.
* ax-gdb.c (gen_struct_ref, gen_namespace_elt)
(gen_maybe_namespace_elt): Update.
* ada-lang.c (ada_type_name): Simplify.
(empty_record, ada_template_to_fixed_record_type_1)
(template_to_static_fixed_type)
(to_record_with_fixed_variant_part, ada_check_typedef): Update.
gdb/testsuite/ChangeLog
2018-06-01 Tom Tromey <tom@tromey.com>
* gdb.xml/tdesc-regs.exp (load_description): Update expected
results.
* gdb.dwarf2/method-ptr.exp: Set language to C++.
* gdb.dwarf2/member-ptr-forwardref.exp: Set language to C++.
* gdb.cp/typeid.exp (do_typeid_tests): Update type_re.
* gdb.base/maint.exp (maint_pass_if): Update.
2018-04-17 21:51:24 +02:00
|
|
|
|
if (TYPE_NAME (type) == NULL)
|
1999-04-16 03:35:26 +02:00
|
|
|
|
fprintf_filtered (stream, "{...}");
|
|
|
|
|
}
|
Remove TYPE_TAG_NAME
TYPE_TAG_NAME has been an occasional source of confusion and bugs. It
seems to me that it is only useful for C and C++ -- but even there,
not so much, because at least with DWARF there doesn't seem to be any
way to wind up with a type where the name and the tag name are both
non-NULL and different.
So, this patch removes TYPE_TAG_NAME entirely. This should save a
little memory, but more importantly, it simplifies this part of gdb.
A few minor test suite adjustments were needed. In some situations
the new code does not yield identical output to the old code.
gdb/ChangeLog
2018-06-01 Tom Tromey <tom@tromey.com>
* valops.c (enum_constant_from_type, value_namespace_elt)
(value_maybe_namespace_elt): Update.
* valarith.c (find_size_for_pointer_math): Update.
* target-descriptions.c (make_gdb_type): Update.
* symmisc.c (print_symbol): Update.
* stabsread.c (define_symbol, read_type)
(complain_about_struct_wipeout, add_undefined_type)
(cleanup_undefined_types_1): Update.
* rust-lang.c (rust_tuple_type_p, rust_slice_type_p)
(rust_range_type_p, val_print_struct, rust_print_struct_def)
(rust_internal_print_type, rust_composite_type)
(rust_evaluate_funcall, rust_evaluate_subexp)
(rust_inclusive_range_type_p): Update.
* python/py-type.c (typy_get_tag): Update.
* p-typeprint.c (pascal_type_print_base): Update.
* mdebugread.c (parse_symbol, parse_type): Update.
* m2-typeprint.c (m2_long_set, m2_record_fields, m2_enum):
Update.
* guile/scm-type.c (gdbscm_type_tag): Update.
* go-lang.c (sixg_string_p): Update.
* gnu-v3-abi.c (build_gdb_vtable_type, build_std_type_info_type):
Update.
* gdbtypes.h (struct main_type) <tag_name>: Remove.
(TYPE_TAG_NAME): Remove.
* gdbtypes.c (type_name_no_tag): Simplify.
(check_typedef, check_types_equal, recursive_dump_type)
(copy_type_recursive, arch_composite_type): Update.
* f-typeprint.c (f_type_print_base): Update. Print "Type" prefix
in summary mode when needed.
* eval.c (evaluate_funcall): Update.
* dwarf2read.c (fixup_go_packaging, read_structure_type)
(process_structure_scope, read_enumeration_type)
(read_namespace_type, read_module_type, determine_prefix): Update.
* cp-support.c (inspect_type): Update.
* coffread.c (process_coff_symbol, decode_base_type): Update.
* c-varobj.c (c_is_path_expr_parent): Update.
* c-typeprint.c (c_type_print_base_struct_union): Update.
(c_type_print_base_1): Update. Print struct/class/union/enum in
summary when using C language.
* ax-gdb.c (gen_struct_ref, gen_namespace_elt)
(gen_maybe_namespace_elt): Update.
* ada-lang.c (ada_type_name): Simplify.
(empty_record, ada_template_to_fixed_record_type_1)
(template_to_static_fixed_type)
(to_record_with_fixed_variant_part, ada_check_typedef): Update.
gdb/testsuite/ChangeLog
2018-06-01 Tom Tromey <tom@tromey.com>
* gdb.xml/tdesc-regs.exp (load_description): Update expected
results.
* gdb.dwarf2/method-ptr.exp: Set language to C++.
* gdb.dwarf2/member-ptr-forwardref.exp: Set language to C++.
* gdb.cp/typeid.exp (do_typeid_tests): Update type_re.
* gdb.base/maint.exp (maint_pass_if): Update.
2018-04-17 21:51:24 +02:00
|
|
|
|
else if (show > 0 || TYPE_NAME (type) == NULL)
|
1999-04-16 03:35:26 +02:00
|
|
|
|
{
|
2012-04-18 08:46:47 +02:00
|
|
|
|
LONGEST lastval = 0;
|
|
|
|
|
|
2014-03-27 19:24:27 +01:00
|
|
|
|
/* We can't handle this case perfectly, as DWARF does not
|
|
|
|
|
tell us whether or not the underlying type was specified
|
|
|
|
|
in the source (and other debug formats don't provide this
|
|
|
|
|
at all). We choose to print the underlying type, if it
|
|
|
|
|
has a name, when in C++ on the theory that it's better to
|
|
|
|
|
print too much than too little; but conversely not to
|
|
|
|
|
print something egregiously outside the current
|
|
|
|
|
language's syntax. */
|
2018-04-17 21:51:23 +02:00
|
|
|
|
if (language == language_cplus && TYPE_TARGET_TYPE (type) != NULL)
|
2014-03-27 19:24:27 +01:00
|
|
|
|
{
|
|
|
|
|
struct type *underlying = check_typedef (TYPE_TARGET_TYPE (type));
|
|
|
|
|
|
|
|
|
|
if (TYPE_NAME (underlying) != NULL)
|
|
|
|
|
fprintf_filtered (stream, ": %s ", TYPE_NAME (underlying));
|
|
|
|
|
}
|
|
|
|
|
|
1999-04-16 03:35:26 +02:00
|
|
|
|
fprintf_filtered (stream, "{");
|
|
|
|
|
len = TYPE_NFIELDS (type);
|
|
|
|
|
for (i = 0; i < len; i++)
|
|
|
|
|
{
|
|
|
|
|
QUIT;
|
1999-07-07 22:19:36 +02:00
|
|
|
|
if (i)
|
|
|
|
|
fprintf_filtered (stream, ", ");
|
1999-04-16 03:35:26 +02:00
|
|
|
|
wrap_here (" ");
|
|
|
|
|
fputs_filtered (TYPE_FIELD_NAME (type, i), stream);
|
2012-04-18 08:46:47 +02:00
|
|
|
|
if (lastval != TYPE_FIELD_ENUMVAL (type, i))
|
1999-04-16 03:35:26 +02:00
|
|
|
|
{
|
2012-04-18 08:46:47 +02:00
|
|
|
|
fprintf_filtered (stream, " = %s",
|
|
|
|
|
plongest (TYPE_FIELD_ENUMVAL (type, i)));
|
|
|
|
|
lastval = TYPE_FIELD_ENUMVAL (type, i);
|
1999-04-16 03:35:26 +02:00
|
|
|
|
}
|
|
|
|
|
lastval++;
|
|
|
|
|
}
|
|
|
|
|
fprintf_filtered (stream, "}");
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
|
2016-03-15 22:37:29 +01:00
|
|
|
|
case TYPE_CODE_FLAGS:
|
|
|
|
|
{
|
|
|
|
|
struct type_print_options local_flags = *flags;
|
|
|
|
|
|
|
|
|
|
local_flags.local_typedefs = NULL;
|
|
|
|
|
|
|
|
|
|
c_type_print_modifier (type, stream, 0, 1);
|
|
|
|
|
fprintf_filtered (stream, "flag ");
|
|
|
|
|
print_name_maybe_canonical (TYPE_NAME (type), flags, stream);
|
|
|
|
|
if (show > 0)
|
|
|
|
|
{
|
|
|
|
|
fputs_filtered (" ", stream);
|
|
|
|
|
fprintf_filtered (stream, "{\n");
|
|
|
|
|
if (TYPE_NFIELDS (type) == 0)
|
|
|
|
|
{
|
|
|
|
|
if (TYPE_STUB (type))
|
|
|
|
|
fprintfi_filtered (level + 4, stream,
|
|
|
|
|
_("<incomplete type>\n"));
|
|
|
|
|
else
|
|
|
|
|
fprintfi_filtered (level + 4, stream,
|
|
|
|
|
_("<no data fields>\n"));
|
|
|
|
|
}
|
|
|
|
|
len = TYPE_NFIELDS (type);
|
|
|
|
|
for (i = 0; i < len; i++)
|
|
|
|
|
{
|
|
|
|
|
QUIT;
|
|
|
|
|
print_spaces_filtered (level + 4, stream);
|
|
|
|
|
/* We pass "show" here and not "show - 1" to get enum types
|
|
|
|
|
printed. There's no other way to see them. */
|
Implement pahole-like 'ptype /o' option
This commit implements the pahole-like '/o' option for 'ptype', which
prints the offsets and sizes of struct fields, reporting whenever
there is a hole found.
The output is heavily based on pahole(1), with a few modifications
here and there to adjust it to our reality. Here's an example:
/* offset | size */ type = struct wer : public tuv {
public:
/* 32 | 24 */ struct tyu {
/* 32:31 | 4 */ int a1 : 1;
/* 32:28 | 4 */ int a2 : 3;
/* 32: 5 | 4 */ int a3 : 23;
/* 35: 3 | 1 */ char a4 : 2;
/* XXX 3-bit hole */
/* XXX 4-byte hole */
/* 40 | 8 */ int64_t a5;
/* 48:27 | 4 */ int a6 : 5;
/* 48:56 | 8 */ int64_t a7 : 3;
/* total size (bytes): 24 */
} a1;
/* total size (bytes): 56 */
}
A big part of this patch handles the formatting logic of 'ptype',
which is a bit messy. The code to handle bitfield offsets, however,
took some time to craft. My thanks to Pedro Alves for figuring things
out and pointing me to the right direction, as well as coming up with
a way to inspect the layout of structs with bitfields (see testcase
for comments).
After many discussions both on IRC and at the mailing list, I tried to
implement printing vtables and inherited classes. Unfortunately the
code grew too complex and there were still a few corner cases failing
so I had to drop the attempt. This should be implemented in a future
patch.
This patch is the start of a long-term work I'll do to flush the local
patches we carry for Fedora GDB. In this specific case, I'm aiming at
upstreaming the feature implemented by the 'pahole.py' script that is
shipped with Fedora GDB:
<https://src.fedoraproject.org/rpms/gdb/blob/master/f/gdb-archer.patch#_311>
This has been regression-tested on the BuildBot. There's a new
testcase for it, along with an update to the documentation. I also
thought it was worth mentioning this feature in the NEWS file.
gdb/ChangeLog:
2017-12-15 Sergio Durigan Junior <sergiodj@redhat.com>
Pedro Alves <palves@redhat.com>
PR cli/16224
* NEWS (Changes since GDB 8.0): Mention new '/o' flag.
* c-typeprint.c (OFFSET_SPC_LEN): New define.
(c_type_print_varspec_prefix): New argument 'struct
print_offset_data *'.
(c_type_print_base_1): New function and prototype.
(c_print_type_1): New function, with code from 'c_print_type'.
(c_print_type): Use 'c_print_type_1'.
(c_type_print_varspec_prefix): New argument 'struct
print_offset_data *'. Use it. Call 'c_type_print_base_1'
instead of 'c_print_type_base'.
(print_spaces_filtered_with_print_options): New function.
(output_access_specifier): Take new argument FLAGS. Modify
function to call 'print_spaces_filtered_with_print_options'.
(c_print_type_vtable_offset_marker): New function.
(c_print_type_union_field_offset): New function.
(c_print_type_struct_field_offset): New function.
(c_print_type_no_offsets): New function.
(c_type_print_base_struct_union): New argument 'struct
print_offset_data *'. Print offsets and sizes for
struct/union/class fields.
* typeprint.c (const struct type_print_options
type_print_raw_options): Initialize 'print_offsets'.
(static struct type_print_options default_ptype_flags):
Likewise.
(struct print_offset_data print_offset_default_data): New
variable.
(whatis_exp): Handle '/o' option.
(_initialize_typeprint): Add '/o' flag to ptype's help.
* typeprint.h (struct print_offset_data): New struct.
(struct type_print_options) <print_offsets>: New field.
gdb/testsuite/ChangeLog:
2017-12-15 Sergio Durigan Junior <sergiodj@redhat.com>
PR cli/16224
* gdb.base/ptype-offsets.cc: New file.
* gdb.base/ptype-offsets.exp: New file.
gdb/doc/ChangeLog:
2017-12-15 Sergio Durigan Junior <sergiodj@redhat.com>
PR cli/16224
* gdb.texinfo (ptype): Add documentation for new flag '/o'.
2017-11-20 22:34:59 +01:00
|
|
|
|
c_print_type_1 (TYPE_FIELD_TYPE (type, i),
|
|
|
|
|
TYPE_FIELD_NAME (type, i),
|
|
|
|
|
stream, show, level + 4,
|
2018-04-17 21:51:23 +02:00
|
|
|
|
language, &local_flags, podata);
|
2016-04-12 21:02:57 +02:00
|
|
|
|
fprintf_filtered (stream, " @%s",
|
|
|
|
|
plongest (TYPE_FIELD_BITPOS (type, i)));
|
2016-03-15 22:37:29 +01:00
|
|
|
|
if (TYPE_FIELD_BITSIZE (type, i) > 1)
|
|
|
|
|
{
|
2016-04-12 21:02:57 +02:00
|
|
|
|
fprintf_filtered (stream, "-%s",
|
|
|
|
|
plongest (TYPE_FIELD_BITPOS (type, i)
|
|
|
|
|
+ TYPE_FIELD_BITSIZE (type, i)
|
|
|
|
|
- 1));
|
2016-03-15 22:37:29 +01:00
|
|
|
|
}
|
|
|
|
|
fprintf_filtered (stream, ";\n");
|
|
|
|
|
}
|
|
|
|
|
fprintfi_filtered (level, stream, "}");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
|
1999-04-16 03:35:26 +02:00
|
|
|
|
case TYPE_CODE_VOID:
|
|
|
|
|
fprintf_filtered (stream, "void");
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case TYPE_CODE_UNDEF:
|
2005-01-29 Baurzhan Ismagulov <ibr@radix50.net>
* ax-gdb.c, ax-general.c, bcache.c, bfd-target.c, bsd-kvm.c,
* buildsym.c, c-lang.c, c-typeprint.c, c-valprint.c, charset.c,
* coff-pe-read.c, coffread.c, complaints.c, copying.c: I18n markup.
2005-01-29 18:53:26 +01:00
|
|
|
|
fprintf_filtered (stream, _("struct <unknown>"));
|
1999-04-16 03:35:26 +02:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case TYPE_CODE_ERROR:
|
2010-06-21 20:01:51 +02:00
|
|
|
|
fprintf_filtered (stream, "%s", TYPE_ERROR_NAME (type));
|
1999-04-16 03:35:26 +02:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case TYPE_CODE_RANGE:
|
2011-01-07 20:36:19 +01:00
|
|
|
|
/* This should not occur. */
|
2005-01-29 Baurzhan Ismagulov <ibr@radix50.net>
* ax-gdb.c, ax-general.c, bcache.c, bfd-target.c, bsd-kvm.c,
* buildsym.c, c-lang.c, c-typeprint.c, c-valprint.c, charset.c,
* coff-pe-read.c, coffread.c, complaints.c, copying.c: I18n markup.
2005-01-29 18:53:26 +01:00
|
|
|
|
fprintf_filtered (stream, _("<range type>"));
|
1999-04-16 03:35:26 +02:00
|
|
|
|
break;
|
|
|
|
|
|
2003-09-11 David Carlton <carlton@kealia.com>
* gdbtypes.h: Add TYPE_CODE_NAMESPACE.
* gdbtypes.c (init_type): Handle TYPE_CODE_NAMESPACE.
(recursive_dump_type): Ditto.
* printcmd.c (print_formatted): Ditto.
* typeprint.c (print_type_scalar): Ditto.
* c-typeprint.c (c_type_print_varspec_prefix): Ditto.
(c_type_print_varspec_suffix, c_type_print_base): Ditto.
* cp-support.h: Declare cp_check_possible_namespace_symbols,
maint_cplus_cmd_list.
* cp-support.c: Make maint_cplus_cmd_list extern.
* cp-namespace.c: Include objfiles.h, gdbtypes.h, dictionary.h,
command.h.
(lookup_symbol_file): Look in possible namespace blocks when
appropriate.
(initialize_namespace_symtab): New.
(get_possible_namespace_block, free_namespace_block)
(check_possible_namespace_symbols)
(check_possible_namespace_symbols_loop)
(check_one_possible_namespace_symbol)
(lookup_possible_namespace_symbol, maintenance_cplus_namespace)
(_initialize_cp_namespace): Ditto.
* block.h: Declare allocate_block.
* block.c (allocate_block): New.
* jv-lang.c (get_java_class_symtab): Allocate blocks via
allocate_block.
* symfile.h: Update declaration of add_psymbol_to_list.
* symfile.c (add_psymbol_to_list): Return the partial symbol in
question.
* dwarf2read.c (dwarf2_build_psymtabs_hard): Add argument to
scan_partial_symbols_call.
(scan_partial_symbols): Add NAMESPACE argument; update calls to
helper functions.
(add_partial_symbol): If necessary, scan mangled names for names
of namespaces.
(add_partial_namespace): Add NAMESPACE argument; generate partial
symbols associated to namespaces.
(add_partial_enumeration): Add NAMESPACE argument.
(new_symbol): Allow namespace syms.
(read_namespace): Generate namespace syms.
* objfiles.h: Add opaque declaration of struct symtab.
(struct objfile): Add cp_namespace_symtab member.
* objfiles.c (allocate_objfile): Set
objfile->cp_namespace_symtab.
* Makefile.in (cp-namespace.o): Depend on objfiles_h, gdbtypes_h,
dictionary_h, command_h.
2003-09-11 David Carlton <carlton@kealia.com>
* gdb.c++/namespace.exp: Add tests for namespace types.
* gdb.c++/maint.exp (test_help): Test 'help maint cp namespace'.
(test_namespace): New.
2003-09-11 21:49:20 +02:00
|
|
|
|
case TYPE_CODE_NAMESPACE:
|
|
|
|
|
fputs_filtered ("namespace ", stream);
|
Remove TYPE_TAG_NAME
TYPE_TAG_NAME has been an occasional source of confusion and bugs. It
seems to me that it is only useful for C and C++ -- but even there,
not so much, because at least with DWARF there doesn't seem to be any
way to wind up with a type where the name and the tag name are both
non-NULL and different.
So, this patch removes TYPE_TAG_NAME entirely. This should save a
little memory, but more importantly, it simplifies this part of gdb.
A few minor test suite adjustments were needed. In some situations
the new code does not yield identical output to the old code.
gdb/ChangeLog
2018-06-01 Tom Tromey <tom@tromey.com>
* valops.c (enum_constant_from_type, value_namespace_elt)
(value_maybe_namespace_elt): Update.
* valarith.c (find_size_for_pointer_math): Update.
* target-descriptions.c (make_gdb_type): Update.
* symmisc.c (print_symbol): Update.
* stabsread.c (define_symbol, read_type)
(complain_about_struct_wipeout, add_undefined_type)
(cleanup_undefined_types_1): Update.
* rust-lang.c (rust_tuple_type_p, rust_slice_type_p)
(rust_range_type_p, val_print_struct, rust_print_struct_def)
(rust_internal_print_type, rust_composite_type)
(rust_evaluate_funcall, rust_evaluate_subexp)
(rust_inclusive_range_type_p): Update.
* python/py-type.c (typy_get_tag): Update.
* p-typeprint.c (pascal_type_print_base): Update.
* mdebugread.c (parse_symbol, parse_type): Update.
* m2-typeprint.c (m2_long_set, m2_record_fields, m2_enum):
Update.
* guile/scm-type.c (gdbscm_type_tag): Update.
* go-lang.c (sixg_string_p): Update.
* gnu-v3-abi.c (build_gdb_vtable_type, build_std_type_info_type):
Update.
* gdbtypes.h (struct main_type) <tag_name>: Remove.
(TYPE_TAG_NAME): Remove.
* gdbtypes.c (type_name_no_tag): Simplify.
(check_typedef, check_types_equal, recursive_dump_type)
(copy_type_recursive, arch_composite_type): Update.
* f-typeprint.c (f_type_print_base): Update. Print "Type" prefix
in summary mode when needed.
* eval.c (evaluate_funcall): Update.
* dwarf2read.c (fixup_go_packaging, read_structure_type)
(process_structure_scope, read_enumeration_type)
(read_namespace_type, read_module_type, determine_prefix): Update.
* cp-support.c (inspect_type): Update.
* coffread.c (process_coff_symbol, decode_base_type): Update.
* c-varobj.c (c_is_path_expr_parent): Update.
* c-typeprint.c (c_type_print_base_struct_union): Update.
(c_type_print_base_1): Update. Print struct/class/union/enum in
summary when using C language.
* ax-gdb.c (gen_struct_ref, gen_namespace_elt)
(gen_maybe_namespace_elt): Update.
* ada-lang.c (ada_type_name): Simplify.
(empty_record, ada_template_to_fixed_record_type_1)
(template_to_static_fixed_type)
(to_record_with_fixed_variant_part, ada_check_typedef): Update.
gdb/testsuite/ChangeLog
2018-06-01 Tom Tromey <tom@tromey.com>
* gdb.xml/tdesc-regs.exp (load_description): Update expected
results.
* gdb.dwarf2/method-ptr.exp: Set language to C++.
* gdb.dwarf2/member-ptr-forwardref.exp: Set language to C++.
* gdb.cp/typeid.exp (do_typeid_tests): Update type_re.
* gdb.base/maint.exp (maint_pass_if): Update.
2018-04-17 21:51:24 +02:00
|
|
|
|
fputs_filtered (TYPE_NAME (type), stream);
|
2003-09-11 David Carlton <carlton@kealia.com>
* gdbtypes.h: Add TYPE_CODE_NAMESPACE.
* gdbtypes.c (init_type): Handle TYPE_CODE_NAMESPACE.
(recursive_dump_type): Ditto.
* printcmd.c (print_formatted): Ditto.
* typeprint.c (print_type_scalar): Ditto.
* c-typeprint.c (c_type_print_varspec_prefix): Ditto.
(c_type_print_varspec_suffix, c_type_print_base): Ditto.
* cp-support.h: Declare cp_check_possible_namespace_symbols,
maint_cplus_cmd_list.
* cp-support.c: Make maint_cplus_cmd_list extern.
* cp-namespace.c: Include objfiles.h, gdbtypes.h, dictionary.h,
command.h.
(lookup_symbol_file): Look in possible namespace blocks when
appropriate.
(initialize_namespace_symtab): New.
(get_possible_namespace_block, free_namespace_block)
(check_possible_namespace_symbols)
(check_possible_namespace_symbols_loop)
(check_one_possible_namespace_symbol)
(lookup_possible_namespace_symbol, maintenance_cplus_namespace)
(_initialize_cp_namespace): Ditto.
* block.h: Declare allocate_block.
* block.c (allocate_block): New.
* jv-lang.c (get_java_class_symtab): Allocate blocks via
allocate_block.
* symfile.h: Update declaration of add_psymbol_to_list.
* symfile.c (add_psymbol_to_list): Return the partial symbol in
question.
* dwarf2read.c (dwarf2_build_psymtabs_hard): Add argument to
scan_partial_symbols_call.
(scan_partial_symbols): Add NAMESPACE argument; update calls to
helper functions.
(add_partial_symbol): If necessary, scan mangled names for names
of namespaces.
(add_partial_namespace): Add NAMESPACE argument; generate partial
symbols associated to namespaces.
(add_partial_enumeration): Add NAMESPACE argument.
(new_symbol): Allow namespace syms.
(read_namespace): Generate namespace syms.
* objfiles.h: Add opaque declaration of struct symtab.
(struct objfile): Add cp_namespace_symtab member.
* objfiles.c (allocate_objfile): Set
objfile->cp_namespace_symtab.
* Makefile.in (cp-namespace.o): Depend on objfiles_h, gdbtypes_h,
dictionary_h, command_h.
2003-09-11 David Carlton <carlton@kealia.com>
* gdb.c++/namespace.exp: Add tests for namespace types.
* gdb.c++/maint.exp (test_help): Test 'help maint cp namespace'.
(test_namespace): New.
2003-09-11 21:49:20 +02:00
|
|
|
|
break;
|
|
|
|
|
|
1999-04-16 03:35:26 +02:00
|
|
|
|
default:
|
2010-12-31 23:59:52 +01:00
|
|
|
|
/* Handle types not explicitly handled by the other cases, such
|
|
|
|
|
as fundamental types. For these, just print whatever the
|
|
|
|
|
type name is, as recorded in the type itself. If there is no
|
|
|
|
|
type name, then complain. */
|
1999-04-16 03:35:26 +02:00
|
|
|
|
if (TYPE_NAME (type) != NULL)
|
|
|
|
|
{
|
2001-11-15 02:55:59 +01:00
|
|
|
|
c_type_print_modifier (type, stream, 0, 1);
|
* c-typeprint.c (find_typedef_for_canonicalize,
print_name_maybe_canonical): New functions.
(c_print_type): Look up type name.
(cp_type_print_derivation_info): Add flags argument. Use
print_name_maybe_canonical.
(cp_type_print_method_args): Add wrapping.
(c_type_print_varspec_prefix): Use print_name_maybe_canonical.
(c_type_print_template_args): New function.
(c_type_print_base): Change wrapping. Use
print_name_maybe_canonical.
<TYPE_CODE_STRUCT>: Possibly create a typedef hash, and do
type name lookups.
* gdbtypes.c (types_equal): No longer static.
* gdbtypes.h (types_equal): Declare.
* typeprint.c (type_print_raw_options, default_ptype_flags):
Update.
(struct typedef_hash_table): New.
(hash_typedef_field, eq_typedef_field,
recursively_update_typedef_hash, add_template_parameters,
create_typedef_hash, free_typedef_hash, do_free_typedef_hash,
make_cleanup_free_typedef_hash, copy_typedef_hash_element,
copy_typedef_hash, find_typedef_in_hash): New functions.
* typeprint.h (struct type_print_options) <local_typedefs>:
New field.
(recursively_update_typedef_hash, add_template_parameters,
create_typedef_hash, free_typedef_hash,
make_cleanup_free_typedef_hash, copy_typedef_hash,
find_typedef_in_hash): Declare.
testsuite
* gdb.base/call-sc.exp: Use "ptype/r".
* gdb.base/volatile.exp: Don't expect "int".
* gdb.cp/ptype-flags.cc: New file.
* gdb.cp/ptype-flags.exp: New file.
* gdb.cp/templates.exp: Use ptype/r.
(test_ptype_of_templates, test_template_typedef): Likewise.
* lib/cp-support.exp (cp_test_ptype_class): Add in_ptype_arg
argument. Handle template names and template parameters.
* gdb.mi/mi-var-cmd.exp: Accept "long".
* gdb.mi/mi-var-child.exp: Accept "long".
* gdb.mi/mi-var-display.exp: Accept "long".
* gdb.mi/mi2-var-child.exp: Accept "long".
2012-11-12 18:37:38 +01:00
|
|
|
|
print_name_maybe_canonical (TYPE_NAME (type), flags, stream);
|
1999-04-16 03:35:26 +02:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2010-12-31 23:59:52 +01:00
|
|
|
|
/* At least for dump_symtab, it is important that this not
|
|
|
|
|
be an error (). */
|
2005-01-29 Baurzhan Ismagulov <ibr@radix50.net>
* ax-gdb.c, ax-general.c, bcache.c, bfd-target.c, bsd-kvm.c,
* buildsym.c, c-lang.c, c-typeprint.c, c-valprint.c, charset.c,
* coff-pe-read.c, coffread.c, complaints.c, copying.c: I18n markup.
2005-01-29 18:53:26 +01:00
|
|
|
|
fprintf_filtered (stream, _("<invalid type code %d>"),
|
1999-04-16 03:35:26 +02:00
|
|
|
|
TYPE_CODE (type));
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
Implement pahole-like 'ptype /o' option
This commit implements the pahole-like '/o' option for 'ptype', which
prints the offsets and sizes of struct fields, reporting whenever
there is a hole found.
The output is heavily based on pahole(1), with a few modifications
here and there to adjust it to our reality. Here's an example:
/* offset | size */ type = struct wer : public tuv {
public:
/* 32 | 24 */ struct tyu {
/* 32:31 | 4 */ int a1 : 1;
/* 32:28 | 4 */ int a2 : 3;
/* 32: 5 | 4 */ int a3 : 23;
/* 35: 3 | 1 */ char a4 : 2;
/* XXX 3-bit hole */
/* XXX 4-byte hole */
/* 40 | 8 */ int64_t a5;
/* 48:27 | 4 */ int a6 : 5;
/* 48:56 | 8 */ int64_t a7 : 3;
/* total size (bytes): 24 */
} a1;
/* total size (bytes): 56 */
}
A big part of this patch handles the formatting logic of 'ptype',
which is a bit messy. The code to handle bitfield offsets, however,
took some time to craft. My thanks to Pedro Alves for figuring things
out and pointing me to the right direction, as well as coming up with
a way to inspect the layout of structs with bitfields (see testcase
for comments).
After many discussions both on IRC and at the mailing list, I tried to
implement printing vtables and inherited classes. Unfortunately the
code grew too complex and there were still a few corner cases failing
so I had to drop the attempt. This should be implemented in a future
patch.
This patch is the start of a long-term work I'll do to flush the local
patches we carry for Fedora GDB. In this specific case, I'm aiming at
upstreaming the feature implemented by the 'pahole.py' script that is
shipped with Fedora GDB:
<https://src.fedoraproject.org/rpms/gdb/blob/master/f/gdb-archer.patch#_311>
This has been regression-tested on the BuildBot. There's a new
testcase for it, along with an update to the documentation. I also
thought it was worth mentioning this feature in the NEWS file.
gdb/ChangeLog:
2017-12-15 Sergio Durigan Junior <sergiodj@redhat.com>
Pedro Alves <palves@redhat.com>
PR cli/16224
* NEWS (Changes since GDB 8.0): Mention new '/o' flag.
* c-typeprint.c (OFFSET_SPC_LEN): New define.
(c_type_print_varspec_prefix): New argument 'struct
print_offset_data *'.
(c_type_print_base_1): New function and prototype.
(c_print_type_1): New function, with code from 'c_print_type'.
(c_print_type): Use 'c_print_type_1'.
(c_type_print_varspec_prefix): New argument 'struct
print_offset_data *'. Use it. Call 'c_type_print_base_1'
instead of 'c_print_type_base'.
(print_spaces_filtered_with_print_options): New function.
(output_access_specifier): Take new argument FLAGS. Modify
function to call 'print_spaces_filtered_with_print_options'.
(c_print_type_vtable_offset_marker): New function.
(c_print_type_union_field_offset): New function.
(c_print_type_struct_field_offset): New function.
(c_print_type_no_offsets): New function.
(c_type_print_base_struct_union): New argument 'struct
print_offset_data *'. Print offsets and sizes for
struct/union/class fields.
* typeprint.c (const struct type_print_options
type_print_raw_options): Initialize 'print_offsets'.
(static struct type_print_options default_ptype_flags):
Likewise.
(struct print_offset_data print_offset_default_data): New
variable.
(whatis_exp): Handle '/o' option.
(_initialize_typeprint): Add '/o' flag to ptype's help.
* typeprint.h (struct print_offset_data): New struct.
(struct type_print_options) <print_offsets>: New field.
gdb/testsuite/ChangeLog:
2017-12-15 Sergio Durigan Junior <sergiodj@redhat.com>
PR cli/16224
* gdb.base/ptype-offsets.cc: New file.
* gdb.base/ptype-offsets.exp: New file.
gdb/doc/ChangeLog:
2017-12-15 Sergio Durigan Junior <sergiodj@redhat.com>
PR cli/16224
* gdb.texinfo (ptype): Add documentation for new flag '/o'.
2017-11-20 22:34:59 +01:00
|
|
|
|
|
|
|
|
|
/* See c_type_print_base_1. */
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
c_type_print_base (struct type *type, struct ui_file *stream,
|
|
|
|
|
int show, int level,
|
|
|
|
|
const struct type_print_options *flags)
|
|
|
|
|
{
|
|
|
|
|
struct print_offset_data podata;
|
|
|
|
|
|
2018-04-17 21:51:23 +02:00
|
|
|
|
c_type_print_base_1 (type, stream, show, level,
|
|
|
|
|
current_language->la_language, flags, &podata);
|
Implement pahole-like 'ptype /o' option
This commit implements the pahole-like '/o' option for 'ptype', which
prints the offsets and sizes of struct fields, reporting whenever
there is a hole found.
The output is heavily based on pahole(1), with a few modifications
here and there to adjust it to our reality. Here's an example:
/* offset | size */ type = struct wer : public tuv {
public:
/* 32 | 24 */ struct tyu {
/* 32:31 | 4 */ int a1 : 1;
/* 32:28 | 4 */ int a2 : 3;
/* 32: 5 | 4 */ int a3 : 23;
/* 35: 3 | 1 */ char a4 : 2;
/* XXX 3-bit hole */
/* XXX 4-byte hole */
/* 40 | 8 */ int64_t a5;
/* 48:27 | 4 */ int a6 : 5;
/* 48:56 | 8 */ int64_t a7 : 3;
/* total size (bytes): 24 */
} a1;
/* total size (bytes): 56 */
}
A big part of this patch handles the formatting logic of 'ptype',
which is a bit messy. The code to handle bitfield offsets, however,
took some time to craft. My thanks to Pedro Alves for figuring things
out and pointing me to the right direction, as well as coming up with
a way to inspect the layout of structs with bitfields (see testcase
for comments).
After many discussions both on IRC and at the mailing list, I tried to
implement printing vtables and inherited classes. Unfortunately the
code grew too complex and there were still a few corner cases failing
so I had to drop the attempt. This should be implemented in a future
patch.
This patch is the start of a long-term work I'll do to flush the local
patches we carry for Fedora GDB. In this specific case, I'm aiming at
upstreaming the feature implemented by the 'pahole.py' script that is
shipped with Fedora GDB:
<https://src.fedoraproject.org/rpms/gdb/blob/master/f/gdb-archer.patch#_311>
This has been regression-tested on the BuildBot. There's a new
testcase for it, along with an update to the documentation. I also
thought it was worth mentioning this feature in the NEWS file.
gdb/ChangeLog:
2017-12-15 Sergio Durigan Junior <sergiodj@redhat.com>
Pedro Alves <palves@redhat.com>
PR cli/16224
* NEWS (Changes since GDB 8.0): Mention new '/o' flag.
* c-typeprint.c (OFFSET_SPC_LEN): New define.
(c_type_print_varspec_prefix): New argument 'struct
print_offset_data *'.
(c_type_print_base_1): New function and prototype.
(c_print_type_1): New function, with code from 'c_print_type'.
(c_print_type): Use 'c_print_type_1'.
(c_type_print_varspec_prefix): New argument 'struct
print_offset_data *'. Use it. Call 'c_type_print_base_1'
instead of 'c_print_type_base'.
(print_spaces_filtered_with_print_options): New function.
(output_access_specifier): Take new argument FLAGS. Modify
function to call 'print_spaces_filtered_with_print_options'.
(c_print_type_vtable_offset_marker): New function.
(c_print_type_union_field_offset): New function.
(c_print_type_struct_field_offset): New function.
(c_print_type_no_offsets): New function.
(c_type_print_base_struct_union): New argument 'struct
print_offset_data *'. Print offsets and sizes for
struct/union/class fields.
* typeprint.c (const struct type_print_options
type_print_raw_options): Initialize 'print_offsets'.
(static struct type_print_options default_ptype_flags):
Likewise.
(struct print_offset_data print_offset_default_data): New
variable.
(whatis_exp): Handle '/o' option.
(_initialize_typeprint): Add '/o' flag to ptype's help.
* typeprint.h (struct print_offset_data): New struct.
(struct type_print_options) <print_offsets>: New field.
gdb/testsuite/ChangeLog:
2017-12-15 Sergio Durigan Junior <sergiodj@redhat.com>
PR cli/16224
* gdb.base/ptype-offsets.cc: New file.
* gdb.base/ptype-offsets.exp: New file.
gdb/doc/ChangeLog:
2017-12-15 Sergio Durigan Junior <sergiodj@redhat.com>
PR cli/16224
* gdb.texinfo (ptype): Add documentation for new flag '/o'.
2017-11-20 22:34:59 +01:00
|
|
|
|
}
|