-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
225 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
{ | ||
"dap": [ | ||
{ | ||
"name": "gdb", | ||
"url": "https://www.gnu.org/software/gdb", | ||
"run": { | ||
"command": "gdb --interpreter=dap" | ||
}, | ||
"configurations": [ | ||
{ | ||
"name": "launch binary", | ||
"command": "launch", | ||
"arguments": { | ||
"program": "${file}", | ||
"args": "${args}", | ||
"cwd": "${cwd}", | ||
"env": "${env}", | ||
"stopOnEntry": "${stopOnEntry}" | ||
} | ||
} | ||
] | ||
}, | ||
{ | ||
"name": "lldb-dab", | ||
"url": "https://github.com/llvm/llvm-project/blob/main/lldb/tools/lldb-dap/README.md", | ||
"run": { | ||
"command": "lldb-dap" | ||
}, | ||
"configurations": [ | ||
{ | ||
"name": "launch binary", | ||
"command": "launch", | ||
"arguments": { | ||
"program": "${file}", | ||
"args": "${args}", | ||
"cwd": "${cwd}", | ||
"env": "${env}", | ||
"stopOnEntry": "${stopOnEntry}" | ||
} | ||
} | ||
] | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,132 @@ | ||
#include "debuggerplugin.hpp" | ||
#include <eepp/system/filesystem.hpp> | ||
#include <eepp/system/scopedop.hpp> | ||
#include <nlohmann/json.hpp> | ||
|
||
using namespace EE::UI; | ||
using namespace EE::UI::Doc; | ||
|
||
using namespace std::literals; | ||
|
||
using json = nlohmann::json; | ||
|
||
#if EE_PLATFORM != EE_PLATFORM_EMSCRIPTEN || defined( __EMSCRIPTEN_PTHREADS__ ) | ||
#define DEBUGGER_THREADED 1 | ||
#else | ||
#define DEBUGGER_THREADED 0 | ||
#endif | ||
|
||
namespace ecode { | ||
|
||
Plugin* DebuggerPlugin::New( PluginManager* pluginManager ) { | ||
return eeNew( DebuggerPlugin, ( pluginManager, false ) ); | ||
} | ||
|
||
Plugin* DebuggerPlugin::NewSync( PluginManager* pluginManager ) { | ||
return eeNew( DebuggerPlugin, ( pluginManager, true ) ); | ||
} | ||
|
||
DebuggerPlugin::DebuggerPlugin( PluginManager* pluginManager, bool sync ) : | ||
PluginBase( pluginManager ) { | ||
if ( sync ) { | ||
load( pluginManager ); | ||
} else { | ||
#if defined( DEBUGGER_THREADED ) && DEBUGGER_THREADED == 1 | ||
mThreadPool->run( [this, pluginManager] { load( pluginManager ); } ); | ||
#else | ||
load( pluginManager ); | ||
#endif | ||
} | ||
} | ||
|
||
DebuggerPlugin::~DebuggerPlugin() { | ||
waitUntilLoaded(); | ||
mShuttingDown = true; | ||
} | ||
|
||
void DebuggerPlugin::load( PluginManager* pluginManager ) { | ||
Clock clock; | ||
AtomicBoolScopedOp loading( mLoading, true ); | ||
pluginManager->subscribeMessages( this, | ||
[this]( const auto& notification ) -> PluginRequestHandle { | ||
return processMessage( notification ); | ||
} ); | ||
|
||
std::string path = pluginManager->getPluginsPath() + "debugger.json"; | ||
if ( FileSystem::fileExists( path ) || | ||
FileSystem::fileWrite( path, "{\n \"config\":{},\n \"keybindings\":{}\n}\n" ) ) { | ||
mConfigPath = path; | ||
} | ||
std::string data; | ||
if ( !FileSystem::fileGet( path, data ) ) | ||
return; | ||
mConfigHash = String::hash( data ); | ||
|
||
json j; | ||
try { | ||
j = json::parse( data, nullptr, true, true ); | ||
} catch ( const json::exception& e ) { | ||
Log::error( "DebuggerPlugin::load - Error parsing config from path %s, error: %s, config " | ||
"file content:\n%s", | ||
path.c_str(), e.what(), data.c_str() ); | ||
// Recreate it | ||
j = json::parse( "{\n \"config\":{},\n \"keybindings\":{},\n}\n", nullptr, true, true ); | ||
} | ||
|
||
bool updateConfigFile = false; | ||
|
||
if ( j.contains( "config" ) ) { | ||
} | ||
|
||
if ( mKeyBindings.empty() ) { | ||
} | ||
|
||
if ( j.contains( "keybindings" ) ) { | ||
auto& kb = j["keybindings"]; | ||
std::initializer_list<std::string> list = {}; | ||
for ( const auto& key : list ) { | ||
if ( kb.contains( key ) ) { | ||
if ( !kb[key].empty() ) | ||
mKeyBindings[key] = kb[key]; | ||
} else { | ||
kb[key] = mKeyBindings[key]; | ||
updateConfigFile = true; | ||
} | ||
} | ||
} | ||
|
||
if ( updateConfigFile ) { | ||
std::string newData = j.dump( 2 ); | ||
if ( newData != data ) { | ||
FileSystem::fileWrite( path, newData ); | ||
mConfigHash = String::hash( newData ); | ||
} | ||
} | ||
|
||
if ( getUISceneNode() ) { | ||
// Init UI | ||
} | ||
|
||
subscribeFileSystemListener(); | ||
mReady = true; | ||
fireReadyCbs(); | ||
setReady( clock.getElapsedTime() ); | ||
} | ||
|
||
PluginRequestHandle DebuggerPlugin::processMessage( const PluginMessage& msg ) { | ||
switch ( msg.type ) { | ||
case PluginMessageType::WorkspaceFolderChanged: { | ||
|
||
break; | ||
} | ||
case ecode::PluginMessageType::UIReady: { | ||
// Init UI if not initialized | ||
break; | ||
} | ||
default: | ||
break; | ||
} | ||
return PluginRequestHandle::empty(); | ||
} | ||
|
||
} // namespace ecode |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
#pragma once | ||
|
||
#include "../plugin.hpp" | ||
#include "../pluginmanager.hpp" | ||
|
||
using namespace EE::UI::Models; | ||
using namespace EE::UI; | ||
|
||
namespace ecode { | ||
|
||
class DebuggerPlugin : public PluginBase { | ||
public: | ||
static PluginDefinition Definition() { | ||
return { "debugger", "Debugger", "Debugger integration", | ||
DebuggerPlugin::New, { 0, 0, 1 }, DebuggerPlugin::NewSync }; | ||
} | ||
|
||
static Plugin* New( PluginManager* pluginManager ); | ||
|
||
static Plugin* NewSync( PluginManager* pluginManager ); | ||
|
||
virtual ~DebuggerPlugin(); | ||
|
||
std::string getId() override { return Definition().id; } | ||
|
||
std::string getTitle() override { return Definition().name; } | ||
|
||
std::string getDescription() override { return Definition().description; } | ||
|
||
protected: | ||
DebuggerPlugin( PluginManager* pluginManager, bool sync ); | ||
|
||
void load( PluginManager* pluginManager ); | ||
|
||
PluginRequestHandle processMessage( const PluginMessage& msg ); | ||
|
||
}; | ||
|
||
} // namespace ecode |