| 1 | // Licensed to the .NET Foundation under one or more agreements. |
|---|---|
| 2 | // The .NET Foundation licenses this file to you under the MIT license. |
| 3 | // See the LICENSE file in the project root for more information. |
| 4 | |
| 5 | #include "sosplugin.h" |
| 6 | #include <dlfcn.h> |
| 7 | #include <string.h> |
| 8 | #include <string> |
| 9 | #include <stdlib.h> |
| 10 | #include <limits.h> |
| 11 | |
| 12 | class setclrpathCommand : public lldb::SBCommandPluginInterface |
| 13 | { |
| 14 | public: |
| 15 | setclrpathCommand() |
| 16 | { |
| 17 | } |
| 18 | |
| 19 | virtual bool |
| 20 | DoExecute (lldb::SBDebugger debugger, |
| 21 | char** arguments, |
| 22 | lldb::SBCommandReturnObject &result) |
| 23 | { |
| 24 | if (arguments[0] == NULL) |
| 25 | { |
| 26 | result.Printf("Load path for sos/dac/dbi: '%s'\n", g_coreclrDirectory == NULL ? "<none>": g_coreclrDirectory); |
| 27 | } |
| 28 | else { |
| 29 | if (g_coreclrDirectory != NULL) |
| 30 | { |
| 31 | free(g_coreclrDirectory); |
| 32 | } |
| 33 | |
| 34 | std::string path(arguments[0]); |
| 35 | if (path[path.length() - 1] != '/') |
| 36 | { |
| 37 | path.append("/"); |
| 38 | } |
| 39 | |
| 40 | g_coreclrDirectory = strdup(path.c_str()); |
| 41 | result.Printf("Set load path for sos/dac/dbi to '%s'\n", g_coreclrDirectory); |
| 42 | } |
| 43 | return result.Succeeded(); |
| 44 | } |
| 45 | }; |
| 46 | |
| 47 | bool |
| 48 | setclrpathCommandInitialize(lldb::SBDebugger debugger) |
| 49 | { |
| 50 | lldb::SBCommandInterpreter interpreter = debugger.GetCommandInterpreter(); |
| 51 | lldb::SBCommand command = interpreter.AddCommand("setclrpath", new setclrpathCommand(), "Set the path to load coreclr sos/dac/dbi files. setclrpath <path>"); |
| 52 | return true; |
| 53 | } |
| 54 |