diff options
author | Andrew Burgess <andrew.burgess@embecosm.com> | 2020-07-12 10:15:32 +0100 |
---|---|---|
committer | Andrew Burgess <andrew.burgess@embecosm.com> | 2020-09-16 11:01:24 +0100 |
commit | efdf6a733d2a59a1a07ec61e848fa9e128259fe3 (patch) | |
tree | 896cf4b18a264b7128c28eaf84d4a694fc5eea01 /gdb | |
parent | bf92aec5884b64a73a334aea875c68e8d1f959fc (diff) | |
download | gdb-efdf6a733d2a59a1a07ec61e848fa9e128259fe3.zip gdb-efdf6a733d2a59a1a07ec61e848fa9e128259fe3.tar.gz gdb-efdf6a733d2a59a1a07ec61e848fa9e128259fe3.tar.bz2 |
gdb: Convert language_data::la_range_check to a method
Convert language_data::la_range_check member variable to a virtual
method language_defn::range_checking_on_by_default.
Where the previous member variable was of type 'enum range_check', the
new member function returns a boolean that selects between range
checking being on or off. This removes the possibility of a language
having its default be the third enum state, range_check_warn, which
no language currently used.
This all makes sense I think, the language's true/false provides the
default when the global 'set check range' is set to 'auto'.
There should be no user visible changes after this commit.
gdb/ChangeLog:
* ada-lang.c (ada_language_data): Remove la_range_check
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.
(f_language::range_checking_on_by_default): New member function.
* go-lang.c (go_language_data): Remove la_range_check initializer.
* language.c (enum range_mode): Moved here from language.h.
(range_mode): Made static.
(show_range_command): Update to use
range_checking_on_by_default.
(set_range_command): Likewise.
(set_range_case): Likewise.
(unknown_language_data): Remove la_range_check initializer.
(auto_language_data): Likewise.
* language.h (range_mode): Delete. Enum definition moved to
language.c.
(language_data): Remove la_range_check field.
(language_defn::range_checking_on_by_default): New member
function.
* m2-lang.c (m2_language_data): Remove la_range_check initializer.
(m2_language::range_checking_on_by_default): New member function.
* objc-lang.c (objc_language_data): Remove la_range_check
initializer.
* opencl-lang.c (opencl_language_data): Likewise.
* p-lang.c (pascal_language_data): Likewise.
(pascal_language::range_checking_on_by_default): New member
function.
* rust-lang.c (rust_language_data): Remove la_range_check
initializer.
(rust_language::range_checking_on_by_default): New member
function.
Diffstat (limited to 'gdb')
-rw-r--r-- | gdb/ChangeLog | 38 | ||||
-rw-r--r-- | gdb/ada-lang.c | 1 | ||||
-rw-r--r-- | gdb/c-lang.c | 4 | ||||
-rw-r--r-- | gdb/d-lang.c | 1 | ||||
-rw-r--r-- | gdb/f-lang.c | 6 | ||||
-rw-r--r-- | gdb/go-lang.c | 1 | ||||
-rw-r--r-- | gdb/language.c | 24 | ||||
-rw-r--r-- | gdb/language.h | 21 | ||||
-rw-r--r-- | gdb/m2-lang.c | 6 | ||||
-rw-r--r-- | gdb/objc-lang.c | 1 | ||||
-rw-r--r-- | gdb/opencl-lang.c | 1 | ||||
-rw-r--r-- | gdb/p-lang.c | 6 | ||||
-rw-r--r-- | gdb/rust-lang.c | 6 |
13 files changed, 83 insertions, 33 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog index ce9d3ae..b46e89c 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,5 +1,43 @@ 2020-09-16 Andrew Burgess <andrew.burgess@embecosm.com> + * ada-lang.c (ada_language_data): Remove la_range_check + 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. + (f_language::range_checking_on_by_default): New member function. + * go-lang.c (go_language_data): Remove la_range_check initializer. + * language.c (enum range_mode): Moved here from language.h. + (range_mode): Made static. + (show_range_command): Update to use + range_checking_on_by_default. + (set_range_command): Likewise. + (set_range_case): Likewise. + (unknown_language_data): Remove la_range_check initializer. + (auto_language_data): Likewise. + * language.h (range_mode): Delete. Enum definition moved to + language.c. + (language_data): Remove la_range_check field. + (language_defn::range_checking_on_by_default): New member + function. + * m2-lang.c (m2_language_data): Remove la_range_check initializer. + (m2_language::range_checking_on_by_default): New member function. + * objc-lang.c (objc_language_data): Remove la_range_check + initializer. + * opencl-lang.c (opencl_language_data): Likewise. + * p-lang.c (pascal_language_data): Likewise. + (pascal_language::range_checking_on_by_default): New member + function. + * rust-lang.c (rust_language_data): Remove la_range_check + initializer. + (rust_language::range_checking_on_by_default): New member + function. + +2020-09-16 Andrew Burgess <andrew.burgess@embecosm.com> + * dwarf2/read.c (dwarf2_physname): Remove special case for language_go. * go-lang.c (go_language::store_sym_names_in_linkage_form_p): New diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c index 723e08e..0a0dc21 100644 --- a/gdb/ada-lang.c +++ b/gdb/ada-lang.c @@ -13708,7 +13708,6 @@ ada_get_symbol_name_matcher (const lookup_name_info &lookup_name) extern const struct language_data ada_language_data = { - range_check_off, case_sensitive_on, /* Yes, Ada is case-insensitive, but that's not quite what this means. */ array_row_major, diff --git a/gdb/c-lang.c b/gdb/c-lang.c index c8fe630..88af458 100644 --- a/gdb/c-lang.c +++ b/gdb/c-lang.c @@ -875,7 +875,6 @@ const struct exp_descriptor exp_descriptor_c = extern const struct language_data c_language_data = { - range_check_off, case_sensitive_on, array_row_major, macro_expansion_c, @@ -985,7 +984,6 @@ enum cplus_primitive_types { extern const struct language_data cplus_language_data = { - range_check_off, case_sensitive_on, array_row_major, macro_expansion_c, @@ -1193,7 +1191,6 @@ static cplus_language cplus_language_defn; extern const struct language_data asm_language_data = { - range_check_off, case_sensitive_on, array_row_major, macro_expansion_c, @@ -1264,7 +1261,6 @@ static asm_language asm_language_defn; extern const struct language_data minimal_language_data = { - range_check_off, case_sensitive_on, array_row_major, macro_expansion_c, diff --git a/gdb/d-lang.c b/gdb/d-lang.c index 2c6da47..4cbe9d8 100644 --- a/gdb/d-lang.c +++ b/gdb/d-lang.c @@ -128,7 +128,6 @@ enum d_primitive_types { extern const struct language_data d_language_data = { - range_check_off, case_sensitive_on, array_row_major, macro_expansion_no, diff --git a/gdb/f-lang.c b/gdb/f-lang.c index f4202c3..dc5c085 100644 --- a/gdb/f-lang.c +++ b/gdb/f-lang.c @@ -486,7 +486,6 @@ static const struct exp_descriptor exp_descriptor_f = extern const struct language_data f_language_data = { - range_check_on, case_sensitive_off, array_column_major, macro_expansion_no, @@ -722,6 +721,11 @@ public: bool c_style_arrays_p () const override { return false; } + /* See language.h. */ + + bool range_checking_on_by_default () const override + { return true; } + protected: /* See language.h. */ diff --git a/gdb/go-lang.c b/gdb/go-lang.c index dfc0ddd..f5abd51 100644 --- a/gdb/go-lang.c +++ b/gdb/go-lang.c @@ -508,7 +508,6 @@ enum go_primitive_types { extern const struct language_data go_language_data = { - range_check_off, case_sensitive_on, array_row_major, macro_expansion_no, diff --git a/gdb/language.c b/gdb/language.c index 3503408..56b3b2e 100644 --- a/gdb/language.c +++ b/gdb/language.c @@ -49,12 +49,21 @@ static void set_range_case (void); +/* range_mode == + range_mode_auto: range_check set automatically to default of language. + range_mode_manual: range_check set manually by user. */ + +enum range_mode + { + range_mode_auto, range_mode_manual + }; + /* The current (default at startup) state of type and range checking. (If the modes are set to "auto", though, these are changed based on the default language at startup, and then again based on the language of the first source file. */ -enum range_mode range_mode = range_mode_auto; +static enum range_mode range_mode = range_mode_auto; enum range_check range_check = range_check_off; enum case_mode case_mode = case_mode_auto; enum case_sensitivity case_sensitivity = case_sensitive_on; @@ -209,7 +218,9 @@ show_range_command (struct ui_file *file, int from_tty, fprintf_filtered (gdb_stdout, _("Range checking is \"%s\".\n"), value); - if (range_check != current_language->la_range_check) + if (range_check == range_check_warn + || ((range_check == range_check_on) + != current_language->range_checking_on_by_default ())) warning (_("the current range check setting " "does not match the language.\n")); } @@ -245,7 +256,9 @@ set_range_command (const char *ignore, internal_error (__FILE__, __LINE__, _("Unrecognized range check setting: \"%s\""), range); } - if (range_check != current_language->la_range_check) + if (range_check == range_check_warn + || ((range_check == range_check_on) + != current_language->range_checking_on_by_default ())) warning (_("the current range check setting " "does not match the language.\n")); } @@ -329,7 +342,8 @@ static void set_range_case (void) { if (range_mode == range_mode_auto) - range_check = current_language->la_range_check; + range_check = (current_language->range_checking_on_by_default () + ? range_check_on : range_check_off); if (case_mode == case_mode_auto) case_sensitivity = current_language->la_case_sensitivity; @@ -775,7 +789,6 @@ unknown_language_arch_info (struct gdbarch *gdbarch, extern const struct language_data unknown_language_data = { - range_check_off, case_sensitive_on, array_row_major, macro_expansion_no, @@ -912,7 +925,6 @@ static unknown_language unknown_language_defn; extern const struct language_data auto_language_data = { - range_check_off, case_sensitive_on, array_row_major, macro_expansion_no, diff --git a/gdb/language.h b/gdb/language.h index 10a9e70..ffdcdbc 100644 --- a/gdb/language.h +++ b/gdb/language.h @@ -42,16 +42,6 @@ class innermost_block_tracker; #define MAX_FORTRAN_DIMS 7 /* Maximum number of F77 array dims. */ -/* range_mode == - range_mode_auto: range_check set automatically to default of language. - range_mode_manual: range_check set manually by user. */ - -extern enum range_mode - { - range_mode_auto, range_mode_manual - } -range_mode; - /* range_check == range_check_on: Ranges are checked in GDB expressions, producing errors. range_check_warn: Ranges are checked, producing warnings. @@ -188,10 +178,6 @@ extern const char *default_word_break_characters (void); struct language_data { - /* Default range checking. */ - - enum range_check la_range_check; - /* Default case sensitivity. */ enum case_sensitivity la_case_sensitivity; @@ -572,6 +558,13 @@ struct language_defn : language_data virtual bool store_sym_names_in_linkage_form_p () const { return false; } + /* Default range checking preference. The return value from this + function provides the automatic setting for 'set check range'. As a + consequence a user is free to override this setting if they want. */ + + virtual bool range_checking_on_by_default () const + { return false; } + 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 577d819..785436c 100644 --- a/gdb/m2-lang.c +++ b/gdb/m2-lang.c @@ -199,7 +199,6 @@ const struct exp_descriptor exp_descriptor_modula2 = extern const struct language_data m2_language_data = { - range_check_on, case_sensitive_on, array_row_major, macro_expansion_no, @@ -444,6 +443,11 @@ public: char string_lower_bound () const override { return 0; } + + /* See language.h. */ + + bool range_checking_on_by_default () const override + { return true; } }; /* Single instance of the M2 language. */ diff --git a/gdb/objc-lang.c b/gdb/objc-lang.c index 7b2dbd8..1788910 100644 --- a/gdb/objc-lang.c +++ b/gdb/objc-lang.c @@ -323,7 +323,6 @@ static const struct op_print objc_op_print_tab[] = extern const struct language_data objc_language_data = { - range_check_off, case_sensitive_on, array_row_major, macro_expansion_c, diff --git a/gdb/opencl-lang.c b/gdb/opencl-lang.c index f8105f2..2ad9321 100644 --- a/gdb/opencl-lang.c +++ b/gdb/opencl-lang.c @@ -1006,7 +1006,6 @@ const struct exp_descriptor exp_descriptor_opencl = /* Constant data representing the OpenCL language. */ extern const struct language_data opencl_language_data = { - range_check_off, case_sensitive_on, array_row_major, macro_expansion_c, diff --git a/gdb/p-lang.c b/gdb/p-lang.c index 9ca1427..2325aca 100644 --- a/gdb/p-lang.c +++ b/gdb/p-lang.c @@ -252,7 +252,6 @@ enum pascal_primitive_types { extern const struct language_data pascal_language_data = { - range_check_on, case_sensitive_on, array_row_major, macro_expansion_no, @@ -508,6 +507,11 @@ public: const char *name_of_this () const override { return "this"; } + + /* See language.h. */ + + bool range_checking_on_by_default () const override + { return true; } }; /* Single instance of the Pascal language class. */ diff --git a/gdb/rust-lang.c b/gdb/rust-lang.c index 25bd965..4489cab 100644 --- a/gdb/rust-lang.c +++ b/gdb/rust-lang.c @@ -1901,7 +1901,6 @@ static const struct exp_descriptor exp_descriptor_rust = extern const struct language_data rust_language_data = { - range_check_on, case_sensitive_on, array_row_major, macro_expansion_no, @@ -2149,6 +2148,11 @@ public: && rust_slice_type_p (type) && strcmp (type->name (), "&str") == 0)); } + + /* See language.h. */ + + bool range_checking_on_by_default () const override + { return true; } }; /* Single instance of the Rust language class. */ |