]> granicus.if.org Git - icinga2/commitdiff
Implement additional functions for printing values with LLDB/GDB 5488/head
authorGunnar Beutner <gunnar.beutner@icinga.com>
Thu, 10 Aug 2017 06:26:22 +0000 (08:26 +0200)
committerGunnar Beutner <gunnar.beutner@icinga.com>
Thu, 10 Aug 2017 06:26:22 +0000 (08:26 +0200)
lib/cli/consolecommand.cpp

index 44b14aecb63371b8a35a928419c51f09246f4c93..a0e92871dd8bf92ed6a40e92ca86c1e684992727 100644 (file)
@@ -82,6 +82,42 @@ extern "C" void dbg_eval(const char *text)
        delete expr;
 }
 
+extern "C" void dbg_eval_with_value(const Value& value, const char *text)
+{
+       Expression *expr = NULL;
+
+       try {
+               ScriptFrame frame;
+               frame.Locals = new Dictionary();
+               frame.Locals->Set("arg", value);
+               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;
+}
+
+extern "C" void dbg_eval_with_object(Object *object, const char *text)
+{
+       Expression *expr = NULL;
+
+       try {
+               ScriptFrame frame;
+               frame.Locals = new Dictionary();
+               frame.Locals->Set("arg", object);
+               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;