From: Tom Tromey <tom@tromey.com>
To: gdb-patches@sourceware.org
Cc: Tom Tromey <tom@tromey.com>
Subject: [RFA 2/2] Remove BITS_IN_BYTES define
Date: Thu, 13 Jul 2017 12:34:00 -0000 [thread overview]
Message-ID: <20170713123400.28917-3-tom@tromey.com> (raw)
In-Reply-To: <20170713123400.28917-1-tom@tromey.com>
While working on the previous patch, I noticed that BITS_IN_BYTES can be
replaced by HOST_CHAR_BIT, which is used more widely in gdb.
2017-07-13 Tom Tromey <tom@tromey.com>
* valprint.c (print_octal_chars): Use HOST_CHAR_BIT.
(print_binary_chars): Likewise.
(BITS_IN_BYTES): Remove.
---
gdb/ChangeLog | 6 ++++++
gdb/printcmd.c | 4 ++--
gdb/valprint.c | 9 +++------
3 files changed, 11 insertions(+), 8 deletions(-)
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 5ac5bab..bc68b67 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,11 @@
2017-07-13 Tom Tromey <tom@tromey.com>
+ * valprint.c (print_octal_chars): Use HOST_CHAR_BIT.
+ (print_binary_chars): Likewise.
+ (BITS_IN_BYTES): Remove.
+
+2017-07-13 Tom Tromey <tom@tromey.com>
+
PR gdb/21675
* valprint.c (LOW_ZERO): Change value to 034.
(print_octal_chars): Add static_asserts for octal constants.
diff --git a/gdb/printcmd.c b/gdb/printcmd.c
index cd615ec..179c22c 100644
--- a/gdb/printcmd.c
+++ b/gdb/printcmd.c
@@ -432,8 +432,8 @@ print_scalar_formatted (const gdb_byte *valaddr, struct type *type,
case 'd':
case 'u':
{
- bool is_signed = options->format != 'u' || !TYPE_UNSIGNED (type);
- print_decimal_chars (stream, valaddr, len, is_signed, byte_order);
+ bool is_unsigned = options->format == 'u' || TYPE_UNSIGNED (type);
+ print_decimal_chars (stream, valaddr, len, !is_unsigned, byte_order);
}
break;
case 0:
diff --git a/gdb/valprint.c b/gdb/valprint.c
index 9e216cf..eef99b1 100644
--- a/gdb/valprint.c
+++ b/gdb/valprint.c
@@ -1490,9 +1490,6 @@ void
print_binary_chars (struct ui_file *stream, const gdb_byte *valaddr,
unsigned len, enum bfd_endian byte_order, bool zero_pad)
{
-
-#define BITS_IN_BYTES 8
-
const gdb_byte *p;
unsigned int i;
int b;
@@ -1512,7 +1509,7 @@ print_binary_chars (struct ui_file *stream, const gdb_byte *valaddr,
/* Every byte has 8 binary characters; peel off
and print from the MSB end. */
- for (i = 0; i < (BITS_IN_BYTES * sizeof (*p)); i++)
+ for (i = 0; i < (HOST_CHAR_BIT * sizeof (*p)); i++)
{
if (*p & (mask >> i))
b = '1';
@@ -1532,7 +1529,7 @@ print_binary_chars (struct ui_file *stream, const gdb_byte *valaddr,
p >= valaddr;
p--)
{
- for (i = 0; i < (BITS_IN_BYTES * sizeof (*p)); i++)
+ for (i = 0; i < (HOST_CHAR_BIT * sizeof (*p)); i++)
{
if (*p & (mask >> i))
b = '1';
@@ -1612,7 +1609,7 @@ print_octal_chars (struct ui_file *stream, const gdb_byte *valaddr,
/* For 32 we start in cycle 2, with two bits and one bit carry;
for 64 in cycle in cycle 1, with one bit and a two bit carry. */
- cycle = (len * BITS_IN_BYTES) % BITS_IN_OCTAL;
+ cycle = (len * HOST_CHAR_BIT) % BITS_IN_OCTAL;
carry = 0;
fputs_filtered ("0", stream);
--
2.9.4
next parent reply other threads:[~2017-07-13 12:34 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20170713123400.28917-1-tom@tromey.com>
2017-07-13 12:34 ` Tom Tromey [this message]
2017-07-14 15:16 ` Pedro Alves
2017-07-14 16:15 ` Tom Tromey
2017-07-13 12:35 ` [RFA 1/2] Fix two regressions in scalar printing Tom Tromey
2017-07-14 14:56 ` Pedro Alves
2017-07-14 15:20 ` Eli Zaretskii
2017-07-14 16:50 ` Tom Tromey
2017-07-14 17:25 ` Pedro Alves
2017-07-31 22:03 ` Tom Tromey
2017-08-14 14:02 ` Pedro Alves
2017-08-14 15:22 ` Tom Tromey
2017-08-14 15:43 ` Tom Tromey
2017-08-14 15:52 ` Pedro Alves
2017-08-17 2:24 ` Tom Tromey
2017-12-10 14:15 ` Regression on 32-bit: gdb.guile/scm-ports.exp [Re: [RFA 1/2] Fix two regressions in scalar printing] Jan Kratochvil
2017-07-14 15:19 ` [RFA 1/2] Fix two regressions in scalar printing Jonah Graham
2017-08-25 16:54 ` Thomas Preudhomme
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20170713123400.28917-3-tom@tromey.com \
--to=tom@tromey.com \
--cc=gdb-patches@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox