aboutsummaryrefslogtreecommitdiff
path: root/devel/electron12/files/patch-base_trace__event_heap__profiler__allocation__context__tracker.cc
diff options
context:
space:
mode:
Diffstat (limited to 'devel/electron12/files/patch-base_trace__event_heap__profiler__allocation__context__tracker.cc')
-rw-r--r--devel/electron12/files/patch-base_trace__event_heap__profiler__allocation__context__tracker.cc38
1 files changed, 38 insertions, 0 deletions
diff --git a/devel/electron12/files/patch-base_trace__event_heap__profiler__allocation__context__tracker.cc b/devel/electron12/files/patch-base_trace__event_heap__profiler__allocation__context__tracker.cc
new file mode 100644
index 000000000000..fe431e31b844
--- /dev/null
+++ b/devel/electron12/files/patch-base_trace__event_heap__profiler__allocation__context__tracker.cc
@@ -0,0 +1,38 @@
+--- base/trace_event/heap_profiler_allocation_context_tracker.cc.orig 2021-04-14 01:08:36 UTC
++++ base/trace_event/heap_profiler_allocation_context_tracker.cc
+@@ -30,6 +30,10 @@
+ #include <sys/prctl.h>
+ #endif
+
++#if defined(OS_BSD)
++#include <pthread_np.h>
++#endif
++
+ namespace base {
+ namespace trace_event {
+
+@@ -61,13 +65,23 @@ ThreadLocalStorage::Slot& AllocationContextTrackerTLS(
+ // with id. This function intentionally leaks the allocated strings since they
+ // are used to tag allocations even after the thread dies.
+ const char* GetAndLeakThreadName() {
+- char name[16];
++#if defined(OS_BSD)
++ constexpr size_t kBufferLen = 64;
++#else
++ constexpr size_t kBufferLen = 16;
++#endif
++ char name[kBufferLen];
+ #if defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_ANDROID)
+ // If the thread name is not set, try to get it from prctl. Thread name might
+ // not be set in cases where the thread started before heap profiling was
+ // enabled.
+ int err = prctl(PR_GET_NAME, name);
+ if (!err) {
++ return strdup(name);
++ }
++#elif defined(OS_BSD) && __FreeBSD__ >= 12
++ pthread_get_name_np(pthread_self(), name, kBufferLen);
++ if (*name != '\0') {
+ return strdup(name);
+ }
+ #endif // defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_ANDROID)