From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by sourceware.org (Postfix) with ESMTPS id CBF0E3855022 for ; Wed, 7 Jul 2021 00:09:27 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org CBF0E3855022 Received: from pps.filterd (m0246629.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.16.0.43/8.16.0.43) with SMTP id 1670255F028601 for ; Wed, 7 Jul 2021 00:09:26 GMT Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by mx0b-00069f02.pphosted.com with ESMTP id 39kq8ec0gh-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Wed, 07 Jul 2021 00:09:26 +0000 Received: from pps.filterd (userp3020.oracle.com [127.0.0.1]) by userp3020.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 16700Wsu093641 for ; Wed, 7 Jul 2021 00:09:24 GMT Received: from nam10-bn7-obe.outbound.protection.outlook.com (mail-bn7nam10lp2107.outbound.protection.outlook.com [104.47.70.107]) by userp3020.oracle.com with ESMTP id 39k1nw1hcq-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Wed, 07 Jul 2021 00:09:24 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=jHqt/sihP0mmU5yOPYOLdhn5eLe86TL5oE7V29M8G0Qd3Pnr1NiLxdCbSTV9prVj19UWqZOn4QFASi3VPjyfYBI9/pDewW0CVhPpR7QlxAKv+4VSnBApLHk3FcULIyg75hX0iqeoWAVYj1yuk86WRDKzRzBAMLz/TB/WCAiZ/JPyldSM+Kt2d5rPyMKrH/asSiOWsFotsX6j59YZXxSbysTkW+NV98T6lLDUPzgcIJtHTArKUi3kpYwJPwxN6QxBMd2Fl5DOQL+4B408NoPj1qN4Bi+CX4t/nVbqU3d7ExHyBVj/0+SN4HU94eie6diiR2cgmh0QsoNl9RZQjxeaqg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=FsXYa/E8gSqYzBkr3+/JwxvAgOWO8EJ1qzBe61IGYvQ=; b=ZZhB35x8ZZY0sP33Hk6LfqXnO9+AeK08/CA8wfe4TIUlgcCQU9V8kHpHja+Of7mNwXD+lxo/ev/NToSYzKUqG+xflhp6MNBPmXWpYW0CEYzTY2gsD9Qiu2mtVSTjfCVRFqIJk2JQgwlZmAvNOFErRn5JjahVEi1ZUYdTyJQkpA4meA2BbYjjwSUr/v3TD2bNX1c35KBYZlfsW5hpBKrBVoXMNzIYAYhBVnjXWIvA43Fp6TtD04+E0stfPYJTyb1jDcdSDk7t9MFft6diUZqtZyWzNBu4M8boFdLL/CDOHrDxIv5h0F7rHoVjSVtfwFOmPNfBDSCXLS+SBsLgl9E/Ow== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none Received: from BN6PR10MB1748.namprd10.prod.outlook.com (2603:10b6:405:9::16) by BN0PR10MB5174.namprd10.prod.outlook.com (2603:10b6:408:126::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4287.23; Wed, 7 Jul 2021 00:09:22 +0000 Received: from BN6PR10MB1748.namprd10.prod.outlook.com ([fe80::ece6:fc47:e567:4335]) by BN6PR10MB1748.namprd10.prod.outlook.com ([fe80::ece6:fc47:e567:4335%7]) with mapi id 15.20.4287.033; Wed, 7 Jul 2021 00:09:21 +0000 Subject: [PING 2][PATCH V7] CTF: multi-CU and archive support To: gdb-patches@sourceware.org Cc: nick.alcock@oracle.com References: <1625009490-2088-1-git-send-email-weimin.pan@oracle.com> <88d4ff85-9642-9648-088a-47ccd30ec024@oracle.com> From: Weimin Pan Message-ID: <6f12de99-4898-cb5e-ba1d-710e3b7bcea0@oracle.com> Date: Tue, 6 Jul 2021 17:09:03 -0700 User-Agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.11.0 In-Reply-To: <88d4ff85-9642-9648-088a-47ccd30ec024@oracle.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-US X-ClientProxiedBy: SJ0PR13CA0236.namprd13.prod.outlook.com (2603:10b6:a03:2c1::31) To BN6PR10MB1748.namprd10.prod.outlook.com (2603:10b6:405:9::16) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from [172.27.35.125] (108.88.88.153) by SJ0PR13CA0236.namprd13.prod.outlook.com (2603:10b6:a03:2c1::31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4308.8 via Frontend Transport; Wed, 7 Jul 2021 00:09:20 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: a601f9f1-2999-4620-a896-08d940db785f X-MS-TrafficTypeDiagnostic: BN0PR10MB5174: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:626; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: =?utf-8?B?dDNDOWVhY25TUE5OWmYzWFpVbDkzUXRpTWxIaXNYNFFFMGVFNHVSa0Z5R0pv?= =?utf-8?B?YzN6c1lyd1BJUU5PZ3ZRZ2pOSVlTUXpPbmhLeHZRSTU3UC9OR3Y0bXRFazV5?= =?utf-8?B?SkhtcDlDT0NJdnNVcVpFOUtidEg5dXNTbmprdlRoYys4cWlCVnBwcWUvb0s4?= =?utf-8?B?Zi9lSGN5SC90ZzBmeFZVU0pwNVdJQ1dtVURNcEhFSjF1VnB0SEpIWWlVblpN?= =?utf-8?B?Tk9ONEFBTlc1RlNhSFMyemxNeXNmR1FGS1ViY2xGUTJnM2Q0L1NiVjhxOWpP?= =?utf-8?B?VDBhUEVTdjRCMm5NMzBuUkNDT1REamxtc0pwSXVwemw5QUR3QUo5bEdXcE5x?= =?utf-8?B?bDVCTmRXK0RwdVhQejA2TC9rS08wQlFmSzVwd2Rrd2ptb3g1TWxrN1orazZH?= =?utf-8?B?Wk4xU25ydUp1OXRKTVFvWmN6OVRvcVIxbGE5VjdQZzlEQ1pJaGlPVDBneHVs?= =?utf-8?B?eWpvZDJnYjJpMzZGdlUrV2c0TVRUcXFDb3RudGJCSWtYOVcrSE10Y0pPc2pP?= =?utf-8?B?YzBib0JYaElEeFdwaEptNkRaOXhVb0ZXamRoZ1dNYVlYcnJQdHlZbXVicnZa?= =?utf-8?B?OXI3L2ZHbGNpUTFwNUNuTHdJRG9mVEF3cmFEVUcxcGEvTE1oalMzbE1OSWRx?= =?utf-8?B?d095aVAwRFFiblViRzAyVXhYV3lMODN5Zzc4S2RuTG5sK09EaURTR21BZUo0?= =?utf-8?B?S3M3RWwvb2VBdTd0ZWFTQkROUHpHeVJycEZtTFVTUlhCdmFpeVJwTE9sa2JY?= =?utf-8?B?OVZIa2RETnk1Y2V6SFZ3SXJIYXlaSVdHS0RtL0FOM1BoWmt0MG9JRUdvWU9t?= =?utf-8?B?WHFONlhxWGJBRENjcTFCcHRFa3BtZ1lQYXNMTlpOckE5cVVDNGoxOVJxQ2RW?= =?utf-8?B?bURlTEliaERrcTRrMVFNWVNvRkVkN29CaERtY05mclROdnBHblVwa1RsdFFz?= =?utf-8?B?dkd1VkkwanZ6Vng0L2FsdWkxaFpqT2s4cG9JTklhZHc0Z3U5cXVHaVVkd290?= =?utf-8?B?KzVBczA0MC9mUzFQMEN3L215VS9sNlh4bFdXWHZsTmdwc3NWYlRsdC9UeDBs?= =?utf-8?B?VHc4Q1RsbW9KbHR0OGMxeVkyR21xZkdkQkJYZXRBemJVbVlST3hJQnArZGhB?= =?utf-8?B?WldqVkcrL0t1dEQ0TzcrRnVjZnQ0bThwL2lOSDFhRVhVUFYvaWxHaTRSOWQ5?= =?utf-8?B?SUpjMytBV2FGQXJJNmVoMUw0ZFBaSU1zU0VBWnV5ZWRmOUoxdXpXWTEwRU4w?= =?utf-8?B?cUVkVDVVWG1HWElyWG9IQ2FhTWRwNTlsbk9RakE4eU9jZFF3dmpSTWVVKzZS?= =?utf-8?B?cWlHeFRjcFRDaUdHVGkzS25nN0ZGVWM5YXQ3N05KU3pmVGJ2eWcyNTN0aXZE?= =?utf-8?B?YXVnRDhUSW5nY2c9PQ==?= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:BN6PR10MB1748.namprd10.prod.outlook.com; PTR:; CAT:NONE; SFS:(346002)(39860400002)(366004)(376002)(396003)(136003)(966005)(5660300002)(66946007)(66476007)(38350700002)(38100700002)(86362001)(26005)(6666004)(2906002)(186003)(53546011)(66556008)(8936002)(107886003)(31686004)(30864003)(52116002)(31696002)(478600001)(83380400001)(4326008)(16576012)(316002)(2616005)(44832011)(6486002)(956004)(8676002)(36756003)(6916009)(2004002)(43740500002)(45980500001)(579004); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?ZHp2amdYN0dRbENVOUhWbGFvTHBHVXdzM0N4TlplUXpuakNRNVhPZDdsdWlv?= =?utf-8?B?NFY2OUU5VGVIZkdlOVdoRDhuKzNpUHJ4Mi8yd0ZKRzJKeXlQMWtPMTIveU96?= =?utf-8?B?cTg1VVFIK3pmdXRmZWpCM3BBalp2cVFFbmduUHM0dmNBSldvT0sweXNUd0Rk?= =?utf-8?B?MTVIMEtLZHRpeWdLbkFaSS8vazZOS2pDbFFmaWxSUy95L1phSHdiMTVFUmEw?= =?utf-8?B?U2F2YW5LQjNCb3kwL1RqRFZyL2pIQ0pTZlhna2tHdm5vb3gycjNDcTFZQXZy?= =?utf-8?B?TDZtQ0ZyZnZOU1gyMk9IYXhkQUdHYk0yeEVPV1UzWEFnd0hLanpBWE9zNGFJ?= =?utf-8?B?WGpqSCtIakdnYjNtZUtrUnYyTThOZVhualBTL0JDeEE0RWxXcTQ3K1A4Nkd3?= =?utf-8?B?YUx2aVVnZ05DSFNJbHdsa0hVNGxiUGxmdUcxQkFwcDJJaW1mSnFIYzFmNTky?= =?utf-8?B?TFo5ZFBXSGIrV01RcUlnOGxJMzFjZm5lcktKbHZRR29GQ0dsd1N1WkJRb2Ri?= =?utf-8?B?V1N1aXBHMGpVZU9VMVhBK1k2dTVrWGF5Z0FSay9HNlNGcmRwbDdYUkR6b3ZE?= =?utf-8?B?Z0d6QUQzZTJqTmdNOUU5T3NDT01mQXAzTU9sWDFrcTNvaS9ZWVp0dTY2Q1lo?= =?utf-8?B?MktGRFRpN3YzYlBDS01Kek1qN1N5TkNOcVNKQ0xiY0VkaUcxdnZlaVEvWXk5?= =?utf-8?B?OCtreUNQSXhwbjY3WlhqL2Evc0picG5NeHRHOGVjRkV2alNsQTB4VVFISjU5?= =?utf-8?B?b1pFVlVqd1A1UkNjRGpPU1RtaEdzamY1Q3IvK0lTajl0RWVNRW5PdnlwNlA1?= =?utf-8?B?MVV1R01YUTJvL3AzeXY0ZWdOTlh0SXdpN09WZ1ZNcnNOMENETWE1dHJGbzdl?= =?utf-8?B?TjR5SDRyQnZrSURTbUdQVG1Fd1RjUUxaZHBrMzlGenV6UHlHWldxcE1ZTmZu?= =?utf-8?B?aVpLbTBaalZoWjFNT05mZVMwZW1Yd3JicnRDY2hhZUNEM0NJY3d5WCtIUC82?= =?utf-8?B?ME95OUNQZFBVNHRLL1dQaGxsazN3SzVmOUFJaWFKdGhPZG1qVW9uNWRwejc2?= =?utf-8?B?Z0RyTDZrdlJ3ZWlUcnRZdUVsM2Q1aHpPdGlVSlROUTZobVZRNlZqSExocmtK?= =?utf-8?B?SnhrTENRdllNQ2hzcytMS3QvTDZFOTdFd1Z0WnFaTVlZdzZMU2Mwd0dMdXk4?= =?utf-8?B?RTZBcFFIVmlOK09iUFBoSjZ0eUxUT2ltTS9tejJwR1grT0hLUHROa0liVWNS?= =?utf-8?B?WkpRYUxCZ3UyVitCdVVpQ2huNDRLdmZUYWQ1NDQ0R0s0Z3A0ZzJDdGtvNUt5?= =?utf-8?B?VnhkcmdqMFVqdGE3TEh1ZTg5Q3lEQkdud210OURQTHAxeFVqL0llc3FHcit1?= =?utf-8?B?NzdKNldDQWg4Q0FUYm1MSjM4Z3F0V2gxaU1sWE9ZTldoUG4wbmtpYmZKN2d5?= =?utf-8?B?YXEzS092V3FIcTNvQ0NFb3NKMWQ2YlRUNW5LdmhKZDFlaHRCL1ZySExXOEhl?= =?utf-8?B?eSthUmEvaHphRE5rYTdDcjR5OXY4cXlaU1JHRU5ia2V1L2RaNWR6Z3V5eU1Y?= =?utf-8?B?QjRwVWJKZ1RzRzZkVTRKdjhYRWhrSFo4amExMS9EYlNSYm83eVF1OXluSG9q?= =?utf-8?B?amYxMlpMM2J5MERWTlVwZmtrS0pJckNBWGFDNnFqT0U0SDdqMDhPNlU4ZHhP?= =?utf-8?B?SkZCV3BaVUN0c29GV2JtQlpjSnd4RiswYVdYcTY0OHBRSEthSzU0d1BTMWYv?= =?utf-8?Q?cytJ+GPkRHTP9/XAUd91eAvoASFMjdS0wX+TD2H?= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: a601f9f1-2999-4620-a896-08d940db785f X-MS-Exchange-CrossTenant-AuthSource: BN6PR10MB1748.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Jul 2021 00:09:21.8473 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4e2c6054-71cb-48f1-bd6c-3a9705aca71b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: L4KGT0O4aw8kh7qOBmwDJeLP3LJ5dIkIZKjNWv21jd6oy3h424/SVZaIrpMTLmqBYtUWfsPdEGv+VewMGUmVPw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN0PR10MB5174 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=10037 signatures=668682 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 spamscore=0 phishscore=0 adultscore=0 suspectscore=0 mlxscore=0 mlxlogscore=999 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2104190000 definitions=main-2107060114 X-Proofpoint-GUID: VJxzRdeDcjWMNFdaUvGF4xCLgh1qvq8X X-Proofpoint-ORIG-GUID: VJxzRdeDcjWMNFdaUvGF4xCLgh1qvq8X X-Spam-Status: No, score=-8.7 required=5.0 tests=BAYES_00, BODY_8BITS, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, KAM_STOCKGEN, MSGID_FROM_MTA_HEADER, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 07 Jul 2021 00:09:33 -0000 On 7/2/2021 4:42 PM, Weimin Pan via Gdb-patches wrote: > > On 6/29/2021 4:31 PM, Weimin Pan via Gdb-patches wrote: >> [Changes from V6: >>   - The CTF/BTF support in GCC was pushed upstream yesterday: >> https://urldefense.com/v3/__https://gcc.gnu.org/pipermail/gcc-patches/2021-June/573851.html__;!!ACWV5N9M2RV99hQ!d-eHRETgxNsmbtvaW-Y592cZ4ywMpnBOauNulLcwDll70oyaH0cSKZn7wdOpeEp6$ >> . >>     Made the following changes after running the testsuite against it: >>     - Replaced -gt with -gctf. >>     - Fixed a type ordering difference concerning function arguments.] >> >> [Changes from V5: >>   - Remove the incorrect ctf_ref call which bumps the refcnt of a >> ctf_dict_t, >>     referring to an archive's source file. >>   - Change struct ctf_psymtab member to "struct ctf_context context;".] >> >> [Changes from V4: >>   - Treat CTF archives as CUs over dependencies to avoid over-expanding >>     psymtabs, as Tom Tromey pointed out. >>   - Avoid calling ctf_dict_close more than once on a dictionary.] >> >> Now gdb is capable of debugging executable, which consists of multiple >> compilation units (CUs) with the CTF debug info. An executable could >> potentially have one or more archives, which, in CTF context, contain >> conflicting types. >> >> all changes were made in ctfread.c in which elfctf_build_psymtabs was >> modified to handle archives, via the ctf archive iterator and its >> callback >> build_ctf_archive_member and scan_partial_symbols was modified to scan >> archives, which are treated as subfiles, to build the psymtabs. >> >> Also changes were made to handle CTF's data object section and function >> info section which now share the same format of their contents - an >> array >> of type IDs. New functions ctf_psymtab_add_stt_entries, which is >> called by >> ctf_psymtab_add_stt_obj and ctf_psymtab_add_stt_func, and >> add_stt_entries, >> which is called by add_stt_obj and add_stt_func when setting up psymtabs >> and full symtab, respectively. >> --- >>   gdb/ChangeLog                             |  16 ++ >>   gdb/ctfread.c                             | 335 >> +++++++++++++++++------------- >>   gdb/testsuite/ChangeLog                   |   9 + >>   gdb/testsuite/gdb.base/ctf-constvars.exp  |   4 +- >>   gdb/testsuite/gdb.base/ctf-ptype.exp      |   4 +- >>   gdb/testsuite/gdb.ctf/cross-tu-cyclic-1.c |  18 ++ >>   gdb/testsuite/gdb.ctf/cross-tu-cyclic-2.c |  16 ++ >>   gdb/testsuite/gdb.ctf/cross-tu-cyclic-3.c |   3 + >>   gdb/testsuite/gdb.ctf/cross-tu-cyclic-4.c |   4 + >>   gdb/testsuite/gdb.ctf/cross-tu-cyclic.exp |  43 ++++ >>   gdb/testsuite/gdb.ctf/ctf-a.c             |  32 +++ >>   gdb/testsuite/gdb.ctf/ctf-a.h             |  22 ++ >>   gdb/testsuite/gdb.ctf/ctf-b.c             |  25 +++ >>   gdb/testsuite/gdb.ctf/ctf-b.h             |  22 ++ >>   gdb/testsuite/gdb.ctf/ctf-c.c             |  25 +++ >>   gdb/testsuite/gdb.ctf/ctf-c.h             |  21 ++ >>   gdb/testsuite/gdb.ctf/funcreturn.exp      |   4 +- >>   gdb/testsuite/gdb.ctf/multi.exp           |  42 ++++ >>   gdb/testsuite/lib/gdb.exp                 |   4 +- >>   19 files changed, 497 insertions(+), 152 deletions(-) >>   create mode 100644 gdb/testsuite/gdb.ctf/cross-tu-cyclic-1.c >>   create mode 100644 gdb/testsuite/gdb.ctf/cross-tu-cyclic-2.c >>   create mode 100644 gdb/testsuite/gdb.ctf/cross-tu-cyclic-3.c >>   create mode 100644 gdb/testsuite/gdb.ctf/cross-tu-cyclic-4.c >>   create mode 100644 gdb/testsuite/gdb.ctf/cross-tu-cyclic.exp >>   create mode 100644 gdb/testsuite/gdb.ctf/ctf-a.c >>   create mode 100644 gdb/testsuite/gdb.ctf/ctf-a.h >>   create mode 100644 gdb/testsuite/gdb.ctf/ctf-b.c >>   create mode 100644 gdb/testsuite/gdb.ctf/ctf-b.h >>   create mode 100644 gdb/testsuite/gdb.ctf/ctf-c.c >>   create mode 100644 gdb/testsuite/gdb.ctf/ctf-c.h >>   create mode 100644 gdb/testsuite/gdb.ctf/multi.exp >> >> diff --git a/gdb/ChangeLog b/gdb/ChangeLog >> index 81e9dd5..964dc20 100644 >> --- a/gdb/ChangeLog >> +++ b/gdb/ChangeLog >> @@ -1,3 +1,19 @@ >> +2021-06-28  Weimin Pan  >> + >> +    * ctfread.c (ctf_per_tu_data): New struct. >> +    (add_stt_entries): New funtion. >> +    (add_stt_obj): Use it. >> +    (add_stt_func): Likewise. >> +    (ctf_psymtab_add_stt_entries): New function. >> +    (ctf_psymtab_add_stt_obj): Use it. >> +    (ctf_psymtab_add_stt_func): Likewise. >> +    (ctf_psymtab::expand_psymtab): Call expand_dependencies to expand >> +    archives. >> +    (scan_partial_symbols): Set up partial symtab list. >> +    (build_ctf_archive_member): New function. >> +    (elfctf_build_psymtabs): Call Iterater to set up archives. >> +    (read_func_kind_type): Handle argument's forward reference type. >> + >>   2021-05-16  Weimin Pan  >>         * ctfread.c (new_symbol): Set function address. >> diff --git a/gdb/ctfread.c b/gdb/ctfread.c >> index 23e859a..498c9bf 100644 >> --- a/gdb/ctfread.c >> +++ b/gdb/ctfread.c >> @@ -117,6 +117,7 @@ struct ctf_context >>     struct objfile *of; >>     psymtab_storage *partial_symtabs; >>     partial_symtab *pst; >> +  ctf_archive_t *arc; >>     struct buildsym_compunit *builder; >>   }; >>   @@ -134,7 +135,7 @@ struct ctf_psymtab : public standard_psymtab >>     void read_symtab (struct objfile *) override; >>     void expand_psymtab (struct objfile *) override; >>   -  struct ctf_context *context; >> +  struct ctf_context context; >>   }; >>     /* The routines that read and process fields/members of a C >> struct, union, >> @@ -166,6 +167,16 @@ struct ctf_field_info >>     std::vector nested_types_list; >>   }; >>   +/* Data held for a translation unit.  */ >> + >> +struct ctf_per_tu_data >> +{ >> +  ctf_dict_t *fp; >> +  struct objfile *of; >> +  ctf_archive_t *arc; >> +  psymtab_storage *pss; >> +  psymbol_functions *psf; >> +}; >>     /* Local function prototypes */ >>   @@ -245,10 +256,8 @@ struct ctf_tid_and_type >>     ids.tid = tid; >>     ids.type = typ; >>     slot = (struct ctf_tid_and_type **) htab_find_slot (htab, &ids, >> INSERT); >> -  if (*slot) >> -    complaint (_("An internal GDB problem: ctf_ id_t %ld type >> already set"), >> -           (tid)); >> -  *slot = XOBNEW (&of->objfile_obstack, struct ctf_tid_and_type); >> +  if (*slot == nullptr) >> +    *slot = XOBNEW (&of->objfile_obstack, struct ctf_tid_and_type); >>     **slot = ids; >>     return typ; >>   } >> @@ -510,7 +519,7 @@ struct ctf_tid_and_type >>           break; >>       } >>   -      add_symbol_to_list (sym, ccp->builder->get_global_symbols ()); >> +      add_symbol_to_list (sym, ccp->builder->get_file_symbols ()); >>       } >>       return sym; >> @@ -706,6 +715,8 @@ struct ctf_tid_and_type >>         for (int iparam = 0; iparam < argc; iparam++) >>       { >>         atype = get_tid_type (of, argv[iparam]); >> +      if (atype == nullptr)        /* A forward reference type?  */ >> +        atype = read_type_record (ccp, argv[iparam]); >>         if (atype != nullptr) >>           type->field (iparam).set_type (atype); >>         else >> @@ -1140,10 +1151,11 @@ struct ctf_tid_and_type >>         case CTF_K_CONST: >>         case CTF_K_POINTER: >>         case CTF_K_ARRAY: >> -    if (type) >> +    if (type != nullptr) >>         { >>           sym = new_symbol (ccp, type, id); >> -        sym->compute_and_set_names (name, false, ccp->of->per_bfd); >> +        if (sym != nullptr) >> +          sym->compute_and_set_names (name, false, ccp->of->per_bfd); >>         } >>       break; >>         case CTF_K_STRUCT: >> @@ -1160,7 +1172,7 @@ struct ctf_tid_and_type >>       SYMBOL_DOMAIN (sym) = VAR_DOMAIN; >>       SYMBOL_ACLASS_INDEX (sym) = LOC_OPTIMIZED_OUT; >>       sym->compute_and_set_names (name, false, ccp->of->per_bfd); >> -    add_symbol_to_list (sym, ccp->builder->get_global_symbols ()); >> +    add_symbol_to_list (sym, ccp->builder->get_file_symbols ()); >>       break; >>         default: >>       complaint (_("ctf_add_var_cb: kind unsupported (%d)"), kind); >> @@ -1173,81 +1185,48 @@ struct ctf_tid_and_type >>     return 0; >>   } >>   -/* Add an ELF STT_OBJ symbol with index IDX to the symbol table.  */ >> +/* Add entries in either data objects or function info section, >> controlled >> +   by FUNCTIONS.  */ >>   -static struct symbol * >> -add_stt_obj (struct ctf_context *ccp, unsigned long idx) >> +static void >> +add_stt_entries (struct ctf_context *ccp, int functions) >>   { >> -  struct symbol *sym; >> -  struct type *type; >> +  ctf_next_t *i = nullptr; >> +  const char *tname; >>     ctf_id_t tid; >> +  struct symbol *sym = nullptr; >> +  struct type *type; >>   -  if ((tid = ctf_lookup_by_symbol (ccp->fp, idx)) == CTF_ERR) >> -    return nullptr; >> - >> -  type = fetch_tid_type (ccp, tid); >> -  if (type == nullptr) >> -    return nullptr; >> - >> -  sym = new_symbol (ccp, type, tid); >> - >> -  return sym; >> +  while ((tid = ctf_symbol_next (ccp->fp, &i, &tname, functions)) != >> CTF_ERR) >> +    { >> +      type = get_tid_type (ccp->of, tid); >> +      if (type == nullptr) >> +    continue; >> +      sym = new (&ccp->of->objfile_obstack) symbol; >> +      OBJSTAT (ccp->of, n_syms++); >> +      SYMBOL_TYPE (sym) = type; >> +      SYMBOL_DOMAIN (sym) = VAR_DOMAIN; >> +      SYMBOL_ACLASS_INDEX (sym) = LOC_STATIC; >> +      sym->compute_and_set_names (tname, false, ccp->of->per_bfd); >> +      add_symbol_to_list (sym, ccp->builder->get_global_symbols ()); >> +      set_symbol_address (ccp->of, sym, tname); >> +    } >>   } >>   -/* Add an ELF STT_FUNC symbol with index IDX to the symbol table.  */ >> +/* Add entries in data objects section.  */ >>   -static struct symbol * >> -add_stt_func (struct ctf_context *ccp, unsigned long idx) >> +static void >> +add_stt_obj (struct ctf_context *ccp) >>   { >> -  struct type *ftype, *atyp, *rettyp; >> -  struct symbol *sym; >> -  ctf_funcinfo_t finfo; >> -  ctf_id_t argv[32]; >> -  uint32_t argc; >> -  ctf_id_t tid; >> -  struct type *void_type = objfile_type (ccp->of)->builtin_void; >> - >> -  if (ctf_func_info (ccp->fp, idx, &finfo) == CTF_ERR) >> -    return nullptr; >> - >> -  argc = finfo.ctc_argc; >> -  if (ctf_func_args (ccp->fp, idx, argc, argv) == CTF_ERR) >> -    return nullptr; >> - >> -  gdb::unique_xmalloc_ptr name (ctf_type_aname_raw (ccp->fp, >> idx)); >> -  if (name == nullptr) >> -    return nullptr; >> - >> -  tid = ctf_lookup_by_symbol (ccp->fp, idx); >> -  ftype = fetch_tid_type (ccp, tid); >> -  if ((finfo.ctc_flags & CTF_FUNC_VARARG) != 0) >> -    ftype->set_has_varargs (true); >> -  ftype->set_num_fields (argc); >> - >> -  /* If argc is 0, it has a "void" type.  */ >> -  if (argc != 0) >> -    ftype->set_fields >> -      ((struct field *) TYPE_ZALLOC (ftype, argc * sizeof (struct >> field))); >> - >> -  /* TYPE_FIELD_TYPE must never be NULL.  Fill it with void_type, if >> failed >> -     to find the argument type.  */ >> -  for (int iparam = 0; iparam < argc; iparam++) >> -    { >> -      atyp = fetch_tid_type (ccp, argv[iparam]); >> -      if (atyp) >> -    ftype->field (iparam).set_type (atyp); >> -      else >> -    ftype->field (iparam).set_type (void_type); >> -    } >> +  add_stt_entries (ccp, 0); >> +} >>   -  sym = new_symbol (ccp, ftype, tid); >> -  rettyp = fetch_tid_type (ccp, finfo.ctc_return); >> -  if (rettyp != nullptr) >> -    SYMBOL_TYPE (sym) = rettyp; >> -  else >> -    SYMBOL_TYPE (sym) = void_type; >> +/* Add entries in function info section.  */ >>   -  return sym; >> +static void >> +add_stt_func (struct ctf_context *ccp) >> +{ >> +  add_stt_entries (ccp, 1); >>   } >>     /* Get text segment base for OBJFILE, TSIZE contains the segment >> size.  */ >> @@ -1271,7 +1250,7 @@ struct ctf_tid_and_type >>   { >>     struct ctf_context *ccp; >>   -  ccp = pst->context; >> +  ccp = &pst->context; >>     ccp->builder = new buildsym_compunit >>                  (of, of->original_name, nullptr, >>                  language_c, text_offset); >> @@ -1288,7 +1267,7 @@ struct ctf_tid_and_type >>   { >>     struct ctf_context *ccp; >>   -  ccp = pst->context; >> +  ccp = &pst->context; >>     struct compunit_symtab *result >>       = ccp->builder->end_symtab (end_addr, section); >>     delete ccp->builder; >> @@ -1317,17 +1296,76 @@ struct ctf_tid_and_type >>              ctf_errmsg (ctf_errno (ccp->fp))); >>   } >>   +/* Add entries in either data objects or function info section, >> controlled >> +   by FUNCTIONS, to psymtab.  */ >> + >> +static void >> +ctf_psymtab_add_stt_entries (ctf_dict_t *cfp, ctf_psymtab *pst, >> +                 struct objfile *of, int functions) >> +{ >> +  ctf_next_t *i = nullptr; >> +  ctf_id_t tid; >> +  const char *tname; >> + >> +  while ((tid = ctf_symbol_next (cfp, &i, &tname, functions)) != >> CTF_ERR) >> +    { >> +      uint32_t kind = ctf_type_kind (cfp, tid); >> +      address_class aclass; >> +      domain_enum tdomain; >> +      switch (kind) >> +    { >> +      case CTF_K_STRUCT: >> +      case CTF_K_UNION: >> +      case CTF_K_ENUM: >> +        tdomain = STRUCT_DOMAIN; >> +        break; >> +      default: >> +        tdomain = VAR_DOMAIN; >> +        break; >> +    } >> + >> +      if (kind == CTF_K_FUNCTION) >> +    aclass = LOC_STATIC; >> +      else if (kind == CTF_K_CONST) >> +    aclass = LOC_CONST; >> +      else >> +    aclass = LOC_TYPEDEF; >> + >> +      pst->add_psymbol (tname, true, >> +            tdomain, aclass, -1, >> +            psymbol_placement::GLOBAL, >> +            0, language_c, pst->context.partial_symtabs, of); >> +    } >> +} >> + >> +/* Add entries in data objects section to psymtab.  */ >> + >> +static void >> +ctf_psymtab_add_stt_obj (ctf_dict_t *cfp, ctf_psymtab *pst, >> +             struct objfile *of) >> +{ >> +  ctf_psymtab_add_stt_entries (cfp, pst, of, 0); >> +} >> + >> +/* Add entries in function info section to psymtab.  */ >> + >> +static void >> +ctf_psymtab_add_stt_func (ctf_dict_t *cfp, ctf_psymtab *pst, >> +              struct objfile *of) >> +{ >> +  ctf_psymtab_add_stt_entries (cfp, pst, of, 1); >> +} >> + >>   /* Read in full symbols for PST, and anything it depends on. */ >>     void >>   ctf_psymtab::expand_psymtab (struct objfile *objfile) >>   { >> -  struct symbol *sym; >>     struct ctf_context *ccp; >>       gdb_assert (!readin); >>   -  ccp = context; >> +  ccp = &context; >>       /* Iterate over entries in data types section.  */ >>     if (ctf_type_iter (ccp->fp, ctf_add_type_cb, ccp) == CTF_ERR) >> @@ -1341,21 +1379,8 @@ struct ctf_tid_and_type >>              ctf_errmsg (ctf_errno (ccp->fp))); >>       /* Add entries in data objects and function info sections.  */ >> -  for (unsigned long i = 0; ; i++) >> -    { >> -      sym = add_stt_obj (ccp, i); >> -      if (sym == nullptr) >> -    { >> -      if (ctf_errno (ccp->fp) == EINVAL >> -          || ctf_errno (ccp->fp) == ECTF_NOSYMTAB) >> -        break; >> -      sym = add_stt_func (ccp, i); >> -    } >> -      if (sym == nullptr) >> -    continue; >> - >> -      set_symbol_address (ccp->of, sym, sym->linkage_name ()); >> -    } >> +  add_stt_obj (ccp); >> +  add_stt_func (ccp); >>       readin = true; >>   } >> @@ -1409,6 +1434,7 @@ struct ctf_tid_and_type >>     static ctf_psymtab * >>   create_partial_symtab (const char *name, >> +               ctf_archive_t *arc, >>                  ctf_dict_t *cfp, >>                  psymtab_storage *partial_symtabs, >>                  struct objfile *objfile) >> @@ -1418,13 +1444,11 @@ struct ctf_tid_and_type >>       pst = new ctf_psymtab (name, partial_symtabs, objfile->per_bfd, >> 0); >>   -  ccx = XOBNEW (&objfile->objfile_obstack, struct ctf_context); >> -  ccx->fp = cfp; >> -  ccx->of = objfile; >> -  ccx->partial_symtabs = partial_symtabs; >> -  ccx->pst = pst; >> -  ccx->builder = nullptr; >> -  pst->context = ccx; >> +  pst->context.arc = arc; >> +  pst->context.fp = cfp; >> +  pst->context.of = objfile; >> +  pst->context.partial_symtabs = partial_symtabs; >> +  pst->context.pst = pst; >>       return pst; >>   } >> @@ -1486,7 +1510,7 @@ struct ctf_tid_and_type >>       ccp->pst->add_psymbol (name, false, >>                domain, aclass, section, >> -             psymbol_placement::GLOBAL, >> +             psymbol_placement::STATIC, >>                0, language_c, ccp->partial_symtabs, ccp->of); >>       return 0; >> @@ -1506,18 +1530,46 @@ struct ctf_tid_and_type >>     return 0; >>   } >>   +/* Start a subfile for CTF. FNAME is the name of the archive.  */ >> + >> +static void >> +ctf_start_archive (struct ctf_context *ccx, struct objfile *of, >> +           const char *fname) >> +{ >> +  if (ccx->builder == nullptr) >> +    { >> +      ccx->builder = new buildsym_compunit (of, >> +              of->original_name, nullptr, language_c, 0); >> +      ccx->builder->record_debugformat ("ctf"); >> +    } >> +  ccx->builder->start_subfile (fname); >> +} >> + >>   /* Setup partial_symtab's describing each source file for which >>      debugging information is available.  */ >>     static void >>   scan_partial_symbols (ctf_dict_t *cfp, psymtab_storage >> *partial_symtabs, >> -              struct objfile *of) >> +              struct ctf_per_tu_data *tup, const char *fname) >>   { >> -  bfd *abfd = of->obfd; >> -  const char *name = bfd_get_filename (abfd); >> -  ctf_psymtab *pst = create_partial_symtab (name, cfp, >> partial_symtabs, of); >> +  struct objfile *of = tup->of; >> +  bool isparent = false; >> + >> +  if (strcmp (fname, ".ctf") == 0) >> +    { >> +      fname = bfd_get_filename (of->obfd); >> +      isparent = true; >> +    } >>   -  struct ctf_context *ccx = pst->context; >> +  ctf_psymtab *pst = create_partial_symtab (fname, tup->arc, cfp, >> +                        partial_symtabs, of); >> + >> +  struct ctf_context *ccx = &pst->context; >> +  if (isparent == false) >> +    { >> +      ctf_start_archive (ccx, of, fname); >> +      ccx->pst = pst; >> +    } >>       if (ctf_type_iter (cfp, ctf_psymtab_type_cb, ccx) == CTF_ERR) >>       complaint (_("ctf_type_iter scan_partial_symbols failed - %s"), >> @@ -1530,46 +1582,33 @@ struct ctf_tid_and_type >>     /* Scan CTF object and function sections which correspond to each >>        STT_FUNC or STT_OBJECT entry in the symbol table, >>        pick up what init_symtab has done.  */ >> -  for (unsigned long idx = 0; ; idx++) >> -    { >> -      ctf_id_t tid; >> -      if ((tid = ctf_lookup_by_symbol (cfp, idx)) == CTF_ERR) >> -    { >> -    if (ctf_errno (cfp) == EINVAL || ctf_errno (cfp) == ECTF_NOSYMTAB) >> -      break;    // Done, reach end of the section. >> -    else >> -      continue; >> -    } >> -      const char *tname = ctf_type_name_raw (cfp, tid); >> -      uint32_t kind = ctf_type_kind (cfp, tid); >> -      address_class aclass; >> -      domain_enum tdomain; >> -      switch (kind) >> -    { >> -      case CTF_K_STRUCT: >> -      case CTF_K_UNION: >> -      case CTF_K_ENUM: >> -        tdomain = STRUCT_DOMAIN; >> -        break; >> -      default: >> -        tdomain = VAR_DOMAIN; >> -        break; >> -    } >> +  ctf_psymtab_add_stt_obj (cfp, pst, of); >> +  ctf_psymtab_add_stt_func (cfp, pst, of); >>   -      if (kind == CTF_K_FUNCTION) >> -    aclass = LOC_STATIC; >> -      else if (kind == CTF_K_CONST) >> -    aclass = LOC_CONST; >> -      else >> -    aclass = LOC_TYPEDEF; >> +  pst->end (); >> +} >>   -      pst->add_psymbol (tname, false, >> -            tdomain, aclass, -1, >> -            psymbol_placement::STATIC, >> -            0, language_c, partial_symtabs, of); >> +/* Callback to build the psymtab for archive member NAME.  */ >> + >> +static int >> +build_ctf_archive_member (ctf_dict_t *ctf, const char *name, void *arg) >> +{ >> +  struct ctf_per_tu_data *tup = (struct ctf_per_tu_data *) arg; >> +  ctf_dict_t *parent = tup->fp; >> + >> +  if (strcmp (name, ".ctf") != 0) >> +    ctf_import (ctf, parent); >> + >> +  if (info_verbose) >> +    { >> +      printf_filtered (_("Scanning archive member %s..."), name); >> +      gdb_flush (gdb_stdout); >>       } >>   -  pst->end (); >> +  psymtab_storage *pss = tup->psf->get_partial_symtabs ().get (); >> +  scan_partial_symbols (ctf, pss, tup, name); >> + >> +  return 0; >>   } >>     /* Read CTF debugging information from a BFD section.  This is >> @@ -1579,6 +1618,7 @@ struct ctf_tid_and_type >>   void >>   elfctf_build_psymtabs (struct objfile *of) >>   { >> +  struct ctf_per_tu_data pcu; >>     bfd *abfd = of->obfd; >>     int err; >>   @@ -1593,10 +1633,17 @@ struct ctf_tid_and_type >>          bfd_get_filename (abfd), ctf_errmsg (err)); >>     ctf_dict_key.emplace (of, fp); >>   +  pcu.fp = fp; >> +  pcu.of = of; >> +  pcu.arc = arc; >> + >>     psymbol_functions *psf = new psymbol_functions (); >> -  psymtab_storage *partial_symtabs = psf->get_partial_symtabs ().get >> (); >>     of->qf.emplace_front (psf); >> -  scan_partial_symbols (fp, partial_symtabs, of); >> +  pcu.psf = psf; >> + >> +  if (ctf_archive_iter (arc, build_ctf_archive_member, &pcu) < 0) >> +    error (_("ctf_archive_iter failed in input file %s: - %s"), >> +       bfd_get_filename (abfd), ctf_errmsg (err)); >>   } >>     #else >> diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog >> index 0a8e5b2..5ab13bf 100644 >> --- a/gdb/testsuite/ChangeLog >> +++ b/gdb/testsuite/ChangeLog >> @@ -1,3 +1,12 @@ >> +2021-06-28  Weimin Pan  >> + >> +    * gdb.ctf/cross-tu-cyclic.exp: New file. >> +    * gdb.ctf/multi.exp: New file. >> +    * gdb.base/ctf-constvars.exp: Replace -gt with -gctf. >> +    * gdb.base/ctf-ptype.exp: Likewise. >> +    * gdb.ctf/funcreturn.exp: Likewise. >> +    * lib/gdb.exp: Likewise. >> + >>   2021-05-16  Weimin Pan  >>         * gdb.ctf/funcreturn.exp: New file. >> diff --git a/gdb/testsuite/gdb.base/ctf-constvars.exp >> b/gdb/testsuite/gdb.base/ctf-constvars.exp >> index 6e9210f..2e57ea0 100644 >> --- a/gdb/testsuite/gdb.base/ctf-constvars.exp >> +++ b/gdb/testsuite/gdb.base/ctf-constvars.exp >> @@ -31,8 +31,8 @@ if [skip_ctf_tests] { >>     standard_testfile .c >>   -# Using `-gt` generates full-fledged CTF debug information. >> -set opts "additional_flags=-gt" >> +# Using `-gctf` generates full-fledged CTF debug information. >> +set opts "additional_flags=-gctf" >>   if { [prepare_for_testing "failed to prepare" ${testfile} \ >>         [list $srcfile] [list $opts nowarnings]] } { >>       return 0 >> diff --git a/gdb/testsuite/gdb.base/ctf-ptype.exp >> b/gdb/testsuite/gdb.base/ctf-ptype.exp >> index 7dd6d95..a756edc 100644 >> --- a/gdb/testsuite/gdb.base/ctf-ptype.exp >> +++ b/gdb/testsuite/gdb.base/ctf-ptype.exp >> @@ -22,8 +22,8 @@ if [skip_ctf_tests] { >>     standard_testfile .c >>   -# Using `-gt` generates full-fledged CTF debug information. >> -set opts "additional_flags=-gt" >> +# Using `-gctf` generates full-fledged CTF debug information. >> +set opts "additional_flags=-gctf" >>     if { [prepare_for_testing "failed to prepare" ${testfile} \ >>         [list $srcfile] [list $opts nowarnings]] } { >> diff --git a/gdb/testsuite/gdb.ctf/cross-tu-cyclic-1.c >> b/gdb/testsuite/gdb.ctf/cross-tu-cyclic-1.c >> new file mode 100644 >> index 0000000..fe52b9e >> --- /dev/null >> +++ b/gdb/testsuite/gdb.ctf/cross-tu-cyclic-1.c >> @@ -0,0 +1,18 @@ >> +struct A; >> +struct B >> +{ >> +  int foo; >> +  struct A *bar; >> +}; >> + >> +struct A >> +{ >> +  long a; >> +  struct B *foo; >> +}; >> + >> +static struct A *foo __attribute__((used)); >> + >> +int main() >> +{ >> +} >> diff --git a/gdb/testsuite/gdb.ctf/cross-tu-cyclic-2.c >> b/gdb/testsuite/gdb.ctf/cross-tu-cyclic-2.c >> new file mode 100644 >> index 0000000..aa2d177 >> --- /dev/null >> +++ b/gdb/testsuite/gdb.ctf/cross-tu-cyclic-2.c >> @@ -0,0 +1,16 @@ >> +struct B; >> +struct A >> +{ >> +  long a; >> +  struct B *foo; >> +  struct C *bar; >> +}; >> + >> +struct C >> +{ >> +  struct B *foo; >> +  int b; >> +}; >> + >> +static struct C *foo __attribute__((used)); >> +static struct A *bar __attribute__((used)); >> diff --git a/gdb/testsuite/gdb.ctf/cross-tu-cyclic-3.c >> b/gdb/testsuite/gdb.ctf/cross-tu-cyclic-3.c >> new file mode 100644 >> index 0000000..19947e8 >> --- /dev/null >> +++ b/gdb/testsuite/gdb.ctf/cross-tu-cyclic-3.c >> @@ -0,0 +1,3 @@ >> +struct A { struct B *foo; }; >> +static struct A *a __attribute__((__used__)); >> +static struct A *conflicty __attribute__((__used__)); >> diff --git a/gdb/testsuite/gdb.ctf/cross-tu-cyclic-4.c >> b/gdb/testsuite/gdb.ctf/cross-tu-cyclic-4.c >> new file mode 100644 >> index 0000000..6e0c957 >> --- /dev/null >> +++ b/gdb/testsuite/gdb.ctf/cross-tu-cyclic-4.c >> @@ -0,0 +1,4 @@ >> +struct A { struct B *foo; }; >> +struct B { struct B *next; }; >> +static struct A *a __attribute__((__used__)); >> +static struct B *conflicty __attribute__((__used__)); >> diff --git a/gdb/testsuite/gdb.ctf/cross-tu-cyclic.exp >> b/gdb/testsuite/gdb.ctf/cross-tu-cyclic.exp >> new file mode 100644 >> index 0000000..f617f1b >> --- /dev/null >> +++ b/gdb/testsuite/gdb.ctf/cross-tu-cyclic.exp >> @@ -0,0 +1,43 @@ >> +# Copyright 2021 Free Software Foundation, Inc. >> + >> +# This program is free software; you can redistribute it and/or modify >> +# it under the terms of the GNU General Public License as published by >> +# the Free Software Foundation; either version 3 of the License, or >> +# (at your option) any later version. >> +# >> +# This program is distributed in the hope that it will be useful, >> +# but WITHOUT ANY WARRANTY; without even the implied warranty of >> +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the >> +# GNU General Public License for more details. >> +# >> +# You should have received a copy of the GNU General Public License >> +# along with this program.  If not, see >> > >. >> + >> +# This file is a subset of ptype.exp written by Rob Savoye. >> (rob@cygnus.com) >> + >> +if [skip_ctf_tests] { >> +    unsupported "no CTF debug format support, or CTF disabled in GDB" >> +    return 0 >> +} >> + >> +standard_testfile cross-tu-cyclic-1.c  cross-tu-cyclic-2.c \ >> +    cross-tu-cyclic-3.c  cross-tu-cyclic-4.c >> + >> +# Using `-gctf` generates full-fledged CTF debug information. >> +set opts "additional_flags=-gctf -Wl,--export-dynamic" >> +if { [prepare_for_testing "failed to prepare" ${testfile} \ >> +      [list $srcfile $srcfile2 $srcfile3 $srcfile4] \ >> +      [list $opts nowarnings]] } { >> +    return 0 >> +} >> + >> +# Create and source the file that provides information about the >> compiler >> +# used to compile the test case. >> +if [get_compiler_info] { >> +    return -1 >> +} >> + >> +# Same thing with struct and union. >> +gdb_test "ptype struct A" "type = struct A \{\[\r\n\]+\[ \t\]+struct >> B \\*foo;\[\r\n\]+\}.*" "ptype structure A" >> +gdb_test "ptype struct B" "type = struct B \{\[\r\n\]+\[ \t\]+struct >> B \\*next;\[\r\n\]+\}.*" "ptype structure B" >> +gdb_test "ptype struct C" "type = struct C \{\[\r\n\]+\[ \t\]+struct >> B \\*foo;\[\r\n\]+\[ \t\]+int b;\[\r\n\]+\}.*" "ptype structure C" >> diff --git a/gdb/testsuite/gdb.ctf/ctf-a.c >> b/gdb/testsuite/gdb.ctf/ctf-a.c >> new file mode 100644 >> index 0000000..9aa2a8f >> --- /dev/null >> +++ b/gdb/testsuite/gdb.ctf/ctf-a.c >> @@ -0,0 +1,32 @@ >> +/* This test program is part of GDB, the GNU debugger. >> + >> +   Copyright 2021 Free Software Foundation, Inc. >> + >> +   This program is free software; you can redistribute it and/or modify >> +   it under the terms of the GNU General Public License as published by >> +   the Free Software Foundation; either version 3 of the License, or >> +   (at your option) any later version. >> + >> +   This program is distributed in the hope that it will be useful, >> +   but WITHOUT ANY WARRANTY; without even the implied warranty of >> +   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the >> +   GNU General Public License for more details. >> + >> +   You should have received a copy of the GNU General Public License >> +   along with this program.  If not, see >> > >.  */ >> + >> +#include "ctf-a.h" >> + >> +static struct A a __attribute__((used)); >> + >> +extern struct C *foo (); >> +extern int bar (); >> + >> +int main () >> +{ >> +  struct C *cp; >> +  cp = foo (); >> +  if (cp) >> +    return bar (); >> +  return 0; >> +} >> diff --git a/gdb/testsuite/gdb.ctf/ctf-a.h >> b/gdb/testsuite/gdb.ctf/ctf-a.h >> new file mode 100644 >> index 0000000..297d740 >> --- /dev/null >> +++ b/gdb/testsuite/gdb.ctf/ctf-a.h >> @@ -0,0 +1,22 @@ >> +/* This test program is part of GDB, the GNU debugger. >> + >> +   Copyright 2021 Free Software Foundation, Inc. >> + >> +   This program is free software; you can redistribute it and/or modify >> +   it under the terms of the GNU General Public License as published by >> +   the Free Software Foundation; either version 3 of the License, or >> +   (at your option) any later version. >> + >> +   This program is distributed in the hope that it will be useful, >> +   but WITHOUT ANY WARRANTY; without even the implied warranty of >> +   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the >> +   GNU General Public License for more details. >> + >> +   You should have received a copy of the GNU General Public License >> +   along with this program.  If not, see >> > >.  */ >> + >> +struct A { >> +  struct B *b; >> +  struct A *next; >> +}; >> + >> diff --git a/gdb/testsuite/gdb.ctf/ctf-b.c >> b/gdb/testsuite/gdb.ctf/ctf-b.c >> new file mode 100644 >> index 0000000..c3a8ce5 >> --- /dev/null >> +++ b/gdb/testsuite/gdb.ctf/ctf-b.c >> @@ -0,0 +1,25 @@ >> +/* This test program is part of GDB, the GNU debugger. >> + >> +   Copyright 2021 Free Software Foundation, Inc. >> + >> +   This program is free software; you can redistribute it and/or modify >> +   it under the terms of the GNU General Public License as published by >> +   the Free Software Foundation; either version 3 of the License, or >> +   (at your option) any later version. >> + >> +   This program is distributed in the hope that it will be useful, >> +   but WITHOUT ANY WARRANTY; without even the implied warranty of >> +   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the >> +   GNU General Public License for more details. >> + >> +   You should have received a copy of the GNU General Public License >> +   along with this program.  If not, see >> > >.  */ >> + >> +#include "ctf-b.h" >> + >> +static struct B b __attribute__((used)); >> + >> +int bar () >> +{ >> +  return b.wombat; >> +} >> diff --git a/gdb/testsuite/gdb.ctf/ctf-b.h >> b/gdb/testsuite/gdb.ctf/ctf-b.h >> new file mode 100644 >> index 0000000..9dbdd7d >> --- /dev/null >> +++ b/gdb/testsuite/gdb.ctf/ctf-b.h >> @@ -0,0 +1,22 @@ >> +/* This test program is part of GDB, the GNU debugger. >> + >> +   Copyright 2021 Free Software Foundation, Inc. >> + >> +   This program is free software; you can redistribute it and/or modify >> +   it under the terms of the GNU General Public License as published by >> +   the Free Software Foundation; either version 3 of the License, or >> +   (at your option) any later version. >> + >> +   This program is distributed in the hope that it will be useful, >> +   but WITHOUT ANY WARRANTY; without even the implied warranty of >> +   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the >> +   GNU General Public License for more details. >> + >> +   You should have received a copy of the GNU General Public License >> +   along with this program.  If not, see >> > >.  */ >> + >> +struct B { >> +  struct C *c; >> +  int wombat; >> +}; >> + >> diff --git a/gdb/testsuite/gdb.ctf/ctf-c.c >> b/gdb/testsuite/gdb.ctf/ctf-c.c >> new file mode 100644 >> index 0000000..b4051b3 >> --- /dev/null >> +++ b/gdb/testsuite/gdb.ctf/ctf-c.c >> @@ -0,0 +1,25 @@ >> +/* This test program is part of GDB, the GNU debugger. >> + >> +   Copyright 2021 Free Software Foundation, Inc. >> + >> +   This program is free software; you can redistribute it and/or modify >> +   it under the terms of the GNU General Public License as published by >> +   the Free Software Foundation; either version 3 of the License, or >> +   (at your option) any later version. >> + >> +   This program is distributed in the hope that it will be useful, >> +   but WITHOUT ANY WARRANTY; without even the implied warranty of >> +   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the >> +   GNU General Public License for more details. >> + >> +   You should have received a copy of the GNU General Public License >> +   along with this program.  If not, see >> > >.  */ >> + >> +#include "ctf-c.h" >> + >> +static struct C c __attribute__((used)); >> + >> +struct C * foo () >> +{ >> +  return &c; >> +} >> diff --git a/gdb/testsuite/gdb.ctf/ctf-c.h >> b/gdb/testsuite/gdb.ctf/ctf-c.h >> new file mode 100644 >> index 0000000..fb18157 >> --- /dev/null >> +++ b/gdb/testsuite/gdb.ctf/ctf-c.h >> @@ -0,0 +1,21 @@ >> +/* This test program is part of GDB, the GNU debugger. >> + >> +   Copyright 2021 Free Software Foundation, Inc. >> + >> +   This program is free software; you can redistribute it and/or modify >> +   it under the terms of the GNU General Public License as published by >> +   the Free Software Foundation; either version 3 of the License, or >> +   (at your option) any later version. >> + >> +   This program is distributed in the hope that it will be useful, >> +   but WITHOUT ANY WARRANTY; without even the implied warranty of >> +   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the >> +   GNU General Public License for more details. >> + >> +   You should have received a copy of the GNU General Public License >> +   along with this program.  If not, see >> > >.  */ >> + >> +struct C { >> +  struct A *a; >> +  int b; >> +}; >> diff --git a/gdb/testsuite/gdb.ctf/funcreturn.exp >> b/gdb/testsuite/gdb.ctf/funcreturn.exp >> index 874160e..4443c2d 100644 >> --- a/gdb/testsuite/gdb.ctf/funcreturn.exp >> +++ b/gdb/testsuite/gdb.ctf/funcreturn.exp >> @@ -26,8 +26,8 @@ if [target_info exists no_long_long] { >>     standard_testfile whatis.c >>   -# Using `-gt` generates full-fledged CTF debug information. >> -set opts "additional_flags=-gt -Wl,--export-dynamic" >> +# Using `-gctf` generates full-fledged CTF debug information. >> +set opts "additional_flags=-gctf -Wl,--export-dynamic" >>     if { [prepare_for_testing "failed to prepare" ${testfile} \ >>         [list $srcfile] [list $opts nowarnings]] } { >> diff --git a/gdb/testsuite/gdb.ctf/multi.exp >> b/gdb/testsuite/gdb.ctf/multi.exp >> new file mode 100644 >> index 0000000..fbed20e >> --- /dev/null >> +++ b/gdb/testsuite/gdb.ctf/multi.exp >> @@ -0,0 +1,42 @@ >> +# Copyright 2021 Free Software Foundation, Inc. >> + >> +# This program is free software; you can redistribute it and/or modify >> +# it under the terms of the GNU General Public License as published by >> +# the Free Software Foundation; either version 3 of the License, or >> +# (at your option) any later version. >> +# >> +# This program is distributed in the hope that it will be useful, >> +# but WITHOUT ANY WARRANTY; without even the implied warranty of >> +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the >> +# GNU General Public License for more details. >> +# >> +# You should have received a copy of the GNU General Public License >> +# along with this program.  If not, see >> > >. >> + >> +# This file is a subset of ptype.exp written by Rob Savoye. >> (rob@cygnus.com) >> + >> +if [skip_ctf_tests] { >> +    unsupported "no CTF debug format support, or CTF disabled in GDB" >> +    return 0 >> +} >> + >> +standard_testfile ctf-a.c ctf-b.c ctf-c.c >> + >> +# Using `-gctf` generates full-fledged CTF debug information. >> +set opts "additional_flags=-gctf -Wl,--export-dynamic" >> +if { [prepare_for_testing "failed to prepare" ${testfile} \ >> +      [list $srcfile $srcfile2 $srcfile3] \ >> +      [list $opts nowarnings]] } { >> +    return 0 >> +} >> + >> +# Create and source the file that provides information about the >> compiler >> +# used to compile the test case. >> +if [get_compiler_info] { >> +    return -1 >> +} >> + >> +# Same thing with struct and union. >> +gdb_test "ptype struct A" "type = struct A \{\[\r\n\]+\[ \t\]+struct >> B \\*b;\[\r\n\]+\[ \t\]+struct A \\*next;\[\r\n\]+\}.*" "ptype >> structure A" >> +gdb_test "ptype struct B" "type = struct B \{\[\r\n\]+\[ \t\]+struct >> C \\*c;\[\r\n\]+\[ \t\]+int \\wombat;\[\r\n\]+\}.*" "ptype structure B" >> +gdb_test "ptype struct C" "type = struct C \{\[\r\n\]+\[ \t\]+struct >> A \\*a;\[\r\n\]+\[ \t\]+int b;\[\r\n\]+\}.*" "ptype structure C" >> diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp >> index 36a5fd4..412724d 100644 >> --- a/gdb/testsuite/lib/gdb.exp >> +++ b/gdb/testsuite/lib/gdb.exp >> @@ -7449,7 +7449,7 @@ proc cmp_file_string { file str msg } { >>       } >>   } >>   -# Does the compiler support CTF debug output using '-gt' compiler >> +# Does the compiler support CTF debug output using '-gctf' compiler >>   # flag?  If not then we should skip these tests.  We should also >>   # skip them if libctf was explicitly disabled. >>   @@ -7464,7 +7464,7 @@ gdb_caching_proc skip_ctf_tests { >>       int main () { >>           return 0; >>       } >> -    } executable "additional_flags=-gt"] >> +    } executable "additional_flags=-gctf"] >>         return [expr {!$can_ctf}] >>   }