OSDN Git Service

* arch-utils.c (selected_byte_order): Return target_byte_order_user.
authoruweigand <uweigand>
Thu, 2 Jul 2009 17:02:29 +0000 (17:02 +0000)
committeruweigand <uweigand>
Thu, 2 Jul 2009 17:02:29 +0000 (17:02 +0000)
(show_endian): Use target_byte_order_user if specified; otherwise
use get_current_arch () instead of current_gdbarch.
(show_architecture): Use set_architecture_string if specified;
otherwise use get_current_arch () instead of current_gdbarch.
(get_current_arch): New function.
* arch-utils.h (get_current_arch): Add prototype.

* osabi.c (show_osabi): Use get_current_arch () instead of
current_gdbarch.

* findcmd.c: Include "arch-utils.h".
(parse_find_args): Add BIG_P argument.  Use it instead of byte order
of current_gdbarch.
(find_command): Use get_current_arch () instead of current_gdbarch.
Pass byte order to parse_find_args.

* maint.c: Include "arch-utils.h".
(maintenance_print_architecture): Use get_current_arch () instead
of current_gdbarch.

* reggroups.c: Include "arch-utils.h".
(maintenance_print_reggroups): Use get_current_arch () instead
of current_gdbarch.

* symfile.c: Include "arch-utils.h".
(overlay_load_command): Use get_current_arch () instead of
current_gdbarch.

* value.c: Include "arch-utils.h".
(show_convenience): Use get_current_arch () instead of
current_gdbarch.

* tui/tui-regs.c: Include "arch-utils.h".
(tui_reg_next_command): Use get_current_arch () instead of
current_gdbarch.

* mi/mi-main.c: Include "arch-utils.h".
(mi_cmd_data_read_memory): Use get_current_arch () instead of
current_gdbarch.

* parse.c: Include "arch-utils.h".
(parse_exp_in_context): Use get_current_arch () instead of
current_gdbarch.

12 files changed:
gdb/ChangeLog
gdb/arch-utils.c
gdb/arch-utils.h
gdb/findcmd.c
gdb/maint.c
gdb/mi/mi-main.c
gdb/osabi.c
gdb/parse.c
gdb/reggroups.c
gdb/symfile.c
gdb/tui/tui-regs.c
gdb/value.c

index fcb9e80..4c7df3e 100644 (file)
@@ -1,5 +1,52 @@
 2009-07-02  Ulrich Weigand  <uweigand@de.ibm.com>
 
+       * arch-utils.c (selected_byte_order): Return target_byte_order_user.
+       (show_endian): Use target_byte_order_user if specified; otherwise
+       use get_current_arch () instead of current_gdbarch.
+       (show_architecture): Use set_architecture_string if specified;
+       otherwise use get_current_arch () instead of current_gdbarch.
+       (get_current_arch): New function.
+       * arch-utils.h (get_current_arch): Add prototype.
+
+       * osabi.c (show_osabi): Use get_current_arch () instead of
+       current_gdbarch.
+
+       * findcmd.c: Include "arch-utils.h".
+       (parse_find_args): Add BIG_P argument.  Use it instead of byte order
+       of current_gdbarch.
+       (find_command): Use get_current_arch () instead of current_gdbarch.
+       Pass byte order to parse_find_args.
+
+       * maint.c: Include "arch-utils.h".
+       (maintenance_print_architecture): Use get_current_arch () instead
+       of current_gdbarch.
+
+       * reggroups.c: Include "arch-utils.h".
+       (maintenance_print_reggroups): Use get_current_arch () instead
+       of current_gdbarch.
+
+       * symfile.c: Include "arch-utils.h".
+       (overlay_load_command): Use get_current_arch () instead of
+       current_gdbarch.
+
+       * value.c: Include "arch-utils.h".
+       (show_convenience): Use get_current_arch () instead of
+       current_gdbarch.
+
+       * tui/tui-regs.c: Include "arch-utils.h".
+       (tui_reg_next_command): Use get_current_arch () instead of
+       current_gdbarch.
+
+       * mi/mi-main.c: Include "arch-utils.h".
+       (mi_cmd_data_read_memory): Use get_current_arch () instead of
+       current_gdbarch.
+
+       * parse.c: Include "arch-utils.h".
+       (parse_exp_in_context): Use get_current_arch () instead of
+       current_gdbarch.
+
+2009-07-02  Ulrich Weigand  <uweigand@de.ibm.com>
+
        * gdbtypes.c (make_pointer_type, make_reference_type,
        smash_to_memberptr_type, lookup_array_range_type, check_stub_method):
        Use type architecture instead of current_gdbarch.
index c1ea9da..76c96e5 100644 (file)
@@ -260,10 +260,7 @@ static const char *set_endian_string;
 enum bfd_endian
 selected_byte_order (void)
 {
-  if (target_byte_order_user != BFD_ENDIAN_UNKNOWN)
-    return gdbarch_byte_order (current_gdbarch);
-  else
-    return BFD_ENDIAN_UNKNOWN;
+  return target_byte_order_user;
 }
 
 /* Called by ``show endian''.  */
@@ -273,14 +270,14 @@ show_endian (struct ui_file *file, int from_tty, struct cmd_list_element *c,
             const char *value)
 {
   if (target_byte_order_user == BFD_ENDIAN_UNKNOWN)
-    if (gdbarch_byte_order (current_gdbarch) == BFD_ENDIAN_BIG)
+    if (gdbarch_byte_order (get_current_arch ()) == BFD_ENDIAN_BIG)
       fprintf_unfiltered (file, _("The target endianness is set automatically "
                                  "(currently big endian)\n"));
     else
       fprintf_unfiltered (file, _("The target endianness is set automatically "
                           "(currently little endian)\n"));
   else
-    if (gdbarch_byte_order (current_gdbarch) == BFD_ENDIAN_BIG)
+    if (target_byte_order_user == BFD_ENDIAN_BIG)
       fprintf_unfiltered (file,
                          _("The target is assumed to be big endian\n"));
     else
@@ -418,14 +415,13 @@ static void
 show_architecture (struct ui_file *file, int from_tty,
                   struct cmd_list_element *c, const char *value)
 {
-  const char *arch;
-  arch = gdbarch_bfd_arch_info (current_gdbarch)->printable_name;
   if (target_architecture_user == NULL)
     fprintf_filtered (file, _("\
-The target architecture is set automatically (currently %s)\n"), arch);
+The target architecture is set automatically (currently %s)\n"),
+               gdbarch_bfd_arch_info (get_current_arch ())->printable_name);
   else
     fprintf_filtered (file, _("\
-The target architecture is assumed to be %s\n"), arch);
+The target architecture is assumed to be %s\n"), set_architecture_string);
 }
 
 
@@ -720,6 +716,21 @@ gdbarch_info_fill (struct gdbarch_info *info)
   gdb_assert (info->bfd_arch_info != NULL);
 }
 
+/* Return "current" architecture.  If the target is running, this is the
+   architecture of the selected frame.  Otherwise, the "current" architecture
+   defaults to the target architecture.
+
+   This function should normally be called solely by the command interpreter
+   routines to determine the architecture to execute a command in.  */
+struct gdbarch *
+get_current_arch (void)
+{
+  if (has_stack_frames ())
+    return get_frame_arch (get_selected_frame (NULL));
+  else
+    return target_gdbarch;
+}
+
 /* */
 
 extern initialize_file_ftype _initialize_gdbarch_utils; /* -Wmissing-prototypes */
index c4e0980..555ff59 100644 (file)
@@ -139,4 +139,12 @@ extern void gdbarch_info_fill (struct gdbarch_info *info);
 
 extern struct gdbarch *gdbarch_from_bfd (bfd *abfd);
 
+/* Return "current" architecture.  If the target is running, this is the
+   architecture of the selected frame.  Otherwise, the "current" architecture
+   defaults to the target architecture.
+
+   This function should normally be called solely by the command interpreter
+   routines to determine the architecture to execute a command in.  */
+extern struct gdbarch *get_current_arch (void);
+
 #endif
index 09d93fc..b701d93 100644 (file)
@@ -18,6 +18,7 @@
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
 #include "defs.h"
+#include "arch-utils.h"
 #include <ctype.h>
 #include "gdb_string.h"
 #include "gdbcmd.h"
@@ -50,7 +51,8 @@ put_bits (bfd_uint64_t data, char *buf, int bits, bfd_boolean big_p)
 static void
 parse_find_args (char *args, ULONGEST *max_countp,
                 char **pattern_bufp, ULONGEST *pattern_lenp,
-                CORE_ADDR *start_addrp, ULONGEST *search_space_lenp)
+                CORE_ADDR *start_addrp, ULONGEST *search_space_lenp,
+                bfd_boolean big_p)
 {
   /* Default to using the specified type.  */
   char size = '\0';
@@ -67,7 +69,6 @@ parse_find_args (char *args, ULONGEST *max_countp,
   CORE_ADDR start_addr;
   ULONGEST search_space_len;
   char *s = args;
-  bfd_boolean big_p = gdbarch_byte_order (current_gdbarch) == BFD_ENDIAN_BIG;
   struct cleanup *old_cleanups;
   struct value *v;
 
@@ -239,6 +240,8 @@ parse_find_args (char *args, ULONGEST *max_countp,
 static void
 find_command (char *args, int from_tty)
 {
+  struct gdbarch *gdbarch = get_current_arch ();
+  bfd_boolean big_p = gdbarch_byte_order (gdbarch) == BFD_ENDIAN_BIG;
   /* Command line parameters.
      These are initialized to avoid uninitialized warnings from -Wall.  */
   ULONGEST max_count = 0;
@@ -252,7 +255,7 @@ find_command (char *args, int from_tty)
   struct cleanup *old_cleanups;
 
   parse_find_args (args, &max_count, &pattern_buf, &pattern_len, 
-                  &start_addr, &search_space_len);
+                  &start_addr, &search_space_len, big_p);
 
   old_cleanups = make_cleanup (free_current_contents, &pattern_buf);
 
@@ -294,7 +297,6 @@ find_command (char *args, int from_tty)
   set_internalvar_integer (lookup_internalvar ("numfound"), found_count);
   if (found_count > 0)
     {
-      struct gdbarch *gdbarch = current_gdbarch;
       struct type *ptr_type = builtin_type (gdbarch)->builtin_data_ptr;
       set_internalvar (lookup_internalvar ("_"),
                       value_from_pointer (ptr_type, last_found_addr));
index 56cafe9..ae465ce 100644 (file)
@@ -22,6 +22,7 @@
 
 
 #include "defs.h"
+#include "arch-utils.h"
 #include <ctype.h>
 #include <signal.h>
 #include "command.h"
@@ -411,8 +412,10 @@ maintenance_print_statistics (char *args, int from_tty)
 static void
 maintenance_print_architecture (char *args, int from_tty)
 {
+  struct gdbarch *gdbarch = get_current_arch ();
+
   if (args == NULL)
-    gdbarch_dump (current_gdbarch, gdb_stdout);
+    gdbarch_dump (gdbarch, gdb_stdout);
   else
     {
       struct cleanup *cleanups;
@@ -420,7 +423,7 @@ maintenance_print_architecture (char *args, int from_tty)
       if (file == NULL)
        perror_with_name (_("maintenance print architecture"));
       cleanups = make_cleanup_ui_file_delete (file);
-      gdbarch_dump (current_gdbarch, file);    
+      gdbarch_dump (gdbarch, file);
       do_cleanups (cleanups);
     }
 }
index a96d43c..aa176f7 100644 (file)
@@ -23,6 +23,7 @@
 /* Work in progress.  */
 
 #include "defs.h"
+#include "arch-utils.h"
 #include "target.h"
 #include "inferior.h"
 #include "gdb_string.h"
@@ -828,7 +829,7 @@ mi_cmd_data_evaluate_expression (char *command, char **argv, int argc)
 void
 mi_cmd_data_read_memory (char *command, char **argv, int argc)
 {
-  struct gdbarch *gdbarch = current_gdbarch;
+  struct gdbarch *gdbarch = get_current_arch ();
   struct cleanup *cleanups = make_cleanup (null_cleanup, NULL);
   CORE_ADDR addr;
   long total_bytes;
index 6024419..778dedc 100644 (file)
@@ -596,7 +596,7 @@ show_osabi (struct ui_file *file, int from_tty, struct cmd_list_element *c,
   if (user_osabi_state == osabi_auto)
     fprintf_filtered (file,
                      _("The current OS ABI is \"auto\" (currently \"%s\").\n"),
-                     gdbarch_osabi_name (gdbarch_osabi (current_gdbarch)));
+                     gdbarch_osabi_name (gdbarch_osabi (get_current_arch ())));
   else
     fprintf_filtered (file, _("The current OS ABI is \"%s\".\n"),
                      gdbarch_osabi_name (user_selected_osabi));
index 8e0373f..ef938e3 100644 (file)
@@ -34,6 +34,7 @@
 #include <ctype.h>
 
 #include "defs.h"
+#include "arch-utils.h"
 #include "gdb_string.h"
 #include "symtab.h"
 #include "gdbtypes.h"
@@ -1086,7 +1087,7 @@ parse_exp_in_context (char **stringptr, struct block *block, int comma,
   expout = (struct expression *)
     xmalloc (sizeof (struct expression) + EXP_ELEM_TO_BYTES (expout_size));
   expout->language_defn = current_language;
-  expout->gdbarch = current_gdbarch;
+  expout->gdbarch = get_current_arch ();
 
   TRY_CATCH (except, RETURN_MASK_ALL)
     {
index 0803422..171fc36 100644 (file)
@@ -20,6 +20,7 @@
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
 #include "defs.h"
+#include "arch-utils.h"
 #include "reggroups.h"
 #include "gdbtypes.h"
 #include "gdb_assert.h"
@@ -230,8 +231,10 @@ reggroups_dump (struct gdbarch *gdbarch, struct ui_file *file)
 static void
 maintenance_print_reggroups (char *args, int from_tty)
 {
+  struct gdbarch *gdbarch = get_current_arch ();
+
   if (args == NULL)
-    reggroups_dump (current_gdbarch, gdb_stdout);
+    reggroups_dump (gdbarch, gdb_stdout);
   else
     {
       struct cleanup *cleanups;
@@ -239,7 +242,7 @@ maintenance_print_reggroups (char *args, int from_tty)
       if (file == NULL)
        perror_with_name (_("maintenance print reggroups"));
       cleanups = make_cleanup_ui_file_delete (file);
-      reggroups_dump (current_gdbarch, file);    
+      reggroups_dump (gdbarch, file);
       do_cleanups (cleanups);
     }
 }
index 25f3f26..cecbda4 100644 (file)
@@ -22,6 +22,7 @@
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
 #include "defs.h"
+#include "arch-utils.h"
 #include "bfdlink.h"
 #include "symtab.h"
 #include "gdbtypes.h"
@@ -3643,8 +3644,10 @@ overlay_off_command (char *args, int from_tty)
 static void
 overlay_load_command (char *args, int from_tty)
 {
-  if (gdbarch_overlay_update_p (current_gdbarch))
-    gdbarch_overlay_update (current_gdbarch, NULL);
+  struct gdbarch *gdbarch = get_current_arch ();
+
+  if (gdbarch_overlay_update_p (gdbarch))
+    gdbarch_overlay_update (gdbarch, NULL);
   else
     error (_("This target does not know how to read its overlay state."));
 }
index c7ad138..bfb66f8 100644 (file)
@@ -21,6 +21,7 @@
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
 #include "defs.h"
+#include "arch-utils.h"
 #include "tui/tui.h"
 #include "tui/tui-data.h"
 #include "symtab.h"
@@ -558,14 +559,16 @@ tui_display_register (struct tui_data_element *data,
 static void
 tui_reg_next_command (char *arg, int from_tty)
 {
+  struct gdbarch *gdbarch = get_current_arch ();
+
   if (TUI_DATA_WIN != 0)
     {
       struct reggroup *group
         = TUI_DATA_WIN->detail.data_display_info.current_group;
 
-      group = reggroup_next (current_gdbarch, group);
+      group = reggroup_next (gdbarch, group);
       if (group == 0)
-        group = reggroup_next (current_gdbarch, 0);
+        group = reggroup_next (gdbarch, 0);
 
       if (group)
         tui_show_registers (group);
index fb8da3e..4632ae4 100644 (file)
@@ -20,6 +20,7 @@
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
 #include "defs.h"
+#include "arch-utils.h"
 #include "gdb_string.h"
 #include "symtab.h"
 #include "gdbtypes.h"
@@ -1448,7 +1449,7 @@ preserve_values (struct objfile *objfile)
 static void
 show_convenience (char *ignore, int from_tty)
 {
-  struct gdbarch *gdbarch = current_gdbarch;
+  struct gdbarch *gdbarch = get_current_arch ();
   struct internalvar *var;
   int varseen = 0;
   struct value_print_options opts;