From acc4efdecd034e70feffeb15799745880ce2c45b Mon Sep 17 00:00:00 2001 From: Per Bothner Date: Thu, 26 Jan 1995 02:32:25 +0000 Subject: [PATCH] * language.h (struct language_defn): New field c_style_arrays. * language.c (unknown_language_defn, auto_language_defn, local_language_defn), c-lang.c (c_language_defn, cplus_language_defn, asm_language_defn): Set c_style_arrays to true. * m2-lang.c (m2_language_defn), ch-lang.c (chill_language_defn), f-lang.c (f_language_defn): Set c_style_arrays to false. * valops.c (value_string): If c_style_array is not set, allocate string in gdb (not inferior) using allocate_value. * value.h (COERCE_ARRAY), valops.c (value_addr, value_arg_coerce): Only call value_coerce_array if current_language->c_style_arrays. * values.c: Add #include "language.h". (Needed for COERCE_ARRAY.) * valops.c (chill_varying_type): New predicate. * valops.c (value_cast): Support assigning a fixed string or array to a variable string/array structure. * valarith.c (value_subscripted_rvalue): Extra parameter lowerbound. Check index>=lowerbound, and then add lowerbound to index here, instead of in caller. Generalize to arbitrary lval_types. (value_subscript): Use enhanced value_subscripted_rvalue if c_style_arrays is false (and index is in range). --- gdb/ChangeLog | 25 +++++++++++++++++++++++++ gdb/c-lang.c | 3 +++ gdb/ch-lang.c | 1 + gdb/f-lang.c | 1 + gdb/language.c | 3 +++ gdb/language.h | 5 +++++ gdb/m2-lang.c | 1 + gdb/values.c | 1 + 8 files changed, 40 insertions(+) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 9dac0e49de7..7954cfc7bdc 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,28 @@ +Wed Jan 25 18:13:14 1995 Per Bothner + + * language.h (struct language_defn): New field c_style_arrays. + * language.c (unknown_language_defn, auto_language_defn, + local_language_defn), c-lang.c (c_language_defn, cplus_language_defn, + asm_language_defn): Set c_style_arrays to true. + * m2-lang.c (m2_language_defn), ch-lang.c (chill_language_defn), + f-lang.c (f_language_defn): Set c_style_arrays to false. + * valops.c (value_string): If c_style_array is not set, + allocate string in gdb (not inferior) using allocate_value. + + * value.h (COERCE_ARRAY), valops.c (value_addr, value_arg_coerce): + Only call value_coerce_array if current_language->c_style_arrays. + * values.c: Add #include "language.h". (Needed for COERCE_ARRAY.) + + * valops.c (chill_varying_type): New predicate. + * valops.c (value_cast): Support assigning a fixed string or array + to a variable string/array structure. + + * valarith.c (value_subscripted_rvalue): Extra parameter lowerbound. + Check index>=lowerbound, and then add lowerbound to index here, + instead of in caller. Generalize to arbitrary lval_types. + (value_subscript): Use enhanced value_subscripted_rvalue if + c_style_arrays is false (and index is in range). + Wed Jan 25 18:23:46 1995 Stu Grossman (grossman@cygnus.com) * gdbtk.c (gdbtk_init): Prevent segfault when gdbtk.tcl can't be diff --git a/gdb/c-lang.c b/gdb/c-lang.c index 98d09eb43b5..eccd2304879 100644 --- a/gdb/c-lang.c +++ b/gdb/c-lang.c @@ -410,6 +410,7 @@ const struct language_defn c_language_defn = { {"%ld", "", "d", ""}, /* Decimal format info */ {"0x%lx", "0x", "x", ""}, /* Hex format info */ c_op_print_tab, /* expression operators for printing */ + 1, /* c-style arrays */ LANG_MAGIC }; @@ -432,6 +433,7 @@ const struct language_defn cplus_language_defn = { {"%ld", "", "d", ""}, /* Decimal format info */ {"0x%lx", "0x", "x", ""}, /* Hex format info */ c_op_print_tab, /* expression operators for printing */ + 1, /* c-style arrays */ LANG_MAGIC }; @@ -454,6 +456,7 @@ const struct language_defn asm_language_defn = { {"%ld", "", "d", ""}, /* Decimal format info */ {"0x%lx", "0x", "x", ""}, /* Hex format info */ c_op_print_tab, /* expression operators for printing */ + 1, /* c-style arrays */ LANG_MAGIC }; diff --git a/gdb/ch-lang.c b/gdb/ch-lang.c index bfd77288631..a3d2d143c23 100644 --- a/gdb/ch-lang.c +++ b/gdb/ch-lang.c @@ -323,6 +323,7 @@ const struct language_defn chill_language_defn = { {"D'%ld", "D'", "d", ""}, /* Decimal format info */ {"H'%lx", "H'", "x", ""}, /* Hex format info */ chill_op_print_tab, /* expression operators for printing */ + 0, /* arrays are first-class (not c-style) */ LANG_MAGIC }; diff --git a/gdb/f-lang.c b/gdb/f-lang.c index 7a1f7142b6f..0232a548b85 100644 --- a/gdb/f-lang.c +++ b/gdb/f-lang.c @@ -431,6 +431,7 @@ const struct language_defn f_language_defn = { {"%d", "", "d", ""}, /* Decimal format info */ {"0x%x", "0x", "x", ""}, /* Hex format info */ f_op_print_tab, /* expression operators for printing */ + 0, /* arrays are first-class (not c-style) */ LANG_MAGIC }; diff --git a/gdb/language.c b/gdb/language.c index f27512c071b..d8cbd569911 100644 --- a/gdb/language.c +++ b/gdb/language.c @@ -1200,6 +1200,7 @@ const struct language_defn unknown_language_defn = { {"%ld", "", "d", ""}, /* Decimal format info */ {"0x%lx", "0x", "x", ""}, /* Hex format info */ unk_op_print_tab, /* expression operators for printing */ + 1, /* c-style arrays */ LANG_MAGIC }; @@ -1223,6 +1224,7 @@ const struct language_defn auto_language_defn = { {"%ld", "", "d", ""}, /* Decimal format info */ {"0x%lx", "0x", "x", ""}, /* Hex format info */ unk_op_print_tab, /* expression operators for printing */ + 1, /* c-style arrays */ LANG_MAGIC }; @@ -1245,6 +1247,7 @@ const struct language_defn local_language_defn = { {"%ld", "", "d", ""}, /* Decimal format info */ {"0x%lx", "0x", "x", ""}, /* Hex format info */ unk_op_print_tab, /* expression operators for printing */ + 1, /* c-style arrays */ LANG_MAGIC }; diff --git a/gdb/language.h b/gdb/language.h index 7ab04dba1b8..6122bbfc21c 100644 --- a/gdb/language.h +++ b/gdb/language.h @@ -172,6 +172,11 @@ struct language_defn const struct op_print *la_op_print_tab; + /* Zero if the language has first-class arrays. True if there are no + array values, and array objects decay to pointers, as in C. */ + + char c_style_arrays; + /* Add fields above this point, so the magic number is always last. */ /* Magic number for compat checking */ diff --git a/gdb/m2-lang.c b/gdb/m2-lang.c index 8d2f2a58e23..c7b75301039 100644 --- a/gdb/m2-lang.c +++ b/gdb/m2-lang.c @@ -412,6 +412,7 @@ const struct language_defn m2_language_defn = { {"%ld", "", "d", ""}, /* Decimal format info */ {"0%lXH", "0", "X", "H"}, /* Hex format info */ m2_op_print_tab, /* expression operators for printing */ + 0, /* arrays are first-class (not c-style) */ LANG_MAGIC }; diff --git a/gdb/values.c b/gdb/values.c index aa4a4f2090a..788222e528c 100644 --- a/gdb/values.c +++ b/gdb/values.c @@ -28,6 +28,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "command.h" #include "gdbcmd.h" #include "target.h" +#include "language.h" #include "demangle.h" /* Local function prototypes. */ -- 2.30.2