+2010-04-20 Joel Brobecker <brobecker@adacore.com>
+
+ * valprint.c (common_val_print): Fix the value before extracting
+ its contents.
+ * ada-lang.c (ada_to_fixed_value): Make this function extern.
+ * ada-lang.h (ada_to_fixed_value): New function declaration.
+ * ada-valprint.c (ada_value_print): Use ada_to_fixed_value
+ to avoid code duplication and fix a bug in the handling of
+ fixed types contents.
+
2010-04-20 Tom Tromey <tromey@redhat.com>
* dwarf2read.c (dwarf2_compute_name): Handle DW_AT_linkage_name.
static struct value *ada_to_fixed_value_create (struct type *, CORE_ADDR,
struct value *);
-static struct value *ada_to_fixed_value (struct value *);
-
static int ada_resolve_function (struct ada_symbol_info *, int,
struct value **, int, const char *,
struct type *);
that correctly describes it. Does not necessarily create a new
value. */
-static struct value *
+struct value *
ada_to_fixed_value (struct value *val)
{
return ada_to_fixed_value_create (value_type (val),
CORE_ADDR, struct value *,
int check_tag);
+extern struct value *ada_to_fixed_value (struct value *val);
+
extern struct type *ada_template_to_fixed_record_type_1 (struct type *type,
const gdb_byte *valaddr,
CORE_ADDR address,
ada_value_print (struct value *val0, struct ui_file *stream,
const struct value_print_options *options)
{
- const gdb_byte *valaddr = value_contents (val0);
- CORE_ADDR address = value_address (val0);
- struct type *type =
- ada_to_fixed_type (value_type (val0), valaddr, address, NULL, 1);
- struct value *val =
- value_from_contents_and_address (type, valaddr, address);
+ struct value *val = ada_to_fixed_value (val0);
+ CORE_ADDR address = value_address (val);
+ struct type *type = value_type (val);
struct value_print_options opts;
/* If it is a pointer, indicate what it points to. */
+2010-04-20 Joel Brobecker <brobecker@adacore.com>
+
+ * gdb.ada/dyn_loc: New testcase.
+
2010-04-20 Chris Moller <cmoller@redhat.com>
PR 10867
--- /dev/null
+# Copyright 2010 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/>.
+
+if $tracelevel then {
+ strace $tracelevel
+}
+
+load_lib "ada.exp"
+
+set testdir "dyn_loc"
+set testfile "${testdir}/p"
+set srcfile ${srcdir}/${subdir}/${testfile}.adb
+set binfile ${objdir}/${subdir}/${testfile}
+
+file mkdir ${objdir}/${subdir}/${testdir}
+if {[gdb_compile_ada "${srcfile}" "${binfile}" executable [list debug ]] != "" } {
+ return -1
+}
+
+clean_restart ${testfile}
+
+set bp_location [gdb_get_line_number "BREAK" ${testdir}/pack.adb]
+if ![runto "pack.adb:$bp_location" ] then {
+ return -1
+}
+
+set eol "\[\r\n\]+"
+
+set test "info locals"
+gdb_test_multiple "$test" "$test" {
+ -re "i = \"AA\"${eol}s = \" \"" {
+ pass $test
+ }
+ -re "i = \"AA\"${eol}.*${eol}s = \" \"" {
+ # The debugger printed the two local variable correctly, but
+ # it probably failed to NOT print some variables internally
+ # generated by the compiler. This is a known issue.
+ xfail $test
+ }
+}
+
--- /dev/null
+-- Copyright 2010 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 Pack; use Pack;
+
+procedure P is
+begin
+ Print (4, 5);
+end P;
--- /dev/null
+-- Copyright 2010 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 Ada.Text_IO; use Ada.Text_IO;
+
+package body Pack is
+
+ procedure Print (I1 : Positive; I2 : Positive) is
+ type My_String is array (I1 .. I2) of Character;
+ I : My_String := (others => 'A');
+ S : String (1 .. I2 + 3) := (others => ' ');
+ begin
+ S (I1 .. I2) := String (I); -- BREAK
+ Put_Line (S);
+ end Print;
+
+end Pack;
--- /dev/null
+-- Copyright 2010 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 Pack is
+
+ procedure Print (I1 : Positive; I2 : Positive);
+
+end Pack;
#include "exceptions.h"
#include "dfp.h"
#include "python/python.h"
+#include "ada-lang.h"
#include <errno.h>
if (!value_check_printable (val, stream))
return 0;
+ if (language->la_language == language_ada)
+ /* The value might have a dynamic type, which would cause trouble
+ below when trying to extract the value contents (since the value
+ size is determined from the type size which is unknown). So
+ get a fixed representation of our value. */
+ val = ada_to_fixed_value (val);
+
return val_print (value_type (val), value_contents_all (val),
value_embedded_offset (val), value_address (val),
stream, recurse, options, language);