From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTPS id D4A1A3858D20 for ; Tue, 13 Feb 2024 01:44:34 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org D4A1A3858D20 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org D4A1A3858D20 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1707788678; cv=none; b=IxsYlF7z4bNwecTw5m4wGkNhCjmlLPCYu3+LXFBCOdcpKW5UmuBTifZlr4uELSQTx33XNrd98BcY9LkyeQRge7KPCOboeDXYBj0xz86fcB5UnoxZ08WlROgYI2X+Z3Ibo9HTEycjkg/6FblRpsNB8lPamCdSJP1urwuzU9z769Q= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1707788678; c=relaxed/simple; bh=Y1fG7BPeMOHbGQYEKO5E/x11G7LwpQt7/z1hXgGaawk=; h=DKIM-Signature:MIME-Version:From:Date:Message-ID:Subject:To; b=aXbcqRN/OiX6XPXbDhGrPvNRGLJxYGOa3DFgD65q8kqwx4DnBvR0Qnyzn07uOHEezlB62cU6W5JFUyzx03YttDtE3O44eWhIlLbjUqJRt25gTksd1Ecc2/8/uWPwtL7Wh0AeLZdnbjsu+a17+T7ItRV7EAs1Wode9zK5DBPr9x0= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1707788674; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=EGjwuZCYWrNygoJSqVx99DOCHwyM0cE6UjFTKczsgDQ=; b=WHbzXLTN/o27NdJgI7eLSlWplEMvFd4m1NoNm00hY/L/QIofF5iHutBhx0JuAThPDnx4yq C7f0pUVJMtYMvWAu6JPVbZ5WinWNd3J2m0SqPhzW7u1xp+QgitO5efXGg7nceC0ACY0eow zJS4XRDbhMEkKX0s/gY7wT0tLsfDtfA= Received: from mail-pf1-f197.google.com (mail-pf1-f197.google.com [209.85.210.197]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-126-14CEuba3MkWdHEMXU_y0XQ-1; Mon, 12 Feb 2024 20:44:32 -0500 X-MC-Unique: 14CEuba3MkWdHEMXU_y0XQ-1 Received: by mail-pf1-f197.google.com with SMTP id d2e1a72fcca58-6e0567e4d16so3445255b3a.2 for ; Mon, 12 Feb 2024 17:44:32 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707788671; x=1708393471; 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=EGjwuZCYWrNygoJSqVx99DOCHwyM0cE6UjFTKczsgDQ=; b=I6N5Oeu2Gh7U5Bh2llhKtWx5AT/lBbURbcG2Pz7g1OmevdGv76XRQffJvkXYo3wj7X +jH8mhLBV1h+ZazHF5/RIjI0SF946t2X38YKP9toWcXWF8rccnHQDwr59kMWqPeXpqfr QZ/BY+N52Qk/e49tWJBjgxxSnRw0Zfzns9IExEpoos8D/FR8pLtrDLqrqdEZUHL4uM0h +85JCmBSR0A+IJvpFlxGjtG4KhUXSbRgKZ3fi9kbVvCv3Go4mnLg1qwxhdOHLnBUHpBY ccAFRck31Izmw8g7O8ToaMKsacg9ePsv3qXHz7WNtNalLJadT9cKAN3kRvX1dBzppWqU Rdtg== X-Gm-Message-State: AOJu0Yye5cQWnoQ5xAXXHT2+KylfQjsNJGnCBtZj4T0XPvmjhklTA2eJ eWeOZ5C7FKK/io4cYIOV7ZXEAvp/46LeAXTAy8AzCw4OwLayYGYjQBXzjOknjfpdRZ3WDblWW4B PJJMqr9p9HAl1Z51gaeGyHlKUIeuerwooEhOX7/HF2QO4w70ze7Gy7aBW7OzDhY68K6PMmDuis+ GrbgQUimCLbAW27VseqhEelu8NOujoPQRyVrnxnomep3+lJDg= X-Received: by 2002:a05:6a21:3a97:b0:19e:c0dd:5dbf with SMTP id zv23-20020a056a213a9700b0019ec0dd5dbfmr7533672pzb.28.1707788671387; Mon, 12 Feb 2024 17:44:31 -0800 (PST) X-Google-Smtp-Source: AGHT+IF2Pz6yLkvcM8enBZHSg2JKrNBXDzMVzU77D/NPUfs3xl1oHYjj2Z3/yZef08726rlqLexCsFZdR0AgQ6e8/H8= X-Received: by 2002:a05:6a21:3a97:b0:19e:c0dd:5dbf with SMTP id zv23-20020a056a213a9700b0019ec0dd5dbfmr7533660pzb.28.1707788671000; Mon, 12 Feb 2024 17:44:31 -0800 (PST) MIME-Version: 1.0 References: <20240210025216.272034-1-amerey@redhat.com> <2477fe1aff09a44653a2fbd8100a724cf8a9819d.camel@klomp.org> <20240212211356.GI21691@gnu.wildebeest.org> In-Reply-To: <20240212211356.GI21691@gnu.wildebeest.org> From: Aaron Merey Date: Mon, 12 Feb 2024 20:44:20 -0500 Message-ID: Subject: Re: [PATCH] Handle DW_AT_decl_file 0 To: Mark Wielaard Cc: elfutils-devel@sourceware.org X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-5.2 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,KAM_NUMSUBJECT,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,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 List-Id: Hi Mark, On Mon, Feb 12, 2024 at 4:14=E2=80=AFPM Mark Wielaard wrot= e: > > On Mon, Feb 12, 2024 at 01:16:30PM -0500, Aaron Merey wrote: > > On Mon, Feb 12, 2024 at 12:31=E2=80=AFPM Mark Wielaard = wrote: > > > > (void) INTUSE(dwarf_getsrclines) (&CUDIE (cu), &lines, &nlin= es); > > > > - assert (cu->lines !=3D 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 wheth= er > > > 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 =3D=3D (void *) -1l) > > > > + if (cu->lines =3D=3D NULL || cu->lines =3D=3D (void *) -1l) > > > > { > > > > - /* If the file index is not zero, there must be file informa= tion > > > > - 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 specifica= lly. > > 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=3D27405 > "libdw_get_srcfiles should not imply srclines" Ok I'll look at PR27405. I've removed the error handling changes from this patch. I also recompiled the testfile without -O0. It didn't end up improving the size of the testfile but the -O0 was unnecessary either way. Pushed as commit add63e0317b6e. Aaron