aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gdb/ChangeLog55
-rw-r--r--gdb/ada-lang.c15
-rw-r--r--gdb/c-lang.c45
-rw-r--r--gdb/d-lang.c14
-rw-r--r--gdb/f-lang.c19
-rw-r--r--gdb/go-lang.c1
-rw-r--r--gdb/language.c10
-rw-r--r--gdb/language.h18
-rw-r--r--gdb/m2-lang.c1
-rw-r--r--gdb/objc-lang.c14
-rw-r--r--gdb/opencl-lang.c1
-rw-r--r--gdb/p-lang.c14
-rw-r--r--gdb/rust-lang.c14
-rw-r--r--gdb/symfile.c1
14 files changed, 147 insertions, 75 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index a58c490..82a621d 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,60 @@
2020-09-16 Andrew Burgess <andrew.burgess@embecosm.com>
+ * ada-lang.c (ada_extensions): Delete, moved into
+ ada_language::filename_extensions.
+ (ada_language_data): Remove la_filename_extensions initializer.
+ (ada_language::filename_extensions): New member function.
+ * c-lang.c (c_extensions): Delete, moved into
+ c_language::filename_extensions.
+ (c_language_data): Remove la_filename_extensions initializer.
+ (c_language::filename_extensions): New member function.
+ (cplus_extensions): Delete, moved into
+ cplus_language::filename_extensions.
+ (cplus_language_data): Remove la_filename_extensions initializer.
+ (cplus_language::filename_extensions): New member function.
+ (asm_extensions): Delete, moved into
+ asm_language::filename_extensions.
+ (asm_language_data): Remove la_filename_extensions initializer.
+ (asm_language::filename_extensions): New member function.
+ (minimal_language_data): Remove la_filename_extensions
+ initializer.
+ * d-lang.c (d_extensions): Delete, moved into
+ d_language::filename_extensions.
+ (d_language_data): Remove la_filename_extensions initializer.
+ (d_language::filename_extensions): New member function.
+ * f-lang.c (f_extensions): Delete, moved into
+ f_language::filename_extensions.
+ (f_language_data): Remove la_filename_extensions initializer.
+ (f_language::filename_extensions): New member function.
+ * go-lang.c (go_language_data): Remove la_filename_extensions
+ initializer.
+ * language.c (add_set_language_command): Update now that
+ filename_extensions returns a vector.
+ (unknown_language_data): Remove la_filename_extensions
+ initializer.
+ (auto_language_data): Likewise.
+ * language.h (language_data): Remove la_filename_extensions field.
+ (language_defn::filename_extensions): New member function.
+ * m2-lang.c (m2_language_data): Remove la_filename_extensions
+ initializer.
+ * objc-lang.c (objc_extensions): Delete, moved into
+ objc_language::filename_extensions.
+ (objc_language_data): Remove la_filename_extensions initializer.
+ (objc_language::filename_extensions): New member function.
+ * opencl-lang.c (opencl_language_data): Remove
+ la_filename_extensions initializer.
+ * p-lang.c (pascal_extensions): Delete, moved into
+ pascal_language::filename_extensions.
+ (pascal_language_data): Remove la_filename_extensions initializer.
+ (pascal_language::filename_extensions): New member function.
+ * rust-lang.c (rust_extensions): Delete, moved into
+ rust_language::filename_extensions.
+ (rust_language_data): Remove la_filename_extensions initializer.
+ (rust_language::filename_extensions): New member function.
+ * symfile.c (add_filename_language): Add new assert.
+
+2020-09-16 Andrew Burgess <andrew.burgess@embecosm.com>
+
* ada-lang.c (ada_language_data): Remove la_name and
la_natural_name initializers.
(ada_language::name): New member function.
diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c
index fd9e6d3..b9cd9a3 100644
--- a/gdb/ada-lang.c
+++ b/gdb/ada-lang.c
@@ -13704,11 +13704,6 @@ ada_get_symbol_name_matcher (const lookup_name_info &lookup_name)
}
}
-static const char * const ada_extensions[] =
-{
- ".adb", ".ads", ".a", ".ada", ".dg", NULL
-};
-
/* Constant data that describes the Ada language. */
extern const struct language_data ada_language_data =
@@ -13719,7 +13714,6 @@ extern const struct language_data ada_language_data =
that's not quite what this means. */
array_row_major,
macro_expansion_no,
- ada_extensions,
&ada_exp_descriptor,
true, /* la_store_sym_names_in_linkage_form_p */
ada_op_print_tab, /* expression operators for printing */
@@ -13747,6 +13741,15 @@ public:
const char *natural_name () const override
{ return "Ada"; }
+ /* See language.h. */
+
+ const std::vector<const char *> &filename_extensions () const override
+ {
+ static const std::vector<const char *> extensions
+ = { ".adb", ".ads", ".a", ".ada", ".dg" };
+ return extensions;
+ }
+
/* Print an array element index using the Ada syntax. */
void print_array_index (struct type *index_type,
diff --git a/gdb/c-lang.c b/gdb/c-lang.c
index eb987f4..ce4620a 100644
--- a/gdb/c-lang.c
+++ b/gdb/c-lang.c
@@ -871,11 +871,6 @@ const struct exp_descriptor exp_descriptor_c =
evaluate_subexp_c
};
-static const char * const c_extensions[] =
-{
- ".c", NULL
-};
-
/* Constant data that describes the C language. */
extern const struct language_data c_language_data =
@@ -885,7 +880,6 @@ extern const struct language_data c_language_data =
case_sensitive_on,
array_row_major,
macro_expansion_c,
- c_extensions,
&exp_descriptor_c,
true, /* la_store_sym_names_in_linkage_form_p */
c_op_print_tab, /* expression operators for printing */
@@ -914,6 +908,14 @@ public:
{ return "C"; }
/* See language.h. */
+
+ const std::vector<const char *> &filename_extensions () const override
+ {
+ static const std::vector<const char *> extensions = { ".c" };
+ return extensions;
+ }
+
+ /* See language.h. */
void language_arch_info (struct gdbarch *gdbarch,
struct language_arch_info *lai) const override
{
@@ -978,11 +980,6 @@ enum cplus_primitive_types {
nr_cplus_primitive_types
};
-static const char * const cplus_extensions[] =
-{
- ".C", ".cc", ".cp", ".cpp", ".cxx", ".c++", NULL
-};
-
/* Constant data that describes the C++ language. */
extern const struct language_data cplus_language_data =
@@ -992,7 +989,6 @@ extern const struct language_data cplus_language_data =
case_sensitive_on,
array_row_major,
macro_expansion_c,
- cplus_extensions,
&exp_descriptor_c,
false, /* la_store_sym_names_in_linkage_form_p */
c_op_print_tab, /* expression operators for printing */
@@ -1022,6 +1018,15 @@ public:
/* See language.h. */
+ const std::vector<const char *> &filename_extensions () const override
+ {
+ static const std::vector<const char *> extensions
+ = { ".C", ".cc", ".cp", ".cpp", ".cxx", ".c++" };
+ return extensions;
+ }
+
+ /* See language.h. */
+
struct language_pass_by_ref_info pass_by_reference_info
(struct type *type) const override
{
@@ -1187,11 +1192,6 @@ protected:
static cplus_language cplus_language_defn;
-static const char * const asm_extensions[] =
-{
- ".s", ".sx", ".S", NULL
-};
-
/* Constant data that describes the ASM language. */
extern const struct language_data asm_language_data =
@@ -1201,7 +1201,6 @@ extern const struct language_data asm_language_data =
case_sensitive_on,
array_row_major,
macro_expansion_c,
- asm_extensions,
&exp_descriptor_c,
true, /* la_store_sym_names_in_linkage_form_p */
c_op_print_tab, /* expression operators for printing */
@@ -1229,6 +1228,15 @@ public:
const char *natural_name () const override
{ return "Assembly"; }
+ /* See language.h. */
+
+ const std::vector<const char *> &filename_extensions () const override
+ {
+ static const std::vector<const char *> extensions
+ = { ".s", ".sx", ".S" };
+ return extensions;
+ }
+
/* See language.h.
FIXME: Should this have its own arch info method? */
@@ -1263,7 +1271,6 @@ extern const struct language_data minimal_language_data =
case_sensitive_on,
array_row_major,
macro_expansion_c,
- NULL,
&exp_descriptor_c,
true, /* la_store_sym_names_in_linkage_form_p */
c_op_print_tab, /* expression operators for printing */
diff --git a/gdb/d-lang.c b/gdb/d-lang.c
index ff2bdf0..2c0ea38 100644
--- a/gdb/d-lang.c
+++ b/gdb/d-lang.c
@@ -124,11 +124,6 @@ enum d_primitive_types {
nr_d_primitive_types
};
-static const char * const d_extensions[] =
-{
- ".d", NULL
-};
-
/* Constant data that describes the D language. */
extern const struct language_data d_language_data =
@@ -138,7 +133,6 @@ extern const struct language_data d_language_data =
case_sensitive_on,
array_row_major,
macro_expansion_no,
- d_extensions,
&exp_descriptor_c,
false, /* la_store_sym_names_in_linkage_form_p */
d_op_print_tab, /* Expression operators for printing. */
@@ -167,6 +161,14 @@ public:
{ return "D"; }
/* See language.h. */
+
+ const std::vector<const char *> &filename_extensions () const override
+ {
+ static const std::vector<const char *> extensions = { ".d" };
+ return extensions;
+ }
+
+ /* See language.h. */
void language_arch_info (struct gdbarch *gdbarch,
struct language_arch_info *lai) const override
{
diff --git a/gdb/f-lang.c b/gdb/f-lang.c
index ace0c56..2c4d523 100644
--- a/gdb/f-lang.c
+++ b/gdb/f-lang.c
@@ -471,13 +471,6 @@ operator_check_f (struct expression *exp, int pos,
return 0;
}
-static const char * const f_extensions[] =
-{
- ".f", ".F", ".for", ".FOR", ".ftn", ".FTN", ".fpp", ".FPP",
- ".f90", ".F90", ".f95", ".F95", ".f03", ".F03", ".f08", ".F08",
- NULL
-};
-
/* Expression processing for Fortran. */
static const struct exp_descriptor exp_descriptor_f =
{
@@ -498,7 +491,6 @@ extern const struct language_data f_language_data =
case_sensitive_off,
array_column_major,
macro_expansion_no,
- f_extensions,
&exp_descriptor_f,
false, /* la_store_sym_names_in_linkage_form_p */
f_op_print_tab, /* expression operators for printing */
@@ -527,6 +519,17 @@ public:
{ return "Fortran"; }
/* See language.h. */
+
+ const std::vector<const char *> &filename_extensions () const override
+ {
+ static const std::vector<const char *> extensions = {
+ ".f", ".F", ".for", ".FOR", ".ftn", ".FTN", ".fpp", ".FPP",
+ ".f90", ".F90", ".f95", ".F95", ".f03", ".F03", ".f08", ".F08"
+ };
+ return extensions;
+ }
+
+ /* See language.h. */
void language_arch_info (struct gdbarch *gdbarch,
struct language_arch_info *lai) const override
{
diff --git a/gdb/go-lang.c b/gdb/go-lang.c
index 6e9b487..13fa0ed 100644
--- a/gdb/go-lang.c
+++ b/gdb/go-lang.c
@@ -513,7 +513,6 @@ extern const struct language_data go_language_data =
case_sensitive_on,
array_row_major,
macro_expansion_no,
- NULL,
&exp_descriptor_c,
false, /* la_store_sym_names_in_linkage_form_p */
go_op_print_tab, /* Expression operators for printing. */
diff --git a/gdb/language.c b/gdb/language.c
index 0b1b488..cc40762 100644
--- a/gdb/language.c
+++ b/gdb/language.c
@@ -503,12 +503,8 @@ add_set_language_command ()
/* Add the filename extensions. */
for (const auto &lang : language_defn::languages)
- if (lang->la_filename_extensions != NULL)
- {
- for (size_t i = 0; lang->la_filename_extensions[i] != NULL; ++i)
- add_filename_language (lang->la_filename_extensions[i],
- lang->la_language);
- }
+ for (const char * const &ext : lang->filename_extensions ())
+ add_filename_language (ext, lang->la_language);
/* Build the "help set language" docs. */
string_file doc;
@@ -784,7 +780,6 @@ extern const struct language_data unknown_language_data =
case_sensitive_on,
array_row_major,
macro_expansion_no,
- NULL,
&exp_descriptor_standard,
true, /* store_sym_names_in_linkage_form_p */
unk_op_print_tab, /* expression operators for printing */
@@ -921,7 +916,6 @@ extern const struct language_data auto_language_data =
case_sensitive_on,
array_row_major,
macro_expansion_no,
- NULL,
&exp_descriptor_standard,
false, /* store_sym_names_in_linkage_form_p */
unk_op_print_tab, /* expression operators for printing */
diff --git a/gdb/language.h b/gdb/language.h
index 980e364..9a7ad21 100644
--- a/gdb/language.h
+++ b/gdb/language.h
@@ -205,13 +205,6 @@ struct language_data
/* Style of macro expansion, if any, supported by this language. */
enum macro_expansion la_macro_expansion;
- /* A NULL-terminated array of file extensions for this language.
- The extension must include the ".", like ".c". If this
- language doesn't need to provide any filename extensions, this
- may be NULL. */
-
- const char *const *la_filename_extensions;
-
/* Definitions related to expression printing, prefixifying, and
dumping. */
@@ -275,6 +268,17 @@ struct language_defn : language_data
virtual const char *natural_name () const = 0;
+ /* Return a vector of file extensions for this language. The extension
+ must include the ".", like ".c". If this language doesn't need to
+ provide any filename extensions, this may be an empty vector (which is
+ the default). */
+
+ virtual const std::vector<const char *> &filename_extensions () const
+ {
+ static const std::vector<const char *> no_extensions;
+ return no_extensions;
+ }
+
/* Print the index of an element of an array. This default
implementation prints using C99 syntax. */
diff --git a/gdb/m2-lang.c b/gdb/m2-lang.c
index 9806caf..ef41538 100644
--- a/gdb/m2-lang.c
+++ b/gdb/m2-lang.c
@@ -204,7 +204,6 @@ extern const struct language_data m2_language_data =
case_sensitive_on,
array_row_major,
macro_expansion_no,
- NULL,
&exp_descriptor_modula2,
false, /* la_store_sym_names_in_linkage_form_p */
m2_op_print_tab, /* expression operators for printing */
diff --git a/gdb/objc-lang.c b/gdb/objc-lang.c
index e63b992..ff9735e 100644
--- a/gdb/objc-lang.c
+++ b/gdb/objc-lang.c
@@ -319,11 +319,6 @@ static const struct op_print objc_op_print_tab[] =
{NULL, OP_NULL, PREC_NULL, 0}
};
-static const char * const objc_extensions[] =
-{
- ".m", NULL
-};
-
/* Constant data representing the Objective-C language. */
extern const struct language_data objc_language_data =
@@ -333,7 +328,6 @@ extern const struct language_data objc_language_data =
case_sensitive_on,
array_row_major,
macro_expansion_c,
- objc_extensions,
&exp_descriptor_standard,
false, /* la_store_sym_names_in_linkage_form_p */
objc_op_print_tab, /* Expression operators for printing */
@@ -362,6 +356,14 @@ public:
{ return "Objective-C"; }
/* See language.h. */
+
+ const std::vector<const char *> &filename_extensions () const override
+ {
+ static const std::vector<const char *> extensions = { ".m" };
+ return extensions;
+ }
+
+ /* See language.h. */
void language_arch_info (struct gdbarch *gdbarch,
struct language_arch_info *lai) const override
{
diff --git a/gdb/opencl-lang.c b/gdb/opencl-lang.c
index 9a311c1..a8d4857 100644
--- a/gdb/opencl-lang.c
+++ b/gdb/opencl-lang.c
@@ -1011,7 +1011,6 @@ extern const struct language_data opencl_language_data =
case_sensitive_on,
array_row_major,
macro_expansion_c,
- NULL,
&exp_descriptor_opencl,
false, /* la_store_sym_names_in_linkage_form_p */
c_op_print_tab, /* expression operators for printing */
diff --git a/gdb/p-lang.c b/gdb/p-lang.c
index 486e906..da48a52 100644
--- a/gdb/p-lang.c
+++ b/gdb/p-lang.c
@@ -248,11 +248,6 @@ enum pascal_primitive_types {
nr_pascal_primitive_types
};
-static const char * const p_extensions[] =
-{
- ".pas", ".p", ".pp", NULL
-};
-
/* Constant data representing the Pascal language. */
extern const struct language_data pascal_language_data =
@@ -262,7 +257,6 @@ extern const struct language_data pascal_language_data =
case_sensitive_on,
array_row_major,
macro_expansion_no,
- p_extensions,
&exp_descriptor_standard,
false, /* la_store_sym_names_in_linkage_form_p */
pascal_op_print_tab, /* expression operators for printing */
@@ -290,6 +284,14 @@ public:
const char *natural_name () const override
{ return "Pascal"; }
+ /* See language.h. */
+
+ const std::vector<const char *> &filename_extensions () const override
+ {
+ static const std::vector<const char *> extensions
+ = { ".pas", ".p", ".pp" };
+ return extensions;
+ }
/* See language.h. */
void language_arch_info (struct gdbarch *gdbarch,
diff --git a/gdb/rust-lang.c b/gdb/rust-lang.c
index 971d60b..a7b5835 100644
--- a/gdb/rust-lang.c
+++ b/gdb/rust-lang.c
@@ -1897,11 +1897,6 @@ static const struct exp_descriptor exp_descriptor_rust =
rust_evaluate_subexp
};
-static const char * const rust_extensions[] =
-{
- ".rs", NULL
-};
-
/* Constant data representing the Rust language. */
extern const struct language_data rust_language_data =
@@ -1911,7 +1906,6 @@ extern const struct language_data rust_language_data =
case_sensitive_on,
array_row_major,
macro_expansion_no,
- rust_extensions,
&exp_descriptor_rust,
false, /* la_store_sym_names_in_linkage_form_p */
c_op_print_tab, /* expression operators for printing */
@@ -1940,6 +1934,14 @@ public:
{ return "Rust"; }
/* See language.h. */
+
+ const std::vector<const char *> &filename_extensions () const override
+ {
+ static const std::vector<const char *> extensions = { ".rs" };
+ return extensions;
+ }
+
+ /* See language.h. */
void language_arch_info (struct gdbarch *gdbarch,
struct language_arch_info *lai) const override
{
diff --git a/gdb/symfile.c b/gdb/symfile.c
index 2c38ce4..d5aa11f 100644
--- a/gdb/symfile.c
+++ b/gdb/symfile.c
@@ -2672,6 +2672,7 @@ static std::vector<filename_language> filename_language_table;
void
add_filename_language (const char *ext, enum language lang)
{
+ gdb_assert (ext != nullptr);
filename_language_table.emplace_back (ext, lang);
}