+2020-06-23 Andrew Burgess <andrew.burgess@embecosm.com>
+
+ * ada-lang.c (ada_language_data): Delete la_printstr initializer.
+ (ada_language::printstr): New member function.
+ * c-lang.c (c_language_data): Delete la_printstr initializer.
+ (cplus_language_data): Likewise.
+ (asm_language_data): Likewise.
+ (minimal_language_data): Likewise.
+ * d-lang.c (d_language_data): Likewise.
+ * f-lang.c (f_printstr): Rename to f_language::printstr.
+ (f_language_data): Delete la_printstr initializer.
+ (f_language::printstr): New member function, implementation from
+ f_printstr.
+ * go-lang.c (go_language_data): Delete la_printstr initializer.
+ * language.c (language_defn::printstr): Define new member
+ function.
+ (unk_lang_printstr): Delete.
+ (unknown_language_data): Delete la_printstr initializer.
+ (unknown_language::printstr): New member function.
+ (auto_language_data): Delete la_printstr initializer.
+ (auto_language::printstr): New member function.
+ * language.h (language_data): Delete la_printstr field.
+ (language_defn::printstr): Declare new member function.
+ (LA_PRINT_STRING): Update call to printstr.
+ * m2-lang.c (m2_printstr): Rename to m2_language::printstr.
+ (m2_language_data): Delete la_printstr initializer.
+ (m2_language::printstr): New member function, implementation from
+ m2_printstr.
+ * objc-lang.c (objc_language_data): Delete la_printstr
+ initializer.
+ * opencl-lang.c (opencl_language_data): Likewise.
+ * p-lang.c (pascal_printstr): Rename to pascal_language::printstr.
+ (pascal_language_data): Delete la_printstr initializer.
+ (pascal_language::printstr): New member function, implementation
+ from pascal_printstr.
+ * p-lang.h (pascal_printstr): Delete declaration.
+ * rust-lang.c (rust_printstr): Update header comment.
+ (rust_language_data): Delete la_printstr initializer.
+ (rust_language::printstr): New member function.
+
2020-06-23 Andrew Burgess <andrew.burgess@embecosm.com>
* ada-lang.c (ada_language_data): Delete la_printchar initializer.
macro_expansion_no,
ada_extensions,
&ada_exp_descriptor,
- ada_printstr, /* Function to print string constant */
ada_print_typedef, /* Print a typedef using appropriate syntax */
NULL, /* name_of_this */
true, /* la_store_sym_names_in_linkage_form_p */
ada_printchar (ch, chtype, stream);
}
+ /* See language.h. */
+
+ void printstr (struct ui_file *stream, struct type *elttype,
+ const gdb_byte *string, unsigned int length,
+ const char *encoding, int force_ellipses,
+ const struct value_print_options *options) const override
+ {
+ ada_printstr (stream, elttype, string, length, encoding,
+ force_ellipses, options);
+ }
+
protected:
/* See language.h. */
macro_expansion_c,
c_extensions,
&exp_descriptor_c,
- c_printstr, /* Function to print string constant */
c_print_typedef, /* Print a typedef using appropriate syntax */
NULL, /* name_of_this */
true, /* la_store_sym_names_in_linkage_form_p */
macro_expansion_c,
cplus_extensions,
&exp_descriptor_c,
- c_printstr, /* Function to print string constant */
c_print_typedef, /* Print a typedef using appropriate syntax */
"this", /* name_of_this */
false, /* la_store_sym_names_in_linkage_form_p */
macro_expansion_c,
asm_extensions,
&exp_descriptor_c,
- c_printstr, /* Function to print string constant */
c_print_typedef, /* Print a typedef using appropriate syntax */
NULL, /* name_of_this */
true, /* la_store_sym_names_in_linkage_form_p */
macro_expansion_c,
NULL,
&exp_descriptor_c,
- c_printstr, /* Function to print string constant */
c_print_typedef, /* Print a typedef using appropriate syntax */
NULL, /* name_of_this */
true, /* la_store_sym_names_in_linkage_form_p */
macro_expansion_no,
d_extensions,
&exp_descriptor_c,
- c_printstr, /* Function to print string constant. */
c_print_typedef, /* Print a typedef using appropriate
syntax. */
"this",
return encoding;
}
-/* Print the character string STRING, printing at most LENGTH characters.
- Printing stops early if the number hits print_max; repeat counts
- are printed as appropriate. Print ellipses at the end if we
- had to stop before printing LENGTH characters, or if FORCE_ELLIPSES.
- FIXME: This is a copy of the same function from c-exp.y. It should
- be replaced with a true F77 version. */
-
-static void
-f_printstr (struct ui_file *stream, struct type *type, const gdb_byte *string,
- unsigned int length, const char *encoding, int force_ellipses,
- const struct value_print_options *options)
-{
- const char *type_encoding = f_get_encoding (type);
-
- if (TYPE_LENGTH (type) == 4)
- fputs_filtered ("4_", stream);
-
- if (!encoding || !*encoding)
- encoding = type_encoding;
-
- generic_printstr (stream, type, string, length, encoding,
- force_ellipses, '\'', 0, options);
-}
\f
/* Table of operators and their precedences for printing expressions. */
macro_expansion_no,
f_extensions,
&exp_descriptor_f,
- f_printstr, /* function to print string constant */
f_print_typedef, /* Print a typedef using appropriate syntax */
NULL, /* name_of_this */
false, /* la_store_sym_names_in_linkage_form_p */
fputs_filtered ("'", stream);
}
+ /* See language.h. */
+
+ void printstr (struct ui_file *stream, struct type *elttype,
+ const gdb_byte *string, unsigned int length,
+ const char *encoding, int force_ellipses,
+ const struct value_print_options *options) const override
+ {
+ const char *type_encoding = f_get_encoding (elttype);
+
+ if (TYPE_LENGTH (elttype) == 4)
+ fputs_filtered ("4_", stream);
+
+ if (!encoding || !*encoding)
+ encoding = type_encoding;
+
+ generic_printstr (stream, elttype, string, length, encoding,
+ force_ellipses, '\'', 0, options);
+ }
+
protected:
/* See language.h. */
macro_expansion_no,
NULL,
&exp_descriptor_c,
- c_printstr, /* Function to print string constant. */
c_print_typedef, /* Print a typedef using appropriate
syntax. */
NULL, /* name_of_this */
c_printchar (ch, chtype, stream);
}
+/* See language.h. */
+
+void
+language_defn::printstr (struct ui_file *stream, struct type *elttype,
+ const gdb_byte *string, unsigned int length,
+ const char *encoding, int force_ellipses,
+ const struct value_print_options *options) const
+{
+ c_printstr (stream, elttype, string, length, encoding, force_ellipses,
+ options);
+}
+
/* The default implementation of the get_symbol_name_matcher_inner method
from the language_defn class. Matches with strncmp_iw. */
return (type->code () == TYPE_CODE_STRING);
}
-static void
-unk_lang_printstr (struct ui_file *stream, struct type *type,
- const gdb_byte *string, unsigned int length,
- const char *encoding, int force_ellipses,
- const struct value_print_options *options)
-{
- error (_("internal error - unimplemented "
- "function unk_lang_printstr called."));
-}
-
static const struct op_print unk_op_print_tab[] =
{
{NULL, OP_NULL, PREC_NULL, 0}
macro_expansion_no,
NULL,
&exp_descriptor_standard,
- unk_lang_printstr,
default_print_typedef, /* Print a typedef using appropriate syntax */
"this", /* name_of_this */
true, /* store_sym_names_in_linkage_form_p */
{
error (_("unimplemented unknown_language::printchar called"));
}
+
+ /* See language.h. */
+
+ void printstr (struct ui_file *stream, struct type *elttype,
+ const gdb_byte *string, unsigned int length,
+ const char *encoding, int force_ellipses,
+ const struct value_print_options *options) const override
+ {
+ error (_("unimplemented unknown_language::printstr called"));
+ }
};
/* Single instance of the unknown language class. */
macro_expansion_no,
NULL,
&exp_descriptor_standard,
- unk_lang_printstr,
default_print_typedef, /* Print a typedef using appropriate syntax */
"this", /* name_of_this */
false, /* store_sym_names_in_linkage_form_p */
{
error (_("unimplemented auto_language::printchar called"));
}
+
+ /* See language.h. */
+
+ void printstr (struct ui_file *stream, struct type *elttype,
+ const gdb_byte *string, unsigned int length,
+ const char *encoding, int force_ellipses,
+ const struct value_print_options *options) const override
+ {
+ error (_("unimplemented auto_language::printstr called"));
+ }
};
/* Single instance of the fake "auto" language. */
const struct exp_descriptor *la_exp_desc;
- void (*la_printstr) (struct ui_file * stream, struct type *elttype,
- const gdb_byte *string, unsigned int length,
- const char *encoding, int force_ellipses,
- const struct value_print_options *);
-
/* Print a typedef using syntax appropriate for this language.
TYPE is the underlying type. NEW_SYMBOL is the symbol naming
the type. STREAM is the output stream on which to print. */
virtual void printchar (int ch, struct type *chtype,
struct ui_file * stream) const;
+/* Print the character string STRING, printing at most LENGTH characters.
+ Printing stops early if the number hits print_max; repeat counts
+ are printed as appropriate. Print ellipses at the end if we
+ had to stop before printing LENGTH characters, or if FORCE_ELLIPSES. */
+
+ virtual void printstr (struct ui_file *stream, struct type *elttype,
+ const gdb_byte *string, unsigned int length,
+ const char *encoding, int force_ellipses,
+ const struct value_print_options *options) const;
+
protected:
/* This is the overridable part of the GET_SYMBOL_NAME_MATCHER method.
#define LA_PRINT_CHAR(ch, type, stream) \
(current_language->printchar (ch, type, stream))
#define LA_PRINT_STRING(stream, elttype, string, length, encoding, force_ellipses, options) \
- (current_language->la_printstr(stream, elttype, string, length, \
- encoding, force_ellipses,options))
+ (current_language->printstr (stream, elttype, string, length, \
+ encoding, force_ellipses,options))
#define LA_EMIT_CHAR(ch, type, stream, quoter) \
(current_language->emitchar (ch, type, stream, quoter))
fputs_filtered ("'", stream);
}
-/* Print the character string STRING, printing at most LENGTH characters.
- Printing stops early if the number hits print_max; repeat counts
- are printed as appropriate. Print ellipses at the end if we
- had to stop before printing LENGTH characters, or if FORCE_ELLIPSES.
- FIXME: This is a copy of the same function from c-exp.y. It should
- be replaced with a true Modula version. */
-
-static void
-m2_printstr (struct ui_file *stream, struct type *type, const gdb_byte *string,
- unsigned int length, const char *encoding, int force_ellipses,
- const struct value_print_options *options)
-{
- unsigned int i;
- unsigned int things_printed = 0;
- int in_quotes = 0;
- int need_comma = 0;
-
- if (length == 0)
- {
- fputs_filtered ("\"\"", gdb_stdout);
- return;
- }
-
- for (i = 0; i < length && things_printed < options->print_max; ++i)
- {
- /* Position of the character we are examining
- to see whether it is repeated. */
- unsigned int rep1;
- /* Number of repetitions we have detected so far. */
- unsigned int reps;
-
- QUIT;
-
- if (need_comma)
- {
- fputs_filtered (", ", stream);
- need_comma = 0;
- }
-
- rep1 = i + 1;
- reps = 1;
- while (rep1 < length && string[rep1] == string[i])
- {
- ++rep1;
- ++reps;
- }
-
- if (reps > options->repeat_count_threshold)
- {
- if (in_quotes)
- {
- fputs_filtered ("\", ", stream);
- in_quotes = 0;
- }
- m2_printchar (string[i], type, stream);
- fprintf_filtered (stream, " <repeats %u times>", reps);
- i = rep1 - 1;
- things_printed += options->repeat_count_threshold;
- need_comma = 1;
- }
- else
- {
- if (!in_quotes)
- {
- fputs_filtered ("\"", stream);
- in_quotes = 1;
- }
- LA_EMIT_CHAR (string[i], type, stream, '"');
- ++things_printed;
- }
- }
-
- /* Terminate the quotes if necessary. */
- if (in_quotes)
- fputs_filtered ("\"", stream);
-
- if (force_ellipses || i < length)
- fputs_filtered ("...", stream);
-}
-
/* Return true if TYPE is a string. */
static bool
macro_expansion_no,
NULL,
&exp_descriptor_modula2,
- m2_printstr, /* function to print string constant */
m2_print_typedef, /* Print a typedef using appropriate syntax */
NULL, /* name_of_this */
false, /* la_store_sym_names_in_linkage_form_p */
{
m2_printchar (ch, chtype, stream);
}
+
+ /* See language.h. */
+
+ void printstr (struct ui_file *stream, struct type *elttype,
+ const gdb_byte *string, unsigned int length,
+ const char *encoding, int force_ellipses,
+ const struct value_print_options *options) const override
+ {
+ unsigned int i;
+ unsigned int things_printed = 0;
+ int in_quotes = 0;
+ int need_comma = 0;
+
+ if (length == 0)
+ {
+ fputs_filtered ("\"\"", gdb_stdout);
+ return;
+ }
+
+ for (i = 0; i < length && things_printed < options->print_max; ++i)
+ {
+ /* Position of the character we are examining
+ to see whether it is repeated. */
+ unsigned int rep1;
+ /* Number of repetitions we have detected so far. */
+ unsigned int reps;
+
+ QUIT;
+
+ if (need_comma)
+ {
+ fputs_filtered (", ", stream);
+ need_comma = 0;
+ }
+
+ rep1 = i + 1;
+ reps = 1;
+ while (rep1 < length && string[rep1] == string[i])
+ {
+ ++rep1;
+ ++reps;
+ }
+
+ if (reps > options->repeat_count_threshold)
+ {
+ if (in_quotes)
+ {
+ fputs_filtered ("\", ", stream);
+ in_quotes = 0;
+ }
+ m2_printchar (string[i], elttype, stream);
+ fprintf_filtered (stream, " <repeats %u times>", reps);
+ i = rep1 - 1;
+ things_printed += options->repeat_count_threshold;
+ need_comma = 1;
+ }
+ else
+ {
+ if (!in_quotes)
+ {
+ fputs_filtered ("\"", stream);
+ in_quotes = 1;
+ }
+ LA_EMIT_CHAR (string[i], elttype, stream, '"');
+ ++things_printed;
+ }
+ }
+
+ /* Terminate the quotes if necessary. */
+ if (in_quotes)
+ fputs_filtered ("\"", stream);
+
+ if (force_ellipses || i < length)
+ fputs_filtered ("...", stream);
+ }
};
/* Single instance of the M2 language. */
macro_expansion_c,
objc_extensions,
&exp_descriptor_standard,
- c_printstr, /* Function to print string constant */
c_print_typedef, /* Print a typedef using appropriate syntax */
"self", /* name_of_this */
false, /* la_store_sym_names_in_linkage_form_p */
macro_expansion_c,
NULL,
&exp_descriptor_opencl,
- c_printstr, /* Function to print string constant */
c_print_typedef, /* Print a typedef using appropriate syntax */
NULL, /* name_of_this */
false, /* la_store_sym_names_in_linkage_form_p */
fputs_filtered ("'", stream);
}
-/* Print the character string STRING, printing at most LENGTH characters.
- Printing stops early if the number hits print_max; repeat counts
- are printed as appropriate. Print ellipses at the end if we
- had to stop before printing LENGTH characters, or if FORCE_ELLIPSES. */
-
-void
-pascal_printstr (struct ui_file *stream, struct type *type,
- const gdb_byte *string, unsigned int length,
- const char *encoding, int force_ellipses,
- const struct value_print_options *options)
-{
- enum bfd_endian byte_order = type_byte_order (type);
- unsigned int i;
- unsigned int things_printed = 0;
- int in_quotes = 0;
- int need_comma = 0;
- int width;
-
- /* Preserve TYPE's original type, just set its LENGTH. */
- check_typedef (type);
- width = TYPE_LENGTH (type);
-
- /* If the string was not truncated due to `set print elements', and
- the last byte of it is a null, we don't print that, in traditional C
- style. */
- if ((!force_ellipses) && length > 0
- && extract_unsigned_integer (string + (length - 1) * width, width,
- byte_order) == 0)
- length--;
-
- if (length == 0)
- {
- fputs_filtered ("''", stream);
- return;
- }
-
- for (i = 0; i < length && things_printed < options->print_max; ++i)
- {
- /* Position of the character we are examining
- to see whether it is repeated. */
- unsigned int rep1;
- /* Number of repetitions we have detected so far. */
- unsigned int reps;
- unsigned long int current_char;
-
- QUIT;
-
- if (need_comma)
- {
- fputs_filtered (", ", stream);
- need_comma = 0;
- }
-
- current_char = extract_unsigned_integer (string + i * width, width,
- byte_order);
-
- rep1 = i + 1;
- reps = 1;
- while (rep1 < length
- && extract_unsigned_integer (string + rep1 * width, width,
- byte_order) == current_char)
- {
- ++rep1;
- ++reps;
- }
-
- if (reps > options->repeat_count_threshold)
- {
- if (in_quotes)
- {
- fputs_filtered ("', ", stream);
- in_quotes = 0;
- }
- pascal_printchar (current_char, type, stream);
- fprintf_filtered (stream, " %p[<repeats %u times>%p]",
- metadata_style.style ().ptr (),
- reps, nullptr);
- i = rep1 - 1;
- things_printed += options->repeat_count_threshold;
- need_comma = 1;
- }
- else
- {
- if ((!in_quotes) && (PRINT_LITERAL_FORM (current_char)))
- {
- fputs_filtered ("'", stream);
- in_quotes = 1;
- }
- pascal_one_char (current_char, stream, &in_quotes);
- ++things_printed;
- }
- }
-
- /* Terminate the quotes if necessary. */
- if (in_quotes)
- fputs_filtered ("'", stream);
-
- if (force_ellipses || i < length)
- fputs_filtered ("...", stream);
-}
\f
/* Table mapping opcodes into strings for printing operators
macro_expansion_no,
p_extensions,
&exp_descriptor_standard,
- pascal_printstr, /* Function to print string constant */
pascal_print_typedef, /* Print a typedef using appropriate syntax */
"this", /* name_of_this */
false, /* la_store_sym_names_in_linkage_form_p */
pascal_printchar (ch, chtype, stream);
}
+ /* See language.h. */
+
+ void printstr (struct ui_file *stream, struct type *elttype,
+ const gdb_byte *string, unsigned int length,
+ const char *encoding, int force_ellipses,
+ const struct value_print_options *options) const override
+ {
+ enum bfd_endian byte_order = type_byte_order (elttype);
+ unsigned int i;
+ unsigned int things_printed = 0;
+ int in_quotes = 0;
+ int need_comma = 0;
+ int width;
+
+ /* Preserve ELTTYPE's original type, just set its LENGTH. */
+ check_typedef (elttype);
+ width = TYPE_LENGTH (elttype);
+
+ /* If the string was not truncated due to `set print elements', and
+ the last byte of it is a null, we don't print that, in traditional C
+ style. */
+ if ((!force_ellipses) && length > 0
+ && extract_unsigned_integer (string + (length - 1) * width, width,
+ byte_order) == 0)
+ length--;
+
+ if (length == 0)
+ {
+ fputs_filtered ("''", stream);
+ return;
+ }
+
+ for (i = 0; i < length && things_printed < options->print_max; ++i)
+ {
+ /* Position of the character we are examining
+ to see whether it is repeated. */
+ unsigned int rep1;
+ /* Number of repetitions we have detected so far. */
+ unsigned int reps;
+ unsigned long int current_char;
+
+ QUIT;
+
+ if (need_comma)
+ {
+ fputs_filtered (", ", stream);
+ need_comma = 0;
+ }
+
+ current_char = extract_unsigned_integer (string + i * width, width,
+ byte_order);
+
+ rep1 = i + 1;
+ reps = 1;
+ while (rep1 < length
+ && extract_unsigned_integer (string + rep1 * width, width,
+ byte_order) == current_char)
+ {
+ ++rep1;
+ ++reps;
+ }
+
+ if (reps > options->repeat_count_threshold)
+ {
+ if (in_quotes)
+ {
+ fputs_filtered ("', ", stream);
+ in_quotes = 0;
+ }
+ pascal_printchar (current_char, elttype, stream);
+ fprintf_filtered (stream, " %p[<repeats %u times>%p]",
+ metadata_style.style ().ptr (),
+ reps, nullptr);
+ i = rep1 - 1;
+ things_printed += options->repeat_count_threshold;
+ need_comma = 1;
+ }
+ else
+ {
+ if ((!in_quotes) && (PRINT_LITERAL_FORM (current_char)))
+ {
+ fputs_filtered ("'", stream);
+ in_quotes = 1;
+ }
+ pascal_one_char (current_char, stream, &in_quotes);
+ ++things_printed;
+ }
+ }
+
+ /* Terminate the quotes if necessary. */
+ if (in_quotes)
+ fputs_filtered ("'", stream);
+
+ if (force_ellipses || i < length)
+ fputs_filtered ("...", stream);
+ }
};
/* Single instance of the Pascal language class. */
extern void pascal_printchar (int, struct type *, struct ui_file *);
-extern void pascal_printstr (struct ui_file *, struct type *, const gdb_byte *,
- unsigned int, const char *, int,
- const struct value_print_options *);
-
extern struct type **const pascal_builtin_types[];
/* These are in p-typeprint.c: */
\f
-/* la_printstr implementation for Rust. */
+/* language_defn::printstr implementation for Rust. */
static void
rust_printstr (struct ui_file *stream, struct type *type,
macro_expansion_no,
rust_extensions,
&exp_descriptor_rust,
- rust_printstr, /* Function to print string constant */
rust_print_typedef, /* Print a typedef using appropriate syntax */
NULL, /* name_of_this */
false, /* la_store_sym_names_in_linkage_form_p */
LA_EMIT_CHAR (ch, chtype, stream, '\'');
fputs_filtered ("'", stream);
}
+
+ /* See language.h. */
+
+ void printstr (struct ui_file *stream, struct type *elttype,
+ const gdb_byte *string, unsigned int length,
+ const char *encoding, int force_ellipses,
+ const struct value_print_options *options) const override
+ {
+ rust_printstr (stream, elttype, string, length, encoding,
+ force_ellipses, options);
+ }
};
/* Single instance of the Rust language class. */