Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* pr9164 patch
@ 2010-02-08 23:17 Chris Moller
  2010-02-08 23:34 ` Daniel Jacobowitz
  2010-02-08 23:38 ` Pedro Alves
  0 siblings, 2 replies; 6+ messages in thread
From: Chris Moller @ 2010-02-08 23:17 UTC (permalink / raw)
  To: gdb-patches

[-- Attachment #1: Type: text/plain, Size: 311 bytes --]

I was rooting around in the gdb c++ bug list a bit ago and came across 
this one: "sizeof should have unsigned type in print expressions."  
Assuming that, as in C/C++, size_t is typedeffed from unsigned int, the 
fix is a one-line patch in c-exp.y, attached.  If that assumption is 
wrong, well, never mind...

[-- Attachment #2: pr9164.patch --]
[-- Type: text/plain, Size: 4365 bytes --]

? testsuite/gdb.base/sizeof
Index: ChangeLog
===================================================================
RCS file: /cvs/src/src/gdb/ChangeLog,v
retrieving revision 1.11335
diff -u -r1.11335 ChangeLog
--- ChangeLog	8 Feb 2010 18:27:53 -0000	1.11335
+++ ChangeLog	8 Feb 2010 23:02:36 -0000
@@ -1,4 +1,12 @@
-Mon Feb  8 13:17:10 2010  Chris Moller  <moller@mollerware.com>
+2010-02-08  Chris Moller  <cmoller@redhat.com>
+
+	PR gdb/9164
+	* c-exp.y (SIZEOF '(' type ')'): Replaced builtin_int with
+	builtin_unsigned_int to have gdb "sizeof" return "unsigned int."
+	(This seems to be consistent the C/C++ standard of returning
+	size_t from sizeof, where size_t is synonymous with "unsigned int.")
+
+2010-02-08  Chris Moller  <cmoller@redhat.com>
 
 	PR gdb/10728
 	* valarith.c (value_ptrdiff): Added a test for a zero type length,
Index: c-exp.y
===================================================================
RCS file: /cvs/src/src/gdb/c-exp.y,v
retrieving revision 1.69
diff -u -r1.69 c-exp.y
--- c-exp.y	18 Jan 2010 20:54:33 -0000	1.69
+++ c-exp.y	8 Feb 2010 23:02:38 -0000
@@ -586,7 +586,7 @@
 
 exp	:	SIZEOF '(' type ')'	%prec UNARY
 			{ write_exp_elt_opcode (OP_LONG);
-			  write_exp_elt_type (parse_type->builtin_int);
+			  write_exp_elt_type (parse_type->builtin_unsigned_int);
 			  CHECK_TYPEDEF ($3);
 			  write_exp_elt_longcst ((LONGEST) TYPE_LENGTH ($3));
 			  write_exp_elt_opcode (OP_LONG); }
Index: testsuite/ChangeLog
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/ChangeLog,v
retrieving revision 1.2126
diff -u -r1.2126 ChangeLog
--- testsuite/ChangeLog	8 Feb 2010 18:27:53 -0000	1.2126
+++ testsuite/ChangeLog	8 Feb 2010 23:02:54 -0000
@@ -1,4 +1,10 @@
-Mon Feb  8 13:18:22 2010  Chris Moller  <moller@mollerware.com>
+2010-02-08  Chris Moller  <cmoller@redhat.com>
+
+	PR gdb/9164
+	* gdb.base/pr9164.exp: New file.
+	* gdb.base/Makefile.in (EXECUTABLES): Add pr9164.
+
+2010-02-08  Chris Moller  <cmoller@redhat.com>
 
 	PR gdb/10728
 	* gdb.cp/pr10728-x.h: New file.
@@ -6,8 +12,7 @@
 	* gdb.cp/pr10728-y.cc: New file.
 	* gdb.cp/pr10728.exp: New file.
 	* gdb.cp/Makefile.in (EXECUTABLES): Add pr10728
-
-Mon Feb  8 12:54:54 2010  Chris Moller  <moller@mollerware.com>
+2010-02-08  Chris Moller  <cmoller@redhat.com>
 
 	PR gdb/9067
 	* gdb.cp/pr9067.exp:  New
Index: testsuite/gdb.base/Makefile.in
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.base/Makefile.in,v
retrieving revision 1.5
diff -u -r1.5 Makefile.in
--- testsuite/gdb.base/Makefile.in	15 Sep 2009 03:30:08 -0000	1.5
+++ testsuite/gdb.base/Makefile.in	8 Feb 2010 23:02:55 -0000
@@ -12,7 +12,8 @@
 	scope section_command setshow setvar shmain sigall signals \
 	solib solib_sl so-impl-ld so-indr-cl \
 	step-line step-test structs structs2 \
-	twice-tmp varargs vforked-prog watchpoint whatis catch-syscall
+	twice-tmp varargs vforked-prog watchpoint whatis catch-syscall \
+	pr9164
 
 MISCELLANEOUS = coremmap.data ../foobar.baz \
 	shr1.sl shr2.sl solib_sl.sl solib1.sl solib2.sl
Index: testsuite/gdb.base/pr9164.exp
===================================================================
RCS file: testsuite/gdb.base/pr9164.exp
diff -N testsuite/gdb.base/pr9164.exp
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ testsuite/gdb.base/pr9164.exp	8 Feb 2010 23:02:55 -0000
@@ -0,0 +1,34 @@
+# This testcase is part of GDB, the GNU debugger.
+
+# Copyright 2010
+# Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+if $tracelevel {
+    strace $tracelevel
+}
+
+set prms_id 0
+set bug_id 0
+
+gdb_exit
+gdb_start
+
+gdb_test "p -4u" ".*4294967292.*"
+gdb_test "p -sizeof(int)" ".*4294967292.*"
+
+gdb_exit
+return 0
+

[-- Attachment #3: pr9164-check.diff --]
[-- Type: text/plain, Size: 3106 bytes --]

--- gdb-virgin.sum	2010-02-08 18:09:17.076039923 -0500
+++ gdb-patched.sum	2010-02-08 17:57:58.351164638 -0500
@@ -1,4 +1,4 @@
-Test Run By moller on Mon Feb  8 17:59:40 2010
+Test Run By moller on Mon Feb  8 17:49:04 2010
 Native configuration is i686-pc-linux-gnu
 
 		=== gdb tests ===
@@ -2696,9 +2696,9 @@
 PASS: gdb.base/constvars.exp: ptype crass
 PASS: gdb.base/constvars.exp: ptype crisp
 Running ../../../src/gdb/testsuite/gdb.base/corefile.exp ...
-PASS: gdb.base/corefile.exp: args: -core=coremaker.core (with bad program name)
-PASS: gdb.base/corefile.exp: args: execfile -core=coremaker.core (with bad program name)
-PASS: gdb.base/corefile.exp: core-file command (with bad program name)
+PASS: gdb.base/corefile.exp: args: -core=coremaker.core
+PASS: gdb.base/corefile.exp: args: execfile -core=coremaker.core
+PASS: gdb.base/corefile.exp: core-file command
 PASS: gdb.base/corefile.exp: print coremaker_data
 PASS: gdb.base/corefile.exp: print coremaker_bss
 PASS: gdb.base/corefile.exp: print coremaker_ro
@@ -5644,8 +5644,11 @@
 PASS: gdb.base/pr11022.exp: breakpoint hit 2
 PASS: gdb.base/pr11022.exp: set var x = 1
 PASS: gdb.base/pr11022.exp: watchpoint hit 2
+Running ../../../src/gdb/testsuite/gdb.base/pr9164.exp ...
+PASS: gdb.base/pr9164.exp: p -4u
+PASS: gdb.base/pr9164.exp: p -sizeof(int)
 Running ../../../src/gdb/testsuite/gdb.base/prelink.exp ...
-PASS: gdb.base/prelink.exp: prelink
+FAIL: gdb.base/prelink.exp: prelink
 Running ../../../src/gdb/testsuite/gdb.base/printcmds.exp ...
 PASS: gdb.base/printcmds.exp: print $pc
 PASS: gdb.base/printcmds.exp: print "abc"
@@ -12595,7 +12598,7 @@
 PASS: gdb.mi/mi-nsmoribund.exp: resume all, thread specific breakpoint
 PASS: gdb.mi/mi-nsmoribund.exp: hit thread specific breakpoint
 PASS: gdb.mi/mi-nsmoribund.exp: thread state: all running except the breakpoint thread
-FAIL: gdb.mi/mi-nsmoribund.exp: unexpected stop
+PASS: gdb.mi/mi-nsmoribund.exp: resume all, program exited normally
 Running ../../../src/gdb/testsuite/gdb.mi/mi-nsthrexec.exp ...
 PASS: gdb.mi/mi-nsthrexec.exp: successfully compiled posix threads test case
 PASS: gdb.mi/mi-nsthrexec.exp: breakpoint at main
@@ -14746,7 +14749,7 @@
 PASS: gdb.server/server-mon.exp: monitor set remote-debug 0
 Running ../../../src/gdb/testsuite/gdb.server/server-run.exp ...
 PASS: gdb.server/server-run.exp: loaded dynamic linker
-PASS: gdb.server/server-run.exp: continue to main
+FAIL: gdb.server/server-run.exp: continue to main
 Running ../../../src/gdb/testsuite/gdb.stabs/exclfwd.exp ...
 PASS: gdb.stabs/exclfwd.exp: ptype v1
 PASS: gdb.stabs/exclfwd.exp: ptype v2
@@ -15501,7 +15504,7 @@
 PASS: gdb.threads/watchthreads.exp: successfully compiled posix threads test case
 PASS: gdb.threads/watchthreads.exp: watch args[0]
 PASS: gdb.threads/watchthreads.exp: watch args[1]
-PASS: gdb.threads/watchthreads.exp: disable 3
+PASS: gdb.threads/watchthreads.exp: disable 2
 PASS: gdb.threads/watchthreads.exp: threaded watch loop
 PASS: gdb.threads/watchthreads.exp: first watchpoint on args[0] hit
 PASS: gdb.threads/watchthreads.exp: first watchpoint on args[1] hit

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: pr9164 patch
  2010-02-08 23:17 pr9164 patch Chris Moller
@ 2010-02-08 23:34 ` Daniel Jacobowitz
  2010-02-09  1:23   ` Chris Moller
  2010-02-08 23:38 ` Pedro Alves
  1 sibling, 1 reply; 6+ messages in thread
From: Daniel Jacobowitz @ 2010-02-08 23:34 UTC (permalink / raw)
  To: Chris Moller; +Cc: gdb-patches

On Mon, Feb 08, 2010 at 06:17:46PM -0500, Chris Moller wrote:
> I was rooting around in the gdb c++ bug list a bit ago and came
> across this one: "sizeof should have unsigned type in print
> expressions."  Assuming that, as in C/C++, size_t is typedeffed from
> unsigned int, the fix is a one-line patch in c-exp.y, attached.  If
> that assumption is wrong, well, never mind...

Try it on x86_64 - size_t is platform dependent, and it's often
unsigned long.

-- 
Daniel Jacobowitz
CodeSourcery


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: pr9164 patch
  2010-02-08 23:17 pr9164 patch Chris Moller
  2010-02-08 23:34 ` Daniel Jacobowitz
@ 2010-02-08 23:38 ` Pedro Alves
  1 sibling, 0 replies; 6+ messages in thread
From: Pedro Alves @ 2010-02-08 23:38 UTC (permalink / raw)
  To: gdb-patches; +Cc: Chris Moller

On Monday 08 February 2010 23:17:46, Chris Moller wrote:
> I was rooting around in the gdb c++ bug list a bit ago and came across 
> this one: "sizeof should have unsigned type in print expressions."  
> Assuming that, as in C/C++, size_t is typedeffed from unsigned int, the 
> fix is a one-line patch in c-exp.y, attached.  If that assumption is 
> wrong, well, never mind...
> 

Previous attempt and discussion:

 http://sourceware.org/ml/gdb-patches/2009-01/msg00014.html

-- 
Pedro Alves


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: pr9164 patch
  2010-02-08 23:34 ` Daniel Jacobowitz
@ 2010-02-09  1:23   ` Chris Moller
  2010-02-09  2:18     ` Daniel Jacobowitz
  0 siblings, 1 reply; 6+ messages in thread
From: Chris Moller @ 2010-02-09  1:23 UTC (permalink / raw)
  To: gdb-patches

On 02/08/10 18:34, Daniel Jacobowitz wrote:
> On Mon, Feb 08, 2010 at 06:17:46PM -0500, Chris Moller wrote:
>    
>> I was rooting around in the gdb c++ bug list a bit ago and came
>> across this one: "sizeof should have unsigned type in print
>> expressions."  Assuming that, as in C/C++, size_t is typedeffed from
>> unsigned int, the fix is a one-line patch in c-exp.y, attached.  If
>> that assumption is wrong, well, never mind...
>>      
>
> Try it on x86_64 - size_t is platform dependent, and it's often
> unsigned long.
>    

I did--it's 4 bytes on both i386 and x86_64. I just don't know about 
non-intel archs.



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: pr9164 patch
  2010-02-09  1:23   ` Chris Moller
@ 2010-02-09  2:18     ` Daniel Jacobowitz
  2010-02-09  2:38       ` Chris Moller
  0 siblings, 1 reply; 6+ messages in thread
From: Daniel Jacobowitz @ 2010-02-09  2:18 UTC (permalink / raw)
  To: Chris Moller; +Cc: gdb-patches

On Mon, Feb 08, 2010 at 08:23:27PM -0500, Chris Moller wrote:
> I did--it's 4 bytes on both i386 and x86_64. I just don't know about
> non-intel archs.

No, it should be 8 bytes on x86_64.

(gdb) list x
1       #include <stdlib.h>
2
3       size_t x;
(gdb) ptype x
type = long unsigned int
(gdb) p sizeof(x)
$2 = 8

-- 
Daniel Jacobowitz
CodeSourcery


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: pr9164 patch
  2010-02-09  2:18     ` Daniel Jacobowitz
@ 2010-02-09  2:38       ` Chris Moller
  0 siblings, 0 replies; 6+ messages in thread
From: Chris Moller @ 2010-02-09  2:38 UTC (permalink / raw)
  To: gdb-patches

On 02/08/10 21:18, Daniel Jacobowitz wrote:
> On Mon, Feb 08, 2010 at 08:23:27PM -0500, Chris Moller wrote:
>    
>> I did--it's 4 bytes on both i386 and x86_64. I just don't know about
>> non-intel archs.
>>      
>
> No, it should be 8 bytes on x86_64.
>
> (gdb) list x
> 1       #include<stdlib.h>
> 2
> 3       size_t x;
> (gdb) ptype x
> type = long unsigned int
> (gdb) p sizeof(x)
> $2 = 8
>    

oops--forgot the -m64 flag...


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2010-02-09  2:38 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-02-08 23:17 pr9164 patch Chris Moller
2010-02-08 23:34 ` Daniel Jacobowitz
2010-02-09  1:23   ` Chris Moller
2010-02-09  2:18     ` Daniel Jacobowitz
2010-02-09  2:38       ` Chris Moller
2010-02-08 23:38 ` Pedro Alves

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox