This is an archive of the discontinued LLVM Phabricator instance.

[lldb-mi] Re-implement MI HandleProcessEventStateSuspended.
ClosedPublic

Authored by apolyakov on Jul 21 2018, 1:48 AM.

Diff Detail

Repository
rL LLVM

Event Timeline

apolyakov created this revision.Jul 21 2018, 1:48 AM
apolyakov added inline comments.Jul 21 2018, 1:51 AM
tools/lldb-mi/MICmnLLDBDebuggerHandleEvents.cpp
963 ↗(On Diff #156668)

Am I right that here should be a synchronization block?

apolyakov retitled this revision from [lldb-mi] Re-implement MI HandleProcessEventStateSuspended. to [WIP] Re-implement MI HandleProcessEventStateSuspended..Jul 21 2018, 4:55 AM

So with CMICmnLLDBDebuggerHandleEvents::HandleProcessEventStateSuspended() it will report a bunch of text back through the MI interface with this each time? Why would it do that? I would assume that the MI interface would handle this programmatically?

tools/lldb-mi/MICmnLLDBDebuggerHandleEvents.cpp
963 ↗(On Diff #156668)

As long as the process remains stopped you are ok.

So with CMICmnLLDBDebuggerHandleEvents::HandleProcessEventStateSuspended() it will report a bunch of text back through the MI interface with this each time? Why would it do that? I would assume that the MI interface would handle this programmatically?

Could you explain more detailed what does it mean that MI interface would handle a report of bunch of text programmatically?

If you look at what this patch is doing, it ends sending text to stdout at the end. So it seems like this function's sole purpose is to report the process status after stop to STDOUT. Seeing as this is a machine interface (MI) to a debugger, I was wondering why it would do this.

You mean that it's unreasonable to provide such an output to stdout since MI clients are text redactors, IDE and not people?

apolyakov retitled this revision from [WIP] Re-implement MI HandleProcessEventStateSuspended. to [lldb-mi] Re-implement MI HandleProcessEventStateSuspended..

It seems that it's impossible to get HandleProcessEventStateSuspended called on Linux, so I've copied code of this patch into
HandleProcessEventStateStopped to check new output.

Was(HandleCommand("process status")):

~"Process 17065 stopped\n* thread #1, name = 'bash', stop reason = breakpoint 1.1\n    frame #0: 0x000000000041eed0 bash`main\nbash`main:\n->  0x41eed0 <+0>: pushq  %r15\n    0x41eed2 <+2>: pushq  %r14\n    0x41eed4 <+4>: pushq  %r13\n    0x41eed6 <+6>: pushq  %r12\n"

Now(SB API):

SBProcess: pid = 17065, state = stopped, threads = 1, executable = bash
thread #1: tid = 17065, 0x000000000041eed0 bash`main, name = 'bash', stop reason = breakpoint 1.1

Of course, it will be state = suspended in a "real life".

I still don't get why we are printing process stopped information to STDOUT. MI is a machine interface for a IDE. The IDE should be showing the process state in the GUI.

I still don't get why we are printing process stopped information to STDOUT. MI is a machine interface for a IDE. The IDE should be showing the process state in the GUI.

AFAIK, all lldb-mi commands print their final result records to stdout. All lldb-mi commands are inherited from CMICmdInvoker which has CmdExecuteFinished(...) method that is invoked when a command is finished, this method then call CmdToStdout(...) method which prints command's result to stdout. So, I guess, it's ok, isn't it?

@clayborg can you explain what are you worry about because I don't completely understand you? As I said, all lldb-mi commands print their result to STDOUT, AFAIK, an IDE should parse it and then show in a GUI.

aprantl accepted this revision.Aug 2 2018, 1:09 PM

Hmm.. yeah, this looks more like a side-channel than a proper part of the MI protocol. That said, this is also what the original code was doing, so we can investigate the proper protocol separately.

This revision is now accepted and ready to land.Aug 2 2018, 1:09 PM
This revision was automatically updated to reflect the committed changes.