-
Notifications
You must be signed in to change notification settings - Fork 309
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds the capability to generate core dumps when specified exceptions …
…occur in a .NET process. (#151)
- Loading branch information
1 parent
91adef0
commit af3cdda
Showing
89 changed files
with
57,447 additions
and
2,127 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -35,3 +35,4 @@ | |
bin/ | ||
release/ | ||
pkgbuild/ | ||
obj/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License | ||
|
||
//-------------------------------------------------------------------- | ||
// | ||
// .NET helpers | ||
// | ||
//-------------------------------------------------------------------- | ||
|
||
#ifndef DOTNETHELPERS_H | ||
#define DOTNETHELPERS_H | ||
|
||
#include <stdio.h> | ||
#include <sys/types.h> | ||
#include <unistd.h> | ||
|
||
bool IsCoreClrProcess(pid_t pid, char** socketName); | ||
bool GenerateCoreClrDump(char* socketName, char* dumpFileName); | ||
|
||
#endif // DOTNETHELPERS_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License | ||
|
||
//-------------------------------------------------------------------- | ||
// | ||
// General purpose helpers | ||
// | ||
//-------------------------------------------------------------------- | ||
|
||
#ifndef GENHELPERS_H | ||
#define GENHELPERS_H | ||
|
||
#include <linux/version.h> | ||
#include <unistd.h> | ||
#include <string.h> | ||
#include <stdbool.h> | ||
#include <stdlib.h> | ||
#include <ctype.h> | ||
#include <stdio.h> | ||
#include <sys/utsname.h> | ||
#include <errno.h> | ||
#include <stdio.h> | ||
#include <sys/types.h> | ||
#include <dirent.h> | ||
|
||
#define MIN_KERNEL_VERSION 3 | ||
#define MIN_KERNEL_PATCH 5 | ||
|
||
//------------------------------------------------------------------------------------- | ||
// Auto clean up of memory using free (void) | ||
//------------------------------------------------------------------------------------- | ||
static inline void cleanup_void(void* val) | ||
{ | ||
void **ppVal = (void**)val; | ||
free(*ppVal); | ||
} | ||
|
||
//------------------------------------------------------------------------------------- | ||
// Auto clean up of file descriptors using close | ||
//------------------------------------------------------------------------------------- | ||
static inline void cleanup_fd(int* val) | ||
{ | ||
if (*val) | ||
{ | ||
close(*val); | ||
} | ||
} | ||
|
||
//------------------------------------------------------------------------------------- | ||
// Auto clean up of dir using closedir | ||
//------------------------------------------------------------------------------------- | ||
static inline void cleanup_dir(DIR** val) | ||
{ | ||
if(*val) | ||
{ | ||
closedir(*val); | ||
} | ||
} | ||
|
||
//------------------------------------------------------------------------------------- | ||
// Auto clean up of FILE using fclose | ||
//------------------------------------------------------------------------------------- | ||
static inline void cleanup_file(FILE** val) | ||
{ | ||
if(*val) | ||
{ | ||
fclose(*val); | ||
} | ||
} | ||
|
||
//------------------------------------------------------------------------------------- | ||
// Auto cancel pthread | ||
//------------------------------------------------------------------------------------- | ||
static inline void cancel_pthread(unsigned long* val) | ||
{ | ||
if(*val!=-1) | ||
{ | ||
pthread_cancel(*val); | ||
} | ||
} | ||
|
||
#define auto_free __attribute__ ((__cleanup__(cleanup_void))) | ||
#define auto_free_fd __attribute__ ((__cleanup__(cleanup_fd))) | ||
#define auto_free_dir __attribute__ ((__cleanup__(cleanup_dir))) | ||
#define auto_free_file __attribute__ ((__cleanup__(cleanup_file))) | ||
#define auto_cancel_thread __attribute__ ((__cleanup__(cancel_pthread))) | ||
|
||
bool ConvertToInt(const char* src, int* conv); | ||
bool IsValidNumberArg(const char *arg); | ||
bool CheckKernelVersion(); | ||
uint16_t* GetUint16(char* buffer); | ||
char* GetPath(char* lineBuf); | ||
FILE *popen2(const char *command, const char *type, pid_t *pid); | ||
char *sanitize(char *processName); | ||
int StringToGuid(char* szGuid, struct CLSID* pGuid); | ||
int GetHex(char* szStr, int size, void* pResult); | ||
bool createDir(const char *dir, mode_t perms); | ||
char* GetSocketPath(char* prefix, pid_t pid, pid_t targetPid); | ||
int send_all(int socket, void *buffer, size_t length); | ||
int recv_all(int socket, void* buffer, size_t length); | ||
|
||
#endif // GENHELPERS_H | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#include "CoreDumpWriter.h" | ||
#include "Events.h" | ||
#include "GenHelpers.h" | ||
#include "Handle.h" | ||
#include "Logging.h" | ||
#include "Monitor.h" | ||
#include "Procdump.h" | ||
#include "ProcDumpConfiguration.h" | ||
#include "Process.h" | ||
#include "DotnetHelpers.h" | ||
#include "ProfilerHelpers.h" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License | ||
|
||
//-------------------------------------------------------------------- | ||
// | ||
// Monitor functions | ||
// | ||
//-------------------------------------------------------------------- | ||
|
||
#ifndef MONITOR_H | ||
#define MONITOR_H | ||
|
||
#include <signal.h> | ||
#include <sys/ptrace.h> | ||
#include <stdlib.h> | ||
|
||
#include "ProcDumpConfiguration.h" | ||
|
||
#define MAX_PROFILER_CONNECTIONS 50 | ||
|
||
// Monitor functions | ||
void MonitorProcesses(struct ProcDumpConfiguration*self); | ||
int CreateMonitorThreads(struct ProcDumpConfiguration *self); | ||
int StartMonitor(struct ProcDumpConfiguration* monitorConfig); | ||
int WaitForQuit(struct ProcDumpConfiguration *self, int milliseconds); | ||
int WaitForQuitOrEvent(struct ProcDumpConfiguration *self, struct Handle *handle, int milliseconds); | ||
int WaitForAllMonitorsToTerminate(struct ProcDumpConfiguration *self); | ||
int WaitForSignalThreadToTerminate(struct ProcDumpConfiguration *self); | ||
bool IsQuit(struct ProcDumpConfiguration *self); | ||
int SetQuit(struct ProcDumpConfiguration *self, int quit); | ||
bool ContinueMonitoring(struct ProcDumpConfiguration *self); | ||
bool BeginMonitoring(struct ProcDumpConfiguration *self); | ||
|
||
// Monitor worker threads | ||
void *CommitMonitoringThread(void *thread_args /* struct ProcDumpConfiguration* */); | ||
void *CpuMonitoringThread(void *thread_args /* struct ProcDumpConfiguration* */); | ||
void *ThreadCountMonitoringThread(void *thread_args /* struct ProcDumpConfiguration* */); | ||
void *FileDescriptorCountMonitoringThread(void *thread_args /* struct ProcDumpConfiguration* */); | ||
void *SignalMonitoringThread(void *thread_args /* struct ProcDumpConfiguration* */); | ||
void *TimerThread(void *thread_args /* struct ProcDumpConfiguration* */); | ||
void *ExceptionMonitoringThread(void *thread_args /* struct ProcDumpConfiguration* */); | ||
void *ProcessMonitor(void *thread_args /* struct ProcDumpConfiguration* */); | ||
void *WaitForProfilerCompletion(void *thread_args /* struct ProcDumpConfiguration* */); | ||
|
||
#endif // MONITOR_H |
Oops, something went wrong.