[PATCH] tests: Create bogus R/nothing.rpm with cyclic symlink.

2020-11-02 Thread Mark Wielaard
We used to try to trigger an error during debuginfod scanning using
a chmod 000 file. But this doesn't always result in an error. Create
a cyclic symlink instead, which always results in a failure to open/read.

Signed-off-by: Mark Wielaard 
---
 tests/ChangeLog  | 5 +
 tests/run-debuginfod-find.sh | 7 ---
 2 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/tests/ChangeLog b/tests/ChangeLog
index 57fc4c8e..2f8b75c3 100644
--- a/tests/ChangeLog
+++ b/tests/ChangeLog
@@ -1,3 +1,8 @@
+2020-11-02  Mark Wielaard  
+
+   * run-debuginfod-find.sh: Create bogus R/nothing.rpm with cyclic
+   symlink instead of chmod 000.
+
 2020-10-31  Mark Wielaard  
 
* dwfl-proc-attach.c (dlopen): New external function override.
diff --git a/tests/run-debuginfod-find.sh b/tests/run-debuginfod-find.sh
index 48dbc7d4..5af45667 100755
--- a/tests/run-debuginfod-find.sh
+++ b/tests/run-debuginfod-find.sh
@@ -95,9 +95,10 @@ wait_ready()
   fi
 }
 
-# create a 000 empty .rpm file to evoke a metric-visible error
-touch R/nothing.rpm
-chmod 000 R/nothing.rpm
+# create a bogus .rpm file to evoke a metric-visible error
+# Use a cyclic symlink instead of chmod 000 to make sure even root
+# would see an error (running the testsuite under root is NOT encouraged).
+ln -s R/nothing.rpm R/nothing.rpm
 
 env LD_LIBRARY_PATH=$ldpath DEBUGINFOD_URLS= 
${abs_builddir}/../debuginfod/debuginfod $VERBOSE -F -R -d $DB -p $PORT1 -t0 
-g0 --fdcache-fds 1 --fdcache-mbs 2 -Z .tar.xz -Z .tar.bz2=bzcat -v R F Z L > 
vlog4 2>&1 &
 PID1=$!
-- 
2.18.4



[PATCH] config: Conditionalize on LIBDEBUGINFOD instead of DEBUGINFOD

2020-11-02 Thread Dmitry V. Levin
When elfutils is configured using --enable-libdebuginfod
--disable-debuginfod, that is, when the library is built and installed
but the server is not, it makes sense to install libdebuginfod.pc
because the latter complements the library rather than the server.

Likewise, it makes sense to install profile.d/debuginfod.*sh files
along with libdebuginfod because the library can use DEBUGINFOD_URLS
environment variable as well as the server.

This change does not affect --enable-debuginfod mode as the latter
requires --enable-libdebuginfod.

Fixes: fed3c3ceeaa6 ("Do not install libdebuginfod.pc unless debuginfod is 
enabled")
Fixes: b503c358dde8 ("Do not install profile.d/debuginfod.*sh files unless 
debuginfod is enabled")
Signed-off-by: Dmitry V. Levin 
---
 config/ChangeLog   | 5 +
 config/Makefile.am | 2 +-
 2 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/config/ChangeLog b/config/ChangeLog
index c532f7e6..e69e7e21 100644
--- a/config/ChangeLog
+++ b/config/ChangeLog
@@ -1,3 +1,8 @@
+2020-11-02  Dmitry V. Levin  
+
+   * Makefile.am (pkgconfig_DATA, install-data-local, uninstall-local):
+   Conditionalize on LIBDEBUGINFOD instead of DEBUGINFOD.
+
 2020-10-31  Dmitry V. Levin  
 
* Makefile.am (install-data-local, uninstall-local): Conditionalize
diff --git a/config/Makefile.am b/config/Makefile.am
index ef28dab6..a66f5490 100644
--- a/config/Makefile.am
+++ b/config/Makefile.am
@@ -34,7 +34,7 @@ EXTRA_DIST = elfutils.spec.in known-dwarf.awk 
10-default-yama-scope.conf \
 
 pkgconfigdir = $(libdir)/pkgconfig
 pkgconfig_DATA = libelf.pc libdw.pc
-if DEBUGINFOD
+if LIBDEBUGINFOD
 pkgconfig_DATA += libdebuginfod.pc
 
 install-data-local:

-- 
ldv


Re: ** POTENTIAL FRAUD ALERT - RED HAT ** building static libs

2020-11-02 Thread Mark Wielaard
Hi,

(Interesting Subject. Disclaimer, I work for Red Hat, but had no idea
 we had a potential fraud alert detection system :)

On Sat, Oct 31, 2020 at 04:05:52PM -0400, Paul Smith wrote:
> On Sat, 2020-10-31 at 15:52 -0400, Frank Ch. Eigler wrote:
> > > I'd like to build, just as an example, libdebuginfod as ONLY a
> > > static library and link it statically with debuginfod, gdb, etc.
> > 
> > libdebuginfod relies on a bunch of other libraries (curl and all of
> > its dependencies), so a libdebuginfod.a is unlikely to buy you much.
> 
> Oh, I'm aware :).
> 
> I have all those other libraries built statically as well... they're
> pretty easy to build that way actually.
> 
> I'm already statically linking libdebuginfod.a with GDB, along with
> curl et.al.
> 
> But to do it, I need to build elfutils then reach into the build
> directory and pluck out the static library and copy it somewhere else
> then tell GDB to look there instead.
> 
> And, I have no solution for building the debuginfod server itself
> statically.

To be honest I recently removed the static development libraries from
Fedora since nobody was using the (and the only package that dependent
on them did so by accident). And was hoping to eventually remove the
static builds from the code.

That said, I also use parts of it for DTS (Developer ToolSet).  See
the git mjw/RH-DTS branch. But there I use the static bits to
"secretly" create "fake" shared libaries. Using linker scripts that
link the actual elfutils bits static, but any dependencies shared. It
is complicated... 

> > OTOH, libtool is one way to arrange building both .a and .so's from
> > such libraries, and propagate dependencies via the .la files.
> 
> Well, I've had pretty much nothing but problems with libtool TBH, in
> terms of trying to generate general-purpose, relocatable libraries.  In
> my experience the libtool solutions always seem to have some hardcoded
> paths somewhere that cause me to bang my forehead on my desk.
> 
> However, I can work with it if necessary.
> 
> I was mainly hoping someone had looked into this already; it doesn't
> sound like it.

Although I am also not a fan of libtool, it might be the only thing
that can do this cleanly. The current support for static code is
actually only for the libraries and is otherwise only really used for
doing the coverage checks (and it isn't clear that really has to be
done static, that might just be a really old requirement that is no
longer true).

Is there an alternative to libtool you would recommend?

Thanks,

Mark


Re: [PATCH v2] Support building when fts and obstack aren't part of libc.

2020-11-02 Thread Mark Wielaard
Hi Érico,

On Sun, Nov 01, 2020 at 09:48:50PM -0300, Érico Nogueira via Elfutils-devel 
wrote:
> From: Érico Rolim 
> 
> - Make configure.ac test for fts and obstack availability;
> - Add fts and obstack ldflags to all files that need them;
> - Add missing argp ldflags to programs in debuginfod/.

This looks good.

> Signed-off-by: Érico Rolim 
> ---
>  ChangeLog  |  4 
>  configure.ac   | 20 
>  debuginfod/Makefile.am |  6 +++---
>  libdw/Makefile.am  |  2 +-
>  src/Makefile.am|  6 +++---
>  5 files changed, 31 insertions(+), 7 deletions(-)
> 
> diff --git a/ChangeLog b/ChangeLog
> index 128da6c6..565d021c 100644
> --- a/ChangeLog
> +++ b/ChangeLog
> @@ -1,3 +1,7 @@
> +2020-11-01  Érico N. Rolim  
> +
> + * configure.ac: Check for fts and obstack from outside libc.
> +
>  2020-10-28  Mark Wielaard  
>  
>   * configure.ac: Set version to 0.182.
> diff --git a/configure.ac b/configure.ac
> index 515ac704..c1a6954d 100644
> --- a/configure.ac
> +++ b/configure.ac
> @@ -542,6 +542,26 @@ else
>  fi
>  AC_SUBST([argp_LDADD])
>  
> +saved_LIBS="$LIBS"
> +AC_SEARCH_LIBS([fts_close], [fts])
> +LIBS="$saved_LIBS"
> +case "$ac_cv_search_fts_close" in
> +no) AC_MSG_FAILURE([failed to find fts_close]) ;;
> +-l*) fts_LIBS="$ac_cv_search_fts_close" ;;
> +*) fts_LIBS= ;;
> +esac
> +AC_SUBST([fts_LIBS])
> +
> +saved_LIBS="$LIBS"
> +AC_SEARCH_LIBS([_obstack_free], [obstack])
> +LIBS="$saved_LIBS"
> +case "$ac_cv_search__obstack_free" in
> +no) AC_MSG_FAILURE([failed to find obstack_free]) ;;
> +-l*) obstack_LIBS="$ac_cv_search__obstack_free" ;;
> +*) obstack_LIBS= ;;
> +esac
> +AC_SUBST([obstack_LIBS])
> +
>  dnl The directories with content.

OK, normally this says none required which is handled by the *) case.
Shouldn't we do argp in the same way? This looks simpler than what we
have now.

>  dnl Documentation.
> diff --git a/debuginfod/Makefile.am b/debuginfod/Makefile.am
> index 01985600..0af3b58c 100644
> --- a/debuginfod/Makefile.am
> +++ b/debuginfod/Makefile.am
> @@ -71,10 +71,10 @@ bin_PROGRAMS += debuginfod-find
>  endif
>  
>  debuginfod_SOURCES = debuginfod.cxx
> -debuginfod_LDADD = $(libdw) $(libelf) $(libeu) $(libdebuginfod) 
> $(libmicrohttpd_LIBS) $(sqlite3_LIBS) $(libarchive_LIBS) -lpthread -ldl
> +debuginfod_LDADD = $(libdw) $(libelf) $(libeu) $(libdebuginfod) 
> $(argp_LDADD) $(fts_LIBS) $(libmicrohttpd_LIBS) $(sqlite3_LIBS) 
> $(libarchive_LIBS) -lpthread -ldl

OK, debuginfod uses argp and fts.

>  debuginfod_find_SOURCES = debuginfod-find.c
> -debuginfod_find_LDADD = $(libdw) $(libelf) $(libeu) $(libdebuginfod)
> +debuginfod_find_LDADD = $(libdw) $(libelf) $(libeu) $(libdebuginfod) 
> $(argp_LDADD) $(fts_LIBS)

Likewise for debuginfod_find.

>  if LIBDEBUGINFOD
>  noinst_LIBRARIES = libdebuginfod.a
> @@ -98,7 +98,7 @@ libdebuginfod_so_LIBS = libdebuginfod_pic.a
>  if DUMMY_LIBDEBUGINFOD
>  libdebuginfod_so_LDLIBS =
>  else
> -libdebuginfod_so_LDLIBS = $(libcurl_LIBS)
> +libdebuginfod_so_LDLIBS = $(libcurl_LIBS) $(fts_LIBS)

libdebuginfod_so uses fts.

>  endif
>  libdebuginfod.so$(EXEEXT): $(srcdir)/libdebuginfod.map 
> $(libdebuginfod_so_LIBS)
>   $(AM_V_CCLD)$(LINK) $(dso_LDFLAGS) -o $@ \
> diff --git a/libdw/Makefile.am b/libdw/Makefile.am
> index 33b5838d..1dbb3d5e 100644
> --- a/libdw/Makefile.am
> +++ b/libdw/Makefile.am
> @@ -109,7 +109,7 @@ libdw_so_LIBS = ../libebl/libebl_pic.a 
> ../backends/libebl_backends_pic.a \
>   ../libcpu/libcpu_pic.a libdw_pic.a ../libdwelf/libdwelf_pic.a \
>   ../libdwfl/libdwfl_pic.a
>  libdw_so_DEPS = ../lib/libeu.a ../libelf/libelf.so
> -libdw_so_LDLIBS = $(libdw_so_DEPS) -ldl -lz $(argp_LDADD) $(zip_LIBS) 
> -pthread
> +libdw_so_LDLIBS = $(libdw_so_DEPS) -ldl -lz $(argp_LDADD) $(fts_LIBS) 
> $(obstack_LIBS) $(zip_LIBS) -pthread

OK. libdw.so uses fts and obstacks.

>  libdw_so_SOURCES =
>  libdw.so$(EXEEXT): $(srcdir)/libdw.map $(libdw_so_LIBS) $(libdw_so_DEPS)
>   $(AM_V_CCLD)$(LINK) $(dso_LDFLAGS) -o $@ \
> diff --git a/src/Makefile.am b/src/Makefile.am
> index e462e7d7..88d0ac8f 100644
> --- a/src/Makefile.am
> +++ b/src/Makefile.am
> @@ -69,7 +69,7 @@ ar_no_Wstack_usage = yes
>  unstrip_no_Wstack_usage = yes
>  
>  readelf_LDADD = $(libdw) $(libebl) $(libelf) $(libeu) $(argp_LDADD)
> -nm_LDADD = $(libdw) $(libebl) $(libelf) $(libeu) $(argp_LDADD) \
> +nm_LDADD = $(libdw) $(libebl) $(libelf) $(libeu) $(argp_LDADD) 
> $(obstack_LIBS) \
>  $(demanglelib)

OK, nm uses obstacks.

>  size_LDADD = $(libelf) $(libeu) $(argp_LDADD)
>  strip_LDADD = $(libebl) $(libelf) $(libdw) $(libeu) $(argp_LDADD)
> @@ -78,9 +78,9 @@ findtextrel_LDADD = $(libdw) $(libelf) $(libeu) 
> $(argp_LDADD)
>  addr2line_LDADD = $(libdw) $(libelf) $(libeu) $(argp_LDADD) $(demanglelib)
>  elfcmp_LDADD = $(libebl) $(libdw) $(libelf) $(libeu) $(argp_LDADD)
>  objdump_LDADD  = $(libasm) $(libebl) $(libdw) $(libelf) $(libeu) 
> $(argp_LDADD)
> -ran

Re: [PATCH v2] debuginfod.cxx: include libintl.h.

2020-11-02 Thread Mark Wielaard
On Sun, Nov 01, 2020 at 09:58:04PM -0300, Érico Nogueira via Elfutils-devel 
wrote:
> From: Érico Rolim 
> 
> Uncomment the  include, since textdomain() and
> bindtextdomain() functions provided by it are being used.
> 
> Signed-off-by: Érico Rolim 
> ---
> 
> This is a follow up to the patch that went the opposite way and removed
> the calls to bindtextdomain() and textdomain(); it was decided that
> those calls should be kept, so all that's needed here is to actually
> include the header.

Thanks, added a ChangeLog entry and pushed.


Re: [PATCH v2] Support building when fts and obstack aren't part of libc.

2020-11-02 Thread Érico Nogueira via Elfutils-devel
On Mon Nov 2, 2020 at 10:13 PM -03, Mark Wielaard wrote:
> Hi Érico,
>
> On Sun, Nov 01, 2020 at 09:48:50PM -0300, Érico Nogueira via
> Elfutils-devel wrote:
> > From: Érico Rolim 
> > 
> > - Make configure.ac test for fts and obstack availability;
> > - Add fts and obstack ldflags to all files that need them;
> > - Add missing argp ldflags to programs in debuginfod/.
>
> This looks good.
>
> > Signed-off-by: Érico Rolim 
> > ---
> >  ChangeLog  |  4 
> >  configure.ac   | 20 
> >  debuginfod/Makefile.am |  6 +++---
> >  libdw/Makefile.am  |  2 +-
> >  src/Makefile.am|  6 +++---
> >  5 files changed, 31 insertions(+), 7 deletions(-)
> > 
> > diff --git a/ChangeLog b/ChangeLog
> > index 128da6c6..565d021c 100644
> > --- a/ChangeLog
> > +++ b/ChangeLog
> > @@ -1,3 +1,7 @@
> > +2020-11-01  Érico N. Rolim  
> > +
> > +   * configure.ac: Check for fts and obstack from outside libc.
> > +
> >  2020-10-28  Mark Wielaard  
> >  
> > * configure.ac: Set version to 0.182.
> > diff --git a/configure.ac b/configure.ac
> > index 515ac704..c1a6954d 100644
> > --- a/configure.ac
> > +++ b/configure.ac
> > @@ -542,6 +542,26 @@ else
> >  fi
> >  AC_SUBST([argp_LDADD])
> >  
> > +saved_LIBS="$LIBS"
> > +AC_SEARCH_LIBS([fts_close], [fts])
> > +LIBS="$saved_LIBS"
> > +case "$ac_cv_search_fts_close" in
> > +no) AC_MSG_FAILURE([failed to find fts_close]) ;;
> > +-l*) fts_LIBS="$ac_cv_search_fts_close" ;;
> > +*) fts_LIBS= ;;
> > +esac
> > +AC_SUBST([fts_LIBS])
> > +
> > +saved_LIBS="$LIBS"
> > +AC_SEARCH_LIBS([_obstack_free], [obstack])
> > +LIBS="$saved_LIBS"
> > +case "$ac_cv_search__obstack_free" in
> > +no) AC_MSG_FAILURE([failed to find obstack_free]) ;;
> > +-l*) obstack_LIBS="$ac_cv_search__obstack_free" ;;
> > +*) obstack_LIBS= ;;
> > +esac
> > +AC_SUBST([obstack_LIBS])
> > +
> >  dnl The directories with content.
>
> OK, normally this says none required which is handled by the *) case.
> Shouldn't we do argp in the same way? This looks simpler than what we
> have now.

I can send a patch to change it.

>
> I added the missing ChangeLog entries and pushed.

Thank you!

>
> Thanks,
>
> Mark

Érico


Re: [PATCH v2] debuginfod.cxx: include libintl.h.

2020-11-02 Thread Érico Nogueira via Elfutils-devel
On Mon Nov 2, 2020 at 10:17 PM -03, Mark Wielaard wrote:
> On Sun, Nov 01, 2020 at 09:58:04PM -0300, Érico Nogueira via
> Elfutils-devel wrote:
> > From: Érico Rolim 
> > 
> > Uncomment the  include, since textdomain() and
> > bindtextdomain() functions provided by it are being used.
> > 
> > Signed-off-by: Érico Rolim 
> > ---
> > 
> > This is a follow up to the patch that went the opposite way and removed
> > the calls to bindtextdomain() and textdomain(); it was decided that
> > those calls should be kept, so all that's needed here is to actually
> > include the header.
>
> Thanks, added a ChangeLog entry and pushed.

Sorry for missing these, and thank you for adding them. So, from what I
understand now, the policy is to add ChangeLog entries in all affected
directories and for every commit?

Thanks,
Érico