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]

[rfc] [07/17] Get rid of current_gdbarch in f-lang.c



Hi,


this patch gets rid of some of the current_gdbarch's in f-lang.c
Is this ok to commit?

ChangeLog:


* f-lang.c: Add new include objfiles.h (f_create_fundamental_type): Use objfile->gdbarch to get at the current architecture. (build_fortran_types): Replace current_gdbarch by gdbarch. * Makefile.in (f-lang.o): Add dependency on objfile.h


-- Markus Deuling GNU Toolchain for Linux on Cell BE deuling@de.ibm.com






diff -urpN src/gdb/f-lang.c dev/gdb/f-lang.c
--- src/gdb/f-lang.c	2007-09-23 18:25:05.000000000 +0200
+++ dev/gdb/f-lang.c	2007-10-11 09:05:49.000000000 +0200
@@ -31,7 +31,7 @@
 #include "f-lang.h"
 #include "valprint.h"
 #include "value.h"
-
+#include "objfiles.h"
 
 /* Following is dubious stuff that had been in the xcoff reader. */
 
@@ -231,6 +231,7 @@ f_printstr (struct ui_file *stream, cons
 static struct type *
 f_create_fundamental_type (struct objfile *objfile, int typeid)
 {
+  struct gdbarch *gdbarch = objfile->gdbarch;
   struct type *type = NULL;
 
   switch (typeid)
@@ -267,110 +268,104 @@ f_create_fundamental_type (struct objfil
       break;
     case FT_SHORT:
       type = init_type (TYPE_CODE_INT,
-			gdbarch_short_bit (current_gdbarch) / TARGET_CHAR_BIT,
+			gdbarch_short_bit (gdbarch) / TARGET_CHAR_BIT,
 			0, "integer*2", objfile);
       break;
     case FT_SIGNED_SHORT:
       type = init_type (TYPE_CODE_INT,
-			gdbarch_short_bit (current_gdbarch) / TARGET_CHAR_BIT,
+			gdbarch_short_bit (gdbarch) / TARGET_CHAR_BIT,
 			0, "short", objfile);	/* FIXME-fnf */
       break;
     case FT_UNSIGNED_SHORT:
       type = init_type (TYPE_CODE_BOOL,
-			gdbarch_short_bit (current_gdbarch) / TARGET_CHAR_BIT,
+			gdbarch_short_bit (gdbarch) / TARGET_CHAR_BIT,
 			TYPE_FLAG_UNSIGNED, "logical*2", objfile);
       break;
     case FT_INTEGER:
       type = init_type (TYPE_CODE_INT,
-			gdbarch_int_bit (current_gdbarch) / TARGET_CHAR_BIT,
+			gdbarch_int_bit (gdbarch) / TARGET_CHAR_BIT,
 			0, "integer*4", objfile);
       break;
     case FT_SIGNED_INTEGER:
       type = init_type (TYPE_CODE_INT,
-			gdbarch_int_bit (current_gdbarch) / TARGET_CHAR_BIT,
+			gdbarch_int_bit (gdbarch) / TARGET_CHAR_BIT,
 			0, "integer", objfile);		/* FIXME -fnf */
       break;
     case FT_UNSIGNED_INTEGER:
       type = init_type (TYPE_CODE_BOOL,
-			gdbarch_int_bit (current_gdbarch) / TARGET_CHAR_BIT,
+			gdbarch_int_bit (gdbarch) / TARGET_CHAR_BIT,
 			TYPE_FLAG_UNSIGNED, "logical*4", objfile);
       break;
     case FT_FIXED_DECIMAL:
       type = init_type (TYPE_CODE_INT,
-			gdbarch_int_bit (current_gdbarch) / TARGET_CHAR_BIT,
+			gdbarch_int_bit (gdbarch) / TARGET_CHAR_BIT,
 			0, "fixed decimal", objfile);
       break;
     case FT_LONG:
       type = init_type (TYPE_CODE_INT,
-			gdbarch_long_bit (current_gdbarch) / TARGET_CHAR_BIT,
+			gdbarch_long_bit (gdbarch) / TARGET_CHAR_BIT,
 			0, "long", objfile);
       break;
     case FT_SIGNED_LONG:
       type = init_type (TYPE_CODE_INT,
-			gdbarch_long_bit (current_gdbarch) / TARGET_CHAR_BIT,
+			gdbarch_long_bit (gdbarch) / TARGET_CHAR_BIT,
 			0, "long", objfile);	/* FIXME -fnf */
       break;
     case FT_UNSIGNED_LONG:
       type = init_type (TYPE_CODE_INT,
-			gdbarch_long_bit (current_gdbarch) / TARGET_CHAR_BIT,
+			gdbarch_long_bit (gdbarch) / TARGET_CHAR_BIT,
 			TYPE_FLAG_UNSIGNED, "unsigned long", objfile);
       break;
     case FT_LONG_LONG:
       type = init_type (TYPE_CODE_INT,
-			gdbarch_long_long_bit (current_gdbarch) 
-			 / TARGET_CHAR_BIT,
+			gdbarch_long_long_bit (gdbarch) / TARGET_CHAR_BIT,
 			0, "long long", objfile);
       break;
     case FT_SIGNED_LONG_LONG:
       type = init_type (TYPE_CODE_INT,
-			gdbarch_long_long_bit (current_gdbarch) 
-			 / TARGET_CHAR_BIT,
+			gdbarch_long_long_bit (gdbarch) / TARGET_CHAR_BIT,
 			0, "signed long long", objfile);
       break;
     case FT_UNSIGNED_LONG_LONG:
       type = init_type (TYPE_CODE_INT,
-			gdbarch_long_long_bit (current_gdbarch) 
-			 / TARGET_CHAR_BIT,
+			gdbarch_long_long_bit (gdbarch) / TARGET_CHAR_BIT,
 			TYPE_FLAG_UNSIGNED, "unsigned long long", objfile);
       break;
     case FT_FLOAT:
       type = init_type (TYPE_CODE_FLT,
-			gdbarch_float_bit (current_gdbarch) / TARGET_CHAR_BIT,
+			gdbarch_float_bit (gdbarch) / TARGET_CHAR_BIT,
 			0, "real", objfile);
       break;
     case FT_DBL_PREC_FLOAT:
       type = init_type (TYPE_CODE_FLT,
-			gdbarch_double_bit (current_gdbarch) / TARGET_CHAR_BIT,
+			gdbarch_double_bit (gdbarch) / TARGET_CHAR_BIT,
 			0, "real*8", objfile);
       break;
     case FT_FLOAT_DECIMAL:
       type = init_type (TYPE_CODE_FLT,
-			gdbarch_double_bit (current_gdbarch) / TARGET_CHAR_BIT,
+			gdbarch_double_bit (gdbarch) / TARGET_CHAR_BIT,
 			0, "floating decimal", objfile);
       break;
     case FT_EXT_PREC_FLOAT:
       type = init_type (TYPE_CODE_FLT,
-			gdbarch_long_double_bit (current_gdbarch)
-			  / TARGET_CHAR_BIT,
+			gdbarch_long_double_bit (gdbarch) / TARGET_CHAR_BIT,
 			0, "real*16", objfile);
       break;
     case FT_COMPLEX:
       type = init_type (TYPE_CODE_COMPLEX,
-			2 * gdbarch_float_bit (current_gdbarch) / TARGET_CHAR_BIT,
+			2 * gdbarch_float_bit (gdbarch) / TARGET_CHAR_BIT,
 			0, "complex*8", objfile);
       TYPE_TARGET_TYPE (type) = builtin_type_f_real;
       break;
     case FT_DBL_PREC_COMPLEX:
       type = init_type (TYPE_CODE_COMPLEX,
-			2 * gdbarch_double_bit (current_gdbarch)
-			  / TARGET_CHAR_BIT,
+			2 * gdbarch_double_bit (gdbarch) / TARGET_CHAR_BIT,
 			0, "complex*16", objfile);
       TYPE_TARGET_TYPE (type) = builtin_type_f_real_s8;
       break;
     case FT_EXT_PREC_COMPLEX:
       type = init_type (TYPE_CODE_COMPLEX,
-			2 * gdbarch_long_double_bit (current_gdbarch)
-			  / TARGET_CHAR_BIT,
+			2 * gdbarch_long_double_bit (gdbarch) / TARGET_CHAR_BIT,
 			0, "complex*32", objfile);
       TYPE_TARGET_TYPE (type) = builtin_type_f_real_s16;
       break;
@@ -380,7 +375,7 @@ f_create_fundamental_type (struct objfil
          name "<?type?>".  When all the dust settles from the type
          reconstruction work, this should probably become an error. */
       type = init_type (TYPE_CODE_INT,
-			gdbarch_int_bit (current_gdbarch) / TARGET_CHAR_BIT,
+			gdbarch_int_bit (gdbarch) / TARGET_CHAR_BIT,
 			0, "<?type?>", objfile);
       warning (_("internal error: no F77 fundamental type %d"), typeid);
       break;
@@ -530,55 +525,50 @@ build_fortran_types (struct gdbarch *gdb
 
   builtin_f_type->builtin_integer_s2 =
     init_type (TYPE_CODE_INT,
-	       gdbarch_short_bit (current_gdbarch) / TARGET_CHAR_BIT,
+	       gdbarch_short_bit (gdbarch) / TARGET_CHAR_BIT,
 	       0, "integer*2", (struct objfile *) NULL);
 
   builtin_f_type->builtin_logical_s2 =
     init_type (TYPE_CODE_BOOL,
-	       gdbarch_short_bit (current_gdbarch) / TARGET_CHAR_BIT,
+	       gdbarch_short_bit (gdbarch) / TARGET_CHAR_BIT,
 	       TYPE_FLAG_UNSIGNED, "logical*2", (struct objfile *) NULL);
 
   builtin_f_type->builtin_integer =
     init_type (TYPE_CODE_INT, 
-	       gdbarch_int_bit (current_gdbarch) / TARGET_CHAR_BIT,
+	       gdbarch_int_bit (gdbarch) / TARGET_CHAR_BIT,
 	       0, "integer", (struct objfile *) NULL);
 
   builtin_f_type->builtin_logical =
     init_type (TYPE_CODE_BOOL, 
-	       gdbarch_int_bit (current_gdbarch) / TARGET_CHAR_BIT,
+	       gdbarch_int_bit (gdbarch) / TARGET_CHAR_BIT,
 	       TYPE_FLAG_UNSIGNED, "logical*4", (struct objfile *) NULL);
 
   builtin_f_type->builtin_real =
     init_type (TYPE_CODE_FLT,
-	       gdbarch_float_bit (current_gdbarch) / TARGET_CHAR_BIT,
-	       0,
-	       "real", (struct objfile *) NULL);
+	       gdbarch_float_bit (gdbarch) / TARGET_CHAR_BIT,
+	       0, "real", (struct objfile *) NULL);
 
   builtin_f_type->builtin_real_s8 =
     init_type (TYPE_CODE_FLT,
-	       gdbarch_double_bit (current_gdbarch) / TARGET_CHAR_BIT,
-	       0,
-	       "real*8", (struct objfile *) NULL);
+	       gdbarch_double_bit (gdbarch) / TARGET_CHAR_BIT,
+	       0, "real*8", (struct objfile *) NULL);
 
   builtin_f_type->builtin_real_s16 =
     init_type (TYPE_CODE_FLT,
-	       gdbarch_long_double_bit (current_gdbarch) / TARGET_CHAR_BIT,
-	       0,
-	       "real*16", (struct objfile *) NULL);
+	       gdbarch_long_double_bit (gdbarch) / TARGET_CHAR_BIT,
+	       0, "real*16", (struct objfile *) NULL);
 
   builtin_f_type->builtin_complex_s8 =
     init_type (TYPE_CODE_COMPLEX,
-	       2 * gdbarch_float_bit (current_gdbarch) / TARGET_CHAR_BIT,
-	       0,
-	       "complex*8", (struct objfile *) NULL);
+	       2 * gdbarch_float_bit (gdbarch) / TARGET_CHAR_BIT,
+	       0,"complex*8", (struct objfile *) NULL);
   TYPE_TARGET_TYPE (builtin_f_type->builtin_complex_s8)
     = builtin_f_type->builtin_real;
 
   builtin_f_type->builtin_complex_s16 =
     init_type (TYPE_CODE_COMPLEX,
-	       2 * gdbarch_double_bit (current_gdbarch) / TARGET_CHAR_BIT,
-	       0,
-	       "complex*16", (struct objfile *) NULL);
+	       2 * gdbarch_double_bit (gdbarch) / TARGET_CHAR_BIT,
+	       0, "complex*16", (struct objfile *) NULL);
   TYPE_TARGET_TYPE (builtin_f_type->builtin_complex_s16)
     = builtin_f_type->builtin_real_s8;
 
@@ -587,9 +577,8 @@ build_fortran_types (struct gdbarch *gdb
 
   builtin_f_type->builtin_complex_s32 =
     init_type (TYPE_CODE_COMPLEX,
-	       2 * gdbarch_long_double_bit (current_gdbarch) / TARGET_CHAR_BIT,
-	       0,
-	       "complex*32", (struct objfile *) NULL);
+	       2 * gdbarch_long_double_bit (gdbarch) / TARGET_CHAR_BIT,
+	       0, "complex*32", (struct objfile *) NULL);
   TYPE_TARGET_TYPE (builtin_f_type->builtin_complex_s32)
     = builtin_f_type->builtin_real_s16;
 
diff -urpN src/gdb/Makefile.in dev/gdb/Makefile.in
--- src/gdb/Makefile.in	2007-10-11 08:30:21.000000000 +0200
+++ dev/gdb/Makefile.in	2007-10-11 09:01:49.000000000 +0200
@@ -2008,7 +2008,7 @@ findvar.o: findvar.c $(defs_h) $(symtab_
 	$(user_regs_h) $(block_h)
 f-lang.o: f-lang.c $(defs_h) $(gdb_string_h) $(symtab_h) $(gdbtypes_h) \
 	$(expression_h) $(parser_defs_h) $(language_h) $(f_lang_h) \
-	$(valprint_h) $(value_h)
+	$(valprint_h) $(value_h) $(objfiles_h)
 fork-child.o: fork-child.c $(defs_h) $(gdb_string_h) $(frame_h) \
 	$(inferior_h) $(target_h) $(gdb_wait_h) $(gdb_vfork_h) $(gdbcore_h) \
 	$(terminal_h) $(gdbthread_h) $(command_h) $(solib_h)






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