list(APPEND CORECLR_LIBRARIES
${START_WHOLE_ARCHIVE} # force all PAL objects to be included so all exports are available
coreclrpal
+ tracepointprovider
${END_WHOLE_ARCHIVE}
mscorrc_debug
palrt
typedef DWORD (PALAPI *PTHREAD_START_ROUTINE)(LPVOID lpThreadParameter);
typedef PTHREAD_START_ROUTINE LPTHREAD_START_ROUTINE;
-
-/******************* Tracing Initialization *******************************/
-
-#if defined(__LINUX__)
-
-// Constructor priority is set to 200, which allows for constructors to
-// guarantee that they run before or after this constructor by setting
-// their priority appropriately.
-
-// Priority values must be greater than 100. The lower the value,
-// the higher the priority.
-static
-void
-__attribute__((__unused__))
-__attribute__((constructor (200)))
-PAL_InitializeTracing(void);
-
-#endif
-
-
/******************* PAL-Specific Entrypoints *****************************/
PALIMPORT
${PLATFORM_SOURCES}
)
+add_library(tracepointprovider
+ STATIC
+ misc/tracepointprovider.cpp
+)
+
if(CMAKE_SYSTEM_NAME STREQUAL Darwin)
find_library(COREFOUNDATION CoreFoundation)
find_library(CORESERVICES CoreServices)
restore_signal(code, &g_previous_sigill);
}
- PROCShutdownProcess();
+ PROCNotifyProcessShutdown();
}
/*++
restore_signal(code, &g_previous_sigfpe);
}
- PROCShutdownProcess();
+ PROCNotifyProcessShutdown();
}
/*++
restore_signal(code, &g_previous_sigsegv);
}
- PROCShutdownProcess();
+ PROCNotifyProcessShutdown();
}
/*++
PROCAbort();
}
- PROCShutdownProcess();
+ PROCNotifyProcessShutdown();
}
/*++
restore_signal(code, &g_previous_sigbus);
}
- PROCShutdownProcess();
+ PROCNotifyProcessShutdown();
}
/*++
{
TRACE("SIGINT signal; chaining to previous sigaction\n");
- PROCShutdownProcess();
+ PROCNotifyProcessShutdown();
// Restore the original or default handler and resend signal
restore_signal(code, &g_previous_sigint);
{
TRACE("SIGQUIT signal; chaining to previous sigaction\n");
- PROCShutdownProcess();
+ PROCNotifyProcessShutdown();
// Restore the original or default handler and resend signal
restore_signal(code, &g_previous_sigquit);
int status = pthread_kill(pThread->GetPThreadSelf(), INJECT_ACTIVATION_SIGNAL);
if (status != 0)
{
- PROCShutdownProcess();
+ PROCNotifyProcessShutdown();
// Failure to send the signal is fatal. There are only two cases when sending
// the signal can fail. First, if the signal ID is invalid and second,
/*++
Function:
- PROCShutdownProcess
+ PROCNotifyProcessShutdown
Calls the abort handler to do any shutdown cleanup. Call be
called from the unhandled native exception handler.
(no return value)
--*/
-void PROCShutdownProcess();
+void PROCNotifyProcessShutdown();
/*++
Function:
// Initialize the environment.
if (FALSE == MiscInitialize())
{
- goto done;
+ goto CLEANUP0;
}
// Initialize debug channel settings before anything else.
// MiscInitialize.
if (FALSE == DBG_init_channels())
{
- goto done;
+ goto CLEANUP0;
}
#if _DEBUG
// we use large numbers of threads or have many open files.
}
+
/* initialize the shared memory infrastructure */
if (!SHMInitialize())
{
CLEANUP1:
SHMCleanup();
CLEANUP0:
+ TLSCleanup();
ERROR("PAL_Initialize failed\n");
SetLastError(palError);
done:
static const char RANDOM_DEVICE_NAME[] ="/dev/random";
static const char URANDOM_DEVICE_NAME[]="/dev/urandom";
-
-/*++
-
-Initialization logic for LTTng tracepoint providers.
-
---*/
-#if defined(__LINUX__)
-
-static const char tpLibName[] = "libcoreclrtraceptprovider.so";
-
-
-/*++
-
-NOTE: PAL_InitializeTracing MUST NOT depend on anything in the PAL itself
-as it is called prior to PAL initialization.
-
---*/
-static
-void
-PAL_InitializeTracing(void)
-{
- // Get the path to the currently executing shared object (libcoreclr.so).
- Dl_info info;
- int succeeded = dladdr((void *)PAL_InitializeTracing, &info);
- if(!succeeded)
- {
- return;
- }
-
- // Copy the path and modify the shared object name to be the tracepoint provider.
- char tpProvPath[MAX_LONGPATH];
- int pathLen = strlen(info.dli_fname);
- int tpLibNameLen = strlen(tpLibName);
-
- // Find the length of the full path without the shared object name, including the trailing slash.
- int lastTrailingSlashLen = -1;
- for(int i=pathLen-1; i>=0; i--)
- {
- if(info.dli_fname[i] == '/')
- {
- lastTrailingSlashLen = i+1;
- break;
- }
- }
-
- // Make sure we found the last trailing slash.
- if(lastTrailingSlashLen == -1)
- {
- return;
- }
-
- // Make sure that the final path is shorter than MAX_PATH.
- // +1 ensures that the string can be NULL-terminated.
- if((lastTrailingSlashLen + tpLibNameLen + 1) > MAX_LONGPATH)
- {
- return;
- }
-
- // Copy the path without the shared object name.
- memcpy(&tpProvPath, info.dli_fname, lastTrailingSlashLen);
-
- // Append the shared object name for the tracepoint provider.
- memcpy(&tpProvPath[lastTrailingSlashLen], &tpLibName, tpLibNameLen);
-
- // NULL-terminate the string.
- tpProvPath[lastTrailingSlashLen + tpLibNameLen] = '\0';
-
- // Load the tracepoint provider.
- // It's OK if this fails - that just means that tracing dependencies aren't available.
- dlopen(tpProvPath, RTLD_NOW | RTLD_GLOBAL);
-}
-
-#endif
-
/*++
Function :
--- /dev/null
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+/*++
+
+Module Name:
+
+ tracepointprovider.cpp
+
+Abstract:
+
+ Trace point provider support
+
+Revision History:
+
+--*/
+
+#include "pal/palinternal.h"
+#include "pal/dbgmsg.h"
+#include "pal/file.h"
+#include "pal/process.h"
+#include "pal/module.h"
+#include "pal/malloc.hpp"
+
+#include <errno.h>
+#include <unistd.h>
+#include <pthread.h>
+#include <dlfcn.h>
+
+SET_DEFAULT_DEBUG_CHANNEL(MISC);
+
+/*++
+
+Initialization logic for LTTng tracepoint providers.
+
+--*/
+#if defined(__LINUX__)
+
+static const char tpLibName[] = "libcoreclrtraceptprovider.so";
+
+
+/*++
+
+NOTE: PAL_InitializeTracing MUST NOT depend on anything in the PAL itself
+as it is called prior to PAL initialization.
+
+Constructor priority is set to 200, which allows for constructors to
+guarantee that they run before or after this constructor by setting
+their priority appropriately.
+
+Priority values must be greater than 100. The lower the value,
+the higher the priority.
+
+--*/
+__attribute__((__unused__))
+__attribute__((constructor (200)))
+static void
+PAL_InitializeTracing(void)
+{
+ // Get the path to the currently executing shared object (libcoreclr.so).
+ Dl_info info;
+ int succeeded = dladdr((void *)PAL_InitializeTracing, &info);
+ if(!succeeded)
+ {
+ return;
+ }
+
+ // Copy the path and modify the shared object name to be the tracepoint provider.
+ char tpProvPath[MAX_LONGPATH];
+ int pathLen = strlen(info.dli_fname);
+ int tpLibNameLen = strlen(tpLibName);
+
+ // Find the length of the full path without the shared object name, including the trailing slash.
+ int lastTrailingSlashLen = -1;
+ for(int i=pathLen-1; i>=0; i--)
+ {
+ if(info.dli_fname[i] == '/')
+ {
+ lastTrailingSlashLen = i+1;
+ break;
+ }
+ }
+
+ // Make sure we found the last trailing slash.
+ if(lastTrailingSlashLen == -1)
+ {
+ return;
+ }
+
+ // Make sure that the final path is shorter than MAX_PATH.
+ // +1 ensures that the string can be NULL-terminated.
+ if((lastTrailingSlashLen + tpLibNameLen + 1) > MAX_LONGPATH)
+ {
+ return;
+ }
+
+ // Copy the path without the shared object name.
+ memcpy(&tpProvPath, info.dli_fname, lastTrailingSlashLen);
+
+ // Append the shared object name for the tracepoint provider.
+ memcpy(&tpProvPath[lastTrailingSlashLen], &tpLibName, tpLibNameLen);
+
+ // NULL-terminate the string.
+ tpProvPath[lastTrailingSlashLen + tpLibNameLen] = '\0';
+
+ // Load the tracepoint provider.
+ // It's OK if this fails - that just means that tracing dependencies aren't available.
+ dlopen(tpProvPath, RTLD_NOW | RTLD_GLOBAL);
+}
+
+#endif
\ No newline at end of file
/*++
Function:
- PROCShutdownProcess
+ PROCNotifyProcessShutdown
Calls the abort handler to do any shutdown cleanup. Call be called
from the unhandled native exception handler.
(no return value)
--*/
__attribute__((destructor))
-void PROCShutdownProcess()
+void PROCNotifyProcessShutdown()
{
- TRACE("PROCShutdownProcess %p\n", g_shutdownCallback.RawValue());
+ TRACE("PROCNotifyProcessShutdown %p\n", g_shutdownCallback.RawValue());
PSHUTDOWN_CALLBACK callback = InterlockedExchangePointer(&g_shutdownCallback, NULL);
if (callback != NULL)
void
PROCAbort()
{
- PROCShutdownProcess();
+ PROCNotifyProcessShutdown();
abort();
}
locked = PALInitLock();
if(locked && PALIsInitialized())
{
- PROCShutdownProcess();
+ PROCNotifyProcessShutdown();
PALCommonCleanup();
}
}
VOID TLSCleanup()
{
SPINLOCKDestroy(&free_threads_spinlock);
+
+ pthread_key_delete(thObjKey);
}
/*++