]> granicus.if.org Git - icinga2/commitdiff
Implement support for inspecting variables with LLDB/GDB
authorGunnar Beutner <gunnar.beutner@netways.de>
Fri, 12 Aug 2016 09:00:19 +0000 (11:00 +0200)
committerGunnar Beutner <gunnar.beutner@netways.de>
Fri, 12 Aug 2016 09:00:19 +0000 (11:00 +0200)
fixes #12407

lib/cli/consolecommand.cpp

index 005ea9e19e5a269224795acc370985bc5de31ca9..a5d78292d5fd95d1fdc8f076feba71f705595746 100644 (file)
@@ -48,6 +48,40 @@ REGISTER_CLICOMMAND("console", ConsoleCommand);
 
 INITIALIZE_ONCE(&ConsoleCommand::StaticInitialize);
 
+extern "C" void dbg_spawn_console(void)
+{
+       ScriptFrame frame;
+       ConsoleCommand::RunScriptConsole(frame);
+}
+
+extern "C" void dbg_inspect_value(const Value& value)
+{
+       ConfigWriter::EmitValue(std::cout, 1, Serialize(value, 0));
+       std::cout << std::endl;
+}
+
+extern "C" void dbg_inspect_object(Object *obj)
+{
+       Object::Ptr objr = obj;
+       dbg_inspect_value(objr);
+}
+
+extern "C" void dbg_eval(const char *text)
+{
+       Expression *expr;
+
+       try {
+               ScriptFrame frame;
+               expr = ConfigCompiler::CompileText("<dbg>", text);
+               Value result = Serialize(expr->Evaluate(frame), 0);
+               dbg_inspect_value(result);
+       } catch (const std::exception& ex) {
+               std::cout << "Error: " << DiagnosticInformation(ex) << "\n";
+       }
+
+       delete expr;
+}
+
 void ConsoleCommand::BreakpointHandler(ScriptFrame& frame, ScriptError *ex, const DebugInfo& di)
 {
        static boost::mutex mutex;