From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2126) id 973D23858C27; Mon, 4 Apr 2022 18:45:09 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 973D23858C27 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Tom Tromey To: gdb-cvs@sourceware.org Subject: [binutils-gdb] Handle ghost entities in symbol lookup X-Act-Checkin: binutils-gdb X-Git-Author: Tom Tromey X-Git-Refname: refs/heads/master X-Git-Oldrev: 59dfe8ad84c6a9ef17a1ba4a8f443ac3cb9f6fd5 X-Git-Newrev: 81eaa5061095f972d48e8160a4f677bd3e6ace51 Message-Id: <20220404184509.973D23858C27@sourceware.org> Date: Mon, 4 Apr 2022 18:45:09 +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: Mon, 04 Apr 2022 18:45:09 -0000 https://sourceware.org/git/gitweb.cgi?p=3Dbinutils-gdb.git;h=3D81eaa5061095= f972d48e8160a4f677bd3e6ace51 commit 81eaa5061095f972d48e8160a4f677bd3e6ace51 Author: Tom Tromey Date: Tue Mar 15 09:03:14 2022 -0600 Handle ghost entities in symbol lookup =20 Normally, SPARK ghost entities are removed from the executable. However, with -gnata, they will be preserved. In this situation, it's handy to be able to inspect them. This patch allows this by removing the "___ghost_" prefix in the appropriate places. Diff: --- gdb/ada-lang.c | 12 ++++++++++++ gdb/testsuite/gdb.ada/ghost.exp | 37 ++++++++++++++++++++++++++++++++= ++++ gdb/testsuite/gdb.ada/ghost/gpck.ads | 18 ++++++++++++++++++ gdb/testsuite/gdb.ada/ghost/main.adb | 22 +++++++++++++++++++++ gdb/testsuite/gdb.ada/ghost/pck.ads | 19 ++++++++++++++++++ 5 files changed, 108 insertions(+) diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c index a3a1a2bcec5..f80ec5b1e04 100644 --- a/gdb/ada-lang.c +++ b/gdb/ada-lang.c @@ -1323,6 +1323,11 @@ ada_decode (const char *encoded, bool wrap) if we see this prefix. */ if (startswith (encoded, "_ada_")) encoded +=3D 5; + /* The "___ghost_" prefix is used for ghost entities. Normally + these aren't preserved but when they are, it's useful to see + them. */ + if (startswith (encoded, "___ghost_")) + encoded +=3D 9; =20 /* If the name starts with '_', then it is not a properly encoded name, so do not attempt to decode it. Similarly, if the name @@ -6016,6 +6021,9 @@ wild_match (const char *name, const char *patn) const char *p; const char *name0 =3D name; =20 + if (startswith (name, "___ghost_")) + name +=3D 9; + while (1) { const char *match =3D name; @@ -13218,6 +13226,10 @@ do_full_match (const char *symbol_search_name, if (startswith (symbol_search_name, "_ada_") && !startswith (lname, "_ada")) symbol_search_name +=3D 5; + /* Likewise for ghost entities. */ + if (startswith (symbol_search_name, "___ghost_") + && !startswith (lname, "___ghost_")) + symbol_search_name +=3D 9; =20 int uscore_count =3D 0; while (*lname !=3D '\0') diff --git a/gdb/testsuite/gdb.ada/ghost.exp b/gdb/testsuite/gdb.ada/ghost.= exp new file mode 100644 index 00000000000..7f92b130eff --- /dev/null +++ b/gdb/testsuite/gdb.ada/ghost.exp @@ -0,0 +1,37 @@ +# Copyright 2022 Free Software Foundation, Inc. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +load_lib "ada.exp" + +if { [skip_ada_tests] } { return -1 } + +standard_ada_testfile main + +set flags [list debug additional_flags=3D-gnata] +if {[gdb_compile_ada "${srcfile}" "${binfile}" executable $flags] !=3D "" = } { + return -1 +} + +clean_restart ${testfile} + +set bp_location [gdb_get_line_number "START" ${testdir}/main.adb] +if ![runto "main.adb:$bp_location" ] then { + perror "Couldn't run ${testfile}" + return +} + +gdb_test "print value" " =3D 64 '@'" +gdb_test "print ghost_value" " =3D 64 '@'" +gdb_test "print value2" " =3D 33 '!'" diff --git a/gdb/testsuite/gdb.ada/ghost/gpck.ads b/gdb/testsuite/gdb.ada/g= host/gpck.ads new file mode 100644 index 00000000000..5a38ed4f94e --- /dev/null +++ b/gdb/testsuite/gdb.ada/ghost/gpck.ads @@ -0,0 +1,18 @@ +-- Copyright 2022 Free Software Foundation, Inc. +-- +-- This program is free software; you can redistribute it and/or modify +-- it under the terms of the GNU General Public License as published by +-- the Free Software Foundation; either version 3 of the License, or +-- (at your option) any later version. +-- +-- This program is distributed in the hope that it will be useful, +-- but WITHOUT ANY WARRANTY; without even the implied warranty of +-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +-- GNU General Public License for more details. +-- +-- You should have received a copy of the GNU General Public License +-- along with this program. If not, see . + +package GPck with Ghost is + Value2 : Character :=3D '!'; +end GPck; diff --git a/gdb/testsuite/gdb.ada/ghost/main.adb b/gdb/testsuite/gdb.ada/g= host/main.adb new file mode 100644 index 00000000000..7da25422071 --- /dev/null +++ b/gdb/testsuite/gdb.ada/ghost/main.adb @@ -0,0 +1,22 @@ +-- Copyright 2022 Free Software Foundation, Inc. +-- +-- This program is free software; you can redistribute it and/or modify +-- it under the terms of the GNU General Public License as published by +-- the Free Software Foundation; either version 3 of the License, or +-- (at your option) any later version. +-- +-- This program is distributed in the hope that it will be useful, +-- but WITHOUT ANY WARRANTY; without even the implied warranty of +-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +-- GNU General Public License for more details. +-- +-- You should have received a copy of the GNU General Public License +-- along with this program. If not, see . + +with Pck; use Pck; +with GPck; use GPck; + +procedure Main with Ghost is +begin + null; -- START +end Main; diff --git a/gdb/testsuite/gdb.ada/ghost/pck.ads b/gdb/testsuite/gdb.ada/gh= ost/pck.ads new file mode 100644 index 00000000000..f56aa509822 --- /dev/null +++ b/gdb/testsuite/gdb.ada/ghost/pck.ads @@ -0,0 +1,19 @@ +-- Copyright 2022 Free Software Foundation, Inc. +-- +-- This program is free software; you can redistribute it and/or modify +-- it under the terms of the GNU General Public License as published by +-- the Free Software Foundation; either version 3 of the License, or +-- (at your option) any later version. +-- +-- This program is distributed in the hope that it will be useful, +-- but WITHOUT ANY WARRANTY; without even the implied warranty of +-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +-- GNU General Public License for more details. +-- +-- You should have received a copy of the GNU General Public License +-- along with this program. If not, see . + +package Pck is + Value : Character :=3D '@'; + Ghost_Value : Character :=3D '@' with Ghost; +end Pck;