From: Chris Moller <cmoller@redhat.com>
To: gdb-patches@sourceware.org
Subject: Patch for PR 10728
Date: Wed, 27 Jan 2010 19:41:00 -0000 [thread overview]
Message-ID: <4B6096D9.1060606@redhat.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 513 bytes --]
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
[-- Attachment #2: pr10728.patch --]
[-- Type: text/plain, Size: 6128 bytes --]
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 <cmoller@redhat.com>
+
+ 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 <tromey@redhat.com>
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 <cmoller@redhat.com>
+
+ 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 <tromey@redhat.com>
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 <http://www.gnu.org/licenses/>.
+
+# 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
+
+
[-- Attachment #3: pr10728-check.diff --]
[-- Type: text/plain, Size: 2504 bytes --]
--- 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
next reply other threads:[~2010-01-27 19:41 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-01-27 19:41 Chris Moller [this message]
2010-01-28 18:09 ` Tom Tromey
2010-01-28 18:38 ` Chris Moller
2010-01-28 20:03 ` Tom Tromey
2010-02-03 20:41 ` Chris Moller
2010-02-03 20:50 ` Tom Tromey
2010-02-02 21:57 Chris Moller
2010-02-02 23:57 ` Tom Tromey
2010-02-03 4:36 ` Chris Moller
2010-02-03 18:23 ` Tom Tromey
2010-02-03 4:52 ` Chris Moller
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=4B6096D9.1060606@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