aboutsummaryrefslogtreecommitdiff
path: root/gdb/language.h
diff options
context:
space:
mode:
authorAndrew Burgess <andrew.burgess@embecosm.com>2020-07-05 09:29:34 +0100
committerAndrew Burgess <andrew.burgess@embecosm.com>2020-09-16 10:16:48 +0100
commit22c12a6c70a0bf1c292478436f12df0a2d84c2a2 (patch)
treeeb8f23e76fedac0151280623ebe9d055819b34d3 /gdb/language.h
parent1c236ddd45b182b6f4895b276183cdd8382d3e1b (diff)
downloadgdb-22c12a6c70a0bf1c292478436f12df0a2d84c2a2.zip
gdb-22c12a6c70a0bf1c292478436f12df0a2d84c2a2.tar.gz
gdb-22c12a6c70a0bf1c292478436f12df0a2d84c2a2.tar.bz2
gdb: Convert language_data::string_lower_bound to a method
Convert language_data::string_lower_bound member variable to a virtual method language_defn::string_lower_bound. Over all of the languages we currently support there are currently only two values for the lower bound, 0 or 1. I noticed that in all cases, if a language has C style arrays then the lower bound is 0, otherwise the lower bound is 1. So the default for the virtual method in language.h makes use of this, which means languages don't have to worry about providing a string_lower_bound method at all. Except for Modula2. This language is defined to not have C style arrays, but has a string_lower_bound index of 0, this behaviour is maintained after this commit by having Modula2 be the only language that overrides the string_lower_bound method. There should be no user visible changes after this commit. gdb/ChangeLog: * ada-lang.c (ada_language_data): Remove string_lower_bound initializer. * c-lang.c (c_language_data): Likewise. (cplus_language_data): Likewise. (asm_language_data): Likewise. (minimal_language_data): Likewise. * d-lang.c (d_language_data): Likewise. * f-lang.c (f_language_data): Likewise. * go-lang.c (go_language_data): Likewise. * language.c (unknown_language_data): Likewise. (auto_language_data): Likewise. * language.h (language_data): Remove string_lower_bound field. (language_defn::string_lower_bound): New member function. * m2-lang.c (m2_language_data): Remove string_lower_bound initializer. (m2_language::string_lower_bound): New member function. * objc-lang.c (objc_language_data): Remove string_lower_bound initializer. * opencl-lang.c (opencl_language_data): Likewise. * p-lang.c (pascal_language_data): Likewise. * rust-lang.c (rust_language_data): Likewise. * valops.c (value_cstring): Update call to string_lower_bound. (value_string): Likewise. * value.c (allocate_repeated_value): Likewise.
Diffstat (limited to 'gdb/language.h')
-rw-r--r--gdb/language.h11
1 files changed, 8 insertions, 3 deletions
diff --git a/gdb/language.h b/gdb/language.h
index 83014e4..d83ea13 100644
--- a/gdb/language.h
+++ b/gdb/language.h
@@ -232,9 +232,6 @@ struct language_data
const struct op_print *la_op_print_tab;
- /* Index to use for extracting the first element of a string. */
- char string_lower_bound;
-
/* Various operations on varobj. */
const struct lang_varobj_ops *la_varobj_ops;
};
@@ -568,6 +565,14 @@ struct language_defn : language_data
virtual bool c_style_arrays_p () const
{ return true; }
+ /* Return the index to use for extracting the first element of a string,
+ or as the lower bound when creating a new string. The default of
+ choosing 0 or 1 based on C_STYLE_ARRAYS_P works for all currently
+ supported languages except Modula-2. */
+
+ virtual char string_lower_bound () const
+ { return c_style_arrays_p () ? 0 : 1; }
+
protected:
/* This is the overridable part of the GET_SYMBOL_NAME_MATCHER method.