Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion src/coreclr/nativeaot/Runtime/eventpipe/ep-rt-aot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@
#include <minipal/random.h>

#include "gcenv.h"
#include "thread.h"
#include "threadstore.h"
#include "threadstore.inl"

#ifndef DIRECTORY_SEPARATOR_CHAR
#ifdef TARGET_UNIX
Expand Down Expand Up @@ -56,7 +59,7 @@ ep_rt_aot_walk_managed_stack_for_thread (
ep_rt_thread_handle_t thread,
EventPipeStackContents *stack_contents)
{
PalDebugBreak();
// NativeAOT does not support getting the call stack
return false;
}

Expand Down Expand Up @@ -826,6 +829,15 @@ void ep_rt_aot_create_activity_id (uint8_t *activity_id, uint32_t activity_id_le
#endif
}

ep_rt_thread_handle_t ep_rt_aot_thread_get_handle (void)
{
return ThreadStore::GetCurrentThreadIfAvailable();
}

ep_rt_thread_id_t ep_rt_aot_thread_get_id (ep_rt_thread_handle_t thread_handle)
{
return thread_handle->GetPalThreadIdForLogging();
}

#ifdef EP_CHECKED_BUILD

Expand Down
38 changes: 10 additions & 28 deletions src/coreclr/nativeaot/Runtime/eventpipe/ep-rt-aot.h
Original file line number Diff line number Diff line change
Expand Up @@ -491,7 +491,7 @@ ep_rt_config_value_get_enable_stackwalk (void)
if (RhConfig::Environment::TryGetBooleanValue("EventPipeEnableStackwalk", &value))
return value;

return true;
return false;
}

/*
Expand Down Expand Up @@ -1550,10 +1550,9 @@ ep_rt_thread_handle_t
ep_rt_thread_get_handle (void)
{
STATIC_CONTRACT_NOTHROW;
// shipping criteria: no EVENTPIPE-NATIVEAOT-TODO left in the codebase
// TODO: Implement thread creation/management if needed
// return GetThreadNULLOk ();
return NULL;

extern ep_rt_thread_handle_t ep_rt_aot_thread_get_handle (void);
return ep_rt_aot_thread_get_handle();
}

static
Expand All @@ -1562,13 +1561,9 @@ ep_rt_thread_id_t
ep_rt_thread_get_id (ep_rt_thread_handle_t thread_handle)
{
STATIC_CONTRACT_NOTHROW;
EP_ASSERT (thread_handle != NULL);

// shipping criteria: no EVENTPIPE-NATIVEAOT-TODO left in the codebase
// TODO: Implement thread creation/management if needed
// return ep_rt_uint64_t_to_thread_id_t (thread_handle->GetOSThreadId64 ());
// PalDebugBreak();
return 0;
extern ep_rt_thread_id_t ep_rt_aot_thread_get_id (ep_rt_thread_handle_t thread_handle);
return ep_rt_aot_thread_get_id(thread_handle);
}

static
Expand Down Expand Up @@ -1605,25 +1600,15 @@ ep_rt_thread_activity_id_handle_t
ep_rt_thread_get_activity_id_handle (void)
{
STATIC_CONTRACT_NOTHROW;
// shipping criteria: no EVENTPIPE-NATIVEAOT-TODO left in the codebase
// TODO: Implement thread creation/management if needed
// return GetThread ();
// PalDebugBreak();
return NULL;
return ep_rt_thread_get_or_create();
}

static
inline
const uint8_t *
ep_rt_thread_get_activity_id_cref (ep_rt_thread_activity_id_handle_t activity_id_handle)
{
STATIC_CONTRACT_NOTHROW;
EP_ASSERT (activity_id_handle != NULL);

// shipping criteria: no EVENTPIPE-NATIVEAOT-TODO left in the codebase
// TODO: Implement thread creation/management if needed
// return reinterpret_cast<const uint8_t *>(activity_id_handle->GetActivityId ());
// PalDebugBreak();
EP_UNREACHABLE ("EP_THREAD_INCLUDE_ACTIVITY_ID should have been defined on NativeAOT");
return NULL;
}

Expand All @@ -1640,7 +1625,7 @@ ep_rt_thread_get_activity_id (
EP_ASSERT (activity_id != NULL);
EP_ASSERT (activity_id_len == EP_ACTIVITY_ID_SIZE);

memcpy (activity_id, ep_rt_thread_get_activity_id_cref (activity_id_handle), EP_ACTIVITY_ID_SIZE);
memcpy (activity_id, ep_thread_get_activity_id_cref (activity_id_handle), EP_ACTIVITY_ID_SIZE);
}

static
Expand All @@ -1656,10 +1641,7 @@ ep_rt_thread_set_activity_id (
EP_ASSERT (activity_id != NULL);
EP_ASSERT (activity_id_len == EP_ACTIVITY_ID_SIZE);

// shipping criteria: no EVENTPIPE-NATIVEAOT-TODO left in the codebase
// TODO: Implement thread creation/management if needed
// activity_id_handle->SetActivityId (reinterpret_cast<LPCGUID>(activity_id));
// PalDebugBreak();
memcpy (ep_thread_get_activity_id_ref (activity_id_handle), activity_id, EP_ACTIVITY_ID_SIZE);
}

#undef EP_YIELD_WHILE
Expand Down
2 changes: 2 additions & 0 deletions src/coreclr/nativeaot/Runtime/eventpipe/ep-rt-config-aot.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,6 @@
#ifndef EVENTPIPE_RT_CONFIG_AOT_H
#define EVENTPIPE_RT_CONFIG_AOT_H

#define EP_THREAD_INCLUDE_ACTIVITY_ID

#endif /* EVENTPIPE_RT_CONFIG_AOT_H */
6 changes: 1 addition & 5 deletions src/coreclr/nativeaot/Runtime/eventpipe/ep-rt-types-aot.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,14 +78,10 @@ typedef struct _rt_aot_lock_internal_t ep_rt_spin_lock_handle_t;
typedef class Thread * ep_rt_thread_handle_t;

#undef ep_rt_thread_activity_id_handle_t
typedef class Thread * ep_rt_thread_activity_id_handle_t;
typedef EventPipeThread * ep_rt_thread_activity_id_handle_t;

#undef ep_rt_thread_id_t
// #ifndef TARGET_UNIX
// typedef DWORD ep_rt_thread_id_t;
// #else
typedef size_t ep_rt_thread_id_t;
//#endif

#undef ep_rt_thread_start_func
typedef size_t (__stdcall *ep_rt_thread_start_func)(void *lpThreadParameter);
Expand Down