From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 7876) id 3FC6D395A034; Tue, 31 May 2022 14:46:14 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 3FC6D395A034 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Nils-Christian Kempke To: gdb-cvs@sourceware.org Subject: [binutils-gdb] testsuite, fortran: allow additional completions in module.exp X-Act-Checkin: binutils-gdb X-Git-Author: Nils-Christian Kempke X-Git-Refname: refs/heads/master X-Git-Oldrev: b8dd7ddff9b71ae2c301957af546724f948a467e X-Git-Newrev: 6b7b705d7c21b0d0dd9eaf5273a711e20e238ec3 Message-Id: <20220531144614.3FC6D395A034@sourceware.org> Date: Tue, 31 May 2022 14:46:14 +0000 (GMT) X-BeenThere: gdb-cvs@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 31 May 2022 14:46:14 -0000 https://sourceware.org/git/gitweb.cgi?p=3Dbinutils-gdb.git;h=3D6b7b705d7c21= b0d0dd9eaf5273a711e20e238ec3 commit 6b7b705d7c21b0d0dd9eaf5273a711e20e238ec3 Author: Nils-Christian Kempke Date: Tue May 31 16:43:45 2022 +0200 testsuite, fortran: allow additional completions in module.exp =20 For ifort, ifx, and flang the tests "complete modm" and "complete modmany" fail. This is because all three emit additional completion suggestions. These additional suggestions have their origin in symbols emitted by the compilers which can also be completed from the respective incomplete word (modm or modmany). For this specific example gfortran does not emit any additional symbols. =20 For example, in this test the linkage name for var_a in ifx is "modmany_mp_var_a_" while gfortran uses "__modmany_MOD_var_a" instead. Since modmany_mp_var_a can be completed from modm and also modmany they will get displayed, while gfortran's symbol starts with "__" and thus w= ill be ignored (it cannot be a completion of a word starting with "m"). =20 Similar things happen in flang and ifort. Some example output is shown below: =20 FLANG (gdb) complete p modm p modmany p modmany::var_a p modmany::var_b p modmany::var_c p modmany::var_i p modmany_ =20 IFX/IFORT (gdb) complete p modm p modmany p modmany._ p modmany::var_a p modmany::var_b p modmany::var_c p modmany::var_i p modmany_mp_var_a_ p modmany_mp_var_b_ p modmany_mp_var_c_ p modmany_mp_var_i_ =20 GFORTRAN (gdb) complete p modm p modmany p modmany::var_a p modmany::var_b p modmany::var_c p modmany::var_i =20 I want to emphasize: for Fortran (and also C/C++) the complete command does not actually check whether its suggestions make sense - all it does is look for any symbol (in the minimal symbols, partial symbols etc.) that a given substring can be completed to (meaning that the given subs= tring is the beginning of the symbol). One can easily produce a similar output for the gfortran compiled executable. For this look at the slightly modified "complete p mod" in gfortran: =20 (gdb) complete p mod p mod1 p mod1::var_const ... p mod_1.c p modcounter p mode_t p modf ... p modify_ldt p modmany p modmany::var_a p modmany::var_b p modmany::var_c p modmany::var_i p module p module.f90 p module_entry p moduse p moduse::var_x p moduse::var_y =20 Many of the displayed symbols do not actually work with print: =20 (gdb) p mode_t Attempt to use a type name as an expression (gdb) p mod_1.c No symbol "mod_1" in current context. (gdb) =20 I think that in the given test the output for gfortran only looks nice "by chance" rather than is actually expected. Expected is any output that also contains the completions =20 p modmany =20 p modmany::var_a p modmany::var_b p modmany::var_c p modmany::var_i =20 while anythings else can be displayed as well (depending on the compiler and its emitted symbols). =20 This, I'd consider all three outputs as valid and expected - one is just somewhat lucky that gfortran does not produce any additional symbols th= at got matched. =20 The given patch improves test performance for all three compilers by allowing additional suggested completions inbetween and after the two given blocks in the test. I did not allow additional print within the modmany_list block since the output is ordered alphabetically and there should normally not appear any additional symbols there. =20 For flang/ifx/ifort I each see 2 failures less (which are exactly the t= wo complete tests). =20 As a side note and since I mentioned C++ in the beginning: I also tried the gdb.cp/completion.exp. The output seems a bit more reasonable, mainly since C++ actually has a demangler in place and linkage symbols do not appear in the output of complete. Still, with a poor enough to-be-completed string one can easily produce similar results: =20 (gdb) complete p t ... p typeinfo name for void p typeinfo name for void const* p typeinfo name for void* p typeinfo name for wchar_t p typeinfo name for wchar_t const* p typeinfo name for wchar_t* p t *** List may be truncated, max-completions reached. *** (gdb) p typeinfo name for void* No symbol "typeinfo" in current context. (gdb) complete p B p BACK_SLASH p BUF_FIRST p BUF_LAST ... p Base p Base::Base() p Base::get_foo() p bad_key_err p buf p buffer p buffer_size p buflen p bufsize p build_charclass.isra (gdb) p bad_key_err No symbol "bad_key_err" in current context. =20 (compiled with gcc/g++ and breaking at main). =20 This patch is only about making the referenced test more 'fair' for the other compilers. Generally, I find the behavior of complete a bit confusing and maybe one wants to change this at some point but this would be a bigger task. Diff: --- gdb/testsuite/gdb.fortran/module.exp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/gdb/testsuite/gdb.fortran/module.exp b/gdb/testsuite/gdb.fortr= an/module.exp index 08dc1a50e88..fe539fbc6d3 100644 --- a/gdb/testsuite/gdb.fortran/module.exp +++ b/gdb/testsuite/gdb.fortran/module.exp @@ -118,9 +118,10 @@ gdb_test "print var_z" " =3D 31" "print var_x value 31" gdb_test "ptype modmany" "type =3D module modmany" =20 proc complete {expr list} { + set n_lines "\(?:\\r\\n.*\)*" set cmd "complete p $expr" - set expect [join [concat [list $cmd] $list] "\r\np "] - gdb_test $cmd $expect "complete $expr" + set expect [join [concat [list $cmd] $list] $n_lines] + gdb_test $cmd "$expect$n_lines" "complete $expr" } set modmany_list {modmany::var_a modmany::var_b modmany::var_c modmany::va= r_i} complete "modm" "modmany $modmany_list"