DEFAULT_OPT --
DEFAULT_OPT /home/owner/share/tmp/sdk_tools/netcoredbg/netcoredbg
EXTRA_KEY __DLP_DEBUG_ARG__
+
+[DEBUGGER]
+NAME MEMORYPROFILER
+EXE /home/owner/share/tmp/sdk_tools/profctl/profctl
+APP_TYPE dotnet|dotnet-nui
+DEFAULT_OPT -v
+DEFAULT_OPT -p
+DEFAULT_OPT /home/owner/share/tmp/sdk_tools/mixed-heaptrack/heaptrack_fifo
+DEFAULT_OPT -w
+DEFAULT_OPT -e
+DEFAULT_OPT /home/owner/share/tmp/sdk_tools/mixed-heaptrack/heaptrack_interpret
+DEFAULT_OPT -o
+DEFAULT_OPT /home/owner/share/tmp/sdk_tools/profctl/profctl_heaptrack.log
+DEFAULT_OPT -E
+DEFAULT_OPT DUMP_HEAPTRACK_OUTPUT=/home/owner/share/tmp/sdk_tools/mixed-heaptrack/heaptrack_fifo
+DEFAULT_OPT CORECLR_PROFILER={C7BAD323-25F0-4C0B-B354-566390B215CA}
+DEFAULT_OPT CORECLR_PROFILER_PATH=/home/owner/share/tmp/sdk_tools/mixed-heaptrack/libprofiler.so
+DEFAULT_OPT PROF_CONFIG_FILENAME=/home/owner/share/tmp/sdk_tools/mixed-heaptrack/profiler.config
+DEFAULT_OPT CORECLR_ENABLE_PROFILING=1
+DEFAULT_OPT COMPlus_LogEnable=1
+DEFAULT_OPT UNW_ARM_UNWIND_METHOD=4
+DEFAULT_OPT HEAPTRACK_NATIVE_ENABLE=1
+DEFAULT_OPT -c
+DEFAULT_OPT 6005
+DEFAULT_OPT -d
+DEFAULT_OPT 6006
+DEFAULT_OPT --
\ No newline at end of file
return -1;
}
- // checkInjection checks dotnet-launcher run mode
+ // checkProfilerInjection checks dotnet-launcher run mode
// At the moment, this mechanism is used only when the Memory Profiler is started.
- int res = checkInjection();
+ int res = checkProfilerInjection();
if (res != 0) {
_ERR("Failed to initnialize Memory Profiler");
return -1;
#include <cstdlib>
#include <cstring>
-
+#include <string>
#include <dlfcn.h>
-#define HT_PATH "/home/owner/share/tmp/sdk_tools/heaptrack/"
-#define HT_LIB_PATH HT_PATH "libprofiler.so"
-#define HT_INJECTION_LIB_PATH HT_PATH "libheaptrack_inject.so"
+#define SDK_TOOLS_PATH "/home/owner/share/tmp/sdk_tools/"
+#define LIB_INJECTION "libheaptrack_inject.so"
-static int injectLibrary(const char path[])
+static int injectHeaptrackLibrary(const char path[])
{
typedef int inject_func();
-
- int res = -1;
void *lib = nullptr;
inject_func *inject = nullptr;
const char *inject_sym = "dotnet_launcher_inject";
lib = dlopen(path, RTLD_NOW | RTLD_GLOBAL);
if (lib == nullptr) {
_ERR("%s", dlerror());
- return res;
+ return -1;
}
inject = reinterpret_cast<inject_func*>(dlsym(lib, inject_sym));
if (inject == nullptr) {
_ERR("%s is not found in the %s", inject_sym, path);
- return res;
+ return -1;
}
- res = inject();
- return res;
+ return inject();
}
-int checkInjection()
+int checkProfilerInjection()
{
char *env = nullptr;
-
env = getenv("CORECLR_PROFILER_PATH");
if (env == nullptr) {
return 0;
}
- // At the moment, this mechanism is used only when the Memory Profiler is started.
- if (strcmp(env, HT_LIB_PATH) != 0) {
- return 0;
+ if (!exist(env)) {
+ return -1;
}
- _INFO("##### Perform injection #########");
+ if (env.find(SDK_TOOLS_PATH) == std::string::npos) {
+ return -1;
+ }
+
+ _INFO("##### Perform profiler injection #########");
+
+ std::string path = concatPath(getBaseName(env), LIB_INJECTION);
+ if (!exist(path)) {
+ return -1;
+ }
- if (injectLibrary(HT_INJECTION_LIB_PATH) != 0) {
- _INFO("##### Injection failed #########");
+ if (injectHeaptrackLibrary(path.c_str()) != 0) {
+ _ERR("##### Heaptrack injection failed #########");
return -1;
}
- _INFO("##### Injection finished #########");
+ _INFO("##### Profiler injection finished #########");
return 0;
}