From 515bf956a2831e7e1798992f62328719ec945316 Mon Sep 17 00:00:00 2001 From: Ulrich Weigand Date: Thu, 2 Jul 2009 17:02:29 +0000 Subject: * 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. --- gdb/arch-utils.c | 31 +++++++++++++++++++++---------- 1 file changed, 21 insertions(+), 10 deletions(-) (limited to 'gdb/arch-utils.c') diff --git a/gdb/arch-utils.c b/gdb/arch-utils.c index c1ea9da3636..76c96e5e513 100644 --- a/gdb/arch-utils.c +++ b/gdb/arch-utils.c @@ -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 */ -- cgit v1.2.1