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.129.124]) by sourceware.org (Postfix) with ESMTPS id EF6743858C30 for ; Mon, 12 Feb 2024 18:16:44 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org EF6743858C30 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 EF6743858C30 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1707761807; cv=none; b=aM/8/ynVLvjbWGKRa5TclGFxjaTGfc3jsCE+sPFAQ5qCFnec7fV5qbXG3KMsaRfRPbQLnkCYmtg2Dv9Wsql6ItfCPGTwJWT5+sqnICKZZhQyjmXgMahvHnIEQOzWM8HkfYp6WnPf6PyKNKNrLFcH9MO3PuWf3eB1k1rhOo3CDjM= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1707761807; c=relaxed/simple; bh=T40VZG/SD2eZUKFpfWbkr3rbyJRarEEgWnxXcnyizTc=; h=DKIM-Signature:MIME-Version:From:Date:Message-ID:Subject:To; b=VCq9bqYO651P/BXxfsUzeGEGulHbXb61ggaF5bjmyIZIkYOg/GCHdpd6ENLjXxkqG6xAowx7Val74cfmv91GWtQ5LOJKxdm26M2H5r2haLTxIhopyw8fD0AdKdH0wIAzfs8L5EtriPIx3NHiuYcRBEju/8TvXv+aWS0NIHldkkE= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1707761804; 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=/WC6yN38PGbwJvkHBvYJvp6O99l8Uvh9HfjDHe+ihNA=; b=foZC9wP8KQnVdTl5k3TxoDi5+Zqhg2INYMdCZ0wUQGtH2n/dRHQA90j2HvFmTTPK1S011E Rzqblc62xp7JD16P+PS04MnH+AASkly78E7MzkidrURhkLwpqot7YqapDDabpMf6YkKt2d 7J3fgQHd0I8mhccv9//o72HviZHUKfY= Received: from mail-pj1-f69.google.com (mail-pj1-f69.google.com [209.85.216.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-115-IeopGJWkN2KsFIIRZ_P6gw-1; Mon, 12 Feb 2024 13:16:43 -0500 X-MC-Unique: IeopGJWkN2KsFIIRZ_P6gw-1 Received: by mail-pj1-f69.google.com with SMTP id 98e67ed59e1d1-296f78bdb40so3623632a91.2 for ; Mon, 12 Feb 2024 10:16:43 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707761802; x=1708366602; 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=/WC6yN38PGbwJvkHBvYJvp6O99l8Uvh9HfjDHe+ihNA=; b=d4VmJsn8sBMBcgvaRK4hqg3mEwv43Pnfd6sTBV2AxuWfvoKZRv6ZYhCdoWn3zbjw7o zGJcIbA7iVYVu4zy0lcwcRtCRhiAzMylE8GnqfwDqBLmlxHbjRwESTWWdnjJ92tVSPW1 fk3sNMKC7oDc9wOjVqAQXMSrYczvTrJ8zXDIkEO+fInoJAecwebO+Bq1WpGJIIXsXHjS y5/C+QzBsNZW/x4mR/1Z90LcF01dpZxF+JqQuq56TnE+GJaRBSSGnupiEjzIVMQZLAIQ 9tY0qok1rw78A9KybkkgrhEImPs2PsssKbmnSeTgnHrmcuFesyQ2f2tW4zGC3Cx3hGwF b1mQ== X-Gm-Message-State: AOJu0YydEKx3pdFq9dggTvBM3sMfpPiAoJv+um7iic2+rttdi6evYrD1 CCoC/mNMFI1iG+2GylGQ94t3LWvzcfIP8lrAI651g4vjY4ON2hXeUyPOnzlzjfFfelRIfUT298d +5x4oquJaCvFtVTy72/iJNGMI6gzILNbxBdKBEZG/wv8qUxE9xJQg2GdNjQlgVNY8ORUzfvOY/v OHBdi8/ZaAnuu82Walfz0Z5kk2pRBiVQcNj+mnvbINT/ft X-Received: by 2002:a17:90b:f0a:b0:297:202a:3ba6 with SMTP id br10-20020a17090b0f0a00b00297202a3ba6mr4738595pjb.0.1707761802092; Mon, 12 Feb 2024 10:16:42 -0800 (PST) X-Google-Smtp-Source: AGHT+IE4R5TwmMmIlImkfvQfZjEgY2eysEuq9oV2J6qR6dWlTk1wiQ4MRJxxkwTfjk7Tzou6GT9wtFN5TDn80q4Khcc= X-Received: by 2002:a17:90b:f0a:b0:297:202a:3ba6 with SMTP id br10-20020a17090b0f0a00b00297202a3ba6mr4738582pjb.0.1707761801806; Mon, 12 Feb 2024 10:16:41 -0800 (PST) MIME-Version: 1.0 References: <20240210025216.272034-1-amerey@redhat.com> <2477fe1aff09a44653a2fbd8100a724cf8a9819d.camel@klomp.org> In-Reply-To: <2477fe1aff09a44653a2fbd8100a724cf8a9819d.camel@klomp.org> From: Aaron Merey Date: Mon, 12 Feb 2024 13:16:30 -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.5 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_H2,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 12:31=E2=80=AFPM Mark Wielaard wro= te: > > (void) INTUSE(dwarf_getsrclines) (&CUDIE (cu), &lines, &nlines); > > - 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 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 =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 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. 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. >> > - assert (cu->files !=3D NULL && cu->files !=3D (void *) -1l); > > + if (cu->files =3D=3D NULL || cu->files =3D=3D (void *) -1l) > > + { > > + /* If the line table was found then then the file table should > > + have also been found. */ > > + __libdw_seterrno (DWARF_E_UNKNOWN_ERROR); > > + return NULL; > > + } > > > > I think if you are going to replace the assert here, then it should > (also) be DWARF_E_INVALID_DWARF. It means a decl_file was given, but > there is no file table. Which IMHO is invalid. Just like in the case > below: > > > > > if (idx >=3D cu->files->nfiles) > > { > > Here we also set DWARF_E_INVALID_DWARF because the decl_file number is > larger than the number of files in the file table. Ok, fixed. > > --- a/tests/run-allfcts.sh > > +++ b/tests/run-allfcts.sh > > @@ -170,4 +170,21 @@ testrun_compare ${abs_builddir}/allfcts testfile-l= to-gcc9 <<\EOF > > /home/mark/src/tests/testfile-lto-main.c:6:main > > EOF > > > > +# =3D dwarf5-line.c =3D > > +# int > > +# main (int argc, char ** argv) > > +# { > > +# return 0; > > +# } > > + > > +# Using clang version 17.0.4 (Fedora 17.0.4-1.fc39) > > +# clang -gdwarf-5 -O0 -o testfile-dwarf5-line-clang dwarf5-line.c > > Does it need to be -O0? Not that I really object. Just hoping to get a > slightly smaller binary/testfile with -O1 or -O2. It doesn't need to be -O0. I'll just leave out -O altogether. Aaron