There are now to new "settings set" variables that live in each debugger
instance:

settings set frame-format <string>
settings set thread-format <string>

This allows users to control the information that is seen when dumping
threads and frames. The default values are set such that they do what they
used to do prior to changing over the the user defined formats.

This allows users with terminals that can display color to make different
items different colors using the escape control codes. A few alias examples
that will colorize your thread and frame prompts are:

settings set frame-format 'frame #${frame.index}: \033[0;33m${frame.pc}\033[0m{ \033[1;4;36m${module.file.basename}\033[0;36m ${function.name}{${function.pc-offset}}\033[0m}{ \033[0;35mat \033[1;35m${line.file.basename}:${line.number}}\033[0m\n'

settings set thread-format 'thread #${thread.index}: \033[1;33mtid\033[0;33m = ${thread.id}\033[0m{, \033[0;33m${frame.pc}\033[0m}{ \033[1;4;36m${module.file.basename}\033[0;36m ${function.name}{${function.pc-offset}}\033[0m}{, \033[1;35mstop reason\033[0;35m = ${thread.stop-reason}\033[0m}{, \033[1;36mname = \033[0;36m${thread.name}\033[0m}{, \033[1;32mqueue = \033[0;32m${thread.queue}}\033[0m\n'

A quick web search for "colorize terminal output" should allow you to see what
you can do to make your output look like you want it.

The "settings set" commands above can of course be added to your ~/.lldbinit
file for permanent use.

Changed the pure virtual 
    void ExecutionContextScope::Calculate (ExecutionContext&);
To:
    void ExecutionContextScope::CalculateExecutionContext (ExecutionContext&);
    
I did this because this is a class that anything in the execution context
heirarchy inherits from and "target->Calculate (exe_ctx)" didn't always tell
you what it was really trying to do unless you look at the parameter.




git-svn-id: https://llvm.org/svn/llvm-project/llvdb/trunk@115485 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/source/Target/ExecutionContext.cpp b/source/Target/ExecutionContext.cpp
index 74ad50a..d0bcdac 100644
--- a/source/Target/ExecutionContext.cpp
+++ b/source/Target/ExecutionContext.cpp
@@ -59,7 +59,7 @@
 ExecutionContext::ExecutionContext (ExecutionContextScope *exe_scope_ptr)
 {
     if (exe_scope_ptr)
-        exe_scope_ptr->Calculate (*this);
+        exe_scope_ptr->CalculateExecutionContext (*this);
     else
     {
         target  = NULL;
@@ -71,7 +71,7 @@
 
 ExecutionContext::ExecutionContext (ExecutionContextScope &exe_scope_ref)
 {
-    exe_scope_ref.Calculate (*this);
+    exe_scope_ref.CalculateExecutionContext (*this);
 }
 
 void
diff --git a/source/Target/Process.cpp b/source/Target/Process.cpp
index 9086c15..3a65c52 100644
--- a/source/Target/Process.cpp
+++ b/source/Target/Process.cpp
@@ -1818,7 +1818,7 @@
 }
 
 void
-Process::Calculate (ExecutionContext &exe_ctx)
+Process::CalculateExecutionContext (ExecutionContext &exe_ctx)
 {
     exe_ctx.target = &m_target;
     exe_ctx.process = this;
diff --git a/source/Target/RegisterContext.cpp b/source/Target/RegisterContext.cpp
index 692fce0..b21890e 100644
--- a/source/Target/RegisterContext.cpp
+++ b/source/Target/RegisterContext.cpp
@@ -226,12 +226,12 @@
 }
 
 void
-RegisterContext::Calculate (ExecutionContext &exe_ctx)
+RegisterContext::CalculateExecutionContext (ExecutionContext &exe_ctx)
 {
     if (m_frame)
-        m_frame->Calculate (exe_ctx);
+        m_frame->CalculateExecutionContext (exe_ctx);
     else
-        m_thread.Calculate (exe_ctx);
+        m_thread.CalculateExecutionContext (exe_ctx);
 }
 
 
diff --git a/source/Target/StackFrame.cpp b/source/Target/StackFrame.cpp
index c7f2c04..2be00d6 100644
--- a/source/Target/StackFrame.cpp
+++ b/source/Target/StackFrame.cpp
@@ -14,6 +14,7 @@
 // Other libraries and framework includes
 // Project includes
 #include "lldb/Core/Module.h"
+#include "lldb/Core/Debugger.h"
 #include "lldb/Core/Disassembler.h"
 #include "lldb/Core/Value.h"
 #include "lldb/Core/ValueObjectVariable.h"
@@ -248,7 +249,7 @@
     if (m_disassembly.GetSize() == 0)
     {
         ExecutionContext exe_ctx;
-        Calculate(exe_ctx);
+        CalculateExecutionContext(exe_ctx);
         Target &target = m_thread.GetProcess().GetTarget();
         Disassembler::Disassemble (target.GetDebugger(),
                                    target.GetArchitecture(),
@@ -615,13 +616,36 @@
 
 
 void
-StackFrame::Calculate (ExecutionContext &exe_ctx)
+StackFrame::CalculateExecutionContext (ExecutionContext &exe_ctx)
 {
-    m_thread.Calculate (exe_ctx);
+    m_thread.CalculateExecutionContext (exe_ctx);
     exe_ctx.frame = this;
 }
 
 void
+StackFrame::DumpUsingSettingsFormat (Stream *strm)
+{
+    if (strm == NULL)
+        return;
+
+    GetSymbolContext(eSymbolContextEverything);
+    ExecutionContext exe_ctx;
+    CalculateExecutionContext(exe_ctx);
+    const char *end = NULL;
+    StreamString s;
+    const char *frame_format = m_thread.GetProcess().GetTarget().GetDebugger().GetFrameFormat();
+    if (frame_format && Debugger::FormatPrompt (frame_format, &m_sc, &exe_ctx, NULL, s, &end))
+    {
+        strm->Write(s.GetData(), s.GetSize());
+    }
+    else
+    {
+        Dump (strm, true, false);
+        strm->EOL();
+    }
+}
+
+void
 StackFrame::Dump (Stream *strm, bool show_frame_index, bool show_fullpaths)
 {
     if (strm == NULL)
diff --git a/source/Target/StackFrameList.cpp b/source/Target/StackFrameList.cpp
index c6ac2de..2dd5fb8 100644
--- a/source/Target/StackFrameList.cpp
+++ b/source/Target/StackFrameList.cpp
@@ -260,7 +260,7 @@
         if (frame)
         {
             frame->GetStackID().Dump (s);
-            frame->Dump(s, true, false);
+            frame->DumpUsingSettingsFormat (s);
         }
         else
             s->Printf("frame #%u", std::distance (begin, pos));
diff --git a/source/Target/StopInfo.cpp b/source/Target/StopInfo.cpp
index d301cc1..49f0792 100644
--- a/source/Target/StopInfo.cpp
+++ b/source/Target/StopInfo.cpp
@@ -276,9 +276,9 @@
             StreamString strm;
             const char *signal_name = m_thread.GetProcess().GetUnixSignals().GetSignalAsCString (m_value);
             if (signal_name)
-                strm.Printf("signal = %s", signal_name);
+                strm.Printf("signal %s", signal_name);
             else
-                strm.Printf("signal = %lli", m_value);
+                strm.Printf("signal %lli", m_value);
             m_description.swap (strm.GetString());
         }
         return m_description.c_str();
diff --git a/source/Target/Target.cpp b/source/Target/Target.cpp
index bbc41be..f8e54ae 100644
--- a/source/Target/Target.cpp
+++ b/source/Target/Target.cpp
@@ -708,7 +708,7 @@
 }
 
 void
-Target::Calculate (ExecutionContext &exe_ctx)
+Target::CalculateExecutionContext (ExecutionContext &exe_ctx)
 {
     exe_ctx.target = this;
     exe_ctx.process = NULL; // Do NOT fill in process...
@@ -794,6 +794,25 @@
                                                        lldb::eVarSetOperationAssign, false, "[]");
 }
 
+Target *
+Target::GetTargetFromContexts (const ExecutionContext *exe_ctx_ptr, const SymbolContext *sc_ptr)
+{
+    // The target can either exist in the "process" of ExecutionContext, or in 
+    // the "target_sp" member of SymbolContext. This accessor helper function
+    // will get the target from one of these locations.
+
+    Target *target = NULL;
+    if (sc_ptr != NULL)
+        target = sc_ptr->target_sp.get();
+    if (target == NULL)
+    {
+        if (exe_ctx_ptr != NULL && exe_ctx_ptr->process != NULL)
+            target = &exe_ctx_ptr->process->GetTarget();
+    }
+    return target;
+}
+
+
 void
 Target::UpdateInstanceName ()
 {
diff --git a/source/Target/Thread.cpp b/source/Target/Thread.cpp
index fb4ad9a..d45f45c 100644
--- a/source/Target/Thread.cpp
+++ b/source/Target/Thread.cpp
@@ -9,6 +9,7 @@
 
 #include "lldb/lldb-private-log.h"
 #include "lldb/Breakpoint/BreakpointLocation.h"
+#include "lldb/Core/Debugger.h"
 #include "lldb/Core/Log.h"
 #include "lldb/Core/Stream.h"
 #include "lldb/Core/StreamString.h"
@@ -810,9 +811,9 @@
 }
 
 void
-Thread::Calculate (ExecutionContext &exe_ctx)
+Thread::CalculateExecutionContext (ExecutionContext &exe_ctx)
 {
-    m_process.Calculate (exe_ctx);
+    m_process.CalculateExecutionContext (exe_ctx);
     exe_ctx.thread = this;
     exe_ctx.frame = NULL;
 }
@@ -872,52 +873,31 @@
 }
 
 void
-Thread::DumpInfo
-(
-    Stream &strm,
-    bool show_stop_reason,
-    bool show_name,
-    bool show_queue,
-    uint32_t idx
-)
+Thread::DumpUsingSettingsFormat (Stream &strm, uint32_t frame_idx)
 {
-    strm.Printf("thread #%u: tid = 0x%4.4x", GetIndexID(), GetID());
+    ExecutionContext exe_ctx;
+    SymbolContext frame_sc;
+    CalculateExecutionContext (exe_ctx);
 
-    if (idx != LLDB_INVALID_INDEX32)
+    if (frame_idx != LLDB_INVALID_INDEX32)
     {
-        StackFrameSP frame_sp(GetStackFrameAtIndex (idx));
+        StackFrameSP frame_sp(GetStackFrameAtIndex (frame_idx));
         if (frame_sp)
         {
-            strm.PutCString(", ");
-            frame_sp->Dump (&strm, false, false);
+            exe_ctx.frame = frame_sp.get();
+            frame_sc = exe_ctx.frame->GetSymbolContext(eSymbolContextEverything);
         }
     }
 
-    if (show_stop_reason)
-    {
-        StopInfo *stop_info = GetStopInfo();
-        
-        if (stop_info)
-        {
-            const char *stop_description = stop_info->GetDescription();
-            if (stop_description)
-                strm.Printf (", stop reason = %s", stop_description);
-        }
-    }
-
-    if (show_name)
-    {
-        const char *name = GetName();
-        if (name && name[0])
-            strm.Printf(", name = %s", name);
-    }
-
-    if (show_queue)
-    {
-        const char *queue = GetQueueName();
-        if (queue && queue[0])
-            strm.Printf(", queue = %s", queue);
-    }
+    const char *thread_format = GetProcess().GetTarget().GetDebugger().GetThreadFormat();
+    assert (thread_format);
+    const char *end = NULL;
+    Debugger::FormatPrompt (thread_format, 
+                            exe_ctx.frame ? &frame_sc : NULL,
+                            &exe_ctx, 
+                            NULL,
+                            strm, 
+                            &end);
 }
 
 lldb::ThreadSP