diff options
author | Patrick Palka <patrick@parcs.ath.cx> | 2015-06-23 10:01:38 -0400 |
---|---|---|
committer | Patrick Palka <patrick@parcs.ath.cx> | 2015-06-23 16:32:36 -0400 |
commit | 0fc26cafacfff9f53d898bb73495b384b80d6d31 (patch) | |
tree | f4185135344cfd1601ae3a57e9136b909464eb6d | |
parent | e750549018d67d545bdaf90cc058f97b954600cc (diff) | |
download | binutils-0fc26cafacfff9f53d898bb73495b384b80d6d31.zip binutils-0fc26cafacfff9f53d898bb73495b384b80d6d31.tar.gz binutils-0fc26cafacfff9f53d898bb73495b384b80d6d31.tar.bz2 |
Fix GDBHISTSIZE test failure on i686
The test
test_histsize_history_setting "99999999999999999999999999999999999" "unlimited"
was failing on i686 because the condition in init_history() for
determining whether to map a large GDBHISTSIZE value to infinity was
long var = strtol (tmpenv);
if (var > INT_MAX)
history_size = unlimited;
but this condition is never true on i686 because INT_MAX == LONG_MAX.
So in order to properly map large out-of-range values of GDBHISTSIZE to
infinity on targets where LONG_MAX > INT_MAX as well as on i686, we have
to instead change the above condition to
if (var > INT_MAX
|| (var == INT_MAX && errno == ERANGE))
history_size = unlimited;
gdb/ChangeLog:
* top.c (init_history): Look at errno after calling strtol to
properly map large GDBHISTSIZE values to infinity.
-rw-r--r-- | gdb/ChangeLog | 5 | ||||
-rw-r--r-- | gdb/top.c | 10 |
2 files changed, 14 insertions, 1 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 5690c2a..99ff2fb 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,8 @@ +2015-06-23 Patrick Palka <patrick@parcs.ath.cx> + + * top.c (init_history): Look at errno after calling strtol to + properly map large GDBHISTSIZE values to infinity. + 2015-06-23 Doug Evans <dje@google.com> * inferior.h (struct inferior_suspend_state): Delete, unused. @@ -1685,10 +1685,13 @@ init_history (void) if (tmpenv) { long var; + int saved_errno; char *endptr; tmpenv = skip_spaces (tmpenv); + errno = 0; var = strtol (tmpenv, &endptr, 10); + saved_errno = errno; endptr = skip_spaces (endptr); /* If GDBHISTSIZE is non-numeric then ignore it. If GDBHISTSIZE is the @@ -1700,7 +1703,12 @@ init_history (void) ; else if (*tmpenv == '\0' || var < 0 - || var > INT_MAX) + || var > INT_MAX + /* On targets where INT_MAX == LONG_MAX, we have to look at + errno after calling strtol to distinguish between a value that + is exactly INT_MAX and an overflowing value that was clamped + to INT_MAX. */ + || (var == INT_MAX && saved_errno == ERANGE)) history_size_setshow_var = -1; else history_size_setshow_var = var; |