Skip to content

Commit

Permalink
devel/google-perftools: Add LD_32_PRELOAD to the valgrind detection code
Browse files Browse the repository at this point in the history
Suggested by:	Paul Floyd <pjfloyd@wanadoo.fr>
  • Loading branch information
yurivict committed Nov 21, 2021
1 parent 0bae2dd commit c3ff309
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
2 changes: 1 addition & 1 deletion devel/google-perftools/Makefile
Expand Up @@ -3,7 +3,7 @@
PORTNAME= google-perftools
DISTVERSIONPREFIX= gperftools-
DISTVERSION= 2.9.1
PORTREVISION= 2
PORTREVISION= 3
CATEGORIES= devel
MASTER_SITES= https://github.com/gperftools/gperftools/releases/download/gperftools-${PORTVERSION}/
DISTNAME= gperftools-${PORTVERSION}
Expand Down
Expand Up @@ -3,13 +3,15 @@

--- src/base/dynamic_annotations.c.orig 2021-02-15 06:44:21 UTC
+++ src/base/dynamic_annotations.c
@@ -43,6 +43,19 @@
@@ -43,6 +43,21 @@
#include "base/dynamic_annotations.h"
#include "getenv_safe.h" // for TCMallocGetenvSafe

+static int running_on_valgrind_preload = -1;
+void __attribute__ ((constructor)) premain() {
+ char *LD_PRELOAD = getenv("LD_PRELOAD");
+ if (LD_PRELOAD == NULL)
+ LD_PRELOAD = getenv("LD_32_PRELOAD");
+ running_on_valgrind_preload = LD_PRELOAD != NULL &&
+ (
+ strstr(LD_PRELOAD, "/valgrind/") != NULL
Expand All @@ -23,7 +25,7 @@
static int GetRunningOnValgrind(void) {
#ifdef RUNNING_ON_VALGRIND
if (RUNNING_ON_VALGRIND) return 1;
@@ -51,6 +64,11 @@ static int GetRunningOnValgrind(void) {
@@ -51,6 +66,11 @@ static int GetRunningOnValgrind(void) {
if (running_on_valgrind_str) {
return strcmp(running_on_valgrind_str, "0") != 0;
}
Expand Down

0 comments on commit c3ff309

Please sign in to comment.