This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[RFA] Make symbol completion language-specific


The current symbol completion mechanism works really well for C, and
maybe other languages too, but it's not well suited for completing
Ada entity names.

As suggested by a comment inside symtab.c:make_symbol_completion_list,
I made this routine language-dependent by adding a new field inside
struct language_defn. I then renamed make_symbol_completion_list to
default_make_symbol_completion_list, and wrote a new
make_symbol_completion_list that called the new language method
using the current_language. All languages use the default completer,
except for Ada, for which I am providing a specific completer.

2007-12-28  Joel Brobecker  <brobecker@adacore.com>

        * language.h (struct language_defn): Add new field
        la_make_symbol_completion_list.
        * symtab.c (default_make_symbol_completion_list): Renames
        make_symbol_completion_list.
        (make_symbol_completion_list): New function.
        * symtab.h (default_make_symbol_completion_list): Add declaration.
        * langauge.c (unknown_language): Set la_make_symbol_completion_list.
        (auto_language, local_language): Likewise.
        * objc-lang.c (objc_language_defn): Likewise.
        * scm-lang.c (scm_language_defn): Likewise.
        * m2-lang.c (m2_language_defn): Likewise.
        * f-lang.c (f_language_defn): Likewise.
        * jv-lang.c (java_language_defn): Likewise.
        * p-lang.c (pascal_language_defn): Likewise.
        * c-lang.c (c_language_defn, cplus_language_defn, asm_language_defn)
        (minimal_language_defn): Likewise.
        * ada-lang.c (struct string_vector): New structure.
        (new_string_vector, string_vector_append, ada_unqualified_name)
        (add_angle_brackets, symbol_completion_match, symbol_completion_add)
        (ada_make_symbol_completion_list): New functions.
        (ada_language_defn): Set la_make_symbol_completion_list.
        * ada-lang.h (ada_make_symbol_completion_list): Remove declaration,
        this function is static.

Tested on x86-linux, no regression.
OK to commit?

I have also written a pretty extensive testcase that tests Ada-specific
completion.

2007-12-28  Joel Brobecker  <brobecker@adacore.com>

        * gdb.ada/complete/pck.ads, gdb.ada/complete/pck.adb,
        gdb.ada/complete/foo.adb: New files.
        * gdb.ada/complete.exp: New testcase.

Also tested on x86-linux.

A couple of remarks:

  1. How does someone verify that a GDB command does not return
     any output. Do we really have to do it "manually" (using
     gdb_send et al)?  Right now, there is a hole in my testcase
     regarding this, and I need to fix it before I commit it.

  2. I was getting tired of writing expected output regexps that
     were completely unreadable mostly because the output was matching
     more than one line that ended up concatenated inside the same
     string. So I wrote the following little helper function:

        proc multi_line { args } {
            return [join $args "\[\r\n\]*"]
        }

     This function allows me to do something like this:

        gdb_test "print variable" \
                 [multi_line "first_line" \
                             "second_line" \
                             "last_line" ] \
                 "print big variable"

     I think that this is far easier to read than:

        gdb_test "print variable" \
                 "first_line${eol}second_line${eol}last_line"
                 "print big variable"

     If there is some interest in using this trick more globally,
     we could provide something similar in gdb.exp so that all scripts
     can take advantage of it.

Thanks,
-- 
Joel

Attachment: complete.diff
Description: Text document

Attachment: test-complete.diff
Description: Text document


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]