Changeset View
Changeset View
Standalone View
Standalone View
source/Commands/CommandObjectThread.cpp
Show First 20 Lines • Show All 1,509 Lines • ▼ Show 20 Lines | bool HandleOneThread(lldb::tid_t tid, CommandReturnObject &result) override { | ||||
} | } | ||||
return true; | return true; | ||||
} | } | ||||
CommandOptions m_options; | CommandOptions m_options; | ||||
}; | }; | ||||
//------------------------------------------------------------------------- | //------------------------------------------------------------------------- | ||||
// CommandObjectThreadException | |||||
//------------------------------------------------------------------------- | |||||
static OptionDefinition g_thread_exception_options[] = { | |||||
// clang-format off | |||||
{ LLDB_OPT_SET_1, false, "count", 'c', OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypeCount, "How many frames to display (-1 for all)" }, | |||||
{ LLDB_OPT_SET_1, false, "start", 's', OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypeFrameIndex, "Frame in which to start the backtrace" }, | |||||
// clang-format on | |||||
}; | |||||
class CommandObjectThreadException : public CommandObjectIterateOverThreads { | |||||
public: | |||||
class CommandOptions : public Options { | |||||
public: | |||||
CommandOptions() : Options() { OptionParsingStarting(nullptr); } | |||||
~CommandOptions() override = default; | |||||
Status SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg, | |||||
ExecutionContext *execution_context) override { | |||||
Status error; | |||||
const int short_option = m_getopt_table[option_idx].val; | |||||
switch (short_option) { | |||||
case 'c': { | |||||
int32_t input_count = 0; | |||||
if (option_arg.getAsInteger(0, m_count)) { | |||||
m_count = UINT32_MAX; | |||||
error.SetErrorStringWithFormat( | |||||
"invalid integer value for option '%c'", short_option); | |||||
} else if (input_count < 0) | |||||
m_count = UINT32_MAX; | |||||
} break; | |||||
case 's': | |||||
if (option_arg.getAsInteger(0, m_start)) | |||||
error.SetErrorStringWithFormat( | |||||
"invalid integer value for option '%c'", short_option); | |||||
break; | |||||
default: | |||||
error.SetErrorStringWithFormat("invalid short option character '%c'", | |||||
short_option); | |||||
break; | |||||
} | |||||
return error; | |||||
} | |||||
void OptionParsingStarting(ExecutionContext *execution_context) override { | |||||
m_count = UINT32_MAX; | |||||
m_start = 0; | |||||
} | |||||
llvm::ArrayRef<OptionDefinition> GetDefinitions() override { | |||||
return llvm::makeArrayRef(g_thread_exception_options); | |||||
} | |||||
// Instance variables to hold the values for command options. | |||||
uint32_t m_count; | |||||
uint32_t m_start; | |||||
}; | |||||
CommandObjectThreadException(CommandInterpreter &interpreter) | |||||
: CommandObjectIterateOverThreads( | |||||
interpreter, "thread exception", | |||||
"Display the current exception object for a thread. Defaults to " | |||||
"the current thread.", | |||||
"thread exception", | |||||
eCommandRequiresProcess | eCommandTryTargetAPILock | | |||||
eCommandProcessMustBeLaunched | eCommandProcessMustBePaused), | |||||
m_options() { | |||||
m_add_return = false; | |||||
} | |||||
~CommandObjectThreadException() override = default; | |||||
Options *GetOptions() override { return &m_options; } | |||||
bool HandleOneThread(lldb::tid_t tid, CommandReturnObject &result) override { | |||||
ThreadSP thread_sp = | |||||
m_exe_ctx.GetProcessPtr()->GetThreadList().FindThreadByID(tid); | |||||
if (!thread_sp) { | |||||
result.AppendErrorWithFormat("thread no longer exists: 0x%" PRIx64 "\n", | |||||
tid); | |||||
result.SetStatus(eReturnStatusFailed); | |||||
return false; | |||||
} | |||||
Stream &strm = result.GetOutputStream(); | |||||
ValueObjectSP exception_object_sp = thread_sp->GetCurrentException(); | |||||
if (exception_object_sp) { | |||||
exception_object_sp->Dump(strm); | |||||
} | |||||
ThreadSP exception_thread_sp = thread_sp->GetCurrentExceptionBacktrace(); | |||||
if (exception_thread_sp && exception_thread_sp->IsValid()) { | |||||
const uint32_t num_frames_with_source = 0; | |||||
const bool stop_format = false; | |||||
exception_thread_sp->GetStatus(strm, m_options.m_start, m_options.m_count, | |||||
num_frames_with_source, stop_format); | |||||
} | |||||
return true; | |||||
} | |||||
CommandOptions m_options; | |||||
}; | |||||
//------------------------------------------------------------------------- | |||||
// CommandObjectThreadReturn | // CommandObjectThreadReturn | ||||
//------------------------------------------------------------------------- | //------------------------------------------------------------------------- | ||||
static constexpr OptionDefinition g_thread_return_options[] = { | static constexpr OptionDefinition g_thread_return_options[] = { | ||||
// clang-format off | // clang-format off | ||||
{ LLDB_OPT_SET_ALL, false, "from-expression", 'x', OptionParser::eNoArgument, nullptr, {}, 0, eArgTypeNone, "Return from the innermost expression evaluation." } | { LLDB_OPT_SET_ALL, false, "from-expression", 'x', OptionParser::eNoArgument, nullptr, {}, 0, eArgTypeNone, "Return from the innermost expression evaluation." } | ||||
// clang-format on | // clang-format on | ||||
}; | }; | ||||
▲ Show 20 Lines • Show All 528 Lines • ▼ Show 20 Lines | CommandObjectMultiwordThread::CommandObjectMultiwordThread( | ||||
LoadSubCommand("jump", | LoadSubCommand("jump", | ||||
CommandObjectSP(new CommandObjectThreadJump(interpreter))); | CommandObjectSP(new CommandObjectThreadJump(interpreter))); | ||||
LoadSubCommand("select", | LoadSubCommand("select", | ||||
CommandObjectSP(new CommandObjectThreadSelect(interpreter))); | CommandObjectSP(new CommandObjectThreadSelect(interpreter))); | ||||
LoadSubCommand("until", | LoadSubCommand("until", | ||||
CommandObjectSP(new CommandObjectThreadUntil(interpreter))); | CommandObjectSP(new CommandObjectThreadUntil(interpreter))); | ||||
LoadSubCommand("info", | LoadSubCommand("info", | ||||
CommandObjectSP(new CommandObjectThreadInfo(interpreter))); | CommandObjectSP(new CommandObjectThreadInfo(interpreter))); | ||||
LoadSubCommand( | |||||
"exception", | |||||
CommandObjectSP(new CommandObjectThreadException(interpreter))); | |||||
LoadSubCommand("step-in", | LoadSubCommand("step-in", | ||||
CommandObjectSP(new CommandObjectThreadStepWithTypeAndScope( | CommandObjectSP(new CommandObjectThreadStepWithTypeAndScope( | ||||
interpreter, "thread step-in", | interpreter, "thread step-in", | ||||
"Source level single step, stepping into calls. Defaults " | "Source level single step, stepping into calls. Defaults " | ||||
"to current thread unless specified.", | "to current thread unless specified.", | ||||
nullptr, eStepTypeInto, eStepScopeSource))); | nullptr, eStepTypeInto, eStepScopeSource))); | ||||
LoadSubCommand("step-out", | LoadSubCommand("step-out", | ||||
Show All 39 Lines |