From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 3803 invoked by alias); 19 May 2008 09:44:15 -0000 Received: (qmail 3795 invoked by uid 22791); 19 May 2008 09:44:14 -0000 X-Spam-Check-By: sourceware.org Received: from mtagate5.de.ibm.com (HELO mtagate5.de.ibm.com) (195.212.29.154) by sourceware.org (qpsmtpd/0.31) with ESMTP; Mon, 19 May 2008 09:43:53 +0000 Received: from d12nrmr1607.megacenter.de.ibm.com (d12nrmr1607.megacenter.de.ibm.com [9.149.167.49]) by mtagate5.de.ibm.com (8.13.8/8.13.8) with ESMTP id m4J9hYYG091826 for ; Mon, 19 May 2008 09:43:34 GMT Received: from d12av02.megacenter.de.ibm.com (d12av02.megacenter.de.ibm.com [9.149.165.228]) by d12nrmr1607.megacenter.de.ibm.com (8.13.8/8.13.8/NCO v8.7) with ESMTP id m4J9hYoJ4321376 for ; Mon, 19 May 2008 11:43:34 +0200 Received: from d12av02.megacenter.de.ibm.com (loopback [127.0.0.1]) by d12av02.megacenter.de.ibm.com (8.12.11.20060308/8.13.3) with ESMTP id m4J9hYoQ025397 for ; Mon, 19 May 2008 11:43:34 +0200 Received: from bbkeks.de.ibm.com (dyn-9-152-248-39.boeblingen.de.ibm.com [9.152.248.39]) by d12av02.megacenter.de.ibm.com (8.12.11.20060308/8.12.11) with ESMTP id m4J9hWpO025345 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Mon, 19 May 2008 11:43:34 +0200 Message-ID: <48314BC3.4040207@de.ibm.com> Date: Mon, 19 May 2008 15:19:00 -0000 From: Markus Deuling User-Agent: Thunderbird 2.0.0.14 (X11/20080421) MIME-Version: 1.0 To: GDB Patches CC: Ulrich Weigand Subject: [patch]: Add endianess to valprint routines Content-Type: multipart/mixed; boundary="------------080507000205060103060407" Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2008-05/txt/msg00551.txt.bz2 This is a multi-part message in MIME format. --------------080507000205060103060407 Content-Type: text/plain; charset=ISO-8859-15; format=flowed Content-Transfer-Encoding: 7bit Content-length: 1227 Hi, this patch adds a new endianess parameter to valprint routines print_hex_chars, print_octal_chars, print_decimal_chars, print_binary_chars and print_char_chars. Those routines base upon endianess which they currently get via gdbarch_byte_order. I temporarely introduce gdbarch_byte_order in the two callers "print_scalar_formatted" and "val_print_type_code_int". I'll come up with some more patches to improve printing routines in the near future. Then those current_gdbarch's will disappear. Tested on x86_64 without regression. Ok to commit ? ChangeLog: * valprint.c (print_hex_chars, print_octal_chars, print_decimal_chars, print_binary_chars, print_char_chars): Add endianess parameter and replace gdbarch_byte_order. (val_print_type_code_int): Introduce gdbarch_byte_order to get at the endianness. Update call to print_hex_chars. * valprint.h (print_hex_chars, print_octal_chars, print_decimal_chars, print_binary_chars, print_char_chars): Add endianess parameter. * printcmd.c (print_scalar_formatted): Introduce gdbarch_byte_order to get at the endianness. Update print_*_char calls to use endianness. Regards, Markus -- Markus Deuling GNU Toolchain for Linux on Cell BE deuling@de.ibm.com --------------080507000205060103060407 Content-Type: text/plain; name="diff-vprint-endian" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="diff-vprint-endian" Content-length: 5971 diff -urpN src/gdb/printcmd.c dev/gdb/printcmd.c --- src/gdb/printcmd.c 2008-05-09 11:34:55.000000000 +0200 +++ dev/gdb/printcmd.c 2008-05-16 11:32:10.000000000 +0200 @@ -322,6 +322,7 @@ print_scalar_formatted (const void *vala { LONGEST val_long = 0; unsigned int len = TYPE_LENGTH (type); + enum bfd_endian endianness = gdbarch_byte_order (current_gdbarch); /* If we get here with a string format, try again without it. Go all the way back to the language printers, which may call us @@ -340,20 +341,20 @@ print_scalar_formatted (const void *vala switch (format) { case 'o': - print_octal_chars (stream, valaddr, len); + print_octal_chars (stream, valaddr, len, endianness); return; case 'u': case 'd': - print_decimal_chars (stream, valaddr, len); + print_decimal_chars (stream, valaddr, len, endianness); return; case 't': - print_binary_chars (stream, valaddr, len); + print_binary_chars (stream, valaddr, len, endianness); return; case 'x': - print_hex_chars (stream, valaddr, len); + print_hex_chars (stream, valaddr, len, endianness); return; case 'c': - print_char_chars (stream, valaddr, len); + print_char_chars (stream, valaddr, len, endianness); return; default: break; diff -urpN src/gdb/valprint.c dev/gdb/valprint.c --- src/gdb/valprint.c 2008-05-09 11:34:57.000000000 +0200 +++ dev/gdb/valprint.c 2008-05-16 11:30:49.000000000 +0200 @@ -313,6 +313,7 @@ void val_print_type_code_int (struct type *type, const gdb_byte *valaddr, struct ui_file *stream) { + enum bfd_endian endianness = gdbarch_byte_order (current_gdbarch); if (TYPE_LENGTH (type) > sizeof (LONGEST)) { LONGEST val; @@ -330,7 +331,7 @@ val_print_type_code_int (struct type *ty complement (a reasonable assumption, I think) and do better than this. */ print_hex_chars (stream, (unsigned char *) valaddr, - TYPE_LENGTH (type)); + TYPE_LENGTH (type), endianness); } } else @@ -525,7 +526,7 @@ print_decimal_floating (const gdb_byte * void print_binary_chars (struct ui_file *stream, const gdb_byte *valaddr, - unsigned len) + unsigned len, enum bfd_endian endianness) { #define BITS_IN_BYTES 8 @@ -541,7 +542,7 @@ print_binary_chars (struct ui_file *stre /* FIXME: We should be not printing leading zeroes in most cases. */ - if (gdbarch_byte_order (current_gdbarch) == BFD_ENDIAN_BIG) + if (endianness == BFD_ENDIAN_BIG) { for (p = valaddr; p < valaddr + len; @@ -585,7 +586,7 @@ print_binary_chars (struct ui_file *stre */ void print_octal_chars (struct ui_file *stream, const gdb_byte *valaddr, - unsigned len) + unsigned len, enum bfd_endian endianness) { const gdb_byte *p; unsigned char octa1, octa2, octa3, carry; @@ -628,7 +629,7 @@ print_octal_chars (struct ui_file *strea carry = 0; fputs_filtered ("0", stream); - if (gdbarch_byte_order (current_gdbarch) == BFD_ENDIAN_BIG) + if (endianness == BFD_ENDIAN_BIG) { for (p = valaddr; p < valaddr + len; @@ -733,7 +734,7 @@ print_octal_chars (struct ui_file *strea */ void print_decimal_chars (struct ui_file *stream, const gdb_byte *valaddr, - unsigned len) + unsigned len, enum bfd_endian endianness) { #define TEN 10 #define TWO_TO_FOURTH 16 @@ -741,11 +742,11 @@ print_decimal_chars (struct ui_file *str #define CARRY_LEFT( x ) ((x) % TEN) #define SHIFT( x ) ((x) << 4) #define START_P \ - ((gdbarch_byte_order (current_gdbarch) == BFD_ENDIAN_BIG) ? valaddr : valaddr + len - 1) + ((endianness == BFD_ENDIAN_BIG) ? valaddr : valaddr + len - 1) #define NOT_END_P \ - ((gdbarch_byte_order (current_gdbarch) == BFD_ENDIAN_BIG) ? (p < valaddr + len) : (p >= valaddr)) + ((endianness == BFD_ENDIAN_BIG) ? (p < valaddr + len) : (p >= valaddr)) #define NEXT_P \ - ((gdbarch_byte_order (current_gdbarch) == BFD_ENDIAN_BIG) ? p++ : p-- ) + ((endianness == BFD_ENDIAN_BIG) ? p++ : p-- ) #define LOW_NIBBLE( x ) ( (x) & 0x00F) #define HIGH_NIBBLE( x ) (((x) & 0x0F0) >> 4) @@ -868,14 +869,14 @@ print_decimal_chars (struct ui_file *str void print_hex_chars (struct ui_file *stream, const gdb_byte *valaddr, - unsigned len) + unsigned len, enum bfd_endian endianness) { const gdb_byte *p; /* FIXME: We should be not printing leading zeroes in most cases. */ fputs_filtered ("0x", stream); - if (gdbarch_byte_order (current_gdbarch) == BFD_ENDIAN_BIG) + if (endianness == BFD_ENDIAN_BIG) { for (p = valaddr; p < valaddr + len; @@ -900,11 +901,11 @@ print_hex_chars (struct ui_file *stream, void print_char_chars (struct ui_file *stream, const gdb_byte *valaddr, - unsigned len) + unsigned len, enum bfd_endian endianness) { const gdb_byte *p; - if (gdbarch_byte_order (current_gdbarch) == BFD_ENDIAN_BIG) + if (endianness == BFD_ENDIAN_BIG) { p = valaddr; while (p < valaddr + len - 1 && *p == 0) diff -urpN src/gdb/valprint.h dev/gdb/valprint.h --- src/gdb/valprint.h 2008-01-01 23:53:13.000000000 +0100 +++ dev/gdb/valprint.h 2008-05-16 11:31:05.000000000 +0200 @@ -69,17 +69,17 @@ extern void val_print_type_code_flags (s struct ui_file *stream); extern void print_binary_chars (struct ui_file *, const gdb_byte *, - unsigned int); + unsigned int, enum bfd_endian); extern void print_octal_chars (struct ui_file *, const gdb_byte *, - unsigned int); + unsigned int, enum bfd_endian); extern void print_decimal_chars (struct ui_file *, const gdb_byte *, - unsigned int); + unsigned int, enum bfd_endian); extern void print_hex_chars (struct ui_file *, const gdb_byte *, - unsigned int); + unsigned int, enum bfd_endian); extern void print_char_chars (struct ui_file *, const gdb_byte *, - unsigned int); + unsigned int, enum bfd_endian); #endif --------------080507000205060103060407--