+2017-11-17 Joel Brobecker <brobecker@adacore.com>
+
+ * 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.
+
2017-11-16 Joel Brobecker <brobecker@adacore.com>
* ada-lang.c (ada_value_cast): Remove parameter "noside".
}
*pos = pc;
- return evaluate_subexp_type (exp, pos);
+ if (exp->elts[pc].opcode == OP_VAR_MSYM_VALUE)
+ return evaluate_var_msym_value (EVAL_AVOID_SIDE_EFFECTS,
+ exp->elts[pc + 1].objfile,
+ exp->elts[pc + 2].msymbol);
+ else
+ return evaluate_subexp_type (exp, pos);
}
/* Return non-zero if formal type FTYPE matches actual type ATYPE. If
entity. Results in this case are unpredictable, as we usually read
past the buffer containing the data =:-o. */
+/* Evaluate a subexpression of EXP, at index *POS, and return a value
+ for that subexpression cast to TO_TYPE. Advance *POS over the
+ subexpression. */
+
+static value *
+ada_evaluate_subexp_for_cast (expression *exp, int *pos,
+ enum noside noside, struct type *to_type)
+{
+ int pc = *pos;
+
+ if (exp->elts[pc].opcode == OP_VAR_MSYM_VALUE
+ || exp->elts[pc].opcode == OP_VAR_VALUE)
+ {
+ (*pos) += 4;
+
+ value *val;
+ if (exp->elts[pc].opcode == OP_VAR_MSYM_VALUE)
+ {
+ if (noside == EVAL_AVOID_SIDE_EFFECTS)
+ return value_zero (to_type, not_lval);
+
+ val = evaluate_var_msym_value (noside,
+ exp->elts[pc + 1].objfile,
+ exp->elts[pc + 2].msymbol);
+ }
+ else
+ val = evaluate_var_value (noside,
+ exp->elts[pc + 1].block,
+ exp->elts[pc + 2].symbol);
+
+ if (noside == EVAL_SKIP)
+ return eval_skip_value (exp);
+
+ val = ada_value_cast (to_type, val);
+
+ /* Follow the Ada language semantics that do not allow taking
+ an address of the result of a cast (view conversion in Ada). */
+ if (VALUE_LVAL (val) == lval_memory)
+ {
+ if (value_lazy (val))
+ value_fetch_lazy (val);
+ VALUE_LVAL (val) = not_lval;
+ }
+ return val;
+ }
+
+ value *val = evaluate_subexp (to_type, exp, pos, noside);
+ if (noside == EVAL_SKIP)
+ return eval_skip_value (exp);
+ return ada_value_cast (to_type, val);
+}
+
/* Implement the evaluate_exp routine in the exp_descriptor structure
for the Ada language. */
case UNOP_CAST:
(*pos) += 2;
type = exp->elts[pc + 1].type;
- arg1 = evaluate_subexp (type, exp, pos, noside);
- if (noside == EVAL_SKIP)
- goto nosideret;
- arg1 = ada_value_cast (type, arg1);
- return arg1;
+ return ada_evaluate_subexp_for_cast (exp, pos, noside, type);
case UNOP_QUAL:
(*pos) += 2;
}
nosideret:
- return value_from_longest (builtin_type (exp->gdbarch)->builtin_int, 1);
+ return eval_skip_value (exp);
}
\f
/* Helper for evaluating an OP_VAR_VALUE. */
-static value *
+value *
evaluate_var_value (enum noside noside, const block *blk, symbol *var)
{
/* JYG: We used to just return value_zero of the symbol type if
/* Helper for evaluating an OP_VAR_MSYM_VALUE. */
-static value *
+value *
evaluate_var_msym_value (enum noside noside,
struct objfile *objfile, minimal_symbol *msymbol)
{
/* Helper for returning a value when handling EVAL_SKIP. */
-static value *
+value *
eval_skip_value (expression *exp)
{
return value_from_longest (builtin_type (exp->gdbarch)->builtin_int, 1);
+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.
--- /dev/null
+# 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"
--- /dev/null
+-- 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;
--- /dev/null
+-- 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;
--- /dev/null
+-- 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;
extern struct value *evaluate_subexpression_type (struct expression *exp,
int subexp);
+extern value *evaluate_var_value (enum noside noside, const block *blk,
+ symbol *var);
+
+extern value *evaluate_var_msym_value (enum noside noside,
+ struct objfile *objfile,
+ minimal_symbol *msymbol);
+
+extern value *eval_skip_value (expression *exp);
+
extern void fetch_subexp_value (struct expression *exp, int *pc,
struct value **valp, struct value **resultp,
struct value **val_chain,