diff options
author | Jim Ingham <jingham@apple.com> | 2021-09-29 19:38:09 -0700 |
---|---|---|
committer | Jim Ingham <jingham@apple.com> | 2021-09-29 19:38:09 -0700 |
commit | 2303391d1f543f4e57f9ed0fc68bad2d4cf890dc (patch) | |
tree | 9bf5a8e31f90c14601678f678bcc1778860df30a /lldb/source/Commands/CommandObjectProcess.cpp | |
parent | 3bf3b96629e8dfc55d01ba0cb05ca01a467017fa (diff) | |
download | llvm-2303391d1f543f4e57f9ed0fc68bad2d4cf890dc.zip llvm-2303391d1f543f4e57f9ed0fc68bad2d4cf890dc.tar.gz llvm-2303391d1f543f4e57f9ed0fc68bad2d4cf890dc.tar.bz2 |
Make "process attach -c" work correctly, and add a test for it.
The issue here was that we were not updating the interpreter's
execution context when calling HandleCommand to continue the process.
Since we had just created the process, it wasn't in the interpreter's
execution context so HandleCommand failed at CheckRequirements. The
patch fixes that by passing the process execution context directly
to HandleCommand.
Differential Revision: https://reviews.llvm.org/D110787
Diffstat (limited to 'lldb/source/Commands/CommandObjectProcess.cpp')
-rw-r--r-- | lldb/source/Commands/CommandObjectProcess.cpp | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/lldb/source/Commands/CommandObjectProcess.cpp b/lldb/source/Commands/CommandObjectProcess.cpp index b3e2f6a..f3d20b3 100644 --- a/lldb/source/Commands/CommandObjectProcess.cpp +++ b/lldb/source/Commands/CommandObjectProcess.cpp @@ -398,9 +398,10 @@ protected: } StreamString stream; + ProcessSP process_sp; const auto error = target->Attach(m_options.attach_info, &stream); if (error.Success()) { - ProcessSP process_sp(target->GetProcessSP()); + process_sp = target->GetProcessSP(); if (process_sp) { result.AppendMessage(stream.GetString()); result.SetStatus(eReturnStatusSuccessFinishNoResult); @@ -452,8 +453,13 @@ protected: // This supports the use-case scenario of immediately continuing the // process once attached. - if (m_options.attach_info.GetContinueOnceAttached()) - m_interpreter.HandleCommand("process continue", eLazyBoolNo, result); + if (m_options.attach_info.GetContinueOnceAttached()) { + // We have made a process but haven't told the interpreter about it yet, + // so CheckRequirements will fail for "process continue". Set the override + // here: + ExecutionContext exe_ctx(process_sp); + m_interpreter.HandleCommand("process continue", eLazyBoolNo, exe_ctx, result); + } return result.Succeeded(); } |