From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from gnu.wildebeest.org (gnu.wildebeest.org [45.83.234.184]) by sourceware.org (Postfix) with ESMTPS id AA3903858C31 for ; Mon, 12 Feb 2024 21:13:57 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org AA3903858C31 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=klomp.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=klomp.org ARC-Filter: OpenARC Filter v1.0.0 sourceware.org AA3903858C31 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=45.83.234.184 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1707772439; cv=none; b=foDB3EkmYUsrCi+bwxAcLsZCrInkDBoZSNgEl5MpI7ZC+KZn9VYw78Y9rkEo7DgLE7k5w7o65cq+zl0inBtad9AdUPwSC8ek6PJGxzeZwytm1OhxWWqC+T/6ZqUzi0a3vZlCJUJmqhC7WhrKL7eCp7aXM71zvZQ6hUk1ZOdvbhc= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1707772439; c=relaxed/simple; bh=gL77eRGRttMavPzrGbAgmKu66GDRj65k39BD5G3WtuU=; h=Date:From:To:Subject:Message-ID:MIME-Version; b=vVL5Ht/jmBvNsyltUzdfUqrhgeEy+kY5WQtPh+3TZM27deRyW2vzSOB9fRnuoiE6QqR4AsIr+w6ffuMLkKmWq6tIF6cFyrC2AfqFI1mUy9+zdcP0Gv1cCrxP3kqcrnVkjEypKXPH767AHXDP483qtNmR02kTLfoZSB3Fq40bP/0= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by gnu.wildebeest.org (Postfix, from userid 1000) id B1E8930003AE; Mon, 12 Feb 2024 22:13:56 +0100 (CET) Date: Mon, 12 Feb 2024 22:13:56 +0100 From: Mark Wielaard To: Aaron Merey Cc: elfutils-devel@sourceware.org Subject: Re: [PATCH] Handle DW_AT_decl_file 0 Message-ID: <20240212211356.GI21691@gnu.wildebeest.org> References: <20240210025216.272034-1-amerey@redhat.com> <2477fe1aff09a44653a2fbd8100a724cf8a9819d.camel@klomp.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) X-Spam-Status: No, score=-2.9 required=5.0 tests=BAYES_00,JMQ_SPF_NEUTRAL,KAM_DMARC_STATUS,KAM_NUMSUBJECT,SPF_HELO_NONE,SPF_PASS,TXREP,T_SCC_BODY_TEXT_LINE 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: Hi Aaron, On Mon, Feb 12, 2024 at 01:16:30PM -0500, Aaron Merey wrote: > On Mon, Feb 12, 2024 at 12:31 PM Mark Wielaard wrote: > > > (void) INTUSE(dwarf_getsrclines) (&CUDIE (cu), &lines, &nlines); > > > - assert (cu->lines != NULL); > > > } > > > > I see why would like to get rid of asserts in the code base. > > But I believe the assert is valid. dwarf_getsrclines will check whether > > cu->lines is NULL, in which case it tries to load the line table. It > > then sets cu->lines to the newly parsed line table, or to -1 to > > indicate there was an error parsing (or no) line table. > > > > > > - if (cu->lines == (void *) -1l) > > > + if (cu->lines == NULL || cu->lines == (void *) -1l) > > > { > > > - /* If the file index is not zero, there must be file information > > > - available. */ > > > - __libdw_seterrno (DWARF_E_INVALID_DWARF); > > > + /* Line table could not be found. */ > > > return NULL; > > > } > > > > Which means this is a change in behavior. Now if there was no line > > table, or a problem parsing it, then no error is set, but NULL is > > returned anyway. Which means using dwarf_errno or dwarf_errmsg after > > dwarf_decl_file returns NULL doesn't work reliably anymore. Are you > > sure libdw errno shouldn't be set to DWARF_E_INVALID_DWARF? > > My thinking was to rely on dwarf_getsrclines setting the libdw errno > if an error occurred. If we always use DWARF_E_INVALID_DWARF then we > might overwrite an error code that describes the failure more specifically. Ah, yes. That makes sense. But because of caching dwarf_getsrclines only sets an error on first try. > If we want to ensure that the libdw errno is set whenever we reach this > condition, we could check if dwarf_getsrclines set the errno. If it did, > then just leave that errno set. If it didn't, then set errno to > DWARF_E_INVALID_DWARF. Good idea. Or we could (also) cache the error in the cu (files_libdwerr?), that is what e.g. dwfl_module_getdwarf does (see mod->dwerr). But I think either solution is more like a redesign/factoring. And you might consider doing it separate from this bug fix. If you have time, you could then also look into this (performance/caching) issue: https://sourceware.org/bugzilla/show_bug.cgi?id=27405 "libdw_get_srcfiles should not imply srclines" Cheers, Mark