From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 23803 invoked by alias); 14 Jul 2008 17:32:21 -0000 Received: (qmail 23795 invoked by uid 22791); 14 Jul 2008 17:32:20 -0000 X-Spam-Check-By: sourceware.org Received: from smtp-out.google.com (HELO smtp-out.google.com) (216.239.33.17) by sourceware.org (qpsmtpd/0.31) with ESMTP; Mon, 14 Jul 2008 17:31:55 +0000 Received: from spaceape13.eur.corp.google.com (spaceape13.eur.corp.google.com [172.28.16.147]) by smtp-out.google.com with ESMTP id m6EHVpMv008221 for ; Mon, 14 Jul 2008 18:31:51 +0100 Received: from localhost (elbrus.corp.google.com [172.18.116.17]) by spaceape13.eur.corp.google.com with ESMTP id m6EHVovQ010277 for ; Mon, 14 Jul 2008 18:31:50 +0100 Received: by localhost (Postfix, from userid 74925) id A03E63A67B4; Mon, 14 Jul 2008 10:31:49 -0700 (PDT) To: gdb-patches@sourceware.org Subject: [RFA] Patch for PR gdb/2477 Message-Id: <20080714173149.A03E63A67B4@localhost> Date: Mon, 14 Jul 2008 17:32:00 -0000 From: ppluzhnikov@google.com (Paul Pluzhnikov) X-IsSubscribed: yes 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: 2008-07/txt/msg00285.txt.bz2 Greetings, Attached patch fixes error in printing NULL pointers when "set print object on". http://sourceware.org/cgi-bin/gnatsweb.pl?cmd=view&database=gdb&pr=2477 and adds a test case for it. Ok to commit? -- Paul Pluzhnikov ChangeLog 2008-07-14 Paul Pluzhnikov PR gdb/2477 * cp-abi.c (value_virtual_fn_field): Handle NULL pointers. testsuite/ChangeLog 2008-07-14 Paul Pluzhnikov * gdb.cp/class2.exp, gdb.cp/class2.cc: Test for PR2477. Index: cp-abi.c =================================================================== RCS file: /cvs/src/src/gdb/cp-abi.c,v retrieving revision 1.21 diff -u -p -u -r1.21 cp-abi.c --- cp-abi.c 1 Jan 2008 22:53:09 -0000 1.21 +++ cp-abi.c 14 Jul 2008 17:23:56 -0000 @@ -89,7 +89,8 @@ value_virtual_fn_field (struct value **a struct type * value_rtti_type (struct value *v, int *full, int *top, int *using_enc) { - if ((current_cp_abi.rtti_type) == NULL) + if ((current_cp_abi.rtti_type) == NULL + || VALUE_ADDRESS (v) == 0) return NULL; return (*current_cp_abi.rtti_type) (v, full, top, using_enc); } Index: testsuite/gdb.cp/class2.cc =================================================================== RCS file: /cvs/src/src/gdb/testsuite/gdb.cp/class2.cc,v retrieving revision 1.6 diff -u -p -u -r1.6 class2.cc --- testsuite/gdb.cp/class2.cc 1 Jan 2008 22:53:19 -0000 1.6 +++ testsuite/gdb.cp/class2.cc 14 Jul 2008 17:23:56 -0000 @@ -41,6 +41,11 @@ B::~B() b2 = 902; } +struct C : public B +{ + A *c1; +}; + // Stop the compiler from optimizing away data. void refer (A *) { @@ -57,16 +62,19 @@ void refer (empty *) int main (void) { - A alpha, *aap, *abp; + A alpha, *aap, *abp, *acp; B beta, *bbp; + C gamma; empty e; alpha.a1 = 100; beta.a1 = 200; beta.b1 = 201; beta.b2 = 202; + gamma.c1 = 0; aap = α refer (aap); abp = β refer (abp); bbp = β refer (bbp); + acp = γ refer (acp); refer (&e); return 0; // marker return 0 Index: testsuite/gdb.cp/class2.exp =================================================================== RCS file: /cvs/src/src/gdb/testsuite/gdb.cp/class2.exp,v retrieving revision 1.6 diff -u -p -u -r1.6 class2.exp --- testsuite/gdb.cp/class2.exp 1 Jan 2008 22:53:19 -0000 1.6 +++ testsuite/gdb.cp/class2.exp 14 Jul 2008 17:23:56 -0000 @@ -117,3 +117,9 @@ gdb_test "print * (B *) abp" \ # Printing the value of an object containing no data fields: gdb_test "p e" "= \{\}" "print object with no data fields" + +# Printing NULL pointers with "set print object on" + +gdb_test "set print object on" "" +gdb_test "p acp" "= \\(C \\*\\) 0x\[a-f0-9\]+" +gdb_test "p acp->c1" "\\(A \\*\\) 0x0"