Initial merge of some of the iOS 8 / Mac OS X Yosemite specific

lldb support.  I'll be doing more testing & cleanup but I wanted to
get the initial checkin done.

This adds a new SBExpressionOptions::SetLanguage API for selecting a
language of an expression.

I added adds a new SBThread::GetInfoItemByPathString for retriving
information about a thread from that thread's StructuredData.

I added a new StructuredData class for representing
key-value/array/dictionary information (e.g. JSON formatted data).
Helper functions to read JSON and create a StructuredData object,
and to print a StructuredData object in JSON format are included.

A few Cocoa / Cocoa Touch data formatters were updated by Enrico
to track changes in iOS 8 / Yosemite.

Before we query a thread's extended information, the system runtime may 
provide hints to the remote debug stub that it will use to retrieve values
out of runtime structures.  I added a new SystemRuntime method 
AddThreadExtendedInfoPacketHints which allows the SystemRuntime to add 
key-value type data to the initial request that we send to the remote stub.

The thread-format formatter string can now retrieve values out of a thread's
extended info structured data.  The default thread-format string picks up
two of these - thread.info.activity.name and thread.info.trace_messages.

I added a new "jThreadExtendedInfo" packet in debugserver; I will
add documentation to the lldb-gdb-remote.txt doc soon.  It accepts
JSON formatted arguments (most importantly, "thread":threadnum) and
it returns a variety of information regarding the thread to lldb
in JSON format.  This JSON return is scanned into a StructuredData
object that is associated with the thread; UI layers can query the
thread's StructuredData to see if key-values are present, and if
so, show them to the user.  These key-values are likely to be
specific to different targets with some commonality among many
targets.  For instance, many targets will be able to advertise the
pthread_t value for a thread.

I added an initial rough cut of "thread info" command which will print
the information about a thread from the jThreadExtendedInfo result.
I need to do more work to make this format reasonably.

Han Ming added calls into the pmenergy and pmsample libraries if
debugserver is run on Mac OS X Yosemite to get information about the
inferior's power use.

I added support to debugserver for gathering the Genealogy information
about threads, if it exists, and returning it in the jThreadExtendedInfo
JSON result.

llvm-svn: 210874
This commit is contained in:
Jason Molenda
2014-06-13 02:37:02 +00:00
parent b4ad29be92
commit 705b180964
47 changed files with 3648 additions and 288 deletions

View File

@@ -292,7 +292,9 @@ Thread::Thread (Process &process, lldb::tid_t tid, bool use_invalid_index_id) :
m_temporary_resume_state (eStateRunning),
m_unwinder_ap (),
m_destroy_called (false),
m_override_should_notify (eLazyBoolCalculate)
m_override_should_notify (eLazyBoolCalculate),
m_extended_info_fetched (false),
m_extended_info ()
{
Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_OBJECT));
if (log)
@@ -1709,6 +1711,9 @@ Thread::ClearStackFrames ()
if (m_curr_frames_sp && m_curr_frames_sp->GetAllFramesFetched())
m_prev_frames_sp.swap (m_curr_frames_sp);
m_curr_frames_sp.reset();
m_extended_info.reset();
m_extended_info_fetched = false;
}
lldb::StackFrameSP
@@ -2068,6 +2073,82 @@ Thread::GetStatus (Stream &strm, uint32_t start_frame, uint32_t num_frames, uint
return num_frames_shown;
}
bool
Thread::GetDescription (Stream &strm, lldb::DescriptionLevel level, bool print_json)
{
DumpUsingSettingsFormat (strm, 0);
strm.Printf("\n");
StructuredData::ObjectSP thread_info = GetExtendedInfo();
if (thread_info && print_json)
{
thread_info->Dump (strm);
strm.Printf("\n");
return true;
}
if (thread_info)
{
StructuredData::ObjectSP activity = thread_info->GetObjectForDotSeparatedPath("activity");
StructuredData::ObjectSP breadcrumb = thread_info->GetObjectForDotSeparatedPath("breadcrumb");
StructuredData::ObjectSP messages = thread_info->GetObjectForDotSeparatedPath("trace_messages");
bool printed_activity = false;
if (activity && activity->GetType() == StructuredData::Type::eTypeDictionary)
{
StructuredData::Dictionary *activity_dict = activity->GetAsDictionary();
StructuredData::ObjectSP id = activity_dict->GetValueForKey("id");
StructuredData::ObjectSP name = activity_dict->GetValueForKey("name");
if (name && name->GetType() == StructuredData::Type::eTypeString
&& id && id->GetType() == StructuredData::Type::eTypeInteger)
{
strm.Printf(" Activity '%s', 0x%" PRIx64 "\n", name->GetAsString()->GetValue().c_str(), id->GetAsInteger()->GetValue());
}
printed_activity = true;
}
bool printed_breadcrumb = false;
if (breadcrumb && breadcrumb->GetType() == StructuredData::Type::eTypeDictionary)
{
if (printed_activity)
strm.Printf ("\n");
StructuredData::Dictionary *breadcrumb_dict = breadcrumb->GetAsDictionary();
StructuredData::ObjectSP breadcrumb_text = breadcrumb_dict->GetValueForKey ("name");
if (breadcrumb_text && breadcrumb_text->GetType() == StructuredData::Type::eTypeString)
{
strm.Printf (" Current Breadcrumb: %s\n", breadcrumb_text->GetAsString()->GetValue().c_str());
}
printed_breadcrumb = true;
}
if (messages && messages->GetType() == StructuredData::Type::eTypeArray)
{
if (printed_breadcrumb)
strm.Printf("\n");
StructuredData::Array *messages_array = messages->GetAsArray();
const size_t msg_count = messages_array->GetSize();
if (msg_count > 0)
{
strm.Printf (" %zu trace messages:\n", msg_count);
for (size_t i = 0; i < msg_count; i++)
{
StructuredData::ObjectSP message = messages_array->GetItemAtIndex(i);
if (message && message->GetType() == StructuredData::Type::eTypeDictionary)
{
StructuredData::Dictionary *message_dict = message->GetAsDictionary();
StructuredData::ObjectSP message_text = message_dict->GetValueForKey ("message");
if (message_text && message_text->GetType() == StructuredData::Type::eTypeString)
{
strm.Printf (" %s\n", message_text->GetAsString()->GetValue().c_str());
}
}
}
}
}
}
return true;
}
size_t
Thread::GetStackFrameStatus (Stream& strm,
uint32_t first_frame,