From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from omta34.uswest2.a.cloudfilter.net (omta34.uswest2.a.cloudfilter.net [35.89.44.33]) by sourceware.org (Postfix) with ESMTPS id DCB1C3849ACF for ; Fri, 19 Apr 2024 20:18:43 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org DCB1C3849ACF 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 DCB1C3849ACF Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=35.89.44.33 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1713557926; cv=none; b=UTG0yfolwan0XEGgPnl8Vn/5QOjfR+dGf48ZwbSyQzIEc38szJGS/UCE/lnkQGNGDBBWg2HvPX3EXfFKwHYouyCkUjpBCwYY4J9YOveD+hlgRCwZwErqJ3noG5TVXBjeGE4r7QBpcKex4t/oTbyY9bsrswsT4MhtKKp9m73g0/0= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1713557926; c=relaxed/simple; bh=m+CSicwVnkBdsMQEK76HhKvNEaiW7taxYNXgcHT32bo=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=hdWbXqVhBPffNKefdJbVYGT/HYvTlpvPTK9Wp5LhohgQVK/jtbqPyFz8yKVpkJtcPCEeskRp5+UCKscwvU1hqJ/Lbz/rhV5nWN5WkCrC2bigassHL8GOfql4LQ2tOKnZ++pDVvWIQec3oCcTCR644skGmzxZ9v7ibnynnQo0+Rg= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from eig-obgw-6007a.ext.cloudfilter.net ([10.0.30.247]) by cmsmtp with ESMTPS id xuMprzQVMHXmAxugzro9C6; Fri, 19 Apr 2024 20:18:41 +0000 Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with ESMTPS id xufNrkiwGVdenxufNrlA8o; Fri, 19 Apr 2024 20:17:01 +0000 X-Authority-Analysis: v=2.4 cv=M4FLKTws c=1 sm=1 tr=0 ts=6622d13d a=ApxJNpeYhEAb1aAlGBBbmA==:117 a=ApxJNpeYhEAb1aAlGBBbmA==:17 a=raytVjVEu-sA:10 a=Qbun_eYptAEA:10 a=p4yhxsxNAAAA:8 a=nFTw3ydG-rFo-tQSGyAA: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=AEWfvF+bweZtmLpb31RYxQI+GiHOWsYvZoJ0GU7h5yI=; b=T9WHcT4AmEHpDTxZfjxbYkOaYQ ZwROcqM+iP2aB2fd5HJ9yz49unp0WVJsLfQb9b3xvCbgz1dc2ij9w+EmpIKo4ptVhnQebaf/wLsM6 US5Z3kajShcchSC0/c5XiP234; Received: from 97-122-86-252.hlrn.qwest.net ([97.122.86.252]:45006 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 1rxufM-004Lq2-2O; Fri, 19 Apr 2024 14:17:00 -0600 From: Tom Tromey To: Will Hawkins Cc: gdb-patches@sourceware.org Subject: Re: [PATCH v5] gdb: Support embedded source in DWARF References: <20240412185525.171292-1-hawkinsw@obs.cr> X-Attribution: Tom Date: Fri, 19 Apr 2024 14:17:00 -0600 In-Reply-To: <20240412185525.171292-1-hawkinsw@obs.cr> (Will Hawkins's message of "Fri, 12 Apr 2024 14:55:23 -0400") Message-ID: <87ttjxt8eb.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.86.252 X-Source-L: No X-Exim-ID: 1rxufM-004Lq2-2O X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: 97-122-86-252.hlrn.qwest.net (murgatroyd) [97.122.86.252]:45006 X-Source-Auth: tom+tromey.com X-Email-Count: 2 X-Org: HG=bhshared;ORG=bluehost; X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-CMAE-Envelope: MS4xfOzBhqwFXAUIVhq7i9Pt+U92GlLU1ZVp6gZkMCQyXcCUbjNfKoOKUppehVRGemWERhSQ90qvZIpgQlZlcx4a50ccHxBA1oa1haHqDz1nAAJHdqfv6pda ID3BBZ0QRAgIeqvW2tKBo97TZFHjykoK5EhecFt4nT4MMy2Cqheq1prtN3ChZa+6wAfNHuE0h/rMjqGF04tgXCviTcd+XL6/gQ8= X-Spam-Status: No, score=-3015.1 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,JMQ_SPF_NEUTRAL,SPF_HELO_NONE,SPF_PASS,TXREP autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: >>>>> "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. Will> - m_fullname = find_source_or_rewrite (get_name (), get_comp_dir ()); Will> + { Will> + if (m_is_embedded) Will> + m_fullname = make_unique_xstrdup (embedded_fullname ( Will> + get_name (), Will> + get_comp_dir ())); No line break before the get_name call. Will> + else if (entry.source != nullptr) Will> + { Will> + /* We have an embedded source for the CU. */ Will> + gdb_assert (offset == 1); Will> + cu_file_embedded = true; This assert makes me a bit nervous. Can this be fooled by bad input data? Or is it really testing some internal invariant? I couldn't convince myself it was the latter. Will> + fullname.reset (embedded_fullname (dirname, qfn->file_names[index])); fullname = ... Will> + /* Because the line header may tell us information about the CU Will> + filename (e.g., whether it is embedded) which will affect other Will> + calculations, we have to read that information here. */ Will> + line_header *lh = cu->line_header; Will> + struct attribute *attr = dwarf2_attr (die, DW_AT_stmt_list, cu); Will> + if (lh == nullptr && attr != nullptr && attr->form_is_unsigned ()) Will> + { Will> + sect_offset line_offset = (sect_offset) attr->as_unsigned (); Will> + line_header_up lhu = dwarf_decode_line_header (line_offset, cu, Will> + res.get_comp_dir ()); Will> + if (lhu != nullptr) Will> + lh = lhu.release(); This will leak memory. However if this is the first time reading the header, should it be stashed somewhere? It seems to me it shouldn't have to be read more than once. IOW, how does this case get reached? Will> +/* See source.h. */ Will> + Will> +char * Will> +embedded_fullname (const char *dirname, const char *filename) Should return a unique_xmalloc_ptr Will> +{ Will> + if (dirname != nullptr) Will> + { Will> + return concat (dirname, SLASH_STRING, filename, (char *) nullptr); Will> + } No braces needed. Will> + Will> + return xstrdup (filename); make_unique_xstrdup thanks, Tom