aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJim Kingdon <jkingdon@engr.sgi.com>1994-02-18 17:47:43 +0000
committerJim Kingdon <jkingdon@engr.sgi.com>1994-02-18 17:47:43 +0000
commitfb0f4231333cbdf9c8d3add1bada84686eddafbe (patch)
treef3b3fcafd2ea8c14b1a251cdc7ddc484cac2b05a
parent79aab093bbf68130784e0351718ca30e574f0810 (diff)
downloadgdb-fb0f4231333cbdf9c8d3add1bada84686eddafbe.zip
gdb-fb0f4231333cbdf9c8d3add1bada84686eddafbe.tar.gz
gdb-fb0f4231333cbdf9c8d3add1bada84686eddafbe.tar.bz2
* defs.h, valprint.c: Make longest_to_int a function not a macro.
Only test against INT_MIN if a LONGEST is bigger than an int.
-rw-r--r--gdb/ChangeLog3
-rw-r--r--gdb/defs.h3
-rw-r--r--gdb/valprint.c29
3 files changed, 31 insertions, 4 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 610bdcd..4dac525 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,8 @@
Fri Feb 18 08:26:29 1994 Jim Kingdon (kingdon@lioth.cygnus.com)
+ * defs.h, valprint.c: Make longest_to_int a function not a macro.
+ Only test against INT_MIN if a LONGEST is bigger than an int.
+
* README: Change GhostScript to Ghostscript.
Fri Feb 18 07:30:55 1994 Jim Kingdon (kingdon@cygnus.com)
diff --git a/gdb/defs.h b/gdb/defs.h
index 0675aaf..1a49d8c 100644
--- a/gdb/defs.h
+++ b/gdb/defs.h
@@ -556,8 +556,7 @@ enum val_prettyprint
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. */
-#define longest_to_int(x) (((x) > INT_MAX || (x) < INT_MIN) \
- ? (error ("Value out of range."),0) : (int) (x))
+extern int longest_to_int PARAMS ((LONGEST));
/* Assorted functions we can declare, now that const and volatile are
defined. */
diff --git a/gdb/valprint.c b/gdb/valprint.c
index a3242fd..c5bd039 100644
--- a/gdb/valprint.c
+++ b/gdb/valprint.c
@@ -277,9 +277,12 @@ val_print_type_code_int (type, valaddr, stream)
#endif
if (len <= sizeof (LONGEST))
{
- /* We can print it in decimal. */
+ /* The most significant bytes are zero, so we can just get
+ the least significant sizeof (LONGEST) bytes and print it
+ in decimal. */
print_longest (stream, 'u', 0,
- unpack_long (BUILTIN_TYPE_LONGEST, first_addr));
+ extract_unsigned_integer (first_addr,
+ sizeof (LONGEST)));
}
else
{
@@ -424,6 +427,28 @@ print_longest (stream, format, use_local, val_long)
#endif /* !PRINTF_HAS_LONG_LONG */
}
+/* This used to be a macro, but I don't think it is called often enough
+ to merit such treatment. */
+/* 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. */
+
+int
+longest_to_int (arg)
+ LONGEST arg;
+{
+
+ /* This check is in case a system header has botched the
+ definition of INT_MIN, like on BSDI. */
+ if (sizeof (LONGEST) <= sizeof (int))
+ return arg;
+
+ if (arg > INT_MAX || arg < INT_MIN)
+ error ("Value out of range.");
+
+ return arg;
+}
+
/* Print a floating point value of type TYPE, pointed to in GDB by VALADDR,
on STREAM. */