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] [01/05] Get rid of current_gdbarch in gdbarch.{c,h,sh}


Hi,

this patch replaces current_gdbarch by gdbarch in gdbarch_alloc from gdbarch.sh. Due to the fact that
current_gdbarch's focus in gdbarch_alloc is local only it doesn't interfere global current_gdbarch.
So there is no reason to give it the same name as a global variable. Hence this patch renames it.

Tested with testsuite on x86 and gdb_mbuild. Ok to commit ?


ChangeLog:



* gdbarch.sh (gdbarch_alloc): Replace current_gdbarch by gdbarch. * gdbarch.{c,h}: Regenerate.



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



diff -urpN src/gdb/gdbarch.c dev/gdb/gdbarch.c
--- src/gdb/gdbarch.c	2007-11-07 07:57:51.000000000 +0100
+++ dev/gdb/gdbarch.c	2007-11-07 08:45:09.000000000 +0100
@@ -368,75 +368,75 @@ gdbarch_alloc (const struct gdbarch_info
      architecture.  This ensures that the new architectures initial
      values are not influenced by the previous architecture.  Once
      everything is parameterised with gdbarch, this will go away.  */
-  struct gdbarch *current_gdbarch;
+  struct gdbarch *gdbarch;
 
   /* Create an obstack for allocating all the per-architecture memory,
      then use that to allocate the architecture vector.  */
   struct obstack *obstack = XMALLOC (struct obstack);
   obstack_init (obstack);
-  current_gdbarch = obstack_alloc (obstack, sizeof (*current_gdbarch));
-  memset (current_gdbarch, 0, sizeof (*current_gdbarch));
-  current_gdbarch->obstack = obstack;
-
-  alloc_gdbarch_data (current_gdbarch);
-
-  current_gdbarch->tdep = tdep;
-
-  current_gdbarch->bfd_arch_info = info->bfd_arch_info;
-  current_gdbarch->byte_order = info->byte_order;
-  current_gdbarch->osabi = info->osabi;
-  current_gdbarch->target_desc = info->target_desc;
+  gdbarch = obstack_alloc (obstack, sizeof (*gdbarch));
+  memset (gdbarch, 0, sizeof (*gdbarch));
+  gdbarch->obstack = obstack;
+
+  alloc_gdbarch_data (gdbarch);
+
+  gdbarch->tdep = tdep;
+
+  gdbarch->bfd_arch_info = info->bfd_arch_info;
+  gdbarch->byte_order = info->byte_order;
+  gdbarch->osabi = info->osabi;
+  gdbarch->target_desc = info->target_desc;
 
   /* Force the explicit initialization of these. */
-  current_gdbarch->short_bit = 2*TARGET_CHAR_BIT;
-  current_gdbarch->int_bit = 4*TARGET_CHAR_BIT;
-  current_gdbarch->long_bit = 4*TARGET_CHAR_BIT;
-  current_gdbarch->long_long_bit = 2*current_gdbarch->long_bit;
-  current_gdbarch->float_bit = 4*TARGET_CHAR_BIT;
-  current_gdbarch->double_bit = 8*TARGET_CHAR_BIT;
-  current_gdbarch->long_double_bit = 8*TARGET_CHAR_BIT;
-  current_gdbarch->ptr_bit = current_gdbarch->int_bit;
-  current_gdbarch->char_signed = -1;
-  current_gdbarch->virtual_frame_pointer = legacy_virtual_frame_pointer;
-  current_gdbarch->num_regs = -1;
-  current_gdbarch->sp_regnum = -1;
-  current_gdbarch->pc_regnum = -1;
-  current_gdbarch->ps_regnum = -1;
-  current_gdbarch->fp0_regnum = -1;
-  current_gdbarch->stab_reg_to_regnum = no_op_reg_to_regnum;
-  current_gdbarch->ecoff_reg_to_regnum = no_op_reg_to_regnum;
-  current_gdbarch->dwarf_reg_to_regnum = no_op_reg_to_regnum;
-  current_gdbarch->sdb_reg_to_regnum = no_op_reg_to_regnum;
-  current_gdbarch->dwarf2_reg_to_regnum = no_op_reg_to_regnum;
-  current_gdbarch->deprecated_fp_regnum = -1;
-  current_gdbarch->call_dummy_location = AT_ENTRY_POINT;
-  current_gdbarch->print_registers_info = default_print_registers_info;
-  current_gdbarch->register_sim_regno = legacy_register_sim_regno;
-  current_gdbarch->cannot_fetch_register = cannot_register_not;
-  current_gdbarch->cannot_store_register = cannot_register_not;
-  current_gdbarch->convert_register_p = generic_convert_register_p;
-  current_gdbarch->value_from_register = default_value_from_register;
-  current_gdbarch->pointer_to_address = unsigned_pointer_to_address;
-  current_gdbarch->address_to_pointer = unsigned_address_to_pointer;
-  current_gdbarch->memory_insert_breakpoint = default_memory_insert_breakpoint;
-  current_gdbarch->memory_remove_breakpoint = default_memory_remove_breakpoint;
-  current_gdbarch->remote_register_number = default_remote_register_number;
-  current_gdbarch->stabs_argument_has_addr = default_stabs_argument_has_addr;
-  current_gdbarch->convert_from_func_ptr_addr = convert_from_func_ptr_addr_identity;
-  current_gdbarch->addr_bits_remove = core_addr_identity;
-  current_gdbarch->smash_text_address = core_addr_identity;
-  current_gdbarch->skip_trampoline_code = generic_skip_trampoline_code;
-  current_gdbarch->skip_solib_resolver = generic_skip_solib_resolver;
-  current_gdbarch->in_solib_return_trampoline = generic_in_solib_return_trampoline;
-  current_gdbarch->in_function_epilogue_p = generic_in_function_epilogue_p;
-  current_gdbarch->construct_inferior_arguments = construct_inferior_arguments;
-  current_gdbarch->elf_make_msymbol_special = default_elf_make_msymbol_special;
-  current_gdbarch->coff_make_msymbol_special = default_coff_make_msymbol_special;
-  current_gdbarch->name_of_malloc = "malloc";
-  current_gdbarch->register_reggroup_p = default_register_reggroup_p;
+  gdbarch->short_bit = 2*TARGET_CHAR_BIT;
+  gdbarch->int_bit = 4*TARGET_CHAR_BIT;
+  gdbarch->long_bit = 4*TARGET_CHAR_BIT;
+  gdbarch->long_long_bit = 2*gdbarch->long_bit;
+  gdbarch->float_bit = 4*TARGET_CHAR_BIT;
+  gdbarch->double_bit = 8*TARGET_CHAR_BIT;
+  gdbarch->long_double_bit = 8*TARGET_CHAR_BIT;
+  gdbarch->ptr_bit = gdbarch->int_bit;
+  gdbarch->char_signed = -1;
+  gdbarch->virtual_frame_pointer = legacy_virtual_frame_pointer;
+  gdbarch->num_regs = -1;
+  gdbarch->sp_regnum = -1;
+  gdbarch->pc_regnum = -1;
+  gdbarch->ps_regnum = -1;
+  gdbarch->fp0_regnum = -1;
+  gdbarch->stab_reg_to_regnum = no_op_reg_to_regnum;
+  gdbarch->ecoff_reg_to_regnum = no_op_reg_to_regnum;
+  gdbarch->dwarf_reg_to_regnum = no_op_reg_to_regnum;
+  gdbarch->sdb_reg_to_regnum = no_op_reg_to_regnum;
+  gdbarch->dwarf2_reg_to_regnum = no_op_reg_to_regnum;
+  gdbarch->deprecated_fp_regnum = -1;
+  gdbarch->call_dummy_location = AT_ENTRY_POINT;
+  gdbarch->print_registers_info = default_print_registers_info;
+  gdbarch->register_sim_regno = legacy_register_sim_regno;
+  gdbarch->cannot_fetch_register = cannot_register_not;
+  gdbarch->cannot_store_register = cannot_register_not;
+  gdbarch->convert_register_p = generic_convert_register_p;
+  gdbarch->value_from_register = default_value_from_register;
+  gdbarch->pointer_to_address = unsigned_pointer_to_address;
+  gdbarch->address_to_pointer = unsigned_address_to_pointer;
+  gdbarch->memory_insert_breakpoint = default_memory_insert_breakpoint;
+  gdbarch->memory_remove_breakpoint = default_memory_remove_breakpoint;
+  gdbarch->remote_register_number = default_remote_register_number;
+  gdbarch->stabs_argument_has_addr = default_stabs_argument_has_addr;
+  gdbarch->convert_from_func_ptr_addr = convert_from_func_ptr_addr_identity;
+  gdbarch->addr_bits_remove = core_addr_identity;
+  gdbarch->smash_text_address = core_addr_identity;
+  gdbarch->skip_trampoline_code = generic_skip_trampoline_code;
+  gdbarch->skip_solib_resolver = generic_skip_solib_resolver;
+  gdbarch->in_solib_return_trampoline = generic_in_solib_return_trampoline;
+  gdbarch->in_function_epilogue_p = generic_in_function_epilogue_p;
+  gdbarch->construct_inferior_arguments = construct_inferior_arguments;
+  gdbarch->elf_make_msymbol_special = default_elf_make_msymbol_special;
+  gdbarch->coff_make_msymbol_special = default_coff_make_msymbol_special;
+  gdbarch->name_of_malloc = "malloc";
+  gdbarch->register_reggroup_p = default_register_reggroup_p;
   /* gdbarch_alloc() */
 
-  return current_gdbarch;
+  return gdbarch;
 }
 
 
diff -urpN src/gdb/gdbarch.sh dev/gdb/gdbarch.sh
--- src/gdb/gdbarch.sh	2007-11-07 07:57:51.000000000 +0100
+++ dev/gdb/gdbarch.sh	2007-11-07 08:44:52.000000000 +0100
@@ -355,7 +355,7 @@ v:int:int_bit:::8 * sizeof (int):4*TARGE
 v:int:long_bit:::8 * sizeof (long):4*TARGET_CHAR_BIT::0
 # Number of bits in a long long or unsigned long long for the target
 # machine.
-v:int:long_long_bit:::8 * sizeof (LONGEST):2*current_gdbarch->long_bit::0
+v:int:long_long_bit:::8 * sizeof (LONGEST):2*gdbarch->long_bit::0
 
 # The ABI default bit-size and format for "float", "double", and "long
 # double".  These bit/format pairs should eventually be combined into
@@ -380,7 +380,7 @@ v:const struct floatformat **:long_doubl
 # as well.
 #
 # ptr_bit is the size of a pointer on the target
-v:int:ptr_bit:::8 * sizeof (void*):current_gdbarch->int_bit::0
+v:int:ptr_bit:::8 * sizeof (void*):gdbarch->int_bit::0
 # addr_bit is the size of a target address as represented in gdb
 v:int:addr_bit:::8 * sizeof (void*):0:gdbarch_ptr_bit (current_gdbarch):
 #
@@ -1202,26 +1202,26 @@ gdbarch_alloc (const struct gdbarch_info
      architecture.  This ensures that the new architectures initial
      values are not influenced by the previous architecture.  Once
      everything is parameterised with gdbarch, this will go away.  */
-  struct gdbarch *current_gdbarch;
+  struct gdbarch *gdbarch;
 
   /* Create an obstack for allocating all the per-architecture memory,
      then use that to allocate the architecture vector.  */
   struct obstack *obstack = XMALLOC (struct obstack);
   obstack_init (obstack);
-  current_gdbarch = obstack_alloc (obstack, sizeof (*current_gdbarch));
-  memset (current_gdbarch, 0, sizeof (*current_gdbarch));
-  current_gdbarch->obstack = obstack;
+  gdbarch = obstack_alloc (obstack, sizeof (*gdbarch));
+  memset (gdbarch, 0, sizeof (*gdbarch));
+  gdbarch->obstack = obstack;
 
-  alloc_gdbarch_data (current_gdbarch);
+  alloc_gdbarch_data (gdbarch);
 
-  current_gdbarch->tdep = tdep;
+  gdbarch->tdep = tdep;
 EOF
 printf "\n"
 function_list | while do_read
 do
     if class_is_info_p
     then
-	printf "  current_gdbarch->${function} = info->${function};\n"
+	printf "  gdbarch->${function} = info->${function};\n"
     fi
 done
 printf "\n"
@@ -1232,14 +1232,14 @@ do
     then
 	if [ -n "${predefault}" -a "x${predefault}" != "x0" ]
 	then
-	  printf "  current_gdbarch->${function} = ${predefault};\n"
+	  printf "  gdbarch->${function} = ${predefault};\n"
 	fi
     fi
 done
 cat <<EOF
   /* gdbarch_alloc() */
 
-  return current_gdbarch;
+  return gdbarch;
 }
 EOF
 



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