aboutsummaryrefslogtreecommitdiff
path: root/gdb/top.c
diff options
context:
space:
mode:
authorIan Lance Taylor <ian@airs.com>1994-10-06 16:47:32 +0000
committerIan Lance Taylor <ian@airs.com>1994-10-06 16:47:32 +0000
commitb8176214a5bb9810bf6d5244815e9a49c5055dce (patch)
treef85f7b264d7a3748cde6bdf99d131edcaa13da36 /gdb/top.c
parent97d3151a59022d8d76fd29100052645bd8d99c6b (diff)
downloadfsf-binutils-gdb-b8176214a5bb9810bf6d5244815e9a49c5055dce.zip
fsf-binutils-gdb-b8176214a5bb9810bf6d5244815e9a49c5055dce.tar.gz
fsf-binutils-gdb-b8176214a5bb9810bf6d5244815e9a49c5055dce.tar.bz2
* defs.h: If TARGET_BYTE_ORDER_SELECTABLE is defined by tm.h,
define TARGET_BYTE_ORDER as target_byte_order, and declare target_byte_order as an extern int, and define BITS_BIG_ENDIAN as a test of TARGET_BYTE_ORDER. * top.c: Several additions if TARGET_BYTE_ORDER_SELECTABLE is defined: (endianlist, target_byte_order): New variables. (set_endian, set_endian_big, set_endian_little): New functions. (show_endian): New function. (init_cmd_lists): Initialize endianlist. (init_main): Add commands ``set endian big'', ``set endian little'', and ``show endian''. * a29k-pinsn.c: Rewrite uses of TARGET_BYTE_ORDER and BITS_BIG_ENDIAN to switch at run time rather than at compile time. * coffread.c, dwarfread.c, findvar.c, mips-tdep.c: Likewise. * remote-os9k.c, stabsread.c, valarith.c, valprint.c: Likewise. * values.c: Likewise. * mips-tdep.c: Rewrite uses of GDB_TARGET_IS_MIPS64 to switch at run time rather than at compile time.
Diffstat (limited to 'gdb/top.c')
-rw-r--r--gdb/top.c85
1 files changed, 85 insertions, 0 deletions
diff --git a/gdb/top.c b/gdb/top.c
index c052302..113c8bb 100644
--- a/gdb/top.c
+++ b/gdb/top.c
@@ -92,6 +92,18 @@ static void init_signals PARAMS ((void));
static void set_verbose PARAMS ((char *, int, struct cmd_list_element *));
+#ifdef TARGET_BYTE_ORDER_SELECTABLE
+
+static void set_endian PARAMS ((char *, int));
+
+static void set_endian_big PARAMS ((char *, int));
+
+static void set_endian_little PARAMS ((char *, int));
+
+static void show_endian PARAMS ((char *, int));
+
+#endif
+
static void show_history PARAMS ((char *, int));
static void set_history PARAMS ((char *, int));
@@ -205,6 +217,12 @@ struct cmd_list_element *unsetlist;
struct cmd_list_element *showlist;
+#ifdef TARGET_BYTE_ORDER_SELECTABLE
+/* Chain containing the \"set endian\" commands. */
+
+struct cmd_list_element *endianlist;
+#endif
+
/* Chain containing all defined \"set history\". */
struct cmd_list_element *sethistlist;
@@ -2626,6 +2644,56 @@ echo_command (text, from_tty)
}
+#ifdef TARGET_BYTE_ORDER_SELECTABLE
+
+/* Functions to manipulate the endianness of the target. */
+
+#ifndef TARGET_BYTE_ORDER_DEFAULT
+#define TARGET_BYTE_ORDER_DEFAULT BIG_ENDIAN
+#endif
+
+int target_byte_order = TARGET_BYTE_ORDER_DEFAULT;
+
+/* Called if the user enters ``set endian'' without an argument. */
+static void
+set_endian (args, from_tty)
+ char *args;
+ int from_tty;
+{
+ printf_unfiltered ("\"set endian\" must be followed by \"big\" or \"little\".\n");
+ show_endian (args, from_tty);
+}
+
+/* Called by ``set endian big''. */
+static void
+set_endian_big (args, from_tty)
+ char *args;
+ int from_tty;
+{
+ target_byte_order = BIG_ENDIAN;
+}
+
+/* Called by ``set endian little''. */
+static void
+set_endian_little (args, from_tty)
+ char *args;
+ int from_tty;
+{
+ target_byte_order = LITTLE_ENDIAN;
+}
+
+/* Called by ``show endian''. */
+static void
+show_endian (args, from_tty)
+ char *args;
+ int from_tty;
+{
+ printf_unfiltered ("The target is assumed to be %s endian.\n",
+ TARGET_BYTE_ORDER == BIG_ENDIAN ? "big" : "little");
+}
+
+#endif /* defined (TARGET_BYTE_ORDER_SELECTABLE) */
+
/* Functions to manipulate command line editing control variables. */
/* Number of commands to print in each call to show_commands. */
@@ -2795,6 +2863,9 @@ init_cmd_lists ()
setlist = NULL;
unsetlist = NULL;
showlist = NULL;
+#ifdef TARGET_BYTE_ORDER_SELECTABLE
+ endianlist = NULL;
+#endif
sethistlist = NULL;
showhistlist = NULL;
unsethistlist = NULL;
@@ -2845,6 +2916,20 @@ init_main ()
{
struct cmd_list_element *c;
+#ifdef TARGET_BYTE_ORDER_SELECTABLE
+
+ add_prefix_cmd ("endian", class_support, set_endian,
+ "Set endianness of target.",
+ &endianlist, "set endian ", 0, &setlist);
+ add_cmd ("big", class_support, set_endian_big,
+ "Set target as being big endian.", &endianlist);
+ add_cmd ("little", class_support, set_endian_little,
+ "Set target as being little endian.", &endianlist);
+ add_cmd ("endian", class_support, show_endian,
+ "Show endianness of target.", &showlist);
+
+#endif /* defined (TARGET_BYTE_ORDER_SELECTABLE) */
+
#ifdef DEFAULT_PROMPT
prompt = savestring (DEFAULT_PROMPT, strlen(DEFAULT_PROMPT));
#else