old-cross-binutils/gdb/testsuite
Pedro Alves ef0026f03b Fix PR gdb/15289 - "set remote hardware-watchpoint-limit" broken (zinteger commands)
This is a regression from 7.5, introduced/exposed by:
  http://sourceware.org/ml/gdb-patches/2012-07/msg00259.html

There are a series of issues with this code.

It does:

	unsigned int val = parse_and_eval_long (arg);
	^^^^^^^^^^^^

(unsigned, usually 32-bit) while parse_and_eval_long returns a LONGEST
(usually 64-bit), so we lose precision without noticing:

  (gdb) set remote hardware-watchpoint-limit 0x100000000
  (gdb) show remote hardware-watchpoint-limit 0x100000000
  The maximum number of target hardware watchpoints is 0.

While at it, print the invalid number with plongest, so the user sees
what GDB thought the number was:

  (gdb) set remote hardware-watchpoint-limit 0x100000000
  integer 4294967296 out of range

So with "set remote hardware-watchpoint-limit -1", val ends converted
to 0xffffffff, which then fails the

	else if (val >= INT_MAX)
	  error (_("integer %u out of range"), val);

test.

Looking at that INT_MAX check, we forbid INT_MAX itself, but we
shouldn't, as that does fit in 'int' -- we want to forbid values
_greater_ than INT_MAX (and less than INT_MIN, while at it):

  (gdb) set remote hardware-watchpoint-limit 2147483647
  integer 2147483647 out of range

The same problem is in the new var_zuinteger_unlimited code, which
also uses "int" for variable.

Also, when printing a 'signed int', we should use %d, not %u.

This adds a couple regression tests.  Not completely thorough in checking
all kinds of invalid input; I'm saving more exaustive testing around
zXXinteger commands for something like new test-assisting commands
like "maint test cmd-zinteger -1", where testing would focus on the
command types, and thus be independent of particular user commands of
particular GDB features.

Tested on x86_64 Fedora 17.

gdb/
2013-03-20  Pedro Alves  <palves@redhat.com>

	PR gdb/15289

	* cli/cli-setshow.c (do_set_command)
	<var_uinteger, var_zuinteger>: Use LONGEST for variable holding
	the result of parsing the command argument.  Throw error if the
	value is greater than UINT_MAX.  Print the invalid value with
	plongest.
	<var_integer, var_zinteger>: Use LONGEST for variable holding the
	result of parsing the command argument.  Throw error if the value
	is greater than INT_MAX, not greater or equal.  Also throw error
	if the value is less than INT_MIN.  Print the invalid value with
	plongest.
	<var_zuinteger_unlimited>: Throw error if the value is greater
	than INT_MAX, not greater or equal.
	(do_show_command) <var_integer, var_zinteger,
	var_zuinteger_unlimited>: Use %d for printing int, not %u.

gdb/testsuite/
2013-03-20  Pedro Alves  <palves@redhat.com>

	PR gdb/15289

	* gdb.base/remote.exp: Test
	"set remote hardware-watchpoint-limit -1",
	"set remote hardware-breakpoint-limit -1",
	"set remote hardware-watchpoint-limit 2147483647" and
	"set remote hardware-breakpoint-limit 2147483647".
2013-03-20 18:58:16 +00:00
..
boards * boards/dwarf4-gdb-index.exp: Use any existing CC_FOR_TARGET, 2013-01-17 20:17:15 +00:00
config gdb/testsuite/ 2013-03-14 13:34:06 +00:00
gdb.ada gdb/testsuite/ 2013-03-14 13:34:06 +00:00
gdb.arch gdb/testsuite/ 2013-03-14 13:34:06 +00:00
gdb.asm Update years in copyright notice for the GDB files. 2013-01-01 06:33:28 +00:00
gdb.base Fix PR gdb/15289 - "set remote hardware-watchpoint-limit" broken (zinteger commands) 2013-03-20 18:58:16 +00:00
gdb.btrace Add tests for the new record-btrace target. 2013-03-11 08:59:00 +00:00
gdb.cell Update years in copyright notice for the GDB files. 2013-01-01 06:33:28 +00:00
gdb.cp PR c++/15116: 2013-03-15 17:10:45 +00:00
gdb.disasm Update years in copyright notice for the GDB files. 2013-01-01 06:33:28 +00:00
gdb.dwarf2 gdb/testsuite/ 2013-03-15 01:41:29 +00:00
gdb.fortran Update years in copyright notice for the GDB files. 2013-01-01 06:41:43 +00:00
gdb.gdb gdb/ 2013-02-03 15:54:18 +00:00
gdb.go Update years in copyright notice for the GDB files. 2013-01-01 06:41:43 +00:00
gdb.hp gdb/testsuite/ 2013-03-14 13:34:06 +00:00
gdb.java Update years in copyright notice for the GDB files. 2013-01-01 06:41:43 +00:00
gdb.linespec gdb/ 2013-03-04 19:30:28 +00:00
gdb.mi gdb/testsuite/ 2013-03-15 01:41:29 +00:00
gdb.modula2 Update years in copyright notice for the GDB files. 2013-01-01 06:41:43 +00:00
gdb.multi Update years in copyright notice for the GDB files. 2013-01-01 06:41:43 +00:00
gdb.objc Update years in copyright notice for the GDB files. 2013-01-01 06:41:43 +00:00
gdb.opencl Update years in copyright notice for the GDB files. 2013-01-01 06:41:43 +00:00
gdb.opt Update years in copyright notice for the GDB files. 2013-01-01 06:41:43 +00:00
gdb.pascal Update years in copyright notice for the GDB files. 2013-01-01 06:41:43 +00:00
gdb.python gdb/testsuite/ 2013-03-14 13:34:06 +00:00
gdb.reverse Update years in copyright notice for the GDB files. 2013-01-01 06:41:43 +00:00
gdb.server From: Sanimir Agovic <sanimir.agovic@intel.com> 2013-02-12 15:03:12 +00:00
gdb.stabs Update years in copyright notice for the GDB files. 2013-01-01 06:41:43 +00:00
gdb.threads gdb/testsuite/ 2013-03-15 01:41:29 +00:00
gdb.trace tfile.exp: Test printing a non-const global that is not covered by the trace frame; test disassembling. 2013-03-20 11:28:55 +00:00
gdb.xml Update years in copyright notice for the GDB files. 2013-01-01 06:41:43 +00:00
lib gdb/testsuite/ 2013-03-14 13:34:06 +00:00
aclocal.m4
ChangeLog Fix PR gdb/15289 - "set remote hardware-watchpoint-limit" broken (zinteger commands) 2013-03-20 18:58:16 +00:00
configure Add tests for the new record-btrace target. 2013-03-11 08:59:00 +00:00
configure.ac Add tests for the new record-btrace target. 2013-03-11 08:59:00 +00:00
dg-extract-results.sh Merge dg-extract-results.sh from gcc upstream (svn 195224). 2013-01-17 14:31:11 +00:00
Makefile.in Add tests for the new record-btrace target. 2013-03-11 08:59:00 +00:00
TODO