summaryrefslogtreecommitdiff
path: root/src/ToolBox/SOS/Strike
diff options
context:
space:
mode:
Diffstat (limited to 'src/ToolBox/SOS/Strike')
-rw-r--r--src/ToolBox/SOS/Strike/CMakeLists.txt6
-rw-r--r--src/ToolBox/SOS/Strike/sos_unixexports.src1
-rw-r--r--src/ToolBox/SOS/Strike/sosdocsunix.txt15
-rw-r--r--src/ToolBox/SOS/Strike/strike.cpp74
-rw-r--r--src/ToolBox/SOS/Strike/util.h79
5 files changed, 95 insertions, 80 deletions
diff --git a/src/ToolBox/SOS/Strike/CMakeLists.txt b/src/ToolBox/SOS/Strike/CMakeLists.txt
index 8ba0ade1d8..ff5f86455c 100644
--- a/src/ToolBox/SOS/Strike/CMakeLists.txt
+++ b/src/ToolBox/SOS/Strike/CMakeLists.txt
@@ -145,6 +145,12 @@ else(WIN32)
endif(WIN32)
if(CLR_CMAKE_PLATFORM_ARCH_AMD64)
+ if(CLR_CMAKE_PLATFORM_LINUX)
+ list(APPEND
+ SOS_LIBRARY
+ createdump_lib
+ )
+ endif(CLR_CMAKE_PLATFORM_LINUX)
set(SOS_SOURCES_ARCH
disasmX86.cpp
)
diff --git a/src/ToolBox/SOS/Strike/sos_unixexports.src b/src/ToolBox/SOS/Strike/sos_unixexports.src
index ed811b6572..a8cc71228b 100644
--- a/src/ToolBox/SOS/Strike/sos_unixexports.src
+++ b/src/ToolBox/SOS/Strike/sos_unixexports.src
@@ -4,6 +4,7 @@
bpmd
ClrStack
+CreateDump
DumpArray
DumpAssembly
DumpClass
diff --git a/src/ToolBox/SOS/Strike/sosdocsunix.txt b/src/ToolBox/SOS/Strike/sosdocsunix.txt
index 5ab2b311cc..517227c092 100644
--- a/src/ToolBox/SOS/Strike/sosdocsunix.txt
+++ b/src/ToolBox/SOS/Strike/sosdocsunix.txt
@@ -53,8 +53,8 @@ DumpSigElem
Examining the GC history Other
----------------------------- -----------------------------
HistInit (histinit) FAQ
-HistRoot (histroot) Help (soshelp)
-HistObj (histobj)
+HistRoot (histroot) CreateDump (createdump)
+HistObj (histobj) Help (soshelp)
HistObjFind (histobjfind)
HistClear (histclear)
\\
@@ -618,6 +618,17 @@ should only need to execute "clrstack -i", and from there, click on the DML
hyperlinks to inspect the different managed stack frames and managed variables.
\\
+COMMAND: createdump.
+createdump [options] [dumpFileName]
+-n - create minidump.
+-h - create minidump with heap (default).
+-t - create triage minidump.
+-d - enable diagnostic messages.
+
+Creates a platform (ELF core on Linux, etc.) minidump. The pid can be placed in the dump
+file name with %d. The default is '/tmp/coredump.%d'.
+\\
+
COMMAND: ip2md.
IP2MD <Code address>
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;
diff --git a/src/ToolBox/SOS/Strike/util.h b/src/ToolBox/SOS/Strike/util.h
index 4612acc299..6d0e79622c 100644
--- a/src/ToolBox/SOS/Strike/util.h
+++ b/src/ToolBox/SOS/Strike/util.h
@@ -1429,84 +1429,7 @@ SafeReadMemory (TO_TADDR(src), &(dst), sizeof(dst), NULL)
extern "C" PDEBUG_DATA_SPACES g_ExtData;
-template <class T>
-class ArrayHolder
-{
-public:
- ArrayHolder(T *ptr)
- : mPtr(ptr)
- {
- }
-
- ~ArrayHolder()
- {
- Clear();
- }
-
- ArrayHolder(const ArrayHolder &rhs)
- {
- mPtr = const_cast<ArrayHolder *>(&rhs)->Detach();
- }
-
- ArrayHolder &operator=(T *ptr)
- {
- Clear();
- mPtr = ptr;
- return *this;
- }
-
- const T &operator[](int i) const
- {
- return mPtr[i];
- }
-
- T &operator[](int i)
- {
- return mPtr[i];
- }
-
- operator const T *() const
- {
- return mPtr;
- }
-
- operator T *()
- {
- return mPtr;
- }
-
- T **operator&()
- {
- return &mPtr;
- }
-
- T *GetPtr()
- {
- return mPtr;
- }
-
- T *Detach()
- {
- T *ret = mPtr;
- mPtr = NULL;
- return ret;
- }
-
-private:
- void Clear()
- {
- if (mPtr)
- {
- delete [] mPtr;
- mPtr = NULL;
- }
- }
-
-private:
- T *mPtr;
-};
-
-
+#include <arrayholder.h>
// This class acts a smart pointer which calls the Release method on any object
// you place in it when the ToRelease class falls out of scope. You may use it