[Lldb-commits] [lldb] r202525 - Fixed all overlapping prompt issues.

Greg Clayton gclayton at apple.com
Mon Mar 3 13:09:28 PST 2014


Ed,

I checked in another fix, but this probably won't fix your issues. We will need to track down how this is coming out out of order on FreeBSD. It doesn't make sense how it can be from what I can tell.

There are two threads:

1 - the main thread that runs the IOHandler stack
2 - the event handler thread that will call HandleProcessEvent()

What usually happens is you launch LLDB and the IOHandler stack looks like:

[0] - IOHanderEditline

Then you run your process and if it is using STDIO, it will push a IOHandlerProcessSTDIO so while running the IOHandler stack will look like:

[0] - IOHanderEditline
[1] - IOHandlerProcessSTDIO

Or it there is no STDIO, then it will just be:

[0] - IOHanderEditline

When an event comes in, we will see if that event generates output, and if it does, it will, inside Debugger::HandleProcessEvent(), hide the top IOHandler (hide the "(lldb) " prompt if there is no ProcessIOHandler (this is the change I just made), or just display the output, and then update the top io handler after the output has been printed (show the "(lldb) " prompt again if the process IO handler wasn't there), and then optionally pop the process IO handler off the stack.

So you will want to make sure no one in the Process plug-in that you guys use, is popping the process IO handler manually. 

So the two flows are as follows:

Flow 1: when the process has an IO handler

1 - launch process

	[0] - IOHanderEditline

2 - IOHandlerProcessSTDIO gets pushed

	[0] - IOHanderEditline
	[1] - IOHandlerProcessSTDIO

	Now the "(lldb) " prompt is hidden

3 - Stop event comes in on thread 2
	stdout gets placed into stream (if any)
	stderr gets placed into stream (if any)
	get eStateStopped event and stop info gets placed into stream (like thread and stack frame zero)
	stream gets printed to debugger console
	IOHandlerProcessSTDIO gets popped which causes the "(lldb) " prompt to show up

	[0] - IOHanderEditline

4 - continue
	IOHandlerProcessSTDIO gets pushed
	we get eStateRunning event and any message gets placed into stream 
	stream gets printed to debugger console

	[0] - IOHanderEditline
	[1] - IOHandlerProcessSTDIO

5 - hit breakpoint or finish step
	stdout gets placed into stream (if any)
	stderr gets placed into stream (if any)
	get eStateStopped event and stop info gets placed into stream (like thread and stack frame zero)
	stream gets printed to debugger console
	IOHandlerProcessSTDIO gets popped which causes the "(lldb) " prompt to show up

	[0] - IOHanderEditline


Flow 2: process does't have an IOHandler

1 - launch process

	[0] - IOHanderEditline

2 - IOHandlerProcessSTDIO doesn't get pushed

	[0] - IOHanderEditline

	The "(lldb) " prompt remains visible and active the entire time

3 - Stop event comes in on thread 2
	stdout gets placed into stream (if any)
	stderr gets placed into stream (if any)
	get eStateStopped event and stop info gets placed into stream (like thread and stack frame zero)
	hide top IOHandler (IOHanderEditline is asked to hide via call to Debugger::HideTopIOHandler(), "(lldb) " prompt should disappear)
	stream gets printed to debugger console
	refresh top IOHandler (IOHanderEditline is asked to refresh via call to Debugger::RefreshTopIOHandler(), "(lldb) prompt shows up again)

	[0] - IOHanderEditline

4 - continue
	we get eStateRunning event and any message gets placed into stream 
	hide top IOHandler (remove "(lldb) ")
	stream gets printed to debugger console
	refresh top IOHandler (show "(lldb) ")

	[0] - IOHanderEditline

5 - hit breakpoint or finish step
	stdout gets placed into stream (if any)
	stderr gets placed into stream (if any)
	get eStateStopped event and stop info gets placed into stream (like thread and stack frame zero)
	hide top IOHandler (remove "(lldb) ")
	stream gets printed to debugger console
	refresh top IOHandler (show "(lldb) ")

	[0] - IOHanderEditline


If this isn't what is happening on FreeBSD, you will need to debug why this is happening.

Greg

On Feb 28, 2014, at 11:37 AM, Ed Maste <emaste at freebsd.org> wrote:

> On 28 February 2014 13:22, Greg Clayton <gclayton at apple.com> wrote:
>> Author: gclayton
>> Date: Fri Feb 28 12:22:24 2014
>> New Revision: 202525
>> 
>> URL: http://llvm.org/viewvc/llvm-project?rev=202525&view=rev
>> Log:
>> Fixed all overlapping prompt issues.
>> 
>> I carefully reviewed exactly how the IOHandlers interact and found places where we weren't properly controlling things. There should be no overlapping prompts and all output should now come out in a controlled fashion.
>> 
>> <rdar://problem/16111293>
> 
> Hi Greg,
> 
> After this change I still encountered an issue on FreeBSD where the
> (lldb) prompt preceeded the stop reason and frame info output (leaving
> me with no prompt on the current line):
> 
> joule% bin/lldb /bin/ls
> Current executable set to '/bin/ls' (x86_64).
> (lldb) b main
> Breakpoint 1: where = ls`main + 33 at ls.c:163, address = 0x00000000004023f1
> (lldb) run
> Process 13033 launching
> Process 13033 stopped
> Process 13033 launched: '/bin/ls' (x86_64)
> Process 13033 stopped
> * thread #1: tid = 100685, 0x00000000004023f1 ls`main(argc=1,
> argv=0x00007fffffffd760) + 33 at ls.c:163, stop reason = breakpoint
> 1.1
>    frame #0: 0x00000000004023f1 ls`main(argc=1,
> argv=0x00007fffffffd760) + 33 at ls.c:163
>   160  #ifdef COLORLS
>   161          char termcapbuf[1024];  /* termcap definition buffer */
>   162          char tcapbuf[512];      /* capability buffer */
> -> 163          char *bp = tcapbuf;
>   164  #endif
>   165
>   166          (void)setlocale(LC_ALL, "");
> (lldb) step
> (lldb) Process 13033 stopped
> * thread #1: tid = 100685, 0x00000000004023fa ls`main(argc=1,
> argv=0x00007fffffffd760) + 42 at ls.c:166, stop reason = step in
>    frame #0: 0x00000000004023fa ls`main(argc=1,
> argv=0x00007fffffffd760) + 42 at ls.c:166
>   163          char *bp = tcapbuf;
>   164  #endif
>   165
> -> 166          (void)setlocale(LC_ALL, "");
>   167
>   168          /* Terminal defaults to -Cq, non-terminal defaults to -1. */
>   169          if (isatty(STDOUT_FILENO)) {




More information about the lldb-commits mailing list