From: Oleg Lekarev Date: Thu, 13 Aug 2020 15:59:49 +0000 (+0300) Subject: Minor modifications for Windows compatibility X-Git-Tag: submit/tizen/20200915.041748~3 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=1c94a59db8fa526d317f3dfe7aac6b56d9d4a23e;p=sdk%2Ftools%2Fnetcoredbg.git Minor modifications for Windows compatibility --- diff --git a/src/debug/netcoredbg/CMakeLists.txt b/src/debug/netcoredbg/CMakeLists.txt index 8bcd292..5b21494 100644 --- a/src/debug/netcoredbg/CMakeLists.txt +++ b/src/debug/netcoredbg/CMakeLists.txt @@ -31,6 +31,7 @@ include_directories(${CORECLR_DIR}/src/coreclr/hosts/inc) # Build native part of the debugger include_directories(${PROJECT_SOURCE_DIR}/third_party) +include_directories(${PROJECT_SOURCE_DIR}/third_party/linenoise-ng/include) set(netcoredbg_SRC main.cpp @@ -66,7 +67,7 @@ endif() add_executable(netcoredbg ${netcoredbg_SRC}) if (WIN32) - target_link_libraries(netcoredbg corguids wsock32 ws2_32) + target_link_libraries(netcoredbg corguids wsock32 ws2_32 linenoise) else() target_link_libraries(netcoredbg corguids dl pthread linenoise) endif() diff --git a/src/debug/netcoredbg/cliprotocol.cpp b/src/debug/netcoredbg/cliprotocol.cpp index 1d207ec..bd012bb 100644 --- a/src/debug/netcoredbg/cliprotocol.cpp +++ b/src/debug/netcoredbg/cliprotocol.cpp @@ -14,8 +14,6 @@ #include #include #include -#include -#include #include "logger.h" #include "tokenizer.h" @@ -294,8 +292,9 @@ void CLIProtocol::EmitStoppedEvent(StoppedEvent event) default: return; } - +#ifndef WIN32 pthread_kill(tid, SIGWINCH); +#endif } void CLIProtocol::EmitExitedEvent(ExitedEvent event) @@ -303,7 +302,9 @@ void CLIProtocol::EmitExitedEvent(ExitedEvent event) LogFuncEntry(); printf("\nstopped, reason: exited, exit-code: %i\n", event.exitCode); +#ifndef WIN32 pthread_kill(tid, SIGWINCH); +#endif } void CLIProtocol::EmitContinuedEvent(int threadId) @@ -578,9 +579,9 @@ void CLIProtocol::CommandLoop() { std::string token; std::string input; - +#ifndef WIN32 tid = pthread_self(); - +#endif linenoiseInstallWindowChangeHandler(); linenoiseHistoryLoad(history.c_str()); @@ -600,7 +601,9 @@ void CLIProtocol::CommandLoop() std::string command; if (!ParseLine(input, token, command, args)) { - printf("%s \x1b[1;31mFailed to parse input\n\x1b[0m", token.c_str()); + printf("%s", redOn.c_str()); + printf("%s Failed to parse input\n", token.c_str()); + printf("%s", colorOff.c_str()); continue; } @@ -626,11 +629,15 @@ void CLIProtocol::CommandLoop() { if (output.empty()) { - printf("%s \x1b[1;31mError: 0x%08x\n\x1b[0m", token.c_str(), hr); + printf("%s", redOn.c_str()); + printf("%s Error: 0x%08x\n", token.c_str(), hr); + printf("%s", colorOff.c_str()); } else { - printf("%s \x1b[1;31m%s\n\x1b[0m", token.c_str(), output.c_str()); + printf("%s", redOn.c_str()); + printf("%s %s\n", token.c_str(), output.c_str()); + printf("%s", colorOff.c_str()); } } linenoiseHistoryAdd(cmdline.get()); diff --git a/src/debug/netcoredbg/cliprotocol.h b/src/debug/netcoredbg/cliprotocol.h index 72a5abd..94a0ed0 100644 --- a/src/debug/netcoredbg/cliprotocol.h +++ b/src/debug/netcoredbg/cliprotocol.h @@ -24,13 +24,21 @@ class CLIProtocol : public IProtocol std::unordered_map m_funcBreakpoints; std::string prompt; std::string history; + std::string redOn; + std::string colorOff; +#ifndef WIN32 pthread_t tid; - +#endif static HRESULT PrintBreakpoint(const Breakpoint &b, std::string &output); public: - CLIProtocol() : IProtocol(), m_varCounter(0), prompt("\x1b[1;32mcli\x1b[0m> "), history(".history") {} + CLIProtocol() : IProtocol(), m_varCounter(0), prompt("\x1b[1;32mcli\x1b[0m> "), history(".history"), +#ifndef WIN32 + redOn("\033[1;31m"), colorOff("\033[0m") {} +#else + redOn(""), colorOff("") {} +#endif void EmitInitializedEvent() override {} void EmitStoppedEvent(StoppedEvent event) override; void EmitExitedEvent(ExitedEvent event) override; diff --git a/src/debug/netcoredbg/main.cpp b/src/debug/netcoredbg/main.cpp index 0b12da2..c288262 100644 --- a/src/debug/netcoredbg/main.cpp +++ b/src/debug/netcoredbg/main.cpp @@ -8,8 +8,6 @@ #include #include -#include - #include "manageddebugger.h" #include "miprotocol.h" #include "vscodeprotocol.h"