From 0d20ae728092963c013036d93d9f0d55c04226c9 Mon Sep 17 00:00:00 2001 From: Ulrich Weigand Date: Thu, 31 May 2007 17:00:07 +0000 Subject: [PATCH] 2007-05-31 Markus Deuling * gdbarch.sh (TARGET_BYTE_ORDER): Replace by gdbarch_byte_order. * ax-gdb.c (gen_bitfield_ref): Likewise. * mi/mi-main.c (get_register): Likewise. * findvar.c (default_value_from_register, extract_signed_integer) (extract_unsigned_integer, extract_long_unsigned_integer) (store_signed_integer, store_unsigned_integer): Likewise. * regcache.c (regcache_dump): Likewise. * value.c (lookup_internalvar, value_of_internalvar) (set_internalvar): Likewise. * defs.h: Likewise. * valprint.c (print_binary_chars, print_octal_chars) (print_decimal_chars, print_hex_chars, print_char_chars): Likewise. * infcmd.c (default_print_registers_info): Likewise. * arch-utils.c (selected_byte_order, show_endian): Likewise. * stabsread.c (define_symbol): Likewise. * doublest.c (floatformat_from_length, floatformat_from_type) (extract_typed_floating, store_typed_floating): Likewise. * gdbarch.c, gdbarch.h: Regenerate. --- gdb/ChangeLog | 21 +++++++++++++++++++++ gdb/arch-utils.c | 6 +++--- gdb/ax-gdb.c | 2 +- gdb/defs.h | 2 +- gdb/doublest.c | 18 ++++++++++-------- gdb/findvar.c | 12 ++++++------ gdb/gdbarch.c | 5 ----- gdb/gdbarch.h | 6 ------ gdb/gdbarch.sh | 2 +- gdb/infcmd.c | 2 +- gdb/mi/mi-main.c | 2 +- gdb/regcache.c | 6 ++++-- gdb/stabsread.c | 2 +- gdb/valprint.c | 14 +++++++------- gdb/value.c | 6 +++--- 15 files changed, 60 insertions(+), 46 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 2cae69dbcf5..9c6d0a69809 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,24 @@ +2007-05-31 Markus Deuling + + * gdbarch.sh (TARGET_BYTE_ORDER): Replace by gdbarch_byte_order. + * ax-gdb.c (gen_bitfield_ref): Likewise. + * mi/mi-main.c (get_register): Likewise. + * findvar.c (default_value_from_register, extract_signed_integer) + (extract_unsigned_integer, extract_long_unsigned_integer) + (store_signed_integer, store_unsigned_integer): Likewise. + * regcache.c (regcache_dump): Likewise. + * value.c (lookup_internalvar, value_of_internalvar) + (set_internalvar): Likewise. + * defs.h: Likewise. + * valprint.c (print_binary_chars, print_octal_chars) + (print_decimal_chars, print_hex_chars, print_char_chars): Likewise. + * infcmd.c (default_print_registers_info): Likewise. + * arch-utils.c (selected_byte_order, show_endian): Likewise. + * stabsread.c (define_symbol): Likewise. + * doublest.c (floatformat_from_length, floatformat_from_type) + (extract_typed_floating, store_typed_floating): Likewise. + * gdbarch.c, gdbarch.h: Regenerate. + 2007-05-31 Markus Deuling * gdbarch.sh (CALL_DUMMY_LOCATION): Replace by diff --git a/gdb/arch-utils.c b/gdb/arch-utils.c index 1f85b38d294..ee9fbfbd81c 100644 --- a/gdb/arch-utils.c +++ b/gdb/arch-utils.c @@ -245,7 +245,7 @@ enum bfd_endian selected_byte_order (void) { if (target_byte_order_user != BFD_ENDIAN_UNKNOWN) - return TARGET_BYTE_ORDER; + return gdbarch_byte_order (current_gdbarch); else return BFD_ENDIAN_UNKNOWN; } @@ -257,14 +257,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 (TARGET_BYTE_ORDER == BFD_ENDIAN_BIG) + if (gdbarch_byte_order (current_gdbarch) == 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 (TARGET_BYTE_ORDER == BFD_ENDIAN_BIG) + if (gdbarch_byte_order (current_gdbarch) == BFD_ENDIAN_BIG) fprintf_unfiltered (file, _("The target is assumed to be big endian\n")); else diff --git a/gdb/ax-gdb.c b/gdb/ax-gdb.c index 9fba0a56505..779aec3d347 100644 --- a/gdb/ax-gdb.c +++ b/gdb/ax-gdb.c @@ -1317,7 +1317,7 @@ gen_bitfield_ref (struct agent_expr *ax, struct axs_value *value, the sign/zero extension will wipe them out. - If we're in the interior of the word, then there is no garbage on either end, because the ref operators zero-extend. */ - if (TARGET_BYTE_ORDER == BFD_ENDIAN_BIG) + if (gdbarch_byte_order (current_gdbarch) == BFD_ENDIAN_BIG) gen_left_shift (ax, end - (offset + op_size)); else gen_left_shift (ax, offset - start); diff --git a/gdb/defs.h b/gdb/defs.h index 8e9501486e7..1ce9184db28 100644 --- a/gdb/defs.h +++ b/gdb/defs.h @@ -1069,7 +1069,7 @@ enum { MAX_REGISTER_SIZE = 16 }; from byte/word byte order. */ #if !defined (BITS_BIG_ENDIAN) -#define BITS_BIG_ENDIAN (TARGET_BYTE_ORDER == BFD_ENDIAN_BIG) +#define BITS_BIG_ENDIAN (gdbarch_byte_order (current_gdbarch) == BFD_ENDIAN_BIG) #endif /* In findvar.c. */ diff --git a/gdb/doublest.c b/gdb/doublest.c index 77e7ef9c783..6107c725854 100644 --- a/gdb/doublest.c +++ b/gdb/doublest.c @@ -725,11 +725,11 @@ floatformat_from_length (int len) { const struct floatformat *format; if (len * TARGET_CHAR_BIT == TARGET_FLOAT_BIT) - format = TARGET_FLOAT_FORMAT[TARGET_BYTE_ORDER]; + format = TARGET_FLOAT_FORMAT[gdbarch_byte_order (current_gdbarch)]; else if (len * TARGET_CHAR_BIT == TARGET_DOUBLE_BIT) - format = TARGET_DOUBLE_FORMAT[TARGET_BYTE_ORDER]; + format = TARGET_DOUBLE_FORMAT[gdbarch_byte_order (current_gdbarch)]; else if (len * TARGET_CHAR_BIT == TARGET_LONG_DOUBLE_BIT) - format = TARGET_LONG_DOUBLE_FORMAT[TARGET_BYTE_ORDER]; + format = TARGET_LONG_DOUBLE_FORMAT[gdbarch_byte_order (current_gdbarch)]; /* On i386 the 'long double' type takes 96 bits, while the real number of used bits is only 80, both in processor and in memory. @@ -737,7 +737,7 @@ floatformat_from_length (int len) else if ((TARGET_LONG_DOUBLE_FORMAT != NULL) && (len * TARGET_CHAR_BIT == TARGET_LONG_DOUBLE_FORMAT[0]->totalsize)) - format = TARGET_LONG_DOUBLE_FORMAT[TARGET_BYTE_ORDER]; + format = TARGET_LONG_DOUBLE_FORMAT[gdbarch_byte_order (current_gdbarch)]; else format = NULL; if (format == NULL) @@ -751,7 +751,7 @@ floatformat_from_type (const struct type *type) { gdb_assert (TYPE_CODE (type) == TYPE_CODE_FLT); if (TYPE_FLOATFORMAT (type) != NULL) - return TYPE_FLOATFORMAT (type)[TARGET_BYTE_ORDER]; + return TYPE_FLOATFORMAT (type)[gdbarch_byte_order (current_gdbarch)]; else return floatformat_from_length (TYPE_LENGTH (type)); } @@ -812,7 +812,8 @@ extract_typed_floating (const void *addr, const struct type *type) specific code? stabs?) so handle that here as a special case. */ return extract_floating_by_length (addr, TYPE_LENGTH (type)); - floatformat_to_doublest (TYPE_FLOATFORMAT (type)[TARGET_BYTE_ORDER], + floatformat_to_doublest + (TYPE_FLOATFORMAT (type)[gdbarch_byte_order (current_gdbarch)], addr, &retval); return retval; } @@ -850,8 +851,9 @@ store_typed_floating (void *addr, const struct type *type, DOUBLEST val) specific code? stabs?) so handle that here as a special case. */ store_floating_by_length (addr, TYPE_LENGTH (type), val); else - floatformat_from_doublest (TYPE_FLOATFORMAT (type)[TARGET_BYTE_ORDER], - &val, addr); + floatformat_from_doublest + (TYPE_FLOATFORMAT (type)[gdbarch_byte_order (current_gdbarch)], + &val, addr); } /* Convert a floating-point number of type FROM_TYPE from a diff --git a/gdb/findvar.c b/gdb/findvar.c index a05ee1f8286..14148520567 100644 --- a/gdb/findvar.c +++ b/gdb/findvar.c @@ -63,7 +63,7 @@ That operation is not available on integers of more than %d bytes."), /* Start at the most significant end of the integer, and work towards the least significant. */ - if (TARGET_BYTE_ORDER == BFD_ENDIAN_BIG) + if (gdbarch_byte_order (current_gdbarch) == BFD_ENDIAN_BIG) { p = startaddr; /* Do the sign extension once at the start. */ @@ -98,7 +98,7 @@ That operation is not available on integers of more than %d bytes."), /* Start at the most significant end of the integer, and work towards the least significant. */ retval = 0; - if (TARGET_BYTE_ORDER == BFD_ENDIAN_BIG) + if (gdbarch_byte_order (current_gdbarch) == BFD_ENDIAN_BIG) { for (p = startaddr; p < endaddr; ++p) retval = (retval << 8) | *p; @@ -125,7 +125,7 @@ extract_long_unsigned_integer (const gdb_byte *addr, int orig_len, int len; len = orig_len; - if (TARGET_BYTE_ORDER == BFD_ENDIAN_BIG) + if (gdbarch_byte_order (current_gdbarch) == BFD_ENDIAN_BIG) { for (p = addr; len > (int) sizeof (LONGEST) && p < addr + orig_len; @@ -187,7 +187,7 @@ store_signed_integer (gdb_byte *addr, int len, LONGEST val) /* Start at the least significant end of the integer, and work towards the most significant. */ - if (TARGET_BYTE_ORDER == BFD_ENDIAN_BIG) + if (gdbarch_byte_order (current_gdbarch) == BFD_ENDIAN_BIG) { for (p = endaddr - 1; p >= startaddr; --p) { @@ -214,7 +214,7 @@ store_unsigned_integer (gdb_byte *addr, int len, ULONGEST val) /* Start at the least significant end of the integer, and work towards the most significant. */ - if (TARGET_BYTE_ORDER == BFD_ENDIAN_BIG) + if (gdbarch_byte_order (current_gdbarch) == BFD_ENDIAN_BIG) { for (p = endaddr - 1; p >= startaddr; --p) { @@ -604,7 +604,7 @@ default_value_from_register (struct type *type, int regnum, an integral number of registers. Otherwise, you need to do some fiddling with the last register copied here for little endian machines. */ - if (TARGET_BYTE_ORDER == BFD_ENDIAN_BIG + if (gdbarch_byte_order (current_gdbarch) == BFD_ENDIAN_BIG && len < register_size (gdbarch, regnum)) /* Big-endian, and we want less than full size. */ set_value_offset (value, register_size (gdbarch, regnum) - len); diff --git a/gdb/gdbarch.c b/gdb/gdbarch.c index 73d87e1a92c..188150509f3 100644 --- a/gdb/gdbarch.c +++ b/gdb/gdbarch.c @@ -751,11 +751,6 @@ gdbarch_dump (struct gdbarch *current_gdbarch, struct ui_file *file) fprintf_unfiltered (file, "gdbarch_dump: breakpoint_from_pc = <0x%lx>\n", (long) current_gdbarch->breakpoint_from_pc); -#ifdef TARGET_BYTE_ORDER - fprintf_unfiltered (file, - "gdbarch_dump: TARGET_BYTE_ORDER # %s\n", - XSTRING (TARGET_BYTE_ORDER)); -#endif fprintf_unfiltered (file, "gdbarch_dump: byte_order = %s\n", paddr_d (current_gdbarch->byte_order)); diff --git a/gdb/gdbarch.h b/gdb/gdbarch.h index 64715de67d7..01f49fb5728 100644 --- a/gdb/gdbarch.h +++ b/gdb/gdbarch.h @@ -69,12 +69,6 @@ extern const struct bfd_arch_info * gdbarch_bfd_arch_info (struct gdbarch *gdbar extern int gdbarch_byte_order (struct gdbarch *gdbarch); /* set_gdbarch_byte_order() - not applicable - pre-initialized. */ -#if !defined (GDB_TM_FILE) && defined (TARGET_BYTE_ORDER) -#error "Non multi-arch definition of TARGET_BYTE_ORDER" -#endif -#if !defined (TARGET_BYTE_ORDER) -#define TARGET_BYTE_ORDER (gdbarch_byte_order (current_gdbarch)) -#endif extern enum gdb_osabi gdbarch_osabi (struct gdbarch *gdbarch); /* set_gdbarch_osabi() - not applicable - pre-initialized. */ diff --git a/gdb/gdbarch.sh b/gdb/gdbarch.sh index b454e9c3462..e81188badfb 100755 --- a/gdb/gdbarch.sh +++ b/gdb/gdbarch.sh @@ -369,7 +369,7 @@ function_list () cat <printable_name # -i:TARGET_BYTE_ORDER:int:byte_order:::BFD_ENDIAN_BIG +i::int:byte_order:::BFD_ENDIAN_BIG # i:TARGET_OSABI:enum gdb_osabi:osabi:::GDB_OSABI_UNKNOWN # diff --git a/gdb/infcmd.c b/gdb/infcmd.c index 0f1e960f0bd..29bc1d32978 100644 --- a/gdb/infcmd.c +++ b/gdb/infcmd.c @@ -1653,7 +1653,7 @@ default_print_registers_info (struct gdbarch *gdbarch, for (j = 0; j < register_size (current_gdbarch, i); j++) { int idx; - if (TARGET_BYTE_ORDER == BFD_ENDIAN_BIG) + if (gdbarch_byte_order (current_gdbarch) == BFD_ENDIAN_BIG) idx = j; else idx = register_size (current_gdbarch, i) - 1 - j; diff --git a/gdb/mi/mi-main.c b/gdb/mi/mi-main.c index 96bf423482a..00e19dde32c 100644 --- a/gdb/mi/mi-main.c +++ b/gdb/mi/mi-main.c @@ -552,7 +552,7 @@ get_register (int regnum, int format) ptr = buf + 2; for (j = 0; j < register_size (current_gdbarch, regnum); j++) { - int idx = TARGET_BYTE_ORDER == BFD_ENDIAN_BIG ? j + int idx = gdbarch_byte_order (current_gdbarch) == BFD_ENDIAN_BIG ? j : register_size (current_gdbarch, regnum) - 1 - j; sprintf (ptr, "%02x", (unsigned char) buffer[idx]); ptr += 2; diff --git a/gdb/regcache.c b/gdb/regcache.c index bb9cfde89b3..e48725a9f25 100644 --- a/gdb/regcache.c +++ b/gdb/regcache.c @@ -1113,7 +1113,8 @@ regcache_dump (struct regcache *regcache, struct ui_file *file, { regcache_raw_read (regcache, regnum, buf); fprintf_unfiltered (file, "0x"); - dump_endian_bytes (file, TARGET_BYTE_ORDER, buf, + dump_endian_bytes (file, + gdbarch_byte_order (current_gdbarch), buf, regcache->descr->sizeof_register[regnum]); } } @@ -1127,7 +1128,8 @@ regcache_dump (struct regcache *regcache, struct ui_file *file, { regcache_cooked_read (regcache, regnum, buf); fprintf_unfiltered (file, "0x"); - dump_endian_bytes (file, TARGET_BYTE_ORDER, buf, + dump_endian_bytes (file, + gdbarch_byte_order (current_gdbarch), buf, regcache->descr->sizeof_register[regnum]); } } diff --git a/gdb/stabsread.c b/gdb/stabsread.c index 0a7f8b74fa5..feda42fddd8 100644 --- a/gdb/stabsread.c +++ b/gdb/stabsread.c @@ -963,7 +963,7 @@ define_symbol (CORE_ADDR valu, char *string, int desc, int type, SYMBOL_DOMAIN (sym) = VAR_DOMAIN; add_symbol_to_list (sym, &local_symbols); - if (TARGET_BYTE_ORDER != BFD_ENDIAN_BIG) + if (gdbarch_byte_order (current_gdbarch) != BFD_ENDIAN_BIG) { /* On little-endian machines, this crud is never necessary, and, if the extra bytes contain garbage, is harmful. */ diff --git a/gdb/valprint.c b/gdb/valprint.c index ff6f5d673e3..f2e90819097 100644 --- a/gdb/valprint.c +++ b/gdb/valprint.c @@ -525,7 +525,7 @@ print_binary_chars (struct ui_file *stream, const gdb_byte *valaddr, /* FIXME: We should be not printing leading zeroes in most cases. */ - if (TARGET_BYTE_ORDER == BFD_ENDIAN_BIG) + if (gdbarch_byte_order (current_gdbarch) == BFD_ENDIAN_BIG) { for (p = valaddr; p < valaddr + len; @@ -612,7 +612,7 @@ print_octal_chars (struct ui_file *stream, const gdb_byte *valaddr, carry = 0; fputs_filtered ("0", stream); - if (TARGET_BYTE_ORDER == BFD_ENDIAN_BIG) + if (gdbarch_byte_order (current_gdbarch) == BFD_ENDIAN_BIG) { for (p = valaddr; p < valaddr + len; @@ -725,11 +725,11 @@ print_decimal_chars (struct ui_file *stream, const gdb_byte *valaddr, #define CARRY_LEFT( x ) ((x) % TEN) #define SHIFT( x ) ((x) << 4) #define START_P \ - ((TARGET_BYTE_ORDER == BFD_ENDIAN_BIG) ? valaddr : valaddr + len - 1) + ((gdbarch_byte_order (current_gdbarch) == BFD_ENDIAN_BIG) ? valaddr : valaddr + len - 1) #define NOT_END_P \ - ((TARGET_BYTE_ORDER == BFD_ENDIAN_BIG) ? (p < valaddr + len) : (p >= valaddr)) + ((gdbarch_byte_order (current_gdbarch) == BFD_ENDIAN_BIG) ? (p < valaddr + len) : (p >= valaddr)) #define NEXT_P \ - ((TARGET_BYTE_ORDER == BFD_ENDIAN_BIG) ? p++ : p-- ) + ((gdbarch_byte_order (current_gdbarch) == BFD_ENDIAN_BIG) ? p++ : p-- ) #define LOW_NIBBLE( x ) ( (x) & 0x00F) #define HIGH_NIBBLE( x ) (((x) & 0x0F0) >> 4) @@ -859,7 +859,7 @@ print_hex_chars (struct ui_file *stream, const gdb_byte *valaddr, /* FIXME: We should be not printing leading zeroes in most cases. */ fputs_filtered ("0x", stream); - if (TARGET_BYTE_ORDER == BFD_ENDIAN_BIG) + if (gdbarch_byte_order (current_gdbarch) == BFD_ENDIAN_BIG) { for (p = valaddr; p < valaddr + len; @@ -888,7 +888,7 @@ print_char_chars (struct ui_file *stream, const gdb_byte *valaddr, { const gdb_byte *p; - if (TARGET_BYTE_ORDER == BFD_ENDIAN_BIG) + if (gdbarch_byte_order (current_gdbarch) == BFD_ENDIAN_BIG) { p = valaddr; while (p < valaddr + len - 1 && *p == 0) diff --git a/gdb/value.c b/gdb/value.c index 26ba2a44898..6b7aae660c4 100644 --- a/gdb/value.c +++ b/gdb/value.c @@ -758,7 +758,7 @@ lookup_internalvar (char *name) var = (struct internalvar *) xmalloc (sizeof (struct internalvar)); var->name = concat (name, (char *)NULL); var->value = allocate_value (builtin_type_void); - var->endian = TARGET_BYTE_ORDER; + var->endian = gdbarch_byte_order (current_gdbarch); release_value (var->value); var->next = internalvars; internalvars = var; @@ -790,7 +790,7 @@ value_of_internalvar (struct internalvar *var) point types) are left alone, because they would be too complicated to correct. */ - if (var->endian != TARGET_BYTE_ORDER) + if (var->endian != gdbarch_byte_order (current_gdbarch)) { gdb_byte *array = value_contents_raw (val); struct type *type = check_typedef (value_enclosing_type (val)); @@ -847,7 +847,7 @@ set_internalvar (struct internalvar *var, struct value *val) long. */ xfree (var->value); var->value = newval; - var->endian = TARGET_BYTE_ORDER; + var->endian = gdbarch_byte_order (current_gdbarch); release_value (newval); /* End code which must not call error(). */ } -- 2.30.2