[Bug debuginfod/27277] support HEAD query for debuginfod content probe requests

2021-02-01 Thread mliska at suse dot cz via Elfutils-devel
https://sourceware.org/bugzilla/show_bug.cgi?id=27277

Martin Liska  changed:

   What|Removed |Added

 CC||mliska at suse dot cz

--- Comment #1 from Martin Liska  ---
I see the suggested functionality quite handy! Thanks.

-- 
You are receiving this mail because:
You are on the CC list for the bug.

Re: Remove nested functions from readelf.c

2021-02-01 Thread Mark Wielaard
On Fri, 2021-01-08 at 09:16 +0100, Timm Bäder via Elfutils-devel wrote:
> here another round for src/readelf.c. I think they are simple, but I'm
> not happy with the advance_pc() commit. I'm open for suggestions here
> but I can't come up with something better right now. I'll keep looking
> in to that in the meantime.

Yeah, the advance_pc function is really why you want nested functions
in the first place IMHO. Passing around the captured state as 6 extra
arguments seems to not really make the code much clearer. Especially
because on its own it isn't immediately clear what the code is about or
that it is to be used as part of the special opcode or
DW_LNS_advance_pc opcode (where DW_LNS_const_add_pc acts like special
opcode 255) handling.

It might be helpful to spell out in a comment to the function which
part of the DWARF4 6.2.5.1 Special Opcodes handling the advance_pc
function is responsible for.

But honestly in this case I think just keeping the nested function is
the cleanest way to handle this.

Cheers,

Mark


elfutils 0.183 release planning - next week (Monday Feb 8)

2021-02-01 Thread Mark Wielaard
Hi,

I believe I reviewed all pending patches, please yell and scream if I
missed something.

It has been 3 months since 0.182. There have been almost 100 commits.
Various bug fixes. And some issues, like recognizing SHF_GNU_RETAIN,
needed for clean results on gcc11 + binutils 2.36.

So I was hoping to do a 0.183 release next week (Monday Feb 8).

If there is anything you want to add/fix before that please post to the
list about it.

Thanks,

Mark


[PATCH] libdwfl: use GNU strerror_r only when available.

2021-02-01 Thread Érico Nogueira via Elfutils-devel
From: Érico Rolim 

Some C libraries don't provide the GNU version of strerror_r, only the
XSI-compliant one. We use the GNU version when available, since it fits
the code better, and otherwise use the XSI-compliant one.

Signed-off-by: Érico Rolim 
---

If possible, I'd like to get this patch in before the release, otherwise
it's an easy one to carry locally.

 ChangeLog|  4 
 configure.ac | 12 
 libdwfl/ChangeLog|  4 
 libdwfl/dwfl_error.c | 17 -
 4 files changed, 36 insertions(+), 1 deletion(-)

diff --git a/ChangeLog b/ChangeLog
index 142caa27..c8f921a5 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2021-02-01  Érico Nogueira  
+
+   * configure.ac: Check for GNU strerror_r.
+
 2021-01-12  Dmitry V. Levin  
 
* configure.ac [--enable-gcov]: Check for gcov, lcov, and genhtml.
diff --git a/configure.ac b/configure.ac
index 346ab800..baf6faf5 100644
--- a/configure.ac
+++ b/configure.ac
@@ -428,6 +428,18 @@ AC_CHECK_DECLS([mempcpy],[],[],
 
 AC_CHECK_FUNCS([process_vm_readv])
 
+AC_CACHE_CHECK([whether C library provides GNU strerror_r], 
ac_cv_gnu_strerror_r, [dnl
+old_CFLAGS="$CFLAGS"
+CFLAGS="$CFLAGS -Werror"
+AC_COMPILE_IFELSE([AC_LANG_SOURCE([dnl
+#define _GNU_SOURCE
+#include 
+char * (*s)(int, char*, size_t) = strerror_r;
+])], ac_cv_gnu_strerror_r=yes, ac_cv_gnu_strerror_r=no)
+CFLAGS="$old_CFLAGS"])
+AS_IF([test "x$ac_cv_gnu_strerror_r" = "xyes"],
+  [AC_DEFINE([HAVE_GNU_STRERROR_R], [1], [Defined if libc has GNU style 
strerror_r])])
+
 AC_CHECK_LIB([stdc++], [__cxa_demangle], [dnl
 AC_DEFINE([USE_DEMANGLE], [1], [Defined if demangling is enabled])])
 AM_CONDITIONAL(DEMANGLE, test "x$ac_cv_lib_stdcpp___cxa_demangle" = "xyes")
diff --git a/libdwfl/ChangeLog b/libdwfl/ChangeLog
index 5058f5f8..d107e78f 100644
--- a/libdwfl/ChangeLog
+++ b/libdwfl/ChangeLog
@@ -1,3 +1,7 @@
+2021-02-01  Érico Nogueira  
+
+   * dwfl_error.c (strerror_r): Only use the GNU version when available.
+
 2021-01-08  Timm Bäder  
 
* elf-from-memory.c (elf_from_remote_memory): Add for loop over
diff --git a/libdwfl/dwfl_error.c b/libdwfl/dwfl_error.c
index 7bcf61cc..ef2834b2 100644
--- a/libdwfl/dwfl_error.c
+++ b/libdwfl/dwfl_error.c
@@ -137,6 +137,21 @@ __libdwfl_seterrno (Dwfl_Error error)
 }
 
 
+static const char *
+errnomsg(int error)
+{
+  /* Won't be changed by strerror_r, but not const so compiler doesn't throw 
warning */
+  static char unknown[] = "unknown error";
+
+#ifdef HAVE_GNU_STRERROR_R
+  return strerror_r (error, unknown, 0);
+#else
+  /* To store the error message from strerror_r in a thread-safe manner */
+  static __thread char msg[128];
+  return strerror_r (error, msg, sizeof (msg)) ? unknown : msg;
+#endif
+}
+
 const char *
 dwfl_errmsg (int error)
 {
@@ -154,7 +169,7 @@ dwfl_errmsg (int error)
   switch (error &~ 0x)
 {
 case OTHER_ERROR (ERRNO):
-  return strerror_r (error & 0x, "bad", 0);
+  return errnomsg (error & 0x);
 case OTHER_ERROR (LIBELF):
   return elf_errmsg (error & 0x);
 case OTHER_ERROR (LIBDW):
-- 
2.30.0



Re: [PATCH] libdwfl: use GNU strerror_r only when available.

2021-02-01 Thread Mark Wielaard
Hi Érico,

On Mon, Feb 01, 2021 at 03:56:26PM -0300, Érico Nogueira via Elfutils-devel 
wrote:
> Some C libraries don't provide the GNU version of strerror_r, only the
> XSI-compliant one. We use the GNU version when available, since it fits
> the code better, and otherwise use the XSI-compliant one.

Could you also mention this bug in the commit message?
https://sourceware.org/bugzilla/show_bug.cgi?id=21010

> If possible, I'd like to get this patch in before the release, otherwise
> it's an easy one to carry locally.

One other comment, but this looks good to go otherwise.

> diff --git a/configure.ac b/configure.ac
> index 346ab800..baf6faf5 100644
> --- a/configure.ac
> +++ b/configure.ac
> @@ -428,6 +428,18 @@ AC_CHECK_DECLS([mempcpy],[],[],
>  
>  AC_CHECK_FUNCS([process_vm_readv])
>  
> +AC_CACHE_CHECK([whether C library provides GNU strerror_r], 
> ac_cv_gnu_strerror_r, [dnl
> +old_CFLAGS="$CFLAGS"
> +CFLAGS="$CFLAGS -Werror"
> +AC_COMPILE_IFELSE([AC_LANG_SOURCE([dnl
> +#define _GNU_SOURCE
> +#include 
> +char * (*s)(int, char*, size_t) = strerror_r;
> +])], ac_cv_gnu_strerror_r=yes, ac_cv_gnu_strerror_r=no)
> +CFLAGS="$old_CFLAGS"])
> +AS_IF([test "x$ac_cv_gnu_strerror_r" = "xyes"],
> +  [AC_DEFINE([HAVE_GNU_STRERROR_R], [1], [Defined if libc has GNU style 
> strerror_r])])
> +

autoconf comes with the following check:

 - Macro: AC_FUNC_STRERROR_R

If strerror_r is available, define HAVE_STRERROR_R, and if it is
declared, define HAVE_DECL_STRERROR_R. If it returns a char *
message, define STRERROR_R_CHAR_P; otherwise it returns an int
error number. The Thread-Safe Functions option of Posix requires
strerror_r to return int, but many systems (including, for
example, version 2.2.4 of the GNU C Library) return a char * value
that is not necessarily equal to the buffer argument.

Can we use that instead?

> +static const char *
> +errnomsg(int error)
> +{
> +  /* Won't be changed by strerror_r, but not const so compiler doesn't throw 
> warning */
> +  static char unknown[] = "unknown error";
> +
> +#ifdef HAVE_GNU_STRERROR_R

And use #ifdef STRERROR_R_CHAR_P here?

Thanks,

Mark


Re: [PATCH] libdwfl: use GNU strerror_r only when available.

2021-02-01 Thread Érico Nogueira via Elfutils-devel

Em 01/02/2021 18:35, Mark Wielaard escreveu:

Hi Érico,

On Mon, Feb 01, 2021 at 03:56:26PM -0300, Érico Nogueira via Elfutils-devel 
wrote:

Some C libraries don't provide the GNU version of strerror_r, only the
XSI-compliant one. We use the GNU version when available, since it fits
the code better, and otherwise use the XSI-compliant one.


Could you also mention this bug in the commit message?
https://sourceware.org/bugzilla/show_bug.cgi?id=21010


Will do!




If possible, I'd like to get this patch in before the release, otherwise
it's an easy one to carry locally.


One other comment, but this looks good to go otherwise.


diff --git a/configure.ac b/configure.ac
index 346ab800..baf6faf5 100644
--- a/configure.ac
+++ b/configure.ac
@@ -428,6 +428,18 @@ AC_CHECK_DECLS([mempcpy],[],[],
  
  AC_CHECK_FUNCS([process_vm_readv])
  
+AC_CACHE_CHECK([whether C library provides GNU strerror_r], ac_cv_gnu_strerror_r, [dnl

+old_CFLAGS="$CFLAGS"
+CFLAGS="$CFLAGS -Werror"
+AC_COMPILE_IFELSE([AC_LANG_SOURCE([dnl
+#define _GNU_SOURCE
+#include 
+char * (*s)(int, char*, size_t) = strerror_r;
+])], ac_cv_gnu_strerror_r=yes, ac_cv_gnu_strerror_r=no)
+CFLAGS="$old_CFLAGS"])
+AS_IF([test "x$ac_cv_gnu_strerror_r" = "xyes"],
+  [AC_DEFINE([HAVE_GNU_STRERROR_R], [1], [Defined if libc has GNU style 
strerror_r])])
+


autoconf comes with the following check:

  - Macro: AC_FUNC_STRERROR_R

 If strerror_r is available, define HAVE_STRERROR_R, and if it is
 declared, define HAVE_DECL_STRERROR_R. If it returns a char *
 message, define STRERROR_R_CHAR_P; otherwise it returns an int
 error number. The Thread-Safe Functions option of Posix requires
 strerror_r to return int, but many systems (including, for
 example, version 2.2.4 of the GNU C Library) return a char * value
 that is not necessarily equal to the buffer argument.

Can we use that instead?


Thank you for pointing me at it :)

I was a bit worried about rolling my own check here, glad to find out 
there is a standard way of doing it.





+static const char *
+errnomsg(int error)
+{
+  /* Won't be changed by strerror_r, but not const so compiler doesn't throw 
warning */
+  static char unknown[] = "unknown error";
+
+#ifdef HAVE_GNU_STRERROR_R


And use #ifdef STRERROR_R_CHAR_P here?

Thanks,

Mark



[PATCH v2] libdwfl: use GNU strerror_r only when available.

2021-02-01 Thread Érico Nogueira via Elfutils-devel
From: Érico Rolim 

Some C libraries don't provide the GNU version of strerror_r, only the
XSI-compliant one. We use the GNU version when available, since it fits
the code better, and otherwise use the XSI-compliant one.

https://sourceware.org/bugzilla/show_bug.cgi?id=21010

Signed-off-by: Érico Rolim 
---

I'm not sure if it's a bug in this configure.ac or this macro, but
_GNU_SOURCE wasn't defined and lead to XSI strerror_r being used on
glibc until I added the trick with CFLAGS and old_CFLAGS. It's still way
slimmer than the previous version :)

I see that -D_GNU_SOURCE is passed to the build via config/eu.am, maybe
it could somehow be plugged into configure.ac earlier? I'm not entirely
sure what's best.

 ChangeLog|  4 
 configure.ac |  5 +
 libdwfl/ChangeLog|  4 
 libdwfl/dwfl_error.c | 17 -
 4 files changed, 29 insertions(+), 1 deletion(-)

diff --git a/ChangeLog b/ChangeLog
index 142caa27..c8f921a5 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2021-02-01  Érico Nogueira  
+
+   * configure.ac: Check for GNU strerror_r.
+
 2021-01-12  Dmitry V. Levin  
 
* configure.ac [--enable-gcov]: Check for gcov, lcov, and genhtml.
diff --git a/configure.ac b/configure.ac
index 346ab800..47db8472 100644
--- a/configure.ac
+++ b/configure.ac
@@ -428,6 +428,11 @@ AC_CHECK_DECLS([mempcpy],[],[],
 
 AC_CHECK_FUNCS([process_vm_readv])
 
+old_CFLAGS="$CFLAGS"
+CFLAGS="$CFLAGS -D_GNU_SOURCE"
+AC_FUNC_STRERROR_R()
+CFLAGS="$old_CFLAGS"
+
 AC_CHECK_LIB([stdc++], [__cxa_demangle], [dnl
 AC_DEFINE([USE_DEMANGLE], [1], [Defined if demangling is enabled])])
 AM_CONDITIONAL(DEMANGLE, test "x$ac_cv_lib_stdcpp___cxa_demangle" = "xyes")
diff --git a/libdwfl/ChangeLog b/libdwfl/ChangeLog
index 5058f5f8..d107e78f 100644
--- a/libdwfl/ChangeLog
+++ b/libdwfl/ChangeLog
@@ -1,3 +1,7 @@
+2021-02-01  Érico Nogueira  
+
+   * dwfl_error.c (strerror_r): Only use the GNU version when available.
+
 2021-01-08  Timm Bäder  
 
* elf-from-memory.c (elf_from_remote_memory): Add for loop over
diff --git a/libdwfl/dwfl_error.c b/libdwfl/dwfl_error.c
index 7bcf61cc..a5c683a9 100644
--- a/libdwfl/dwfl_error.c
+++ b/libdwfl/dwfl_error.c
@@ -137,6 +137,21 @@ __libdwfl_seterrno (Dwfl_Error error)
 }
 
 
+static const char *
+errnomsg(int error)
+{
+  /* Won't be changed by strerror_r, but not const so compiler doesn't throw 
warning */
+  static char unknown[] = "unknown error";
+
+#ifdef STRERROR_R_CHAR_P
+  return strerror_r (error, unknown, 0);
+#else
+  /* To store the error message from strerror_r in a thread-safe manner */
+  static __thread char msg[128];
+  return strerror_r (error, msg, sizeof (msg)) ? unknown : msg;
+#endif
+}
+
 const char *
 dwfl_errmsg (int error)
 {
@@ -154,7 +169,7 @@ dwfl_errmsg (int error)
   switch (error &~ 0x)
 {
 case OTHER_ERROR (ERRNO):
-  return strerror_r (error & 0x, "bad", 0);
+  return errnomsg (error & 0x);
 case OTHER_ERROR (LIBELF):
   return elf_errmsg (error & 0x);
 case OTHER_ERROR (LIBDW):
-- 
2.30.0



[PATCH] backends/ppc_initreg.c: include .

2021-02-01 Thread Érico Nogueira via Elfutils-devel
From: Érico Rolim 

Necessary on musl, doesn't affect the build on glibc.
---
 backends/ChangeLog | 4 
 backends/ppc_initreg.c | 1 +
 2 files changed, 5 insertions(+)

diff --git a/backends/ChangeLog b/backends/ChangeLog
index f22cd57f..eb15c81d 100644
--- a/backends/ChangeLog
+++ b/backends/ChangeLog
@@ -1,3 +1,7 @@
+2021-02-01  Érico Nogueira  
+
+   * ppc_initreg.c: Also include .
+
 2020-12-12  Dmitry V. Levin  
 
* aarch64_retval.c (aarch64_return_value_location): Fix spelling typo
diff --git a/backends/ppc_initreg.c b/backends/ppc_initreg.c
index 0e0d3599..72cdb860 100644
--- a/backends/ppc_initreg.c
+++ b/backends/ppc_initreg.c
@@ -32,6 +32,7 @@
 
 #include 
 #if defined(__powerpc__) && defined(__linux__)
+# include 
 # include 
 # include 
 #endif
-- 
2.30.0



Re: [PATCH v2] libdwfl: use GNU strerror_r only when available.

2021-02-01 Thread Dmitry V. Levin
Hi,

On Mon, Feb 01, 2021 at 09:16:56PM -0300, Érico Nogueira via Elfutils-devel 
wrote:
[...]
> I'm not sure if it's a bug in this configure.ac or this macro, but
> _GNU_SOURCE wasn't defined and lead to XSI strerror_r being used on
> glibc until I added the trick with CFLAGS and old_CFLAGS. It's still way
> slimmer than the previous version :)
> 
> I see that -D_GNU_SOURCE is passed to the build via config/eu.am, maybe
> it could somehow be plugged into configure.ac earlier? I'm not entirely
> sure what's best.

I wonder why don't we just use AC_USE_SYSTEM_EXTENSIONS
instead of all these dances with -D_GNU_SOURCE.


-- 
ldv


[PATCH v2] backends/ppc_initreg.c: include .

2021-02-01 Thread Érico Nogueira via Elfutils-devel
From: Érico Rolim 

Necessary on musl for struct pt_regs definition, doesn't affect the
build on glibc.

Signed-off-by: Érico Rolim 
---

Sending a v2 with the main difference being a slightly different commit
message and signed-off-by line.

I'm a bit hesitant on this being the correct patch, so I'd ask that you
only merge if you think it makes total sense, otherwise I'd like to sit
on it for a bit. For the record, it has been in use in Void Linux since
the end of 2019.

 backends/ChangeLog | 4 
 backends/ppc_initreg.c | 1 +
 2 files changed, 5 insertions(+)

diff --git a/backends/ChangeLog b/backends/ChangeLog
index f22cd57f..eb15c81d 100644
--- a/backends/ChangeLog
+++ b/backends/ChangeLog
@@ -1,3 +1,7 @@
+2021-02-01  Érico Nogueira  
+
+   * ppc_initreg.c: Also include .
+
 2020-12-12  Dmitry V. Levin  
 
* aarch64_retval.c (aarch64_return_value_location): Fix spelling typo
diff --git a/backends/ppc_initreg.c b/backends/ppc_initreg.c
index 0e0d3599..72cdb860 100644
--- a/backends/ppc_initreg.c
+++ b/backends/ppc_initreg.c
@@ -32,6 +32,7 @@
 
 #include 
 #if defined(__powerpc__) && defined(__linux__)
+# include 
 # include 
 # include 
 #endif
-- 
2.30.0



Re: [PATCH v2] backends/ppc_initreg.c: include .

2021-02-01 Thread Dmitry V. Levin
On Tue, Feb 02, 2021 at 12:04:03AM -0300, Érico Nogueira via Elfutils-devel 
wrote:
> From: Érico Rolim 
> 
> Necessary on musl for struct pt_regs definition, doesn't affect the
> build on glibc.
> 
> Signed-off-by: Érico Rolim 
> ---
> 
> Sending a v2 with the main difference being a slightly different commit
> message and signed-off-by line.
> 
> I'm a bit hesitant on this being the correct patch, so I'd ask that you
> only merge if you think it makes total sense, otherwise I'd like to sit
> on it for a bit. For the record, it has been in use in Void Linux since
> the end of 2019.

I'm afraid this won't work as is.

The reason why glibc doesn't require this change is that its
sysdeps/unix/sysv/linux/powerpc/sys/user.h contains #include 
since the very beginning of this file back in 1998.

As you probably know,  and  are not as
compatible as we would like them to be, this is the reason why e.g.
elfutils commit 4482d0009a99b1773f2426479b666b08f57af9d5 moved
#include  before #include .

Said that, I think it's safe to include  right before
 on powerpc since in glibc the latter includes the former.

>  backends/ChangeLog | 4 
>  backends/ppc_initreg.c | 1 +
>  2 files changed, 5 insertions(+)
> 
> diff --git a/backends/ChangeLog b/backends/ChangeLog
> index f22cd57f..eb15c81d 100644
> --- a/backends/ChangeLog
> +++ b/backends/ChangeLog
> @@ -1,3 +1,7 @@
> +2021-02-01  Érico Nogueira  
> +
> + * ppc_initreg.c: Also include .
> +
>  2020-12-12  Dmitry V. Levin  
>  
>   * aarch64_retval.c (aarch64_return_value_location): Fix spelling typo
> diff --git a/backends/ppc_initreg.c b/backends/ppc_initreg.c
> index 0e0d3599..72cdb860 100644
> --- a/backends/ppc_initreg.c
> +++ b/backends/ppc_initreg.c
> @@ -32,6 +32,7 @@
>  
>  #include 
>  #if defined(__powerpc__) && defined(__linux__)
> +# include 
>  # include 
>  # include 
>  #endif
> -- 
> 2.30.0

-- 
ldv