From patchwork Thu Jun 27 06:37:20 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Indu Bhagat X-Patchwork-Id: 1123149 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-503843-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=oracle.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="XrwKqYJg"; dkim=pass (2048-bit key; unprotected) header.d=oracle.com header.i=@oracle.com header.b="4tAmJKQJ"; dkim-atps=neutral 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 ozlabs.org (Postfix) with ESMTPS id 45Z9FZ2L1rz9s4Y for ; Thu, 27 Jun 2019 16:38:10 +1000 (AEST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:subject:date:message-id; q=dns; s=default; b=GdunBl2zi8Cf3eP RqKTkFuxEouEsdsEslkn4FEWOP1Hc8P51gt/M9N8HdaN5je862Bld3XBtUcE17+1 +WWPYADAGuTkvTPohaI5aaYuy67qA4MhGTpCu8O9CxH0X0uelp8PAOXthOoqf1rz oxTHk7OfBR2dxa5Ps+DbWrq7dc8c= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:subject:date:message-id; s=default; bh=HhDf+kI3JUwrH0/EEPN+G zBCd9Y=; b=XrwKqYJgprVNggTh2orpdViW9gulDWTRpBdOdEZJGGohb+WfxrMGZ TQneqQ/ZDQcYUl8XAhD7bUTgatQr1aJ/K//Vl9XnK8GM/yLSBhD7QyMwHfNBIJuA O746vCWjEbhV9XtJsNK+iERDr3JsDs/gS6kzKqdfJCT4tgWzgLkR7g= Received: (qmail 108117 invoked by alias); 27 Jun 2019 06:37:39 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 108000 invoked by uid 89); 27 Jun 2019 06:37:38 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-10.5 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_3, KAM_SHORT, SPF_HELO_PASS, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 spammy=H*r:8.14.4 X-HELO: userp2120.oracle.com Received: from userp2120.oracle.com (HELO userp2120.oracle.com) (156.151.31.85) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 27 Jun 2019 06:37:36 +0000 Received: from pps.filterd (userp2120.oracle.com [127.0.0.1]) by userp2120.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x5R6Y1vi027437; Thu, 27 Jun 2019 06:37:34 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : subject : date : message-id; s=corp-2018-07-02; bh=YtUD3gMXjczo9s0rrZbgvLSumD9aYx/hRYWVOUeKehU=; b=4tAmJKQJ145F7imD9kP+876T7TWbM0Ymvdhg6TP23MvvK7MLzqj7eymCOyeepZrN0viA 34ygpQgo9E8AN9PxLheiOTbcfI34c12tT2+WBHJnXQuIkVSyJ4qLYSUHmSFsh9kMSr/j sxqoJL4tTgF5nQZYQ1c32gtazBM49/Agwg5fAct1TVdgWtOUCDHDddZ0heCkJV1gXIPU YHKpwAhRRp4rccnRW9TInDz3wl9j5xCQJZHoXNHyKgKyzpylv/czvjBTL4/tGFOUcbV9 MrNzIICWZ2jdbfh+JXOhLlzpgJhKy4xihlW2i8Keo0HdLr8tA3dwku/nrGNNcIjT40pA xQ== Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by userp2120.oracle.com with ESMTP id 2t9cyqp81t-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 27 Jun 2019 06:37:34 +0000 Received: from pps.filterd (userp3030.oracle.com [127.0.0.1]) by userp3030.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x5R6ZxNH091172; Thu, 27 Jun 2019 06:37:33 GMT Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by userp3030.oracle.com with ESMTP id 2t99f4u8ud-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 27 Jun 2019 06:37:33 +0000 Received: from abhmp0012.oracle.com (abhmp0012.oracle.com [141.146.116.18]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id x5R6bUkn006837; Thu, 27 Jun 2019 06:37:32 GMT Received: from ibhagatpc.us.oracle.com (/10.159.231.47) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Wed, 26 Jun 2019 23:37:30 -0700 From: Indu Bhagat To: gcc-patches@gcc.gnu.org, richard.guenther@gmail.com Subject: [PATCH,RFC,V3 0/5] Support for CTF in GCC Date: Wed, 26 Jun 2019 23:37:20 -0700 Message-Id: <1561617445-9328-1-git-send-email-indu.bhagat@oracle.com> Hello, This patch series adds support for CTF generation in GCC. [Changes from V2] - Patch 1, 2, and 3 have minor edits if any. - Patch 4 is a new addition. - Patch 5 is a new addition. Summary of the GCC RFC V3 patch set : Patch 1, 2, and 3 do the preparatory work of adding the CTF command line options and setting up the framework for CTF generation and emission. More details on these patches can be seen in the previous posting https://gcc.gnu.org/ml/gcc-patches/2019-06/msg00718.html With Patch 4 in the current set, the compiler can generate a .ctf section for a single compilation unit if -gt (when unspecified, LEVEL defaults to 2) or -gt2 is specified. Recall that -gt2 produces type information for entities (functions, variables etc.) at file-scope or global-scope. For each translation unit, a CTF container (ctf_container_t) is used to keep the generated CTF. Two hash_map structures are kept to hold the generated CTF for type and variables. CTF does need pre-processing before emission into a section; there are code comments in ctfout.c to help understand this. There are a couple of TBDs and FIXMEs in Patch 4 which will be resolved as I progress further; Inputs on some of which will be very helpful : - ctf_dtdef_hash : The compiler uses a hashing scheme to keep track of whether CTF has been generated for a type of decl. For a type, the hashing scheme uses TYPE_UID, but for a decl it uses htab_hash_pointer (decl). Is there a better way to do this ? (See hash_dtd_tree_decl in ctfout.c) - delete_ctf_container routine in ctfout.c : I have used the GTY (()) tags in the CTF container structs. Does this ensure that if I set the CTF container global variable (ctfc) to NULL, the garbage collection machinery will take care of cleaning up the the internals of the container (including hash_map). Haven't been able to get a definitive answer looking at the code in hash-map.h and the generated code in gtype-desc.c. Testing : - Bootstrapped and regression tested on x86_64/linux and aarch64/linux. Also bootstrapped on SPARC64/linux with some testing. - Parsed .ctf sections of libdtrace-ctf files via a CTF dumping utility on x86_64/linux. This simply ensures that the CTF sections are well-formed. - Interaction with an internally available GDB looks promising. Basic whatis and ptype tests work. GDB patches to uptake CTF debug info are in the works and will be upstreamed soon. In the subsequent patches, I intend to close some open ends in the current patch and add LTO support. Thanks, Indu Bhagat (5): Add new function lang_GNU_GIMPLE Add CTF command line options : -gtLEVEL Setup for CTF generation and emission CTF generation for a single compilation unit Update CTF testsuite gcc/ChangeLog | 91 + gcc/Makefile.in | 5 + gcc/cgraphunit.c | 12 +- gcc/common.opt | 9 + gcc/ctfcreate.c | 526 ++++++ gcc/ctfout.c | 1739 ++++++++++++++++++++ gcc/ctfout.h | 359 ++++ gcc/ctfutils.c | 198 +++ gcc/doc/invoke.texi | 16 + gcc/flag-types.h | 13 + gcc/gengtype.c | 4 +- gcc/langhooks.c | 9 + gcc/langhooks.h | 1 + gcc/opts.c | 26 + gcc/passes.c | 7 +- gcc/testsuite/ChangeLog | 35 + gcc/testsuite/gcc.dg/debug/ctf/ctf-1.c | 6 + gcc/testsuite/gcc.dg/debug/ctf/ctf-2.c | 10 + .../gcc.dg/debug/ctf/ctf-anonymous-struct-1.c | 23 + .../gcc.dg/debug/ctf/ctf-anonymous-union-1.c | 26 + gcc/testsuite/gcc.dg/debug/ctf/ctf-array-1.c | 31 + gcc/testsuite/gcc.dg/debug/ctf/ctf-bitfields-1.c | 30 + gcc/testsuite/gcc.dg/debug/ctf/ctf-bitfields-2.c | 39 + gcc/testsuite/gcc.dg/debug/ctf/ctf-cvr-quals-1.c | 44 + gcc/testsuite/gcc.dg/debug/ctf/ctf-cvr-quals-2.c | 30 + gcc/testsuite/gcc.dg/debug/ctf/ctf-cvr-quals-3.c | 41 + gcc/testsuite/gcc.dg/debug/ctf/ctf-enum-1.c | 21 + gcc/testsuite/gcc.dg/debug/ctf/ctf-float-1.c | 16 + gcc/testsuite/gcc.dg/debug/ctf/ctf-forward-1.c | 36 + gcc/testsuite/gcc.dg/debug/ctf/ctf-forward-2.c | 16 + .../gcc.dg/debug/ctf/ctf-function-pointers-1.c | 24 + gcc/testsuite/gcc.dg/debug/ctf/ctf-functions-1.c | 34 + gcc/testsuite/gcc.dg/debug/ctf/ctf-int-1.c | 17 + gcc/testsuite/gcc.dg/debug/ctf/ctf-pointers-1.c | 26 + gcc/testsuite/gcc.dg/debug/ctf/ctf-preamble-1.c | 11 + gcc/testsuite/gcc.dg/debug/ctf/ctf-str-table-1.c | 26 + gcc/testsuite/gcc.dg/debug/ctf/ctf-struct-1.c | 25 + gcc/testsuite/gcc.dg/debug/ctf/ctf-struct-2.c | 30 + .../gcc.dg/debug/ctf/ctf-struct-array-1.c | 36 + gcc/testsuite/gcc.dg/debug/ctf/ctf-typedef-1.c | 23 + .../gcc.dg/debug/ctf/ctf-typedef-struct-1.c | 12 + gcc/testsuite/gcc.dg/debug/ctf/ctf-union-1.c | 14 + gcc/testsuite/gcc.dg/debug/ctf/ctf-variables-1.c | 25 + gcc/testsuite/gcc.dg/debug/ctf/ctf.exp | 41 + gcc/testsuite/gcc.dg/debug/dwarf2-ctf-1.c | 7 + gcc/toplev.c | 18 + include/ChangeLog | 8 + include/ctf.h | 487 ++++++ 48 files changed, 4277 insertions(+), 6 deletions(-) create mode 100644 gcc/ctfcreate.c create mode 100644 gcc/ctfout.c create mode 100644 gcc/ctfout.h create mode 100644 gcc/ctfutils.c create mode 100644 gcc/testsuite/gcc.dg/debug/ctf/ctf-1.c create mode 100644 gcc/testsuite/gcc.dg/debug/ctf/ctf-2.c create mode 100644 gcc/testsuite/gcc.dg/debug/ctf/ctf-anonymous-struct-1.c create mode 100644 gcc/testsuite/gcc.dg/debug/ctf/ctf-anonymous-union-1.c create mode 100644 gcc/testsuite/gcc.dg/debug/ctf/ctf-array-1.c create mode 100644 gcc/testsuite/gcc.dg/debug/ctf/ctf-bitfields-1.c create mode 100644 gcc/testsuite/gcc.dg/debug/ctf/ctf-bitfields-2.c create mode 100644 gcc/testsuite/gcc.dg/debug/ctf/ctf-cvr-quals-1.c create mode 100644 gcc/testsuite/gcc.dg/debug/ctf/ctf-cvr-quals-2.c create mode 100644 gcc/testsuite/gcc.dg/debug/ctf/ctf-cvr-quals-3.c create mode 100644 gcc/testsuite/gcc.dg/debug/ctf/ctf-enum-1.c create mode 100644 gcc/testsuite/gcc.dg/debug/ctf/ctf-float-1.c create mode 100644 gcc/testsuite/gcc.dg/debug/ctf/ctf-forward-1.c create mode 100644 gcc/testsuite/gcc.dg/debug/ctf/ctf-forward-2.c create mode 100644 gcc/testsuite/gcc.dg/debug/ctf/ctf-function-pointers-1.c create mode 100644 gcc/testsuite/gcc.dg/debug/ctf/ctf-functions-1.c create mode 100644 gcc/testsuite/gcc.dg/debug/ctf/ctf-int-1.c create mode 100644 gcc/testsuite/gcc.dg/debug/ctf/ctf-pointers-1.c create mode 100644 gcc/testsuite/gcc.dg/debug/ctf/ctf-preamble-1.c create mode 100644 gcc/testsuite/gcc.dg/debug/ctf/ctf-str-table-1.c create mode 100644 gcc/testsuite/gcc.dg/debug/ctf/ctf-struct-1.c create mode 100644 gcc/testsuite/gcc.dg/debug/ctf/ctf-struct-2.c create mode 100644 gcc/testsuite/gcc.dg/debug/ctf/ctf-struct-array-1.c create mode 100644 gcc/testsuite/gcc.dg/debug/ctf/ctf-typedef-1.c create mode 100644 gcc/testsuite/gcc.dg/debug/ctf/ctf-typedef-struct-1.c create mode 100644 gcc/testsuite/gcc.dg/debug/ctf/ctf-union-1.c create mode 100644 gcc/testsuite/gcc.dg/debug/ctf/ctf-variables-1.c create mode 100644 gcc/testsuite/gcc.dg/debug/ctf/ctf.exp create mode 100644 gcc/testsuite/gcc.dg/debug/dwarf2-ctf-1.c create mode 100644 include/ctf.h