apolyakov updated this revision to Diff 157533. apolyakov retitled this revision from "[WIP] Re-implement MI HandleProcessEventStateSuspended." to "[lldb-mi] Re-implement MI HandleProcessEventStateSuspended.". apolyakov added a comment.
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". https://reviews.llvm.org/D49632 Files: tools/lldb-mi/MICmnLLDBDebuggerHandleEvents.cpp Index: tools/lldb-mi/MICmnLLDBDebuggerHandleEvents.cpp =================================================================== --- tools/lldb-mi/MICmnLLDBDebuggerHandleEvents.cpp +++ tools/lldb-mi/MICmnLLDBDebuggerHandleEvents.cpp @@ -950,24 +950,26 @@ bool CMICmnLLDBDebuggerHandleEvents::HandleProcessEventStateSuspended( const lldb::SBEvent &vEvent) { bool bOk = MIstatus::success; + lldb::SBStream streamOut; lldb::SBDebugger &rDebugger = CMICmnLLDBDebugSessionInfo::Instance().GetDebugger(); lldb::SBProcess sbProcess = CMICmnLLDBDebugSessionInfo::Instance().GetProcess(); lldb::SBTarget target = sbProcess.GetTarget(); if (rDebugger.GetSelectedTarget() == target) { if (!UpdateSelectedThread()) return MIstatus::failure; - - lldb::SBCommandReturnObject result; - const lldb::ReturnStatus status = - rDebugger.GetCommandInterpreter().HandleCommand("process status", - result, false); - MIunused(status); - bOk = TextToStderr(result.GetError()); - bOk = bOk && TextToStdout(result.GetOutput()); + sbProcess.GetDescription(streamOut); + // Add a delimiter between process' and threads' info. + streamOut.Printf("\n"); + for (uint32_t i = 0, e = sbProcess.GetNumThreads(); i < e; ++i) { + const lldb::SBThread thread = sbProcess.GetThreadAtIndex(i); + if (!thread.IsValid()) + continue; + thread.GetDescription(streamOut); + } + bOk = TextToStdout(streamOut.GetData()); } else { - lldb::SBStream streamOut; const MIuint nTargetIndex = rDebugger.GetIndexOfTarget(target); if (nTargetIndex != UINT_MAX) streamOut.Printf("Target %d: (", nTargetIndex);
Index: tools/lldb-mi/MICmnLLDBDebuggerHandleEvents.cpp =================================================================== --- tools/lldb-mi/MICmnLLDBDebuggerHandleEvents.cpp +++ tools/lldb-mi/MICmnLLDBDebuggerHandleEvents.cpp @@ -950,24 +950,26 @@ bool CMICmnLLDBDebuggerHandleEvents::HandleProcessEventStateSuspended( const lldb::SBEvent &vEvent) { bool bOk = MIstatus::success; + lldb::SBStream streamOut; lldb::SBDebugger &rDebugger = CMICmnLLDBDebugSessionInfo::Instance().GetDebugger(); lldb::SBProcess sbProcess = CMICmnLLDBDebugSessionInfo::Instance().GetProcess(); lldb::SBTarget target = sbProcess.GetTarget(); if (rDebugger.GetSelectedTarget() == target) { if (!UpdateSelectedThread()) return MIstatus::failure; - - lldb::SBCommandReturnObject result; - const lldb::ReturnStatus status = - rDebugger.GetCommandInterpreter().HandleCommand("process status", - result, false); - MIunused(status); - bOk = TextToStderr(result.GetError()); - bOk = bOk && TextToStdout(result.GetOutput()); + sbProcess.GetDescription(streamOut); + // Add a delimiter between process' and threads' info. + streamOut.Printf("\n"); + for (uint32_t i = 0, e = sbProcess.GetNumThreads(); i < e; ++i) { + const lldb::SBThread thread = sbProcess.GetThreadAtIndex(i); + if (!thread.IsValid()) + continue; + thread.GetDescription(streamOut); + } + bOk = TextToStdout(streamOut.GetData()); } else { - lldb::SBStream streamOut; const MIuint nTargetIndex = rDebugger.GetIndexOfTarget(target); if (nTargetIndex != UINT_MAX) streamOut.Printf("Target %d: (", nTargetIndex);
_______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits