This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[patch 07/12] entryval: "code cleanup": Remove `const' struct value *


Hi,

this is very mechanical patch just removing `const' from the `struct value
*original_value' parameter everywhere.

[patch 10/12] contains lines:
+  if (VALUE_LVAL (arg) == lval_computed)

where `arg' must not be `const'.  I could implement the check some other
simple way but I just think `struct value *' should not be passed in C as
`const' even if intended so as C does not support `const' well.

In C++ one can overload value_func as:
const struct value *value_func (const struct value *v) { return v; }
      struct value *value_func (      struct value *v) { return v; }

In C one cannot, one needs to implement `value_func' with two different names
and call it accordingly.  If GDB is in C++ I would not do this patch.


Thanks,
Jan


gdb/
2011-07-18  Jan Kratochvil  <jan.kratochvil@redhat.com>

	Remove const from struct value *original_value.
	* ada-lang.h (ada_val_print): Remove const from the val parameter.
	* ada-valprint.c (print_record, print_field_values): Likewise.
	(ada_val_print_1): Remove const from the original_value parameter.
	(ada_val_print, ada_val_print_array): Remove const from the val
	parameter.
	(ada_val_print_1): Remove const from the original_value parameter.
	(print_variant_part, print_record, print_field_values): Remove const
	from the val parameter.
	* c-lang.h (c_val_print): Remove const from the original_value
	parameter.
	(cp_print_value_fields, cp_print_value_fields_rtti): Remove const from
	the val parameter.
	* c-valprint.c (c_val_print): Remove const from the original_value
	parameter.
	* cp-valprint.c (cp_print_value, cp_print_value_fields)
	(cp_print_value_fields_rtti): Remove const from the val parameter.
	(cp_print_value): Remove const from the val parameter and the base_val
	variable.
	* d-lang.h (d_val_print): Remove const from the val parameter.
	* d-valprint.c (d_val_print): Likewise.
	* f-lang.h (f_val_print): Remove const from the original_value
	parameter.
	* f-valprint.c (f77_print_array_1, f77_print_array): Remove const from
	the val parameter.
	(f_val_print): Remove const from the original_value parameter.
	* jv-lang.h (java_val_print): Remove const from the val parameter.
	* jv-valprint.c (java_print_value_fields, java_val_print): Likewise.
	* language.c (unk_lang_val_print): Likewise.
	* language.h (struct language_defn) <la_val_print>: Likewise.
	* m2-lang.h (m2_val_print): Remove const from the original_value
	parameter.
	* m2-valprint.c (m2_print_array_contents): Remove const from the val
	parameter.  Twice.
	(m2_val_print): Remove const from the original_value parameter.
	* p-lang.h (pascal_val_print): Likewise.
	(pascal_object_print_value_fields): Remove const from the val
	parameter.
	* p-valprint.c (pascal_val_print): Remove const from the original_value
	parameter.
	(pascal_object_print_value, pascal_object_print_value_fields)
	(pascal_object_print_value): Remove const from the val parameter.
	* valprint.c (val_print, val_print_scalar_formatted)
	(val_print_array_elements): Likewise.
	* valprint.h (val_print_array_elements, val_print_scalar_formatted):
	Likewise.
	* value.h (val_print): Likewise.

--- a/gdb/ada-lang.h
+++ b/gdb/ada-lang.h
@@ -164,8 +164,7 @@ 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 *,
+                          struct ui_file *, int, struct value *,
 			  const struct value_print_options *);
 
 extern int ada_value_print (struct value *, struct ui_file *,
--- a/gdb/ada-valprint.c
+++ b/gdb/ada-valprint.c
@@ -37,23 +37,18 @@
 #include "objfiles.h"
 
 static void print_record (struct type *, const gdb_byte *, int,
-			  struct ui_file *,
-			  int,
-			  const struct value *,
+			  struct ui_file *, int, struct value *,
 			  const struct value_print_options *);
 
 static int print_field_values (struct type *, const gdb_byte *,
-			       int,
-			       struct ui_file *, int,
-			       const struct value *,
+			       int, struct ui_file *, int, struct value *,
 			       const struct value_print_options *,
 			       int, struct type *, int);
 
 static void adjust_type_signedness (struct type *);
 
 static int ada_val_print_1 (struct type *, const gdb_byte *, int, CORE_ADDR,
-			    struct ui_file *, int,
-			    const struct value *,
+			    struct ui_file *, int, struct value *,
 			    const struct value_print_options *);
 
 
@@ -573,8 +568,7 @@ ada_printstr (struct ui_file *stream, struct type *type,
 int
 ada_val_print (struct type *type, const gdb_byte *valaddr,
 	       int embedded_offset, CORE_ADDR address,
-	       struct ui_file *stream, int recurse,
-	       const struct value *val,
+	       struct ui_file *stream, int recurse, struct value *val,
 	       const struct value_print_options *options)
 {
   volatile struct gdb_exception except;
@@ -601,8 +595,7 @@ ada_val_print (struct type *type, const gdb_byte *valaddr,
 static int
 ada_val_print_array (struct type *type, const gdb_byte *valaddr,
 		     int offset, CORE_ADDR address,
-		     struct ui_file *stream, int recurse,
-		     const struct value *val,
+		     struct ui_file *stream, int recurse, struct value *val,
 		     const struct value_print_options *options)
 {
   int result = 0;
@@ -670,7 +663,7 @@ static int
 ada_val_print_1 (struct type *type, const gdb_byte *valaddr,
 		 int offset, CORE_ADDR address,
 		 struct ui_file *stream, int recurse,
-		 const struct value *original_value,
+		 struct value *original_value,
 		 const struct value_print_options *options)
 {
   unsigned int len;
@@ -929,8 +922,7 @@ ada_val_print_1 (struct type *type, const gdb_byte *valaddr,
 static int
 print_variant_part (struct type *type, int field_num,
 		    const gdb_byte *valaddr, int offset,
-		    struct ui_file *stream, int recurse,
-		    const struct value *val,
+		    struct ui_file *stream, int recurse, struct value *val,
 		    const struct value_print_options *options,
 		    int comma_needed,
 		    struct type *outer_type, int outer_offset)
@@ -1004,8 +996,7 @@ ada_value_print (struct value *val0, struct ui_file *stream,
 static void
 print_record (struct type *type, const gdb_byte *valaddr,
 	      int offset,
-	      struct ui_file *stream, int recurse,
-	      const struct value *val,
+	      struct ui_file *stream, int recurse, struct value *val,
 	      const struct value_print_options *options)
 {
   type = ada_check_typedef (type);
@@ -1041,7 +1032,7 @@ print_record (struct type *type, const gdb_byte *valaddr,
 static int
 print_field_values (struct type *type, const gdb_byte *valaddr,
 		    int offset, struct ui_file *stream, int recurse,
-		    const struct value *val,
+		    struct value *val,
 		    const struct value_print_options *options,
 		    int comma_needed,
 		    struct type *outer_type, int outer_offset)
--- a/gdb/c-lang.h
+++ b/gdb/c-lang.h
@@ -73,8 +73,7 @@ extern void c_print_typedef (struct type *,
 
 extern int c_val_print (struct type *, const gdb_byte *,
 			int, CORE_ADDR,
-			struct ui_file *, int,
-			const struct value *,
+			struct ui_file *, int, struct value *,
 			const struct value_print_options *);
 
 extern int c_value_print (struct value *, struct ui_file *,
@@ -119,15 +118,13 @@ extern void cp_print_class_member (const gdb_byte *, struct type *,
 
 extern void cp_print_value_fields (struct type *, struct type *,
 				   const gdb_byte *, int, CORE_ADDR,
-				   struct ui_file *, int,
-				   const struct value *,
+				   struct ui_file *, int, struct value *,
 				   const struct value_print_options *,
 				   struct type **, int);
 
 extern void cp_print_value_fields_rtti (struct type *,
 					const gdb_byte *, int, CORE_ADDR,
-					struct ui_file *, int,
-					const struct value *,
+					struct ui_file *, int, struct value *,
 					const struct value_print_options *,
 					struct type **, int);
 
--- a/gdb/c-valprint.c
+++ b/gdb/c-valprint.c
@@ -149,8 +149,7 @@ c_textual_element_type (struct type *type, char format)
 int
 c_val_print (struct type *type, const gdb_byte *valaddr,
 	     int embedded_offset, CORE_ADDR address,
-	     struct ui_file *stream, int recurse,
-	     const struct value *original_value,
+	     struct ui_file *stream, int recurse, struct value *original_value,
 	     const struct value_print_options *options)
 {
   struct gdbarch *gdbarch = get_type_arch (type);
--- a/gdb/cp-valprint.c
+++ b/gdb/cp-valprint.c
@@ -85,7 +85,7 @@ static void cp_print_static_field (struct type *, struct value *,
 static void cp_print_value (struct type *, struct type *,
 			    const gdb_byte *, int,
 			    CORE_ADDR, struct ui_file *,
-			    int, const struct value *,
+			    int, struct value *,
 			    const struct value_print_options *,
 			    struct type **);
 
@@ -159,7 +159,7 @@ void
 cp_print_value_fields (struct type *type, struct type *real_type,
 		       const gdb_byte *valaddr, int offset,
 		       CORE_ADDR address, struct ui_file *stream,
-		       int recurse, const struct value *val,
+		       int recurse, struct value *val,
 		       const struct value_print_options *options,
 		       struct type **dont_print_vb,
 		       int dont_print_statmem)
@@ -432,7 +432,7 @@ cp_print_value_fields_rtti (struct type *type,
 			    const gdb_byte *valaddr, int offset,
 			    CORE_ADDR address,
 			    struct ui_file *stream, int recurse,
-			    const struct value *val,
+			    struct value *val,
 			    const struct value_print_options *options,
 			    struct type **dont_print_vb, 
 			    int dont_print_statmem)
@@ -471,7 +471,7 @@ static void
 cp_print_value (struct type *type, struct type *real_type,
 		const gdb_byte *valaddr, int offset,
 		CORE_ADDR address, struct ui_file *stream,
-		int recurse, const struct value *val,
+		int recurse, struct value *val,
 		const struct value_print_options *options,
 		struct type **dont_print_vb)
 {
@@ -498,7 +498,7 @@ cp_print_value (struct type *type, struct type *real_type,
       struct type *baseclass = check_typedef (TYPE_BASECLASS (type, i));
       char *basename = TYPE_NAME (baseclass);
       const gdb_byte *base_valaddr = NULL;
-      const struct value *base_val = NULL;
+      struct value *base_val = NULL;
       volatile struct gdb_exception ex;
 
       if (BASETYPE_VIA_VIRTUAL (type, i))
--- a/gdb/d-lang.h
+++ b/gdb/d-lang.h
@@ -27,8 +27,7 @@ extern char *d_demangle (const char *mangled, int options);
 
 extern int d_val_print (struct type *type, const gdb_byte *valaddr,
 			int embedded_offset, CORE_ADDR address,
-			struct ui_file *stream, int recurse,
-			const struct value *val,
+			struct ui_file *stream, int recurse, struct value *val,
 			const struct value_print_options *options);
 
 #endif /* !defined (D_LANG_H) */
--- a/gdb/d-valprint.c
+++ b/gdb/d-valprint.c
@@ -72,8 +72,7 @@ dynamic_array_type (struct type *type, const gdb_byte *valaddr,
 int
 d_val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset,
              CORE_ADDR address, struct ui_file *stream, int recurse,
-	     const struct value *val,
-             const struct value_print_options *options)
+	     struct value *val, const struct value_print_options *options)
 {
   int ret;
 
--- a/gdb/f-lang.h
+++ b/gdb/f-lang.h
@@ -29,8 +29,7 @@ extern void f_print_type (struct type *, const char *, struct ui_file *, int,
 			  int);
 
 extern int f_val_print (struct type *, const gdb_byte *, int, CORE_ADDR,
-			struct ui_file *, int,
-			const struct value *,
+			struct ui_file *, int, struct value *,
 			const struct value_print_options *);
 
 /* Language-specific data structures */
--- a/gdb/f-valprint.c
+++ b/gdb/f-valprint.c
@@ -165,8 +165,7 @@ static void
 f77_print_array_1 (int nss, int ndimensions, struct type *type,
 		   const gdb_byte *valaddr,
 		   int embedded_offset, CORE_ADDR address,
-		   struct ui_file *stream, int recurse,
-		   const struct value *val,
+		   struct ui_file *stream, int recurse, struct value *val,
 		   const struct value_print_options *options,
 		   int *elts)
 {
@@ -217,8 +216,7 @@ static void
 f77_print_array (struct type *type, const gdb_byte *valaddr,
 		 int embedded_offset,
 		 CORE_ADDR address, struct ui_file *stream,
-		 int recurse,
-		 const struct value *val,
+		 int recurse, struct value *val,
 		 const struct value_print_options *options)
 {
   int ndimensions;
@@ -249,7 +247,7 @@ Type node corrupt! F77 arrays cannot have %d subscripts (%d Max)"),
 int
 f_val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset,
 	     CORE_ADDR address, struct ui_file *stream, int recurse,
-	     const struct value *original_value,
+	     struct value *original_value,
 	     const struct value_print_options *options)
 {
   struct gdbarch *gdbarch = get_type_arch (type);
--- a/gdb/jv-lang.h
+++ b/gdb/jv-lang.h
@@ -43,8 +43,7 @@ struct builtin_java_type
 extern const struct builtin_java_type *builtin_java_type (struct gdbarch *);
 
 extern int java_val_print (struct type *, const gdb_byte *, int, CORE_ADDR,
-			   struct ui_file *, int,
-			   const struct value *,
+			   struct ui_file *, int, struct value *,
 			   const struct value_print_options *);
 
 extern int java_value_print (struct value *, struct ui_file *,
--- a/gdb/jv-valprint.c
+++ b/gdb/jv-valprint.c
@@ -264,8 +264,7 @@ static void
 java_print_value_fields (struct type *type, const gdb_byte *valaddr,
 			 int offset,
 			 CORE_ADDR address, struct ui_file *stream,
-			 int recurse,
-			 const struct value *val,
+			 int recurse, struct value *val,
 			 const struct value_print_options *options)
 {
   int i, len, n_baseclasses;
@@ -482,8 +481,7 @@ java_print_value_fields (struct type *type, const gdb_byte *valaddr,
 int
 java_val_print (struct type *type, const gdb_byte *valaddr,
 		int embedded_offset, CORE_ADDR address,
-		struct ui_file *stream, int recurse,
-		const struct value *val,
+		struct ui_file *stream, int recurse, struct value *val,
 		const struct value_print_options *options)
 {
   struct gdbarch *gdbarch = get_type_arch (type);
--- a/gdb/language.c
+++ b/gdb/language.c
@@ -1118,7 +1118,7 @@ static int
 unk_lang_val_print (struct type *type, const gdb_byte *valaddr,
 		    int embedded_offset, CORE_ADDR address,
 		    struct ui_file *stream, int recurse,
-		    const struct value *val,
+		    struct value *val,
 		    const struct value_print_options *options)
 {
   error (_("internal error - unimplemented "
--- a/gdb/language.h
+++ b/gdb/language.h
@@ -234,7 +234,7 @@ struct language_defn
 			 const gdb_byte *contents,
 			 int embedded_offset, CORE_ADDR address,
 			 struct ui_file *stream, int recurse,
-			 const struct value *val,
+			 struct value *val,
 			 const struct value_print_options *options);
 
     /* Print a top-level value using syntax appropriate for this language.  */
--- a/gdb/m2-lang.h
+++ b/gdb/m2-lang.h
@@ -33,8 +33,7 @@ extern int m2_is_long_set (struct type *type);
 extern int m2_is_unbounded_array (struct type *type);
 
 extern int m2_val_print (struct type *, const gdb_byte *, int, CORE_ADDR,
-			 struct ui_file *, int,
-			 const struct value *,
+			 struct ui_file *, int, struct value *,
 			 const struct value_print_options *);
 
 extern int get_long_set_bounds (struct type *type, LONGEST *low,
--- a/gdb/m2-valprint.c
+++ b/gdb/m2-valprint.c
@@ -38,7 +38,7 @@ static void
 m2_print_array_contents (struct type *type, const gdb_byte *valaddr,
 			 int embedded_offset, CORE_ADDR address,
 			 struct ui_file *stream, int recurse,
-			 const struct value *val,
+			 struct value *val,
 			 const struct value_print_options *options,
 			 int len);
 
@@ -279,7 +279,7 @@ static void
 m2_print_array_contents (struct type *type, const gdb_byte *valaddr,
 			 int embedded_offset, CORE_ADDR address,
 			 struct ui_file *stream, int recurse,
-			 const struct value *val,
+			 struct value *val,
 			 const struct value_print_options *options,
 			 int len)
 {
@@ -317,7 +317,7 @@ m2_print_array_contents (struct type *type, const gdb_byte *valaddr,
 int
 m2_val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset,
 	      CORE_ADDR address, struct ui_file *stream, int recurse,
-	      const struct value *original_value,
+	      struct value *original_value,
 	      const struct value_print_options *options)
 {
   struct gdbarch *gdbarch = get_type_arch (type);
--- a/gdb/p-lang.h
+++ b/gdb/p-lang.h
@@ -38,7 +38,7 @@ extern void pascal_print_typedef (struct type *, struct symbol *,
 
 extern int pascal_val_print (struct type *, const gdb_byte *, int,
 			     CORE_ADDR, struct ui_file *, int,
-			     const struct value *,
+			     struct value *,
 			     const struct value_print_options *);
 
 extern int pascal_value_print (struct value *, struct ui_file *,
@@ -72,8 +72,7 @@ extern void
 extern void pascal_object_print_value_fields (struct type *, const gdb_byte *,
 					      int,
 					      CORE_ADDR, struct ui_file *,
-					      int,
-					      const struct value *,
+					      int, struct value *,
 					      const struct value_print_options *,
 					      struct type **, int);
 
--- a/gdb/p-valprint.c
+++ b/gdb/p-valprint.c
@@ -49,7 +49,7 @@ int
 pascal_val_print (struct type *type, const gdb_byte *valaddr,
 		  int embedded_offset, CORE_ADDR address,
 		  struct ui_file *stream, int recurse,
-		  const struct value *original_value,
+		  struct value *original_value,
 		  const struct value_print_options *options)
 {
   struct gdbarch *gdbarch = get_type_arch (type);
@@ -626,7 +626,7 @@ static void pascal_object_print_static_field (struct value *,
 static void pascal_object_print_value (struct type *, const gdb_byte *,
 				       int,
 				       CORE_ADDR, struct ui_file *, int,
-				       const struct value *,
+				       struct value *,
 				       const struct value_print_options *,
 				       struct type **);
 
@@ -685,8 +685,7 @@ void
 pascal_object_print_value_fields (struct type *type, const gdb_byte *valaddr,
 				  int offset,
 				  CORE_ADDR address, struct ui_file *stream,
-				  int recurse,
-				  const struct value *val,
+				  int recurse, struct value *val,
 				  const struct value_print_options *options,
 				  struct type **dont_print_vb,
 				  int dont_print_statmem)
@@ -880,8 +879,7 @@ static void
 pascal_object_print_value (struct type *type, const gdb_byte *valaddr,
 			   int offset,
 			   CORE_ADDR address, struct ui_file *stream,
-			   int recurse,
-			   const struct value *val,
+			   int recurse, struct value *val,
 			   const struct value_print_options *options,
 			   struct type **dont_print_vb)
 {
--- a/gdb/valprint.c
+++ b/gdb/valprint.c
@@ -340,7 +340,7 @@ val_print_invalid_address (struct ui_file *stream)
 int
 val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset,
 	   CORE_ADDR address, struct ui_file *stream, int recurse,
-	   const struct value *val,
+	   struct value *val,
 	   const struct value_print_options *options,
 	   const struct language_defn *language)
 {
@@ -555,7 +555,7 @@ val_print_type_code_flags (struct type *type, const gdb_byte *valaddr,
 void
 val_print_scalar_formatted (struct type *type,
 			    const gdb_byte *valaddr, int embedded_offset,
-			    const struct value *val,
+			    struct value *val,
 			    const struct value_print_options *options,
 			    int size,
 			    struct ui_file *stream)
@@ -1189,8 +1189,7 @@ void
 val_print_array_elements (struct type *type,
 			  const gdb_byte *valaddr, int embedded_offset,
 			  CORE_ADDR address, struct ui_file *stream,
-			  int recurse,
-			  const struct value *val,
+			  int recurse, struct value *val,
 			  const struct value_print_options *options,
 			  unsigned int i)
 {
--- a/gdb/valprint.h
+++ b/gdb/valprint.h
@@ -115,7 +115,7 @@ extern void maybe_print_array_index (struct type *index_type, LONGEST index,
 
 extern void val_print_array_elements (struct type *, const gdb_byte *, int,
 				      CORE_ADDR, struct ui_file *, int,
-				      const struct value *,
+				      struct value *,
 				      const struct value_print_options *,
 				      unsigned int);
 
@@ -127,8 +127,7 @@ extern void val_print_type_code_flags (struct type *type,
 				       struct ui_file *stream);
 
 extern void val_print_scalar_formatted (struct type *,
-					const gdb_byte *, int,
-					const struct value *,
+					const gdb_byte *, int, struct value *,
 					const struct value_print_options *,
 					int,
 					struct ui_file *);
--- a/gdb/value.h
+++ b/gdb/value.h
@@ -787,7 +787,7 @@ extern struct value *value_release_to_mark (struct value *mark);
 extern int val_print (struct type *type, const gdb_byte *valaddr,
 		      int embedded_offset, CORE_ADDR address,
 		      struct ui_file *stream, int recurse,
-		      const struct value *val,
+		      struct value *val,
 		      const struct value_print_options *options,
 		      const struct language_defn *language);
 


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]