From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 18502 invoked by alias); 27 Jan 2010 19:41:23 -0000 Received: (qmail 18484 invoked by uid 22791); 27 Jan 2010 19:41:20 -0000 X-SWARE-Spam-Status: No, hits=-2.3 required=5.0 tests=AWL,BAYES_00,HK_OBFDOM,SPF_HELO_PASS,SPF_PASS X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Wed, 27 Jan 2010 19:41:15 +0000 Received: from int-mx03.intmail.prod.int.phx2.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o0RJfDbk016218 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Wed, 27 Jan 2010 14:41:14 -0500 Received: from qcore.mollernet.net (vpn-11-41.rdu.redhat.com [10.11.11.41]) by int-mx03.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o0RJfDk3022911 for ; Wed, 27 Jan 2010 14:41:13 -0500 Message-ID: <4B6096D9.1060606@redhat.com> Date: Wed, 27 Jan 2010 19:41:00 -0000 From: Chris Moller User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1b3pre) Gecko/20090513 Fedora/3.0-2.3.beta2.fc11 Thunderbird/3.0b2 MIME-Version: 1.0 To: gdb-patches@sourceware.org Subject: Patch for PR 10728 Content-Type: multipart/mixed; boundary="------------080900030206090001050609" Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2010-01/txt/msg00596.txt.bz2 This is a multi-part message in MIME format. --------------080900030206090001050609 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-length: 513 The attached stuff is a patch for PR 10728: http://sourceware.org/bugzilla/show_bug.cgi?id=10728 "infinite loop evaluating pointer difference w/o complete debug info" The bug was in valarith.c : value_ptrdiff--if the type structs showed size == 0, things came unstuck. This patch fixes that by issuing a warning and assuming size = 1. The patch includes testcase source files and and an expects file. The gdb.sum diff between the unpatched and patched make check is also attached. Chris Moller, Red Hat --------------080900030206090001050609 Content-Type: text/plain; name="pr10728.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="pr10728.patch" Content-length: 6128 Index: gdb/ChangeLog =================================================================== RCS file: /cvs/src/src/gdb/ChangeLog,v retrieving revision 1.11289 diff -u -r1.11289 ChangeLog --- gdb/ChangeLog 25 Jan 2010 19:31:23 -0000 1.11289 +++ gdb/ChangeLog 27 Jan 2010 18:56:27 -0000 @@ -1,3 +1,9 @@ +2010-01-25 Chris Moller + + PR gdb/10728: + * valarith.c (value_ptrdiff): Added a test for a zero type length, + warn if found, and assume length = 1. + 2010-01-25 Tom Tromey PR gdb/11049: Index: gdb/valarith.c =================================================================== RCS file: /cvs/src/src/gdb/valarith.c,v retrieving revision 1.79 diff -u -r1.79 valarith.c --- gdb/valarith.c 20 Jan 2010 18:06:15 -0000 1.79 +++ gdb/valarith.c 27 Jan 2010 18:56:29 -0000 @@ -122,6 +122,13 @@ an integer nor a pointer of the same type.")); sz = TYPE_LENGTH (check_typedef (TYPE_TARGET_TYPE (type1))); + if (sz == 0) + { + warning (_("Type size unknown, assuming 1. " + "Try casting to a known type, or void *.")); + sz = 1; + } + return (value_as_long (arg1) - value_as_long (arg2)) / sz; } Index: gdb/testsuite/ChangeLog =================================================================== RCS file: /cvs/src/src/gdb/testsuite/ChangeLog,v retrieving revision 1.2101 diff -u -r1.2101 ChangeLog --- gdb/testsuite/ChangeLog 25 Jan 2010 19:31:23 -0000 1.2101 +++ gdb/testsuite/ChangeLog 27 Jan 2010 18:56:45 -0000 @@ -1,3 +1,12 @@ +2010-01-26 Chris Moller + + PR gdb/10728 + * gdb.cp/pr10728-x.h: New file. + * gdb.cp/pr10728-x.cc: New file. + * gdb.cp/pr10728-y.cc: New file. + * gdb.cp/pr10728.exp: New file. + * gdb.cp/Makefile.in (EXECUTABLES): Add pr10728 + 2010-01-25 Tom Tromey PR gdb/11049: Index: gdb/testsuite/gdb.cp/Makefile.in =================================================================== RCS file: /cvs/src/src/gdb/testsuite/gdb.cp/Makefile.in,v retrieving revision 1.7 diff -u -r1.7 Makefile.in --- gdb/testsuite/gdb.cp/Makefile.in 10 Dec 2009 20:57:10 -0000 1.7 +++ gdb/testsuite/gdb.cp/Makefile.in 27 Jan 2010 18:56:45 -0000 @@ -4,7 +4,7 @@ EXECUTABLES = ambiguous annota2 anon-union cplusfuncs cttiadd \ derivation inherit local member-ptr method misc \ overload ovldbreak ref-typ ref-typ2 templates userdef virtfunc namespace \ - ref-types ref-params method2 pr9594 gdb2495 virtfunc2 + ref-types ref-params method2 pr9594 gdb2495 virtfunc2 pr10728 all info install-info dvi install uninstall installcheck check: @echo "Nothing to be done for $@..." Index: gdb/testsuite/gdb.cp/pr10728-x.cc =================================================================== RCS file: gdb/testsuite/gdb.cp/pr10728-x.cc diff -N gdb/testsuite/gdb.cp/pr10728-x.cc --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ gdb/testsuite/gdb.cp/pr10728-x.cc 27 Jan 2010 18:56:45 -0000 @@ -0,0 +1,7 @@ +#include "pr10728-x.h" + +int main() +{ + X* x = y(); + return 0; // marker 1 +} Index: gdb/testsuite/gdb.cp/pr10728-x.h =================================================================== RCS file: gdb/testsuite/gdb.cp/pr10728-x.h diff -N gdb/testsuite/gdb.cp/pr10728-x.h --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ gdb/testsuite/gdb.cp/pr10728-x.h 27 Jan 2010 18:56:45 -0000 @@ -0,0 +1,9 @@ +struct Y; +struct X +{ + Y* y1; + Y* y2; +}; + +X* y(); + Index: gdb/testsuite/gdb.cp/pr10728-y.cc =================================================================== RCS file: gdb/testsuite/gdb.cp/pr10728-y.cc diff -N gdb/testsuite/gdb.cp/pr10728-y.cc --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ gdb/testsuite/gdb.cp/pr10728-y.cc 27 Jan 2010 18:56:45 -0000 @@ -0,0 +1,11 @@ +#include "pr10728-x.h" +struct Y{}; + +X* y() +{ + static X xx; + static Y yy; + xx.y1 = &yy; + xx.y2 = xx.y1+1; + return &xx; +} Index: gdb/testsuite/gdb.cp/pr10728.exp =================================================================== RCS file: gdb/testsuite/gdb.cp/pr10728.exp diff -N gdb/testsuite/gdb.cp/pr10728.exp --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ gdb/testsuite/gdb.cp/pr10728.exp 27 Jan 2010 18:56:45 -0000 @@ -0,0 +1,73 @@ +# 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 . + +# This file is part of the gdb testsuite + +set nl "\[\r\n\]+" + +if { [skip_cplus_tests] } { continue } + +load_lib "cp-support.exp" + +set testfile "pr10728" +set srcfile ${testfile}-x.cc +set tfx ${testfile}-x +set tfy ${testfile}-y +set binfile ${objdir}/${subdir}/${testfile} + +if { [gdb_compile "${srcdir}/${subdir}/${tfy}.cc" "${tfy}.o" object {c++}] != "" } { + untested psmang.exp + return -1 +} + +if { [gdb_compile "${srcdir}/${subdir}/${tfx}.cc" "${tfx}.o" object {debug c++}] != "" } { + untested psmang.exp + return -1 +} + +if { [gdb_compile "${tfx}.o ${tfy}.o" ${binfile} executable {debug c++}] != "" } { + untested psmang.exp + return -1 +} + + +gdb_exit +gdb_start +gdb_reinitialize_dir $srcdir/$subdir +gdb_load ${binfile} + +if ![runto_main] then { + perror "couldn't run to breakpoint" + continue +} + +# set a breakpoint at the return stmt + +gdb_breakpoint [gdb_get_line_number "marker 1"] +gdb_continue_to_breakpoint "marker 1" + +send_gdb "print x->y2 - x->y1\n" + +gdb_expect { + -re "warning: Type size unknown, assuming 1\. Try casting to a known type, or void \*\.\[^=\]*= 1" { + pass "print x->y2 - x->y1" + } + timeout { fail "(timeout) print x->y2 - x->y1" } +} + +gdb_exit +return 0 + + --------------080900030206090001050609 Content-Type: text/plain; name="pr10728-check.diff" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="pr10728-check.diff" Content-length: 2504 --- gdb-virgin.sum 2010-01-25 22:03:19.916165023 -0500 +++ gdb-patched2.sum 2010-01-26 22:24:47.539164893 -0500 @@ -1,4 +1,4 @@ -Test Run By moller on Mon Jan 25 21:55:54 2010 +Test Run By moller on Tue Jan 26 22:06:34 2010 Native configuration is i686-pc-linux-gnu === gdb tests === @@ -11460,6 +11460,9 @@ Running ../../../src/gdb/testsuite/gdb.cp/pr-574.exp ... PASS: gdb.cp/pr-574.exp: continue to breakpoint: end of constructors PASS: gdb.cp/pr-574.exp: PR gdb/574 +Running ../../../src/gdb/testsuite/gdb.cp/pr10728.exp ... +PASS: gdb.cp/pr10728.exp: continue to breakpoint: marker 1 +PASS: gdb.cp/pr10728.exp: print x->y2 - x->y1 Running ../../../src/gdb/testsuite/gdb.cp/pr9631.exp ... PASS: gdb.cp/pr9631.exp: continue to breakpoint: after bar tender is initialized PASS: gdb.cp/pr9631.exp: print tender @@ -12530,7 +12533,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 @@ -15083,7 +15086,8 @@ PASS: gdb.threads/local-watch-wrong-thread.exp: local watchpoint still triggers PASS: gdb.threads/local-watch-wrong-thread.exp: let thread_function0 return PASS: gdb.threads/local-watch-wrong-thread.exp: breakpoint on thread_function0's caller -PASS: gdb.threads/local-watch-wrong-thread.exp: local watchpoint automatically deleted +ERROR: Process no longer exists +UNRESOLVED: gdb.threads/local-watch-wrong-thread.exp: local watchpoint automatically deleted Running ../../../src/gdb/testsuite/gdb.threads/manythreads.exp ... PASS: gdb.threads/manythreads.exp: successfully compiled posix threads test case PASS: gdb.threads/manythreads.exp: set print sevenbit-strings @@ -15640,11 +15644,11 @@ === gdb Summary === -# of expected passes 14847 -# of unexpected failures 26 +# of expected passes 14849 +# of unexpected failures 25 # of expected failures 41 # of untested testcases 3 -# of unresolved testcases 1 +# of unresolved testcases 2 # of unsupported tests 61 /home/moller/tinkering/fsfgdb-10728/build/gdb/testsuite/../../gdb/gdb version 7.0.50.20100125-cvs -nw -nx --------------080900030206090001050609--