diff options
author | Joel Brobecker <brobecker@adacore.com> | 2017-11-15 19:02:33 -0500 |
---|---|---|
committer | Joel Brobecker <brobecker@adacore.com> | 2017-11-17 12:45:43 -0500 |
commit | ced9779b4c45b9bc9c16dd98fa30d7a620e93a55 (patch) | |
tree | bb361015e2ac859c1bd1298ee796706414f75265 /gdb/testsuite | |
parent | 3cfd3dd0956fe854a07795de12c1302ecabbd819 (diff) | |
download | gdb-ced9779b4c45b9bc9c16dd98fa30d7a620e93a55.zip gdb-ced9779b4c45b9bc9c16dd98fa30d7a620e93a55.tar.gz gdb-ced9779b4c45b9bc9c16dd98fa30d7a620e93a55.tar.bz2 |
(Ada) fix handling of minimal symbols (UNOP_CAST and UNOP_ADDR)
Consider a program which provides a symbol without debugging
information. For instance, compiling the following code without -g:
Some_Minimal_Symbol : Integer := 1234;
pragma Export (C, Some_Minimal_Symbol, "some_minsym");
Trying to print this variable with GDB now causes an error, which
is now expected:
(gdb) p some_minsym
'some_minsym' has unknown type; cast it to its declared type
However, trying to cast this symbol, or to take its address
does not work:
(gdb) p integer(some_minsym)
'some_minsym' has unknown type; cast it to its declared type
(gdb) p &some_minsym
'some_minsym' has unknown type; cast it to its declared type
Another manisfestation of this issue can be seen when trying to
insert an Ada exception catchpoint for a specific standard exception
(this only occurs if the Ada runtime is built without debugging
information, which is the default). For instance:
$ (gdb) catch exception constraint_error
warning: failed to reevaluate internal exception condition for catchpoint 0: 'constraint_error' has unknown type; cast it to its declared type
This is because, internally, the cachtpoint uses a condition referencing
a minimal symbol, more precisely:
long_integer (e) = long_integer (&constraint_error)
This patch fixes all issues listed above:
1. resolve_subexp: Special-case the handling of OP_VAR_MSYM_VALUE
expression elements, where there are no ambiguities to be resolved
in that situation;
2. ada_evaluate_subexp: Enhance the handling of the UNOP_CAST
handling so as to process the case where the target of
the cast is a minimal symbol (as well as a symbol with debugging
information). This mimics what's done in C.
gdb/ChangeLog:
* ada-lang.c (resolve_subexp): Add handling of OP_VAR_MSYM_VALUE.
(ada_evaluate_subexp_for_cast): New function.
(ada_evaluate_subexp) <UNOP_CAST>: Replace code by call to
ada_evaluate_subexp_for_cast.
(ada_evaluate_subexp) <nosideret>: Replace code by call to
eval_skip_value.
* eval.c (evaluate_var_value): Make non-static.
(evaluate_var_msym_value, eval_skip_value): Likewise.
* value.h (evaluate_var_value, evaluate_var_msym_value)
(eval_skip_value): Declare.
gdb/testsuite/ChangeLog:
* gdb.ada/minsyms: New testcase.
Tested on x86_64-linux. No regression. Fixes the following failures:
catch_ex.exp: continuing to Program_Error exception
catch_ex.exp: continuing to failed assertion
catch_ex.exp: continuing to unhandled exception
catch_ex.exp: continuing to program completion
complete.exp: p <Exported_Capitalized>
complete.exp: p Exported_Capitalized
complete.exp: p exported_capitalized
mi_catch_ex.exp: catch Program_Error (unexpected output)
mi_catch_ex.exp: continue to exception catchpoint hit (unknown output after running)
mi_catch_ex.exp: continue to assert failure catchpoint hit (unknown output after running)
mi_catch_ex.exp: continue to unhandled exception catchpoint hit (unknown output after running)
mi_ex_cond.exp: catch C_E if i = 2 (unexpected output)
Diffstat (limited to 'gdb/testsuite')
-rw-r--r-- | gdb/testsuite/ChangeLog | 4 | ||||
-rw-r--r-- | gdb/testsuite/gdb.ada/minsyms.exp | 41 | ||||
-rw-r--r-- | gdb/testsuite/gdb.ada/minsyms/foo_qb07_057.adb | 20 | ||||
-rw-r--r-- | gdb/testsuite/gdb.ada/minsyms/pck.adb | 21 | ||||
-rw-r--r-- | gdb/testsuite/gdb.ada/minsyms/pck.ads | 21 |
5 files changed, 107 insertions, 0 deletions
diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog index c70c650..7334fd7 100644 --- a/gdb/testsuite/ChangeLog +++ b/gdb/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2017-11-17 Joel Brobecker <brobecker@adacore.com> + + * gdb.ada/minsyms: New testcase. + 2017-11-16 Pedro Alves <palves@redhat.com> * gdb.base/bp-cmds-continue-ctrl-c.c: New file. diff --git a/gdb/testsuite/gdb.ada/minsyms.exp b/gdb/testsuite/gdb.ada/minsyms.exp new file mode 100644 index 0000000..2c91125 --- /dev/null +++ b/gdb/testsuite/gdb.ada/minsyms.exp @@ -0,0 +1,41 @@ +# Copyright 2017 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 <http://www.gnu.org/licenses/>. + +load_lib "ada.exp" + +standard_ada_testfile foo_qb07_057 + +if {[gdb_compile_ada "${srcfile}" "${binfile}" executable ""] != "" } { + return -1 +} + +clean_restart ${testfile} + +if ![runto "_ada_foo_qb07_057" ] then { + perror "Couldn't run ${testfile}" + return +} + +gdb_test "print some_minsym" \ + "'some_minsym' has unknown type; cast it to its declared type" + +gdb_test "print integer(some_minsym)" \ + " = 1234" + +gdb_test "print &some_minsym" \ + " = \\(access <data variable, no debug info>\\) 0x62c2f8 <some_minsym>" + +gdb_test "print /x integer(&some_minsym)" \ + " = $hex" diff --git a/gdb/testsuite/gdb.ada/minsyms/foo_qb07_057.adb b/gdb/testsuite/gdb.ada/minsyms/foo_qb07_057.adb new file mode 100644 index 0000000..5a081dc --- /dev/null +++ b/gdb/testsuite/gdb.ada/minsyms/foo_qb07_057.adb @@ -0,0 +1,20 @@ +-- Copyright 2017 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 <http://www.gnu.org/licenses/>. + +with Pck; use Pck; +procedure Foo_QB07_057 is +begin + Increment (Some_Minimal_Symbol); +end Foo_QB07_057; diff --git a/gdb/testsuite/gdb.ada/minsyms/pck.adb b/gdb/testsuite/gdb.ada/minsyms/pck.adb new file mode 100644 index 0000000..10e8c9b --- /dev/null +++ b/gdb/testsuite/gdb.ada/minsyms/pck.adb @@ -0,0 +1,21 @@ +-- Copyright 2017 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 <http://www.gnu.org/licenses/>. + +package body Pck is + procedure Increment (I: in out Integer) is + begin + I := I + 1; + end Increment; +end Pck; diff --git a/gdb/testsuite/gdb.ada/minsyms/pck.ads b/gdb/testsuite/gdb.ada/minsyms/pck.ads new file mode 100644 index 0000000..4ad4c07 --- /dev/null +++ b/gdb/testsuite/gdb.ada/minsyms/pck.ads @@ -0,0 +1,21 @@ +-- Copyright 2017 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 <http://www.gnu.org/licenses/>. + +package Pck is + Some_Minimal_Symbol : Integer := 1234; + pragma Export (C, Some_Minimal_Symbol, "some_minsym"); + + procedure Increment (I: in out Integer); +end Pck; |