* [patch] Remove BITS_BIG_ENDIAN from defs.h
@ 2008-01-11 18:20 Markus Deuling
2008-01-11 19:24 ` Daniel Jacobowitz
` (2 more replies)
0 siblings, 3 replies; 11+ messages in thread
From: Markus Deuling @ 2008-01-11 18:20 UTC (permalink / raw)
To: GDB Patches, Ulrich Weigand, Eli Zaretskii
[-- Attachment #1: Type: text/plain, Size: 1174 bytes --]
Hi,
this patch removes BITS_BIG_ENDIAN from defs.h by replacing it with its expression. The way to recognize
endianess of a target is gdbarch_byte_order (current_gdbarch) == BFD_ENDIAN_BIG which is widely used by most files.
So this macro is unnecessary. The other patch removes BITS_BIG_ENDIAN from the documentation.
This patch introduces some new current_gdbarch's which will be replaced by a later patch.
Tested on x86 without regressions. Is this ok ?
ChangeLog:
* value.h: Correct comment.
* value.c (struct value): Likewise.
* gdbtypes.h (struct field): Likewise.
(unpack_field_as_long, modify_field): Replace BITS_BIG_ENDIAN by its
expression.
* valops.c (value_slice): Likewise.
* valarith.c (value_subscript, value_bit_index): Likewise.
* eval.c (evaluate_subexp_standard): Likewise.
* dwarf2read.c (dwarf2_add_field): Likewise.
* ada-lang.c (decode_packed_array, ada_value_primitive_packed_val)
(move_bits, ada_value_assign, value_assign_to_component): Likewise.
* defs.h (BITS_BIG_ENDIAN): Remove.
ChangeLog doc:
* gdbint.texinfo (BITS_BIG_ENDIAN): Remove.
--
Markus Deuling
GNU Toolchain for Linux on Cell BE
deuling@de.ibm.com
[-- Attachment #2: diff-BITS_BIG_ENDIAN --]
[-- Type: text/plain, Size: 8308 bytes --]
diff -urpN src/gdb/ada-lang.c dev/gdb/ada-lang.c
--- src/gdb/ada-lang.c 2008-01-09 11:01:28.000000000 +0100
+++ dev/gdb/ada-lang.c 2008-01-11 18:43:46.000000000 +0100
@@ -1875,7 +1875,8 @@ decode_packed_array (struct value *arr)
return NULL;
}
- if (BITS_BIG_ENDIAN && ada_is_modular_type (value_type (arr)))
+ if (gdbarch_byte_order (current_gdbarch) == BFD_ENDIAN_BIG
+ && ada_is_modular_type (value_type (arr)))
{
/* This is a (right-justified) modular type representing a packed
array with no wrapper. In order to interpret the value through
@@ -1998,7 +1999,7 @@ ada_value_primitive_packed_val (struct v
int len = (bit_size + bit_offset + HOST_CHAR_BIT - 1) / 8;
/* Transmit bytes from least to most significant; delta is the direction
the indices move. */
- int delta = BITS_BIG_ENDIAN ? -1 : 1;
+ int delta = (gdbarch_byte_order (current_gdbarch) == BFD_ENDIAN_BIG) ? -1 : 1;
type = ada_check_typedef (type);
@@ -2047,7 +2048,7 @@ ada_value_primitive_packed_val (struct v
memset (unpacked, 0, TYPE_LENGTH (type));
return v;
}
- else if (BITS_BIG_ENDIAN)
+ else if (gdbarch_byte_order (current_gdbarch) == BFD_ENDIAN_BIG)
{
src = len - 1;
if (has_negatives (type)
@@ -2141,7 +2142,7 @@ move_bits (gdb_byte *target, int targ_of
targ_offset %= HOST_CHAR_BIT;
source += src_offset / HOST_CHAR_BIT;
src_offset %= HOST_CHAR_BIT;
- if (BITS_BIG_ENDIAN)
+ if (gdbarch_byte_order (current_gdbarch) == BFD_ENDIAN_BIG)
{
accum = (unsigned char) *source;
source += 1;
@@ -2229,7 +2230,7 @@ ada_value_assign (struct value *toval, s
fromval = value_cast (type, fromval);
read_memory (to_addr, buffer, len);
- if (BITS_BIG_ENDIAN)
+ if (gdbarch_byte_order (current_gdbarch) == BFD_ENDIAN_BIG)
move_bits (buffer, value_bitpos (toval),
value_contents (fromval),
TYPE_LENGTH (value_type (fromval)) * TARGET_CHAR_BIT -
@@ -2276,7 +2277,7 @@ value_assign_to_component (struct value
else
bits = value_bitsize (component);
- if (BITS_BIG_ENDIAN)
+ if (gdbarch_byte_order (current_gdbarch) == BFD_ENDIAN_BIG)
move_bits (value_contents_writeable (container) + offset_in_container,
value_bitpos (container) + bit_offset_in_container,
value_contents (val),
diff -urpN src/gdb/defs.h dev/gdb/defs.h
--- src/gdb/defs.h 2008-01-11 13:28:02.000000000 +0100
+++ dev/gdb/defs.h 2008-01-11 18:45:26.000000000 +0100
@@ -1043,14 +1043,6 @@ enum { MAX_REGISTER_SIZE = 16 };
#define HOST_CHAR_BIT TARGET_CHAR_BIT
#endif
-/* The bit byte-order has to do just with numbering of bits in
- debugging symbols and such. Conceptually, it's quite separate
- from byte/word byte order. */
-
-#if !defined (BITS_BIG_ENDIAN)
-#define BITS_BIG_ENDIAN (gdbarch_byte_order (current_gdbarch) == BFD_ENDIAN_BIG)
-#endif
-
/* In findvar.c. */
extern LONGEST extract_signed_integer (const gdb_byte *, int);
diff -urpN src/gdb/dwarf2read.c dev/gdb/dwarf2read.c
--- src/gdb/dwarf2read.c 2008-01-11 14:32:31.000000000 +0100
+++ dev/gdb/dwarf2read.c 2008-01-11 18:41:27.000000000 +0100
@@ -3502,7 +3502,7 @@ dwarf2_add_field (struct field_info *fip
attr = dwarf2_attr (die, DW_AT_bit_offset, cu);
if (attr)
{
- if (BITS_BIG_ENDIAN)
+ if (gdbarch_byte_order (current_gdbarch) == BFD_ENDIAN_BIG)
{
/* For big endian bits, the DW_AT_bit_offset gives the
additional bit offset from the MSB of the containing
diff -urpN src/gdb/eval.c dev/gdb/eval.c
--- src/gdb/eval.c 2008-01-08 11:22:24.000000000 +0100
+++ dev/gdb/eval.c 2008-01-11 18:40:32.000000000 +0100
@@ -686,7 +686,7 @@ evaluate_subexp_standard (struct type *e
for (; range_low <= range_high; range_low++)
{
int bit_index = (unsigned) range_low % TARGET_CHAR_BIT;
- if (BITS_BIG_ENDIAN)
+ if (gdbarch_byte_order (current_gdbarch) == BFD_ENDIAN_BIG)
bit_index = TARGET_CHAR_BIT - 1 - bit_index;
valaddr[(unsigned) range_low / TARGET_CHAR_BIT]
|= 1 << bit_index;
diff -urpN src/gdb/gdbtypes.h dev/gdb/gdbtypes.h
--- src/gdb/gdbtypes.h 2008-01-01 23:53:10.000000000 +0100
+++ dev/gdb/gdbtypes.h 2008-01-11 18:39:29.000000000 +0100
@@ -403,8 +403,8 @@ struct main_type
{
/* Position of this field, counting in bits from start of
containing structure.
- For BITS_BIG_ENDIAN=1 targets, it is the bit offset to the MSB.
- For BITS_BIG_ENDIAN=0 targets, it is the bit offset to the LSB.
+ For Big Endian targets, it is the bit offset to the MSB.
+ For Little Endian targets, it is the bit offset to the LSB.
For a range bound or enum value, this is the value itself. */
int bitpos;
diff -urpN src/gdb/valarith.c dev/gdb/valarith.c
--- src/gdb/valarith.c 2008-01-08 11:22:24.000000000 +0100
+++ dev/gdb/valarith.c 2008-01-11 18:38:31.000000000 +0100
@@ -230,7 +230,8 @@ value_subscript (struct value *array, st
offset = index / TARGET_CHAR_BIT;
byte = *((char *) value_contents (array) + offset);
bit_index = index % TARGET_CHAR_BIT;
- byte >>= (BITS_BIG_ENDIAN ? TARGET_CHAR_BIT - 1 - bit_index : bit_index);
+ byte >>= (gdbarch_byte_order (current_gdbarch) == BFD_ENDIAN_BIG ?
+ TARGET_CHAR_BIT - 1 - bit_index : bit_index);
v = value_from_longest (LA_BOOL_TYPE, byte & 1);
set_value_bitpos (v, bit_index);
set_value_bitsize (v, 1);
@@ -1573,7 +1574,7 @@ value_bit_index (struct type *type, cons
word = unpack_long (builtin_type_unsigned_char,
valaddr + (rel_index / TARGET_CHAR_BIT));
rel_index %= TARGET_CHAR_BIT;
- if (BITS_BIG_ENDIAN)
+ if (gdbarch_byte_order (current_gdbarch) == BFD_ENDIAN_BIG)
rel_index = TARGET_CHAR_BIT - 1 - rel_index;
return (word >> rel_index) & 1;
}
diff -urpN src/gdb/valops.c dev/gdb/valops.c
--- src/gdb/valops.c 2008-01-08 11:22:24.000000000 +0100
+++ dev/gdb/valops.c 2008-01-11 18:36:58.000000000 +0100
@@ -2743,7 +2743,7 @@ value_slice (struct value *array, int lo
else if (element > 0)
{
int j = i % TARGET_CHAR_BIT;
- if (BITS_BIG_ENDIAN)
+ if (gdbarch_byte_order (current_gdbarch) == BFD_ENDIAN_BIG)
j = TARGET_CHAR_BIT - 1 - j;
value_contents_raw (slice)[i / TARGET_CHAR_BIT] |= (1 << j);
}
diff -urpN src/gdb/value.c dev/gdb/value.c
--- src/gdb/value.c 2008-01-08 11:22:24.000000000 +0100
+++ dev/gdb/value.c 2008-01-11 18:36:10.000000000 +0100
@@ -72,8 +72,8 @@ struct value
int bitsize;
/* Only used for bitfields; position of start of field. For
- BITS_BIG_ENDIAN=0 targets, it is the position of the LSB. For
- BITS_BIG_ENDIAN=1 targets, it is the position of the MSB. */
+ Little Endian targets, it is the position of the LSB. For
+ Big Endian targets, it is the position of the MSB. */
int bitpos;
/* Frame register value is relative to. This will be described in
@@ -1481,7 +1481,7 @@ unpack_field_as_long (struct type *type,
/* Extract bits. See comment above. */
- if (BITS_BIG_ENDIAN)
+ if (gdbarch_byte_order (current_gdbarch) == BFD_ENDIAN_BIG)
lsbcount = (sizeof val * 8 - bitpos % 8 - bitsize);
else
lsbcount = (bitpos % 8);
@@ -1537,7 +1537,7 @@ modify_field (gdb_byte *addr, LONGEST fi
oword = extract_unsigned_integer (addr, sizeof oword);
/* Shifting for bit field depends on endianness of the target machine. */
- if (BITS_BIG_ENDIAN)
+ if (gdbarch_byte_order (current_gdbarch) == BFD_ENDIAN_BIG)
bitpos = sizeof (oword) * 8 - bitpos - bitsize;
oword &= ~(mask << bitpos);
diff -urpN src/gdb/value.h dev/gdb/value.h
--- src/gdb/value.h 2008-01-08 11:22:24.000000000 +0100
+++ dev/gdb/value.h 2008-01-11 18:34:08.000000000 +0100
@@ -62,8 +62,8 @@ extern int value_bitsize (struct value *
extern void set_value_bitsize (struct value *, int bit);
/* Only used for bitfields; position of start of field. For
- BITS_BIG_ENDIAN=0 targets, it is the position of the LSB. For
- BITS_BIG_ENDIAN=1 targets, it is the position of the MSB. */
+ Little Endian targets, it is the position of the LSB. For
+ Big Endian targets, it is the position of the MSB. */
extern int value_bitpos (struct value *);
extern void set_value_bitpos (struct value *, int bit);
[-- Attachment #3: diff-doc-ENDIAN --]
[-- Type: text/plain, Size: 758 bytes --]
diff -urpN src/gdb/doc/gdbint.texinfo dev/gdb/doc/gdbint.texinfo
--- src/gdb/doc/gdbint.texinfo 2008-01-05 17:49:53.000000000 +0100
+++ dev/gdb/doc/gdbint.texinfo 2008-01-11 18:47:54.000000000 +0100
@@ -3344,12 +3344,6 @@ Used to notify if the compiler promotes
parameter to an @code{int}, but still reports the parameter as its
original type, rather than the promoted type.
-@item BITS_BIG_ENDIAN
-@findex BITS_BIG_ENDIAN
-Define this if the numbering of bits in the targets does @strong{not} match the
-endianness of the target byte order. A value of 1 means that the bits
-are numbered in a big-endian bit order, 0 means little-endian.
-
@item BREAKPOINT
@findex BREAKPOINT
This is the character array initializer for the bit pattern to put into
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [patch] Remove BITS_BIG_ENDIAN from defs.h
2008-01-11 18:20 [patch] Remove BITS_BIG_ENDIAN from defs.h Markus Deuling
@ 2008-01-11 19:24 ` Daniel Jacobowitz
2008-01-11 20:59 ` Eli Zaretskii
2008-01-14 18:11 ` Ulrich Weigand
2 siblings, 0 replies; 11+ messages in thread
From: Daniel Jacobowitz @ 2008-01-11 19:24 UTC (permalink / raw)
To: Markus Deuling; +Cc: GDB Patches, Ulrich Weigand, Eli Zaretskii
On Fri, Jan 11, 2008 at 07:18:09PM +0100, Markus Deuling wrote:
> So this macro is unnecessary.
> -/* The bit byte-order has to do just with numbering of bits in
> - debugging symbols and such. Conceptually, it's quite separate
> - from byte/word byte order. */
You're dropping this distinction. Is it still a useful one?
If so, please use a new bits_big_endian (current_gdbarch) instead.
--
Daniel Jacobowitz
CodeSourcery
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [patch] Remove BITS_BIG_ENDIAN from defs.h
2008-01-11 18:20 [patch] Remove BITS_BIG_ENDIAN from defs.h Markus Deuling
2008-01-11 19:24 ` Daniel Jacobowitz
@ 2008-01-11 20:59 ` Eli Zaretskii
2008-01-14 18:11 ` Ulrich Weigand
2 siblings, 0 replies; 11+ messages in thread
From: Eli Zaretskii @ 2008-01-11 20:59 UTC (permalink / raw)
To: Markus Deuling; +Cc: gdb-patches, uweigand
> Date: Fri, 11 Jan 2008 19:18:09 +0100
> From: Markus Deuling <deuling@de.ibm.com>
>
> this patch removes BITS_BIG_ENDIAN from defs.h by replacing it with its expression. The way to recognize
> endianess of a target is gdbarch_byte_order (current_gdbarch) == BFD_ENDIAN_BIG which is widely used by most files.
> So this macro is unnecessary.
Sorry, I don't see how this argument is the proof that the macro is
unnecessary. defs.h allows a target to define BITS_BIG_ENDIAN, and
only looks at gdbarch_byte_order if BITS_BIG_ENDIAN is undefined.
Your change removes that possibility. Why is that justified?
The gdbint.texinfo text you want to remove clearly says that this
macro is for the targets whose bit numbering does NOT match the
endianess of the target itself:
> -@item BITS_BIG_ENDIAN
> -@findex BITS_BIG_ENDIAN
> -Define this if the numbering of bits in the targets does @strong{not} match the
> -endianness of the target byte order.
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [patch] Remove BITS_BIG_ENDIAN from defs.h
2008-01-11 18:20 [patch] Remove BITS_BIG_ENDIAN from defs.h Markus Deuling
2008-01-11 19:24 ` Daniel Jacobowitz
2008-01-11 20:59 ` Eli Zaretskii
@ 2008-01-14 18:11 ` Ulrich Weigand
2008-01-15 9:06 ` Markus Deuling
2 siblings, 1 reply; 11+ messages in thread
From: Ulrich Weigand @ 2008-01-14 18:11 UTC (permalink / raw)
To: Markus Deuling; +Cc: GDB Patches, Eli Zaretskii
Markus Deuling wrote:
> this patch removes BITS_BIG_ENDIAN from defs.h by replacing it with
> its expression. The way to recognize endianess of a target is
> gdbarch_byte_order (current_gdbarch) == BFD_ENDIAN_BIG which is
> widely used by most files. So this macro is unnecessary.
As Dan and Eli pointed out, there *is* a difference between the two:
- gdbarch_byte_order says whether in a multi-byte value, the least
or most significant *byte* comes first
- BITS_BIG_ENDIAN is intended to say whether in a bitfield, the
least of most significant *bit* comes first
Looking at GCC, there are targets with big endian byte order but
little endian bit order (or vice versa), even though those are
not supported in GDB today (or maybe they are but bitfields simply
do not work correctly).
Thus I think we should introduce a new gdbarch property to allow
to set the bit order.
Bye,
Ulrich
--
Dr. Ulrich Weigand
GNU Toolchain for Linux on System z and Cell BE
Ulrich.Weigand@de.ibm.com
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [patch] Remove BITS_BIG_ENDIAN from defs.h
2008-01-14 18:11 ` Ulrich Weigand
@ 2008-01-15 9:06 ` Markus Deuling
2008-01-15 21:01 ` Ulrich Weigand
0 siblings, 1 reply; 11+ messages in thread
From: Markus Deuling @ 2008-01-15 9:06 UTC (permalink / raw)
To: Ulrich Weigand; +Cc: GDB Patches, Eli Zaretskii, Daniel Jacobowitz
[-- Attachment #1: Type: text/plain, Size: 2075 bytes --]
Ulrich Weigand schrieb:
> Markus Deuling wrote:
>
>> this patch removes BITS_BIG_ENDIAN from defs.h by replacing it with
>> its expression. The way to recognize endianess of a target is
>> gdbarch_byte_order (current_gdbarch) == BFD_ENDIAN_BIG which is
>> widely used by most files. So this macro is unnecessary.
>
> As Dan and Eli pointed out, there *is* a difference between the two:
> - gdbarch_byte_order says whether in a multi-byte value, the least
> or most significant *byte* comes first
> - BITS_BIG_ENDIAN is intended to say whether in a bitfield, the
> least of most significant *bit* comes first
>
> Looking at GCC, there are targets with big endian byte order but
> little endian bit order (or vice versa), even though those are
> not supported in GDB today (or maybe they are but bitfields simply
> do not work correctly).
>
> Thus I think we should introduce a new gdbarch property to allow
> to set the bit order.
>
Hi,
thank you very much for all of your valuable feedback. I rewrote the patch
and introduce a new gdbarch property bits_big_endian now to replace BITS_BIG_ENDIAN.
I tested this patch on both Little and Big Endian machine (x86/ppc) without regression.
If this patch is ok I'll post another one for the documentation. Ok to commit?
ChangeLog:
* gdbarch.sh (function_list): Add new property bits_big_endian to
gdbarch structure.
* gdbarch.{c,h}: Regenerate.
* value.c (struct value): Replace BITS_BIG_ENDIAN by
gdbarch_bits_big_endian (comment).
(unpack_field_as_long, modify_field): Likewise.
* value.h: Likewise (comment).
* valops.c (value_slice): Likewise.
* valarith.c (value_subscript, value_bit_index): Likewise.
* gdbtypes.h (field): Likewise (comment).
* eval.c (evaluate_subexp_standard): Likewise.
* dwarf2read.c (dwarf2_add_field): Likewise.
* ada-lang.c (decode_packed_array, ada_value_primitive_packed_val)
(move_bits, ada_value_assign, value_assign_to_component): Likewise.
* defs.h (BITS_BIG_ENDIAN): Remove.
--
Markus Deuling
GNU Toolchain for Linux on Cell BE
deuling@de.ibm.com
[-- Attachment #2: diff-BITS_BIG_ENDIAN --]
[-- Type: text/plain, Size: 12337 bytes --]
diff -urpN src/gdb/ada-lang.c dev/gdb/ada-lang.c
--- src/gdb/ada-lang.c 2008-01-09 11:01:28.000000000 +0100
+++ dev/gdb/ada-lang.c 2008-01-15 08:02:37.000000000 +0100
@@ -1875,7 +1875,8 @@ decode_packed_array (struct value *arr)
return NULL;
}
- if (BITS_BIG_ENDIAN && ada_is_modular_type (value_type (arr)))
+ if (gdbarch_bits_big_endian (current_gdbarch)
+ && ada_is_modular_type (value_type (arr)))
{
/* This is a (right-justified) modular type representing a packed
array with no wrapper. In order to interpret the value through
@@ -1998,7 +1999,7 @@ ada_value_primitive_packed_val (struct v
int len = (bit_size + bit_offset + HOST_CHAR_BIT - 1) / 8;
/* Transmit bytes from least to most significant; delta is the direction
the indices move. */
- int delta = BITS_BIG_ENDIAN ? -1 : 1;
+ int delta = gdbarch_bits_big_endian (current_gdbarch) ? -1 : 1;
type = ada_check_typedef (type);
@@ -2047,7 +2048,7 @@ ada_value_primitive_packed_val (struct v
memset (unpacked, 0, TYPE_LENGTH (type));
return v;
}
- else if (BITS_BIG_ENDIAN)
+ else if (gdbarch_bits_big_endian (current_gdbarch))
{
src = len - 1;
if (has_negatives (type)
@@ -2141,7 +2142,7 @@ move_bits (gdb_byte *target, int targ_of
targ_offset %= HOST_CHAR_BIT;
source += src_offset / HOST_CHAR_BIT;
src_offset %= HOST_CHAR_BIT;
- if (BITS_BIG_ENDIAN)
+ if (gdbarch_bits_big_endian (current_gdbarch))
{
accum = (unsigned char) *source;
source += 1;
@@ -2229,7 +2230,7 @@ ada_value_assign (struct value *toval, s
fromval = value_cast (type, fromval);
read_memory (to_addr, buffer, len);
- if (BITS_BIG_ENDIAN)
+ if (gdbarch_bits_big_endian (current_gdbarch))
move_bits (buffer, value_bitpos (toval),
value_contents (fromval),
TYPE_LENGTH (value_type (fromval)) * TARGET_CHAR_BIT -
@@ -2276,7 +2277,7 @@ value_assign_to_component (struct value
else
bits = value_bitsize (component);
- if (BITS_BIG_ENDIAN)
+ if (gdbarch_bits_big_endian (current_gdbarch))
move_bits (value_contents_writeable (container) + offset_in_container,
value_bitpos (container) + bit_offset_in_container,
value_contents (val),
diff -urpN src/gdb/defs.h dev/gdb/defs.h
--- src/gdb/defs.h 2008-01-11 13:28:02.000000000 +0100
+++ dev/gdb/defs.h 2008-01-15 08:04:32.000000000 +0100
@@ -1043,14 +1043,6 @@ enum { MAX_REGISTER_SIZE = 16 };
#define HOST_CHAR_BIT TARGET_CHAR_BIT
#endif
-/* The bit byte-order has to do just with numbering of bits in
- debugging symbols and such. Conceptually, it's quite separate
- from byte/word byte order. */
-
-#if !defined (BITS_BIG_ENDIAN)
-#define BITS_BIG_ENDIAN (gdbarch_byte_order (current_gdbarch) == BFD_ENDIAN_BIG)
-#endif
-
/* In findvar.c. */
extern LONGEST extract_signed_integer (const gdb_byte *, int);
diff -urpN src/gdb/dwarf2read.c dev/gdb/dwarf2read.c
--- src/gdb/dwarf2read.c 2008-01-11 14:32:31.000000000 +0100
+++ dev/gdb/dwarf2read.c 2008-01-15 07:55:28.000000000 +0100
@@ -3502,7 +3502,7 @@ dwarf2_add_field (struct field_info *fip
attr = dwarf2_attr (die, DW_AT_bit_offset, cu);
if (attr)
{
- if (BITS_BIG_ENDIAN)
+ if (gdbarch_bits_big_endian (current_gdbarch))
{
/* For big endian bits, the DW_AT_bit_offset gives the
additional bit offset from the MSB of the containing
diff -urpN src/gdb/eval.c dev/gdb/eval.c
--- src/gdb/eval.c 2008-01-08 11:22:24.000000000 +0100
+++ dev/gdb/eval.c 2008-01-15 07:53:28.000000000 +0100
@@ -686,7 +686,7 @@ evaluate_subexp_standard (struct type *e
for (; range_low <= range_high; range_low++)
{
int bit_index = (unsigned) range_low % TARGET_CHAR_BIT;
- if (BITS_BIG_ENDIAN)
+ if (gdbarch_bits_big_endian (current_gdbarch))
bit_index = TARGET_CHAR_BIT - 1 - bit_index;
valaddr[(unsigned) range_low / TARGET_CHAR_BIT]
|= 1 << bit_index;
diff -urpN src/gdb/gdbarch.c dev/gdb/gdbarch.c
--- src/gdb/gdbarch.c 2008-01-11 14:20:52.000000000 +0100
+++ dev/gdb/gdbarch.c 2008-01-15 08:04:34.000000000 +0100
@@ -130,6 +130,7 @@ struct gdbarch
*/
+ int bits_big_endian;
int short_bit;
int int_bit;
int long_bit;
@@ -251,6 +252,7 @@ struct gdbarch startup_gdbarch =
/*per-architecture data-pointers and swap regions */
0, NULL, NULL,
/* Multi-arch values */
+ 0, /* bits_big_endian */
8 * sizeof (short), /* short_bit */
8 * sizeof (int), /* int_bit */
8 * sizeof (long), /* long_bit */
@@ -382,6 +384,7 @@ gdbarch_alloc (const struct gdbarch_info
gdbarch->target_desc = info->target_desc;
/* Force the explicit initialization of these. */
+ gdbarch->bits_big_endian = (gdbarch->byte_order == BFD_ENDIAN_BIG);
gdbarch->short_bit = 2*TARGET_CHAR_BIT;
gdbarch->int_bit = 4*TARGET_CHAR_BIT;
gdbarch->long_bit = 4*TARGET_CHAR_BIT;
@@ -480,6 +483,7 @@ verify_gdbarch (struct gdbarch *gdbarch)
if (gdbarch->bfd_arch_info == NULL)
fprintf_unfiltered (log, "\n\tbfd_arch_info");
/* Check those that need to be defined for the given multi-arch level. */
+ /* Skip verify of bits_big_endian, invalid_p == 0 */
/* Skip verify of short_bit, invalid_p == 0 */
/* Skip verify of int_bit, invalid_p == 0 */
/* Skip verify of long_bit, invalid_p == 0 */
@@ -648,6 +652,9 @@ gdbarch_dump (struct gdbarch *gdbarch, s
"gdbarch_dump: bfd_arch_info = %s\n",
gdbarch_bfd_arch_info (gdbarch)->printable_name);
fprintf_unfiltered (file,
+ "gdbarch_dump: bits_big_endian = %s\n",
+ paddr_d (gdbarch->bits_big_endian));
+ fprintf_unfiltered (file,
"gdbarch_dump: breakpoint_from_pc = <0x%lx>\n",
(long) gdbarch->breakpoint_from_pc);
fprintf_unfiltered (file,
@@ -1060,6 +1067,23 @@ gdbarch_target_desc (struct gdbarch *gdb
}
int
+gdbarch_bits_big_endian (struct gdbarch *gdbarch)
+{
+ gdb_assert (gdbarch != NULL);
+ /* Skip verify of bits_big_endian, invalid_p == 0 */
+ if (gdbarch_debug >= 2)
+ fprintf_unfiltered (gdb_stdlog, "gdbarch_bits_big_endian called\n");
+ return gdbarch->bits_big_endian;
+}
+
+void
+set_gdbarch_bits_big_endian (struct gdbarch *gdbarch,
+ int bits_big_endian)
+{
+ gdbarch->bits_big_endian = bits_big_endian;
+}
+
+int
gdbarch_short_bit (struct gdbarch *gdbarch)
{
gdb_assert (gdbarch != NULL);
diff -urpN src/gdb/gdbarch.h dev/gdb/gdbarch.h
--- src/gdb/gdbarch.h 2008-01-11 14:20:52.000000000 +0100
+++ dev/gdb/gdbarch.h 2008-01-15 08:04:28.000000000 +0100
@@ -71,6 +71,12 @@ extern const struct target_desc * gdbarc
/* The following are initialized by the target dependent code. */
+/* The bit byte-order has to do just with numbering of bits in debugging symbols
+ and such. Conceptually, it's quite separate from byte/word byte order. */
+
+extern int gdbarch_bits_big_endian (struct gdbarch *gdbarch);
+extern void set_gdbarch_bits_big_endian (struct gdbarch *gdbarch, int bits_big_endian);
+
/* Number of bits in a char or unsigned char for the target machine.
Just like CHAR_BIT in <limits.h> but describes the target machine.
v:TARGET_CHAR_BIT:int:char_bit::::8 * sizeof (char):8::0:
diff -urpN src/gdb/gdbarch.sh dev/gdb/gdbarch.sh
--- src/gdb/gdbarch.sh 2008-01-11 14:20:52.000000000 +0100
+++ dev/gdb/gdbarch.sh 2008-01-15 08:04:22.000000000 +0100
@@ -343,6 +343,11 @@ i:int:byte_order:::BFD_ENDIAN_BIG
i:enum gdb_osabi:osabi:::GDB_OSABI_UNKNOWN
#
i:const struct target_desc *:target_desc:::::::paddr_d ((long) gdbarch->target_desc)
+
+# The bit byte-order has to do just with numbering of bits in debugging symbols
+# and such. Conceptually, it's quite separate from byte/word byte order.
+v:int:bits_big_endian:::0:(gdbarch->byte_order == BFD_ENDIAN_BIG)::0
+
# Number of bits in a char or unsigned char for the target machine.
# Just like CHAR_BIT in <limits.h> but describes the target machine.
# v:TARGET_CHAR_BIT:int:char_bit::::8 * sizeof (char):8::0:
diff -urpN src/gdb/gdbtypes.h dev/gdb/gdbtypes.h
--- src/gdb/gdbtypes.h 2008-01-01 23:53:10.000000000 +0100
+++ dev/gdb/gdbtypes.h 2008-01-15 07:52:38.000000000 +0100
@@ -403,8 +403,8 @@ struct main_type
{
/* Position of this field, counting in bits from start of
containing structure.
- For BITS_BIG_ENDIAN=1 targets, it is the bit offset to the MSB.
- For BITS_BIG_ENDIAN=0 targets, it is the bit offset to the LSB.
+ For gdbarch_bits_big_endian=1 targets, it is the bit offset to the MSB.
+ For gdbarch_bits_big_endian=0 targets, it is the bit offset to the LSB.
For a range bound or enum value, this is the value itself. */
int bitpos;
diff -urpN src/gdb/valarith.c dev/gdb/valarith.c
--- src/gdb/valarith.c 2008-01-08 11:22:24.000000000 +0100
+++ dev/gdb/valarith.c 2008-01-15 07:51:31.000000000 +0100
@@ -230,7 +230,8 @@ value_subscript (struct value *array, st
offset = index / TARGET_CHAR_BIT;
byte = *((char *) value_contents (array) + offset);
bit_index = index % TARGET_CHAR_BIT;
- byte >>= (BITS_BIG_ENDIAN ? TARGET_CHAR_BIT - 1 - bit_index : bit_index);
+ byte >>= (gdbarch_bits_big_endian (current_gdbarch) ?
+ TARGET_CHAR_BIT - 1 - bit_index : bit_index);
v = value_from_longest (LA_BOOL_TYPE, byte & 1);
set_value_bitpos (v, bit_index);
set_value_bitsize (v, 1);
@@ -1573,7 +1574,7 @@ value_bit_index (struct type *type, cons
word = unpack_long (builtin_type_unsigned_char,
valaddr + (rel_index / TARGET_CHAR_BIT));
rel_index %= TARGET_CHAR_BIT;
- if (BITS_BIG_ENDIAN)
+ if (gdbarch_bits_big_endian (current_gdbarch))
rel_index = TARGET_CHAR_BIT - 1 - rel_index;
return (word >> rel_index) & 1;
}
diff -urpN src/gdb/valops.c dev/gdb/valops.c
--- src/gdb/valops.c 2008-01-08 11:22:24.000000000 +0100
+++ dev/gdb/valops.c 2008-01-15 07:28:43.000000000 +0100
@@ -2743,7 +2743,7 @@ value_slice (struct value *array, int lo
else if (element > 0)
{
int j = i % TARGET_CHAR_BIT;
- if (BITS_BIG_ENDIAN)
+ if (gdbarch_bits_big_endian (current_gdbarch))
j = TARGET_CHAR_BIT - 1 - j;
value_contents_raw (slice)[i / TARGET_CHAR_BIT] |= (1 << j);
}
diff -urpN src/gdb/value.c dev/gdb/value.c
--- src/gdb/value.c 2008-01-08 11:22:24.000000000 +0100
+++ dev/gdb/value.c 2008-01-15 07:26:01.000000000 +0100
@@ -72,8 +72,8 @@ struct value
int bitsize;
/* Only used for bitfields; position of start of field. For
- BITS_BIG_ENDIAN=0 targets, it is the position of the LSB. For
- BITS_BIG_ENDIAN=1 targets, it is the position of the MSB. */
+ gdbarch_bits_big_endian=0 targets, it is the position of the LSB. For
+ gdbarch_bits_big_endian=1 targets, it is the position of the MSB. */
int bitpos;
/* Frame register value is relative to. This will be described in
@@ -1481,7 +1481,7 @@ unpack_field_as_long (struct type *type,
/* Extract bits. See comment above. */
- if (BITS_BIG_ENDIAN)
+ if (gdbarch_bits_big_endian (current_gdbarch))
lsbcount = (sizeof val * 8 - bitpos % 8 - bitsize);
else
lsbcount = (bitpos % 8);
@@ -1537,7 +1537,7 @@ modify_field (gdb_byte *addr, LONGEST fi
oword = extract_unsigned_integer (addr, sizeof oword);
/* Shifting for bit field depends on endianness of the target machine. */
- if (BITS_BIG_ENDIAN)
+ if (gdbarch_bits_big_endian (current_gdbarch))
bitpos = sizeof (oword) * 8 - bitpos - bitsize;
oword &= ~(mask << bitpos);
diff -urpN src/gdb/value.h dev/gdb/value.h
--- src/gdb/value.h 2008-01-08 11:22:24.000000000 +0100
+++ dev/gdb/value.h 2008-01-15 07:27:58.000000000 +0100
@@ -62,8 +62,8 @@ extern int value_bitsize (struct value *
extern void set_value_bitsize (struct value *, int bit);
/* Only used for bitfields; position of start of field. For
- BITS_BIG_ENDIAN=0 targets, it is the position of the LSB. For
- BITS_BIG_ENDIAN=1 targets, it is the position of the MSB. */
+ gdbarch_bits_big_endian=0 targets, it is the position of the LSB. For
+ gdbarch_bits_big_endian=1 targets, it is the position of the MSB. */
extern int value_bitpos (struct value *);
extern void set_value_bitpos (struct value *, int bit);
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [patch] Remove BITS_BIG_ENDIAN from defs.h
2008-01-15 9:06 ` Markus Deuling
@ 2008-01-15 21:01 ` Ulrich Weigand
2008-01-16 5:59 ` Markus Deuling
0 siblings, 1 reply; 11+ messages in thread
From: Ulrich Weigand @ 2008-01-15 21:01 UTC (permalink / raw)
To: Markus Deuling; +Cc: GDB Patches, Eli Zaretskii, Daniel Jacobowitz
Markus Deuling wrote:
> @@ -251,6 +252,7 @@ struct gdbarch startup_gdbarch =
> /*per-architecture data-pointers and swap regions */
> 0, NULL, NULL,
> /* Multi-arch values */
> + 0, /* bits_big_endian */
> 8 * sizeof (short), /* short_bit */
> 8 * sizeof (int), /* int_bit */
> 8 * sizeof (long), /* long_bit */
The "static default" of 0 for bits_big_endian is inconsistent
with the static default of BFD_ENDIAN_BIG for byte_order ...
> +# The bit byte-order has to do just with numbering of bits in debugging symbols
> +# and such. Conceptually, it's quite separate from byte/word byte order.
> +v:int:bits_big_endian:::0:(gdbarch->byte_order == BFD_ENDIAN_BIG)::0
... so I guess this should preferably be:
v:int:bits_big_endian:::1:(gdbarch->byte_order == BFD_ENDIAN_BIG)::0
Otherwise, this patch is OK, but please commit only together with ...
>I tested this patch on both Little and Big Endian machine (x86/ppc) without regression.
>If this patch is ok I'll post another one for the documentation. Ok to commit?
... the documentation patch (once that is approved).
Thanks,
Ulrich
--
Dr. Ulrich Weigand
GNU Toolchain for Linux on System z and Cell BE
Ulrich.Weigand@de.ibm.com
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [patch] Remove BITS_BIG_ENDIAN from defs.h
2008-01-15 21:01 ` Ulrich Weigand
@ 2008-01-16 5:59 ` Markus Deuling
2008-01-16 18:43 ` Eli Zaretskii
0 siblings, 1 reply; 11+ messages in thread
From: Markus Deuling @ 2008-01-16 5:59 UTC (permalink / raw)
To: Ulrich Weigand; +Cc: GDB Patches, Eli Zaretskii, Daniel Jacobowitz
[-- Attachment #1: Type: text/plain, Size: 1524 bytes --]
Ulrich Weigand schrieb:
> Markus Deuling wrote:
>
>> @@ -251,6 +252,7 @@ struct gdbarch startup_gdbarch =
>> /*per-architecture data-pointers and swap regions */
>> 0, NULL, NULL,
>> /* Multi-arch values */
>> + 0, /* bits_big_endian */
>> 8 * sizeof (short), /* short_bit */
>> 8 * sizeof (int), /* int_bit */
>> 8 * sizeof (long), /* long_bit */
>
> The "static default" of 0 for bits_big_endian is inconsistent
> with the static default of BFD_ENDIAN_BIG for byte_order ...
>
>> +# The bit byte-order has to do just with numbering of bits in debugging symbols
>> +# and such. Conceptually, it's quite separate from byte/word byte order.
>> +v:int:bits_big_endian:::0:(gdbarch->byte_order == BFD_ENDIAN_BIG)::0
>
> .... so I guess this should preferably be:
>
> v:int:bits_big_endian:::1:(gdbarch->byte_order == BFD_ENDIAN_BIG)::0
>
> Otherwise, this patch is OK, but please commit only together with ...
>
>> I tested this patch on both Little and Big Endian machine (x86/ppc) without regression.
>> If this patch is ok I'll post another one for the documentation. Ok to commit?
>
> .... the documentation patch (once that is approved).
Thanks a lot. I reworked and retested the patch on x86 and ppc. I attached both the patch for
the source and the documentation.
Eli, is the documentation ok like this ?
ChangeLog Doc:
* gdbint.texinfo (BITS_BIG_ENDIAN): Rewrite to match
gdbarch_bits_big_endian.
--
Markus Deuling
GNU Toolchain for Linux on Cell BE
deuling@de.ibm.com
[-- Attachment #2: diff-doc-ENDIAN --]
[-- Type: text/plain, Size: 804 bytes --]
diff -urpN src/gdb/doc/gdbint.texinfo dev/gdb/doc/gdbint.texinfo
--- src/gdb/doc/gdbint.texinfo 2008-01-05 17:49:53.000000000 +0100
+++ dev/gdb/doc/gdbint.texinfo 2008-01-16 06:20:24.000000000 +0100
@@ -3344,9 +3344,9 @@ Used to notify if the compiler promotes
parameter to an @code{int}, but still reports the parameter as its
original type, rather than the promoted type.
-@item BITS_BIG_ENDIAN
-@findex BITS_BIG_ENDIAN
-Define this if the numbering of bits in the targets does @strong{not} match the
+@item gdbarch_bits_big_endian (@var{gdbarch})
+@findex gdbarch_bits_big_endian
+Set this if the numbering of bits in the targets does @strong{not} match the
endianness of the target byte order. A value of 1 means that the bits
are numbered in a big-endian bit order, 0 means little-endian.
[-- Attachment #3: diff-BITS_BIG_ENDIAN --]
[-- Type: text/plain, Size: 12336 bytes --]
diff -urpN src/gdb/ada-lang.c dev/gdb/ada-lang.c
--- src/gdb/ada-lang.c 2008-01-09 11:01:28.000000000 +0100
+++ dev/gdb/ada-lang.c 2008-01-16 06:12:28.000000000 +0100
@@ -1875,7 +1875,8 @@ decode_packed_array (struct value *arr)
return NULL;
}
- if (BITS_BIG_ENDIAN && ada_is_modular_type (value_type (arr)))
+ if (gdbarch_bits_big_endian (current_gdbarch)
+ && ada_is_modular_type (value_type (arr)))
{
/* This is a (right-justified) modular type representing a packed
array with no wrapper. In order to interpret the value through
@@ -1998,7 +1999,7 @@ ada_value_primitive_packed_val (struct v
int len = (bit_size + bit_offset + HOST_CHAR_BIT - 1) / 8;
/* Transmit bytes from least to most significant; delta is the direction
the indices move. */
- int delta = BITS_BIG_ENDIAN ? -1 : 1;
+ int delta = gdbarch_bits_big_endian (current_gdbarch) ? -1 : 1;
type = ada_check_typedef (type);
@@ -2047,7 +2048,7 @@ ada_value_primitive_packed_val (struct v
memset (unpacked, 0, TYPE_LENGTH (type));
return v;
}
- else if (BITS_BIG_ENDIAN)
+ else if (gdbarch_bits_big_endian (current_gdbarch))
{
src = len - 1;
if (has_negatives (type)
@@ -2141,7 +2142,7 @@ move_bits (gdb_byte *target, int targ_of
targ_offset %= HOST_CHAR_BIT;
source += src_offset / HOST_CHAR_BIT;
src_offset %= HOST_CHAR_BIT;
- if (BITS_BIG_ENDIAN)
+ if (gdbarch_bits_big_endian (current_gdbarch))
{
accum = (unsigned char) *source;
source += 1;
@@ -2229,7 +2230,7 @@ ada_value_assign (struct value *toval, s
fromval = value_cast (type, fromval);
read_memory (to_addr, buffer, len);
- if (BITS_BIG_ENDIAN)
+ if (gdbarch_bits_big_endian (current_gdbarch))
move_bits (buffer, value_bitpos (toval),
value_contents (fromval),
TYPE_LENGTH (value_type (fromval)) * TARGET_CHAR_BIT -
@@ -2276,7 +2277,7 @@ value_assign_to_component (struct value
else
bits = value_bitsize (component);
- if (BITS_BIG_ENDIAN)
+ if (gdbarch_bits_big_endian (current_gdbarch))
move_bits (value_contents_writeable (container) + offset_in_container,
value_bitpos (container) + bit_offset_in_container,
value_contents (val),
diff -urpN src/gdb/defs.h dev/gdb/defs.h
--- src/gdb/defs.h 2008-01-11 13:28:02.000000000 +0100
+++ dev/gdb/defs.h 2008-01-16 06:12:28.000000000 +0100
@@ -1043,14 +1043,6 @@ enum { MAX_REGISTER_SIZE = 16 };
#define HOST_CHAR_BIT TARGET_CHAR_BIT
#endif
-/* The bit byte-order has to do just with numbering of bits in
- debugging symbols and such. Conceptually, it's quite separate
- from byte/word byte order. */
-
-#if !defined (BITS_BIG_ENDIAN)
-#define BITS_BIG_ENDIAN (gdbarch_byte_order (current_gdbarch) == BFD_ENDIAN_BIG)
-#endif
-
/* In findvar.c. */
extern LONGEST extract_signed_integer (const gdb_byte *, int);
diff -urpN src/gdb/dwarf2read.c dev/gdb/dwarf2read.c
--- src/gdb/dwarf2read.c 2008-01-11 14:32:31.000000000 +0100
+++ dev/gdb/dwarf2read.c 2008-01-16 06:12:28.000000000 +0100
@@ -3502,7 +3502,7 @@ dwarf2_add_field (struct field_info *fip
attr = dwarf2_attr (die, DW_AT_bit_offset, cu);
if (attr)
{
- if (BITS_BIG_ENDIAN)
+ if (gdbarch_bits_big_endian (current_gdbarch))
{
/* For big endian bits, the DW_AT_bit_offset gives the
additional bit offset from the MSB of the containing
diff -urpN src/gdb/eval.c dev/gdb/eval.c
--- src/gdb/eval.c 2008-01-08 11:22:24.000000000 +0100
+++ dev/gdb/eval.c 2008-01-16 06:12:28.000000000 +0100
@@ -686,7 +686,7 @@ evaluate_subexp_standard (struct type *e
for (; range_low <= range_high; range_low++)
{
int bit_index = (unsigned) range_low % TARGET_CHAR_BIT;
- if (BITS_BIG_ENDIAN)
+ if (gdbarch_bits_big_endian (current_gdbarch))
bit_index = TARGET_CHAR_BIT - 1 - bit_index;
valaddr[(unsigned) range_low / TARGET_CHAR_BIT]
|= 1 << bit_index;
diff -urpN src/gdb/gdbarch.c dev/gdb/gdbarch.c
--- src/gdb/gdbarch.c 2008-01-11 14:20:52.000000000 +0100
+++ dev/gdb/gdbarch.c 2008-01-16 06:13:06.000000000 +0100
@@ -130,6 +130,7 @@ struct gdbarch
*/
+ int bits_big_endian;
int short_bit;
int int_bit;
int long_bit;
@@ -251,6 +252,7 @@ struct gdbarch startup_gdbarch =
/*per-architecture data-pointers and swap regions */
0, NULL, NULL,
/* Multi-arch values */
+ 1, /* bits_big_endian */
8 * sizeof (short), /* short_bit */
8 * sizeof (int), /* int_bit */
8 * sizeof (long), /* long_bit */
@@ -382,6 +384,7 @@ gdbarch_alloc (const struct gdbarch_info
gdbarch->target_desc = info->target_desc;
/* Force the explicit initialization of these. */
+ gdbarch->bits_big_endian = (gdbarch->byte_order == BFD_ENDIAN_BIG);
gdbarch->short_bit = 2*TARGET_CHAR_BIT;
gdbarch->int_bit = 4*TARGET_CHAR_BIT;
gdbarch->long_bit = 4*TARGET_CHAR_BIT;
@@ -480,6 +483,7 @@ verify_gdbarch (struct gdbarch *gdbarch)
if (gdbarch->bfd_arch_info == NULL)
fprintf_unfiltered (log, "\n\tbfd_arch_info");
/* Check those that need to be defined for the given multi-arch level. */
+ /* Skip verify of bits_big_endian, invalid_p == 0 */
/* Skip verify of short_bit, invalid_p == 0 */
/* Skip verify of int_bit, invalid_p == 0 */
/* Skip verify of long_bit, invalid_p == 0 */
@@ -648,6 +652,9 @@ gdbarch_dump (struct gdbarch *gdbarch, s
"gdbarch_dump: bfd_arch_info = %s\n",
gdbarch_bfd_arch_info (gdbarch)->printable_name);
fprintf_unfiltered (file,
+ "gdbarch_dump: bits_big_endian = %s\n",
+ paddr_d (gdbarch->bits_big_endian));
+ fprintf_unfiltered (file,
"gdbarch_dump: breakpoint_from_pc = <0x%lx>\n",
(long) gdbarch->breakpoint_from_pc);
fprintf_unfiltered (file,
@@ -1060,6 +1067,23 @@ gdbarch_target_desc (struct gdbarch *gdb
}
int
+gdbarch_bits_big_endian (struct gdbarch *gdbarch)
+{
+ gdb_assert (gdbarch != NULL);
+ /* Skip verify of bits_big_endian, invalid_p == 0 */
+ if (gdbarch_debug >= 2)
+ fprintf_unfiltered (gdb_stdlog, "gdbarch_bits_big_endian called\n");
+ return gdbarch->bits_big_endian;
+}
+
+void
+set_gdbarch_bits_big_endian (struct gdbarch *gdbarch,
+ int bits_big_endian)
+{
+ gdbarch->bits_big_endian = bits_big_endian;
+}
+
+int
gdbarch_short_bit (struct gdbarch *gdbarch)
{
gdb_assert (gdbarch != NULL);
diff -urpN src/gdb/gdbarch.h dev/gdb/gdbarch.h
--- src/gdb/gdbarch.h 2008-01-11 14:20:52.000000000 +0100
+++ dev/gdb/gdbarch.h 2008-01-16 06:12:59.000000000 +0100
@@ -71,6 +71,12 @@ extern const struct target_desc * gdbarc
/* The following are initialized by the target dependent code. */
+/* The bit byte-order has to do just with numbering of bits in debugging symbols
+ and such. Conceptually, it's quite separate from byte/word byte order. */
+
+extern int gdbarch_bits_big_endian (struct gdbarch *gdbarch);
+extern void set_gdbarch_bits_big_endian (struct gdbarch *gdbarch, int bits_big_endian);
+
/* Number of bits in a char or unsigned char for the target machine.
Just like CHAR_BIT in <limits.h> but describes the target machine.
v:TARGET_CHAR_BIT:int:char_bit::::8 * sizeof (char):8::0:
diff -urpN src/gdb/gdbarch.sh dev/gdb/gdbarch.sh
--- src/gdb/gdbarch.sh 2008-01-11 14:20:52.000000000 +0100
+++ dev/gdb/gdbarch.sh 2008-01-16 06:12:50.000000000 +0100
@@ -343,6 +343,11 @@ i:int:byte_order:::BFD_ENDIAN_BIG
i:enum gdb_osabi:osabi:::GDB_OSABI_UNKNOWN
#
i:const struct target_desc *:target_desc:::::::paddr_d ((long) gdbarch->target_desc)
+
+# The bit byte-order has to do just with numbering of bits in debugging symbols
+# and such. Conceptually, it's quite separate from byte/word byte order.
+v:int:bits_big_endian:::1:(gdbarch->byte_order == BFD_ENDIAN_BIG)::0
+
# Number of bits in a char or unsigned char for the target machine.
# Just like CHAR_BIT in <limits.h> but describes the target machine.
# v:TARGET_CHAR_BIT:int:char_bit::::8 * sizeof (char):8::0:
diff -urpN src/gdb/gdbtypes.h dev/gdb/gdbtypes.h
--- src/gdb/gdbtypes.h 2008-01-01 23:53:10.000000000 +0100
+++ dev/gdb/gdbtypes.h 2008-01-16 06:12:28.000000000 +0100
@@ -403,8 +403,8 @@ struct main_type
{
/* Position of this field, counting in bits from start of
containing structure.
- For BITS_BIG_ENDIAN=1 targets, it is the bit offset to the MSB.
- For BITS_BIG_ENDIAN=0 targets, it is the bit offset to the LSB.
+ For gdbarch_bits_big_endian=1 targets, it is the bit offset to the MSB.
+ For gdbarch_bits_big_endian=0 targets, it is the bit offset to the LSB.
For a range bound or enum value, this is the value itself. */
int bitpos;
diff -urpN src/gdb/valarith.c dev/gdb/valarith.c
--- src/gdb/valarith.c 2008-01-08 11:22:24.000000000 +0100
+++ dev/gdb/valarith.c 2008-01-16 06:12:28.000000000 +0100
@@ -230,7 +230,8 @@ value_subscript (struct value *array, st
offset = index / TARGET_CHAR_BIT;
byte = *((char *) value_contents (array) + offset);
bit_index = index % TARGET_CHAR_BIT;
- byte >>= (BITS_BIG_ENDIAN ? TARGET_CHAR_BIT - 1 - bit_index : bit_index);
+ byte >>= (gdbarch_bits_big_endian (current_gdbarch) ?
+ TARGET_CHAR_BIT - 1 - bit_index : bit_index);
v = value_from_longest (LA_BOOL_TYPE, byte & 1);
set_value_bitpos (v, bit_index);
set_value_bitsize (v, 1);
@@ -1573,7 +1574,7 @@ value_bit_index (struct type *type, cons
word = unpack_long (builtin_type_unsigned_char,
valaddr + (rel_index / TARGET_CHAR_BIT));
rel_index %= TARGET_CHAR_BIT;
- if (BITS_BIG_ENDIAN)
+ if (gdbarch_bits_big_endian (current_gdbarch))
rel_index = TARGET_CHAR_BIT - 1 - rel_index;
return (word >> rel_index) & 1;
}
diff -urpN src/gdb/valops.c dev/gdb/valops.c
--- src/gdb/valops.c 2008-01-08 11:22:24.000000000 +0100
+++ dev/gdb/valops.c 2008-01-16 06:12:28.000000000 +0100
@@ -2743,7 +2743,7 @@ value_slice (struct value *array, int lo
else if (element > 0)
{
int j = i % TARGET_CHAR_BIT;
- if (BITS_BIG_ENDIAN)
+ if (gdbarch_bits_big_endian (current_gdbarch))
j = TARGET_CHAR_BIT - 1 - j;
value_contents_raw (slice)[i / TARGET_CHAR_BIT] |= (1 << j);
}
diff -urpN src/gdb/value.c dev/gdb/value.c
--- src/gdb/value.c 2008-01-08 11:22:24.000000000 +0100
+++ dev/gdb/value.c 2008-01-16 06:12:28.000000000 +0100
@@ -72,8 +72,8 @@ struct value
int bitsize;
/* Only used for bitfields; position of start of field. For
- BITS_BIG_ENDIAN=0 targets, it is the position of the LSB. For
- BITS_BIG_ENDIAN=1 targets, it is the position of the MSB. */
+ gdbarch_bits_big_endian=0 targets, it is the position of the LSB. For
+ gdbarch_bits_big_endian=1 targets, it is the position of the MSB. */
int bitpos;
/* Frame register value is relative to. This will be described in
@@ -1481,7 +1481,7 @@ unpack_field_as_long (struct type *type,
/* Extract bits. See comment above. */
- if (BITS_BIG_ENDIAN)
+ if (gdbarch_bits_big_endian (current_gdbarch))
lsbcount = (sizeof val * 8 - bitpos % 8 - bitsize);
else
lsbcount = (bitpos % 8);
@@ -1537,7 +1537,7 @@ modify_field (gdb_byte *addr, LONGEST fi
oword = extract_unsigned_integer (addr, sizeof oword);
/* Shifting for bit field depends on endianness of the target machine. */
- if (BITS_BIG_ENDIAN)
+ if (gdbarch_bits_big_endian (current_gdbarch))
bitpos = sizeof (oword) * 8 - bitpos - bitsize;
oword &= ~(mask << bitpos);
diff -urpN src/gdb/value.h dev/gdb/value.h
--- src/gdb/value.h 2008-01-08 11:22:24.000000000 +0100
+++ dev/gdb/value.h 2008-01-16 06:12:28.000000000 +0100
@@ -62,8 +62,8 @@ extern int value_bitsize (struct value *
extern void set_value_bitsize (struct value *, int bit);
/* Only used for bitfields; position of start of field. For
- BITS_BIG_ENDIAN=0 targets, it is the position of the LSB. For
- BITS_BIG_ENDIAN=1 targets, it is the position of the MSB. */
+ gdbarch_bits_big_endian=0 targets, it is the position of the LSB. For
+ gdbarch_bits_big_endian=1 targets, it is the position of the MSB. */
extern int value_bitpos (struct value *);
extern void set_value_bitpos (struct value *, int bit);
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [patch] Remove BITS_BIG_ENDIAN from defs.h
2008-01-16 5:59 ` Markus Deuling
@ 2008-01-16 18:43 ` Eli Zaretskii
2008-01-17 7:09 ` Markus Deuling
0 siblings, 1 reply; 11+ messages in thread
From: Eli Zaretskii @ 2008-01-16 18:43 UTC (permalink / raw)
To: Markus Deuling; +Cc: uweigand, gdb-patches, drow
> Date: Wed, 16 Jan 2008 06:57:05 +0100
> From: Markus Deuling <deuling@de.ibm.com>
> CC: GDB Patches <gdb-patches@sourceware.org>, Eli Zaretskii <eliz@gnu.org>,
> Daniel Jacobowitz <drow@false.org>
>
> Eli, is the documentation ok like this ?
I have a few comments:
> ChangeLog Doc:
>
> * gdbint.texinfo (BITS_BIG_ENDIAN): Rewrite to match
> gdbarch_bits_big_endian.
Actually, this should say something like:
* gdbint.texinfo (Target Conditionals): Replace the
description of BITS_BIG_ENDIAN with a description of
gdbarch_bits_big_endian.
Note that the text in parens is the name of the node in which you make
the change.
> +@item gdbarch_bits_big_endian (@var{gdbarch})
> +@findex gdbarch_bits_big_endian
> +Set this if the numbering of bits in the targets does @strong{not} match the
"Set this" isn't right, because you don't "set" a function. I think
it's better to say "Define this to return non-zero it bits are
numbered in the big-endian order (i.e., the rightmost bit has the
largest number), zero otherwise."
Btw, should we also document set_gdbarch_bits_big_endian?
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [patch] Remove BITS_BIG_ENDIAN from defs.h
2008-01-16 18:43 ` Eli Zaretskii
@ 2008-01-17 7:09 ` Markus Deuling
2008-01-18 16:21 ` Eli Zaretskii
0 siblings, 1 reply; 11+ messages in thread
From: Markus Deuling @ 2008-01-17 7:09 UTC (permalink / raw)
To: Eli Zaretskii; +Cc: uweigand, gdb-patches, drow
[-- Attachment #1: Type: text/plain, Size: 1620 bytes --]
Eli Zaretskii schrieb:
>> Date: Wed, 16 Jan 2008 06:57:05 +0100
>> From: Markus Deuling <deuling@de.ibm.com>
>> CC: GDB Patches <gdb-patches@sourceware.org>, Eli Zaretskii <eliz@gnu.org>,
>> Daniel Jacobowitz <drow@false.org>
>>
>> Eli, is the documentation ok like this ?
>
> I have a few comments:
>
>> ChangeLog Doc:
>>
>> * gdbint.texinfo (BITS_BIG_ENDIAN): Rewrite to match
>> gdbarch_bits_big_endian.
>
> Actually, this should say something like:
>
> * gdbint.texinfo (Target Conditionals): Replace the
> description of BITS_BIG_ENDIAN with a description of
> gdbarch_bits_big_endian.
>
> Note that the text in parens is the name of the node in which you make
> the change.
>
>> +@item gdbarch_bits_big_endian (@var{gdbarch})
>> +@findex gdbarch_bits_big_endian
>> +Set this if the numbering of bits in the targets does @strong{not} match the
>
> "Set this" isn't right, because you don't "set" a function. I think
> it's better to say "Define this to return non-zero it bits are
> numbered in the big-endian order (i.e., the rightmost bit has the
> largest number), zero otherwise."
>
> Btw, should we also document set_gdbarch_bits_big_endian?
>
Hi Eli,
thank you very much for your review. I reworked the patch and added an entry for set_gdbarch_bits_big_endian.
I also added it to the Target Conditionals node. Is that right?
Is this ok ?
ChangeLog:
* gdbint.texinfo (Target Conditionals): Replace the description of
BITS_BIG_ENDIAN with a description of gdbarch_bits_big_endian.
Regards,
Markus
--
Markus Deuling
GNU Toolchain for Linux on Cell BE
deuling@de.ibm.com
[-- Attachment #2: diff-doc-ENDIAN --]
[-- Type: text/plain, Size: 1270 bytes --]
diff -urpN src/gdb/doc/gdbint.texinfo dev/gdb/doc/gdbint.texinfo
--- src/gdb/doc/gdbint.texinfo 2008-01-05 17:49:53.000000000 +0100
+++ dev/gdb/doc/gdbint.texinfo 2008-01-17 07:57:10.000000000 +0100
@@ -3344,12 +3344,19 @@ Used to notify if the compiler promotes
parameter to an @code{int}, but still reports the parameter as its
original type, rather than the promoted type.
-@item BITS_BIG_ENDIAN
-@findex BITS_BIG_ENDIAN
-Define this if the numbering of bits in the targets does @strong{not} match the
-endianness of the target byte order. A value of 1 means that the bits
+@item gdbarch_bits_big_endian (@var{gdbarch})
+@findex gdbarch_bits_big_endian
+This is used if the numbering of bits in the targets does @strong{not} match
+the endianness of the target byte order. A value of 1 means that the bits
are numbered in a big-endian bit order, 0 means little-endian.
+@item set_gdbarch_bits_big_endian (@var{gdbarch}, @var{bits_big_endian})
+@findex set_gdbarch_bits_big_endian
+Calling set_gdbarch_bits_big_endian with a value of 1 indicates that the
+bits in the target are numbered in a big-endian bit order, 0 indicates
+little-endian.
+
+
@item BREAKPOINT
@findex BREAKPOINT
This is the character array initializer for the bit pattern to put into
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [patch] Remove BITS_BIG_ENDIAN from defs.h
2008-01-17 7:09 ` Markus Deuling
@ 2008-01-18 16:21 ` Eli Zaretskii
2008-01-18 17:08 ` Markus Deuling
0 siblings, 1 reply; 11+ messages in thread
From: Eli Zaretskii @ 2008-01-18 16:21 UTC (permalink / raw)
To: Markus Deuling; +Cc: uweigand, gdb-patches, drow
> Date: Thu, 17 Jan 2008 08:06:46 +0100
> From: Markus Deuling <deuling@de.ibm.com>
> CC: uweigand@de.ibm.com, gdb-patches@sourceware.org, drow@false.org
>
> thank you very much for your review. I reworked the patch and added an entry for set_gdbarch_bits_big_endian.
> I also added it to the Target Conditionals node. Is that right?
>
> Is this ok ?
Yes, thanks.
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [patch] Remove BITS_BIG_ENDIAN from defs.h
2008-01-18 16:21 ` Eli Zaretskii
@ 2008-01-18 17:08 ` Markus Deuling
0 siblings, 0 replies; 11+ messages in thread
From: Markus Deuling @ 2008-01-18 17:08 UTC (permalink / raw)
To: Eli Zaretskii; +Cc: uweigand, gdb-patches, drow
Eli Zaretskii schrieb:
>> Date: Thu, 17 Jan 2008 08:06:46 +0100
>> From: Markus Deuling <deuling@de.ibm.com>
>> CC: uweigand@de.ibm.com, gdb-patches@sourceware.org, drow@false.org
>>
>> thank you very much for your review. I reworked the patch and added an entry for set_gdbarch_bits_big_endian.
>> I also added it to the Target Conditionals node. Is that right?
>>
>> Is this ok ?
>
> Yes, thanks.
>
Thanks to all of you. I've now committed my patch.
Regards,
Markus
--
Markus Deuling
GNU Toolchain for Linux on Cell BE
deuling@de.ibm.com
^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2008-01-18 17:08 UTC | newest]
Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-01-11 18:20 [patch] Remove BITS_BIG_ENDIAN from defs.h Markus Deuling
2008-01-11 19:24 ` Daniel Jacobowitz
2008-01-11 20:59 ` Eli Zaretskii
2008-01-14 18:11 ` Ulrich Weigand
2008-01-15 9:06 ` Markus Deuling
2008-01-15 21:01 ` Ulrich Weigand
2008-01-16 5:59 ` Markus Deuling
2008-01-16 18:43 ` Eli Zaretskii
2008-01-17 7:09 ` Markus Deuling
2008-01-18 16:21 ` Eli Zaretskii
2008-01-18 17:08 ` Markus Deuling
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox