From patchwork Sun Apr 13 06:43:40 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Blaikie X-Patchwork-Id: 523 Return-Path: X-Original-To: siddhesh@wilcox.dreamhost.com Delivered-To: siddhesh@wilcox.dreamhost.com Received: from homiemail-mx22.g.dreamhost.com (mx2.sub5.homie.mail.dreamhost.com [208.113.200.128]) by wilcox.dreamhost.com (Postfix) with ESMTP id A743536007C for ; Sat, 12 Apr 2014 23:43:52 -0700 (PDT) Received: by homiemail-mx22.g.dreamhost.com (Postfix, from userid 14314964) id 47194499CB09; Sat, 12 Apr 2014 23:43:52 -0700 (PDT) X-Original-To: gdb@patchwork.siddhesh.in Delivered-To: x14314964@homiemail-mx22.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-mx22.g.dreamhost.com (Postfix) with ESMTPS id DD838499CB11 for ; Sat, 12 Apr 2014 23:43:51 -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:date:message-id:subject:from:to :content-type; q=dns; s=default; b=Cb9Fj1xAIWQEBlFlV0ZWBR0imPoRo yLZcKIh5Wq7SDxaIXYm6z+iP0NM/gBSj1VmVBsZ/TYktDxryPuhcuunO00L5vPOa f7wgMgT+Wyv8VTy4s+tKK5y6ioX/bPLB85t6k9voIUvWISBdqfo5zmMxsKMe2GJc PoWbU6ZJLfBi1E= 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:date:message-id:subject:from:to :content-type; s=default; bh=tp2qINHI3ST18n3rPepU3O/PfuI=; b=HLj /9jqFfT8bg+70h3VVQxpqmPLfQ9aMidhvet8jrEn0nZDjRtELipJUDQKUcCTDt8g o2lhQmhJgA4rq5bPIP76bug5AsCPxM4FK3v3z/0mpAhatejIjZryZbzQ5A9APWJ1 CMmFvAV5T7UlJ6VEJt3V+3HX6rbWnDAqB3YDCc8I= Received: (qmail 2272 invoked by alias); 13 Apr 2014 06:43:47 -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 2254 invoked by uid 89); 13 Apr 2014 06:43:44 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-0.9 required=5.0 tests=AWL, BAYES_00, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.2 X-HELO: mail-qg0-f46.google.com Received: from mail-qg0-f46.google.com (HELO mail-qg0-f46.google.com) (209.85.192.46) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-SHA encrypted) ESMTPS; Sun, 13 Apr 2014 06:43:43 +0000 Received: by mail-qg0-f46.google.com with SMTP id 63so6808624qgz.5 for ; Sat, 12 Apr 2014 23:43:41 -0700 (PDT) MIME-Version: 1.0 X-Received: by 10.224.13.76 with SMTP id b12mr1967899qaa.34.1397371421023; Sat, 12 Apr 2014 23:43:41 -0700 (PDT) Received: by 10.140.30.74 with HTTP; Sat, 12 Apr 2014 23:43:40 -0700 (PDT) Date: Sat, 12 Apr 2014 23:43:40 -0700 Message-ID: Subject: [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 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 1128f6fb45483d45668d09e0696f4a590334e0c4 Author: David Blaikie Date: Sat Apr 12 23:27:19 2014 -0700 Cause clang to emit the definition of a type used only by pointer gdb/testsuite/ * gdb.stabs/gdb11479.c: introduce a variable to cause clang to emit the full definition of type required by the test * gdb.stabs/gdb11479.exp: correct a typo in a test message diff --git gdb/testsuite/ChangeLog gdb/testsuite/ChangeLog index 730c116..07ba18e 100644 --- gdb/testsuite/ChangeLog +++ gdb/testsuite/ChangeLog @@ -1,3 +1,9 @@ +2014-04-12 David Blaikie + + * gdb.stabs/gdb11479.c: introduce a variable to cause clang to + emit the full definition of type required by the test + * gdb.stabs/gdb11479.exp: correct a typo in a test message + 2014-04-12 Siva Chandra Reddy Doug Evans diff --git gdb/testsuite/gdb.stabs/gdb11479.c gdb/testsuite/gdb.stabs/gdb11479.c index eb7fcf9..f70930f 100644 --- gdb/testsuite/gdb.stabs/gdb11479.c +++ gdb/testsuite/gdb.stabs/gdb11479.c @@ -55,7 +55,7 @@ struct dummy { enum dummy_enum { enum1, enum2 -}; +} tag_dummy_enum; void * hack (const struct dummy *t, const enum dummy_enum *e) diff --git gdb/testsuite/gdb.stabs/gdb11479.exp gdb/testsuite/gdb.stabs/gdb11479.exp index b9ed238..a2782ac 100644 --- gdb/testsuite/gdb.stabs/gdb11479.exp +++ gdb/testsuite/gdb.stabs/gdb11479.exp @@ -31,13 +31,13 @@ proc do_test {version} { gdb_test "print *t" ".*\{x = 5, y = 25, b = 2.5\}.*" \ "Inspect t in test2 $version" # Check that the enum type length has been set to a non-zero value - gdb_test "print sizeof (*e)" "= \[1-9\]*" "sizeof (e) in test2 $version" + gdb_test "print sizeof (*e)" "= \[1-9\]*" "sizeof (*e) in test2 $version" gdb_test "continue" "Breakpoint .* test .*" \ "Stop at first breakpoint $version" gdb_test "print *t" ".*\{x = 5, y = 25, b = 2.5\}.*" \ "Inspect t in test $version" # Check that the enum type length has been set to a non-zero value - gdb_test "print sizeof (*e)" "= \[1-9\]*" "sizeof (e) in test $version" + gdb_test "print sizeof (*e)" "= \[1-9\]*" "sizeof (*e) in test $version" } if { [prepare_for_testing $testfile.exp $testfile $testfile.c {debug additional_flags=-gstabs}] == 0 } {