This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
[02/11] Fortran dynamic arrays support: la_print_type with an address
- From: Jan Kratochvil <jan dot kratochvil at redhat dot com>
- To: gdb-patches at sourceware dot org
- Date: Fri, 16 Nov 2007 04:20:13 +0100
- Subject: [02/11] Fortran dynamic arrays support: la_print_type with an address
Hi,
[copy from 0/9]
There is a design problem that GDB deals with the TYPE already without any
relation to the original variable. I tried to patch there a general
TYPE->VARIABLE binding first but it is too intrusive for GDB as it makes the
same abstract TYPE and VARIABLE-bound TYPE two different objects. Current
patchset provides another function parameter in the codepaths requiring it.
Regards,
Jan
2007-11-16 Jan Kratochvil <jan.kratochvil@redhat.com>
* ada-lang.c (ada_print_type_with_address): New function.
(ada_language_defn): Replace ADA_PRINT_TYPE with
ADA_PRINT_TYPE_WITH_ADDRESS.
* c-lang.c (c_print_type_with_address): Call C_PRINT_TYPE.
(c_language_defn, cplus_language_defn, asm_language_defn,
minimal_language_defn): Replace C_PRINT_TYPE with
C_PRINT_TYPE_WITH_ADDRESS.
* c-lang.h (c_print_type_with_address): New prototype.
* f-lang.c (f_language_defn): Replace F_PRINT_TYPE with
F_PRINT_TYPE_WITH_ADDRESS.
* f-lang.h (f_print_type): Prototype replaced with ...
(f_print_type_with_address): ... this one.
* f-typeprint.c (f_print_type): Add the parameter ADDRESS and renamed
the function to ...
(f_print_type_with_address): ... this name.
Replace the F_PRINT_TYPE call with F_PRINT_TYPE_WITH_ADDRESS.
* jv-lang.c (java_print_type_with_address): New function.
(java_language_defn): Replace JAVA_PRINT_TYPE with
JAVA_PRINT_TYPE_WITH_ADDRESS.
* language.h (struct language_defn): Renamed the field LA_PRINT_TYPE to
LA_PRINT_TYPE_WITH_ADDRESS and add its ADDRESS parameter.
(LA_PRINT_TYPE_WITH_ADDRESS): New macro.
(LA_PRINT_TYPE): Replace LA_PRINT_TYPE with LA_PRINT_TYPE_WITH_ADDRESS
and add its new ADDRESS paramete dummy value.
* m2-lang.c (m2_print_type_with_address): New function.
(m2_language_defn): Replace M2_PRINT_TYPE with
M2_PRINT_TYPE_WITH_ADDRESS.
* objc-lang.c (objc_language_defn): Replace C_PRINT_TYPE with
C_PRINT_TYPE_WITH_ADDRESS.
* p-lang.c (pascal_print_type_with_address): New function.
(pascal_language_defn): Replace PASCAL_PRINT_TYPE with
PASCAL_PRINT_TYPE_WITH_ADDRESS.
* scm-lang.c (scm_language_defn): Replace C_PRINT_TYPE with
C_PRINT_TYPE_WITH_ADDRESS.
* typeprint.c (type_print_with_address): New function.
(whatis_exp): Replace the TYPE_PRINT call with the
TYPE_PRINT_WITH_ADDRESS call with the additional ADDRESS value.
* language.c (unk_lang_print_type): Add the unused ADDRESS parameter.
* value.h (type_print_with_address): New prototype.
Index: sources/gdb/ada-lang.c
===================================================================
--- sources.orig/gdb/ada-lang.c 2007-11-16 00:40:59.000000000 +0100
+++ sources/gdb/ada-lang.c 2007-11-16 00:41:12.000000000 +0100
@@ -10408,6 +10408,14 @@ static const struct exp_descriptor ada_e
ada_evaluate_subexp
};
+static void
+ada_print_type_with_address (struct type *type0, CORE_ADDR address,
+ char *varstring, struct ui_file *stream, int show,
+ int level)
+{
+ ada_print_type (type0, varstring, stream, show, level);
+}
+
const struct language_defn ada_language_defn = {
"ada", /* Language name */
language_ada,
@@ -10424,7 +10432,7 @@ const struct language_defn ada_language_
ada_printstr, /* Function to print string constant */
emit_char, /* Function to print single char (not used) */
ada_create_fundamental_type, /* Create fundamental type in this language */
- ada_print_type, /* Print a type using appropriate syntax */
+ ada_print_type_with_address, /* Print a type 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 */
Index: sources/gdb/c-lang.c
===================================================================
--- sources.orig/gdb/c-lang.c 2007-11-16 00:40:59.000000000 +0100
+++ sources/gdb/c-lang.c 2007-11-16 00:41:12.000000000 +0100
@@ -588,6 +588,14 @@ c_language_arch_info (struct gdbarch *gd
lai->primitive_type_vector [c_primitive_type_double_complex] = builtin->builtin_double_complex;
}
+void
+c_print_type_with_address (struct type *type, CORE_ADDR address,
+ char *varstring, struct ui_file *stream, int show,
+ int level)
+{
+ c_print_type (type, varstring, stream, show, level);
+}
+
const struct language_defn c_language_defn =
{
"c", /* Language name */
@@ -604,7 +612,7 @@ const struct language_defn c_language_de
c_printstr, /* Function to print string constant */
c_emit_char, /* Print a single char */
c_create_fundamental_type, /* Create fundamental type in this language */
- c_print_type, /* Print a type using appropriate syntax */
+ c_print_type_with_address, /* Print a type using appropriate syntax */
c_val_print, /* Print a value using appropriate syntax */
c_value_print, /* Print a top-level value */
NULL, /* Language specific skip_trampoline */
@@ -708,7 +716,7 @@ const struct language_defn cplus_languag
c_printstr, /* Function to print string constant */
c_emit_char, /* Print a single char */
c_create_fundamental_type, /* Create fundamental type in this language */
- c_print_type, /* Print a type using appropriate syntax */
+ c_print_type_with_address, /* Print a type using appropriate syntax */
c_val_print, /* Print a value using appropriate syntax */
c_value_print, /* Print a top-level value */
cplus_skip_trampoline, /* Language specific skip_trampoline */
@@ -743,7 +751,7 @@ const struct language_defn asm_language_
c_printstr, /* Function to print string constant */
c_emit_char, /* Print a single char */
c_create_fundamental_type, /* Create fundamental type in this language */
- c_print_type, /* Print a type using appropriate syntax */
+ c_print_type_with_address, /* Print a type using appropriate syntax */
c_val_print, /* Print a value using appropriate syntax */
c_value_print, /* Print a top-level value */
NULL, /* Language specific skip_trampoline */
@@ -783,7 +791,7 @@ const struct language_defn minimal_langu
c_printstr, /* Function to print string constant */
c_emit_char, /* Print a single char */
c_create_fundamental_type, /* Create fundamental type in this language */
- c_print_type, /* Print a type using appropriate syntax */
+ c_print_type_with_address, /* Print a type using appropriate syntax */
c_val_print, /* Print a value using appropriate syntax */
c_value_print, /* Print a top-level value */
NULL, /* Language specific skip_trampoline */
Index: sources/gdb/c-lang.h
===================================================================
--- sources.orig/gdb/c-lang.h 2007-11-16 00:40:59.000000000 +0100
+++ sources/gdb/c-lang.h 2007-11-16 00:41:12.000000000 +0100
@@ -36,6 +36,9 @@ extern void c_error (char *); /* Defined
/* Defined in c-typeprint.c */
extern void c_print_type (struct type *, char *, struct ui_file *, int,
int);
+extern void c_print_type_with_address (struct type *type, CORE_ADDR address,
+ char *varstring, struct ui_file *stream,
+ int show, int level);
extern int c_val_print (struct type *, const gdb_byte *, int, CORE_ADDR,
struct ui_file *, int, int, int,
Index: sources/gdb/f-lang.c
===================================================================
--- sources.orig/gdb/f-lang.c 2007-11-16 00:40:59.000000000 +0100
+++ sources/gdb/f-lang.c 2007-11-16 00:41:12.000000000 +0100
@@ -486,7 +486,7 @@ const struct language_defn f_language_de
f_printstr, /* function to print string constant */
f_emit_char, /* Function to print a single character */
f_create_fundamental_type, /* Create fundamental type in this language */
- f_print_type, /* Print a type using appropriate syntax */
+ f_print_type_with_address, /* Print a type using appropriate syntax */
f_val_print, /* Print a value using appropriate syntax */
c_value_print, /* FIXME */
NULL, /* Language specific skip_trampoline */
Index: sources/gdb/f-lang.h
===================================================================
--- sources.orig/gdb/f-lang.h 2007-11-16 00:40:59.000000000 +0100
+++ sources/gdb/f-lang.h 2007-11-16 00:41:12.000000000 +0100
@@ -25,8 +25,8 @@ extern int f_parse (void);
extern void f_error (char *); /* Defined in f-exp.y */
-extern void f_print_type (struct type *, char *, struct ui_file *, int,
- int);
+extern void f_print_type_with_address (struct type *, CORE_ADDR, char *,
+ struct ui_file *, int, int);
extern int f_val_print (struct type *, const gdb_byte *, int, CORE_ADDR,
struct ui_file *, int, int, int,
Index: sources/gdb/f-typeprint.c
===================================================================
--- sources.orig/gdb/f-typeprint.c 2007-11-16 00:40:59.000000000 +0100
+++ sources/gdb/f-typeprint.c 2007-11-16 00:41:12.000000000 +0100
@@ -54,8 +54,9 @@ void f_type_print_base (struct type *, s
/* LEVEL is the depth to indent lines by. */
void
-f_print_type (struct type *type, char *varstring, struct ui_file *stream,
- int show, int level)
+f_print_type_with_address (struct type *type, CORE_ADDR address,
+ char *varstring, struct ui_file *stream, int show,
+ int level)
{
enum type_code code;
int demangled_args;
@@ -395,7 +396,8 @@ f_type_print_base (struct type *type, st
fputs_filtered ("\n", stream);
for (index = 0; index < TYPE_NFIELDS (type); index++)
{
- f_print_type (TYPE_FIELD_TYPE (type, index), "", stream, show, level + 4);
+ f_print_type_with_address (TYPE_FIELD_TYPE (type, index), 0, "", stream,
+ show, level + 4);
fputs_filtered (" :: ", stream);
fputs_filtered (TYPE_FIELD_NAME (type, index), stream);
fputs_filtered ("\n", stream);
Index: sources/gdb/jv-lang.c
===================================================================
--- sources.orig/gdb/jv-lang.c 2007-11-16 00:40:59.000000000 +0100
+++ sources/gdb/jv-lang.c 2007-11-16 00:41:12.000000000 +0100
@@ -1082,6 +1082,14 @@ const struct exp_descriptor exp_descript
evaluate_subexp_java
};
+static void
+java_print_type_with_address (struct type *type, CORE_ADDR address,
+ char *varstring, struct ui_file *stream,
+ int show, int level)
+{
+ return java_print_type (type, varstring, stream, show, level);
+}
+
const struct language_defn java_language_defn =
{
"java", /* Language name */
@@ -1098,7 +1106,7 @@ const struct language_defn java_language
c_printstr, /* Function to print string constant */
java_emit_char, /* Function to print a single character */
java_create_fundamental_type, /* Create fundamental type in this language */
- java_print_type, /* Print a type using appropriate syntax */
+ java_print_type_with_address, /* Print a type using appropriate syntax */
java_val_print, /* Print a value using appropriate syntax */
java_value_print, /* Print a top-level value */
NULL, /* Language specific skip_trampoline */
Index: sources/gdb/language.h
===================================================================
--- sources.orig/gdb/language.h 2007-11-16 00:40:59.000000000 +0100
+++ sources/gdb/language.h 2007-11-16 00:41:12.000000000 +0100
@@ -195,8 +195,8 @@ struct language_defn
/* Print a type using syntax appropriate for this language. */
- void (*la_print_type) (struct type *, char *, struct ui_file *, int,
- int);
+ void (*la_print_type_with_address) (struct type *, CORE_ADDR, char *,
+ struct ui_file *, int, int);
/* Print a value using syntax appropriate for this language. */
@@ -345,8 +345,11 @@ extern enum language set_language (enum
#define create_fundamental_type(objfile,typeid) \
(current_language->la_fund_type(objfile, typeid))
+#define LA_PRINT_TYPE_WITH_ADDRESS(type,adress,varstring,stream,show,level) \
+ (current_language->la_print_type_with_address(type,address,varstring,stream,show,level))
+
#define LA_PRINT_TYPE(type,varstring,stream,show,level) \
- (current_language->la_print_type(type,varstring,stream,show,level))
+ (current_language->la_print_type_with_address(type,0,varstring,stream,show,level))
#define LA_VAL_PRINT(type,valaddr,offset,addr,stream,fmt,deref,recurse,pretty) \
(current_language->la_val_print(type,valaddr,offset,addr,stream,fmt,deref, \
Index: sources/gdb/m2-lang.c
===================================================================
--- sources.orig/gdb/m2-lang.c 2007-11-16 00:40:59.000000000 +0100
+++ sources/gdb/m2-lang.c 2007-11-16 00:41:12.000000000 +0100
@@ -525,6 +525,14 @@ const struct exp_descriptor exp_descript
evaluate_subexp_modula2
};
+static void
+m2_print_type_with_address (struct type *type, CORE_ADDR address,
+ char *varstring, struct ui_file *stream, int show,
+ int level)
+{
+ m2_print_type (type, varstring, stream, show, level);
+}
+
const struct language_defn m2_language_defn =
{
"modula-2",
@@ -541,7 +549,7 @@ const struct language_defn m2_language_d
m2_printstr, /* function to print string constant */
m2_emit_char, /* Function to print a single character */
m2_create_fundamental_type, /* Create fundamental type in this language */
- m2_print_type, /* Print a type using appropriate syntax */
+ m2_print_type_with_address, /* Print a type using appropriate syntax */
m2_val_print, /* Print a value using appropriate syntax */
c_value_print, /* Print a top-level value */
NULL, /* Language specific skip_trampoline */
Index: sources/gdb/objc-lang.c
===================================================================
--- sources.orig/gdb/objc-lang.c 2007-11-16 00:40:59.000000000 +0100
+++ sources/gdb/objc-lang.c 2007-11-16 00:41:12.000000000 +0100
@@ -651,7 +651,7 @@ const struct language_defn objc_language
objc_printstr, /* Function to print string constant */
objc_emit_char,
objc_create_fundamental_type, /* Create fundamental type in this language */
- c_print_type, /* Print a type using appropriate syntax */
+ c_print_type_with_address, /* Print a type using appropriate syntax */
c_val_print, /* Print a value using appropriate syntax */
c_value_print, /* Print a top-level value */
objc_skip_trampoline, /* Language specific skip_trampoline */
Index: sources/gdb/p-lang.c
===================================================================
--- sources.orig/gdb/p-lang.c 2007-11-16 00:40:59.000000000 +0100
+++ sources/gdb/p-lang.c 2007-11-16 00:41:12.000000000 +0100
@@ -542,6 +542,14 @@ pascal_language_arch_info (struct gdbarc
= builtin->builtin_double_complex;
}
+static void
+pascal_print_type_with_address (struct type *type, CORE_ADDR address,
+ char *varstring, struct ui_file *stream,
+ int show, int level)
+{
+ return pascal_print_type (type, varstring, stream, show, level);
+}
+
const struct language_defn pascal_language_defn =
{
"pascal", /* Language name */
@@ -558,7 +566,7 @@ const struct language_defn pascal_langua
pascal_printstr, /* Function to print string constant */
pascal_emit_char, /* Print a single char */
pascal_create_fundamental_type, /* Create fundamental type in this language */
- pascal_print_type, /* Print a type using appropriate syntax */
+ pascal_print_type_with_address, /* Print a type using appropriate syntax */
pascal_val_print, /* Print a value using appropriate syntax */
pascal_value_print, /* Print a top-level value */
NULL, /* Language specific skip_trampoline */
Index: sources/gdb/scm-lang.c
===================================================================
--- sources.orig/gdb/scm-lang.c 2007-11-16 00:40:59.000000000 +0100
+++ sources/gdb/scm-lang.c 2007-11-16 00:41:12.000000000 +0100
@@ -250,7 +250,7 @@ const struct language_defn scm_language_
scm_printstr, /* Function to print string constant */
NULL, /* Function to print a single character */
NULL, /* Create fundamental type in this language */
- c_print_type, /* Print a type using appropriate syntax */
+ c_print_type_with_address, /* Print a type using appropriate syntax */
scm_val_print, /* Print a value using appropriate syntax */
scm_value_print, /* Print a top-level value */
NULL, /* Language specific skip_trampoline */
Index: sources/gdb/typeprint.c
===================================================================
--- sources.orig/gdb/typeprint.c 2007-11-16 00:40:59.000000000 +0100
+++ sources/gdb/typeprint.c 2007-11-16 00:41:12.000000000 +0100
@@ -99,6 +99,13 @@ typedef_print (struct type *type, struct
If SHOW is negative, we never show the details of elements' types. */
void
+type_print_with_address (struct type *type, CORE_ADDR address, char *varstring,
+ struct ui_file *stream, int show)
+{
+ LA_PRINT_TYPE_WITH_ADDRESS (type, address, varstring, stream, show, 0);
+}
+
+void
type_print (struct type *type, char *varstring, struct ui_file *stream,
int show)
{
@@ -156,13 +163,14 @@ whatis_exp (char *exp, int show)
if (real_type)
{
printf_filtered ("/* real type = ");
- type_print (real_type, "", gdb_stdout, -1);
+ type_print_with_address (real_type, VALUE_ADDRESS (val), "", gdb_stdout,
+ -1);
if (! full)
printf_filtered (" (incomplete object)");
printf_filtered (" */\n");
}
- type_print (type, "", gdb_stdout, show);
+ type_print_with_address (type, VALUE_ADDRESS (val), "", gdb_stdout, show);
printf_filtered ("\n");
if (exp)
Index: sources/gdb/language.c
===================================================================
--- sources.orig/gdb/language.c 2007-11-16 00:40:59.000000000 +0100
+++ sources/gdb/language.c 2007-11-16 00:41:12.000000000 +0100
@@ -70,8 +70,8 @@ static void unk_lang_printchar (int c, s
static struct type *unk_lang_create_fundamental_type (struct objfile *, int);
-static void unk_lang_print_type (struct type *, char *, struct ui_file *,
- int, int);
+static void unk_lang_print_type (struct type *, CORE_ADDR, char *,
+ struct ui_file *, int, int);
static int unk_lang_value_print (struct value *, struct ui_file *, int, enum val_prettyprint);
@@ -1123,8 +1123,8 @@ unk_lang_create_fundamental_type (struct
}
static void
-unk_lang_print_type (struct type *type, char *varstring, struct ui_file *stream,
- int show, int level)
+unk_lang_print_type (struct type *type, CORE_ADDR address, char *varstring,
+ struct ui_file *stream, int show, int level)
{
error (_("internal error - unimplemented function unk_lang_print_type called."));
}
Index: sources/gdb/value.h
===================================================================
--- sources.orig/gdb/value.h 2007-11-16 00:40:59.000000000 +0100
+++ sources/gdb/value.h 2007-11-16 00:41:12.000000000 +0100
@@ -482,6 +482,10 @@ extern int record_latest_value (struct v
extern void modify_field (gdb_byte *addr, LONGEST fieldval, int bitpos,
int bitsize);
+extern void type_print_with_address (struct type *type, CORE_ADDR address,
+ char *varstring, struct ui_file *stream,
+ int show);
+
extern void type_print (struct type *type, char *varstring,
struct ui_file *stream, int show);