/* Support for printing C and C++ types for GDB, the GNU debugger.
- Copyright (C) 1986-2021 Free Software Foundation, Inc.
+ Copyright (C) 1986-2022 Free Software Foundation, Inc.
This file is part of GDB.
along with this program. If not, see <http://www.gnu.org/licenses/>. */
#include "defs.h"
-#include "gdb_obstack.h"
+#include "gdbsupport/gdb_obstack.h"
#include "bfd.h" /* Binary File Description. */
#include "symtab.h"
#include "gdbtypes.h"
code = type->code ();
if (local_name != NULL)
{
+ c_type_print_modifier (type, stream, 0, 1, language);
fputs_filtered (local_name, stream);
if (varstring != NULL && *varstring != '\0')
fputs_filtered (" ", stream);
type = check_typedef (type);
fprintf_filtered (stream, "typedef ");
type_print (type, "", stream, -1);
- if ((SYMBOL_TYPE (new_symbol))->name () == 0
- || strcmp ((SYMBOL_TYPE (new_symbol))->name (),
+ if ((new_symbol->type ())->name () == 0
+ || strcmp ((new_symbol->type ())->name (),
new_symbol->linkage_name ()) != 0
- || SYMBOL_TYPE (new_symbol)->code () == TYPE_CODE_TYPEDEF)
+ || new_symbol->type ()->code () == TYPE_CODE_TYPEDEF)
fprintf_filtered (stream, " %s", new_symbol->print_name ());
fprintf_filtered (stream, ";");
}
for (i = 0; i < TYPE_N_BASECLASSES (type); i++)
{
- wrap_here (" ");
+ stream->wrap_here (8);
fputs_filtered (i == 0 ? ": " : ", ", stream);
fprintf_filtered (stream, "%s%s ",
BASETYPE_VIA_PUBLIC (type, i)
else if (i < nargs)
{
fprintf_filtered (stream, ", ");
- wrap_here (" ");
+ stream->wrap_here (8);
}
}
}
if (printed_any)
{
fprintf_filtered (stream, ", ");
- wrap_here (" ");
+ stream->wrap_here (4);
}
param_type = type->field (i).type ();
if (printed_any && type->has_varargs ())
{
fprintf_filtered (stream, ", ");
- wrap_here (" ");
+ stream->wrap_here (4);
fprintf_filtered (stream, "...");
}
}
form. Even the author of this function feels that writing little
parsers like this everywhere is stupid. */
-static char *
-remove_qualifiers (char *qid)
+static const char *
+remove_qualifiers (const char *qid)
{
int quoted = 0; /* Zero if we're not in quotes;
'"' if we're in a double-quoted string;
'\'' if we're in a single-quoted string. */
int depth = 0; /* Number of unclosed parens we've seen. */
char *parenstack = (char *) alloca (strlen (qid));
- char *scan;
- char *last = 0; /* The character after the rightmost
+ const char *scan;
+ const char *last = 0; /* The character after the rightmost
`::' token we've seen so far. */
for (scan = qid; *scan; scan++)
{
struct symbol *sym = TYPE_TEMPLATE_ARGUMENT (type, i);
- if (SYMBOL_CLASS (sym) != LOC_TYPEDEF)
+ if (sym->aclass () != LOC_TYPEDEF)
continue;
if (first)
{
- wrap_here (" ");
+ stream->wrap_here (4);
fprintf_filtered (stream, _("[with %s = "), sym->linkage_name ());
first = 0;
}
else
{
fputs_filtered (", ", stream);
- wrap_here (" ");
+ stream->wrap_here (9);
fprintf_filtered (stream, "%s = ", sym->linkage_name ());
}
- c_print_type (SYMBOL_TYPE (sym), "", stream, -1, 0, flags);
+ c_print_type (sym->type (), "", stream, -1, 0, flags);
}
if (!first)
/* Make sure we carry our offset when we expand the
struct/union. */
local_podata.offset_bitpos
- = podata->offset_bitpos + TYPE_FIELD_BITPOS (type, i);
+ = podata->offset_bitpos + type->field (i).loc_bitpos ();
/* We're entering a struct/union. Right now,
PODATA->END_BITPOS points right *after* the
struct/union. However, when printing the first field
{
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)
else
mangled_name = TYPE_FN_FIELD_PHYSNAME (f, j);
- demangled_name =
- gdb_demangle (mangled_name,
- DMGL_ANSI | DMGL_PARAMS);
+ gdb::unique_xmalloc_ptr<char> demangled_name
+ = gdb_demangle (mangled_name,
+ DMGL_ANSI | DMGL_PARAMS);
if (demangled_name == NULL)
{
/* In some cases (for instance with the HP
}
else
{
- char *p;
- char *demangled_no_class
- = remove_qualifiers (demangled_name);
+ const char *p;
+ const char *demangled_no_class
+ = remove_qualifiers (demangled_name.get ());
/* Get rid of the `static' appended by the
demangler. */
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);
+ std::string demangled_no_static (demangled_no_class,
+ length);
+ fputs_filtered (demangled_no_static.c_str (), stream);
}
else
fputs_filtered (demangled_no_class, stream);
- xfree (demangled_name);
}
fprintf_filtered (stream, ";\n");
fputs_filtered (" ", stream);
}
- wrap_here (" ");
+ stream->wrap_here (4);
if (show < 0)
{
/* If we just printed a tag name, no need to print anything
QUIT;
if (i)
fprintf_filtered (stream, ", ");
- wrap_here (" ");
+ stream->wrap_here (4);
fputs_styled (type->field (i).name (),
variable_name_style.style (), stream);
- if (lastval != TYPE_FIELD_ENUMVAL (type, i))
+ if (lastval != type->field (i).loc_enumval ())
{
fprintf_filtered (stream, " = %s",
- plongest (TYPE_FIELD_ENUMVAL (type, i)));
- lastval = TYPE_FIELD_ENUMVAL (type, i);
+ plongest (type->field (i).loc_enumval ()));
+ lastval = type->field (i).loc_enumval ();
}
lastval++;
}
stream, show, level + 4,
language, &local_flags, podata);
fprintf_filtered (stream, " @%s",
- plongest (TYPE_FIELD_BITPOS (type, i)));
+ plongest (type->field (i).loc_bitpos ()));
if (TYPE_FIELD_BITSIZE (type, i) > 1)
{
fprintf_filtered (stream, "-%s",
- plongest (TYPE_FIELD_BITPOS (type, i)
+ plongest (type->field (i).loc_bitpos ()
+ TYPE_FIELD_BITSIZE (type, i)
- 1));
}