From: "Maciej W. Rozycki" <macro@embecosm.com>
To: gdb-patches@sourceware.org
Cc: Andrew Burgess <aburgess@redhat.com>, Tom Tromey <tom@tromey.com>,
Richard Bunt <Richard.Bunt@arm.com>
Subject: [PATCH v4 1/6] GDB: Switch to using C++ standard integer type limits
Date: Fri, 10 Feb 2023 14:19:04 +0000 (GMT) [thread overview]
Message-ID: <alpine.DEB.2.20.2302092251100.7841@tpp.orcam.me.uk> (raw)
In-Reply-To: <alpine.DEB.2.20.2302092205020.7841@tpp.orcam.me.uk>
Use <climits> instead of <limits.h> and ditch local fallback definitions
for minimum and maximum value macros provided by C++11. Add LONGEST_MAX
and LONGEST_MIN definitions.
---
New change in v4.
---
gdb/defs.h | 33 +--------------------------------
gdb/gnu-nat.c | 1 -
gdbsupport/common-types.h | 8 +++++++-
3 files changed, 8 insertions(+), 34 deletions(-)
gdb-climits.diff
Index: src/gdb/defs.h
===================================================================
--- src.orig/gdb/defs.h
+++ src/gdb/defs.h
@@ -37,7 +37,7 @@
#include "bfd.h"
#include <sys/types.h>
-#include <limits.h>
+#include <climits>
/* The libdecnumber library, on which GDB depends, includes a header file
called gstdint.h instead of relying directly on stdint.h. GDB, on the
@@ -446,37 +446,6 @@ enum val_prettyformat
# include "fopen-bin.h"
#endif
-/* Defaults for system-wide constants (if not defined by xm.h, we fake it).
- FIXME: Assumes 2's complement arithmetic. */
-
-#if !defined (UINT_MAX)
-#define UINT_MAX ((unsigned int)(~0)) /* 0xFFFFFFFF for 32-bits */
-#endif
-
-#if !defined (INT_MAX)
-#define INT_MAX ((int)(UINT_MAX >> 1)) /* 0x7FFFFFFF for 32-bits */
-#endif
-
-#if !defined (INT_MIN)
-#define INT_MIN ((int)((int) ~0 ^ INT_MAX)) /* 0x80000000 for 32-bits */
-#endif
-
-#if !defined (ULONG_MAX)
-#define ULONG_MAX ((unsigned long)(~0L)) /* 0xFFFFFFFF for 32-bits */
-#endif
-
-#if !defined (LONG_MAX)
-#define LONG_MAX ((long)(ULONG_MAX >> 1)) /* 0x7FFFFFFF for 32-bits */
-#endif
-
-#if !defined (ULONGEST_MAX)
-#define ULONGEST_MAX (~(ULONGEST)0) /* 0xFFFFFFFFFFFFFFFF for 64-bits */
-#endif
-
-#if !defined (LONGEST_MAX) /* 0x7FFFFFFFFFFFFFFF for 64-bits */
-#define LONGEST_MAX ((LONGEST)(ULONGEST_MAX >> 1))
-#endif
-
/* * Convert a LONGEST to an int. This is used in contexts (e.g. number of
arguments to a function, number in a value history, register number, etc.)
where the value must not be larger than can fit in an int. */
Index: src/gdb/gnu-nat.c
===================================================================
--- src.orig/gdb/gnu-nat.c
+++ src/gdb/gnu-nat.c
@@ -52,7 +52,6 @@ extern "C"
#include "defs.h"
#include <ctype.h>
-#include <limits.h>
#include <setjmp.h>
#include <signal.h>
#include <sys/ptrace.h>
Index: src/gdbsupport/common-types.h
===================================================================
--- src.orig/gdbsupport/common-types.h
+++ src/gdbsupport/common-types.h
@@ -36,9 +36,15 @@ typedef uint64_t ULONGEST;
/* * The largest CORE_ADDR value. */
#define CORE_ADDR_MAX (~(CORE_ADDR) 0)
-/* * The largest ULONGEST value. */
+/* * The largest ULONGEST value, 0xFFFFFFFFFFFFFFFF for 64-bits. */
#define ULONGEST_MAX (~(ULONGEST) 0)
+/* * The largest LONGEST value, 0x7FFFFFFFFFFFFFFF for 64-bits. */
+#define LONGEST_MAX ((LONGEST) (ULONGEST_MAX >> 1))
+
+/* * The smallest LONGEST value, 0x8000000000000000 for 64-bits. */
+#define LONGEST_MIN ((LONGEST) (~(LONGEST) 0 ^ LONGEST_MAX))
+
enum tribool { TRIBOOL_UNKNOWN = -1, TRIBOOL_FALSE = 0, TRIBOOL_TRUE = 1 };
#endif /* COMMON_COMMON_TYPES_H */
next prev parent reply other threads:[~2023-02-10 14:19 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-02-10 14:18 [PATCH v4 0/6] gdb: introduce limited array lengths while printing values Maciej W. Rozycki
2023-02-10 14:19 ` Maciej W. Rozycki [this message]
2023-02-10 21:13 ` [PATCH v4 1/6] GDB: Switch to using C++ standard integer type limits Tom Tromey
2023-02-10 14:19 ` [PATCH v4 2/6] GDB: Ignore `max-value-size' setting with value history accesses Maciej W. Rozycki
2023-02-10 14:19 ` [PATCH v4 3/6] GDB: Fix the mess with value byte/bit range types Maciej W. Rozycki
2023-02-10 14:19 ` [PATCH v4 4/6] GDB: Only make data actually retrieved into value history available Maciej W. Rozycki
2023-02-10 21:16 ` Tom Tromey
2023-02-10 14:19 ` [PATCH v4 5/6] GDB/testsuite: Add `-nonl' option to `gdb_test' Maciej W. Rozycki
2023-02-10 14:19 ` [PATCH v4 6/6] GDB: Introduce limited array lengths while printing values Maciej W. Rozycki
2023-02-13 14:45 ` Simon Marchi
2023-02-14 19:20 ` Maciej W. Rozycki
2023-02-23 21:16 ` Maciej W. Rozycki
2023-02-10 21:17 ` [PATCH v4 0/6] gdb: introduce " Tom Tromey
2023-02-10 23:50 ` Maciej W. Rozycki
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=alpine.DEB.2.20.2302092251100.7841@tpp.orcam.me.uk \
--to=macro@embecosm.com \
--cc=Richard.Bunt@arm.com \
--cc=aburgess@redhat.com \
--cc=gdb-patches@sourceware.org \
--cc=tom@tromey.com \
/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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).