From: Gunnar Beutner Date: Thu, 10 Aug 2017 06:26:22 +0000 (+0200) Subject: Implement additional functions for printing values with LLDB/GDB X-Git-Tag: v2.8.0~125^2 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=refs%2Fpull%2F5488%2Fhead;p=icinga2 Implement additional functions for printing values with LLDB/GDB --- diff --git a/lib/cli/consolecommand.cpp b/lib/cli/consolecommand.cpp index 44b14aecb..a0e92871d 100644 --- a/lib/cli/consolecommand.cpp +++ b/lib/cli/consolecommand.cpp @@ -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("", 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("", 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;