This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
[rfc] [2/6] Remove macro TARGET_BYTE_ORDER
- From: Markus Deuling <deuling at de dot ibm dot com>
- To: GDB Patches <gdb-patches at sourceware dot org>
- Cc: Ulrich Weigand <uweigand at de dot ibm dot com>
- Date: Tue, 29 May 2007 09:20:37 +0200
- Subject: [rfc] [2/6] Remove macro TARGET_BYTE_ORDER
Hello,
this patch removes TARGET_BYTE_ORDER macro from gdbarch.sh.
ChangeLog:
* 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.
Is this ok to commit?
Regards,
Markus
--
Markus Deuling
GNU Toolchain for Linux on Cell BE
deuling@de.ibm.com
diff -urN src/gdb/arch-utils.c dev/gdb/arch-utils.c
--- src/gdb/arch-utils.c 2007-05-11 22:03:48.000000000 +0200
+++ dev/gdb/arch-utils.c 2007-05-18 08:40:24.000000000 +0200
@@ -245,7 +245,7 @@
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 @@
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 -urN src/gdb/ax-gdb.c dev/gdb/ax-gdb.c
--- src/gdb/ax-gdb.c 2007-01-09 18:58:49.000000000 +0100
+++ dev/gdb/ax-gdb.c 2007-05-18 08:18:17.000000000 +0200
@@ -1317,7 +1317,7 @@
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 -urN src/gdb/defs.h dev/gdb/defs.h
--- src/gdb/defs.h 2007-04-16 13:51:29.000000000 +0200
+++ dev/gdb/defs.h 2007-05-18 08:32:31.000000000 +0200
@@ -1069,7 +1069,7 @@
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 -urN src/gdb/doublest.c dev/gdb/doublest.c
--- src/gdb/doublest.c 2007-04-02 05:53:36.000000000 +0200
+++ dev/gdb/doublest.c 2007-05-18 08:45:50.000000000 +0200
@@ -725,11 +725,11 @@
{
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 @@
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 @@
{
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 @@
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 @@
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 -urN src/gdb/findvar.c dev/gdb/findvar.c
--- src/gdb/findvar.c 2007-05-07 13:21:04.000000000 +0200
+++ dev/gdb/findvar.c 2007-05-18 08:23:50.000000000 +0200
@@ -63,7 +63,7 @@
/* 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 @@
/* 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 @@
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 @@
/* 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 @@
/* 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 @@
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 -urN src/gdb/gdbarch.c dev/gdb/gdbarch.c
--- src/gdb/gdbarch.c 2007-05-15 05:41:29.000000000 +0200
+++ dev/gdb/gdbarch.c 2007-05-18 08:12:56.000000000 +0200
@@ -751,11 +751,6 @@
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 -urN src/gdb/gdbarch.h dev/gdb/gdbarch.h
--- src/gdb/gdbarch.h 2007-05-15 05:41:29.000000000 +0200
+++ dev/gdb/gdbarch.h 2007-05-18 08:12:46.000000000 +0200
@@ -69,12 +69,6 @@
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 -urN src/gdb/gdbarch.sh dev/gdb/gdbarch.sh
--- src/gdb/gdbarch.sh 2007-05-15 05:41:29.000000000 +0200
+++ dev/gdb/gdbarch.sh 2007-05-18 08:12:39.000000000 +0200
@@ -369,7 +369,7 @@
cat <<EOF
i:TARGET_ARCHITECTURE:const struct bfd_arch_info *:bfd_arch_info:::&bfd_default_arch_struct::::TARGET_ARCHITECTURE->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 -urN src/gdb/infcmd.c dev/gdb/infcmd.c
--- src/gdb/infcmd.c 2007-04-18 13:12:57.000000000 +0200
+++ dev/gdb/infcmd.c 2007-05-18 08:38:45.000000000 +0200
@@ -1653,7 +1653,7 @@
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 -urN src/gdb/mi/mi-main.c dev/gdb/mi/mi-main.c
--- src/gdb/mi/mi-main.c 2007-05-02 14:55:07.000000000 +0200
+++ dev/gdb/mi/mi-main.c 2007-05-18 08:19:19.000000000 +0200
@@ -552,7 +552,7 @@
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 -urN src/gdb/regcache.c dev/gdb/regcache.c
--- src/gdb/regcache.c 2007-05-14 05:45:00.000000000 +0200
+++ dev/gdb/regcache.c 2007-05-18 08:25:55.000000000 +0200
@@ -1113,7 +1113,8 @@
{
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_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 -urN src/gdb/stabsread.c dev/gdb/stabsread.c
--- src/gdb/stabsread.c 2007-03-30 05:24:17.000000000 +0200
+++ dev/gdb/stabsread.c 2007-05-18 08:42:01.000000000 +0200
@@ -963,7 +963,7 @@
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 -urN src/gdb/valprint.c dev/gdb/valprint.c
--- src/gdb/valprint.c 2007-04-02 05:53:36.000000000 +0200
+++ dev/gdb/valprint.c 2007-05-18 08:37:40.000000000 +0200
@@ -525,7 +525,7 @@
/* 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 @@
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 @@
#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 @@
/* 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 @@
{
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 -urN src/gdb/value.c dev/gdb/value.c
--- src/gdb/value.c 2007-05-15 05:41:29.000000000 +0200
+++ dev/gdb/value.c 2007-05-18 08:30:04.000000000 +0200
@@ -754,7 +754,7 @@
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;
@@ -786,7 +786,7 @@
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));
@@ -843,7 +843,7 @@
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(). */
}