From 750b7942964c37db092d613eef64eff6dd5de7f3 Mon Sep 17 00:00:00 2001 From: Andrew Cagney Date: Wed, 27 Aug 1997 07:45:50 +0000 Subject: [PATCH] Only pass endianess to simulator when explicitly set by user with set endian. Prepend endian argument so that it can be overriden with target sim -ARGS. --- gdb/ChangeLog | 9 +++++++++ gdb/defs.h | 4 +++- gdb/remote-sim.c | 31 +++++++++++++++++++++++-------- gdb/top.c | 2 +- 4 files changed, 36 insertions(+), 10 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 90f70e7bcbf..5f1aa846329 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,12 @@ +Tue Aug 26 17:13:43 1997 Andrew Cagney + + * remote-sim.c (gdbsim_open): Only pass endianness to sim_open + when set explicitly. Prepend endianness arg so that it can be + overridden. + + * defs.h, top.c (target_byte_order_auto): Make global when + byteorder is selectable. + Tue Aug 26 15:19:56 1997 Andrew Cagney * remote-sim.c (gdbsim_create_inferior): Pass exec_bfd into diff --git a/gdb/defs.h b/gdb/defs.h index 65558e005f0..94725a9ad54 100644 --- a/gdb/defs.h +++ b/gdb/defs.h @@ -758,6 +758,8 @@ extern void free (); #undef TARGET_BYTE_ORDER #define TARGET_BYTE_ORDER target_byte_order extern int target_byte_order; +/* Nonzero when target_byte_order auto-detected */ +extern int target_byte_order_auto; #endif extern void set_endian_from_file PARAMS ((bfd *)); @@ -1004,7 +1006,7 @@ struct target_waitstatus; struct cmd_list_element; #endif -extern void (*init_ui_hook) PARAMS ((void)); +extern void (*init_ui_hook) PARAMS ((char *argv0)); extern void (*command_loop_hook) PARAMS ((void)); extern void (*fputs_unfiltered_hook) PARAMS ((const char *linebuffer, FILE *stream)); diff --git a/gdb/remote-sim.c b/gdb/remote-sim.c index 023eca0670b..71a73d35aee 100644 --- a/gdb/remote-sim.c +++ b/gdb/remote-sim.c @@ -506,16 +506,31 @@ gdbsim_open (args, from_tty) len = 7 + 1 + (args ? strlen (args) : 0) + 50; arg_buf = (char *) alloca (len); - sprintf (arg_buf, "gdbsim%s%s", - args ? " " : "", args ? args : ""); + strcpy (arg_buf, "gdbsim"); /* 7 */ + /* Specify the byte order for the target when it is both selectable + and explicitly specified by the user (not auto detected). */ #ifdef TARGET_BYTE_ORDER_SELECTABLE - /* Since GDB always closes the target and updates byte-order when - opening a new file, TARGET_BYTE_ORDER is normally correct. */ - if (TARGET_BYTE_ORDER == BIG_ENDIAN) - strcat (arg_buf, " -E big"); - else - strcat (arg_buf, " -E little"); + if (!target_byte_order_auto) + { + switch (TARGET_BYTE_ORDER) + { + case BIG_ENDIAN: + strcat (arg_buf, " -E big"); + break; + case LITTLE_ENDIAN: + strcat (arg_buf, " -E little"); + break; + default: + fatal ("Value of TARGET_BYTE_ORDER unknown"); + } + } #endif + /* finally, any explicit args */ + if (args) + { + strcat (arg_buf, " "); /* 1 */ + strcat (arg_buf, args); + } argv = buildargv (arg_buf); if (argv == NULL) error ("Insufficient memory available to allocate simulator arg list."); diff --git a/gdb/top.c b/gdb/top.c index dfa8f3d2c41..1c85374f0fe 100644 --- a/gdb/top.c +++ b/gdb/top.c @@ -3126,7 +3126,7 @@ dont_repeat_command (ignored, from_tty) #define TARGET_BYTE_ORDER_DEFAULT BIG_ENDIAN #endif int target_byte_order = TARGET_BYTE_ORDER_DEFAULT; -static int target_byte_order_auto = 1; +int target_byte_order_auto = 1; #else static int target_byte_order_auto = 0; #endif -- 2.30.2