forked from OSchip/llvm-project
Print process's output line by line (MI)
For example: was: ``` @"'\r\n` - it's \\ni=1\r\nj=2\r\nx=3\r\ny=4\r\nargc: /Users/IliaK/p/hello\r\nargc: (null)\r\n" ``` now: ``` @"'\r\n" @"` - it's \\ni=1\r\n" @"j=2\r\n" @"x=3\r\n" @"y=4\r\n" @"argc: /Users/IliaK/p/hello\r\n" @"argc: (null)\r\n" ``` llvm-svn: 236824
This commit is contained in:
parent
cb9547b941
commit
a4cfe98a86
|
|
@ -75,7 +75,8 @@ class MiSyntaxTestCase(lldbmi_testcase.MiTestCaseBase):
|
|||
self.expect("\^running")
|
||||
|
||||
# Test that a process output is wrapped correctly
|
||||
self.expect("\@\"'\\\\r\\\\n` - it's \\\\\\\\n\\\\x12\\\\\"\\\\\\\\\\\\\"")
|
||||
self.expect("\@\"'\\\\r\\\\n\"")
|
||||
self.expect("\@\"` - it's \\\\\\\\n\\\\x12\\\\\"\\\\\\\\\\\\\"")
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest2.main()
|
||||
|
|
|
|||
|
|
@ -1526,19 +1526,38 @@ CMICmnLLDBDebuggerHandleEvents::GetProcessStdout(void)
|
|||
while (1)
|
||||
{
|
||||
const size_t nBytes = process.GetSTDOUT(apStdoutBuffer.get(), 1024);
|
||||
if (nBytes == 0)
|
||||
break;
|
||||
|
||||
text.append(apStdoutBuffer.get(), nBytes);
|
||||
|
||||
while (1)
|
||||
{
|
||||
const size_t nNewLine = text.find('\n');
|
||||
if (nNewLine == std::string::npos)
|
||||
break;
|
||||
|
||||
const CMIUtilString line(text.substr(0, nNewLine + 1).c_str());
|
||||
text.erase(0, nNewLine + 1);
|
||||
const bool bEscapeQuotes(true);
|
||||
CMICmnMIValueConst miValueConst(line.Escape(bEscapeQuotes));
|
||||
CMICmnMIOutOfBandRecord miOutOfBandRecord(CMICmnMIOutOfBandRecord::eOutOfBand_TargetStreamOutput, miValueConst);
|
||||
const bool bOk = MiOutOfBandRecordToStdout(miOutOfBandRecord);
|
||||
if (!bOk)
|
||||
return MIstatus::failure;
|
||||
}
|
||||
|
||||
if (nBytes == 0)
|
||||
{
|
||||
if (!text.empty())
|
||||
{
|
||||
const bool bEscapeQuotes(true);
|
||||
CMICmnMIValueConst miValueConst(text.Escape(bEscapeQuotes));
|
||||
CMICmnMIOutOfBandRecord miOutOfBandRecord(CMICmnMIOutOfBandRecord::eOutOfBand_TargetStreamOutput, miValueConst);
|
||||
return MiOutOfBandRecordToStdout(miOutOfBandRecord);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (text.empty())
|
||||
return MIstatus::success;
|
||||
|
||||
const bool bEscapeQuotes(true);
|
||||
CMICmnMIValueConst miValueConst(text.Escape(bEscapeQuotes));
|
||||
CMICmnMIOutOfBandRecord miOutOfBandRecord(CMICmnMIOutOfBandRecord::eOutOfBand_TargetStreamOutput, miValueConst);
|
||||
return MiOutOfBandRecordToStdout(miOutOfBandRecord);
|
||||
return MIstatus::success;
|
||||
}
|
||||
|
||||
//++ ------------------------------------------------------------------------------------
|
||||
|
|
@ -1560,19 +1579,37 @@ CMICmnLLDBDebuggerHandleEvents::GetProcessStderr(void)
|
|||
while (1)
|
||||
{
|
||||
const size_t nBytes = process.GetSTDERR(apStderrBuffer.get(), 1024);
|
||||
if (nBytes == 0)
|
||||
break;
|
||||
|
||||
text.append(apStderrBuffer.get(), nBytes);
|
||||
|
||||
while (1)
|
||||
{
|
||||
const size_t nNewLine = text.find('\n');
|
||||
if (nNewLine == std::string::npos)
|
||||
break;
|
||||
|
||||
const CMIUtilString line(text.substr(0, nNewLine + 1).c_str());
|
||||
const bool bEscapeQuotes(true);
|
||||
CMICmnMIValueConst miValueConst(line.Escape(bEscapeQuotes));
|
||||
CMICmnMIOutOfBandRecord miOutOfBandRecord(CMICmnMIOutOfBandRecord::eOutOfBand_TargetStreamOutput, miValueConst);
|
||||
const bool bOk = MiOutOfBandRecordToStdout(miOutOfBandRecord);
|
||||
if (!bOk)
|
||||
return MIstatus::failure;
|
||||
}
|
||||
|
||||
if (nBytes == 0)
|
||||
{
|
||||
if (!text.empty())
|
||||
{
|
||||
const bool bEscapeQuotes(true);
|
||||
CMICmnMIValueConst miValueConst(text.Escape(bEscapeQuotes));
|
||||
CMICmnMIOutOfBandRecord miOutOfBandRecord(CMICmnMIOutOfBandRecord::eOutOfBand_TargetStreamOutput, miValueConst);
|
||||
return MiOutOfBandRecordToStdout(miOutOfBandRecord);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (text.empty())
|
||||
return MIstatus::success;
|
||||
|
||||
const bool bEscapeQuotes(true);
|
||||
CMICmnMIValueConst miValueConst(text.Escape(bEscapeQuotes));
|
||||
CMICmnMIOutOfBandRecord miOutOfBandRecord(CMICmnMIOutOfBandRecord::eOutOfBand_TargetStreamOutput, miValueConst);
|
||||
return MiOutOfBandRecordToStdout(miOutOfBandRecord);
|
||||
return MIstatus::success;
|
||||
}
|
||||
|
||||
//++ ------------------------------------------------------------------------------------
|
||||
|
|
|
|||
Loading…
Reference in New Issue