diff options
author | Tom Tromey <tom@tromey.com> | 2016-05-26 10:33:28 -0600 |
---|---|---|
committer | Tom Tromey <tom@tromey.com> | 2016-06-23 21:11:47 -0600 |
commit | 56618e20bc50e55b49ed224df2a2a7e0840056fe (patch) | |
tree | 2d6ce4327fa617f2524ac99e77eac4cb4a62f71b /gdb/symfile.c | |
parent | 3fcf0b0d5a8cf04da4b4210121e7276ca1f20101 (diff) | |
download | gdb-56618e20bc50e55b49ed224df2a2a7e0840056fe.zip gdb-56618e20bc50e55b49ed224df2a2a7e0840056fe.tar.gz gdb-56618e20bc50e55b49ed224df2a2a7e0840056fe.tar.bz2 |
Move filename extensions into language_defn
This moves filename extensions from a function in symfile.c out to
each language_defn. I think this is an improvement because it means
less digging around when writing a new language port.
2016-06-23 Tom Tromey <tom@tromey.com>
* ada-lang.c (ada_extensions): New array.
(ada_language_defn): Use it.
* c-lang.c (c_extensions): New array.
(c_language_defn): Use it.
(cplus_extensions): New array.
(cplus_language_defn): Use it.
(asm_extensions): New array.
(asm_language_defn): Use it.
(minimal_language_defn): Update.
* d-lang.c (d_extensions): New array.
(d_language_defn): Use it.
* f-lang.c (f_extensions): New array.
(f_language_defn): Use it.
* go-lang.c (go_language_defn): Update.
* jv-lang.c (java_extensions): New array.
(java_language_defn): Use it.
* language.c (add_language): Call add_filename_language.
(unknown_language_defn, auto_language_defn, local_language_defn):
Update.
* language.h (struct language_defn) <la_filename_extensions>: New
field.
* m2-lang.c (m2_language_defn): Update.
* objc-lang.c (objc_extensions): New array.
(objc_language_defn): Use it.
* opencl-lang.c (opencl_language_defn): Update.
* p-lang.c (p_extensions): New array.
(pascal_language_defn): Use it.
* rust-lang.c (rust_extensions): New array.
(rust_language_defn): Use it.
* symfile.c (add_filename_language): No longer static. Make "ext"
const.
(init_filename_language_table): Remove.
(_initialize_symfile): Update.
* symfile.h (add_filename_language): Declare.
Diffstat (limited to 'gdb/symfile.c')
-rw-r--r-- | gdb/symfile.c | 59 |
1 files changed, 4 insertions, 55 deletions
diff --git a/gdb/symfile.c b/gdb/symfile.c index f7f56c6..d29e96c 100644 --- a/gdb/symfile.c +++ b/gdb/symfile.c @@ -114,12 +114,8 @@ static int simple_read_overlay_table (void); static int simple_overlay_update_1 (struct obj_section *); -static void add_filename_language (char *ext, enum language lang); - static void info_ext_lang_command (char *args, int from_tty); -static void init_filename_language_table (void); - static void symfile_find_segment_sections (struct objfile *objfile); void _initialize_symfile (void); @@ -2719,8 +2715,10 @@ DEF_VEC_O (filename_language); static VEC (filename_language) *filename_language_table; -static void -add_filename_language (char *ext, enum language lang) +/* See symfile.h. */ + +void +add_filename_language (const char *ext, enum language lang) { filename_language entry; @@ -2818,54 +2816,6 @@ info_ext_lang_command (char *args, int from_tty) printf_filtered ("\t%s\t- %s\n", entry->ext, language_str (entry->lang)); } -static void -init_filename_language_table (void) -{ - /* Protect against repetition. */ - if (VEC_empty (filename_language, filename_language_table)) - { - add_filename_language (".c", language_c); - add_filename_language (".d", language_d); - add_filename_language (".C", language_cplus); - add_filename_language (".cc", language_cplus); - add_filename_language (".cp", language_cplus); - add_filename_language (".cpp", language_cplus); - add_filename_language (".cxx", language_cplus); - add_filename_language (".c++", language_cplus); - add_filename_language (".java", language_java); - add_filename_language (".class", language_java); - add_filename_language (".m", language_objc); - add_filename_language (".f", language_fortran); - add_filename_language (".F", language_fortran); - add_filename_language (".for", language_fortran); - add_filename_language (".FOR", language_fortran); - add_filename_language (".ftn", language_fortran); - add_filename_language (".FTN", language_fortran); - add_filename_language (".fpp", language_fortran); - add_filename_language (".FPP", language_fortran); - add_filename_language (".f90", language_fortran); - add_filename_language (".F90", language_fortran); - add_filename_language (".f95", language_fortran); - add_filename_language (".F95", language_fortran); - add_filename_language (".f03", language_fortran); - add_filename_language (".F03", language_fortran); - add_filename_language (".f08", language_fortran); - add_filename_language (".F08", language_fortran); - add_filename_language (".s", language_asm); - add_filename_language (".sx", language_asm); - add_filename_language (".S", language_asm); - add_filename_language (".pas", language_pascal); - add_filename_language (".p", language_pascal); - add_filename_language (".pp", language_pascal); - add_filename_language (".adb", language_ada); - add_filename_language (".ads", language_ada); - add_filename_language (".a", language_ada); - add_filename_language (".ada", language_ada); - add_filename_language (".dg", language_ada); - add_filename_language (".rs", language_rust); - } -} - enum language deduce_language_from_filename (const char *filename) { @@ -4018,7 +3968,6 @@ A load OFFSET may also be given."), &cmdlist); _("Read the overlay mapping state from the target."), &overlaylist); /* Filename extension to source language lookup table: */ - init_filename_language_table (); add_setshow_string_noescape_cmd ("extension-language", class_files, &ext_args, _("\ Set mapping between filename extension and source language."), _("\ |