-
Notifications
You must be signed in to change notification settings - Fork 5.2k
EventPipe support for ProcessInfo #87562
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 9 commits
35f104c
0ebec81
f768b69
e6d76cf
744856c
7e95d43
98129b3
0012451
e909d16
304d2cf
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -28,6 +28,14 @@ | |
| #include "holder.h" | ||
| #include "SpinLock.h" | ||
|
|
||
| #ifndef DIRECTORY_SEPARATOR_CHAR | ||
| #ifdef TARGET_UNIX | ||
| #define DIRECTORY_SEPARATOR_CHAR '/' | ||
| #else // TARGET_UNIX | ||
| #define DIRECTORY_SEPARATOR_CHAR '\\' | ||
| #endif // TARGET_UNIX | ||
| #endif | ||
|
|
||
| #ifdef TARGET_UNIX | ||
| // Per module (1 for NativeAOT), key that will be used to implement TLS in Unix | ||
| pthread_key_t eventpipe_tls_key; | ||
|
|
@@ -41,7 +49,6 @@ thread_local EventPipeAotThreadHolderTLS EventPipeAotThreadHolderTLS::g_threadHo | |
| ep_rt_lock_handle_t _ep_rt_aot_config_lock_handle; | ||
| CrstStatic _ep_rt_aot_config_lock; | ||
|
|
||
| ep_char8_t *volatile _ep_rt_aot_diagnostics_cmd_line; | ||
|
|
||
| #ifndef TARGET_UNIX | ||
| uint32_t *_ep_rt_aot_proc_group_offsets; | ||
|
|
@@ -88,9 +95,57 @@ ep_rt_aot_sample_profiler_write_sampling_event_for_threads ( | |
| const ep_char8_t * | ||
| ep_rt_aot_entrypoint_assembly_name_get_utf8 (void) | ||
| { | ||
| // shipping criteria: no EVENTPIPE-NATIVEAOT-TODO left in the codebase | ||
| // TODO: Implement EventPipe assembly name - return filename in nativeaot? | ||
| return reinterpret_cast<const ep_char8_t*>(""); | ||
| // Cannot use __cpp_threadsafe_static_init feature since it will bring in the C++ runtime and need to use threadsafe way to initialize entrypoint_assembly_name | ||
| static const ep_char8_t * entrypoint_assembly_name = nullptr; | ||
| if (entrypoint_assembly_name == nullptr) { | ||
| ep_char8_t * entrypoint_assembly_name_local; | ||
| const TCHAR * wszModuleFileName = NULL; | ||
| HANDLE moduleHandle = PalGetModuleHandleFromPointer((void*)&ep_rt_aot_entrypoint_assembly_name_get_utf8); | ||
| if(PalGetModuleFileName(&wszModuleFileName, moduleHandle) == 0) { | ||
| entrypoint_assembly_name_local = reinterpret_cast<ep_char8_t *>(malloc(1)); | ||
| if(entrypoint_assembly_name_local==NULL) { | ||
| return NULL; | ||
| } | ||
| *entrypoint_assembly_name_local = '\0'; | ||
| } | ||
| else { | ||
| #ifdef HOST_WINDOWS | ||
| const wchar_t* process_name_const = wcsrchr(wszModuleFileName, DIRECTORY_SEPARATOR_CHAR); | ||
| if (process_name_const != NULL) { | ||
| process_name_const++; | ||
| } | ||
LakshanF marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| size_t len = -1; | ||
| const wchar_t* extension = wcsrchr(process_name_const, '.'); | ||
| if (extension != NULL) { | ||
| len = extension - process_name_const; | ||
| } | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You could define something like
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Added this to the tracking issue, #87069 |
||
| const ep_char16_t* process_name = reinterpret_cast<const ep_char16_t *>(process_name_const); | ||
| entrypoint_assembly_name_local = ep_rt_utf16_to_utf8_string(process_name, len); | ||
LakshanF marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| #else | ||
| const ep_char8_t* process_name_const = strrchr(wszModuleFileName, DIRECTORY_SEPARATOR_CHAR); | ||
| if (process_name_const != NULL) { | ||
| process_name_const++; | ||
| } | ||
| size_t len = strlen(process_name_const); | ||
| const ep_char8_t *extension = strrchr(process_name_const, '.'); | ||
| if (extension != NULL) { | ||
| len = len - strlen(extension); | ||
LakshanF marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| } | ||
| ep_char8_t* process_name = reinterpret_cast<ep_char8_t *>(malloc(len + 1)); | ||
| if (process_name == NULL) { | ||
| return NULL; | ||
| } | ||
| memcpy(process_name, process_name_const, len); | ||
| process_name[len] = '\0'; | ||
| entrypoint_assembly_name_local = reinterpret_cast<ep_char8_t*>(process_name); | ||
| #endif // HOST_WINDOWS | ||
| } | ||
|
|
||
| if (PalInterlockedCompareExchangePointer((void**)(&entrypoint_assembly_name), (void*)(entrypoint_assembly_name_local), nullptr) != nullptr) | ||
| free(entrypoint_assembly_name_local); | ||
| } | ||
|
|
||
| return reinterpret_cast<const char*>(entrypoint_assembly_name); | ||
|
||
| } | ||
|
|
||
| const ep_char8_t * | ||
|
|
@@ -101,6 +156,20 @@ ep_rt_aot_diagnostics_command_line_get (void) | |
| #ifdef TARGET_WINDOWS | ||
| const ep_char16_t* command_line = reinterpret_cast<const ep_char16_t *>(::GetCommandLineW()); | ||
| return ep_rt_utf16_to_utf8_string(command_line, -1); | ||
| #elif TARGET_LINUX | ||
| FILE *cmdline_file = ::fopen("/proc/self/cmdline", "r"); | ||
LakshanF marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| if (cmdline_file == nullptr) | ||
| return ""; | ||
|
|
||
| char *line = NULL; | ||
| size_t line_len = 0; | ||
| if (::getline (&line, &line_len, cmdline_file) == -1) { | ||
| ::fclose (cmdline_file); | ||
| return ""; | ||
| } | ||
|
|
||
| ::fclose (cmdline_file); | ||
| return reinterpret_cast<const ep_char8_t*>(line); | ||
| #else | ||
| return ""; | ||
| #endif | ||
|
|
@@ -388,10 +457,10 @@ ep_rt_aot_file_close (ep_rt_file_handle_t file_handle) | |
|
|
||
| bool | ||
| ep_rt_aot_file_write ( | ||
| ep_rt_file_handle_t file_handle, | ||
| const uint8_t *buffer, | ||
| uint32_t bytes_to_write, | ||
| uint32_t *bytes_written) | ||
| ep_rt_file_handle_t file_handle, | ||
| const uint8_t *buffer, | ||
| uint32_t bytes_to_write, | ||
| uint32_t *bytes_written) | ||
| { | ||
| #ifdef TARGET_WINDOWS | ||
| return ::WriteFile (file_handle, buffer, bytes_to_write, reinterpret_cast<LPDWORD>(bytes_written), NULL) != FALSE; | ||
|
|
@@ -722,12 +791,12 @@ void ep_rt_aot_lock_requires_lock_not_held (const ep_rt_lock_handle_t *lock) | |
| void ep_rt_aot_spin_lock_requires_lock_held (const ep_rt_spin_lock_handle_t *spin_lock) | ||
| { | ||
| EP_ASSERT (ep_rt_spin_lock_is_valid (spin_lock)); | ||
| EP_ASSERT (spin_lock->lock->OwnedByCurrentThread ()); | ||
| EP_ASSERT (spin_lock->lock->OwnedByCurrentThread ()); | ||
| } | ||
|
|
||
| void ep_rt_aot_spin_lock_requires_lock_not_held (const ep_rt_spin_lock_handle_t *spin_lock) | ||
| { | ||
| EP_ASSERT (spin_lock->lock == NULL || !spin_lock->lock->OwnedByCurrentThread ()); | ||
| EP_ASSERT (spin_lock->lock == NULL || !spin_lock->lock->OwnedByCurrentThread ()); | ||
| } | ||
|
|
||
| #endif /* EP_CHECKED_BUILD */ | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.