[lldb-dev] Process::SetPrivateState / SetPublicState
Zachary Turner
zturner at google.com
Tue Nov 11 09:46:08 PST 2014
A follow up question. Trying to make sure I get this right for the
sequence of launching a process. You launch the process, wait for the
initial stop, then lldb resumes your process, then it's running.
Conceptually it seems like the following state sequence makes the most sense
Upon returning from Process::DoLaunch() Public = Private = Launching
After the initial stop is received Public = launching, private = stopped
After LLDB calls DoResume() Public = private = running
On the other hand, you said I should never touch the public state myself.
Did I understand this correctly, or is it ok to set the public state from
within my process plugin?
On Thu Nov 06 2014 at 2:07:34 PM Zachary Turner <zturner at google.com> wrote:
> Thanks, makes sense.
>
> On Thu Nov 06 2014 at 2:05:15 PM Greg Clayton <gclayton at apple.com> wrote:
>
>> > What is the difference between these two, and when would I use one over
>> the other? SetPrivateState() doesn't appear to modify the public state,
>> and SetPublicState doesn't appear to modify the private state, so it seems
>> a little confusing that these can get out of sync with each other. What's
>> the use case here?
>>
>>
>> When you detect the truth (when your process starts or stops), you set
>> the private state. The public state could be set to running, but you are
>> implementing a source line single step which may involve starting and
>> stopping the process 100s of times before the step is actually done. So the
>> thread plans use the private state and determine when the public state
>> should be updated. Another example is running an expression. The public
>> state may say "stopped", but privately the process can be resumed and
>> stopped many times when evaluating the expression, but you wouldn't want
>> the public (people listening to the process events) to know about such
>> changes.
>>
>> So the thread plans and process use the private state to make things
>> happen and this tracks the "truth" of what the current process is doing.
>> The public facing state is what causes the events to be broadcast to
>> whomever is listening to the process events and should only notify the GUI
>> or command line when it would like to update the views or display the stop
>> reason, etc.
>>
>> In the classes that are controlling your actual process, you should
>> always be setting the private state. Never touch the public state yourself.
>>
>> Greg
>>
>>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/lldb-dev/attachments/20141111/de881eaa/attachment.html>
More information about the lldb-dev
mailing list