# 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
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()
#include <iostream>
#include <iomanip>
#include <csignal>
-#include <unistd.h>
-#include <sys/syscall.h>
#include "logger.h"
#include "tokenizer.h"
default:
return;
}
-
+#ifndef WIN32
pthread_kill(tid, SIGWINCH);
+#endif
}
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)
{
std::string token;
std::string input;
-
+#ifndef WIN32
tid = pthread_self();
-
+#endif
linenoiseInstallWindowChangeHandler();
linenoiseHistoryLoad(history.c_str());
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;
}
{
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());
std::unordered_map<uint32_t, FunctionBreakpoint> 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;