From patchwork Fri Apr 11 06:51:49 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Blaikie X-Patchwork-Id: 497 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 393A8360078 for ; Thu, 10 Apr 2014 23:51:59 -0700 (PDT) Received: by homiemail-mx23.g.dreamhost.com (Postfix, from userid 14314964) id A20F86277B298; Thu, 10 Apr 2014 23:51:58 -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 5C9E86277B232 for ; Thu, 10 Apr 2014 23:51:58 -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=V+lpskE1sCO5QPXTwwoqQTyN3bpC8 c997z/MnfAjc5xRcLVN5nV99J6EwfHu3R6AWKpYOOt4KB1dlQMgYI+KiJ32AP5xt g+41svTIztURCwYfHDXzoKUigOqfCA3QclH0T5qYwXXZ1V4aGnIysqdRdu70HlRl pWkOj7CgxQfL6o= 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=Qq+QTLKDhdLf2rQKkMi7PmMTw5c=; b=BjD EMcHM2ultwTYoPJvEKy2IHvxJwhvMh/SJJpRIfqJSYGulhoTUeihqd3fBA9ByH4X bpMdIF2nn3iwiG835tbPwgVqkcLgxPG3PhG+TLqLLUEFF7COxBvQVEUTvMjT26Qt +y9VQvlbL31ZzGE96gdCgms1L+/4aUBhslvNfipE= Received: (qmail 7490 invoked by alias); 11 Apr 2014 06:51:56 -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 7477 invoked by uid 89); 11 Apr 2014 06:51:55 -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-qa0-f52.google.com Received: from mail-qa0-f52.google.com (HELO mail-qa0-f52.google.com) (209.85.216.52) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-SHA encrypted) ESMTPS; Fri, 11 Apr 2014 06:51:52 +0000 Received: by mail-qa0-f52.google.com with SMTP id s7so2956090qap.11 for ; Thu, 10 Apr 2014 23:51:50 -0700 (PDT) MIME-Version: 1.0 X-Received: by 10.224.5.136 with SMTP id 8mr26707255qav.42.1397199110003; Thu, 10 Apr 2014 23:51:50 -0700 (PDT) Received: by 10.140.30.74 with HTTP; Thu, 10 Apr 2014 23:51:49 -0700 (PDT) Date: Thu, 10 Apr 2014 23:51:49 -0700 Message-ID: Subject: [patch] Fix unused static symbols so they're not dropped by clang From: David Blaikie To: gdb-patches@sourceware.org, Eric Christopher , Doug Evans X-IsSubscribed: yes X-DH-Original-To: gdb@patchwork.siddhesh.in Several tests used file-static functions and variables that were not referenced by the code. Even at -O0, clang omits these entities at the frontend so the tests fail. Since it doesn't look like these tests needed this functionality for what they were testing, I've modified the variables/functions to either be non-static, or marked them with __attribute__((used)). If it's preferred that I use the attribute more pervasively, rather than just making the entities non-static, I can provide a patch for that (or some other preferred solution). There's certainly precedent for both (non-static entities and __attribute__((used)) in the testsuite already and much more of the former than the latter). I have commit-after-review access, so just looking for sign-off here. Thanks, - David commit d72b042cbd4f0af6d2e4ac6901445677b93f77ee Author: David Blaikie Date: Thu Apr 10 23:45:28 2014 -0700 Ensure unreferenced static symbols aren't omitted by clang (either marking them __attribute__((used)) or making them non-static) gdb/testsuite/ * gdb.base/catch-syscall.c: Make unreferenced statics non-static to ensure clang would not discard them. * gdb.base/gdbvars.c: Ditto. * gdb.base/memattr.c: Ditto. * gdb.base/whatis.c: Ditto. * gdb.python/py-prettyprint.c: Ditto. * gdb.trace/actions.c: Ditto. * gdb.cp/ptype-cv-cp.cc: Mark unused global const int as used to ensure clang would not discard it. diff --git gdb/testsuite/ChangeLog gdb/testsuite/ChangeLog index 12ed4f9..623831a 100644 --- gdb/testsuite/ChangeLog +++ gdb/testsuite/ChangeLog @@ -1,3 +1,15 @@ +2014-04-10 David Blaikie + + * gdb.base/catch-syscall.c: Make unreferenced statics non-static to + ensure clang would not discard them. + * gdb.base/gdbvars.c: Ditto. + * gdb.base/memattr.c: Ditto. + * gdb.base/whatis.c: Ditto. + * gdb.python/py-prettyprint.c: Ditto. + * gdb.trace/actions.c: Ditto. + * gdb.cp/ptype-cv-cp.cc: Mark unused global const int as used to + ensure clang would not discard it. + 2014-04-10 Pedro Alves * gdb.base/cond-eval-mode.c: New file. diff --git gdb/testsuite/gdb.base/catch-syscall.c gdb/testsuite/gdb.base/catch-syscall.c index aa5727a..ea33b93 100644 --- gdb/testsuite/gdb.base/catch-syscall.c +++ gdb/testsuite/gdb.base/catch-syscall.c @@ -14,16 +14,16 @@ /* These are the syscalls numbers used by the test. */ -static int close_syscall = SYS_close; -static int chroot_syscall = SYS_chroot; +int close_syscall = SYS_close; +int chroot_syscall = SYS_chroot; /* GDB had a bug where it couldn't catch syscall number 0 (PR 16297). In most GNU/Linux architectures, syscall number 0 is restart_syscall, which can't be called from userspace. However, the "read" syscall is zero on x86_64. */ -static int read_syscall = SYS_read; -static int pipe_syscall = SYS_pipe; -static int write_syscall = SYS_write; -static int exit_group_syscall = SYS_exit_group; +int read_syscall = SYS_read; +int pipe_syscall = SYS_pipe; +int write_syscall = SYS_write; +int exit_group_syscall = SYS_exit_group; int main (void) diff --git gdb/testsuite/gdb.base/gdbvars.c gdb/testsuite/gdb.base/gdbvars.c index 352a76b..46fa84b 100644 --- gdb/testsuite/gdb.base/gdbvars.c +++ gdb/testsuite/gdb.base/gdbvars.c @@ -4,12 +4,12 @@ typedef void *ptr; ptr p = &p; -static void +void foo_void (void) { } -static int +int foo_int (void) { return 0; diff --git gdb/testsuite/gdb.base/memattr.c gdb/testsuite/gdb.base/memattr.c index 74b2d61..62868b6 100644 --- gdb/testsuite/gdb.base/memattr.c +++ gdb/testsuite/gdb.base/memattr.c @@ -16,11 +16,11 @@ along with this program. If not, see . */ #define MEMSIZE 64 -static int mem1[MEMSIZE] = {111, 222, 333, 444, 555}; -static int mem2[MEMSIZE]; -static int mem3[MEMSIZE]; -static int mem4[MEMSIZE]; -static int mem5[MEMSIZE]; +int mem1[MEMSIZE] = {111, 222, 333, 444, 555}; +int mem2[MEMSIZE]; +int mem3[MEMSIZE]; +int mem4[MEMSIZE]; +int mem5[MEMSIZE]; int main() { diff --git gdb/testsuite/gdb.base/whatis.c gdb/testsuite/gdb.base/whatis.c index a1a3188..bcda5fd 100644 --- gdb/testsuite/gdb.base/whatis.c +++ gdb/testsuite/gdb.base/whatis.c @@ -88,14 +88,14 @@ double v_double_array[2]; a special case kludge in GDB (Unix system include files like to define caddr_t), but for a variety of types. */ typedef char *char_addr; -static char_addr a_char_addr; +char_addr a_char_addr; typedef unsigned short *ushort_addr; -static ushort_addr a_ushort_addr; +ushort_addr a_ushort_addr; typedef signed long *slong_addr; -static slong_addr a_slong_addr; +slong_addr a_slong_addr; #ifndef NO_LONG_LONG typedef signed long long *slong_long_addr; -static slong_long_addr a_slong_long_addr; +slong_long_addr a_slong_long_addr; #endif char *v_char_pointer; diff --git gdb/testsuite/gdb.cp/ptype-cv-cp.cc gdb/testsuite/gdb.cp/ptype-cv-cp.cc index 6546f68..add4021 100644 --- gdb/testsuite/gdb.cp/ptype-cv-cp.cc +++ gdb/testsuite/gdb.cp/ptype-cv-cp.cc @@ -22,7 +22,7 @@ typedef volatile const_my_int volatile_const_my_int; typedef const volatile_my_int const_volatile_my_int; my_int v_my_int (0); -const_my_int v_const_my_int (1); +__attribute__((used)) const_my_int v_const_my_int (1); volatile_my_int v_volatile_my_int (2); const_volatile_my_int v_const_volatile_my_int (3); volatile_const_my_int v_volatile_const_my_int (4); diff --git gdb/testsuite/gdb.python/py-prettyprint.c gdb/testsuite/gdb.python/py-prettyprint.c index 0fd05f5..817bf33 100644 --- gdb/testsuite/gdb.python/py-prettyprint.c +++ gdb/testsuite/gdb.python/py-prettyprint.c @@ -230,7 +230,7 @@ struct nullstr struct string_repr string_1 = { { "one" } }; struct string_repr string_2 = { { "two" } }; -static int +int eval_func (int p1, int p2, int p3, int p4, int p5, int p6, int p7, int p8) { return p1; diff --git gdb/testsuite/gdb.trace/actions.c gdb/testsuite/gdb.trace/actions.c index 04c69f2..497d04d 100644 --- gdb/testsuite/gdb.trace/actions.c +++ gdb/testsuite/gdb.trace/actions.c @@ -116,7 +116,7 @@ unsigned long gdb_c_test( unsigned long *parm ) return ( (unsigned long) 0 ); } -static void gdb_asm_test (void) +void gdb_asm_test (void) { }