From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id WpJBIha6amK3JgMAWB0awg (envelope-from ) for ; Thu, 28 Apr 2022 12:00:22 -0400 Received: by simark.ca (Postfix, from userid 112) id 807CA1E058; Thu, 28 Apr 2022 12:00:22 -0400 (EDT) Authentication-Results: simark.ca; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.a=rsa-sha256 header.s=default header.b=nXDy8uSt; dkim-atps=neutral X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-4.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,NICE_REPLY_A,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 Received: from 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 RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id 0F48C1E01D for ; Thu, 28 Apr 2022 12:00:22 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 2F9EE3888838 for ; Thu, 28 Apr 2022 16:00:21 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 2F9EE3888838 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1651161621; bh=1urGRxDZIlTTg0r1VcPnW3UyxIlo21qHPNtH0oGs+z0=; h=Date:Subject:To:References:In-Reply-To:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=nXDy8uStzG6MauHmR5/cPPEoDRIKCyX2qHAvHomo5v+za+lMWwl+9Glvz9lKi3glX ZvajXOpxrerMgAJl4/VWkxvz5/egsia0CfUtgJ3sKewKA/RKMR+p5Z8HDSV5p0xK58 r0UrdvT27a5v3W8wMxKeAeMOCCP/GPydCoqZYzl0= Received: from smtp.polymtl.ca (smtp.polymtl.ca [132.207.4.11]) by sourceware.org (Postfix) with ESMTPS id 289B538346A9 for ; Thu, 28 Apr 2022 16:00:02 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 289B538346A9 Received: from simark.ca (simark.ca [158.69.221.121]) (authenticated bits=0) by smtp.polymtl.ca (8.14.7/8.14.7) with ESMTP id 23SFxuZM031366 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 28 Apr 2022 12:00:00 -0400 DKIM-Filter: OpenDKIM Filter v2.11.0 smtp.polymtl.ca 23SFxuZM031366 Received: from [10.0.0.11] (192-222-157-6.qc.cable.ebox.net [192.222.157.6]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPSA id 02D491E01D; Thu, 28 Apr 2022 11:59:55 -0400 (EDT) Message-ID: Date: Thu, 28 Apr 2022 11:59:55 -0400 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.8.1 Subject: Re: [PATCH v3 3/7] gdb/dwarf: pass compilation directory to line header Content-Language: en-US To: Tom Tromey , Simon Marchi via Gdb-patches References: <20220428033542.1636284-1-simon.marchi@polymtl.ca> <20220428033542.1636284-4-simon.marchi@polymtl.ca> <874k2dmcny.fsf@tromey.com> In-Reply-To: <874k2dmcny.fsf@tromey.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Poly-FromMTA: (simark.ca [158.69.221.121]) at Thu, 28 Apr 2022 15:59:56 +0000 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: , From: Simon Marchi via Gdb-patches Reply-To: Simon Marchi Errors-To: gdb-patches-bounces+public-inbox=simark.ca@sourceware.org Sender: "Gdb-patches" On 2022-04-28 11:48, Tom Tromey wrote: >>>>>> "Simon" == Simon Marchi via Gdb-patches writes: > > Simon> + /* COMP_DIR is the value of the DW_AT_comp_dir attribute of the compilation > Simon> + unit in the context of which we are reading this line header, or nullptr > Simon> + if not applicable. */ > Simon> + line_header (const char *comp_dir) > Simon> + : m_comp_dir (comp_dir != nullptr ? comp_dir : "") > Simon> + {} > > I think a single-argument constructor should be 'explicit'. Fixed. I should also initialize the bitfield field offset_in_dwz, fixed that too. > > Simon> + /* Compilation directory of the compilation unit in the context of which this > Simon> + line header is read. */ > Simon> + std::string m_comp_dir; > > Is there a need to copy the value here? > I didn't check in this case, but often in the DWARF reader, a string > will come directly from some mapped section, and in that case there > aren't lifetime issues -- and so it's fine to just store the pointer. I thought there might be lifetime issues. read_file_scope owns a file_and_directory object, which contains a possibly computed comp dir. That object's lifetime is read_file_scope, but the line_header created there (by calling handle_DW_AT_stmt_list) lives on, it is stored in dwarf2_cu::line_header. However, I see that we call fnd.intern_comp_dir prior to that, so the returned string should actually be one with objfile lifetime, it should be fine. I'll change it to a const char*, we'll see if it causes any test to fail (I build with ASan, so it should point out any use-after-free). Thanks, Simon