Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Chris Moller <cmoller@redhat.com>
To: gdb-patches@sourceware.org
Subject: pr9164 patch
Date: Mon, 08 Feb 2010 23:17:00 -0000	[thread overview]
Message-ID: <4B709B9A.3050001@redhat.com> (raw)

[-- 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

             reply	other threads:[~2010-02-08 23:17 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-02-08 23:17 Chris Moller [this message]
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

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=4B709B9A.3050001@redhat.com \
    --to=cmoller@redhat.com \
    --cc=gdb-patches@sourceware.org \
    /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