projects
/
deliverable
/
binutils-gdb.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
[gdb/testsuite] Fix duplicate test-names in gdb.multi
[deliverable/binutils-gdb.git]
/
gdb
/
c-typeprint.c
diff --git
a/gdb/c-typeprint.c
b/gdb/c-typeprint.c
index f8e02c279630b0e3866d28fb1c3720a388810c5f..aaf9e0dfe0a1a70a5dbae4edfb96c80f168688fa 100644
(file)
--- a/
gdb/c-typeprint.c
+++ b/
gdb/c-typeprint.c
@@
-1,5
+1,5
@@
/* Support for printing C and C++ types for GDB, the GNU debugger.
/* Support for printing C and C++ types for GDB, the GNU debugger.
- Copyright (C) 1986-20
19
Free Software Foundation, Inc.
+ Copyright (C) 1986-20
20
Free Software Foundation, Inc.
This file is part of GDB.
This file is part of GDB.
@@
-17,23
+17,21
@@
along with this program. If not, see <http://www.gnu.org/licenses/>. */
#include "defs.h"
along with this program. If not, see <http://www.gnu.org/licenses/>. */
#include "defs.h"
-
-/* Local non-gdb includes. */
-#include "bfd.h"
-#include "c-lang.h"
-#include "cli/cli-style.h"
-#include "cp-abi.h"
-#include "cp-support.h"
-#include "demangle.h"
-#include "expression.h"
#include "gdb_obstack.h"
#include "gdb_obstack.h"
-#include "gdbcore.h"
-#include "gdbtypes.h"
-#include "language.h"
+#include "bfd.h" /* Binary File Description. */
#include "symtab.h"
#include "symtab.h"
+#include "gdbtypes.h"
+#include "expression.h"
+#include "value.h"
+#include "gdbcore.h"
#include "target.h"
#include "target.h"
+#include "language.h"
+#include "demangle.h"
+#include "c-lang.h"
+#include "cli/cli-style.h"
#include "typeprint.h"
#include "typeprint.h"
-#include "value.h"
+#include "cp-abi.h"
+#include "cp-support.h"
/* A list of access specifiers used for printing. */
/* A list of access specifiers used for printing. */
@@
-60,7
+58,7
@@
static void c_type_print_varspec_prefix (struct type *,
/* Print "const", "volatile", or address space modifiers. */
static void c_type_print_modifier (struct type *,
struct ui_file *,
/* Print "const", "volatile", or address space modifiers. */
static void c_type_print_modifier (struct type *,
struct ui_file *,
- int, int);
+ int, int
, enum language
);
static void c_type_print_base_1 (struct type *type, struct ui_file *stream,
int show, int level, enum language language,
static void c_type_print_base_1 (struct type *type, struct ui_file *stream,
int show, int level, enum language language,
@@
-86,14
+84,14
@@
print_name_maybe_canonical (const char *name,
const struct type_print_options *flags,
struct ui_file *stream)
{
const struct type_print_options *flags,
struct ui_file *stream)
{
-
std::string
s;
+
gdb::unique_xmalloc_ptr<char>
s;
if (!flags->raw)
s = cp_canonicalize_string_full (name,
find_typedef_for_canonicalize,
(void *) flags);
if (!flags->raw)
s = cp_canonicalize_string_full (name,
find_typedef_for_canonicalize,
(void *) flags);
- fputs_filtered (
!s.empty () ? s.c_str
() : name, stream);
+ fputs_filtered (
s != nullptr ? s.get
() : name, stream);
}
\f
}
\f
@@
-150,7
+148,7
@@
c_print_type_1 (struct type *type,
if (code == TYPE_CODE_FUNC || code == TYPE_CODE_METHOD)
fputs_styled (varstring, function_name_style.style (), stream);
else
if (code == TYPE_CODE_FUNC || code == TYPE_CODE_METHOD)
fputs_styled (varstring, function_name_style.style (), stream);
else
- fputs_
filtered (varstring
, stream);
+ fputs_
styled (varstring, variable_name_style.style ()
, stream);
/* For demangled function names, we have the arglist as part of
the name, so don't print an additional pair of ()'s. */
/* For demangled function names, we have the arglist as part of
the name, so don't print an additional pair of ()'s. */
@@
-207,13
+205,13
@@
c_print_typedef (struct type *type,
{
type = check_typedef (type);
fprintf_filtered (stream, "typedef ");
{
type = check_typedef (type);
fprintf_filtered (stream, "typedef ");
- type_print (type, "", stream,
0
);
+ type_print (type, "", stream,
-1
);
if (TYPE_NAME ((SYMBOL_TYPE (new_symbol))) == 0
|| strcmp (TYPE_NAME ((SYMBOL_TYPE (new_symbol))),
if (TYPE_NAME ((SYMBOL_TYPE (new_symbol))) == 0
|| strcmp (TYPE_NAME ((SYMBOL_TYPE (new_symbol))),
-
SYMBOL_LINKAGE_NAME (new_symbol
)) != 0
+
new_symbol->linkage_name (
)) != 0
|| TYPE_CODE (SYMBOL_TYPE (new_symbol)) == TYPE_CODE_TYPEDEF)
|| TYPE_CODE (SYMBOL_TYPE (new_symbol)) == TYPE_CODE_TYPEDEF)
- fprintf_filtered (stream, " %s",
SYMBOL_PRINT_NAME (new_symbol
));
- fprintf_filtered (stream, ";
\n
");
+ fprintf_filtered (stream, " %s",
new_symbol->print_name (
));
+ fprintf_filtered (stream, ";");
}
/* If TYPE is a derived type, then print out derivation information.
}
/* If TYPE is a derived type, then print out derivation information.
@@
-339,7
+337,9
@@
cp_type_print_method_args (struct type *mtype, const char *prefix,
fprintf_filtered (stream, " volatile");
if (TYPE_RESTRICT (domain))
fprintf_filtered (stream, " volatile");
if (TYPE_RESTRICT (domain))
- fprintf_filtered (stream, " restrict");
+ fprintf_filtered (stream, (language == language_cplus
+ ? " __restrict__"
+ : " restrict"));
if (TYPE_ATOMIC (domain))
fprintf_filtered (stream, " _Atomic");
if (TYPE_ATOMIC (domain))
fprintf_filtered (stream, " _Atomic");
@@
-385,7
+385,7
@@
c_type_print_varspec_prefix (struct type *type,
stream, show, 1, 1, language, flags,
podata);
fprintf_filtered (stream, "*");
stream, show, 1, 1, language, flags,
podata);
fprintf_filtered (stream, "*");
- c_type_print_modifier (type, stream, 1, need_post_space);
+ c_type_print_modifier (type, stream, 1, need_post_space
, language
);
break;
case TYPE_CODE_MEMBERPTR:
break;
case TYPE_CODE_MEMBERPTR:
@@
-422,7
+422,7
@@
c_type_print_varspec_prefix (struct type *type,
stream, show, 1, 0, language, flags,
podata);
fprintf_filtered (stream, TYPE_CODE(type) == TYPE_CODE_REF ? "&" : "&&");
stream, show, 1, 0, language, flags,
podata);
fprintf_filtered (stream, TYPE_CODE(type) == TYPE_CODE_REF ? "&" : "&&");
- c_type_print_modifier (type, stream, 1, need_post_space);
+ c_type_print_modifier (type, stream, 1, need_post_space
, language
);
break;
case TYPE_CODE_METHOD:
break;
case TYPE_CODE_METHOD:
@@
-483,7
+483,8
@@
c_type_print_varspec_prefix (struct type *type,
static void
c_type_print_modifier (struct type *type, struct ui_file *stream,
static void
c_type_print_modifier (struct type *type, struct ui_file *stream,
- int need_pre_space, int need_post_space)
+ int need_pre_space, int need_post_space,
+ enum language language)
{
int did_print_modifier = 0;
const char *address_space_id;
{
int did_print_modifier = 0;
const char *address_space_id;
@@
-511,7
+512,9
@@
c_type_print_modifier (struct type *type, struct ui_file *stream,
{
if (did_print_modifier || need_pre_space)
fprintf_filtered (stream, " ");
{
if (did_print_modifier || need_pre_space)
fprintf_filtered (stream, " ");
- fprintf_filtered (stream, "restrict");
+ fprintf_filtered (stream, (language == language_cplus
+ ? "__restrict__"
+ : "restrict"));
did_print_modifier = 1;
}
did_print_modifier = 1;
}
@@
-882,15
+885,14
@@
c_type_print_template_args (const struct type_print_options *flags,
if (first)
{
wrap_here (" ");
if (first)
{
wrap_here (" ");
- fprintf_filtered (stream, _("[with %s = "),
- SYMBOL_LINKAGE_NAME (sym));
+ fprintf_filtered (stream, _("[with %s = "), sym->linkage_name ());
first = 0;
}
else
{
fputs_filtered (", ", stream);
wrap_here (" ");
first = 0;
}
else
{
fputs_filtered (", ", stream);
wrap_here (" ");
- fprintf_filtered (stream, "%s = ",
SYMBOL_LINKAGE_NAME (sym
));
+ fprintf_filtered (stream, "%s = ",
sym->linkage_name (
));
}
c_print_type (SYMBOL_TYPE (sym), "", stream, -1, 0, flags);
}
c_print_type (SYMBOL_TYPE (sym), "", stream, -1, 0, flags);
@@
-1053,7
+1055,7
@@
c_type_print_base_struct_union (struct type *type, struct ui_file *stream,
hash_holder.reset (local_flags.local_typedefs);
}
hash_holder.reset (local_flags.local_typedefs);
}
- c_type_print_modifier (type, stream, 0, 1);
+ c_type_print_modifier (type, stream, 0, 1
, language
);
if (TYPE_CODE (type) == TYPE_CODE_UNION)
fprintf_filtered (stream, "union ");
else if (TYPE_DECLARED_CLASS (type))
if (TYPE_CODE (type) == TYPE_CODE_UNION)
fprintf_filtered (stream, "union ");
else if (TYPE_DECLARED_CLASS (type))
@@
-1118,10
+1120,12
@@
c_type_print_base_struct_union (struct type *type, struct ui_file *stream,
{
if (TYPE_STUB (type))
fprintfi_filtered (level + 4, stream,
{
if (TYPE_STUB (type))
fprintfi_filtered (level + 4, stream,
- _("<incomplete type>\n"));
+ _("%p[<incomplete type>%p]\n"),
+ metadata_style.style ().ptr (), nullptr);
else
fprintfi_filtered (level + 4, stream,
else
fprintfi_filtered (level + 4, stream,
- _("<no data fields>\n"));
+ _("%p[<no data fields>%p]\n"),
+ metadata_style.style ().ptr (), nullptr);
}
/* Start off with no specific section type, so we can print
}
/* Start off with no specific section type, so we can print
@@
-1279,7
+1283,8
@@
c_type_print_base_struct_union (struct type *type, struct ui_file *stream,
{
/* Keep GDB from crashing here. */
fprintf_filtered (stream,
{
/* Keep GDB from crashing here. */
fprintf_filtered (stream,
- _("<undefined type> %s;\n"),
+ _("%p[<undefined type>%p] %s;\n"),
+ metadata_style.style ().ptr (), nullptr,
TYPE_FN_FIELD_PHYSNAME (f, j));
break;
}
TYPE_FN_FIELD_PHYSNAME (f, j));
break;
}
@@
-1327,9
+1332,9
@@
c_type_print_base_struct_union (struct type *type, struct ui_file *stream,
&local_flags);
}
else
&local_flags);
}
else
- fprintf_
filtered (stream
,
-
_("<badly mangled name '%s'>"),
-
mangled_name);
+ fprintf_
styled (stream, metadata_style.style ()
,
+ _("<badly mangled name '%s'>"),
+ mangled_name);
}
else
{
}
else
{
@@
-1467,7
+1472,7
@@
c_type_print_base_1 (struct type *type, struct ui_file *stream,
if (type == NULL)
{
if (type == NULL)
{
- fputs_
filtered (_("<type unknown>"
), stream);
+ fputs_
styled (_("<type unknown>"), metadata_style.style (
), stream);
return;
}
return;
}
@@
-1477,7
+1482,7
@@
c_type_print_base_1 (struct type *type, struct ui_file *stream,
if (show <= 0
&& TYPE_NAME (type) != NULL)
{
if (show <= 0
&& TYPE_NAME (type) != NULL)
{
- c_type_print_modifier (type, stream, 0, 1);
+ c_type_print_modifier (type, stream, 0, 1
, language
);
/* If we have "typedef struct foo {. . .} bar;" do we want to
print it as "struct foo" or as "bar"? Pick the latter for
/* If we have "typedef struct foo {. . .} bar;" do we want to
print it as "struct foo" or as "bar"? Pick the latter for
@@
-1513,7
+1518,8
@@
c_type_print_base_1 (struct type *type, struct ui_file *stream,
couldn't resolve TYPE_TARGET_TYPE. Not much we can do. */
gdb_assert (TYPE_NAME (type) == NULL);
gdb_assert (TYPE_TARGET_TYPE (type) == NULL);
couldn't resolve TYPE_TARGET_TYPE. Not much we can do. */
gdb_assert (TYPE_NAME (type) == NULL);
gdb_assert (TYPE_TARGET_TYPE (type) == NULL);
- fprintf_filtered (stream, _("<unnamed typedef>"));
+ fprintf_styled (stream, metadata_style.style (),
+ _("<unnamed typedef>"));
break;
case TYPE_CODE_FUNC:
break;
case TYPE_CODE_FUNC:
@@
-1541,7
+1547,7
@@
c_type_print_base_1 (struct type *type, struct ui_file *stream,
break;
case TYPE_CODE_ENUM:
break;
case TYPE_CODE_ENUM:
- c_type_print_modifier (type, stream, 0, 1);
+ c_type_print_modifier (type, stream, 0, 1
, language
);
fprintf_filtered (stream, "enum ");
if (TYPE_DECLARED_CLASS (type))
fprintf_filtered (stream, "class ");
fprintf_filtered (stream, "enum ");
if (TYPE_DECLARED_CLASS (type))
fprintf_filtered (stream, "class ");
@@
-1594,7
+1600,8
@@
c_type_print_base_1 (struct type *type, struct ui_file *stream,
if (i)
fprintf_filtered (stream, ", ");
wrap_here (" ");
if (i)
fprintf_filtered (stream, ", ");
wrap_here (" ");
- fputs_filtered (TYPE_FIELD_NAME (type, i), stream);
+ fputs_styled (TYPE_FIELD_NAME (type, i),
+ variable_name_style.style (), stream);
if (lastval != TYPE_FIELD_ENUMVAL (type, i))
{
fprintf_filtered (stream, " = %s",
if (lastval != TYPE_FIELD_ENUMVAL (type, i))
{
fprintf_filtered (stream, " = %s",
@@
-1613,7
+1620,7
@@
c_type_print_base_1 (struct type *type, struct ui_file *stream,
local_flags.local_typedefs = NULL;
local_flags.local_typedefs = NULL;
- c_type_print_modifier (type, stream, 0, 1);
+ c_type_print_modifier (type, stream, 0, 1
, language
);
fprintf_filtered (stream, "flag ");
print_name_maybe_canonical (TYPE_NAME (type), flags, stream);
if (show > 0)
fprintf_filtered (stream, "flag ");
print_name_maybe_canonical (TYPE_NAME (type), flags, stream);
if (show > 0)
@@
-1624,10
+1631,12
@@
c_type_print_base_1 (struct type *type, struct ui_file *stream,
{
if (TYPE_STUB (type))
fprintfi_filtered (level + 4, stream,
{
if (TYPE_STUB (type))
fprintfi_filtered (level + 4, stream,
- _("<incomplete type>\n"));
+ _("%p[<incomplete type>%p]\n"),
+ metadata_style.style ().ptr (), nullptr);
else
fprintfi_filtered (level + 4, stream,
else
fprintfi_filtered (level + 4, stream,
- _("<no data fields>\n"));
+ _("%p[<no data fields>%p]\n"),
+ metadata_style.style ().ptr (), nullptr);
}
len = TYPE_NFIELDS (type);
for (i = 0; i < len; i++)
}
len = TYPE_NFIELDS (type);
for (i = 0; i < len; i++)
@@
-1670,7
+1679,7
@@
c_type_print_base_1 (struct type *type, struct ui_file *stream,
case TYPE_CODE_RANGE:
/* This should not occur. */
case TYPE_CODE_RANGE:
/* This should not occur. */
- fprintf_
filtered (stream
, _("<range type>"));
+ fprintf_
styled (stream, metadata_style.style ()
, _("<range type>"));
break;
case TYPE_CODE_NAMESPACE:
break;
case TYPE_CODE_NAMESPACE:
@@
-1685,15
+1694,15
@@
c_type_print_base_1 (struct type *type, struct ui_file *stream,
type name, then complain. */
if (TYPE_NAME (type) != NULL)
{
type name, then complain. */
if (TYPE_NAME (type) != NULL)
{
- c_type_print_modifier (type, stream, 0, 1);
+ c_type_print_modifier (type, stream, 0, 1
, language
);
print_name_maybe_canonical (TYPE_NAME (type), flags, stream);
}
else
{
/* At least for dump_symtab, it is important that this not
be an error (). */
print_name_maybe_canonical (TYPE_NAME (type), flags, stream);
}
else
{
/* At least for dump_symtab, it is important that this not
be an error (). */
- fprintf_
filtered (stream, _("<invalid type code %d>"
),
-
TYPE_CODE (type));
+ fprintf_
styled (stream, metadata_style.style (
),
+
_("<invalid type code %d>"),
TYPE_CODE (type));
}
break;
}
}
break;
}
This page took
0.029795 seconds
and
4
git commands to generate.