1616#include " SwiftMetadataCache.h"
1717
1818#include " Plugins/ExpressionParser/Swift/SwiftPersistentExpressionState.h"
19- #include " Plugins/LanguageRuntime/Swift/SwiftTask.h"
2019#include " Plugins/Process/Utility/RegisterContext_x86.h"
2120#include " Plugins/TypeSystem/Clang/TypeSystemClang.h"
2221#include " Plugins/TypeSystem/Swift/SwiftDemangle.h"
@@ -2086,89 +2085,6 @@ class CommandObjectSwift_RefCount : public CommandObjectRaw {
20862085 }
20872086};
20882087
2089- class CommandObjectLanguageSwiftTaskBacktrace final
2090- : public CommandObjectParsed {
2091- public:
2092- CommandObjectLanguageSwiftTaskBacktrace (CommandInterpreter &interpreter)
2093- : CommandObjectParsed(interpreter, " backtrace" ,
2094- " Show the backtrace of Swift tasks. See `thread "
2095- " backtrace` for customizing backtrace output." ,
2096- " language swift task backtrace <variable-name>" ) {
2097- AddSimpleArgumentList (eArgTypeVarName);
2098- }
2099-
2100- private:
2101- void DoExecute (Args &command, CommandReturnObject &result) override {
2102- if (!m_exe_ctx.GetFramePtr ()) {
2103- result.AppendError (" no active frame selected" );
2104- return ;
2105- }
2106-
2107- if (command.empty () || command[0 ].ref ().empty ()) {
2108- result.AppendError (" no task variable" );
2109- return ;
2110- }
2111-
2112- StackFrame &frame = m_exe_ctx.GetFrameRef ();
2113- uint32_t path_options =
2114- StackFrame::eExpressionPathOptionsAllowDirectIVarAccess;
2115- VariableSP var_sp;
2116- Status status;
2117- ValueObjectSP valobj_sp = frame.GetValueForVariableExpressionPath (
2118- command[0 ].c_str (), eDynamicDontRunTarget, path_options, var_sp,
2119- status);
2120- if (!valobj_sp) {
2121- result.AppendError (status.AsCString ());
2122- return ;
2123- }
2124-
2125- addr_t task_ptr = LLDB_INVALID_ADDRESS;
2126- ThreadSafeReflectionContext reflection_ctx;
2127- if (ValueObjectSP task_obj_sp =
2128- valobj_sp->GetChildMemberWithName (" _task" )) {
2129- task_ptr = task_obj_sp->GetValueAsUnsigned (LLDB_INVALID_ADDRESS);
2130- if (task_ptr != LLDB_INVALID_ADDRESS)
2131- if (auto *runtime = SwiftLanguageRuntime::Get (m_exe_ctx.GetProcessSP ()))
2132- reflection_ctx = runtime->GetReflectionContext ();
2133- }
2134- if (task_ptr == LLDB_INVALID_ADDRESS || !reflection_ctx) {
2135- result.AppendError (" failed to access Task data from runtime" );
2136- return ;
2137- }
2138-
2139- llvm::Expected<ReflectionContextInterface::AsyncTaskInfo> task_info =
2140- reflection_ctx->asyncTaskInfo (task_ptr);
2141- if (auto error = task_info.takeError ()) {
2142- result.AppendError (toString (std::move (error)));
2143- return ;
2144- }
2145-
2146- auto thread_task = ThreadTask::Create (
2147- task_info->id , task_info->resumeAsyncContext , m_exe_ctx);
2148- if (auto error = thread_task.takeError ()) {
2149- result.AppendError (toString (std::move (error)));
2150- return ;
2151- }
2152-
2153- // GetStatus prints the backtrace.
2154- thread_task.get ()->GetStatus (result.GetOutputStream (), 0 , UINT32_MAX, 0 ,
2155- false , true );
2156- result.SetStatus (lldb::eReturnStatusSuccessFinishResult);
2157- }
2158- };
2159-
2160- class CommandObjectLanguageSwiftTask final : public CommandObjectMultiword {
2161- public:
2162- CommandObjectLanguageSwiftTask (CommandInterpreter &interpreter)
2163- : CommandObjectMultiword(
2164- interpreter, " task" , " Commands for inspecting Swift Tasks." ,
2165- " language swift task <subcommand> [<subcommand-options>]" ) {
2166- LoadSubCommand (" backtrace" ,
2167- CommandObjectSP (new CommandObjectLanguageSwiftTaskBacktrace (
2168- interpreter)));
2169- }
2170- };
2171-
21722088class CommandObjectMultiwordSwift : public CommandObjectMultiword {
21732089public:
21742090 CommandObjectMultiwordSwift (CommandInterpreter &interpreter)
@@ -2180,8 +2096,6 @@ class CommandObjectMultiwordSwift : public CommandObjectMultiword {
21802096 interpreter)));
21812097 LoadSubCommand (" refcount" , CommandObjectSP (new CommandObjectSwift_RefCount (
21822098 interpreter)));
2183- LoadSubCommand (" task" , CommandObjectSP (new CommandObjectLanguageSwiftTask (
2184- interpreter)));
21852099 }
21862100
21872101 virtual ~CommandObjectMultiwordSwift () {}
0 commit comments