diff options
author | Jason Molenda <jmolenda@apple.com> | 2013-11-12 07:02:07 +0000 |
---|---|---|
committer | Jason Molenda <jmolenda@apple.com> | 2013-11-12 07:02:07 +0000 |
commit | 750ea692e83bd84797eb357316a41af9acc41b8b (patch) | |
tree | 490491909c95efa2dbf5b5c33062e252d4937e3f /lldb/source/Commands/CommandObjectThread.cpp | |
parent | b9a29f2782313ef6b73c772f0095c1f6e1f8b2c8 (diff) | |
download | bcm5719-llvm-750ea692e83bd84797eb357316a41af9acc41b8b.tar.gz bcm5719-llvm-750ea692e83bd84797eb357316a41af9acc41b8b.zip |
Add initial --extended / -e support to thread backtrace.
llvm-svn: 194455
Diffstat (limited to 'lldb/source/Commands/CommandObjectThread.cpp')
-rw-r--r-- | lldb/source/Commands/CommandObjectThread.cpp | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/lldb/source/Commands/CommandObjectThread.cpp b/lldb/source/Commands/CommandObjectThread.cpp index 3dce83c48d0..bfe9541154a 100644 --- a/lldb/source/Commands/CommandObjectThread.cpp +++ b/lldb/source/Commands/CommandObjectThread.cpp @@ -28,6 +28,7 @@ #include "lldb/Symbol/LineEntry.h" #include "lldb/Target/Process.h" #include "lldb/Target/RegisterContext.h" +#include "lldb/Target/SystemRuntime.h" #include "lldb/Target/Target.h" #include "lldb/Target/Thread.h" #include "lldb/Target/ThreadPlan.h" @@ -92,6 +93,13 @@ public: if (!success) error.SetErrorStringWithFormat("invalid integer value for option '%c'", short_option); } + case 'e': + { + bool success; + m_extended_backtrace = Args::StringToBoolean (option_arg, false, &success); + if (!success) + error.SetErrorStringWithFormat("invalid boolean value for option '%c'", short_option); + } break; default: error.SetErrorStringWithFormat("invalid short option character '%c'", short_option); @@ -106,6 +114,7 @@ public: { m_count = UINT32_MAX; m_start = 0; + m_extended_backtrace = false; } const OptionDefinition* @@ -121,6 +130,7 @@ public: // Instance variables to hold the values for command options. uint32_t m_count; uint32_t m_start; + bool m_extended_backtrace; }; CommandObjectThreadBacktrace (CommandInterpreter &interpreter) : @@ -160,6 +170,32 @@ public: } protected: + void + DoExtendedBacktrace (Thread *thread, CommandReturnObject &result) + { + SystemRuntime *runtime = thread->GetProcess()->GetSystemRuntime(); + if (runtime) + { + Stream &strm = result.GetOutputStream(); + const std::vector<ConstString> &types = runtime->GetExtendedBacktraceTypes(); + for (auto type : types) + { + ThreadSP ext_thread_sp = runtime->GetExtendedBacktrace (thread->shared_from_this(), type); + if (ext_thread_sp && ext_thread_sp->IsValid ()) + { + const uint32_t num_frames_with_source = 0; + if (ext_thread_sp->GetStatus (strm, + m_options.m_start, + m_options.m_count, + num_frames_with_source)) + { + DoExtendedBacktrace (ext_thread_sp.get(), result); + } + } + } + } + } + virtual bool DoExecute (Args& command, CommandReturnObject &result) { @@ -178,6 +214,10 @@ protected: num_frames_with_source)) { result.SetStatus (eReturnStatusSuccessFinishResult); + if (m_options.m_extended_backtrace) + { + DoExtendedBacktrace (thread, result); + } } } else if (command.GetArgumentCount() == 1 && ::strcmp (command.GetArgumentAtIndex(0), "all") == 0) @@ -198,6 +238,10 @@ protected: result.SetStatus (eReturnStatusFailed); return false; } + if (m_options.m_extended_backtrace) + { + DoExtendedBacktrace (thread_sp.get(), result); + } ++idx; } @@ -243,6 +287,10 @@ protected: result.SetStatus (eReturnStatusFailed); return false; } + if (m_options.m_extended_backtrace) + { + DoExtendedBacktrace (thread_sps[i].get(), result); + } if (i < num_args - 1) result.AppendMessage(""); @@ -259,6 +307,7 @@ CommandObjectThreadBacktrace::CommandOptions::g_option_table[] = { { LLDB_OPT_SET_1, false, "count", 'c', OptionParser::eRequiredArgument, NULL, 0, eArgTypeCount, "How many frames to display (-1 for all)"}, { LLDB_OPT_SET_1, false, "start", 's', OptionParser::eRequiredArgument, NULL, 0, eArgTypeFrameIndex, "Frame in which to start the backtrace"}, +{ LLDB_OPT_SET_1, false, "extended", 'e', OptionParser::eRequiredArgument, NULL, 0, eArgTypeBoolean, "Show the extended backtrace, if available"}, { 0, false, NULL, 0, 0, NULL, 0, eArgTypeNone, NULL } }; |