All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] valgrind: helgrind: Intercept libc functions
@ 2020-11-19 18:31 Stacy Gaikovaia
  2020-11-20 11:00 ` [OE-core] " Richard Purdie
  2020-11-20 16:32 ` Richard Purdie
  0 siblings, 2 replies; 5+ messages in thread
From: Stacy Gaikovaia @ 2020-11-19 18:31 UTC (permalink / raw)
  To: openembedded-core

From: Stacy Gaikovaia <Stacy.Gaikovaia@windriver.com>

PTH_FUNC definition needs to be modified in order to
intercept posix thread functions in both libc and libpthread.
In order to handle this in helgrind, weak alias the pthread functions in glibc.
This also prevents any need for a special case for musl, where
these definitions aren't duplicated.

See https://bugs.kde.org/show_bug.cgi?id=428909 for additional
discussion.

Signed-off-by: Paul Floyd <paulf@free.fr>
Signed-off-by: Stacy Gaikovaia <Stacy.Gaikovaia@windriver.com>
---
 ...01-helgrind-Intercept-libc-functions.patch | 45 +++++++++++++++++++
 .../valgrind/valgrind_3.16.1.bb               |  1 +
 2 files changed, 46 insertions(+)
 create mode 100644 meta/recipes-devtools/valgrind/valgrind/0001-helgrind-Intercept-libc-functions.patch

diff --git a/meta/recipes-devtools/valgrind/valgrind/0001-helgrind-Intercept-libc-functions.patch b/meta/recipes-devtools/valgrind/valgrind/0001-helgrind-Intercept-libc-functions.patch
new file mode 100644
index 0000000000..b3ab329bd8
--- /dev/null
+++ b/meta/recipes-devtools/valgrind/valgrind/0001-helgrind-Intercept-libc-functions.patch
@@ -0,0 +1,45 @@
+From d02cafce8dd29df0309935beefbfbca1d8e29862 Mon Sep 17 00:00:00 2001
+From: Paul Floyd <paulf@free.fr>
+Date: Wed, 18 Nov 2020 12:49:20 -0400
+Subject: [PATCH] helgrind: Intercept libc functions
+
+Signed-off-by: Paul Floyd <paulf@free.fr>
+
+PTH_FUNC definition needs to be modified in order to
+intercept posix threa functions in both libc and
+libpthread. In order to handle this in helgrind, weak alias
+the pthread functions in glibc.
+
+Signed-off-by: Stacy Gaikovaia <stacy.gaikovaia@windriver.com>
+
+---
+ helgrind/hg_intercepts.c | 6 ++++++
+ 1 file changed, 6 insertions(+)
+
+diff --git a/helgrind/hg_intercepts.c b/helgrind/hg_intercepts.c
+index a10c3a4a3..4b571bef9 100644
+--- a/helgrind/hg_intercepts.c
++++ b/helgrind/hg_intercepts.c
+@@ -77,6 +77,11 @@
+ /*---                                                          ---*/
+ /*----------------------------------------------------------------*/
+ 
++#define hg_expand(tok) #tok
++#define hg_str(tok) hg_expand(tok)
++# define hg_weak_alias(name, aliasname) \
++  extern __typeof (name) aliasname __attribute__ ((weak, alias(hg_str(name))))
++
+ #if defined(VGO_solaris)
+ /* On Solaris, libpthread is just a filter library on top of libc.
+  * Threading and synchronization functions in runtime linker are not
+@@ -93,6 +98,7 @@
+ #else
+ #define PTH_FUNC(ret_ty, f, args...) \
+    ret_ty I_WRAP_SONAME_FNNAME_ZZ(VG_Z_LIBPTHREAD_SONAME,f)(args); \
++   hg_weak_alias(I_WRAP_SONAME_FNNAME_ZZ(VG_Z_LIBPTHREAD_SONAME,f), I_WRAP_SONAME_FNNAME_ZZ(VG_Z_LIBC_SONAME,f)); \
+    ret_ty I_WRAP_SONAME_FNNAME_ZZ(VG_Z_LIBPTHREAD_SONAME,f)(args)
+ #define CREQ_PTHREAD_T pthread_t
+ #define SEM_ERROR errno
+-- 
+2.17.1
+
diff --git a/meta/recipes-devtools/valgrind/valgrind_3.16.1.bb b/meta/recipes-devtools/valgrind/valgrind_3.16.1.bb
index bcba55f327..5db181ac14 100644
--- a/meta/recipes-devtools/valgrind/valgrind_3.16.1.bb
+++ b/meta/recipes-devtools/valgrind/valgrind_3.16.1.bb
@@ -42,6 +42,7 @@ SRC_URI = "https://sourceware.org/pub/valgrind/valgrind-${PV}.tar.bz2 \
            file://0001-memcheck-tests-Fix-timerfd-syscall-test.patch \
            file://0001-drd-Port-to-Fedora-33.patch \
            file://0001-drd-musl-fix.patch \
+           file://0001-helgrind-Intercept-libc-functions.patch \
            "
 SRC_URI[md5sum] = "d1b153f1ab17cf1f311705e7a83ef589"
 SRC_URI[sha256sum] = "c91f3a2f7b02db0f3bc99479861656154d241d2fdb265614ba918cc6720a33ca"
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [OE-core] [PATCH] valgrind: helgrind: Intercept libc functions
  2020-11-19 18:31 [PATCH] valgrind: helgrind: Intercept libc functions Stacy Gaikovaia
@ 2020-11-20 11:00 ` Richard Purdie
  2020-11-20 16:32 ` Richard Purdie
  1 sibling, 0 replies; 5+ messages in thread
From: Richard Purdie @ 2020-11-20 11:00 UTC (permalink / raw)
  To: Stacy Gaikovaia, openembedded-core; +Cc: Mittal, Anuj

On Thu, 2020-11-19 at 10:31 -0800, Stacy Gaikovaia wrote:
> From: Stacy Gaikovaia <Stacy.Gaikovaia@windriver.com>
> 
> PTH_FUNC definition needs to be modified in order to
> intercept posix thread functions in both libc and libpthread.
> In order to handle this in helgrind, weak alias the pthread functions in glibc.
> This also prevents any need for a special case for musl, where
> these definitions aren't duplicated.
> 
> See https://bugs.kde.org/show_bug.cgi?id=428909 for additional
> discussion.
> 
> Signed-off-by: Paul Floyd <paulf@free.fr>
> Signed-off-by: Stacy Gaikovaia <Stacy.Gaikovaia@windriver.com>
> ---
>  ...01-helgrind-Intercept-libc-functions.patch | 45 +++++++++++++++++++
>  .../valgrind/valgrind_3.16.1.bb               |  1 +
>  2 files changed, 46 insertions(+)
>  create mode 100644 meta/recipes-devtools/valgrind/valgrind/0001-helgrind-Intercept-libc-functions.patch
> 
> diff --git a/meta/recipes-devtools/valgrind/valgrind/0001-helgrind-Intercept-libc-functions.patch b/meta/recipes-devtools/valgrind/valgrind/0001-helgrind-Intercept-libc-functions.patch
> new file mode 100644
> index 0000000000..b3ab329bd8
> --- /dev/null
> +++ b/meta/recipes-devtools/valgrind/valgrind/0001-helgrind-Intercept-libc-functions.patch
> @@ -0,0 +1,45 @@
> +From d02cafce8dd29df0309935beefbfbca1d8e29862 Mon Sep 17 00:00:00 2001
> +From: Paul Floyd <paulf@free.fr>
> +Date: Wed, 18 Nov 2020 12:49:20 -0400
> +Subject: [PATCH] helgrind: Intercept libc functions
> +
> +Signed-off-by: Paul Floyd <paulf@free.fr>
> +
> +PTH_FUNC definition needs to be modified in order to
> +intercept posix threa functions in both libc and
> +libpthread. In order to handle this in helgrind, weak alias
> +the pthread functions in glibc.
> +
> +Signed-off-by: Stacy Gaikovaia <stacy.gaikovaia@windriver.com>

The patch in OE needs an Upstream-Status which would be Submitted in
this case I guess. I've added as I queued the patch to save you
resubmitting, thanks for the fix.

Anuj: This should fix a ptest regression in gatesgarth that QA
highlighted at release.

Cheers,

Richard


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [OE-core] [PATCH] valgrind: helgrind: Intercept libc functions
  2020-11-19 18:31 [PATCH] valgrind: helgrind: Intercept libc functions Stacy Gaikovaia
  2020-11-20 11:00 ` [OE-core] " Richard Purdie
@ 2020-11-20 16:32 ` Richard Purdie
  2020-11-20 17:18   ` Stacy Gaikovaia
  1 sibling, 1 reply; 5+ messages in thread
From: Richard Purdie @ 2020-11-20 16:32 UTC (permalink / raw)
  To: Stacy Gaikovaia, openembedded-core; +Cc: Ross Burton

On Thu, 2020-11-19 at 10:31 -0800, Stacy Gaikovaia wrote:
> From: Stacy Gaikovaia <Stacy.Gaikovaia@windriver.com>
> 
> PTH_FUNC definition needs to be modified in order to
> intercept posix thread functions in both libc and libpthread.
> In order to handle this in helgrind, weak alias the pthread functions
> in glibc.
> This also prevents any need for a special case for musl, where
> these definitions aren't duplicated.
> 
> See https://bugs.kde.org/show_bug.cgi?id=428909 for additional
> discussion.
> 
> Signed-off-by: Paul Floyd <paulf@free.fr>
> Signed-off-by: Stacy Gaikovaia <Stacy.Gaikovaia@windriver.com>

Unfortunately this failed on musl:

https://autobuilder.yoctoproject.org/typhoon/#/builders/45/builds/2731
https://autobuilder.yoctoproject.org/typhoon/#/builders/64/builds/2728

Cheers,

Richard


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [OE-core] [PATCH] valgrind: helgrind: Intercept libc functions
  2020-11-20 16:32 ` Richard Purdie
@ 2020-11-20 17:18   ` Stacy Gaikovaia
  0 siblings, 0 replies; 5+ messages in thread
From: Stacy Gaikovaia @ 2020-11-20 17:18 UTC (permalink / raw)
  To: Richard Purdie, openembedded-core; +Cc: Ross Burton

Alright - I'll submit a fix today.

Stacy

On 2020-11-20 11:32 a.m., Richard Purdie wrote:
> [Please note this e-mail is from an EXTERNAL e-mail address]
>
> On Thu, 2020-11-19 at 10:31 -0800, Stacy Gaikovaia wrote:
>> From: Stacy Gaikovaia <Stacy.Gaikovaia@windriver.com>
>>
>> PTH_FUNC definition needs to be modified in order to
>> intercept posix thread functions in both libc and libpthread.
>> In order to handle this in helgrind, weak alias the pthread functions
>> in glibc.
>> This also prevents any need for a special case for musl, where
>> these definitions aren't duplicated.
>>
>> See https://bugs.kde.org/show_bug.cgi?id=428909 for additional
>> discussion.
>>
>> Signed-off-by: Paul Floyd <paulf@free.fr>
>> Signed-off-by: Stacy Gaikovaia <Stacy.Gaikovaia@windriver.com>
> Unfortunately this failed on musl:
>
> https://autobuilder.yoctoproject.org/typhoon/#/builders/45/builds/2731
> https://autobuilder.yoctoproject.org/typhoon/#/builders/64/builds/2728
>
> Cheers,
>
> Richard
>

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH] valgrind: helgrind: Intercept libc functions
@ 2020-11-20 19:51 Stacy Gaikovaia
  0 siblings, 0 replies; 5+ messages in thread
From: Stacy Gaikovaia @ 2020-11-20 19:51 UTC (permalink / raw)
  To: openembedded-core

From: Stacy Gaikovaia <Stacy.Gaikovaia@windriver.com>

PTH_FUNC definition needs to be modified in order to
intercept posix thread functions in both libc and libpthread.
In order to handle this in helgrind, weak alias the pthread functions in glibc.
Include a special case for musl.

See https://bugs.kde.org/show_bug.cgi?id=428909 for additional
discussion.

Upstream-Status: Submitted

Signed-off-by: Paul Floyd <paulf@free.fr>
Signed-off-by: Stacy Gaikovaia <Stacy.Gaikovaia@windriver.com>
---
 ...01-helgrind-Intercept-libc-functions.patch | 54 +++++++++++++++++++
 .../valgrind/valgrind_3.16.1.bb               |  1 +
 2 files changed, 55 insertions(+)
 create mode 100644 meta/recipes-devtools/valgrind/valgrind/0001-helgrind-Intercept-libc-functions.patch

diff --git a/meta/recipes-devtools/valgrind/valgrind/0001-helgrind-Intercept-libc-functions.patch b/meta/recipes-devtools/valgrind/valgrind/0001-helgrind-Intercept-libc-functions.patch
new file mode 100644
index 0000000000..f66df3d2d2
--- /dev/null
+++ b/meta/recipes-devtools/valgrind/valgrind/0001-helgrind-Intercept-libc-functions.patch
@@ -0,0 +1,54 @@
+From cdec010444df5a4328e90d07a2024fdeefcc74b5 Mon Sep 17 00:00:00 2001
+From: Paul Floyd <paulf@free.fr>
+Date: Wed, 18 Nov 2020 12:49:20 -0400
+Subject: [PATCH] helgrind: Intercept libc functions
+
+PTH_FUNC definition needs to be modified in order to
+intercept posix thread functions in both libc and
+libpthread. In order to handle this in helgrind, weak alias
+the pthread functions in glibc.
+
+Upstream-Status: Submitted
+
+Signed-off-by: Paul Floyd <paulf@free.fr>
+Signed-off-by: Stacy Gaikovaia <stacy.gaikovaia@windriver.com>
+---
+ helgrind/hg_intercepts.c | 12 ++++++++++++
+ 1 file changed, 12 insertions(+)
+
+diff --git a/helgrind/hg_intercepts.c b/helgrind/hg_intercepts.c
+index a10c3a4a3..316140ca6 100644
+--- a/helgrind/hg_intercepts.c
++++ b/helgrind/hg_intercepts.c
+@@ -77,6 +77,11 @@
+ /*---                                                          ---*/
+ /*----------------------------------------------------------------*/
+ 
++#define hg_expand(tok) #tok
++#define hg_str(tok) hg_expand(tok)
++# define hg_weak_alias(name, aliasname) \
++  extern __typeof (name) aliasname __attribute__ ((weak, alias(hg_str(name))))
++
+ #if defined(VGO_solaris)
+ /* On Solaris, libpthread is just a filter library on top of libc.
+  * Threading and synchronization functions in runtime linker are not
+@@ -91,9 +96,16 @@
+ #define CREQ_PTHREAD_T Word
+ #define SEM_ERROR ret
+ #else
++#ifdef MUSL_LIBC
++#define PTH_FUNC(ret_ty, f, args...) \
++   ret_ty I_WRAP_SONAME_FNNAME_ZZ(VG_Z_LIBPTHREAD_SONAME,f)(args); \
++   ret_ty I_WRAP_SONAME_FNNAME_ZZ(VG_Z_LIBPTHREAD_SONAME,f)(args)
++#else
+ #define PTH_FUNC(ret_ty, f, args...) \
+    ret_ty I_WRAP_SONAME_FNNAME_ZZ(VG_Z_LIBPTHREAD_SONAME,f)(args); \
++   hg_weak_alias(I_WRAP_SONAME_FNNAME_ZZ(VG_Z_LIBPTHREAD_SONAME,f), I_WRAP_SONAME_FNNAME_ZZ(VG_Z_LIBC_SONAME,f)); \
+    ret_ty I_WRAP_SONAME_FNNAME_ZZ(VG_Z_LIBPTHREAD_SONAME,f)(args)
++#endif
+ #define CREQ_PTHREAD_T pthread_t
+ #define SEM_ERROR errno
+ #endif /* VGO_solaris */
+-- 
+2.17.1
+
diff --git a/meta/recipes-devtools/valgrind/valgrind_3.16.1.bb b/meta/recipes-devtools/valgrind/valgrind_3.16.1.bb
index bcba55f327..5db181ac14 100644
--- a/meta/recipes-devtools/valgrind/valgrind_3.16.1.bb
+++ b/meta/recipes-devtools/valgrind/valgrind_3.16.1.bb
@@ -42,6 +42,7 @@ SRC_URI = "https://sourceware.org/pub/valgrind/valgrind-${PV}.tar.bz2 \
            file://0001-memcheck-tests-Fix-timerfd-syscall-test.patch \
            file://0001-drd-Port-to-Fedora-33.patch \
            file://0001-drd-musl-fix.patch \
+           file://0001-helgrind-Intercept-libc-functions.patch \
            "
 SRC_URI[md5sum] = "d1b153f1ab17cf1f311705e7a83ef589"
 SRC_URI[sha256sum] = "c91f3a2f7b02db0f3bc99479861656154d241d2fdb265614ba918cc6720a33ca"
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2020-11-20 19:52 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-11-19 18:31 [PATCH] valgrind: helgrind: Intercept libc functions Stacy Gaikovaia
2020-11-20 11:00 ` [OE-core] " Richard Purdie
2020-11-20 16:32 ` Richard Purdie
2020-11-20 17:18   ` Stacy Gaikovaia
2020-11-20 19:51 Stacy Gaikovaia

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.