Make a way to set the result status for Python defined commands, and don't overwrite the status of the result if

the python command has set it.

llvm-svn: 159273
This commit is contained in:
Jim Ingham 2012-06-27 17:25:36 +00:00
parent a58862310c
commit 70f11f88e3
4 changed files with 25 additions and 1 deletions

View File

@ -61,6 +61,9 @@ public:
lldb::ReturnStatus lldb::ReturnStatus
GetStatus(); GetStatus();
void
SetStatus (lldb::ReturnStatus status);
bool bool
Succeeded (); Succeeded ();

View File

@ -50,6 +50,9 @@ public:
void void
Clear(); Clear();
void
SetStatus (lldb::ReturnStatus status);
lldb::ReturnStatus lldb::ReturnStatus
GetStatus(); GetStatus();

View File

@ -160,6 +160,13 @@ SBCommandReturnObject::GetStatus()
return lldb::eReturnStatusInvalid; return lldb::eReturnStatusInvalid;
} }
void
SBCommandReturnObject::SetStatus(lldb::ReturnStatus status)
{
if (m_opaque_ap.get())
m_opaque_ap->SetStatus(status);
}
bool bool
SBCommandReturnObject::Succeeded () SBCommandReturnObject::Succeeded ()
{ {

View File

@ -1214,6 +1214,8 @@ protected:
Error error; Error error;
result.SetStatus(eReturnStatusInvalid);
if (!scripter || scripter->RunScriptBasedCommand(m_function_name.c_str(), if (!scripter || scripter->RunScriptBasedCommand(m_function_name.c_str(),
raw_command_line, raw_command_line,
m_synchro, m_synchro,
@ -1224,7 +1226,16 @@ protected:
result.SetStatus(eReturnStatusFailed); result.SetStatus(eReturnStatusFailed);
} }
else else
result.SetStatus(eReturnStatusSuccessFinishNoResult); {
// Don't change the status if the command already set it...
if (result.GetStatus() == eReturnStatusInvalid)
{
if (result.GetOutputData() == NULL || result.GetOutputData()[0] == '\0')
result.SetStatus(eReturnStatusSuccessFinishNoResult);
else
result.SetStatus(eReturnStatusSuccessFinishResult);
}
}
return result.Succeeded(); return result.Succeeded();
} }