From patchwork Sun Apr 13 07:52:34 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Blaikie X-Patchwork-Id: 527 Return-Path: X-Original-To: siddhesh@wilcox.dreamhost.com Delivered-To: siddhesh@wilcox.dreamhost.com Received: from homiemail-mx23.g.dreamhost.com (mx2.sub5.homie.mail.dreamhost.com [208.113.200.128]) by wilcox.dreamhost.com (Postfix) with ESMTP id CBE4B36007C for ; Sun, 13 Apr 2014 00:52:46 -0700 (PDT) Received: by homiemail-mx23.g.dreamhost.com (Postfix, from userid 14314964) id 6B119628B0A86; Sun, 13 Apr 2014 00:52:41 -0700 (PDT) X-Original-To: gdb@patchwork.siddhesh.in Delivered-To: x14314964@homiemail-mx23.g.dreamhost.com Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by homiemail-mx23.g.dreamhost.com (Postfix) with ESMTPS id 2083A628B0A7C for ; Sun, 13 Apr 2014 00:52:41 -0700 (PDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:mime-version:in-reply-to:references:date :message-id:subject:from:to:content-type; q=dns; s=default; b=yW ehf4T3yjkC1fr4HGzFu2W4WWyLMgjBVOi7LWfdlOoHRePG+2+7os1v4oaV1D2UFA AUvfBwIH5UgMMLebARnLWgTtrgluCls+NDZpS7616u2BgY+K1vzY6IHdQ5vug34D a5hV8KmgshvwwOu7VbgmJv7jnlSyHEg+mKwh9kWEc= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:mime-version:in-reply-to:references:date :message-id:subject:from:to:content-type; s=default; bh=XRDXnEIV KiHepYRR2+Rkou2nShs=; b=nJZxlpxoOhwZ7vRH9SikZRZRe0zFuhHQFLJqhskB PNuYCQCwsLMFVGsktgQ0fPhwijVNcZpBOcPQDuLVuKAFGN5B+f9fG59w1nyap/Hu JtyVvJ2U+8QY33BRYNelac64H7iYPQ26mEhMDHy0zv4sWEc66l0L/6yYLxiDOoFi Ayk= Received: (qmail 27327 invoked by alias); 13 Apr 2014 07:52:39 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 27310 invoked by uid 89); 13 Apr 2014 07:52:38 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.3 required=5.0 tests=AWL, BAYES_00, FREEMAIL_FROM, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.2 X-HELO: mail-qc0-f176.google.com Received: from mail-qc0-f176.google.com (HELO mail-qc0-f176.google.com) (209.85.216.176) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-SHA encrypted) ESMTPS; Sun, 13 Apr 2014 07:52:36 +0000 Received: by mail-qc0-f176.google.com with SMTP id m20so7637120qcx.35 for ; Sun, 13 Apr 2014 00:52:34 -0700 (PDT) MIME-Version: 1.0 X-Received: by 10.229.54.201 with SMTP id r9mr42319622qcg.6.1397375554853; Sun, 13 Apr 2014 00:52:34 -0700 (PDT) Received: by 10.140.30.74 with HTTP; Sun, 13 Apr 2014 00:52:34 -0700 (PDT) In-Reply-To: References: Date: Sun, 13 Apr 2014 00:52:34 -0700 Message-ID: Subject: Re: [patch] [gdb/testsuite] include a use of the definition of a type to cause clang to emit debug info From: David Blaikie To: gdb-patches X-IsSubscribed: yes X-DH-Original-To: gdb@patchwork.siddhesh.in Oh, and there was one other instance of the same issue (I believe these are the only two cases) This test case (gdb.cp/pr10728) seems like it could probably be simplified a great deal, down to: struct foo; foo *f, *g; int main() { } // break and print f - g if I'm not mistaken... - but I've made a relatively small change for now. If preferred, I can make the more substantial simplification suggested. Or otherwise appease clang (by introducing a use of the original 'x' type definition in some other way - dereferencing a pointer, etc). - David On Sat, Apr 12, 2014 at 11:43 PM, David Blaikie wrote: > Clang has an optimization that causes a the debug info to only include > the declaration of a type if the type is referenced but never used in > a context that requires a definition (eg: pointers are handed around > but never deferenced). > > This patch introduces a variable to one test file to cause clang to > emit the full definition of the type as well as fixing up a related > typo in the test message of the associated expect file. > > Like the difference between GCC and Clang in the emission of unused > static entities, I think this case is also a matter of degrees - both > GCC and Clang implement other similar optimizations* to the one > outlined here and the GDB test suite has managed to pass without > disabling those optimizations in GCC and I hope it's suitable to do > the same for Clang. > > Though admittedly I don't have much of the context of the history of > the testsuite, its priorities/preferences when it comes to > distinguishing testing compiler behavior versus debugger behavior, > etc. > > * the one I know of involves dynamic types: both GCC and Clang only > emit the debug info definition of such a type in any translation unit > that emits the key function. This means in many contexts where a full > definition is provided in the source only a declaration is provided in > the debug info. commit 24a8810a97155710d3c53b401eb8729bc4f80c00 Author: David Blaikie Date: Sun Apr 13 00:48:45 2014 -0700 Return by value to coax Clang into emitting the full definition of a test type. gdb/testsuite/ * gdb.cp/pr10728-x.cc: Return by value instead of pointer to coax Clang into emitting the definition of the type. * gdb.cp/pr10728-x.h: Ditto. * gdb.cp/pr10728-y.cc: Ditto. diff --git gdb/testsuite/ChangeLog gdb/testsuite/ChangeLog index 730c116..1d15721 100644 --- gdb/testsuite/ChangeLog +++ gdb/testsuite/ChangeLog @@ -1,3 +1,10 @@ +2014-04-12 David Blaikie + + * gdb.cp/pr10728-x.cc: Return by value instead of pointer to coax + Clang into emitting the definition of the type. + * gdb.cp/pr10728-x.h: Ditto. + * gdb.cp/pr10728-y.cc: Ditto. + 2014-04-12 Siva Chandra Reddy Doug Evans diff --git gdb/testsuite/gdb.cp/pr10728-x.cc gdb/testsuite/gdb.cp/pr10728-x.cc index 7623c0b..d6b7666 100644 --- gdb/testsuite/gdb.cp/pr10728-x.cc +++ gdb/testsuite/gdb.cp/pr10728-x.cc @@ -2,6 +2,6 @@ int main() { - X* x = y(); + X x = y(); return 0; // marker 1 } diff --git gdb/testsuite/gdb.cp/pr10728-x.h gdb/testsuite/gdb.cp/pr10728-x.h index 63737d9..0ba58bb 100644 --- gdb/testsuite/gdb.cp/pr10728-x.h +++ gdb/testsuite/gdb.cp/pr10728-x.h @@ -5,5 +5,5 @@ struct X Y* y2; }; -X* y(); +X y(); diff --git gdb/testsuite/gdb.cp/pr10728-y.cc gdb/testsuite/gdb.cp/pr10728-y.cc index 84b222d..d8a932a 100644 --- gdb/testsuite/gdb.cp/pr10728-y.cc +++ gdb/testsuite/gdb.cp/pr10728-y.cc @@ -1,11 +1,11 @@ #include "pr10728-x.h" struct Y{}; -X* y() +X y() { - static X xx; + X xx; static Y yy; xx.y1 = &yy; xx.y2 = xx.y1+1; - return &xx; + return xx; }