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 8AD193858D37 for ; Mon, 23 Oct 2023 22:44:11 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 8AD193858D37 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 8AD193858D37 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=1698101053; cv=none; b=a0Z2fO0dwYX6IhHlPJf8wbX31KCKQvA0xvfmVO/dZmMjaVmZWWtOKKfQiiqQVrj1Slcj/ftkfkaXjbaJEsnnJ02Ooz6ikbAoAwcsrCV4DFbNPSC6kQpqOZrYk1fzlMnM9aC/P02uBVx5LRp99VXHm7vNwJYhkUXA24mGRoFHlxk= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1698101053; c=relaxed/simple; bh=9nIhbujXXbNy2fGU4pkAVphMmogRz9BtzCpX5FodRFA=; h=DKIM-Signature:MIME-Version:From:Date:Message-ID:Subject:To; b=oWs4X8aYR+SdfwfTvHpSQUbij8gOIZJIMTzm6e7rrNqhGP0ryz6htokOvcq2UdqrgklXOlNYJeu/GRwpFvvmDKIwxxMtiz7goNqBiXIC0ych56VuSi3DDwE9eue8llqG5gtapHmrc1CWMBu9Laa916kofqlAMLUYJytozTwrxV4= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1698101051; 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=ifuyhi6CsMp7Dv1oXcbt2+29uldgN43QCVrTbCWYSS4=; b=a9XZ3OSHXGINhLasDXsRYdWKCXz/AANPoRhAQ/u0Dsa6R7rsrMbM3w1fHqy0Lm+hNOj+s2 JD6jvkAZEUFcmlh9DcY2Mbv4D0h/EMhZUutL5gPjJyynFtX0pFjxUCPZSCVSqG6x9eGY3n gLY2EXE2rOM11rYw9jpGMRGDrWCYu2c= Received: from mail-pl1-f199.google.com (mail-pl1-f199.google.com [209.85.214.199]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-581-R89T6F-AMtmxtMoHSqkX4A-1; Mon, 23 Oct 2023 18:44:09 -0400 X-MC-Unique: R89T6F-AMtmxtMoHSqkX4A-1 Received: by mail-pl1-f199.google.com with SMTP id d9443c01a7336-1c9fc94b182so41707795ad.1 for ; Mon, 23 Oct 2023 15:44:09 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698101049; x=1698705849; 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=ifuyhi6CsMp7Dv1oXcbt2+29uldgN43QCVrTbCWYSS4=; b=xAXPKt6IMigs19hvxN49pgBHSruerr9nOVV9ZaLAO4QJF0XFych026N1ud3lhI5SMq HtFIVILH4K/UTa1jsH8Zihyc2v10YzoIWOPUMvoTCuC2QBcyyzlyHLwotwGNv7u993z7 Ga9epl2V+knXKj7/fDmzFHzUSIXd849yngjMrHy0L+I91QYuTQ93YevqIRXXwxFEfoEA 8tBNZ0ie1yOpW5o25wjcRXxHxRDbcZMB01HeC4k7z6XwNyXXHfIIPoiIQunjg013ynUS 7q8QHBMPCf0pAuf3ie+BnvgyIv4RpcFAN9Grs6zSuv43RvNbfJJEYYGSsTsrGbnkhLFF MKOw== X-Gm-Message-State: AOJu0Yyco6pyqMQDwqdeZvG/pbPmpldnebQwQVkNcNOYl/iWRVlwgSpb B1i/GZlX+TFAjmZRmqMh16pEsuDZyEQGszjWeM6pC19HCWhwz0RGkCWoBIVqFWLJ+OX2Obc1rwJ lwXj7M5E2FgUjGsIf69J6+mTaLWsAgJ/UArMSaTt6 X-Received: by 2002:a17:903:23cd:b0:1ca:7086:60ec with SMTP id o13-20020a17090323cd00b001ca708660ecmr9968061plh.65.1698101048764; Mon, 23 Oct 2023 15:44:08 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFl0X8PYoEBKGmdhxkgYxXrBGrTzFzxyFvlDfo/fngMp9Xw+jmE4N1jfEaTLrOt/PPmFlNw6Qt9By10aRoej8U= X-Received: by 2002:a17:903:23cd:b0:1ca:7086:60ec with SMTP id o13-20020a17090323cd00b001ca708660ecmr9968048plh.65.1698101048317; Mon, 23 Oct 2023 15:44:08 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Aaron Merey Date: Mon, 23 Oct 2023 18:43:57 -0400 Message-ID: Subject: Re: PR30000 - introduce new srcfiles tool To: Housam Alamour 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=-11.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,KAM_SHORT,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE,TXREP 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 Housam, On Thu, Sep 28, 2023 at 11:00=E2=80=AFAM Housam Alamour via Elfutils-devel wrote: > > Here is the new srcfiles tool ready for review. Thanks for working on this. I was not able to apply the patch from your email due to some line breaks that your email client may have inserted. `git format-patch` and `git send-email` are useful for emailing patches with the right format. However I was able to test the patch using your try-pr30000 git branch. > diff --git a/doc/srcfiles.1 b/doc/srcfiles.1 > new file mode 100644 > index 00000000..245c2d27 > --- /dev/null > +++ b/doc/srcfiles.1 srcfile.1 does not install since it's missing from doc/Makefile.am. > @@ -0,0 +1,125 @@ > +.\" Copyright 2023 Red Hat Inc. > +.\" Mon 2023-Sept 23 Housam Alamour > +.\" Contact elfutils-devel@sourceware.org to correct errors or typos. > +.TH EU-SRCFILES 1 "2023-Sept-25" "elfutils" > + > +.de SAMPLE > +.br > +.RS 0 > +.nf > +.nh > +\fB > +.. > +.de ESAMPLE > +\fP > +.hy > +.fi > +.RE > +.. > + > +.SH "NAME" > +eu-srcfiles \- Lists the source files of a dwarf/elf file. DWARF and ELF are usually capitalized. > + > +.SH "SYNOPSIS" > +eu-srcfiles [\fB\-0\fR|\fB\-\-null\fR] [\fB\-c\fR|\fB\-\-cu\-only\fR] > [\fB\-v\fR|\fB\-\-verbose\fR] INPUT This description of the arg format differs from `eu-srcfiles --help` $ eu-srcfiles --help Usage: eu-srcfiles [OPTION...] [FILE] [...] The --help description implies that `eu-srcfiles ./prog` should work for some executable named prog but this is not the case. The man page is correct that I have to include -e or --core for this to work and that '-e a.out' is used as a default file name. > + > +.SH "DESCRIPTION" > +\fBeu-srcfiles\fR lists the source files of a given \s-1dwarf/elf\s0 > +file. This list is based on a search of the dwarf debuginfo, which > +may be automatically fetched by debuginfod if applicable. The target > +file may be an executable, a coredump, a process, or even the running > +kernel. The default is the file 'a.out'. The source file names are > +made unique and printed to standard output. > + > +.SH "OPTIONS" > +The long and short forms of options, shown here as alternatives, are > +equivalent. > + > +.SS "Input Options" > + > +Only one INPUT option may be used. The default is '-e a.out'. There are some input options, such as -k, that are listed in --help but not included in the man page. > diff --git a/src/srcfiles.cxx b/src/srcfiles.cxx > new file mode 100644 > index 00000000..c948269d > [...] > +int > +main (int argc, char *argv[]) > +{ > + int remaining; > + > + /* Parse and process arguments. This includes opening the modules. *= / > + argp_children[0].argp =3D dwfl_standard_argp (); > + argp_children[0].group =3D 1; > + > + Dwfl *dwfl =3D NULL; > + (void) argp_parse (&argp, argc, argv, 0, &remaining, &dwfl); > + assert (dwfl !=3D NULL); > + // Process all loaded modules - probably just one, except if -K or -p = is > used. The use of /* */ and // for comments is inconsistent. Although to be fair it's inconsistent in parts of elfutils too! > diff --git a/tests/run-srcfiles-self.sh b/tests/run-srcfiles-self.sh > new file mode 100755 > index 00000000..075ff7d2 > --- /dev/null > +++ b/tests/run-srcfiles-self.sh > @@ -0,0 +1,45 @@ > +#! /bin/sh > +# Copyright (C) 2023 Red Hat, Inc. > +# This file is part of elfutils. > +# > +# This file is free software; you can redistribute it and/or modify > +# it under the terms of the GNU General Public License as published by > +# the Free Software Foundation; either version 3 of the License, or > +# (at your option) any later version. > +# > +# elfutils is distributed in the hope that it will be useful, but > +# WITHOUT ANY WARRANTY; without even the implied warranty of > +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the > +# GNU General Public License for more details. > +# > +# You should have received a copy of the GNU General Public License > +# along with this program. If not, see . > + > +. $srcdir/test-subr.sh > + > +# Test different command line combinations on the srcfiles binary itself= . > +ET_EXEC=3D"${abs_top_builddir}/src/srcfiles" > +ET_PID=3D$$ > + > +SRC_NAME=3D"srcfiles.cxx" > + > +for null_arg in --null ""; do > + for verbose_arg in --verbose ""; do > + testrun $ET_EXEC $null_arg $verbose_arg -p $ET_PID > /dev/null > + > + # Ensure that the output contains srclines.cxx > + cu_only=3D$(testrun $ET_EXEC $null_arg $verbose_arg -c -e $ET_EXEC) > + default=3D$(testrun $ET_EXEC $null_arg $verbose_arg -e $ET_EXEC) > + result1=3D$(echo "$cu_only" | grep "$SRC_NAME") > + result2=3D$(echo "$default" | grep "$SRC_NAME") > + if [ -z "$result1" ] || [-z "$result2"]; then > + exit 1 > + fi > + > + # Ensure that the output with the cu-only option contains less sourc= e > files > + if [ "$cu_only" -gt "$default" ]; then > + exit 1 > + fi > + done > +done > + These tests pass for me on F38 x86_64. It looks like this only tests whether different command line options generate the same output or not. Would it be possible to add a test that checks whether a particular source file actually appears in the output as intended? For example, you could test whether src/srcfiles.cxx appears in the output of "$ET_EXEC -e $ET_EXEC". Aaron