plugin storage
This commit is contained in:
parent
794eba983e
commit
3610fc0e59
|
@ -19,6 +19,7 @@
|
||||||
#include "filehelper.h"
|
#include "filehelper.h"
|
||||||
#include "xrefs.h"
|
#include "xrefs.h"
|
||||||
#include "TraceRecord.h"
|
#include "TraceRecord.h"
|
||||||
|
#include "plugin_loader.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
\brief Directory where program databases are stored (usually in \db). UTF-8 encoding.
|
\brief Directory where program databases are stored (usually in \db). UTF-8 encoding.
|
||||||
|
@ -34,7 +35,7 @@ void DbSave(DbLoadSaveType saveType)
|
||||||
{
|
{
|
||||||
EXCLUSIVE_ACQUIRE(LockDatabase);
|
EXCLUSIVE_ACQUIRE(LockDatabase);
|
||||||
|
|
||||||
dprintf("Saving database...");
|
dputs("Saving database...");
|
||||||
DWORD ticks = GetTickCount();
|
DWORD ticks = GetTickCount();
|
||||||
JSON root = json_object();
|
JSON root = json_object();
|
||||||
|
|
||||||
|
@ -63,6 +64,27 @@ void DbSave(DbLoadSaveType saveType)
|
||||||
json_object_set_new(root, "notes", json_string(text));
|
json_object_set_new(root, "notes", json_string(text));
|
||||||
BridgeFree(text);
|
BridgeFree(text);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//plugin data
|
||||||
|
PLUG_CB_LOADSAVEDB pluginSaveDb;
|
||||||
|
// Some plugins may wish to change this value so that all plugins after his or her plugin will save data into plugin-supplied storage instead of the system's.
|
||||||
|
// We back up this value so that the debugger is not fooled by such plugins.
|
||||||
|
JSON pluginRoot = json_object();
|
||||||
|
pluginSaveDb.root = pluginRoot;
|
||||||
|
switch(saveType)
|
||||||
|
{
|
||||||
|
case DbLoadSaveType::DebugData:
|
||||||
|
pluginSaveDb.loadSaveType = PLUG_DB_LOADSAVE_DATA;
|
||||||
|
break;
|
||||||
|
case DbLoadSaveType::All:
|
||||||
|
pluginSaveDb.loadSaveType = PLUG_DB_LOADSAVE_ALL;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
pluginSaveDb.loadSaveType = 0;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
plugincbcall(CBTYPE::CB_SAVEDB, &pluginSaveDb);
|
||||||
|
json_object_set_new(root, "plugins", pluginRoot);
|
||||||
}
|
}
|
||||||
|
|
||||||
auto wdbpath = StringUtils::Utf8ToUtf16(dbpath);
|
auto wdbpath = StringUtils::Utf8ToUtf16(dbpath);
|
||||||
|
@ -166,10 +188,32 @@ void DbLoad(DbLoadSaveType loadType)
|
||||||
TraceRecord.loadFromDb(root);
|
TraceRecord.loadFromDb(root);
|
||||||
BpCacheLoad(root);
|
BpCacheLoad(root);
|
||||||
|
|
||||||
|
|
||||||
// Load notes
|
// Load notes
|
||||||
const char* text = json_string_value(json_object_get(root, "notes"));
|
const char* text = json_string_value(json_object_get(root, "notes"));
|
||||||
GuiSetDebuggeeNotes(text);
|
GuiSetDebuggeeNotes(text);
|
||||||
|
|
||||||
|
// Plugins
|
||||||
|
JSON pluginRoot = json_object_get(root, "plugins");
|
||||||
|
if(pluginRoot)
|
||||||
|
{
|
||||||
|
PLUG_CB_LOADSAVEDB pluginLoadDb;
|
||||||
|
pluginLoadDb.root = pluginRoot;
|
||||||
|
switch(loadType)
|
||||||
|
{
|
||||||
|
case DbLoadSaveType::DebugData:
|
||||||
|
pluginLoadDb.loadSaveType = PLUG_DB_LOADSAVE_DATA;
|
||||||
|
break;
|
||||||
|
case DbLoadSaveType::All:
|
||||||
|
pluginLoadDb.loadSaveType = PLUG_DB_LOADSAVE_ALL;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
pluginLoadDb.loadSaveType = 0;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
//TODO: We have to increment the reference count before every callback invoke.
|
||||||
|
plugincbcall(CB_LOADDB, &pluginLoadDb);
|
||||||
|
json_decref(pluginRoot);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Free root
|
// Free root
|
||||||
|
|
Loading…
Reference in New Issue