diff options
author | Jiyoung Yun <jy910.yun@samsung.com> | 2017-04-27 16:54:50 +0900 |
---|---|---|
committer | Jiyoung Yun <jy910.yun@samsung.com> | 2017-04-27 16:54:50 +0900 |
commit | 5b975f8233e8c8d17b215372f89ca713b45d6a0b (patch) | |
tree | 0267bcc331458a01f4c26fafd28110a72273beb3 /src/ToolBox/SOS/Strike/strike.cpp | |
parent | a56e30c8d33048216567753d9d3fefc2152af8ac (diff) | |
download | coreclr-5b975f8233e8c8d17b215372f89ca713b45d6a0b.tar.gz coreclr-5b975f8233e8c8d17b215372f89ca713b45d6a0b.tar.bz2 coreclr-5b975f8233e8c8d17b215372f89ca713b45d6a0b.zip |
Imported Upstream version 2.0.0.11599upstream/2.0.0.11599
Diffstat (limited to 'src/ToolBox/SOS/Strike/strike.cpp')
-rw-r--r-- | src/ToolBox/SOS/Strike/strike.cpp | 74 |
1 files changed, 74 insertions, 0 deletions
diff --git a/src/ToolBox/SOS/Strike/strike.cpp b/src/ToolBox/SOS/Strike/strike.cpp index 2b54b4f037..0d5d8c3b8b 100644 --- a/src/ToolBox/SOS/Strike/strike.cpp +++ b/src/ToolBox/SOS/Strike/strike.cpp @@ -14368,6 +14368,80 @@ _EFN_GetManagedObjectFieldInfo( return S_OK; } +#ifdef FEATURE_PAL + +#ifdef __linux__ +#include <dumpcommon.h> +#include "datatarget.h" +extern bool CreateDumpForSOS(const char* programPath, const char* dumpPathTemplate, pid_t pid, MINIDUMP_TYPE minidumpType, ICLRDataTarget* dataTarget); +extern bool g_diagnostics; +#endif // __linux__ + +DECLARE_API(CreateDump) +{ + INIT_API(); +#ifdef __linux__ + StringHolder sFileName; + BOOL normal = FALSE; + BOOL withHeap = FALSE; + BOOL triage = FALSE; + BOOL diag = FALSE; + + size_t nArg = 0; + CMDOption option[] = + { // name, vptr, type, hasValue + {"-n", &normal, COBOOL, FALSE}, + {"-h", &withHeap, COBOOL, FALSE}, + {"-t", &triage, COBOOL, FALSE}, + {"-d", &diag, COBOOL, FALSE}, + }; + CMDValue arg[] = + { // vptr, type + {&sFileName.data, COSTRING} + }; + if (!GetCMDOption(args, option, _countof(option), arg, _countof(arg), &nArg)) + { + return E_FAIL; + } + MINIDUMP_TYPE minidumpType = MiniDumpWithPrivateReadWriteMemory; + ULONG pid = 0; + g_ExtSystem->GetCurrentProcessId(&pid); + + if (withHeap) + { + minidumpType = MiniDumpWithPrivateReadWriteMemory; + } + else if (triage) + { + minidumpType = MiniDumpFilterTriage; + } + else if (normal) + { + minidumpType = MiniDumpNormal; + } + g_diagnostics = diag; + + const char* programPath = g_ExtServices->GetCoreClrDirectory(); + const char* dumpPathTemplate = "/tmp/coredump.%d"; + ToRelease<ICLRDataTarget> dataTarget = new DataTarget(); + dataTarget->AddRef(); + + if (sFileName.data != nullptr) + { + dumpPathTemplate = sFileName.data; + } + if (!CreateDumpForSOS(programPath, dumpPathTemplate, pid, minidumpType, dataTarget)) + { + Status = E_FAIL; + } +#else // __linux__ + ExtErr("CreateDump not supported on this platform\n"); +#endif // __linux__ + return Status; +} + +#endif // FEATURE_PAL + void PrintHelp (__in_z LPCSTR pszCmdName) { static LPSTR pText = NULL; |