mirror of https://github.com/Icinga/icinga2.git
parent
7c361853ad
commit
2d2e7ecdb2
|
@ -57,11 +57,13 @@ DebugInfo icinga::DebugInfoRange(const DebugInfo& start, const DebugInfo& end)
|
||||||
|
|
||||||
#define EXTRA_LINES 2
|
#define EXTRA_LINES 2
|
||||||
|
|
||||||
void icinga::ShowCodeFragment(std::ostream& out, const DebugInfo& di, bool verbose)
|
void icinga::ShowCodeLocation(std::ostream& out, const DebugInfo& di, bool verbose)
|
||||||
{
|
{
|
||||||
if (di.Path.IsEmpty())
|
if (di.Path.IsEmpty())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
out << "Location: " << di << "\n";
|
||||||
|
|
||||||
std::ifstream ifs;
|
std::ifstream ifs;
|
||||||
ifs.open(di.Path.CStr(), std::ifstream::in);
|
ifs.open(di.Path.CStr(), std::ifstream::in);
|
||||||
|
|
||||||
|
|
|
@ -48,7 +48,7 @@ I2_BASE_API std::ostream& operator<<(std::ostream& out, const DebugInfo& val);
|
||||||
|
|
||||||
I2_BASE_API DebugInfo DebugInfoRange(const DebugInfo& start, const DebugInfo& end);
|
I2_BASE_API DebugInfo DebugInfoRange(const DebugInfo& start, const DebugInfo& end);
|
||||||
|
|
||||||
I2_BASE_API void ShowCodeFragment(std::ostream& out, const DebugInfo& di, bool verbose = true);
|
I2_BASE_API void ShowCodeLocation(std::ostream& out, const DebugInfo& di, bool verbose = true);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -140,16 +140,14 @@ String icinga::DiagnosticInformation(const std::exception& ex, bool verbose, Sta
|
||||||
const ValidationError *vex = dynamic_cast<const ValidationError *>(&ex);
|
const ValidationError *vex = dynamic_cast<const ValidationError *>(&ex);
|
||||||
|
|
||||||
if (message.IsEmpty())
|
if (message.IsEmpty())
|
||||||
result << boost::diagnostic_information(ex);
|
result << boost::diagnostic_information(ex) << "\n";
|
||||||
else
|
else
|
||||||
result << "Error: " << message;
|
result << "Error: " << message << "\n";
|
||||||
|
|
||||||
const ScriptError *dex = dynamic_cast<const ScriptError *>(&ex);
|
const ScriptError *dex = dynamic_cast<const ScriptError *>(&ex);
|
||||||
|
|
||||||
if (dex && !dex->GetDebugInfo().Path.IsEmpty()) {
|
if (dex && !dex->GetDebugInfo().Path.IsEmpty())
|
||||||
result << "\nLocation:\n";
|
ShowCodeLocation(result, dex->GetDebugInfo());
|
||||||
ShowCodeFragment(result, dex->GetDebugInfo());
|
|
||||||
}
|
|
||||||
|
|
||||||
if (vex) {
|
if (vex) {
|
||||||
DebugInfo di;
|
DebugInfo di;
|
||||||
|
@ -187,10 +185,8 @@ String icinga::DiagnosticInformation(const std::exception& ex, bool verbose, Sta
|
||||||
di.LastColumn = message->Get(5);
|
di.LastColumn = message->Get(5);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!di.Path.IsEmpty()) {
|
if (!di.Path.IsEmpty())
|
||||||
result << "\nLocation:\n";
|
ShowCodeLocation(result, di);
|
||||||
ShowCodeFragment(result, di);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const user_error *uex = dynamic_cast<const user_error *>(&ex);
|
const user_error *uex = dynamic_cast<const user_error *>(&ex);
|
||||||
|
|
|
@ -59,12 +59,13 @@ void ConsoleCommand::BreakpointHandler(ScriptFrame& frame, ScriptError *ex, cons
|
||||||
if (ex && ex->IsHandledByDebugger())
|
if (ex && ex->IsHandledByDebugger())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
std::cout << "Breakpoint encountered " << di << "\n";
|
std::cout << "Breakpoint encountered.\n";
|
||||||
|
|
||||||
if (ex) {
|
if (ex) {
|
||||||
std::cout << "Exception: " << DiagnosticInformation(*ex);
|
std::cout << "Exception: " << DiagnosticInformation(*ex) << "\n";
|
||||||
ex->SetHandledByDebugger(true);
|
ex->SetHandledByDebugger(true);
|
||||||
}
|
} else
|
||||||
|
ShowCodeLocation(std::cout, di);
|
||||||
|
|
||||||
std::cout << "You can inspect expressions (such as variables) by entering them at the prompt.\n"
|
std::cout << "You can inspect expressions (such as variables) by entering them at the prompt.\n"
|
||||||
<< "To leave the debugger and continue the program use \"$continue\".\n";
|
<< "To leave the debugger and continue the program use \"$continue\".\n";
|
||||||
|
@ -358,7 +359,7 @@ incomplete:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
ShowCodeFragment(std::cout, di);
|
ShowCodeLocation(std::cout, di);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::cout << ex.what() << "\n";
|
std::cout << ex.what() << "\n";
|
||||||
|
|
|
@ -56,7 +56,7 @@ ExpressionResult Expression::Evaluate(ScriptFrame& frame, DebugHint *dhint) cons
|
||||||
try {
|
try {
|
||||||
#ifdef I2_DEBUG
|
#ifdef I2_DEBUG
|
||||||
/* std::ostringstream msgbuf;
|
/* std::ostringstream msgbuf;
|
||||||
ShowCodeFragment(msgbuf, GetDebugInfo(), false);
|
ShowCodeLocation(msgbuf, GetDebugInfo(), false);
|
||||||
Log(LogDebug, "Expression")
|
Log(LogDebug, "Expression")
|
||||||
<< "Executing:\n" << msgbuf.str();*/
|
<< "Executing:\n" << msgbuf.str();*/
|
||||||
#endif /* I2_DEBUG */
|
#endif /* I2_DEBUG */
|
||||||
|
|
Loading…
Reference in New Issue