aboutsummaryrefslogtreecommitdiff
path: root/gdb/m2-lang.c
diff options
context:
space:
mode:
authorAndrew Burgess <andrew.burgess@embecosm.com>2020-06-03 16:44:05 +0100
committerAndrew Burgess <andrew.burgess@embecosm.com>2020-06-23 13:34:11 +0100
commitd711ee67aca06c9753f09dc154eb8c75cb4f58ef (patch)
tree3eb445d93e521604f3e07adadf2eba3ceac068f6 /gdb/m2-lang.c
parent52b50f2c1b1eaf6fd6e685e2c9575f92c581a6dc (diff)
downloadgdb-d711ee67aca06c9753f09dc154eb8c75cb4f58ef.zip
gdb-d711ee67aca06c9753f09dc154eb8c75cb4f58ef.tar.gz
gdb-d711ee67aca06c9753f09dc154eb8c75cb4f58ef.tar.bz2
gdb: Convert language la_printstr field to a method
This commit changes the language_data::la_printstr function pointer member variable into a member function of language_defn. There should be no user visible changes after this commit. gdb/ChangeLog: * 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.
Diffstat (limited to 'gdb/m2-lang.c')
-rw-r--r--gdb/m2-lang.c156
1 files changed, 75 insertions, 81 deletions
diff --git a/gdb/m2-lang.c b/gdb/m2-lang.c
index bdb1a46..b84a9a4 100644
--- a/gdb/m2-lang.c
+++ b/gdb/m2-lang.c
@@ -42,86 +42,6 @@ m2_printchar (int c, struct type *type, struct ui_file *stream)
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
@@ -309,7 +229,6 @@ extern const struct language_data m2_language_data =
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 */
@@ -433,6 +352,81 @@ public:
{
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. */