aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gdb/ChangeLog27
-rw-r--r--gdb/ada-lang.c1
-rw-r--r--gdb/c-lang.c4
-rw-r--r--gdb/d-lang.c1
-rw-r--r--gdb/f-lang.c1
-rw-r--r--gdb/go-lang.c1
-rw-r--r--gdb/language.c2
-rw-r--r--gdb/language.h11
-rw-r--r--gdb/m2-lang.c7
-rw-r--r--gdb/objc-lang.c1
-rw-r--r--gdb/opencl-lang.c1
-rw-r--r--gdb/p-lang.c1
-rw-r--r--gdb/rust-lang.c1
-rw-r--r--gdb/valops.c4
-rw-r--r--gdb/value.c5
15 files changed, 47 insertions, 21 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 741e9bf..a337c60 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,32 @@
2020-09-16 Andrew Burgess <andrew.burgess@embecosm.com>
+ * 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.
+
+2020-09-16 Andrew Burgess <andrew.burgess@embecosm.com>
+
* valops.c (value_repeat): Fix incorrect argument name in comment.
2020-09-16 Andrew Burgess <andrew.burgess@embecosm.com>
diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c
index 859dcec..b90e7a0 100644
--- a/gdb/ada-lang.c
+++ b/gdb/ada-lang.c
@@ -13716,7 +13716,6 @@ extern const struct language_data ada_language_data =
&ada_exp_descriptor,
true, /* la_store_sym_names_in_linkage_form_p */
ada_op_print_tab, /* expression operators for printing */
- 1, /* String lower bound */
&ada_varobj_ops,
};
diff --git a/gdb/c-lang.c b/gdb/c-lang.c
index 41eac2d..ecb339c 100644
--- a/gdb/c-lang.c
+++ b/gdb/c-lang.c
@@ -882,7 +882,6 @@ extern const struct language_data c_language_data =
&exp_descriptor_c,
true, /* la_store_sym_names_in_linkage_form_p */
c_op_print_tab, /* expression operators for printing */
- 0, /* String lower bound */
&c_varobj_ops,
};
@@ -989,7 +988,6 @@ extern const struct language_data cplus_language_data =
&exp_descriptor_c,
false, /* la_store_sym_names_in_linkage_form_p */
c_op_print_tab, /* expression operators for printing */
- 0, /* String lower bound */
&cplus_varobj_ops,
};
@@ -1199,7 +1197,6 @@ extern const struct language_data asm_language_data =
&exp_descriptor_c,
true, /* la_store_sym_names_in_linkage_form_p */
c_op_print_tab, /* expression operators for printing */
- 0, /* String lower bound */
&default_varobj_ops,
};
@@ -1267,7 +1264,6 @@ extern const struct language_data minimal_language_data =
&exp_descriptor_c,
true, /* la_store_sym_names_in_linkage_form_p */
c_op_print_tab, /* expression operators for printing */
- 0, /* String lower bound */
&default_varobj_ops,
};
diff --git a/gdb/d-lang.c b/gdb/d-lang.c
index 6791208..f75a973 100644
--- a/gdb/d-lang.c
+++ b/gdb/d-lang.c
@@ -135,7 +135,6 @@ extern const struct language_data d_language_data =
&exp_descriptor_c,
false, /* la_store_sym_names_in_linkage_form_p */
d_op_print_tab, /* Expression operators for printing. */
- 0, /* String lower bound. */
&default_varobj_ops,
};
diff --git a/gdb/f-lang.c b/gdb/f-lang.c
index 649716b..344bdb8 100644
--- a/gdb/f-lang.c
+++ b/gdb/f-lang.c
@@ -493,7 +493,6 @@ extern const struct language_data f_language_data =
&exp_descriptor_f,
false, /* la_store_sym_names_in_linkage_form_p */
f_op_print_tab, /* expression operators for printing */
- 1, /* String lower bound */
&default_varobj_ops,
};
diff --git a/gdb/go-lang.c b/gdb/go-lang.c
index c2724e3..c0ad0be 100644
--- a/gdb/go-lang.c
+++ b/gdb/go-lang.c
@@ -515,7 +515,6 @@ extern const struct language_data go_language_data =
&exp_descriptor_c,
false, /* la_store_sym_names_in_linkage_form_p */
go_op_print_tab, /* Expression operators for printing. */
- 0, /* String lower bound. */
&default_varobj_ops,
};
diff --git a/gdb/language.c b/gdb/language.c
index 9a496ae..1866a96 100644
--- a/gdb/language.c
+++ b/gdb/language.c
@@ -782,7 +782,6 @@ extern const struct language_data unknown_language_data =
&exp_descriptor_standard,
true, /* store_sym_names_in_linkage_form_p */
unk_op_print_tab, /* expression operators for printing */
- 0, /* String lower bound */
&default_varobj_ops,
};
@@ -916,7 +915,6 @@ extern const struct language_data auto_language_data =
&exp_descriptor_standard,
false, /* store_sym_names_in_linkage_form_p */
unk_op_print_tab, /* expression operators for printing */
- 0, /* String lower bound */
&default_varobj_ops,
};
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.
diff --git a/gdb/m2-lang.c b/gdb/m2-lang.c
index 9dd5577..7bd9e71 100644
--- a/gdb/m2-lang.c
+++ b/gdb/m2-lang.c
@@ -206,7 +206,6 @@ extern const struct language_data m2_language_data =
&exp_descriptor_modula2,
false, /* la_store_sym_names_in_linkage_form_p */
m2_op_print_tab, /* expression operators for printing */
- 0, /* String lower bound */
&default_varobj_ops,
};
@@ -440,6 +439,12 @@ public:
bool c_style_arrays_p () const override
{ return false; }
+
+ /* See language.h. Despite not having C-style arrays, Modula-2 uses 0
+ for its string lower bounds. */
+
+ char string_lower_bound () const override
+ { return 0; }
};
/* Single instance of the M2 language. */
diff --git a/gdb/objc-lang.c b/gdb/objc-lang.c
index 66b7b50..337b7a4 100644
--- a/gdb/objc-lang.c
+++ b/gdb/objc-lang.c
@@ -330,7 +330,6 @@ extern const struct language_data objc_language_data =
&exp_descriptor_standard,
false, /* la_store_sym_names_in_linkage_form_p */
objc_op_print_tab, /* Expression operators for printing */
- 0, /* String lower bound */
&default_varobj_ops,
};
diff --git a/gdb/opencl-lang.c b/gdb/opencl-lang.c
index 1ac3aa4..2e3e54a 100644
--- a/gdb/opencl-lang.c
+++ b/gdb/opencl-lang.c
@@ -1013,7 +1013,6 @@ extern const struct language_data opencl_language_data =
&exp_descriptor_opencl,
false, /* la_store_sym_names_in_linkage_form_p */
c_op_print_tab, /* expression operators for printing */
- 0, /* String lower bound */
&default_varobj_ops,
};
diff --git a/gdb/p-lang.c b/gdb/p-lang.c
index 66ba51a..b075571 100644
--- a/gdb/p-lang.c
+++ b/gdb/p-lang.c
@@ -259,7 +259,6 @@ extern const struct language_data pascal_language_data =
&exp_descriptor_standard,
false, /* la_store_sym_names_in_linkage_form_p */
pascal_op_print_tab, /* expression operators for printing */
- 0, /* String lower bound */
&default_varobj_ops,
};
diff --git a/gdb/rust-lang.c b/gdb/rust-lang.c
index de971e6..12fc138 100644
--- a/gdb/rust-lang.c
+++ b/gdb/rust-lang.c
@@ -1908,7 +1908,6 @@ extern const struct language_data rust_language_data =
&exp_descriptor_rust,
false, /* la_store_sym_names_in_linkage_form_p */
c_op_print_tab, /* expression operators for printing */
- 0, /* String lower bound */
&default_varobj_ops,
};
diff --git a/gdb/valops.c b/gdb/valops.c
index cf4cbab..0995a76 100644
--- a/gdb/valops.c
+++ b/gdb/valops.c
@@ -1644,7 +1644,7 @@ struct value *
value_cstring (const char *ptr, ssize_t len, struct type *char_type)
{
struct value *val;
- int lowbound = current_language->string_lower_bound;
+ int lowbound = current_language->string_lower_bound ();
ssize_t highbound = len / TYPE_LENGTH (char_type);
struct type *stringtype
= lookup_array_range_type (char_type, lowbound, highbound + lowbound - 1);
@@ -1667,7 +1667,7 @@ struct value *
value_string (const char *ptr, ssize_t len, struct type *char_type)
{
struct value *val;
- int lowbound = current_language->string_lower_bound;
+ int lowbound = current_language->string_lower_bound ();
ssize_t highbound = len / TYPE_LENGTH (char_type);
struct type *stringtype
= lookup_string_range_type (char_type, lowbound, highbound + lowbound - 1);
diff --git a/gdb/value.c b/gdb/value.c
index c72b2fd..c8d9414 100644
--- a/gdb/value.c
+++ b/gdb/value.c
@@ -1041,7 +1041,10 @@ allocate_value (struct type *type)
struct value *
allocate_repeat_value (struct type *type, int count)
{
- int low_bound = current_language->string_lower_bound; /* ??? */
+ /* Despite the fact that we are really creating an array of TYPE here, we
+ use the string lower bound as the array lower bound. This seems to
+ work fine for now. */
+ int low_bound = current_language->string_lower_bound ();
/* FIXME-type-allocation: need a way to free this type when we are
done with it. */
struct type *array_type