+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,
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''. */
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
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);
}
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 */
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
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"
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';
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;
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;
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);
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));
#include "defs.h"
+#include "arch-utils.h"
#include <ctype.h>
#include <signal.h>
#include "command.h"
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;
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);
}
}
/* Work in progress. */
#include "defs.h"
+#include "arch-utils.h"
#include "target.h"
#include "inferior.h"
#include "gdb_string.h"
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;
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));
#include <ctype.h>
#include "defs.h"
+#include "arch-utils.h"
#include "gdb_string.h"
#include "symtab.h"
#include "gdbtypes.h"
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)
{
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"
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;
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);
}
}
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"
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."));
}
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"
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);
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"
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;