21#include "gdbsupport/gdb_obstack.h"
103 unsigned int hole_byte = hole / TARGET_CHAR_BIT;
104 unsigned int hole_bit = hole % TARGET_CHAR_BIT;
109 "/* XXX %2u-bit %-7s */", hole_bit, for_what);
116 "/* XXX %2u-byte %-7s */", hole_byte, for_what);
135 if (
type->
code () == TYPE_CODE_UNION)
141 hex_string_custom (ftype->
length (), 4) :
142 pulongest (ftype->
length ())));
147 unsigned int fieldsize_byte = ftype->
length ();
148 unsigned int fieldsize_bit = fieldsize_byte * TARGET_CHAR_BIT;
162 real_bitpos / TARGET_CHAR_BIT,
163 real_bitpos % TARGET_CHAR_BIT);
187 unsigned int bitpos =
type->
length () * TARGET_CHAR_BIT;
192 gdb_printf (stream,
"/* total size (bytes): %4s */\n",
231 slot = htab_find_slot (
m_table.get (), tdef, INSERT);
264 slot = htab_find_slot (
m_table.get (), tf, INSERT);
283 htab_t new_table = (htab_t) nt;
286 new_slot = htab_find_slot (new_table, *slot, INSERT);
287 if (*new_slot == NULL)
315 if (
flags->global_typedefs == NULL)
321 slot = htab_find_slot (
flags->global_typedefs->m_table.get (), &tf, INSERT);
330 new_tf = XOBNEW (&
flags->global_typedefs->m_storage,
struct decl_field);
336 gdb::unique_xmalloc_ptr<char> applied
339 if (applied !=
nullptr)
340 new_tf->
name = obstack_strdup (&
flags->global_typedefs->m_storage,
352 if (
flags->local_typedefs != NULL)
358 htab_t table =
flags->local_typedefs->m_table.get ();
359 found = (
struct decl_field *) htab_find (table, &tf);
408 catch (
const gdb_exception &except)
421 _(
"<unknown return type>"));
429 error (_(
"'%s' has unknown type; cast it to its declared type"),
440 struct type *real_type = NULL;
454 for (++exp; *exp && !isspace (*exp); ++exp)
462 flags.print_methods = 0;
465 flags.print_methods = 1;
468 flags.print_typedefs = 0;
471 flags.print_typedefs = 1;
480 flags.print_offsets = 1;
481 flags.print_typedefs = 0;
482 flags.print_methods = 0;
487 flags.print_in_hex = 1;
490 flags.print_in_hex = 0;
493 error (_(
"unrecognized flag '%c'"), *exp);
498 if (!*exp && !seen_one)
499 error (_(
"flag expected"));
501 error (_(
"expected space after format"));
502 exp = skip_spaces (exp);
514 val =
expr->evaluate_type ();
517 if (show == -1 &&
expr->first_opcode () == OP_TYPE)
525 if (
type->
code () == TYPE_CODE_TYPEDEF)
541 warning (_(
"ptype/o does not work with dynamic types; disabling '/o'"));
542 flags.print_offsets = 0;
546 if (val != NULL && opts.objectprint)
551 else if (
type->
code () == TYPE_CODE_STRUCT)
555 if (
flags.print_offsets
556 && (
type->
code () == TYPE_CODE_STRUCT
557 ||
type->
code () == TYPE_CODE_UNION))
562 std::unique_ptr<typedef_hash_table> table_holder;
563 std::unique_ptr<ext_lang_type_printers> printer_holder;
567 flags.global_typedefs = table_holder.get ();
570 flags.global_printers = printer_holder.get ();
628 for (i = 0; i < len; i++)
657 case TYPE_CODE_RANGE:
661 case TYPE_CODE_FIXED_POINT:
667 case TYPE_CODE_ARRAY:
668 case TYPE_CODE_STRUCT:
669 case TYPE_CODE_UNION:
674 case TYPE_CODE_STRING:
675 case TYPE_CODE_ERROR:
676 case TYPE_CODE_MEMBERPTR:
677 case TYPE_CODE_METHODPTR:
678 case TYPE_CODE_METHOD:
680 case TYPE_CODE_RVALUE_REF:
681 case TYPE_CODE_NAMESPACE:
682 error (_(
"internal error: unhandled type in print_type_scalar"));
686 error (_(
"Invalid type code in symbol table."));
697 gdb_printf (stream,
"%s-byte fixed point (small = %s)",
698 pulongest (
type->
length ()), small_img.c_str ());
708 if (type_name != NULL)
711 struct value *val =
expr->evaluate_type ();
737 gdb_printf (file, _(
"Printing of methods defined in a class in %s\n"),
754 gdb_printf (file, _(
"Printing of typedefs defined in a class in %s\n"),
783 _(
"Will not print nested types defined in a class\n"));
788 _(
"Will print %s nested types defined in a class\n"),
818Display of struct members offsets and sizes in hexadecimal is %s\n"),
829Print definition of type TYPE.\n\
830Usage: ptype[/FLAGS] TYPE | EXPRESSION\n\
831Argument may be any type (for example a type name defined by typedef,\n\
832or \"struct STRUCT-TAG\" or \"class CLASS-NAME\" or \"union UNION-TAG\"\n\
833or \"enum ENUM-TAG\") or an expression.\n\
834The selected stack frame's lexical context is used to look up the name.\n\
835Contrary to \"whatis\", \"ptype\" always unrolls any typedefs.\n\
837Available FLAGS are:\n\
838 /r print in \"raw\" form; do not substitute typedefs\n\
839 /m do not print methods defined in a class\n\
840 /M print methods defined in a class\n\
841 /t do not print typedefs defined in a class\n\
842 /T print typedefs defined in a class\n\
843 /o print offsets and sizes of fields in a struct (like pahole)\n\
844 /x use hexadecimal notation when displaying sizes and offsets\n\
846 /d use decimal notation when displaying sizes and offsets\n\
847 of struct members "));
851 _(
"Print data type of expression EXP.\n\
852Only one level of typedefs is unrolled. See also \"ptype\"."));
856 _(
"Generic command for showing type-printing settings."),
857 _(
"Generic command for setting how types print."),
863Set printing of methods defined in classes."), _(
"\
864Show printing of methods defined in classes."), NULL,
870Set printing of typedefs defined in classes."), _(
"\
871Show printing of typedefs defined in classes."), NULL,
879Set the number of recursive nested type definitions to print \
880(\"unlimited\" or -1 to show all)."), _(
"\
881Show the number of recursive nested type definitions to print."), NULL,
888Set printing of struct members sizes and offsets using hex notation."), _(
"\
889Show whether sizes and offsets of struct members are printed using hex \
void * xcalloc(size_t number, size_t size)
ui_file_style style() const
void add_template_parameters(struct type *t)
static const char * find_global_typedef(const struct type_print_options *flags, struct type *t)
static const char * find_typedef(const struct type_print_options *flags, struct type *t)
void recursively_update(struct type *)
struct cmd_list_element * showprintlist
struct cmd_list_element * setprintlist
void set_cmd_completer(struct cmd_list_element *cmd, completer_ftype *completer)
struct cmd_list_element * add_com(const char *name, enum command_class theclass, cmd_simple_func_ftype *fun, const char *doc)
set_show_commands add_setshow_zuinteger_unlimited_cmd(const char *name, enum command_class theclass, int *var, const char *set_doc, const char *show_doc, const char *help_doc, cmd_func_ftype *set_func, show_value_ftype *show_func, struct cmd_list_element **set_list, struct cmd_list_element **show_list)
set_show_commands add_setshow_prefix_cmd(const char *name, command_class theclass, const char *set_doc, const char *show_doc, cmd_list_element **set_subcommands_list, cmd_list_element **show_subcommands_list, cmd_list_element **set_list, cmd_list_element **show_list)
set_show_commands add_setshow_boolean_cmd(const char *name, enum command_class theclass, bool *var, const char *set_doc, const char *show_doc, const char *help_doc, cmd_func_ftype *set_func, show_value_ftype *show_func, struct cmd_list_element **set_list, struct cmd_list_element **show_list)
cli_style_option highlight_style
cli_style_option metadata_style
void expression_completer(struct cmd_list_element *ignore, completion_tracker &tracker, const char *text, const char *word)
struct type * value_rtti_type(struct value *v, int *full, LONGEST *top, int *using_enc)
std::unique_ptr< expression > expression_up
expression_up parse_expression(const char *, innermost_block_tracker *=nullptr, parser_flags flags=0)
gdb::unique_xmalloc_ptr< char > apply_ext_lang_type_printers(struct ext_lang_type_printers *printers, struct type *type)
int is_dynamic_type(struct type *type)
bool types_equal(struct type *a, struct type *b)
void recursive_dump_type(struct type *type, int spaces)
struct type * check_typedef(struct type *type)
#define TYPE_SAFE_NAME(type)
#define TYPE_BASECLASS(thistype, index)
#define TYPE_N_TEMPLATE_ARGUMENTS(thistype)
#define TYPE_TEMPLATE_ARGUMENT(thistype, n)
#define TYPE_TYPEDEF_FIELD(thistype, n)
#define TYPE_TYPEDEF_FIELD_COUNT(thistype)
#define TYPE_N_BASECLASSES(thistype)
mach_port_t kern_return_t mach_port_t mach_msg_type_name_t msgportsPoly mach_port_t kern_return_t pid_t pid mach_port_t kern_return_t mach_port_t task mach_port_t kern_return_t int flags
const struct language_defn * current_language
LONGEST loc_bitpos() const
LONGEST loc_enumval() const
const char * name() const
unsigned int bitsize() const
struct type * type() const
virtual bool can_print_type_offsets() const
virtual void print_type(struct type *type, const char *varstring, struct ui_file *stream, int show, int level, const struct type_print_options *flags) const =0
virtual void printchar(int ch, struct type *chtype, struct ui_file *stream) const
virtual void print_typedef(struct type *type, struct symbol *new_symbol, struct ui_file *stream) const
void update(struct type *type, unsigned int field_idx, struct ui_file *stream)
static const int indentation
void finish(struct type *type, int level, struct ui_file *stream)
unsigned int offset_bitpos
print_offset_data(const struct type_print_options *flags)
void maybe_print_hole(struct ui_file *stream, unsigned int bitpos, const char *for_what)
unsigned int print_in_hex
unsigned int print_methods
unsigned int print_typedefs
int print_nested_type_limit
struct type * target_type() const
struct field & field(int idx) const
unsigned int num_fields() const
const gdb_mpq & fixed_point_scaling_factor()
bool is_pointer_or_reference() const
struct type * type() const
static void set_print_offsets_and_sizes_in_hex(const char *args, int from_tty, struct cmd_list_element *c)
static struct type_print_options default_ptype_flags
void val_print_not_allocated(struct ui_file *stream)
void print_type_fixed_point(struct type *type, struct ui_file *stream)
static int eq_typedef_field(const void *a, const void *b)
void maintenance_print_type(const char *type_name, int from_tty)
struct cmd_list_element * showprinttypelist
void print_type_scalar(struct type *type, LONGEST val, struct ui_file *stream)
static void show_print_type_methods(struct ui_file *file, int from_tty, struct cmd_list_element *c, const char *value)
static void set_print_type_typedefs(const char *args, int from_tty, struct cmd_list_element *c)
static void set_print_type_nested_types(const char *args, int from_tty, struct cmd_list_element *c)
static int copy_typedef_hash_element(void **slot, void *nt)
const struct type_print_options type_print_raw_options
static void whatis_command(const char *exp, int from_tty)
std::string type_to_string(struct type *type)
static void show_print_type_nested_types(struct ui_file *file, int from_tty, struct cmd_list_element *c, const char *value)
static void ptype_command(const char *type_name, int from_tty)
static bool print_offsets_and_sizes_in_hex
static void whatis_exp(const char *exp, int show)
static void show_print_offsets_and_sizes_in_hex(struct ui_file *file, int from_tty, struct cmd_list_element *c, const char *value)
void val_print_not_associated(struct ui_file *stream)
static hashval_t hash_typedef_field(const void *p)
static bool print_typedefs
static int print_nested_type_limit
static void show_print_type_typedefs(struct ui_file *file, int from_tty, struct cmd_list_element *c, const char *value)
void type_print(struct type *type, const char *varstring, struct ui_file *stream, int show)
void _initialize_typeprint()
void error_unknown_type(const char *sym_print_name)
static bool print_methods
void typedef_print(struct type *type, struct symbol *newobj, struct ui_file *stream)
static void set_print_type_methods(const char *args, int from_tty, struct cmd_list_element *c)
struct cmd_list_element * setprinttypelist
void type_print_unknown_return_type(struct ui_file *stream)
void print_spaces(int n, struct ui_file *stream)
void fprintf_styled(struct ui_file *stream, const ui_file_style &style, const char *format,...)
void gdb_printf(struct ui_file *stream, const char *format,...)
void gdb_puts(const char *linebuffer, struct ui_file *stream)
struct type * value_rtti_indirect_type(struct value *v, int *full, LONGEST *top, int *using_enc)
void get_user_print_options(struct value_print_options *opts)
void print_longest(struct ui_file *stream, int format, int use_c_format, LONGEST val_long)
struct value * access_value_history(int num)