From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id DKv4FuZ4+GUChgwAWB0awg (envelope-from ) for ; Mon, 18 Mar 2024 13:24:54 -0400 Authentication-Results: simark.ca; dkim=fail reason="signature verification failed" (768-bit key; unprotected) header.d=tromey.com header.i=@tromey.com header.a=rsa-sha256 header.s=default header.b=hHMAKgMs; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id 495091E0BB; Mon, 18 Mar 2024 13:24:54 -0400 (EDT) Received: from server2.sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id 2F7891E08C for ; Mon, 18 Mar 2024 13:24:52 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 73FCF3858C5F for ; Mon, 18 Mar 2024 17:24:51 +0000 (GMT) Received: from omta040.useast.a.cloudfilter.net (omta040.useast.a.cloudfilter.net [44.202.169.39]) by sourceware.org (Postfix) with ESMTPS id DF79C3858D37 for ; Mon, 18 Mar 2024 17:24:29 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org DF79C3858D37 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=tromey.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=tromey.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org DF79C3858D37 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=44.202.169.39 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1710782672; cv=none; b=hNeHuFXsOGGSr6LJlVho3J7IZnvrYFzBK1Q0OAK94tLI9c9K00yxPW3iA7D8dYIUN4aozx3FykulVvUjJ7I4+tLgnWLe/q4cENdabi0TssSw8Q6zXJleD92Zzz1XCBf3c0UoAplGgwnkjNn5qaJHM1vuFPsGLGd9iRivio9fWgQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1710782672; c=relaxed/simple; bh=upZdMqJQ9MFytSQIOI602V++Q4Cxfusqud3s7lj1+cQ=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=i5jr4C8c1uIo0z20wo4hC924k2ovcj3YUUqHFCO1neXxiykII6/y32OSw69oNRK4pFlLGw/2SajdP4op3z7efAPIn4vp1RiUlRfMlPcq/S0V9BBLwemFbIlCb/0+oO6G4AZ0AWyaaXAqq8iCtaC/gptWIFKaRK6Qerz9gkSumAo= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from eig-obgw-5001a.ext.cloudfilter.net ([10.0.29.139]) by cmsmtp with ESMTPS id mGIqrNBQ6l9dRmGirr7VoL; Mon, 18 Mar 2024 17:24:29 +0000 Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with ESMTPS id mGiqrC43K232imGiqr8MUo; Mon, 18 Mar 2024 17:24:28 +0000 X-Authority-Analysis: v=2.4 cv=H4XdwfYi c=1 sm=1 tr=0 ts=65f878cc a=ApxJNpeYhEAb1aAlGBBbmA==:117 a=ApxJNpeYhEAb1aAlGBBbmA==:17 a=K6JAEmCyrfEA:10 a=Qbun_eYptAEA:10 a=p4yhxsxNAAAA:8 a=TDWDU9CJuZOQigxrQnoA:9 a=mxQolvAE3cIA:10 a=4AvGVvso5qoc5vnZhopw:22 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tromey.com; s=default; h=Content-Type:MIME-Version:Message-ID:In-Reply-To:Date:References :Subject:Cc:To:From:Sender:Reply-To:Content-Transfer-Encoding:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=DgVgcbcjh5jps5pexx1pEC7iAV7QpvI5y7VZCmqoVeU=; b=hHMAKgMs5DoQLL+XOInSps0nT5 Qr+e4aD4AlEqw5RZ7hMVH9N3Bmtx5CVC6Dzo9ts3zmg4pSV4Vqy3r8D3RpQmkT+au90iLHrFUCPtq 5wayiAnr7qYhuhw/uUroeSTgt; Received: from 97-122-82-115.hlrn.qwest.net ([97.122.82.115]:55266 helo=murgatroyd) by box5379.bluehost.com with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96.2) (envelope-from ) id 1rmGip-003ZYN-2w; Mon, 18 Mar 2024 11:24:27 -0600 From: Tom Tromey To: Will Hawkins Cc: gdb-patches@sourceware.org Subject: Re: [RFC][PATCH 1/1] gdb: Support embedded source in DWARF References: <20240318162209.468831-1-hawkinsw@obs.cr> <20240318162209.468831-2-hawkinsw@obs.cr> X-Attribution: Tom Date: Mon, 18 Mar 2024 11:24:26 -0600 In-Reply-To: <20240318162209.468831-2-hawkinsw@obs.cr> (Will Hawkins's message of "Mon, 18 Mar 2024 12:22:06 -0400") Message-ID: <875xxjihbp.fsf@tromey.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.3 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - box5379.bluehost.com X-AntiAbuse: Original Domain - sourceware.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - tromey.com X-BWhitelist: no X-Source-IP: 97.122.82.115 X-Source-L: No X-Exim-ID: 1rmGip-003ZYN-2w X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: 97-122-82-115.hlrn.qwest.net (murgatroyd) [97.122.82.115]:55266 X-Source-Auth: tom+tromey.com X-Email-Count: 4 X-Org: HG=bhshared;ORG=bluehost; X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-CMAE-Envelope: MS4xfDgGyvNzGAauTr5azN1uQTA8vkpacZxiSMnIKz583S0g8bwdTgj/xFmNvCBSlFyGnel7sSu+FpsobYy3dCAMei+J/KX/TZrDgV1KgQe1YbnTunoasoVD jksRViAKcXjUlt+QVsmQ1FJQc0sS5LSTHdqt43c6OBxvystExzpYkjV4bpSX09YrS5Bhq8HLkdyzDZjDl2tvAmh8XcNnL0BOsOA= X-Spam-Status: No, score=-3021.7 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, GIT_PATCH_0, JMQ_SPF_NEUTRAL, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces+public-inbox=simark.ca@sourceware.org >>>>> "Will" == Will Hawkins writes: Will> While DW_LNCT_source is not yet finalized in the DWARF standard Will> (https://dwarfstd.org/issues/180201.1.html), LLVM does emit it. Will> This patch adds support for it in gdb. Thanks for the patch. Will> ChangeLog: gdb doesn't use ChangeLogs any more, so you can delete this part. Will> + if (fe.source) Will> + sf->symtab->source = cu->per_objfile->objfile->intern (fe.source); IIUC the 'source' here is the full text of the source code. In this case you don't want to use intern. That will make a copy of the text. Instead, because the section data is read-in and not unmapped or freed until the objfile is destroyed, you can just use the pointer directly. Will> +/* Open an embedded source file given a symtab S. Returns a file descriptor Will> + or negative errno for error. */ Will> + Will> +scoped_fd Will> +open_embedded_source(struct symtab *s, Will> + gdb::unique_xmalloc_ptr *fullname) Will> +{ I think some other refactoring should be done so that gdb doesn't have to write the source to a file and then re-read it. Some kind of abstraction here would be appropriate. Will> --- a/gdb/symtab.h Will> +++ b/gdb/symtab.h Will> @@ -1755,6 +1755,8 @@ struct symtab Will> const char *filename; Will> + const char *source; This line could use an explanatory comment. Will> diff --git a/include/dwarf2.h b/include/dwarf2.h Will> index b3d3731ee83..abe0359926b 100644 Will> --- a/include/dwarf2.h Will> +++ b/include/dwarf2.h Will> @@ -288,7 +288,9 @@ enum dwarf_line_number_content_type Will> DW_LNCT_timestamp = 0x3, Will> DW_LNCT_size = 0x4, Will> DW_LNCT_MD5 = 0x5, Will> + DW_LNCT_SOURCE = 0x6, Will> DW_LNCT_lo_user = 0x2000, Will> + DW_LNCT_llvm_SOURCE = 0x2001, This should probably use "LLVM" and not "llvm". Also for vendor extensions we like to have some kind of comment or documentation explaining what it is about -- in the more distant past this wasn't done and as a result there are some mystery extensions. Also I would not assign DW_LNCT_SOURCE until DWARF officially blesses it. Tom