summaryrefslogtreecommitdiff
path: root/gdb
diff options
context:
space:
mode:
authorJoel Brobecker <brobecker@gnat.com>2010-04-20 22:38:01 +0000
committerJoel Brobecker <brobecker@gnat.com>2010-04-20 22:38:01 +0000
commit0df8296ccbe06c092d21cf9e808d4f634ca1a6c2 (patch)
tree88094fe000c1a7ac8aa6bef3c1fe5dbcc8f80b24 /gdb
parent949ed6ecaacec61013e66818f1f1d0c17369b185 (diff)
downloadgdb-0df8296ccbe06c092d21cf9e808d4f634ca1a6c2.tar.gz
"unsupported language" error in info types when using Ada.
This implements a rudimentary version of the la_print_typedef method for Ada. Ada usually does not use typedefs, but there is one exception: pointers to unconstrained arrays. Without this patch, we sometimes get an error in the "info types" output: (gdb) info types new_integer_type All types matching regular expression "new_integer_type": File foo.adb: Language not supported. For now, we treat the typedef as if it did not exist - using the underlying type instead. This is the right thing to do for most cases, the only exception being access to array types. Since we already have a general issue in handling these pointers (we confuse them with fat pointers), we will enhance ada_print_typedef to handle these pointers at the same time we address the general issue. gdb/ChangeLog: * ada-typeprint.c (ada_print_typedef): New function. * ada-lang.h (ada_print_typedef): Add declaration. * ada-lang.c (ada_language_defn): set la_print_typdef field to ada_print_typedef. gdb/testsuite/ChangeLog: * info_types.c, info_types.exp: New files. Tested on x86_64-linux.
Diffstat (limited to 'gdb')
-rw-r--r--gdb/ChangeLog7
-rw-r--r--gdb/ada-lang.c2
-rw-r--r--gdb/ada-lang.h3
-rw-r--r--gdb/ada-typeprint.c11
-rw-r--r--gdb/testsuite/ChangeLog4
-rw-r--r--gdb/testsuite/gdb.ada/info_types.c35
-rw-r--r--gdb/testsuite/gdb.ada/info_types.exp31
7 files changed, 92 insertions, 1 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 8684d81f1ff..fe8bcb790c4 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,12 @@
2010-04-20 Joel Brobecker <brobecker@adacore.com>
+ * ada-typeprint.c (ada_print_typedef): New function.
+ * ada-lang.h (ada_print_typedef): Add declaration.
+ * ada-lang.c (ada_language_defn): set la_print_typdef field
+ to ada_print_typedef.
+
+2010-04-20 Joel Brobecker <brobecker@adacore.com>
+
* procfs.c (procfs_address_to_host_pointer): Only define when used.
2010-04-20 Joel Brobecker <brobecker@adacore.com>
diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c
index df8ff19f195..a598c6db791 100644
--- a/gdb/ada-lang.c
+++ b/gdb/ada-lang.c
@@ -11276,7 +11276,7 @@ const struct language_defn ada_language_defn = {
ada_printstr, /* Function to print string constant */
emit_char, /* Function to print single char (not used) */
ada_print_type, /* Print a type using appropriate syntax */
- default_print_typedef, /* Print a typedef using appropriate syntax */
+ ada_print_typedef, /* Print a typedef using appropriate syntax */
ada_val_print, /* Print a value using appropriate syntax */
ada_value_print, /* Print a top-level value */
NULL, /* Language specific skip_trampoline */
diff --git a/gdb/ada-lang.h b/gdb/ada-lang.h
index 017cff2548b..3d60f8f8a1d 100644
--- a/gdb/ada-lang.h
+++ b/gdb/ada-lang.h
@@ -159,6 +159,9 @@ extern void ada_error (char *); /* Defined in ada-exp.y */
extern void ada_print_type (struct type *, char *, struct ui_file *, int,
int);
+extern void ada_print_typedef (struct type *type, struct symbol *new_symbol,
+ struct ui_file *stream);
+
extern int ada_val_print (struct type *, const gdb_byte *, int, CORE_ADDR,
struct ui_file *, int,
const struct value_print_options *);
diff --git a/gdb/ada-typeprint.c b/gdb/ada-typeprint.c
index 74eaabf2afb..17d3594250d 100644
--- a/gdb/ada-typeprint.c
+++ b/gdb/ada-typeprint.c
@@ -828,3 +828,14 @@ ada_print_type (struct type *type0, char *varstring, struct ui_file *stream,
break;
}
}
+
+/* Implement the la_print_typedef language method for Ada. */
+
+void
+ada_print_typedef (struct type *type, struct symbol *new_symbol,
+ struct ui_file *stream)
+{
+ type = ada_check_typedef (type);
+ ada_print_type (type, "", stream, 0, 0);
+ fprintf_filtered (stream, "\n");
+}
diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog
index 8913d8962b9..1a1df4c779c 100644
--- a/gdb/testsuite/ChangeLog
+++ b/gdb/testsuite/ChangeLog
@@ -1,5 +1,9 @@
2010-04-20 Joel Brobecker <brobecker@adacore.com>
+ * info_types.c, info_types.exp: New files.
+
+2010-04-20 Joel Brobecker <brobecker@adacore.com>
+
* gdb.ada/dyn_loc: New testcase.
2010-04-20 Chris Moller <cmoller@redhat.com>
diff --git a/gdb/testsuite/gdb.ada/info_types.c b/gdb/testsuite/gdb.ada/info_types.c
new file mode 100644
index 00000000000..c7fd3f4d789
--- /dev/null
+++ b/gdb/testsuite/gdb.ada/info_types.c
@@ -0,0 +1,35 @@
+/* This test program is part of GDB, the GNU debugger.
+
+ 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/>.
+ */
+
+typedef int new_integer_type;
+
+void
+do_something (int *val)
+{
+ *val = *val + 1;
+}
+
+int
+main (void)
+{
+ new_integer_type toto = 30;
+
+ do_something(&toto);
+ return 0;
+}
+
diff --git a/gdb/testsuite/gdb.ada/info_types.exp b/gdb/testsuite/gdb.ada/info_types.exp
new file mode 100644
index 00000000000..a62da35debe
--- /dev/null
+++ b/gdb/testsuite/gdb.ada/info_types.exp
@@ -0,0 +1,31 @@
+# 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/>.
+
+set testfile info_types
+set srcfile ${testfile}.c
+if { [prepare_for_testing ${testfile}.exp ${testfile} ${srcfile}] } {
+ return -1
+}
+
+# Force the language to Ada. We used a C program because it was trivial
+# to get a typedef type, but the situation we are trying to reproduce is
+# when the Ada language is being used.
+gdb_test "set lang ada" ""
+
+set eol "\[\r\n\]+"
+
+gdb_test "info types new_integer_type" \
+ "All types matching regular expression \"new_integer_type\":${eol}File .*info_types.c:${eol}int"
+