Fake vsdbg commands
authorIgor Kulaychuk <i.kulaychuk@samsung.com>
Mon, 17 Jul 2017 01:25:44 +0000 (04:25 +0300)
committerIgor Kulaychuk <i.kulaychuk@samsung.com>
Mon, 13 Nov 2017 19:22:40 +0000 (22:22 +0300)
src/debug/netcoredbg/breakpoints.cpp
src/debug/netcoredbg/commands.cpp
src/debug/netcoredbg/main.cpp

index b3ab5e3..d2ee7fc 100644 (file)
@@ -126,6 +126,12 @@ static ULONG32 InsertBreakpoint(Breakpoint &bp)
     return id;
 }
 
+ULONG32 InsertExceptionBreakpoint(const std::string &name)
+{
+    Breakpoint bp;
+    return InsertBreakpoint(bp);
+}
+
 HRESULT DeleteBreakpoint(ULONG32 id)
 {
     std::lock_guard<std::mutex> lock(g_breakMutex);
index 0aa1ff1..606a7bd 100644 (file)
@@ -25,6 +25,7 @@ HRESULT GetStepRangeFromCurrentIP(ICorDebugThread *pThread, COR_DEBUG_STEP_RANGE
 HRESULT DeleteBreakpoint(ULONG32 id);
 HRESULT InsertBreakpointInProcess(ICorDebugProcess *pProcess, std::string filename, int linenum, ULONG32 &id);
 HRESULT PrintBreakpoint(ULONG32 id, std::string &output);
+ULONG32 InsertExceptionBreakpoint(const std::string &name);
 
 // Frames
 HRESULT GetFrameAt(ICorDebugThread *pThread, int level, ICorDebugFrame **ppFrame);
@@ -368,7 +369,38 @@ HRESULT Debugger::HandleCommand(std::string command,
         this->TerminateProcess();
 
         return S_OK;
-    }}
+    }},
+    { "handshake", [](ICorDebugProcess *, const std::vector<std::string> &args, std::string &output) -> HRESULT {
+        if (!args.empty() && args.at(0) == "init")
+            output = "request=\"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=\"";
+
+        return S_OK;
+    }},
+    { "gdb-set", [this](ICorDebugProcess *, const std::vector<std::string> &args, std::string &output) -> HRESULT {
+        return S_OK;
+    }},
+    { "break-exception-insert", [](ICorDebugProcess *, const std::vector<std::string> &args, std::string &output) -> HRESULT {
+        if (args.empty())
+            return E_FAIL;
+        size_t i = 1;
+        if (args.at(0) == "--mda")
+            i = 2;
+
+        std::stringstream ss;
+        const char *sep = "";
+        ss << "bkpt=[";
+        for (; i < args.size(); i++)
+        {
+            ULONG32 id = InsertExceptionBreakpoint(args.at(i));
+            ss << sep;
+            sep = ",";
+            ss << "{number=\"" << id << "\"}";
+        }
+        ss << "]";
+        output = ss.str();
+
+        return S_OK;
+    }},
     };
 
     auto command_it = commands.find(command);
index 83d4e75..1a1ad0a 100644 (file)
@@ -444,7 +444,9 @@ public:
             TryLoadModuleSymbols(pModule, id, name, symbolsLoaded, baseAddress, size);
             {
                 std::stringstream ss;
-                ss << "id=\"{" << id << "}\",target-name=\"" << name << "\","
+                ss << "id=\"{" << id << "}\","
+                   << "target-name=\"" << name << "\","
+                   << "host-name=\"" << name << "\","
                    << "symbols-loaded=\"" << symbolsLoaded << "\","
                    << "base-address=\"0x" << std::hex << baseAddress << "\","
                    << "size=\"" << std::dec << size << "\"";