Browse Source

Fixed tests when using -fsanitize=thread

merge-requests/398/head
eidheim 7 years ago
parent
commit
16d9aa5525
  1. 24
      src/debug_lldb.cc
  2. 11
      src/debug_lldb.h
  3. 4
      src/project.cc
  4. 2
      src/project.h
  5. 5
      src/window.cc
  6. 2
      tests/lldb_test.cc

24
src/debug_lldb.cc

@ -12,6 +12,8 @@
extern char **environ;
bool Debug::LLDB::initialized = false;
void log(const char *msg, void *) {
std::cout << "debugger log: " << msg << std::endl;
}
@ -31,6 +33,21 @@ Debug::LLDB::LLDB() : state(lldb::StateType::eStateInvalid), buffer_size(131072)
}
}
void Debug::LLDB::destroy_() {
{
LockGuard lock(mutex);
if(process)
process->Kill();
}
if(debug_thread.joinable())
debug_thread.join();
LockGuard lock(mutex);
if(debugger)
lldb::SBDebugger::Destroy(*debugger);
}
std::tuple<std::vector<std::string>, std::string, std::vector<std::string>> Debug::LLDB::parse_run_arguments(const std::string &command) {
std::vector<std::string> environment;
std::string executable;
@ -89,6 +106,7 @@ void Debug::LLDB::start(const std::string &command, const boost::filesystem::pat
LockGuard lock(mutex);
if(!debugger) {
initialized = true;
lldb::SBDebugger::Initialize();
debugger = std::make_unique<lldb::SBDebugger>(lldb::SBDebugger::Create(true, log, nullptr));
listener = std::make_unique<lldb::SBListener>("juCi++ lldb listener");
@ -411,12 +429,6 @@ void Debug::LLDB::select_frame(uint32_t frame_index, uint32_t thread_index_id) {
}
}
void Debug::LLDB::cancel() {
kill();
if(debug_thread.joinable())
debug_thread.join();
}
std::string Debug::LLDB::get_value(const std::string &variable, const boost::filesystem::path &file_path, unsigned int line_nr, unsigned int line_index) {
LockGuard lock(mutex);
if(state == lldb::StateType::eStateStopped) {

11
src/debug_lldb.h

@ -32,6 +32,9 @@ namespace Debug {
private:
LLDB();
void destroy_();
static bool initialized;
public:
static LLDB &get() {
@ -39,6 +42,12 @@ namespace Debug {
return singleton;
}
/// Must be called before application terminates (cannot be placed in destructor sadly)
static void destroy() {
if(initialized)
get().destroy_();
}
std::list<std::function<void(const lldb::SBProcess &)>> on_start;
/// The handlers are not run in the main loop.
std::list<std::function<void(int exit_status)>> on_exit;
@ -61,8 +70,6 @@ namespace Debug {
std::vector<Variable> get_variables();
void select_frame(uint32_t frame_index, uint32_t thread_index_id = 0);
void cancel();
/// Get value using variable name and location
std::string get_value(const std::string &variable_name, const boost::filesystem::path &file_path, unsigned int line_nr, unsigned int line_index);
/// Get value from expression

4
src/project.cc

@ -663,10 +663,6 @@ bool Project::LLDB::debug_is_running() {
void Project::LLDB::debug_write(const std::string &buffer) {
Debug::LLDB::get().write(buffer);
}
void Project::LLDB::debug_cancel() {
Debug::LLDB::get().cancel();
}
#endif
void Project::LanguageProtocol::show_symbols() {

2
src/project.h

@ -74,7 +74,6 @@ namespace Project {
virtual void debug_remove_breakpoint(const boost::filesystem::path &file_path, int line_nr, int line_count) {}
virtual bool debug_is_running() { return false; }
virtual void debug_write(const std::string &buffer) {}
virtual void debug_cancel() {}
};
class LLDB : public virtual Base {
@ -98,7 +97,6 @@ namespace Project {
void debug_remove_breakpoint(const boost::filesystem::path &file_path, int line_nr, int line_count) override;
bool debug_is_running() override;
void debug_write(const std::string &buffer) override;
void debug_cancel() override;
#endif
};

5
src/window.cc

@ -1,5 +1,6 @@
#include "window.h"
#include "config.h"
#include "debug_lldb.h"
#include "dialogs.h"
#include "directories.h"
#include "entrybox.h"
@ -1443,9 +1444,9 @@ bool Window::on_delete_event(GdkEventAny *event) {
return true;
}
Terminal::get().kill_async_processes();
#ifdef JUCI_ENABLE_DEBUG
if(Project::current)
Project::current->debug_cancel();
Debug::LLDB::destroy();
#endif
return false;

2
tests/lldb_test.cc

@ -136,5 +136,5 @@ int main() {
std::this_thread::sleep_for(std::chrono::milliseconds(10));
}
Debug::LLDB::get().cancel();
Debug::LLDB::destroy();
}

Loading…
Cancel
Save