Page MenuHomePhabricator

[lldbmi] Fix prompt which can get inserted in the middle of lldb-mi output

Authored by dawn on Sep 30 2016, 3:16 PM.



The code added in svn trunk 264332 causes "(lldb)" to be printed in the middle of program console output. This fix restores the behavior for non-Windows platforms to before the patch.

For a C++ program with the following source:

printf("\n#Break: Function parameters - arrays");
printf("\n#Evaluate:A[0]-C[0] + (A[1]-C[1])*1000 #ExpectedEval:%d", 1001);
printf("\n#Evaluate:FuncArr(C,B) #ExpectedEval:%d", RES);
printf("\n#Evaluate:A[0]-C[0] + (A[1]-C[1])*1000 + 0 #ExpectedEval:%d", 0);
printf("\n#Evaluate:ref[0] + ref[1]*10 #ExpectedEval:%d", 65);
printf("\n#Evaluate:FuncArrRet(7,8) #ExpectedLike:deferred");

the following output is produced when running the program in lldb-mi:

#Break: Function parameters - arrays
#Evaluate:A[0]-C[0] + (A[1]-C[1])*1000 #ExpectedEval:1001
#Evaluate:FuncArr(C,B) #ExpectedEval:4321
#Evaluate:A[0]-C[0] + (A[1]-C[1])*1000 + 0 #ExpectedEval:0
#Evaluate:ref[0] + ref[1]*10 #ExpectedEval:65
#Evalua(lldb) te:FuncArrRet(7,8) #ExpectedLike:deferred

Note the "(lldb) " inserted into the program output of the 6th print statement. This is a problem for debuggers which want to display the program output to the user (or in this case, for a test harness which reads the program output and uses it to interactively test lldb-mi).

Diff Detail


Event Timeline

dawn updated this revision to Diff 73142.Sep 30 2016, 3:16 PM
dawn retitled this revision from to [lldbmi] Fix prompt which can get inserted in the middle of lldb-mi output.
dawn updated this object.
dawn added reviewers: ted, zturner, clayborg.
dawn set the repository for this revision to rL LLVM.
dawn added subscribers: amccarth, lldb-commits.
dawn updated this object.Sep 30 2016, 3:27 PM
ted accepted this revision.Sep 30 2016, 3:39 PM
ted edited edge metadata.

The problem this scenario has is asynchronous output from 2 different sources. The original fix made Windows (or any lldb without libedit) much better, but I think most non-Windows builds will use libedit, because it's extremely useful. lldb-mi has a different set of constraints; the position of the prompt isn't as important, since users won't use it as a cue to tell when the debugger can accept more input.

Since this improves lldb-mi, and only hurts a use case I think is not very prevalent (LLDB_DISABLE_LIBEDIT on a non-Windows platform), I think it's OK. LGTM.

This revision is now accepted and ready to land.Sep 30 2016, 3:39 PM
This revision was automatically updated to reflect the committed changes.