From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id yGnjNMyv+GXwwgwAWB0awg (envelope-from ) for ; Mon, 18 Mar 2024 17:19:08 -0400 Authentication-Results: simark.ca; dkim=pass (2048-bit key; unprotected) header.d=obs-cr.20230601.gappssmtp.com header.i=@obs-cr.20230601.gappssmtp.com header.a=rsa-sha256 header.s=20230601 header.b=OgafsHcF; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id C50411E0BB; Mon, 18 Mar 2024 17:19:08 -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 8B16F1E08C for ; Mon, 18 Mar 2024 17:19:06 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 0B0843858432 for ; Mon, 18 Mar 2024 21:19:06 +0000 (GMT) Received: from mail-qk1-x736.google.com (mail-qk1-x736.google.com [IPv6:2607:f8b0:4864:20::736]) by sourceware.org (Postfix) with ESMTPS id 8015F3858CD1 for ; Mon, 18 Mar 2024 21:18:36 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 8015F3858CD1 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=obs.cr Authentication-Results: sourceware.org; spf=none smtp.mailfrom=obs.cr ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 8015F3858CD1 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::736 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1710796726; cv=none; b=mm6Cchf88EJpN+K3XLzeFCyaEfsnJMu7qcoVBxjB/wjlPxja4q8Vc7qGDyS9JSmR7we9djosMipeS4hL/0u2Ka30Igh/GwU/LcfFKfkyp34AXLy6exSWa4vcFyKNXFPU04zrS3ykFv6HKkWV2FaD5fleOJjBRxVcGGCKq/Maap0= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1710796726; c=relaxed/simple; bh=6Fm2Ty4VdFPWeI/DgY0OFLbgZeI5c/4w7GpFR2DfghE=; h=DKIM-Signature:MIME-Version:From:Date:Message-ID:Subject:To; b=M8bdPl3d63oYrP4wXipWm+Zp8BeScc8dW1gyPttUWGn3FfsYOraq05gPMwgEEeFZEbPLets++ZCLdkVzVTZnRKqdDZq/hM0qMDpWbExXwA+LyqJBhWdtZucLUpQZnfpbtOGTT8gDByOX4+GaVgWUrPlK4Gb4fZ9i69JhgzGVi9I= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-qk1-x736.google.com with SMTP id af79cd13be357-789f5ce0b5bso129923485a.3 for ; Mon, 18 Mar 2024 14:18:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=obs-cr.20230601.gappssmtp.com; s=20230601; t=1710796716; x=1711401516; darn=sourceware.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=7XvpauxuceUhhtYdnAuL6+ICWwYT6k/DGdUI2+YltuY=; b=OgafsHcFOdl1K857twTbA4yKmI23d58Ok2f2D9EkDVJzhUJd8R2h5AE3wkfypHFXJv oqRezHCYaLykgyWHOrnRW4CHGb8ToOOFdBNbuT4C/sgHUC3NrmVKLaBNRs0HT3m2R1WN 6fuDvh2fjtws8cHkzReFfEdjRS/qwt1hcTsE2fVMLd3b6kD+uyN1iE3pR7abRfRK6c9D njF0Muf6IDxon1uV2ogiDTERR9h80efYeQKAYPp2UNTqADv4qof2ev5MnLrwjhzatQ42 85p9pqYEs9Ttejo1nd2Ndn1Qc7ccCQk4v6AnJLrLpXoSsM5yk7XfgpxqvOgqpqY19pLG tBgg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710796716; x=1711401516; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=7XvpauxuceUhhtYdnAuL6+ICWwYT6k/DGdUI2+YltuY=; b=Cvx4qEBtzPv/W2Bh5uEgS4zQA9YUjskVqnQHXoVAtO6OKD6ShckDSp5sJ6tNEtlpGl iIYh/h6n/O16Nogjh1F8ZWB98+2HRNxLtoZZXQJ06RnOgmtk7GS6C69tKvrAqmRbSvfx 7oigBieyAxOKehSbUDyUDoxWT55pTLqTuoOk1hpGgTPhiBeUSES/KIzxldExMHVtNTPr tmva7iniEXbJathq7n7vvGCbBgZMiy3TaZHz4G3i+6YwBvfnjhIm2nhJ/UErdBHvlnns dJy6oY5EvWdUGBevX8WZPV+2yUUIlT8XMKizLlVvRvWROrCWMeRdlwsYLwSGtVyCkmds r/yA== X-Gm-Message-State: AOJu0YxqKcGWrdhX2R+Fnd+EYSEOLrzvuZhjbLp4zMcVE+OCcbX1GyZ+ fOWkxBXLLQjE7JT7Rbhx3gzCGE+Rf81vd2sPYvvfjveM9KgamEifSKKQf8+Q9RhxvdELGAqXQSo 032bb3qe193zyAQoCuhUEucEt1BONHX7DtHIDXnJaGZOIkvFl X-Google-Smtp-Source: AGHT+IHYHr7qDOsLWT3Mmlif+pVNW14DP5hdW+NZiWXzy3sH5OOH46nIWt6/PjML6YGAWBMkirNArpJzV6GJQhtGxEs= X-Received: by 2002:a0c:c709:0:b0:691:815d:d78e with SMTP id w9-20020a0cc709000000b00691815dd78emr11131499qvi.39.1710796715764; Mon, 18 Mar 2024 14:18:35 -0700 (PDT) MIME-Version: 1.0 References: <20240318162209.468831-1-hawkinsw@obs.cr> <20240318162209.468831-2-hawkinsw@obs.cr> <875xxjihbp.fsf@tromey.com> In-Reply-To: <875xxjihbp.fsf@tromey.com> From: Will Hawkins Date: Mon, 18 Mar 2024 17:18:26 -0400 Message-ID: Subject: Re: [RFC][PATCH 1/1] gdb: Support embedded source in DWARF To: Tom Tromey Cc: gdb-patches@sourceware.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-7.2 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_NONE, 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 On Mon, Mar 18, 2024 at 1:24=E2=80=AFPM Tom Tromey wrote: > > >>>>> "Will" =3D=3D 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. Tom, Thank you so much for the comments! I am glad to see that (based on the volume of comments) I am on the right track. I really appreciate you taking the time to respond! And, yes, I *thought* that gdb had "retired" ChangeLogs, but I wasn't sure. I was trying to be as "correct" as possible. I will definitely drop it in v2! > > Will> + if (fe.source) > Will> + sf->symtab->source =3D cu->per_objfile->objfile->intern (fe.s= ource); > > 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. Thank you for confirming! I thought that was the case (that the lifetime of the objfile outlives the symtab) but I wasn't sure. > > 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. Absolutely! I will do that! > > 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. I *thought* I added one -- sorry! > > 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 =3D 0x3, > Will> DW_LNCT_size =3D 0x4, > Will> DW_LNCT_MD5 =3D 0x5, > Will> + DW_LNCT_SOURCE =3D 0x6, > Will> DW_LNCT_lo_user =3D 0x2000, > Will> + DW_LNCT_llvm_SOURCE =3D 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. You got it! > > Also I would not assign DW_LNCT_SOURCE until DWARF officially blesses > it. > Will do!! Thank you, again, Tom! Will > Tom