* srclines.cxx: Introduce new option that places all the
source files associated with a specified dwarf/elf file
into a zip file and sends it to stdout.
* run-srcfiles-self.sh: Added test-case for the new zip feature.
* srcfiles.1, NEWS: Added documentation for the new zip feature
Example:
% ./src/srcfiles -z -e /bin/ls > output.zip
https://sourceware.org/bugzilla/show_bug.cgi?id=30991
Signed-off-by: Housam Alamour
---
NEWS | 4 +
configure.ac | 15 +++
doc/srcfiles.1 | 20 +++-
src/Makefile.am| 2 +-
src/srcfiles.cxx | 193 ++---
tests/run-srcfiles-self.sh | 40 +++-
6 files changed, 251 insertions(+), 23 deletions(-)
diff --git a/NEWS b/NEWS
index 53c717eb..388a3b63 100644
--- a/NEWS
+++ b/NEWS
@@ -1,5 +1,9 @@
Version 0.190
+srcfiles: added srcfiles tool that lists all the source files of a given
+ DWARF/ELF file. May also be used to create fetch the source files and
+ place them into a zip.
+
readelf: Support readelf -Ds, --use-dynamic --symbol.
debuginfod: Schema change (reindexing required, sorry!) for a 60%
diff --git a/configure.ac b/configure.ac
index 29ed32fe..3bfd2097 100644
--- a/configure.ac
+++ b/configure.ac
@@ -880,6 +880,21 @@ AC_ARG_ENABLE(debuginfod-urls,
AC_SUBST(DEBUGINFOD_URLS, $default_debuginfod_urls)
AC_CONFIG_FILES([config/profile.sh config/profile.csh])
+dnl Check if libarchive is available to determine if the
+dnl srcfiles --zip option should be enabled or disabled
+AC_CACHE_CHECK([whether libarchive is available],
+ac_cv_have_libarchive,
+[AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
+#include
+]])],
+ac_cv_have_libarchive=yes,
+ac_cv_have_libarchive=no)])
+AS_IF([test "x$ac_cv_have_libarchive" = "xyes"],
+[
+AC_DEFINE([HAVE_LIBARCHIVE], [1], [Define to 1 if libarchive is
available])
+])
+AM_CONDITIONAL([HAVE_LIBARCHIVE], [test "x$ac_cv_have_libarchive" = "xyes"])
+
AC_OUTPUT
AC_MSG_NOTICE([
diff --git a/doc/srcfiles.1 b/doc/srcfiles.1
index 6149c21b..6157045b 100644
--- a/doc/srcfiles.1
+++ b/doc/srcfiles.1
@@ -21,15 +21,18 @@
eu-srcfiles \- Lists the source files of a DWARF/ELF file.
.SH "SYNOPSIS"
-eu-srcfiles [\fB\-0\fR|\fB\-\-null\fR] [\fB\-c\fR|\fB\-\-cu\-only\fR]
[\fB\-v\fR|\fB\-\-verbose\fR] INPUT
+eu-srcfiles [\fB\-0\fR|\fB\-\-null\fR] [\fB\-c\fR|\fB\-\-cu\-only\fR]
[\fB\-v\fR|\fB\-\-verbose\fR] [\fB\-z\fR|\fB\-\-zip\fR] INPUT
.SH "DESCRIPTION"
-\fBeu-srcfiles\fR lists the source files of a given \s-DWARF/ELF\s0
+\fBeu-srcfiles\fR lists all the source files of a given DWARF/ELF
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.
+made unique and printed to standard output. The source files can be
+placed in a zip file that is sent to stdout.
+
+Note that all occurrences of '/./' and '/../' in the path name are
canonicalized.
.SH "INPUT OPTIONS"
The long and short forms of options, shown here as alternatives, are
@@ -78,7 +81,7 @@ Print program version.
.TP
\fB\-0, \-\-null\fR
-Separate items by a null instead of a newline.
+Separate items by a null instead of a newline. Cannot be used with the zip
option becuase it raises errors when unzipping.
.TP
\fB\-c, \-\-cu\-only\fR
@@ -88,6 +91,10 @@ Only list the CU names.
\fB\-v, \-\-verbose\fR
Increase verbosity of logging messages.
+.TP
+\fB\-z, \-\-zip\fR
+Zip all the source files and send to stdout. Cannot be used with the null
option becuase it raises errors when unzipping.
+
.SH EXAMPLES
@@ -119,6 +126,11 @@ List the source files of a kernel image.
eu-srcfiles -e /boot/vmlinuz-`uname -r`
.ESAMPLE
+Zip all the source files for a binary.
+.SAMPLE
+eu-srcfiles -z -e /bin/ls > ls.zip
+.ESAMPLE
+
.SH "AUTHOR"
Written by Housam Alamour.
diff --git a/src/Makefile.am b/src/Makefile.am
index d3d9d408..3853c152 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -85,7 +85,7 @@ stack_LDADD = $(libebl) $(libelf) $(libdw) $(libeu)
$(argp_LDADD) $(demanglelib)
elfcompress_LDADD = $(libebl) $(libelf) $(libdw) $(libeu) $(argp_LDADD)
elfclassify_LDADD = $(libelf) $(libdw) $(libeu) $(argp_LDADD)
srcfiles_SOURCES = srcfiles.cxx
-srcfiles_LDADD = $(libdw) $(libelf) $(libeu) $(argp_LDADD)
+srcfiles_LDADD = $(libdw) $(libelf) $(libeu) $(argp_LDADD) $(libarchive_LIBS)
installcheck-binPROGRAMS: $(bin_PROGRAMS)
bad=0; pid=; list="$(bin_PROGRAMS)"; for p in $$list; do \
diff --git a/src/srcfiles.cxx b/src/srcfiles.cxx
index 3c7afdc4..b88ce919 100644
--- a/src/srcfiles.cxx
+++ b/src/srcfiles.cxx
@@ -15,7 +15,19 @@
You should have received a copy of the GNU General Public License
along with this