[llvm-branch-commits] [lldb] r183468 - Update platform branch with top of tree.

Greg Clayton gclayton at apple.com
Thu Jun 6 17:08:08 PDT 2013


Modified: lldb/branches/lldb-platform-work/source/Core/Debugger.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/lldb-platform-work/source/Core/Debugger.cpp?rev=183468&r1=183467&r2=183468&view=diff
==============================================================================
--- lldb/branches/lldb-platform-work/source/Core/Debugger.cpp (original)
+++ lldb/branches/lldb-platform-work/source/Core/Debugger.cpp Thu Jun  6 19:06:43 2013
@@ -7,6 +7,10 @@
 //
 //===----------------------------------------------------------------------===//
 
+#include "lldb/lldb-python.h"
+
+#include "lldb/API/SBDebugger.h"
+
 #include "lldb/Core/Debugger.h"
 
 #include <map>
@@ -16,9 +20,9 @@
 
 #include "lldb/lldb-private.h"
 #include "lldb/Core/ConnectionFileDescriptor.h"
-#include "lldb/Core/DataVisualization.h"
-#include "lldb/Core/FormatManager.h"
 #include "lldb/Core/InputReader.h"
+#include "lldb/Core/Module.h"
+#include "lldb/Core/PluginManager.h"
 #include "lldb/Core/RegisterValue.h"
 #include "lldb/Core/State.h"
 #include "lldb/Core/StreamAsynchronousIO.h"
@@ -27,13 +31,23 @@
 #include "lldb/Core/Timer.h"
 #include "lldb/Core/ValueObject.h"
 #include "lldb/Core/ValueObjectVariable.h"
+#include "lldb/DataFormatters/DataVisualization.h"
+#include "lldb/DataFormatters/FormatManager.h"
+#include "lldb/Host/DynamicLibrary.h"
 #include "lldb/Host/Terminal.h"
 #include "lldb/Interpreter/CommandInterpreter.h"
+#include "lldb/Interpreter/OptionValueSInt64.h"
+#include "lldb/Interpreter/OptionValueString.h"
+#include "lldb/Symbol/ClangASTContext.h"
+#include "lldb/Symbol/CompileUnit.h"
+#include "lldb/Symbol/Function.h"
+#include "lldb/Symbol/Symbol.h"
 #include "lldb/Symbol/VariableList.h"
 #include "lldb/Target/TargetList.h"
 #include "lldb/Target/Process.h"
 #include "lldb/Target/RegisterContext.h"
 #include "lldb/Target/StopInfo.h"
+#include "lldb/Target/Target.h"
 #include "lldb/Target/Thread.h"
 #include "lldb/Utility/AnsiTerminal.h"
 
@@ -64,124 +78,284 @@ GetDebuggerList()
     return g_list;
 }
 
+OptionEnumValueElement
+g_show_disassembly_enum_values[] =
+{
+    { Debugger::eStopDisassemblyTypeNever,    "never",     "Never show disassembly when displaying a stop context."},
+    { Debugger::eStopDisassemblyTypeNoSource, "no-source", "Show disassembly when there is no source information, or the source file is missing when displaying a stop context."},
+    { Debugger::eStopDisassemblyTypeAlways,   "always",    "Always show disassembly when displaying a stop context."},
+    { 0, NULL, NULL }
+};
+
+OptionEnumValueElement
+g_language_enumerators[] =
+{
+    { eScriptLanguageNone,      "none",     "Disable scripting languages."},
+    { eScriptLanguagePython,    "python",   "Select python as the default scripting language."},
+    { eScriptLanguageDefault,   "default",  "Select the lldb default as the default scripting language."},
+    { 0, NULL, NULL }
+};
+
+#define MODULE_WITH_FUNC "{ ${module.file.basename}{`${function.name-with-args}${function.pc-offset}}}"
+#define FILE_AND_LINE "{ at ${line.file.basename}:${line.number}}"
+
+#define DEFAULT_THREAD_FORMAT "thread #${thread.index}: tid = ${thread.id}"\
+    "{, ${frame.pc}}"\
+    MODULE_WITH_FUNC\
+    FILE_AND_LINE\
+    "{, name = '${thread.name}}"\
+    "{, queue = '${thread.queue}}"\
+    "{, stop reason = ${thread.stop-reason}}"\
+    "{\\nReturn value: ${thread.return-value}}"\
+    "\\n"
+
+#define DEFAULT_FRAME_FORMAT "frame #${frame.index}: ${frame.pc}"\
+    MODULE_WITH_FUNC\
+    FILE_AND_LINE\
+    "\\n"
+
+
 
-static const ConstString &
-PromptVarName ()
+static PropertyDefinition
+g_properties[] =
 {
-    static ConstString g_const_string ("prompt");
-    return g_const_string;
+{   "auto-confirm",             OptionValue::eTypeBoolean, true, false, NULL, NULL, "If true all confirmation prompts will receive their default reply." },
+{   "frame-format",             OptionValue::eTypeString , true, 0    , DEFAULT_FRAME_FORMAT, NULL, "The default frame format string to use when displaying stack frame information for threads." },
+{   "notify-void",              OptionValue::eTypeBoolean, true, false, NULL, NULL, "Notify the user explicitly if an expression returns void (default: false)." },
+{   "prompt",                   OptionValue::eTypeString , true, OptionValueString::eOptionEncodeCharacterEscapeSequences, "(lldb) ", NULL, "The debugger command line prompt displayed for the user." },
+{   "script-lang",              OptionValue::eTypeEnum   , true, eScriptLanguagePython, NULL, g_language_enumerators, "The script language to be used for evaluating user-written scripts." },
+{   "stop-disassembly-count",   OptionValue::eTypeSInt64 , true, 4    , NULL, NULL, "The number of disassembly lines to show when displaying a stopped context." },
+{   "stop-disassembly-display", OptionValue::eTypeEnum   , true, Debugger::eStopDisassemblyTypeNoSource, NULL, g_show_disassembly_enum_values, "Control when to display disassembly when displaying a stopped context." },
+{   "stop-line-count-after",    OptionValue::eTypeSInt64 , true, 3    , NULL, NULL, "The number of sources lines to display that come after the current source line when displaying a stopped context." },
+{   "stop-line-count-before",   OptionValue::eTypeSInt64 , true, 3    , NULL, NULL, "The number of sources lines to display that come before the current source line when displaying a stopped context." },
+{   "term-width",               OptionValue::eTypeSInt64 , true, 80   , NULL, NULL, "The maximum number of columns to use for displaying text." },
+{   "thread-format",            OptionValue::eTypeString , true, 0    , DEFAULT_THREAD_FORMAT, NULL, "The default thread format string to use when displaying thread information." },
+{   "use-external-editor",      OptionValue::eTypeBoolean, true, false, NULL, NULL, "Whether to use an external editor or not." },
+{   "use-color",                OptionValue::eTypeBoolean, true, true , NULL, NULL, "Whether to use Ansi color codes or not." },
+
+    {   NULL,                       OptionValue::eTypeInvalid, true, 0    , NULL, NULL, NULL }
+};
+
+enum
+{
+    ePropertyAutoConfirm = 0,
+    ePropertyFrameFormat,
+    ePropertyNotiftVoid,
+    ePropertyPrompt,
+    ePropertyScriptLanguage,
+    ePropertyStopDisassemblyCount,
+    ePropertyStopDisassemblyDisplay,
+    ePropertyStopLineCountAfter,
+    ePropertyStopLineCountBefore,
+    ePropertyTerminalWidth,
+    ePropertyThreadFormat,
+    ePropertyUseExternalEditor,
+    ePropertyUseColor,
+};
+
+//
+//const char *
+//Debugger::GetFrameFormat() const
+//{
+//    return m_properties_sp->GetFrameFormat();
+//}
+//const char *
+//Debugger::GetThreadFormat() const
+//{
+//    return m_properties_sp->GetThreadFormat();
+//}
+//
+
+
+Error
+Debugger::SetPropertyValue (const ExecutionContext *exe_ctx,
+                            VarSetOperationType op,
+                            const char *property_path,
+                            const char *value)
+{
+    bool is_load_script = strcmp(property_path,"target.load-script-from-symbol-file") == 0;
+    TargetSP target_sp;
+    LoadScriptFromSymFile load_script_old_value;
+    if (is_load_script && exe_ctx->GetTargetSP())
+    {
+        target_sp = exe_ctx->GetTargetSP();
+        load_script_old_value = target_sp->TargetProperties::GetLoadScriptFromSymbolFile();
+    }
+    Error error (Properties::SetPropertyValue (exe_ctx, op, property_path, value));
+    if (error.Success())
+    {
+        // FIXME it would be nice to have "on-change" callbacks for properties
+        if (strcmp(property_path, g_properties[ePropertyPrompt].name) == 0)
+        {
+            const char *new_prompt = GetPrompt();
+            std::string str = lldb_utility::ansi::FormatAnsiTerminalCodes (new_prompt, GetUseColor());
+            if (str.length())
+                new_prompt = str.c_str();
+            EventSP prompt_change_event_sp (new Event(CommandInterpreter::eBroadcastBitResetPrompt, new EventDataBytes (new_prompt)));
+            GetCommandInterpreter().BroadcastEvent (prompt_change_event_sp);
+        }
+        else if (strcmp(property_path, g_properties[ePropertyUseColor].name) == 0)
+        {
+			// use-color changed. Ping the prompt so it can reset the ansi terminal codes.
+            SetPrompt (GetPrompt());
+        }
+        else if (is_load_script && target_sp && load_script_old_value == eLoadScriptFromSymFileWarn)
+        {
+            if (target_sp->TargetProperties::GetLoadScriptFromSymbolFile() == eLoadScriptFromSymFileTrue)
+            {
+                std::list<Error> errors;
+                StreamString feedback_stream;
+                if (!target_sp->LoadScriptingResources(errors,&feedback_stream))
+                {
+                    for (auto error : errors)
+                    {
+                        GetErrorStream().Printf("%s\n",error.AsCString());
+                    }
+                    if (feedback_stream.GetSize())
+                        GetErrorStream().Printf("%s",feedback_stream.GetData());
+                }
+            }
+        }
+    }
+    return error;
 }
 
-static const ConstString &
-GetNotifyVoidName ()
+bool
+Debugger::GetAutoConfirm () const
 {
-    static ConstString g_const_string ("notify-void");
-    return g_const_string;
+    const uint32_t idx = ePropertyAutoConfirm;
+    return m_collection_sp->GetPropertyAtIndexAsBoolean (NULL, idx, g_properties[idx].default_uint_value != 0);
 }
 
-static const ConstString &
-GetFrameFormatName ()
+const char *
+Debugger::GetFrameFormat() const
 {
-    static ConstString g_const_string ("frame-format");
-    return g_const_string;
+    const uint32_t idx = ePropertyFrameFormat;
+    return m_collection_sp->GetPropertyAtIndexAsString (NULL, idx, g_properties[idx].default_cstr_value);
 }
 
-static const ConstString &
-GetThreadFormatName ()
+bool
+Debugger::GetNotifyVoid () const
 {
-    static ConstString g_const_string ("thread-format");
-    return g_const_string;
+    const uint32_t idx = ePropertyNotiftVoid;
+    return m_collection_sp->GetPropertyAtIndexAsBoolean (NULL, idx, g_properties[idx].default_uint_value != 0);
 }
 
-static const ConstString &
-ScriptLangVarName ()
+const char *
+Debugger::GetPrompt() const
 {
-    static ConstString g_const_string ("script-lang");
-    return g_const_string;
+    const uint32_t idx = ePropertyPrompt;
+    return m_collection_sp->GetPropertyAtIndexAsString (NULL, idx, g_properties[idx].default_cstr_value);
 }
 
-static const ConstString &
-TermWidthVarName ()
+void
+Debugger::SetPrompt(const char *p)
 {
-    static ConstString g_const_string ("term-width");
-    return g_const_string;
+    const uint32_t idx = ePropertyPrompt;
+    m_collection_sp->SetPropertyAtIndexAsString (NULL, idx, p);
+    const char *new_prompt = GetPrompt();
+    std::string str = lldb_utility::ansi::FormatAnsiTerminalCodes (new_prompt, GetUseColor());
+    if (str.length())
+        new_prompt = str.c_str();
+    EventSP prompt_change_event_sp (new Event(CommandInterpreter::eBroadcastBitResetPrompt, new EventDataBytes (new_prompt)));;
+    GetCommandInterpreter().BroadcastEvent (prompt_change_event_sp);
 }
 
-static const ConstString &
-UseExternalEditorVarName ()
+const char *
+Debugger::GetThreadFormat() const
 {
-    static ConstString g_const_string ("use-external-editor");
-    return g_const_string;
+    const uint32_t idx = ePropertyThreadFormat;
+    return m_collection_sp->GetPropertyAtIndexAsString (NULL, idx, g_properties[idx].default_cstr_value);
 }
 
-static const ConstString &
-AutoConfirmName ()
+lldb::ScriptLanguage
+Debugger::GetScriptLanguage() const
 {
-    static ConstString g_const_string ("auto-confirm");
-    return g_const_string;
+    const uint32_t idx = ePropertyScriptLanguage;
+    return (lldb::ScriptLanguage)m_collection_sp->GetPropertyAtIndexAsEnumeration (NULL, idx, g_properties[idx].default_uint_value);
 }
 
-static const ConstString &
-StopSourceContextBeforeName ()
+bool
+Debugger::SetScriptLanguage (lldb::ScriptLanguage script_lang)
 {
-    static ConstString g_const_string ("stop-line-count-before");
-    return g_const_string;
+    const uint32_t idx = ePropertyScriptLanguage;
+    return m_collection_sp->SetPropertyAtIndexAsEnumeration (NULL, idx, script_lang);
 }
 
-static const ConstString &
-StopSourceContextAfterName ()
+uint32_t
+Debugger::GetTerminalWidth () const
 {
-    static ConstString g_const_string ("stop-line-count-after");
-    return g_const_string;
+    const uint32_t idx = ePropertyTerminalWidth;
+    return m_collection_sp->GetPropertyAtIndexAsSInt64 (NULL, idx, g_properties[idx].default_uint_value);
 }
 
-static const ConstString &
-StopDisassemblyCountName ()
+bool
+Debugger::SetTerminalWidth (uint32_t term_width)
 {
-    static ConstString g_const_string ("stop-disassembly-count");
-    return g_const_string;
+    const uint32_t idx = ePropertyTerminalWidth;
+    return m_collection_sp->SetPropertyAtIndexAsSInt64 (NULL, idx, term_width);
 }
 
-static const ConstString &
-StopDisassemblyDisplayName ()
+bool
+Debugger::GetUseExternalEditor () const
 {
-    static ConstString g_const_string ("stop-disassembly-display");
-    return g_const_string;
+    const uint32_t idx = ePropertyUseExternalEditor;
+    return m_collection_sp->GetPropertyAtIndexAsBoolean (NULL, idx, g_properties[idx].default_uint_value != 0);
 }
 
-OptionEnumValueElement
-DebuggerInstanceSettings::g_show_disassembly_enum_values[] =
+bool
+Debugger::SetUseExternalEditor (bool b)
 {
-    { eStopDisassemblyTypeNever,    "never",     "Never show disassembly when displaying a stop context."},
-    { eStopDisassemblyTypeNoSource, "no-source", "Show disassembly when there is no source information, or the source file is missing when displaying a stop context."},
-    { eStopDisassemblyTypeAlways,   "always",    "Always show disassembly when displaying a stop context."},
-    { 0, NULL, NULL }
-};
+    const uint32_t idx = ePropertyUseExternalEditor;
+    return m_collection_sp->SetPropertyAtIndexAsBoolean (NULL, idx, b);
+}
 
+bool
+Debugger::GetUseColor () const
+{
+    const uint32_t idx = ePropertyUseColor;
+    return m_collection_sp->GetPropertyAtIndexAsBoolean (NULL, idx, g_properties[idx].default_uint_value != 0);
+}
 
+bool
+Debugger::SetUseColor (bool b)
+{
+    const uint32_t idx = ePropertyUseColor;
+    bool ret = m_collection_sp->SetPropertyAtIndexAsBoolean (NULL, idx, b);
+    SetPrompt (GetPrompt());
+    return ret;
+}
 
-#pragma mark Debugger
+uint32_t
+Debugger::GetStopSourceLineCount (bool before) const
+{
+    const uint32_t idx = before ? ePropertyStopLineCountBefore : ePropertyStopLineCountAfter;
+    return m_collection_sp->GetPropertyAtIndexAsSInt64 (NULL, idx, g_properties[idx].default_uint_value);
+}
 
-UserSettingsControllerSP &
-Debugger::GetSettingsController ()
+Debugger::StopDisassemblyType
+Debugger::GetStopDisassemblyDisplay () const
 {
-    static UserSettingsControllerSP g_settings_controller_sp;
-    if (!g_settings_controller_sp)
-    {
-        g_settings_controller_sp.reset (new Debugger::SettingsController);
-    
-        // The first shared pointer to Debugger::SettingsController in
-        // g_settings_controller_sp must be fully created above so that 
-        // the DebuggerInstanceSettings can use a weak_ptr to refer back 
-        // to the master setttings controller
-        InstanceSettingsSP default_instance_settings_sp (new DebuggerInstanceSettings (g_settings_controller_sp, 
-                                                                                       false, 
-                                                                                       InstanceSettings::GetDefaultName().AsCString()));
-        g_settings_controller_sp->SetDefaultInstanceSettings (default_instance_settings_sp);
-    }
-    return g_settings_controller_sp;
+    const uint32_t idx = ePropertyStopDisassemblyDisplay;
+    return (Debugger::StopDisassemblyType)m_collection_sp->GetPropertyAtIndexAsEnumeration (NULL, idx, g_properties[idx].default_uint_value);
 }
 
+uint32_t
+Debugger::GetDisassemblyLineCount () const
+{
+    const uint32_t idx = ePropertyStopDisassemblyCount;
+    return m_collection_sp->GetPropertyAtIndexAsSInt64 (NULL, idx, g_properties[idx].default_uint_value);
+}
+
+#pragma mark Debugger
+
+//const DebuggerPropertiesSP &
+//Debugger::GetSettings() const
+//{
+//    return m_properties_sp;
+//}
+//
+
 int
 Debugger::TestDebuggerRefCount ()
 {
@@ -216,33 +390,131 @@ Debugger::Terminate ()
 void
 Debugger::SettingsInitialize ()
 {
-    static bool g_initialized = false;
-    
-    if (!g_initialized)
-    {
-        g_initialized = true;
-        UserSettingsController::InitializeSettingsController (GetSettingsController(),
-                                                              SettingsController::global_settings_table,
-                                                              SettingsController::instance_settings_table);
-        // Now call SettingsInitialize for each settings 'child' of Debugger
-        Target::SettingsInitialize ();
-    }
+    Target::SettingsInitialize ();
 }
 
 void
 Debugger::SettingsTerminate ()
 {
+    Target::SettingsTerminate ();
+}
 
-    // Must call SettingsTerminate() for each settings 'child' of Debugger, before terminating the Debugger's 
-    // Settings.
+bool
+Debugger::LoadPlugin (const FileSpec& spec, Error& error)
+{
+    lldb::DynamicLibrarySP dynlib_sp(new lldb_private::DynamicLibrary(spec));
+    if (!dynlib_sp || dynlib_sp->IsValid() == false)
+    {
+        if (spec.Exists())
+            error.SetErrorString("this file does not represent a loadable dylib");
+        else
+            error.SetErrorString("no such file");
+        return false;
+    }
+    lldb::DebuggerSP debugger_sp(shared_from_this());
+    lldb::SBDebugger debugger_sb(debugger_sp);
+    // TODO: mangle this differently for your system - on OSX, the first underscore needs to be removed and the second one stays
+    LLDBCommandPluginInit init_func = dynlib_sp->GetSymbol<LLDBCommandPluginInit>("_ZN4lldb16PluginInitializeENS_10SBDebuggerE");
+    if (!init_func)
+    {
+        error.SetErrorString("cannot find the initialization function lldb::PluginInitialize(lldb::SBDebugger)");
+        return false;
+    }
+    if (init_func(debugger_sb))
+    {
+        m_loaded_plugins.push_back(dynlib_sp);
+        return true;
+    }
+    error.SetErrorString("dylib refused to be loaded");
+    return false;
+}
 
-    Target::SettingsTerminate ();
+static FileSpec::EnumerateDirectoryResult
+LoadPluginCallback
+(
+ void *baton,
+ FileSpec::FileType file_type,
+ const FileSpec &file_spec
+ )
+{
+    Error error;
+    
+    static ConstString g_dylibext("dylib");
+    
+    if (!baton)
+        return FileSpec::eEnumerateDirectoryResultQuit;
+    
+    Debugger *debugger = (Debugger*)baton;
+    
+    // If we have a regular file, a symbolic link or unknown file type, try
+    // and process the file. We must handle unknown as sometimes the directory
+    // enumeration might be enumerating a file system that doesn't have correct
+    // file type information.
+    if (file_type == FileSpec::eFileTypeRegular         ||
+        file_type == FileSpec::eFileTypeSymbolicLink    ||
+        file_type == FileSpec::eFileTypeUnknown          )
+    {
+        FileSpec plugin_file_spec (file_spec);
+        plugin_file_spec.ResolvePath ();
+        
+        if (plugin_file_spec.GetFileNameExtension() != g_dylibext)
+            return FileSpec::eEnumerateDirectoryResultNext;
 
-    // Now terminate the Debugger Settings.
+        Error plugin_load_error;
+        debugger->LoadPlugin (plugin_file_spec, plugin_load_error);
+        
+        return FileSpec::eEnumerateDirectoryResultNext;
+    }
+    
+    else if (file_type == FileSpec::eFileTypeUnknown     ||
+        file_type == FileSpec::eFileTypeDirectory   ||
+        file_type == FileSpec::eFileTypeSymbolicLink )
+    {
+        // Try and recurse into anything that a directory or symbolic link.
+        // We must also do this for unknown as sometimes the directory enumeration
+        // might be enurating a file system that doesn't have correct file type
+        // information.
+        return FileSpec::eEnumerateDirectoryResultEnter;
+    }
+    
+    return FileSpec::eEnumerateDirectoryResultNext;
+}
 
-    UserSettingsControllerSP &usc = GetSettingsController();
-    UserSettingsController::FinalizeSettingsController (usc);
-    usc.reset();
+void
+Debugger::InstanceInitialize ()
+{
+    FileSpec dir_spec;
+    const bool find_directories = true;
+    const bool find_files = true;
+    const bool find_other = true;
+    char dir_path[PATH_MAX];
+    if (Host::GetLLDBPath (ePathTypeLLDBSystemPlugins, dir_spec))
+    {
+        if (dir_spec.Exists() && dir_spec.GetPath(dir_path, sizeof(dir_path)))
+        {
+            FileSpec::EnumerateDirectory (dir_path,
+                                          find_directories,
+                                          find_files,
+                                          find_other,
+                                          LoadPluginCallback,
+                                          this);
+        }
+    }
+    
+    if (Host::GetLLDBPath (ePathTypeLLDBUserPlugins, dir_spec))
+    {
+        if (dir_spec.Exists() && dir_spec.GetPath(dir_path, sizeof(dir_path)))
+        {
+            FileSpec::EnumerateDirectory (dir_path,
+                                          find_directories,
+                                          find_files,
+                                          find_other,
+                                          LoadPluginCallback,
+                                          this);
+        }
+    }
+    
+    PluginManager::DebuggerInitialize (*this);
 }
 
 DebuggerSP
@@ -254,6 +526,7 @@ Debugger::CreateInstance (lldb::LogOutpu
         Mutex::Locker locker (GetDebuggerListMutex ());
         GetDebuggerList().push_back(debugger_sp);
     }
+    debugger_sp->InstanceInitialize ();
     return debugger_sp;
 }
 
@@ -285,7 +558,6 @@ DebuggerSP
 Debugger::FindDebuggerWithInstanceName (const ConstString &instance_name)
 {
     DebuggerSP debugger_sp;
-   
     if (g_shared_debugger_refcount > 0)
     {
         Mutex::Locker locker (GetDebuggerListMutex ());
@@ -342,23 +614,27 @@ Debugger::FindTargetWithProcess (Process
     return target_sp;
 }
 
-
 Debugger::Debugger (lldb::LogOutputCallback log_callback, void *baton) :
     UserID (g_unique_id++),
-    DebuggerInstanceSettings (GetSettingsController()),
+    Properties(OptionValuePropertiesSP(new OptionValueProperties())), 
     m_input_comm("debugger.input"),
     m_input_file (),
     m_output_file (),
     m_error_file (),
+    m_terminal_state (),
     m_target_list (*this),
     m_platform_list (),
     m_listener ("lldb.Debugger"),
-    m_source_manager(*this),
+    m_source_manager_ap(),
     m_source_file_cache(),
     m_command_interpreter_ap (new CommandInterpreter (*this, eScriptLanguageDefault, false)),
     m_input_reader_stack (),
-    m_input_reader_data ()
+    m_input_reader_data (),
+    m_instance_name()
 {
+    char instance_cstr[256];
+    snprintf(instance_cstr, sizeof(instance_cstr), "debugger_%d", (int)GetID());
+    m_instance_name.SetCString(instance_cstr);
     if (log_callback)
         m_log_callback_stream_sp.reset (new StreamCallback (log_callback, baton));
     m_command_interpreter_ap->Initialize ();
@@ -366,6 +642,27 @@ Debugger::Debugger (lldb::LogOutputCallb
     PlatformSP default_platform_sp (Platform::GetDefaultPlatform());
     assert (default_platform_sp.get());
     m_platform_list.Append (default_platform_sp, true);
+    
+    m_collection_sp->Initialize (g_properties);
+    m_collection_sp->AppendProperty (ConstString("target"),
+                                     ConstString("Settings specify to debugging targets."),
+                                     true,
+                                     Target::GetGlobalProperties()->GetValueProperties());
+    if (m_command_interpreter_ap.get())
+    {
+        m_collection_sp->AppendProperty (ConstString("interpreter"),
+                                         ConstString("Settings specify to the debugger's command interpreter."),
+                                         true,
+                                         m_command_interpreter_ap->GetValueProperties());
+    }
+    OptionValueSInt64 *term_width = m_collection_sp->GetPropertyAtIndexAsOptionValueSInt64 (NULL, ePropertyTerminalWidth);
+    term_width->SetMinimumValue(10);
+    term_width->SetMaximumValue(1024);
+
+    // Turn off use-color if this is a dumb terminal.
+    const char *term = getenv ("TERM");
+    if (term && !strcmp (term, "dumb"))
+        SetUseColor (false);
 }
 
 Debugger::~Debugger ()
@@ -386,10 +683,7 @@ Debugger::Clear()
         {
             ProcessSP process_sp (target_sp->GetProcessSP());
             if (process_sp)
-            {
-                if (process_sp->GetShouldDetach())
-                    process_sp->Detach();
-            }
+                process_sp->Finalize();
             target_sp->Destroy();
         }
     }
@@ -397,6 +691,7 @@ Debugger::Clear()
     
     // Close the input file _before_ we close the input read communications class
     // as it does NOT own the input file, our m_input_file does.
+    m_terminal_state.Clear();
     GetInputFile().Close ();
     // Now that we have closed m_input_file, we can now tell our input communication
     // class to close down. Its read thread should quickly exit after we close
@@ -444,7 +739,10 @@ Debugger::SetInputFileHandle (FILE *fh,
     // want to objects trying to own and close a file descriptor.
     m_input_comm.SetConnection (new ConnectionFileDescriptor (in_file.GetDescriptor(), false));
     m_input_comm.SetReadThreadBytesReceivedCallback (Debugger::DispatchInputCallback, this);
-
+    
+    // Save away the terminal state if that is relevant, so that we can restore it in RestoreInputState.
+    SaveInputTerminalState ();
+    
     Error error;
     if (m_input_comm.StartReadThread (&error) == false)
     {
@@ -463,7 +761,12 @@ Debugger::SetOutputFileHandle (FILE *fh,
     if (out_file.IsValid() == false)
         out_file.SetStream (stdout, false);
     
-    GetCommandInterpreter().GetScriptInterpreter()->ResetOutputFileHandle (fh);
+    // do not create the ScriptInterpreter just for setting the output file handle
+    // as the constructor will know how to do the right thing on its own
+    const bool can_create = false;
+    ScriptInterpreter* script_interpreter = GetCommandInterpreter().GetScriptInterpreter(can_create);
+    if (script_interpreter)
+        script_interpreter->ResetOutputFileHandle (fh);
 }
 
 void
@@ -475,6 +778,20 @@ Debugger::SetErrorFileHandle (FILE *fh,
         err_file.SetStream (stderr, false);
 }
 
+void
+Debugger::SaveInputTerminalState ()
+{
+    File &in_file = GetInputFile();
+    if (in_file.GetDescriptor() != File::kInvalidDescriptor)
+        m_terminal_state.Save(in_file.GetDescriptor(), true);
+}
+
+void
+Debugger::RestoreInputTerminalState ()
+{
+    m_terminal_state.Restore();
+}
+
 ExecutionContext
 Debugger::GetSelectedExecutionContext ()
 {
@@ -755,7 +1072,7 @@ Debugger::GetAsyncErrorStream ()
                                                CommandInterpreter::eBroadcastBitAsynchronousErrorData));
 }    
 
-uint32_t
+size_t
 Debugger::GetNumDebuggers()
 {
     if (g_shared_debugger_refcount > 0)
@@ -767,7 +1084,7 @@ Debugger::GetNumDebuggers()
 }
 
 lldb::DebuggerSP
-Debugger::GetDebuggerAtIndex (uint32_t index)
+Debugger::GetDebuggerAtIndex (size_t index)
 {
     DebuggerSP debugger_sp;
     
@@ -856,14 +1173,12 @@ TestPromptFormats (StackFrame *frame)
     SymbolContext sc (frame->GetSymbolContext(eSymbolContextEverything));
     ExecutionContext exe_ctx;
     frame->CalculateExecutionContext(exe_ctx);
-    const char *end = NULL;
-    if (Debugger::FormatPrompt (prompt_format, &sc, &exe_ctx, &sc.line_entry.range.GetBaseAddress(), s, &end))
+    if (Debugger::FormatPrompt (prompt_format, &sc, &exe_ctx, &sc.line_entry.range.GetBaseAddress(), s))
     {
         printf("%s\n", s.GetData());
     }
     else
     {
-        printf ("error: at '%s'\n", end);
         printf ("what we got: %s\n", s.GetData());
     }
 }
@@ -876,57 +1191,63 @@ ScanFormatDescriptor (const char* var_na
                       Format* custom_format,
                       ValueObject::ValueObjectRepresentationStyle* val_obj_display)
 {
-    LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_TYPES));
+    Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_TYPES));
     *percent_position = ::strchr(var_name_begin,'%');
     if (!*percent_position || *percent_position > var_name_end)
     {
         if (log)
-            log->Printf("no format descriptor in string, skipping");
+            log->Printf("[ScanFormatDescriptor] no format descriptor in string, skipping");
         *var_name_final = var_name_end;
     }
     else
     {
         *var_name_final = *percent_position;
-        char* format_name = new char[var_name_end-*var_name_final]; format_name[var_name_end-*var_name_final-1] = '\0';
-        memcpy(format_name, *var_name_final+1, var_name_end-*var_name_final-1);
+        std::string format_name(*var_name_final+1, var_name_end-*var_name_final-1);
         if (log)
-            log->Printf("parsing %s as a format descriptor", format_name);
-        if ( !FormatManager::GetFormatFromCString(format_name,
+            log->Printf("ScanFormatDescriptor] parsing %s as a format descriptor", format_name.c_str());
+        if ( !FormatManager::GetFormatFromCString(format_name.c_str(),
                                                   true,
                                                   *custom_format) )
         {
             if (log)
-                log->Printf("%s is an unknown format", format_name);
-            // if this is an @ sign, print ObjC description
-            if (*format_name == '@')
-                *val_obj_display = ValueObject::eValueObjectRepresentationStyleLanguageSpecific;
-            // if this is a V, print the value using the default format
-            else if (*format_name == 'V')
-                *val_obj_display = ValueObject::eValueObjectRepresentationStyleValue;
-            // if this is an L, print the location of the value
-            else if (*format_name == 'L')
-                *val_obj_display = ValueObject::eValueObjectRepresentationStyleLocation;
-            // if this is an S, print the summary after all
-            else if (*format_name == 'S')
-                *val_obj_display = ValueObject::eValueObjectRepresentationStyleSummary;
-            else if (*format_name == '#')
-                *val_obj_display = ValueObject::eValueObjectRepresentationStyleChildrenCount;
-            else if (*format_name == 'T')
-                *val_obj_display = ValueObject::eValueObjectRepresentationStyleType;
-            else if (log)
-                log->Printf("%s is an error, leaving the previous value alone", format_name);
+                log->Printf("ScanFormatDescriptor] %s is an unknown format", format_name.c_str());
+            
+            switch (format_name.front())
+            {
+                case '@':             // if this is an @ sign, print ObjC description
+                    *val_obj_display = ValueObject::eValueObjectRepresentationStyleLanguageSpecific;
+                    break;
+                case 'V': // if this is a V, print the value using the default format
+                    *val_obj_display = ValueObject::eValueObjectRepresentationStyleValue;
+                    break;
+                case 'L': // if this is an L, print the location of the value
+                    *val_obj_display = ValueObject::eValueObjectRepresentationStyleLocation;
+                    break;
+                case 'S': // if this is an S, print the summary after all
+                    *val_obj_display = ValueObject::eValueObjectRepresentationStyleSummary;
+                    break;
+                case '#': // if this is a '#', print the number of children
+                    *val_obj_display = ValueObject::eValueObjectRepresentationStyleChildrenCount;
+                    break;
+                case 'T': // if this is a 'T', print the type
+                    *val_obj_display = ValueObject::eValueObjectRepresentationStyleType;
+                    break;
+                default:
+                    if (log)
+                        log->Printf("ScanFormatDescriptor] %s is an error, leaving the previous value alone", format_name.c_str());
+                    break;
+            }
         }
         // a good custom format tells us to print the value using it
         else
         {
             if (log)
-                log->Printf("will display value for this VO");
+                log->Printf("ScanFormatDescriptor] will display value for this VO");
             *val_obj_display = ValueObject::eValueObjectRepresentationStyleValue;
         }
-        delete format_name;
     }
     if (log)
-        log->Printf("final format description outcome: custom_format = %d, val_obj_display = %d",
+        log->Printf("ScanFormatDescriptor] final format description outcome: custom_format = %d, val_obj_display = %d",
                     *custom_format,
                     *val_obj_display);
     return true;
@@ -943,7 +1264,7 @@ ScanBracketedRange (const char* var_name
                     int64_t* index_lower,
                     int64_t* index_higher)
 {
-    LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_TYPES));
+    Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_TYPES));
     *open_bracket_position = ::strchr(var_name_begin,'[');
     if (*open_bracket_position && *open_bracket_position < var_name_final)
     {
@@ -955,7 +1276,7 @@ ScanBracketedRange (const char* var_name
         if (*close_bracket_position - *open_bracket_position == 1)
         {
             if (log)
-                log->Printf("[] detected.. going from 0 to end of data");
+                log->Printf("[ScanBracketedRange] '[]' detected.. going from 0 to end of data");
             *index_lower = 0;
         }
         else if (*separator_position == NULL || *separator_position > var_name_end)
@@ -964,7 +1285,7 @@ ScanBracketedRange (const char* var_name
             *index_lower = ::strtoul (*open_bracket_position+1, &end, 0);
             *index_higher = *index_lower;
             if (log)
-                log->Printf("[%lld] detected, high index is same", *index_lower);
+                log->Printf("[ScanBracketedRange] [%" PRId64 "] detected, high index is same", *index_lower);
         }
         else if (*close_bracket_position && *close_bracket_position < var_name_end)
         {
@@ -972,46 +1293,46 @@ ScanBracketedRange (const char* var_name
             *index_lower = ::strtoul (*open_bracket_position+1, &end, 0);
             *index_higher = ::strtoul (*separator_position+1, &end, 0);
             if (log)
-                log->Printf("[%lld-%lld] detected", *index_lower, *index_higher);
+                log->Printf("[ScanBracketedRange] [%" PRId64 "-%" PRId64 "] detected", *index_lower, *index_higher);
         }
         else
         {
             if (log)
-                log->Printf("expression is erroneous, cannot extract indices out of it");
+                log->Printf("[ScanBracketedRange] expression is erroneous, cannot extract indices out of it");
             return false;
         }
         if (*index_lower > *index_higher && *index_higher > 0)
         {
             if (log)
-                log->Printf("swapping indices");
-            int temp = *index_lower;
+                log->Printf("[ScanBracketedRange] swapping indices");
+            int64_t temp = *index_lower;
             *index_lower = *index_higher;
             *index_higher = temp;
         }
     }
     else if (log)
-            log->Printf("no bracketed range, skipping entirely");
+            log->Printf("[ScanBracketedRange] no bracketed range, skipping entirely");
     return true;
 }
 
 static ValueObjectSP
 ExpandIndexedExpression (ValueObject* valobj,
-                         uint32_t index,
+                         size_t index,
                          StackFrame* frame,
                          bool deref_pointer)
 {
-    LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_TYPES));
+    Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_TYPES));
     const char* ptr_deref_format = "[%d]";
-    std::auto_ptr<char> ptr_deref_buffer(new char[10]);
-    ::sprintf(ptr_deref_buffer.get(), ptr_deref_format, index);
+    std::string ptr_deref_buffer(10,0);
+    ::sprintf(&ptr_deref_buffer[0], ptr_deref_format, index);
     if (log)
-        log->Printf("name to deref: %s",ptr_deref_buffer.get());
+        log->Printf("[ExpandIndexedExpression] name to deref: %s",ptr_deref_buffer.c_str());
     const char* first_unparsed;
     ValueObject::GetValueForExpressionPathOptions options;
     ValueObject::ExpressionPathEndResultType final_value_type;
     ValueObject::ExpressionPathScanEndReason reason_to_stop;
     ValueObject::ExpressionPathAftermath what_next = (deref_pointer ? ValueObject::eExpressionPathAftermathDereference : ValueObject::eExpressionPathAftermathNothing);
-    ValueObjectSP item = valobj->GetValueForExpressionPath (ptr_deref_buffer.get(),
+    ValueObjectSP item = valobj->GetValueForExpressionPath (ptr_deref_buffer.c_str(),
                                                           &first_unparsed,
                                                           &reason_to_stop,
                                                           &final_value_type,
@@ -1020,22 +1341,22 @@ ExpandIndexedExpression (ValueObject* va
     if (!item)
     {
         if (log)
-            log->Printf("ERROR: unparsed portion = %s, why stopping = %d,"
+            log->Printf("[ExpandIndexedExpression] ERROR: unparsed portion = %s, why stopping = %d,"
                " final_value_type %d",
                first_unparsed, reason_to_stop, final_value_type);
     }
     else
     {
         if (log)
-            log->Printf("ALL RIGHT: unparsed portion = %s, why stopping = %d,"
+            log->Printf("[ExpandIndexedExpression] ALL RIGHT: unparsed portion = %s, why stopping = %d,"
                " final_value_type %d",
                first_unparsed, reason_to_stop, final_value_type);
     }
     return item;
 }
 
-bool
-Debugger::FormatPrompt 
+static bool
+FormatPromptRecurse
 (
     const char *format,
     const SymbolContext *sc,
@@ -1049,7 +1370,8 @@ Debugger::FormatPrompt
     ValueObject* realvalobj = NULL; // makes it super-easy to parse pointers
     bool success = true;
     const char *p;
-    LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_TYPES));
+    Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_TYPES));
+
     for (p = format; *p != '\0'; ++p)
     {
         if (realvalobj)
@@ -1083,8 +1405,8 @@ Debugger::FormatPrompt
             StreamString sub_strm;
 
             ++p;  // Skip the '{'
-            
-            if (FormatPrompt (p, sc, exe_ctx, addr, sub_strm, &p, valobj))
+
+            if (FormatPromptRecurse (p, sc, exe_ctx, addr, sub_strm, &p, valobj))
             {
                 // The stream had all it needed
                 s.Write(sub_strm.GetData(), sub_strm.GetSize());
@@ -1140,7 +1462,7 @@ Debugger::FormatPrompt
                                     break;
                                 
                                 if (log)
-                                    log->Printf("initial string: %s",var_name_begin);
+                                    log->Printf("[Debugger::FormatPrompt] initial string: %s",var_name_begin);
                                 
                                 // check for *var and *svar
                                 if (*var_name_begin == '*')
@@ -1150,7 +1472,7 @@ Debugger::FormatPrompt
                                 }
                                 
                                 if (log)
-                                    log->Printf("initial string: %s",var_name_begin);
+                                    log->Printf("[Debugger::FormatPrompt] initial string: %s",var_name_begin);
                                 
                                 if (*var_name_begin == 's')
                                 {
@@ -1162,14 +1484,14 @@ Debugger::FormatPrompt
                                 }
                                 
                                 if (log)
-                                    log->Printf("initial string: %s",var_name_begin);
+                                    log->Printf("[Debugger::FormatPrompt] initial string: %s",var_name_begin);
                                 
                                 // should be a 'v' by now
                                 if (*var_name_begin != 'v')
                                     break;
                                 
                                 if (log)
-                                    log->Printf("initial string: %s",var_name_begin);
+                                    log->Printf("[Debugger::FormatPrompt] initial string: %s",var_name_begin);
                                                                 
                                 ValueObject::ExpressionPathAftermath what_next = (do_deref_pointer ?
                                                                                   ValueObject::eExpressionPathAftermathDereference : ValueObject::eExpressionPathAftermathNothing);
@@ -1237,15 +1559,14 @@ Debugger::FormatPrompt
                                                         &index_higher);
                                                                     
                                     Error error;
-                                                                        
-                                    std::auto_ptr<char> expr_path(new char[var_name_final-var_name_begin-1]);
-                                    ::memset(expr_path.get(), 0, var_name_final-var_name_begin-1);
-                                    memcpy(expr_path.get(), var_name_begin+3,var_name_final-var_name_begin-3);
-                                                                        
+                                    
+                                    std::string expr_path(var_name_final-var_name_begin-1,0);
+                                    memcpy(&expr_path[0], var_name_begin+3,var_name_final-var_name_begin-3);
+
                                     if (log)
-                                        log->Printf("symbol to expand: %s",expr_path.get());
+                                        log->Printf("[Debugger::FormatPrompt] symbol to expand: %s",expr_path.c_str());
                                     
-                                    target = valobj->GetValueForExpressionPath(expr_path.get(),
+                                    target = valobj->GetValueForExpressionPath(expr_path.c_str(),
                                                                              &first_unparsed,
                                                                              &reason_to_stop,
                                                                              &final_value_type,
@@ -1255,7 +1576,7 @@ Debugger::FormatPrompt
                                     if (!target)
                                     {
                                         if (log)
-                                            log->Printf("ERROR: unparsed portion = %s, why stopping = %d,"
+                                            log->Printf("[Debugger::FormatPrompt] ERROR: unparsed portion = %s, why stopping = %d,"
                                                " final_value_type %d",
                                                first_unparsed, reason_to_stop, final_value_type);
                                         break;
@@ -1263,7 +1584,7 @@ Debugger::FormatPrompt
                                     else
                                     {
                                         if (log)
-                                            log->Printf("ALL RIGHT: unparsed portion = %s, why stopping = %d,"
+                                            log->Printf("[Debugger::FormatPrompt] ALL RIGHT: unparsed portion = %s, why stopping = %d,"
                                                " final_value_type %d",
                                                first_unparsed, reason_to_stop, final_value_type);
                                     }
@@ -1286,7 +1607,7 @@ Debugger::FormatPrompt
                                     if (error.Fail())
                                     {
                                         if (log)
-                                            log->Printf("ERROR: %s\n", error.AsCString("unknown")); \
+                                            log->Printf("[Debugger::FormatPrompt] ERROR: %s\n", error.AsCString("unknown")); \
                                         break;
                                     }
                                     do_deref_pointer = false;
@@ -1307,7 +1628,7 @@ Debugger::FormatPrompt
                                 }
                                 
                                 // TODO use flags for these
-                                bool is_array = ClangASTContext::IsArrayType(target->GetClangType());
+                                bool is_array = ClangASTContext::IsArrayType(target->GetClangType(), NULL, NULL, NULL);
                                 bool is_pointer = ClangASTContext::IsPointerType(target->GetClangType());
                                 bool is_aggregate = ClangASTContext::IsAggregateType(target->GetClangType());
                                 
@@ -1315,22 +1636,19 @@ Debugger::FormatPrompt
                                 {
                                     StreamString str_temp;
                                     if (log)
-                                        log->Printf("I am into array || pointer && !range");
+                                        log->Printf("[Debugger::FormatPrompt] I am into array || pointer && !range");
                                     
-                                    if (target->HasSpecialPrintableRepresentation(val_obj_display,
-                                                                                  custom_format))
+                                    if (target->HasSpecialPrintableRepresentation(val_obj_display, custom_format))
                                     {
                                         // try to use the special cases
                                         var_success = target->DumpPrintableRepresentation(str_temp,
                                                                                           val_obj_display,
                                                                                           custom_format);
                                         if (log)
-                                            log->Printf("special cases did%s match", var_success ? "" : "n't");
+                                            log->Printf("[Debugger::FormatPrompt] special cases did%s match", var_success ? "" : "n't");
                                         
                                         // should not happen
-                                        if (!var_success)
-                                            s << "<invalid usage of pointer value as object>";
-                                        else
+                                        if (var_success)
                                             s << str_temp.GetData();
                                         var_success = true;
                                         break;
@@ -1348,10 +1666,6 @@ Debugger::FormatPrompt
                                                                                  custom_format,
                                                                                  ValueObject::ePrintableRepresentationSpecialCasesDisable);
                                         }
-                                        else
-                                        {
-                                            s << "<invalid usage of pointer value as object>";
-                                        }
                                         var_success = true;
                                         break;
                                     }
@@ -1377,17 +1691,17 @@ Debugger::FormatPrompt
                                 if (!is_array_range)
                                 {
                                     if (log)
-                                        log->Printf("dumping ordinary printable output");
+                                        log->Printf("[Debugger::FormatPrompt] dumping ordinary printable output");
                                     var_success = target->DumpPrintableRepresentation(s,val_obj_display, custom_format);
                                 }
                                 else
                                 {   
                                     if (log)
-                                        log->Printf("checking if I can handle as array");
+                                        log->Printf("[Debugger::FormatPrompt] checking if I can handle as array");
                                     if (!is_array && !is_pointer)
                                         break;
                                     if (log)
-                                        log->Printf("handle as array");
+                                        log->Printf("[Debugger::FormatPrompt] handle as array");
                                     const char* special_directions = NULL;
                                     StreamString special_directions_writer;
                                     if (close_bracket_position && (var_name_end-close_bracket_position > 1))
@@ -1419,18 +1733,18 @@ Debugger::FormatPrompt
                                         if (!item)
                                         {
                                             if (log)
-                                                log->Printf("ERROR in getting child item at index %lld", index_lower);
+                                                log->Printf("[Debugger::FormatPrompt] ERROR in getting child item at index %" PRId64, index_lower);
                                         }
                                         else
                                         {
                                             if (log)
-                                                log->Printf("special_directions for child item: %s",special_directions);
+                                                log->Printf("[Debugger::FormatPrompt] special_directions for child item: %s",special_directions);
                                         }
 
                                         if (!special_directions)
                                             var_success &= item->DumpPrintableRepresentation(s,val_obj_display, custom_format);
                                         else
-                                            var_success &= FormatPrompt(special_directions, sc, exe_ctx, addr, s, NULL, item);
+                                            var_success &= FormatPromptRecurse(special_directions, sc, exe_ctx, addr, s, NULL, item);
                                         
                                         if (--max_num_children == 0)
                                         {
@@ -1454,214 +1768,6 @@ Debugger::FormatPrompt
                                     format_addr = *addr;
                                 }
                             }
-                            else if (::strncmp (var_name_begin, "ansi.", strlen("ansi.")) == 0)
-                            {
-                                var_success = true;
-                                var_name_begin += strlen("ansi."); // Skip the "ansi."
-                                if (::strncmp (var_name_begin, "fg.", strlen("fg.")) == 0)
-                                {
-                                    var_name_begin += strlen("fg."); // Skip the "fg."
-                                    if (::strncmp (var_name_begin, "black}", strlen("black}")) == 0)
-                                    {
-                                        s.Printf ("%s%s%s", 
-                                                  lldb_utility::ansi::k_escape_start, 
-                                                  lldb_utility::ansi::k_fg_black,
-                                                  lldb_utility::ansi::k_escape_end);
-                                    }
-                                    else if (::strncmp (var_name_begin, "red}", strlen("red}")) == 0)
-                                    {
-                                        s.Printf ("%s%s%s", 
-                                                  lldb_utility::ansi::k_escape_start, 
-                                                  lldb_utility::ansi::k_fg_red,
-                                                  lldb_utility::ansi::k_escape_end);
-                                    }
-                                    else if (::strncmp (var_name_begin, "green}", strlen("green}")) == 0)
-                                    {
-                                        s.Printf ("%s%s%s", 
-                                                  lldb_utility::ansi::k_escape_start, 
-                                                  lldb_utility::ansi::k_fg_green,
-                                                  lldb_utility::ansi::k_escape_end);
-                                    }
-                                    else if (::strncmp (var_name_begin, "yellow}", strlen("yellow}")) == 0)
-                                    {
-                                        s.Printf ("%s%s%s", 
-                                                  lldb_utility::ansi::k_escape_start, 
-                                                  lldb_utility::ansi::k_fg_yellow,
-                                                  lldb_utility::ansi::k_escape_end);
-                                    }
-                                    else if (::strncmp (var_name_begin, "blue}", strlen("blue}")) == 0)
-                                    {
-                                        s.Printf ("%s%s%s", 
-                                                  lldb_utility::ansi::k_escape_start, 
-                                                  lldb_utility::ansi::k_fg_blue,
-                                                  lldb_utility::ansi::k_escape_end);
-                                    }
-                                    else if (::strncmp (var_name_begin, "purple}", strlen("purple}")) == 0)
-                                    {
-                                        s.Printf ("%s%s%s", 
-                                                  lldb_utility::ansi::k_escape_start, 
-                                                  lldb_utility::ansi::k_fg_purple,
-                                                  lldb_utility::ansi::k_escape_end);
-                                    }
-                                    else if (::strncmp (var_name_begin, "cyan}", strlen("cyan}")) == 0)
-                                    {
-                                        s.Printf ("%s%s%s", 
-                                                  lldb_utility::ansi::k_escape_start, 
-                                                  lldb_utility::ansi::k_fg_cyan,
-                                                  lldb_utility::ansi::k_escape_end);
-                                    }
-                                    else if (::strncmp (var_name_begin, "white}", strlen("white}")) == 0)
-                                    {
-                                        s.Printf ("%s%s%s", 
-                                                  lldb_utility::ansi::k_escape_start, 
-                                                  lldb_utility::ansi::k_fg_white,
-                                                  lldb_utility::ansi::k_escape_end);
-                                    }
-                                    else
-                                    {
-                                        var_success = false;
-                                    }
-                                }
-                                else if (::strncmp (var_name_begin, "bg.", strlen("bg.")) == 0)
-                                {
-                                    var_name_begin += strlen("bg."); // Skip the "bg."
-                                    if (::strncmp (var_name_begin, "black}", strlen("black}")) == 0)
-                                    {
-                                        s.Printf ("%s%s%s", 
-                                                  lldb_utility::ansi::k_escape_start, 
-                                                  lldb_utility::ansi::k_bg_black,
-                                                  lldb_utility::ansi::k_escape_end);
-                                    }
-                                    else if (::strncmp (var_name_begin, "red}", strlen("red}")) == 0)
-                                    {
-                                        s.Printf ("%s%s%s", 
-                                                  lldb_utility::ansi::k_escape_start, 
-                                                  lldb_utility::ansi::k_bg_red,
-                                                  lldb_utility::ansi::k_escape_end);
-                                    }
-                                    else if (::strncmp (var_name_begin, "green}", strlen("green}")) == 0)
-                                    {
-                                        s.Printf ("%s%s%s", 
-                                                  lldb_utility::ansi::k_escape_start, 
-                                                  lldb_utility::ansi::k_bg_green,
-                                                  lldb_utility::ansi::k_escape_end);
-                                    }
-                                    else if (::strncmp (var_name_begin, "yellow}", strlen("yellow}")) == 0)
-                                    {
-                                        s.Printf ("%s%s%s", 
-                                                  lldb_utility::ansi::k_escape_start, 
-                                                  lldb_utility::ansi::k_bg_yellow,
-                                                  lldb_utility::ansi::k_escape_end);
-                                    }
-                                    else if (::strncmp (var_name_begin, "blue}", strlen("blue}")) == 0)
-                                    {
-                                        s.Printf ("%s%s%s", 
-                                                  lldb_utility::ansi::k_escape_start, 
-                                                  lldb_utility::ansi::k_bg_blue,
-                                                  lldb_utility::ansi::k_escape_end);
-                                    }
-                                    else if (::strncmp (var_name_begin, "purple}", strlen("purple}")) == 0)
-                                    {
-                                        s.Printf ("%s%s%s", 
-                                                  lldb_utility::ansi::k_escape_start, 
-                                                  lldb_utility::ansi::k_bg_purple,
-                                                  lldb_utility::ansi::k_escape_end);
-                                    }
-                                    else if (::strncmp (var_name_begin, "cyan}", strlen("cyan}")) == 0)
-                                    {
-                                        s.Printf ("%s%s%s", 
-                                                  lldb_utility::ansi::k_escape_start, 
-                                                  lldb_utility::ansi::k_bg_cyan,
-                                                  lldb_utility::ansi::k_escape_end);
-                                    }
-                                    else if (::strncmp (var_name_begin, "white}", strlen("white}")) == 0)
-                                    {
-                                        s.Printf ("%s%s%s", 
-                                                  lldb_utility::ansi::k_escape_start, 
-                                                  lldb_utility::ansi::k_bg_white,
-                                                  lldb_utility::ansi::k_escape_end);
-                                    }
-                                    else
-                                    {
-                                        var_success = false;
-                                    }
-                                }
-                                else if (::strncmp (var_name_begin, "normal}", strlen ("normal}")) == 0)
-                                {
-                                    s.Printf ("%s%s%s", 
-                                              lldb_utility::ansi::k_escape_start, 
-                                              lldb_utility::ansi::k_ctrl_normal,
-                                              lldb_utility::ansi::k_escape_end);
-                                }
-                                else if (::strncmp (var_name_begin, "bold}", strlen("bold}")) == 0)
-                                {
-                                    s.Printf ("%s%s%s", 
-                                              lldb_utility::ansi::k_escape_start, 
-                                              lldb_utility::ansi::k_ctrl_bold,
-                                              lldb_utility::ansi::k_escape_end);
-                                }
-                                else if (::strncmp (var_name_begin, "faint}", strlen("faint}")) == 0)
-                                {
-                                    s.Printf ("%s%s%s", 
-                                              lldb_utility::ansi::k_escape_start, 
-                                              lldb_utility::ansi::k_ctrl_faint,
-                                              lldb_utility::ansi::k_escape_end);
-                                }
-                                else if (::strncmp (var_name_begin, "italic}", strlen("italic}")) == 0)
-                                {
-                                    s.Printf ("%s%s%s", 
-                                              lldb_utility::ansi::k_escape_start, 
-                                              lldb_utility::ansi::k_ctrl_italic,
-                                              lldb_utility::ansi::k_escape_end);
-                                }
-                                else if (::strncmp (var_name_begin, "underline}", strlen("underline}")) == 0)
-                                {
-                                    s.Printf ("%s%s%s", 
-                                              lldb_utility::ansi::k_escape_start, 
-                                              lldb_utility::ansi::k_ctrl_underline,
-                                              lldb_utility::ansi::k_escape_end);
-                                }
-                                else if (::strncmp (var_name_begin, "slow-blink}", strlen("slow-blink}")) == 0)
-                                {
-                                    s.Printf ("%s%s%s", 
-                                              lldb_utility::ansi::k_escape_start, 
-                                              lldb_utility::ansi::k_ctrl_slow_blink,
-                                              lldb_utility::ansi::k_escape_end);
-                                }
-                                else if (::strncmp (var_name_begin, "fast-blink}", strlen("fast-blink}")) == 0)
-                                {
-                                    s.Printf ("%s%s%s", 
-                                              lldb_utility::ansi::k_escape_start, 
-                                              lldb_utility::ansi::k_ctrl_fast_blink,
-                                              lldb_utility::ansi::k_escape_end);
-                                }
-                                else if (::strncmp (var_name_begin, "negative}", strlen("negative}")) == 0)
-                                {
-                                    s.Printf ("%s%s%s", 
-                                              lldb_utility::ansi::k_escape_start, 
-                                              lldb_utility::ansi::k_ctrl_negative,
-                                              lldb_utility::ansi::k_escape_end);
-                                }
-                                else if (::strncmp (var_name_begin, "conceal}", strlen("conceal}")) == 0)
-                                {
-                                    s.Printf ("%s%s%s", 
-                                              lldb_utility::ansi::k_escape_start, 
-                                              lldb_utility::ansi::k_ctrl_conceal,
-                                              lldb_utility::ansi::k_escape_end);
-
-                                }
-                                else if (::strncmp (var_name_begin, "crossed-out}", strlen("crossed-out}")) == 0)
-                                {
-                                    s.Printf ("%s%s%s", 
-                                              lldb_utility::ansi::k_escape_start, 
-                                              lldb_utility::ansi::k_ctrl_crossed_out,
-                                              lldb_utility::ansi::k_escape_end);
-                                }
-                                else
-                                {
-                                    var_success = false;
-                                }
-                            }
                             break;
 
                         case 'p':
@@ -1675,7 +1781,7 @@ Debugger::FormatPrompt
                                         var_name_begin += ::strlen ("process.");
                                         if (::strncmp (var_name_begin, "id}", strlen("id}")) == 0)
                                         {
-                                            s.Printf("%llu", process->GetID());
+                                            s.Printf("%" PRIu64, process->GetID());
                                             var_success = true;
                                         }
                                         else if ((::strncmp (var_name_begin, "name}", strlen("name}")) == 0) ||
@@ -1713,7 +1819,12 @@ Debugger::FormatPrompt
                                         var_name_begin += ::strlen ("thread.");
                                         if (::strncmp (var_name_begin, "id}", strlen("id}")) == 0)
                                         {
-                                            s.Printf("0x%4.4llx", thread->GetID());
+                                            s.Printf("0x%4.4" PRIx64, thread->GetID());
+                                            var_success = true;
+                                        }
+                                        else if (::strncmp (var_name_begin, "protocol_id}", strlen("protocol_id}")) == 0)
+                                        {
+                                            s.Printf("0x%4.4" PRIx64, thread->GetProtocolID());
                                             var_success = true;
                                         }
                                         else if (::strncmp (var_name_begin, "index}", strlen("index}")) == 0)
@@ -1738,7 +1849,7 @@ Debugger::FormatPrompt
                                         else if (::strncmp (var_name_begin, "stop-reason}", strlen("stop-reason}")) == 0)
                                         {
                                             StopInfoSP stop_info_sp = thread->GetStopInfo ();
-                                            if (stop_info_sp)
+                                            if (stop_info_sp && stop_info_sp->IsValid())
                                             {
                                                 cstr = stop_info_sp->GetDescription();
                                                 if (cstr && cstr[0])
@@ -1751,13 +1862,12 @@ Debugger::FormatPrompt
                                         else if (::strncmp (var_name_begin, "return-value}", strlen("return-value}")) == 0)
                                         {
                                             StopInfoSP stop_info_sp = thread->GetStopInfo ();
-                                            if (stop_info_sp)
+                                            if (stop_info_sp && stop_info_sp->IsValid())
                                             {
                                                 ValueObjectSP return_valobj_sp = StopInfo::GetReturnValueObject (stop_info_sp);
                                                 if (return_valobj_sp)
                                                 {
-                                                    ValueObject::DumpValueObjectOptions dump_options;
-                                                    ValueObject::DumpValueObject (s, return_valobj_sp.get(), dump_options);
+                                                    ValueObject::DumpValueObject (s, return_valobj_sp.get());
                                                     var_success = true;
                                                 }
                                             }
@@ -1767,6 +1877,29 @@ Debugger::FormatPrompt
                             }
                             else if (::strncmp (var_name_begin, "target.", strlen("target.")) == 0)
                             {
+                                // TODO: hookup properties
+//                                if (!target_properties_sp)
+//                                {
+//                                    Target *target = Target::GetTargetFromContexts (exe_ctx, sc);
+//                                    if (target)
+//                                        target_properties_sp = target->GetProperties();
+//                                }
+//
+//                                if (target_properties_sp)
+//                                {
+//                                    var_name_begin += ::strlen ("target.");
+//                                    const char *end_property = strchr(var_name_begin, '}');
+//                                    if (end_property)
+//                                    {
+//                                        ConstString property_name(var_name_begin, end_property - var_name_begin);
+//                                        std::string property_value (target_properties_sp->GetPropertyValue(property_name));
+//                                        if (!property_value.empty())
+//                                        {
+//                                            s.PutCString (property_value.c_str());
+//                                            var_success = true;
+//                                        }
+//                                    }
+//                                }                                        
                                 Target *target = Target::GetTargetFromContexts (exe_ctx, sc);
                                 if (target)
                                 {
@@ -1780,7 +1913,7 @@ Debugger::FormatPrompt
                                             var_success = true;
                                         }
                                     }
-                                }                                        
+                                }
                             }
                             break;
                             
@@ -1898,7 +2031,7 @@ Debugger::FormatPrompt
                                     if (::strncmp (var_name_begin, "id}", strlen("id}")) == 0)
                                     {
                                         if (sc->function)
-                                            s.Printf("function{0x%8.8llx}", sc->function->GetID());
+                                            s.Printf("function{0x%8.8" PRIx64 "}", sc->function->GetID());
                                         else
                                             s.Printf("symbol[%u]", sc->symbol->GetID());
 
@@ -1971,22 +2104,22 @@ Debugger::FormatPrompt
                                                 
                                                 VariableList args;
                                                 if (variable_list_sp)
-                                                {
-                                                    const size_t num_variables = variable_list_sp->GetSize();
-                                                    for (size_t var_idx = 0; var_idx < num_variables; ++var_idx)
-                                                    {
-                                                        VariableSP var_sp (variable_list_sp->GetVariableAtIndex(var_idx));
-                                                        if (var_sp->GetScope() == eValueTypeVariableArgument)
-                                                            args.AddVariable (var_sp);
-                                                    }
-
-                                                }
+                                                    variable_list_sp->AppendVariablesWithScope(eValueTypeVariableArgument, args);
                                                 if (args.GetSize() > 0)
                                                 {
                                                     const char *open_paren = strchr (cstr, '(');
                                                     const char *close_paren = NULL;
                                                     if (open_paren)
-                                                        close_paren = strchr (open_paren, ')');
+                                                    {
+                                                        if (strncmp(open_paren, "(anonymous namespace)", strlen("(anonymous namespace)")) == 0)
+                                                        {
+                                                            open_paren = strchr (open_paren + strlen("(anonymous namespace)"), '(');
+                                                            if (open_paren)
+                                                                close_paren = strchr (open_paren, ')');
+                                                        }
+                                                        else
+                                                            close_paren = strchr (open_paren, ')');
+                                                    }
                                                     
                                                     if (open_paren)
                                                         s.Write(cstr, open_paren - cstr + 1);
@@ -2002,12 +2135,17 @@ Debugger::FormatPrompt
                                                         ValueObjectSP var_value_sp (ValueObjectVariable::Create (exe_scope, var_sp));
                                                         const char *var_name = var_value_sp->GetName().GetCString();
                                                         const char *var_value = var_value_sp->GetValueAsCString();
+                                                        if (arg_idx > 0)
+                                                            s.PutCString (", ");
                                                         if (var_value_sp->GetError().Success())
                                                         {
-                                                            if (arg_idx > 0)
-                                                                s.PutCString (", ");
-                                                            s.Printf ("%s=%s", var_name, var_value);
+                                                            if (var_value)
+                                                                s.Printf ("%s=%s", var_name, var_value);
+                                                            else
+                                                                s.Printf ("%s=%s at %s", var_name, var_value_sp->GetTypeName().GetCString(), var_value_sp->GetLocationAsCString());
                                                         }
+                                                        else
+                                                            s.Printf ("%s=<unavailable>", var_name);
                                                     }
                                                     
                                                     if (close_paren)
@@ -2184,9 +2322,9 @@ Debugger::FormatPrompt
                                             addr_t func_file_addr = func_addr.GetFileAddress();
                                             addr_t addr_file_addr = format_addr.GetFileAddress();
                                             if (addr_file_addr > func_file_addr)
-                                                s.Printf(" + %llu", addr_file_addr - func_file_addr);
+                                                s.Printf(" + %" PRIu64, addr_file_addr - func_file_addr);
                                             else if (addr_file_addr < func_file_addr)
-                                                s.Printf(" - %llu", func_file_addr - addr_file_addr);
+                                                s.Printf(" - %" PRIu64, func_file_addr - addr_file_addr);
                                             var_success = true;
                                         }
                                         else
@@ -2197,9 +2335,9 @@ Debugger::FormatPrompt
                                                 addr_t func_load_addr = func_addr.GetLoadAddress (target);
                                                 addr_t addr_load_addr = format_addr.GetLoadAddress (target);
                                                 if (addr_load_addr > func_load_addr)
-                                                    s.Printf(" + %llu", addr_load_addr - func_load_addr);
+                                                    s.Printf(" + %" PRIu64, addr_load_addr - func_load_addr);
                                                 else if (addr_load_addr < func_load_addr)
-                                                    s.Printf(" - %llu", func_load_addr - addr_load_addr);
+                                                    s.Printf(" - %" PRIu64, func_load_addr - addr_load_addr);
                                                 var_success = true;
                                             }
                                         }
@@ -2219,7 +2357,7 @@ Debugger::FormatPrompt
                                         int addr_width = target->GetArchitecture().GetAddressByteSize() * 2;
                                         if (addr_width == 0)
                                             addr_width = 16;
-                                        s.Printf("0x%*.*llx", addr_width, addr_width, vaddr);
+                                        s.Printf("0x%*.*" PRIx64, addr_width, addr_width, vaddr);
                                         var_success = true;
                                     }
                                 }
@@ -2272,8 +2410,7 @@ Debugger::FormatPrompt
                     unsigned long octal_value = ::strtoul (oct_str, NULL, 8);
                     if (octal_value <= UINT8_MAX)
                     {
-                        char octal_char = octal_value;
-                        s.Write (&octal_char, 1);
+                        s.PutChar((char)octal_value);
                     }
                 }
                 break;
@@ -2296,7 +2433,7 @@ Debugger::FormatPrompt
 
                     unsigned long hex_value = strtoul (hex_str, NULL, 16);                    
                     if (hex_value <= UINT8_MAX)
-                        s.PutChar (hex_value);
+                        s.PutChar ((char)hex_value);
                 }
                 else
                 {
@@ -2319,6 +2456,24 @@ Debugger::FormatPrompt
     return success;
 }
 
+bool
+Debugger::FormatPrompt
+(
+    const char *format,
+    const SymbolContext *sc,
+    const ExecutionContext *exe_ctx,
+    const Address *addr,
+    Stream &s,
+    ValueObject* valobj
+)
+{
+    bool use_color = exe_ctx ? exe_ctx->GetTargetRef().GetDebugger().GetUseColor() : true;
+    std::string format_str = lldb_utility::ansi::FormatAnsiTerminalCodes (format, use_color);
+    if (format_str.length())
+        format = format_str.c_str();
+    return FormatPromptRecurse (format, sc, exe_ctx, addr, s, NULL, valobj);
+}
+
 void
 Debugger::SetLoggingCallback (lldb::LogOutputCallback log_callback, void *baton)
 {
@@ -2347,20 +2502,20 @@ Debugger::EnableLog (const char *channel
     else
     {
         LogStreamMap::iterator pos = m_log_streams.find(log_file);
-        if (pos == m_log_streams.end())
+        if (pos != m_log_streams.end())
+            log_stream_sp = pos->second.lock();
+        if (!log_stream_sp)
         {
             log_stream_sp.reset (new StreamFile (log_file));
             m_log_streams[log_file] = log_stream_sp;
         }
-        else
-            log_stream_sp = pos->second;
     }
     assert (log_stream_sp.get());
     
     if (log_options == 0)
         log_options = LLDB_LOG_OPTION_PREPEND_THREAD_NAME | LLDB_LOG_OPTION_THREADSAFE;
         
-    if (Log::GetLogChannelCallbacks (channel, log_callbacks))
+    if (Log::GetLogChannelCallbacks (ConstString(channel), log_callbacks))
     {
         log_callbacks.enable (log_stream_sp, log_options, categories, &error_stream);
         return true;
@@ -2389,465 +2544,12 @@ Debugger::EnableLog (const char *channel
     return false;
 }
 
-#pragma mark Debugger::SettingsController
-
-//--------------------------------------------------
-// class Debugger::SettingsController
-//--------------------------------------------------
-
-Debugger::SettingsController::SettingsController () :
-    UserSettingsController ("", UserSettingsControllerSP())
+SourceManager &
+Debugger::GetSourceManager ()
 {
+    if (m_source_manager_ap.get() == NULL)
+        m_source_manager_ap.reset (new SourceManager (shared_from_this()));
+    return *m_source_manager_ap;
 }
 
-Debugger::SettingsController::~SettingsController ()
-{
-}
-
-
-InstanceSettingsSP
-Debugger::SettingsController::CreateInstanceSettings (const char *instance_name)
-{
-    InstanceSettingsSP new_settings_sp (new DebuggerInstanceSettings (GetSettingsController(),
-                                                                      false, 
-                                                                      instance_name));
-    return new_settings_sp;
-}
-
-#pragma mark DebuggerInstanceSettings
-//--------------------------------------------------
-//  class DebuggerInstanceSettings
-//--------------------------------------------------
-
-DebuggerInstanceSettings::DebuggerInstanceSettings 
-(
-    const UserSettingsControllerSP &m_owner_sp, 
-    bool live_instance,
-    const char *name
-) :
-    InstanceSettings (m_owner_sp, name ? name : InstanceSettings::InvalidName().AsCString(), live_instance),
-    m_term_width (80),
-    m_stop_source_before_count (3),
-    m_stop_source_after_count (3),
-    m_stop_disassembly_count (4),
-    m_stop_disassembly_display (eStopDisassemblyTypeNoSource),
-    m_prompt (),
-    m_notify_void (false),
-    m_frame_format (),
-    m_thread_format (),    
-    m_script_lang (),
-    m_use_external_editor (false),
-    m_auto_confirm_on (false)
-{
-    // CopyInstanceSettings is a pure virtual function in InstanceSettings; it therefore cannot be called
-    // until the vtables for DebuggerInstanceSettings are properly set up, i.e. AFTER all the initializers.
-    // For this reason it has to be called here, rather than in the initializer or in the parent constructor.
-    // The same is true of CreateInstanceName().
 
-    if (GetInstanceName() == InstanceSettings::InvalidName())
-    {
-        ChangeInstanceName (std::string (CreateInstanceName().AsCString()));
-        m_owner_sp->RegisterInstanceSettings (this);
-    }
-
-    if (live_instance)
-    {
-        const InstanceSettingsSP &pending_settings = m_owner_sp->FindPendingSettings (m_instance_name);
-        CopyInstanceSettings (pending_settings, false);
-    }
-}
-
-DebuggerInstanceSettings::DebuggerInstanceSettings (const DebuggerInstanceSettings &rhs) :
-    InstanceSettings (Debugger::GetSettingsController(), CreateInstanceName ().AsCString()),
-    m_prompt (rhs.m_prompt),
-    m_notify_void (rhs.m_notify_void),
-    m_frame_format (rhs.m_frame_format),
-    m_thread_format (rhs.m_thread_format),
-    m_script_lang (rhs.m_script_lang),
-    m_use_external_editor (rhs.m_use_external_editor),
-    m_auto_confirm_on(rhs.m_auto_confirm_on)
-{
-    UserSettingsControllerSP owner_sp (m_owner_wp.lock());
-    if (owner_sp)
-    {
-        CopyInstanceSettings (owner_sp->FindPendingSettings (m_instance_name), false);
-        owner_sp->RemovePendingSettings (m_instance_name);
-    }
-}
-
-DebuggerInstanceSettings::~DebuggerInstanceSettings ()
-{
-}
-
-DebuggerInstanceSettings&
-DebuggerInstanceSettings::operator= (const DebuggerInstanceSettings &rhs)
-{
-    if (this != &rhs)
-    {
-        m_term_width = rhs.m_term_width;
-        m_prompt = rhs.m_prompt;
-        m_notify_void = rhs.m_notify_void;
-        m_frame_format = rhs.m_frame_format;
-        m_thread_format = rhs.m_thread_format;
-        m_script_lang = rhs.m_script_lang;
-        m_use_external_editor = rhs.m_use_external_editor;
-        m_auto_confirm_on = rhs.m_auto_confirm_on;
-    }
-
-    return *this;
-}
-
-bool
-DebuggerInstanceSettings::ValidTermWidthValue (const char *value, Error err)
-{
-    bool valid = false;
-
-    // Verify we have a value string.
-    if (value == NULL || value[0] == '\0')
-    {
-        err.SetErrorString ("missing value, can't set terminal width without a value");
-    }
-    else
-    {
-        char *end = NULL;
-        const uint32_t width = ::strtoul (value, &end, 0);
-        
-        if (end && end[0] == '\0')
-        {
-            return ValidTermWidthValue (width, err);
-        }
-        else
-            err.SetErrorStringWithFormat ("'%s' is not a valid unsigned integer string", value);
-    }
-
-    return valid;
-}
-
-bool
-DebuggerInstanceSettings::ValidTermWidthValue (uint32_t value, Error err)
-{
-    if (value >= 10 && value <= 1024)
-        return true;
-    else
-    {
-        err.SetErrorString ("invalid term-width value; value must be between 10 and 1024");
-        return false;
-    }
-}
-
-void
-DebuggerInstanceSettings::UpdateInstanceSettingsVariable (const ConstString &var_name,
-                                                          const char *index_value,
-                                                          const char *value,
-                                                          const ConstString &instance_name,
-                                                          const SettingEntry &entry,
-                                                          VarSetOperationType op,
-                                                          Error &err,
-                                                          bool pending)
-{
-
-    if (var_name == TermWidthVarName())
-    {
-        if (ValidTermWidthValue (value, err))
-        {
-            m_term_width = ::strtoul (value, NULL, 0);
-        }
-    }
-    else if (var_name == PromptVarName())
-    {
-        UserSettingsController::UpdateStringVariable (op, m_prompt, value, err);
-        if (!pending)
-        {
-            // 'instance_name' is actually (probably) in the form '[<instance_name>]';  if so, we need to
-            // strip off the brackets before passing it to BroadcastPromptChange.
-
-            std::string tmp_instance_name (instance_name.AsCString());
-            if ((tmp_instance_name[0] == '[') 
-                && (tmp_instance_name[instance_name.GetLength() - 1] == ']'))
-                tmp_instance_name = tmp_instance_name.substr (1, instance_name.GetLength() - 2);
-            ConstString new_name (tmp_instance_name.c_str());
-
-            BroadcastPromptChange (new_name, m_prompt.c_str());
-        }
-    }
-    else if (var_name == GetNotifyVoidName())
-    {
-        UserSettingsController::UpdateBooleanVariable (op, m_notify_void, value, false, err);
-    }
-    else if (var_name == GetFrameFormatName())
-    {
-        UserSettingsController::UpdateStringVariable (op, m_frame_format, value, err);
-    }
-    else if (var_name == GetThreadFormatName())
-    {
-        UserSettingsController::UpdateStringVariable (op, m_thread_format, value, err);
-    }
-    else if (var_name == ScriptLangVarName())
-    {
-        bool success;
-        m_script_lang = Args::StringToScriptLanguage (value, eScriptLanguageDefault,
-                                                      &success);
-    }
-    else if (var_name == UseExternalEditorVarName ())
-    {
-        UserSettingsController::UpdateBooleanVariable (op, m_use_external_editor, value, false, err);
-    }
-    else if (var_name == AutoConfirmName ())
-    {
-        UserSettingsController::UpdateBooleanVariable (op, m_auto_confirm_on, value, false, err);
-    }
-    else if (var_name == StopSourceContextBeforeName ())
-    {
-        uint32_t new_value = Args::StringToUInt32(value, UINT32_MAX, 10, NULL);
-        if (new_value != UINT32_MAX)
-            m_stop_source_before_count = new_value;
-        else
-            err.SetErrorStringWithFormat("invalid unsigned string value '%s' for the '%s' setting", value, StopSourceContextBeforeName ().GetCString());
-    }
-    else if (var_name == StopSourceContextAfterName ())
-    {
-        uint32_t new_value = Args::StringToUInt32(value, UINT32_MAX, 10, NULL);
-        if (new_value != UINT32_MAX)
-            m_stop_source_after_count = new_value;
-        else
-            err.SetErrorStringWithFormat("invalid unsigned string value '%s' for the '%s' setting", value, StopSourceContextAfterName ().GetCString());
-    }
-    else if (var_name == StopDisassemblyCountName ())
-    {
-        uint32_t new_value = Args::StringToUInt32(value, UINT32_MAX, 10, NULL);
-        if (new_value != UINT32_MAX)
-            m_stop_disassembly_count = new_value;
-        else
-            err.SetErrorStringWithFormat("invalid unsigned string value '%s' for the '%s' setting", value, StopDisassemblyCountName ().GetCString());
-    }
-    else if (var_name == StopDisassemblyDisplayName ())
-    {
-        int new_value;
-        UserSettingsController::UpdateEnumVariable (g_show_disassembly_enum_values, &new_value, value, err);
-        if (err.Success())
-            m_stop_disassembly_display = (StopDisassemblyType)new_value;
-    }
-}
-
-bool
-DebuggerInstanceSettings::GetInstanceSettingsValue (const SettingEntry &entry,
-                                                    const ConstString &var_name,
-                                                    StringList &value,
-                                                    Error *err)
-{
-    if (var_name == PromptVarName())
-    {
-        value.AppendString (m_prompt.c_str(), m_prompt.size());
-    }
-    else if (var_name == GetNotifyVoidName())
-    {
-        value.AppendString (m_notify_void ? "true" : "false");
-    }
-    else if (var_name == ScriptLangVarName())
-    {
-        value.AppendString (ScriptInterpreter::LanguageToString (m_script_lang).c_str());
-    }
-    else if (var_name == TermWidthVarName())
-    {
-        StreamString width_str;
-        width_str.Printf ("%u", m_term_width);
-        value.AppendString (width_str.GetData());
-    }
-    else if (var_name == GetFrameFormatName ())
-    {
-        value.AppendString(m_frame_format.c_str(), m_frame_format.size());
-    }
-    else if (var_name == GetThreadFormatName ())
-    {
-        value.AppendString(m_thread_format.c_str(), m_thread_format.size());
-    }
-    else if (var_name == UseExternalEditorVarName())
-    {
-        if (m_use_external_editor)
-            value.AppendString ("true");
-        else
-            value.AppendString ("false");
-    }
-    else if (var_name == AutoConfirmName())
-    {
-        if (m_auto_confirm_on)
-            value.AppendString ("true");
-        else
-            value.AppendString ("false");
-    }
-    else if (var_name == StopSourceContextAfterName ())
-    {
-        StreamString strm;
-        strm.Printf ("%u", m_stop_source_after_count);
-        value.AppendString (strm.GetData());
-    }
-    else if (var_name == StopSourceContextBeforeName ())
-    {
-        StreamString strm;
-        strm.Printf ("%u", m_stop_source_before_count);
-        value.AppendString (strm.GetData());
-    }
-    else if (var_name == StopDisassemblyCountName ())
-    {
-        StreamString strm;
-        strm.Printf ("%u", m_stop_disassembly_count);
-        value.AppendString (strm.GetData());
-    }
-    else if (var_name == StopDisassemblyDisplayName ())
-    {
-        if (m_stop_disassembly_display >= eStopDisassemblyTypeNever && m_stop_disassembly_display <= eStopDisassemblyTypeAlways)
-            value.AppendString (g_show_disassembly_enum_values[m_stop_disassembly_display].string_value);
-        else
-            value.AppendString ("<invalid>");
-    }
-    else
-    {
-        if (err)
-            err->SetErrorStringWithFormat ("unrecognized variable name '%s'", var_name.AsCString());
-        return false;
-    }
-    return true;
-}
-
-void
-DebuggerInstanceSettings::CopyInstanceSettings (const InstanceSettingsSP &new_settings,
-                                                bool pending)
-{
-    if (new_settings.get() == NULL)
-        return;
-
-    DebuggerInstanceSettings *new_debugger_settings = (DebuggerInstanceSettings *) new_settings.get();
-
-    m_prompt = new_debugger_settings->m_prompt;
-    if (!pending)
-    {
-        // 'instance_name' is actually (probably) in the form '[<instance_name>]';  if so, we need to
-        // strip off the brackets before passing it to BroadcastPromptChange.
-
-        std::string tmp_instance_name (m_instance_name.AsCString());
-        if ((tmp_instance_name[0] == '[')
-            && (tmp_instance_name[m_instance_name.GetLength() - 1] == ']'))
-            tmp_instance_name = tmp_instance_name.substr (1, m_instance_name.GetLength() - 2);
-        ConstString new_name (tmp_instance_name.c_str());
-
-        BroadcastPromptChange (new_name, m_prompt.c_str());
-    }
-    m_notify_void = new_debugger_settings->m_notify_void;
-    m_frame_format = new_debugger_settings->m_frame_format;
-    m_thread_format = new_debugger_settings->m_thread_format;
-    m_term_width = new_debugger_settings->m_term_width;
-    m_script_lang = new_debugger_settings->m_script_lang;
-    m_use_external_editor = new_debugger_settings->m_use_external_editor;
-    m_auto_confirm_on = new_debugger_settings->m_auto_confirm_on;
-}
-
-
-bool
-DebuggerInstanceSettings::BroadcastPromptChange (const ConstString &instance_name, const char *new_prompt)
-{
-    std::string tmp_prompt;
-    
-    if (new_prompt != NULL)
-    {
-        tmp_prompt = new_prompt ;
-        int len = tmp_prompt.size();
-        if (len > 1
-            && (tmp_prompt[0] == '\'' || tmp_prompt[0] == '"')
-            && (tmp_prompt[len-1] == tmp_prompt[0]))
-        {
-            tmp_prompt = tmp_prompt.substr(1,len-2);
-        }
-        len = tmp_prompt.size();
-        if (tmp_prompt[len-1] != ' ')
-            tmp_prompt.append(" ");
-    }
-    EventSP new_event_sp;
-    new_event_sp.reset (new Event(CommandInterpreter::eBroadcastBitResetPrompt, 
-                                  new EventDataBytes (tmp_prompt.c_str())));
-
-    if (instance_name.GetLength() != 0)
-    {
-        // Set prompt for a particular instance.
-        Debugger *dbg = Debugger::FindDebuggerWithInstanceName (instance_name).get();
-        if (dbg != NULL)
-        {
-            dbg->GetCommandInterpreter().BroadcastEvent (new_event_sp);
-        }
-    }
-
-    return true;
-}
-
-const ConstString
-DebuggerInstanceSettings::CreateInstanceName ()
-{
-    static int instance_count = 1;
-    StreamString sstr;
-
-    sstr.Printf ("debugger_%d", instance_count);
-    ++instance_count;
-
-    const ConstString ret_val (sstr.GetData());
-
-    return ret_val;
-}
-
-
-//--------------------------------------------------
-// SettingsController Variable Tables
-//--------------------------------------------------
-
-
-SettingEntry
-Debugger::SettingsController::global_settings_table[] =
-{
-  //{ "var-name",    var-type,      "default", enum-table, init'd, hidden, "help-text"},
-  // The Debugger level global table should always be empty; all Debugger settable variables should be instance
-  // variables.
-    {  NULL, eSetVarTypeNone, NULL, NULL, 0, 0, NULL }
-};
-
-#define MODULE_WITH_FUNC "{ ${module.file.basename}{`${function.name-with-args}${function.pc-offset}}}"
-#define FILE_AND_LINE "{ at ${line.file.basename}:${line.number}}"
-
-#define DEFAULT_THREAD_FORMAT "thread #${thread.index}: tid = ${thread.id}"\
-    "{, ${frame.pc}}"\
-    MODULE_WITH_FUNC\
-    FILE_AND_LINE\
-    "{, stop reason = ${thread.stop-reason}}"\
-    "{\\nReturn value: ${thread.return-value}}"\
-    "\\n"
-
-//#define DEFAULT_THREAD_FORMAT "thread #${thread.index}: tid = ${thread.id}"\
-//    "{, ${frame.pc}}"\
-//    MODULE_WITH_FUNC\
-//    FILE_AND_LINE\
-//    "{, stop reason = ${thread.stop-reason}}"\
-//    "{, name = ${thread.name}}"\
-//    "{, queue = ${thread.queue}}"\
-//    "\\n"
-
-#define DEFAULT_FRAME_FORMAT "frame #${frame.index}: ${frame.pc}"\
-    MODULE_WITH_FUNC\
-    FILE_AND_LINE\
-    "\\n"
-
-SettingEntry
-Debugger::SettingsController::instance_settings_table[] =
-{
-//  NAME                    Setting variable type   Default                 Enum  Init'd Hidden Help
-//  ======================= ======================= ======================  ====  ====== ====== ======================
-{   "frame-format",         eSetVarTypeString,      DEFAULT_FRAME_FORMAT,   NULL, false, false, "The default frame format string to use when displaying thread information." },
-{   "prompt",               eSetVarTypeString,      "(lldb) ",              NULL, false, false, "The debugger command line prompt displayed for the user." },
-{   "notify-void",          eSetVarTypeBoolean,     "false",                NULL, false, false, "Notify the user explicitly if an expression returns void." },
-{   "script-lang",          eSetVarTypeString,      "python",               NULL, false, false, "The script language to be used for evaluating user-written scripts." },
-{   "term-width",           eSetVarTypeInt,         "80"    ,               NULL, false, false, "The maximum number of columns to use for displaying text." },
-{   "thread-format",        eSetVarTypeString,      DEFAULT_THREAD_FORMAT,  NULL, false, false, "The default thread format string to use when displaying thread information." },
-{   "use-external-editor",  eSetVarTypeBoolean,     "false",                NULL, false, false, "Whether to use an external editor or not." },
-{   "auto-confirm",         eSetVarTypeBoolean,     "false",                NULL, false, false, "If true all confirmation prompts will receive their default reply." },
-{   "stop-line-count-before",eSetVarTypeInt,        "3",                    NULL, false, false, "The number of sources lines to display that come before the current source line when displaying a stopped context." },
-{   "stop-line-count-after", eSetVarTypeInt,        "3",                    NULL, false, false, "The number of sources lines to display that come after the current source line when displaying a stopped context." },
-{   "stop-disassembly-count",  eSetVarTypeInt,      "0",                    NULL, false, false, "The number of disassembly lines to show when displaying a stopped context." },
-{   "stop-disassembly-display", eSetVarTypeEnum,    "no-source",           g_show_disassembly_enum_values, false, false, "Control when to display disassembly when displaying a stopped context." },
-{   NULL,                   eSetVarTypeNone,        NULL,                   NULL, false, false, NULL }
-};

Modified: lldb/branches/lldb-platform-work/source/Core/Disassembler.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/lldb-platform-work/source/Core/Disassembler.cpp?rev=183468&r1=183467&r2=183468&view=diff
==============================================================================
--- lldb/branches/lldb-platform-work/source/Core/Disassembler.cpp (original)
+++ lldb/branches/lldb-platform-work/source/Core/Disassembler.cpp Thu Jun  6 19:06:43 2013
@@ -7,6 +7,8 @@
 //
 //===----------------------------------------------------------------------===//
 
+#include "lldb/lldb-python.h"
+
 #include "lldb/Core/Disassembler.h"
 
 // C Includes
@@ -23,8 +25,13 @@
 #include "lldb/Core/PluginManager.h"
 #include "lldb/Core/RegularExpression.h"
 #include "lldb/Core/Timer.h"
-#include "lldb/Interpreter/NamedOptionValue.h"
+#include "lldb/Interpreter/OptionValue.h"
+#include "lldb/Interpreter/OptionValueArray.h"
+#include "lldb/Interpreter/OptionValueDictionary.h"
+#include "lldb/Interpreter/OptionValueString.h"
+#include "lldb/Interpreter/OptionValueUInt64.h"
 #include "lldb/Symbol/ClangNamespaceDecl.h"
+#include "lldb/Symbol/Function.h"
 #include "lldb/Symbol/ObjectFile.h"
 #include "lldb/Target/ExecutionContext.h"
 #include "lldb/Target/Process.h"
@@ -38,7 +45,7 @@ using namespace lldb_private;
 
 
 DisassemblerSP
-Disassembler::FindPlugin (const ArchSpec &arch, const char *plugin_name)
+Disassembler::FindPlugin (const ArchSpec &arch, const char *flavor, const char *plugin_name)
 {
     Timer scoped_timer (__PRETTY_FUNCTION__,
                         "Disassembler::FindPlugin (arch = %s, plugin_name = %s)",
@@ -49,10 +56,11 @@ Disassembler::FindPlugin (const ArchSpec
     
     if (plugin_name)
     {
-        create_callback = PluginManager::GetDisassemblerCreateCallbackForPluginName (plugin_name);
+        ConstString const_plugin_name (plugin_name);
+        create_callback = PluginManager::GetDisassemblerCreateCallbackForPluginName (const_plugin_name);
         if (create_callback)
         {
-            DisassemblerSP disassembler_sp(create_callback(arch));
+            DisassemblerSP disassembler_sp(create_callback(arch, flavor));
             
             if (disassembler_sp.get())
                 return disassembler_sp;
@@ -62,7 +70,7 @@ Disassembler::FindPlugin (const ArchSpec
     {
         for (uint32_t idx = 0; (create_callback = PluginManager::GetDisassemblerCreateCallbackAtIndex(idx)) != NULL; ++idx)
         {
-            DisassemblerSP disassembler_sp(create_callback(arch));
+            DisassemblerSP disassembler_sp(create_callback(arch, flavor));
 
             if (disassembler_sp.get())
                 return disassembler_sp;
@@ -71,6 +79,20 @@ Disassembler::FindPlugin (const ArchSpec
     return DisassemblerSP();
 }
 
+DisassemblerSP
+Disassembler::FindPluginForTarget(const TargetSP target_sp, const ArchSpec &arch, const char *flavor, const char *plugin_name)
+{
+    if (target_sp && flavor == NULL)
+    {
+        // FIXME - we don't have the mechanism in place to do per-architecture settings.  But since we know that for now
+        // we only support flavors on x86 & x86_64,
+        if (arch.GetTriple().getArch() == llvm::Triple::x86
+            || arch.GetTriple().getArch() == llvm::Triple::x86_64)
+           flavor = target_sp->GetDisassemblyFlavor();
+    }
+    return FindPlugin(arch, flavor, plugin_name);
+}
+
 
 static void
 ResolveAddress (const ExecutionContext &exe_ctx,
@@ -107,6 +129,7 @@ Disassembler::Disassemble
     Debugger &debugger,
     const ArchSpec &arch,
     const char *plugin_name,
+    const char *flavor,
     const ExecutionContext &exe_ctx,
     SymbolContextList &sc_list,
     uint32_t num_instructions,
@@ -130,6 +153,7 @@ Disassembler::Disassemble
             if (Disassemble (debugger, 
                              arch, 
                              plugin_name,
+                             flavor,
                              exe_ctx, 
                              range, 
                              num_instructions,
@@ -151,6 +175,7 @@ Disassembler::Disassemble
     Debugger &debugger,
     const ArchSpec &arch,
     const char *plugin_name,
+    const char *flavor,
     const ExecutionContext &exe_ctx,
     const ConstString &name,
     Module *module,
@@ -169,10 +194,7 @@ Disassembler::Disassemble
         {
             module->FindFunctions (name,
                                    NULL,
-                                   eFunctionNameTypeBase | 
-                                   eFunctionNameTypeFull | 
-                                   eFunctionNameTypeMethod | 
-                                   eFunctionNameTypeSelector, 
+                                   eFunctionNameTypeAuto, 
                                    include_symbols,
                                    include_inlines,
                                    true,
@@ -181,10 +203,7 @@ Disassembler::Disassemble
         else if (exe_ctx.GetTargetPtr())
         {
             exe_ctx.GetTargetPtr()->GetImages().FindFunctions (name, 
-                                                               eFunctionNameTypeBase | 
-                                                               eFunctionNameTypeFull | 
-                                                               eFunctionNameTypeMethod | 
-                                                               eFunctionNameTypeSelector,
+                                                               eFunctionNameTypeAuto,
                                                                include_symbols,
                                                                include_inlines,
                                                                false,
@@ -197,6 +216,7 @@ Disassembler::Disassemble
         return Disassemble (debugger, 
                             arch, 
                             plugin_name,
+                            flavor,
                             exe_ctx, 
                             sc_list,
                             num_instructions, 
@@ -213,6 +233,7 @@ Disassembler::DisassembleRange
 (
     const ArchSpec &arch,
     const char *plugin_name,
+    const char *flavor,
     const ExecutionContext &exe_ctx,
     const AddressRange &range
 )
@@ -220,11 +241,12 @@ Disassembler::DisassembleRange
     lldb::DisassemblerSP disasm_sp;
     if (range.GetByteSize() > 0 && range.GetBaseAddress().IsValid())
     {
-        disasm_sp = Disassembler::FindPlugin(arch, plugin_name);
+        disasm_sp = Disassembler::FindPluginForTarget(exe_ctx.GetTargetSP(), arch, flavor, plugin_name);
 
         if (disasm_sp)
         {
-            size_t bytes_disassembled = disasm_sp->ParseInstructions (&exe_ctx, range, NULL);
+            const bool prefer_file_cache = false;
+            size_t bytes_disassembled = disasm_sp->ParseInstructions (&exe_ctx, range, NULL, prefer_file_cache);
             if (bytes_disassembled == 0)
                 disasm_sp.reset();
         }
@@ -233,31 +255,31 @@ Disassembler::DisassembleRange
 }
 
 lldb::DisassemblerSP 
-Disassembler::DisassembleBytes 
-(
-    const ArchSpec &arch,
-    const char *plugin_name,
-    const Address &start,
-    const void *bytes,
-    size_t length,
-    uint32_t num_instructions
-)
+Disassembler::DisassembleBytes (const ArchSpec &arch,
+                                const char *plugin_name,
+                                const char *flavor,
+                                const Address &start,
+                                const void *src,
+                                size_t src_len,
+                                uint32_t num_instructions,
+                                bool data_from_file)
 {
     lldb::DisassemblerSP disasm_sp;
     
-    if (bytes)
+    if (src)
     {
-        disasm_sp = Disassembler::FindPlugin(arch, plugin_name);
+        disasm_sp = Disassembler::FindPlugin(arch, flavor, plugin_name);
         
         if (disasm_sp)
         {
-            DataExtractor data(bytes, length, arch.GetByteOrder(), arch.GetAddressByteSize());
+            DataExtractor data(src, src_len, arch.GetByteOrder(), arch.GetAddressByteSize());
             
             (void)disasm_sp->DecodeInstructions (start,
                                                  data,
                                                  0,
                                                  num_instructions,
-                                                 false);
+                                                 false,
+                                                 data_from_file);
         }
     }
     
@@ -271,6 +293,7 @@ Disassembler::Disassemble
     Debugger &debugger,
     const ArchSpec &arch,
     const char *plugin_name,
+    const char *flavor,
     const ExecutionContext &exe_ctx,
     const AddressRange &disasm_range,
     uint32_t num_instructions,
@@ -281,15 +304,15 @@ Disassembler::Disassemble
 {
     if (disasm_range.GetByteSize())
     {
-        lldb::DisassemblerSP disasm_sp (Disassembler::FindPlugin(arch, plugin_name));
+        lldb::DisassemblerSP disasm_sp (Disassembler::FindPluginForTarget(exe_ctx.GetTargetSP(), arch, flavor, plugin_name));
 
         if (disasm_sp.get())
         {
             AddressRange range;
             ResolveAddress (exe_ctx, disasm_range.GetBaseAddress(), range.GetBaseAddress());
             range.SetByteSize (disasm_range.GetByteSize());
-            
-            size_t bytes_disassembled = disasm_sp->ParseInstructions (&exe_ctx, range, &strm);
+            const bool prefer_file_cache = false;
+            size_t bytes_disassembled = disasm_sp->ParseInstructions (&exe_ctx, range, &strm, prefer_file_cache);
             if (bytes_disassembled == 0)
                 return false;
 
@@ -312,6 +335,7 @@ Disassembler::Disassemble
     Debugger &debugger,
     const ArchSpec &arch,
     const char *plugin_name,
+    const char *flavor,
     const ExecutionContext &exe_ctx,
     const Address &start_address,
     uint32_t num_instructions,
@@ -322,13 +346,19 @@ Disassembler::Disassemble
 {
     if (num_instructions > 0)
     {
-        lldb::DisassemblerSP disasm_sp (Disassembler::FindPlugin(arch, plugin_name));
+        lldb::DisassemblerSP disasm_sp (Disassembler::FindPluginForTarget(exe_ctx.GetTargetSP(),
+                                                                          arch,
+                                                                          flavor,
+                                                                          plugin_name));
         if (disasm_sp.get())
         {
             Address addr;
             ResolveAddress (exe_ctx, start_address, addr);
-
-            size_t bytes_disassembled = disasm_sp->ParseInstructions (&exe_ctx, addr, num_instructions);
+            const bool prefer_file_cache = false;
+            size_t bytes_disassembled = disasm_sp->ParseInstructions (&exe_ctx,
+                                                                      addr,
+                                                                      num_instructions,
+                                                                      prefer_file_cache);
             if (bytes_disassembled == 0)
                 return false;
             return PrintInstructions (disasm_sp.get(),
@@ -438,7 +468,7 @@ Disassembler::PrintInstructions
                 }
                 else
                 {
-                    sc.Clear();
+                    sc.Clear(true);
                 }
             }
 
@@ -466,6 +496,7 @@ Disassembler::Disassemble
     Debugger &debugger,
     const ArchSpec &arch,
     const char *plugin_name,
+    const char *flavor,
     const ExecutionContext &exe_ctx,
     uint32_t num_instructions,
     uint32_t num_mixed_context_lines,
@@ -499,6 +530,7 @@ Disassembler::Disassemble
     return Disassemble (debugger, 
                         arch, 
                         plugin_name,
+                        flavor,
                         exe_ctx, 
                         range, 
                         num_instructions, 
@@ -534,7 +566,7 @@ Instruction::Dump (lldb_private::Stream
                    bool show_bytes,
                    const ExecutionContext* exe_ctx)
 {
-    const size_t opcode_column_width = 7;
+    size_t opcode_column_width = 7;
     const size_t operand_column_width = 25;
     
     CalculateMnemonicOperandsAndCommentIfNeeded (exe_ctx);
@@ -577,9 +609,17 @@ Instruction::Dump (lldb_private::Stream
     
     const size_t opcode_pos = ss.GetSize();
     
+    // The default opcode size of 7 characters is plenty for most architectures
+    // but some like arm can pull out the occasional vqrshrun.s16.  We won't get
+    // consistent column spacing in these cases, unfortunately.
+    if (m_opcode_name.length() >= opcode_column_width)
+    {
+        opcode_column_width = m_opcode_name.length() + 1;
+    }
+
     ss.PutCString (m_opcode_name.c_str());
     ss.FillLastLineToColumn (opcode_pos + opcode_column_width, ' ');
-    ss.PutCString (m_mnemocics.c_str());
+    ss.PutCString (m_mnemonics.c_str());
     
     if (!m_comment.empty())
     {
@@ -593,7 +633,7 @@ Instruction::Dump (lldb_private::Stream
 bool
 Instruction::DumpEmulation (const ArchSpec &arch)
 {
-	std::auto_ptr<EmulateInstruction> insn_emulator_ap (EmulateInstruction::FindPlugin (arch, eInstructionTypeAny, NULL));
+	std::unique_ptr<EmulateInstruction> insn_emulator_ap (EmulateInstruction::FindPlugin (arch, eInstructionTypeAny, NULL));
 	if (insn_emulator_ap.get())
 	{
         insn_emulator_ap->SetInstruction (GetOpcode(), GetAddress(), NULL);
@@ -623,7 +663,7 @@ Instruction::ReadArray (FILE *in_file, S
 
         std::string line (buffer);
         
-        int len = line.size();
+        size_t len = line.size();
         if (line[len-1] == '\n')
         {
             line[len-1] = '\0';
@@ -639,10 +679,11 @@ Instruction::ReadArray (FILE *in_file, S
         if (line.size() > 0)
         {
             std::string value;
-            RegularExpression reg_exp ("^[ \t]*([^ \t]+)[ \t]*$");
-            bool reg_exp_success = reg_exp.Execute (line.c_str(), 1);
+            static RegularExpression g_reg_exp ("^[ \t]*([^ \t]+)[ \t]*$");
+            RegularExpression::Match regex_match(1);
+            bool reg_exp_success = g_reg_exp.Execute (line.c_str(), &regex_match);
             if (reg_exp_success)
-                reg_exp.GetMatchAtIndex (line.c_str(), 1, value);
+                regex_match.GetMatchAtIndex (line.c_str(), 1, value);
             else
                 value = line;
                 
@@ -691,7 +732,7 @@ Instruction::ReadDictionary (FILE *in_fi
         // Check to see if the line contains the end-of-dictionary marker ("}")
         std::string line (buffer);
 
-        int len = line.size();
+        size_t len = line.size();
         if (line[len-1] == '\n')
         {
             line[len-1] = '\0';
@@ -707,14 +748,16 @@ Instruction::ReadDictionary (FILE *in_fi
         // Try to find a key-value pair in the current line and add it to the dictionary.
         if (line.size() > 0)
         {
-            RegularExpression reg_exp ("^[ \t]*([a-zA-Z_][a-zA-Z0-9_]*)[ \t]*=[ \t]*(.*)[ \t]*$");
-            bool reg_exp_success = reg_exp.Execute (line.c_str(), 2);
+            static RegularExpression g_reg_exp ("^[ \t]*([a-zA-Z_][a-zA-Z0-9_]*)[ \t]*=[ \t]*(.*)[ \t]*$");
+            RegularExpression::Match regex_match(2);
+
+            bool reg_exp_success = g_reg_exp.Execute (line.c_str(), &regex_match);
             std::string key;
             std::string value;
             if (reg_exp_success)
             {
-                reg_exp.GetMatchAtIndex (line.c_str(), 1, key);
-                reg_exp.GetMatchAtIndex (line.c_str(), 2, value);
+                regex_match.GetMatchAtIndex (line.c_str(), 1, key);
+                regex_match.GetMatchAtIndex (line.c_str(), 2, value);
             }
             else 
             {
@@ -761,7 +804,7 @@ Instruction::ReadDictionary (FILE *in_fi
             }
             else
             {
-                int len = value.size();
+                size_t len = value.size();
                 if ((value[0] == '"') && (value[len-1] == '"'))
                     value = value.substr (1, len-2);
                 value_sp.reset (new OptionValueString (value.c_str(), ""));
@@ -856,7 +899,7 @@ Instruction::TestEmulation (Stream *out_
     arch.SetTriple (llvm::Triple (value_sp->GetStringValue()));
 
     bool success = false;
-    std::auto_ptr<EmulateInstruction> insn_emulator_ap (EmulateInstruction::FindPlugin (arch, eInstructionTypeAny, NULL));
+    std::unique_ptr<EmulateInstruction> insn_emulator_ap (EmulateInstruction::FindPlugin (arch, eInstructionTypeAny, NULL));
     if (insn_emulator_ap.get())
         success = insn_emulator_ap->TestEmulation (out_stream, arch, data_dictionary);
 
@@ -877,7 +920,7 @@ Instruction::Emulate (const ArchSpec &ar
                       EmulateInstruction::ReadRegisterCallback read_reg_callback,
                       EmulateInstruction::WriteRegisterCallback write_reg_callback)
 {
-	std::auto_ptr<EmulateInstruction> insn_emulator_ap (EmulateInstruction::FindPlugin (arch, eInstructionTypeAny, NULL));
+	std::unique_ptr<EmulateInstruction> insn_emulator_ap (EmulateInstruction::FindPlugin (arch, eInstructionTypeAny, NULL));
 	if (insn_emulator_ap.get())
 	{
 		insn_emulator_ap->SetBaton (baton);
@@ -930,7 +973,7 @@ InstructionList::GetMaxOpcocdeByteSize (
 
 
 InstructionSP
-InstructionList::GetInstructionAtIndex (uint32_t idx) const
+InstructionList::GetInstructionAtIndex (size_t idx) const
 {
     InstructionSP inst_sp;
     if (idx < m_instructions.size())
@@ -992,9 +1035,9 @@ InstructionList::GetIndexOfInstructionAt
 {
     Address address;
     address.SetLoadAddress(load_addr, &target);
-    uint32_t num_instructions = m_instructions.size();
+    size_t num_instructions = m_instructions.size();
     uint32_t index = UINT32_MAX;
-    for (int i = 0; i < num_instructions; i++)
+    for (size_t i = 0; i < num_instructions; i++)
     {
         if (m_instructions[i]->GetAddress() == address)
         {
@@ -1006,12 +1049,10 @@ InstructionList::GetIndexOfInstructionAt
 }
 
 size_t
-Disassembler::ParseInstructions
-(
-    const ExecutionContext *exe_ctx,
-    const AddressRange &range,
-    Stream *error_strm_ptr
-)
+Disassembler::ParseInstructions (const ExecutionContext *exe_ctx,
+                                 const AddressRange &range,
+                                 Stream *error_strm_ptr,
+                                 bool prefer_file_cache)
 {
     if (exe_ctx)
     {
@@ -1024,12 +1065,13 @@ Disassembler::ParseInstructions
         DataBufferSP data_sp(heap_buffer);
 
         Error error;
-        const bool prefer_file_cache = true;
-        const size_t bytes_read = target->ReadMemory (range.GetBaseAddress(), 
+        lldb::addr_t load_addr = LLDB_INVALID_ADDRESS;
+        const size_t bytes_read = target->ReadMemory (range.GetBaseAddress(),
                                                       prefer_file_cache, 
                                                       heap_buffer->GetBytes(), 
                                                       heap_buffer->GetByteSize(), 
-                                                      error);
+                                                      error,
+                                                      &load_addr);
         
         if (bytes_read > 0)
         {
@@ -1038,7 +1080,8 @@ Disassembler::ParseInstructions
             DataExtractor data (data_sp, 
                                 m_arch.GetByteOrder(),
                                 m_arch.GetAddressByteSize());
-            return DecodeInstructions (range.GetBaseAddress(), data, 0, UINT32_MAX, false);
+            const bool data_from_file = load_addr == LLDB_INVALID_ADDRESS;
+            return DecodeInstructions (range.GetBaseAddress(), data, 0, UINT32_MAX, false, data_from_file);
         }
         else if (error_strm_ptr)
         {
@@ -1057,12 +1100,10 @@ Disassembler::ParseInstructions
 }
 
 size_t
-Disassembler::ParseInstructions
-(
-    const ExecutionContext *exe_ctx,
-    const Address &start,
-    uint32_t num_instructions
-)
+Disassembler::ParseInstructions (const ExecutionContext *exe_ctx,
+                                 const Address &start,
+                                 uint32_t num_instructions,
+                                 bool prefer_file_cache)
 {
     m_instruction_list.Clear();
 
@@ -1080,12 +1121,15 @@ Disassembler::ParseInstructions
     DataBufferSP data_sp (heap_buffer);
 
     Error error;
-    bool prefer_file_cache = true;
-    const size_t bytes_read = target->ReadMemory (start, 
+    lldb::addr_t load_addr = LLDB_INVALID_ADDRESS;
+    const size_t bytes_read = target->ReadMemory (start,
                                                   prefer_file_cache, 
                                                   heap_buffer->GetBytes(), 
                                                   byte_size, 
-                                                  error);
+                                                  error,
+                                                  &load_addr);
+
+    const bool data_from_file = load_addr == LLDB_INVALID_ADDRESS;
 
     if (bytes_read == 0)
         return 0;
@@ -1098,7 +1142,8 @@ Disassembler::ParseInstructions
                         data, 
                         0, 
                         num_instructions, 
-                        append_instructions);
+                        append_instructions,
+                        data_from_file);
 
     return m_instruction_list.GetSize();
 }
@@ -1106,12 +1151,16 @@ Disassembler::ParseInstructions
 //----------------------------------------------------------------------
 // Disassembler copy constructor
 //----------------------------------------------------------------------
-Disassembler::Disassembler(const ArchSpec& arch) :
+Disassembler::Disassembler(const ArchSpec& arch, const char *flavor) :
     m_arch (arch),
     m_instruction_list(),
-    m_base_addr(LLDB_INVALID_ADDRESS)
+    m_base_addr(LLDB_INVALID_ADDRESS),
+    m_flavor ()
 {
-
+    if (flavor == NULL)
+        m_flavor.assign("default");
+    else
+        m_flavor.assign(flavor);
 }
 
 //----------------------------------------------------------------------
@@ -1147,7 +1196,7 @@ PseudoInstruction::~PseudoInstruction ()
 }
      
 bool
-PseudoInstruction::DoesBranch () const
+PseudoInstruction::DoesBranch ()
 {
     // This is NOT a valid question for a pseudo instruction.
     return false;
@@ -1156,7 +1205,7 @@ PseudoInstruction::DoesBranch () const
 size_t
 PseudoInstruction::Decode (const lldb_private::Disassembler &disassembler,
                            const lldb_private::DataExtractor &data,
-                           uint32_t data_offset)
+                           lldb::offset_t data_offset)
 {
     return m_opcode.GetByteSize();
 }

Modified: lldb/branches/lldb-platform-work/source/Core/DynamicLoader.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/lldb-platform-work/source/Core/DynamicLoader.cpp?rev=183468&r1=183467&r2=183468&view=diff
==============================================================================
--- lldb/branches/lldb-platform-work/source/Core/DynamicLoader.cpp (original)
+++ lldb/branches/lldb-platform-work/source/Core/DynamicLoader.cpp Thu Jun  6 19:06:43 2013
@@ -9,6 +9,7 @@
 
 #include "lldb/lldb-private.h"
 #include "lldb/Target/DynamicLoader.h"
+#include "lldb/Target/Process.h"
 #include "lldb/Core/PluginManager.h"
 
 using namespace lldb;
@@ -20,10 +21,11 @@ DynamicLoader::FindPlugin (Process *proc
     DynamicLoaderCreateInstance create_callback = NULL;
     if (plugin_name)
     {
-        create_callback  = PluginManager::GetDynamicLoaderCreateCallbackForPluginName (plugin_name);
+        ConstString const_plugin_name(plugin_name);
+        create_callback  = PluginManager::GetDynamicLoaderCreateCallbackForPluginName (const_plugin_name);
         if (create_callback)
         {
-            std::auto_ptr<DynamicLoader> instance_ap(create_callback(process, true));
+            std::unique_ptr<DynamicLoader> instance_ap(create_callback(process, true));
             if (instance_ap.get())
                 return instance_ap.release();
         }
@@ -32,7 +34,7 @@ DynamicLoader::FindPlugin (Process *proc
     {
         for (uint32_t idx = 0; (create_callback = PluginManager::GetDynamicLoaderCreateCallbackAtIndex(idx)) != NULL; ++idx)
         {
-            std::auto_ptr<DynamicLoader> instance_ap(create_callback(process, false));
+            std::unique_ptr<DynamicLoader> instance_ap(create_callback(process, false));
             if (instance_ap.get())
                 return instance_ap.release();
         }
@@ -45,8 +47,7 @@ DynamicLoader::FindPlugin (Process *proc
 // DynamicLoader constructor
 //----------------------------------------------------------------------
 DynamicLoader::DynamicLoader(Process *process) :
-    m_process (process),
-    m_stop_when_images_change(false)    // Stop the process by default when a process' images change
+    m_process (process)
 {
 }
 
@@ -64,12 +65,12 @@ DynamicLoader::~DynamicLoader()
 bool
 DynamicLoader::GetStopWhenImagesChange () const
 {
-    return m_stop_when_images_change;
+    return m_process->GetStopOnSharedLibraryEvents();
 }
 
 void
 DynamicLoader::SetStopWhenImagesChange (bool stop)
 {
-    m_stop_when_images_change = stop;
+    m_process->SetStopOnSharedLibraryEvents (stop);
 }
 

Modified: lldb/branches/lldb-platform-work/source/Core/EmulateInstruction.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/lldb-platform-work/source/Core/EmulateInstruction.cpp?rev=183468&r1=183467&r2=183468&view=diff
==============================================================================
--- lldb/branches/lldb-platform-work/source/Core/EmulateInstruction.cpp (original)
+++ lldb/branches/lldb-platform-work/source/Core/EmulateInstruction.cpp Thu Jun  6 19:06:43 2013
@@ -32,7 +32,8 @@ EmulateInstruction::FindPlugin (const Ar
     EmulateInstructionCreateInstance create_callback = NULL;
     if (plugin_name)
     {
-        create_callback  = PluginManager::GetEmulateInstructionCreateCallbackForPluginName (plugin_name);
+        ConstString const_plugin_name (plugin_name);
+        create_callback  = PluginManager::GetEmulateInstructionCreateCallbackForPluginName (const_plugin_name);
         if (create_callback)
         {
            	EmulateInstruction *emulate_insn_ptr = create_callback(arch, supported_inst_type);
@@ -186,7 +187,7 @@ EmulateInstruction::ReadMemoryUnsigned (
         size_t bytes_read = m_read_mem_callback (this, m_baton, context, addr, buf, byte_size);
         if (bytes_read == byte_size)
         {
-            uint32_t offset = 0;
+            lldb::offset_t offset = 0;
             DataExtractor data (buf, byte_size, GetByteOrder(), GetAddressByteSize());
             uval64 = data.GetMaxU64 (&offset, byte_size);
             success = true;
@@ -361,7 +362,7 @@ EmulateInstruction::ReadMemoryDefault (E
                                        size_t length)
 {
     StreamFile strm (stdout, false);
-    strm.Printf ("    Read from Memory (address = 0x%llx, length = %zu, context = ", addr, length);
+    strm.Printf ("    Read from Memory (address = 0x%" PRIx64 ", length = %" PRIu64 ", context = ", addr, (uint64_t)length);
     context.Dump (strm, instruction);    
     strm.EOL();
     *((uint64_t *) dst) = 0xdeadbeef;
@@ -377,7 +378,7 @@ EmulateInstruction::WriteMemoryDefault (
                                         size_t length)
 {
     StreamFile strm (stdout, false);
-    strm.Printf ("    Write to Memory (address = 0x%llx, length = %zu, context = ", addr, length);
+    strm.Printf ("    Write to Memory (address = 0x%" PRIx64 ", length = %" PRIu64 ", context = ", addr, (uint64_t)length);
     context.Dump (strm, instruction);    
     strm.EOL();
     return length;
@@ -503,7 +504,7 @@ EmulateInstruction::Context::Dump (Strea
     {
     case eInfoTypeRegisterPlusOffset:
         {
-            strm.Printf (" (reg_plus_offset = %s%+lld)",
+            strm.Printf (" (reg_plus_offset = %s%+" PRId64 ")",
                          info.RegisterPlusOffset.reg.name,
                          info.RegisterPlusOffset.signed_offset);
         }
@@ -519,7 +520,7 @@ EmulateInstruction::Context::Dump (Strea
 
     case eInfoTypeRegisterToRegisterPlusOffset:
         {
-            strm.Printf (" (base_and_imm_offset = %s%+lld, data_reg = %s)", 
+            strm.Printf (" (base_and_imm_offset = %s%+" PRId64 ", data_reg = %s)",
                          info.RegisterToRegisterPlusOffset.base_reg.name, 
                          info.RegisterToRegisterPlusOffset.offset,
                          info.RegisterToRegisterPlusOffset.data_reg.name);
@@ -544,7 +545,7 @@ EmulateInstruction::Context::Dump (Strea
         break;
 
     case eInfoTypeOffset:
-        strm.Printf (" (signed_offset = %+lld)", info.signed_offset);
+        strm.Printf (" (signed_offset = %+" PRId64 ")", info.signed_offset);
         break;
         
     case eInfoTypeRegister:
@@ -552,19 +553,19 @@ EmulateInstruction::Context::Dump (Strea
         break;
         
     case eInfoTypeImmediate:
-        strm.Printf (" (unsigned_immediate = %llu (0x%16.16llx))", 
+        strm.Printf (" (unsigned_immediate = %" PRIu64 " (0x%16.16" PRIx64 "))",
                      info.unsigned_immediate, 
                      info.unsigned_immediate);
         break;
 
     case eInfoTypeImmediateSigned:
-        strm.Printf (" (signed_immediate = %+lld (0x%16.16llx))", 
+        strm.Printf (" (signed_immediate = %+" PRId64 " (0x%16.16" PRIx64 "))",
                      info.signed_immediate, 
                      info.signed_immediate);
         break;
         
     case eInfoTypeAddress:
-        strm.Printf (" (address = 0x%llx)", info.address);
+        strm.Printf (" (address = 0x%" PRIx64 ")", info.address);
         break;
         
     case eInfoTypeISAAndImmediate:
@@ -587,10 +588,6 @@ EmulateInstruction::Context::Dump (Strea
         
     case eInfoTypeNoArgs:
         break;
-
-    default:
-        strm.Printf (" (unknown <info_type>)");
-        break;
     }
 }
 

Modified: lldb/branches/lldb-platform-work/source/Core/Error.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/lldb-platform-work/source/Core/Error.cpp?rev=183468&r1=183467&r2=183468&view=diff
==============================================================================
--- lldb/branches/lldb-platform-work/source/Core/Error.cpp (original)
+++ lldb/branches/lldb-platform-work/source/Core/Error.cpp Thu Jun  6 19:06:43 2013
@@ -20,7 +20,7 @@
 #include <cstdlib>
 #include <cstring>
 
-#if defined (__arm__)
+#if defined (__arm__) && defined (__APPLE__)
 #include <SpringBoardServices/SpringBoardServer.h>
 #endif
 
@@ -356,7 +356,7 @@ Error::SetErrorStringWithVarArg (const c
         // allocated buffer above
         va_list copy_args;
         va_copy (copy_args, args);
-        size_t length = ::vsnprintf (buf.data(), buf.size(), format, args);
+        unsigned length = ::vsnprintf (buf.data(), buf.size(), format, args);
         if (length >= buf.size())
         {
             // The error formatted string didn't fit into our buffer, resize it

Modified: lldb/branches/lldb-platform-work/source/Core/Event.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/lldb-platform-work/source/Core/Event.cpp?rev=183468&r1=183467&r2=183468&view=diff
==============================================================================
--- lldb/branches/lldb-platform-work/source/Core/Event.cpp (original)
+++ lldb/branches/lldb-platform-work/source/Core/Event.cpp Thu Jun  6 19:06:43 2013
@@ -52,7 +52,25 @@ Event::~Event ()
 void
 Event::Dump (Stream *s) const
 {
-    s->Printf("%p Event: broadcaster = %p, type = 0x%8.8x, data = ", this, m_broadcaster, m_type);
+    if (m_broadcaster)
+    {
+        StreamString event_name;
+        if (m_broadcaster->GetEventNames (event_name, m_type, false))
+            s->Printf("%p Event: broadcaster = %p (%s), type = 0x%8.8x (%s), data = ",
+                      this,
+                      m_broadcaster,
+                      m_broadcaster->GetBroadcasterName().GetCString(),
+                      m_type,
+                      event_name.GetString().c_str());
+        else
+            s->Printf("%p Event: broadcaster = %p (%s), type = 0x%8.8x, data = ",
+                      this,
+                      m_broadcaster,
+                      m_broadcaster->GetBroadcasterName().GetCString(),
+                      m_type);
+    }
+    else
+        s->Printf("%p Event: broadcaster = NULL, type = 0x%8.8x, data = ", this, m_type);
 
     if (m_data_ap.get() == NULL)
         s->Printf ("<NULL>");

Modified: lldb/branches/lldb-platform-work/source/Core/FileLineResolver.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/lldb-platform-work/source/Core/FileLineResolver.cpp?rev=183468&r1=183467&r2=183468&view=diff
==============================================================================
--- lldb/branches/lldb-platform-work/source/Core/FileLineResolver.cpp (original)
+++ lldb/branches/lldb-platform-work/source/Core/FileLineResolver.cpp Thu Jun  6 19:06:43 2013
@@ -13,6 +13,7 @@
 #include "lldb/lldb-private-log.h"
 #include "lldb/Core/Log.h"
 #include "lldb/Core/StreamString.h"
+#include "lldb/Symbol/CompileUnit.h"
 #include "lldb/Symbol/LineTable.h"
 
 using namespace lldb;
@@ -89,10 +90,8 @@ FileLineResolver::GetDepth()
 void
 FileLineResolver::GetDescription (Stream *s)
 {
-    s->Printf ("File and line resolver for file: \"%s%s%s\" line: %u", 
-               m_file_spec.GetDirectory().GetCString(),
-               m_file_spec.GetDirectory() ? "/" : "",
-               m_file_spec.GetFilename().GetCString(),
+    s->Printf ("File and line resolver for file: \"%s\" line: %u", 
+               m_file_spec.GetPath().c_str(),
                m_line_number);
 }
 

Modified: lldb/branches/lldb-platform-work/source/Core/FileSpecList.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/lldb-platform-work/source/Core/FileSpecList.cpp?rev=183468&r1=183467&r2=183468&view=diff
==============================================================================
--- lldb/branches/lldb-platform-work/source/Core/FileSpecList.cpp (original)
+++ lldb/branches/lldb-platform-work/source/Core/FileSpecList.cpp Thu Jun  6 19:06:43 2013
@@ -94,7 +94,7 @@ FileSpecList::Dump(Stream *s, const char
     for (pos = m_files.begin(); pos != end; ++pos)
     {
         pos->Dump(s);
-        if (separator_cstr)
+        if (separator_cstr && ((pos + 1) != end))
             s->PutCString(separator_cstr);
     }
 }
@@ -106,17 +106,16 @@ FileSpecList::Dump(Stream *s, const char
 // Returns the valid index of the file that matches "file_spec" if
 // it is found, else UINT32_MAX is returned.
 //------------------------------------------------------------------
-uint32_t
-FileSpecList::FindFileIndex (uint32_t start_idx, const FileSpec &file_spec, bool full) const
+size_t
+FileSpecList::FindFileIndex (size_t start_idx, const FileSpec &file_spec, bool full) const
 {
-    const uint32_t num_files = m_files.size();
-    uint32_t idx;
+    const size_t num_files = m_files.size();
 
     // When looking for files, we will compare only the filename if the
     // FILE_SPEC argument is empty
     bool compare_filename_only = file_spec.GetDirectory().IsEmpty();
 
-    for (idx = start_idx; idx < num_files; ++idx)
+    for (size_t idx = start_idx; idx < num_files; ++idx)
     {
         if (compare_filename_only)
         {
@@ -139,7 +138,7 @@ FileSpecList::FindFileIndex (uint32_t st
 // range, then an empty FileSpec object will be returned.
 //------------------------------------------------------------------
 const FileSpec &
-FileSpecList::GetFileSpecAtIndex(uint32_t idx) const
+FileSpecList::GetFileSpecAtIndex(size_t idx) const
 {
 
     if (idx < m_files.size())
@@ -149,7 +148,7 @@ FileSpecList::GetFileSpecAtIndex(uint32_
 }
 
 const FileSpec *
-FileSpecList::GetFileSpecPointerAtIndex(uint32_t idx) const
+FileSpecList::GetFileSpecPointerAtIndex(size_t idx) const
 {
     if (idx < m_files.size())
         return &m_files[idx];
@@ -179,7 +178,7 @@ FileSpecList::MemorySize () const
 //------------------------------------------------------------------
 // Return the number of files in the file spec list.
 //------------------------------------------------------------------
-uint32_t
+size_t
 FileSpecList::GetSize() const
 {
     return m_files.size();

Removed: lldb/branches/lldb-platform-work/source/Core/FormatClasses.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/lldb-platform-work/source/Core/FormatClasses.cpp?rev=183467&view=auto
==============================================================================
--- lldb/branches/lldb-platform-work/source/Core/FormatClasses.cpp (original)
+++ lldb/branches/lldb-platform-work/source/Core/FormatClasses.cpp (removed)
@@ -1,357 +0,0 @@
-//===-- FormatClasses.cpp ----------------------------------------*- C++ -*-===//
-//
-//                     The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-// C Includes
-
-// C++ Includes
-
-// Other libraries and framework includes
-
-// Project includes
-#include "lldb/lldb-public.h"
-#include "lldb/lldb-enumerations.h"
-
-#include "lldb/Core/Debugger.h"
-#include "lldb/Core/FormatClasses.h"
-#include "lldb/Core/StreamString.h"
-#include "lldb/Core/Timer.h"
-#include "lldb/Interpreter/CommandInterpreter.h"
-#include "lldb/Symbol/ClangASTType.h"
-#include "lldb/Target/StackFrame.h"
-#include "lldb/Target/Target.h"
-
-using namespace lldb;
-using namespace lldb_private;
-
-TypeFormatImpl::TypeFormatImpl (lldb::Format f,
-                          const Flags& flags) : 
-    m_flags(flags),
-    m_format (f)
-{
-}
-
-std::string
-TypeFormatImpl::GetDescription()
-{
-    StreamString sstr;
-    sstr.Printf ("%s%s%s%s\n", 
-                 FormatManager::GetFormatAsCString (GetFormat()),
-                 Cascades() ? "" : " (not cascading)",
-                 SkipsPointers() ? " (skip pointers)" : "",
-                 SkipsReferences() ? " (skip references)" : "");
-    return sstr.GetString();
-}
-
-TypeSummaryImpl::TypeSummaryImpl(const TypeSummaryImpl::Flags& flags) :
-    m_flags(flags)
-{
-}
-
-
-StringSummaryFormat::StringSummaryFormat(const TypeSummaryImpl::Flags& flags,
-                                         const char *format_cstr) :
-    TypeSummaryImpl(flags),
-    m_format()
-{
-  if (format_cstr)
-    m_format.assign(format_cstr);
-}
-
-bool
-StringSummaryFormat::FormatObject(ValueObject *valobj,
-                                  std::string& retval)
-{
-    if (!valobj)
-    {
-        retval.assign("NULL ValueObject");
-        return false;
-    }
-    
-    StreamString s;
-    ExecutionContext exe_ctx (valobj->GetExecutionContextRef());
-    SymbolContext sc;
-    StackFrame *frame = exe_ctx.GetFramePtr();
-    if (frame)
-        sc = frame->GetSymbolContext(lldb::eSymbolContextEverything);
-    
-    if (IsOneliner())
-    {
-        ValueObject* object;
-        
-        ValueObjectSP synth_valobj = valobj->GetSyntheticValue();
-        if (synth_valobj)
-            object = synth_valobj.get();
-        else
-            object = valobj;
-        
-        const uint32_t num_children = object->GetNumChildren();
-        if (num_children)
-        {
-            s.PutChar('(');
-            
-            for (uint32_t idx=0; idx<num_children; ++idx)
-            {
-                lldb::ValueObjectSP child_sp(object->GetChildAtIndex(idx, true));
-                if (child_sp.get())
-                {
-                    if (idx)
-                        s.PutCString(", ");
-                    if (!HideNames())
-                    {
-                        s.PutCString(child_sp.get()->GetName().AsCString());
-                        s.PutCString(" = ");
-                    }
-                    child_sp.get()->DumpPrintableRepresentation(s,
-                                                                ValueObject::eValueObjectRepresentationStyleSummary,
-                                                                lldb::eFormatInvalid,
-                                                                ValueObject::ePrintableRepresentationSpecialCasesDisable);
-                }
-            }
-            
-            s.PutChar(')');
-            
-            retval.assign(s.GetString());
-            return true;
-        }
-        else
-        {
-            retval.assign("error: oneliner for no children");
-            return false;
-        }
-        
-    }
-    else
-    {
-        if (Debugger::FormatPrompt(m_format.c_str(), &sc, &exe_ctx, &sc.line_entry.range.GetBaseAddress(), s, NULL, valobj))
-        {
-            retval.assign(s.GetString());
-            return true;
-        }
-        else
-        {
-            retval.assign("error: summary string parsing error");
-            return false;
-        }
-    }
-}
-
-std::string
-StringSummaryFormat::GetDescription()
-{
-    StreamString sstr;
-    
-    sstr.Printf ("`%s`%s%s%s%s%s%s%s",      m_format.c_str(),
-                 Cascades() ? "" : " (not cascading)",
-                 !DoesPrintChildren() ? "" : " (show children)",
-                 !DoesPrintValue() ? " (hide value)" : "",
-                 IsOneliner() ? " (one-line printout)" : "",
-                 SkipsPointers() ? " (skip pointers)" : "",
-                 SkipsReferences() ? " (skip references)" : "",
-                 HideNames() ? " (hide member names)" : "");
-    return sstr.GetString();
-}
-
-#ifndef LLDB_DISABLE_PYTHON
-
-
-ScriptSummaryFormat::ScriptSummaryFormat(const TypeSummaryImpl::Flags& flags,
-                                         const char * function_name,
-                                         const char * python_script) :
-    TypeSummaryImpl(flags),
-    m_function_name(),
-    m_python_script(),
-    m_script_function_sp()
-{
-   if (function_name)
-     m_function_name.assign(function_name);
-   if (python_script)
-     m_python_script.assign(python_script);
-}
-
-bool
-ScriptSummaryFormat::FormatObject(ValueObject *valobj,
-                                  std::string& retval)
-{
-    Timer scoped_timer (__PRETTY_FUNCTION__, __PRETTY_FUNCTION__);
-
-    TargetSP target_sp(valobj->GetTargetSP());
-
-    if (!target_sp)
-    {
-        retval.assign("error: no target");
-        return false;
-    }
-
-    ScriptInterpreter *script_interpreter = target_sp->GetDebugger().GetCommandInterpreter().GetScriptInterpreter();
-
-    if (!script_interpreter)
-    {
-        retval.assign("error: no ScriptInterpreter");
-        return false;
-    }
-        
-    return script_interpreter->GetScriptedSummary(m_function_name.c_str(),
-                                                  valobj->GetSP(),
-                                                  m_script_function_sp,
-                                                  retval);
-
-}
-
-std::string
-ScriptSummaryFormat::GetDescription()
-{
-    StreamString sstr;
-    sstr.Printf ("%s%s%s%s%s%s%s\n%s",       Cascades() ? "" : " (not cascading)",
-                 !DoesPrintChildren() ? "" : " (show children)",
-                 !DoesPrintValue() ? " (hide value)" : "",
-                 IsOneliner() ? " (one-line printout)" : "",
-                 SkipsPointers() ? " (skip pointers)" : "",
-                 SkipsReferences() ? " (skip references)" : "",
-                 HideNames() ? " (hide member names)" : "",
-                 m_python_script.c_str());
-    return sstr.GetString();
-    
-}
-
-#endif // #ifndef LLDB_DISABLE_PYTHON
-
-std::string
-TypeFilterImpl::GetDescription()
-{
-    StreamString sstr;
-    sstr.Printf("%s%s%s {\n",
-                Cascades() ? "" : " (not cascading)",
-                SkipsPointers() ? " (skip pointers)" : "",
-                SkipsReferences() ? " (skip references)" : "");
-    
-    for (int i = 0; i < GetCount(); i++)
-    {
-        sstr.Printf("    %s\n",
-                    GetExpressionPathAtIndex(i));
-    }
-                    
-    sstr.Printf("}");
-    return sstr.GetString();
-}
-
-std::string
-SyntheticArrayView::GetDescription()
-{
-    StreamString sstr;
-    sstr.Printf("%s%s%s {\n",
-                Cascades() ? "" : " (not cascading)",
-                SkipsPointers() ? " (skip pointers)" : "",
-                SkipsReferences() ? " (skip references)" : "");
-    
-    SyntheticArrayRange* ptr = &m_head;
-    while (ptr && ptr != m_tail)
-    {
-        if (ptr->GetLow() == ptr->GetHigh())
-            sstr.Printf("    [%d]\n",
-                        ptr->GetLow());
-        else
-            sstr.Printf("    [%d-%d]\n",
-                        ptr->GetLow(),
-                        ptr->GetHigh());
-        ptr = ptr->GetNext();
-    }
-    
-    sstr.Printf("}");
-    return sstr.GetString();
-}
-
-#ifndef LLDB_DISABLE_PYTHON
-
-TypeSyntheticImpl::FrontEnd::FrontEnd(std::string pclass, ValueObject &backend) :
-    SyntheticChildrenFrontEnd(backend),
-    m_python_class(pclass),
-    m_wrapper_sp(),
-    m_interpreter(NULL)
-{
-    if (backend == NULL)
-        return;
-    
-    TargetSP target_sp = backend.GetTargetSP();
-    
-    if (!target_sp)
-        return;
-    
-    m_interpreter = target_sp->GetDebugger().GetCommandInterpreter().GetScriptInterpreter();
-    
-    if (m_interpreter != NULL)
-        m_wrapper_sp = m_interpreter->CreateSyntheticScriptedProvider(m_python_class, backend.GetSP());
-}
-
-TypeSyntheticImpl::FrontEnd::~FrontEnd()
-{
-}
-
-lldb::ValueObjectSP
-TypeSyntheticImpl::FrontEnd::GetChildAtIndex (uint32_t idx, bool can_create)
-{
-    if (!m_wrapper_sp || !m_interpreter)
-        return lldb::ValueObjectSP();
-    
-    return m_interpreter->GetChildAtIndex(m_wrapper_sp, idx);
-}
-
-std::string
-TypeSyntheticImpl::GetDescription()
-{
-    StreamString sstr;
-    sstr.Printf("%s%s%s Python class %s",
-                Cascades() ? "" : " (not cascading)",
-                SkipsPointers() ? " (skip pointers)" : "",
-                SkipsReferences() ? " (skip references)" : "",
-                m_python_class.c_str());
-    
-    return sstr.GetString();
-}
-
-#endif // #ifndef LLDB_DISABLE_PYTHON
-
-int
-SyntheticArrayView::GetRealIndexForIndex(int i)
-{
-    if (i >= GetCount())
-        return -1;
-    
-    SyntheticArrayRange* ptr = &m_head;
-    
-    int residual = i;
-    
-    while(ptr && ptr != m_tail)
-    {
-        if (residual >= ptr->GetSelfCount())
-        {
-            residual -= ptr->GetSelfCount();
-            ptr = ptr->GetNext();
-        }
-        
-        return ptr->GetLow() + residual;
-    }
-    
-    return -1;
-}
-
-uint32_t
-SyntheticArrayView::FrontEnd::GetIndexOfChildWithName (const ConstString &name_cs)
-{
-    const char* name_cstr = name_cs.GetCString();
-    if (*name_cstr != '[')
-        return UINT32_MAX;
-    std::string name(name_cstr+1);
-    if (name[name.size()-1] != ']')
-        return UINT32_MAX;
-    name = name.erase(name.size()-1,1);
-    int index = Args::StringToSInt32 (name.c_str(), -1);
-    if (index < 0)
-        return UINT32_MAX;
-    return index;
-}

Removed: lldb/branches/lldb-platform-work/source/Core/FormatManager.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/lldb-platform-work/source/Core/FormatManager.cpp?rev=183467&view=auto
==============================================================================
--- lldb/branches/lldb-platform-work/source/Core/FormatManager.cpp (original)
+++ lldb/branches/lldb-platform-work/source/Core/FormatManager.cpp (removed)
@@ -1,1171 +0,0 @@
-//===-- FormatManager.cpp -------------------------------------------*- C++ -*-===//
-//
-//                     The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-#include "lldb/Core/FormatManager.h"
-
-// C Includes
-// C++ Includes
-// Other libraries and framework includes
-// Project includes
-
-#include "lldb/Core/Debugger.h"
-
-using namespace lldb;
-using namespace lldb_private;
-
-
-struct FormatInfo
-{
-    Format format;
-    const char format_char; // One or more format characters that can be used for this format.
-    const char *format_name;    // Long format name that can be used to specify the current format
-};
-
-static FormatInfo 
-g_format_infos[] = 
-{
-    { eFormatDefault        , '\0'  , "default"             },
-    { eFormatBoolean        , 'B'   , "boolean"             },
-    { eFormatBinary         , 'b'   , "binary"              },
-    { eFormatBytes          , 'y'   , "bytes"               },
-    { eFormatBytesWithASCII , 'Y'   , "bytes with ASCII"    },
-    { eFormatChar           , 'c'   , "character"           },
-    { eFormatCharPrintable  , 'C'   , "printable character" },
-    { eFormatComplexFloat   , 'F'   , "complex float"       },
-    { eFormatCString        , 's'   , "c-string"            },
-    { eFormatDecimal        , 'd'   , "decimal"             },
-    { eFormatEnum           , 'E'   , "enumeration"         },
-    { eFormatHex            , 'x'   , "hex"                 },
-    { eFormatHexUppercase   , 'X'   , "uppercase hex"       },
-    { eFormatFloat          , 'f'   , "float"               },
-    { eFormatOctal          , 'o'   , "octal"               },
-    { eFormatOSType         , 'O'   , "OSType"              },
-    { eFormatUnicode16      , 'U'   , "unicode16"           },
-    { eFormatUnicode32      , '\0'  , "unicode32"           },
-    { eFormatUnsigned       , 'u'   , "unsigned decimal"    },
-    { eFormatPointer        , 'p'   , "pointer"             },
-    { eFormatVectorOfChar   , '\0'  , "char[]"              },
-    { eFormatVectorOfSInt8  , '\0'  , "int8_t[]"            },
-    { eFormatVectorOfUInt8  , '\0'  , "uint8_t[]"           },
-    { eFormatVectorOfSInt16 , '\0'  , "int16_t[]"           },
-    { eFormatVectorOfUInt16 , '\0'  , "uint16_t[]"          },
-    { eFormatVectorOfSInt32 , '\0'  , "int32_t[]"           },
-    { eFormatVectorOfUInt32 , '\0'  , "uint32_t[]"          },
-    { eFormatVectorOfSInt64 , '\0'  , "int64_t[]"           },
-    { eFormatVectorOfUInt64 , '\0'  , "uint64_t[]"          },
-    { eFormatVectorOfFloat32, '\0'  , "float32[]"           },
-    { eFormatVectorOfFloat64, '\0'  , "float64[]"           },
-    { eFormatVectorOfUInt128, '\0'  , "uint128_t[]"         },
-    { eFormatComplexInteger , 'I'   , "complex integer"     },
-    { eFormatCharArray      , 'a'   , "character array"     },
-    { eFormatAddressInfo    , 'A'   , "address"             },
-    { eFormatHexFloat       , '\0'  , "hex float"           },
-    { eFormatInstruction    , 'i'   , "instruction"         },
-    { eFormatVoid           , 'v'   , "void"                }
-};
-
-static uint32_t 
-g_num_format_infos = sizeof(g_format_infos)/sizeof(FormatInfo);
-
-static bool
-GetFormatFromFormatChar (char format_char, Format &format)
-{
-    for (uint32_t i=0; i<g_num_format_infos; ++i)
-    {
-        if (g_format_infos[i].format_char == format_char)
-        {
-            format = g_format_infos[i].format;
-            return true;
-        }
-    }
-    format = eFormatInvalid;
-    return false;
-}
-
-static bool
-GetFormatFromFormatName (const char *format_name, bool partial_match_ok, Format &format)
-{
-    uint32_t i;
-    for (i=0; i<g_num_format_infos; ++i)
-    {
-        if (strcasecmp (g_format_infos[i].format_name, format_name) == 0)
-        {
-            format = g_format_infos[i].format;
-            return true;
-        }
-    }
-    
-    if (partial_match_ok)
-    {
-        for (i=0; i<g_num_format_infos; ++i)
-        {
-            if (strcasestr (g_format_infos[i].format_name, format_name) == g_format_infos[i].format_name)
-            {
-                format = g_format_infos[i].format;
-                return true;
-            }
-        }
-    }
-    format = eFormatInvalid;
-    return false;
-}
-
-bool
-FormatManager::GetFormatFromCString (const char *format_cstr,
-                                     bool partial_match_ok,
-                                     lldb::Format &format)
-{
-    bool success = false;
-    if (format_cstr && format_cstr[0])
-    {
-        if (format_cstr[1] == '\0')
-        {
-            success = GetFormatFromFormatChar (format_cstr[0], format);
-            if (success)
-                return true;
-        }
-        
-        success = GetFormatFromFormatName (format_cstr, partial_match_ok, format);
-    }
-    if (!success)
-        format = eFormatInvalid;
-    return success;
-}
-
-char
-FormatManager::GetFormatAsFormatChar (lldb::Format format)
-{
-    for (uint32_t i=0; i<g_num_format_infos; ++i)
-    {
-        if (g_format_infos[i].format == format)
-            return g_format_infos[i].format_char;
-    }
-    return '\0';
-}
-    
-
-
-const char *
-FormatManager::GetFormatAsCString (Format format)
-{
-    if (format >= eFormatDefault && format < kNumFormats)
-        return g_format_infos[format].format_name;
-    return NULL;
-}
-
-TypeCategoryImpl::TypeCategoryImpl(IFormatChangeListener* clist,
-                                   ConstString name) :
-    m_summary_nav(new SummaryNavigator("summary",clist)),
-    m_regex_summary_nav(new RegexSummaryNavigator("regex-summary",clist)),
-    m_filter_nav(new FilterNavigator("filter",clist)),
-    m_regex_filter_nav(new RegexFilterNavigator("regex-filter",clist)),
-#ifndef LLDB_DISABLE_PYTHON
-    m_synth_nav(new SynthNavigator("synth",clist)),
-    m_regex_synth_nav(new RegexSynthNavigator("regex-synth",clist)),
-#endif
-    m_enabled(false),
-    m_change_listener(clist),
-    m_mutex(Mutex::eMutexTypeRecursive),
-    m_name(name)
-{}
-
-bool
-TypeCategoryImpl::Get (ValueObject& valobj,
-                     lldb::TypeSummaryImplSP& entry,
-                     lldb::DynamicValueType use_dynamic,
-                     uint32_t* reason)
-{
-    if (!IsEnabled())
-        return false;
-    if (GetSummaryNavigator()->Get(valobj, entry, use_dynamic, reason))
-        return true;
-    bool regex = GetRegexSummaryNavigator()->Get(valobj, entry, use_dynamic, reason);
-    if (regex && reason)
-        *reason |= lldb_private::eFormatterChoiceCriterionRegularExpressionSummary;
-    return regex;
-}
-
-bool
-TypeCategoryImpl::Get(ValueObject& valobj,
-                    lldb::SyntheticChildrenSP& entry_sp,
-                    lldb::DynamicValueType use_dynamic,
-                    uint32_t* reason)
-{
-    if (!IsEnabled())
-        return false;
-    TypeFilterImpl::SharedPointer filter_sp;
-    uint32_t reason_filter = 0;
-    bool regex_filter = false;
-    // first find both Filter and Synth, and then check which is most recent
-    
-    if (!GetFilterNavigator()->Get(valobj, filter_sp, use_dynamic, &reason_filter))
-        regex_filter = GetRegexFilterNavigator()->Get (valobj, filter_sp, use_dynamic, &reason_filter);
-
-#ifndef LLDB_DISABLE_PYTHON
-    bool regex_synth = false;
-    uint32_t reason_synth = 0;    
-    bool pick_synth = false;
-    TypeSyntheticImpl::SharedPointer synth;
-    if (!GetSyntheticNavigator()->Get(valobj, synth, use_dynamic, &reason_synth))
-        regex_synth = GetRegexSyntheticNavigator()->Get (valobj, synth, use_dynamic, &reason_synth);
-    if (!filter_sp.get() && !synth.get())
-        return false;
-    else if (!filter_sp.get() && synth.get())
-        pick_synth = true;
-    
-    else if (filter_sp.get() && !synth.get())
-        pick_synth = false;
-    
-    else /*if (filter_sp.get() && synth.get())*/
-    {
-        if (filter_sp->GetRevision() > synth->GetRevision())
-            pick_synth = false;
-        else
-            pick_synth = true;
-    }
-    if (pick_synth)
-    {
-        if (regex_synth && reason)
-            *reason |= lldb_private::eFormatterChoiceCriterionRegularExpressionFilter;
-        entry_sp = synth;
-        return true;
-    }
-    else
-    {
-        if (regex_filter && reason)
-            *reason |= lldb_private::eFormatterChoiceCriterionRegularExpressionFilter;
-        entry_sp = filter_sp;
-        return true;
-    }
-
-#else
-    if (filter_sp)
-    {
-        entry_sp = filter_sp;
-        return true;
-    }
-#endif
-
-    return false;    
-    
-}
-
-void
-TypeCategoryImpl::Clear (FormatCategoryItems items)
-{
-    if ( (items & eFormatCategoryItemSummary) == eFormatCategoryItemSummary )
-        m_summary_nav->Clear();
-    if ( (items & eFormatCategoryItemRegexSummary) == eFormatCategoryItemRegexSummary )
-        m_regex_summary_nav->Clear();
-    if ( (items & eFormatCategoryItemFilter)  == eFormatCategoryItemFilter )
-        m_filter_nav->Clear();
-    if ( (items & eFormatCategoryItemRegexFilter) == eFormatCategoryItemRegexFilter )
-        m_regex_filter_nav->Clear();
-#ifndef LLDB_DISABLE_PYTHON
-    if ( (items & eFormatCategoryItemSynth)  == eFormatCategoryItemSynth )
-        m_synth_nav->Clear();
-    if ( (items & eFormatCategoryItemRegexSynth) == eFormatCategoryItemRegexSynth )
-        m_regex_synth_nav->Clear();
-#endif
-}
-
-bool
-TypeCategoryImpl::Delete (ConstString name,
-                        FormatCategoryItems items)
-{
-    bool success = false;
-    if ( (items & eFormatCategoryItemSummary) == eFormatCategoryItemSummary )
-        success = m_summary_nav->Delete(name) || success;
-    if ( (items & eFormatCategoryItemRegexSummary) == eFormatCategoryItemRegexSummary )
-        success = m_regex_summary_nav->Delete(name) || success;
-    if ( (items & eFormatCategoryItemFilter)  == eFormatCategoryItemFilter )
-        success = m_filter_nav->Delete(name) || success;
-    if ( (items & eFormatCategoryItemRegexFilter) == eFormatCategoryItemRegexFilter )
-        success = m_regex_filter_nav->Delete(name) || success;
-#ifndef LLDB_DISABLE_PYTHON
-    if ( (items & eFormatCategoryItemSynth)  == eFormatCategoryItemSynth )
-        success = m_synth_nav->Delete(name) || success;
-    if ( (items & eFormatCategoryItemRegexSynth) == eFormatCategoryItemRegexSynth )
-        success = m_regex_synth_nav->Delete(name) || success;
-#endif
-    return success;
-}
-
-uint32_t
-TypeCategoryImpl::GetCount (FormatCategoryItems items)
-{
-    uint32_t count = 0;
-    if ( (items & eFormatCategoryItemSummary) == eFormatCategoryItemSummary )
-        count += m_summary_nav->GetCount();
-    if ( (items & eFormatCategoryItemRegexSummary) == eFormatCategoryItemRegexSummary )
-        count += m_regex_summary_nav->GetCount();
-    if ( (items & eFormatCategoryItemFilter)  == eFormatCategoryItemFilter )
-        count += m_filter_nav->GetCount();
-    if ( (items & eFormatCategoryItemRegexFilter) == eFormatCategoryItemRegexFilter )
-        count += m_regex_filter_nav->GetCount();
-#ifndef LLDB_DISABLE_PYTHON
-    if ( (items & eFormatCategoryItemSynth)  == eFormatCategoryItemSynth )
-        count += m_synth_nav->GetCount();
-    if ( (items & eFormatCategoryItemRegexSynth) == eFormatCategoryItemRegexSynth )
-        count += m_regex_synth_nav->GetCount();
-#endif
-    return count;
-}
-
-bool
-TypeCategoryImpl::AnyMatches(ConstString type_name,
-                           FormatCategoryItems items,
-                           bool only_enabled,
-                           const char** matching_category,
-                           FormatCategoryItems* matching_type)
-{
-    if (!IsEnabled() && only_enabled)
-        return false;
-    
-    lldb::TypeSummaryImplSP summary;
-    TypeFilterImpl::SharedPointer filter;
-#ifndef LLDB_DISABLE_PYTHON
-    TypeSyntheticImpl::SharedPointer synth;
-#endif
-    
-    if ( (items & eFormatCategoryItemSummary) == eFormatCategoryItemSummary )
-    {
-        if (m_summary_nav->Get(type_name, summary))
-        {
-            if (matching_category)
-                *matching_category = m_name.GetCString();
-            if (matching_type)
-                *matching_type = eFormatCategoryItemSummary;
-            return true;
-        }
-    }
-    if ( (items & eFormatCategoryItemRegexSummary) == eFormatCategoryItemRegexSummary )
-    {
-        if (m_regex_summary_nav->Get(type_name, summary))
-        {
-            if (matching_category)
-                *matching_category = m_name.GetCString();
-            if (matching_type)
-                *matching_type = eFormatCategoryItemRegexSummary;
-            return true;
-        }
-    }
-    if ( (items & eFormatCategoryItemFilter)  == eFormatCategoryItemFilter )
-    {
-        if (m_filter_nav->Get(type_name, filter))
-        {
-            if (matching_category)
-                *matching_category = m_name.GetCString();
-            if (matching_type)
-                *matching_type = eFormatCategoryItemFilter;
-            return true;
-        }
-    }
-    if ( (items & eFormatCategoryItemRegexFilter) == eFormatCategoryItemRegexFilter )
-    {
-        if (m_regex_filter_nav->Get(type_name, filter))
-        {
-            if (matching_category)
-                *matching_category = m_name.GetCString();
-            if (matching_type)
-                *matching_type = eFormatCategoryItemRegexFilter;
-            return true;
-        }
-    }
-#ifndef LLDB_DISABLE_PYTHON
-    if ( (items & eFormatCategoryItemSynth)  == eFormatCategoryItemSynth )
-    {
-        if (m_synth_nav->Get(type_name, synth))
-        {
-            if (matching_category)
-                *matching_category = m_name.GetCString();
-            if (matching_type)
-                *matching_type = eFormatCategoryItemSynth;
-            return true;
-        }
-    }
-    if ( (items & eFormatCategoryItemRegexSynth) == eFormatCategoryItemRegexSynth )
-    {
-        if (m_regex_synth_nav->Get(type_name, synth))
-        {
-            if (matching_category)
-                *matching_category = m_name.GetCString();
-            if (matching_type)
-                *matching_type = eFormatCategoryItemRegexSynth;
-            return true;
-        }
-    }
-#endif
-    return false;
-}
-
-bool
-CategoryMap::AnyMatches (ConstString type_name,
-                         TypeCategoryImpl::FormatCategoryItems items,
-                         bool only_enabled,
-                         const char** matching_category,
-                         TypeCategoryImpl::FormatCategoryItems* matching_type)
-{
-    Mutex::Locker(m_map_mutex);
-    
-    MapIterator pos, end = m_map.end();
-    for (pos = m_map.begin(); pos != end; pos++)
-    {
-        if (pos->second->AnyMatches(type_name,
-                                    items,
-                                    only_enabled,
-                                    matching_category,
-                                    matching_type))
-            return true;
-    }
-    return false;
-}
-
-lldb::TypeSummaryImplSP
-CategoryMap::GetSummaryFormat (ValueObject& valobj,
-                               lldb::DynamicValueType use_dynamic)
-{
-    Mutex::Locker(m_map_mutex);
-    
-    uint32_t reason_why;        
-    ActiveCategoriesIterator begin, end = m_active_categories.end();
-    
-    for (begin = m_active_categories.begin(); begin != end; begin++)
-    {
-        lldb::TypeCategoryImplSP category = *begin;
-        lldb::TypeSummaryImplSP current_format;
-        if (!category->Get(valobj, current_format, use_dynamic, &reason_why))
-            continue;
-        return current_format;
-    }
-    return lldb::TypeSummaryImplSP();
-}
-
-lldb::TypeSummaryImplSP
-FormatManager::GetSummaryForType (lldb::TypeNameSpecifierImplSP type_sp)
-{
-    if (!type_sp)
-        return lldb::TypeSummaryImplSP();
-    lldb::TypeSummaryImplSP summary_chosen_sp;
-    uint32_t num_categories = m_categories_map.GetCount();
-    lldb::TypeCategoryImplSP category_sp;
-    uint32_t prio_category = UINT32_MAX;
-    for (uint32_t category_id = 0;
-         category_id < num_categories;
-         category_id++)
-    {
-        category_sp = GetCategoryAtIndex(category_id);
-        if (category_sp->IsEnabled() == false)
-            continue;
-        lldb::TypeSummaryImplSP summary_current_sp = category_sp->GetSummaryForType(type_sp);
-        if (summary_current_sp && (summary_chosen_sp.get() == NULL || (prio_category > category_sp->GetEnabledPosition())))
-        {
-            prio_category = category_sp->GetEnabledPosition();
-            summary_chosen_sp = summary_current_sp;
-        }
-    }
-    return summary_chosen_sp;
-}
-
-lldb::TypeFilterImplSP
-FormatManager::GetFilterForType (lldb::TypeNameSpecifierImplSP type_sp)
-{
-    if (!type_sp)
-        return lldb::TypeFilterImplSP();
-    lldb::TypeFilterImplSP filter_chosen_sp;
-    uint32_t num_categories = m_categories_map.GetCount();
-    lldb::TypeCategoryImplSP category_sp;
-    uint32_t prio_category = UINT32_MAX;
-    for (uint32_t category_id = 0;
-         category_id < num_categories;
-         category_id++)
-    {
-        category_sp = GetCategoryAtIndex(category_id);
-        if (category_sp->IsEnabled() == false)
-            continue;
-        lldb::TypeFilterImplSP filter_current_sp((TypeFilterImpl*)category_sp->GetFilterForType(type_sp).get());
-        if (filter_current_sp && (filter_chosen_sp.get() == NULL || (prio_category > category_sp->GetEnabledPosition())))
-        {
-            prio_category = category_sp->GetEnabledPosition();
-            filter_chosen_sp = filter_current_sp;
-        }
-    }
-    return filter_chosen_sp;
-}
-
-#ifndef LLDB_DISABLE_PYTHON
-lldb::TypeSyntheticImplSP
-FormatManager::GetSyntheticForType (lldb::TypeNameSpecifierImplSP type_sp)
-{
-    if (!type_sp)
-        return lldb::TypeSyntheticImplSP();
-    lldb::TypeSyntheticImplSP synth_chosen_sp;
-    uint32_t num_categories = m_categories_map.GetCount();
-    lldb::TypeCategoryImplSP category_sp;
-    uint32_t prio_category = UINT32_MAX;
-    for (uint32_t category_id = 0;
-         category_id < num_categories;
-         category_id++)
-    {
-        category_sp = GetCategoryAtIndex(category_id);
-        if (category_sp->IsEnabled() == false)
-            continue;
-        lldb::TypeSyntheticImplSP synth_current_sp((TypeSyntheticImpl*)category_sp->GetSyntheticForType(type_sp).get());
-        if (synth_current_sp && (synth_chosen_sp.get() == NULL || (prio_category > category_sp->GetEnabledPosition())))
-        {
-            prio_category = category_sp->GetEnabledPosition();
-            synth_chosen_sp = synth_current_sp;
-        }
-    }
-    return synth_chosen_sp;
-}
-#endif
-
-#ifndef LLDB_DISABLE_PYTHON
-lldb::SyntheticChildrenSP
-FormatManager::GetSyntheticChildrenForType (lldb::TypeNameSpecifierImplSP type_sp)
-{
-    if (!type_sp)
-        return lldb::SyntheticChildrenSP();
-    lldb::TypeFilterImplSP filter_sp = GetFilterForType(type_sp);
-    lldb::TypeSyntheticImplSP synth_sp = GetSyntheticForType(type_sp);
-    if (filter_sp->GetRevision() > synth_sp->GetRevision())
-        return lldb::SyntheticChildrenSP(filter_sp.get());
-    else
-        return lldb::SyntheticChildrenSP(synth_sp.get());
-}
-#endif
-
-#ifndef LLDB_DISABLE_PYTHON
-lldb::SyntheticChildrenSP
-CategoryMap::GetSyntheticChildren (ValueObject& valobj,
-                                   lldb::DynamicValueType use_dynamic)
-{
-    Mutex::Locker(m_map_mutex);
-    
-    uint32_t reason_why;
-    
-    ActiveCategoriesIterator begin, end = m_active_categories.end();
-    
-    for (begin = m_active_categories.begin(); begin != end; begin++)
-    {
-        lldb::TypeCategoryImplSP category = *begin;
-        lldb::SyntheticChildrenSP current_format;
-        if (!category->Get(valobj, current_format, use_dynamic, &reason_why))
-            continue;
-        return current_format;
-    }
-    return lldb::SyntheticChildrenSP();
-}
-#endif
-
-void
-CategoryMap::LoopThrough(CallbackType callback, void* param)
-{
-    if (callback)
-    {
-        Mutex::Locker(m_map_mutex);
-        
-        // loop through enabled categories in respective order
-        {
-            ActiveCategoriesIterator begin, end = m_active_categories.end();
-            for (begin = m_active_categories.begin(); begin != end; begin++)
-            {
-                lldb::TypeCategoryImplSP category = *begin;
-                ConstString type = ConstString(category->GetName());
-                if (!callback(param, category))
-                    break;
-            }
-        }
-        
-        // loop through disabled categories in just any order
-        {
-            MapIterator pos, end = m_map.end();
-            for (pos = m_map.begin(); pos != end; pos++)
-            {
-                if (pos->second->IsEnabled())
-                    continue;
-                KeyType type = pos->first;
-                if (!callback(param, pos->second))
-                    break;
-            }
-        }
-    }
-}
-
-TypeCategoryImplSP
-CategoryMap::GetAtIndex (uint32_t index)
-{
-    Mutex::Locker(m_map_mutex);
-    
-    if (index < m_map.size())
-    {
-        MapIterator pos, end = m_map.end();
-        for (pos = m_map.begin(); pos != end; pos++)
-        {
-            if (index == 0)
-                return pos->second;
-            index--;
-        }
-    }
-    
-    return TypeCategoryImplSP();
-}
-
-lldb::TypeCategoryImplSP
-FormatManager::GetCategory (const ConstString& category_name,
-                         bool can_create)
-{
-    if (!category_name)
-        return GetCategory(m_default_category_name);
-    lldb::TypeCategoryImplSP category;
-    if (m_categories_map.Get(category_name, category))
-        return category;
-    
-    if (!can_create)
-        return lldb::TypeCategoryImplSP();
-    
-    m_categories_map.Add(category_name,lldb::TypeCategoryImplSP(new TypeCategoryImpl(this, category_name)));
-    return GetCategory(category_name);
-}
-
-lldb::Format
-FormatManager::GetSingleItemFormat(lldb::Format vector_format)
-{
-    switch(vector_format)
-    {
-        case eFormatVectorOfChar:
-            return eFormatCharArray;
-            
-        case eFormatVectorOfSInt8:
-        case eFormatVectorOfSInt16:
-        case eFormatVectorOfSInt32:
-        case eFormatVectorOfSInt64:
-            return eFormatDecimal;
-            
-        case eFormatVectorOfUInt8:
-        case eFormatVectorOfUInt16:
-        case eFormatVectorOfUInt32:
-        case eFormatVectorOfUInt64:
-        case eFormatVectorOfUInt128:
-            return eFormatHex;
-            
-        case eFormatVectorOfFloat32:
-        case eFormatVectorOfFloat64:
-            return eFormatFloat;
-            
-        default:
-            return lldb::eFormatInvalid;
-    }
-}
-
-ConstString
-FormatManager::GetValidTypeName (const ConstString& type)
-{
-    return ::GetValidTypeName_Impl(type);
-}
-
-FormatManager::FormatManager() : 
-    m_value_nav("format",this),
-    m_named_summaries_map(this),
-    m_last_revision(0),
-    m_categories_map(this),
-    m_default_category_name(ConstString("default")),
-    m_system_category_name(ConstString("system")), 
-    m_gnu_cpp_category_name(ConstString("gnu-libstdc++")),
-    m_libcxx_category_name(ConstString("libcxx")),
-    m_objc_category_name(ConstString("objc")),
-    m_corefoundation_category_name(ConstString("CoreFoundation")),
-    m_coregraphics_category_name(ConstString("CoreGraphics")),
-    m_coreservices_category_name(ConstString("CoreServices")),
-    m_vectortypes_category_name(ConstString("VectorTypes")),
-    m_appkit_category_name(ConstString("AppKit"))
-{
-    
-    LoadSystemFormatters();
-    LoadSTLFormatters();
-    LoadLibcxxFormatters();
-#ifndef LLDB_DISABLE_PYTHON
-    LoadObjCFormatters();
-#endif
-    
-    EnableCategory(m_objc_category_name,CategoryMap::Last);
-    EnableCategory(m_corefoundation_category_name,CategoryMap::Last);
-    EnableCategory(m_appkit_category_name,CategoryMap::Last);
-    EnableCategory(m_coreservices_category_name,CategoryMap::Last);
-    EnableCategory(m_coregraphics_category_name,CategoryMap::Last);
-    EnableCategory(m_gnu_cpp_category_name,CategoryMap::Last);
-    EnableCategory(m_libcxx_category_name,CategoryMap::Last);
-    EnableCategory(m_vectortypes_category_name,CategoryMap::Last);
-    EnableCategory(m_system_category_name,CategoryMap::Last);
-}
-
-void
-FormatManager::LoadSTLFormatters()
-{
-    TypeSummaryImpl::Flags stl_summary_flags;
-    stl_summary_flags.SetCascades(true)
-    .SetSkipPointers(false)
-    .SetSkipReferences(false)
-    .SetDontShowChildren(true)
-    .SetDontShowValue(true)
-    .SetShowMembersOneLiner(false)
-    .SetHideItemNames(false);
-    
-    lldb::TypeSummaryImplSP std_string_summary_sp(new StringSummaryFormat(stl_summary_flags,
-                                                                          "${var._M_dataplus._M_p}"));
-    
-    TypeCategoryImpl::SharedPointer gnu_category_sp = GetCategory(m_gnu_cpp_category_name);
-    
-    gnu_category_sp->GetSummaryNavigator()->Add(ConstString("std::string"),
-                                                std_string_summary_sp);
-    gnu_category_sp->GetSummaryNavigator()->Add(ConstString("std::basic_string<char>"),
-                                                std_string_summary_sp);
-    gnu_category_sp->GetSummaryNavigator()->Add(ConstString("std::basic_string<char,std::char_traits<char>,std::allocator<char> >"),
-                                                std_string_summary_sp);
-    gnu_category_sp->GetSummaryNavigator()->Add(ConstString("std::basic_string<char, std::char_traits<char>, std::allocator<char> >"),
-                                                std_string_summary_sp);
-    
-    
-#ifndef LLDB_DISABLE_PYTHON
-    
-    SyntheticChildren::Flags stl_synth_flags;
-    stl_synth_flags.SetCascades(true).SetSkipPointers(false).SetSkipReferences(false);
-    
-    gnu_category_sp->GetRegexSyntheticNavigator()->Add(RegularExpressionSP(new RegularExpression("^std::vector<.+>(( )?&)?$")),
-                                                       SyntheticChildrenSP(new TypeSyntheticImpl(stl_synth_flags,
-                                                                                                 "lldb.formatters.cpp.gnu_libstdcpp.StdVectorSynthProvider")));
-    gnu_category_sp->GetRegexSyntheticNavigator()->Add(RegularExpressionSP(new RegularExpression("^std::map<.+> >(( )?&)?$")),
-                                                       SyntheticChildrenSP(new TypeSyntheticImpl(stl_synth_flags,
-                                                                                                 "lldb.formatters.cpp.gnu_libstdcpp.StdMapSynthProvider")));
-    gnu_category_sp->GetRegexSyntheticNavigator()->Add(RegularExpressionSP(new RegularExpression("^std::list<.+>(( )?&)?$")),
-                                                       SyntheticChildrenSP(new TypeSyntheticImpl(stl_synth_flags,
-                                                                                                 "lldb.formatters.cpp.gnu_libstdcpp.StdListSynthProvider")));
-    
-    stl_summary_flags.SetDontShowChildren(false);
-    gnu_category_sp->GetRegexSummaryNavigator()->Add(RegularExpressionSP(new RegularExpression("^std::vector<.+>(( )?&)?$")),
-                                                     TypeSummaryImplSP(new StringSummaryFormat(stl_summary_flags,
-                                                                                               "size=${svar%#}")));
-    gnu_category_sp->GetRegexSummaryNavigator()->Add(RegularExpressionSP(new RegularExpression("^std::map<.+> >(( )?&)?$")),
-                                                     TypeSummaryImplSP(new StringSummaryFormat(stl_summary_flags,
-                                                                                               "size=${svar%#}")));
-    gnu_category_sp->GetRegexSummaryNavigator()->Add(RegularExpressionSP(new RegularExpression("^std::list<.+>(( )?&)?$")),
-                                                     TypeSummaryImplSP(new StringSummaryFormat(stl_summary_flags,
-                                                                                               "size=${svar%#}")));
-#endif
-}
-
-void
-FormatManager::LoadLibcxxFormatters()
-{
-    TypeSummaryImpl::Flags stl_summary_flags;
-    stl_summary_flags.SetCascades(true)
-    .SetSkipPointers(false)
-    .SetSkipReferences(false)
-    .SetDontShowChildren(true)
-    .SetDontShowValue(true)
-    .SetShowMembersOneLiner(false)
-    .SetHideItemNames(false);
-    
-#ifndef LLDB_DISABLE_PYTHON
-    std::string code("     lldb.formatters.cpp.libcxx.stdstring_SummaryProvider(valobj,internal_dict)");
-    lldb::TypeSummaryImplSP std_string_summary_sp(new ScriptSummaryFormat(stl_summary_flags, "lldb.formatters.cpp.libcxx.stdstring_SummaryProvider",code.c_str()));
-    
-    TypeCategoryImpl::SharedPointer libcxx_category_sp = GetCategory(m_libcxx_category_name);
-    
-    libcxx_category_sp->GetSummaryNavigator()->Add(ConstString("std::__1::string"),
-                                                   std_string_summary_sp);
-    libcxx_category_sp->GetSummaryNavigator()->Add(ConstString("std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >"),
-                                                   std_string_summary_sp);
-
-    SyntheticChildren::Flags stl_synth_flags;
-    stl_synth_flags.SetCascades(true).SetSkipPointers(false).SetSkipReferences(false);
-    
-    libcxx_category_sp->GetRegexSyntheticNavigator()->Add(RegularExpressionSP(new RegularExpression("^std::__1::vector<.+>(( )?&)?$")),
-                                                       SyntheticChildrenSP(new TypeSyntheticImpl(stl_synth_flags,
-                                                                                                 "lldb.formatters.cpp.libcxx.stdvector_SynthProvider")));
-    libcxx_category_sp->GetRegexSyntheticNavigator()->Add(RegularExpressionSP(new RegularExpression("^std::__1::list<.+>(( )?&)?$")),
-                                                       SyntheticChildrenSP(new TypeSyntheticImpl(stl_synth_flags,
-                                                                                                 "lldb.formatters.cpp.libcxx.stdlist_SynthProvider")));
-    libcxx_category_sp->GetRegexSyntheticNavigator()->Add(RegularExpressionSP(new RegularExpression("^std::__1::map<.+> >(( )?&)?$")),
-                                                       SyntheticChildrenSP(new TypeSyntheticImpl(stl_synth_flags,
-                                                                                                 "lldb.formatters.cpp.libcxx.stdmap_SynthProvider")));
-    
-    stl_summary_flags.SetDontShowChildren(false);
-    libcxx_category_sp->GetRegexSummaryNavigator()->Add(RegularExpressionSP(new RegularExpression("^std::__1::vector<.+>(( )?&)?")),
-                                                        TypeSummaryImplSP(new StringSummaryFormat(stl_summary_flags, "size=${svar%#}")));
-    libcxx_category_sp->GetRegexSummaryNavigator()->Add(RegularExpressionSP(new RegularExpression("^std::__1::list<.+>(( )?&)?$")),
-                                                        TypeSummaryImplSP(new StringSummaryFormat(stl_summary_flags, "size=${svar%#}")));
-    libcxx_category_sp->GetRegexSummaryNavigator()->Add(RegularExpressionSP(new RegularExpression("^std::__1::map<.+> >(( )?&)?$")),
-                                                        TypeSummaryImplSP(new StringSummaryFormat(stl_summary_flags, "size=${svar%#}")));
-#endif
-}
-
-void
-FormatManager::LoadSystemFormatters()
-{
-    lldb::TypeSummaryImplSP string_format(new StringSummaryFormat(TypeSummaryImpl::Flags().SetCascades(false)
-                                                                  .SetSkipPointers(true)
-                                                                  .SetSkipReferences(false)
-                                                                  .SetDontShowChildren(true)
-                                                                  .SetDontShowValue(false)
-                                                                  .SetShowMembersOneLiner(false)
-                                                                  .SetHideItemNames(false),
-                                                                  "${var%s}"));
-    
-    
-    lldb::TypeSummaryImplSP string_array_format(new StringSummaryFormat(TypeSummaryImpl::Flags().SetCascades(false)
-                                                                        .SetSkipPointers(true)
-                                                                        .SetSkipReferences(false)
-                                                                        .SetDontShowChildren(false)
-                                                                        .SetDontShowValue(true)
-                                                                        .SetShowMembersOneLiner(false)
-                                                                        .SetHideItemNames(false),
-                                                                        "${var%s}"));
-    
-    lldb::RegularExpressionSP any_size_char_arr(new RegularExpression("char \\[[0-9]+\\]"));
-    
-    TypeCategoryImpl::SharedPointer sys_category_sp = GetCategory(m_system_category_name);
-    
-    sys_category_sp->GetSummaryNavigator()->Add(ConstString("char *"), string_format);
-    sys_category_sp->GetSummaryNavigator()->Add(ConstString("const char *"), string_format);
-    sys_category_sp->GetRegexSummaryNavigator()->Add(any_size_char_arr, string_array_format);
-    
-    lldb::TypeSummaryImplSP ostype_summary(new StringSummaryFormat(TypeSummaryImpl::Flags().SetCascades(false)
-                                                                   .SetSkipPointers(true)
-                                                                   .SetSkipReferences(true)
-                                                                   .SetDontShowChildren(true)
-                                                                   .SetDontShowValue(false)
-                                                                   .SetShowMembersOneLiner(false)
-                                                                   .SetHideItemNames(false),
-                                                                   "${var%O}"));
-    
-    sys_category_sp->GetSummaryNavigator()->Add(ConstString("OSType"), ostype_summary);
-}
-
-static void
-AddSummary(TypeCategoryImpl::SharedPointer category_sp,
-           const char* string,
-           ConstString type_name,
-           TypeSummaryImpl::Flags flags)
-{
-    lldb::TypeSummaryImplSP summary_sp(new StringSummaryFormat(flags,
-                                                               string));
-    category_sp->GetSummaryNavigator()->Add(type_name,
-                                            summary_sp);
-}
-
-#ifndef LLDB_DISABLE_PYTHON
-static void
-AddScriptSummary(TypeCategoryImpl::SharedPointer category_sp,
-                 const char* funct_name,
-                 ConstString type_name,
-                 TypeSummaryImpl::Flags flags)
-{
-    
-    std::string code("     ");
-    code.append(funct_name).append("(valobj,internal_dict)");
-    
-    lldb::TypeSummaryImplSP summary_sp(new ScriptSummaryFormat(flags,
-                                                               funct_name,
-                                                               code.c_str()));
-    category_sp->GetSummaryNavigator()->Add(type_name,
-                                            summary_sp);
-}
-#endif
-
-#ifndef LLDB_DISABLE_PYTHON
-void
-FormatManager::LoadObjCFormatters()
-{
-    TypeSummaryImpl::Flags objc_flags;
-    objc_flags.SetCascades(false)
-    .SetSkipPointers(true)
-    .SetSkipReferences(true)
-    .SetDontShowChildren(true)
-    .SetDontShowValue(true)
-    .SetShowMembersOneLiner(false)
-    .SetHideItemNames(false);
-    
-    lldb::TypeSummaryImplSP ObjC_BOOL_summary(new ScriptSummaryFormat(objc_flags,
-                                                                      "lldb.formatters.objc.objc.BOOL_SummaryProvider",
-                                                                      ""));
-    TypeCategoryImpl::SharedPointer objc_category_sp = GetCategory(m_objc_category_name);
-    objc_category_sp->GetSummaryNavigator()->Add(ConstString("BOOL"),
-                                                 ObjC_BOOL_summary);
-
-    lldb::TypeSummaryImplSP ObjC_BOOLRef_summary(new ScriptSummaryFormat(objc_flags,
-                                                                      "lldb.formatters.objc.objc.BOOLRef_SummaryProvider",
-                                                                      ""));
-    objc_category_sp->GetSummaryNavigator()->Add(ConstString("BOOL &"),
-                                                 ObjC_BOOLRef_summary);
-    lldb::TypeSummaryImplSP ObjC_BOOLPtr_summary(new ScriptSummaryFormat(objc_flags,
-                                                                      "lldb.formatters.objc.objc.BOOLPtr_SummaryProvider",
-                                                                      ""));
-    objc_category_sp->GetSummaryNavigator()->Add(ConstString("BOOL *"),
-                                                 ObjC_BOOLPtr_summary);
-
-    
-    // we need to skip pointers here since we are special casing a SEL* when retrieving its value
-    objc_flags.SetSkipPointers(true);
-    AddScriptSummary(objc_category_sp, "lldb.formatters.objc.Selector.SEL_Summary", ConstString("SEL"), objc_flags);
-    AddScriptSummary(objc_category_sp, "lldb.formatters.objc.Selector.SEL_Summary", ConstString("struct objc_selector"), objc_flags);
-    AddScriptSummary(objc_category_sp, "lldb.formatters.objc.Selector.SEL_Summary", ConstString("objc_selector"), objc_flags);
-    AddScriptSummary(objc_category_sp, "lldb.formatters.objc.Selector.SELPointer_Summary", ConstString("objc_selector *"), objc_flags);
-    AddScriptSummary(objc_category_sp, "lldb.formatters.objc.Class.Class_Summary", ConstString("Class"), objc_flags);
-    objc_flags.SetSkipPointers(false);
-
-    TypeCategoryImpl::SharedPointer corefoundation_category_sp = GetCategory(m_corefoundation_category_name);
-
-    AddSummary(corefoundation_category_sp,
-               "${var.years} years, ${var.months} months, ${var.days} days, ${var.hours} hours, ${var.minutes} minutes ${var.seconds} seconds",
-               ConstString("CFGregorianUnits"),
-               objc_flags);
-    AddSummary(corefoundation_category_sp,
-               "location=${var.location} length=${var.length}",
-               ConstString("CFRange"),
-               objc_flags);
-    AddSummary(corefoundation_category_sp,
-               "(x=${var.x}, y=${var.y})",
-               ConstString("NSPoint"),
-               objc_flags);
-    AddSummary(corefoundation_category_sp,
-               "location=${var.location}, length=${var.length}",
-               ConstString("NSRange"),
-               objc_flags);
-    AddSummary(corefoundation_category_sp,
-               "${var.origin}, ${var.size}",
-               ConstString("NSRect"),
-               objc_flags);
-    AddSummary(corefoundation_category_sp,
-               "(${var.origin}, ${var.size}), ...",
-               ConstString("NSRectArray"),
-               objc_flags);
-    AddSummary(objc_category_sp,
-               "(width=${var.width}, height=${var.height})",
-               ConstString("NSSize"),
-               objc_flags);
-    
-    TypeCategoryImpl::SharedPointer coregraphics_category_sp = GetCategory(m_coregraphics_category_name);
-    
-    AddSummary(coregraphics_category_sp,
-               "(width=${var.width}, height=${var.height})",
-               ConstString("CGSize"),
-               objc_flags);
-    AddSummary(coregraphics_category_sp,
-               "(x=${var.x}, y=${var.y})",
-               ConstString("CGPoint"),
-               objc_flags);
-    AddSummary(coregraphics_category_sp,
-               "origin=${var.origin} size=${var.size}",
-               ConstString("CGRect"),
-               objc_flags);
-    
-    TypeCategoryImpl::SharedPointer coreservices_category_sp = GetCategory(m_coreservices_category_name);
-    
-    AddSummary(coreservices_category_sp,
-               "red=${var.red} green=${var.green} blue=${var.blue}",
-               ConstString("RGBColor"),
-               objc_flags);
-    AddSummary(coreservices_category_sp,
-               "(t=${var.top}, l=${var.left}, b=${var.bottom}, r=${var.right})",
-               ConstString("Rect"),
-               objc_flags);
-    AddSummary(coreservices_category_sp,
-               "(v=${var.v}, h=${var.h})",
-               ConstString("Point"),
-               objc_flags);
-    AddSummary(coreservices_category_sp,
-               "${var.month}/${var.day}/${var.year}  ${var.hour} :${var.minute} :${var.second} dayOfWeek:${var.dayOfWeek}",
-               ConstString("DateTimeRect *"),
-               objc_flags);
-    AddSummary(coreservices_category_sp,
-               "${var.ld.month}/${var.ld.day}/${var.ld.year} ${var.ld.hour} :${var.ld.minute} :${var.ld.second} dayOfWeek:${var.ld.dayOfWeek}",
-               ConstString("LongDateRect"),
-               objc_flags);
-    AddSummary(coreservices_category_sp,
-               "(x=${var.x}, y=${var.y})",
-               ConstString("HIPoint"),
-               objc_flags);
-    AddSummary(coreservices_category_sp,
-               "origin=${var.origin} size=${var.size}",
-               ConstString("HIRect"),
-               objc_flags);
-    
-    TypeCategoryImpl::SharedPointer appkit_category_sp = GetCategory(m_appkit_category_name);
-    
-    TypeSummaryImpl::Flags appkit_flags;
-    appkit_flags.SetCascades(true)
-    .SetSkipPointers(false)
-    .SetSkipReferences(false)
-    .SetDontShowChildren(true)
-    .SetDontShowValue(false)
-    .SetShowMembersOneLiner(false)
-    .SetHideItemNames(false);
-
-    AddScriptSummary(appkit_category_sp, "lldb.formatters.objc.CFArray.CFArray_SummaryProvider", ConstString("NSArray"), appkit_flags);
-    AddScriptSummary(appkit_category_sp, "lldb.formatters.objc.CFArray.CFArray_SummaryProvider", ConstString("__NSArrayI"), appkit_flags);
-    AddScriptSummary(appkit_category_sp, "lldb.formatters.objc.CFArray.CFArray_SummaryProvider", ConstString("__NSArrayM"), appkit_flags);
-    AddScriptSummary(appkit_category_sp, "lldb.formatters.objc.CFArray.CFArray_SummaryProvider", ConstString("__NSCFArray"), appkit_flags);
-    AddScriptSummary(appkit_category_sp, "lldb.formatters.objc.CFArray.CFArray_SummaryProvider", ConstString("CFArrayRef"), appkit_flags);
-    AddScriptSummary(appkit_category_sp, "lldb.formatters.objc.CFArray.CFArray_SummaryProvider", ConstString("CFMutableArrayRef"), appkit_flags);
-
-    AddScriptSummary(appkit_category_sp, "lldb.formatters.objc.CFBag.CFBag_SummaryProvider", ConstString("CFBagRef"), appkit_flags);
-    AddScriptSummary(appkit_category_sp, "lldb.formatters.objc.CFBag.CFBag_SummaryProvider", ConstString("__CFBag"), appkit_flags);
-    AddScriptSummary(appkit_category_sp, "lldb.formatters.objc.CFBag.CFBag_SummaryProvider", ConstString("const struct __CFBag"), appkit_flags);
-    AddScriptSummary(appkit_category_sp, "lldb.formatters.objc.CFBag.CFBag_SummaryProvider", ConstString("CFMutableBagRef"), appkit_flags);
-    
-    AddScriptSummary(appkit_category_sp, "lldb.formatters.objc.CFBinaryHeap.CFBinaryHeap_SummaryProvider", ConstString("CFBinaryHeapRef"), appkit_flags);
-    AddScriptSummary(appkit_category_sp, "lldb.formatters.objc.CFBinaryHeap.CFBinaryHeap_SummaryProvider", ConstString("__CFBinaryHeap"), appkit_flags);
-
-    AddScriptSummary(appkit_category_sp, "lldb.formatters.objc.CFDictionary.CFDictionary_SummaryProvider", ConstString("NSDictionary"), appkit_flags);
-    AddScriptSummary(appkit_category_sp, "lldb.formatters.objc.CFDictionary.CFDictionary_SummaryProvider2", ConstString("CFDictionaryRef"), appkit_flags);
-    AddScriptSummary(appkit_category_sp, "lldb.formatters.objc.CFDictionary.CFDictionary_SummaryProvider2", ConstString("CFMutableDictionaryRef"), appkit_flags);
-    AddScriptSummary(appkit_category_sp, "lldb.formatters.objc.CFDictionary.CFDictionary_SummaryProvider", ConstString("__NSCFDictionary"), appkit_flags);
-    AddScriptSummary(appkit_category_sp, "lldb.formatters.objc.CFDictionary.CFDictionary_SummaryProvider", ConstString("__NSDictionaryI"), appkit_flags);
-    AddScriptSummary(appkit_category_sp, "lldb.formatters.objc.CFDictionary.CFDictionary_SummaryProvider", ConstString("__NSDictionaryM"), appkit_flags);
-
-    AddScriptSummary(appkit_category_sp, "lldb.formatters.objc.CFString.CFString_SummaryProvider", ConstString("NSString"), appkit_flags);
-    AddScriptSummary(appkit_category_sp, "lldb.formatters.objc.CFString.CFString_SummaryProvider", ConstString("CFStringRef"), appkit_flags);
-    AddScriptSummary(appkit_category_sp, "lldb.formatters.objc.CFString.CFString_SummaryProvider", ConstString("CFMutableStringRef"), appkit_flags);
-    AddScriptSummary(appkit_category_sp, "lldb.formatters.objc.CFString.CFAttributedString_SummaryProvider", ConstString("NSAttributedString"), appkit_flags);
-    AddScriptSummary(appkit_category_sp, "lldb.formatters.objc.CFString.CFString_SummaryProvider", ConstString("__NSCFConstantString"), appkit_flags);
-    AddScriptSummary(appkit_category_sp, "lldb.formatters.objc.CFString.CFString_SummaryProvider", ConstString("__NSCFString"), appkit_flags);
-    AddScriptSummary(appkit_category_sp, "lldb.formatters.objc.CFString.CFString_SummaryProvider", ConstString("NSCFConstantString"), appkit_flags);
-    AddScriptSummary(appkit_category_sp, "lldb.formatters.objc.CFString.CFString_SummaryProvider", ConstString("NSCFString"), appkit_flags);
-    AddScriptSummary(appkit_category_sp, "lldb.formatters.objc.CFString.CFString_SummaryProvider", ConstString("NSPathStore2"), appkit_flags);
-    
-    AddScriptSummary(appkit_category_sp, "lldb.formatters.objc.NSBundle.NSBundle_SummaryProvider", ConstString("NSBundle"), appkit_flags);
-    
-    AddScriptSummary(appkit_category_sp, "lldb.formatters.objc.NSData.NSData_SummaryProvider", ConstString("NSData"), appkit_flags);
-    AddScriptSummary(appkit_category_sp, "lldb.formatters.objc.NSData.NSData_SummaryProvider2", ConstString("CFDataRef"), appkit_flags);
-    AddScriptSummary(appkit_category_sp, "lldb.formatters.objc.NSData.NSData_SummaryProvider2", ConstString("CFMutableDataRef"), appkit_flags);
-    AddScriptSummary(appkit_category_sp, "lldb.formatters.objc.NSData.NSData_SummaryProvider", ConstString("NSConcreteData"), appkit_flags);
-    AddScriptSummary(appkit_category_sp, "lldb.formatters.objc.NSData.NSData_SummaryProvider", ConstString("NSConcreteMutableData"), appkit_flags);
-    AddScriptSummary(appkit_category_sp, "lldb.formatters.objc.NSData.NSData_SummaryProvider", ConstString("__NSCFData"), appkit_flags);
-
-    AddScriptSummary(appkit_category_sp, "lldb.formatters.objc.NSException.NSException_SummaryProvider", ConstString("NSException"), appkit_flags);
-
-    AddScriptSummary(appkit_category_sp, "lldb.formatters.objc.NSMachPort.NSMachPort_SummaryProvider", ConstString("NSMachPort"), appkit_flags);
-    
-    AddScriptSummary(appkit_category_sp, "lldb.formatters.objc.NSNotification.NSNotification_SummaryProvider", ConstString("NSNotification"), appkit_flags);
-    AddScriptSummary(appkit_category_sp, "lldb.formatters.objc.NSNotification.NSNotification_SummaryProvider", ConstString("NSConcreteNotification"), appkit_flags);
-
-    AddScriptSummary(appkit_category_sp, "lldb.formatters.objc.NSNumber.NSNumber_SummaryProvider", ConstString("NSNumber"), appkit_flags);
-    AddScriptSummary(appkit_category_sp, "lldb.formatters.objc.NSNumber.NSNumber_SummaryProvider", ConstString("__NSCFBoolean"), appkit_flags);
-    AddScriptSummary(appkit_category_sp, "lldb.formatters.objc.NSNumber.NSNumber_SummaryProvider", ConstString("__NSCFNumber"), appkit_flags);
-    AddScriptSummary(appkit_category_sp, "lldb.formatters.objc.NSNumber.NSNumber_SummaryProvider", ConstString("NSCFBoolean"), appkit_flags);
-    AddScriptSummary(appkit_category_sp, "lldb.formatters.objc.NSNumber.NSNumber_SummaryProvider", ConstString("NSCFNumber"), appkit_flags);
-
-    AddScriptSummary(appkit_category_sp, "lldb.formatters.objc.NSSet.NSSet_SummaryProvider", ConstString("NSSet"), appkit_flags);
-    AddScriptSummary(appkit_category_sp, "lldb.formatters.objc.NSSet.NSSet_SummaryProvider2", ConstString("CFSetRef"), appkit_flags);
-    AddScriptSummary(appkit_category_sp, "lldb.formatters.objc.NSSet.NSSet_SummaryProvider2", ConstString("CFMutableSetRef"), appkit_flags);
-    AddScriptSummary(appkit_category_sp, "lldb.formatters.objc.NSSet.NSSet_SummaryProvider", ConstString("__NSCFSet"), appkit_flags);
-    AddScriptSummary(appkit_category_sp, "lldb.formatters.objc.NSSet.NSSet_SummaryProvider", ConstString("__NSSetI"), appkit_flags);
-    AddScriptSummary(appkit_category_sp, "lldb.formatters.objc.NSSet.NSSet_SummaryProvider", ConstString("__NSSetM"), appkit_flags);
-    AddScriptSummary(appkit_category_sp, "lldb.formatters.objc.NSSet.NSSet_SummaryProvider", ConstString("NSCountedSet"), appkit_flags);
-
-    AddScriptSummary(appkit_category_sp, "lldb.formatters.objc.NSURL.NSURL_SummaryProvider", ConstString("NSURL"), appkit_flags);
-    AddScriptSummary(appkit_category_sp, "lldb.formatters.objc.NSURL.NSURL_SummaryProvider", ConstString("CFURLRef"), appkit_flags);
-    
-    AddScriptSummary(appkit_category_sp, "lldb.formatters.objc.NSDate.NSDate_SummaryProvider", ConstString("NSDate"), appkit_flags);
-    AddScriptSummary(appkit_category_sp, "lldb.formatters.objc.NSDate.NSDate_SummaryProvider", ConstString("__NSDate"), appkit_flags);
-    AddScriptSummary(appkit_category_sp, "lldb.formatters.objc.NSDate.NSDate_SummaryProvider", ConstString("__NSTaggedDate"), appkit_flags);
-    AddScriptSummary(appkit_category_sp, "lldb.formatters.objc.NSDate.NSDate_SummaryProvider", ConstString("NSCalendarDate"), appkit_flags);
-
-    AddScriptSummary(appkit_category_sp, "lldb.formatters.objc.NSDate.NSTimeZone_SummaryProvider", ConstString("NSTimeZone"), appkit_flags);
-    AddScriptSummary(appkit_category_sp, "lldb.formatters.objc.NSDate.NSTimeZone_SummaryProvider", ConstString("CFTimeZoneRef"), appkit_flags);
-    AddScriptSummary(appkit_category_sp, "lldb.formatters.objc.NSDate.NSTimeZone_SummaryProvider", ConstString("__NSTimeZone"), appkit_flags);
-
-    // CFAbsoluteTime is actually a double rather than a pointer to an object
-    // we do not care about the numeric value, since it is probably meaningless to users
-    appkit_flags.SetDontShowValue(true);
-    AddScriptSummary(appkit_category_sp, "lldb.formatters.objc.NSDate.CFAbsoluteTime_SummaryProvider", ConstString("CFAbsoluteTime"), appkit_flags);
-    appkit_flags.SetDontShowValue(false);
-    
-    AddScriptSummary(appkit_category_sp, "lldb.formatters.objc.NSIndexSet.NSIndexSet_SummaryProvider", ConstString("NSIndexSet"), appkit_flags);
-    AddScriptSummary(appkit_category_sp, "lldb.formatters.objc.NSIndexSet.NSIndexSet_SummaryProvider", ConstString("NSMutableIndexSet"), appkit_flags);
-
-    AddSummary(appkit_category_sp, "@\"${var.month%d}/${var.day%d}/${var.year%d} ${var.hour%d}:${var.minute%d}:${var.second}\"", ConstString("CFGregorianDate"), appkit_flags);
-    
-    AddScriptSummary(appkit_category_sp, "lldb.formatters.objc.CFBitVector.CFBitVector_SummaryProvider", ConstString("CFBitVectorRef"), appkit_flags);
-    AddScriptSummary(appkit_category_sp, "lldb.formatters.objc.CFBitVector.CFBitVector_SummaryProvider", ConstString("CFMutableBitVectorRef"), appkit_flags);
-    AddScriptSummary(appkit_category_sp, "lldb.formatters.objc.CFBitVector.CFBitVector_SummaryProvider", ConstString("__CFBitVector"), appkit_flags);
-    AddScriptSummary(appkit_category_sp, "lldb.formatters.objc.CFBitVector.CFBitVector_SummaryProvider", ConstString("__CFMutableBitVector"), appkit_flags);
-
-    TypeCategoryImpl::SharedPointer vectors_category_sp = GetCategory(m_vectortypes_category_name);
-
-    TypeSummaryImpl::Flags vector_flags;
-    vector_flags.SetCascades(true)
-    .SetSkipPointers(true)
-    .SetSkipReferences(false)
-    .SetDontShowChildren(true)
-    .SetDontShowValue(false)
-    .SetShowMembersOneLiner(true)
-    .SetHideItemNames(true);
-    
-    AddSummary(vectors_category_sp,
-               "${var.uint128}",
-               ConstString("builtin_type_vec128"),
-               objc_flags);
-
-    AddSummary(vectors_category_sp,
-               "",
-               ConstString("float [4]"),
-               vector_flags);
-    AddSummary(vectors_category_sp,
-               "",
-               ConstString("int32_t [4]"),
-               vector_flags);
-    AddSummary(vectors_category_sp,
-               "",
-               ConstString("int16_t [8]"),
-               vector_flags);
-    AddSummary(vectors_category_sp,
-               "",
-               ConstString("vDouble"),
-               vector_flags);
-    AddSummary(vectors_category_sp,
-               "",
-               ConstString("vFloat"),
-               vector_flags);
-    AddSummary(vectors_category_sp,
-               "",
-               ConstString("vSInt8"),
-               vector_flags);
-    AddSummary(vectors_category_sp,
-               "",
-               ConstString("vSInt16"),
-               vector_flags);
-    AddSummary(vectors_category_sp,
-               "",
-               ConstString("vSInt32"),
-               vector_flags);
-    AddSummary(vectors_category_sp,
-               "",
-               ConstString("vUInt16"),
-               vector_flags);
-    AddSummary(vectors_category_sp,
-               "",
-               ConstString("vUInt8"),
-               vector_flags);
-    AddSummary(vectors_category_sp,
-               "",
-               ConstString("vUInt16"),
-               vector_flags);
-    AddSummary(vectors_category_sp,
-               "",
-               ConstString("vUInt32"),
-               vector_flags);
-    AddSummary(vectors_category_sp,
-               "",
-               ConstString("vBool32"),
-               vector_flags);
-}
-#endif // LLDB_DISABLE_PYTHON

Modified: lldb/branches/lldb-platform-work/source/Core/History.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/lldb-platform-work/source/Core/History.cpp?rev=183468&r1=183467&r2=183468&view=diff
==============================================================================
--- lldb/branches/lldb-platform-work/source/Core/History.cpp (original)
+++ lldb/branches/lldb-platform-work/source/Core/History.cpp Thu Jun  6 19:06:43 2013
@@ -10,6 +10,7 @@
 #include "lldb/Core/History.h"
 
 // C Includes
+#include <inttypes.h>
 // C++ Includes
 // Other libraries and framework includes
 // Project includes
@@ -21,5 +22,5 @@ using namespace lldb_private;
 void
 HistorySourceUInt::DumpHistoryEvent (Stream &strm, HistoryEvent event)
 {
-    strm.Printf ("%s %llu", m_name.c_str(), (uint64_t)((uintptr_t)event));
+    strm.Printf ("%s %" PRIu64, m_name.c_str(), (uint64_t)((uintptr_t)event));
 }

Modified: lldb/branches/lldb-platform-work/source/Core/InputReader.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/lldb-platform-work/source/Core/InputReader.cpp?rev=183468&r1=183467&r2=183468&view=diff
==============================================================================
--- lldb/branches/lldb-platform-work/source/Core/InputReader.cpp (original)
+++ lldb/branches/lldb-platform-work/source/Core/InputReader.cpp Thu Jun  6 19:06:43 2013
@@ -7,6 +7,8 @@
 //
 //===----------------------------------------------------------------------===//
 
+#include "lldb/lldb-python.h"
+
 #include <string>
 
 #include "lldb/Core/InputReader.h"

Modified: lldb/branches/lldb-platform-work/source/Core/Listener.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/lldb-platform-work/source/Core/Listener.cpp?rev=183468&r1=183467&r2=183468&view=diff
==============================================================================
--- lldb/branches/lldb-platform-work/source/Core/Listener.cpp (original)
+++ lldb/branches/lldb-platform-work/source/Core/Listener.cpp Thu Jun  6 19:06:43 2013
@@ -32,14 +32,14 @@ Listener::Listener(const char *name) :
     m_events_mutex (Mutex::eMutexTypeRecursive),
     m_cond_wait()
 {
-    LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_OBJECT));
+    Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_OBJECT));
     if (log)
         log->Printf ("%p Listener::Listener('%s')", this, m_name.c_str());
 }
 
 Listener::~Listener()
 {
-    LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_OBJECT));
+    Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_OBJECT));
     Mutex::Locker locker (m_broadcasters_mutex);
     
     size_t num_managers = m_broadcaster_managers.size();
@@ -84,7 +84,7 @@ Listener::StartListeningForEvents (Broad
         {
 
         }
-        LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EVENTS));
+        Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EVENTS));
         if (log)
             log->Printf ("%p Listener::StartListeningForEvents (broadcaster = %p, mask = 0x%8.8x) acquired_mask = 0x%8.8x for %s",
                          this,
@@ -113,7 +113,7 @@ Listener::StartListeningForEvents (Broad
 
         uint32_t acquired_mask = broadcaster->AddListener (this, event_mask);
 
-        LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EVENTS));
+        Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EVENTS));
         if (log)
             log->Printf ("%p Listener::StartListeningForEvents (broadcaster = %p, mask = 0x%8.8x, callback = %p, user_data = %p) acquired_mask = 0x%8.8x for %s",
                         this, broadcaster, event_mask, callback, callback_user_data, acquired_mask, m_name.c_str());
@@ -183,7 +183,7 @@ Listener::BroadcasterManagerWillDestruct
 void
 Listener::AddEvent (EventSP &event_sp)
 {
-    LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EVENTS));
+    Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EVENTS));
     if (log)
         log->Printf ("%p Listener('%s')::AddEvent (event_sp = {%p})", this, m_name.c_str(), event_sp.get());
 
@@ -270,7 +270,7 @@ Listener::FindNextEventInternal
     EventSP &event_sp,
     bool remove)
 {
-    //LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EVENTS));
+    Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EVENTS));
 
     Mutex::Locker lock(m_events_mutex);
 
@@ -292,6 +292,18 @@ Listener::FindNextEventInternal
     if (pos != m_events.end())
     {
         event_sp = *pos;
+        
+        if (log)
+            log->Printf ("%p '%s' Listener::FindNextEventInternal(broadcaster=%p, broadcaster_names=%p[%u], event_type_mask=0x%8.8x, remove=%i) event %p",
+                         this,
+                         GetName(),
+                         broadcaster,
+                         broadcaster_names,
+                         num_broadcaster_names,
+                         event_type_mask,
+                         remove,
+                         event_sp.get());
+
         if (remove)
         {
             m_events.erase(pos);
@@ -388,7 +400,7 @@ Listener::WaitForEventsInternal
     EventSP &event_sp
 )
 {
-    LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EVENTS));
+    Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EVENTS));
     bool timed_out = false;
 
     if (log)
@@ -399,12 +411,24 @@ Listener::WaitForEventsInternal
 
     while (1)
     {
+        // Note, we don't want to lock the m_events_mutex in the call to GetNextEventInternal, since the DoOnRemoval
+        // code might require that new events be serviced.  For instance, the Breakpoint Command's 
         if (GetNextEventInternal (broadcaster, broadcaster_names, num_broadcaster_names, event_type_mask, event_sp))
-            return true;
+                return true;
 
-        // Reset condition value to false, so we can wait for new events to be
-        // added that might meet our current filter
-        m_cond_wait.SetValue (false, eBroadcastNever);
+        {
+            // Reset condition value to false, so we can wait for new events to be
+            // added that might meet our current filter
+            // But first poll for any new event that might satisfy our condition, and if so consume it,
+            // otherwise wait.
+            
+            Mutex::Locker event_locker(m_events_mutex);
+            const bool remove = false;
+            if (FindNextEventInternal (broadcaster, broadcaster_names, num_broadcaster_names, event_type_mask, event_sp, remove))
+                continue;
+            else
+                m_cond_wait.SetValue (false, eBroadcastNever);
+        }
 
         if (m_cond_wait.WaitForValueEqualTo (true, timeout, &timed_out))
             continue;
@@ -413,14 +437,14 @@ Listener::WaitForEventsInternal
         {
             log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EVENTS);
             if (log)
-                log->Printf ("%p Listener::WaitForEvents() timed out for %s", this, m_name.c_str());
+                log->Printf ("%p Listener::WaitForEventsInternal() timed out for %s", this, m_name.c_str());
             break;
         }
         else
         {
             log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EVENTS);
             if (log)
-                log->Printf ("%p Listener::WaitForEvents() unknown error for %s", this, m_name.c_str());
+                log->Printf ("%p Listener::WaitForEventsInternal() unknown error for %s", this, m_name.c_str());
             break;
         }
     }
@@ -509,6 +533,9 @@ uint32_t
 Listener::StartListeningForEventSpec (BroadcasterManager &manager, 
                              const BroadcastEventSpec &event_spec)
 {
+    // The BroadcasterManager mutex must be locked before m_broadcasters_mutex 
+    // to avoid violating the lock hierarchy (manager before broadcasters).
+    Mutex::Locker manager_locker(manager.m_manager_mutex);
     Mutex::Locker locker(m_broadcasters_mutex);
 
     uint32_t bits_acquired = manager.RegisterListenerForEvents(*this, event_spec);

Modified: lldb/branches/lldb-platform-work/source/Core/Log.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/lldb-platform-work/source/Core/Log.cpp?rev=183468&r1=183467&r2=183468&view=diff
==============================================================================
--- lldb/branches/lldb-platform-work/source/Core/Log.cpp (original)
+++ lldb/branches/lldb-platform-work/source/Core/Log.cpp Thu Jun  6 19:06:43 2013
@@ -7,6 +7,8 @@
 //
 //===----------------------------------------------------------------------===//
 
+#include "lldb/lldb-python.h"
+
 // C Includes
 #include <pthread.h>
 #include <stdio.h>
@@ -39,7 +41,7 @@ Log::Log () :
 {
 }
 
-Log::Log (StreamSP &stream_sp) :
+Log::Log (const StreamSP &stream_sp) :
     m_stream_sp(stream_sp),
     m_options(0),
     m_mask_bits(0)
@@ -100,24 +102,26 @@ Log::PrintfWithFlagsVarArg (uint32_t fla
         if (m_options.Test (LLDB_LOG_OPTION_PREPEND_TIMESTAMP))
         {
             struct timeval tv = TimeValue::Now().GetAsTimeVal();
-            header.Printf ("%9ld.%6.6d ", tv.tv_sec, tv.tv_usec);
+            header.Printf ("%9ld.%6.6d ", tv.tv_sec, (int32_t)tv.tv_usec);
         }
 
         // Add the process and thread if requested
         if (m_options.Test (LLDB_LOG_OPTION_PREPEND_PROC_AND_THREAD))
-            header.Printf ("[%4.4x/%4.4llx]: ", getpid(), Host::GetCurrentThreadID());
+            header.Printf ("[%4.4x/%4.4" PRIx64 "]: ", getpid(), Host::GetCurrentThreadID());
 
         // Add the process and thread if requested
         if (m_options.Test (LLDB_LOG_OPTION_PREPEND_THREAD_NAME))
         {
-            const char *thread_name_str = Host::GetThreadName (getpid(), Host::GetCurrentThreadID());
-            if (thread_name_str)
-                header.Printf ("%s ", thread_name_str);
-
+            std::string thread_name (Host::GetThreadName (getpid(), Host::GetCurrentThreadID()));
+            if (!thread_name.empty())
+                header.Printf ("%s ", thread_name.c_str());
         }
 
         header.PrintfVarArg (format, args);
         m_stream_sp->Printf("%s\n", header.GetData());
+        
+        if (m_options.Test (LLDB_LOG_OPTION_BACKTRACE))
+            Host::Backtrace (*m_stream_sp, 1024);
         m_stream_sp->Flush();
     }
 }
@@ -309,7 +313,7 @@ Log::Warning (const char *format, ...)
     }
 }
 
-typedef std::map <std::string, Log::Callbacks> CallbackMap;
+typedef std::map <ConstString, Log::Callbacks> CallbackMap;
 typedef CallbackMap::iterator CallbackMapIter;
 
 typedef std::map <ConstString, LogChannelSP> LogChannelMap;
@@ -333,19 +337,19 @@ GetChannelMap ()
 }
 
 void
-Log::RegisterLogChannel (const char *channel, const Log::Callbacks &log_callbacks)
+Log::RegisterLogChannel (const ConstString &channel, const Log::Callbacks &log_callbacks)
 {
     GetCallbackMap().insert(std::make_pair(channel, log_callbacks));
 }
 
 bool
-Log::UnregisterLogChannel (const char *channel)
+Log::UnregisterLogChannel (const ConstString &channel)
 {
     return GetCallbackMap().erase(channel) != 0;
 }
 
 bool
-Log::GetLogChannelCallbacks (const char *channel, Log::Callbacks &log_callbacks)
+Log::GetLogChannelCallbacks (const ConstString &channel, Log::Callbacks &log_callbacks)
 {
     CallbackMap &callback_map = GetCallbackMap ();
     CallbackMapIter pos = callback_map.find(channel);
@@ -423,7 +427,7 @@ void
 Log::Initialize()
 {
     Log::Callbacks log_callbacks = { DisableLog, EnableLog, ListLogCategories };
-    Log::RegisterLogChannel ("lldb", log_callbacks);
+    Log::RegisterLogChannel (ConstString("lldb"), log_callbacks);
 }
 
 void
@@ -491,7 +495,8 @@ LogChannel::FindPlugin (const char *plug
     LogChannelMapIter pos = channel_map.find (log_channel_name);
     if (pos == channel_map.end())
     {
-        LogChannelCreateInstance create_callback  = PluginManager::GetLogChannelCreateCallbackForPluginName (plugin_name);
+        ConstString const_plugin_name (plugin_name);
+        LogChannelCreateInstance create_callback  = PluginManager::GetLogChannelCreateCallbackForPluginName (const_plugin_name);
         if (create_callback)
         {
             log_channel_sp.reset(create_callback());
@@ -513,7 +518,7 @@ LogChannel::FindPlugin (const char *plug
 }
 
 LogChannel::LogChannel () :
-    m_log_sp ()
+    m_log_ap ()
 {
 }
 

Modified: lldb/branches/lldb-platform-work/source/Core/Makefile
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/lldb-platform-work/source/Core/Makefile?rev=183468&r1=183467&r2=183468&view=diff
==============================================================================
--- lldb/branches/lldb-platform-work/source/Core/Makefile (original)
+++ lldb/branches/lldb-platform-work/source/Core/Makefile Thu Jun  6 19:06:43 2013
@@ -12,3 +12,15 @@ LIBRARYNAME := lldbCore
 BUILD_ARCHIVE = 1
 
 include $(LLDB_LEVEL)/Makefile
+
+# Enable RTTI on GCC builds because one source file in this directory
+# (cxa_demangle.cpp) uses dynamic_cast<> and GCC (at least 4.6 and 4.7)
+# complain if we try to compile it with -fno-rtti.
+$(info shell basename CXX is $(shell basename $(CXX)))
+ifeq (g++,$(shell basename $(CXX) | colrm 4))
+$(ObjDir)/cxa_demangle.o: Compile.CXX := $(filter-out -fno-rtti,$(Compile.CXX)) -frtti
+endif
+
+ifeq (Darwin,$(shell uname -s))
+$(ObjDir)/cxa_demangle.o: Compile.CXX := $(filter-out -fno-rtti,$(Compile.CXX)) -frtti
+endif

Modified: lldb/branches/lldb-platform-work/source/Core/Mangled.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/lldb-platform-work/source/Core/Mangled.cpp?rev=183468&r1=183467&r2=183468&view=diff
==============================================================================
--- lldb/branches/lldb-platform-work/source/Core/Mangled.cpp (original)
+++ lldb/branches/lldb-platform-work/source/Core/Mangled.cpp Thu Jun  6 19:06:43 2013
@@ -15,6 +15,8 @@
 #if defined(USE_BUILTIN_LIBCXXABI_DEMANGLER)
 #include "lldb/Core/cxa_demangle.h"
 #else
+// FreeBSD9-STABLE requires this to know about size_t in cxxabi.h
+#include <cstddef>
 #include <cxxabi.h>
 #endif
 
@@ -28,6 +30,7 @@
 #include "lldb/Core/Timer.h"
 #include <ctype.h>
 #include <string.h>
+#include <stdlib.h>
 
 using namespace lldb_private;
 

Modified: lldb/branches/lldb-platform-work/source/Core/Module.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/lldb-platform-work/source/Core/Module.cpp?rev=183468&r1=183467&r2=183468&view=diff
==============================================================================
--- lldb/branches/lldb-platform-work/source/Core/Module.cpp (original)
+++ lldb/branches/lldb-platform-work/source/Core/Module.cpp Thu Jun  6 19:06:43 2013
@@ -7,19 +7,30 @@
 //
 //===----------------------------------------------------------------------===//
 
+#include "lldb/lldb-python.h"
+
+#include "lldb/Core/Error.h"
 #include "lldb/Core/Module.h"
 #include "lldb/Core/DataBuffer.h"
 #include "lldb/Core/DataBufferHeap.h"
 #include "lldb/Core/Log.h"
 #include "lldb/Core/ModuleList.h"
+#include "lldb/Core/ModuleSpec.h"
 #include "lldb/Core/RegularExpression.h"
+#include "lldb/Core/Section.h"
 #include "lldb/Core/StreamString.h"
 #include "lldb/Core/Timer.h"
 #include "lldb/Host/Host.h"
+#include "lldb/Host/Symbols.h"
+#include "lldb/Interpreter/CommandInterpreter.h"
+#include "lldb/Interpreter/ScriptInterpreter.h"
 #include "lldb/lldb-private-log.h"
+#include "lldb/Symbol/CompileUnit.h"
 #include "lldb/Symbol/ObjectFile.h"
 #include "lldb/Symbol/SymbolContext.h"
 #include "lldb/Symbol/SymbolVendor.h"
+#include "lldb/Target/CPPLanguageRuntime.h"
+#include "lldb/Target/ObjCLanguageRuntime.h"
 #include "lldb/Target/Process.h"
 #include "lldb/Target/Target.h"
 
@@ -96,7 +107,7 @@ namespace lldb {
         Mutex::Locker locker (Module::GetAllocationModuleCollectionMutex());
         ModuleCollection &modules = GetModuleCollection();
         const size_t count = modules.size();
-        printf ("%s: %zu modules:\n", __PRETTY_FUNCTION__, count);
+        printf ("%s: %" PRIu64 " modules:\n", __PRETTY_FUNCTION__, (uint64_t)count);
         for (size_t i=0; i<count; ++i)
         {
             
@@ -114,7 +125,7 @@ namespace lldb {
 }
 
 #endif
-    
+
 Module::Module (const ModuleSpec &module_spec) :
     m_mutex (Mutex::eMutexTypeRecursive),
     m_mod_time (module_spec.GetFileSpec().GetModificationTime()),
@@ -125,6 +136,7 @@ Module::Module (const ModuleSpec &module
     m_symfile_spec (module_spec.GetSymbolFileSpec()),
     m_object_name (module_spec.GetObjectName()),
     m_object_offset (module_spec.GetObjectOffset()),
+    m_object_mod_time (module_spec.GetObjectModificationTime()),
     m_objfile_sp (),
     m_symfile_ap (),
     m_ast (),
@@ -143,13 +155,12 @@ Module::Module (const ModuleSpec &module
         GetModuleCollection().push_back(this);
     }
     
-    LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_OBJECT));
+    Log *log(lldb_private::GetLogIfAnyCategoriesSet (LIBLLDB_LOG_OBJECT|LIBLLDB_LOG_MODULES));
     if (log)
-        log->Printf ("%p Module::Module((%s) '%s/%s%s%s%s')",
+        log->Printf ("%p Module::Module((%s) '%s%s%s%s')",
                      this,
                      m_arch.GetArchitectureName(),
-                     m_file.GetDirectory().AsCString(""),
-                     m_file.GetFilename().AsCString(""),
+                     m_file.GetPath().c_str(),
                      m_object_name.IsEmpty() ? "" : "(",
                      m_object_name.IsEmpty() ? "" : m_object_name.AsCString(""),
                      m_object_name.IsEmpty() ? "" : ")");
@@ -158,7 +169,8 @@ Module::Module (const ModuleSpec &module
 Module::Module(const FileSpec& file_spec, 
                const ArchSpec& arch, 
                const ConstString *object_name, 
-               off_t object_offset) :
+               off_t object_offset,
+               const TimeValue *object_mod_time_ptr) :
     m_mutex (Mutex::eMutexTypeRecursive),
     m_mod_time (file_spec.GetModificationTime()),
     m_arch (arch),
@@ -168,6 +180,7 @@ Module::Module(const FileSpec& file_spec
     m_symfile_spec (),
     m_object_name (),
     m_object_offset (object_offset),
+    m_object_mod_time (),
     m_objfile_sp (),
     m_symfile_ap (),
     m_ast (),
@@ -188,13 +201,16 @@ Module::Module(const FileSpec& file_spec
 
     if (object_name)
         m_object_name = *object_name;
-    LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_OBJECT));
+    
+    if (object_mod_time_ptr)
+        m_object_mod_time = *object_mod_time_ptr;
+
+    Log *log(lldb_private::GetLogIfAnyCategoriesSet (LIBLLDB_LOG_OBJECT|LIBLLDB_LOG_MODULES));
     if (log)
-        log->Printf ("%p Module::Module((%s) '%s/%s%s%s%s')",
+        log->Printf ("%p Module::Module((%s) '%s%s%s%s')",
                      this,
                      m_arch.GetArchitectureName(),
-                     m_file.GetDirectory().AsCString(""),
-                     m_file.GetFilename().AsCString(""),
+                     m_file.GetPath().c_str(),
                      m_object_name.IsEmpty() ? "" : "(",
                      m_object_name.IsEmpty() ? "" : m_object_name.AsCString(""),
                      m_object_name.IsEmpty() ? "" : ")");
@@ -202,22 +218,24 @@ Module::Module(const FileSpec& file_spec
 
 Module::~Module()
 {
+    // Lock our module down while we tear everything down to make sure
+    // we don't get any access to the module while it is being destroyed
+    Mutex::Locker locker (m_mutex);
     // Scope for locker below...
     {
         Mutex::Locker locker (GetAllocationModuleCollectionMutex());
         ModuleCollection &modules = GetModuleCollection();
         ModuleCollection::iterator end = modules.end();
         ModuleCollection::iterator pos = std::find(modules.begin(), end, this);
-        if (pos != end)
-            modules.erase(pos);
+        assert (pos != end);
+        modules.erase(pos);
     }
-    LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_OBJECT));
+    Log *log(lldb_private::GetLogIfAnyCategoriesSet (LIBLLDB_LOG_OBJECT|LIBLLDB_LOG_MODULES));
     if (log)
-        log->Printf ("%p Module::~Module((%s) '%s/%s%s%s%s')",
+        log->Printf ("%p Module::~Module((%s) '%s%s%s%s')",
                      this,
                      m_arch.GetArchitectureName(),
-                     m_file.GetDirectory().AsCString(""),
-                     m_file.GetFilename().AsCString(""),
+                     m_file.GetPath().c_str(),
                      m_object_name.IsEmpty() ? "" : "(",
                      m_object_name.IsEmpty() ? "" : m_object_name.AsCString(""),
                      m_object_name.IsEmpty() ? "" : ")");
@@ -243,7 +261,7 @@ Module::GetMemoryObjectFile (const lldb:
         if (process_sp)
         {
             m_did_load_objfile = true;
-            std::auto_ptr<DataBufferHeap> data_ap (new DataBufferHeap (512, 0));
+            std::unique_ptr<DataBufferHeap> data_ap (new DataBufferHeap (512, 0));
             Error readmem_error;
             const size_t bytes_read = process_sp->ReadMemory (header_addr, 
                                                               data_ap->GetBytes(), 
@@ -256,7 +274,7 @@ Module::GetMemoryObjectFile (const lldb:
                 if (m_objfile_sp)
                 {
                     StreamString s;
-                    s.Printf("0x%16.16llx", header_addr);
+                    s.Printf("0x%16.16" PRIx64, header_addr);
                     m_object_name.SetCString (s.GetData());
 
                     // Once we get the object file, update our module with the object file's
@@ -311,6 +329,22 @@ Module::GetClangASTContext ()
         if (objfile && objfile->GetArchitecture(object_arch))
         {
             m_did_init_ast = true;
+
+            // LLVM wants this to be set to iOS or MacOSX; if we're working on
+            // a bare-boards type image, change the triple for llvm's benefit.
+            if (object_arch.GetTriple().getVendor() == llvm::Triple::Apple 
+                && object_arch.GetTriple().getOS() == llvm::Triple::UnknownOS)
+            {
+                if (object_arch.GetTriple().getArch() == llvm::Triple::arm || 
+                    object_arch.GetTriple().getArch() == llvm::Triple::thumb)
+                {
+                    object_arch.GetTriple().setOS(llvm::Triple::IOS);
+                }
+                else
+                {
+                    object_arch.GetTriple().setOS(llvm::Triple::MacOSX);
+                }
+            }
             m_ast.SetArchitecture (object_arch);
         }
     }
@@ -321,16 +355,15 @@ void
 Module::ParseAllDebugSymbols()
 {
     Mutex::Locker locker (m_mutex);
-    uint32_t num_comp_units = GetNumCompileUnits();
+    size_t num_comp_units = GetNumCompileUnits();
     if (num_comp_units == 0)
         return;
 
     SymbolContext sc;
     sc.module_sp = shared_from_this();
-    uint32_t cu_idx;
     SymbolVendor *symbols = GetSymbolVendor ();
 
-    for (cu_idx = 0; cu_idx < num_comp_units; cu_idx++)
+    for (size_t cu_idx = 0; cu_idx < num_comp_units; cu_idx++)
     {
         sc.comp_unit = symbols->GetCompileUnitAtIndex(cu_idx).get();
         if (sc.comp_unit)
@@ -340,8 +373,7 @@ Module::ParseAllDebugSymbols()
 
             symbols->ParseCompileUnitFunctions(sc);
 
-            uint32_t func_idx;
-            for (func_idx = 0; (sc.function = sc.comp_unit->GetFunctionAtIndex(func_idx).get()) != NULL; ++func_idx)
+            for (size_t func_idx = 0; (sc.function = sc.comp_unit->GetFunctionAtIndex(func_idx).get()) != NULL; ++func_idx)
             {
                 symbols->ParseFunctionBlocks(sc);
 
@@ -375,7 +407,7 @@ Module::DumpSymbolContext(Stream *s)
     s->Printf(", Module{%p}", this);
 }
 
-uint32_t
+size_t
 Module::GetNumCompileUnits()
 {
     Mutex::Locker locker (m_mutex);
@@ -387,10 +419,10 @@ Module::GetNumCompileUnits()
 }
 
 CompUnitSP
-Module::GetCompileUnitAtIndex (uint32_t index)
+Module::GetCompileUnitAtIndex (size_t index)
 {
     Mutex::Locker locker (m_mutex);
-    uint32_t num_comp_units = GetNumCompileUnits ();
+    size_t num_comp_units = GetNumCompileUnits ();
     CompUnitSP cu_sp;
 
     if (index < num_comp_units)
@@ -406,7 +438,7 @@ bool
 Module::ResolveFileAddress (lldb::addr_t vm_addr, Address& so_addr)
 {
     Mutex::Locker locker (m_mutex);
-    Timer scoped_timer(__PRETTY_FUNCTION__, "Module::ResolveFileAddress (vm_addr = 0x%llx)", vm_addr);
+    Timer scoped_timer(__PRETTY_FUNCTION__, "Module::ResolveFileAddress (vm_addr = 0x%" PRIx64 ")", vm_addr);
     ObjectFile* ofile = GetObjectFile();
     if (ofile)
         return so_addr.ResolveAddressUsingFileSections(vm_addr, ofile->GetSectionList());
@@ -419,8 +451,8 @@ Module::ResolveSymbolContextForAddress (
     Mutex::Locker locker (m_mutex);
     uint32_t resolved_flags = 0;
 
-    // Clear the result symbol context in case we don't find anything
-    sc.Clear();
+    // Clear the result symbol context in case we don't find anything, but don't clear the target
+    sc.Clear(false);
 
     // Get the section from the section/offset address.
     SectionSP section_sp (so_addr.GetSection());
@@ -486,10 +518,8 @@ Module::ResolveSymbolContextsForFileSpec
 {
     Mutex::Locker locker (m_mutex);
     Timer scoped_timer(__PRETTY_FUNCTION__,
-                       "Module::ResolveSymbolContextForFilePath (%s%s%s:%u, check_inlines = %s, resolve_scope = 0x%8.8x)",
-                       file_spec.GetDirectory().AsCString(""),
-                       file_spec.GetDirectory() ? "/" : "",
-                       file_spec.GetFilename().AsCString(""),
+                       "Module::ResolveSymbolContextForFilePath (%s:%u, check_inlines = %s, resolve_scope = 0x%8.8x)",
+                       file_spec.GetPath().c_str(),
                        line,
                        check_inlines ? "yes" : "no",
                        resolve_scope);
@@ -504,16 +534,24 @@ Module::ResolveSymbolContextsForFileSpec
 }
 
 
-uint32_t
-Module::FindGlobalVariables(const ConstString &name, const ClangNamespaceDecl *namespace_decl, bool append, uint32_t max_matches, VariableList& variables)
+size_t
+Module::FindGlobalVariables (const ConstString &name,
+                             const ClangNamespaceDecl *namespace_decl,
+                             bool append,
+                             size_t max_matches,
+                             VariableList& variables)
 {
     SymbolVendor *symbols = GetSymbolVendor ();
     if (symbols)
         return symbols->FindGlobalVariables(name, namespace_decl, append, max_matches, variables);
     return 0;
 }
-uint32_t
-Module::FindGlobalVariables(const RegularExpression& regex, bool append, uint32_t max_matches, VariableList& variables)
+
+size_t
+Module::FindGlobalVariables (const RegularExpression& regex,
+                             bool append,
+                             size_t max_matches,
+                             VariableList& variables)
 {
     SymbolVendor *symbols = GetSymbolVendor ();
     if (symbols)
@@ -521,7 +559,7 @@ Module::FindGlobalVariables(const Regula
     return 0;
 }
 
-uint32_t
+size_t
 Module::FindCompileUnits (const FileSpec &path,
                           bool append,
                           SymbolContextList &sc_list)
@@ -529,12 +567,12 @@ Module::FindCompileUnits (const FileSpec
     if (!append)
         sc_list.Clear();
     
-    const uint32_t start_size = sc_list.GetSize();
-    const uint32_t num_compile_units = GetNumCompileUnits();
+    const size_t start_size = sc_list.GetSize();
+    const size_t num_compile_units = GetNumCompileUnits();
     SymbolContext sc;
     sc.module_sp = shared_from_this();
     const bool compare_directory = path.GetDirectory();
-    for (uint32_t i=0; i<num_compile_units; ++i)
+    for (size_t i=0; i<num_compile_units; ++i)
     {
         sc.comp_unit = GetCompileUnitAtIndex(i).get();
         if (sc.comp_unit)
@@ -546,10 +584,10 @@ Module::FindCompileUnits (const FileSpec
     return sc_list.GetSize() - start_size;
 }
 
-uint32_t
+size_t
 Module::FindFunctions (const ConstString &name,
                        const ClangNamespaceDecl *namespace_decl,
-                       uint32_t name_type_mask, 
+                       uint32_t name_type_mask,
                        bool include_symbols,
                        bool include_inlines,
                        bool append, 
@@ -558,42 +596,86 @@ Module::FindFunctions (const ConstString
     if (!append)
         sc_list.Clear();
 
-    const uint32_t start_size = sc_list.GetSize();
+    const size_t old_size = sc_list.GetSize();
 
     // Find all the functions (not symbols, but debug information functions...
     SymbolVendor *symbols = GetSymbolVendor ();
-    if (symbols)
-        symbols->FindFunctions(name, namespace_decl, name_type_mask, include_inlines, append, sc_list);
-
-    // Now check our symbol table for symbols that are code symbols if requested
-    if (include_symbols)
+    
+    if (name_type_mask & eFunctionNameTypeAuto)
     {
-        ObjectFile *objfile = GetObjectFile();
-        if (objfile)
+        ConstString lookup_name;
+        uint32_t lookup_name_type_mask = 0;
+        bool match_name_after_lookup = false;
+        Module::PrepareForFunctionNameLookup (name,
+                                              name_type_mask,
+                                              lookup_name,
+                                              lookup_name_type_mask,
+                                              match_name_after_lookup);
+        
+        if (symbols)
+            symbols->FindFunctions(lookup_name,
+                                   namespace_decl,
+                                   lookup_name_type_mask,
+                                   include_inlines,
+                                   append,
+                                   sc_list);
+        
+        // Now check our symbol table for symbols that are code symbols if requested
+        if (include_symbols)
         {
-            Symtab *symtab = objfile->GetSymtab();
-            if (symtab)
+            ObjectFile *objfile = GetObjectFile();
+            if (objfile)
             {
-                std::vector<uint32_t> symbol_indexes;
-                symtab->FindAllSymbolsWithNameAndType (name, eSymbolTypeCode, Symtab::eDebugAny, Symtab::eVisibilityAny, symbol_indexes);
-                const uint32_t num_matches = symbol_indexes.size();
-                if (num_matches)
+                Symtab *symtab = objfile->GetSymtab();
+                if (symtab)
+                    symtab->FindFunctionSymbols(lookup_name, lookup_name_type_mask, sc_list);
+            }
+        }
+
+        if (match_name_after_lookup)
+        {
+            SymbolContext sc;
+            size_t i = old_size;
+            while (i<sc_list.GetSize())
+            {
+                if (sc_list.GetContextAtIndex(i, sc))
                 {
-                    const bool merge_symbol_into_function = true;
-                    SymbolContext sc(this);
-                    for (uint32_t i=0; i<num_matches; i++)
+                    const char *func_name = sc.GetFunctionName().GetCString();
+                    if (func_name && strstr (func_name, name.GetCString()) == NULL)
                     {
-                        sc.symbol = symtab->SymbolAtIndex(symbol_indexes[i]);
-                        sc_list.AppendIfUnique (sc, merge_symbol_into_function);
+                        // Remove the current context
+                        sc_list.RemoveContextAtIndex(i);
+                        // Don't increment i and continue in the loop
+                        continue;
                     }
                 }
+                ++i;
             }
         }
+        
     }
-    return sc_list.GetSize() - start_size;
+    else
+    {
+        if (symbols)
+            symbols->FindFunctions(name, namespace_decl, name_type_mask, include_inlines, append, sc_list);
+
+        // Now check our symbol table for symbols that are code symbols if requested
+        if (include_symbols)
+        {
+            ObjectFile *objfile = GetObjectFile();
+            if (objfile)
+            {
+                Symtab *symtab = objfile->GetSymtab();
+                if (symtab)
+                    symtab->FindFunctionSymbols(name, name_type_mask, sc_list);
+            }
+        }
+    }
+
+    return sc_list.GetSize() - old_size;
 }
 
-uint32_t
+size_t
 Module::FindFunctions (const RegularExpression& regex, 
                        bool include_symbols,
                        bool include_inlines,
@@ -603,7 +685,7 @@ Module::FindFunctions (const RegularExpr
     if (!append)
         sc_list.Clear();
     
-    const uint32_t start_size = sc_list.GetSize();
+    const size_t start_size = sc_list.GetSize();
     
     SymbolVendor *symbols = GetSymbolVendor ();
     if (symbols)
@@ -618,16 +700,19 @@ Module::FindFunctions (const RegularExpr
             if (symtab)
             {
                 std::vector<uint32_t> symbol_indexes;
-                symtab->AppendSymbolIndexesMatchingRegExAndType (regex, eSymbolTypeCode, Symtab::eDebugAny, Symtab::eVisibilityAny, symbol_indexes);
-                const uint32_t num_matches = symbol_indexes.size();
+                symtab->AppendSymbolIndexesMatchingRegExAndType (regex, eSymbolTypeAny, Symtab::eDebugAny, Symtab::eVisibilityAny, symbol_indexes);
+                const size_t num_matches = symbol_indexes.size();
                 if (num_matches)
                 {
                     const bool merge_symbol_into_function = true;
                     SymbolContext sc(this);
-                    for (uint32_t i=0; i<num_matches; i++)
+                    for (size_t i=0; i<num_matches; i++)
                     {
                         sc.symbol = symtab->SymbolAtIndex(symbol_indexes[i]);
-                        sc_list.AppendIfUnique (sc, merge_symbol_into_function);
+                        SymbolType sym_type = sc.symbol->GetType();
+                        if (sc.symbol && (sym_type == eSymbolTypeCode ||
+                                          sym_type == eSymbolTypeResolver))
+                            sc_list.AppendIfUnique (sc, merge_symbol_into_function);
                     }
                 }
             }
@@ -636,12 +721,12 @@ Module::FindFunctions (const RegularExpr
     return sc_list.GetSize() - start_size;
 }
 
-uint32_t
+size_t
 Module::FindTypes_Impl (const SymbolContext& sc,
                         const ConstString &name,
                         const ClangNamespaceDecl *namespace_decl,
                         bool append,
-                        uint32_t max_matches,
+                        size_t max_matches,
                         TypeList& types)
 {
     Timer scoped_timer(__PRETTY_FUNCTION__, __PRETTY_FUNCTION__);
@@ -654,30 +739,44 @@ Module::FindTypes_Impl (const SymbolCont
     return 0;
 }
 
-uint32_t
+size_t
 Module::FindTypesInNamespace (const SymbolContext& sc,
                               const ConstString &type_name,
                               const ClangNamespaceDecl *namespace_decl,
-                              uint32_t max_matches,
+                              size_t max_matches,
                               TypeList& type_list)
 {
     const bool append = true;
     return FindTypes_Impl(sc, type_name, namespace_decl, append, max_matches, type_list);
 }
 
-uint32_t
+lldb::TypeSP
+Module::FindFirstType (const SymbolContext& sc,
+                       const ConstString &name,
+                       bool exact_match)
+{
+    TypeList type_list;
+    const size_t num_matches = FindTypes (sc, name, exact_match, 1, type_list);
+    if (num_matches)
+        return type_list.GetTypeAtIndex(0);
+    return TypeSP();
+}
+
+
+size_t
 Module::FindTypes (const SymbolContext& sc,
                    const ConstString &name,
                    bool exact_match,
-                   uint32_t max_matches,
+                   size_t max_matches,
                    TypeList& types)
 {
-    uint32_t num_matches = 0;
+    size_t num_matches = 0;
     const char *type_name_cstr = name.GetCString();
     std::string type_scope;
     std::string type_basename;
     const bool append = true;
-    if (Type::GetTypeScopeAndBasename (type_name_cstr, type_scope, type_basename))
+    TypeClass type_class = eTypeClassAny;
+    if (Type::GetTypeScopeAndBasename (type_name_cstr, type_scope, type_basename, type_class))
     {
         // Check if "name" starts with "::" which means the qualified type starts
         // from the root namespace and implies and exact match. The typenames we
@@ -692,33 +791,33 @@ Module::FindTypes (const SymbolContext&
         ConstString type_basename_const_str (type_basename.c_str());
         if (FindTypes_Impl(sc, type_basename_const_str, NULL, append, max_matches, types))
         {
-            types.RemoveMismatchedTypes (type_scope, type_basename, exact_match);
+            types.RemoveMismatchedTypes (type_scope, type_basename, type_class, exact_match);
             num_matches = types.GetSize();
         }
     }
     else
     {
         // The type is not in a namespace/class scope, just search for it by basename
-        num_matches = FindTypes_Impl(sc, name, NULL, append, max_matches, types);
+        if (type_class != eTypeClassAny)
+        {
+            // The "type_name_cstr" will have been modified if we have a valid type class
+            // prefix (like "struct", "class", "union", "typedef" etc).
+            num_matches = FindTypes_Impl(sc, ConstString(type_name_cstr), NULL, append, max_matches, types);
+            types.RemoveMismatchedTypes (type_class);
+            num_matches = types.GetSize();
+        }
+        else
+        {
+            num_matches = FindTypes_Impl(sc, name, NULL, append, max_matches, types);
+        }
     }
     
     return num_matches;
     
 }
 
-//uint32_t
-//Module::FindTypes(const SymbolContext& sc, const RegularExpression& regex, bool append, uint32_t max_matches, Type::Encoding encoding, const char *udt_name, TypeList& types)
-//{
-//  Timer scoped_timer(__PRETTY_FUNCTION__);
-//  SymbolVendor *symbols = GetSymbolVendor ();
-//  if (symbols)
-//      return symbols->FindTypes(sc, regex, append, max_matches, encoding, udt_name, types);
-//  return 0;
-//
-//}
-
 SymbolVendor*
-Module::GetSymbolVendor (bool can_create)
+Module::GetSymbolVendor (bool can_create, lldb_private::Stream *feedback_strm)
 {
     Mutex::Locker locker (m_mutex);
     if (m_did_load_symbol_vendor == false && can_create)
@@ -727,7 +826,7 @@ Module::GetSymbolVendor (bool can_create
         if (obj_file != NULL)
         {
             Timer scoped_timer(__PRETTY_FUNCTION__, __PRETTY_FUNCTION__);
-            m_symfile_ap.reset(SymbolVendor::FindPlugin(shared_from_this()));
+            m_symfile_ap.reset(SymbolVendor::FindPlugin(shared_from_this(), feedback_strm));
             m_did_load_symbol_vendor = true;
         }
     }
@@ -750,6 +849,19 @@ Module::GetArchitecture () const
     return m_arch;
 }
 
+std::string
+Module::GetSpecificationDescription () const
+{
+    std::string spec(GetFileSpec().GetPath());
+    if (m_object_name)
+    {
+        spec += '(';
+        spec += m_object_name.GetCString();
+        spec += ')';
+    }
+    return spec;
+}
+
 void
 Module::GetDescription (Stream *s, lldb::DescriptionLevel level)
 {
@@ -913,9 +1025,8 @@ Module::Dump(Stream *s)
     Mutex::Locker locker (m_mutex);
     //s->Printf("%.*p: ", (int)sizeof(void*) * 2, this);
     s->Indent();
-    s->Printf("Module %s/%s%s%s%s\n",
-              m_file.GetDirectory().AsCString(),
-              m_file.GetFilename().AsCString(),
+    s->Printf("Module %s%s%s%s\n",
+              m_file.GetPath().c_str(),
               m_object_name ? "(" : "",
               m_object_name ? m_object_name.GetCString() : "",
               m_object_name ? ")" : "");
@@ -959,12 +1070,14 @@ Module::GetObjectFile()
         m_did_load_objfile = true;
         Timer scoped_timer(__PRETTY_FUNCTION__,
                            "Module::GetObjectFile () module = %s", GetFileSpec().GetFilename().AsCString(""));
-        DataBufferSP file_data_sp;
-        m_objfile_sp = ObjectFile::FindPlugin (shared_from_this(), 
+        DataBufferSP data_sp;
+        lldb::offset_t data_offset = 0;
+        m_objfile_sp = ObjectFile::FindPlugin (shared_from_this(),
                                                &m_file, 
                                                m_object_offset, 
                                                m_file.GetByteSize(), 
-                                               file_data_sp);
+                                               data_sp,
+                                               data_offset);
         if (m_objfile_sp)
         {
 			// Once we get the object file, update our module with the object file's 
@@ -1014,6 +1127,25 @@ Module::SymbolIndicesToSymbolContextList
 }
 
 size_t
+Module::FindFunctionSymbols (const ConstString &name,
+                             uint32_t name_type_mask,
+                             SymbolContextList& sc_list)
+{
+    Timer scoped_timer(__PRETTY_FUNCTION__,
+                       "Module::FindSymbolsFunctions (name = %s, mask = 0x%8.8x)",
+                       name.AsCString(),
+                       name_type_mask);
+    ObjectFile *objfile = GetObjectFile ();
+    if (objfile)
+    {
+        Symtab *symtab = objfile->GetSymtab();
+        if (symtab)
+            return symtab->FindFunctionSymbols (name, name_type_mask, sc_list);
+    }
+    return 0;
+}
+
+size_t
 Module::FindSymbolsWithNameAndType (const ConstString &name, SymbolType symbol_type, SymbolContextList &sc_list)
 {
     // No need to protect this call using m_mutex all other method calls are
@@ -1064,12 +1196,15 @@ Module::FindSymbolsMatchingRegExAndType
     return sc_list.GetSize() - initial_size;
 }
 
-const TimeValue &
-Module::GetModificationTime () const
+void
+Module::SetSymbolFileFileSpec (const FileSpec &file)
 {
-    return m_mod_time;
+    m_symfile_spec = file;
+    m_symfile_ap.reset();
+    m_did_load_symbol_vendor = false;
 }
 
+
 bool
 Module::IsExecutable ()
 {
@@ -1101,7 +1236,76 @@ Module::IsLoadedInTarget (Target *target
     }
     return false;
 }
-bool 
+
+bool
+Module::LoadScriptingResourceInTarget (Target *target, Error& error, Stream* feedback_stream)
+{
+    if (!target)
+    {
+        error.SetErrorString("invalid destination Target");
+        return false;
+    }
+    
+    LoadScriptFromSymFile shoud_load = target->TargetProperties::GetLoadScriptFromSymbolFile();
+    
+    Debugger &debugger = target->GetDebugger();
+    const ScriptLanguage script_language = debugger.GetScriptLanguage();
+    if (script_language != eScriptLanguageNone)
+    {
+        
+        PlatformSP platform_sp(target->GetPlatform());
+        
+        if (!platform_sp)
+        {
+            error.SetErrorString("invalid Platform");
+            return false;
+        }
+
+        FileSpecList file_specs = platform_sp->LocateExecutableScriptingResources (target,
+                                                                                   *this);
+        
+        
+        const uint32_t num_specs = file_specs.GetSize();
+        if (num_specs)
+        {
+            ScriptInterpreter *script_interpreter = debugger.GetCommandInterpreter().GetScriptInterpreter();
+            if (script_interpreter)
+            {
+                for (uint32_t i=0; i<num_specs; ++i)
+                {
+                    FileSpec scripting_fspec (file_specs.GetFileSpecAtIndex(i));
+                    if (scripting_fspec && scripting_fspec.Exists())
+                    {
+                        if (shoud_load == eLoadScriptFromSymFileFalse)
+                            return false;
+                        if (shoud_load == eLoadScriptFromSymFileWarn)
+                        {
+                            if (feedback_stream)
+                                feedback_stream->Printf("warning: '%s' contains a debug script. To run this script in this debug session:\n\n    command script import \"%s\"\n\nTo run all discovered debug scripts in this session:\n\n    settings set target.load-script-from-symbol-file true\n"
+                                                        ,GetFileSpec().GetFileNameStrippingExtension().GetCString(),scripting_fspec.GetPath().c_str());
+                            return false;
+                        }
+                        StreamString scripting_stream;
+                        scripting_fspec.Dump(&scripting_stream);
+                        const bool can_reload = true;
+                        const bool init_lldb_globals = false;
+                        bool did_load = script_interpreter->LoadScriptingModule(scripting_stream.GetData(), can_reload, init_lldb_globals, error);
+                        if (!did_load)
+                            return false;
+                    }
+                }
+            }
+            else
+            {
+                error.SetErrorString("invalid ScriptInterpreter");
+                return false;
+            }
+        }
+    }
+    return true;
+}
+
+bool
 Module::SetArchitecture (const ArchSpec &new_arch)
 {
     if (!m_arch.IsValid())
@@ -1109,7 +1313,7 @@ Module::SetArchitecture (const ArchSpec
         m_arch = new_arch;
         return true;
     }    
-    return m_arch == new_arch;
+    return m_arch.IsExactMatch(new_arch);
 }
 
 bool 
@@ -1168,14 +1372,14 @@ Module::MatchesModuleSpec (const ModuleS
     const FileSpec &platform_file_spec = module_ref.GetPlatformFileSpec();
     if (platform_file_spec)
     {
-        if (!FileSpec::Equal (platform_file_spec, m_platform_file, platform_file_spec.GetDirectory()))
+        if (!FileSpec::Equal (platform_file_spec, GetPlatformFileSpec (), platform_file_spec.GetDirectory()))
             return false;
     }
     
     const ArchSpec &arch = module_ref.GetArchitecture();
     if (arch.IsValid())
     {
-        if (m_arch != arch)
+        if (!m_arch.IsCompatibleMatch(arch))
             return false;
     }
     
@@ -1202,3 +1406,122 @@ Module::RemapSourceFile (const char *pat
     return m_source_mappings.RemapPath(path, new_path);
 }
 
+uint32_t
+Module::GetVersion (uint32_t *versions, uint32_t num_versions)
+{
+    ObjectFile *obj_file = GetObjectFile();
+    if (obj_file)
+        return obj_file->GetVersion (versions, num_versions);
+        
+    if (versions && num_versions)
+    {
+        for (uint32_t i=0; i<num_versions; ++i)
+            versions[i] = UINT32_MAX;
+    }
+    return 0;
+}
+
+void
+Module::PrepareForFunctionNameLookup (const ConstString &name,
+                                      uint32_t name_type_mask,
+                                      ConstString &lookup_name,
+                                      uint32_t &lookup_name_type_mask,
+                                      bool &match_name_after_lookup)
+{
+    const char *name_cstr = name.GetCString();
+    lookup_name_type_mask = eFunctionNameTypeNone;
+    match_name_after_lookup = false;
+    const char *base_name_start = NULL;
+    const char *base_name_end = NULL;
+    
+    if (name_type_mask & eFunctionNameTypeAuto)
+    {
+        if (CPPLanguageRuntime::IsCPPMangledName (name_cstr))
+            lookup_name_type_mask = eFunctionNameTypeFull;
+        else if (ObjCLanguageRuntime::IsPossibleObjCMethodName (name_cstr))
+            lookup_name_type_mask = eFunctionNameTypeFull;
+        else
+        {
+            if (ObjCLanguageRuntime::IsPossibleObjCSelector(name_cstr))
+                lookup_name_type_mask |= eFunctionNameTypeSelector;
+            
+            CPPLanguageRuntime::MethodName cpp_method (name);
+            llvm::StringRef basename (cpp_method.GetBasename());
+            if (basename.empty())
+            {
+                if (CPPLanguageRuntime::StripNamespacesFromVariableName (name_cstr, base_name_start, base_name_end))
+                    lookup_name_type_mask |= (eFunctionNameTypeMethod | eFunctionNameTypeBase);
+            }
+            else
+            {
+                base_name_start = basename.data();
+                base_name_end = base_name_start + basename.size();
+                lookup_name_type_mask |= (eFunctionNameTypeMethod | eFunctionNameTypeBase);
+            }
+        }
+    }
+    else
+    {
+        lookup_name_type_mask = name_type_mask;
+        if (lookup_name_type_mask & eFunctionNameTypeMethod || name_type_mask & eFunctionNameTypeBase)
+        {
+            // If they've asked for a CPP method or function name and it can't be that, we don't
+            // even need to search for CPP methods or names.
+            CPPLanguageRuntime::MethodName cpp_method (name);
+            if (cpp_method.IsValid())
+            {
+                llvm::StringRef basename (cpp_method.GetBasename());
+                base_name_start = basename.data();
+                base_name_end = base_name_start + basename.size();
+
+                if (!cpp_method.GetQualifiers().empty())
+                {
+                    // There is a "const" or other qualifer following the end of the fucntion parens,
+                    // this can't be a eFunctionNameTypeBase
+                    lookup_name_type_mask &= ~(eFunctionNameTypeBase);
+                    if (lookup_name_type_mask == eFunctionNameTypeNone)
+                        return;
+                }
+            }
+            else
+            {
+                if (!CPPLanguageRuntime::StripNamespacesFromVariableName (name_cstr, base_name_start, base_name_end))
+                {
+                    lookup_name_type_mask &= ~(eFunctionNameTypeMethod | eFunctionNameTypeBase);
+                    if (lookup_name_type_mask == eFunctionNameTypeNone)
+                        return;
+                }
+            }
+        }
+        
+        if (lookup_name_type_mask & eFunctionNameTypeSelector)
+        {
+            if (!ObjCLanguageRuntime::IsPossibleObjCSelector(name_cstr))
+            {
+                lookup_name_type_mask &= ~(eFunctionNameTypeSelector);
+                if (lookup_name_type_mask == eFunctionNameTypeNone)
+                    return;
+            }
+        }
+    }
+    
+    if (base_name_start &&
+        base_name_end &&
+        base_name_start != name_cstr &&
+        base_name_start < base_name_end)
+    {
+        // The name supplied was a partial C++ path like "a::count". In this case we want to do a
+        // lookup on the basename "count" and then make sure any matching results contain "a::count"
+        // so that it would match "b::a::count" and "a::count". This is why we set "match_name_after_lookup"
+        // to true
+        lookup_name.SetCStringWithLength(base_name_start, base_name_end - base_name_start);
+        match_name_after_lookup = true;
+    }
+    else
+    {
+        // The name is already correct, just use the exact name as supplied, and we won't need
+        // to check if any matches contain "name"
+        lookup_name = name;
+        match_name_after_lookup = false;
+    }
+}
\ No newline at end of file

Modified: lldb/branches/lldb-platform-work/source/Core/ModuleList.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/lldb-platform-work/source/Core/ModuleList.cpp?rev=183468&r1=183467&r2=183468&view=diff
==============================================================================
--- lldb/branches/lldb-platform-work/source/Core/ModuleList.cpp (original)
+++ lldb/branches/lldb-platform-work/source/Core/ModuleList.cpp Thu Jun  6 19:06:43 2013
@@ -15,6 +15,7 @@
 // Project includes
 #include "lldb/Core/Log.h"
 #include "lldb/Core/Module.h"
+#include "lldb/Core/ModuleSpec.h"
 #include "lldb/Host/Host.h"
 #include "lldb/Host/Symbols.h"
 #include "lldb/Symbol/ClangNamespaceDecl.h"
@@ -29,7 +30,8 @@ using namespace lldb_private;
 //----------------------------------------------------------------------
 ModuleList::ModuleList() :
     m_modules(),
-    m_modules_mutex (Mutex::eMutexTypeRecursive)
+    m_modules_mutex (Mutex::eMutexTypeRecursive),
+    m_notifier(NULL)
 {
 }
 
@@ -45,6 +47,13 @@ ModuleList::ModuleList(const ModuleList&
     m_modules = rhs.m_modules;
 }
 
+ModuleList::ModuleList (ModuleList::Notifier* notifier) :
+    m_modules(),
+    m_modules_mutex (Mutex::eMutexTypeRecursive),
+    m_notifier(notifier)
+{
+}
+
 //----------------------------------------------------------------------
 // Assignment operator
 //----------------------------------------------------------------------
@@ -68,16 +77,24 @@ ModuleList::~ModuleList()
 }
 
 void
-ModuleList::Append (const ModuleSP &module_sp)
+ModuleList::AppendImpl (const ModuleSP &module_sp, bool use_notifier)
 {
     if (module_sp)
     {
         Mutex::Locker locker(m_modules_mutex);
         m_modules.push_back(module_sp);
+        if (use_notifier && m_notifier)
+            m_notifier->ModuleAdded(*this, module_sp);
     }
 }
 
 void
+ModuleList::Append (const ModuleSP &module_sp)
+{
+    AppendImpl (module_sp);
+}
+
+void
 ModuleList::ReplaceEquivalent (const ModuleSP &module_sp)
 {
     if (module_sp)
@@ -94,12 +111,12 @@ ModuleList::ReplaceEquivalent (const Mod
         {
             ModuleSP module_sp (m_modules[idx]);
             if (module_sp->MatchesModuleSpec (equivalent_module_spec))
-                m_modules.erase(m_modules.begin() + idx);
+                RemoveImpl(m_modules.begin() + idx);
             else
                 ++idx;
         }
         // Now add the new module to the list
-        m_modules.push_back(module_sp);
+        Append(module_sp);
     }
 }
 
@@ -116,14 +133,30 @@ ModuleList::AppendIfNeeded (const Module
                 return false; // Already in the list
         }
         // Only push module_sp on the list if it wasn't already in there.
-        m_modules.push_back(module_sp);
+        Append(module_sp);
         return true;
     }
     return false;
 }
 
+void
+ModuleList::Append (const ModuleList& module_list)
+{
+    for (auto pos : module_list.m_modules)
+        Append(pos);
+}
+
 bool
-ModuleList::Remove (const ModuleSP &module_sp)
+ModuleList::AppendIfNeeded (const ModuleList& module_list)
+{
+    bool any_in = false;
+    for (auto pos : module_list.m_modules)
+        any_in = AppendIfNeeded(pos) | any_in;
+    return any_in;
+}
+
+bool
+ModuleList::RemoveImpl (const ModuleSP &module_sp, bool use_notifier)
 {
     if (module_sp)
     {
@@ -134,6 +167,8 @@ ModuleList::Remove (const ModuleSP &modu
             if (pos->get() == module_sp.get())
             {
                 m_modules.erase (pos);
+                if (use_notifier && m_notifier)
+                    m_notifier->ModuleRemoved(*this, module_sp);
                 return true;
             }
         }
@@ -141,6 +176,33 @@ ModuleList::Remove (const ModuleSP &modu
     return false;
 }
 
+ModuleList::collection::iterator
+ModuleList::RemoveImpl (ModuleList::collection::iterator pos, bool use_notifier)
+{
+    ModuleSP module_sp(*pos);
+    collection::iterator retval = m_modules.erase(pos);
+    if (use_notifier && m_notifier)
+        m_notifier->ModuleRemoved(*this, module_sp);
+    return retval;
+}
+
+bool
+ModuleList::Remove (const ModuleSP &module_sp)
+{
+    return RemoveImpl (module_sp);
+}
+
+bool
+ModuleList::ReplaceModule (const lldb::ModuleSP &old_module_sp, const lldb::ModuleSP &new_module_sp)
+{
+    if (!RemoveImpl(old_module_sp, false))
+        return false;
+    AppendImpl (new_module_sp, false);
+    if (m_notifier)
+        m_notifier->ModuleUpdated(*this, old_module_sp,new_module_sp);
+    return true;
+}
+
 bool
 ModuleList::RemoveIfOrphaned (const Module *module_ptr)
 {
@@ -154,7 +216,7 @@ ModuleList::RemoveIfOrphaned (const Modu
             {
                 if (pos->unique())
                 {
-                    pos = m_modules.erase (pos);
+                    pos = RemoveImpl(pos);
                     return true;
                 }
                 else
@@ -186,7 +248,7 @@ ModuleList::RemoveOrphans (bool mandator
     {
         if (pos->unique())
         {
-            pos = m_modules.erase (pos);
+            pos = RemoveImpl(pos);
             ++remove_count;
         }
         else
@@ -212,31 +274,36 @@ ModuleList::Remove (ModuleList &module_l
 }
 
 
-
 void
 ModuleList::Clear()
 {
-    Mutex::Locker locker(m_modules_mutex);
-    m_modules.clear();
+    ClearImpl();
 }
 
 void
 ModuleList::Destroy()
 {
+    ClearImpl();
+}
+
+void
+ModuleList::ClearImpl (bool use_notifier)
+{
     Mutex::Locker locker(m_modules_mutex);
-    collection empty;
-    m_modules.swap(empty);
+    if (use_notifier && m_notifier)
+        m_notifier->WillClearList(*this);
+    m_modules.clear();
 }
 
 Module*
-ModuleList::GetModulePointerAtIndex (uint32_t idx) const
+ModuleList::GetModulePointerAtIndex (size_t idx) const
 {
     Mutex::Locker locker(m_modules_mutex);
     return GetModulePointerAtIndexUnlocked(idx);
 }
 
 Module*
-ModuleList::GetModulePointerAtIndexUnlocked (uint32_t idx) const
+ModuleList::GetModulePointerAtIndexUnlocked (size_t idx) const
 {
     if (idx < m_modules.size())
         return m_modules[idx].get();
@@ -244,14 +311,14 @@ ModuleList::GetModulePointerAtIndexUnloc
 }
 
 ModuleSP
-ModuleList::GetModuleAtIndex(uint32_t idx)
+ModuleList::GetModuleAtIndex(size_t idx) const
 {
     Mutex::Locker locker(m_modules_mutex);
     return GetModuleAtIndexUnlocked(idx);
 }
 
 ModuleSP
-ModuleList::GetModuleAtIndexUnlocked(uint32_t idx)
+ModuleList::GetModuleAtIndexUnlocked(size_t idx) const
 {
     ModuleSP module_sp;
     if (idx < m_modules.size())
@@ -259,31 +326,81 @@ ModuleList::GetModuleAtIndexUnlocked(uin
     return module_sp;
 }
 
-uint32_t
+size_t
 ModuleList::FindFunctions (const ConstString &name, 
                            uint32_t name_type_mask, 
                            bool include_symbols,
                            bool include_inlines,
                            bool append, 
-                           SymbolContextList &sc_list)
+                           SymbolContextList &sc_list) const
 {
     if (!append)
         sc_list.Clear();
     
-    Mutex::Locker locker(m_modules_mutex);
-    collection::const_iterator pos, end = m_modules.end();
-    for (pos = m_modules.begin(); pos != end; ++pos)
+    const size_t old_size = sc_list.GetSize();
+    
+    if (name_type_mask & eFunctionNameTypeAuto)
     {
-        (*pos)->FindFunctions (name, NULL, name_type_mask, include_symbols, include_inlines, true, sc_list);
+        ConstString lookup_name;
+        uint32_t lookup_name_type_mask = 0;
+        bool match_name_after_lookup = false;
+        Module::PrepareForFunctionNameLookup (name, name_type_mask,
+                                              lookup_name,
+                                              lookup_name_type_mask,
+                                              match_name_after_lookup);
+    
+        Mutex::Locker locker(m_modules_mutex);
+        collection::const_iterator pos, end = m_modules.end();
+        for (pos = m_modules.begin(); pos != end; ++pos)
+        {
+            (*pos)->FindFunctions (lookup_name,
+                                   NULL,
+                                   lookup_name_type_mask,
+                                   include_symbols,
+                                   include_inlines,
+                                   true,
+                                   sc_list);
+        }
+        
+        if (match_name_after_lookup)
+        {
+            SymbolContext sc;
+            size_t i = old_size;
+            while (i<sc_list.GetSize())
+            {
+                if (sc_list.GetContextAtIndex(i, sc))
+                {
+                    const char *func_name = sc.GetFunctionName().GetCString();
+                    if (func_name && strstr (func_name, name.GetCString()) == NULL)
+                    {
+                        // Remove the current context
+                        sc_list.RemoveContextAtIndex(i);
+                        // Don't increment i and continue in the loop
+                        continue;
+                    }
+                }
+                ++i;
+            }
+        }
+
     }
+    else
+    {
     
-    return sc_list.GetSize();
+        Mutex::Locker locker(m_modules_mutex);
+        collection::const_iterator pos, end = m_modules.end();
+        for (pos = m_modules.begin(); pos != end; ++pos)
+        {
+            (*pos)->FindFunctions (name, NULL, name_type_mask, include_symbols, include_inlines, true, sc_list);
+        }
+    }
+    return sc_list.GetSize() - old_size;
 }
 
-uint32_t
+size_t
 ModuleList::FindCompileUnits (const FileSpec &path, 
                               bool append, 
-                              SymbolContextList &sc_list)
+                              SymbolContextList &sc_list) const
 {
     if (!append)
         sc_list.Clear();
@@ -298,15 +415,15 @@ ModuleList::FindCompileUnits (const File
     return sc_list.GetSize();
 }
 
-uint32_t
+size_t
 ModuleList::FindGlobalVariables (const ConstString &name, 
                                  bool append, 
-                                 uint32_t max_matches, 
-                                 VariableList& variable_list)
+                                 size_t max_matches,
+                                 VariableList& variable_list) const
 {
     size_t initial_size = variable_list.GetSize();
     Mutex::Locker locker(m_modules_mutex);
-    collection::iterator pos, end = m_modules.end();
+    collection::const_iterator pos, end = m_modules.end();
     for (pos = m_modules.begin(); pos != end; ++pos)
     {
         (*pos)->FindGlobalVariables (name, NULL, append, max_matches, variable_list);
@@ -315,15 +432,15 @@ ModuleList::FindGlobalVariables (const C
 }
 
 
-uint32_t
+size_t
 ModuleList::FindGlobalVariables (const RegularExpression& regex, 
                                  bool append, 
-                                 uint32_t max_matches, 
-                                 VariableList& variable_list)
+                                 size_t max_matches,
+                                 VariableList& variable_list) const
 {
     size_t initial_size = variable_list.GetSize();
     Mutex::Locker locker(m_modules_mutex);
-    collection::iterator pos, end = m_modules.end();
+    collection::const_iterator pos, end = m_modules.end();
     for (pos = m_modules.begin(); pos != end; ++pos)
     {
         (*pos)->FindGlobalVariables (regex, append, max_matches, variable_list);
@@ -336,14 +453,14 @@ size_t
 ModuleList::FindSymbolsWithNameAndType (const ConstString &name, 
                                         SymbolType symbol_type, 
                                         SymbolContextList &sc_list,
-                                        bool append)
+                                        bool append) const
 {
     Mutex::Locker locker(m_modules_mutex);
     if (!append)
         sc_list.Clear();
     size_t initial_size = sc_list.GetSize();
     
-    collection::iterator pos, end = m_modules.end();
+    collection::const_iterator pos, end = m_modules.end();
     for (pos = m_modules.begin(); pos != end; ++pos)
         (*pos)->FindSymbolsWithNameAndType (name, symbol_type, sc_list);
     return sc_list.GetSize() - initial_size;
@@ -353,14 +470,14 @@ size_t
 ModuleList::FindSymbolsMatchingRegExAndType (const RegularExpression &regex, 
                                              lldb::SymbolType symbol_type, 
                                              SymbolContextList &sc_list,
-                                             bool append)
+                                             bool append) const
 {
     Mutex::Locker locker(m_modules_mutex);
     if (!append)
         sc_list.Clear();
     size_t initial_size = sc_list.GetSize();
     
-    collection::iterator pos, end = m_modules.end();
+    collection::const_iterator pos, end = m_modules.end();
     for (pos = m_modules.begin(); pos != end; ++pos)
         (*pos)->FindSymbolsMatchingRegExAndType (regex, symbol_type, sc_list);
     return sc_list.GetSize() - initial_size;
@@ -383,7 +500,7 @@ ModuleList::FindModules (const ModuleSpe
 }
 
 ModuleSP
-ModuleList::FindModule (const Module *module_ptr)
+ModuleList::FindModule (const Module *module_ptr) const
 {
     ModuleSP module_sp;
 
@@ -406,7 +523,7 @@ ModuleList::FindModule (const Module *mo
 }
 
 ModuleSP
-ModuleList::FindModule (const UUID &uuid)
+ModuleList::FindModule (const UUID &uuid) const
 {
     ModuleSP module_sp;
     
@@ -428,12 +545,12 @@ ModuleList::FindModule (const UUID &uuid
 }
 
 
-uint32_t
-ModuleList::FindTypes (const SymbolContext& sc, const ConstString &name, bool name_is_fully_qualified, uint32_t max_matches, TypeList& types)
+size_t
+ModuleList::FindTypes (const SymbolContext& sc, const ConstString &name, bool name_is_fully_qualified, size_t max_matches, TypeList& types) const
 {
     Mutex::Locker locker(m_modules_mutex);
 
-    uint32_t total_matches = 0;
+    size_t total_matches = 0;
     collection::const_iterator pos, end = m_modules.end();
     if (sc.module_sp)
     {
@@ -453,13 +570,14 @@ ModuleList::FindTypes (const SymbolConte
     
     if (total_matches < max_matches)
     {
+        SymbolContext world_sc;
         for (pos = m_modules.begin(); pos != end; ++pos)
         {
             // Search the module if the module is not equal to the one in the symbol
             // context "sc". If "sc" contains a empty module shared pointer, then
             // the comparisong will always be true (valid_module_ptr != NULL).
             if (sc.module_sp.get() != (*pos).get())
-                total_matches += (*pos)->FindTypes (sc, name, name_is_fully_qualified, max_matches, types);
+                total_matches += (*pos)->FindTypes (world_sc, name, name_is_fully_qualified, max_matches, types);
             
             if (total_matches >= max_matches)
                 break;
@@ -485,7 +603,7 @@ ModuleList::FindSourceFile (const FileSp
 
 
 ModuleSP
-ModuleList::FindFirstModule (const ModuleSpec &module_spec)
+ModuleList::FindFirstModule (const ModuleSpec &module_spec) const
 {
     ModuleSP module_sp;
     Mutex::Locker locker(m_modules_mutex);
@@ -528,31 +646,28 @@ ModuleList::Dump(Stream *s) const
 }
 
 void
-ModuleList::LogUUIDAndPaths (LogSP &log_sp, const char *prefix_cstr)
+ModuleList::LogUUIDAndPaths (Log *log, const char *prefix_cstr)
 {
-    if (log_sp)
+    if (log)
     {   
         Mutex::Locker locker(m_modules_mutex);
-        char uuid_cstr[256];
         collection::const_iterator pos, begin = m_modules.begin(), end = m_modules.end();
         for (pos = begin; pos != end; ++pos)
         {
             Module *module = pos->get();
-            module->GetUUID().GetAsCString (uuid_cstr, sizeof(uuid_cstr));
             const FileSpec &module_file_spec = module->GetFileSpec();
-            log_sp->Printf ("%s[%u] %s (%s) \"%s/%s\"", 
-                            prefix_cstr ? prefix_cstr : "",
-                            (uint32_t)std::distance (begin, pos),
-                            uuid_cstr,
-                            module->GetArchitecture().GetArchitectureName(),
-                            module_file_spec.GetDirectory().GetCString(),
-                            module_file_spec.GetFilename().GetCString());
+            log->Printf ("%s[%u] %s (%s) \"%s\"",
+                         prefix_cstr ? prefix_cstr : "",
+                         (uint32_t)std::distance (begin, pos),
+                         module->GetUUID().GetAsString().c_str(),
+                         module->GetArchitecture().GetArchitectureName(),
+                         module_file_spec.GetPath().c_str());
         }
     }
 }
 
 bool
-ModuleList::ResolveFileAddress (lldb::addr_t vm_addr, Address& so_addr)
+ModuleList::ResolveFileAddress (lldb::addr_t vm_addr, Address& so_addr) const
 {
     Mutex::Locker locker(m_modules_mutex);
     collection::const_iterator pos, end = m_modules.end();
@@ -566,7 +681,7 @@ ModuleList::ResolveFileAddress (lldb::ad
 }
 
 uint32_t
-ModuleList::ResolveSymbolContextForAddress (const Address& so_addr, uint32_t resolve_scope, SymbolContext& sc)
+ModuleList::ResolveSymbolContextForAddress (const Address& so_addr, uint32_t resolve_scope, SymbolContext& sc) const
 {
     // The address is already section offset so it has a module
     uint32_t resolved_flags = 0;
@@ -602,14 +717,14 @@ ModuleList::ResolveSymbolContextForFileP
     bool check_inlines, 
     uint32_t resolve_scope, 
     SymbolContextList& sc_list
-)
+)  const
 {
     FileSpec file_spec(file_path, false);
     return ResolveSymbolContextsForFileSpec (file_spec, line, check_inlines, resolve_scope, sc_list);
 }
 
 uint32_t
-ModuleList::ResolveSymbolContextsForFileSpec (const FileSpec &file_spec, uint32_t line, bool check_inlines, uint32_t resolve_scope, SymbolContextList& sc_list)
+ModuleList::ResolveSymbolContextsForFileSpec (const FileSpec &file_spec, uint32_t line, bool check_inlines, uint32_t resolve_scope, SymbolContextList& sc_list) const
 {
     Mutex::Locker locker(m_modules_mutex);
     collection::const_iterator pos, end = m_modules.end();
@@ -621,7 +736,7 @@ ModuleList::ResolveSymbolContextsForFile
     return sc_list.GetSize();
 }
 
-uint32_t
+size_t
 ModuleList::GetIndexForModule (const Module *module) const
 {
     if (module)
@@ -642,8 +757,14 @@ ModuleList::GetIndexForModule (const Mod
 static ModuleList &
 GetSharedModuleList ()
 {
-    static ModuleList g_shared_module_list;
-    return g_shared_module_list;
+    // NOTE: Intentionally leak the module list so a program doesn't have to
+    // cleanup all modules and object files as it exits. This just wastes time
+    // doing a bunch of cleanup that isn't required.
+    static ModuleList *g_shared_module_list = NULL;
+    if (g_shared_module_list == NULL)
+        g_shared_module_list = new ModuleList(); // <--- Intentional leak!!!
+    
+    return *g_shared_module_list;
 }
 
 bool
@@ -663,7 +784,7 @@ ModuleList::FindSharedModules (const Mod
     return GetSharedModuleList ().FindModules (module_spec, matching_module_list);
 }
 
-uint32_t
+size_t
 ModuleList::RemoveOrphanSharedModules (bool mandatory)
 {
     return GetSharedModuleList ().RemoveOrphans(mandatory);
@@ -683,7 +804,6 @@ ModuleList::GetSharedModule
     ModuleList &shared_module_list = GetSharedModuleList ();
     Mutex::Locker locker(shared_module_list.m_modules_mutex);
     char path[PATH_MAX];
-    char uuid_cstr[64];
 
     Error error;
 
@@ -707,7 +827,7 @@ ModuleList::GetSharedModule
         const size_t num_matching_modules = shared_module_list.FindModules (module_spec, matching_module_list);
         if (num_matching_modules > 0)
         {
-            for (uint32_t module_idx = 0; module_idx < num_matching_modules; ++module_idx)
+            for (size_t module_idx = 0; module_idx < num_matching_modules; ++module_idx)
             {
                 module_sp = matching_module_list.GetModuleAtIndex(module_idx);
                 
@@ -716,6 +836,11 @@ ModuleList::GetSharedModule
                 {
                     if (old_module_sp_ptr && !old_module_sp_ptr->get())
                         *old_module_sp_ptr = module_sp;
+
+                    Log *log(lldb_private::GetLogIfAnyCategoriesSet (LIBLLDB_LOG_MODULES));
+                    if (log)
+                        log->Printf("module changed: %p, removing from global module list", module_sp.get());
+
                     shared_module_list.Remove (module_sp);
                     module_sp.reset();
                 }
@@ -778,16 +903,14 @@ ModuleList::GetSharedModule
                 module_file_spec.GetPath(path, sizeof(path));
             if (file_spec.Exists())
             {
+                std::string uuid_str;
                 if (uuid_ptr && uuid_ptr->IsValid())
-                    uuid_ptr->GetAsCString(uuid_cstr, sizeof (uuid_cstr));
-                else
-                    uuid_cstr[0] = '\0';
-
+                    uuid_str = uuid_ptr->GetAsString();
 
                 if (arch.IsValid())
                 {
-                    if (uuid_cstr[0])
-                        error.SetErrorStringWithFormat("'%s' does not contain the %s architecture and UUID %s", path, arch.GetArchitectureName(), uuid_cstr);
+                    if (!uuid_str.empty())
+                        error.SetErrorStringWithFormat("'%s' does not contain the %s architecture and UUID %s", path, arch.GetArchitectureName(), uuid_str.c_str());
                     else
                         error.SetErrorStringWithFormat("'%s' does not contain the %s architecture.", path, arch.GetArchitectureName());
                 }
@@ -857,13 +980,12 @@ ModuleList::GetSharedModule
                 }
                 else
                 {
+                    std::string uuid_str;
                     if (uuid_ptr && uuid_ptr->IsValid())
-                        uuid_ptr->GetAsCString(uuid_cstr, sizeof (uuid_cstr));
-                    else
-                        uuid_cstr[0] = '\0';
+                        uuid_str = uuid_ptr->GetAsString();
 
-                    if (uuid_cstr[0])
-                        error.SetErrorStringWithFormat("cannot locate a module for UUID '%s'", uuid_cstr);
+                    if (!uuid_str.empty())
+                        error.SetErrorStringWithFormat("cannot locate a module for UUID '%s'", uuid_str.c_str());
                     else
                         error.SetErrorStringWithFormat("cannot locate a module");
                 }
@@ -886,4 +1008,33 @@ ModuleList::RemoveSharedModuleIfOrphaned
     return GetSharedModuleList ().RemoveIfOrphaned (module_ptr);
 }
 
-
+bool
+ModuleList::LoadScriptingResourcesInTarget (Target *target,
+                                            std::list<Error>& errors,
+                                            Stream *feedback_stream,
+                                            bool continue_on_error)
+{
+    if (!target)
+        return false;
+    Mutex::Locker locker(m_modules_mutex);
+    for (auto module : m_modules)
+    {
+        Error error;
+        if (module)
+        {
+            if (!module->LoadScriptingResourceInTarget(target, error, feedback_stream))
+            {
+                if (error.Fail() && error.AsCString())
+                {
+                    error.SetErrorStringWithFormat("unable to load scripting data for module %s - error reported was %s",
+                                                   module->GetFileSpec().GetFileNameStrippingExtension().GetCString(),
+                                                   error.AsCString());
+                    errors.push_back(error);
+                }
+                if (!continue_on_error)
+                    return false;
+            }
+        }
+    }
+    return errors.size() == 0;
+}

Modified: lldb/branches/lldb-platform-work/source/Core/Opcode.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/lldb-platform-work/source/Core/Opcode.cpp?rev=183468&r1=183467&r2=183468&view=diff
==============================================================================
--- lldb/branches/lldb-platform-work/source/Core/Opcode.cpp (original)
+++ lldb/branches/lldb-platform-work/source/Core/Opcode.cpp Thu Jun  6 19:06:43 2013
@@ -46,7 +46,7 @@ Opcode::Dump (Stream *s, uint32_t min_by
         break;
 
     case Opcode::eType64:
-        bytes_written = s->Printf ("0x%16.16llx", m_data.inst64); 
+        bytes_written = s->Printf ("0x%16.16" PRIx64, m_data.inst64);
         break;
 
     case Opcode::eTypeBytes:

Modified: lldb/branches/lldb-platform-work/source/Core/PluginManager.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/lldb-platform-work/source/Core/PluginManager.cpp?rev=183468&r1=183467&r2=183468&view=diff
==============================================================================
--- lldb/branches/lldb-platform-work/source/Core/PluginManager.cpp (original)
+++ lldb/branches/lldb-platform-work/source/Core/PluginManager.cpp Thu Jun  6 19:06:43 2013
@@ -7,6 +7,8 @@
 //
 //===----------------------------------------------------------------------===//
 
+#include "lldb/lldb-python.h"
+
 #include "lldb/Core/PluginManager.h"
 
 #include <limits.h>
@@ -14,10 +16,12 @@
 #include <string>
 #include <vector>
 
+#include "lldb/Core/Debugger.h"
 #include "lldb/Core/Error.h"
 #include "lldb/Host/FileSpec.h"
 #include "lldb/Host/Host.h"
 #include "lldb/Host/Mutex.h"
+#include "lldb/Interpreter/OptionValueProperties.h"
 
 #include "llvm/ADT/StringRef.h"
 
@@ -31,11 +35,15 @@ enum PluginAction
     ePluginGetInstanceAtIndex
 };
 
+
+typedef bool (*PluginInitCallback) (void);
+typedef void (*PluginTermCallback) (void);
+
 struct PluginInfo
 {
     void *plugin_handle;
-    void *plugin_init_callback;
-    void *plugin_term_callback;
+    PluginInitCallback plugin_init_callback;
+    PluginTermCallback plugin_term_callback;
 };
 
 typedef std::map<FileSpec, PluginInfo> PluginTerminateMap;
@@ -107,17 +115,17 @@ LoadPluginCallback
             if (plugin_info.plugin_handle)
             {
                 bool success = false;
-                plugin_info.plugin_init_callback = Host::DynamicLibraryGetSymbol (plugin_info.plugin_handle, "LLDBPluginInitialize", error);
+                plugin_info.plugin_init_callback = (PluginInitCallback)Host::DynamicLibraryGetSymbol (plugin_info.plugin_handle, "LLDBPluginInitialize", error);
                 if (plugin_info.plugin_init_callback)
                 {
                     // Call the plug-in "bool LLDBPluginInitialize(void)" function
-                    success = ((bool (*)(void))plugin_info.plugin_init_callback)();
+                    success = plugin_info.plugin_init_callback();
                 }
 
                 if (success)
                 {
                     // It is ok for the "LLDBPluginTerminate" symbol to be NULL
-                    plugin_info.plugin_term_callback = Host::DynamicLibraryGetSymbol (plugin_info.plugin_handle, "LLDBPluginTerminate", error);
+                    plugin_info.plugin_term_callback = (PluginTermCallback)Host::DynamicLibraryGetSymbol (plugin_info.plugin_handle, "LLDBPluginTerminate", error);
                 }
                 else 
                 {
@@ -205,7 +213,7 @@ PluginManager::Terminate ()
         if (pos->second.plugin_handle)
         {
             if (pos->second.plugin_term_callback)
-                ((void (*)(void))pos->second.plugin_term_callback)();
+                pos->second.plugin_term_callback();
             Host::DynamicLibraryClose (pos->second.plugin_handle);
         }
     }
@@ -225,7 +233,7 @@ struct ABIInstance
     {
     }
 
-    std::string name;
+    ConstString name;
     std::string description;
     ABICreateInstance create_callback;
 };
@@ -249,7 +257,7 @@ GetABIInstances ()
 bool
 PluginManager::RegisterPlugin
 (
-    const char *name,
+    const ConstString &name,
     const char *description,
     ABICreateInstance create_callback
 )
@@ -257,8 +265,8 @@ PluginManager::RegisterPlugin
     if (create_callback)
     {
         ABIInstance instance;
-        assert (name && name[0]);
-        instance.name.assign (name);
+        assert ((bool)name);
+        instance.name = name;
         if (description && description[0])
             instance.description = description;
         instance.create_callback = create_callback;
@@ -301,18 +309,17 @@ PluginManager::GetABICreateCallbackAtInd
 }
 
 ABICreateInstance
-PluginManager::GetABICreateCallbackForPluginName (const char *name)
+PluginManager::GetABICreateCallbackForPluginName (const ConstString &name)
 {
-    if (name && name[0])
+    if (name)
     {
         Mutex::Locker locker (GetABIInstancesMutex ());
-        llvm::StringRef name_sref(name);
         ABIInstances &instances = GetABIInstances ();
 
         ABIInstances::iterator pos, end = instances.end();
         for (pos = instances.begin(); pos != end; ++ pos)
         {
-            if (name_sref.equals (pos->name))
+            if (name == pos->name)
                 return pos->create_callback;
         }
     }
@@ -332,7 +339,7 @@ struct DisassemblerInstance
     {
     }
 
-    std::string name;
+    ConstString name;
     std::string description;
     DisassemblerCreateInstance create_callback;
 };
@@ -356,7 +363,7 @@ GetDisassemblerInstances ()
 bool
 PluginManager::RegisterPlugin
 (
-    const char *name,
+    const ConstString &name,
     const char *description,
     DisassemblerCreateInstance create_callback
 )
@@ -364,7 +371,7 @@ PluginManager::RegisterPlugin
     if (create_callback)
     {
         DisassemblerInstance instance;
-        assert (name && name[0]);
+        assert ((bool)name);
         instance.name = name;
         if (description && description[0])
             instance.description = description;
@@ -408,18 +415,17 @@ PluginManager::GetDisassemblerCreateCall
 }
 
 DisassemblerCreateInstance
-PluginManager::GetDisassemblerCreateCallbackForPluginName (const char *name)
+PluginManager::GetDisassemblerCreateCallbackForPluginName (const ConstString &name)
 {
-    if (name && name[0])
+    if (name)
     {
-        llvm::StringRef name_sref(name);
         Mutex::Locker locker (GetDisassemblerMutex ());
         DisassemblerInstances &instances = GetDisassemblerInstances ();
         
         DisassemblerInstances::iterator pos, end = instances.end();
         for (pos = instances.begin(); pos != end; ++ pos)
         {
-            if (name_sref.equals (pos->name))
+            if (name == pos->name)
                 return pos->create_callback;
         }
     }
@@ -436,13 +442,15 @@ struct DynamicLoaderInstance
     DynamicLoaderInstance() :
         name(),
         description(),
-        create_callback(NULL)
+        create_callback(NULL),
+        debugger_init_callback (NULL)
     {
     }
 
-    std::string name;
+    ConstString name;
     std::string description;
     DynamicLoaderCreateInstance create_callback;
+    DebuggerInitializeCallback debugger_init_callback;
 };
 
 typedef std::vector<DynamicLoaderInstance> DynamicLoaderInstances;
@@ -466,19 +474,21 @@ GetDynamicLoaderInstances ()
 bool
 PluginManager::RegisterPlugin
 (
-    const char *name,
+    const ConstString &name,
     const char *description,
-    DynamicLoaderCreateInstance create_callback
+    DynamicLoaderCreateInstance create_callback,
+    DebuggerInitializeCallback debugger_init_callback
 )
 {
     if (create_callback)
     {
         DynamicLoaderInstance instance;
-        assert (name && name[0]);
+        assert ((bool)name);
         instance.name = name;
         if (description && description[0])
             instance.description = description;
         instance.create_callback = create_callback;
+        instance.debugger_init_callback = debugger_init_callback;
         Mutex::Locker locker (GetDynamicLoaderMutex ());
         GetDynamicLoaderInstances ().push_back (instance);
     }
@@ -517,18 +527,17 @@ PluginManager::GetDynamicLoaderCreateCal
 }
 
 DynamicLoaderCreateInstance
-PluginManager::GetDynamicLoaderCreateCallbackForPluginName (const char *name)
+PluginManager::GetDynamicLoaderCreateCallbackForPluginName (const ConstString &name)
 {
-    if (name && name[0])
+    if (name)
     {
-        llvm::StringRef name_sref(name);
         Mutex::Locker locker (GetDynamicLoaderMutex ());
         DynamicLoaderInstances &instances = GetDynamicLoaderInstances ();
         
         DynamicLoaderInstances::iterator pos, end = instances.end();
         for (pos = instances.begin(); pos != end; ++ pos)
         {
-            if (name_sref.equals (pos->name))
+            if (name == pos->name)
                 return pos->create_callback;
         }
     }
@@ -547,7 +556,7 @@ struct EmulateInstructionInstance
     {
     }
     
-    std::string name;
+    ConstString name;
     std::string description;
     EmulateInstructionCreateInstance create_callback;
 };
@@ -572,7 +581,7 @@ GetEmulateInstructionInstances ()
 bool
 PluginManager::RegisterPlugin
 (
-    const char *name,
+    const ConstString &name,
     const char *description,
     EmulateInstructionCreateInstance create_callback
 )
@@ -580,7 +589,7 @@ PluginManager::RegisterPlugin
     if (create_callback)
     {
         EmulateInstructionInstance instance;
-        assert (name && name[0]);
+        assert ((bool)name);
         instance.name = name;
         if (description && description[0])
             instance.description = description;
@@ -623,18 +632,17 @@ PluginManager::GetEmulateInstructionCrea
 }
 
 EmulateInstructionCreateInstance
-PluginManager::GetEmulateInstructionCreateCallbackForPluginName (const char *name)
+PluginManager::GetEmulateInstructionCreateCallbackForPluginName (const ConstString &name)
 {
-    if (name && name[0])
+    if (name)
     {
-        llvm::StringRef name_sref(name);
         Mutex::Locker locker (GetEmulateInstructionMutex ());
         EmulateInstructionInstances &instances = GetEmulateInstructionInstances ();
         
         EmulateInstructionInstances::iterator pos, end = instances.end();
         for (pos = instances.begin(); pos != end; ++ pos)
         {
-            if (name_sref.equals (pos->name))
+            if (name == pos->name)
                 return pos->create_callback;
         }
     }
@@ -652,7 +660,7 @@ struct OperatingSystemInstance
     {
     }
     
-    std::string name;
+    ConstString name;
     std::string description;
     OperatingSystemCreateInstance create_callback;
 };
@@ -674,17 +682,14 @@ GetOperatingSystemInstances ()
 }
 
 bool
-PluginManager::RegisterPlugin
-(
- const char *name,
- const char *description,
- OperatingSystemCreateInstance create_callback
- )
+PluginManager::RegisterPlugin (const ConstString &name,
+                               const char *description,
+                               OperatingSystemCreateInstance create_callback)
 {
     if (create_callback)
     {
         OperatingSystemInstance instance;
-        assert (name && name[0]);
+        assert ((bool)name);
         instance.name = name;
         if (description && description[0])
             instance.description = description;
@@ -727,18 +732,17 @@ PluginManager::GetOperatingSystemCreateC
 }
 
 OperatingSystemCreateInstance
-PluginManager::GetOperatingSystemCreateCallbackForPluginName (const char *name)
+PluginManager::GetOperatingSystemCreateCallbackForPluginName (const ConstString &name)
 {
-    if (name && name[0])
+    if (name)
     {
-        llvm::StringRef name_sref(name);
         Mutex::Locker locker (GetOperatingSystemMutex ());
         OperatingSystemInstances &instances = GetOperatingSystemInstances ();
         
         OperatingSystemInstances::iterator pos, end = instances.end();
         for (pos = instances.begin(); pos != end; ++ pos)
         {
-            if (name_sref.equals (pos->name))
+            if (name == pos->name)
                 return pos->create_callback;
         }
     }
@@ -758,7 +762,7 @@ struct LanguageRuntimeInstance
     {
     }
 
-    std::string name;
+    ConstString name;
     std::string description;
     LanguageRuntimeCreateInstance create_callback;
 };
@@ -782,7 +786,7 @@ GetLanguageRuntimeInstances ()
 bool
 PluginManager::RegisterPlugin
 (
-    const char *name,
+    const ConstString &name,
     const char *description,
     LanguageRuntimeCreateInstance create_callback
 )
@@ -790,7 +794,7 @@ PluginManager::RegisterPlugin
     if (create_callback)
     {
         LanguageRuntimeInstance instance;
-        assert (name && name[0]);
+        assert ((bool)name);
         instance.name = name;
         if (description && description[0])
             instance.description = description;
@@ -833,18 +837,17 @@ PluginManager::GetLanguageRuntimeCreateC
 }
 
 LanguageRuntimeCreateInstance
-PluginManager::GetLanguageRuntimeCreateCallbackForPluginName (const char *name)
+PluginManager::GetLanguageRuntimeCreateCallbackForPluginName (const ConstString &name)
 {
-    if (name && name[0])
+    if (name)
     {
-        llvm::StringRef name_sref(name);
         Mutex::Locker locker (GetLanguageRuntimeMutex ());
         LanguageRuntimeInstances &instances = GetLanguageRuntimeInstances ();
         
         LanguageRuntimeInstances::iterator pos, end = instances.end();
         for (pos = instances.begin(); pos != end; ++ pos)
         {
-            if (name_sref.equals (pos->name))
+            if (name == pos->name)
                 return pos->create_callback;
         }
     }
@@ -858,15 +861,17 @@ struct ObjectFileInstance
     ObjectFileInstance() :
         name(),
         description(),
-        create_callback(NULL)
+        create_callback(NULL),
+        create_memory_callback (NULL),
+        get_module_specifications (NULL)
     {
     }
 
-    std::string name;
+    ConstString name;
     std::string description;
     ObjectFileCreateInstance create_callback;
     ObjectFileCreateMemoryInstance create_memory_callback;
-
+    ObjectFileGetModuleSpecifications get_module_specifications;
 };
 
 typedef std::vector<ObjectFileInstance> ObjectFileInstances;
@@ -887,23 +892,22 @@ GetObjectFileInstances ()
 
 
 bool
-PluginManager::RegisterPlugin
-(
-    const char *name,
-    const char *description,
-    ObjectFileCreateInstance create_callback,
-    ObjectFileCreateMemoryInstance create_memory_callback
-)
+PluginManager::RegisterPlugin (const ConstString &name,
+                               const char *description,
+                               ObjectFileCreateInstance create_callback,
+                               ObjectFileCreateMemoryInstance create_memory_callback,
+                               ObjectFileGetModuleSpecifications get_module_specifications)
 {
     if (create_callback)
     {
         ObjectFileInstance instance;
-        assert (name && name[0]);
+        assert ((bool)name);
         instance.name = name;
         if (description && description[0])
             instance.description = description;
         instance.create_callback = create_callback;
         instance.create_memory_callback = create_memory_callback;
+        instance.get_module_specifications = get_module_specifications;
         Mutex::Locker locker (GetObjectFileMutex ());
         GetObjectFileInstances ().push_back (instance);
     }
@@ -952,19 +956,28 @@ PluginManager::GetObjectFileCreateMemory
     return NULL;
 }
 
+ObjectFileGetModuleSpecifications
+PluginManager::GetObjectFileGetModuleSpecificationsCallbackAtIndex (uint32_t idx)
+{
+    Mutex::Locker locker (GetObjectFileMutex ());
+    ObjectFileInstances &instances = GetObjectFileInstances ();
+    if (idx < instances.size())
+        return instances[idx].get_module_specifications;
+    return NULL;
+}
+
 ObjectFileCreateInstance
-PluginManager::GetObjectFileCreateCallbackForPluginName (const char *name)
+PluginManager::GetObjectFileCreateCallbackForPluginName (const ConstString &name)
 {
-    if (name && name[0])
+    if (name)
     {
-        llvm::StringRef name_sref(name);
         Mutex::Locker locker (GetObjectFileMutex ());
         ObjectFileInstances &instances = GetObjectFileInstances ();
         
         ObjectFileInstances::iterator pos, end = instances.end();
         for (pos = instances.begin(); pos != end; ++ pos)
         {
-            if (name_sref.equals (pos->name))
+            if (name == pos->name)
                 return pos->create_callback;
         }
     }
@@ -973,18 +986,17 @@ PluginManager::GetObjectFileCreateCallba
 
 
 ObjectFileCreateMemoryInstance
-PluginManager::GetObjectFileCreateMemoryCallbackForPluginName (const char *name)
+PluginManager::GetObjectFileCreateMemoryCallbackForPluginName (const ConstString &name)
 {
-    if (name && name[0])
+    if (name)
     {
-        llvm::StringRef name_sref(name);
         Mutex::Locker locker (GetObjectFileMutex ());
         ObjectFileInstances &instances = GetObjectFileInstances ();
         
         ObjectFileInstances::iterator pos, end = instances.end();
         for (pos = instances.begin(); pos != end; ++ pos)
         {
-            if (name_sref.equals (pos->name))
+            if (name == pos->name)
                 return pos->create_memory_callback;
         }
     }
@@ -1000,13 +1012,16 @@ struct ObjectContainerInstance
     ObjectContainerInstance() :
         name(),
         description(),
-        create_callback(NULL)
+        create_callback (NULL),
+        get_module_specifications (NULL)
     {
     }
 
-    std::string name;
+    ConstString name;
     std::string description;
     ObjectContainerCreateInstance create_callback;
+    ObjectFileGetModuleSpecifications get_module_specifications;
+
 };
 
 typedef std::vector<ObjectContainerInstance> ObjectContainerInstances;
@@ -1026,21 +1041,20 @@ GetObjectContainerInstances ()
 }
 
 bool
-PluginManager::RegisterPlugin
-(
-    const char *name,
-    const char *description,
-    ObjectContainerCreateInstance create_callback
-)
+PluginManager::RegisterPlugin (const ConstString &name,
+                               const char *description,
+                               ObjectContainerCreateInstance create_callback,
+                               ObjectFileGetModuleSpecifications get_module_specifications)
 {
     if (create_callback)
     {
         ObjectContainerInstance instance;
-        assert (name && name[0]);
+        assert ((bool)name);
         instance.name = name;
         if (description && description[0])
             instance.description = description;
         instance.create_callback = create_callback;
+        instance.get_module_specifications = get_module_specifications;
         Mutex::Locker locker (GetObjectContainerMutex ());
         GetObjectContainerInstances ().push_back (instance);
     }
@@ -1079,24 +1093,33 @@ PluginManager::GetObjectContainerCreateC
 }
 
 ObjectContainerCreateInstance
-PluginManager::GetObjectContainerCreateCallbackForPluginName (const char *name)
+PluginManager::GetObjectContainerCreateCallbackForPluginName (const ConstString &name)
 {
-    if (name && name[0])
+    if (name)
     {
-        llvm::StringRef name_sref(name);
         Mutex::Locker locker (GetObjectContainerMutex ());
         ObjectContainerInstances &instances = GetObjectContainerInstances ();
         
         ObjectContainerInstances::iterator pos, end = instances.end();
         for (pos = instances.begin(); pos != end; ++ pos)
         {
-            if (name_sref.equals (pos->name))
+            if (name == pos->name)
                 return pos->create_callback;
         }
     }
     return NULL;
 }
 
+ObjectFileGetModuleSpecifications
+PluginManager::GetObjectContainerGetModuleSpecificationsCallbackAtIndex (uint32_t idx)
+{
+    Mutex::Locker locker (GetObjectContainerMutex ());
+    ObjectContainerInstances &instances = GetObjectContainerInstances ();
+    if (idx < instances.size())
+        return instances[idx].get_module_specifications;
+    return NULL;
+}
+
 #pragma mark LogChannel
 
 struct LogInstance
@@ -1108,7 +1131,7 @@ struct LogInstance
     {
     }
 
-    std::string name;
+    ConstString name;
     std::string description;
     LogChannelCreateInstance create_callback;
 };
@@ -1134,7 +1157,7 @@ GetLogInstances ()
 bool
 PluginManager::RegisterPlugin
 (
-    const char *name,
+    const ConstString &name,
     const char *description,
     LogChannelCreateInstance create_callback
 )
@@ -1142,7 +1165,7 @@ PluginManager::RegisterPlugin
     if (create_callback)
     {
         LogInstance instance;
-        assert (name && name[0]);
+        assert ((bool)name);
         instance.name = name;
         if (description && description[0])
             instance.description = description;
@@ -1180,7 +1203,7 @@ PluginManager::GetLogChannelCreateNameAt
     Mutex::Locker locker (GetLogMutex ());
     LogInstances &instances = GetLogInstances ();
     if (idx < instances.size())
-        return instances[idx].name.c_str();
+        return instances[idx].name.GetCString();
     return NULL;
 }
 
@@ -1196,18 +1219,17 @@ PluginManager::GetLogChannelCreateCallba
 }
 
 LogChannelCreateInstance
-PluginManager::GetLogChannelCreateCallbackForPluginName (const char *name)
+PluginManager::GetLogChannelCreateCallbackForPluginName (const ConstString &name)
 {
-    if (name && name[0])
+    if (name)
     {
-        llvm::StringRef name_sref(name);
         Mutex::Locker locker (GetLogMutex ());
         LogInstances &instances = GetLogInstances ();
         
         LogInstances::iterator pos, end = instances.end();
         for (pos = instances.begin(); pos != end; ++ pos)
         {
-            if (name_sref.equals (pos->name))
+            if (name == pos->name)
                 return pos->create_callback;
         }
     }
@@ -1221,13 +1243,15 @@ struct PlatformInstance
     PlatformInstance() :
         name(),
         description(),
-        create_callback(NULL)
+        create_callback(NULL),
+        debugger_init_callback (NULL)
     {
     }
     
-    std::string name;
+    ConstString name;
     std::string description;
     PlatformCreateInstance create_callback;
+    DebuggerInitializeCallback debugger_init_callback;
 };
 
 typedef std::vector<PlatformInstance> PlatformInstances;
@@ -1248,33 +1272,36 @@ GetPlatformInstances ()
 
 
 bool
-PluginManager::RegisterPlugin (const char *name,
+PluginManager::RegisterPlugin (const ConstString &name,
                                const char *description,
-                               PlatformCreateInstance create_callback)
+                               PlatformCreateInstance create_callback,
+                               DebuggerInitializeCallback debugger_init_callback)
 {
     if (create_callback)
     {
         Mutex::Locker locker (GetPlatformInstancesMutex ());
         
         PlatformInstance instance;
-        assert (name && name[0]);
+        assert ((bool)name);
         instance.name = name;
         if (description && description[0])
             instance.description = description;
         instance.create_callback = create_callback;
+        instance.debugger_init_callback = debugger_init_callback;
         GetPlatformInstances ().push_back (instance);
         return true;
     }
     return false;
 }
 
+
 const char *
 PluginManager::GetPlatformPluginNameAtIndex (uint32_t idx)
 {
     Mutex::Locker locker (GetPlatformInstancesMutex ());
     PlatformInstances &instances = GetPlatformInstances ();
     if (idx < instances.size())
-        return instances[idx].name.c_str();
+        return instances[idx].name.GetCString();
     return NULL;
 }
 
@@ -1320,28 +1347,27 @@ PluginManager::GetPlatformCreateCallback
 }
 
 PlatformCreateInstance
-PluginManager::GetPlatformCreateCallbackForPluginName (const char *name)
+PluginManager::GetPlatformCreateCallbackForPluginName (const ConstString &name)
 {
-    if (name && name[0])
+    if (name)
     {
         Mutex::Locker locker (GetPlatformInstancesMutex ());
         PlatformInstances &instances = GetPlatformInstances ();
-        llvm::StringRef name_sref(name);
 
         PlatformInstances::iterator pos, end = instances.end();
         for (pos = instances.begin(); pos != end; ++ pos)
         {
-            if (name_sref.equals (pos->name))
+            if (name == pos->name)
                 return pos->create_callback;
         }
     }
     return NULL;
 }
 
-uint32_t
+size_t
 PluginManager::AutoCompletePlatformName (const char *name, StringList &matches)
 {
-    if (name && name[0])
+    if (name)
     {
         Mutex::Locker locker (GetPlatformInstancesMutex ());
         PlatformInstances &instances = GetPlatformInstances ();
@@ -1350,14 +1376,13 @@ PluginManager::AutoCompletePlatformName
         PlatformInstances::iterator pos, end = instances.end();
         for (pos = instances.begin(); pos != end; ++ pos)
         {
-            llvm::StringRef plugin_name (pos->name);
+            llvm::StringRef plugin_name (pos->name.GetCString());
             if (plugin_name.startswith(name_sref))
                 matches.AppendString (plugin_name.data());
         }
     }
     return matches.GetSize();
 }
-
 #pragma mark Process
 
 struct ProcessInstance
@@ -1369,7 +1394,7 @@ struct ProcessInstance
     {
     }
     
-    std::string name;
+    ConstString name;
     std::string description;
     ProcessCreateInstance create_callback;
 };
@@ -1394,7 +1419,7 @@ GetProcessInstances ()
 bool
 PluginManager::RegisterPlugin
 (
- const char *name,
+ const ConstString &name,
  const char *description,
  ProcessCreateInstance create_callback
  )
@@ -1402,7 +1427,7 @@ PluginManager::RegisterPlugin
     if (create_callback)
     {
         ProcessInstance instance;
-        assert (name && name[0]);
+        assert ((bool)name);
         instance.name = name;
         if (description && description[0])
             instance.description = description;
@@ -1419,7 +1444,7 @@ PluginManager::GetProcessPluginNameAtInd
     Mutex::Locker locker (GetProcessMutex ());
     ProcessInstances &instances = GetProcessInstances ();
     if (idx < instances.size())
-        return instances[idx].name.c_str();
+        return instances[idx].name.GetCString();
     return NULL;
 }
 
@@ -1466,18 +1491,17 @@ PluginManager::GetProcessCreateCallbackA
 
 
 ProcessCreateInstance
-PluginManager::GetProcessCreateCallbackForPluginName (const char *name)
+PluginManager::GetProcessCreateCallbackForPluginName (const ConstString &name)
 {
-    if (name && name[0])
+    if (name)
     {
-        llvm::StringRef name_sref(name);
         Mutex::Locker locker (GetProcessMutex ());
         ProcessInstances &instances = GetProcessInstances ();
         
         ProcessInstances::iterator pos, end = instances.end();
         for (pos = instances.begin(); pos != end; ++ pos)
         {
-            if (name_sref.equals (pos->name))
+            if (name == pos->name)
                 return pos->create_callback;
         }
     }
@@ -1495,7 +1519,7 @@ struct SymbolFileInstance
     {
     }
 
-    std::string name;
+    ConstString name;
     std::string description;
     SymbolFileCreateInstance create_callback;
 };
@@ -1520,7 +1544,7 @@ GetSymbolFileInstances ()
 bool
 PluginManager::RegisterPlugin
 (
-    const char *name,
+    const ConstString &name,
     const char *description,
     SymbolFileCreateInstance create_callback
 )
@@ -1528,7 +1552,7 @@ PluginManager::RegisterPlugin
     if (create_callback)
     {
         SymbolFileInstance instance;
-        assert (name && name[0]);
+        assert ((bool)name);
         instance.name = name;
         if (description && description[0])
             instance.description = description;
@@ -1571,18 +1595,17 @@ PluginManager::GetSymbolFileCreateCallba
 }
 
 SymbolFileCreateInstance
-PluginManager::GetSymbolFileCreateCallbackForPluginName (const char *name)
+PluginManager::GetSymbolFileCreateCallbackForPluginName (const ConstString &name)
 {
-    if (name && name[0])
+    if (name)
     {
-        llvm::StringRef name_sref(name);
         Mutex::Locker locker (GetSymbolFileMutex ());
         SymbolFileInstances &instances = GetSymbolFileInstances ();
         
         SymbolFileInstances::iterator pos, end = instances.end();
         for (pos = instances.begin(); pos != end; ++ pos)
         {
-            if (name_sref.equals (pos->name))
+            if (name == pos->name)
                 return pos->create_callback;
         }
     }
@@ -1602,7 +1625,7 @@ struct SymbolVendorInstance
     {
     }
 
-    std::string name;
+    ConstString name;
     std::string description;
     SymbolVendorCreateInstance create_callback;
 };
@@ -1626,7 +1649,7 @@ GetSymbolVendorInstances ()
 bool
 PluginManager::RegisterPlugin
 (
-    const char *name,
+    const ConstString &name,
     const char *description,
     SymbolVendorCreateInstance create_callback
 )
@@ -1634,7 +1657,7 @@ PluginManager::RegisterPlugin
     if (create_callback)
     {
         SymbolVendorInstance instance;
-        assert (name && name[0]);
+        assert ((bool)name);
         instance.name = name;
         if (description && description[0])
             instance.description = description;
@@ -1678,18 +1701,17 @@ PluginManager::GetSymbolVendorCreateCall
 
 
 SymbolVendorCreateInstance
-PluginManager::GetSymbolVendorCreateCallbackForPluginName (const char *name)
+PluginManager::GetSymbolVendorCreateCallbackForPluginName (const ConstString &name)
 {
-    if (name && name[0])
+    if (name)
     {
-        llvm::StringRef name_sref(name);
         Mutex::Locker locker (GetSymbolVendorMutex ());
         SymbolVendorInstances &instances = GetSymbolVendorInstances ();
         
         SymbolVendorInstances::iterator pos, end = instances.end();
         for (pos = instances.begin(); pos != end; ++ pos)
         {
-            if (name_sref.equals (pos->name))
+            if (name == pos->name)
                 return pos->create_callback;
         }
     }
@@ -1708,7 +1730,7 @@ struct UnwindAssemblyInstance
     {
     }
 
-    std::string name;
+    ConstString name;
     std::string description;
     UnwindAssemblyCreateInstance create_callback;
 };
@@ -1732,7 +1754,7 @@ GetUnwindAssemblyInstances ()
 bool
 PluginManager::RegisterPlugin
 (
-    const char *name,
+    const ConstString &name,
     const char *description,
     UnwindAssemblyCreateInstance create_callback
 )
@@ -1740,7 +1762,7 @@ PluginManager::RegisterPlugin
     if (create_callback)
     {
         UnwindAssemblyInstance instance;
-        assert (name && name[0]);
+        assert ((bool)name);
         instance.name = name;
         if (description && description[0])
             instance.description = description;
@@ -1784,21 +1806,207 @@ PluginManager::GetUnwindAssemblyCreateCa
 
 
 UnwindAssemblyCreateInstance
-PluginManager::GetUnwindAssemblyCreateCallbackForPluginName (const char *name)
+PluginManager::GetUnwindAssemblyCreateCallbackForPluginName (const ConstString &name)
 {
-    if (name && name[0])
+    if (name)
     {
-        llvm::StringRef name_sref(name);
         Mutex::Locker locker (GetUnwindAssemblyMutex ());
         UnwindAssemblyInstances &instances = GetUnwindAssemblyInstances ();
         
         UnwindAssemblyInstances::iterator pos, end = instances.end();
         for (pos = instances.begin(); pos != end; ++ pos)
         {
-            if (name_sref.equals (pos->name))
+            if (name == pos->name)
                 return pos->create_callback;
         }
     }
     return NULL;
 }
 
+void
+PluginManager::DebuggerInitialize (Debugger &debugger)
+{
+    // Initialize the DynamicLoader plugins
+    {
+        Mutex::Locker locker (GetDynamicLoaderMutex ());
+        DynamicLoaderInstances &instances = GetDynamicLoaderInstances ();
+    
+        DynamicLoaderInstances::iterator pos, end = instances.end();
+        for (pos = instances.begin(); pos != end; ++ pos)
+        {
+            if (pos->debugger_init_callback)
+                pos->debugger_init_callback (debugger);
+        }
+    }
+
+    // Initialize the Platform plugins
+    {
+        Mutex::Locker locker (GetPlatformInstancesMutex ());
+        PlatformInstances &instances = GetPlatformInstances ();
+    
+        PlatformInstances::iterator pos, end = instances.end();
+        for (pos = instances.begin(); pos != end; ++ pos)
+        {
+            if (pos->debugger_init_callback)
+                pos->debugger_init_callback (debugger);
+        }
+    }
+}
+
+// This will put a plugin's settings under e.g. "plugin.dynamic-loader.darwin-kernel.SETTINGNAME".
+// The new preferred ordering is to put plugins under "dynamic-loader.plugin.darwin-kernel.SETTINGNAME"
+// and if there were a generic dynamic-loader setting, it would be "dynamic-loader.SETTINGNAME".
+static lldb::OptionValuePropertiesSP
+GetDebuggerPropertyForPluginsOldStyle (Debugger &debugger,
+                                       const ConstString &plugin_type_name,
+                                       const ConstString &plugin_type_desc,
+                                       bool can_create)
+{
+    lldb::OptionValuePropertiesSP parent_properties_sp (debugger.GetValueProperties());
+    if (parent_properties_sp)
+    {
+        static ConstString g_property_name("plugin");
+        
+        OptionValuePropertiesSP plugin_properties_sp = parent_properties_sp->GetSubProperty (NULL, g_property_name);
+        if (!plugin_properties_sp && can_create)
+        {
+            plugin_properties_sp.reset (new OptionValueProperties (g_property_name));
+            parent_properties_sp->AppendProperty (g_property_name,
+                                                  ConstString("Settings specify to plugins."),
+                                                  true,
+                                                  plugin_properties_sp);
+        }
+        
+        if (plugin_properties_sp)
+        {
+            lldb::OptionValuePropertiesSP plugin_type_properties_sp = plugin_properties_sp->GetSubProperty (NULL, plugin_type_name);
+            if (!plugin_type_properties_sp && can_create)
+            {
+                plugin_type_properties_sp.reset (new OptionValueProperties (plugin_type_name));
+                plugin_properties_sp->AppendProperty (plugin_type_name,
+                                                      plugin_type_desc,
+                                                      true,
+                                                      plugin_type_properties_sp);
+            }
+            return plugin_type_properties_sp;
+        }
+    }
+    return lldb::OptionValuePropertiesSP();
+}
+
+// This is the preferred new way to register plugin specific settings.  e.g.
+// "platform.plugin.darwin-kernel.SETTINGNAME"
+// and Platform generic settings would be under "platform.SETTINGNAME".
+static lldb::OptionValuePropertiesSP
+GetDebuggerPropertyForPlugins (Debugger &debugger, 
+                               const ConstString &plugin_type_name,
+                               const ConstString &plugin_type_desc,
+                               bool can_create)
+{
+    static ConstString g_property_name("plugin");
+    lldb::OptionValuePropertiesSP parent_properties_sp (debugger.GetValueProperties());
+    if (parent_properties_sp)
+    {
+        OptionValuePropertiesSP plugin_properties_sp = parent_properties_sp->GetSubProperty (NULL, plugin_type_name);
+        if (!plugin_properties_sp && can_create)
+        {
+            plugin_properties_sp.reset (new OptionValueProperties (plugin_type_name));
+            parent_properties_sp->AppendProperty (plugin_type_name,
+                                                  plugin_type_desc,
+                                                  true,
+                                                  plugin_properties_sp);
+        }
+        
+        if (plugin_properties_sp)
+        {
+            lldb::OptionValuePropertiesSP plugin_type_properties_sp = plugin_properties_sp->GetSubProperty (NULL, g_property_name);
+            if (!plugin_type_properties_sp && can_create)
+            {
+                plugin_type_properties_sp.reset (new OptionValueProperties (g_property_name));
+                plugin_properties_sp->AppendProperty (g_property_name,
+                                                      ConstString("Settings specific to plugins"),
+                                                      true,
+                                                      plugin_type_properties_sp);
+            }
+            return plugin_type_properties_sp;
+        }
+    }
+    return lldb::OptionValuePropertiesSP();
+}
+
+
+lldb::OptionValuePropertiesSP
+PluginManager::GetSettingForDynamicLoaderPlugin (Debugger &debugger, const ConstString &setting_name)
+{
+    lldb::OptionValuePropertiesSP properties_sp;
+    lldb::OptionValuePropertiesSP plugin_type_properties_sp (GetDebuggerPropertyForPluginsOldStyle (debugger,
+                                                                                            ConstString("dynamic-loader"),
+                                                                                            ConstString(), // not creating to so we don't need the description
+                                                                                            false));
+    if (plugin_type_properties_sp)
+        properties_sp = plugin_type_properties_sp->GetSubProperty (NULL, setting_name);
+    return properties_sp;
+}
+
+bool
+PluginManager::CreateSettingForDynamicLoaderPlugin (Debugger &debugger,
+                                                    const lldb::OptionValuePropertiesSP &properties_sp,
+                                                    const ConstString &description,
+                                                    bool is_global_property)
+{
+    if (properties_sp)
+    {
+        lldb::OptionValuePropertiesSP plugin_type_properties_sp (GetDebuggerPropertyForPluginsOldStyle (debugger,
+                                                                                                ConstString("dynamic-loader"),
+                                                                                                ConstString("Settings for dynamic loader plug-ins"),
+                                                                                                true));
+        if (plugin_type_properties_sp)
+        {
+            plugin_type_properties_sp->AppendProperty (properties_sp->GetName(),
+                                                       description,
+                                                       is_global_property,
+                                                       properties_sp);
+            return true;
+        }
+    }
+    return false;
+}
+
+
+lldb::OptionValuePropertiesSP
+PluginManager::GetSettingForPlatformPlugin (Debugger &debugger, const ConstString &setting_name)
+{
+    lldb::OptionValuePropertiesSP properties_sp;
+    lldb::OptionValuePropertiesSP plugin_type_properties_sp (GetDebuggerPropertyForPlugins (debugger,
+                                                                                            ConstString("platform"),
+                                                                                            ConstString(), // not creating to so we don't need the description
+                                                                                            false));
+    if (plugin_type_properties_sp)
+        properties_sp = plugin_type_properties_sp->GetSubProperty (NULL, setting_name);
+    return properties_sp;
+}
+
+bool
+PluginManager::CreateSettingForPlatformPlugin (Debugger &debugger,
+                                                    const lldb::OptionValuePropertiesSP &properties_sp,
+                                                    const ConstString &description,
+                                                    bool is_global_property)
+{
+    if (properties_sp)
+    {
+        lldb::OptionValuePropertiesSP plugin_type_properties_sp (GetDebuggerPropertyForPlugins (debugger,
+                                                                                                ConstString("platform"),
+                                                                                                ConstString("Settings for platform plug-ins"),
+                                                                                                true));
+        if (plugin_type_properties_sp)
+        {
+            plugin_type_properties_sp->AppendProperty (properties_sp->GetName(),
+                                                       description,
+                                                       is_global_property,
+                                                       properties_sp);
+            return true;
+        }
+    }
+    return false;
+}
+

Modified: lldb/branches/lldb-platform-work/source/Core/RegisterValue.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/lldb-platform-work/source/Core/RegisterValue.cpp?rev=183468&r1=183467&r2=183468&view=diff
==============================================================================
--- lldb/branches/lldb-platform-work/source/Core/RegisterValue.cpp (original)
+++ lldb/branches/lldb-platform-work/source/Core/RegisterValue.cpp Thu Jun  6 19:06:43 2013
@@ -237,7 +237,17 @@ RegisterValue::GetScalarValue (Scalar &s
     switch (m_type)
     {
         case eTypeInvalid:      break;
-        case eTypeBytes:        break;
+        case eTypeBytes:
+        {
+            switch (m_data.buffer.length)
+            {
+            default:    break;
+            case 1:     scalar = m_data.uint8; return true;
+            case 2:     scalar = m_data.uint16; return true;
+            case 4:     scalar = m_data.uint32; return true;
+            case 8:     scalar = m_data.uint64; return true;
+            }
+        }
         case eTypeUInt8:        scalar = m_data.uint8; return true;
         case eTypeUInt16:       scalar = m_data.uint16; return true;
         case eTypeUInt32:       scalar = m_data.uint32; return true;
@@ -287,9 +297,9 @@ RegisterValue::SetType (const RegisterIn
         case eEncodingIEEE754:
             if (byte_size == sizeof(float))
                 m_type = eTypeFloat;
-            if (byte_size == sizeof(double))
+            else if (byte_size == sizeof(double))
                 m_type = eTypeDouble;
-            if (byte_size == sizeof(long double))
+            else if (byte_size == sizeof(long double))
                 m_type = eTypeLongDouble;
             break;
 
@@ -301,7 +311,7 @@ RegisterValue::SetType (const RegisterIn
 }
 
 Error
-RegisterValue::SetValueFromData (const RegisterInfo *reg_info, DataExtractor &src, uint32_t src_offset, bool partial_data_ok)
+RegisterValue::SetValueFromData (const RegisterInfo *reg_info, DataExtractor &src, lldb::offset_t src_offset, bool partial_data_ok)
 {
     Error error;
     
@@ -450,7 +460,6 @@ RegisterValue::SetValueFromCString (cons
     const uint32_t byte_size = reg_info->byte_size;
     switch (reg_info->encoding)
     {
-        default:
         case eEncodingInvalid:
             error.SetErrorString ("Invalid encoding.");
             break;
@@ -462,7 +471,7 @@ RegisterValue::SetValueFromCString (cons
                 if (!success)
                     error.SetErrorStringWithFormat ("'%s' is not a valid unsigned integer string value", value_str);
                 else if (!Args::UInt64ValueIsValidForByteSize (uval64, byte_size))
-                    error.SetErrorStringWithFormat ("value 0x%llx is too large to fit in a %u byte unsigned integer value", uval64, byte_size);
+                    error.SetErrorStringWithFormat ("value 0x%" PRIx64 " is too large to fit in a %u byte unsigned integer value", uval64, byte_size);
                 else
                 {
                     if (!SetUInt (uval64, reg_info->byte_size))
@@ -483,7 +492,7 @@ RegisterValue::SetValueFromCString (cons
                 if (!success)
                     error.SetErrorStringWithFormat ("'%s' is not a valid signed integer string value", value_str);
                 else if (!Args::SInt64ValueIsValidForByteSize (sval64, byte_size))
-                    error.SetErrorStringWithFormat ("value 0x%llx is too large to fit in a %u byte signed integer value", sval64, byte_size);
+                    error.SetErrorStringWithFormat ("value 0x%" PRIx64 " is too large to fit in a %u byte signed integer value", sval64, byte_size);
                 else
                 {
                     if (!SetUInt (sval64, reg_info->byte_size))
@@ -637,7 +646,6 @@ RegisterValue::CopyValue (const Register
     m_type = rhs.m_type;
     switch (m_type)
     {
-        default:
         case eTypeInvalid: 
             return false;
         case eTypeUInt8:        m_data.uint8 = rhs.m_data.uint8; break;
@@ -671,6 +679,16 @@ RegisterValue::GetAsUInt16 (uint16_t fai
         default:            break;
         case eTypeUInt8:    return m_data.uint8;
         case eTypeUInt16:   return m_data.uint16;
+        case eTypeBytes:
+        {
+            switch (m_data.buffer.length)
+            {
+            default:    break;
+            case 1:     return m_data.uint8;
+            case 2:     return m_data.uint16;
+            }
+        }
+        break;
     }
     if (success_ptr)
         *success_ptr = false;
@@ -700,6 +718,17 @@ RegisterValue::GetAsUInt32 (uint32_t fai
             if (sizeof(long double) == sizeof(uint32_t))
                 return m_data.uint32;
             break;
+        case eTypeBytes:
+        {
+            switch (m_data.buffer.length)
+            {
+            default:    break;
+            case 1:     return m_data.uint8;
+            case 2:     return m_data.uint16;
+            case 4:     return m_data.uint32;
+            }
+        }
+        break;
     }
     if (success_ptr)
         *success_ptr = false;
@@ -730,6 +759,18 @@ RegisterValue::GetAsUInt64 (uint64_t fai
             if (sizeof(long double) == sizeof(uint64_t))
                 return m_data.uint64;
             break;
+        case eTypeBytes:
+        {
+            switch (m_data.buffer.length)
+            {
+            default:    break;
+            case 1:     return m_data.uint8;
+            case 2:     return m_data.uint16;
+            case 4:     return m_data.uint32;
+            case 8:     return m_data.uint64;
+            }
+        }
+        break;
     }
     if (success_ptr)
         *success_ptr = false;
@@ -762,6 +803,20 @@ RegisterValue::GetAsUInt128 (__uint128_t
             if (sizeof(long double) == sizeof(__uint128_t))
                 return m_data.uint128;
             break;
+        case eTypeBytes:
+        {
+            switch (m_data.buffer.length)
+            {
+            default:
+                break;
+            case 1:     return m_data.uint8;
+            case 2:     return m_data.uint16;
+            case 4:     return m_data.uint32;
+            case 8:     return m_data.uint64;
+            case 16:    return m_data.uint128;
+            }
+        }
+        break;
     }
     if (success_ptr)
         *success_ptr = false;
@@ -983,12 +1038,11 @@ RegisterValue::SetBytes (const void *byt
     // m_data.buffer.bytes, or make it something that is allocated on
     // the heap. Since the data buffer is in a union, we can't make it
     // a collection class like SmallVector...
-    assert (length <= sizeof (m_data.buffer.bytes));
     if (bytes && length > 0)
     {
+        assert (length <= sizeof (m_data.buffer.bytes) && "Storing too many bytes in a RegisterValue.");
         m_type = eTypeBytes;
         m_data.buffer.length = length;
-        assert (length < sizeof (m_data.buffer.bytes));
         memcpy (m_data.buffer.bytes, bytes, length);
         m_data.buffer.byte_order = byte_order;
     }

Modified: lldb/branches/lldb-platform-work/source/Core/RegularExpression.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/lldb-platform-work/source/Core/RegularExpression.cpp?rev=183468&r1=183467&r2=183468&view=diff
==============================================================================
--- lldb/branches/lldb-platform-work/source/Core/RegularExpression.cpp (original)
+++ lldb/branches/lldb-platform-work/source/Core/RegularExpression.cpp Thu Jun  6 19:06:43 2013
@@ -8,6 +8,7 @@
 //===----------------------------------------------------------------------===//
 
 #include "lldb/Core/RegularExpression.h"
+#include "llvm/ADT/StringRef.h"
 #include <string.h>
 
 using namespace lldb_private;
@@ -19,8 +20,7 @@ RegularExpression::RegularExpression() :
     m_re(),
     m_comp_err (1),
     m_preg(),
-    m_compile_flags(REG_EXTENDED),
-    m_matches()
+    m_compile_flags(REG_EXTENDED)
 {
     memset(&m_preg,0,sizeof(m_preg));
 }
@@ -124,31 +124,45 @@ RegularExpression::Compile(const char* r
 // matches "match_count" should indicate the number of regmatch_t
 // values that are present in "match_ptr". The regular expression
 // will be executed using the "execute_flags".
-//----------------------------------------------------------------------
+//---------------------------------------------------------------------
 bool
-RegularExpression::Execute(const char* s, size_t num_matches, int execute_flags) const
+RegularExpression::Execute(const char* s, Match *match, int execute_flags) const
 {
-    int match_result = 1;
-    if (m_comp_err == 0)
+    int err = 1;
+    if (s != NULL && m_comp_err == 0)
     {
-        if (num_matches > 0)
-            m_matches.resize(num_matches + 1);
+        if (match)
+        {
+            err = ::regexec (&m_preg,
+                             s,
+                             match->GetSize(),
+                             match->GetData(),
+                             execute_flags);
+        }
         else
-            m_matches.clear();
-
-        match_result = ::regexec (&m_preg,
-                                  s,
-                                  m_matches.size(),
-                                  &m_matches[0],
-                                  execute_flags);
+        {
+            err = ::regexec (&m_preg,
+                             s,
+                             0,
+                             NULL,
+                             execute_flags);
+        }
+    }
+    
+    if (err != 0)
+    {
+        // The regular expression didn't compile, so clear the matches
+        if (match)
+            match->Clear();
+        return false;
     }
-    return match_result == 0;
+    return true;
 }
 
 bool
-RegularExpression::GetMatchAtIndex (const char* s, uint32_t idx, std::string& match_str) const
+RegularExpression::Match::GetMatchAtIndex (const char* s, uint32_t idx, std::string& match_str) const
 {
-    if (idx <= m_preg.re_nsub && idx < m_matches.size())
+    if (idx < m_matches.size())
     {
         if (m_matches[idx].rm_eo == m_matches[idx].rm_so)
         {
@@ -166,6 +180,46 @@ RegularExpression::GetMatchAtIndex (cons
     return false;
 }
 
+bool
+RegularExpression::Match::GetMatchAtIndex (const char* s, uint32_t idx, llvm::StringRef& match_str) const
+{
+    if (idx < m_matches.size())
+    {
+        if (m_matches[idx].rm_eo == m_matches[idx].rm_so)
+        {
+            // Matched the empty string...
+            match_str = llvm::StringRef();
+            return true;
+        }
+        else if (m_matches[idx].rm_eo > m_matches[idx].rm_so)
+        {
+            match_str = llvm::StringRef (s + m_matches[idx].rm_so, m_matches[idx].rm_eo - m_matches[idx].rm_so);
+            return true;
+        }
+    }
+    return false;
+}
+
+bool
+RegularExpression::Match::GetMatchSpanningIndices (const char* s, uint32_t idx1, uint32_t idx2, llvm::StringRef& match_str) const
+{
+    if (idx1 < m_matches.size() && idx2 < m_matches.size())
+    {
+        if (m_matches[idx1].rm_so == m_matches[idx2].rm_eo)
+        {
+            // Matched the empty string...
+            match_str = llvm::StringRef();
+            return true;
+        }
+        else if (m_matches[idx1].rm_so < m_matches[idx2].rm_eo)
+        {
+            match_str = llvm::StringRef (s + m_matches[idx1].rm_so, m_matches[idx2].rm_eo - m_matches[idx1].rm_so);
+            return true;
+        }
+    }
+    return false;
+}
+
 
 //----------------------------------------------------------------------
 // Returns true if the regular expression compiled and is ready
@@ -184,6 +238,8 @@ RegularExpression::IsValid () const
 const char*
 RegularExpression::GetText () const
 {
+    if (m_re.empty())
+        return NULL;
     return m_re.c_str();
 }
 

Modified: lldb/branches/lldb-platform-work/source/Core/Scalar.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/lldb-platform-work/source/Core/Scalar.cpp?rev=183468&r1=183467&r2=183468&view=diff
==============================================================================
--- lldb/branches/lldb-platform-work/source/Core/Scalar.cpp (original)
+++ lldb/branches/lldb-platform-work/source/Core/Scalar.cpp Thu Jun  6 19:06:43 2013
@@ -10,6 +10,7 @@
 #include "lldb/Core/Scalar.h"
 
 #include <math.h>
+#include <inttypes.h>
 
 #include "lldb/Interpreter/Args.h"
 #include "lldb/Core/Error.h"
@@ -168,7 +169,6 @@ Scalar::GetByteSize() const
 {
     switch (m_type)
     {
-    default:
     case e_void:
         break;
     case e_sint:        return sizeof(m_data.sint);
@@ -189,7 +189,6 @@ Scalar::IsZero() const
 {
     switch (m_type)
     {
-    default:
     case e_void:
         break;
     case e_sint:        return m_data.sint == 0;
@@ -214,7 +213,6 @@ Scalar::GetValue (Stream *s, bool show_t
     switch (m_type)
     {
     case e_void:
-    default:
         break;
     case e_sint:        s->Printf("%i", m_data.sint);               break;
     case e_uint:        s->Printf("0x%8.8x", m_data.uint);          break;
@@ -233,8 +231,6 @@ Scalar::GetTypeAsCString() const
 {
     switch (m_type)
     {
-    default:
-        break;
     case e_void:        return "void";
     case e_sint:        return "int";
     case e_uint:        return "unsigned int";
@@ -357,7 +353,6 @@ Scalar::Promote(Scalar::Type type)
     case e_sint:
         switch (type)
         {
-        default:
         case e_void:        break;
         case e_sint:        success = true; break;
         case e_uint:        m_data.uint         = m_data.sint;      success = true; break;
@@ -374,7 +369,6 @@ Scalar::Promote(Scalar::Type type)
     case e_uint:
         switch (type)
         {
-        default:
         case e_void:
         case e_sint:        break;
         case e_uint:        success = true; break;
@@ -391,7 +385,6 @@ Scalar::Promote(Scalar::Type type)
     case e_slong:
         switch (type)
         {
-        default:
         case e_void:
         case e_sint:
         case e_uint:        break;
@@ -408,7 +401,6 @@ Scalar::Promote(Scalar::Type type)
     case e_ulong:
         switch (type)
         {
-        default:
         case e_void:
         case e_sint:
         case e_uint:
@@ -425,7 +417,6 @@ Scalar::Promote(Scalar::Type type)
     case e_slonglong:
         switch (type)
         {
-        default:
         case e_void:
         case e_sint:
         case e_uint:
@@ -442,7 +433,6 @@ Scalar::Promote(Scalar::Type type)
     case e_ulonglong:
         switch (type)
         {
-        default:
         case e_void:
         case e_sint:
         case e_uint:
@@ -459,7 +449,6 @@ Scalar::Promote(Scalar::Type type)
     case e_float:
         switch (type)
         {
-        default:
         case e_void:
         case e_sint:
         case e_uint:
@@ -476,7 +465,6 @@ Scalar::Promote(Scalar::Type type)
     case e_double:
         switch (type)
         {
-        default:
         case e_void:
         case e_sint:
         case e_uint:
@@ -493,7 +481,6 @@ Scalar::Promote(Scalar::Type type)
     case e_long_double:
         switch (type)
         {
-        default:
         case e_void:
         case e_sint:
         case e_uint:
@@ -518,7 +505,6 @@ Scalar::GetValueTypeAsCString (Scalar::T
 {
     switch (type)
     {
-    default:            break;
     case e_void:        return "void";
     case e_sint:        return "int";
     case e_uint:        return "unsigned int";
@@ -537,11 +523,11 @@ Scalar::GetValueTypeAsCString (Scalar::T
 Scalar::Type
 Scalar::GetValueTypeForSignedIntegerWithByteSize (size_t byte_size)
 {
-    if (byte_size <= sizeof(int))
+    if (byte_size <= sizeof(sint_t))
         return e_sint;
-    if (byte_size <= sizeof(long))
+    if (byte_size <= sizeof(slong_t))
         return e_slong;
-    if (byte_size <= sizeof(long long))
+    if (byte_size <= sizeof(slonglong_t))
         return e_slonglong;
     return e_void;
 }
@@ -549,11 +535,11 @@ Scalar::GetValueTypeForSignedIntegerWith
 Scalar::Type
 Scalar::GetValueTypeForUnsignedIntegerWithByteSize (size_t byte_size)
 {
-    if (byte_size <= sizeof(unsigned int))
+    if (byte_size <= sizeof(uint_t))
         return e_uint;
-    if (byte_size <= sizeof(unsigned long))
+    if (byte_size <= sizeof(ulong_t))
         return e_ulong;
-    if (byte_size <= sizeof(unsigned long long))
+    if (byte_size <= sizeof(ulonglong_t))
         return e_ulonglong;
     return e_void;
 }
@@ -561,11 +547,11 @@ Scalar::GetValueTypeForUnsignedIntegerWi
 Scalar::Type
 Scalar::GetValueTypeForFloatWithByteSize (size_t byte_size)
 {
-    if (byte_size == sizeof(float))
+    if (byte_size == sizeof(float_t))
         return e_float;
-    if (byte_size == sizeof(double))
+    if (byte_size == sizeof(double_t))
         return e_double;
-    if (byte_size == sizeof(long double))
+    if (byte_size == sizeof(long_double_t))
         return e_long_double;
     return e_void;
 }
@@ -582,7 +568,6 @@ Scalar::Cast(Scalar::Type type)
     case e_sint:
         switch (type)
         {
-        default:
         case e_void:        break;
         case e_sint:        success = true; break;
         case e_uint:        m_data.uint         = m_data.sint;      success = true; break;
@@ -599,7 +584,6 @@ Scalar::Cast(Scalar::Type type)
     case e_uint:
         switch (type)
         {
-        default:
         case e_void:
         case e_sint:        m_data.sint         = m_data.uint;      success = true; break;
         case e_uint:        success = true; break;
@@ -616,10 +600,9 @@ Scalar::Cast(Scalar::Type type)
     case e_slong:
         switch (type)
         {
-        default:
         case e_void:
-        case e_sint:        m_data.sint         = m_data.slong;     success = true; break;
-        case e_uint:        m_data.uint         = m_data.slong;     success = true; break;
+        case e_sint:        m_data.sint         = (sint_t)m_data.slong;     success = true; break;
+        case e_uint:        m_data.uint         = (uint_t)m_data.slong;     success = true; break;
         case e_slong:       success = true; break;
         case e_ulong:       m_data.ulong        = m_data.slong;     success = true; break;
         case e_slonglong:   m_data.slonglong    = m_data.slong;     success = true; break;
@@ -633,10 +616,9 @@ Scalar::Cast(Scalar::Type type)
     case e_ulong:
         switch (type)
         {
-        default:
         case e_void:
-        case e_sint:        m_data.sint         = m_data.ulong;     success = true; break;
-        case e_uint:        m_data.uint         = m_data.ulong;     success = true; break;
+        case e_sint:        m_data.sint         = (sint_t)m_data.ulong;     success = true; break;
+        case e_uint:        m_data.uint         = (uint_t)m_data.ulong;     success = true; break;
         case e_slong:       m_data.slong        = m_data.ulong;     success = true; break;
         case e_ulong:       success = true; break;
         case e_slonglong:   m_data.slonglong    = m_data.ulong;     success = true; break;
@@ -650,10 +632,9 @@ Scalar::Cast(Scalar::Type type)
     case e_slonglong:
         switch (type)
         {
-        default:
         case e_void:
-        case e_sint:        m_data.sint         = m_data.slonglong;     success = true; break;
-        case e_uint:        m_data.uint         = m_data.slonglong;     success = true; break;
+        case e_sint:        m_data.sint         = (sint_t)m_data.slonglong;     success = true; break;
+        case e_uint:        m_data.uint         = (uint_t)m_data.slonglong;     success = true; break;
         case e_slong:       m_data.slong        = m_data.slonglong;     success = true; break;
         case e_ulong:       m_data.ulong        = m_data.slonglong;     success = true; break;
         case e_slonglong:   success = true; break;
@@ -667,10 +648,9 @@ Scalar::Cast(Scalar::Type type)
     case e_ulonglong:
         switch (type)
         {
-        default:
         case e_void:
-        case e_sint:        m_data.sint         = m_data.ulonglong;     success = true; break;
-        case e_uint:        m_data.uint         = m_data.ulonglong;     success = true; break;
+        case e_sint:        m_data.sint         = (sint_t)m_data.ulonglong;     success = true; break;
+        case e_uint:        m_data.uint         = (uint_t)m_data.ulonglong;     success = true; break;
         case e_slong:       m_data.slong        = m_data.ulonglong;     success = true; break;
         case e_ulong:       m_data.ulong        = m_data.ulonglong;     success = true; break;
         case e_slonglong:   m_data.slonglong    = m_data.ulonglong;     success = true; break;
@@ -684,50 +664,47 @@ Scalar::Cast(Scalar::Type type)
     case e_float:
         switch (type)
         {
-        default:
         case e_void:
-        case e_sint:        m_data.sint         = m_data.flt;       success = true; break;
-        case e_uint:        m_data.uint         = m_data.flt;       success = true; break;
-        case e_slong:       m_data.slong        = m_data.flt;       success = true; break;
-        case e_ulong:       m_data.ulong        = m_data.flt;       success = true; break;
-        case e_slonglong:   m_data.slonglong    = m_data.flt;       success = true; break;
-        case e_ulonglong:   m_data.ulonglong    = m_data.flt;       success = true; break;
+        case e_sint:        m_data.sint         = (sint_t)m_data.flt;       success = true; break;
+        case e_uint:        m_data.uint         = (uint_t)m_data.flt;       success = true; break;
+        case e_slong:       m_data.slong        = (slong_t)m_data.flt;      success = true; break;
+        case e_ulong:       m_data.ulong        = (ulong_t)m_data.flt;      success = true; break;
+        case e_slonglong:   m_data.slonglong    = (slonglong_t)m_data.flt;  success = true; break;
+        case e_ulonglong:   m_data.ulonglong    = (ulonglong_t)m_data.flt;  success = true; break;
         case e_float:       success = true; break;
-        case e_double:      m_data.dbl          = m_data.flt;       success = true; break;
-        case e_long_double: m_data.ldbl         = m_data.flt;       success = true; break;
+        case e_double:      m_data.dbl          = m_data.flt;               success = true; break;
+        case e_long_double: m_data.ldbl         = m_data.flt;               success = true; break;
         }
         break;
 
     case e_double:
         switch (type)
         {
-        default:
         case e_void:
-        case e_sint:        m_data.sint         = m_data.dbl;       success = true; break;
-        case e_uint:        m_data.uint         = m_data.dbl;       success = true; break;
-        case e_slong:       m_data.slong        = m_data.dbl;       success = true; break;
-        case e_ulong:       m_data.ulong        = m_data.dbl;       success = true; break;
-        case e_slonglong:   m_data.slonglong    = m_data.dbl;       success = true; break;
-        case e_ulonglong:   m_data.ulonglong    = m_data.dbl;       success = true; break;
-        case e_float:       m_data.flt          = m_data.dbl;       success = true; break;
+        case e_sint:        m_data.sint         = (sint_t)m_data.dbl;       success = true; break;
+        case e_uint:        m_data.uint         = (uint_t)m_data.dbl;       success = true; break;
+        case e_slong:       m_data.slong        = (slong_t)m_data.dbl;      success = true; break;
+        case e_ulong:       m_data.ulong        = (ulong_t)m_data.dbl;      success = true; break;
+        case e_slonglong:   m_data.slonglong    = (slonglong_t)m_data.dbl;  success = true; break;
+        case e_ulonglong:   m_data.ulonglong    = (ulonglong_t)m_data.dbl;  success = true; break;
+        case e_float:       m_data.flt          = (float_t)m_data.dbl;      success = true; break;
         case e_double:      success = true; break;
-        case e_long_double: m_data.ldbl         = m_data.dbl;       success = true; break;
+        case e_long_double: m_data.ldbl         = m_data.dbl;               success = true; break;
         }
         break;
 
     case e_long_double:
         switch (type)
         {
-        default:
         case e_void:
-        case e_sint:        m_data.sint         = m_data.ldbl;      success = true; break;
-        case e_uint:        m_data.uint         = m_data.ldbl;      success = true; break;
-        case e_slong:       m_data.slong        = m_data.ldbl;      success = true; break;
-        case e_ulong:       m_data.ulong        = m_data.ldbl;      success = true; break;
-        case e_slonglong:   m_data.slonglong    = m_data.ldbl;      success = true; break;
-        case e_ulonglong:   m_data.ulonglong    = m_data.ldbl;      success = true; break;
-        case e_float:       m_data.flt          = m_data.ldbl;      success = true; break;
-        case e_double:      m_data.dbl          = m_data.ldbl;      success = true; break;
+        case e_sint:        m_data.sint         = (sint_t)m_data.ldbl;      success = true; break;
+        case e_uint:        m_data.uint         = (uint_t)m_data.ldbl;      success = true; break;
+        case e_slong:       m_data.slong        = (slong_t)m_data.ldbl;     success = true; break;
+        case e_ulong:       m_data.ulong        = (ulong_t)m_data.ldbl;     success = true; break;
+        case e_slonglong:   m_data.slonglong    = (slonglong_t)m_data.ldbl; success = true; break;
+        case e_ulonglong:   m_data.ulonglong    = (ulonglong_t)m_data.ldbl; success = true; break;
+        case e_float:       m_data.flt          = (float_t)m_data.ldbl;     success = true; break;
+        case e_double:      m_data.dbl          = (double_t)m_data.ldbl;    success = true; break;
         case e_long_double: success = true; break;
         }
         break;
@@ -738,12 +715,33 @@ Scalar::Cast(Scalar::Type type)
     return success;
 }
 
+bool
+Scalar::MakeSigned ()
+{
+    bool success = false;
+    
+    switch (m_type)
+    {
+    case e_void:                                break;
+    case e_sint:                                success = true; break;
+    case e_uint:        m_type = e_sint;        success = true; break;
+    case e_slong:                               success = true; break;
+    case e_ulong:       m_type = e_slong;       success = true; break;
+    case e_slonglong:                           success = true; break;
+    case e_ulonglong:   m_type = e_slonglong;   success = true; break;
+    case e_float:                               success = true; break;
+    case e_double:                              success = true; break;
+    case e_long_double:                         success = true; break;
+    }
+    
+    return success;
+}
+
 int
 Scalar::SInt(int fail_value) const
 {
     switch (m_type)
     {
-    default:
     case e_void:        break;
     case e_sint:        return m_data.sint;
     case e_uint:        return (int)m_data.uint;
@@ -763,7 +761,6 @@ Scalar::UInt(unsigned int fail_value) co
 {
     switch (m_type)
     {
-    default:
     case e_void:        break;
     case e_sint:        return (unsigned int)m_data.sint;
     case e_uint:        return (unsigned int)m_data.uint;
@@ -784,7 +781,6 @@ Scalar::SLong(long fail_value) const
 {
     switch (m_type)
     {
-    default:
     case e_void:        break;
     case e_sint:        return (long)m_data.sint;
     case e_uint:        return (long)m_data.uint;
@@ -806,7 +802,6 @@ Scalar::ULong(unsigned long fail_value)
 {
     switch (m_type)
     {
-    default:
     case e_void:        break;
     case e_sint:        return (unsigned long)m_data.sint;
     case e_uint:        return (unsigned long)m_data.uint;
@@ -826,7 +821,6 @@ Scalar::GetRawBits64(uint64_t fail_value
 {
     switch (m_type)
     {
-    default:
     case e_void:
         break;
 
@@ -843,29 +837,29 @@ Scalar::GetRawBits64(uint64_t fail_value
         return m_data.ulonglong;
 
     case e_float:
-        if (sizeof(m_data.flt) == sizeof(int))
+        if (sizeof(m_data.flt) == sizeof(m_data.uint))
             return m_data.uint;
-        else if (sizeof(m_data.flt) == sizeof(unsigned long))
+        else if (sizeof(m_data.flt) == sizeof(m_data.ulong))
             return m_data.ulong;
-        else if (sizeof(m_data.flt) == sizeof(unsigned long long))
+        else if (sizeof(m_data.flt) == sizeof(m_data.ulonglong))
             return m_data.ulonglong;
         break;
 
     case e_double:
-        if (sizeof(m_data.dbl) == sizeof(int))
+        if (sizeof(m_data.dbl) == sizeof(m_data.uint))
             return m_data.uint;
-        else if (sizeof(m_data.dbl) == sizeof(unsigned long))
+        else if (sizeof(m_data.dbl) == sizeof(m_data.ulong))
             return m_data.ulong;
-        else if (sizeof(m_data.dbl) == sizeof(unsigned long long))
+        else if (sizeof(m_data.dbl) == sizeof(m_data.ulonglong))
             return m_data.ulonglong;
         break;
 
     case e_long_double:
-        if (sizeof(m_data.ldbl) == sizeof(int))
+        if (sizeof(m_data.ldbl) == sizeof(m_data.uint))
             return m_data.uint;
-        else if (sizeof(m_data.ldbl) == sizeof(unsigned long))
+        else if (sizeof(m_data.ldbl) == sizeof(m_data.ulong))
             return m_data.ulong;
-        else if (sizeof(m_data.ldbl) == sizeof(unsigned long long))
+        else if (sizeof(m_data.ldbl) == sizeof(m_data.ulonglong))
             return m_data.ulonglong;
         break;
     }
@@ -879,7 +873,6 @@ Scalar::SLongLong(long long fail_value)
 {
     switch (m_type)
     {
-    default:
     case e_void:        break;
     case e_sint:        return (long long)m_data.sint;
     case e_uint:        return (long long)m_data.uint;
@@ -900,7 +893,6 @@ Scalar::ULongLong(unsigned long long fai
 {
     switch (m_type)
     {
-    default:
     case e_void:        break;
     case e_sint:        return (unsigned long long)m_data.sint;
     case e_uint:        return (unsigned long long)m_data.uint;
@@ -921,7 +913,6 @@ Scalar::Float(float fail_value) const
 {
     switch (m_type)
     {
-    default:
     case e_void:        break;
     case e_sint:        return (float)m_data.sint;
     case e_uint:        return (float)m_data.uint;
@@ -942,7 +933,6 @@ Scalar::Double(double fail_value) const
 {
     switch (m_type)
     {
-    default:
     case e_void:        break;
     case e_sint:        return (double)m_data.sint;
     case e_uint:        return (double)m_data.uint;
@@ -963,7 +953,6 @@ Scalar::LongDouble(long double fail_valu
 {
     switch (m_type)
     {
-    default:
     case e_void:        break;
     case e_sint:        return (long double)m_data.sint;
     case e_uint:        return (long double)m_data.uint;
@@ -989,7 +978,6 @@ Scalar::operator+= (const Scalar& rhs)
     {
         switch (m_type)
         {
-        default:
         case e_void:        break;
         case e_sint:        m_data.sint         = a->m_data.sint        + b->m_data.sint;       break;
         case e_uint:        m_data.uint         = a->m_data.uint        + b->m_data.uint;       break;
@@ -1010,7 +998,6 @@ Scalar::operator<<= (const Scalar& rhs)
 {
     switch (m_type)
     {
-    default:
     case e_void:
     case e_float:
     case e_double:
@@ -1021,7 +1008,6 @@ Scalar::operator<<= (const Scalar& rhs)
     case e_sint:
         switch (rhs.m_type)
         {
-        default:
         case e_void:
         case e_float:
         case e_double:
@@ -1040,7 +1026,6 @@ Scalar::operator<<= (const Scalar& rhs)
     case e_uint:
         switch (rhs.m_type)
         {
-        default:
         case e_void:
         case e_float:
         case e_double:
@@ -1059,7 +1044,6 @@ Scalar::operator<<= (const Scalar& rhs)
     case e_slong:
         switch (rhs.m_type)
         {
-        default:
         case e_void:
         case e_float:
         case e_double:
@@ -1078,7 +1062,6 @@ Scalar::operator<<= (const Scalar& rhs)
     case e_ulong:
         switch (rhs.m_type)
         {
-        default:
         case e_void:
         case e_float:
         case e_double:
@@ -1096,7 +1079,6 @@ Scalar::operator<<= (const Scalar& rhs)
     case e_slonglong:
         switch (rhs.m_type)
         {
-        default:
         case e_void:
         case e_float:
         case e_double:
@@ -1115,7 +1097,6 @@ Scalar::operator<<= (const Scalar& rhs)
     case e_ulonglong:
         switch (rhs.m_type)
         {
-        default:
         case e_void:
         case e_float:
         case e_double:
@@ -1139,7 +1120,6 @@ Scalar::ShiftRightLogical(const Scalar&
 {
     switch (m_type)
     {
-    default:
     case e_void:
     case e_float:
     case e_double:
@@ -1151,7 +1131,6 @@ Scalar::ShiftRightLogical(const Scalar&
     case e_uint:
         switch (rhs.m_type)
         {
-        default:
         case e_void:
         case e_float:
         case e_double:
@@ -1171,7 +1150,6 @@ Scalar::ShiftRightLogical(const Scalar&
     case e_ulong:
         switch (rhs.m_type)
         {
-        default:
         case e_void:
         case e_float:
         case e_double:
@@ -1191,7 +1169,6 @@ Scalar::ShiftRightLogical(const Scalar&
     case e_ulonglong:
         switch (rhs.m_type)
         {
-        default:
         case e_void:
         case e_float:
         case e_double:
@@ -1216,7 +1193,6 @@ Scalar::operator>>= (const Scalar& rhs)
 {
     switch (m_type)
     {
-    default:
     case e_void:
     case e_float:
     case e_double:
@@ -1227,7 +1203,6 @@ Scalar::operator>>= (const Scalar& rhs)
     case e_sint:
         switch (rhs.m_type)
         {
-        default:
         case e_void:
         case e_float:
         case e_double:
@@ -1246,7 +1221,6 @@ Scalar::operator>>= (const Scalar& rhs)
     case e_uint:
         switch (rhs.m_type)
         {
-        default:
         case e_void:
         case e_float:
         case e_double:
@@ -1265,7 +1239,6 @@ Scalar::operator>>= (const Scalar& rhs)
     case e_slong:
         switch (rhs.m_type)
         {
-        default:
         case e_void:
         case e_float:
         case e_double:
@@ -1284,7 +1257,6 @@ Scalar::operator>>= (const Scalar& rhs)
     case e_ulong:
         switch (rhs.m_type)
         {
-        default:
         case e_void:
         case e_float:
         case e_double:
@@ -1302,7 +1274,6 @@ Scalar::operator>>= (const Scalar& rhs)
     case e_slonglong:
         switch (rhs.m_type)
         {
-        default:
         case e_void:
         case e_float:
         case e_double:
@@ -1321,7 +1292,6 @@ Scalar::operator>>= (const Scalar& rhs)
     case e_ulonglong:
         switch (rhs.m_type)
         {
-        default:
         case e_void:
         case e_float:
         case e_double:
@@ -1346,7 +1316,6 @@ Scalar::operator&= (const Scalar& rhs)
 {
     switch (m_type)
     {
-    default:
     case e_void:
     case e_float:
     case e_double:
@@ -1357,7 +1326,6 @@ Scalar::operator&= (const Scalar& rhs)
     case e_sint:
         switch (rhs.m_type)
         {
-        default:
         case e_void:
         case e_float:
         case e_double:
@@ -1376,7 +1344,6 @@ Scalar::operator&= (const Scalar& rhs)
     case e_uint:
         switch (rhs.m_type)
         {
-        default:
         case e_void:
         case e_float:
         case e_double:
@@ -1395,7 +1362,6 @@ Scalar::operator&= (const Scalar& rhs)
     case e_slong:
         switch (rhs.m_type)
         {
-        default:
         case e_void:
         case e_float:
         case e_double:
@@ -1414,7 +1380,6 @@ Scalar::operator&= (const Scalar& rhs)
     case e_ulong:
         switch (rhs.m_type)
         {
-        default:
         case e_void:
         case e_float:
         case e_double:
@@ -1432,7 +1397,6 @@ Scalar::operator&= (const Scalar& rhs)
     case e_slonglong:
         switch (rhs.m_type)
         {
-        default:
         case e_void:
         case e_float:
         case e_double:
@@ -1451,7 +1415,6 @@ Scalar::operator&= (const Scalar& rhs)
     case e_ulonglong:
         switch (rhs.m_type)
         {
-        default:
         case e_void:
         case e_float:
         case e_double:
@@ -1477,7 +1440,6 @@ Scalar::AbsoluteValue()
 {
     switch (m_type)
     {
-    default:
     case e_void:
         break;
 
@@ -1512,7 +1474,6 @@ Scalar::UnaryNegate()
 {
     switch (m_type)
     {
-    default:
     case e_void:        break;
     case e_sint:        m_data.sint = -m_data.sint;             return true;
     case e_uint:        m_data.uint = -m_data.uint;             return true;
@@ -1539,7 +1500,6 @@ Scalar::OnesComplement()
     case e_slonglong:   m_data.slonglong = ~m_data.slonglong; return true;
     case e_ulonglong:   m_data.ulonglong = ~m_data.ulonglong; return true;
 
-    default:
     case e_void:
     case e_float:
     case e_double:
@@ -1561,7 +1521,6 @@ lldb_private::operator+ (const Scalar& l
     {
         switch (result.m_type)
         {
-        default:
         case Scalar::e_void:            break;
         case Scalar::e_sint:            result.m_data.sint      = a->m_data.sint        + b->m_data.sint;       break;
         case Scalar::e_uint:            result.m_data.uint      = a->m_data.uint        + b->m_data.uint;       break;
@@ -1589,7 +1548,6 @@ lldb_private::operator- (const Scalar& l
     {
         switch (result.m_type)
         {
-        default:
         case Scalar::e_void:            break;
         case Scalar::e_sint:            result.m_data.sint      = a->m_data.sint        - b->m_data.sint;       break;
         case Scalar::e_uint:            result.m_data.uint      = a->m_data.uint        - b->m_data.uint;       break;
@@ -1616,7 +1574,6 @@ lldb_private::operator/ (const Scalar& l
     {
         switch (result.m_type)
         {
-        default:
         case Scalar::e_void:            break;
 
         case Scalar::e_sint:            if (b->m_data.sint != 0)        { result.m_data.sint = a->m_data.sint/ b->m_data.sint; return result; } break;
@@ -1647,7 +1604,6 @@ lldb_private::operator* (const Scalar& l
     {
         switch (result.m_type)
         {
-        default:
         case Scalar::e_void:            break;
         case Scalar::e_sint:            result.m_data.sint      = a->m_data.sint        * b->m_data.sint;       break;
         case Scalar::e_uint:            result.m_data.uint      = a->m_data.uint        * b->m_data.uint;       break;
@@ -1681,7 +1637,6 @@ lldb_private::operator& (const Scalar& l
         case Scalar::e_slonglong:   result.m_data.slonglong = a->m_data.slonglong   & b->m_data.slonglong;  break;
         case Scalar::e_ulonglong:   result.m_data.ulonglong = a->m_data.ulonglong   & b->m_data.ulonglong;  break;
 
-        default:
         case Scalar::e_void:
         case Scalar::e_float:
         case Scalar::e_double:
@@ -1712,7 +1667,6 @@ lldb_private::operator| (const Scalar& l
         case Scalar::e_slonglong:   result.m_data.slonglong = a->m_data.slonglong   | b->m_data.slonglong;  break;
         case Scalar::e_ulonglong:   result.m_data.ulonglong = a->m_data.ulonglong   | b->m_data.ulonglong;  break;
 
-        default:
         case Scalar::e_void:
         case Scalar::e_float:
         case Scalar::e_double:
@@ -1743,7 +1697,6 @@ lldb_private::operator% (const Scalar& l
         case Scalar::e_slonglong:   result.m_data.slonglong = a->m_data.slonglong   % b->m_data.slonglong;  break;
         case Scalar::e_ulonglong:   result.m_data.ulonglong = a->m_data.ulonglong   % b->m_data.ulonglong;  break;
 
-        default:
         case Scalar::e_void:
         case Scalar::e_float:
         case Scalar::e_double:
@@ -1774,7 +1727,6 @@ lldb_private::operator^ (const Scalar& l
         case Scalar::e_slonglong:   result.m_data.slonglong = a->m_data.slonglong   ^ b->m_data.slonglong;  break;
         case Scalar::e_ulonglong:   result.m_data.ulonglong = a->m_data.ulonglong   ^ b->m_data.ulonglong;  break;
 
-        default:
         case Scalar::e_void:
         case Scalar::e_float:
         case Scalar::e_double:
@@ -1787,6 +1739,22 @@ lldb_private::operator^ (const Scalar& l
     return result;
 }
 
+const Scalar
+lldb_private::operator<< (const Scalar& lhs, const Scalar &rhs)
+{
+    Scalar result = lhs;
+    result <<= rhs;
+    return result;
+}
+
+const Scalar
+lldb_private::operator>> (const Scalar& lhs, const Scalar &rhs)
+{
+    Scalar result = lhs;
+    result >>= rhs;
+    return result;
+}
+
 // Return the raw unsigned integer without any casting or conversion
 unsigned int
 Scalar::RawUInt () const
@@ -1810,7 +1778,7 @@ Scalar::RawULongLong () const
 
 
 Error
-Scalar::SetValueFromCString (const char *value_str, Encoding encoding, uint32_t byte_size)
+Scalar::SetValueFromCString (const char *value_str, Encoding encoding, size_t byte_size)
 {
     Error error;
     if (value_str == NULL || value_str[0] == '\0')
@@ -1821,7 +1789,6 @@ Scalar::SetValueFromCString (const char
     bool success = false;
     switch (encoding)
     {
-    default:
     case eEncodingInvalid:
         error.SetErrorString ("Invalid encoding.");
         break;
@@ -1833,24 +1800,24 @@ Scalar::SetValueFromCString (const char
             if (!success)
                 error.SetErrorStringWithFormat ("'%s' is not a valid unsigned integer string value", value_str);
             else if (!UIntValueIsValidForSize (uval64, byte_size))
-                error.SetErrorStringWithFormat ("value 0x%llx is too large to fit in a %u byte unsigned integer value", uval64, byte_size);
+                error.SetErrorStringWithFormat ("value 0x%" PRIx64 " is too large to fit in a %zu byte unsigned integer value", uval64, byte_size);
             else
             {
                 m_type = Scalar::GetValueTypeForUnsignedIntegerWithByteSize (byte_size);
                 switch (m_type)
                 {
-                case e_uint:        m_data.uint = uval64;       break;
-                case e_ulong:       m_data.ulong = uval64;      break;
-                case e_ulonglong:   m_data.ulonglong = uval64;  break;
+                case e_uint:        m_data.uint = (uint_t)uval64;           break;
+                case e_ulong:       m_data.ulong = (ulong_t)uval64;         break;
+                case e_ulonglong:   m_data.ulonglong = (ulonglong_t)uval64; break;
                 default:
-                    error.SetErrorStringWithFormat ("unsupported unsigned integer byte size: %u", byte_size);
+                    error.SetErrorStringWithFormat ("unsupported unsigned integer byte size: %zu", byte_size);
                     break;
                 }
             }
         }
         else
         {
-            error.SetErrorStringWithFormat ("unsupported unsigned integer byte size: %u", byte_size);
+            error.SetErrorStringWithFormat ("unsupported unsigned integer byte size: %zu", byte_size);
             return error;
         }
         break;
@@ -1862,24 +1829,24 @@ Scalar::SetValueFromCString (const char
             if (!success)
                 error.SetErrorStringWithFormat ("'%s' is not a valid signed integer string value", value_str);
             else if (!SIntValueIsValidForSize (sval64, byte_size))
-                error.SetErrorStringWithFormat ("value 0x%llx is too large to fit in a %u byte signed integer value", sval64, byte_size);
+                error.SetErrorStringWithFormat ("value 0x%" PRIx64 " is too large to fit in a %zu byte signed integer value", sval64, byte_size);
             else
             {
                 m_type = Scalar::GetValueTypeForSignedIntegerWithByteSize (byte_size);
                 switch (m_type)
                 {
-                case e_sint:        m_data.sint = sval64;       break;
-                case e_slong:       m_data.slong = sval64;      break;
-                case e_slonglong:   m_data.slonglong = sval64;  break;
+                case e_sint:        m_data.sint = (sint_t)sval64;           break;
+                case e_slong:       m_data.slong = (slong_t)sval64;         break;
+                case e_slonglong:   m_data.slonglong = (slonglong_t)sval64; break;
                 default:
-                    error.SetErrorStringWithFormat ("unsupported signed integer byte size: %u", byte_size);
+                    error.SetErrorStringWithFormat ("unsupported signed integer byte size: %zu", byte_size);
                     break;
                 }
             }
         }
         else
         {
-            error.SetErrorStringWithFormat ("unsupported signed integer byte size: %u", byte_size);
+            error.SetErrorStringWithFormat ("unsupported signed integer byte size: %zu", byte_size);
             return error;
         }
         break;
@@ -1908,7 +1875,7 @@ Scalar::SetValueFromCString (const char
         }
         else
         {
-            error.SetErrorStringWithFormat ("unsupported float byte size: %u", byte_size);
+            error.SetErrorStringWithFormat ("unsupported float byte size: %zu", byte_size);
             return error;
         }
         break;
@@ -1923,6 +1890,70 @@ Scalar::SetValueFromCString (const char
     return error;
 }
 
+Error
+Scalar::SetValueFromData (DataExtractor &data, lldb::Encoding encoding, size_t byte_size)
+{
+    Error error;
+    
+    switch (encoding)
+    {
+    case lldb::eEncodingInvalid:
+        error.SetErrorString ("invalid encoding");
+        break;
+    case lldb::eEncodingVector:
+        error.SetErrorString ("vector encoding unsupported");
+        break;
+    case lldb::eEncodingUint:
+        {
+            lldb::offset_t offset;
+            
+            switch (byte_size)
+            {
+            case 1: operator=((uint8_t)data.GetU8(&offset)); break;
+            case 2: operator=((uint16_t)data.GetU16(&offset)); break;
+            case 4: operator=((uint32_t)data.GetU32(&offset)); break;
+            case 8: operator=((uint64_t)data.GetU64(&offset)); break;
+            default:
+                error.SetErrorStringWithFormat ("unsupported unsigned integer byte size: %zu", byte_size);
+                break;
+            }
+        }
+        break;
+    case lldb::eEncodingSint:
+        {
+            lldb::offset_t offset;
+            
+            switch (byte_size)
+            {
+            case 1: operator=((int8_t)data.GetU8(&offset)); break;
+            case 2: operator=((int16_t)data.GetU16(&offset)); break;
+            case 4: operator=((int32_t)data.GetU32(&offset)); break;
+            case 8: operator=((int64_t)data.GetU64(&offset)); break;
+            default:
+                error.SetErrorStringWithFormat ("unsupported signed integer byte size: %zu", byte_size);
+                break;
+            }
+        }
+        break;
+    case lldb::eEncodingIEEE754:
+        {
+            lldb::offset_t offset;
+            
+            if (byte_size == sizeof (float))
+                operator=((float)data.GetFloat(&offset));
+            else if (byte_size == sizeof (double))
+                operator=((double)data.GetDouble(&offset));
+            else if (byte_size == sizeof (long double))
+                operator=((long double)data.GetLongDouble(&offset));
+            else
+                error.SetErrorStringWithFormat ("unsupported float byte size: %zu", byte_size);
+        }
+        break;
+    }
+    
+    return error;
+}
+
 bool
 Scalar::SignExtend (uint32_t sign_bit_pos)
 {
@@ -1932,7 +1963,6 @@ Scalar::SignExtend (uint32_t sign_bit_po
     {
         switch (m_type)
         {
-        default:
         case Scalar::e_void:
         case Scalar::e_float:
         case Scalar::e_double:
@@ -1991,9 +2021,9 @@ Scalar::SignExtend (uint32_t sign_bit_po
     return false;
 }
 
-uint32_t
+size_t
 Scalar::GetAsMemoryData (void *dst,
-                         uint32_t dst_len, 
+                         size_t dst_len, 
                          lldb::ByteOrder dst_byte_order,
                          Error &error) const
 {
@@ -2008,7 +2038,7 @@ Scalar::GetAsMemoryData (void *dst,
     const size_t src_len = data.GetByteSize();
 
     // Prepare a memory buffer that contains some or all of the register value
-    const uint32_t bytes_copied = data.CopyByteOrderedData (0,                  // src offset
+    const size_t bytes_copied = data.CopyByteOrderedData (0,                  // src offset
                                                             src_len,            // src length
                                                             dst,                // dst buffer
                                                             dst_len,            // dst length
@@ -2030,65 +2060,64 @@ Scalar::ExtractBitfield (uint32_t bit_si
     uint32_t lsbit = bit_offset;
     switch (m_type)
     {
-        default:
         case Scalar::e_void:
             break;
             
         case e_float:
-            if (sizeof(m_data.flt) == sizeof(int))
-                m_data.sint = SignedBits (m_data.sint, msbit, lsbit);
-            else if (sizeof(m_data.flt) == sizeof(unsigned long))
-                m_data.slong = SignedBits (m_data.slong, msbit, lsbit);
-            else if (sizeof(m_data.flt) == sizeof(unsigned long long))
-                m_data.slonglong = SignedBits (m_data.slonglong, msbit, lsbit);
+            if (sizeof(m_data.flt) == sizeof(sint_t))
+                m_data.sint = (sint_t)SignedBits (m_data.sint, msbit, lsbit);
+            else if (sizeof(m_data.flt) == sizeof(ulong_t))
+                m_data.slong = (slong_t)SignedBits (m_data.slong, msbit, lsbit);
+            else if (sizeof(m_data.flt) == sizeof(ulonglong_t))
+                m_data.slonglong = (slonglong_t)SignedBits (m_data.slonglong, msbit, lsbit);
             else
                 return false;
             return true;
             
         case e_double:
-            if (sizeof(m_data.dbl) == sizeof(int))
+            if (sizeof(m_data.dbl) == sizeof(sint_t))
                 m_data.sint = SignedBits (m_data.sint, msbit, lsbit);
-            else if (sizeof(m_data.dbl) == sizeof(unsigned long))
+            else if (sizeof(m_data.dbl) == sizeof(ulong_t))
                 m_data.slong = SignedBits (m_data.slong, msbit, lsbit);
-            else if (sizeof(m_data.dbl) == sizeof(unsigned long long))
+            else if (sizeof(m_data.dbl) == sizeof(ulonglong_t))
                 m_data.slonglong = SignedBits (m_data.slonglong, msbit, lsbit);
             else
                 return false;
             return true;
             
         case e_long_double:
-            if (sizeof(m_data.ldbl) == sizeof(int))
+            if (sizeof(m_data.ldbl) == sizeof(sint_t))
                 m_data.sint = SignedBits (m_data.sint, msbit, lsbit);
-            else if (sizeof(m_data.ldbl) == sizeof(unsigned long))
+            else if (sizeof(m_data.ldbl) == sizeof(ulong_t))
                 m_data.slong = SignedBits (m_data.slong, msbit, lsbit);
-            else if (sizeof(m_data.ldbl) == sizeof(unsigned long long))
+            else if (sizeof(m_data.ldbl) == sizeof(ulonglong_t))
                 m_data.slonglong = SignedBits (m_data.slonglong, msbit, lsbit);
             else
                 return false;
             return true;
             
         case Scalar::e_sint:
-            m_data.sint = SignedBits (m_data.sint, msbit, lsbit);
+            m_data.sint = (sint_t)SignedBits (m_data.sint, msbit, lsbit);
             return true;
 
         case Scalar::e_uint:
-            m_data.uint = UnsignedBits (m_data.uint, msbit, lsbit);
+            m_data.uint = (uint_t)UnsignedBits (m_data.uint, msbit, lsbit);
             return true;
             
         case Scalar::e_slong:
-            m_data.slong = SignedBits (m_data.slong, msbit, lsbit);
+            m_data.slong = (slong_t)SignedBits (m_data.slong, msbit, lsbit);
             return true;
 
         case Scalar::e_ulong:
-            m_data.ulong = SignedBits (m_data.ulong, msbit, lsbit);
+            m_data.ulong = (ulong_t)UnsignedBits (m_data.ulong, msbit, lsbit);
             return true;
             
         case Scalar::e_slonglong:
-            m_data.slonglong = SignedBits (m_data.slonglong, msbit, lsbit);
+            m_data.slonglong = (slonglong_t)SignedBits (m_data.slonglong, msbit, lsbit);
             return true;
 
         case Scalar::e_ulonglong:
-            m_data.ulonglong = SignedBits (m_data.ulonglong, msbit, lsbit);
+            m_data.ulonglong = (ulonglong_t)UnsignedBits (m_data.ulonglong, msbit, lsbit);
             return true;
     }
     return false;
@@ -2110,7 +2139,6 @@ lldb_private::operator== (const Scalar&
     const Scalar* b;
     switch (PromoteToMaxType(lhs, rhs, temp_value, a, b))
     {
-    default:
     case Scalar::e_void:            break;
     case Scalar::e_sint:            return a->m_data.sint       == b->m_data.sint;
     case Scalar::e_uint:            return a->m_data.uint       == b->m_data.uint;
@@ -2137,7 +2165,6 @@ lldb_private::operator!= (const Scalar&
     const Scalar* b;
     switch (PromoteToMaxType(lhs, rhs, temp_value, a, b))
     {
-    default:
     case Scalar::e_void:            break;
     case Scalar::e_sint:            return a->m_data.sint       != b->m_data.sint;
     case Scalar::e_uint:            return a->m_data.uint       != b->m_data.uint;
@@ -2163,7 +2190,6 @@ lldb_private::operator< (const Scalar& l
     const Scalar* b;
     switch (PromoteToMaxType(lhs, rhs, temp_value, a, b))
     {
-    default:
     case Scalar::e_void:            break;
     case Scalar::e_sint:            return a->m_data.sint       < b->m_data.sint;
     case Scalar::e_uint:            return a->m_data.uint       < b->m_data.uint;
@@ -2189,7 +2215,6 @@ lldb_private::operator<= (const Scalar&
     const Scalar* b;
     switch (PromoteToMaxType(lhs, rhs, temp_value, a, b))
     {
-    default:
     case Scalar::e_void:            break;
     case Scalar::e_sint:            return a->m_data.sint       <= b->m_data.sint;
     case Scalar::e_uint:            return a->m_data.uint       <= b->m_data.uint;
@@ -2216,7 +2241,6 @@ lldb_private::operator> (const Scalar& l
     const Scalar* b;
     switch (PromoteToMaxType(lhs, rhs, temp_value, a, b))
     {
-    default:
     case Scalar::e_void:            break;
     case Scalar::e_sint:            return a->m_data.sint       > b->m_data.sint;
     case Scalar::e_uint:            return a->m_data.uint       > b->m_data.uint;
@@ -2242,7 +2266,6 @@ lldb_private::operator>= (const Scalar&
     const Scalar* b;
     switch (PromoteToMaxType(lhs, rhs, temp_value, a, b))
     {
-    default:
     case Scalar::e_void:            break;
     case Scalar::e_sint:            return a->m_data.sint       >= b->m_data.sint;
     case Scalar::e_uint:            return a->m_data.uint       >= b->m_data.uint;

Modified: lldb/branches/lldb-platform-work/source/Core/SearchFilter.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/lldb-platform-work/source/Core/SearchFilter.cpp?rev=183468&r1=183467&r2=183468&view=diff
==============================================================================
--- lldb/branches/lldb-platform-work/source/Core/SearchFilter.cpp (original)
+++ lldb/branches/lldb-platform-work/source/Core/SearchFilter.cpp Thu Jun  6 19:06:43 2013
@@ -14,6 +14,8 @@
 
 #include "lldb/lldb-private.h"
 #include "lldb/Core/SearchFilter.h"
+#include "lldb/Core/Module.h"
+#include "lldb/Symbol/CompileUnit.h"
 #include "lldb/Target/Target.h"
 
 using namespace lldb;
@@ -83,16 +85,6 @@ SearchFilter::ModulePasses (const Module
 }
 
 bool
-SearchFilter::SymbolContextPasses
-(
-    const SymbolContext &context,
-    lldb::SymbolContextItem scope
-)
-{
-    return true;
-}
-
-bool
 SearchFilter::AddressPasses (Address &address)
 {
     return true;
@@ -202,7 +194,7 @@ SearchFilter::DoModuleIteration (const S
         }
         else
         {
-            ModuleList &target_images = m_target_sp->GetImages();
+            const ModuleList &target_images = m_target_sp->GetImages();
             Mutex::Locker modules_locker(target_images.GetMutex());
             
             size_t n_modules = target_images.GetSize();
@@ -243,8 +235,8 @@ SearchFilter::DoCUIteration (const Modul
     Searcher::CallbackReturn shouldContinue;
     if (context.comp_unit == NULL)
     {
-        uint32_t num_comp_units = module_sp->GetNumCompileUnits();
-        for (uint32_t i = 0; i < num_comp_units; i++)
+        const size_t num_comp_units = module_sp->GetNumCompileUnits();
+        for (size_t i = 0; i < num_comp_units; i++)
         {
             CompUnitSP cu_sp (module_sp->GetCompileUnitAtIndex (i));
             if (cu_sp)
@@ -368,26 +360,9 @@ SearchFilterByModule::ModulePasses (cons
 bool
 SearchFilterByModule::ModulePasses (const FileSpec &spec)
 {
-    if (FileSpec::Compare(spec, m_module_spec, false) == 0)
-        return true;
-    else
-        return false;
-}
-
-bool
-SearchFilterByModule::SymbolContextPasses
-(
- const SymbolContext &context,
- lldb::SymbolContextItem scope
- )
-{
-    if (!(scope & eSymbolContextModule))
-        return false;
-
-    if (context.module_sp && FileSpec::Compare (context.module_sp->GetFileSpec(), m_module_spec, false) == 0)
-        return true;
-    else
-        return false;
+    // Do a full match only if "spec" has a directory
+    const bool full_match = spec.GetDirectory();
+    return FileSpec::Equal(spec, m_module_spec, full_match);
 }
 
 bool
@@ -427,14 +402,15 @@ SearchFilterByModule::Search (Searcher &
     // filespec that passes.  Otherwise, we need to go through all modules and
     // find the ones that match the file name.
 
-    ModuleList &target_modules = m_target_sp->GetImages();
+    const ModuleList &target_modules = m_target_sp->GetImages();
     Mutex::Locker modules_locker (target_modules.GetMutex());
     
     const size_t num_modules = target_modules.GetSize ();
     for (size_t i = 0; i < num_modules; i++)
     {
         Module* module = target_modules.GetModulePointerAtIndexUnlocked(i);
-        if (FileSpec::Compare (m_module_spec, module->GetFileSpec(), false) == 0)
+        const bool full_match = m_module_spec.GetDirectory();
+        if (FileSpec::Equal (m_module_spec, module->GetFileSpec(), full_match))
         {
             SymbolContext matchingContext(m_target_sp, module->shared_from_this());
             Searcher::CallbackReturn shouldContinue;
@@ -541,22 +517,6 @@ SearchFilterByModuleList::ModulePasses (
 }
 
 bool
-SearchFilterByModuleList::SymbolContextPasses
-(
- const SymbolContext &context,
- lldb::SymbolContextItem scope
- )
-{
-    if (!(scope & eSymbolContextModule))
-        return false;
-
-    if (context.module_sp && m_module_spec_list.FindFileIndex(0, context.module_sp->GetFileSpec(), true) != UINT32_MAX)
-        return true;
-    else
-        return false;
-}
-
-bool
 SearchFilterByModuleList::AddressPasses (Address &address)
 {
     // FIXME: Not yet implemented
@@ -593,7 +553,7 @@ SearchFilterByModuleList::Search (Search
     // filespec that passes.  Otherwise, we need to go through all modules and
     // find the ones that match the file name.
 
-    ModuleList &target_modules = m_target_sp->GetImages();
+    const ModuleList &target_modules = m_target_sp->GetImages();
     Mutex::Locker modules_locker (target_modules.GetMutex());
     
     const size_t num_modules = target_modules.GetSize ();
@@ -615,7 +575,7 @@ SearchFilterByModuleList::Search (Search
 void
 SearchFilterByModuleList::GetDescription (Stream *s)
 {
-    uint32_t num_modules = m_module_spec_list.GetSize();
+    size_t num_modules = m_module_spec_list.GetSize();
     if (num_modules == 1)
     {
         s->Printf (", module = ");
@@ -632,8 +592,8 @@ SearchFilterByModuleList::GetDescription
     }
     else
     {
-        s->Printf (", modules(%u) = ", num_modules);
-        for (uint32_t i = 0; i < num_modules; i++)
+        s->Printf (", modules(%zu) = ", num_modules);
+        for (size_t i = 0; i < num_modules; i++)
         {
             if (s->GetVerbose())
             {
@@ -713,25 +673,8 @@ SearchFilterByModuleListAndCU::~SearchFi
 }
 
 bool
-SearchFilterByModuleListAndCU::SymbolContextPasses
-(
- const SymbolContext &context,
- lldb::SymbolContextItem scope
- )
-{
-    if (!SearchFilterByModuleList::SymbolContextPasses(context, scope))
-        return false;
-    if (!(scope & eSymbolContextCompUnit))
-        return false;
-    if (context.comp_unit && m_cu_spec_list.FindFileIndex(0, static_cast<FileSpec>(context.comp_unit), false) == UINT32_MAX)
-        return false;
-    return true;
-}
-
-bool
 SearchFilterByModuleListAndCU::AddressPasses (Address &address)
 {
-    // FIXME: Not yet implemented
     return true;
 }
 
@@ -745,7 +688,7 @@ SearchFilterByModuleListAndCU::CompUnitP
 bool
 SearchFilterByModuleListAndCU::CompUnitPasses (CompileUnit &compUnit)
 {
-    return m_cu_spec_list.FindFileIndex(0, static_cast<FileSpec>(compUnit), false) != UINT32_MAX;
+    return m_cu_spec_list.FindFileIndex(0, compUnit, false) != UINT32_MAX;
 }
 
 void
@@ -766,7 +709,7 @@ SearchFilterByModuleListAndCU::Search (S
     // find the ones that match the file name.
 
     ModuleList matching_modules;
-    ModuleList &target_images = m_target_sp->GetImages();
+    const ModuleList &target_images = m_target_sp->GetImages();
     Mutex::Locker modules_locker(target_images.GetMutex());
     
     const size_t num_modules = target_images.GetSize ();
@@ -810,7 +753,7 @@ SearchFilterByModuleListAndCU::Search (S
 void
 SearchFilterByModuleListAndCU::GetDescription (Stream *s)
 {
-    uint32_t num_modules = m_module_spec_list.GetSize();
+    size_t num_modules = m_module_spec_list.GetSize();
     if (num_modules == 1)
     {
         s->Printf (", module = ");
@@ -827,8 +770,8 @@ SearchFilterByModuleListAndCU::GetDescri
     }
     else if (num_modules > 0)
     {
-        s->Printf (", modules(%d) = ", num_modules);
-        for (uint32_t i = 0; i < num_modules; i++)
+        s->Printf (", modules(%zd) = ", num_modules);
+        for (size_t i = 0; i < num_modules; i++)
         {
             if (s->GetVerbose())
             {

Modified: lldb/branches/lldb-platform-work/source/Core/Section.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/lldb-platform-work/source/Core/Section.cpp?rev=183468&r1=183467&r2=183468&view=diff
==============================================================================
--- lldb/branches/lldb-platform-work/source/Core/Section.cpp (original)
+++ lldb/branches/lldb-platform-work/source/Core/Section.cpp Thu Jun  6 19:06:43 2013
@@ -21,8 +21,8 @@ Section::Section (const ModuleSP &module
                   SectionType sect_type,
                   addr_t file_addr,
                   addr_t byte_size,
-                  uint64_t file_offset,
-                  uint64_t file_size,
+                  lldb::offset_t file_offset,
+                  lldb::offset_t file_size,
                   uint32_t flags) :
     ModuleChild     (module_sp),
     UserID          (sect_id),
@@ -37,11 +37,9 @@ Section::Section (const ModuleSP &module
     m_children      (),
     m_fake          (false),
     m_encrypted     (false),
-    m_thread_specific (false),
-    m_linked_section_wp(),
-    m_linked_offset (0)
+    m_thread_specific (false)
 {
-//    printf ("Section::Section(%p): module=%p, sect_id = 0x%16.16llx, addr=[0x%16.16llx - 0x%16.16llx), file [0x%16.16llx - 0x%16.16llx), flags = 0x%8.8x, name = %s\n",
+//    printf ("Section::Section(%p): module=%p, sect_id = 0x%16.16" PRIx64 ", addr=[0x%16.16" PRIx64 " - 0x%16.16" PRIx64 "), file [0x%16.16" PRIx64 " - 0x%16.16" PRIx64 "), flags = 0x%8.8x, name = %s\n",
 //            this, module_sp.get(), sect_id, file_addr, file_addr + byte_size, file_offset, file_offset + file_size, flags, name.GetCString());
 }
 
@@ -52,8 +50,8 @@ Section::Section (const lldb::SectionSP
                   SectionType sect_type,
                   addr_t file_addr,
                   addr_t byte_size,
-                  uint64_t file_offset,
-                  uint64_t file_size,
+                  lldb::offset_t file_offset,
+                  lldb::offset_t file_size,
                   uint32_t flags) :
     ModuleChild     (module_sp),
     UserID          (sect_id),
@@ -68,11 +66,9 @@ Section::Section (const lldb::SectionSP
     m_children      (),
     m_fake          (false),
     m_encrypted     (false),
-    m_thread_specific (false),
-    m_linked_section_wp(),
-    m_linked_offset (0)
+    m_thread_specific (false)
 {
-//    printf ("Section::Section(%p): module=%p, sect_id = 0x%16.16llx, addr=[0x%16.16llx - 0x%16.16llx), file [0x%16.16llx - 0x%16.16llx), flags = 0x%8.8x, name = %s.%s\n",
+//    printf ("Section::Section(%p): module=%p, sect_id = 0x%16.16" PRIx64 ", addr=[0x%16.16" PRIx64 " - 0x%16.16" PRIx64 "), file [0x%16.16" PRIx64 " - 0x%16.16" PRIx64 "), flags = 0x%8.8x, name = %s.%s\n",
 //            this, module_sp.get(), sect_id, file_addr, file_addr + byte_size, file_offset, file_offset + file_size, flags, parent_section_sp->GetName().GetCString(), name.GetCString());
     if (parent_section_sp)
         m_parent_wp = parent_section_sp;
@@ -83,15 +79,6 @@ Section::~Section()
 //    printf ("Section::~Section(%p)\n", this);
 }
 
-const ConstString&
-Section::GetName() const
-{
-    SectionSP linked_section_sp (m_linked_section_wp.lock());
-    if (linked_section_sp)
-        return linked_section_sp->GetName();
-    return m_name;
-}
-
 addr_t
 Section::GetFileAddress () const
 {
@@ -119,53 +106,31 @@ Section::GetOffset () const
     return 0;
 }
 
-
-addr_t
-Section::GetLinkedFileAddress () const
-{
-    SectionSP linked_section_sp (m_linked_section_wp.lock());
-    if (linked_section_sp)
-        return linked_section_sp->GetFileAddress() + m_linked_offset;
-    return LLDB_INVALID_ADDRESS;
-}
-
-
 addr_t
 Section::GetLoadBaseAddress (Target *target) const
 {
     addr_t load_base_addr = LLDB_INVALID_ADDRESS;
-    SectionSP linked_section_sp (m_linked_section_wp.lock());
-    if (linked_section_sp)
+    SectionSP parent_sp (GetParent ());
+    if (parent_sp)
     {
-        load_base_addr = linked_section_sp->GetLoadBaseAddress(target);
+        load_base_addr = parent_sp->GetLoadBaseAddress (target);
         if (load_base_addr != LLDB_INVALID_ADDRESS)
-            load_base_addr += m_linked_offset;
+            load_base_addr += GetOffset();
     }
     else
     {
-        SectionSP parent_sp (GetParent ());
-        if (parent_sp)
-        {
-            load_base_addr = parent_sp->GetLoadBaseAddress (target);
-            if (load_base_addr != LLDB_INVALID_ADDRESS)
-                load_base_addr += GetOffset();
-        }
-        else
-        {
-            load_base_addr = target->GetSectionLoadList().GetSectionLoadAddress (const_cast<Section *>(this)->shared_from_this());
-        }
+        load_base_addr = target->GetSectionLoadList().GetSectionLoadAddress (const_cast<Section *>(this)->shared_from_this());
     }
-
     return load_base_addr;
 }
 
 bool
 Section::ResolveContainedAddress (addr_t offset, Address &so_addr) const
 {
-    const uint32_t num_children = m_children.GetSize();
+    const size_t num_children = m_children.GetSize();
     if (num_children > 0)
     {
-        for (uint32_t i=0; i<num_children; i++)
+        for (size_t i=0; i<num_children; i++)
         {
             Section* child_section = m_children.GetSectionAtIndex (i).get();
 
@@ -174,22 +139,13 @@ Section::ResolveContainedAddress (addr_t
                 return child_section->ResolveContainedAddress (offset - child_offset, so_addr);
         }
     }
-    SectionSP linked_section_sp (m_linked_section_wp.lock());
-    if (linked_section_sp)
-    {
-        so_addr.SetOffset(m_linked_offset + offset);
-        so_addr.SetSection(linked_section_sp);
-    }
-    else
-    {
-        so_addr.SetOffset(offset);
-        so_addr.SetSection(const_cast<Section *>(this)->shared_from_this());
-        
+    so_addr.SetOffset(offset);
+    so_addr.SetSection(const_cast<Section *>(this)->shared_from_this());
+    
 #ifdef LLDB_CONFIGURATION_DEBUG
-        // For debug builds, ensure that there are no orphaned (i.e., moduleless) sections.
-        assert(GetModule().get());
+    // For debug builds, ensure that there are no orphaned (i.e., moduleless) sections.
+    assert(GetModule().get());
 #endif
-    }
     return true;
 }
 
@@ -208,21 +164,6 @@ Section::ContainsFileAddress (addr_t vm_
     return false;
 }
 
-bool
-Section::ContainsLinkedFileAddress (addr_t vm_addr) const
-{
-    const addr_t linked_file_addr = GetLinkedFileAddress();
-    if (linked_file_addr != LLDB_INVALID_ADDRESS)
-    {
-        if (linked_file_addr <= vm_addr)
-        {
-            const addr_t offset = vm_addr - linked_file_addr;
-            return offset < GetByteSize();
-        }
-    }
-    return false;
-}
-
 int
 Section::Compare (const Section& a, const Section& b)
 {
@@ -257,16 +198,15 @@ Section::Dump (Stream *s, Target *target
 {
 //    s->Printf("%.*p: ", (int)sizeof(void*) * 2, this);
     s->Indent();
-    s->Printf("0x%8.8llx %-16s ", GetID(), GetSectionTypeAsCString (m_type));
+    s->Printf("0x%8.8" PRIx64 " %-16s ", GetID(), GetSectionTypeAsCString (m_type));
     bool resolved = true;
     addr_t addr = LLDB_INVALID_ADDRESS;
 
-    SectionSP linked_section_sp (m_linked_section_wp.lock());
     if (GetByteSize() == 0)
         s->Printf("%39s", "");
     else
     {
-        if (target && linked_section_sp.get() == NULL)
+        if (target)
             addr = GetLoadBaseAddress (target);
 
         if (addr == LLDB_INVALID_ADDRESS)
@@ -280,41 +220,12 @@ Section::Dump (Stream *s, Target *target
         range.Dump (s, 0);
     }
 
-    s->Printf("%c 0x%8.8llx 0x%8.8llx 0x%8.8x ", resolved ? ' ' : '*', m_file_offset, m_file_size, Get());
+    s->Printf("%c 0x%8.8" PRIx64 " 0x%8.8" PRIx64 " 0x%8.8x ", resolved ? ' ' : '*', m_file_offset, m_file_size, Get());
 
     DumpName (s);
 
     s->EOL();
 
-    if (linked_section_sp)
-    {
-        addr = LLDB_INVALID_ADDRESS;
-        resolved = true;
-        if (target)
-        {
-            addr = linked_section_sp->GetLoadBaseAddress(target);
-            if (addr != LLDB_INVALID_ADDRESS)
-                addr += m_linked_offset;
-        }
-
-        if (addr == LLDB_INVALID_ADDRESS)
-        {
-            if (target)
-                resolved = false;
-            addr = linked_section_sp->GetFileAddress() + m_linked_offset;
-        }
-
-        int indent = 26 + s->GetIndentLevel();
-        s->Printf("%*.*s", indent, indent, "");
-        VMRange linked_range(addr, addr + m_byte_size);
-        linked_range.Dump (s, 0);
-        indent = 3 * (sizeof(uint32_t) * 2 + 2 + 1) + 1;
-        s->Printf("%c%*.*s", resolved ? ' ' : '*', indent, indent, "");
-
-        linked_section_sp->DumpName(s);
-        s->Printf(" + 0x%llx\n", m_linked_offset);
-    }
-
     if (depth > 0)
         m_children.Dump(s, target, false, depth - 1);
 }
@@ -371,22 +282,10 @@ Section::Slide (addr_t slide_amount, boo
     return false;
 }
 
-void
-Section::SetLinkedLocation (const lldb::SectionSP &linked_section_sp, uint64_t linked_offset)
-{
-    if (linked_section_sp)
-        m_module_wp = linked_section_sp->GetModule();
-    m_linked_section_wp = linked_section_sp;
-    m_linked_offset  = linked_offset;
-}
-
 #pragma mark SectionList
 
 SectionList::SectionList () :
     m_sections()
-#ifdef LLDB_CONFIGURATION_DEBUG
-    , m_finalized(false)
-#endif
 {
 }
 
@@ -395,17 +294,16 @@ SectionList::~SectionList ()
 {
 }
 
-uint32_t
+size_t
 SectionList::AddSection (const lldb::SectionSP& section_sp)
 {
     assert (section_sp.get());
-    uint32_t section_index = m_sections.size();
+    size_t section_index = m_sections.size();
     m_sections.push_back(section_sp);
-    InvalidateRangeCache();
     return section_index;
 }
 
-uint32_t
+size_t
 SectionList::FindSectionIndex (const Section* sect)
 {
     iterator sect_iter;
@@ -422,10 +320,10 @@ SectionList::FindSectionIndex (const Sec
     return UINT32_MAX;
 }
 
-uint32_t
+size_t
 SectionList::AddUniqueSection (const lldb::SectionSP& sect_sp)
 {
-    uint32_t sect_idx = FindSectionIndex (sect_sp.get());
+    size_t sect_idx = FindSectionIndex (sect_sp.get());
     if (sect_idx == UINT32_MAX)
         sect_idx = AddSection (sect_sp);
     return sect_idx;
@@ -441,7 +339,6 @@ SectionList::ReplaceSection (user_id_t s
         if ((*sect_iter)->GetID() == sect_id)
         {
             *sect_iter = sect_sp;
-            InvalidateRangeCache();
             return true;
         }
         else if (depth > 0)
@@ -470,7 +367,7 @@ SectionList::GetNumSections (uint32_t de
 }
 
 SectionSP
-SectionList::GetSectionAtIndex (uint32_t idx) const
+SectionList::GetSectionAtIndex (size_t idx) const
 {
     SectionSP sect_sp;
     if (idx < m_sections.size())
@@ -530,11 +427,11 @@ SectionList::FindSectionByID (user_id_t
 
 
 SectionSP
-SectionList::FindSectionByType (SectionType sect_type, bool check_children, uint32_t start_idx) const
+SectionList::FindSectionByType (SectionType sect_type, bool check_children, size_t start_idx) const
 {
     SectionSP sect_sp;
-    uint32_t num_sections = m_sections.size();
-    for (uint32_t idx = start_idx; idx < num_sections; ++idx)
+    size_t num_sections = m_sections.size();
+    for (size_t idx = start_idx; idx < num_sections; ++idx)
     {
         if (m_sections[idx]->GetType() == sect_type)
         {
@@ -575,71 +472,6 @@ SectionList::FindSectionContainingFileAd
     return sect_sp;
 }
 
-void
-SectionList::BuildRangeCache() const
-{
-    m_range_cache.Clear();
-    
-    for (collection::size_type idx = 0, last_idx = m_sections.size();
-         idx < last_idx;
-         ++idx)
-    {
-        Section *sect = m_sections[idx].get();
-        
-        addr_t linked_file_address = sect->GetLinkedFileAddress();
-        
-        if (linked_file_address != LLDB_INVALID_ADDRESS)
-            m_range_cache.Append(SectionRangeCache::Entry(linked_file_address, sect->GetByteSize(), idx));
-    }
-    
-    m_range_cache.Sort();
-    
-#ifdef LLDB_CONFIGURATION_DEBUG
-    m_finalized = true;
-#endif
-}
-
-void
-SectionList::InvalidateRangeCache() const
-{
-#ifdef LLDB_CONFIGURATION_DEBUG
-    assert(!m_finalized);
-#endif
-    m_range_cache.Clear();
-}
-
-SectionSP
-SectionList::FindSectionContainingLinkedFileAddress (addr_t vm_addr, uint32_t depth) const
-{
-    //if (m_range_cache.IsEmpty())
-    //    BuildRangeCache();
-#ifdef LLDB_CONFIGURATION_DEBUG
-    assert(m_finalized);
-#endif
-    
-    SectionRangeCache::Entry *entry = m_range_cache.FindEntryThatContains(vm_addr);
-    
-    if (entry)
-        return m_sections[entry->data];
-        
-    if (depth == 0)
-        return SectionSP();
-    
-    for (const_iterator si = m_sections.begin(), se = m_sections.end();
-         si != se;
-         ++si)
-    {
-        Section *sect = si->get();
-        
-        SectionSP sect_sp = sect->GetChildren().FindSectionContainingLinkedFileAddress(vm_addr, depth - 1);
-            
-        if (sect_sp)
-            return sect_sp;
-    }
-    
-    return SectionSP();
-}
-
 bool
 SectionList::ContainsSection(user_id_t sect_id) const
 {
@@ -681,15 +513,12 @@ SectionList::Slide (addr_t slide_amount,
         if ((*pos)->Slide(slide_amount, slide_children))
             ++count;
     }
-    InvalidateRangeCache();
     return count;
 }
 
 void
 SectionList::Finalize ()
 {
-    BuildRangeCache();
-    
     for (const_iterator si = m_sections.begin(), se = m_sections.end();
          si != se;
          ++si)

Modified: lldb/branches/lldb-platform-work/source/Core/SourceManager.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/lldb-platform-work/source/Core/SourceManager.cpp?rev=183468&r1=183467&r2=183468&view=diff
==============================================================================
--- lldb/branches/lldb-platform-work/source/Core/SourceManager.cpp (original)
+++ lldb/branches/lldb-platform-work/source/Core/SourceManager.cpp Thu Jun  6 19:06:43 2013
@@ -7,6 +7,8 @@
 //
 //===----------------------------------------------------------------------===//
 
+#include "lldb/lldb-python.h"
+
 #include "lldb/Core/SourceManager.h"
 
 // C Includes
@@ -15,13 +17,18 @@
 // Project includes
 #include "lldb/Core/DataBuffer.h"
 #include "lldb/Core/Debugger.h"
+#include "lldb/Core/Module.h"
 #include "lldb/Core/Stream.h"
 #include "lldb/Symbol/ClangNamespaceDecl.h"
+#include "lldb/Symbol/CompileUnit.h"
+#include "lldb/Symbol/Function.h"
 #include "lldb/Symbol/SymbolContext.h"
 #include "lldb/Target/Target.h"
 
+using namespace lldb;
 using namespace lldb_private;
 
+
 static inline bool is_newline_char(char ch)
 {
     return ch == '\n' || ch == '\r';
@@ -31,26 +38,23 @@ static inline bool is_newline_char(char
 //----------------------------------------------------------------------
 // SourceManager constructor
 //----------------------------------------------------------------------
-SourceManager::SourceManager(Target &target) :
+SourceManager::SourceManager(const TargetSP &target_sp) :
     m_last_file_sp (),
-    m_last_file_line (0),
-    m_last_file_context_before (0),
-    m_last_file_context_after (10),
+    m_last_line (0),
+    m_last_count (0),
     m_default_set(false),
-    m_target (&target),
-    m_debugger(NULL)
+    m_target_wp (target_sp),
+    m_debugger_wp(target_sp->GetDebugger().shared_from_this())
 {
-    m_debugger = &(m_target->GetDebugger());
 }
 
-SourceManager::SourceManager(Debugger &debugger) :
+SourceManager::SourceManager(const DebuggerSP &debugger_sp) :
     m_last_file_sp (),
-    m_last_file_line (0),
-    m_last_file_context_before (0),
-    m_last_file_context_after (10),
+    m_last_line (0),
+    m_last_count (0),
     m_default_set(false),
-    m_target (NULL),
-    m_debugger (&debugger)
+    m_target_wp (),
+    m_debugger_wp (debugger_sp)
 {
 }
 
@@ -61,88 +65,80 @@ SourceManager::~SourceManager()
 {
 }
 
-size_t
-SourceManager::DisplaySourceLines
-(
-    const FileSpec &file_spec,
-    uint32_t line,
-    uint32_t context_before,
-    uint32_t context_after,
-    Stream *s
-)
-{
-    m_last_file_sp = GetFile (file_spec);
-    m_last_file_line = line + context_after + 1;
-    m_last_file_context_before = context_before;
-    m_last_file_context_after = context_after;
-    if (m_last_file_sp.get())
-        return m_last_file_sp->DisplaySourceLines (line, context_before, context_after, s);
-
-    return 0;
-}
-
 SourceManager::FileSP
 SourceManager::GetFile (const FileSpec &file_spec)
 {
+    bool same_as_previous = m_last_file_sp && m_last_file_sp->FileSpecMatches (file_spec);
+
+    DebuggerSP debugger_sp (m_debugger_wp.lock());
     FileSP file_sp;
-    file_sp = m_debugger->GetSourceFileCache().FindSourceFile (file_spec);
+    if (same_as_previous)
+        file_sp = m_last_file_sp;
+    else if (debugger_sp)
+        file_sp = debugger_sp->GetSourceFileCache().FindSourceFile (file_spec);
+    
+    TargetSP target_sp (m_target_wp.lock());
+
+    // It the target source path map has been updated, get this file again so we
+    // can successfully remap the source file
+    if (target_sp && file_sp && file_sp->GetSourceMapModificationID() != target_sp->GetSourcePathMap().GetModificationID())
+        file_sp.reset();
+
     // If file_sp is no good or it points to a non-existent file, reset it.
     if (!file_sp || !file_sp->GetFileSpec().Exists())
     {
-        file_sp.reset (new File (file_spec, m_target));
+        file_sp.reset (new File (file_spec, target_sp.get()));
 
-        m_debugger->GetSourceFileCache().AddSourceFile(file_sp);
+        if (debugger_sp)
+            debugger_sp->GetSourceFileCache().AddSourceFile(file_sp);
     }
     return file_sp;
 }
 
 size_t
-SourceManager::DisplaySourceLinesWithLineNumbersUsingLastFile
-(
-    uint32_t line,
-    uint32_t context_before,
-    uint32_t context_after,
-    const char* current_line_cstr,
-    Stream *s,
-    const SymbolContextList *bp_locs
-)
+SourceManager::DisplaySourceLinesWithLineNumbersUsingLastFile (uint32_t start_line,
+                                                               uint32_t count,
+                                                               uint32_t curr_line,
+                                                               const char* current_line_cstr,
+                                                               Stream *s,
+                                                               const SymbolContextList *bp_locs)
 {
+    if (count == 0)
+        return 0;
     size_t return_value = 0;
-    if (line == 0)
+    if (start_line == 0)
     {
-        if (m_last_file_line != 0
-            && m_last_file_line != UINT32_MAX)
-            line = m_last_file_line + context_before;
+        if (m_last_line != 0 && m_last_line != UINT32_MAX)
+            start_line = m_last_line + m_last_count;
         else
-            line = 1;
+            start_line = 1;
     }
 
-    m_last_file_line = line + context_after + 1;
-    m_last_file_context_before = context_before;
-    m_last_file_context_after = context_after;
+    if (!m_default_set)
+    {
+        FileSpec tmp_spec;
+        uint32_t tmp_line;
+        GetDefaultFileAndLine(tmp_spec, tmp_line);
+    }
 
-    if (context_before == UINT32_MAX)
-        context_before = 0;
-    if (context_after == UINT32_MAX)
-        context_after = 10;
+    m_last_line = start_line;
+    m_last_count = count;
 
     if (m_last_file_sp.get())
     {
-        const uint32_t start_line = line <= context_before ? 1 : line - context_before;
-        const uint32_t end_line = line + context_after;
-        uint32_t curr_line;
-        for (curr_line = start_line; curr_line <= end_line; ++curr_line)
+        const uint32_t end_line = start_line + count - 1;
+        for (uint32_t line = start_line; line <= end_line; ++line)
         {
-            if (!m_last_file_sp->LineIsValid (curr_line))
+            if (!m_last_file_sp->LineIsValid (line))
             {
-                m_last_file_line = UINT32_MAX;
+                m_last_line = UINT32_MAX;
                 break;
             }
 
             char prefix[32] = "";
             if (bp_locs)
             {
-                uint32_t bp_count = bp_locs->NumLineEntriesWithLine (curr_line);
+                uint32_t bp_count = bp_locs->NumLineEntriesWithLine (line);
                 
                 if (bp_count > 0)
                     ::snprintf (prefix, sizeof (prefix), "[%u] ", bp_count);
@@ -151,13 +147,13 @@ SourceManager::DisplaySourceLinesWithLin
             }
 
             return_value += s->Printf("%s%2.2s %-4u\t", 
-                      prefix,
-                      curr_line == line ? current_line_cstr : "", 
-                      curr_line);
-            size_t this_line_size = m_last_file_sp->DisplaySourceLines (curr_line, 0, 0, s); 
+                                      prefix,
+                                      line == curr_line ? current_line_cstr : "",
+                                      line);
+            size_t this_line_size = m_last_file_sp->DisplaySourceLines (line, 0, 0, s);
             if (this_line_size == 0)
             {
-                m_last_file_line = UINT32_MAX;
+                m_last_line = UINT32_MAX;
                 break;
             }
             else
@@ -179,28 +175,70 @@ SourceManager::DisplaySourceLinesWithLin
     const SymbolContextList *bp_locs
 )
 {
-    bool same_as_previous = m_last_file_sp && m_last_file_sp->FileSpecMatches (file_spec);
+    FileSP file_sp (GetFile (file_spec));
 
-    if (!same_as_previous)
-        m_last_file_sp = GetFile (file_spec);
-
-    if (line == 0)
+    uint32_t start_line;
+    uint32_t count = context_before + context_after + 1;
+    if (line > context_before)
+        start_line = line - context_before;
+    else
+        start_line = 1;
+    
+    if (m_last_file_sp.get() != file_sp.get())
     {
-        if (!same_as_previous)
-            m_last_file_line = 0;
+        if (line == 0)
+            m_last_line = 0;
+        m_last_file_sp = file_sp;
     }
-
-    return DisplaySourceLinesWithLineNumbersUsingLastFile (line, context_before, context_after, current_line_cstr, s, bp_locs);
+    return DisplaySourceLinesWithLineNumbersUsingLastFile (start_line, count, line, current_line_cstr, s, bp_locs);
 }
 
 size_t
-SourceManager::DisplayMoreWithLineNumbers (Stream *s, const SymbolContextList *bp_locs)
-{
+SourceManager::DisplayMoreWithLineNumbers (Stream *s,
+                                           uint32_t count,
+                                           bool reverse,
+                                           const SymbolContextList *bp_locs)
+{
+    // If we get called before anybody has set a default file and line, then try to figure it out here.
+    const bool have_default_file_line = m_last_file_sp && m_last_line > 0;
+    if (!m_default_set)
+    {
+        FileSpec tmp_spec;
+        uint32_t tmp_line;
+        GetDefaultFileAndLine(tmp_spec, tmp_line);
+    }
+    
     if (m_last_file_sp)
     {
-        if (m_last_file_line == UINT32_MAX)
+        if (m_last_line == UINT32_MAX)
             return 0;
-        return DisplaySourceLinesWithLineNumbersUsingLastFile (0, m_last_file_context_before, m_last_file_context_after, "", s, bp_locs);
+        
+        if (reverse && m_last_line == 1)
+            return 0;
+    
+        if (count > 0)
+            m_last_count = count;
+        else if (m_last_count == 0)
+            m_last_count = 10;
+
+        if (m_last_line > 0)
+        {
+            if (reverse)
+            {
+                // If this is the first time we've done a reverse, then back up one more time so we end
+                // up showing the chunk before the last one we've shown:
+                if (m_last_line > m_last_count)
+                    m_last_line -= m_last_count;
+                else
+                    m_last_line = 1;
+            }
+            else if (have_default_file_line)
+                m_last_line += m_last_count;
+        }
+        else
+            m_last_line = 1;
+        
+        return DisplaySourceLinesWithLineNumbersUsingLastFile (m_last_line, m_last_count, UINT32_MAX, "", s, bp_locs);
     }
     return 0;
 }
@@ -214,7 +252,7 @@ SourceManager::SetDefaultFileAndLine (co
     m_default_set = true;
     if (m_last_file_sp)
     {
-        m_last_file_line = line;
+        m_last_line = line;
         return true;
     }
     else
@@ -230,38 +268,48 @@ SourceManager::GetDefaultFileAndLine (Fi
     if (m_last_file_sp)
     {
         file_spec = m_last_file_sp->GetFileSpec();
-        line = m_last_file_line;
+        line = m_last_line;
         return true;
     }
     else if (!m_default_set)
     {
-        // If nobody has set the default file and line then try here.  If there's no executable, then we
-        // will try again later when there is one.  Otherwise, if we can't find it we won't look again,
-        // somebody will have to set it (for instance when we stop somewhere...)
-        Module *executable_ptr = m_target->GetExecutableModulePointer();
-        if (executable_ptr)
+        TargetSP target_sp (m_target_wp.lock());
+
+        if (target_sp)
         {
-            SymbolContextList sc_list;
-            uint32_t num_matches;
-            ConstString main_name("main");
-            bool symbols_okay = false;  // Force it to be a debug symbol.
-            bool inlines_okay = true;
-            bool append = false;
-            num_matches = executable_ptr->FindFunctions (main_name, NULL, lldb::eFunctionNameTypeBase, inlines_okay, symbols_okay, append, sc_list);
-            for (uint32_t idx = 0; idx < num_matches; idx++)
+            // If nobody has set the default file and line then try here.  If there's no executable, then we
+            // will try again later when there is one.  Otherwise, if we can't find it we won't look again,
+            // somebody will have to set it (for instance when we stop somewhere...)
+            Module *executable_ptr = target_sp->GetExecutableModulePointer();
+            if (executable_ptr)
             {
-                SymbolContext sc;
-                sc_list.GetContextAtIndex(idx, sc);
-                if (sc.function)
+                SymbolContextList sc_list;
+                ConstString main_name("main");
+                bool symbols_okay = false;  // Force it to be a debug symbol.
+                bool inlines_okay = true;
+                bool append = false;
+                size_t num_matches = executable_ptr->FindFunctions (main_name,
+                                                                    NULL,
+                                                                    lldb::eFunctionNameTypeBase,
+                                                                    inlines_okay,
+                                                                    symbols_okay,
+                                                                    append,
+                                                                    sc_list);
+                for (size_t idx = 0; idx < num_matches; idx++)
                 {
-                    lldb_private::LineEntry line_entry;
-                    if (sc.function->GetAddressRange().GetBaseAddress().CalculateSymbolContextLineEntry (line_entry))
+                    SymbolContext sc;
+                    sc_list.GetContextAtIndex(idx, sc);
+                    if (sc.function)
                     {
-                        SetDefaultFileAndLine (line_entry.file, 
-                                               line_entry.line);
-                        file_spec = m_last_file_sp->GetFileSpec();
-                        line = m_last_file_line;
-                        return true;
+                        lldb_private::LineEntry line_entry;
+                        if (sc.function->GetAddressRange().GetBaseAddress().CalculateSymbolContextLineEntry (line_entry))
+                        {
+                            SetDefaultFileAndLine (line_entry.file, 
+                                                   line_entry.line);
+                            file_spec = m_last_file_sp->GetFileSpec();
+                            line = m_last_line;
+                            return true;
+                        }
                     }
                 }
             }
@@ -288,6 +336,7 @@ SourceManager::File::File(const FileSpec
     m_file_spec_orig (file_spec),
     m_file_spec(file_spec),
     m_mod_time (file_spec.GetModificationTime()),
+    m_source_map_mod_id (0),
     m_data_sp(),
     m_offsets()
 {
@@ -295,6 +344,8 @@ SourceManager::File::File(const FileSpec
     {
         if (target)
         {
+            m_source_map_mod_id = target->GetSourcePathMap().GetModificationID();
+
             if (!file_spec.GetDirectory() && file_spec.GetFilename())
             {
                 // If this is just a file name, lets see if we can find it in the target:
@@ -522,11 +573,14 @@ SourceManager::File::CalculateLineOffset
                     register char curr_ch = *s;
                     if (is_newline_char (curr_ch))
                     {
-                        register char next_ch = s[1];
-                        if (is_newline_char (next_ch))
+                        if (s + 1 < end)
                         {
-                            if (curr_ch != next_ch)
-                                ++s;
+                            register char next_ch = s[1];
+                            if (is_newline_char (next_ch))
+                            {
+                                if (curr_ch != next_ch)
+                                    ++s;
+                            }
                         }
                         m_offsets.push_back(s + 1 - start);
                     }
@@ -542,14 +596,14 @@ SourceManager::File::CalculateLineOffset
         else
         {
             // Some lines have been populated, start where we last left off
-            assert(!"Not implemented yet");
+            assert("Not implemented yet" == NULL);
         }
 
     }
     else
     {
         // Calculate all line offsets up to "line"
-        assert(!"Not implemented yet");
+        assert("Not implemented yet" == NULL);
     }
     return false;
 }
@@ -560,8 +614,8 @@ SourceManager::File::GetLine (uint32_t l
     if (!LineIsValid(line_no))
         return false;
 
-    uint32_t start_offset = GetLineOffset (line_no);
-    uint32_t end_offset = GetLineOffset (line_no + 1);
+    size_t start_offset = GetLineOffset (line_no);
+    size_t end_offset = GetLineOffset (line_no + 1);
     if (end_offset == UINT32_MAX)
     {
         end_offset = m_data_sp->GetByteSize();

Modified: lldb/branches/lldb-platform-work/source/Core/State.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/lldb-platform-work/source/Core/State.cpp?rev=183468&r1=183467&r2=183468&view=diff
==============================================================================
--- lldb/branches/lldb-platform-work/source/Core/State.cpp (original)
+++ lldb/branches/lldb-platform-work/source/Core/State.cpp Thu Jun  6 19:06:43 2013
@@ -83,7 +83,6 @@ lldb_private::StateIsRunningState (State
     case eStateCrashed:
     case eStateExited:
     case eStateSuspended:
-    default:
         break;
     }
     return false;
@@ -101,7 +100,6 @@ lldb_private::StateIsStoppedState (State
     case eStateRunning:
     case eStateStepping:
     case eStateDetached:
-    default:
         break;
 
     case eStateUnloaded:

Modified: lldb/branches/lldb-platform-work/source/Core/Stream.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/lldb-platform-work/source/Core/Stream.cpp?rev=183468&r1=183467&r2=183468&view=diff
==============================================================================
--- lldb/branches/lldb-platform-work/source/Core/Stream.cpp (original)
+++ lldb/branches/lldb-platform-work/source/Core/Stream.cpp Thu Jun  6 19:06:43 2013
@@ -14,6 +14,8 @@
 #include <string.h>
 #include <stdlib.h>
 
+#include <inttypes.h>
+
 using namespace lldb;
 using namespace lldb_private;
 
@@ -62,10 +64,10 @@ Stream::Offset (uint32_t uval, const cha
 // Put an SLEB128 "uval" out to the stream using the printf format
 // in "format".
 //------------------------------------------------------------------
-int
+size_t
 Stream::PutSLEB128 (int64_t sval)
 {
-    int bytes_written = 0;
+    size_t bytes_written = 0;
     if (m_flags.Test(eBinary))
     {
         bool more = true;
@@ -85,7 +87,7 @@ Stream::PutSLEB128 (int64_t sval)
     }
     else
     {
-        bytes_written = Printf ("0x%lli", sval);
+        bytes_written = Printf ("0x%" PRIi64, sval);
     }
 
     return bytes_written;
@@ -96,10 +98,10 @@ Stream::PutSLEB128 (int64_t sval)
 // Put an ULEB128 "uval" out to the stream using the printf format
 // in "format".
 //------------------------------------------------------------------
-int
+size_t
 Stream::PutULEB128 (uint64_t uval)
 {
-    int bytes_written = 0;
+    size_t bytes_written = 0;
     if (m_flags.Test(eBinary))
     {
         do
@@ -117,7 +119,7 @@ Stream::PutULEB128 (uint64_t uval)
     }
     else
     {
-        bytes_written = Printf ("0x%llx", uval);
+        bytes_written = Printf ("0x%" PRIx64, uval);
     }
     return bytes_written;
 }
@@ -125,10 +127,10 @@ Stream::PutULEB128 (uint64_t uval)
 //------------------------------------------------------------------
 // Print a raw NULL terminated C string to the stream.
 //------------------------------------------------------------------
-int
+size_t
 Stream::PutCString (const char *cstr)
 {
-    int cstr_len = strlen(cstr);
+    size_t cstr_len = strlen(cstr);
     // when in binary mode, emit the NULL terminator
     if (m_flags.Test(eBinary))
         ++cstr_len;
@@ -150,15 +152,15 @@ Stream::QuotedCString (const char *cstr,
 // and suffix strings.
 //------------------------------------------------------------------
 void
-Stream::Address (uint64_t addr, int addr_size, const char *prefix, const char *suffix)
+Stream::Address (uint64_t addr, uint32_t addr_size, const char *prefix, const char *suffix)
 {
     if (prefix == NULL)
         prefix = "";
     if (suffix == NULL)
         suffix = "";
 //    int addr_width = m_addr_size << 1;
-//    Printf ("%s0x%0*llx%s", prefix, addr_width, addr, suffix);
-    Printf ("%s0x%0*llx%s", prefix, addr_size * 2, (uint64_t)addr, suffix);
+//    Printf ("%s0x%0*" PRIx64 "%s", prefix, addr_width, addr, suffix);
+    Printf ("%s0x%0*" PRIx64 "%s", prefix, addr_size * 2, (uint64_t)addr, suffix);
 }
 
 //------------------------------------------------------------------
@@ -166,7 +168,7 @@ Stream::Address (uint64_t addr, int addr
 // and suffix strings.
 //------------------------------------------------------------------
 void
-Stream::AddressRange(uint64_t lo_addr, uint64_t hi_addr, int addr_size, const char *prefix, const char *suffix)
+Stream::AddressRange(uint64_t lo_addr, uint64_t hi_addr, uint32_t addr_size, const char *prefix, const char *suffix)
 {
     if (prefix && prefix[0])
         PutCString (prefix);
@@ -177,7 +179,7 @@ Stream::AddressRange(uint64_t lo_addr, u
 }
 
 
-int
+size_t
 Stream::PutChar (char ch)
 {
     return Write (&ch, 1);
@@ -187,7 +189,7 @@ Stream::PutChar (char ch)
 //------------------------------------------------------------------
 // Print some formatted output to the stream.
 //------------------------------------------------------------------
-int
+size_t
 Stream::Printf (const char *format, ...)
 {
     va_list args;
@@ -200,7 +202,7 @@ Stream::Printf (const char *format, ...)
 //------------------------------------------------------------------
 // Print some formatted output to the stream.
 //------------------------------------------------------------------
-int
+size_t
 Stream::PrintfVarArg (const char *format, va_list args)
 {
     char str[1024];
@@ -208,7 +210,7 @@ Stream::PrintfVarArg (const char *format
 
     va_copy (args_copy, args);
 
-    int bytes_written = 0;
+    size_t bytes_written = 0;
     // Try and format our string into a fixed buffer first and see if it fits
     size_t length = ::vsnprintf (str, sizeof(str), format, args);
     if (length < sizeof(str))
@@ -242,7 +244,7 @@ Stream::PrintfVarArg (const char *format
 //------------------------------------------------------------------
 // Print and End of Line character to the stream
 //------------------------------------------------------------------
-int
+size_t
 Stream::EOL()
 {
     return PutChar ('\n');
@@ -252,7 +254,7 @@ Stream::EOL()
 // Indent the current line using the current indentation level and
 // print an optional string following the idenatation spaces.
 //------------------------------------------------------------------
-int
+size_t
 Stream::Indent(const char *s)
 {
     return Printf ("%*.*s%s", m_indent_level, m_indent_level, "", s ? s : "");
@@ -364,7 +366,7 @@ Stream::operator<< (int32_t sval)
 Stream&
 Stream::operator<< (int64_t sval)
 {
-    Printf ("%lli", sval);
+    Printf ("%" PRIi64, sval);
     return *this;
 }
 
@@ -410,7 +412,7 @@ Stream::IndentLess (int amount)
 //------------------------------------------------------------------
 // Get the address size in bytes
 //------------------------------------------------------------------
-uint8_t
+uint32_t
 Stream::GetAddressByteSize() const
 {
     return m_addr_size;
@@ -420,7 +422,7 @@ Stream::GetAddressByteSize() const
 // Set the address size in bytes
 //------------------------------------------------------------------
 void
-Stream::SetAddressByteSize(uint8_t addr_size)
+Stream::SetAddressByteSize(uint32_t addr_size)
 {
     m_addr_size = addr_size;
 }
@@ -471,7 +473,7 @@ Stream::GetByteOrder() const
     return m_byte_order;
 }
 
-int
+size_t
 Stream::PrintfAsRawHex8 (const char *format, ...)
 {
     va_list args;
@@ -480,7 +482,7 @@ Stream::PrintfAsRawHex8 (const char *for
     va_copy (args, args_copy); // Copy this so we
 
     char str[1024];
-    int bytes_written = 0;
+    size_t bytes_written = 0;
     // Try and format our string into a fixed buffer first and see if it fits
     size_t length = ::vsnprintf (str, sizeof(str), format, args);
     if (length < sizeof(str))
@@ -509,19 +511,19 @@ Stream::PrintfAsRawHex8 (const char *for
     return bytes_written;
 }
 
-int
+size_t
 Stream::PutNHex8 (size_t n, uint8_t uvalue)
 {
-    int bytes_written = 0;
+    size_t bytes_written = 0;
     for (size_t i=0; i<n; ++i)
         bytes_written += _PutHex8 (uvalue, m_flags.Test(eAddPrefix));
     return bytes_written;
 }
 
-int
+size_t
 Stream::_PutHex8 (uint8_t uvalue, bool add_prefix)
 {
-    int bytes_written = 0;
+    size_t bytes_written = 0;
     if (m_flags.Test(eBinary))
     {
         bytes_written = Write (&uvalue, 1);
@@ -540,76 +542,76 @@ Stream::_PutHex8 (uint8_t uvalue, bool a
     return bytes_written;
 }
 
-int
+size_t
 Stream::PutHex8 (uint8_t uvalue)
 {
     return _PutHex8 (uvalue, m_flags.Test(eAddPrefix));
 }
 
-int
+size_t
 Stream::PutHex16 (uint16_t uvalue, ByteOrder byte_order)
 {
     if (byte_order == eByteOrderInvalid)
         byte_order = m_byte_order;
 
     bool add_prefix = m_flags.Test(eAddPrefix);
-    int bytes_written = 0;
+    size_t bytes_written = 0;
     if (byte_order == eByteOrderLittle)
     {
         for (size_t byte = 0; byte < sizeof(uvalue); ++byte, add_prefix = false)
-            bytes_written += _PutHex8 (uvalue >> (byte * 8), add_prefix);
+            bytes_written += _PutHex8 ((uint8_t)(uvalue >> (byte * 8)), add_prefix);
     }
     else
     {
         for (size_t byte = sizeof(uvalue)-1; byte < sizeof(uvalue); --byte, add_prefix = false)
-            bytes_written += _PutHex8 (uvalue >> (byte * 8), add_prefix);
+            bytes_written += _PutHex8 ((uint8_t)(uvalue >> (byte * 8)), add_prefix);
     }
     return bytes_written;
 }
 
-int
+size_t
 Stream::PutHex32(uint32_t uvalue, ByteOrder byte_order)
 {
     if (byte_order == eByteOrderInvalid)
         byte_order = m_byte_order;
 
     bool add_prefix = m_flags.Test(eAddPrefix);
-    int bytes_written = 0;
+    size_t bytes_written = 0;
     if (byte_order == eByteOrderLittle)
     {
         for (size_t byte = 0; byte < sizeof(uvalue); ++byte, add_prefix = false)
-            bytes_written += _PutHex8 (uvalue >> (byte * 8), add_prefix);
+            bytes_written += _PutHex8 ((uint8_t)(uvalue >> (byte * 8)), add_prefix);
     }
     else
     {
         for (size_t byte = sizeof(uvalue)-1; byte < sizeof(uvalue); --byte, add_prefix = false)
-            bytes_written += _PutHex8 (uvalue >> (byte * 8), add_prefix);
+            bytes_written += _PutHex8 ((uint8_t)(uvalue >> (byte * 8)), add_prefix);
     }
     return bytes_written;
 }
 
-int
+size_t
 Stream::PutHex64(uint64_t uvalue, ByteOrder byte_order)
 {
     if (byte_order == eByteOrderInvalid)
         byte_order = m_byte_order;
 
     bool add_prefix = m_flags.Test(eAddPrefix);
-    int bytes_written = 0;
+    size_t bytes_written = 0;
     if (byte_order == eByteOrderLittle)
     {
         for (size_t byte = 0; byte < sizeof(uvalue); ++byte, add_prefix = false)
-            bytes_written += _PutHex8 (uvalue >> (byte * 8), add_prefix);
+            bytes_written += _PutHex8 ((uint8_t)(uvalue >> (byte * 8)), add_prefix);
     }
     else
     {
         for (size_t byte = sizeof(uvalue)-1; byte < sizeof(uvalue); --byte, add_prefix = false)
-            bytes_written += _PutHex8 (uvalue >> (byte * 8), add_prefix);
+            bytes_written += _PutHex8 ((uint8_t)(uvalue >> (byte * 8)), add_prefix);
     }
     return bytes_written;
 }
 
-int
+size_t
 Stream::PutMaxHex64
 (
     uint64_t uvalue,
@@ -619,21 +621,21 @@ Stream::PutMaxHex64
 {
     switch (byte_size)
     {
-    case 1: return PutHex8 (uvalue);
-    case 2: return PutHex16 (uvalue);
-    case 4: return PutHex32 (uvalue);
+    case 1: return PutHex8  ((uint8_t)uvalue);
+    case 2: return PutHex16 ((uint16_t)uvalue);
+    case 4: return PutHex32 ((uint32_t)uvalue);
     case 8: return PutHex64 (uvalue);
     }
     return 0;
 }
 
-int
+size_t
 Stream::PutPointer (void *ptr)
 {
     return PutRawBytes (&ptr, sizeof(ptr), lldb::endian::InlHostByteOrder(), lldb::endian::InlHostByteOrder());
 }
 
-int
+size_t
 Stream::PutFloat(float f, ByteOrder byte_order)
 {
     if (byte_order == eByteOrderInvalid)
@@ -642,7 +644,7 @@ Stream::PutFloat(float f, ByteOrder byte
     return PutRawBytes (&f, sizeof(f), lldb::endian::InlHostByteOrder(), byte_order);
 }
 
-int
+size_t
 Stream::PutDouble(double d, ByteOrder byte_order)
 {
     if (byte_order == eByteOrderInvalid)
@@ -651,7 +653,7 @@ Stream::PutDouble(double d, ByteOrder by
     return PutRawBytes (&d, sizeof(d), lldb::endian::InlHostByteOrder(), byte_order);
 }
 
-int
+size_t
 Stream::PutLongDouble(long double ld, ByteOrder byte_order)
 {
     if (byte_order == eByteOrderInvalid)
@@ -660,7 +662,7 @@ Stream::PutLongDouble(long double ld, By
     return PutRawBytes (&ld, sizeof(ld), lldb::endian::InlHostByteOrder(), byte_order);
 }
 
-int
+size_t
 Stream::PutRawBytes (const void *s, size_t src_len, ByteOrder src_byte_order, ByteOrder dst_byte_order)
 {
     if (src_byte_order == eByteOrderInvalid)
@@ -669,7 +671,7 @@ Stream::PutRawBytes (const void *s, size
     if (dst_byte_order == eByteOrderInvalid)
         dst_byte_order = m_byte_order;
 
-    int bytes_written = 0;
+    size_t bytes_written = 0;
     const uint8_t *src = (const uint8_t *)s;
     bool binary_was_set = m_flags.Test (eBinary);
     if (!binary_was_set)
@@ -690,7 +692,7 @@ Stream::PutRawBytes (const void *s, size
     return bytes_written;
 }
 
-int
+size_t
 Stream::PutBytesAsRawHex8 (const void *s, size_t src_len, ByteOrder src_byte_order, ByteOrder dst_byte_order)
 {
     if (src_byte_order == eByteOrderInvalid)
@@ -699,7 +701,7 @@ Stream::PutBytesAsRawHex8 (const void *s
     if (dst_byte_order == eByteOrderInvalid)
         dst_byte_order = m_byte_order;
 
-    int bytes_written = 0;
+    size_t bytes_written = 0;
     const uint8_t *src = (const uint8_t *)s;
     bool binary_is_set = m_flags.Test(eBinary);
     m_flags.Clear(eBinary);
@@ -719,10 +721,10 @@ Stream::PutBytesAsRawHex8 (const void *s
     return bytes_written;
 }
 
-int
+size_t
 Stream::PutCStringAsRawHex8 (const char *s)
 {
-    int bytes_written = 0;
+    size_t bytes_written = 0;
     bool binary_is_set = m_flags.Test(eBinary);
     m_flags.Clear(eBinary);
     do

Modified: lldb/branches/lldb-platform-work/source/Core/StreamAsynchronousIO.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/lldb-platform-work/source/Core/StreamAsynchronousIO.cpp?rev=183468&r1=183467&r2=183468&view=diff
==============================================================================
--- lldb/branches/lldb-platform-work/source/Core/StreamAsynchronousIO.cpp (original)
+++ lldb/branches/lldb-platform-work/source/Core/StreamAsynchronousIO.cpp Thu Jun  6 19:06:43 2013
@@ -35,7 +35,7 @@ StreamAsynchronousIO::Flush ()
 {
     if (m_accumulated_data.GetSize() > 0)
     {
-        std::auto_ptr<EventDataBytes> data_bytes_ap (new EventDataBytes);
+        std::unique_ptr<EventDataBytes> data_bytes_ap (new EventDataBytes);
         // Let's swap the bytes to avoid LARGE string copies.
         data_bytes_ap->SwapBytes (m_accumulated_data.GetString());
         EventSP new_event_sp (new Event (m_broadcast_event_type, data_bytes_ap.release()));
@@ -44,7 +44,7 @@ StreamAsynchronousIO::Flush ()
     }
 }
 
-int
+size_t
 StreamAsynchronousIO::Write (const void *s, size_t length)
 {
     m_accumulated_data.Write (s, length);

Modified: lldb/branches/lldb-platform-work/source/Core/StreamCallback.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/lldb-platform-work/source/Core/StreamCallback.cpp?rev=183468&r1=183467&r2=183468&view=diff
==============================================================================
--- lldb/branches/lldb-platform-work/source/Core/StreamCallback.cpp (original)
+++ lldb/branches/lldb-platform-work/source/Core/StreamCallback.cpp Thu Jun  6 19:06:43 2013
@@ -35,7 +35,7 @@ StreamCallback::~StreamCallback ()
 StreamString &
 StreamCallback::FindStreamForThread(lldb::tid_t cur_tid)
 {
-    Mutex::Locker (m_collection_mutex);
+    Mutex::Locker locker(m_collection_mutex);
     collection::iterator iter = m_accumulated_data.find (cur_tid);
     if (iter == m_accumulated_data.end())
     {
@@ -55,7 +55,7 @@ StreamCallback::Flush ()
     out_stream.Clear();
 }
 
-int
+size_t
 StreamCallback::Write (const void *s, size_t length)
 {
     lldb::tid_t cur_tid = Host::GetCurrentThreadID();

Modified: lldb/branches/lldb-platform-work/source/Core/StreamFile.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/lldb-platform-work/source/Core/StreamFile.cpp?rev=183468&r1=183467&r2=183468&view=diff
==============================================================================
--- lldb/branches/lldb-platform-work/source/Core/StreamFile.cpp (original)
+++ lldb/branches/lldb-platform-work/source/Core/StreamFile.cpp Thu Jun  6 19:06:43 2013
@@ -64,7 +64,7 @@ StreamFile::Flush ()
     m_file.Flush();
 }
 
-int
+size_t
 StreamFile::Write (const void *s, size_t length)
 {
     m_file.Write (s, length);

Modified: lldb/branches/lldb-platform-work/source/Core/StreamString.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/lldb-platform-work/source/Core/StreamString.cpp?rev=183468&r1=183467&r2=183468&view=diff
==============================================================================
--- lldb/branches/lldb-platform-work/source/Core/StreamString.cpp (original)
+++ lldb/branches/lldb-platform-work/source/Core/StreamString.cpp Thu Jun  6 19:06:43 2013
@@ -34,7 +34,7 @@ StreamString::Flush ()
     // Nothing to do when flushing a buffer based stream...
 }
 
-int
+size_t
 StreamString::Write (const void *s, size_t length)
 {
     m_packet.append ((char *)s, length);

Modified: lldb/branches/lldb-platform-work/source/Core/StringList.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/lldb-platform-work/source/Core/StringList.cpp?rev=183468&r1=183467&r2=183468&view=diff
==============================================================================
--- lldb/branches/lldb-platform-work/source/Core/StringList.cpp (original)
+++ lldb/branches/lldb-platform-work/source/Core/StringList.cpp Thu Jun  6 19:06:43 2013
@@ -50,6 +50,12 @@ StringList::AppendString (const char *st
 }
 
 void
+StringList::AppendString (const std::string &s)
+{
+    m_strings.push_back (s);
+}
+
+void
 StringList::AppendString (const char *str, size_t str_len)
 {
     if (str)
@@ -69,9 +75,9 @@ StringList::AppendList (const char **str
 void
 StringList::AppendList (StringList strings)
 {
-    uint32_t len = strings.GetSize();
+    size_t len = strings.GetSize();
 
-    for (uint32_t i = 0; i < len; ++i)
+    for (size_t i = 0; i < len; ++i)
         m_strings.push_back (strings.GetStringAtIndex(i));
 }
 
@@ -81,7 +87,7 @@ StringList::ReadFileLines (FileSpec &inp
     return input_file.ReadFileLines (m_strings);
 }
 
-uint32_t
+size_t
 StringList::GetSize () const
 {
     return m_strings.size();
@@ -98,7 +104,7 @@ StringList::GetStringAtIndex (size_t idx
 void
 StringList::Join (const char *separator, Stream &strm)
 {
-    uint32_t size = GetSize();
+    size_t size = GetSize();
     
     if (size == 0)
         return;
@@ -121,8 +127,8 @@ void
 StringList::LongestCommonPrefix (std::string &common_prefix)
 {
     //arg_sstr_collection::iterator pos, end = m_args.end();
-    int pos = 0;
-    int end = m_strings.size();
+    size_t pos = 0;
+    size_t end = m_strings.size();
 
     if (pos == end)
         common_prefix.clear();
@@ -253,3 +259,32 @@ StringList::operator << (StringList stri
     AppendList(strings);
     return *this;
 }
+
+size_t
+StringList::AutoComplete (const char *s, StringList &matches, size_t &exact_idx) const
+{
+    matches.Clear();
+    exact_idx = SIZE_MAX;
+    if (s && s[0])
+    {
+        const size_t s_len = strlen (s);
+        const size_t num_strings = m_strings.size();
+        
+        for (size_t i=0; i<num_strings; ++i)
+        {
+            if (m_strings[i].find(s) == 0)
+            {
+                if (exact_idx == SIZE_MAX && m_strings[i].size() == s_len)
+                    exact_idx = matches.GetSize();
+                matches.AppendString (m_strings[i]);
+            }
+        }
+    }
+    else
+    {
+        // No string, so it matches everything
+        matches = *this;
+    }
+    return matches.GetSize();
+}
+

Modified: lldb/branches/lldb-platform-work/source/Core/Timer.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/lldb-platform-work/source/Core/Timer.cpp?rev=183468&r1=183467&r2=183468&view=diff
==============================================================================
--- lldb/branches/lldb-platform-work/source/Core/Timer.cpp (original)
+++ lldb/branches/lldb-platform-work/source/Core/Timer.cpp Thu Jun  6 19:06:43 2013
@@ -25,7 +25,7 @@ uint32_t Timer::g_depth = 0;
 uint32_t Timer::g_display_depth = 0;
 FILE * Timer::g_file = NULL;
 typedef std::vector<Timer *> TimerStack;
-typedef std::map<const char *, uint64_t> CategoryMap;
+typedef std::map<const char *, uint64_t> TimerCategoryMap;
 static pthread_key_t g_key;
 
 static Mutex &
@@ -35,10 +35,10 @@ GetCategoryMutex()
     return g_category_mutex;
 }
 
-static CategoryMap &
+static TimerCategoryMap &
 GetCategoryMap()
 {
-    static CategoryMap g_category_map;
+    static TimerCategoryMap g_category_map;
     return g_category_map;
 }
 
@@ -153,7 +153,7 @@ Timer::~Timer()
 
         // Keep total results for each category so we can dump results.
         Mutex::Locker locker (GetCategoryMutex());
-        CategoryMap &category_map = GetCategoryMap();
+        TimerCategoryMap &category_map = GetCategoryMap();
         category_map[m_category] += timer_nsec_uint;
     }
     if (g_depth > 0)
@@ -214,7 +214,7 @@ Timer::SetDisplayDepth (uint32_t depth)
  * - returns whether a person is less than another person
  */
 static bool
-CategoryMapIteratorSortCriterion (const CategoryMap::const_iterator& lhs, const CategoryMap::const_iterator& rhs)
+CategoryMapIteratorSortCriterion (const TimerCategoryMap::const_iterator& lhs, const TimerCategoryMap::const_iterator& rhs)
 {
     return lhs->second > rhs->second;
 }
@@ -224,7 +224,7 @@ void
 Timer::ResetCategoryTimes ()
 {
     Mutex::Locker locker (GetCategoryMutex());
-    CategoryMap &category_map = GetCategoryMap();
+    TimerCategoryMap &category_map = GetCategoryMap();
     category_map.clear();
 }
 
@@ -232,9 +232,9 @@ void
 Timer::DumpCategoryTimes (Stream *s)
 {
     Mutex::Locker locker (GetCategoryMutex());
-    CategoryMap &category_map = GetCategoryMap();
-    std::vector<CategoryMap::const_iterator> sorted_iterators;
-    CategoryMap::const_iterator pos, end = category_map.end();
+    TimerCategoryMap &category_map = GetCategoryMap();
+    std::vector<TimerCategoryMap::const_iterator> sorted_iterators;
+    TimerCategoryMap::const_iterator pos, end = category_map.end();
     for (pos = category_map.begin(); pos != end; ++pos)
     {
         sorted_iterators.push_back (pos);

Modified: lldb/branches/lldb-platform-work/source/Core/UUID.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/lldb-platform-work/source/Core/UUID.cpp?rev=183468&r1=183467&r2=183468&view=diff
==============================================================================
--- lldb/branches/lldb-platform-work/source/Core/UUID.cpp (original)
+++ lldb/branches/lldb-platform-work/source/Core/UUID.cpp Thu Jun  6 19:06:43 2013
@@ -14,35 +14,38 @@
 #include <ctype.h>
 
 // C++ Includes
+#include <string>
+
 // Other libraries and framework includes
 // Project includes
 #include "lldb/Core/Stream.h"
 
 namespace lldb_private {
 
-UUID::UUID()
+UUID::UUID() : m_num_uuid_bytes(16)
 {
     ::memset (m_uuid, 0, sizeof(m_uuid));
 }
 
 UUID::UUID(const UUID& rhs)
 {
+    m_num_uuid_bytes = rhs.m_num_uuid_bytes;
     ::memcpy (m_uuid, rhs.m_uuid, sizeof (m_uuid));
 }
 
 UUID::UUID (const void *uuid_bytes, uint32_t num_uuid_bytes)
 {
-    if (uuid_bytes && num_uuid_bytes >= 16)
-        ::memcpy (m_uuid, uuid_bytes, sizeof (m_uuid));
-    else
-        ::memset (m_uuid, 0, sizeof(m_uuid));
+    SetBytes (uuid_bytes, num_uuid_bytes);
 }
 
 const UUID&
 UUID::operator=(const UUID& rhs)
 {
     if (this != &rhs)
+    {
+        m_num_uuid_bytes = rhs.m_num_uuid_bytes;
         ::memcpy (m_uuid, rhs.m_uuid, sizeof (m_uuid));
+    }
     return *this;
 }
 
@@ -53,6 +56,7 @@ UUID::~UUID()
 void
 UUID::Clear()
 {
+    m_num_uuid_bytes = 16;
     ::memset (m_uuid, 0, sizeof(m_uuid));
 }
 
@@ -62,13 +66,25 @@ UUID::GetBytes() const
     return m_uuid;
 }
 
-char *
-UUID::GetAsCString (char *dst, size_t dst_len) const
+std::string
+UUID::GetAsString () const
 {
+    std::string result;
+    char buf[64];
     const uint8_t *u = (const uint8_t *)GetBytes();
-    snprintf(dst, dst_len, "%2.2X%2.2X%2.2X%2.2X-%2.2X%2.2X-%2.2X%2.2X-%2.2X%2.2X-%2.2X%2.2X%2.2X%2.2X%2.2X%2.2X",
-             u[0],u[1],u[2],u[3],u[4],u[5],u[6],u[7],u[8],u[9],u[10],u[11],u[12],u[13],u[14],u[15]);
-    return dst;
+    if (sizeof (buf) > (size_t)snprintf (buf,
+                            sizeof (buf),
+                            "%2.2X%2.2X%2.2X%2.2X-%2.2X%2.2X-%2.2X%2.2X-%2.2X%2.2X-%2.2X%2.2X%2.2X%2.2X%2.2X%2.2X",
+                            u[0],u[1],u[2],u[3],u[4],u[5],u[6],u[7],u[8],u[9],u[10],u[11],u[12],u[13],u[14],u[15]))
+    {
+        result.append (buf);
+        if (m_num_uuid_bytes == 20)
+        {
+            if (sizeof (buf) > (size_t)snprintf (buf, sizeof (buf), "-%2.2X%2.2X%2.2X%2.2X", u[16],u[17],u[18],u[19]))
+                result.append (buf);
+        }
+    }
+    return result;
 }
 
 void
@@ -77,21 +93,37 @@ UUID::Dump (Stream *s) const
     const uint8_t *u = (const uint8_t *)GetBytes();
     s->Printf ("%2.2X%2.2X%2.2X%2.2X-%2.2X%2.2X-%2.2X%2.2X-%2.2X%2.2X-%2.2X%2.2X%2.2X%2.2X%2.2X%2.2X",
               u[0],u[1],u[2],u[3],u[4],u[5],u[6],u[7],u[8],u[9],u[10],u[11],u[12],u[13],u[14],u[15]);
+    if (m_num_uuid_bytes == 20)
+    {
+        s->Printf ("-%2.2X%2.2X%2.2X%2.2X", u[16],u[17],u[18],u[19]);
+    }
 }
 
 void
-UUID::SetBytes (const void *uuid_bytes)
+UUID::SetBytes (const void *uuid_bytes, uint32_t num_uuid_bytes)
 {
-    if (uuid_bytes)
-        ::memcpy (m_uuid, uuid_bytes, sizeof (m_uuid));
+    if (uuid_bytes && num_uuid_bytes >= 20)
+    {
+        m_num_uuid_bytes = 20;
+        ::memcpy (m_uuid, uuid_bytes, m_num_uuid_bytes);
+    }
+    else if (uuid_bytes && num_uuid_bytes >= 16)
+    {
+        m_num_uuid_bytes = 16;
+        ::memcpy (m_uuid, uuid_bytes, m_num_uuid_bytes);
+        m_uuid[16] = m_uuid[17] = m_uuid[18] = m_uuid[19] = 0;
+    }
     else
+    {
+        m_num_uuid_bytes = 16;
         ::memset (m_uuid, 0, sizeof(m_uuid));
+    }
 }
 
 size_t
 UUID::GetByteSize()
 {
-    return sizeof(UUID::ValueType);
+    return m_num_uuid_bytes;
 }
 
 bool
@@ -112,7 +144,11 @@ UUID::IsValid () const
             m_uuid[12] ||
             m_uuid[13] ||
             m_uuid[14] ||
-            m_uuid[15];
+            m_uuid[15] ||
+            m_uuid[16] ||
+            m_uuid[17] ||
+            m_uuid[18] ||
+            m_uuid[19];
 }
 
 static inline int
@@ -125,50 +161,64 @@ xdigit_to_int (char ch)
 }
 
 size_t
-UUID::SetfromCString (const char *cstr)
+UUID::DecodeUUIDBytesFromCString (const char *p, ValueType &uuid_bytes, const char **end, uint32_t num_uuid_bytes)
+{
+    size_t uuid_byte_idx = 0;
+    if (p)
+    {
+        while (*p)
+        {
+            if (isxdigit(p[0]) && isxdigit(p[1]))
+            {
+                int hi_nibble = xdigit_to_int(p[0]);
+                int lo_nibble = xdigit_to_int(p[1]);
+                // Translate the two hex nibble characters into a byte
+                uuid_bytes[uuid_byte_idx] = (hi_nibble << 4) + lo_nibble;
+                
+                // Skip both hex digits
+                p += 2;
+                
+                // Increment the byte that we are decoding within the UUID value
+                // and break out if we are done
+                if (++uuid_byte_idx == num_uuid_bytes)
+                    break;
+            }
+            else if (*p == '-')
+            {
+                // Skip dashes
+                p++;
+            }
+            else
+            {
+                // UUID values can only consist of hex characters and '-' chars
+                break;
+            }
+        }
+    }
+    if (end)
+        *end = p;
+    // Clear trailing bytes to 0.
+    for (uint32_t i = uuid_byte_idx; i < sizeof(ValueType); i++)
+        uuid_bytes[i] = 0;
+    return uuid_byte_idx;
+}
+size_t
+UUID::SetFromCString (const char *cstr, uint32_t num_uuid_bytes)
 {
     if (cstr == NULL)
         return 0;
 
-    uint32_t uuid_byte_idx = 0;
     const char *p = cstr;
 
     // Skip leading whitespace characters
     while (isspace(*p))
         ++p;
+    
+    const size_t uuid_byte_idx = UUID::DecodeUUIDBytesFromCString (p, m_uuid, &p, num_uuid_bytes);
 
-    // Try and decode a UUID
-    while (*p != '\0')
-    {
-        if (isxdigit(*p) && isxdigit(p[1]))
-        {
-            int hi_nibble = xdigit_to_int(p[0]);
-            int lo_nibble = xdigit_to_int(p[1]);
-            // Translate the two hex nibble characters into a byte
-            m_uuid[uuid_byte_idx] = (hi_nibble << 4) + lo_nibble;
-
-            // Skip both hex digits
-            p += 2;
-
-            // Increment the byte that we are decoding within the UUID value
-            // and break out if we are done
-            if (++uuid_byte_idx == 16)
-                break;
-        }
-        else if (*p == '-')
-        {
-            // Skip dashes
-            p++;
-        }
-        else
-        {
-            // UUID values can only consist of hex characters and '-' chars
-            return 0;
-        }
-    }
     // If we successfully decoded a UUID, return the amount of characters that
     // were consumed
-    if (uuid_byte_idx == 16)
+    if (uuid_byte_idx == num_uuid_bytes)
         return p - cstr;
 
     // Else return zero to indicate we were not able to parse a UUID value
@@ -180,35 +230,35 @@ UUID::SetfromCString (const char *cstr)
 bool
 lldb_private::operator == (const lldb_private::UUID &lhs, const lldb_private::UUID &rhs)
 {
-    return ::memcmp (lhs.GetBytes(), rhs.GetBytes(), lldb_private::UUID::GetByteSize()) == 0;
+    return ::memcmp (lhs.GetBytes(), rhs.GetBytes(), sizeof (lldb_private::UUID::ValueType)) == 0;
 }
 
 bool
 lldb_private::operator != (const lldb_private::UUID &lhs, const lldb_private::UUID &rhs)
 {
-    return ::memcmp (lhs.GetBytes(), rhs.GetBytes(), lldb_private::UUID::GetByteSize()) != 0;
+    return ::memcmp (lhs.GetBytes(), rhs.GetBytes(), sizeof (lldb_private::UUID::ValueType)) != 0;
 }
 
 bool
 lldb_private::operator <  (const lldb_private::UUID &lhs, const lldb_private::UUID &rhs)
 {
-    return ::memcmp (lhs.GetBytes(), rhs.GetBytes(), lldb_private::UUID::GetByteSize()) <  0;
+    return ::memcmp (lhs.GetBytes(), rhs.GetBytes(), sizeof (lldb_private::UUID::ValueType)) <  0;
 }
 
 bool
 lldb_private::operator <= (const lldb_private::UUID &lhs, const lldb_private::UUID &rhs)
 {
-    return ::memcmp (lhs.GetBytes(), rhs.GetBytes(), lldb_private::UUID::GetByteSize()) <= 0;
+    return ::memcmp (lhs.GetBytes(), rhs.GetBytes(), sizeof (lldb_private::UUID::ValueType)) <= 0;
 }
 
 bool
 lldb_private::operator >  (const lldb_private::UUID &lhs, const lldb_private::UUID &rhs)
 {
-    return ::memcmp (lhs.GetBytes(), rhs.GetBytes(), lldb_private::UUID::GetByteSize()) >  0;
+    return ::memcmp (lhs.GetBytes(), rhs.GetBytes(), sizeof (lldb_private::UUID::ValueType)) >  0;
 }
 
 bool
 lldb_private::operator >= (const lldb_private::UUID &lhs, const lldb_private::UUID &rhs)
 {
-    return ::memcmp (lhs.GetBytes(), rhs.GetBytes(), lldb_private::UUID::GetByteSize()) >= 0;
+    return ::memcmp (lhs.GetBytes(), rhs.GetBytes(), sizeof (lldb_private::UUID::ValueType)) >= 0;
 }

Modified: lldb/branches/lldb-platform-work/source/Core/UserID.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/lldb-platform-work/source/Core/UserID.cpp?rev=183468&r1=183467&r2=183468&view=diff
==============================================================================
--- lldb/branches/lldb-platform-work/source/Core/UserID.cpp (original)
+++ lldb/branches/lldb-platform-work/source/Core/UserID.cpp Thu Jun  6 19:06:43 2013
@@ -10,6 +10,8 @@
 #include "lldb/Core/UserID.h"
 #include "lldb/Core/Stream.h"
 
+#include <inttypes.h>
+
 using namespace lldb;
 using namespace lldb_private;
 
@@ -20,6 +22,6 @@ UserID::~UserID ()
 Stream&
 lldb_private::operator << (Stream& strm, const UserID& uid)
 {
-    strm.Printf("{0x%8.8llx}", uid.GetID());
+    strm.Printf("{0x%8.8" PRIx64 "}", uid.GetID());
     return strm;
 }

Modified: lldb/branches/lldb-platform-work/source/Core/UserSettingsController.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/lldb-platform-work/source/Core/UserSettingsController.cpp?rev=183468&r1=183467&r2=183468&view=diff
==============================================================================
--- lldb/branches/lldb-platform-work/source/Core/UserSettingsController.cpp (original)
+++ lldb/branches/lldb-platform-work/source/Core/UserSettingsController.cpp Thu Jun  6 19:06:43 2013
@@ -7,6 +7,8 @@
 //
 //===----------------------------------------------------------------------===//
 
+#include "lldb/lldb-python.h"
+
 #include <string.h>
 #include <algorithm>
 
@@ -16,2467 +18,94 @@
 #include "lldb/Core/Stream.h"
 #include "lldb/Core/StreamString.h"
 #include "lldb/Interpreter/CommandInterpreter.h"
+#include "lldb/Interpreter/OptionValueString.h"
 
 using namespace lldb;
 using namespace lldb_private;
 
-static void
-DumpSettingEntry (CommandInterpreter &interpreter, 
-                  Stream &strm,
-                  const uint32_t max_len, 
-                  const SettingEntry &entry)
-{
-    StreamString description;
-
-    if (entry.description)
-        description.Printf ("%s", entry.description);
-    
-    if (entry.default_value && entry.default_value[0])
-        description.Printf (" (default: %s)", entry.default_value);
-    
-    interpreter.OutputFormattedHelpText (strm, 
-                                         entry.var_name, 
-                                         "--", 
-                                         description.GetData(), 
-                                         max_len);
-    
-    if (entry.enum_values && entry.enum_values[0].string_value)
-    {
-        interpreter.OutputFormattedHelpText (strm, 
-                                             "", 
-                                             "  ", 
-                                             "Enumeration values:", 
-                                             max_len);
-        for (uint32_t enum_idx=0; entry.enum_values[enum_idx].string_value != NULL; ++enum_idx)
-        {
-            description.Clear();
-            if (entry.enum_values[enum_idx].usage)
-                description.Printf ("%s = %s", 
-                                    entry.enum_values[enum_idx].string_value,
-                                    entry.enum_values[enum_idx].usage);
-            else
-                description.Printf ("%s", entry.enum_values[enum_idx].string_value);
-            interpreter.OutputFormattedHelpText (strm, 
-                                                 "", 
-                                                 "  ", 
-                                                 description.GetData(), 
-                                                 max_len);
-        }
-    }
-}
-
-UserSettingsController::UserSettingsController (const char *level_name, 
-                                                const UserSettingsControllerSP &parent) :
-    m_default_settings (),
-    m_settings (),
-    m_children (),
-    m_pending_settings (),
-    m_live_settings (),
-    m_children_mutex (Mutex::eMutexTypeNormal),
-    m_pending_settings_mutex (Mutex::eMutexTypeRecursive),
-    m_live_settings_mutex (Mutex::eMutexTypeRecursive)
-{
-    m_settings.parent = parent;
-    m_settings.level_name.SetCString (level_name);
-}
-
-UserSettingsController::~UserSettingsController ()
-{
-    Mutex::Locker locker (m_live_settings_mutex);
-    m_live_settings.clear();
-}
-
-bool
-UserSettingsController::SetGlobalVariable
-(
-    const ConstString &var_name,
-    const char *index_value,
-    const char *value,
-    const SettingEntry &entry,
-    const VarSetOperationType op,
-    Error &err
-)
-{
-    err.SetErrorString ("UserSettingsController has no global settings");
-    return false;
-}
-
-bool
-UserSettingsController::GetGlobalVariable 
-(
-    const ConstString &var_name, 
-    StringList &value,
-    Error &err
-)
-{
-    return false;
-}
-
-bool
-UserSettingsController::InitializeSettingsController (UserSettingsControllerSP &controller_sp,
-                                                      SettingEntry *global_settings,
-                                                      SettingEntry *instance_settings)
-{
-    const UserSettingsControllerSP &parent = controller_sp->GetParent ();
-    if (parent)
-        parent->RegisterChild (controller_sp);
-
-    controller_sp->CreateSettingsVector (global_settings, true);
-    controller_sp->CreateSettingsVector (instance_settings, false);
-
-    controller_sp->InitializeGlobalVariables ();
-    controller_sp->CreateDefaultInstanceSettings ();
-
-    return true;
-}
-
-void
-UserSettingsController::FinalizeSettingsController (UserSettingsControllerSP &controller_sp)
-{
-    const UserSettingsControllerSP &parent = controller_sp->GetParent ();
-    if (parent)
-        parent->RemoveChild (controller_sp);
-}
-
-void
-UserSettingsController::InitializeGlobalVariables ()
-{
-    int num_entries;
-    const char *prefix = GetLevelName().GetCString();
-
-    num_entries = m_settings.global_settings.size();
-    for (int i = 0; i < num_entries; ++i)
-    {
-        const SettingEntry &entry = m_settings.global_settings[i];
-        if (entry.default_value != NULL)
-        {
-            StreamString full_name;
-            if (prefix[0] != '\0')
-                full_name.Printf ("%s.%s", prefix, entry.var_name);
-            else
-                full_name.Printf ("%s", entry.var_name);
-            SetVariable (full_name.GetData(), entry.default_value, eVarSetOperationAssign, false, "");
-        }
-    }
-}
-
-const UserSettingsControllerSP &
-UserSettingsController::GetParent ()
-{
-    return m_settings.parent;
-}
-
-void
-UserSettingsController::RegisterChild (const UserSettingsControllerSP &child)
-{
-    Mutex::Locker locker (m_children_mutex);
-
-    // Verify child is not already in m_children.
-    size_t num_children = m_children.size();
-    for (size_t i = 0; i < num_children; ++i)
-    {
-        if (m_children[i].get() == child.get())
-            return;
-    }
-    // Add child to m_children.
-    m_children.push_back (child);
-}
-
-const ConstString &
-UserSettingsController::GetLevelName ()
-{
-    return m_settings.level_name;
-}
-
-size_t
-UserSettingsController::GetNumChildren ()
-{
-    return m_children.size();
-}
-
-const UserSettingsControllerSP
-UserSettingsController::GetChildAtIndex (size_t index)
-{
-    if (index < m_children.size())
-        return m_children[index];
-
-    UserSettingsControllerSP dummy_value;
-
-    return dummy_value;
-}
-
-const SettingEntry *
-UserSettingsController::GetGlobalEntry (const ConstString &var_name)
-{
-
-    for (int i = 0; i < m_settings.global_settings.size(); ++i)
-    {
-        const SettingEntry &entry = m_settings.global_settings[i];
-        ConstString entry_name (entry.var_name);
-        if (entry_name == var_name)
-            return &entry;
-    }
-
-    return NULL;
-}
-
-const SettingEntry *
-UserSettingsController::GetInstanceEntry (const ConstString &const_var_name)
-{
-
-    for (int i = 0; i < m_settings.instance_settings.size(); ++i)
-    {
-        SettingEntry &entry = m_settings.instance_settings[i];
-        ConstString entry_name (entry.var_name);
-        if (entry_name == const_var_name)
-            return &entry;
-    }
-
-    return NULL;
-}
-
-void
-UserSettingsController::BuildParentPrefix (std::string &parent_prefix)
-{
-    UserSettingsControllerSP parent = GetParent();
-    if (parent.get() != NULL)
-    {
-        parent->BuildParentPrefix (parent_prefix);
-        if (parent_prefix.length() > 0)
-            parent_prefix.append (".");
-    }
-    parent_prefix.append (GetLevelName().GetCString());
-}
-
-void
-UserSettingsController::RemoveChild (const UserSettingsControllerSP &child)
-{
-    Mutex::Locker locker (m_children_mutex);
-    std::vector<UserSettingsControllerSP>::iterator pos, end = m_children.end();
 
-   for (pos = m_children.begin(); pos != end; ++pos)
-   {
-      UserSettingsControllerSP entry = *pos;
-      if (entry == child)
-      {
-          m_children.erase (pos);
-          break;
-      }
-   }
+lldb::OptionValueSP
+Properties::GetPropertyValue (const ExecutionContext *exe_ctx,
+                              const char *path,
+                              bool will_modify,
+                              Error &error) const
+{
+    OptionValuePropertiesSP properties_sp (GetValueProperties ());
+    if (properties_sp)
+        return properties_sp->GetSubValue(exe_ctx, path, will_modify, error);
+    return lldb::OptionValueSP();
 }
 
 Error
-UserSettingsController::SetVariable (const char *full_dot_name, 
-                                     const char *value, 
-                                     const VarSetOperationType op,
-                                     const bool override,
-                                     const char *debugger_instance_name,
-                                     const char *index_value)
-{
-    Error err;
-    ConstString const_var_name;
-    const ConstString &default_name = InstanceSettings::GetDefaultName();
-
-    Args names;
-    if (full_dot_name )
-        names = UserSettingsController::BreakNameIntoPieces (full_dot_name);
-    int num_pieces = names.GetArgumentCount();
-
-    if (num_pieces < 1)
-    {
-        err.SetErrorStringWithFormat ("'%s' is not a valid variable name; cannot assign value", full_dot_name);
-        return err;
-    }
-
-    ConstString prefix (names.GetArgumentAtIndex (0));
-
-    if ((prefix == m_settings.level_name)
-        || (m_settings.level_name.GetLength() == 0))
-    {
-
-        if (prefix == m_settings.level_name)
-        {
-            names.Shift ();
-            num_pieces = names.GetArgumentCount();
-        }
-
-        if (num_pieces == 0)
-        {
-            err.SetErrorString ("no variable name specified, cannot assign value");
-            return err;
-        }
-        else if (num_pieces == 1)
-        {
-
-            // Must be one of the class-wide settings.
-
-            const_var_name.SetCString (names.GetArgumentAtIndex (0));
-            const SettingEntry *entry = GetGlobalEntry (const_var_name);
-            if (entry)
-            {
-                UserSettingsController::VerifyOperationForType (entry->var_type, op, const_var_name, err);
-
-                if (err.Fail())
-                    return err;
-
-                if ((value == NULL || value[0] == '\0')
-                    && (op == eVarSetOperationAssign))
-                {
-                    if (entry->var_type != eSetVarTypeEnum)
-                        value = entry->default_value;
-                    else
-                        value = entry->enum_values[0].string_value;
-                }
-                SetGlobalVariable (const_var_name, index_value, value, *entry, op, err);
-            }
-            else
-            {
-                // MIGHT be instance variable, to be for ALL instances.
-
-                entry = GetInstanceEntry (const_var_name);
-                if (entry == NULL)
-                {
-                    err.SetErrorStringWithFormat ("unable to find variable '%s.%s', cannot assign value",
-                                                  prefix.GetCString(), const_var_name.GetCString());
-                    return err;
-                }
-                else
-                {
-                    UserSettingsController::VerifyOperationForType (entry->var_type, op, const_var_name, err);
-
-                    if (err.Fail())
-                        return err;
-
-                    if ((value == NULL || value[0] == '\0')
-                        && (op == eVarSetOperationAssign))
-                    {
-                        if (entry->var_type != eSetVarTypeEnum)
-                            value = entry->default_value;
-                        else
-                            value = entry->enum_values[0].string_value;
-                    }
-
-                    if ((m_settings.level_name.GetLength() > 0)
-                        || strlen (debugger_instance_name) == 0)
-                      {
-                        // Set the default settings
-                        m_default_settings->UpdateInstanceSettingsVariable (const_var_name, index_value, value, 
-                                                                            default_name, *entry, op, err, true);
-                      }
-                    else
-                      {
-                        // We're at the Debugger level; find the correct debugger instance and set those settings
-                        StreamString tmp_name;
-                        if (debugger_instance_name[0] != '[')
-                            tmp_name.Printf ("[%s]", debugger_instance_name);
-                        else
-                            tmp_name.Printf ("%s", debugger_instance_name);
-                        ConstString dbg_name (tmp_name.GetData());
-                        InstanceSettings *dbg_settings = FindSettingsForInstance (dbg_name);
-                        if (dbg_settings)
-                            dbg_settings->UpdateInstanceSettingsVariable (const_var_name, index_value, value, dbg_name,
-                                                                          *entry, op, err, false);
-                      }
-
-                    if (override)
-                    {
-                        OverrideAllInstances (const_var_name, value, op, index_value, err);
-
-                        // Update all pending records as well.
-//                        std::map<std::string, InstanceSettingsSP>::iterator pos, end = m_pending_settings.end();
-//                        for (pos = m_pending_settings.begin(); pos != end; end++)
-//                        {
-//                            const ConstString instance_name (pos->first.c_str());
-//                            InstanceSettingsSP setting_sp = pos->second;
-//                            setting_sp->UpdateInstanceSettingsVariable (const_var_name, index_value, value, 
-//                                                                        instance_name, *entry, op, err, true);
-//                        }
-                    }
-                }
-            }
-        }
-        else
-        {
-            // Either a child's setting or an instance setting.
-
-            if (names.GetArgumentAtIndex(0)[0] == '[')
-            {
-                // An instance setting.  Supposedly.
-
-                ConstString instance_name (names.GetArgumentAtIndex (0));
-                
-                // First verify that there is only one more name.
-                
-                names.Shift();
-                
-                if (names.GetArgumentCount() != 1)
-                {
-                    err.SetErrorStringWithFormat ("invalid variable name format '%s', cannot assign value",
-                                                  full_dot_name);
-                    return err;
-                }
-                
-                // Next verify that it is a valid instance setting name.
-                
-                const_var_name.SetCString (names.GetArgumentAtIndex (0));
-                const SettingEntry *entry = GetInstanceEntry (const_var_name);
-
-                if (entry == NULL)
-                {
-                    err.SetErrorStringWithFormat ("unknown instance variable '%s', cannot assign value",
-                                                  const_var_name.GetCString());
-                    return err;
-                }
-
-                UserSettingsController::VerifyOperationForType (entry->var_type, op, const_var_name, err);
-
-                if (err.Fail())
-                    return err;
-
-                if ((value == NULL || value[0] == '\0')
-                    && (op == eVarSetOperationAssign))
-                {
-                    if (entry->var_type != eSetVarTypeEnum)
-                        value = entry->default_value;
-                    else
-                        value = entry->enum_values[0].string_value;
-                }
-
-                // Now look for existing instance with given instance name; if not found, find or create pending
-                // setting for instance with given name.
-
-                InstanceSettings *current_settings = FindSettingsForInstance (instance_name);
-
-                if (current_settings != NULL)
-                {
-                    current_settings->UpdateInstanceSettingsVariable (const_var_name, index_value, value, 
-                                                                      instance_name, *entry, op, err, false);
-
-                }
-                else
-                {
-                    // Instance does not currently exist; make or update a pending setting for it.
-                    InstanceSettingsSP current_settings_sp = PendingSettingsForInstance (instance_name);
-
-                    // Now we have a settings record, update it appropriately.
-
-                    current_settings_sp->UpdateInstanceSettingsVariable (const_var_name, index_value, value, 
-                                                                         instance_name, *entry, op, err, true);
-                    
-                    {   // Scope for mutex.
-                        Mutex::Locker locker (m_pending_settings_mutex);
-                        m_pending_settings[instance_name.GetCString()] = current_settings_sp;
-                    }
- 
-                    if (override)
-                    {
-                        OverrideAllInstances (const_var_name, value, op, index_value, err);
-                        
-                        // Update all pending records as well.
-                        std::map<std::string, InstanceSettingsSP>::iterator pos;
-                        std::map<std::string, InstanceSettingsSP>::iterator end = m_pending_settings.end();
-                        for (pos = m_pending_settings.begin(); pos != end; end++)
-                        {
-                            const ConstString tmp_inst_name (pos->first.c_str());
-                            InstanceSettingsSP setting_sp = pos->second;
-                            setting_sp->UpdateInstanceSettingsVariable (const_var_name, index_value, value, 
-                                                                        tmp_inst_name, *entry, op, err, true);
-                        }
-                    }
-                }
-            }
-            else
-            {
-                // A child setting.
-                UserSettingsControllerSP child;
-                ConstString child_prefix (names.GetArgumentAtIndex (0));
-                int num_children = GetNumChildren();
-                for (int i = 0; i < num_children; ++i)
-                {
-                    child = GetChildAtIndex (i);
-                    ConstString current_prefix = child->GetLevelName();
-                    if (current_prefix == child_prefix)
-                    {
-                        std::string new_name;
-                        for (int j = 0; j < names.GetArgumentCount(); ++j)
-                        {
-                            if (j > 0)
-                                new_name += '.';
-                            new_name += names.GetArgumentAtIndex (j);
-                        }
-                        return child->SetVariable (new_name.c_str(), value, op, override, debugger_instance_name,
-                                                   index_value);
-                    }
-                }
-                err.SetErrorStringWithFormat ("unable to find variable '%s', cannot assign value",
-                                              full_dot_name);
-                return err;
-            }
-        }
-    }
-    else
-    {
-        err.SetErrorStringWithFormat ("'%s' is not a valid level name; was expecting '%s', cannot assign value",
-                                      prefix.GetCString(), m_settings.level_name.GetCString());
-    }
-
-    return err;
-}
-
-StringList
-UserSettingsController::GetVariable 
-(
-    const char *full_dot_name, 
-    SettableVariableType &var_type, 
-    const char *debugger_instance_name,
-    Error &err
-)
-{
-    StringList value;
-    if (!full_dot_name)
-    {
-        err.SetErrorString ("invalid variable name");
-        return value;
-    }
-
-    Args names = UserSettingsController::BreakNameIntoPieces (full_dot_name);
-    int num_pieces = names.GetArgumentCount();
-
-    ConstString const_var_name;
-
-    ConstString prefix (names.GetArgumentAtIndex (0));
-    const_var_name.SetCString (names.GetArgumentAtIndex (num_pieces - 1));
-
-    const SettingEntry *global_entry = GetGlobalEntry (const_var_name);
-    const SettingEntry *instance_entry = GetInstanceEntry (const_var_name);
-
-    if ((prefix != m_settings.level_name)
-        && (m_settings.level_name.GetLength () > 0))
-    {
-        err.SetErrorString ("invalid variable name");
-        return value;
-    }
-
-    // prefix name matched; remove it from names.
-    if (m_settings.level_name.GetLength() > 0)
-        names.Shift();
-
-    // Should we pass this off to a child?  If there is more than one name piece left, and the next name piece
-    // matches a child prefix, then yes.
-
-    UserSettingsControllerSP child;
-    if (names.GetArgumentCount() > 1)
-    {
-        ConstString child_prefix (names.GetArgumentAtIndex (0));
-        for (int i = 0; i < m_children.size(); ++i)
-        {
-            if (child_prefix == m_children[i]->GetLevelName())
-            {
-                child = m_children[i];
-                std::string new_name;
-                for (int j = 0; j < names.GetArgumentCount(); ++j)
-                {
-                    if (j > 0)
-                        new_name += '.';
-                    new_name += names.GetArgumentAtIndex (j);
-                }
-                return child->GetVariable (new_name.c_str(), var_type, debugger_instance_name, err);
-            }
-        }
-
-        // Cannot be handled by a child, because name did not match any child prefixes.
-        // Cannot be a class-wide variable because there are too many name pieces.
-
-        if (instance_entry != NULL)
-        {
-            var_type = instance_entry->var_type;
-            ConstString instance_name (names.GetArgumentAtIndex (0));
-            InstanceSettings *current_settings = FindSettingsForInstance (instance_name);
-
-            if (current_settings != NULL)
-            {
-                current_settings->GetInstanceSettingsValue (*instance_entry, const_var_name, value, &err);
-            }
-            else
-            {
-                // Look for instance name setting in pending settings.
-
-                std::string inst_name_str = instance_name.GetCString();
-                std::map<std::string, InstanceSettingsSP>::iterator pos;
-
-                pos = m_pending_settings.find (inst_name_str);
-                if (pos != m_pending_settings.end())
-                {
-                    InstanceSettingsSP settings_sp = pos->second;
-                    settings_sp->GetInstanceSettingsValue (*instance_entry, const_var_name,  value, &err);
-                }
-                else 
-                {
-                    if (m_settings.level_name.GetLength() > 0)
-                    {
-                        // No valid instance name; assume they want the default settings.
-                        m_default_settings->GetInstanceSettingsValue (*instance_entry, const_var_name, value, &err);
-                    }
-                    else
-                    {
-                        // We're at the Debugger level;  use the debugger's instance settings.
-                        StreamString tmp_name;
-                        if (debugger_instance_name[0] != '[')
-                            tmp_name.Printf ("[%s]", debugger_instance_name);
-                        else
-                            tmp_name.Printf ("%s", debugger_instance_name);
-                        ConstString dbg_name (debugger_instance_name);
-                        InstanceSettings *dbg_settings = FindSettingsForInstance (dbg_name);
-                        if (dbg_settings)
-                            dbg_settings->GetInstanceSettingsValue (*instance_entry, const_var_name, value, &err);
-                    }
-                }
-            }
-        }
-        else
-            err.SetErrorString ("invalid variable name");
-    }
-    else
-    {
-        // Only one name left.  It must belong to the current level, or be an error.
-        if ((global_entry == NULL)
-            && (instance_entry == NULL))
-        {
-            err.SetErrorString ("invalid variable name");
-        }
-        else if (global_entry)
-        {
-            var_type = global_entry->var_type;
-            GetGlobalVariable (const_var_name, value, err);
-        }
-        else if (instance_entry)
-        {
-            var_type = instance_entry->var_type;
-            if (m_settings.level_name.GetLength() > 0)
-                m_default_settings->GetInstanceSettingsValue  (*instance_entry, const_var_name, value, &err);
-            else
-            {
-                // We're at the Debugger level;  use the debugger's instance settings.
-                StreamString tmp_name;
-                if (debugger_instance_name[0] != '[')
-                    tmp_name.Printf ("[%s]", debugger_instance_name);
-                else
-                    tmp_name.Printf ("%s", debugger_instance_name);
-                ConstString dbg_name (tmp_name.GetData());
-                InstanceSettings *dbg_settings = FindSettingsForInstance (dbg_name);
-                if (dbg_settings)
-                    dbg_settings->GetInstanceSettingsValue (*instance_entry, const_var_name, value, &err);
-            }
-        }
-    }
-
-    return value;
-}
-
-void
-UserSettingsController::RemovePendingSettings (const ConstString &instance_name)
-{
-    StreamString tmp_name;
-
-    // Add surrounding brackets to instance name if not already present.
-
-    if (instance_name.GetCString()[0] != '[')
-        tmp_name.Printf ("[%s]", instance_name.GetCString());
-    else
-        tmp_name.Printf ("%s", instance_name.GetCString());
-
-    std::string instance_name_str (tmp_name.GetData());
-    std::map<std::string, InstanceSettingsSP>::iterator pos;
-    Mutex::Locker locker (m_pending_settings_mutex);
-
-    m_pending_settings.erase (instance_name_str);
-}
-
-const InstanceSettingsSP &
-UserSettingsController::FindPendingSettings (const ConstString &instance_name)
-{
-    std::map<std::string, InstanceSettingsSP>::iterator pos;
-    StreamString tmp_name;
-
-    // Add surrounding brackets to instance name if not already present.
-
-    if (instance_name.GetCString()[0] != '[')
-        tmp_name.Printf ("[%s]", instance_name.GetCString());
-    else
-        tmp_name.Printf ("%s", instance_name.GetCString());
-
-    std::string instance_name_str (tmp_name.GetData());  // Need std::string for std::map look-up
-
-    {   // Scope for mutex.
-        Mutex::Locker locker (m_pending_settings_mutex);
-
-        pos = m_pending_settings.find (instance_name_str);
-        if (pos != m_pending_settings.end())
-            return pos->second;
-    }
-
-    return m_default_settings;
-}
-
-void
-UserSettingsController::CreateDefaultInstanceSettings ()
-{
-    Error err;
-    const ConstString &default_instance_name = InstanceSettings::GetDefaultName();
-    for (int i = 0; i < m_settings.instance_settings.size(); ++i)
-    {
-        SettingEntry &entry = m_settings.instance_settings[i];
-        ConstString var_name (entry.var_name);
-        const char *default_value = entry.default_value;
-
-        // If there is no default value, then use the first enumeration value
-        // as the default value
-        if (default_value == NULL && entry.var_type == eSetVarTypeEnum)
-            default_value = entry.enum_values[0].string_value;
-  
-        if (default_value != NULL)
-            m_default_settings->UpdateInstanceSettingsVariable (var_name, 
-                                                                NULL, 
-                                                                default_value, 
-                                                                default_instance_name, 
-                                                                entry, 
-                                                                eVarSetOperationAssign, 
-                                                                err, 
-                                                                true);
-    } 
-}
-
-void
-UserSettingsController::CopyDefaultSettings (const InstanceSettingsSP &actual_settings,
-                                             const ConstString &instance_name,
-                                             bool pending)
-{
-    Error err;
-    for (int i = 0; i < m_settings.instance_settings.size(); ++i)
-    {
-        SettingEntry &entry = m_settings.instance_settings[i];
-        ConstString var_name (entry.var_name);
-        StringList value;
-        m_default_settings->GetInstanceSettingsValue (entry, var_name, value, NULL);
-
-        std::string value_str;
-        if (value.GetSize() == 1)
-            value_str.append (value.GetStringAtIndex (0));
-        else if (value.GetSize() > 1)
-        {
-            for (int j = 0; j < value.GetSize(); ++j)
-            {
-                if (j > 0)
-                    value_str.append (" ");
-              value_str.append (value.GetStringAtIndex (j));
-            }
-        }
-
-        actual_settings->UpdateInstanceSettingsVariable (var_name, NULL, value_str.c_str(), instance_name, entry, 
-                                                         eVarSetOperationAssign, err, pending);
-
-    }
-}
-
-InstanceSettingsSP
-UserSettingsController::PendingSettingsForInstance (const ConstString &instance_name)
-{
-    std::string name_str (instance_name.GetCString());
-    std::map<std::string, InstanceSettingsSP>::iterator pos;
-    Mutex::Locker locker (m_pending_settings_mutex);
-
-    pos = m_pending_settings.find (name_str);
-    if (pos != m_pending_settings.end())
-    {
-        InstanceSettingsSP settings_sp = pos->second;
-        return settings_sp;
-    }
-    else
-    {
-        InstanceSettingsSP new_settings_sp = CreateInstanceSettings (instance_name.GetCString());
-        CopyDefaultSettings (new_settings_sp, instance_name, true);
-        m_pending_settings[name_str] = new_settings_sp;
-        return new_settings_sp;
-    }
-    
-    // Should never reach this line.
-
-    InstanceSettingsSP dummy;
-
-    return dummy;
-}
-
-void
-UserSettingsController::GetAllDefaultSettingValues (Stream &strm)
-{
-    std::string parent_prefix;
-    BuildParentPrefix (parent_prefix);
-
-    for (int i = 0; i < m_settings.instance_settings.size(); ++i)
-    {
-        SettingEntry &entry = m_settings.instance_settings[i];
-        ConstString var_name (entry.var_name);
-        StringList value;
-        m_default_settings->GetInstanceSettingsValue (entry, var_name, value, NULL);
-        
-        if (!parent_prefix.empty())
-            strm.Printf ("%s.", parent_prefix.c_str());
-    
-        DumpValue (var_name.GetCString(),
-                   entry.var_type,
-                   value,
-                   strm);
-    }
-}
-
-void
-UserSettingsController::GetAllPendingSettingValues (Stream &strm)
-{
-    std::map<std::string, InstanceSettingsSP>::iterator pos;
-
-    std::string parent_prefix;
-    BuildParentPrefix (parent_prefix);
-    const char *prefix = parent_prefix.c_str();
-    
-    for (pos = m_pending_settings.begin(); pos != m_pending_settings.end(); ++pos)
-    {
-        std::string tmp_name = pos->first;
-        InstanceSettingsSP settings_sp = pos->second;
-
-        const ConstString instance_name (tmp_name.c_str());
-
-        for (int i = 0; i < m_settings.instance_settings.size(); ++i)
-        {
-            SettingEntry &entry = m_settings.instance_settings[i];
-            ConstString var_name (entry.var_name);
-            StringList tmp_value;
-            settings_sp->GetInstanceSettingsValue (entry, var_name, tmp_value, NULL);
-
-            StreamString value_str;
-
-            if (tmp_value.GetSize() == 1)
-                value_str.Printf ("%s", tmp_value.GetStringAtIndex (0));
-            else
-            {
-                for (int j = 0; j < tmp_value.GetSize(); ++j)
-                    value_str.Printf  ("%s ", tmp_value.GetStringAtIndex (j));
-            }
-            
-            if (parent_prefix.length() > 0)
-            {
-                strm.Printf ("%s.%s.%s (%s) = '%s' [pending]\n", prefix, instance_name.GetCString(), 
-                                      var_name.GetCString(), UserSettingsController::GetTypeString (entry.var_type),
-                                      value_str.GetData());
-            }
-            else
-            {
-                strm.Printf ("%s (%s) = '%s' [pending]\n", var_name.GetCString(),
-                                      UserSettingsController::GetTypeString (entry.var_type), 
-                                      value_str.GetData());                                      
-            }
-        }
-    }
-}
-
-InstanceSettings *
-UserSettingsController::FindSettingsForInstance (const ConstString &instance_name)
-{
-    std::string instance_name_str (instance_name.GetCString());
-    Mutex::Locker locker (m_live_settings_mutex);
-    InstanceSettingsMap::iterator pos = m_live_settings.find (instance_name_str);
-    if (pos != m_live_settings.end ())
-        return pos->second;
-    return NULL;
-}
-
-void
-UserSettingsController::GetAllInstanceVariableValues (CommandInterpreter &interpreter,
-                                                      Stream &strm)
-{
-    std::string parent_prefix;
-    BuildParentPrefix (parent_prefix);
-    StreamString description;
-
-    Mutex::Locker locker (m_live_settings_mutex);
-    for (InstanceSettingsMap::iterator pos = m_live_settings.begin(); pos != m_live_settings.end(); ++pos)
-    {
-        std::string instance_name = pos->first;
-        InstanceSettings *settings = pos->second;
-
-        for (int i = 0; i < m_settings.instance_settings.size(); ++i)
-        {
-            SettingEntry &entry = m_settings.instance_settings[i];
-            const ConstString var_name (entry.var_name);
-            StringList tmp_value;
-            settings->GetInstanceSettingsValue (entry, var_name, tmp_value, NULL);
-            
-            if (!parent_prefix.empty())
-                strm.Printf ("%s.", parent_prefix.c_str());
-            
-            DumpValue(var_name.GetCString(), entry.var_type, tmp_value, strm);
-        }
-    }
-}
-
-void
-UserSettingsController::OverrideAllInstances (const ConstString &var_name,
-                                              const char *value,
-                                              VarSetOperationType op,
-                                              const char *index_value,
-                                              Error &err)
-{
-    StreamString description;
-
-    Mutex::Locker locker (m_live_settings_mutex);
-    for (InstanceSettingsMap::iterator pos = m_live_settings.begin(); pos != m_live_settings.end(); ++pos)
-    {
-        InstanceSettings *settings = pos->second;
-        StreamString tmp_name;
-        tmp_name.Printf ("[%s]", settings->GetInstanceName().GetCString());
-        const ConstString instance_name (tmp_name.GetData());
-        const SettingEntry *entry = GetInstanceEntry (var_name);
-        settings->UpdateInstanceSettingsVariable (var_name, index_value, value, instance_name, *entry, op, err, false);
-
-    }
+Properties::SetPropertyValue (const ExecutionContext *exe_ctx,
+                              VarSetOperationType op,
+                              const char *path,
+                              const char *value)
+{
+    OptionValuePropertiesSP properties_sp (GetValueProperties ());
+    if (properties_sp)
+        return properties_sp->SetSubValue(exe_ctx, op, path, value);
+    Error error;
+    error.SetErrorString ("no properties");
+    return error;
 }
 
 void
-UserSettingsController::RegisterInstanceSettings (InstanceSettings *instance_settings)
+Properties::DumpAllPropertyValues (const ExecutionContext *exe_ctx, Stream &strm, uint32_t dump_mask)
 {
-    Mutex::Locker locker (m_live_settings_mutex);
-    StreamString tmp_name;
-    tmp_name.Printf ("[%s]", instance_settings->GetInstanceName().GetCString());
-    const ConstString instance_name (tmp_name.GetData());
-    std::string instance_name_str (instance_name.GetCString());
-    if (instance_name_str.compare (InstanceSettings::GetDefaultName().GetCString()) != 0)
-        m_live_settings[instance_name_str] = instance_settings;
+    OptionValuePropertiesSP properties_sp (GetValueProperties ());
+    if (properties_sp)
+        return properties_sp->DumpValue (exe_ctx, strm, dump_mask);
 }
 
 void
-UserSettingsController::UnregisterInstanceSettings (InstanceSettings *instance)
+Properties::DumpAllDescriptions (CommandInterpreter &interpreter,
+                                 Stream &strm) const
 {
-    Mutex::Locker locker (m_live_settings_mutex);
-    StreamString tmp_name;
-    tmp_name.Printf ("[%s]", instance->GetInstanceName().GetCString());
-    std::string instance_name (tmp_name.GetData());
+    strm.PutCString("Top level variables:\n\n");
 
-    InstanceSettingsMap::iterator pos = m_live_settings.find (instance_name);
-    if (pos != m_live_settings.end())
-        m_live_settings.erase (pos);
+    OptionValuePropertiesSP properties_sp (GetValueProperties ());
+    if (properties_sp)
+        return properties_sp->DumpAllDescriptions (interpreter, strm);
 }
 
-void
-UserSettingsController::CreateSettingsVector (const SettingEntry *table,
-                                              bool global)
-{
-    int i = 0;
-    while (table[i].var_name != NULL)
-    {
-        const SettingEntry &table_entry = table[i];
-        ConstString const_var_name (table_entry.var_name);
-        SettingEntry new_entry;
-        
-        new_entry = table_entry;
-        new_entry.var_name = const_var_name.GetCString();
-        
-        if (global)
-            m_settings.global_settings.push_back (new_entry);
-        else
-            m_settings.instance_settings.push_back (new_entry);
-
-        ++i;
-    }
-}
 
-//----------------------------------------------------------------------
-// UserSettingsController static methods
-//----------------------------------------------------------------------
 
-int
-FindMaxNameLength (std::vector<SettingEntry> table)
+Error
+Properties::DumpPropertyValue (const ExecutionContext *exe_ctx, Stream &strm, const char *property_path, uint32_t dump_mask)
 {
-    int max_length = 1;
-
-    for (int i = 0; i < table.size(); ++i)
+    OptionValuePropertiesSP properties_sp (GetValueProperties ());
+    if (properties_sp)
     {
-        int len = strlen (table[i].var_name);
-        if (len > max_length)
-            max_length = len;
+        return properties_sp->DumpPropertyValue (exe_ctx,
+                                                 strm,
+                                                 property_path,
+                                                 dump_mask);
     }
-
-    return max_length;
+    Error error;
+    error.SetErrorString("empty property list");
+    return error;
 }
 
-const char *
-UserSettingsController::GetTypeString (SettableVariableType var_type)
+size_t
+Properties::Apropos (const char *keyword, std::vector<const Property *> &matching_properties) const
 {
-    switch (var_type)
+    OptionValuePropertiesSP properties_sp (GetValueProperties ());
+    if (properties_sp)
     {
-        case eSetVarTypeInt:
-            return "int";
-        case eSetVarTypeBoolean:
-            return "boolean";
-        case eSetVarTypeString:
-            return "string";
-        case eSetVarTypeArray:
-            return "array";
-        case eSetVarTypeDictionary:
-            return "dictionary";
-        case eSetVarTypeEnum:
-            return "enum";
-        case eSetVarTypeNone:
-            return "no type";
+        properties_sp->Apropos (keyword, matching_properties);
     }
-
-    return "";
+    return matching_properties.size();
 }
 
-void
-UserSettingsController::PrintEnumValues (const OptionEnumValueElement *enum_values, Stream &str)
-{
-    int i = 0;
-    while (enum_values[i].string_value != NULL)
-    {
-        str.Printf ("%s ", enum_values[i].string_value);
-        ++i;
-    }
-  
-}
 
-void
-UserSettingsController::FindAllSettingsDescriptions (CommandInterpreter &interpreter,
-                                                     const UserSettingsControllerSP& usc_sp, 
-                                                     const char *current_prefix, 
-                                                     Stream &strm,
-                                                     Error &err)
+lldb::OptionValuePropertiesSP
+Properties::GetSubProperty (const ExecutionContext *exe_ctx,
+                            const ConstString &name)
 {
-    // Write out current prefix line.
-    StreamString prefix_line;
-    StreamString description;
-    uint32_t max_len = FindMaxNameLength (usc_sp->m_settings.global_settings);
-    int num_entries = usc_sp->m_settings.global_settings.size();
-
-    if (current_prefix && current_prefix[0])
-        strm.Printf ("\n'%s' variables:\n\n", current_prefix);
-    else
-        strm.Printf ("\nTop level variables:\n\n");
-        
-    if (num_entries > 0)
-    {
-        // Write out all "global" variables.
-        for (int i = 0; i < num_entries; ++i)
-        {
-            DumpSettingEntry (interpreter, strm, max_len, usc_sp->m_settings.global_settings[i]);
-        }
-    }
-
-    num_entries = usc_sp->m_settings.instance_settings.size();
-    max_len = FindMaxNameLength (usc_sp->m_settings.instance_settings);
-   
-    if (num_entries > 0)
-    {
-        // Write out all instance variables.
-        for (int i = 0; i < num_entries; ++i)
-        {
-            DumpSettingEntry (interpreter, strm, max_len, usc_sp->m_settings.instance_settings[i]);
-        }
-    }
-    
-    // Now, recurse across all children.
-    int num_children = usc_sp->GetNumChildren();
-    for (int i = 0; i < num_children; ++i)
-    {
-        UserSettingsControllerSP child = usc_sp->GetChildAtIndex (i);
-        
-        if (child)
-        {
-            ConstString child_prefix = child->GetLevelName();
-            if (current_prefix && current_prefix[0])
-            {
-                StreamString new_prefix;
-                new_prefix.Printf ("%s.%s", current_prefix, child_prefix.GetCString());
-                UserSettingsController::FindAllSettingsDescriptions (interpreter, 
-                                                                     child, 
-                                                                     new_prefix.GetData(), 
-                                                                     strm, 
-                                                                     err);
-            }
-            else
-            {
-                UserSettingsController::FindAllSettingsDescriptions (interpreter, 
-                                                                     child, 
-                                                                     child_prefix.GetCString(),
-                                                                     strm, 
-                                                                     err);
-            }
-        }
-    }
+    OptionValuePropertiesSP properties_sp (GetValueProperties ());
+    if (properties_sp)
+        return properties_sp->GetSubProperty (exe_ctx, name);
+    return lldb::OptionValuePropertiesSP();
 }
 
-void
-UserSettingsController::FindSettingsDescriptions (CommandInterpreter &interpreter,
-                                                  const UserSettingsControllerSP& usc_sp,
-                                                  const char *current_prefix,
-                                                  const char *search_name,
-                                                  Stream &strm,
-                                                  Error &err)
-{
-    Args names = UserSettingsController::BreakNameIntoPieces (search_name);
-    int num_pieces = names.GetArgumentCount ();
-
-    if (num_pieces == 0)
-        return;
-
-    if (usc_sp->GetLevelName().GetLength() > 0)
-    {
-        ConstString prefix (names.GetArgumentAtIndex (0));
-        if (prefix != usc_sp->GetLevelName())
-        {
-            std::string parent_prefix;
-            usc_sp->BuildParentPrefix (parent_prefix);
-            err.SetErrorStringWithFormat ("cannot find match for '%s.%s'", parent_prefix.c_str(), 
-                                          prefix.GetCString());
-            return;
-        }
-        else
-        {
-            names.Shift();
-            --num_pieces;
-        }
-    }
-
-    // If there's nothing left then dump all global and instance descriptions for this root.
-    if (num_pieces == 0)
-    {
-        StreamString prefix_line;
-        StreamString description;
-        uint32_t max_len;
-        int num_entries = usc_sp->m_settings.global_settings.size();
-        
-        max_len = FindMaxNameLength (usc_sp->m_settings.global_settings);
-
-        strm.Printf ("\n'%s' variables:\n\n", search_name);
-        
-        if (num_entries > 0)
-        {
-            // Write out all "global" variables.
-            for (int i = 0; i < num_entries; ++i)
-            {
-                DumpSettingEntry (interpreter, strm, max_len, usc_sp->m_settings.global_settings[i]);
-            }
-        }
-        
-        num_entries = usc_sp->m_settings.instance_settings.size();
-        max_len = FindMaxNameLength (usc_sp->m_settings.instance_settings);
-        
-        if (num_entries > 0)
-        {
-            // Write out all instance variables.
-            for (int i = 0; i < num_entries; ++i)
-            {
-                DumpSettingEntry (interpreter, strm, max_len, usc_sp->m_settings.instance_settings[i]);
-            }
-        }
-    }
-    else if (num_pieces == 1)
-    {
-        ConstString var_name (names.GetArgumentAtIndex (0));
-
-        const SettingEntry *setting_entry = usc_sp->GetGlobalEntry (var_name);
-
-        if (setting_entry == NULL)
-            setting_entry = usc_sp->GetInstanceEntry (var_name);
-
-        // Check to see if it is a global or instance variable name.
-        if (setting_entry != NULL)
-        {
-            DumpSettingEntry (interpreter, strm, var_name.GetLength(), *setting_entry);
-        }
-        else
-        {
-            // It must be a child name.
-            int num_children = usc_sp->GetNumChildren();
-            bool found = false;
-            for (int i = 0; i < num_children && !found; ++i)
-            {
-                UserSettingsControllerSP child = usc_sp->GetChildAtIndex (i);
-                if (child)
-                {
-                    ConstString child_prefix = child->GetLevelName();
-                    if (child_prefix == var_name)
-                    {
-                        found = true;
-                        UserSettingsController::FindSettingsDescriptions (interpreter, 
-                                                                          child, 
-                                                                          current_prefix,
-                                                                          var_name.GetCString(), 
-                                                                          strm, 
-                                                                          err);
-                    }
-                }
-            }
-            if (!found)
-            {
-                std::string parent_prefix;
-                usc_sp->BuildParentPrefix (parent_prefix);
-                err.SetErrorStringWithFormat ("cannot find match for '%s.%s'", parent_prefix.c_str(), search_name);
-                return;
-            }
-        }
-    }
-    else
-    {
-        // It must be a child name; find the child and call this function recursively on child.
-        ConstString child_name (names.GetArgumentAtIndex (0));
-
-        StreamString rest_of_search_name;
-        for (int i = 0; i < num_pieces; ++i)
-        {
-            rest_of_search_name.Printf ("%s", names.GetArgumentAtIndex (i));
-            if ((i + 1) < num_pieces)
-                rest_of_search_name.Printf (".");
-        }
-
-        int num_children = usc_sp->GetNumChildren();
-        bool found = false;
-        for (int i = 0; i < num_children && !found; ++i)
-        {
-            UserSettingsControllerSP child = usc_sp->GetChildAtIndex (i);
-            if (child)
-            {
-                ConstString child_prefix = child->GetLevelName();
-                if (child_prefix == child_name)
-                {
-                    found = true;
-                    UserSettingsController::FindSettingsDescriptions (interpreter, child, current_prefix,
-                                                                      rest_of_search_name.GetData(), strm,
-                                                                      err);
-                }
-            }
-        }
-        if (!found)
-        {
-            std::string parent_prefix;
-            usc_sp->BuildParentPrefix (parent_prefix);
-            err.SetErrorStringWithFormat ("cannot find match for '%s.%s'", parent_prefix.c_str(), search_name);
-            return;
-        }
-    }
-}
-
-void
-UserSettingsController::SearchAllSettingsDescriptions (CommandInterpreter &interpreter,
-                                                       const UserSettingsControllerSP& usc_sp,
-                                                       const char *current_prefix,
-                                                       const char *search_word,
-                                                       Stream &strm)
-{
-    if ((search_word == NULL) || (strlen (search_word) == 0))
-        return;
-    
-    int num_entries = usc_sp->m_settings.global_settings.size();
-
-    if (num_entries > 0)
-    {
-        for (int i = 0; i < num_entries; ++i)
-        {
-            const SettingEntry &entry = usc_sp->m_settings.global_settings[i];
-            if (strcasestr (entry.description, search_word) != NULL)
-            {
-                StreamString var_name;
-                if (current_prefix && current_prefix[0])
-                    var_name.Printf ("%s.%s", current_prefix, entry.var_name);
-                else
-                    var_name.Printf ("%s", entry.var_name);
-                interpreter.OutputFormattedHelpText (strm, var_name.GetData(), "--", entry.description,
-                                                     var_name.GetSize());
-            }
-        }
-    }
-    
-    num_entries = usc_sp->m_settings.instance_settings.size();
-    if (num_entries > 0)
-    {
-        for (int i = 0; i < num_entries; ++i)
-        {
-            SettingEntry &entry = usc_sp->m_settings.instance_settings[i];
-            if (strcasestr (entry.description, search_word) != NULL)
-            {
-                StreamString var_name;
-                if (current_prefix && current_prefix[0])
-                    var_name.Printf ("%s.%s", current_prefix, entry.var_name);
-                else
-                    var_name.Printf ("%s", entry.var_name);
-                interpreter.OutputFormattedHelpText (strm, 
-                                                     var_name.GetData(),
-                                                     "--", 
-                                                     entry.description,
-                                                     var_name.GetSize());
-            }
-        }
-    }
-    
-    int num_children = usc_sp->GetNumChildren ();
-    for (int i = 0; i < num_children; ++i)
-    {
-        UserSettingsControllerSP child = usc_sp->GetChildAtIndex (i);
-        
-        if (child)
-        {
-            ConstString child_prefix = child->GetLevelName();
-            if (current_prefix && current_prefix[0])
-            {
-                StreamString new_prefix;
-                new_prefix.Printf ("%s.%s", current_prefix, child_prefix.GetCString());
-                UserSettingsController::SearchAllSettingsDescriptions (interpreter, 
-                                                                       child, 
-                                                                       new_prefix.GetData(), 
-                                                                       search_word,
-                                                                       strm);
-            }
-            else
-            {
-                UserSettingsController::SearchAllSettingsDescriptions (interpreter, 
-                                                                       child, 
-                                                                       child_prefix.GetCString(),
-                                                                       search_word,
-                                                                       strm);
-            }
-        }
-    }
-}
-
-bool
-UserSettingsController::DumpValue (CommandInterpreter &interpreter, 
-                                   const UserSettingsControllerSP& usc_sp,
-                                   const char *variable_dot_name,
-                                   Stream &strm)
-{
-    SettableVariableType var_type;
-    Error err;
-    StringList value = usc_sp->GetVariable (variable_dot_name, 
-                                            var_type,
-                                            interpreter.GetDebugger().GetInstanceName().GetCString(),
-                                            err);
-    
-    if (err.Success())
-        return DumpValue (variable_dot_name, var_type, value, strm);
-    return false;
-}
-
-
-bool
-UserSettingsController::DumpValue (const char *variable_dot_name,
-                                   SettableVariableType var_type,
-                                   const StringList &value,
-                                   Stream &strm)
-{
-    const char *type_name = UserSettingsController::GetTypeString (var_type);
-    
-    strm.Printf ("%s (%s) = ", variable_dot_name, type_name);
-    if (value.GetSize() == 0)
-    {
-        strm.EOL();
-    }
-    else
-    {
-        switch (var_type)
-        {
-            case eSetVarTypeNone:
-            case eSetVarTypeEnum:
-            case eSetVarTypeInt:
-            case eSetVarTypeBoolean:
-                strm.Printf ("%s\n", value.GetStringAtIndex (0));
-                break;
-
-            case eSetVarTypeString:
-                strm.Printf ("\"%s\"\n", value.GetStringAtIndex (0));
-                break;
-                
-            case eSetVarTypeArray:
-                {
-                    strm.EOL();
-                    for (unsigned i = 0, e = value.GetSize(); i != e; ++i)
-                        strm.Printf ("  [%u]: \"%s\"\n", i, value.GetStringAtIndex (i));
-                }
-                break;
-                
-            case eSetVarTypeDictionary:
-                {   
-                    strm.EOL();
-                    for (unsigned i = 0, e = value.GetSize(); i != e; ++i)
-                        strm.Printf ("  %s\n", value.GetStringAtIndex (i));
-                }
-                break;
-                
-            default:
-                return false;
-        }
-    }
-    return true;
-}
-
-void
-UserSettingsController::GetAllVariableValues (CommandInterpreter &interpreter,
-                                              const UserSettingsControllerSP& usc_sp,
-                                              const char *current_prefix,
-                                              Stream &strm,
-                                              Error &err)
-{
-    StreamString description;
-    int num_entries = usc_sp->m_settings.global_settings.size();
-
-    for (int i = 0; i < num_entries; ++i)
-    {
-        StreamString full_var_name;
-        const SettingEntry &entry = usc_sp->m_settings.global_settings[i];
-        
-        if (current_prefix && current_prefix[0])
-            full_var_name.Printf ("%s.%s", current_prefix, entry.var_name);
-        else
-            full_var_name.Printf ("%s", entry.var_name);
-        
-        DumpValue (interpreter, usc_sp, full_var_name.GetData(),  strm);
-    }
-
-    usc_sp->GetAllInstanceVariableValues (interpreter, strm);
-    usc_sp->GetAllPendingSettingValues (strm);
-    if (usc_sp->GetLevelName().GetLength() > 0)               // Don't bother with default values for Debugger level.
-         usc_sp->GetAllDefaultSettingValues (strm);
-
-
-    // Now, recurse across all children.
-    int num_children = usc_sp->GetNumChildren();
-    for (int i = 0; i < num_children; ++i)
-    {
-        UserSettingsControllerSP child = usc_sp->GetChildAtIndex (i);
-        
-        if (child)
-        {
-            ConstString child_prefix = child->GetLevelName();
-            if (current_prefix && current_prefix[0])
-            {
-                StreamString new_prefix;
-                new_prefix.Printf ("%s.%s", current_prefix, child_prefix.GetCString());
-                UserSettingsController::GetAllVariableValues (interpreter, 
-                                                              child, 
-                                                              new_prefix.GetData(), 
-                                                              strm, 
-                                                              err);
-            }
-            else
-            {
-                UserSettingsController::GetAllVariableValues (interpreter, 
-                                                              child, 
-                                                              child_prefix.GetCString(),
-                                                              strm, 
-                                                              err);
-            }
-        }
-    }
-
-}
-
-Args
-UserSettingsController::BreakNameIntoPieces (const char *full_dot_name)
-{
-    Args return_value;
-    std::string name_string (full_dot_name);
-    bool done = false;
-    
-    std::string piece;
-    std::string remainder (full_dot_name);
-  
-    while (!done)
-    {
-        size_t idx = remainder.find_first_of ('.');
-        piece = remainder.substr (0, idx);
-        return_value.AppendArgument (piece.c_str());
-        if (idx != std::string::npos)
-            remainder = remainder.substr (idx+1);
-        else
-            done = true;
-    }
-
-    return return_value;
-}
-
-bool
-UserSettingsController::IsLiveInstance (const std::string &instance_name)
-{
-    Mutex::Locker locker (m_live_settings_mutex);
-    InstanceSettingsMap::iterator pos = m_live_settings.find (instance_name);
-    if (pos != m_live_settings.end())
-        return true;
-    
-    return false;
-}
-
-int
-UserSettingsController::CompleteSettingsValue (const UserSettingsControllerSP& usc_sp,
-                                               const char *full_dot_name,
-                                               const char *partial_value,
-                                               bool &word_complete,
-                                               StringList &matches)
-{
-    Args names = UserSettingsController::BreakNameIntoPieces (full_dot_name);
-    int num_pieces = names.GetArgumentCount();
-    word_complete = true;
-
-    ConstString root_level = usc_sp->GetLevelName();
-    int num_extra_levels = num_pieces - 2;
-    if ((num_extra_levels > 0)
-        && root_level.GetLength() > 0)
-    {
-        ConstString current_level (names.GetArgumentAtIndex (0));
-        if (current_level == root_level)
-        {
-            names.Shift();
-            --num_extra_levels;
-        }
-        else
-            return 0;
-    }
-
-    for (int i = 0; i < num_extra_levels; ++i)
-    {
-        ConstString child_level (names.GetArgumentAtIndex (0));
-        bool found = false;
-        int num_children = usc_sp->GetNumChildren();
-        UserSettingsControllerSP child_usc_sp = usc_sp;
-        for (int j = 0; j < num_children && !found; ++j)
-        {
-            if (child_usc_sp->GetChildAtIndex (j)->GetLevelName() == child_level)
-            {
-                found = true;
-                child_usc_sp = child_usc_sp->GetChildAtIndex (j);
-                names.Shift();
-            }
-        }
-        if (!found)
-            return 0;
-    }
-
-    if (names.GetArgumentCount() != 2)
-        return 0;
-
-    std::string next_name (names.GetArgumentAtIndex (0));
-    int len = next_name.length();
-    names.Shift();
-
-    if ((next_name[0] == '[') && (next_name[len-1] == ']'))
-    {
-        // 'next_name' is instance name.  Instance names are irrelevent here.
-    }
-    else
-    {
-        // 'next_name' is child name.
-        bool found = false;
-        int num_children = usc_sp->GetNumChildren();
-        ConstString child_level (next_name.c_str());
-        UserSettingsControllerSP child_usc_sp = usc_sp;
-        for (int j = 0; j < num_children && !found; ++j)
-        {
-            if (child_usc_sp->GetChildAtIndex (j)->GetLevelName() == child_level)
-            {
-                found = true;
-                child_usc_sp = child_usc_sp->GetChildAtIndex (j);
-            }
-        }
-        if (!found)
-            return 0;
-    }
-
-    ConstString var_name (names.GetArgumentAtIndex(0));
-    const SettingEntry *entry = usc_sp->GetGlobalEntry (var_name);
-    if (entry == NULL)
-        entry = usc_sp->GetInstanceEntry (var_name);
-
-    if (entry == NULL)
-        return 0;
-
-    if (entry->var_type == eSetVarTypeBoolean)
-        return UserSettingsController::BooleanMatches (partial_value, word_complete, matches);
-    else if (entry->var_type == eSetVarTypeEnum)
-        return UserSettingsController::EnumMatches (partial_value, entry->enum_values, word_complete, matches);
-    else
-        return 0;
-}
-
-int
-UserSettingsController::BooleanMatches (const char *partial_value,
-                                        bool &word_complete,
-                                        StringList &matches)
-{
-    static const std::string true_string ("true");
-    static const std::string false_string ("false");
-
-    if (partial_value == NULL)
-    {
-        matches.AppendString ("true");
-        matches.AppendString ("false");
-    }
-    else
-    {
-        int partial_len = strlen (partial_value);
-
-        if ((partial_len <= true_string.length())
-            && (true_string.find (partial_value) == 0))
-            matches.AppendString ("true");
-        else if ((partial_len <= false_string.length())
-                 && (false_string.find (partial_value) == 0))
-            matches.AppendString ("false");
-    }
-
-    word_complete = false;
-    if (matches.GetSize() == 1)
-        word_complete = true;
-
-    return matches.GetSize();
-}
-
-int
-UserSettingsController::EnumMatches (const char *partial_value,
-                                     OptionEnumValueElement *enum_values,
-                                     bool &word_complete,
-                                     StringList &matches)
-{
-    int len = (partial_value != NULL) ? strlen (partial_value) : 0;
-
-    int i = 0;
-    while (enum_values[i].string_value != NULL)
-    {
-        if (len == 0)
-            matches.AppendString (enum_values[i].string_value);
-        else
-        {
-            std::string tmp_value (enum_values[i].string_value);
-            if ((len <= tmp_value.length())
-                && tmp_value.find (partial_value) == 0)
-              matches.AppendString (enum_values[i].string_value);
-        }
-        ++i;
-    }
-
-    word_complete = false;
-    if (matches.GetSize() == 1)
-      word_complete = true;
-
-    return matches.GetSize();
-}
-
-int
-UserSettingsController::CompleteSettingsNames (const UserSettingsControllerSP& usc_sp,
-                                               Args &partial_setting_name_pieces,
-                                               bool &word_complete,
-                                               StringList &matches)
-{
-    int num_matches = 0;
-    int num_name_pieces = partial_setting_name_pieces.GetArgumentCount();
-
-    if (num_name_pieces > 1)
-    {
-        // There are at least two pieces, perhaps with multiple level names preceding them.
-        // First traverse all the extra levels, until we have exactly two pieces left.
-        
-        int num_extra_levels = num_name_pieces - 2;
-
-        // Deal with current level first.
-
-        ConstString root_level = usc_sp->GetLevelName();
-        if ((num_extra_levels > 0)
-            && (root_level.GetLength() > 0))
-        {
-            ConstString current_level (partial_setting_name_pieces.GetArgumentAtIndex (0));
-            if (current_level == root_level)
-            {
-                partial_setting_name_pieces.Shift();
-                --num_extra_levels;
-            }
-            else
-                return 0; // The current level did not match the name pieces; something is wrong, so return immediately
-            
-        }
-
-        // The variable my_usc_sp keeps track of the user settings controller as
-        // we descend through the tree hierarchy.
-        UserSettingsControllerSP my_usc_sp = usc_sp;
-        for (int i = 0; i < num_extra_levels; ++i)
-        {
-            ConstString child_level (partial_setting_name_pieces.GetArgumentAtIndex (0));
-            bool found = false;
-            int num_children = my_usc_sp->GetNumChildren();
-
-            for (int j = 0; j < num_children && !found; ++j)
-            {
-                if (my_usc_sp->GetChildAtIndex (j)->GetLevelName() == child_level)
-                {
-                    found = true;
-                    my_usc_sp = my_usc_sp->GetChildAtIndex (j);
-                    partial_setting_name_pieces.Shift();
-                }
-            }
-            if (! found)
-            {
-                return 0; // Unable to find a matching child level name; something is wrong, so return immediately.
-            }
-        }
-
-        // Now there should be exactly two name pieces left.  If not there is an error, so return immediately
-
-        if (partial_setting_name_pieces.GetArgumentCount() != 2)
-            return 0;
-
-        std::string next_name (partial_setting_name_pieces.GetArgumentAtIndex (0));
-        int len = next_name.length();
-        partial_setting_name_pieces.Shift();
-
-        if ((next_name[0] == '[') && (next_name[len-1] == ']'))
-        {
-            // 'next_name' is an instance name.  The last name piece must be a non-empty partial match against an
-            // instance_name, assuming 'next_name' is valid.
-
-            if (my_usc_sp->IsLiveInstance (next_name))
-            {
-                std::string complete_prefix;
-                my_usc_sp->BuildParentPrefix (complete_prefix);
-
-                num_matches = my_usc_sp->InstanceVariableMatches(partial_setting_name_pieces.GetArgumentAtIndex(0),
-                                                                 complete_prefix,
-                                                                 next_name.c_str(),
-                                                                 matches);
-                word_complete = true;
-                if (num_matches > 1)
-                    word_complete = false;
-
-                return num_matches;
-            }
-            else
-                return 0;   // Invalid instance_name
-        }
-        else
-        {
-            // 'next_name' must be a child name.  Find the correct child and pass the remaining piece to be resolved.
-            int num_children = my_usc_sp->GetNumChildren();
-            ConstString child_level (next_name.c_str());
-            for (int i = 0; i < num_children; ++i)
-            {
-                if (my_usc_sp->GetChildAtIndex (i)->GetLevelName() == child_level)
-                {
-                    return UserSettingsController::CompleteSettingsNames (my_usc_sp->GetChildAtIndex (i),
-                                                                          partial_setting_name_pieces,
-                                                                          word_complete, matches);
-                }
-            }
-            return 0;
-        }
-    }
-    else if (num_name_pieces == 1)
-    {
-        std::string complete_prefix;
-        usc_sp->BuildParentPrefix (complete_prefix);
-
-        word_complete = true;
-        std::string name (partial_setting_name_pieces.GetArgumentAtIndex (0));
-
-        if (name[0] == '[')
-        {
-            // It's a partial instance name.
-
-            num_matches = usc_sp->LiveInstanceMatches (name.c_str(), complete_prefix, word_complete, matches);
-        }
-        else
-        {
-            // It could be anything *except* an instance name...
-
-            num_matches = usc_sp->GlobalVariableMatches (name.c_str(), complete_prefix, matches);
-            num_matches += usc_sp->InstanceVariableMatches (name.c_str(), complete_prefix, NULL, matches);
-            num_matches += usc_sp->ChildMatches (name.c_str(), complete_prefix, word_complete, matches);
-        }
-
-        if (num_matches > 1)
-            word_complete = false;
-
-        return num_matches;
-    }
-    else
-    {
-        // We have a user settings controller with a blank partial string.  Return everything possible at this level.
-
-        std::string complete_prefix;
-        usc_sp->BuildParentPrefix (complete_prefix);
-        num_matches = usc_sp->GlobalVariableMatches (NULL, complete_prefix, matches);
-        num_matches += usc_sp->InstanceVariableMatches (NULL, complete_prefix, NULL, matches);
-        num_matches += usc_sp->LiveInstanceMatches (NULL, complete_prefix, word_complete, matches);
-        num_matches += usc_sp->ChildMatches (NULL, complete_prefix, word_complete, matches);
-        word_complete = false;
-        return num_matches;
-    }
-
-    return num_matches;
-}
-
-int
-UserSettingsController::GlobalVariableMatches (const char *partial_name,
-                                               const std::string &complete_prefix,
-                                               StringList &matches)
-{
-    int partial_len = (partial_name != NULL) ? strlen (partial_name) : 0;
-    int num_matches = 0;
-
-    for (size_t i = 0; i < m_settings.global_settings.size(); ++i)
-    {
-        const SettingEntry &entry = m_settings.global_settings[i];
-        std::string var_name (entry.var_name);
-        if ((partial_len == 0)
-            || ((partial_len <= var_name.length())
-                && (var_name.find (partial_name) == 0)))
-        {
-            StreamString match_name;
-            if (complete_prefix.length() > 0)
-            {
-                match_name.Printf ("%s.%s", complete_prefix.c_str(), var_name.c_str());
-                matches.AppendString (match_name.GetData());
-            }
-            else
-                matches.AppendString (var_name.c_str());
-            ++num_matches;
-        }
-    }
-    return num_matches;
-}
-
-int
-UserSettingsController::InstanceVariableMatches (const char *partial_name,
-                                                 const std::string &complete_prefix,
-                                                 const char *instance_name,
-                                                 StringList &matches)
-{
-    int partial_len = (partial_name != NULL) ? strlen (partial_name) : 0;
-    int num_matches = 0;
-
-    for (size_t i = 0; i < m_settings.instance_settings.size(); ++i)
-    {
-        SettingEntry &entry = m_settings.instance_settings[i];
-        std::string var_name (entry.var_name);
-        if ((partial_len == 0)
-            || ((partial_len <= var_name.length())
-                && (var_name.find (partial_name) == 0)))
-        {
-            StreamString match_name;
-            if (complete_prefix.length() > 0)
-            {
-                if (instance_name != NULL)
-                    match_name.Printf ("%s.%s.%s", complete_prefix.c_str(), instance_name, var_name.c_str());
-                else
-                    match_name.Printf ("%s.%s", complete_prefix.c_str(), var_name.c_str());
-
-                matches.AppendString (match_name.GetData());
-            }
-            else
-            {
-                if (instance_name != NULL)
-                {
-                    match_name.Printf ("%s.%s", instance_name, var_name.c_str());
-                    matches.AppendString (match_name.GetData());
-                }
-                else
-                    matches.AppendString (var_name.c_str());
-            }
-            ++num_matches;
-        }
-    }
-    return num_matches;
-}
-
-int
-UserSettingsController::LiveInstanceMatches (const char *partial_name,
-                                             const std::string &complete_prefix,
-                                             bool &word_complete,
-                                             StringList &matches)
-{
-    int partial_len = (partial_name != NULL) ? strlen (partial_name) : 0;
-    int num_matches = 0;
-
-    InstanceSettingsMap::iterator pos;
-    Mutex::Locker locker (m_live_settings_mutex);
-    for (pos = m_live_settings.begin(); pos != m_live_settings.end(); ++pos)
-    {
-        std::string instance_name = pos->first;
-        if ((partial_len == 0)
-            || ((partial_len <= instance_name.length())
-                && (instance_name.find (partial_name) == 0)))
-        {
-            StreamString match_name;
-            if (complete_prefix.length() > 0)
-                match_name.Printf ("%s.%s.", complete_prefix.c_str(), instance_name.c_str());
-            else
-                match_name.Printf ("%s.", instance_name.c_str());
-            matches.AppendString (match_name.GetData());
-            ++num_matches;
-        }
-    }
-
-    if (num_matches > 0)
-        word_complete = false;
-
-    return num_matches;
-}
-
-int
-UserSettingsController::ChildMatches (const char *partial_name,
-                                      const std::string &complete_prefix,
-                                      bool &word_complete,
-                                      StringList &matches)
-{
-    int partial_len = (partial_name != NULL) ? strlen (partial_name) : 0;
-    int num_children = GetNumChildren();
-    int num_matches = 0;
-    for (int i = 0; i < num_children; ++i)
-    {
-        std::string child_name (GetChildAtIndex(i)->GetLevelName().GetCString());
-        StreamString match_name;
-        if ((partial_len == 0)
-          || ((partial_len <= child_name.length())
-              && (child_name.find (partial_name) == 0)))
-        {
-            if (complete_prefix.length() > 0)
-                match_name.Printf ("%s.%s.", complete_prefix.c_str(), child_name.c_str());
-            else
-                match_name.Printf ("%s.", child_name.c_str());
-            matches.AppendString (match_name.GetData());
-            ++num_matches;
-        }
-    }
-
-    if (num_matches > 0)
-        word_complete = false;
-
-    return num_matches;
-}
-
-void
-UserSettingsController::VerifyOperationForType (SettableVariableType var_type, 
-                                                VarSetOperationType op, 
-                                                const ConstString &var_name,
-                                                Error &err)
-{
-    if (op == eVarSetOperationAssign)
-        return;
-
-
-    if (op == eVarSetOperationInvalid)
-    {
-        err.SetErrorString ("invalid 'settings' subcommand operation");  
-        return;
-    }
-
-    switch (op)
-    {
-        case eVarSetOperationInsertBefore:
-        case eVarSetOperationInsertAfter:
-            if (var_type != eSetVarTypeArray)
-                err.SetErrorString ("invalid operation: this operation can only be performed on array variables");
-            break;
-        case eVarSetOperationReplace:
-        case eVarSetOperationRemove:
-            if ((var_type != eSetVarTypeArray)
-                && (var_type != eSetVarTypeDictionary))
-                err.SetErrorString ("invalid operation: this operation can only be performed on array or dictionary variables");
-            break;
-        case eVarSetOperationAppend:
-        case eVarSetOperationClear:
-            if ((var_type != eSetVarTypeArray)
-                && (var_type != eSetVarTypeDictionary)
-                && (var_type != eSetVarTypeString))
-                err.SetErrorString ("invalid operation: this operation can only be performed on array, dictionary or string variables");
-            break;
-        default:
-            break;
-    }
-
-    return;
-}
-
-void
-UserSettingsController::UpdateStringVariable (VarSetOperationType op, 
-                                              std::string &string_var, 
-                                              const char *new_value,
-                                              Error &err)
-{
-    if (op == eVarSetOperationAssign)
-    {
-        if (new_value && new_value[0])
-            string_var.assign (new_value);
-        else
-            string_var.clear();
-    }
-    else if (op == eVarSetOperationAppend)
-    {
-        if (new_value && new_value[0])
-            string_var.append (new_value);
-    }
-    else if (op == eVarSetOperationClear)
-        string_var.clear();
-    else
-        err.SetErrorString ("unrecognized operation. Cannot update value");
-}
-
-Error
-UserSettingsController::UpdateStringOptionValue (const char *value,
-                                                 VarSetOperationType op, 
-                                                 OptionValueString &option_value)
-{
-    Error error;
-    if (op == eVarSetOperationAssign)
-    {
-        option_value.SetCurrentValue (value);
-    }
-    else if (op == eVarSetOperationAppend)
-    {
-        option_value.AppendToCurrentValue (value);
-    }
-    else if (op == eVarSetOperationClear)
-    {
-        option_value.Clear();
-    }
-    else
-    {
-        error.SetErrorString ("unrecognized operation, cannot update value");
-    }
-    return error;
-}
-
-Error
-UserSettingsController::UpdateFileSpecOptionValue (const char *value,
-                                                   VarSetOperationType op, 
-                                                   OptionValueFileSpec &option_value)
-{
-    Error error;
-    if (op == eVarSetOperationAssign)
-    {
-        option_value.GetCurrentValue().SetFile (value, false);
-    }
-    else if (op == eVarSetOperationAppend)
-    {
-        char path[PATH_MAX];
-        if (option_value.GetCurrentValue().GetPath (path, sizeof(path)))
-        {
-            int path_len = ::strlen (path);
-            int value_len = ::strlen (value);
-            if (value_len + 1  > sizeof(path) - path_len)
-            {
-                error.SetErrorString("path too long.");
-            }
-            else
-            {
-                ::strncat (path, value, sizeof(path) - path_len - 1);
-                option_value.GetCurrentValue().SetFile (path, false);
-            }
-        }
-        else
-        {
-            error.SetErrorString("path too long.");
-        }
-    }
-    else if (op == eVarSetOperationClear)
-    {
-        option_value.Clear();
-    }
-    else
-    {
-        error.SetErrorString ("operation not supported for FileSpec option value type.");
-    }
-    return error;
-}
-
-
-void
-UserSettingsController::UpdateBooleanVariable (VarSetOperationType op,
-                                               bool &bool_value,
-                                               const char *value_cstr,
-                                               bool clear_value,
-                                               Error &err)
-{
-    switch (op)
-    {
-    case eVarSetOperationReplace:
-    case eVarSetOperationInsertBefore:
-    case eVarSetOperationInsertAfter:
-    case eVarSetOperationRemove:
-    case eVarSetOperationAppend:
-    case eVarSetOperationInvalid:
-    default:
-        err.SetErrorString ("invalid operation for Boolean variable, cannot update value");
-        break;
-
-    case eVarSetOperationClear:
-        err.Clear();
-        bool_value = clear_value;
-        break;
-        
-    case eVarSetOperationAssign:
-        {
-            bool success = false;
-            
-            
-            if (value_cstr == NULL)
-                err.SetErrorStringWithFormat ("invalid boolean string value (NULL)");
-            else if (value_cstr[0] == '\0')
-                err.SetErrorStringWithFormat ("invalid boolean string value (empty)");
-            else
-            {
-                bool new_value = Args::StringToBoolean (value_cstr, false, &success);
-                if (success)
-                {
-                    err.Clear();
-                    bool_value = new_value;
-                }
-                else
-                    err.SetErrorStringWithFormat ("invalid boolean string value: '%s'", value_cstr);
-            }
-        }
-        break;
-    }
-}
-Error
-UserSettingsController::UpdateBooleanOptionValue (const char *value,
-                                                  VarSetOperationType op,
-                                                  OptionValueBoolean &option_value)
-{
-    Error error;
-    switch (op)
-    {
-    case eVarSetOperationReplace:
-    case eVarSetOperationInsertBefore:
-    case eVarSetOperationInsertAfter:
-    case eVarSetOperationRemove:
-    case eVarSetOperationAppend:
-    case eVarSetOperationInvalid:
-    default:
-        error.SetErrorString ("Invalid operation for Boolean variable.  Cannot update value.\n");
-        break;
-
-    case eVarSetOperationClear:
-        option_value.Clear();
-        break;
-        
-    case eVarSetOperationAssign:
-        {
-            bool success = false;
-            error = option_value.SetValueFromCString(value);
-            
-            if (value == NULL)
-                error.SetErrorStringWithFormat ("invalid boolean string value (NULL)\n");
-            else if (value[0] == '\0')
-                error.SetErrorStringWithFormat ("invalid boolean string value (empty)\n");
-            else
-            {
-                bool new_value = Args::StringToBoolean (value, false, &success);
-                if (success)
-                {
-                    error.Clear();
-                    option_value = new_value;
-                }
-                else
-                    error.SetErrorStringWithFormat ("invalid boolean string value: '%s'\n", value);
-            }
-        }
-        break;
-    }
-    return error;
-}
-
-void
-UserSettingsController::UpdateStringArrayVariable (VarSetOperationType op, 
-                                                   const char *index_value,
-                                                   Args &array_var,
-                                                   const char *new_value,
-                                                   Error &err)
-{
-    int index = -1;
-    bool valid_index = true;
-    
-    if (index_value != NULL)
-    {
-        for (int i = 0; i < strlen(index_value); ++i)
-            if (!isdigit (index_value[i]))
-            {
-                valid_index = false;
-                err.SetErrorStringWithFormat ("'%s' is not a valid integer index, cannot update array value", 
-                                              index_value);
-            }
-                
-        if (valid_index)
-            index = atoi (index_value);
-            
-        if (index < 0
-            || index >= array_var.GetArgumentCount())
-        {
-            valid_index = false;
-            err.SetErrorStringWithFormat ("%d is outside the bounds of the specified array variable, "
-                                          "cannot update array value", index);
-        }
-    }
-
-    switch (op) 
-    {
-        case eVarSetOperationAssign:
-            array_var.SetCommandString (new_value);
-            break;
-        case eVarSetOperationReplace:
-        {
-            if (valid_index)
-                array_var.ReplaceArgumentAtIndex (index, new_value);
-            break;
-        }
-        case eVarSetOperationInsertBefore:
-        case eVarSetOperationInsertAfter:
-        {
-            if (valid_index)
-            {
-                Args new_array (new_value);
-                if (op == eVarSetOperationInsertAfter)
-                    ++index;
-                for (int i = 0; i < new_array.GetArgumentCount(); ++i)
-                    array_var.InsertArgumentAtIndex (index, new_array.GetArgumentAtIndex (i));
-            }
-            break;
-        }
-        case eVarSetOperationRemove:
-        {
-            if (valid_index)
-                array_var.DeleteArgumentAtIndex (index);
-            break;
-        }
-        case eVarSetOperationAppend:
-        {
-            Args new_array (new_value);
-            array_var.AppendArguments (new_array);
-            break;
-        }
-        case eVarSetOperationClear:
-            array_var.Clear();
-            break;
-        default:
-            err.SetErrorString ("unrecognized operation, cannot update value");
-            break;
-    }
-}
-
-void
-UserSettingsController::UpdateDictionaryVariable (VarSetOperationType op,
-                                                  const char *index_value,
-                                                  std::map<std::string, std::string> &dictionary,
-                                                  const char *new_value,
-                                                  Error &err)
-{
-    switch (op)
-    {
-        case eVarSetOperationReplace:
-            if (index_value != NULL)
-            {
-                std::string key (index_value);
-                std::map<std::string, std::string>::iterator pos;
-                
-                pos = dictionary.find (key);
-                if (pos != dictionary.end())
-                    dictionary[key] = new_value;
-                else
-                    err.SetErrorStringWithFormat ("'%s' is not an existing key; cannot replace value", index_value);
-            }
-            else
-                err.SetErrorString ("'settings replace' requires a key for dictionary variables, no key supplied");
-            break;
-        case eVarSetOperationRemove:
-            if (index_value != NULL)
-            {
-                std::string key (index_value);
-                dictionary.erase (key);
-            }
-            else
-                err.SetErrorString ("'settings remove' requires a key for dictionary variables, no key supplied");
-            break;
-        case eVarSetOperationClear:
-            dictionary.clear ();
-            break;
-        case eVarSetOperationAppend:
-        case eVarSetOperationAssign:
-            {
-                // Clear the dictionary if it's an assign with new_value as NULL.
-                if (new_value == NULL && op == eVarSetOperationAssign)
-                {
-                    dictionary.clear ();
-                    break;
-                }
-                Args args (new_value);
-                size_t num_args = args.GetArgumentCount();
-                RegularExpression regex("(\\[\"?)?"                 // Regex match 1 (optional key prefix of '["' pr '[')
-                                        "([A-Za-z_][A-Za-z_0-9]*)"  // Regex match 2 (key string)
-                                        "(\"?\\])?"                 // Regex match 3 (optional key suffix of '"]' pr ']')
-                                        "="                         // The equal sign that is required
-                                        "(.*)");                    // Regex match 4 (value string)
-                std::string key, value;
-
-                for (size_t i = 0; i < num_args; ++i)
-                {
-                    const char *key_equal_value_arg = args.GetArgumentAtIndex (i);
-                    // Execute the regular expression on each arg.
-                    if (regex.Execute(key_equal_value_arg, 5))
-                    {
-                        // The regular expression succeeded. The match at index
-                        // zero will be the entire string that matched the entire
-                        // regular expression. The match at index 1 - 4 will be
-                        // as mentioned above by the creation of the regex pattern.
-                        // Match index 2 is the key, match index 4 is the value.
-                        regex.GetMatchAtIndex (key_equal_value_arg, 2, key);
-                        regex.GetMatchAtIndex (key_equal_value_arg, 4, value);
-                        dictionary[key] = value;
-                    }
-                    else
-                    {
-                        err.SetErrorString ("invalid format for dictionary value, expected one of '[\"<key>\"]=<value>', '[<key>]=<value>', or '<key>=<value>'");
-                    }
-                }
-            }  
-            break;
-        case eVarSetOperationInsertBefore:
-        case eVarSetOperationInsertAfter:
-            err.SetErrorString ("specified operation cannot be performed on dictionary variables");
-            break;
-        default:
-            err.SetErrorString ("unrecognized operation");
-            break;
-    }
-}
-
-const char *
-UserSettingsController::EnumToString (const OptionEnumValueElement *enum_values,
-                                      int value)
-{
-    int i = 0;
-    while (enum_values[i].string_value != NULL)
-    {
-        if (enum_values[i].value == value)
-            return enum_values[i].string_value;
-        ++i;
-    }
-
-    return "";
-}
-
-
-void
-UserSettingsController::UpdateEnumVariable (OptionEnumValueElement *enum_values,
-                                            int *enum_var,
-                                            const char *new_value,
-                                            Error &error)
-{
-    *enum_var = Args::StringToOptionEnum (new_value, enum_values, enum_values[0].value, error);
-}
-
-void
-UserSettingsController::RenameInstanceSettings (const char *old_name, const char *new_name)
-{
-    Mutex::Locker live_mutex (m_live_settings_mutex);
-    Mutex::Locker pending_mutex (m_pending_settings_mutex);
-    std::string old_name_key (old_name);
-    std::string new_name_key (new_name);
-
-    // First, find the live instance settings for the old_name.  If they don't exist in the live settings
-    // list, then this is not a setting that can be renamed.
-
-    if ((old_name_key[0] != '[') || (old_name_key[old_name_key.size() -1] != ']'))
-    {
-        StreamString tmp_str;
-        tmp_str.Printf ("[%s]", old_name);
-          old_name_key = tmp_str.GetData();
-    }
-
-    if ((new_name_key[0] != '[') || (new_name_key[new_name_key.size() -1] != ']'))
-    {
-        StreamString tmp_str;
-        tmp_str.Printf ("[%s]", new_name);
-        new_name_key = tmp_str.GetData();
-    }
-
-    if (old_name_key.compare (new_name_key) == 0) 
-        return;
-
-    size_t len = new_name_key.length();
-    std::string stripped_new_name = new_name_key.substr (1, len-2);  // new name without the '[ ]'
-
-    InstanceSettingsMap::iterator pos;
-
-    pos = m_live_settings.find (old_name_key);
-    if (pos != m_live_settings.end())
-    {
-        InstanceSettings *live_settings = pos->second;
-
-        // Rename the settings.
-        live_settings->ChangeInstanceName (stripped_new_name);
-
-        // Now see if there are any pending settings for the new name; if so, copy them into live_settings.
-        std::map<std::string,  InstanceSettingsSP>::iterator pending_pos;
-        pending_pos = m_pending_settings.find (new_name_key);
-        if (pending_pos != m_pending_settings.end())
-        {
-            InstanceSettingsSP pending_settings_sp = pending_pos->second;
-            live_settings->CopyInstanceSettings (pending_settings_sp, false);
-        }
-
-        // Erase the old entry (under the old name) from live settings.
-        m_live_settings.erase (pos);
-
-        // Add the new entry, with the new name, into live settings.
-        m_live_settings[new_name_key] = live_settings;
-    }
-}
-
-//----------------------------------------------------------------------
-// class InstanceSettings
-//----------------------------------------------------------------------
-
-InstanceSettings::InstanceSettings (const UserSettingsControllerSP &owner_sp, const char *instance_name, bool live_instance) :
-    m_owner_wp (owner_sp),
-    m_instance_name (instance_name)
-{
-    if ((m_instance_name != InstanceSettings::GetDefaultName())
-        && (m_instance_name !=  InstanceSettings::InvalidName())
-        && live_instance)
-        owner_sp->RegisterInstanceSettings (this);
-}
-
-InstanceSettings::~InstanceSettings ()
-{
-    if (m_instance_name != InstanceSettings::GetDefaultName())
-    {
-        UserSettingsControllerSP owner_sp (m_owner_wp.lock());
-        if (owner_sp)
-            owner_sp->UnregisterInstanceSettings (this);
-    }
-}
-
-const ConstString &
-InstanceSettings::GetDefaultName ()
-{
-    static const ConstString g_default_settings_name ("[DEFAULT]");
-
-    return g_default_settings_name;
-}
-
-const ConstString &
-InstanceSettings::InvalidName ()
-{
-    static const ConstString g_invalid_name ("Invalid instance name");
-
-    return g_invalid_name;
-}
-
-void
-InstanceSettings::ChangeInstanceName (const std::string &new_instance_name)
-{
-    m_instance_name.SetCString (new_instance_name.c_str());
-}
-
-

Modified: lldb/branches/lldb-platform-work/source/Core/VMRange.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/lldb-platform-work/source/Core/VMRange.cpp?rev=183468&r1=183467&r2=183468&view=diff
==============================================================================
--- lldb/branches/lldb-platform-work/source/Core/VMRange.cpp (original)
+++ lldb/branches/lldb-platform-work/source/Core/VMRange.cpp Thu Jun  6 19:06:43 2013
@@ -40,7 +40,7 @@ VMRange::ContainsRange(const VMRange::co
     return false;
 }
 
-uint32_t
+size_t
 VMRange::FindRangeIndexThatContainsValue (const VMRange::collection& coll, lldb::addr_t value)
 {
     ValueInRangeUnaryPredicate in_range_predicate(value);

Modified: lldb/branches/lldb-platform-work/source/Core/Value.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/lldb-platform-work/source/Core/Value.cpp?rev=183468&r1=183467&r2=183468&view=diff
==============================================================================
--- lldb/branches/lldb-platform-work/source/Core/Value.cpp (original)
+++ lldb/branches/lldb-platform-work/source/Core/Value.cpp Thu Jun  6 19:06:43 2013
@@ -128,7 +128,7 @@ Value::GetValueAddressType () const
 }
 
 RegisterInfo *
-Value::GetRegisterInfo()
+Value::GetRegisterInfo() const
 {
     if (m_context_type == eContextTypeRegisterInfo)
         return static_cast<RegisterInfo *> (m_context);
@@ -144,7 +144,7 @@ Value::GetType()
 }
 
 void
-Value::ResizeData(int len)
+Value::ResizeData(size_t len)
 {
     m_value_type = eValueTypeHostAddress;
     m_data_buffer.SetByteSize(len);
@@ -156,7 +156,6 @@ Value::ValueOf(ExecutionContext *exe_ctx
 {
     switch (m_context_type)
     {
-    default:
     case eContextTypeInvalid:
     case eContextTypeClangType:         // clang::Type *
     case eContextTypeRegisterInfo:      // RegisterInfo *
@@ -170,14 +169,13 @@ Value::ValueOf(ExecutionContext *exe_ctx
     return false;
 }
 
-size_t
+uint64_t
 Value::GetValueByteSize (clang::ASTContext *ast_context, Error *error_ptr)
 {
-    size_t byte_size = 0;
+    uint64_t byte_size = 0;
 
     switch (m_context_type)
     {
-    default:
     case eContextTypeInvalid:
         // If we have no context, there is no way to know how much memory to read
         if (error_ptr)
@@ -192,8 +190,7 @@ Value::GetValueByteSize (clang::ASTConte
         }
         else
         {
-            uint64_t bit_width = ClangASTType::GetClangTypeBitWidth (ast_context, m_context);
-            byte_size = (bit_width + 7 ) / 8;
+            byte_size = ClangASTType(ast_context, m_context).GetClangTypeByteSize();
         }
         break;
 
@@ -201,8 +198,7 @@ Value::GetValueByteSize (clang::ASTConte
         if (GetRegisterInfo())
             byte_size = GetRegisterInfo()->byte_size;
         else if (error_ptr)
-                error_ptr->SetErrorString ("Can't determine byte size with NULL RegisterInfo *.");
-
+            error_ptr->SetErrorString ("Can't determine byte size with NULL RegisterInfo *.");
         break;
 
     case eContextTypeLLDBType:             // Type *
@@ -245,7 +241,6 @@ Value::GetClangType ()
 {
     switch (m_context_type)
     {
-    default:
     case eContextTypeInvalid:
         break;
 
@@ -274,7 +269,6 @@ Value::GetValueDefaultFormat ()
 {
     switch (m_context_type)
     {
-    default:
     case eContextTypeInvalid:
         break;
 
@@ -331,7 +325,7 @@ Value::GetData (DataExtractor &data)
 }
 
 Error
-Value::GetValueAsData (ExecutionContext *exe_ctx, 
+Value::GetValueAsData (ExecutionContext *exe_ctx,
                        clang::ASTContext *ast_context, 
                        DataExtractor &data, 
                        uint32_t data_offset,
@@ -345,17 +339,24 @@ Value::GetValueAsData (ExecutionContext
     Address file_so_addr;
     switch (m_value_type)
     {
-    default:
-        error.SetErrorStringWithFormat("invalid value type %i", m_value_type);
+    case eValueTypeVector:
+        if (m_context_type == eContextTypeClangType && ast_context)
+        {
+            ClangASTType ptr_type (ast_context, ClangASTContext::GetVoidPtrType(ast_context, false));
+            uint64_t ptr_byte_size = ptr_type.GetClangTypeByteSize();
+            data.SetAddressByteSize (ptr_byte_size);
+        }
+        else
+            data.SetAddressByteSize(sizeof(void *));
+        data.SetData(m_vector.bytes, m_vector.length, m_vector.byte_order);
         break;
 
     case eValueTypeScalar:
         data.SetByteOrder (lldb::endian::InlHostByteOrder());
         if (m_context_type == eContextTypeClangType && ast_context)
         {
-            uint32_t ptr_bit_width = ClangASTType::GetClangTypeBitWidth (ast_context, 
-                                                                     ClangASTContext::GetVoidPtrType(ast_context, false));
-            uint32_t ptr_byte_size = (ptr_bit_width + 7) / 8;
+            ClangASTType ptr_type (ast_context, ClangASTContext::GetVoidPtrType(ast_context, false));
+            uint64_t ptr_byte_size = ptr_type.GetClangTypeByteSize();
             data.SetAddressByteSize (ptr_byte_size);
         }
         else
@@ -373,9 +374,54 @@ Value::GetValueAsData (ExecutionContext
         else 
         {
             Process *process = exe_ctx->GetProcessPtr();
-            if (process == NULL)
+            if (process == NULL || !process->IsAlive())
             {
-                error.SetErrorString ("can't read load address (invalid process)");
+                Target *target = exe_ctx->GetTargetPtr();
+                if (target)
+                {
+                    // Allow expressions to run and evaluate things when the target
+                    // has memory sections loaded. This allows you to use "target modules load"
+                    // to load your executable and any shared libraries, then execute
+                    // commands where you can look at types in data sections.
+                    const SectionLoadList &target_sections = target->GetSectionLoadList();
+                    if (!target_sections.IsEmpty())
+                    {
+                        address = m_value.ULongLong(LLDB_INVALID_ADDRESS);
+                        if (target_sections.ResolveLoadAddress(address, file_so_addr))
+                        {
+                            address_type = eAddressTypeLoad;
+                            data.SetByteOrder(target->GetArchitecture().GetByteOrder());
+                            data.SetAddressByteSize(target->GetArchitecture().GetAddressByteSize());
+                        }
+                        else
+                            address = LLDB_INVALID_ADDRESS;
+                    }
+//                    else
+//                    {
+//                        ModuleSP exe_module_sp (target->GetExecutableModule());
+//                        if (exe_module_sp)
+//                        {
+//                            address = m_value.ULongLong(LLDB_INVALID_ADDRESS);
+//                            if (address != LLDB_INVALID_ADDRESS)
+//                            {
+//                                if (exe_module_sp->ResolveFileAddress(address, file_so_addr))
+//                                {
+//                                    data.SetByteOrder(target->GetArchitecture().GetByteOrder());
+//                                    data.SetAddressByteSize(target->GetArchitecture().GetAddressByteSize());
+//                                    address_type = eAddressTypeFile;
+//                                }
+//                                else
+//                                {
+//                                    address = LLDB_INVALID_ADDRESS;
+//                                }
+//                            }
+//                        }
+//                    }
+                }
+                else
+                {
+                    error.SetErrorString ("can't read load address (invalid process)");
+                }
             }
             else
             {
@@ -456,27 +502,23 @@ Value::GetValueAsData (ExecutionContext
                         if (module)
                         {
                             if (variable)
-                                error.SetErrorStringWithFormat ("unable to resolve the module for file address 0x%llx for variable '%s' in %s%s%s", 
+                                error.SetErrorStringWithFormat ("unable to resolve the module for file address 0x%" PRIx64 " for variable '%s' in %s",
                                                                 address, 
                                                                 variable->GetName().AsCString(""),
-                                                                module->GetFileSpec().GetDirectory().GetCString(),
-                                                                module->GetFileSpec().GetDirectory() ? "/" : "",
-                                                                module->GetFileSpec().GetFilename().GetCString());
+                                                                module->GetFileSpec().GetPath().c_str());
                             else
-                                error.SetErrorStringWithFormat ("unable to resolve the module for file address 0x%llx in %s%s%s", 
+                                error.SetErrorStringWithFormat ("unable to resolve the module for file address 0x%" PRIx64 " in %s",
                                                                 address, 
-                                                                module->GetFileSpec().GetDirectory().GetCString(),
-                                                                module->GetFileSpec().GetDirectory() ? "/" : "",
-                                                                module->GetFileSpec().GetFilename().GetCString());
+                                                                module->GetFileSpec().GetPath().c_str());
                         }
                         else
                         {
                             if (variable)
-                                error.SetErrorStringWithFormat ("unable to resolve the module for file address 0x%llx for variable '%s'", 
+                                error.SetErrorStringWithFormat ("unable to resolve the module for file address 0x%" PRIx64 " for variable '%s'",
                                                                 address, 
                                                                 variable->GetName().AsCString(""));
                             else
-                                error.SetErrorStringWithFormat ("unable to resolve the module for file address 0x%llx", address);
+                                error.SetErrorStringWithFormat ("unable to resolve the module for file address 0x%" PRIx64, address);
                         }
                     }
                 }
@@ -520,7 +562,7 @@ Value::GetValueAsData (ExecutionContext
     }
 
     // If we got here, we need to read the value from memory
-    uint32_t byte_size = GetValueByteSize (ast_context, &error);
+    size_t byte_size = GetValueByteSize (ast_context, &error);
 
     // Bail if we encountered any errors getting the byte size
     if (error.Fail())
@@ -555,7 +597,7 @@ Value::GetValueAsData (ExecutionContext
                 const bool prefer_file_cache = false;
                 if (exe_ctx->GetTargetRef().ReadMemory(file_so_addr, prefer_file_cache, dst, byte_size, error) != byte_size)
                 {
-                    error.SetErrorStringWithFormat("read memory from 0x%llx failed", (uint64_t)address);
+                    error.SetErrorStringWithFormat("read memory from 0x%" PRIx64 " failed", (uint64_t)address);
                 }
             }
             else
@@ -570,14 +612,14 @@ Value::GetValueAsData (ExecutionContext
                 {
                     const size_t bytes_read = process->ReadMemory(address, dst, byte_size, error);
                     if (bytes_read != byte_size)
-                        error.SetErrorStringWithFormat("read memory from 0x%llx failed (%u of %u bytes read)", 
+                        error.SetErrorStringWithFormat("read memory from 0x%" PRIx64 " failed (%u of %u bytes read)",
                                                        (uint64_t)address, 
                                                        (uint32_t)bytes_read, 
                                                        (uint32_t)byte_size);
                 }
                 else
                 {
-                    error.SetErrorStringWithFormat("read memory from 0x%llx failed (invalid process)", (uint64_t)address);                    
+                    error.SetErrorStringWithFormat("read memory from 0x%" PRIx64 " failed (invalid process)", (uint64_t)address);
                 }
             }
         }
@@ -607,16 +649,13 @@ Value::ResolveValue(ExecutionContext *ex
 
         default:
         case eValueTypeFileAddress:
-            m_value.Clear();
-            break;
-
         case eValueTypeLoadAddress:          // load address value
         case eValueTypeHostAddress:          // host address value (for memory in the process that is using liblldb)
             {
-                AddressType address_type = m_value_type == eValueTypeLoadAddress ? eAddressTypeLoad : eAddressTypeHost;
-                lldb::addr_t addr = m_value.ULongLong(LLDB_INVALID_ADDRESS);
                 DataExtractor data;
-                if (ClangASTType::ReadFromMemory (ast_context, opaque_clang_qual_type, exe_ctx, addr, address_type, data))
+                lldb::addr_t addr = m_value.ULongLong(LLDB_INVALID_ADDRESS);
+                Error error (GetValueAsData (exe_ctx, ast_context, data, 0, NULL));
+                if (error.Success())
                 {
                     Scalar scalar;
                     if (ClangASTType::GetValueAsScalar (ast_context, opaque_clang_qual_type, data, 0, data.GetByteSize(), scalar))
@@ -662,6 +701,7 @@ Value::GetValueTypeAsCString (ValueType
     switch (value_type)
     {
     case eValueTypeScalar:      return "scalar";
+    case eValueTypeVector:      return "vector";
     case eValueTypeFileAddress: return "file address";
     case eValueTypeLoadAddress: return "load address";
     case eValueTypeHostAddress: return "host address";

Modified: lldb/branches/lldb-platform-work/source/Core/ValueObject.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/lldb-platform-work/source/Core/ValueObject.cpp?rev=183468&r1=183467&r2=183468&view=diff
==============================================================================
--- lldb/branches/lldb-platform-work/source/Core/ValueObject.cpp (original)
+++ lldb/branches/lldb-platform-work/source/Core/ValueObject.cpp Thu Jun  6 19:06:43 2013
@@ -7,6 +7,8 @@
 //
 //===----------------------------------------------------------------------===//
 
+#include "lldb/lldb-python.h"
+
 #include "lldb/Core/ValueObject.h"
 
 // C Includes
@@ -19,10 +21,11 @@
 
 // Project includes
 #include "lldb/Core/DataBufferHeap.h"
-#include "lldb/Core/DataVisualization.h"
 #include "lldb/Core/Debugger.h"
 #include "lldb/Core/Log.h"
+#include "lldb/Core/Module.h"
 #include "lldb/Core/StreamString.h"
+#include "lldb/Core/ValueObjectCast.h"
 #include "lldb/Core/ValueObjectChild.h"
 #include "lldb/Core/ValueObjectConstResult.h"
 #include "lldb/Core/ValueObjectDynamicValue.h"
@@ -30,6 +33,8 @@
 #include "lldb/Core/ValueObjectMemory.h"
 #include "lldb/Core/ValueObjectSyntheticFilter.h"
 
+#include "lldb/DataFormatters/DataVisualization.h"
+
 #include "lldb/Host/Endian.h"
 
 #include "lldb/Interpreter/CommandInterpreter.h"
@@ -47,8 +52,6 @@
 #include "lldb/Target/Target.h"
 #include "lldb/Target/Thread.h"
 
-#include "lldb/Utility/RefCounter.h"
-
 using namespace lldb;
 using namespace lldb_private;
 using namespace lldb_utility;
@@ -61,6 +64,7 @@ static user_id_t g_value_obj_uid = 0;
 ValueObject::ValueObject (ValueObject &parent) :
     UserID (++g_value_obj_uid), // Unique identifier for every value object
     m_parent (&parent),
+    m_root (NULL),
     m_update_point (parent.GetUpdatePoint ()),
     m_name (),
     m_data (),
@@ -78,8 +82,8 @@ ValueObject::ValueObject (ValueObject &p
     m_synthetic_value(NULL),
     m_deref_valobj(NULL),
     m_format (eFormatDefault),
+    m_last_format (eFormatDefault),
     m_last_format_mgr_revision(0),
-    m_last_format_mgr_dynamic(parent.m_last_format_mgr_dynamic),
     m_type_summary_sp(),
     m_type_format_sp(),
     m_synthetic_children_sp(),
@@ -92,7 +96,6 @@ ValueObject::ValueObject (ValueObject &p
     m_is_deref_of_parent (false),
     m_is_array_item_for_pointer(false),
     m_is_bitfield_for_scalar(false),
-    m_is_expression_path_child(false),
     m_is_child_at_offset(false),
     m_is_getting_summary(false),
     m_did_calculate_complete_objc_class_type(false)
@@ -107,6 +110,7 @@ ValueObject::ValueObject (ExecutionConte
                           AddressType child_ptr_or_ref_addr_type) :
     UserID (++g_value_obj_uid), // Unique identifier for every value object
     m_parent (NULL),
+    m_root (NULL),
     m_update_point (exe_scope),
     m_name (),
     m_data (),
@@ -124,8 +128,8 @@ ValueObject::ValueObject (ExecutionConte
     m_synthetic_value(NULL),
     m_deref_valobj(NULL),
     m_format (eFormatDefault),
+    m_last_format (eFormatDefault),
     m_last_format_mgr_revision(0),
-    m_last_format_mgr_dynamic(eNoDynamicValues),
     m_type_summary_sp(),
     m_type_format_sp(),
     m_synthetic_children_sp(),
@@ -138,7 +142,6 @@ ValueObject::ValueObject (ExecutionConte
     m_is_deref_of_parent (false),
     m_is_array_item_for_pointer(false),
     m_is_bitfield_for_scalar(false),
-    m_is_expression_path_child(false),
     m_is_child_at_offset(false),
     m_is_getting_summary(false),
     m_did_calculate_complete_objc_class_type(false)
@@ -157,17 +160,11 @@ ValueObject::~ValueObject ()
 bool
 ValueObject::UpdateValueIfNeeded (bool update_format)
 {
-    return UpdateValueIfNeeded(m_last_format_mgr_dynamic, update_format);
-}
-
-bool
-ValueObject::UpdateValueIfNeeded (DynamicValueType use_dynamic, bool update_format)
-{
     
     bool did_change_formats = false;
     
     if (update_format)
-        did_change_formats = UpdateFormatsIfNeeded(use_dynamic);
+        did_change_formats = UpdateFormatsIfNeeded();
     
     // If this is a constant value, then our success is predicated on whether
     // we have an error or not
@@ -234,28 +231,27 @@ ValueObject::UpdateValueIfNeeded (Dynami
 }
 
 bool
-ValueObject::UpdateFormatsIfNeeded(DynamicValueType use_dynamic)
+ValueObject::UpdateFormatsIfNeeded()
 {
-    LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_TYPES));
+    Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_TYPES));
     if (log)
-        log->Printf("checking for FormatManager revisions. VO named %s is at revision %d, while the format manager is at revision %d",
+        log->Printf("[%s %p] checking for FormatManager revisions. ValueObject rev: %d - Global rev: %d",
            GetName().GetCString(),
+           this,
            m_last_format_mgr_revision,
            DataVisualization::GetCurrentRevision());
     
     bool any_change = false;
     
-    if ( (m_last_format_mgr_revision != DataVisualization::GetCurrentRevision()) ||
-          m_last_format_mgr_dynamic != use_dynamic)
+    if ( (m_last_format_mgr_revision != DataVisualization::GetCurrentRevision()))
     {
         SetValueFormat(DataVisualization::ValueFormats::GetFormat (*this, eNoDynamicValues));
-        SetSummaryFormat(DataVisualization::GetSummaryFormat (*this, use_dynamic));
+        SetSummaryFormat(DataVisualization::GetSummaryFormat (*this, GetDynamicValueType()));
 #ifndef LLDB_DISABLE_PYTHON
-        SetSyntheticChildren(DataVisualization::GetSyntheticChildren (*this, use_dynamic));
+        SetSyntheticChildren(DataVisualization::GetSyntheticChildren (*this, GetDynamicValueType()));
 #endif
 
         m_last_format_mgr_revision = DataVisualization::GetCurrentRevision();
-        m_last_format_mgr_dynamic = use_dynamic;
         
         any_change = true;
     }
@@ -273,6 +269,17 @@ ValueObject::SetNeedsUpdate ()
     ClearUserVisibleData(eClearUserVisibleDataItemsValue);
 }
 
+void
+ValueObject::ClearDynamicTypeInformation ()
+{
+    m_did_calculate_complete_objc_class_type = false;
+    m_last_format_mgr_revision = 0;
+    m_override_type = ClangASTType();
+    SetValueFormat(lldb::TypeFormatImplSP());
+    SetSummaryFormat(lldb::TypeSummaryImplSP());
+    SetSyntheticChildren(lldb::SyntheticChildrenSP());
+}
+
 ClangASTType
 ValueObject::MaybeCalculateCompleteType ()
 {
@@ -396,39 +403,49 @@ ValueObject::GetName() const
 const char *
 ValueObject::GetLocationAsCString ()
 {
+    return GetLocationAsCStringImpl(m_value,
+                                    m_data);
+}
+
+const char *
+ValueObject::GetLocationAsCStringImpl (const Value& value,
+                                       const DataExtractor& data)
+{
     if (UpdateValueIfNeeded(false))
     {
         if (m_location_str.empty())
         {
             StreamString sstr;
-
-            switch (m_value.GetValueType())
+            
+            Value::ValueType value_type = value.GetValueType();
+            
+            switch (value_type)
             {
-            default:
-                break;
-
             case Value::eValueTypeScalar:
-                if (m_value.GetContextType() == Value::eContextTypeRegisterInfo)
+            case Value::eValueTypeVector:
+                if (value.GetContextType() == Value::eContextTypeRegisterInfo)
                 {
-                    RegisterInfo *reg_info = m_value.GetRegisterInfo();
+                    RegisterInfo *reg_info = value.GetRegisterInfo();
                     if (reg_info)
                     {
                         if (reg_info->name)
                             m_location_str = reg_info->name;
                         else if (reg_info->alt_name)
                             m_location_str = reg_info->alt_name;
-                        break;
+                        if (m_location_str.empty())
+                            m_location_str = (reg_info->encoding == lldb::eEncodingVector) ? "vector" : "scalar";
                     }
                 }
-                m_location_str = "scalar";
+                if (m_location_str.empty())
+                    m_location_str = (value_type == Value::eValueTypeVector) ? "vector" : "scalar";
                 break;
 
             case Value::eValueTypeLoadAddress:
             case Value::eValueTypeFileAddress:
             case Value::eValueTypeHostAddress:
                 {
-                    uint32_t addr_nibble_size = m_data.GetAddressByteSize() * 2;
-                    sstr.Printf("0x%*.*llx", addr_nibble_size, addr_nibble_size, m_value.GetScalar().ULongLong(LLDB_INVALID_ADDRESS));
+                    uint32_t addr_nibble_size = data.GetAddressByteSize() * 2;
+                    sstr.Printf("0x%*.*llx", addr_nibble_size, addr_nibble_size, value.GetScalar().ULongLong(LLDB_INVALID_ADDRESS));
                     m_location_str.swap(sstr.GetString());
                 }
                 break;
@@ -496,7 +513,7 @@ ValueObject::SetValueDidChange (bool val
 }
 
 ValueObjectSP
-ValueObject::GetChildAtIndex (uint32_t idx, bool can_create)
+ValueObject::GetChildAtIndex (size_t idx, bool can_create)
 {
     ValueObjectSP child_sp;
     // We may need to update our value if we are dynamic
@@ -519,7 +536,87 @@ ValueObject::GetChildAtIndex (uint32_t i
     return child_sp;
 }
 
-uint32_t
+ValueObjectSP
+ValueObject::GetChildAtIndexPath (const std::initializer_list<size_t>& idxs,
+                                  size_t* index_of_error)
+{
+    if (idxs.size() == 0)
+        return GetSP();
+    ValueObjectSP root(GetSP());
+    for (size_t idx : idxs)
+    {
+        root = root->GetChildAtIndex(idx, true);
+        if (!root)
+        {
+            if (index_of_error)
+                *index_of_error = idx;
+            return root;
+        }
+    }
+    return root;
+}
+
+ValueObjectSP
+ValueObject::GetChildAtIndexPath (const std::initializer_list< std::pair<size_t, bool> >& idxs,
+                                  size_t* index_of_error)
+{
+    if (idxs.size() == 0)
+        return GetSP();
+    ValueObjectSP root(GetSP());
+    for (std::pair<size_t, bool> idx : idxs)
+    {
+        root = root->GetChildAtIndex(idx.first, idx.second);
+        if (!root)
+        {
+            if (index_of_error)
+                *index_of_error = idx.first;
+            return root;
+        }
+    }
+    return root;
+}
+
+lldb::ValueObjectSP
+ValueObject::GetChildAtIndexPath (const std::vector<size_t> &idxs,
+                                  size_t* index_of_error)
+{
+    if (idxs.size() == 0)
+        return GetSP();
+    ValueObjectSP root(GetSP());
+    for (size_t idx : idxs)
+    {
+        root = root->GetChildAtIndex(idx, true);
+        if (!root)
+        {
+            if (index_of_error)
+                *index_of_error = idx;
+            return root;
+        }
+    }
+    return root;
+}
+
+lldb::ValueObjectSP
+ValueObject::GetChildAtIndexPath (const std::vector< std::pair<size_t, bool> > &idxs,
+                                  size_t* index_of_error)
+{
+    if (idxs.size() == 0)
+        return GetSP();
+    ValueObjectSP root(GetSP());
+    for (std::pair<size_t, bool> idx : idxs)
+    {
+        root = root->GetChildAtIndex(idx.first, idx.second);
+        if (!root)
+        {
+            if (index_of_error)
+                *index_of_error = idx.first;
+            return root;
+        }
+    }
+    return root;
+}
+
+size_t
 ValueObject::GetIndexOfChildWithName (const ConstString &name)
 {
     bool omit_empty_base_classes = true;
@@ -574,7 +671,7 @@ ValueObject::GetChildMemberWithName (con
 }
 
 
-uint32_t
+size_t
 ValueObject::GetNumChildren ()
 {
     UpdateValueIfNeeded();
@@ -584,8 +681,29 @@ ValueObject::GetNumChildren ()
     }
     return m_children.GetChildrenCount();
 }
+
+bool
+ValueObject::MightHaveChildren()
+{
+    bool has_children = false;
+    const uint32_t type_info = GetTypeInfo();
+    if (type_info)
+    {
+        if (type_info & (ClangASTContext::eTypeHasChildren |
+                         ClangASTContext::eTypeIsPointer |
+                         ClangASTContext::eTypeIsReference))
+            has_children = true;
+    }
+    else
+    {
+        has_children = GetNumChildren () > 0;
+    }
+    return has_children;
+}
+
+// Should only be called by ValueObject::GetNumChildren()
 void
-ValueObject::SetNumChildren (uint32_t num_children)
+ValueObject::SetNumChildren (size_t num_children)
 {
     m_children_count_valid = true;
     m_children.SetChildrenCount(num_children);
@@ -598,7 +716,7 @@ ValueObject::SetName (const ConstString
 }
 
 ValueObject *
-ValueObject::CreateChildAtIndex (uint32_t idx, bool synthetic_array_member, int32_t synthetic_index)
+ValueObject::CreateChildAtIndex (size_t idx, bool synthetic_array_member, int32_t synthetic_index)
 {
     ValueObject *valobj = NULL;
     
@@ -634,7 +752,7 @@ ValueObject::CreateChildAtIndex (uint32_
                                                                   child_bitfield_bit_offset,
                                                                   child_is_base_class,
                                                                   child_is_deref_of_parent);
-    if (child_clang_type && child_byte_size)
+    if (child_clang_type)
     {
         if (synthetic_index)
             child_byte_offset += child_byte_size * synthetic_index;
@@ -768,11 +886,9 @@ bool
 ValueObject::IsCStringContainer(bool check_pointer)
 {
     clang_type_t elem_or_pointee_clang_type;
-    const Flags type_flags (ClangASTContext::GetTypeInfo (GetClangType(), 
-                                                          GetClangAST(), 
-                                                          &elem_or_pointee_clang_type));
+    const Flags type_flags (GetTypeInfo (&elem_or_pointee_clang_type));
     bool is_char_arr_ptr (type_flags.AnySet (ClangASTContext::eTypeIsArray | ClangASTContext::eTypeIsPointer) &&
-            ClangASTContext::IsCharType (elem_or_pointee_clang_type));
+                          ClangASTContext::IsCharType (elem_or_pointee_clang_type));
     if (!is_char_arr_ptr)
         return false;
     if (!check_pointer)
@@ -790,19 +906,20 @@ ValueObject::GetPointeeData (DataExtract
                              uint32_t item_idx,
                              uint32_t item_count)
 {
-    if (!IsPointerType() && !IsArrayType())
+    clang_type_t pointee_or_element_clang_type;
+    const uint32_t type_info = GetTypeInfo (&pointee_or_element_clang_type);
+    const bool is_pointer_type = type_info & ClangASTContext::eTypeIsPointer;
+    const bool is_array_type = type_info & ClangASTContext::eTypeIsArray;
+    if (!(is_pointer_type || is_array_type))
         return 0;
     
     if (item_count == 0)
         return 0;
     
-    uint32_t stride = 0;
+    clang::ASTContext *ast = GetClangAST();
+    ClangASTType pointee_or_element_type(ast, pointee_or_element_clang_type);
     
-    ClangASTType type(GetClangAST(),
-                      GetClangType());
-    
-    const uint64_t item_type_size = (IsPointerType() ? ClangASTType::GetTypeByteSize(GetClangAST(), type.GetPointeeType()) :
-                                     ClangASTType::GetTypeByteSize(GetClangAST(), type.GetArrayElementType(stride)));
+    const uint64_t item_type_size = pointee_or_element_type.GetClangTypeByteSize();
     
     const uint64_t bytes = item_count * item_type_size;
     
@@ -810,7 +927,7 @@ ValueObject::GetPointeeData (DataExtract
     
     if (item_idx == 0 && item_count == 1) // simply a deref
     {
-        if (IsPointerType())
+        if (is_pointer_type)
         {
             Error error;
             ValueObjectSP pointee_sp = Dereference(error);
@@ -834,7 +951,7 @@ ValueObject::GetPointeeData (DataExtract
         lldb::DataBufferSP data_sp(heap_buf_ptr = new lldb_private::DataBufferHeap());
         
         AddressType addr_type;
-        lldb::addr_t addr = IsPointerType() ? GetPointerValue(&addr_type) : GetAddressOf(true, &addr_type);
+        lldb::addr_t addr = is_pointer_type ? GetPointerValue(&addr_type) : GetAddressOf(true, &addr_type);
         
         switch (addr_type)
         {
@@ -879,32 +996,125 @@ ValueObject::GetPointeeData (DataExtract
                 break;
             case eAddressTypeHost:
                 {
-                    heap_buf_ptr->CopyData((uint8_t*)(addr + offset), bytes);
-                    data.SetData(data_sp);
-                    return bytes;
+                    ClangASTType valobj_type(ast, GetClangType());
+                    uint64_t max_bytes = valobj_type.GetClangTypeByteSize();
+                    if (max_bytes > offset)
+                    {
+                        size_t bytes_read = std::min<uint64_t>(max_bytes - offset, bytes);
+                        heap_buf_ptr->CopyData((uint8_t*)(addr + offset), bytes_read);
+                        data.SetData(data_sp);
+                        return bytes_read;
+                    }
                 }
                 break;
             case eAddressTypeInvalid:
-            default:
                 break;
         }
     }
     return 0;
 }
 
-size_t
+uint64_t
 ValueObject::GetData (DataExtractor& data)
 {
     UpdateValueIfNeeded(false);
     ExecutionContext exe_ctx (GetExecutionContextRef());
     Error error = m_value.GetValueAsData(&exe_ctx, GetClangAST(), data, 0, GetModule().get());
     if (error.Fail())
-        return 0;
+    {
+        if (m_data.GetByteSize())
+        {
+            data = m_data;
+            return data.GetByteSize();
+        }
+        else
+        {
+            return 0;
+        }
+    }
     data.SetAddressByteSize(m_data.GetAddressByteSize());
     data.SetByteOrder(m_data.GetByteOrder());
     return data.GetByteSize();
 }
 
+bool
+ValueObject::SetData (DataExtractor &data, Error &error)
+{
+    error.Clear();
+    // Make sure our value is up to date first so that our location and location
+    // type is valid.
+    if (!UpdateValueIfNeeded(false))
+    {
+        error.SetErrorString("unable to read value");
+        return false;
+    }
+    
+    uint64_t count = 0;
+    Encoding encoding = ClangASTType::GetEncoding (GetClangType(), count);
+    
+    const size_t byte_size = GetByteSize();
+    
+    Value::ValueType value_type = m_value.GetValueType();
+    
+    switch (value_type)
+    {
+    case Value::eValueTypeScalar:
+        {
+            Error set_error = m_value.GetScalar().SetValueFromData(data, encoding, byte_size);
+            
+            if (!set_error.Success())
+            {
+                error.SetErrorStringWithFormat("unable to set scalar value: %s", set_error.AsCString());
+                return false;
+            }
+        }
+        break;
+    case Value::eValueTypeLoadAddress:
+        {
+            // If it is a load address, then the scalar value is the storage location
+            // of the data, and we have to shove this value down to that load location.
+            ExecutionContext exe_ctx (GetExecutionContextRef());
+            Process *process = exe_ctx.GetProcessPtr();
+            if (process)
+            {
+                addr_t target_addr = m_value.GetScalar().ULongLong(LLDB_INVALID_ADDRESS);
+                size_t bytes_written = process->WriteMemory(target_addr,
+                                                            data.GetDataStart(),
+                                                            byte_size,
+                                                            error);
+                if (!error.Success())
+                    return false;
+                if (bytes_written != byte_size)
+                {
+                    error.SetErrorString("unable to write value to memory");
+                    return false;
+                }
+            }
+        }
+        break;
+    case Value::eValueTypeHostAddress:
+        {
+            // If it is a host address, then we stuff the scalar as a DataBuffer into the Value's data.            
+            DataBufferSP buffer_sp (new DataBufferHeap(byte_size, 0));
+            m_data.SetData(buffer_sp, 0);
+            data.CopyByteOrderedData (0,
+                                      byte_size,
+                                      const_cast<uint8_t *>(m_data.GetDataStart()),
+                                      byte_size,
+                                      m_data.GetByteOrder());
+            m_value.GetScalar() = (uintptr_t)m_data.GetDataStart();
+        }
+        break;
+    case Value::eValueTypeFileAddress:
+    case Value::eValueTypeVector:
+        break;
+    }
+    
+    // If we have reached this point, then we have successfully changed the value.
+    SetNeedsUpdate();
+    return true;
+}
+
 // will compute strlen(str), but without consuming more than
 // maxlen bytes out of str (this serves the purpose of reading
 // chunks of a string without having to worry about
@@ -923,14 +1133,14 @@ strlen_or_inf (const char* str,
         while(*str)
         {
             len++;str++;
-            if (len > maxlen)
+            if (len >= maxlen)
                 return maxlen_value;
         }
     }
     return len;
 }
 
-void
+size_t
 ValueObject::ReadPointedString (Stream& s,
                                 Error& error,
                                 uint32_t max_length,
@@ -940,141 +1150,149 @@ ValueObject::ReadPointedString (Stream&
     ExecutionContext exe_ctx (GetExecutionContextRef());
     Target* target = exe_ctx.GetTargetPtr();
 
-    if (target && max_length == 0)
+    if (!target)
+    {
+        s << "<no target to read from>";
+        error.SetErrorString("no target to read from");
+        return 0;
+    }
+    
+    if (max_length == 0)
         max_length = target->GetMaximumSizeOfStringSummary();
     
+    size_t bytes_read = 0;
+    size_t total_bytes_read = 0;
+    
     clang_type_t clang_type = GetClangType();
     clang_type_t elem_or_pointee_clang_type;
-    const Flags type_flags (ClangASTContext::GetTypeInfo (clang_type, 
-                                                          GetClangAST(), 
-                                                          &elem_or_pointee_clang_type));
+    const Flags type_flags (GetTypeInfo (&elem_or_pointee_clang_type));
     if (type_flags.AnySet (ClangASTContext::eTypeIsArray | ClangASTContext::eTypeIsPointer) &&
         ClangASTContext::IsCharType (elem_or_pointee_clang_type))
     {
-        if (target == NULL)
+        addr_t cstr_address = LLDB_INVALID_ADDRESS;
+        AddressType cstr_address_type = eAddressTypeInvalid;
+        
+        size_t cstr_len = 0;
+        bool capped_data = false;
+        if (type_flags.Test (ClangASTContext::eTypeIsArray))
         {
-            s << "<no target to read from>";
+            // We have an array
+            cstr_len = ClangASTContext::GetArraySize (clang_type);
+            if (cstr_len > max_length)
+            {
+                capped_data = true;
+                cstr_len = max_length;
+            }
+            cstr_address = GetAddressOf (true, &cstr_address_type);
         }
         else
         {
-            addr_t cstr_address = LLDB_INVALID_ADDRESS;
-            AddressType cstr_address_type = eAddressTypeInvalid;
+            // We have a pointer
+            cstr_address = GetPointerValue (&cstr_address_type);
+        }
+        
+        if (cstr_address == 0 || cstr_address == LLDB_INVALID_ADDRESS)
+        {
+            s << "<invalid address>";
+            error.SetErrorString("invalid address");
+            return 0;
+        }
+
+        Address cstr_so_addr (cstr_address);
+        DataExtractor data;
+        if (cstr_len > 0 && honor_array)
+        {
+            // I am using GetPointeeData() here to abstract the fact that some ValueObjects are actually frozen pointers in the host
+            // but the pointed-to data lives in the debuggee, and GetPointeeData() automatically takes care of this
+            GetPointeeData(data, 0, cstr_len);
+
+            if ((bytes_read = data.GetByteSize()) > 0)
+            {
+                total_bytes_read = bytes_read;
+                s << '"';
+                data.Dump (&s,
+                           0,                 // Start offset in "data"
+                           item_format,
+                           1,                 // Size of item (1 byte for a char!)
+                           bytes_read,        // How many bytes to print?
+                           UINT32_MAX,        // num per line
+                           LLDB_INVALID_ADDRESS,// base address
+                           0,                 // bitfield bit size
+                           0);                // bitfield bit offset
+                if (capped_data)
+                    s << "...";
+                s << '"';
+            }
+        }
+        else
+        {
+            cstr_len = max_length;
+            const size_t k_max_buf_size = 64;
+                                        
+            size_t offset = 0;
             
-            size_t cstr_len = 0;
-            bool capped_data = false;
-            if (type_flags.Test (ClangASTContext::eTypeIsArray))
-            {
-                // We have an array
-                cstr_len = ClangASTContext::GetArraySize (clang_type);
-                if (cstr_len > max_length)
+            int cstr_len_displayed = -1;
+            bool capped_cstr = false;
+            // I am using GetPointeeData() here to abstract the fact that some ValueObjects are actually frozen pointers in the host
+            // but the pointed-to data lives in the debuggee, and GetPointeeData() automatically takes care of this
+            while ((bytes_read = GetPointeeData(data, offset, k_max_buf_size)) > 0)
+            {
+                total_bytes_read += bytes_read;
+                const char *cstr = data.PeekCStr(0);
+                size_t len = strlen_or_inf (cstr, k_max_buf_size, k_max_buf_size+1);
+                if (len > k_max_buf_size)
+                    len = k_max_buf_size;
+                if (cstr && cstr_len_displayed < 0)
+                    s << '"';
+
+                if (cstr_len_displayed < 0)
+                    cstr_len_displayed = len;
+
+                if (len == 0)
+                    break;
+                cstr_len_displayed += len;
+                if (len > bytes_read)
+                    len = bytes_read;
+                if (len > cstr_len)
+                    len = cstr_len;
+                
+                data.Dump (&s,
+                           0,                 // Start offset in "data"
+                           item_format,
+                           1,                 // Size of item (1 byte for a char!)
+                           len,               // How many bytes to print?
+                           UINT32_MAX,        // num per line
+                           LLDB_INVALID_ADDRESS,// base address
+                           0,                 // bitfield bit size
+                           0);                // bitfield bit offset
+                
+                if (len < k_max_buf_size)
+                    break;
+                
+                if (len >= cstr_len)
                 {
-                    capped_data = true;
-                    cstr_len = max_length;
+                    capped_cstr = true;
+                    break;
                 }
-                cstr_address = GetAddressOf (true, &cstr_address_type);
+
+                cstr_len -= len;
+                offset += len;
             }
-            else
+            
+            if (cstr_len_displayed >= 0)
             {
-                // We have a pointer
-                cstr_address = GetPointerValue (&cstr_address_type);
-            }
-            if (cstr_address != 0 && cstr_address != LLDB_INVALID_ADDRESS)
-            {
-                Address cstr_so_addr (cstr_address);
-                DataExtractor data;
-                size_t bytes_read = 0;
-                if (cstr_len > 0 && honor_array)
-                {
-                    // I am using GetPointeeData() here to abstract the fact that some ValueObjects are actually frozen pointers in the host
-                    // but the pointed-to data lives in the debuggee, and GetPointeeData() automatically takes care of this
-                    GetPointeeData(data, 0, cstr_len);
-
-                    if ((bytes_read = data.GetByteSize()) > 0)
-                    {
-                        s << '"';
-                        data.Dump (&s,
-                                   0,                 // Start offset in "data"
-                                   item_format,
-                                   1,                 // Size of item (1 byte for a char!)
-                                   bytes_read,        // How many bytes to print?
-                                   UINT32_MAX,        // num per line
-                                   LLDB_INVALID_ADDRESS,// base address
-                                   0,                 // bitfield bit size
-                                   0);                // bitfield bit offset
-                        if (capped_data)
-                            s << "...";
-                        s << '"';
-                    }
-                }
-                else
-                {
-                    cstr_len = max_length;
-                    const size_t k_max_buf_size = 64;
-                                                
-                    size_t offset = 0;
-                    
-                    int cstr_len_displayed = -1;
-                    bool capped_cstr = false;
-                    // I am using GetPointeeData() here to abstract the fact that some ValueObjects are actually frozen pointers in the host
-                    // but the pointed-to data lives in the debuggee, and GetPointeeData() automatically takes care of this
-                    while ((bytes_read = GetPointeeData(data, offset, k_max_buf_size)) > 0)
-                    {
-                        const char *cstr = data.PeekCStr(0);
-                        size_t len = strlen_or_inf (cstr, k_max_buf_size, k_max_buf_size+1);
-                        if (len > k_max_buf_size)
-                            len = k_max_buf_size;
-                        if (cstr && cstr_len_displayed < 0)
-                            s << '"';
-
-                        if (cstr_len_displayed < 0)
-                            cstr_len_displayed = len;
-
-                        if (len == 0)
-                            break;
-                        cstr_len_displayed += len;
-                        if (len > bytes_read)
-                            len = bytes_read;
-                        if (len > cstr_len)
-                            len = cstr_len;
-                        
-                        data.Dump (&s,
-                                   0,                 // Start offset in "data"
-                                   item_format,
-                                   1,                 // Size of item (1 byte for a char!)
-                                   len,               // How many bytes to print?
-                                   UINT32_MAX,        // num per line
-                                   LLDB_INVALID_ADDRESS,// base address
-                                   0,                 // bitfield bit size
-                                   0);                // bitfield bit offset
-                        
-                        if (len < k_max_buf_size)
-                            break;
-                        
-                        if (len >= cstr_len)
-                        {
-                            capped_cstr = true;
-                            break;
-                        }
-
-                        cstr_len -= len;
-                        offset += len;
-                    }
-                    
-                    if (cstr_len_displayed >= 0)
-                    {
-                        s << '"';
-                        if (capped_cstr)
-                            s << "...";
-                    }
-                }
+                s << '"';
+                if (capped_cstr)
+                    s << "...";
             }
         }
     }
     else
     {
-        error.SetErrorString("impossible to read a string from this object");
+        error.SetErrorString("not a string object");
         s << "<not a string object>";
     }
+    return total_bytes_read;
 }
 
 const char *
@@ -1141,17 +1359,40 @@ ValueObject::GetValueAsCString (lldb::Fo
                 clang_type_t clang_type = GetClangType ();
                 if (clang_type)
                 {
+                     // put custom bytes to display in this DataExtractor to override the default value logic
+                    lldb_private::DataExtractor special_format_data;
+                    clang::ASTContext* ast = GetClangAST();
+                    if (format == eFormatCString)
+                    {
+                        Flags type_flags(ClangASTContext::GetTypeInfo(clang_type, ast, NULL));
+                        if (type_flags.Test(ClangASTContext::eTypeIsPointer) && !type_flags.Test(ClangASTContext::eTypeIsObjC))
+                        {
+                            // if we are dumping a pointer as a c-string, get the pointee data as a string
+                            TargetSP target_sp(GetTargetSP());
+                            if (target_sp)
+                            {
+                                size_t max_len = target_sp->GetMaximumSizeOfStringSummary();
+                                Error error;
+                                DataBufferSP buffer_sp(new DataBufferHeap(max_len+1,0));
+                                Address address(GetPointerValue());
+                                if (target_sp->ReadCStringFromMemory(address, (char*)buffer_sp->GetBytes(), max_len, error) && error.Success())
+                                    special_format_data.SetData(buffer_sp);
+                            }
+                        }
+                    }
+                    
                     StreamString sstr;
                     ExecutionContext exe_ctx (GetExecutionContextRef());
-                    ClangASTType::DumpTypeValue (GetClangAST(),             // The clang AST
-                                                 clang_type,                // The clang type to display
-                                                 &sstr,
-                                                 format,                    // Format to display this type with
-                                                 m_data,                    // Data to extract from
-                                                 0,                         // Byte offset into "m_data"
-                                                 GetByteSize(),             // Byte size of item in "m_data"
-                                                 GetBitfieldBitSize(),      // Bitfield bit size
-                                                 GetBitfieldBitOffset(),    // Bitfield bit offset
+                    ClangASTType::DumpTypeValue (ast,                           // The clang AST
+                                                 clang_type,                    // The clang type to display
+                                                 &sstr,                         // The stream to use for display
+                                                 format,                        // Format to display this type with
+                                                 special_format_data.GetByteSize() ?
+                                                 special_format_data: m_data,   // Data to extract from
+                                                 0,                             // Byte offset into "m_data"
+                                                 GetByteSize(),                 // Byte size of item in "m_data"
+                                                 GetBitfieldBitSize(),          // Bitfield bit size
+                                                 GetBitfieldBitOffset(),        // Bitfield bit offset
                                                  exe_ctx.GetBestExecutionContextScope()); 
                     // Don't set the m_error to anything here otherwise
                     // we won't be able to re-format as anything else. The
@@ -1202,10 +1443,10 @@ ValueObject::GetValueAsCString (lldb::Fo
 const char *
 ValueObject::GetValueAsCString ()
 {
-    if (UpdateValueIfNeeded(true) && m_value_str.empty())
+    if (UpdateValueIfNeeded(true))
     {
         lldb::Format my_format = GetFormat();
-        if (m_format == lldb::eFormatDefault)
+        if (my_format == lldb::eFormatDefault)
         {
             if (m_type_format_sp)
                 my_format = m_type_format_sp->GetFormat();
@@ -1229,13 +1470,17 @@ ValueObject::GetValueAsCString ()
                 }
             }
         }
-        if (GetValueAsCString(my_format, m_value_str))
+        if (my_format != m_last_format || m_value_str.empty())
         {
-            if (!m_value_did_change && m_old_value_valid)
+            m_last_format = my_format;
+            if (GetValueAsCString(my_format, m_value_str))
             {
-                // The value was gotten successfully, so we consider the
-                // value as changed if the value string differs
-                SetValueDidChange (m_old_value_str != m_value_str);
+                if (!m_value_did_change && m_old_value_valid)
+                {
+                    // The value was gotten successfully, so we consider the
+                    // value as changed if the value string differs
+                    SetValueDidChange (m_old_value_str != m_value_str);
+                }
             }
         }
     }
@@ -1257,7 +1502,7 @@ ValueObject::GetValueAsUnsigned (uint64_
         {
             if (success)
                 *success = true;
-            return scalar.GetRawBits64(fail_value);
+            return scalar.ULongLong(fail_value);
         }
         // fallthrough, otherwise...
     }
@@ -1275,7 +1520,7 @@ ValueObject::HasSpecialPrintableRepresen
                                                Format custom_format)
 {
     clang_type_t elem_or_pointee_type;
-    Flags flags(ClangASTContext::GetTypeInfo(GetClangType(), GetClangAST(), &elem_or_pointee_type));
+    Flags flags(GetTypeInfo(&elem_or_pointee_type));
     
     if (flags.AnySet(ClangASTContext::eTypeIsArray | ClangASTContext::eTypeIsPointer)
         && val_obj_display == ValueObject::eValueObjectRepresentationStyleValue)
@@ -1319,7 +1564,7 @@ ValueObject::DumpPrintableRepresentation
 {
 
     clang_type_t elem_or_pointee_type;
-    Flags flags(ClangASTContext::GetTypeInfo(GetClangType(), GetClangAST(), &elem_or_pointee_type));
+    Flags flags(GetTypeInfo(&elem_or_pointee_type));
     
     bool allow_special = ((special & ePrintableRepresentationSpecialCasesAllow) == ePrintableRepresentationSpecialCasesAllow);
     bool only_special = ((special & ePrintableRepresentationSpecialCasesOnly) == ePrintableRepresentationSpecialCasesOnly);
@@ -1357,10 +1602,10 @@ ValueObject::DumpPrintableRepresentation
                 if ((custom_format == eFormatBytes) ||
                     (custom_format == eFormatBytesWithASCII))
                 {
-                    uint32_t count = GetNumChildren();
+                    const size_t count = GetNumChildren();
                                     
                     s << '[';
-                    for (uint32_t low = 0; low < count; low++)
+                    for (size_t low = 0; low < count; low++)
                     {
                         
                         if (low)
@@ -1393,12 +1638,12 @@ ValueObject::DumpPrintableRepresentation
                     (custom_format == eFormatVectorOfUInt64) ||
                     (custom_format == eFormatVectorOfUInt8)) // arrays of bytes, bytes with ASCII or any vector format should be printed directly
                 {
-                    uint32_t count = GetNumChildren();
+                    const size_t count = GetNumChildren();
 
                     Format format = FormatManager::GetSingleItemFormat(custom_format);
                     
                     s << '[';
-                    for (uint32_t low = 0; low < count; low++)
+                    for (size_t low = 0; low < count; low++)
                     {
                         
                         if (low)
@@ -1447,8 +1692,8 @@ ValueObject::DumpPrintableRepresentation
     bool var_success = false;
     
     {
-        const char * return_value;
-        std::string alloc_mem;
+        const char *cstr = NULL;
+        StreamString strm;
 
         if (custom_format != eFormatInvalid)
             SetFormat(custom_format);
@@ -1456,62 +1701,49 @@ ValueObject::DumpPrintableRepresentation
         switch(val_obj_display)
         {
             case eValueObjectRepresentationStyleValue:
-                return_value = GetValueAsCString();
+                cstr = GetValueAsCString();
                 break;
                 
             case eValueObjectRepresentationStyleSummary:
-                return_value = GetSummaryAsCString();
+                cstr = GetSummaryAsCString();
                 break;
                 
             case eValueObjectRepresentationStyleLanguageSpecific:
-                return_value = GetObjectDescription();
+                cstr = GetObjectDescription();
                 break;
                 
             case eValueObjectRepresentationStyleLocation:
-                return_value = GetLocationAsCString();
+                cstr = GetLocationAsCString();
                 break;
                 
             case eValueObjectRepresentationStyleChildrenCount:
-            {
-                alloc_mem.resize(512);
-                return_value = &alloc_mem[0];
-                int count = GetNumChildren();
-                snprintf((char*)return_value, 512, "%d", count);
-            }
+                strm.Printf("%zu", GetNumChildren());
+                cstr = strm.GetString().c_str();
                 break;
                 
             case eValueObjectRepresentationStyleType:
-                return_value = GetTypeName().AsCString();
-                break;
-                
-            default:
+                cstr = GetTypeName().AsCString();
                 break;
         }
         
-        if (!return_value)
+        if (!cstr)
         {
             if (val_obj_display == eValueObjectRepresentationStyleValue)
-                return_value = GetSummaryAsCString();        
+                cstr = GetSummaryAsCString();
             else if (val_obj_display == eValueObjectRepresentationStyleSummary)
             {
                 if (ClangASTContext::IsAggregateType (GetClangType()) == true)
                 {
-                    // this thing has no value, and it seems to have no summary
-                    // some combination of unitialized data and other factors can also
-                    // raise this condition, so let's print a nice generic description
-                    {
-                        alloc_mem.resize(684);
-                        return_value = &alloc_mem[0];
-                        snprintf((char*)return_value, 684, "%s @ %s", GetTypeName().AsCString(), GetLocationAsCString());
-                    }
+                    strm.Printf("%s @ %s", GetTypeName().AsCString(), GetLocationAsCString());
+                    cstr = strm.GetString().c_str();
                 }
                 else
-                    return_value = GetValueAsCString();
+                    cstr = GetValueAsCString();
             }
         }
         
-        if (return_value)
-            s.PutCString(return_value);
+        if (cstr)
+            s.PutCString(cstr);
         else
         {
             if (m_error.Fail())
@@ -1547,6 +1779,7 @@ ValueObject::GetAddressOf (bool scalar_i
     switch (m_value.GetValueType())
     {
     case Value::eValueTypeScalar:
+    case Value::eValueTypeVector:
         if (scalar_is_load_address)
         {
             if(address_type)
@@ -1583,6 +1816,7 @@ ValueObject::GetPointerValue (AddressTyp
     switch (m_value.GetValueType())
     {
     case Value::eValueTypeScalar:
+    case Value::eValueTypeVector:
         address = m_value.GetScalar().ULongLong(LLDB_INVALID_ADDRESS);
         break;
 
@@ -1590,7 +1824,7 @@ ValueObject::GetPointerValue (AddressTyp
     case Value::eValueTypeLoadAddress:
     case Value::eValueTypeFileAddress:
         {
-            uint32_t data_offset = 0;
+            lldb::offset_t data_offset = 0;
             address = m_data.GetPointer(&data_offset);
         }
         break;
@@ -1614,7 +1848,7 @@ ValueObject::SetValueFromCString (const
         return false;
     }
 
-    uint32_t count = 0;
+    uint64_t count = 0;
     Encoding encoding = ClangASTType::GetEncoding (GetClangType(), count);
 
     const size_t byte_size = GetByteSize();
@@ -1644,7 +1878,7 @@ ValueObject::SetValueFromCString (const
                     Process *process = exe_ctx.GetProcessPtr();
                     if (process)
                     {
-                        addr_t target_addr = m_value.GetScalar().GetRawBits64(LLDB_INVALID_ADDRESS);
+                        addr_t target_addr = m_value.GetScalar().ULongLong(LLDB_INVALID_ADDRESS);
                         size_t bytes_written = process->WriteScalarToMemory (target_addr, 
                                                                              new_scalar, 
                                                                              byte_size, 
@@ -1682,7 +1916,8 @@ ValueObject::SetValueFromCString (const
                 break;
             case Value::eValueTypeFileAddress:
             case Value::eValueTypeScalar:
-                break;    
+            case Value::eValueTypeVector:
+                break;
             }
         }
         else
@@ -1745,6 +1980,12 @@ ValueObject::GetSyntheticChild (const Co
     return synthetic_child_sp;
 }
 
+uint32_t
+ValueObject::GetTypeInfo (clang_type_t *pointee_or_element_clang_type)
+{
+    return ClangASTContext::GetTypeInfo (GetClangType(), GetClangAST(), pointee_or_element_clang_type);
+}
+
 bool
 ValueObject::IsPointerType ()
 {
@@ -1754,7 +1995,7 @@ ValueObject::IsPointerType ()
 bool
 ValueObject::IsArrayType ()
 {
-    return ClangASTContext::IsArrayType (GetClangType());
+    return ClangASTContext::IsArrayType (GetClangType(), NULL, NULL, NULL);
 }
 
 bool
@@ -1783,16 +2024,29 @@ ValueObject::IsPossibleDynamicType ()
     if (process)
         return process->IsPossibleDynamicValue(*this);
     else
-        return ClangASTContext::IsPossibleDynamicType (GetClangAST (), GetClangType());
+        return ClangASTContext::IsPossibleDynamicType (GetClangAST (), GetClangType(), NULL, true, true);
+}
+
+bool
+ValueObject::IsObjCNil ()
+{
+    const uint32_t mask = ClangASTContext::eTypeIsObjC | ClangASTContext::eTypeIsPointer;
+    bool isObjCpointer = ( ((ClangASTContext::GetTypeInfo(GetClangType(), GetClangAST(), NULL)) & mask) == mask);
+    if (!isObjCpointer)
+        return false;
+    bool canReadValue = true;
+    bool isZero = GetValueAsUnsigned(0,&canReadValue) == 0;
+    return canReadValue && isZero;
 }
 
 ValueObjectSP
-ValueObject::GetSyntheticArrayMember (int32_t index, bool can_create)
+ValueObject::GetSyntheticArrayMember (size_t index, bool can_create)
 {
-    if (IsArrayType())
+    const uint32_t type_info = GetTypeInfo ();
+    if (type_info & ClangASTContext::eTypeIsArray)
         return GetSyntheticArrayMemberFromArray(index, can_create);
 
-    if (IsPointerType())
+    if (type_info & ClangASTContext::eTypeIsPointer)
         return GetSyntheticArrayMemberFromPointer(index, can_create);
     
     return ValueObjectSP();
@@ -1800,13 +2054,13 @@ ValueObject::GetSyntheticArrayMember (in
 }
 
 ValueObjectSP
-ValueObject::GetSyntheticArrayMemberFromPointer (int32_t index, bool can_create)
+ValueObject::GetSyntheticArrayMemberFromPointer (size_t index, bool can_create)
 {
     ValueObjectSP synthetic_child_sp;
     if (IsPointerType ())
     {
         char index_str[64];
-        snprintf(index_str, sizeof(index_str), "[%i]", index);
+        snprintf(index_str, sizeof(index_str), "[%zu]", index);
         ConstString index_const_str(index_str);
         // Check if we have already created a synthetic array member in this
         // valid object. If we have we will re-use it.
@@ -1843,13 +2097,13 @@ ValueObject::GetSyntheticArrayMemberFrom
 // there are more items in "item_array".
 
 ValueObjectSP
-ValueObject::GetSyntheticArrayMemberFromArray (int32_t index, bool can_create)
+ValueObject::GetSyntheticArrayMemberFromArray (size_t index, bool can_create)
 {
     ValueObjectSP synthetic_child_sp;
     if (IsArrayType ())
     {
         char index_str[64];
-        snprintf(index_str, sizeof(index_str), "[%i]", index);
+        snprintf(index_str, sizeof(index_str), "[%zu]", index);
         ConstString index_const_str(index_str);
         // Check if we have already created a synthetic array member in this
         // valid object. If we have we will re-use it.
@@ -1917,42 +2171,6 @@ ValueObject::GetSyntheticBitFieldChild (
 }
 
 ValueObjectSP
-ValueObject::GetSyntheticArrayRangeChild (uint32_t from, uint32_t to, bool can_create)
-{
-    ValueObjectSP synthetic_child_sp;
-    if (IsArrayType () || IsPointerType ())
-    {
-        char index_str[64];
-        snprintf(index_str, sizeof(index_str), "[%i-%i]", from, to);
-        ConstString index_const_str(index_str);
-        // Check if we have already created a synthetic array member in this
-        // valid object. If we have we will re-use it.
-        synthetic_child_sp = GetSyntheticChild (index_const_str);
-        if (!synthetic_child_sp)
-        {
-            ValueObjectSynthetic *synthetic_child;
-            
-            // We haven't made a synthetic array member for INDEX yet, so
-            // lets make one and cache it for any future reference.
-            SyntheticArrayView *view = new SyntheticArrayView(SyntheticChildren::Flags());
-            view->AddRange(from,to);
-            SyntheticChildrenSP view_sp(view);
-            synthetic_child = new ValueObjectSynthetic(*this, view_sp);
-            
-            // Cache the value if we got one back...
-            if (synthetic_child)
-            {
-                AddSyntheticChild(index_const_str, synthetic_child);
-                synthetic_child_sp = synthetic_child->GetSP();
-                synthetic_child_sp->SetName(ConstString(index_str));
-                synthetic_child_sp->m_is_bitfield_for_scalar = true;
-            }
-        }
-    }
-    return synthetic_child_sp;
-}
-
-ValueObjectSP
 ValueObject::GetSyntheticChildAtOffset(uint32_t offset, const ClangASTType& type, bool can_create)
 {
     
@@ -2029,9 +2247,9 @@ ValueObject::GetSyntheticExpressionPathC
         // Cache the value if we got one back...
         if (synthetic_child_sp.get())
         {
+            // FIXME: this causes a "real" child to end up with its name changed to the contents of expression
             AddSyntheticChild(name_const_string, synthetic_child_sp.get());
             synthetic_child_sp->SetName(ConstString(SkipLeadingExpressionPathSeparators(expression)));
-            synthetic_child_sp->m_is_expression_path_child = true;
         }
     }
     return synthetic_child_sp;
@@ -2050,12 +2268,17 @@ ValueObject::CalculateSyntheticValue (bo
         return;
     }
     
-    if (!UpdateFormatsIfNeeded(m_last_format_mgr_dynamic) && m_synthetic_value)
+    lldb::SyntheticChildrenSP current_synth_sp(m_synthetic_children_sp);
+    
+    if (!UpdateFormatsIfNeeded() && m_synthetic_value)
         return;
     
     if (m_synthetic_children_sp.get() == NULL)
         return;
     
+    if (current_synth_sp == m_synthetic_children_sp && m_synthetic_value)
+        return;
+    
     m_synthetic_value = new ValueObjectSynthetic(*this, m_synthetic_children_sp);
 }
 
@@ -2070,7 +2293,10 @@ ValueObject::CalculateDynamicValue (Dyna
         ExecutionContext exe_ctx (GetExecutionContextRef());
         Process *process = exe_ctx.GetProcessPtr();
         if (process && process->IsPossibleDynamicValue(*this))
+        {
+            ClearDynamicTypeInformation ();
             m_dynamic_value = new ValueObjectDynamicValue (*this, use_dynamic);
+        }
     }
 }
 
@@ -2119,7 +2345,7 @@ ValueObject::GetSyntheticValue (bool use
 bool
 ValueObject::HasSyntheticValue()
 {
-    UpdateFormatsIfNeeded(m_last_format_mgr_dynamic);
+    UpdateFormatsIfNeeded();
     
     if (m_synthetic_children_sp.get() == NULL)
         return false;
@@ -2250,8 +2476,8 @@ ValueObject::GetValueForExpressionPath(c
 {
     
     const char* dummy_first_unparsed;
-    ExpressionPathScanEndReason dummy_reason_to_stop;
-    ExpressionPathEndResultType dummy_final_value_type;
+    ExpressionPathScanEndReason dummy_reason_to_stop = ValueObject::eExpressionPathScanEndReasonUnknown;
+    ExpressionPathEndResultType dummy_final_value_type = ValueObject::eExpressionPathEndResultTypeInvalid;
     ExpressionPathAftermath dummy_final_task_on_target = ValueObject::eExpressionPathAftermathNothing;
     
     ValueObjectSP ret_val = GetValueForExpressionPath_Impl(expression,
@@ -2482,7 +2708,7 @@ ValueObject::GetValueForExpressionPath_I
                     
                     if (child_valobj_sp.get()) // we know we are done, so just return
                     {
-                        *first_unparsed = '\0';
+                        *first_unparsed = "";
                         *reason_to_stop = ValueObject::eExpressionPathScanEndReasonEndOfString;
                         *final_result = ValueObject::eExpressionPathEndResultTypePlain;
                         return child_valobj_sp;
@@ -2506,7 +2732,7 @@ ValueObject::GetValueForExpressionPath_I
                     // so we hit the "else" branch, and return an error
                     if(child_valobj_sp.get()) // if it worked, just return
                     {
-                        *first_unparsed = '\0';
+                        *first_unparsed = "";
                         *reason_to_stop = ValueObject::eExpressionPathScanEndReasonEndOfString;
                         *final_result = ValueObject::eExpressionPathEndResultTypePlain;
                         return child_valobj_sp;
@@ -2923,8 +3149,8 @@ ValueObject::ExpandArraySliceExpression(
                     }
                     else // expand this into list
                     {
-                        int max_index = root->GetNumChildren() - 1;
-                        for (int index = 0; index < max_index; index++)
+                        const size_t max_index = root->GetNumChildren() - 1;
+                        for (size_t index = 0; index < max_index; index++)
                         {
                             ValueObjectSP child = 
                                 root->GetChildAtIndex(index, true);
@@ -2960,8 +3186,8 @@ ValueObject::ExpandArraySliceExpression(
                     {
                         if (root_clang_type_info.Test(ClangASTContext::eTypeIsArray))
                         {
-                            int max_index = root->GetNumChildren() - 1;
-                            for (int index = 0; index < max_index; index++)
+                            const size_t max_index = root->GetNumChildren() - 1;
+                            for (size_t index = 0; index < max_index; index++)
                             {
                                 ValueObjectSP child = 
                                 root->GetChildAtIndex(index, true);
@@ -3161,7 +3387,7 @@ DumpValueObject_Impl (Stream &s,
 {
     if (valobj)
     {
-        bool update_success = valobj->UpdateValueIfNeeded (options.m_use_dynamic, true);
+        bool update_success = valobj->UpdateValueIfNeeded (true);
 
         const char *root_valobj_name = 
             options.m_root_valobj_name.empty() ? 
@@ -3203,47 +3429,24 @@ DumpValueObject_Impl (Stream &s,
             
             if (show_type)
             {
-                const char* typeName = valobj->GetQualifiedTypeName().AsCString("<invalid type>");
-                //const char* typeName = valobj->GetTypeName().AsCString("<invalid type>");
-                s.Printf("(%s", typeName);
-                // only show dynamic types if the user really wants to see types
-                if (options.m_show_types && options.m_use_dynamic != eNoDynamicValues &&
-                    (/*strstr(typeName, "id") == typeName ||*/
-                     ClangASTType::GetMinimumLanguage(valobj->GetClangAST(), valobj->GetClangType()) == eLanguageTypeObjC))
-                {
-                    ExecutionContext exe_ctx (valobj->GetExecutionContextRef());
-                    Process *process = exe_ctx.GetProcessPtr();
-                    if (process == NULL)
-                        s.Printf(", dynamic type: unknown) ");
-                    else
-                    {
-                        ObjCLanguageRuntime *runtime = process->GetObjCLanguageRuntime();
-                        if (runtime == NULL)
-                            s.Printf(", dynamic type: unknown) ");
-                        else
-                        {
-                            ObjCLanguageRuntime::ObjCISA isa = runtime->GetISA(*valobj);
-                            if (!runtime->IsValidISA(isa))
-                                s.Printf(", dynamic type: unknown) ");
-                            else
-                                s.Printf(", dynamic type: %s) ",
-                                         runtime->GetActualTypeName(isa).GetCString());
-                        }
-                    }
-                }
-                else
-                    s.Printf(") ");
+                // Some ValueObjects don't have types (like registers sets). Only print
+                // the type if there is one to print
+                ConstString qualified_type_name(valobj->GetQualifiedTypeName());
+                if (qualified_type_name)
+                    s.Printf("(%s) ", qualified_type_name.GetCString());
             }
 
-
             if (options.m_flat_output)
             {
                 // If we are showing types, also qualify the C++ base classes 
                 const bool qualify_cxx_base_classes = options.m_show_types;
-                valobj->GetExpressionPath(s, qualify_cxx_base_classes);
-                s.PutCString(" =");
+                if (!options.m_hide_name)
+                {
+                    valobj->GetExpressionPath(s, qualify_cxx_base_classes);
+                    s.PutCString(" =");
+                }
             }
-            else
+            else if (!options.m_hide_name)
             {
                 const char *name_cstr = root_valobj_name ? root_valobj_name : valobj->GetName().AsCString("");
                 s.Printf ("%s =", name_cstr);
@@ -3264,6 +3467,8 @@ DumpValueObject_Impl (Stream &s,
         if (options.m_omit_summary_depth > 0)
             entry = NULL;
         
+        bool is_nil = valobj->IsObjCNil();
+        
         if (err_cstr == NULL)
         {
             if (options.m_format != eFormatDefault && options.m_format != valobj->GetFormat())
@@ -3289,7 +3494,9 @@ DumpValueObject_Impl (Stream &s,
             const bool is_ref = type_flags.Test (ClangASTContext::eTypeIsReference);
             if (print_valobj)
             {
-                if (options.m_omit_summary_depth == 0)
+                if (is_nil)
+                    sum_cstr = "nil";
+                else if (options.m_omit_summary_depth == 0)
                 {
                     if (options.m_summary_sp)
                     {
@@ -3301,20 +3508,25 @@ DumpValueObject_Impl (Stream &s,
                 }
 
                 // Make sure we have a value and make sure the summary didn't
-                // specify that the value should not be printed
-                if (!value_str.empty() && (entry == NULL || entry->DoesPrintValue() || sum_cstr == NULL))
+                // specify that the value should not be printed - and do not print
+                // the value if this thing is nil
+                // (but show the value if the user passes a format explicitly)
+                if (!is_nil && !value_str.empty() && (entry == NULL || (entry->DoesPrintValue() || options.m_format != eFormatDefault) || sum_cstr == NULL) && !options.m_hide_value)
                     s.Printf(" %s", value_str.c_str());
 
                 if (sum_cstr)
                     s.Printf(" %s", sum_cstr);
                 
-                if (options.m_use_objc)
+                // let's avoid the overly verbose no description error for a nil thing
+                if (options.m_use_objc && !is_nil)
                 {
+                    if (!options.m_hide_value || !options.m_hide_name)
+                        s.Printf(" ");
                     const char *object_desc = valobj->GetObjectDescription();
                     if (object_desc)
-                        s.Printf(" %s\n", object_desc);
+                        s.Printf("%s\n", object_desc);
                     else
-                        s.Printf (" [no Objective-C description available]\n");
+                        s.Printf ("[no Objective-C description available]\n");
                     return;
                 }
             }
@@ -3355,11 +3567,10 @@ DumpValueObject_Impl (Stream &s,
                 
                 if (print_children && (!entry || entry->DoesPrintChildren() || !sum_cstr))
                 {
-                    ValueObject* synth_valobj;
                     ValueObjectSP synth_valobj_sp = valobj->GetSyntheticValue (options.m_use_synthetic);
-                    synth_valobj = (synth_valobj_sp ? synth_valobj_sp.get() : valobj);
+                    ValueObject* synth_valobj = (synth_valobj_sp ? synth_valobj_sp.get() : valobj);
                     
-                    uint32_t num_children = synth_valobj->GetNumChildren();
+                    size_t num_children = synth_valobj->GetNumChildren();
                     bool print_dotdotdot = false;
                     if (num_children)
                     {
@@ -3375,7 +3586,7 @@ DumpValueObject_Impl (Stream &s,
                             s.IndentMore();
                         }
                         
-                        uint32_t max_num_children = valobj->GetTargetSP()->GetMaximumNumberOfChildrenToDisplay();
+                        const size_t max_num_children = valobj->GetTargetSP()->GetMaximumNumberOfChildrenToDisplay();
                         
                         if (num_children > max_num_children && !options.m_ignore_cap)
                         {
@@ -3384,10 +3595,10 @@ DumpValueObject_Impl (Stream &s,
                         }
 
                         ValueObject::DumpValueObjectOptions child_options(options);
-                        child_options.SetFormat().SetSummary().SetRootValueObjectName();
-                        child_options.SetScopeChecked(true)
+                        child_options.SetFormat(options.m_format).SetSummary().SetRootValueObjectName();
+                        child_options.SetScopeChecked(true).SetHideName(options.m_hide_name).SetHideValue(options.m_hide_value)
                         .SetOmitSummaryDepth(child_options.m_omit_summary_depth > 1 ? child_options.m_omit_summary_depth - 1 : 0);
-                        for (uint32_t idx=0; idx<num_children; ++idx)
+                        for (size_t idx=0; idx<num_children; ++idx)
                         {
                             ValueObjectSP child_sp(synth_valobj->GetChildAtIndex(idx, true));
                             if (child_sp.get())
@@ -3623,7 +3834,6 @@ ValueObject::AddressOf (Error &error)
     {
         switch (address_type)
         {
-        default:
         case eAddressTypeInvalid:
             {
                 StreamString expr_path_strm;
@@ -3655,6 +3865,13 @@ ValueObject::AddressOf (Error &error)
             break;
         }
     }
+    else
+    {
+        StreamString expr_path_strm;
+        GetExpressionPath(expr_path_strm, true);
+        error.SetErrorStringWithFormat("'%s' doesn't have a valid address", expr_path_strm.GetString().c_str());
+    }
+    
     return m_addr_of_valobj_sp;
 }
 
@@ -3989,3 +4206,131 @@ ValueObject::GetSymbolContextScope()
     }
     return NULL;
 }
+
+lldb::ValueObjectSP
+ValueObject::CreateValueObjectFromExpression (const char* name,
+                                              const char* expression,
+                                              const ExecutionContext& exe_ctx)
+{
+    lldb::ValueObjectSP retval_sp;
+    lldb::TargetSP target_sp(exe_ctx.GetTargetSP());
+    if (!target_sp)
+        return retval_sp;
+    if (!expression || !*expression)
+        return retval_sp;
+    target_sp->EvaluateExpression (expression,
+                                   exe_ctx.GetFrameSP().get(),
+                                   retval_sp);
+    if (retval_sp && name && *name)
+        retval_sp->SetName(ConstString(name));
+    return retval_sp;
+}
+
+lldb::ValueObjectSP
+ValueObject::CreateValueObjectFromAddress (const char* name,
+                                           uint64_t address,
+                                           const ExecutionContext& exe_ctx,
+                                           ClangASTType type)
+{
+    ClangASTType pointer_type(type.GetASTContext(),type.GetPointerType());
+    lldb::DataBufferSP buffer(new lldb_private::DataBufferHeap(&address,sizeof(lldb::addr_t)));
+    lldb::ValueObjectSP ptr_result_valobj_sp(ValueObjectConstResult::Create (exe_ctx.GetBestExecutionContextScope(),
+                                                                             pointer_type.GetASTContext(),
+                                                                             pointer_type.GetOpaqueQualType(),
+                                                                             ConstString(name),
+                                                                             buffer,
+                                                                             lldb::endian::InlHostByteOrder(),
+                                                                             exe_ctx.GetAddressByteSize()));
+    if (ptr_result_valobj_sp)
+    {
+        ptr_result_valobj_sp->GetValue().SetValueType(Value::eValueTypeLoadAddress);
+        Error err;
+        ptr_result_valobj_sp = ptr_result_valobj_sp->Dereference(err);
+        if (ptr_result_valobj_sp && name && *name)
+            ptr_result_valobj_sp->SetName(ConstString(name));
+    }
+    return ptr_result_valobj_sp;
+}
+
+lldb::ValueObjectSP
+ValueObject::CreateValueObjectFromData (const char* name,
+                                        DataExtractor& data,
+                                        const ExecutionContext& exe_ctx,
+                                        ClangASTType type)
+{
+    lldb::ValueObjectSP new_value_sp;
+    new_value_sp = ValueObjectConstResult::Create (exe_ctx.GetBestExecutionContextScope(),
+                                                   type.GetASTContext() ,
+                                                   type.GetOpaqueQualType(),
+                                                   ConstString(name),
+                                                   data,
+                                                   LLDB_INVALID_ADDRESS);
+    new_value_sp->SetAddressTypeOfChildren(eAddressTypeLoad);
+    if (new_value_sp && name && *name)
+        new_value_sp->SetName(ConstString(name));
+    return new_value_sp;
+}
+
+ModuleSP
+ValueObject::GetModule ()
+{
+    ValueObject* root(GetRoot());
+    if (root != this)
+        return root->GetModule();
+    return lldb::ModuleSP();
+}
+
+ValueObject*
+ValueObject::GetRoot ()
+{
+    if (m_root)
+        return m_root;
+    ValueObject* parent = m_parent;
+    if (!parent)
+        return (m_root = this);
+    while (parent->m_parent)
+    {
+        if (parent->m_root)
+            return (m_root = parent->m_root);
+        parent = parent->m_parent;
+    }
+    return (m_root = parent);
+}
+
+AddressType
+ValueObject::GetAddressTypeOfChildren()
+{
+    if (m_address_type_of_ptr_or_ref_children == eAddressTypeInvalid)
+    {
+        ValueObject* root(GetRoot());
+        if (root != this)
+            return root->GetAddressTypeOfChildren();
+    }
+    return m_address_type_of_ptr_or_ref_children;
+}
+
+lldb::DynamicValueType
+ValueObject::GetDynamicValueType ()
+{
+    ValueObject* with_dv_info = this;
+    while (with_dv_info)
+    {
+        if (with_dv_info->HasDynamicValueTypeInfo())
+            return with_dv_info->GetDynamicValueTypeImpl();
+        with_dv_info = with_dv_info->m_parent;
+    }
+    return lldb::eNoDynamicValues;
+}
+
+lldb::Format
+ValueObject::GetFormat () const
+{
+    const ValueObject* with_fmt_info = this;
+    while (with_fmt_info)
+    {
+        if (with_fmt_info->m_format != lldb::eFormatDefault)
+            return with_fmt_info->m_format;
+        with_fmt_info = with_fmt_info->m_parent;
+    }
+    return m_format;
+}

Modified: lldb/branches/lldb-platform-work/source/Core/ValueObjectChild.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/lldb-platform-work/source/Core/ValueObjectChild.cpp?rev=183468&r1=183467&r2=183468&view=diff
==============================================================================
--- lldb/branches/lldb-platform-work/source/Core/ValueObjectChild.cpp (original)
+++ lldb/branches/lldb-platform-work/source/Core/ValueObjectChild.cpp Thu Jun  6 19:06:43 2013
@@ -30,7 +30,7 @@ ValueObjectChild::ValueObjectChild
     clang::ASTContext *clang_ast,
     void *clang_type,
     const ConstString &name,
-    uint32_t byte_size,
+    uint64_t byte_size,
     int32_t byte_offset,
     uint32_t bitfield_bit_size,
     uint32_t bitfield_bit_offset,
@@ -62,7 +62,7 @@ ValueObjectChild::GetValueType() const
     return m_parent->GetValueType();
 }
 
-uint32_t
+size_t
 ValueObjectChild::CalculateNumChildren()
 {
     return ClangASTContext::GetNumChildren (GetClangAST (), GetClangType(), true);
@@ -164,7 +164,6 @@ ValueObjectChild::UpdateValue ()
                             m_value.SetValueType(Value::eValueTypeHostAddress);
                             break;
                         case eAddressTypeInvalid:
-                        default:
                             // TODO: does this make sense?
                             m_value.SetValueType(Value::eValueTypeScalar);
                             break;
@@ -230,5 +229,8 @@ ValueObjectChild::UpdateValue ()
 bool
 ValueObjectChild::IsInScope ()
 {
-    return m_parent->IsInScope ();
+    ValueObject* root(GetRoot());
+    if (root)
+        return root->IsInScope ();
+    return false;
 }

Modified: lldb/branches/lldb-platform-work/source/Core/ValueObjectConstResult.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/lldb-platform-work/source/Core/ValueObjectConstResult.cpp?rev=183468&r1=183467&r2=183468&view=diff
==============================================================================
--- lldb/branches/lldb-platform-work/source/Core/ValueObjectConstResult.cpp (original)
+++ lldb/branches/lldb-platform-work/source/Core/ValueObjectConstResult.cpp Thu Jun  6 19:06:43 2013
@@ -124,7 +124,7 @@ ValueObjectConstResult::Create
     const ConstString &name,
     const lldb::DataBufferSP &data_sp,
     lldb::ByteOrder data_byte_order, 
-    uint8_t data_addr_size,
+    uint32_t data_addr_size,
     lldb::addr_t address
 )
 {
@@ -155,7 +155,7 @@ ValueObjectConstResult::ValueObjectConst
     const ConstString &name,
     const lldb::DataBufferSP &data_sp,
     lldb::ByteOrder data_byte_order, 
-    uint8_t data_addr_size,
+    uint32_t data_addr_size,
     lldb::addr_t address
 ) :
     ValueObject (exe_scope),
@@ -185,7 +185,7 @@ ValueObjectConstResult::Create
     const ConstString &name,
     lldb::addr_t address,
     AddressType address_type,
-    uint8_t addr_byte_size
+    uint32_t addr_byte_size
 )
 {
     return (new ValueObjectConstResult (exe_scope,
@@ -205,7 +205,7 @@ ValueObjectConstResult::ValueObjectConst
     const ConstString &name,
     lldb::addr_t address,
     AddressType address_type,
-    uint8_t addr_byte_size
+    uint32_t addr_byte_size
 ) :
     ValueObject (exe_scope),
     m_clang_ast (clang_ast),
@@ -219,7 +219,6 @@ ValueObjectConstResult::ValueObjectConst
     //m_value.SetValueType(Value::eValueTypeHostAddress); 
     switch (address_type)
     {
-    default:
     case eAddressTypeInvalid:   m_value.SetValueType(Value::eValueTypeScalar);      break;
     case eAddressTypeFile:      m_value.SetValueType(Value::eValueTypeFileAddress); break;
     case eAddressTypeLoad:      m_value.SetValueType(Value::eValueTypeLoadAddress); break;    
@@ -287,7 +286,7 @@ ValueObjectConstResult::GetValueType() c
     return eValueTypeConstResult;
 }
 
-size_t
+uint64_t
 ValueObjectConstResult::GetByteSize()
 {
     if (m_byte_size == 0)
@@ -301,7 +300,7 @@ ValueObjectConstResult::SetByteSize (siz
     m_byte_size = size;
 }
 
-uint32_t
+size_t
 ValueObjectConstResult::CalculateNumChildren()
 {
     return ClangASTContext::GetNumChildren (GetClangAST (), GetClangType(), true);
@@ -364,7 +363,7 @@ ValueObjectConstResult::GetAddressOf (bo
 }
 
 ValueObject *
-ValueObjectConstResult::CreateChildAtIndex (uint32_t idx, bool synthetic_array_member, int32_t synthetic_index)
+ValueObjectConstResult::CreateChildAtIndex (size_t idx, bool synthetic_array_member, int32_t synthetic_index)
 {
     return m_impl.CreateChildAtIndex(idx, synthetic_array_member, synthetic_index);
 }

Modified: lldb/branches/lldb-platform-work/source/Core/ValueObjectConstResultChild.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/lldb-platform-work/source/Core/ValueObjectConstResultChild.cpp?rev=183468&r1=183467&r2=183468&view=diff
==============================================================================
--- lldb/branches/lldb-platform-work/source/Core/ValueObjectConstResultChild.cpp (original)
+++ lldb/branches/lldb-platform-work/source/Core/ValueObjectConstResultChild.cpp Thu Jun  6 19:06:43 2013
@@ -68,7 +68,7 @@ ValueObjectConstResultChild::AddressOf (
 }
 
 ValueObject *
-ValueObjectConstResultChild::CreateChildAtIndex (uint32_t idx, bool synthetic_array_member, int32_t synthetic_index)
+ValueObjectConstResultChild::CreateChildAtIndex (size_t idx, bool synthetic_array_member, int32_t synthetic_index)
 {
     return m_impl.CreateChildAtIndex(idx, synthetic_array_member, synthetic_index);
 }

Modified: lldb/branches/lldb-platform-work/source/Core/ValueObjectConstResultImpl.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/lldb-platform-work/source/Core/ValueObjectConstResultImpl.cpp?rev=183468&r1=183467&r2=183468&view=diff
==============================================================================
--- lldb/branches/lldb-platform-work/source/Core/ValueObjectConstResultImpl.cpp (original)
+++ lldb/branches/lldb-platform-work/source/Core/ValueObjectConstResultImpl.cpp Thu Jun  6 19:06:43 2013
@@ -84,7 +84,7 @@ ValueObjectConstResultImpl::Dereference
 }
 
 ValueObject *
-ValueObjectConstResultImpl::CreateChildAtIndex (uint32_t idx, bool synthetic_array_member, int32_t synthetic_index)
+ValueObjectConstResultImpl::CreateChildAtIndex (size_t idx, bool synthetic_array_member, int32_t synthetic_index)
 {
     if (m_impl_backend == NULL)
         return NULL;

Modified: lldb/branches/lldb-platform-work/source/Core/ValueObjectDynamicValue.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/lldb-platform-work/source/Core/ValueObjectDynamicValue.cpp?rev=183468&r1=183467&r2=183468&view=diff
==============================================================================
--- lldb/branches/lldb-platform-work/source/Core/ValueObjectDynamicValue.cpp (original)
+++ lldb/branches/lldb-platform-work/source/Core/ValueObjectDynamicValue.cpp Thu Jun  6 19:06:43 2013
@@ -14,11 +14,13 @@
 // C++ Includes
 // Other libraries and framework includes
 // Project includes
+#include "lldb/Core/Log.h"
 #include "lldb/Core/Module.h"
 #include "lldb/Core/ValueObjectList.h"
 #include "lldb/Core/Value.h"
 #include "lldb/Core/ValueObject.h"
 
+#include "lldb/Symbol/ClangASTType.h"
 #include "lldb/Symbol/ObjectFile.h"
 #include "lldb/Symbol/SymbolContext.h"
 #include "lldb/Symbol/Type.h"
@@ -31,119 +33,14 @@
 #include "lldb/Target/Target.h"
 #include "lldb/Target/Thread.h"
 
-
 using namespace lldb_private;
 
-lldb::ValueObjectSP
-ValueObjectCast::Create (ValueObject &parent, 
-                         const ConstString &name, 
-                         const ClangASTType &cast_type)
-{
-    ValueObjectCast *cast_valobj_ptr = new ValueObjectCast (parent, name, cast_type);
-    return cast_valobj_ptr->GetSP();
-}
-
-ValueObjectCast::ValueObjectCast
-(
-    ValueObject &parent, 
-    const ConstString &name, 
-    const ClangASTType &cast_type
-) :
-    ValueObject(parent),
-    m_cast_type (cast_type)
-{
-    SetName (name);
-    m_value.SetContext (Value::eContextTypeClangType, cast_type.GetOpaqueQualType());
-}
-
-ValueObjectCast::~ValueObjectCast()
-{
-}
-
-lldb::clang_type_t
-ValueObjectCast::GetClangTypeImpl ()
-{
-    return m_cast_type.GetOpaqueQualType();
-}
-
-uint32_t
-ValueObjectCast::CalculateNumChildren()
-{
-    return ClangASTContext::GetNumChildren (GetClangAST (), GetClangType(), true);
-}
-
-clang::ASTContext *
-ValueObjectCast::GetClangASTImpl ()
-{
-    return m_cast_type.GetASTContext();
-}
-
-size_t
-ValueObjectCast::GetByteSize()
-{
-    return m_value.GetValueByteSize(GetClangAST(), NULL);
-}
-
-lldb::ValueType
-ValueObjectCast::GetValueType() const
-{
-    // Let our parent answer global, local, argument, etc...
-    return m_parent->GetValueType();
-}
-
-bool
-ValueObjectCast::UpdateValue ()
-{
-    SetValueIsValid (false);
-    m_error.Clear();
-    
-    if (m_parent->UpdateValueIfNeeded(false))
-    {
-        Value old_value(m_value);
-        m_update_point.SetUpdated();
-        m_value = m_parent->GetValue();
-        m_value.SetContext (Value::eContextTypeClangType, GetClangType());
-        SetAddressTypeOfChildren(m_parent->GetAddressTypeOfChildren());
-        if (ClangASTContext::IsAggregateType (GetClangType()))
-        {
-            // this value object represents an aggregate type whose
-            // children have values, but this object does not. So we
-            // say we are changed if our location has changed.
-            SetValueDidChange (m_value.GetValueType() != old_value.GetValueType() || m_value.GetScalar() != old_value.GetScalar());
-        } 
-        ExecutionContext exe_ctx (GetExecutionContextRef());
-        m_error = m_value.GetValueAsData(&exe_ctx, GetClangAST(), m_data, 0, GetModule().get());
-        SetValueDidChange (m_parent->GetValueDidChange());
-        return true;
-    }
-    
-    // The dynamic value failed to get an error, pass the error along
-    if (m_error.Success() && m_parent->GetError().Fail())
-        m_error = m_parent->GetError();
-    SetValueIsValid (false);
-    return false;
-}
-
-
-
-bool
-ValueObjectCast::IsInScope ()
-{
-    return m_parent->IsInScope();
-}
-
-//----------------------------------------------------------------------
-
-
-
-
 ValueObjectDynamicValue::ValueObjectDynamicValue (ValueObject &parent, lldb::DynamicValueType use_dynamic) :
     ValueObject(parent),
     m_address (),
-    m_type_sp(),
+    m_dynamic_type_info(),
     m_use_dynamic (use_dynamic)
 {
-    m_last_format_mgr_dynamic = use_dynamic;
     SetName (parent.GetName());
 }
 
@@ -155,7 +52,7 @@ ValueObjectDynamicValue::~ValueObjectDyn
 lldb::clang_type_t
 ValueObjectDynamicValue::GetClangTypeImpl ()
 {
-    if (m_type_sp)
+    if (m_dynamic_type_info.HasTypeSP())
         return m_value.GetClangType();
     else
         return m_parent->GetClangType();
@@ -165,17 +62,35 @@ ConstString
 ValueObjectDynamicValue::GetTypeName()
 {
     const bool success = UpdateValueIfNeeded(false);
-    if (success && m_type_sp)
-        return ClangASTType::GetConstTypeName (GetClangAST(), GetClangType());
-    else
-        return m_parent->GetTypeName();
+    if (success)
+    {
+        if (m_dynamic_type_info.HasTypeSP())
+            return ClangASTType::GetConstTypeName (GetClangAST(), GetClangType());
+        if (m_dynamic_type_info.HasName())
+            return m_dynamic_type_info.GetName();
+    }
+    return m_parent->GetTypeName();
+}
+
+ConstString
+ValueObjectDynamicValue::GetQualifiedTypeName()
+{
+    const bool success = UpdateValueIfNeeded(false);
+    if (success)
+    {
+        if (m_dynamic_type_info.HasTypeSP())
+            return ClangASTType::GetConstQualifiedTypeName (GetClangAST(), GetClangType());
+        if (m_dynamic_type_info.HasName())
+            return m_dynamic_type_info.GetName();
+    }
+    return m_parent->GetTypeName();
 }
 
-uint32_t
+size_t
 ValueObjectDynamicValue::CalculateNumChildren()
 {
     const bool success = UpdateValueIfNeeded(false);
-    if (success && m_type_sp)
+    if (success && m_dynamic_type_info.HasTypeSP())
         return ClangASTContext::GetNumChildren (GetClangAST (), GetClangType(), true);
     else
         return m_parent->GetNumChildren();
@@ -185,17 +100,17 @@ clang::ASTContext *
 ValueObjectDynamicValue::GetClangASTImpl ()
 {
     const bool success = UpdateValueIfNeeded(false);
-    if (success && m_type_sp)
-        return m_type_sp->GetClangAST();
+    if (success && m_dynamic_type_info.HasTypeSP())
+        return m_dynamic_type_info.GetTypeSP()->GetClangAST();
     else
         return m_parent->GetClangAST ();
 }
 
-size_t
+uint64_t
 ValueObjectDynamicValue::GetByteSize()
 {
     const bool success = UpdateValueIfNeeded(false);
-    if (success && m_type_sp)
+    if (success && m_dynamic_type_info.HasTypeSP())
         return m_value.GetValueByteSize(GetClangAST(), NULL);
     else
         return m_parent->GetByteSize();
@@ -225,7 +140,7 @@ ValueObjectDynamicValue::UpdateValue ()
     // parent which is equivalent to not using dynamic values.
     if (m_use_dynamic == lldb::eNoDynamicValues)
     {
-        m_type_sp.reset();
+        m_dynamic_type_info.Clear();
         return true;
     }
     
@@ -267,8 +182,6 @@ ValueObjectDynamicValue::UpdateValue ()
         }
     }
     
-    lldb::TypeSP dynamic_type_sp = class_type_or_name.GetTypeSP();
-    
     // Getting the dynamic value may have run the program a bit, and so marked us as needing updating, but we really
     // don't...
     
@@ -278,8 +191,10 @@ ValueObjectDynamicValue::UpdateValue ()
     // Or we could return false, and make ourselves an echo of our parent?
     if (!found_dynamic_type)
     {
-        if (m_type_sp)
+        if (m_dynamic_type_info)
             SetValueDidChange(true);
+        ClearDynamicTypeInformation();
+        m_dynamic_type_info.Clear();
         m_value = m_parent->GetValue();
         m_error = m_value.GetValueAsData (&exe_ctx, GetClangAST(), m_data, 0, GetModule().get());
         return m_error.Success();
@@ -287,17 +202,26 @@ ValueObjectDynamicValue::UpdateValue ()
     
     Value old_value(m_value);
 
-    if (!m_type_sp)
+    Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_TYPES));
+    
+    bool has_changed_type = false;
+    
+    if (!m_dynamic_type_info)
     {
-        m_type_sp = dynamic_type_sp;
+        m_dynamic_type_info = class_type_or_name;
+        has_changed_type = true;
     }
-    else if (dynamic_type_sp != m_type_sp)
+    else if (class_type_or_name != m_dynamic_type_info)
     {
         // We are another type, we need to tear down our children...
-        m_type_sp = dynamic_type_sp;
+        m_dynamic_type_info = class_type_or_name;
         SetValueDidChange (true);
+        has_changed_type = true;
     }
     
+    if (has_changed_type)
+        ClearDynamicTypeInformation ();
+    
     if (!m_address.IsValid() || m_address != dynamic_address)
     {
         if (m_address.IsValid())
@@ -310,23 +234,47 @@ ValueObjectDynamicValue::UpdateValue ()
         m_value.GetScalar() = load_address;
     }
     
-    // The type will always be the type of the dynamic object.  If our parent's type was a pointer,
-    // then our type should be a pointer to the type of the dynamic object.  If a reference, then the original type
-    // should be okay...
-    lldb::clang_type_t orig_type = m_type_sp->GetClangForwardType();
-    lldb::clang_type_t corrected_type = orig_type;
-    if (m_parent->IsPointerType())
-        corrected_type = ClangASTContext::CreatePointerType (m_type_sp->GetClangAST(), orig_type);
-    else if (m_parent->IsPointerOrReferenceType())
-        corrected_type = ClangASTContext::CreateLValueReferenceType (m_type_sp->GetClangAST(), orig_type);
-        
+    lldb::clang_type_t corrected_type;
+    if (m_dynamic_type_info.HasTypeSP())
+    {
+        // The type will always be the type of the dynamic object.  If our parent's type was a pointer,
+        // then our type should be a pointer to the type of the dynamic object.  If a reference, then the original type
+        // should be okay...
+        lldb::clang_type_t orig_type;
+        clang::ASTContext* ast;
+        orig_type = m_dynamic_type_info.GetTypeSP()->GetClangForwardType();
+        ast = m_dynamic_type_info.GetTypeSP()->GetClangAST();
+        corrected_type = orig_type;
+        if (m_parent->IsPointerType())
+            corrected_type = ClangASTContext::CreatePointerType (ast, orig_type);
+        else if (m_parent->IsPointerOrReferenceType())
+            corrected_type = ClangASTContext::CreateLValueReferenceType (ast, orig_type);
+    }
+    else /*if (m_dynamic_type_info.HasName())*/
+    {
+        // If we are here we need to adjust our dynamic type name to include the correct & or * symbol
+        std::string type_name_buf (m_dynamic_type_info.GetName().GetCString());
+        if (m_parent->IsPointerType())
+            type_name_buf.append(" *");
+        else if (m_parent->IsPointerOrReferenceType())
+            type_name_buf.append(" &");
+        corrected_type = m_parent->GetClangType();
+        m_dynamic_type_info.SetName(type_name_buf.c_str());
+    }
+    
     m_value.SetContext (Value::eContextTypeClangType, corrected_type);
     
     // Our address is the location of the dynamic type stored in memory.  It isn't a load address,
     // because we aren't pointing to the LOCATION that stores the pointer to us, we're pointing to us...
     m_value.SetValueType(Value::eValueTypeScalar);
 
-    if (m_address.IsValid() && m_type_sp)
+    if (has_changed_type && log)
+        log->Printf("[%s %p] has a new dynamic type %s",
+                    GetName().GetCString(),
+                    this,
+                    GetTypeName().GetCString());
+    
+    if (m_address.IsValid() && m_dynamic_type_info)
     {
         // The variable value is in the Scalar value inside the m_value.
         // We can point our m_data right to it.
@@ -395,3 +343,42 @@ ValueObjectDynamicValue::SetValueFromCSt
     SetNeedsUpdate();
     return ret_val;
 }
+
+bool
+ValueObjectDynamicValue::SetData (DataExtractor &data, Error &error)
+{
+    if (!UpdateValueIfNeeded(false))
+    {
+        error.SetErrorString("unable to read value");
+        return false;
+    }
+    
+    uint64_t my_value = GetValueAsUnsigned(UINT64_MAX);
+    uint64_t parent_value = m_parent->GetValueAsUnsigned(UINT64_MAX);
+    
+    if (my_value == UINT64_MAX || parent_value == UINT64_MAX)
+    {
+        error.SetErrorString("unable to read value");
+        return false;
+    }
+    
+    // if we are at an offset from our parent, in order to set ourselves correctly we would need
+    // to change the new value so that it refers to the correct dynamic type. we choose not to deal
+    // with that - if anything more than a value overwrite is required, you should be using the
+    // expression parser instead of the value editing facility
+    if (my_value != parent_value)
+    {
+        // but NULL'ing out a value should always be allowed
+        lldb::offset_t offset = 0;
+        
+        if (data.GetPointer(&offset) != 0)
+        {
+            error.SetErrorString("unable to modify dynamic value, use 'expression' command");
+            return false;
+        }
+    }
+    
+    bool ret_val = m_parent->SetData(data, error);
+    SetNeedsUpdate();
+    return ret_val;
+}

Modified: lldb/branches/lldb-platform-work/source/Core/ValueObjectList.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/lldb-platform-work/source/Core/ValueObjectList.cpp?rev=183468&r1=183467&r2=183468&view=diff
==============================================================================
--- lldb/branches/lldb-platform-work/source/Core/ValueObjectList.cpp (original)
+++ lldb/branches/lldb-platform-work/source/Core/ValueObjectList.cpp Thu Jun  6 19:06:43 2013
@@ -61,20 +61,20 @@ ValueObjectList::Append (const ValueObje
 }
 
 
-uint32_t
+size_t
 ValueObjectList::GetSize() const
 {
     return m_value_objects.size();
 }
 
 void
-ValueObjectList::Resize (uint32_t size)
+ValueObjectList::Resize (size_t size)
 {
     m_value_objects.resize (size);
 }
 
 lldb::ValueObjectSP
-ValueObjectList::GetValueObjectAtIndex (uint32_t idx)
+ValueObjectList::GetValueObjectAtIndex (size_t idx)
 {
     lldb::ValueObjectSP valobj_sp;
     if (idx < m_value_objects.size())
@@ -83,7 +83,7 @@ ValueObjectList::GetValueObjectAtIndex (
 }
 
 lldb::ValueObjectSP
-ValueObjectList::RemoveValueObjectAtIndex (uint32_t idx)
+ValueObjectList::RemoveValueObjectAtIndex (size_t idx)
 {
     lldb::ValueObjectSP valobj_sp;
     if (idx < m_value_objects.size())
@@ -95,7 +95,7 @@ ValueObjectList::RemoveValueObjectAtInde
 }
 
 void
-ValueObjectList::SetValueObjectAtIndex (uint32_t idx, const ValueObjectSP &valobj_sp)
+ValueObjectList::SetValueObjectAtIndex (size_t idx, const ValueObjectSP &valobj_sp)
 {
     if (idx >= m_value_objects.size())
         m_value_objects.resize (idx + 1);

Modified: lldb/branches/lldb-platform-work/source/Core/ValueObjectMemory.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/lldb-platform-work/source/Core/ValueObjectMemory.cpp?rev=183468&r1=183467&r2=183468&view=diff
==============================================================================
--- lldb/branches/lldb-platform-work/source/Core/ValueObjectMemory.cpp (original)
+++ lldb/branches/lldb-platform-work/source/Core/ValueObjectMemory.cpp Thu Jun  6 19:06:43 2013
@@ -146,7 +146,7 @@ ValueObjectMemory::GetTypeName()
     return ClangASTType::GetConstTypeName (GetClangAST(), m_clang_type.GetOpaqueQualType());
 }
 
-uint32_t
+size_t
 ValueObjectMemory::CalculateNumChildren()
 {
     if (m_type_sp)
@@ -165,12 +165,12 @@ ValueObjectMemory::GetClangASTImpl ()
     return m_clang_type.GetASTContext();
 }
 
-size_t
+uint64_t
 ValueObjectMemory::GetByteSize()
 {
     if (m_type_sp)
         return m_type_sp->GetByteSize();
-    return (m_clang_type.GetClangTypeBitWidth () + 7) / 8;
+    return m_clang_type.GetClangTypeByteSize ();
 }
 
 lldb::ValueType

Modified: lldb/branches/lldb-platform-work/source/Core/ValueObjectRegister.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/lldb-platform-work/source/Core/ValueObjectRegister.cpp?rev=183468&r1=183467&r2=183468&view=diff
==============================================================================
--- lldb/branches/lldb-platform-work/source/Core/ValueObjectRegister.cpp (original)
+++ lldb/branches/lldb-platform-work/source/Core/ValueObjectRegister.cpp Thu Jun  6 19:06:43 2013
@@ -60,7 +60,7 @@ ValueObjectRegisterContext::GetQualified
     return ConstString();
 }
 
-uint32_t
+size_t
 ValueObjectRegisterContext::CalculateNumChildren()
 {
     return m_reg_ctx_sp->GetRegisterSetCount();
@@ -72,7 +72,7 @@ ValueObjectRegisterContext::GetClangASTI
     return NULL;
 }
 
-size_t
+uint64_t
 ValueObjectRegisterContext::GetByteSize()
 {
     return 0;
@@ -101,11 +101,11 @@ ValueObjectRegisterContext::UpdateValue
 }
 
 ValueObject *
-ValueObjectRegisterContext::CreateChildAtIndex (uint32_t idx, bool synthetic_array_member, int32_t synthetic_index)
+ValueObjectRegisterContext::CreateChildAtIndex (size_t idx, bool synthetic_array_member, int32_t synthetic_index)
 {
     ValueObject *new_valobj = NULL;
     
-    const uint32_t num_children = GetNumChildren();
+    const size_t num_children = GetNumChildren();
     if (idx < num_children)
     {
         ExecutionContext exe_ctx(GetExecutionContextRef());
@@ -162,7 +162,7 @@ ValueObjectRegisterSet::GetQualifiedType
     return ConstString();
 }
 
-uint32_t
+size_t
 ValueObjectRegisterSet::CalculateNumChildren()
 {
     const RegisterSet *reg_set = m_reg_ctx_sp->GetRegisterSet(m_reg_set_idx);
@@ -177,7 +177,7 @@ ValueObjectRegisterSet::GetClangASTImpl
     return NULL;
 }
 
-size_t
+uint64_t
 ValueObjectRegisterSet::GetByteSize()
 {
     return 0;
@@ -222,12 +222,12 @@ ValueObjectRegisterSet::UpdateValue ()
 
 
 ValueObject *
-ValueObjectRegisterSet::CreateChildAtIndex (uint32_t idx, bool synthetic_array_member, int32_t synthetic_index)
+ValueObjectRegisterSet::CreateChildAtIndex (size_t idx, bool synthetic_array_member, int32_t synthetic_index)
 {
     ValueObject *valobj = NULL;
     if (m_reg_ctx_sp && m_reg_set)
     {
-        const uint32_t num_children = GetNumChildren();
+        const size_t num_children = GetNumChildren();
         if (idx < num_children)
             valobj = new ValueObjectRegister(*this, m_reg_ctx_sp, m_reg_set->registers[idx]);
     }
@@ -250,7 +250,7 @@ ValueObjectRegisterSet::GetChildMemberWi
         return ValueObjectSP();
 }
 
-uint32_t
+size_t
 ValueObjectRegisterSet::GetIndexOfChildWithName (const ConstString &name)
 {
     if (m_reg_ctx_sp && m_reg_set)
@@ -341,10 +341,10 @@ ValueObjectRegister::GetTypeName()
     return m_type_name;
 }
 
-uint32_t
+size_t
 ValueObjectRegister::CalculateNumChildren()
 {
-    return 0;
+    return ClangASTContext::GetNumChildren(GetClangAST(), GetClangType(), true);
 }
 
 clang::ASTContext *
@@ -361,7 +361,7 @@ ValueObjectRegister::GetClangASTImpl ()
     return NULL;
 }
 
-size_t
+uint64_t
 ValueObjectRegister::GetByteSize()
 {
     return m_reg_info.byte_size;
@@ -423,6 +423,24 @@ ValueObjectRegister::SetValueFromCString
 }
 
 bool
+ValueObjectRegister::SetData (DataExtractor &data, Error &error)
+{
+    error = m_reg_value.SetValueFromData(&m_reg_info, data, 0, false);
+    if (error.Success())
+    {
+        if (m_reg_ctx_sp->WriteRegister (&m_reg_info, m_reg_value))
+        {
+            SetNeedsUpdate();
+            return true;
+        }
+        else
+            return false;
+    }
+    else
+        return false;
+}
+
+bool
 ValueObjectRegister::ResolveValue (Scalar &scalar)
 {
     if (UpdateValueIfNeeded(false)) // make sure that you are up to date before returning anything
@@ -430,4 +448,10 @@ ValueObjectRegister::ResolveValue (Scala
     return false;
 }
 
+void
+ValueObjectRegister::GetExpressionPath (Stream &s, bool qualify_cxx_base_classes, GetExpressionPathFormat epformat)
+{
+    s.Printf("$%s", m_reg_info.name);
+}
+
 

Modified: lldb/branches/lldb-platform-work/source/Core/ValueObjectSyntheticFilter.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/lldb-platform-work/source/Core/ValueObjectSyntheticFilter.cpp?rev=183468&r1=183467&r2=183468&view=diff
==============================================================================
--- lldb/branches/lldb-platform-work/source/Core/ValueObjectSyntheticFilter.cpp (original)
+++ lldb/branches/lldb-platform-work/source/Core/ValueObjectSyntheticFilter.cpp Thu Jun  6 19:06:43 2013
@@ -7,6 +7,7 @@
 //
 //===----------------------------------------------------------------------===//
 
+#include "lldb/lldb-python.h"
 
 #include "lldb/Core/ValueObjectSyntheticFilter.h"
 
@@ -14,18 +15,58 @@
 // C++ Includes
 // Other libraries and framework includes
 // Project includes
-#include "lldb/Core/FormatClasses.h"
 #include "lldb/Core/ValueObject.h"
+#include "lldb/DataFormatters/FormatClasses.h"
 
 using namespace lldb_private;
 
+class DummySyntheticFrontEnd : public SyntheticChildrenFrontEnd
+{
+public:
+    DummySyntheticFrontEnd(ValueObject &backend) :
+    SyntheticChildrenFrontEnd(backend)
+    {}
+
+    size_t
+    CalculateNumChildren()
+    {
+        return 0;
+    }
+    
+    lldb::ValueObjectSP
+    GetChildAtIndex (size_t idx)
+    {
+        return lldb::ValueObjectSP();
+    }
+    
+    size_t
+    GetIndexOfChildWithName (const ConstString &name)
+    {
+        return UINT32_MAX;
+    }
+    
+    bool
+    MightHaveChildren ()
+    {
+        return true;
+    }
+    
+    bool
+    Update()
+    {
+        return false;
+    }
+
+};
+
 ValueObjectSynthetic::ValueObjectSynthetic (ValueObject &parent, lldb::SyntheticChildrenSP filter) :
     ValueObject(parent),
     m_synth_sp(filter),
-    m_synth_filter_ap(filter->GetFrontEnd(parent)),
     m_children_byindex(),
     m_name_toindex(),
-    m_synthetic_children_count(UINT32_MAX)
+    m_synthetic_children_count(UINT32_MAX),
+    m_parent_type_name(parent.GetTypeName()),
+    m_might_have_children(eLazyBoolCalculate)
 {
 #ifdef LLDB_CONFIGURATION_DEBUG
     std::string new_name(parent.GetName().AsCString());
@@ -34,6 +75,8 @@ ValueObjectSynthetic::ValueObjectSynthet
 #else
     SetName(parent.GetName());
 #endif
+    CopyParentData();
+    CreateSynthFilter();
 }
 
 ValueObjectSynthetic::~ValueObjectSynthetic()
@@ -52,7 +95,13 @@ ValueObjectSynthetic::GetTypeName()
     return m_parent->GetTypeName();
 }
 
-uint32_t
+ConstString
+ValueObjectSynthetic::GetQualifiedTypeName()
+{
+    return m_parent->GetQualifiedTypeName();
+}
+
+size_t
 ValueObjectSynthetic::CalculateNumChildren()
 {
     UpdateValueIfNeeded();
@@ -61,13 +110,32 @@ ValueObjectSynthetic::CalculateNumChildr
     return (m_synthetic_children_count = m_synth_filter_ap->CalculateNumChildren());
 }
 
+lldb::ValueObjectSP
+ValueObjectSynthetic::GetDynamicValue (lldb::DynamicValueType valueType)
+{
+    if (!m_parent)
+        return lldb::ValueObjectSP();
+    if (IsDynamic() && GetDynamicValueType() == valueType)
+        return GetSP();
+    return m_parent->GetDynamicValue(valueType);
+}
+
+bool
+ValueObjectSynthetic::MightHaveChildren()
+{
+    if (m_might_have_children == eLazyBoolCalculate)
+        m_might_have_children = (m_synth_filter_ap->MightHaveChildren() ? eLazyBoolYes : eLazyBoolNo);
+    return (m_might_have_children == eLazyBoolNo ? false : true);
+}
+
+
 clang::ASTContext *
 ValueObjectSynthetic::GetClangASTImpl ()
 {
     return m_parent->GetClangAST ();
 }
 
-size_t
+uint64_t
 ValueObjectSynthetic::GetByteSize()
 {
     return m_parent->GetByteSize();
@@ -79,6 +147,14 @@ ValueObjectSynthetic::GetValueType() con
     return m_parent->GetValueType();
 }
 
+void
+ValueObjectSynthetic::CreateSynthFilter ()
+{
+    m_synth_filter_ap = (m_synth_sp->GetFrontEnd(*m_parent));
+    if (!m_synth_filter_ap.get())
+        m_synth_filter_ap.reset(new DummySyntheticFrontEnd(*m_parent));
+}
+
 bool
 ValueObjectSynthetic::UpdateValue ()
 {
@@ -92,6 +168,15 @@ ValueObjectSynthetic::UpdateValue ()
             m_error = m_parent->GetError();
         return false;
     }
+    
+    // regenerate the synthetic filter if our typename changes
+    // <rdar://problem/12424824>
+    ConstString new_parent_type_name = m_parent->GetTypeName();
+    if (new_parent_type_name != m_parent_type_name)
+    {
+        m_parent_type_name = new_parent_type_name;
+        CreateSynthFilter();
+    }
 
     // let our backend do its update
     if (m_synth_filter_ap->Update() == false)
@@ -104,14 +189,17 @@ ValueObjectSynthetic::UpdateValue ()
         // that they need to come back to us asking for children
         m_children_count_valid = false;
         m_synthetic_children_count = UINT32_MAX;
+        m_might_have_children = eLazyBoolCalculate;
     }
     
+    CopyParentData();
+    
     SetValueIsValid(true);
     return true;
 }
 
 lldb::ValueObjectSP
-ValueObjectSynthetic::GetChildAtIndex (uint32_t idx, bool can_create)
+ValueObjectSynthetic::GetChildAtIndex (size_t idx, bool can_create)
 {
     UpdateValueIfNeeded();
     
@@ -121,7 +209,7 @@ ValueObjectSynthetic::GetChildAtIndex (u
     {
         if (can_create && m_synth_filter_ap.get() != NULL)
         {
-            lldb::ValueObjectSP synth_guy = m_synth_filter_ap->GetChildAtIndex (idx, can_create);
+            lldb::ValueObjectSP synth_guy = m_synth_filter_ap->GetChildAtIndex (idx);
             if (!synth_guy)
                 return synth_guy;
             m_children_byindex[idx]= synth_guy.get();
@@ -147,7 +235,7 @@ ValueObjectSynthetic::GetChildMemberWith
     return GetChildAtIndex(index, can_create);
 }
 
-uint32_t
+size_t
 ValueObjectSynthetic::GetIndexOfChildWithName (const ConstString &name)
 {
     UpdateValueIfNeeded();
@@ -179,3 +267,11 @@ ValueObjectSynthetic::GetNonSyntheticVal
 {
     return m_parent->GetSP();
 }
+
+void
+ValueObjectSynthetic::CopyParentData ()
+{
+    m_value = m_parent->GetValue();
+    ExecutionContext exe_ctx (GetExecutionContextRef());
+    m_error = m_value.GetValueAsData (&exe_ctx, GetClangAST(), m_data, 0, GetModule().get());
+}

Modified: lldb/branches/lldb-platform-work/source/Core/ValueObjectVariable.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/lldb-platform-work/source/Core/ValueObjectVariable.cpp?rev=183468&r1=183467&r2=183468&view=diff
==============================================================================
--- lldb/branches/lldb-platform-work/source/Core/ValueObjectVariable.cpp (original)
+++ lldb/branches/lldb-platform-work/source/Core/ValueObjectVariable.cpp Thu Jun  6 19:06:43 2013
@@ -15,9 +15,11 @@
 // Other libraries and framework includes
 // Project includes
 #include "lldb/Core/Module.h"
+#include "lldb/Core/RegisterValue.h"
 #include "lldb/Core/ValueObjectList.h"
 #include "lldb/Core/Value.h"
 
+#include "lldb/Symbol/Function.h"
 #include "lldb/Symbol/ObjectFile.h"
 #include "lldb/Symbol/SymbolContext.h"
 #include "lldb/Symbol/SymbolContextScope.h"
@@ -79,7 +81,7 @@ ValueObjectVariable::GetQualifiedTypeNam
     return ConstString();
 }
 
-uint32_t
+size_t
 ValueObjectVariable::CalculateNumChildren()
 {    
     ClangASTType type(GetClangAST(),
@@ -101,16 +103,15 @@ ValueObjectVariable::GetClangASTImpl ()
     return 0;
 }
 
-size_t
+uint64_t
 ValueObjectVariable::GetByteSize()
 {
-    ClangASTType type(GetClangAST(),
-                      GetClangType());
+    ClangASTType type(GetClangAST(), GetClangType());
     
     if (!type.IsValid())
         return 0;
     
-    return (ClangASTType::GetClangTypeBitWidth(type.GetASTContext(), type.GetOpaqueQualType()) + 7) / 8;
+    return type.GetClangTypeByteSize();
 }
 
 lldb::ValueType
@@ -138,6 +139,8 @@ ValueObjectVariable::UpdateValue ()
             m_value.SetContext(Value::eContextTypeVariable, variable);
         else
             m_error.SetErrorString ("empty constant data");
+        // constant bytes can't be edited - sorry
+        m_resolved_value.SetContext(Value::eContextTypeInvalid, NULL);
     }
     else
     {
@@ -161,6 +164,7 @@ ValueObjectVariable::UpdateValue ()
         Value old_value(m_value);
         if (expr.Evaluate (&exe_ctx, GetClangAST(), NULL, NULL, NULL, loclist_base_load_addr, NULL, m_value, &m_error))
         {
+            m_resolved_value = m_value;
             m_value.SetContext(Value::eContextTypeVariable, variable);
 
             Value::ValueType value_type = m_value.GetValueType();
@@ -175,16 +179,15 @@ ValueObjectVariable::UpdateValue ()
                     break;
                 case Value::eValueTypeLoadAddress:
                 case Value::eValueTypeScalar:
+                case Value::eValueTypeVector:
                     SetAddressTypeOfChildren(eAddressTypeLoad);
                     break;
             }
 
             switch (value_type)
             {
-            default:
-                assert(!"Unhandled expression result value kind...");
-                break;
-
+            case Value::eValueTypeVector:
+                    // fall through
             case Value::eValueTypeScalar:
                 // The variable value is in the Scalar value inside the m_value.
                 // We can point our m_data right to it.
@@ -248,6 +251,11 @@ ValueObjectVariable::UpdateValue ()
 
             SetValueIsValid (m_error.Success());
         }
+        else
+        {
+            // could not find location, won't allow editing
+            m_resolved_value.SetContext(Value::eContextTypeInvalid, NULL);
+        }
     }
     return m_error.Success();
 }
@@ -312,3 +320,77 @@ ValueObjectVariable::GetDeclaration (Dec
     }
     return false;
 }
+
+const char *
+ValueObjectVariable::GetLocationAsCString ()
+{
+    if (m_resolved_value.GetContextType() == Value::eContextTypeRegisterInfo)
+        return GetLocationAsCStringImpl(m_resolved_value,
+                                        m_data);
+    else
+        return ValueObject::GetLocationAsCString();
+}
+
+bool
+ValueObjectVariable::SetValueFromCString (const char *value_str, Error& error)
+{
+    if (m_resolved_value.GetContextType() == Value::eContextTypeRegisterInfo)
+    {
+        RegisterInfo *reg_info = m_resolved_value.GetRegisterInfo();
+        ExecutionContext exe_ctx(GetExecutionContextRef());
+        RegisterContext *reg_ctx = exe_ctx.GetRegisterContext();
+        RegisterValue reg_value;
+        if (!reg_info || !reg_ctx)
+        {
+            error.SetErrorString("unable to retrieve register info");
+            return false;
+        }
+        error = reg_value.SetValueFromCString(reg_info, value_str);
+        if (error.Fail())
+            return false;
+        if (reg_ctx->WriteRegister (reg_info, reg_value))
+        {
+            SetNeedsUpdate();
+            return true;
+        }
+        else
+        {
+            error.SetErrorString("unable to write back to register");
+            return false;
+        }
+    }
+    else
+        return ValueObject::SetValueFromCString(value_str, error);
+}
+
+bool
+ValueObjectVariable::SetData (DataExtractor &data, Error &error)
+{
+    if (m_resolved_value.GetContextType() == Value::eContextTypeRegisterInfo)
+    {
+        RegisterInfo *reg_info = m_resolved_value.GetRegisterInfo();
+        ExecutionContext exe_ctx(GetExecutionContextRef());
+        RegisterContext *reg_ctx = exe_ctx.GetRegisterContext();
+        RegisterValue reg_value;
+        if (!reg_info || !reg_ctx)
+        {
+            error.SetErrorString("unable to retrieve register info");
+            return false;
+        }
+        error = reg_value.SetValueFromData(reg_info, data, 0, false);
+        if (error.Fail())
+            return false;
+        if (reg_ctx->WriteRegister (reg_info, reg_value))
+        {
+            SetNeedsUpdate();
+            return true;
+        }
+        else
+        {
+            error.SetErrorString("unable to write back to register");
+            return false;
+        }
+    }
+    else
+        return ValueObject::SetData(data, error);
+}

Modified: lldb/branches/lldb-platform-work/source/Core/cxa_demangle.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/lldb-platform-work/source/Core/cxa_demangle.cpp?rev=183468&r1=183467&r2=183468&view=diff
==============================================================================
--- lldb/branches/lldb-platform-work/source/Core/cxa_demangle.cpp (original)
+++ lldb/branches/lldb-platform-work/source/Core/cxa_demangle.cpp Thu Jun  6 19:06:43 2013
@@ -133,9 +133,14 @@ void display(__node* x, int indent = 0)
     {
         for (int i = 0; i < 2*indent; ++i)
             printf(" ");
-        char* buf = (char*)malloc(x->size());
+        size_t sz = x->size();
+        char* buf = (char*)calloc(sz+10, 1);
         x->get_demangled_name(buf);
-        printf("%s %s, %p\n", typeid(*x).name(), buf, x);
+        printf("%s [%ld] %s, %p\n", typeid(*x).name(), sz, buf, x);
+        if (strlen(buf) != sz)
+        {
+            printf("strlen(buf) = %ld and size = %ld\n", strlen(buf), sz);
+        }
         free(buf);
         display(x->__left_, indent+1);
         display(x->__right_, indent+1);
@@ -3822,10 +3827,14 @@ public:
     }
     virtual bool ends_with_template(bool parsing = false) const
     {
-        if (__right_ != NULL)
+        if (__right_ && __right_->size() > 0)
+        {
             return __right_->ends_with_template(parsing);
-        if (__left_ != NULL)
+        }
+        else if (__left_ && __left_->size() > 0)
+        {
             return __left_->ends_with_template(parsing);
+        }
         return false;
     }
     virtual bool fix_forward_references(__node** t_begin, __node** t_end)
@@ -3932,11 +3941,11 @@ public:
     }
 };
 
-class __lambda
+class ___lambda_node
     : public __node
 {
 public:
-    __lambda(__node* params, const char *number, size_t number_size)
+    ___lambda_node(__node* params, const char *number, size_t number_size)
     {
         __right_ = params;
         __name_ = number;
@@ -6914,6 +6923,10 @@ __demangle_tree::__parse_expr_primary(co
                     first = t+1;
             }
             break;
+        case 'T':
+            // Invalid mangled name per
+            //   http://sourcerytools.com/pipermail/cxx-abi-dev/2011-August/002422.html
+            break;
         default:
             {
                 // might be named type
@@ -6965,50 +6978,62 @@ __demangle_tree::__parse_unnamed_type_na
         {
         case 't':
         case 'l':
-            first += 2;
-
+            {
+            const char* t = first + 2;
+            __node* params = 0;
             if (type == 'l')
             {
-                __root_ = 0;
-                if (first[0] == 'v')
+                if (*t == 'v')
                 {
                     // void lambda
-                    ++first;
-                    if (first[0] == 'E')
-                        ++first;
+                    ++t;
+                    if (t != last && *t == 'E')
+                        ++t;
                     else
                         return first;
                 }
                 else
                 {
-                    while (first[0] && first[0] != 'E')
+                    const char* t1 = __parse_type(t, last);
+                    if (t1 == t || !__make<__list>(__root_))
+                        return first;
+                    params = __root_;
+                    __node* prev = params;
+                    t = t1;
+                    while (true)
                     {
-                        const char *old = first;
-                        first = __parse_type(first, last);
-                        if (first == old)
+                        t1 = __parse_type(t, last);
+                        if (t1 == t)
                             break;
+                        if (!__make<__list>(__root_))
+                            return first;
+                        t = t1;
+                        prev->__right_ = __root_;
+                        __root_->__size_ = prev->__size_ + 1;
+                        prev = __root_;
                     }
-                    if (first[0] == 'E')
-                        ++first;
-                    else
+                    if (t == last || *t != 'E')
                         return first;
+                    ++t;
                 }
             }
-            const char *number_start = first;
-            first = __parse_number(first, last);
-            const char *number_end = first;
-            if (first[0] == '_')
-            {
-                ++first;
-            }
-            else
+            const char* number_start = t;
+            const char* number_end = __parse_number(t, last);
+            if (number_end == last || *number_end != '_')
                 return first;
-              
+            t = number_end + 1;
             if (type == 'l')
-                __make<__lambda>(__root_, number_start, static_cast<size_t>(number_end - number_start));
+            {
+                if (!__make<___lambda_node>(params, number_start, static_cast<size_t>(number_end - number_start)))
+                    return first;
+            }
             else
-                __make<__unnamed>(number_start, static_cast<size_t>(number_end - number_start));
-            
+            {
+                if (!__make<__unnamed>(number_start, static_cast<size_t>(number_end - number_start)))
+                    return first;
+            }
+            first = t;
+            }
             break;
         }
     }

Copied: lldb/branches/lldb-platform-work/source/DataFormatters/CF.cpp (from r182522, lldb/trunk/source/DataFormatters/CF.cpp)
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/lldb-platform-work/source/DataFormatters/CF.cpp?p2=lldb/branches/lldb-platform-work/source/DataFormatters/CF.cpp&p1=lldb/trunk/source/DataFormatters/CF.cpp&r1=182522&r2=183468&rev=183468&view=diff
==============================================================================
--- lldb/trunk/source/DataFormatters/CF.cpp (original)
+++ lldb/branches/lldb-platform-work/source/DataFormatters/CF.cpp Thu Jun  6 19:06:43 2013
@@ -7,6 +7,8 @@
 //
 //===----------------------------------------------------------------------===//
 
+#include "lldb/lldb-python.h"
+
 #include "lldb/DataFormatters/CXXFormatterFunctions.h"
 
 #include "lldb/Core/DataBufferHeap.h"

Copied: lldb/branches/lldb-platform-work/source/DataFormatters/CXXFormatterFunctions.cpp (from r182522, lldb/trunk/source/DataFormatters/CXXFormatterFunctions.cpp)
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/lldb-platform-work/source/DataFormatters/CXXFormatterFunctions.cpp?p2=lldb/branches/lldb-platform-work/source/DataFormatters/CXXFormatterFunctions.cpp&p1=lldb/trunk/source/DataFormatters/CXXFormatterFunctions.cpp&r1=182522&r2=183468&rev=183468&view=diff
==============================================================================
--- lldb/trunk/source/DataFormatters/CXXFormatterFunctions.cpp (original)
+++ lldb/branches/lldb-platform-work/source/DataFormatters/CXXFormatterFunctions.cpp Thu Jun  6 19:06:43 2013
@@ -7,6 +7,8 @@
 //
 //===----------------------------------------------------------------------===//
 
+#include "lldb/lldb-python.h"
+
 #include "lldb/DataFormatters/CXXFormatterFunctions.h"
 
 #include "llvm/Support/ConvertUTF.h"
@@ -902,7 +904,7 @@ lldb_private::formatters::NSDataSummaryP
     stream.Printf("%s%" PRIu64 " byte%s%s",
                   (needs_at ? "@\"" : ""),
                   value,
-                  (value > 1 ? "s" : ""),
+                  (value != 1 ? "s" : ""),
                   (needs_at ? "\"" : ""));
     
     return true;

Copied: lldb/branches/lldb-platform-work/source/DataFormatters/Cocoa.cpp (from r182522, lldb/trunk/source/DataFormatters/Cocoa.cpp)
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/lldb-platform-work/source/DataFormatters/Cocoa.cpp?p2=lldb/branches/lldb-platform-work/source/DataFormatters/Cocoa.cpp&p1=lldb/trunk/source/DataFormatters/Cocoa.cpp&r1=182522&r2=183468&rev=183468&view=diff
==============================================================================
--- lldb/trunk/source/DataFormatters/Cocoa.cpp (original)
+++ lldb/branches/lldb-platform-work/source/DataFormatters/Cocoa.cpp Thu Jun  6 19:06:43 2013
@@ -7,6 +7,8 @@
 //
 //===----------------------------------------------------------------------===//
 
+#include "lldb/lldb-python.h"
+
 #include "lldb/DataFormatters/CXXFormatterFunctions.h"
 
 #include "lldb/Core/DataBufferHeap.h"
@@ -284,7 +286,7 @@ lldb_private::formatters::NSIndexSetSumm
                 return false;
         }
     }  while (false);
-    stream.Printf("%llu index%s",
+    stream.Printf("%" PRIu64 " index%s",
                   count,
                   (count == 1 ? "" : "es"));
     return true;

Copied: lldb/branches/lldb-platform-work/source/DataFormatters/FormatManager.cpp (from r182522, lldb/trunk/source/DataFormatters/FormatManager.cpp)
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/lldb-platform-work/source/DataFormatters/FormatManager.cpp?p2=lldb/branches/lldb-platform-work/source/DataFormatters/FormatManager.cpp&p1=lldb/trunk/source/DataFormatters/FormatManager.cpp&r1=182522&r2=183468&rev=183468&view=diff
==============================================================================
--- lldb/trunk/source/DataFormatters/FormatManager.cpp (original)
+++ lldb/branches/lldb-platform-work/source/DataFormatters/FormatManager.cpp Thu Jun  6 19:06:43 2013
@@ -627,6 +627,9 @@ FormatManager::LoadLibcxxFormatters()
     AddCXXSynthetic(libcxx_category_sp, lldb_private::formatters::LibcxxStdListSyntheticFrontEndCreator, "libc++ std::list synthetic children", ConstString("^std::__1::list<.+>(( )?&)?$"), stl_synth_flags, true);
     AddCXXSynthetic(libcxx_category_sp, lldb_private::formatters::LibcxxStdMapSyntheticFrontEndCreator, "libc++ std::map synthetic children", ConstString("^std::__1::map<.+> >(( )?&)?$"), stl_synth_flags, true);
     AddCXXSynthetic(libcxx_category_sp, lldb_private::formatters::LibcxxVectorBoolSyntheticFrontEndCreator, "libc++ std::vector<bool> synthetic children", ConstString("std::__1::vector<std::__1::allocator<bool> >"), stl_synth_flags);
+    AddCXXSynthetic(libcxx_category_sp, lldb_private::formatters::LibcxxStdMapSyntheticFrontEndCreator, "libc++ std::set synthetic children", ConstString("^std::__1::set<.+> >(( )?&)?$"), stl_synth_flags, true);
+    AddCXXSynthetic(libcxx_category_sp, lldb_private::formatters::LibcxxStdMapSyntheticFrontEndCreator, "libc++ std::multiset synthetic children", ConstString("^std::__1::multiset<.+> >(( )?&)?$"), stl_synth_flags, true);
+    AddCXXSynthetic(libcxx_category_sp, lldb_private::formatters::LibcxxStdMapSyntheticFrontEndCreator, "libc++ std::multimap synthetic children", ConstString("^std::__1::multimap<.+> >(( )?&)?$"), stl_synth_flags, true);
 
     libcxx_category_sp->GetRegexSyntheticNavigator()->Add(RegularExpressionSP(new RegularExpression("^(std::__1::)deque<.+>(( )?&)?$")),
                                                           SyntheticChildrenSP(new ScriptedSyntheticChildren(stl_synth_flags,
@@ -642,6 +645,9 @@ FormatManager::LoadLibcxxFormatters()
     AddCXXSummary(libcxx_category_sp, lldb_private::formatters::LibcxxContainerSummaryProvider, "libc++ std::map summary provider", ConstString("^std::__1::map<.+>(( )?&)?$"), stl_summary_flags, true);
     AddCXXSummary(libcxx_category_sp, lldb_private::formatters::LibcxxContainerSummaryProvider, "libc++ std::deque summary provider", ConstString("^std::__1::deque<.+>(( )?&)?$"), stl_summary_flags, true);
     AddCXXSummary(libcxx_category_sp, lldb_private::formatters::LibcxxContainerSummaryProvider, "libc++ std::vector<bool> summary provider", ConstString("std::__1::vector<std::__1::allocator<bool> >"), stl_summary_flags);
+    AddCXXSummary(libcxx_category_sp, lldb_private::formatters::LibcxxContainerSummaryProvider, "libc++ std::set summary provider", ConstString("^std::__1::set<.+>(( )?&)?$"), stl_summary_flags, true);
+    AddCXXSummary(libcxx_category_sp, lldb_private::formatters::LibcxxContainerSummaryProvider, "libc++ std::multiset summary provider", ConstString("^std::__1::multiset<.+>(( )?&)?$"), stl_summary_flags, true);
+    AddCXXSummary(libcxx_category_sp, lldb_private::formatters::LibcxxContainerSummaryProvider, "libc++ std::multimap summary provider", ConstString("^std::__1::multimap<.+>(( )?&)?$"), stl_summary_flags, true);
 
     stl_summary_flags.SetSkipPointers(true);
     AddStringSummary(libcxx_category_sp, "{${var.__ptr_%S}} (strong=${var.count} weak=${var.weak_count})}", ConstString("^std::__1::shared_ptr<.+>(( )?&)?$"), stl_summary_flags, true);
@@ -685,6 +691,8 @@ FormatManager::LoadSystemFormatters()
     
     sys_category_sp->GetSummaryNavigator()->Add(ConstString("char *"), string_format);
     sys_category_sp->GetSummaryNavigator()->Add(ConstString("const char *"), string_format);
+    sys_category_sp->GetSummaryNavigator()->Add(ConstString("unsigned char *"), string_format);
+    sys_category_sp->GetSummaryNavigator()->Add(ConstString("const unsigned char *"), string_format);
     sys_category_sp->GetRegexSummaryNavigator()->Add(any_size_char_arr, string_array_format);
     
     lldb::TypeSummaryImplSP ostype_summary(new StringSummaryFormat(TypeSummaryImpl::Flags().SetCascades(false)

Copied: lldb/branches/lldb-platform-work/source/DataFormatters/LibCxx.cpp (from r182522, lldb/trunk/source/DataFormatters/LibCxx.cpp)
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/lldb-platform-work/source/DataFormatters/LibCxx.cpp?p2=lldb/branches/lldb-platform-work/source/DataFormatters/LibCxx.cpp&p1=lldb/trunk/source/DataFormatters/LibCxx.cpp&r1=182522&r2=183468&rev=183468&view=diff
==============================================================================
--- lldb/trunk/source/DataFormatters/LibCxx.cpp (original)
+++ lldb/branches/lldb-platform-work/source/DataFormatters/LibCxx.cpp Thu Jun  6 19:06:43 2013
@@ -514,7 +514,7 @@ lldb_private::formatters::LibcxxContaine
         uint64_t value = valobj.GetValueAsUnsigned(0);
         if (!value)
             return false;
-        stream.Printf("0x%016llx ", value);
+        stream.Printf("0x%016" PRIx64 " ", value);
     }
-    return Debugger::FormatPrompt("size=${svar%#}", NULL, NULL, NULL, stream, NULL, &valobj);
+    return Debugger::FormatPrompt("size=${svar%#}", NULL, NULL, NULL, stream, &valobj);
 }

Copied: lldb/branches/lldb-platform-work/source/DataFormatters/LibCxxList.cpp (from r182522, lldb/trunk/source/DataFormatters/LibCxxList.cpp)
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/lldb-platform-work/source/DataFormatters/LibCxxList.cpp?p2=lldb/branches/lldb-platform-work/source/DataFormatters/LibCxxList.cpp&p1=lldb/trunk/source/DataFormatters/LibCxxList.cpp&r1=182522&r2=183468&rev=183468&view=diff
==============================================================================
--- lldb/trunk/source/DataFormatters/LibCxxList.cpp (original)
+++ lldb/branches/lldb-platform-work/source/DataFormatters/LibCxxList.cpp Thu Jun  6 19:06:43 2013
@@ -7,6 +7,8 @@
 //
 //===----------------------------------------------------------------------===//
 
+#include "lldb/lldb-python.h"
+
 #include "lldb/DataFormatters/CXXFormatterFunctions.h"
 
 #include "lldb/Core/DataBufferHeap.h"

Copied: lldb/branches/lldb-platform-work/source/DataFormatters/LibCxxMap.cpp (from r182522, lldb/trunk/source/DataFormatters/LibCxxMap.cpp)
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/lldb-platform-work/source/DataFormatters/LibCxxMap.cpp?p2=lldb/branches/lldb-platform-work/source/DataFormatters/LibCxxMap.cpp&p1=lldb/trunk/source/DataFormatters/LibCxxMap.cpp&r1=182522&r2=183468&rev=183468&view=diff
==============================================================================
--- lldb/trunk/source/DataFormatters/LibCxxMap.cpp (original)
+++ lldb/branches/lldb-platform-work/source/DataFormatters/LibCxxMap.cpp Thu Jun  6 19:06:43 2013
@@ -7,6 +7,8 @@
 //
 //===----------------------------------------------------------------------===//
 
+#include "lldb/lldb-python.h"
+
 #include "lldb/DataFormatters/CXXFormatterFunctions.h"
 
 #include "lldb/Core/DataBufferHeap.h"
@@ -378,7 +380,7 @@ lldb_private::formatters::LibcxxStdMapSy
     m_children.clear();
     m_tree = m_backend.GetChildMemberWithName(ConstString("__tree_"), true).get();
     if (!m_tree)
-        return NULL;
+        return false;
     m_root_node = m_tree->GetChildMemberWithName(ConstString("__begin_node_"), true).get();
     return false;
 }

Copied: lldb/branches/lldb-platform-work/source/DataFormatters/TypeSummary.cpp (from r182522, lldb/trunk/source/DataFormatters/TypeSummary.cpp)
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/lldb-platform-work/source/DataFormatters/TypeSummary.cpp?p2=lldb/branches/lldb-platform-work/source/DataFormatters/TypeSummary.cpp&p1=lldb/trunk/source/DataFormatters/TypeSummary.cpp&r1=182522&r2=183468&rev=183468&view=diff
==============================================================================
--- lldb/trunk/source/DataFormatters/TypeSummary.cpp (original)
+++ lldb/branches/lldb-platform-work/source/DataFormatters/TypeSummary.cpp Thu Jun  6 19:06:43 2013
@@ -113,7 +113,7 @@ StringSummaryFormat::FormatObject (Value
     }
     else
     {
-        if (Debugger::FormatPrompt(m_format.c_str(), &sc, &exe_ctx, &sc.line_entry.range.GetBaseAddress(), s, NULL, valobj))
+        if (Debugger::FormatPrompt(m_format.c_str(), &sc, &exe_ctx, &sc.line_entry.range.GetBaseAddress(), s, valobj))
         {
             retval.assign(s.GetString());
             return true;

Modified: lldb/branches/lldb-platform-work/source/Expression/ASTDumper.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/lldb-platform-work/source/Expression/ASTDumper.cpp?rev=183468&r1=183467&r2=183468&view=diff
==============================================================================
--- lldb/branches/lldb-platform-work/source/Expression/ASTDumper.cpp (original)
+++ lldb/branches/lldb-platform-work/source/Expression/ASTDumper.cpp Thu Jun  6 19:06:43 2013
@@ -89,7 +89,7 @@ void ASTDumper::ToSTDERR()
     fprintf(stderr, "%s\n", m_dump.c_str());
 }
 
-void ASTDumper::ToLog(lldb::LogSP &log, const char *prefix)
+void ASTDumper::ToLog(Log *log, const char *prefix)
 {
     size_t len = m_dump.length() + 1;
     

Modified: lldb/branches/lldb-platform-work/source/Expression/ASTResultSynthesizer.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/lldb-platform-work/source/Expression/ASTResultSynthesizer.cpp?rev=183468&r1=183467&r2=183468&view=diff
==============================================================================
--- lldb/branches/lldb-platform-work/source/Expression/ASTResultSynthesizer.cpp (original)
+++ lldb/branches/lldb-platform-work/source/Expression/ASTResultSynthesizer.cpp Thu Jun  6 19:06:43 2013
@@ -60,7 +60,7 @@ ASTResultSynthesizer::Initialize(ASTCont
 void
 ASTResultSynthesizer::TransformTopLevelDecl(Decl* D)
 {
-    lldb::LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
+    Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
 
     if (NamedDecl *named_decl = dyn_cast<NamedDecl>(D))
     {
@@ -129,10 +129,8 @@ ASTResultSynthesizer::HandleTopLevelDecl
 bool 
 ASTResultSynthesizer::SynthesizeFunctionResult (FunctionDecl *FunDecl)
 {
-    lldb::LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
+    Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
     
-    ASTContext &Ctx(*m_ast_context);
-
     if (!m_sema)
         return false;
     
@@ -146,11 +144,11 @@ ASTResultSynthesizer::SynthesizeFunction
         std::string s;
         raw_string_ostream os(s);
         
-        Ctx.getTranslationUnitDecl()->print(os);
+        function_decl->print(os);
         
         os.flush();
         
-        log->Printf("AST context before transforming:\n%s", s.c_str());
+        log->Printf ("Untransformed function AST:\n%s", s.c_str());
     }
     
     Stmt *function_body = function_decl->getBody();
@@ -177,10 +175,8 @@ ASTResultSynthesizer::SynthesizeFunction
 bool
 ASTResultSynthesizer::SynthesizeObjCMethodResult (ObjCMethodDecl *MethodDecl)
 {
-    lldb::LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
-    
-    ASTContext &Ctx(*m_ast_context);
-    
+    Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
+        
     if (!m_sema)
         return false;
         
@@ -192,11 +188,11 @@ ASTResultSynthesizer::SynthesizeObjCMeth
         std::string s;
         raw_string_ostream os(s);
         
-        Ctx.getTranslationUnitDecl()->print(os);
+        MethodDecl->print(os);
         
         os.flush();
         
-        log->Printf("AST context before transforming:\n%s", s.c_str());
+        log->Printf ("Untransformed method AST:\n%s", s.c_str());
     }
     
     Stmt *method_body = MethodDecl->getBody();
@@ -209,7 +205,7 @@ ASTResultSynthesizer::SynthesizeObjCMeth
     bool ret = SynthesizeBodyResult (compound_stmt,
                                      MethodDecl);
     
-    if (log)
+    if (log && log->GetVerbose())
     {
         std::string s;
         raw_string_ostream os(s);
@@ -218,7 +214,7 @@ ASTResultSynthesizer::SynthesizeObjCMeth
         
         os.flush();
         
-        log->Printf("Transformed function AST:\n%s", s.c_str());
+        log->Printf("Transformed method AST:\n%s", s.c_str());
     }
     
     return ret;
@@ -228,7 +224,7 @@ bool
 ASTResultSynthesizer::SynthesizeBodyResult (CompoundStmt *Body, 
                                             DeclContext *DC)
 {
-    lldb::LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
+    Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
     
     ASTContext &Ctx(*m_ast_context);
         
@@ -269,7 +265,7 @@ ASTResultSynthesizer::SynthesizeBodyResu
         if (!implicit_cast)
             break;
         
-        if (!implicit_cast->getCastKind() == CK_LValueToRValue)
+        if (implicit_cast->getCastKind() != CK_LValueToRValue)
             break;
         
         last_expr = implicit_cast->getSubExpr();
@@ -361,7 +357,6 @@ ASTResultSynthesizer::SynthesizeBodyResu
                                       result_ptr_id,
                                       ptr_qual_type,
                                       NULL,
-                                      SC_Static,
                                       SC_Static);
         
         if (!result_decl)
@@ -382,7 +377,6 @@ ASTResultSynthesizer::SynthesizeBodyResu
                                       &result_id, 
                                       expr_qual_type, 
                                       NULL, 
-                                      SC_Static, 
                                       SC_Static);
         
         if (!result_decl)
@@ -456,7 +450,7 @@ ASTResultSynthesizer::MaybeRecordPersist
     if (name.size() == 0 || name[0] != '$')
         return;
     
-    lldb::LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
+    Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
 
     ConstString name_cs(name.str().c_str());
     

Modified: lldb/branches/lldb-platform-work/source/Expression/ASTStructExtractor.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/lldb-platform-work/source/Expression/ASTStructExtractor.cpp?rev=183468&r1=183467&r2=183468&view=diff
==============================================================================
--- lldb/branches/lldb-platform-work/source/Expression/ASTStructExtractor.cpp (original)
+++ lldb/branches/lldb-platform-work/source/Expression/ASTStructExtractor.cpp Thu Jun  6 19:06:43 2013
@@ -59,13 +59,42 @@ ASTStructExtractor::Initialize(ASTContex
 void
 ASTStructExtractor::ExtractFromFunctionDecl(FunctionDecl *F)
 {
-    DeclarationName struct_name(&m_ast_context->Idents.get(m_struct_name.c_str()));
-    RecordDecl::lookup_result struct_lookup = F->lookup(struct_name);
-    
-    if (struct_lookup.first == struct_lookup.second)
+    if (!F->hasBody())
         return;
     
-    RecordDecl *struct_decl = dyn_cast<RecordDecl>(*(struct_lookup.first));
+    Stmt *body_stmt = F->getBody();
+    CompoundStmt *body_compound_stmt = dyn_cast<CompoundStmt>(body_stmt);
+    
+    if (!body_compound_stmt)
+        return; // do we have to handle this?
+    
+    RecordDecl *struct_decl = NULL;
+    
+    StringRef desired_name(m_struct_name.c_str());
+    
+    for (CompoundStmt::const_body_iterator bi = body_compound_stmt->body_begin(), be = body_compound_stmt->body_end();
+         bi != be;
+         ++bi)
+    {
+        Stmt *curr_stmt = *bi;
+        DeclStmt *curr_decl_stmt = dyn_cast<DeclStmt>(curr_stmt);
+        if (!curr_decl_stmt)
+            continue;
+        DeclGroupRef decl_group = curr_decl_stmt->getDeclGroup();
+        for (Decl *candidate_decl : decl_group)
+        {
+            RecordDecl *candidate_record_decl = dyn_cast<RecordDecl>(candidate_decl);
+            if (!candidate_record_decl)
+                continue;
+            if (candidate_record_decl->getName() == desired_name)
+            {
+                struct_decl = candidate_record_decl;
+                break;
+            }
+        }
+        if (struct_decl)
+            break;
+    }
     
     if (!struct_decl)
         return;

Modified: lldb/branches/lldb-platform-work/source/Expression/ClangASTSource.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/lldb-platform-work/source/Expression/ClangASTSource.cpp?rev=183468&r1=183467&r2=183468&view=diff
==============================================================================
--- lldb/branches/lldb-platform-work/source/Expression/ClangASTSource.cpp (original)
+++ lldb/branches/lldb-platform-work/source/Expression/ClangASTSource.cpp Thu Jun  6 19:06:43 2013
@@ -17,6 +17,7 @@
 #include "lldb/Expression/ClangASTSource.h"
 #include "lldb/Expression/ClangExpression.h"
 #include "lldb/Symbol/ClangNamespaceDecl.h"
+#include "lldb/Symbol/Function.h"
 #include "lldb/Symbol/SymbolVendor.h"
 #include "lldb/Target/ObjCLanguageRuntime.h"
 #include "lldb/Target/Target.h"
@@ -55,7 +56,7 @@ ClangASTSource::StartTranslationUnit(AST
 }
 
 // The core lookup interface.
-DeclContext::lookup_result 
+bool
 ClangASTSource::FindExternalVisibleDeclsByName
 (
     const DeclContext *decl_ctx, 
@@ -63,11 +64,17 @@ ClangASTSource::FindExternalVisibleDecls
 ) 
 {
     if (!m_ast_context)
-        return SetNoExternalVisibleDeclsForName(decl_ctx, clang_decl_name);
+    {
+        SetNoExternalVisibleDeclsForName(decl_ctx, clang_decl_name);
+        return false;
+    }
     
     if (GetImportInProgress())
-        return SetNoExternalVisibleDeclsForName(decl_ctx, clang_decl_name);
-        
+    {
+        SetNoExternalVisibleDeclsForName(decl_ctx, clang_decl_name);
+        return false;
+    }
+    
     std::string decl_name (clang_decl_name.getAsString());
 
 //    if (m_decl_map.DoingASTImport ())
@@ -82,7 +89,8 @@ ClangASTSource::FindExternalVisibleDecls
             if (!identifier_info ||
                 identifier_info->getBuiltinID() != 0)
             {
-                return SetNoExternalVisibleDeclsForName(decl_ctx, clang_decl_name);
+                SetNoExternalVisibleDeclsForName(decl_ctx, clang_decl_name);
+                return false;
             }
         }
         break;
@@ -90,12 +98,14 @@ ClangASTSource::FindExternalVisibleDecls
     // Operator names.  Not important for now.
     case DeclarationName::CXXOperatorName:
     case DeclarationName::CXXLiteralOperatorName:
-      return DeclContext::lookup_result();
+      SetNoExternalVisibleDeclsForName(decl_ctx, clang_decl_name);
+      return false;
             
     // Using directives found in this context.
     // Tell Sema we didn't find any or we'll end up getting asked a *lot*.
     case DeclarationName::CXXUsingDirective:
-      return SetNoExternalVisibleDeclsForName(decl_ctx, clang_decl_name);
+      SetNoExternalVisibleDeclsForName(decl_ctx, clang_decl_name);
+      return false;
             
     case DeclarationName::ObjCZeroArgSelector:
     case DeclarationName::ObjCOneArgSelector:
@@ -107,13 +117,15 @@ ClangASTSource::FindExternalVisibleDecls
      
       FindObjCMethodDecls(method_search_context);
 
-      return SetExternalVisibleDeclsForName (decl_ctx, clang_decl_name, method_decls);
+      SetExternalVisibleDeclsForName (decl_ctx, clang_decl_name, method_decls);
+      return (method_decls.size() > 0);
     }
     // These aren't possible in the global context.
     case DeclarationName::CXXConstructorName:
     case DeclarationName::CXXDestructorName:
     case DeclarationName::CXXConversionFunctionName:
-      return DeclContext::lookup_result();
+      SetNoExternalVisibleDeclsForName(decl_ctx, clang_decl_name);
+      return false;
     }
 
 
@@ -127,7 +139,8 @@ ClangASTSource::FindExternalVisibleDecls
         }
         else
         {               
-            return SetNoExternalVisibleDeclsForName(decl_ctx, clang_decl_name);
+            SetNoExternalVisibleDeclsForName(decl_ctx, clang_decl_name);
+            return false;
         }
     }
 
@@ -137,7 +150,8 @@ ClangASTSource::FindExternalVisibleDecls
     if (m_active_lookups.find (uniqued_const_decl_name) != m_active_lookups.end())
     {
         // We are currently looking up this name...
-        return DeclContext::lookup_result();
+        SetNoExternalVisibleDeclsForName(decl_ctx, clang_decl_name);
+        return false;
     }
     m_active_lookups.insert(uniqued_const_decl_name);
 //  static uint32_t g_depth = 0;
@@ -146,16 +160,16 @@ ClangASTSource::FindExternalVisibleDecls
     llvm::SmallVector<NamedDecl*, 4> name_decls;    
     NameSearchContext name_search_context(*this, name_decls, clang_decl_name, decl_ctx);
     FindExternalVisibleDecls(name_search_context);
-    DeclContext::lookup_result result (SetExternalVisibleDeclsForName (decl_ctx, clang_decl_name, name_decls));
+    SetExternalVisibleDeclsForName (decl_ctx, clang_decl_name, name_decls);
 //  --g_depth;
     m_active_lookups.erase (uniqued_const_decl_name);
-    return result;
+    return (name_decls.size() != 0);
 }
 
 void
 ClangASTSource::CompleteType (TagDecl *tag_decl)
 {    
-    lldb::LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
+    Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
     
     static unsigned int invocation_id = 0;
     unsigned int current_id = invocation_id++;
@@ -249,7 +263,7 @@ ClangASTSource::CompleteType (TagDecl *t
             ConstString name(tag_decl->getName().str().c_str());
             ClangNamespaceDecl namespace_decl;
             
-            ModuleList &module_list = m_target->GetImages();
+            const ModuleList &module_list = m_target->GetImages();
 
             bool exact_match = false;
             module_list.FindTypes (null_sc, name, exact_match, UINT32_MAX, types);
@@ -292,7 +306,7 @@ ClangASTSource::CompleteType (TagDecl *t
 void
 ClangASTSource::CompleteType (clang::ObjCInterfaceDecl *interface_decl)
 {    
-    lldb::LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
+    Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
     
     if (log)
     {
@@ -312,12 +326,51 @@ ClangASTSource::CompleteType (clang::Obj
     }
 }
 
+clang::ObjCInterfaceDecl *
+ClangASTSource::GetCompleteObjCInterface (clang::ObjCInterfaceDecl *interface_decl)
+{
+    lldb::ProcessSP process(m_target->GetProcessSP());
+    
+    if (!process)
+        return NULL;
+    
+    ObjCLanguageRuntime *language_runtime(process->GetObjCLanguageRuntime());
+    
+    if (!language_runtime)
+        return NULL;
+        
+    ConstString class_name(interface_decl->getNameAsString().c_str());
+    
+    lldb::TypeSP complete_type_sp(language_runtime->LookupInCompleteClassCache(class_name));
+    
+    if (!complete_type_sp)
+        return NULL;
+    
+    TypeFromUser complete_type = TypeFromUser(complete_type_sp->GetClangFullType(), complete_type_sp->GetClangAST());
+    lldb::clang_type_t complete_opaque_type = complete_type.GetOpaqueQualType();
+    
+    if (!complete_opaque_type)
+        return NULL;
+    
+    const clang::Type *complete_clang_type = QualType::getFromOpaquePtr(complete_opaque_type).getTypePtr();
+    const ObjCInterfaceType *complete_interface_type = dyn_cast<ObjCInterfaceType>(complete_clang_type);
+    
+    if (!complete_interface_type)
+        return NULL;
+    
+    ObjCInterfaceDecl *complete_iface_decl(complete_interface_type->getDecl());
+    
+    return complete_iface_decl;
+}
+
 clang::ExternalLoadResult
-ClangASTSource::FindExternalLexicalDecls (const DeclContext *decl_context, 
+ClangASTSource::FindExternalLexicalDecls (const DeclContext *decl_context,
                                           bool (*predicate)(Decl::Kind),
                                           llvm::SmallVectorImpl<Decl*> &decls)
-{    
-    lldb::LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
+{
+    ClangASTMetrics::RegisterLexicalQuery();
+
+    Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
     
     const Decl *context_decl = dyn_cast<Decl>(decl_context);
     
@@ -359,10 +412,23 @@ ClangASTSource::FindExternalLexicalDecls
     
     if (log)
     {       
-        log->Printf("  FELD[%u] Original decl (Decl*)%p:", current_id, original_decl);
+        log->Printf("  FELD[%u] Original decl (ASTContext*)%p (Decl*)%p:", current_id, original_ctx, original_decl);
         ASTDumper(original_decl).ToLog(log, "    ");
     }
     
+    if (ObjCInterfaceDecl *original_iface_decl = dyn_cast<ObjCInterfaceDecl>(original_decl))
+    {
+        ObjCInterfaceDecl *complete_iface_decl = GetCompleteObjCInterface(original_iface_decl);
+        
+        if (complete_iface_decl && (complete_iface_decl != original_iface_decl))
+        {
+            original_decl = complete_iface_decl;
+            original_ctx = &complete_iface_decl->getASTContext();
+            
+            m_ast_importer->SetDeclOrigin(context_decl, original_iface_decl);
+        }
+    }
+    
     if (TagDecl *original_tag_decl = dyn_cast<TagDecl>(original_decl))
     {
         ExternalASTSource *external_source = original_ctx->getExternalSource();
@@ -388,9 +454,9 @@ ClangASTSource::FindExternalLexicalDecls
             {
                 ASTDumper ast_dumper(decl);
                 if (const NamedDecl *context_named_decl = dyn_cast<NamedDecl>(context_decl))
-                    log->Printf("  FELD[%d] Adding [to %s] lexical decl %s", current_id, context_named_decl->getNameAsString().c_str(), ast_dumper.GetCString());
+                    log->Printf("  FELD[%d] Adding [to %sDecl %s] lexical %sDecl %s", current_id, context_named_decl->getDeclKindName(), context_named_decl->getNameAsString().c_str(), decl->getDeclKindName(), ast_dumper.GetCString());
                 else
-                    log->Printf("  FELD[%d] Adding lexical decl %s", current_id, ast_dumper.GetCString());
+                    log->Printf("  FELD[%d] Adding lexical %sDecl %s", current_id, decl->getDeclKindName(), ast_dumper.GetCString());
             }
             
             Decl *copied_decl = m_ast_importer->CopyDecl(m_ast_context, original_ctx, decl);
@@ -402,14 +468,22 @@ ClangASTSource::FindExternalLexicalDecls
             {
                 QualType copied_field_type = copied_field->getType();
                 
-                if (const TagType *copied_field_tag_type = copied_field_type->getAs<TagType>())
-                    m_ast_importer->CompleteTagDecl(copied_field_tag_type->getDecl());
-                if (const ObjCObjectType *copied_field_object_type = copied_field_type->getAs<ObjCObjectType>())
-                    if (ObjCInterfaceDecl *copied_field_objc_interface_decl = copied_field_object_type->getInterface())
-                        m_ast_importer->CompleteObjCInterfaceDecl(copied_field_objc_interface_decl);
+                m_ast_importer->RequireCompleteType(copied_field_type);
             }
             
             decls.push_back(copied_decl);
+            
+            DeclContext *decl_context_non_const = const_cast<DeclContext *>(decl_context);
+            
+            if (copied_decl->getDeclContext() != decl_context)
+            {
+                if (copied_decl->getDeclContext()->containsDecl(copied_decl))
+                    copied_decl->getDeclContext()->removeDecl(copied_decl);
+                copied_decl->setDeclContext(decl_context_non_const);
+            }
+            
+            if (!decl_context_non_const->containsDecl(copied_decl))
+                decl_context_non_const->addDeclInternal(copied_decl);
         }
     }
     
@@ -421,9 +495,11 @@ ClangASTSource::FindExternalVisibleDecls
 {
     assert (m_ast_context);
     
+    ClangASTMetrics::RegisterVisibleQuery();
+    
     const ConstString name(context.m_decl_name.getAsString().c_str());
     
-    lldb::LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
+    Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
     
     static unsigned int invocation_id = 0;
     unsigned int current_id = invocation_id++;
@@ -514,7 +590,7 @@ ClangASTSource::FindExternalVisibleDecls
 {
     assert (m_ast_context);
     
-    lldb::LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
+    Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
     
     SymbolContextList sc_list;
     
@@ -561,12 +637,10 @@ ClangASTSource::FindExternalVisibleDecls
     }
     else 
     {
-        ModuleList &target_images = m_target->GetImages();
+        const ModuleList &target_images = m_target->GetImages();
         Mutex::Locker modules_locker (target_images.GetMutex());
         
-        for (uint32_t i = 0, e = target_images.GetSize();
-             i != e;
-             ++i)
+        for (size_t i = 0, e = target_images.GetSize(); i < e; ++i)
         {
             lldb::ModuleSP image = target_images.GetModuleAtIndexUnlocked(i);
             
@@ -621,14 +695,16 @@ ClangASTSource::FindExternalVisibleDecls
                             name.GetCString(), 
                             (name_string ? name_string : "<anonymous>"));
             }
-            
+                        
+            clang::ASTContext *type_ast = type_sp->GetClangAST();
+            lldb::clang_type_t full_type = type_sp->GetClangFullType();
 
-            void *copied_type = GuardedCopyType(m_ast_context, type_sp->GetClangAST(), type_sp->GetClangFullType());
+            void *copied_type = GuardedCopyType(m_ast_context, type_ast, full_type);
                 
             if (!copied_type)
             {                
                 if (log)
-                    log->Printf("  CAS::FEVD[%u] - Couldn't export the type for a constant integer result",
+                    log->Printf("  CAS::FEVD[%u] - Couldn't export a type",
                                 current_id);
                     
                 break;
@@ -636,14 +712,209 @@ ClangASTSource::FindExternalVisibleDecls
                 
             context.AddTypeDecl(copied_type);
         }
+        else
+        {
+            do
+            {
+                // Couldn't find any types elsewhere.  Try the Objective-C runtime if one exists.
+                
+                lldb::ProcessSP process(m_target->GetProcessSP());
+                
+                if (!process)
+                    break;
+                
+                ObjCLanguageRuntime *language_runtime(process->GetObjCLanguageRuntime());
+                
+                if (!language_runtime)
+                    break;
+                
+                TypeVendor *type_vendor = language_runtime->GetTypeVendor();
+                
+                if (!type_vendor)
+                    break;
+                
+                bool append = false;
+                uint32_t max_matches = 1;
+                std::vector <ClangASTType> types;
+                
+                if (!type_vendor->FindTypes(name,
+                                            append,
+                                            max_matches,
+                                            types))
+                    break;
+                
+                if (log)
+                {                    
+                    log->Printf("  CAS::FEVD[%u] Matching type found for \"%s\" in the runtime",
+                                current_id,
+                                name.GetCString());
+                }
+                
+                const clang::Type *runtime_clang_type = QualType::getFromOpaquePtr(types[0].GetOpaqueQualType()).getTypePtr();
+                
+                clang::QualType runtime_qual_type(runtime_clang_type, 0);
+                
+                void *copied_type = GuardedCopyType(m_ast_context, type_vendor->GetClangASTContext(), runtime_qual_type.getAsOpaquePtr());
+                
+                if (!copied_type)
+                {
+                    if (log)
+                        log->Printf("  CAS::FEVD[%u] - Couldn't export a type from the runtime",
+                                    current_id);
+                    
+                    break;
+                }
+                
+                context.AddTypeDecl(copied_type);
+            }
+            while(0);
+        }
         
     } while(0);
 }
 
+template <class D> class TaggedASTDecl {
+public:
+    TaggedASTDecl() : decl(NULL) { }
+    TaggedASTDecl(D *_decl) : decl(_decl) { }
+    bool IsValid() const { return (decl != NULL); }
+    bool IsInvalid() const { return !IsValid(); }
+    D *operator->() const { return decl; }
+    D *decl;
+};
+
+template <class D2, template <class D> class TD, class D1> 
+TD<D2>
+DynCast(TD<D1> source)
+{
+    return TD<D2> (dyn_cast<D2>(source.decl));
+}
+
+template <class D = Decl> class DeclFromParser;
+template <class D = Decl> class DeclFromUser;
+
+template <class D> class DeclFromParser : public TaggedASTDecl<D> { 
+public:
+    DeclFromParser() : TaggedASTDecl<D>() { }
+    DeclFromParser(D *_decl) : TaggedASTDecl<D>(_decl) { }
+    
+    DeclFromUser<D> GetOrigin(ClangASTImporter *importer);
+};
+
+template <class D> class DeclFromUser : public TaggedASTDecl<D> { 
+public:
+    DeclFromUser() : TaggedASTDecl<D>() { }
+    DeclFromUser(D *_decl) : TaggedASTDecl<D>(_decl) { }
+    
+    DeclFromParser<D> Import(ClangASTImporter *importer, ASTContext &dest_ctx);
+};
+
+template <class D>
+DeclFromUser<D>
+DeclFromParser<D>::GetOrigin(ClangASTImporter *importer)
+{
+    DeclFromUser <> origin_decl;
+    importer->ResolveDeclOrigin(this->decl, &origin_decl.decl, NULL);
+    if (origin_decl.IsInvalid())
+        return DeclFromUser<D>();
+    return DeclFromUser<D>(dyn_cast<D>(origin_decl.decl));
+}
+
+template <class D>
+DeclFromParser<D>
+DeclFromUser<D>::Import(ClangASTImporter *importer, ASTContext &dest_ctx)
+{
+    DeclFromParser <> parser_generic_decl(importer->CopyDecl(&dest_ctx, &this->decl->getASTContext(), this->decl));
+    if (parser_generic_decl.IsInvalid())
+        return DeclFromParser<D>();
+    return DeclFromParser<D>(dyn_cast<D>(parser_generic_decl.decl));
+}
+
+static bool
+FindObjCMethodDeclsWithOrigin (unsigned int current_id,
+                               NameSearchContext &context,
+                               ObjCInterfaceDecl *original_interface_decl,
+                               clang::ASTContext *ast_context,
+                               ClangASTImporter *ast_importer,
+                               const char *log_info)
+{
+    const DeclarationName &decl_name(context.m_decl_name);
+    clang::ASTContext *original_ctx = &original_interface_decl->getASTContext();
+
+    Selector original_selector;
+    
+    if (decl_name.isObjCZeroArgSelector())
+    {
+        IdentifierInfo *ident = &original_ctx->Idents.get(decl_name.getAsString());
+        original_selector = original_ctx->Selectors.getSelector(0, &ident);
+    }
+    else if (decl_name.isObjCOneArgSelector())
+    {
+        const std::string &decl_name_string = decl_name.getAsString();
+        std::string decl_name_string_without_colon(decl_name_string.c_str(), decl_name_string.length() - 1);
+        IdentifierInfo *ident = &original_ctx->Idents.get(decl_name_string_without_colon.c_str());
+        original_selector = original_ctx->Selectors.getSelector(1, &ident);
+    }
+    else
+    {
+        SmallVector<IdentifierInfo *, 4> idents;
+        
+        clang::Selector sel = decl_name.getObjCSelector();
+        
+        int num_args = sel.getNumArgs();
+        
+        for (unsigned i = 0;
+             i != num_args;
+             ++i)
+        {
+            idents.push_back(&original_ctx->Idents.get(sel.getNameForSlot(i)));
+        }
+        
+        original_selector = original_ctx->Selectors.getSelector(num_args, idents.data());
+    }
+    
+    DeclarationName original_decl_name(original_selector);
+    
+    ObjCInterfaceDecl::lookup_result result = original_interface_decl->lookup(original_decl_name);
+    
+    if (result.empty())
+        return false;
+    
+    if (!result[0])
+        return false;
+    
+    ObjCMethodDecl *result_method = dyn_cast<ObjCMethodDecl>(result[0]);
+    
+    if (!result_method)
+        return false;
+    
+    Decl *copied_decl = ast_importer->CopyDecl(ast_context, &result_method->getASTContext(), result_method);
+    
+    if (!copied_decl)
+        return false;
+    
+    ObjCMethodDecl *copied_method_decl = dyn_cast<ObjCMethodDecl>(copied_decl);
+    
+    if (!copied_method_decl)
+        return false;
+    
+    Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
+    
+    if (log)
+    {
+        ASTDumper dumper((Decl*)copied_method_decl);
+        log->Printf("  CAS::FOMD[%d] found (%s) %s", current_id, log_info, dumper.GetCString());
+    }
+    
+    context.AddNamedDecl(copied_method_decl);
+    
+    return true;
+}
+
 void
 ClangASTSource::FindObjCMethodDecls (NameSearchContext &context)
 {
-    lldb::LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
+    Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
     
     static unsigned int invocation_id = 0;
     unsigned int current_id = invocation_id++;
@@ -668,72 +939,13 @@ ClangASTSource::FindObjCMethodDecls (Nam
             
         ObjCInterfaceDecl *original_interface_decl = dyn_cast<ObjCInterfaceDecl>(original_decl);
         
-        Selector original_selector;
-                
-        if (decl_name.isObjCZeroArgSelector())
-        {
-            IdentifierInfo *ident = &original_ctx->Idents.get(decl_name.getAsString());
-            original_selector = original_ctx->Selectors.getSelector(0, &ident);
-        }
-        else if (decl_name.isObjCOneArgSelector())
-        {
-            const std::string &decl_name_string = decl_name.getAsString();
-            std::string decl_name_string_without_colon(decl_name_string.c_str(), decl_name_string.length() - 1);
-            IdentifierInfo *ident = &original_ctx->Idents.get(decl_name_string_without_colon.c_str());
-            original_selector = original_ctx->Selectors.getSelector(1, &ident);
-        }
-        else
-        {
-            SmallVector<IdentifierInfo *, 4> idents;
-            
-            clang::Selector sel = decl_name.getObjCSelector();
-            
-            int num_args = sel.getNumArgs();
-            
-            for (unsigned i = 0;
-                 i != num_args;
-                 ++i)
-            {
-                idents.push_back(&original_ctx->Idents.get(sel.getNameForSlot(i)));
-            }
-            
-            original_selector = original_ctx->Selectors.getSelector(num_args, idents.data());
-        }
-        
-        DeclarationName original_decl_name(original_selector);
-                
-        ObjCInterfaceDecl::lookup_result result = original_interface_decl->lookup(original_decl_name);
-        
-        if (result.first == result.second)
-            break;
-        
-        if (!*result.first)
-            break;
-        
-        ObjCMethodDecl *result_method = dyn_cast<ObjCMethodDecl>(*result.first);
-        
-        if (!result_method)
-            break;
-        
-        Decl *copied_decl = m_ast_importer->CopyDecl(m_ast_context, &result_method->getASTContext(), result_method);
-        
-        if (!copied_decl)
-            continue;
-        
-        ObjCMethodDecl *copied_method_decl = dyn_cast<ObjCMethodDecl>(copied_decl);
-        
-        if (!copied_method_decl)
-            continue;
-        
-        if (log)
-        {
-            ASTDumper dumper((Decl*)copied_method_decl);
-            log->Printf("  CAS::FOMD[%d] found (in debug info) %s", current_id, dumper.GetCString());
-        }
-        
-        context.AddNamedDecl(copied_method_decl);
-        
-        return;
+        if (FindObjCMethodDeclsWithOrigin(current_id,
+                                          context,
+                                          original_interface_decl,
+                                          m_ast_context,
+                                          m_ast_importer,
+                                          "at origin"))
+            return; // found it, no need to look any further
     } while (0);
     
     StreamString ss;
@@ -844,111 +1056,142 @@ ClangASTSource::FindObjCMethodDecls (Nam
     }
     while (0);
     
-    for (uint32_t i = 0, e = sc_list.GetSize();
-         i != e;
-         ++i)
+    if (sc_list.GetSize())
     {
-        SymbolContext sc;
-        
-        if (!sc_list.GetContextAtIndex(i, sc))
-            continue;
-        
-        if (!sc.function)
-            continue;
-        
-        DeclContext *function_ctx = sc.function->GetClangDeclContext();
-        
-        if (!function_ctx)
-            continue;
-        
-        ObjCMethodDecl *method_decl = dyn_cast<ObjCMethodDecl>(function_ctx);
-        
-        if (!method_decl)
-            continue;
-        
-        ObjCInterfaceDecl *found_interface_decl = method_decl->getClassInterface();
-        
-        if (!found_interface_decl)
-            continue;
+        // We found a good function symbol.  Use that.
         
-        if (found_interface_decl->getName() == interface_decl->getName())
+        for (uint32_t i = 0, e = sc_list.GetSize();
+             i != e;
+             ++i)
         {
-            Decl *copied_decl = m_ast_importer->CopyDecl(m_ast_context, &method_decl->getASTContext(), method_decl);
+            SymbolContext sc;
             
-            if (!copied_decl)
+            if (!sc_list.GetContextAtIndex(i, sc))
                 continue;
             
-            ObjCMethodDecl *copied_method_decl = dyn_cast<ObjCMethodDecl>(copied_decl);
+            if (!sc.function)
+                continue;
             
-            if (!copied_method_decl)
+            DeclContext *function_ctx = sc.function->GetClangDeclContext();
+            
+            if (!function_ctx)
                 continue;
             
-            if (log)
+            ObjCMethodDecl *method_decl = dyn_cast<ObjCMethodDecl>(function_ctx);
+            
+            if (!method_decl)
+                continue;
+            
+            ObjCInterfaceDecl *found_interface_decl = method_decl->getClassInterface();
+            
+            if (!found_interface_decl)
+                continue;
+            
+            if (found_interface_decl->getName() == interface_decl->getName())
             {
-                ASTDumper dumper((Decl*)copied_method_decl);
-                log->Printf("  CAS::FOMD[%d] found (in debug info) %s", current_id, dumper.GetCString());
+                Decl *copied_decl = m_ast_importer->CopyDecl(m_ast_context, &method_decl->getASTContext(), method_decl);
+                
+                if (!copied_decl)
+                    continue;
+                
+                ObjCMethodDecl *copied_method_decl = dyn_cast<ObjCMethodDecl>(copied_decl);
+                
+                if (!copied_method_decl)
+                    continue;
+                
+                if (log)
+                {
+                    ASTDumper dumper((Decl*)copied_method_decl);
+                    log->Printf("  CAS::FOMD[%d] found (in symbols) %s", current_id, dumper.GetCString());
+                }
+                
+                context.AddNamedDecl(copied_method_decl);
             }
-            
-            context.AddNamedDecl(copied_method_decl);
         }
+        
+        return;
     }
-}
-
-template <class D> class TaggedASTDecl {
-public:
-    TaggedASTDecl() : decl(NULL) { }
-    TaggedASTDecl(D *_decl) : decl(_decl) { }
-    bool IsValid() const { return (decl != NULL); }
-    bool IsInvalid() const { return !IsValid(); }
-    D *operator->() const { return decl; }
-    D *decl;
-};
-
-template <class D2, template <class D> class TD, class D1> 
-TD<D2>
-DynCast(TD<D1> source)
-{
-    return TD<D2> (dyn_cast<D2>(source.decl));
-}
-
-template <class D = Decl> class DeclFromParser;
-template <class D = Decl> class DeclFromUser;
-
-template <class D> class DeclFromParser : public TaggedASTDecl<D> { 
-public:
-    DeclFromParser() : TaggedASTDecl<D>() { }
-    DeclFromParser(D *_decl) : TaggedASTDecl<D>(_decl) { }
     
-    DeclFromUser<D> GetOrigin(ClangASTImporter *importer);
-};
-
-template <class D> class DeclFromUser : public TaggedASTDecl<D> { 
-public:
-    DeclFromUser() : TaggedASTDecl<D>() { }
-    DeclFromUser(D *_decl) : TaggedASTDecl<D>(_decl) { }
+    // Try the debug information.
     
-    DeclFromParser<D> Import(ClangASTImporter *importer, ASTContext &dest_ctx);
-};
-
-template <class D>
-DeclFromUser<D>
-DeclFromParser<D>::GetOrigin(ClangASTImporter *importer)
-{
-    DeclFromUser <> origin_decl;
-    importer->ResolveDeclOrigin(this->decl, &origin_decl.decl, NULL);
-    if (origin_decl.IsInvalid())
-        return DeclFromUser<D>();
-    return DeclFromUser<D>(dyn_cast<D>(origin_decl.decl));
-}
-
-template <class D>
-DeclFromParser<D>
-DeclFromUser<D>::Import(ClangASTImporter *importer, ASTContext &dest_ctx)
-{
-    DeclFromParser <> parser_generic_decl(importer->CopyDecl(&dest_ctx, &this->decl->getASTContext(), this->decl));
-    if (parser_generic_decl.IsInvalid())
-        return DeclFromParser<D>();
-    return DeclFromParser<D>(dyn_cast<D>(parser_generic_decl.decl));
+    do
+    {
+        ObjCInterfaceDecl *complete_interface_decl = GetCompleteObjCInterface(const_cast<ObjCInterfaceDecl*>(interface_decl));
+        
+        if (!complete_interface_decl)
+            break;
+        
+        // We found the complete interface.  The runtime never needs to be queried in this scenario.
+        
+        DeclFromUser<const ObjCInterfaceDecl> complete_iface_decl(complete_interface_decl);
+        
+        if (complete_interface_decl == interface_decl)
+            break; // already checked this one
+        
+        if (log)
+            log->Printf("CAS::FOPD[%d] trying origin (ObjCInterfaceDecl*)%p/(ASTContext*)%p...",
+                        current_id,
+                        complete_interface_decl,
+                        &complete_iface_decl->getASTContext());
+        
+        FindObjCMethodDeclsWithOrigin(current_id,
+                                      context,
+                                      complete_interface_decl,
+                                      m_ast_context,
+                                      m_ast_importer,
+                                      "in debug info");
+        
+        return;
+    }
+    while (0);
+    
+    do
+    {
+        // Check the runtime only if the debug information didn't have a complete interface.
+        
+        lldb::ProcessSP process(m_target->GetProcessSP());
+        
+        if (!process)
+            break;
+        
+        ObjCLanguageRuntime *language_runtime(process->GetObjCLanguageRuntime());
+        
+        if (!language_runtime)
+            break;
+        
+        TypeVendor *type_vendor = language_runtime->GetTypeVendor();
+        
+        if (!type_vendor)
+            break;
+        
+        ConstString interface_name(interface_decl->getNameAsString().c_str());
+        bool append = false;
+        uint32_t max_matches = 1;
+        std::vector <ClangASTType> types;
+        
+        if (!type_vendor->FindTypes(interface_name,
+                                    append,
+                                    max_matches,
+                                    types))
+            break;
+        
+        const clang::Type *runtime_clang_type = QualType::getFromOpaquePtr(types[0].GetOpaqueQualType()).getTypePtr();
+        
+        const ObjCInterfaceType *runtime_interface_type = dyn_cast<ObjCInterfaceType>(runtime_clang_type);
+        
+        if (!runtime_interface_type)
+            break;
+        
+        ObjCInterfaceDecl *runtime_interface_decl = runtime_interface_type->getDecl();
+        
+        FindObjCMethodDeclsWithOrigin(current_id,
+                                      context,
+                                      runtime_interface_decl,
+                                      m_ast_context,
+                                      m_ast_importer,
+                                      "in runtime");
+    }
+    while(0);
 }
 
 static bool
@@ -958,7 +1201,7 @@ FindObjCPropertyAndIvarDeclsWithOrigin (
                                         ClangASTImporter *ast_importer,
                                         DeclFromUser<const ObjCInterfaceDecl> &origin_iface_decl)
 {
-    lldb::LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
+    Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
 
     if (origin_iface_decl.IsInvalid())
         return false;
@@ -1011,7 +1254,7 @@ FindObjCPropertyAndIvarDeclsWithOrigin (
 void
 ClangASTSource::FindObjCPropertyAndIvarDecls (NameSearchContext &context)
 {
-    lldb::LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
+    Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
 
     static unsigned int invocation_id = 0;
     unsigned int current_id = invocation_id++;
@@ -1044,51 +1287,88 @@ ClangASTSource::FindObjCPropertyAndIvarD
     SymbolContext null_sc;
     TypeList type_list;
     
-    lldb::ProcessSP process(m_target->GetProcessSP());
-    
-    if (!process)
-        return;
-    
-    ObjCLanguageRuntime *language_runtime(process->GetObjCLanguageRuntime());
-    
-    if (!language_runtime)
-        return;
-    
-    lldb::TypeSP complete_type_sp(language_runtime->LookupInCompleteClassCache(class_name));
-    
-    if (!complete_type_sp)
-        return;
-    
-    TypeFromUser complete_type = TypeFromUser(complete_type_sp->GetClangFullType(), complete_type_sp->GetClangAST());
-    lldb::clang_type_t complete_opaque_type = complete_type.GetOpaqueQualType();
-    
-    if (!complete_opaque_type)
-        return;
-    
-    const clang::Type *complete_clang_type = QualType::getFromOpaquePtr(complete_opaque_type).getTypePtr();
-    const ObjCInterfaceType *complete_interface_type = dyn_cast<ObjCInterfaceType>(complete_clang_type);
-    
-    if (!complete_interface_type)
-        return;
-    
-    DeclFromUser<const ObjCInterfaceDecl> complete_iface_decl(complete_interface_type->getDecl());
-    
-    if (complete_iface_decl.decl == origin_iface_decl.decl)
-        return; // already checked this one
-    
-    if (log)
-        log->Printf("CAS::FOPD[%d] trying origin (ObjCInterfaceDecl*)%p/(ASTContext*)%p...",
-                    current_id,
-                    complete_iface_decl.decl, 
-                    &complete_iface_decl->getASTContext());
-    
-    
-    if (FindObjCPropertyAndIvarDeclsWithOrigin(current_id, 
+    do
+    {
+        ObjCInterfaceDecl *complete_interface_decl = GetCompleteObjCInterface(const_cast<ObjCInterfaceDecl*>(parser_iface_decl.decl));
+        
+        if (!complete_interface_decl)
+            break;
+        
+        // We found the complete interface.  The runtime never needs to be queried in this scenario.
+        
+        DeclFromUser<const ObjCInterfaceDecl> complete_iface_decl(complete_interface_decl);
+        
+        if (complete_iface_decl.decl == origin_iface_decl.decl)
+            break; // already checked this one
+        
+        if (log)
+            log->Printf("CAS::FOPD[%d] trying origin (ObjCInterfaceDecl*)%p/(ASTContext*)%p...",
+                        current_id,
+                        complete_iface_decl.decl, 
+                        &complete_iface_decl->getASTContext());
+        
+        FindObjCPropertyAndIvarDeclsWithOrigin(current_id, 
                                                context, 
                                                *m_ast_context, 
                                                m_ast_importer, 
-                                               complete_iface_decl))
+                                               complete_iface_decl);
+        
         return;
+    }
+    while(0);
+    
+    do
+    {
+        // Check the runtime only if the debug information didn't have a complete interface.
+        
+        lldb::ProcessSP process(m_target->GetProcessSP());
+        
+        if (!process)
+            return;
+        
+        ObjCLanguageRuntime *language_runtime(process->GetObjCLanguageRuntime());
+        
+        if (!language_runtime)
+            return;
+        
+        TypeVendor *type_vendor = language_runtime->GetTypeVendor();
+        
+        if (!type_vendor)
+            break;
+        
+        bool append = false;
+        uint32_t max_matches = 1;
+        std::vector <ClangASTType> types;
+        
+        if (!type_vendor->FindTypes(class_name,
+                                    append,
+                                    max_matches,
+                                    types))
+            break;
+        
+        const clang::Type *runtime_clang_type = QualType::getFromOpaquePtr(types[0].GetOpaqueQualType()).getTypePtr();
+
+        const ObjCInterfaceType *runtime_interface_type = dyn_cast<ObjCInterfaceType>(runtime_clang_type);
+        
+        if (!runtime_interface_type)
+            break;
+        
+        DeclFromUser<const ObjCInterfaceDecl> runtime_iface_decl(runtime_interface_type->getDecl());
+        
+        if (log)
+            log->Printf("CAS::FOPD[%d] trying runtime (ObjCInterfaceDecl*)%p/(ASTContext*)%p...",
+                        current_id,
+                        runtime_iface_decl.decl,
+                        &runtime_iface_decl->getASTContext());
+        
+        if (FindObjCPropertyAndIvarDeclsWithOrigin(current_id,
+                                                   context,
+                                                   *m_ast_context,
+                                                   m_ast_importer,
+                                                   runtime_iface_decl))
+            return;
+    }
+    while(0);
 }
 
 typedef llvm::DenseMap <const FieldDecl *, uint64_t> FieldOffsetMap;
@@ -1167,16 +1447,19 @@ ClangASTSource::layoutRecordType(const R
                                  BaseOffsetMap &base_offsets,
                                  BaseOffsetMap &virtual_base_offsets)
 {
+    ClangASTMetrics::RegisterRecordLayout();
+    
     static unsigned int invocation_id = 0;
     unsigned int current_id = invocation_id++;
     
-    lldb::LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
+    Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
     
     if (log)
     {
-        log->Printf("LayoutRecordType[%u] on (RecordDecl*)%p [name = '%s']",
+        log->Printf("LayoutRecordType[%u] on (ASTContext*)%p for (RecordDecl*)%p [name = '%s']",
                     current_id,
                     m_ast_context,
+                    record,
                     record->getNameAsString().c_str());
     }
     
@@ -1198,12 +1481,15 @@ ClangASTSource::layoutRecordType(const R
     
     const ASTRecordLayout &record_layout(origin_record->getASTContext().getASTRecordLayout(origin_record.decl));
     
-    int field_idx = 0;
+    int field_idx = 0, field_count = record_layout.getFieldCount();
     
     for (RecordDecl::field_iterator fi = origin_record->field_begin(), fe = origin_record->field_end();
          fi != fe;
          ++fi)
     {
+        if (field_idx >= field_count)
+            return false; // Layout didn't go well.  Bail out.
+        
         uint64_t field_offset = record_layout.getFieldOffset(field_idx);
         
         origin_field_offsets.insert(std::pair<const FieldDecl *, uint64_t>(*fi, field_offset));
@@ -1234,14 +1520,14 @@ ClangASTSource::layoutRecordType(const R
     {
         log->Printf("LRT[%u] returned:", current_id);
         log->Printf("LRT[%u]   Original = (RecordDecl*)%p", current_id, origin_record.decl);
-        log->Printf("LRT[%u]   Size = %lld", current_id, size);
-        log->Printf("LRT[%u]   Alignment = %lld", current_id, alignment);
+        log->Printf("LRT[%u]   Size = %" PRId64, current_id, size);
+        log->Printf("LRT[%u]   Alignment = %" PRId64, current_id, alignment);
         log->Printf("LRT[%u]   Fields:", current_id);
         for (RecordDecl::field_iterator fi = record->field_begin(), fe = record->field_end();
              fi != fe;
              ++fi)
         {
-            log->Printf("LRT[%u]     (FieldDecl*)%p, Name = '%s', Offset = %lld bits",
+            log->Printf("LRT[%u]     (FieldDecl*)%p, Name = '%s', Offset = %" PRId64 " bits",
                         current_id,
                         *fi,
                         fi->getNameAsString().c_str(),
@@ -1262,7 +1548,7 @@ ClangASTSource::layoutRecordType(const R
                 DeclFromParser <RecordDecl> base_record(base_record_type->getDecl());
                 DeclFromParser <CXXRecordDecl> base_cxx_record = DynCast<CXXRecordDecl>(base_record);
                 
-                log->Printf("LRT[%u]     %s(CXXRecordDecl*)%p, Name = '%s', Offset = %lld chars",
+                log->Printf("LRT[%u]     %s(CXXRecordDecl*)%p, Name = '%s', Offset = %" PRId64 " chars",
                             current_id,
                             (is_virtual ? "Virtual " : ""),
                             base_cxx_record.decl,
@@ -1288,7 +1574,7 @@ ClangASTSource::CompleteNamespaceMap (Cl
     static unsigned int invocation_id = 0;
     unsigned int current_id = invocation_id++;
     
-    lldb::LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
+    Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
     
     if (log)
     {
@@ -1340,14 +1626,12 @@ ClangASTSource::CompleteNamespaceMap (Cl
     }
     else
     {
-        ModuleList &target_images = m_target->GetImages();
+        const ModuleList &target_images = m_target->GetImages();
         Mutex::Locker modules_locker(target_images.GetMutex());
         
         ClangNamespaceDecl null_namespace_decl;
         
-        for (uint32_t i = 0, e = target_images.GetSize();
-             i != e;
-             ++i)
+        for (size_t i = 0, e = target_images.GetSize(); i < e; ++i)
         {
             lldb::ModuleSP image = target_images.GetModuleAtIndexUnlocked(i);
             
@@ -1385,17 +1669,20 @@ ClangASTSource::AddNamespace (NameSearch
     if (!namespace_decls)
         return NULL;
     
-    lldb::LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
-        
     const ClangNamespaceDecl &namespace_decl = namespace_decls->begin()->second;
     
     Decl *copied_decl = m_ast_importer->CopyDecl(m_ast_context, namespace_decl.GetASTContext(), namespace_decl.GetNamespaceDecl());
     
     if (!copied_decl)
         return NULL;
-    
+        
     NamespaceDecl *copied_namespace_decl = dyn_cast<NamespaceDecl>(copied_decl);
     
+    if (!copied_namespace_decl)
+        return NULL;
+    
+    context.m_decls.push_back(copied_namespace_decl);
+    
     m_ast_importer->RegisterNamespaceMap(copied_namespace_decl, namespace_decls);
     
     return dyn_cast<NamespaceDecl>(copied_decl);
@@ -1405,7 +1692,9 @@ void *
 ClangASTSource::GuardedCopyType (ASTContext *dest_context, 
                                  ASTContext *source_context,
                                  void *clang_type)
-{    
+{
+    ClangASTMetrics::RegisterLLDBImport();
+    
     SetImportInProgress(true);
     
     QualType ret_qual_type = m_ast_importer->CopyType (m_ast_context, source_context, QualType::getFromOpaquePtr(clang_type));
@@ -1436,7 +1725,6 @@ NameSearchContext::AddVarDecl(void *type
                                              ii, 
                                              QualType::getFromOpaquePtr(type), 
                                              0, 
-                                             SC_Static, 
                                              SC_Static);
     m_decls.push_back(Decl);
     
@@ -1448,6 +1736,11 @@ NameSearchContext::AddFunDecl (void *typ
 {
     assert (type && "Type for variable must be non-NULL!");
     
+    if (m_function_types.count(type))
+        return NULL;
+    
+    m_function_types.insert(type);
+    
     clang::FunctionDecl *func_decl = FunctionDecl::Create (*m_ast_source.m_ast_context,
                                                            const_cast<DeclContext*>(m_decl_context),
                                                            SourceLocation(),
@@ -1486,7 +1779,6 @@ NameSearchContext::AddFunDecl (void *typ
                                                           arg_qual_type,
                                                           NULL,
                                                           SC_Static,
-                                                          SC_Static,
                                                           NULL));
         }
         
@@ -1494,9 +1786,10 @@ NameSearchContext::AddFunDecl (void *typ
     }
     else
     {
-        lldb::LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
+        Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
 
-        log->Printf("Function type wasn't a FunctionProtoType");
+        if (log)
+            log->Printf("Function type wasn't a FunctionProtoType");
     }
     
     m_decls.push_back(func_decl);
@@ -1512,8 +1805,7 @@ NameSearchContext::AddGenericFunDecl()
     proto_info.Variadic = true;
     
     QualType generic_function_type(m_ast_source.m_ast_context->getFunctionType (m_ast_source.m_ast_context->UnknownAnyTy,    // result
-                                                                                NULL,                                        // argument types
-                                                                                0,                                           // number of arguments
+                                                                                ArrayRef<QualType>(),                                        // argument types
                                                                                 proto_info));
     
     return AddFunDecl(generic_function_type.getAsOpaquePtr());
@@ -1542,6 +1834,14 @@ NameSearchContext::AddTypeDecl(void *typ
             
             return (NamedDecl*)interface_decl;
         }
+        else if (const TypedefType *typedef_type = qual_type->getAs<TypedefType>())
+        {
+            TypedefNameDecl *typedef_name_decl = typedef_type->getDecl();
+            
+            m_decls.push_back(typedef_name_decl);
+            
+            return (NamedDecl*)typedef_name_decl;
+        }
     }
     return NULL;
 }
@@ -1549,10 +1849,8 @@ NameSearchContext::AddTypeDecl(void *typ
 void 
 NameSearchContext::AddLookupResult (clang::DeclContextLookupConstResult result)
 {
-    for (clang::NamedDecl * const *decl_iterator = result.first;
-         decl_iterator != result.second;
-         ++decl_iterator)
-        m_decls.push_back (*decl_iterator);
+    for (clang::NamedDecl *decl : result)
+        m_decls.push_back (decl);
 }
 
 void

Modified: lldb/branches/lldb-platform-work/source/Expression/ClangExpressionDeclMap.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/lldb-platform-work/source/Expression/ClangExpressionDeclMap.cpp?rev=183468&r1=183467&r2=183468&view=diff
==============================================================================
--- lldb/branches/lldb-platform-work/source/Expression/ClangExpressionDeclMap.cpp (original)
+++ lldb/branches/lldb-platform-work/source/Expression/ClangExpressionDeclMap.cpp Thu Jun  6 19:06:43 2013
@@ -13,6 +13,7 @@
 // C++ Includes
 // Other libraries and framework includes
 // Project includes
+#include "clang/AST/ASTContext.h"
 #include "clang/AST/DeclarationName.h"
 #include "clang/AST/Decl.h"
 #include "lldb/lldb-private.h"
@@ -26,6 +27,7 @@
 #include "lldb/Expression/ASTDumper.h"
 #include "lldb/Expression/ClangASTSource.h"
 #include "lldb/Expression/ClangPersistentVariables.h"
+#include "lldb/Expression/Materializer.h"
 #include "lldb/Host/Endian.h"
 #include "lldb/Symbol/ClangASTContext.h"
 #include "lldb/Symbol/ClangNamespaceDecl.h"
@@ -39,6 +41,7 @@
 #include "lldb/Symbol/Variable.h"
 #include "lldb/Symbol/VariableList.h"
 #include "lldb/Target/ExecutionContext.h"
+#include "lldb/Target/ObjCLanguageRuntime.h"
 #include "lldb/Target/Process.h"
 #include "lldb/Target/RegisterContext.h"
 #include "lldb/Target/StackFrame.h"
@@ -67,29 +70,31 @@ ClangExpressionDeclMap::~ClangExpression
     //   that valuable lookup data (like namespaces) doesn't vanish, but 
     
     DidParse();
-    DidDematerialize();
     DisableStructVars();
 }
 
 bool 
-ClangExpressionDeclMap::WillParse(ExecutionContext &exe_ctx)
-{    
+ClangExpressionDeclMap::WillParse(ExecutionContext &exe_ctx,
+                                  Materializer *materializer)
+{
+    ClangASTMetrics::ClearLocalCounters();
+    
     EnableParserVars();
     m_parser_vars->m_exe_ctx = exe_ctx;
     
     Target *target = exe_ctx.GetTargetPtr();
     if (exe_ctx.GetFramePtr())
         m_parser_vars->m_sym_ctx = exe_ctx.GetFramePtr()->GetSymbolContext(lldb::eSymbolContextEverything);
-    else if (exe_ctx.GetThreadPtr())
+    else if (exe_ctx.GetThreadPtr() && exe_ctx.GetThreadPtr()->GetStackFrameAtIndex(0))
         m_parser_vars->m_sym_ctx = exe_ctx.GetThreadPtr()->GetStackFrameAtIndex(0)->GetSymbolContext(lldb::eSymbolContextEverything);
     else if (exe_ctx.GetProcessPtr())
     {
-        m_parser_vars->m_sym_ctx.Clear();
+        m_parser_vars->m_sym_ctx.Clear(true);
         m_parser_vars->m_sym_ctx.target_sp = exe_ctx.GetTargetSP();
     }
     else if (target)
     {
-        m_parser_vars->m_sym_ctx.Clear();
+        m_parser_vars->m_sym_ctx.Clear(true);
         m_parser_vars->m_sym_ctx.target_sp = exe_ctx.GetTargetSP();
     }
     
@@ -102,13 +107,19 @@ ClangExpressionDeclMap::WillParse(Execut
     }
     
     m_parser_vars->m_target_info = GetTargetInfo();
+    m_parser_vars->m_materializer = materializer;
     
     return true;
 }
 
-void 
+void
 ClangExpressionDeclMap::DidParse()
 {
+    Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
+
+    if (log)
+        ClangASTMetrics::DumpCounters(log);
+    
     if (m_parser_vars.get())
     {
         for (size_t entity_index = 0, num_entities = m_found_entities.GetSize();
@@ -116,12 +127,15 @@ ClangExpressionDeclMap::DidParse()
              ++entity_index)
         {
             ClangExpressionVariableSP var_sp(m_found_entities.GetVariableAtIndex(entity_index));
-            if (var_sp && 
-                var_sp->m_parser_vars.get() && 
-                var_sp->m_parser_vars->m_lldb_value)
-                delete var_sp->m_parser_vars->m_lldb_value;
+            if (var_sp)
+            {
+                ClangExpressionVariable::ParserVars *parser_vars = var_sp->GetParserVars(GetParserID());
+                
+                if (parser_vars && parser_vars->m_lldb_value)
+                    delete parser_vars->m_lldb_value;
             
-            var_sp->DisableParserVars();
+                var_sp->DisableParserVars(GetParserID());
+            }
         }
         
         for (size_t pvar_index = 0, num_pvars = m_parser_vars->m_persistent_vars->GetSize();
@@ -130,7 +144,7 @@ ClangExpressionDeclMap::DidParse()
         {
             ClangExpressionVariableSP pvar_sp(m_parser_vars->m_persistent_vars->GetVariableAtIndex(pvar_index));
             if (pvar_sp)
-                pvar_sp->DisableParserVars();
+                pvar_sp->DisableParserVars(GetParserID());
         }
         
         DisableParserVars();
@@ -167,285 +181,64 @@ ClangExpressionDeclMap::GetTargetInfo()
     return ret;
 }
 
-const ConstString &
-ClangExpressionDeclMap::GetPersistentResultName ()
-{
-    assert (m_struct_vars.get());
-    assert (m_parser_vars.get());
-    if (!m_struct_vars->m_result_name)
-    {
-        Target *target = m_parser_vars->GetTarget();
-        assert (target);
-        m_struct_vars->m_result_name = target->GetPersistentVariables().GetNextPersistentVariableName();
-    }
-    return m_struct_vars->m_result_name;
-}
-
-lldb::ClangExpressionVariableSP
-ClangExpressionDeclMap::BuildIntegerVariable (const ConstString &name,
-                                              lldb_private::TypeFromParser type,
-                                              const llvm::APInt& value)
+bool 
+ClangExpressionDeclMap::AddPersistentVariable 
+(
+    const NamedDecl *decl, 
+    const ConstString &name, 
+    TypeFromParser parser_type,
+    bool is_result,
+    bool is_lvalue
+)
 {
     assert (m_parser_vars.get());
     
-    ExecutionContext &exe_ctx = m_parser_vars->m_exe_ctx;
-    
-    Target *target = exe_ctx.GetTargetPtr();
-    
-    if (!target)
-        return ClangExpressionVariableSP();
-
-    ASTContext *context(target->GetScratchClangASTContext()->getASTContext());
-    
-    TypeFromUser user_type(m_ast_importer->CopyType(context, 
-                                                    type.GetASTContext(),
-                                                    type.GetOpaqueQualType()),
-                           context);
-    
-    if (!user_type.GetOpaqueQualType())
-    {
-        lldb::LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
-
-        if (log)
-            log->Printf("ClangExpressionDeclMap::BuildIntegerVariable - Couldn't export the type for a constant integer result");
-        
-        return lldb::ClangExpressionVariableSP();
-    }
-    
-    if (!m_parser_vars->m_persistent_vars->CreatePersistentVariable (exe_ctx.GetBestExecutionContextScope (),
-                                                                     name, 
-                                                                     user_type, 
-                                                                     m_parser_vars->m_target_info.byte_order,
-                                                                     m_parser_vars->m_target_info.address_byte_size))
-        return lldb::ClangExpressionVariableSP();
-    
-    ClangExpressionVariableSP pvar_sp (m_parser_vars->m_persistent_vars->GetVariable(name));
-    
-    if (!pvar_sp)
-        return lldb::ClangExpressionVariableSP();
-    
-    uint8_t *pvar_data = pvar_sp->GetValueBytes();
-    if (pvar_data == NULL)
-        return lldb::ClangExpressionVariableSP();
-    
-    uint64_t value64 = value.getLimitedValue();
-        
-    size_t num_val_bytes = sizeof(value64);
-    size_t num_data_bytes = pvar_sp->GetByteSize();
-    
-    size_t num_bytes = num_val_bytes;
-    if (num_bytes > num_data_bytes)
-        num_bytes = num_data_bytes;
-    
-    for (size_t byte_idx = 0;
-         byte_idx < num_bytes;
-         ++byte_idx)
+    if (m_parser_vars->m_materializer && is_result)
     {
-        uint64_t shift = byte_idx * 8;
-        uint64_t mask = 0xffll << shift;
-        uint8_t cur_byte = (uint8_t)((value64 & mask) >> shift);
+        Error err;
         
-        switch (m_parser_vars->m_target_info.byte_order)
-        {
-            case eByteOrderBig:
-                //                    High         Low
-                // Original:         |AABBCCDDEEFFGGHH|
-                // Target:                   |EEFFGGHH|
-                
-                pvar_data[num_data_bytes - (1 + byte_idx)] = cur_byte;
-                break;
-            case eByteOrderLittle:
-                // Target:                   |HHGGFFEE|
-                pvar_data[byte_idx] = cur_byte;
-                break;
-            default:
-                return lldb::ClangExpressionVariableSP();    
-        }
-    }
-    
-    pvar_sp->m_flags |= ClangExpressionVariable::EVIsFreezeDried;
-    pvar_sp->m_flags |= ClangExpressionVariable::EVIsLLDBAllocated;
-    pvar_sp->m_flags |= ClangExpressionVariable::EVNeedsAllocation;
-
-    return pvar_sp;
-}
-
-lldb::ClangExpressionVariableSP
-ClangExpressionDeclMap::BuildCastVariable (const ConstString &name,
-                                           VarDecl *decl,
-                                           lldb_private::TypeFromParser type)
-{
-    assert (m_parser_vars.get());
-    
-    lldb::LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
-    
-    ExecutionContext &exe_ctx = m_parser_vars->m_exe_ctx;
-    Target *target = exe_ctx.GetTargetPtr();
-    if (target == NULL)
-        return lldb::ClangExpressionVariableSP();
-
-    ASTContext *context(target->GetScratchClangASTContext()->getASTContext());
-    
-    ClangExpressionVariableSP var_sp (m_found_entities.GetVariable(decl));
-    
-    if (!var_sp)
-        var_sp = m_parser_vars->m_persistent_vars->GetVariable(decl);
-    
-    if (!var_sp)
-        return ClangExpressionVariableSP();
-    
-    TypeFromUser user_type(m_ast_importer->CopyType(context, 
-                                                    type.GetASTContext(),
-                                                    type.GetOpaqueQualType()),
-                           context);
-    
-    if (!user_type.GetOpaqueQualType())
-    {
-        lldb::LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
+        ExecutionContext &exe_ctx = m_parser_vars->m_exe_ctx;
+        Target *target = exe_ctx.GetTargetPtr();
+        if (target == NULL)
+            return false;
         
-        if (log)
-            log->Printf("ClangExpressionDeclMap::BuildCastVariable - Couldn't export the type for a constant cast result");
+        ASTContext *context(target->GetScratchClangASTContext()->getASTContext());
         
-        return lldb::ClangExpressionVariableSP();
-    }
-    
-    TypeFromUser var_type = var_sp->GetTypeFromUser();
-    
-    StackFrame *frame = exe_ctx.GetFramePtr();
-    if (frame == NULL)
-        return lldb::ClangExpressionVariableSP();
-    
-    VariableSP var = FindVariableInScope (*frame, var_sp->GetName(), &var_type);
-    
-    if (!var)
-        return lldb::ClangExpressionVariableSP(); // but we should handle this; it may be a persistent variable
-    
-    ValueObjectSP var_valobj = frame->GetValueObjectForFrameVariable(var, lldb::eNoDynamicValues);
-
-    if (!var_valobj)
-        return lldb::ClangExpressionVariableSP();
-    
-    ValueObjectSP var_casted_valobj = var_valobj->CastPointerType(name.GetCString(), user_type);
-    
-    if (!var_casted_valobj)
-        return lldb::ClangExpressionVariableSP();
-    
-    if (log)
-    {
-        StreamString my_stream_string;
+        TypeFromUser user_type(m_ast_importer->DeportType(context,
+                                                          parser_type.GetASTContext(),
+                                                          parser_type.GetOpaqueQualType()),
+                               context);
         
-        ClangASTType::DumpTypeDescription (var_type.GetASTContext(),
-                                           var_type.GetOpaqueQualType(),
-                                           &my_stream_string);
+        uint32_t offset = m_parser_vars->m_materializer->AddResultVariable(user_type, is_lvalue, m_keep_result_in_memory, err);
         
+        m_found_entities.CreateVariable(exe_ctx.GetBestExecutionContextScope(),
+                                        name,
+                                        user_type,
+                                        m_parser_vars->m_target_info.byte_order,
+                                        m_parser_vars->m_target_info.address_byte_size);
         
-        log->Printf("Building cast variable to type: %s", my_stream_string.GetString().c_str());
-    }
-    
-    ClangExpressionVariableSP pvar_sp = m_parser_vars->m_persistent_vars->CreatePersistentVariable (var_casted_valobj);
-    
-    if (!pvar_sp)
-        return lldb::ClangExpressionVariableSP();
-    
-    if (pvar_sp != m_parser_vars->m_persistent_vars->GetVariable(name))
-        return lldb::ClangExpressionVariableSP();
-    
-    pvar_sp->m_flags |= ClangExpressionVariable::EVIsFreezeDried;
-    pvar_sp->m_flags |= ClangExpressionVariable::EVIsLLDBAllocated;
-    pvar_sp->m_flags |= ClangExpressionVariable::EVNeedsAllocation;
-            
-    return pvar_sp;
-}
-
-bool
-ClangExpressionDeclMap::ResultIsReference (const ConstString &name)
-{
-    ClangExpressionVariableSP pvar_sp = m_parser_vars->m_persistent_vars->GetVariable(name);
-    
-    return (pvar_sp->m_flags & ClangExpressionVariable::EVIsProgramReference);
-}
-
-bool
-ClangExpressionDeclMap::CompleteResultVariable (lldb::ClangExpressionVariableSP &valobj, 
-                                                lldb_private::Value &value,
-                                                const ConstString &name,
-                                                lldb_private::TypeFromParser type,
-                                                bool transient,
-                                                bool maybe_make_load)
-{
-    assert (m_parser_vars.get());
+        ClangExpressionVariableSP var_sp (m_found_entities.GetVariable(name));
         
-    ClangExpressionVariableSP pvar_sp = m_parser_vars->m_persistent_vars->GetVariable(name);
-    
-    if (!pvar_sp)
-        return false;
+        if (!var_sp)
+            return false;
         
-    if (maybe_make_load && 
-        value.GetValueType() == Value::eValueTypeFileAddress &&
-        m_parser_vars->m_exe_ctx.GetProcessPtr())
-    {
-        value.SetValueType(Value::eValueTypeLoadAddress);
-    }
-    
-    if (pvar_sp->m_flags & ClangExpressionVariable::EVIsProgramReference &&
-        !pvar_sp->m_live_sp &&
-        !transient)
-    {
-        // The reference comes from the program.  We need to set up a live SP for it.
+        var_sp->EnableParserVars(GetParserID());
         
-        unsigned long long address = value.GetScalar().ULongLong();
-        AddressType address_type = value.GetValueAddressType();
+        ClangExpressionVariable::ParserVars *parser_vars = var_sp->GetParserVars(GetParserID());
+
+        parser_vars->m_named_decl = decl;
+        parser_vars->m_parser_type = parser_type;
         
-        pvar_sp->m_live_sp = ValueObjectConstResult::Create(m_parser_vars->m_exe_ctx.GetBestExecutionContextScope(),
-                                                            pvar_sp->GetTypeFromUser().GetASTContext(),
-                                                            pvar_sp->GetTypeFromUser().GetOpaqueQualType(),
-                                                            pvar_sp->GetName(),
-                                                            address,
-                                                            address_type,
-                                                            pvar_sp->GetByteSize());
-    }
-    
-    if (pvar_sp->m_flags & ClangExpressionVariable::EVNeedsFreezeDry)
-    {
-        pvar_sp->ValueUpdated();
+        var_sp->EnableJITVars(GetParserID());
         
-        const size_t pvar_byte_size = pvar_sp->GetByteSize();
-        uint8_t *pvar_data = pvar_sp->GetValueBytes();
+        ClangExpressionVariable::JITVars *jit_vars = var_sp->GetJITVars(GetParserID());
         
-        if (!ReadTarget(pvar_data, value, pvar_byte_size))
-            return false;
+        jit_vars->m_offset = offset;
         
-        pvar_sp->m_flags &= ~(ClangExpressionVariable::EVNeedsFreezeDry);
+        return true;
     }
     
-    valobj = pvar_sp;
-    
-    return true;
-}
-
-void
-ClangExpressionDeclMap::RemoveResultVariable
-(
-    const ConstString &name
-)
-{
-    ClangExpressionVariableSP pvar_sp = m_parser_vars->m_persistent_vars->GetVariable(name);
-    m_parser_vars->m_persistent_vars->RemovePersistentVariable(pvar_sp);
-}
-
-bool 
-ClangExpressionDeclMap::AddPersistentVariable 
-(
-    const NamedDecl *decl, 
-    const ConstString &name, 
-    TypeFromParser parser_type,
-    bool is_result,
-    bool is_lvalue
-)
-{
-    assert (m_parser_vars.get());
-    
-    lldb::LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
+    Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
     ExecutionContext &exe_ctx = m_parser_vars->m_exe_ctx;
     Target *target = exe_ctx.GetTargetPtr();
     if (target == NULL)
@@ -480,6 +273,8 @@ ClangExpressionDeclMap::AddPersistentVar
     if (!var_sp)
         return false;
     
+    var_sp->m_frozen_sp->SetHasCompleteType();
+    
     if (is_result)
         var_sp->m_flags |= ClangExpressionVariable::EVNeedsFreezeDry;
     else
@@ -495,13 +290,20 @@ ClangExpressionDeclMap::AddPersistentVar
         var_sp->m_flags |= ClangExpressionVariable::EVNeedsAllocation;
     }
     
+    if (m_keep_result_in_memory)
+    {
+        var_sp->m_flags |= ClangExpressionVariable::EVKeepInTarget;
+    }
+    
     if (log)
         log->Printf("Created persistent variable with flags 0x%hx", var_sp->m_flags);
     
-    var_sp->EnableParserVars();
+    var_sp->EnableParserVars(GetParserID());
     
-    var_sp->m_parser_vars->m_named_decl = decl;
-    var_sp->m_parser_vars->m_parser_type = parser_type;
+    ClangExpressionVariable::ParserVars *parser_vars = var_sp->GetParserVars(GetParserID());
+    
+    parser_vars->m_named_decl = decl;
+    parser_vars->m_parser_type = parser_type;
     
     return true;
 }
@@ -519,17 +321,22 @@ ClangExpressionDeclMap::AddValueToStruct
     assert (m_struct_vars.get());
     assert (m_parser_vars.get());
     
-    lldb::LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
+    bool is_persistent_variable = false;
+    
+    Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
     
     m_struct_vars->m_struct_laid_out = false;
     
-    if (m_struct_members.GetVariable(decl))
+    if (m_struct_members.GetVariable(decl, GetParserID()))
         return true;
     
-    ClangExpressionVariableSP var_sp (m_found_entities.GetVariable(decl));
+    ClangExpressionVariableSP var_sp (m_found_entities.GetVariable(decl, GetParserID()));
     
     if (!var_sp)
-        var_sp = m_parser_vars->m_persistent_vars->GetVariable(decl);
+    {
+        var_sp = m_parser_vars->m_persistent_vars->GetVariable(decl, GetParserID());
+        is_persistent_variable = true;
+    }
     
     if (!var_sp)
         return false;
@@ -542,14 +349,57 @@ ClangExpressionDeclMap::AddValueToStruct
     
     // We know entity->m_parser_vars is valid because we used a parser variable
     // to find it
-    var_sp->m_parser_vars->m_llvm_value = value;
     
-    var_sp->EnableJITVars();
-    var_sp->m_jit_vars->m_alignment = alignment;
-    var_sp->m_jit_vars->m_size = size;
+    ClangExpressionVariable::ParserVars *parser_vars = var_sp->GetParserVars(GetParserID());
+
+    parser_vars->m_llvm_value = value;
+    
+    if (ClangExpressionVariable::JITVars *jit_vars = var_sp->GetJITVars(GetParserID()))
+    {
+        // We already laid this out; do not touch
+        
+        if (log)
+            log->Printf("Already placed at 0x%llx", (unsigned long long)jit_vars->m_offset);
+    }
+    
+    var_sp->EnableJITVars(GetParserID());
+    
+    ClangExpressionVariable::JITVars *jit_vars = var_sp->GetJITVars(GetParserID());
+
+    jit_vars->m_alignment = alignment;
+    jit_vars->m_size = size;
     
     m_struct_members.AddVariable(var_sp);
     
+    if (m_parser_vars->m_materializer)
+    {
+        uint32_t offset = 0;
+
+        Error err;
+
+        if (is_persistent_variable)
+        {
+            offset = m_parser_vars->m_materializer->AddPersistentVariable(var_sp, err);
+        }
+        else
+        {
+            if (const lldb_private::Symbol *sym = parser_vars->m_lldb_sym)
+                offset = m_parser_vars->m_materializer->AddSymbol(*sym, err);
+            else if (const RegisterInfo *reg_info = var_sp->GetRegisterInfo())
+                offset = m_parser_vars->m_materializer->AddRegister(*reg_info, err);
+            else if (parser_vars->m_lldb_var)
+                offset = m_parser_vars->m_materializer->AddVariable(parser_vars->m_lldb_var, err);
+        }
+        
+        if (!err.Success())
+            return false;
+        
+        if (log)
+            log->Printf("Placed at 0x%llx", (unsigned long long)offset);
+        
+        jit_vars->m_offset = offset; // TODO DoStructLayout() should not change this.
+    }
+    
     return true;
 }
 
@@ -561,34 +411,11 @@ ClangExpressionDeclMap::DoStructLayout (
     if (m_struct_vars->m_struct_laid_out)
         return true;
     
-    off_t cursor = 0;
-    
-    m_struct_vars->m_struct_alignment = 0;
-    m_struct_vars->m_struct_size = 0;
-    
-    for (size_t member_index = 0, num_members = m_struct_members.GetSize();
-         member_index < num_members;
-         ++member_index)
-    {
-        ClangExpressionVariableSP member_sp(m_struct_members.GetVariableAtIndex(member_index));
-        if (!member_sp)
-            return false;
-
-        if (!member_sp->m_jit_vars.get())
-            return false;
-        
-        if (member_index == 0)
-            m_struct_vars->m_struct_alignment = member_sp->m_jit_vars->m_alignment;
-        
-        if (cursor % member_sp->m_jit_vars->m_alignment)
-            cursor += (member_sp->m_jit_vars->m_alignment - (cursor % member_sp->m_jit_vars->m_alignment));
-        
-        member_sp->m_jit_vars->m_offset = cursor;
-        cursor += member_sp->m_jit_vars->m_size;
-    }
-    
-    m_struct_vars->m_struct_size = cursor;
+    if (!m_parser_vars->m_materializer)
+        return false;
     
+    m_struct_vars->m_struct_alignment = m_parser_vars->m_materializer->GetStructAlignment();
+    m_struct_vars->m_struct_size = m_parser_vars->m_materializer->GetStructByteSize();
     m_struct_vars->m_struct_laid_out = true;
     return true;
 }
@@ -632,15 +459,20 @@ ClangExpressionDeclMap::GetStructElement
     
     ClangExpressionVariableSP member_sp(m_struct_members.GetVariableAtIndex(index));
     
-    if (!member_sp ||
-        !member_sp->m_parser_vars.get() ||
-        !member_sp->m_jit_vars.get() ||
+    if (!member_sp)
+        return false;
+    
+    ClangExpressionVariable::ParserVars *parser_vars = member_sp->GetParserVars(GetParserID());
+    ClangExpressionVariable::JITVars *jit_vars = member_sp->GetJITVars(GetParserID());
+    
+    if (!parser_vars ||
+        !jit_vars ||
         !member_sp->GetValueObject())
         return false;
     
-    decl = member_sp->m_parser_vars->m_named_decl;
-    value = member_sp->m_parser_vars->m_llvm_value;
-    offset = member_sp->m_jit_vars->m_offset;
+    decl = parser_vars->m_named_decl;
+    value = parser_vars->m_llvm_value;
+    offset = jit_vars->m_offset;
     name = member_sp->GetName();
         
     return true;
@@ -653,7 +485,7 @@ ClangExpressionDeclMap::GetFunctionInfo
     uint64_t &ptr
 )
 {
-    ClangExpressionVariableSP entity_sp(m_found_entities.GetVariable(decl));
+    ClangExpressionVariableSP entity_sp(m_found_entities.GetVariable(decl, GetParserID()));
 
     if (!entity_sp)
         return false;
@@ -661,7 +493,9 @@ ClangExpressionDeclMap::GetFunctionInfo
     // We know m_parser_vars is valid since we searched for the variable by
     // its NamedDecl
     
-    ptr = entity_sp->m_parser_vars->m_lldb_value->GetScalar().ULongLong();
+    ClangExpressionVariable::ParserVars *parser_vars = entity_sp->GetParserVars(GetParserID());
+
+    ptr = parser_vars->m_lldb_value->GetScalar().ULongLong();
     
     return true;
 }
@@ -674,11 +508,32 @@ FindCodeSymbolInContext
     SymbolContextList &sc_list
 )
 {
+    SymbolContextList temp_sc_list;
     if (sym_ctx.module_sp)
-       sym_ctx.module_sp->FindSymbolsWithNameAndType(name, eSymbolTypeCode, sc_list);
+        sym_ctx.module_sp->FindSymbolsWithNameAndType(name, eSymbolTypeAny, temp_sc_list);
     
-    if (!sc_list.GetSize())
-        sym_ctx.target_sp->GetImages().FindSymbolsWithNameAndType(name, eSymbolTypeCode, sc_list);
+    if (!sc_list.GetSize() && sym_ctx.target_sp)
+        sym_ctx.target_sp->GetImages().FindSymbolsWithNameAndType(name, eSymbolTypeAny, temp_sc_list);
+
+    unsigned temp_sc_list_size = temp_sc_list.GetSize();
+    for (unsigned i = 0; i < temp_sc_list_size; i++)
+    {
+        SymbolContext sym_ctx;
+        temp_sc_list.GetContextAtIndex(i, sym_ctx);
+        if (sym_ctx.symbol)
+        {
+            switch (sym_ctx.symbol->GetType())
+            {
+                case eSymbolTypeCode:
+                case eSymbolTypeResolver:
+                    sc_list.Append(sym_ctx);
+                    break;
+
+                default:
+                    break;
+            }
+        }
+    }
 }
 
 bool
@@ -690,7 +545,7 @@ ClangExpressionDeclMap::GetFunctionAddre
 {
     assert (m_parser_vars.get());
     
-    lldb::LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
+    Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
     ExecutionContext &exe_ctx = m_parser_vars->m_exe_ctx;
     Target *target = exe_ctx.GetTargetPtr();
     // Back out in all cases where we're not fully initialized
@@ -702,7 +557,7 @@ ClangExpressionDeclMap::GetFunctionAddre
     SymbolContextList sc_list;
     
     FindCodeSymbolInContext(name, m_parser_vars->m_sym_ctx, sc_list);
-        
+
     if (!sc_list.GetSize())
     {
         // We occasionally get debug information in which a const function is reported 
@@ -724,29 +579,31 @@ ClangExpressionDeclMap::GetFunctionAddre
     
     if (!sc_list.GetSize())
         return false;
-    
+
     SymbolContext sym_ctx;
     sc_list.GetContextAtIndex(0, sym_ctx);
-    
+
     const Address *func_so_addr = NULL;
-    
+    bool is_indirect_function = false;
+
     if (sym_ctx.function)
         func_so_addr = &sym_ctx.function->GetAddressRange().GetBaseAddress();
-    else if (sym_ctx.symbol)
+    else if (sym_ctx.symbol) {
         func_so_addr = &sym_ctx.symbol->GetAddress();
-    else
+        is_indirect_function = sym_ctx.symbol->IsIndirect();
+    } else
         return false;
-    
+
     if (!func_so_addr || !func_so_addr->IsValid())
         return false;
-    
-    func_addr = func_so_addr->GetCallableLoadAddress (target);
+
+    func_addr = func_so_addr->GetCallableLoadAddress (target, is_indirect_function);
 
     return true;
 }
 
 addr_t
-ClangExpressionDeclMap::GetSymbolAddress (Target &target, const ConstString &name, lldb::SymbolType symbol_type)
+ClangExpressionDeclMap::GetSymbolAddress (Target &target, Process *process, const ConstString &name, lldb::SymbolType symbol_type)
 {
     SymbolContextList sc_list;
     
@@ -763,7 +620,7 @@ ClangExpressionDeclMap::GetSymbolAddress
         const Address *sym_address = &sym_ctx.symbol->GetAddress();
         
         if (!sym_address || !sym_address->IsValid())
-            return LLDB_INVALID_ADDRESS;
+            continue;
         
         if (sym_address)
         {
@@ -773,1508 +630,130 @@ ClangExpressionDeclMap::GetSymbolAddress
                 case eSymbolTypeTrampoline:
                     symbol_load_addr = sym_address->GetCallableLoadAddress (&target);
                     break;
-                    
+
+                case eSymbolTypeResolver:
+                    symbol_load_addr = sym_address->GetCallableLoadAddress (&target, true);
+                    break;
+
                 case eSymbolTypeData:
                 case eSymbolTypeRuntime:
                 case eSymbolTypeVariable:
                 case eSymbolTypeLocal:
                 case eSymbolTypeParam:
-                case eSymbolTypeInvalid:
-                case eSymbolTypeAbsolute:
-                case eSymbolTypeException:
-                case eSymbolTypeSourceFile:
-                case eSymbolTypeHeaderFile:
-                case eSymbolTypeObjectFile:
-                case eSymbolTypeCommonBlock:
-                case eSymbolTypeBlock:
-                case eSymbolTypeVariableType:
-                case eSymbolTypeLineEntry:
-                case eSymbolTypeLineHeader:
-                case eSymbolTypeScopeBegin:
-                case eSymbolTypeScopeEnd:
-                case eSymbolTypeAdditional:
-                case eSymbolTypeCompiler:
-                case eSymbolTypeInstrumentation:
-                case eSymbolTypeUndefined:
-                case eSymbolTypeObjCClass:
-                case eSymbolTypeObjCMetaClass:
-                case eSymbolTypeObjCIVar:
-                    symbol_load_addr = sym_address->GetLoadAddress (&target);
-                    break;
-            }
-        }
-    }
-    
-    return symbol_load_addr;
-}
-
-addr_t
-ClangExpressionDeclMap::GetSymbolAddress (const ConstString &name, lldb::SymbolType symbol_type)
-{
-    assert (m_parser_vars.get());
-    
-    if (!m_parser_vars->m_exe_ctx.GetTargetPtr())
-        return false;
-    
-    return GetSymbolAddress(m_parser_vars->m_exe_ctx.GetTargetRef(), name, symbol_type);
-}
-
-// Interface for IRInterpreter
-
-Value 
-ClangExpressionDeclMap::WrapBareAddress (lldb::addr_t addr)
-{
-    Value ret;
-
-    ret.SetContext(Value::eContextTypeInvalid, NULL);
-
-    if (m_parser_vars->m_exe_ctx.GetProcessPtr())
-        ret.SetValueType(Value::eValueTypeLoadAddress);
-    else
-        ret.SetValueType(Value::eValueTypeFileAddress);
-
-    ret.GetScalar() = (unsigned long long)addr;
-
-    return ret;
-}
-
-bool
-ClangExpressionDeclMap::WriteTarget (lldb_private::Value &value,
-                                     const uint8_t *data,
-                                     size_t length)
-{
-    assert (m_parser_vars.get());
-    
-    ExecutionContext &exe_ctx = m_parser_vars->m_exe_ctx;
-    
-    Process *process = exe_ctx.GetProcessPtr();
-    if (value.GetContextType() == Value::eContextTypeRegisterInfo)
-    {
-        if (!process)
-            return false;
-        
-        RegisterContext *reg_ctx = exe_ctx.GetRegisterContext();
-        RegisterInfo *reg_info = value.GetRegisterInfo();
-        
-        if (!reg_ctx)
-            return false;
-        
-        lldb_private::RegisterValue reg_value;
-        Error err;
-        
-        if (!reg_value.SetFromMemoryData (reg_info, data, length, process->GetByteOrder(), err))
-            return false;
-        
-        return reg_ctx->WriteRegister(reg_info, reg_value);
-    }
-    else
-    {
-        switch (value.GetValueType())
-        {
-        default:
-            return false;
-        case Value::eValueTypeFileAddress:
-            {
-                if (!process)
-                    return false;
-                
-                Target *target = exe_ctx.GetTargetPtr();
-                Address file_addr;
-                
-                if (!target->GetImages().ResolveFileAddress((lldb::addr_t)value.GetScalar().ULongLong(), file_addr))
-                    return false;
-                
-                lldb::addr_t load_addr = file_addr.GetLoadAddress(target);
-                
-                Error err;
-                process->WriteMemory(load_addr, data, length, err);
-                
-                return err.Success();
-            }
-        case Value::eValueTypeLoadAddress:
-            {
-                if (!process)
-                    return false;
-                
-                Error err;
-                process->WriteMemory((lldb::addr_t)value.GetScalar().ULongLong(), data, length, err);
-    
-                return err.Success();
-            }
-        case Value::eValueTypeHostAddress:
-            {
-                if (value.GetScalar().ULongLong() == 0 || data == NULL)
-                    return false;
-                memcpy ((void *)value.GetScalar().ULongLong(), data, length);
-                return true;
-            }
-        case Value::eValueTypeScalar:
-            return false;
-        }
-    }
-}
-
-bool
-ClangExpressionDeclMap::ReadTarget (uint8_t *data,
-                                    lldb_private::Value &value,
-                                    size_t length)
-{
-    assert (m_parser_vars.get());
-    
-    ExecutionContext &exe_ctx = m_parser_vars->m_exe_ctx;
-
-    Process *process = exe_ctx.GetProcessPtr();
-
-    if (value.GetContextType() == Value::eContextTypeRegisterInfo)
-    {
-        if (!process)
-            return false;
-        
-        RegisterContext *reg_ctx = exe_ctx.GetRegisterContext();
-        RegisterInfo *reg_info = value.GetRegisterInfo();
-        
-        if (!reg_ctx)
-            return false;
-        
-        lldb_private::RegisterValue reg_value;
-        Error err;
-        
-        if (!reg_ctx->ReadRegister(reg_info, reg_value))
-            return false;
-        
-        return reg_value.GetAsMemoryData(reg_info, data, length, process->GetByteOrder(), err);        
-    }
-    else
-    {
-        switch (value.GetValueType())
-        {
-            default:
-                return false;
-            case Value::eValueTypeFileAddress:
-            {
-                Target *target = exe_ctx.GetTargetPtr();
-                if (target == NULL)
-                    return false;
-                
-                Address file_addr;
-                
-                if (!target->GetImages().ResolveFileAddress((lldb::addr_t)value.GetScalar().ULongLong(), file_addr))
-                    return false;
-                
-                Error err;
-                target->ReadMemory(file_addr, false, data, length, err);
-                
-                return err.Success();
-            }
-            case Value::eValueTypeLoadAddress:
-            {
-                if (!process)
-                    return false;
-                
-                Error err;
-                process->ReadMemory((lldb::addr_t)value.GetScalar().ULongLong(), data, length, err);
-                
-                return err.Success();
-            }
-            case Value::eValueTypeHostAddress:
-            {
-                void *host_addr = (void*)value.GetScalar().ULongLong();
-                
-                if (!host_addr)
-                    return false;
-                
-                memcpy (data, host_addr, length);
-                return true;
-            }
-            case Value::eValueTypeScalar:
-                return false;
-        }
-    }
-}
-
-lldb_private::Value
-ClangExpressionDeclMap::LookupDecl (clang::NamedDecl *decl, ClangExpressionVariable::FlagType &flags)
-{
-    assert (m_parser_vars.get());
-            
-    ClangExpressionVariableSP expr_var_sp (m_found_entities.GetVariable(decl));
-    ClangExpressionVariableSP persistent_var_sp (m_parser_vars->m_persistent_vars->GetVariable(decl));
-    
-    if (expr_var_sp)
-    {
-        flags = expr_var_sp->m_flags;
-
-        if (!expr_var_sp->m_parser_vars.get())
-            return Value();
-        
-        bool is_reference = expr_var_sp->m_flags & ClangExpressionVariable::EVTypeIsReference;
-
-        if (expr_var_sp->m_parser_vars->m_lldb_var)
-        {
-            std::auto_ptr<Value> value(GetVariableValue(expr_var_sp->m_parser_vars->m_lldb_var, NULL));
-            
-            if (is_reference && value.get() && value->GetValueType() == Value::eValueTypeLoadAddress)
-            {
-                Process *process = m_parser_vars->m_exe_ctx.GetProcessPtr();
-                
-                if (!process)
-                    return Value();
-                
-                lldb::addr_t value_addr = value->GetScalar().ULongLong();
-                Error read_error;
-                addr_t ref_value = process->ReadPointerFromMemory (value_addr, read_error);
-                
-                if (!read_error.Success())
-                    return Value();
-                
-                value->GetScalar() = (unsigned long long)ref_value;
-            }
-        
-            if (value.get())
-                return *value;
-            else
-                return Value();
-        }
-        else if (expr_var_sp->m_parser_vars->m_lldb_sym)
-        {
-            const Address sym_address = expr_var_sp->m_parser_vars->m_lldb_sym->GetAddress();
-            
-            if (!sym_address.IsValid())
-                return Value();
-                        
-            Value ret;
-        
-            ProcessSP process_sp (m_parser_vars->m_exe_ctx.GetProcessSP());
-            
-            if (process_sp)
-            {
-                uint64_t symbol_load_addr = sym_address.GetLoadAddress(&process_sp->GetTarget());
-                
-                ret.GetScalar() = symbol_load_addr;
-                ret.SetValueType(Value::eValueTypeLoadAddress);
-            }
-            else 
-            {
-                uint64_t symbol_file_addr = sym_address.GetFileAddress();
-                
-                ret.GetScalar() = symbol_file_addr;
-                ret.SetValueType(Value::eValueTypeFileAddress);
-            }
-            
-            return ret;
-        }
-        else if (RegisterInfo *reg_info = expr_var_sp->GetRegisterInfo())
-        {
-            StackFrame *frame = m_parser_vars->m_exe_ctx.GetFramePtr();
-            
-            if (!frame)
-                return Value();
-            
-            RegisterContextSP reg_context_sp(frame->GetRegisterContextSP());
-            
-            RegisterValue reg_value;
-            
-            if (!reg_context_sp->ReadRegister(reg_info, reg_value))
-                return Value();
-            
-            Value ret;
-            
-            ret.SetContext(Value::eContextTypeRegisterInfo, reg_info);
-            if (!reg_value.GetScalarValue(ret.GetScalar()))
-                return Value();
-            
-            return ret;
-        }
-        else
-        {
-            return Value();
-        }
-    }
-    else if (persistent_var_sp)
-    {
-        flags = persistent_var_sp->m_flags;
-        
-        if ((persistent_var_sp->m_flags & ClangExpressionVariable::EVIsProgramReference ||
-             persistent_var_sp->m_flags & ClangExpressionVariable::EVIsLLDBAllocated) &&
-            persistent_var_sp->m_live_sp &&
-            ((persistent_var_sp->m_live_sp->GetValue().GetValueType() == Value::eValueTypeLoadAddress &&
-              m_parser_vars->m_exe_ctx.GetProcessSP() &&
-              m_parser_vars->m_exe_ctx.GetProcessSP()->IsAlive()) ||
-             (persistent_var_sp->m_live_sp->GetValue().GetValueType() == Value::eValueTypeFileAddress)))
-        {
-            return persistent_var_sp->m_live_sp->GetValue();
-        }
-        else
-        {
-            lldb_private::Value ret;
-            ret.SetValueType(Value::eValueTypeHostAddress);
-            ret.SetContext(Value::eContextTypeInvalid, NULL);
-            ret.GetScalar() = (lldb::addr_t)persistent_var_sp->GetValueBytes();
-            return ret;
-        }
-    }
-    else
-    {
-        return Value();
-    }
-}
-
-Value
-ClangExpressionDeclMap::GetSpecialValue (const ConstString &name)
-{
-    assert(m_parser_vars.get());
-    
-    StackFrame *frame = m_parser_vars->m_exe_ctx.GetFramePtr();
-    
-    if (!frame)
-        return Value();
-    
-    VariableList *vars = frame->GetVariableList(false);
-    
-    if (!vars)
-        return Value();
-    
-    lldb::VariableSP var = vars->FindVariable(name);
-    
-    if (!var ||
-        !var->IsInScope(frame) || 
-        !var->LocationIsValidForFrame (frame))
-        return Value();
-    
-    std::auto_ptr<Value> value(GetVariableValue(var, NULL));
-    
-    if (value.get() && value->GetValueType() == Value::eValueTypeLoadAddress)
-    {
-        Process *process = m_parser_vars->m_exe_ctx.GetProcessPtr();
-        
-        if (!process)
-            return Value();
-        
-        lldb::addr_t value_addr = value->GetScalar().ULongLong();
-        Error read_error;
-        addr_t ptr_value = process->ReadPointerFromMemory (value_addr, read_error);
-        
-        if (!read_error.Success())
-            return Value();
-        
-        value->GetScalar() = (unsigned long long)ptr_value;
-    }
-    
-    if (value.get())
-        return *value;
-    else
-        return Value();
-}
-
-// Interface for CommandObjectExpression
-
-bool 
-ClangExpressionDeclMap::Materialize 
-(
-    lldb::addr_t &struct_address,
-    Error &err
-)
-{
-    if (!m_parser_vars.get())
-        return false;
-    
-    EnableMaterialVars();
-    
-    m_material_vars->m_process = m_parser_vars->m_exe_ctx.GetProcessPtr();
-    
-    bool result = DoMaterialize(false /* dematerialize */, 
-                                LLDB_INVALID_ADDRESS /* top of stack frame */, 
-                                LLDB_INVALID_ADDRESS /* bottom of stack frame */, 
-                                NULL, /* result SP */
-                                err);
-    
-    if (result)
-        struct_address = m_material_vars->m_materialized_location;
-    
-    return result;
-}
-
-bool 
-ClangExpressionDeclMap::GetObjectPointer
-(
-    lldb::addr_t &object_ptr,
-    ConstString &object_name,
-    Error &err,
-    bool suppress_type_check
-)
-{
-    assert (m_struct_vars.get());
-    
-    Target *target = m_parser_vars->m_exe_ctx.GetTargetPtr();
-    Process *process = m_parser_vars->m_exe_ctx.GetProcessPtr();
-    StackFrame *frame = m_parser_vars->m_exe_ctx.GetFramePtr();
-
-    if (frame == NULL || process == NULL || target == NULL)
-    {
-        err.SetErrorStringWithFormat("Couldn't load '%s' because the context is incomplete", object_name.AsCString());
-        return false;
-    }
-    
-    if (!m_struct_vars->m_object_pointer_type.GetOpaqueQualType())
-    {
-        err.SetErrorStringWithFormat("Couldn't load '%s' because its type is unknown", object_name.AsCString());
-        return false;
-    }
-    
-    const bool object_pointer = true;
-    
-    VariableSP object_ptr_var = FindVariableInScope (*frame,
-                                                     object_name, 
-                                                     (suppress_type_check ? NULL : &m_struct_vars->m_object_pointer_type),
-                                                     object_pointer);
-    
-    if (!object_ptr_var)
-    {
-        err.SetErrorStringWithFormat("Couldn't find '%s' with appropriate type in scope", object_name.AsCString());
-        return false;
-    }
-    
-    std::auto_ptr<lldb_private::Value> location_value(GetVariableValue(object_ptr_var,
-                                                                       NULL));
-    
-    if (!location_value.get())
-    {
-        err.SetErrorStringWithFormat("Couldn't get the location for '%s'", object_name.GetCString());
-        return false;
-    }
-    
-    switch (location_value->GetValueType())
-    {
-    default:
-        err.SetErrorStringWithFormat("'%s' is not in memory; LLDB must be extended to handle registers", object_name.GetCString());
-        return false;
-    case Value::eValueTypeLoadAddress:
-        {
-            lldb::addr_t value_addr = location_value->GetScalar().ULongLong();
-            uint32_t address_byte_size = target->GetArchitecture().GetAddressByteSize();
-            
-            if (ClangASTType::GetClangTypeBitWidth(m_struct_vars->m_object_pointer_type.GetASTContext(), 
-                                                   m_struct_vars->m_object_pointer_type.GetOpaqueQualType()) != address_byte_size * 8)
-            {
-                err.SetErrorStringWithFormat("'%s' is not of an expected pointer size", object_name.GetCString());
-                return false;
-            }
-            
-            Error read_error;
-            object_ptr = process->ReadPointerFromMemory (value_addr, read_error);
-            if (read_error.Fail() || object_ptr == LLDB_INVALID_ADDRESS)
-            {
-                err.SetErrorStringWithFormat("Coldn't read '%s' from the target: %s", object_name.GetCString(), read_error.AsCString());
-                return false;
-            }            
-            return true;
-        }
-    case Value::eValueTypeScalar:
-        {
-            if (location_value->GetContextType() != Value::eContextTypeRegisterInfo)
-            {
-                StreamString ss;
-                location_value->Dump(&ss);
-                
-                err.SetErrorStringWithFormat("%s is a scalar of unhandled type: %s", object_name.GetCString(), ss.GetString().c_str());
-                return false;
-            }
-                        
-            RegisterInfo *reg_info = location_value->GetRegisterInfo();
-            
-            if (!reg_info)
-            {
-                err.SetErrorStringWithFormat("Couldn't get the register information for %s", object_name.GetCString());
-                return false;
-            }
-            
-            RegisterContext *reg_ctx = m_parser_vars->m_exe_ctx.GetRegisterContext();
-            
-            if (!reg_ctx)
-            {
-                err.SetErrorStringWithFormat("Couldn't read register context to read %s from %s", object_name.GetCString(), reg_info->name);
-                return false;
-            }
-            
-            uint32_t register_number = reg_info->kinds[lldb::eRegisterKindLLDB];
-            
-            object_ptr = reg_ctx->ReadRegisterAsUnsigned(register_number, 0x0);
-            
-            return true;
-        }
-    }
-}
-
-bool 
-ClangExpressionDeclMap::Dematerialize 
-(
-    ClangExpressionVariableSP &result_sp,
-    lldb::addr_t stack_frame_top,
-    lldb::addr_t stack_frame_bottom,
-    Error &err
-)
-{
-    return DoMaterialize(true, stack_frame_top, stack_frame_bottom, &result_sp, err);
-    
-    DidDematerialize();
-}
-
-void
-ClangExpressionDeclMap::DidDematerialize()
-{
-    if (m_material_vars.get())
-    {
-        if (m_material_vars->m_materialized_location)
-        {        
-            //#define SINGLE_STEP_EXPRESSIONS
-            
-#ifndef SINGLE_STEP_EXPRESSIONS
-            m_material_vars->m_process->DeallocateMemory(m_material_vars->m_materialized_location);
-#endif
-            m_material_vars->m_materialized_location = 0;
-        }
-        
-        DisableMaterialVars();
-    }
-}
-
-bool
-ClangExpressionDeclMap::DumpMaterializedStruct
-(
-    Stream &s,
-    Error &err
-)
-{
-    assert (m_struct_vars.get());
-    assert (m_material_vars.get());
-    
-    if (!m_struct_vars->m_struct_laid_out)
-    {
-        err.SetErrorString("Structure hasn't been laid out yet");
-        return false;
-    }
-    Process *process = m_parser_vars->m_exe_ctx.GetProcessPtr();
-
-    if (!process)
-    {
-        err.SetErrorString("Couldn't find the process");
-        return false;
-    }
-    
-    Target *target = m_parser_vars->m_exe_ctx.GetTargetPtr();
-    if (!target)
-    {
-        err.SetErrorString("Couldn't find the target");
-        return false;
-    }
-    
-    if (!m_material_vars->m_materialized_location)
-    {
-        err.SetErrorString("No materialized location");
-        return false;
-    }
-    
-    lldb::DataBufferSP data_sp(new DataBufferHeap(m_struct_vars->m_struct_size, 0));    
-    
-    Error error;
-    if (process->ReadMemory (m_material_vars->m_materialized_location, 
-                                     data_sp->GetBytes(), 
-                                     data_sp->GetByteSize(), error) != data_sp->GetByteSize())
-    {
-        err.SetErrorStringWithFormat ("Couldn't read struct from the target: %s", error.AsCString());
-        return false;
-    }
-    
-    DataExtractor extractor(data_sp, process->GetByteOrder(), target->GetArchitecture().GetAddressByteSize());
-    
-    for (size_t member_idx = 0, num_members = m_struct_members.GetSize();
-         member_idx < num_members;
-         ++member_idx)
-    {
-        ClangExpressionVariableSP member_sp(m_struct_members.GetVariableAtIndex(member_idx));
-        
-        if (!member_sp)
-            return false;
-
-        s.Printf("[%s]\n", member_sp->GetName().GetCString());
-        
-        if (!member_sp->m_jit_vars.get())
-            return false;
-        
-        extractor.Dump (&s,                                                                          // stream
-                        member_sp->m_jit_vars->m_offset,                                             // offset
-                        lldb::eFormatBytesWithASCII,                                                 // format
-                        1,                                                                           // byte size of individual entries
-                        member_sp->m_jit_vars->m_size,                                               // number of entries
-                        16,                                                                          // entries per line
-                        m_material_vars->m_materialized_location + member_sp->m_jit_vars->m_offset,  // address to print
-                        0,                                                                           // bit size (bitfields only; 0 means ignore)
-                        0);                                                                          // bit alignment (bitfields only; 0 means ignore)
-        
-        s.PutChar('\n');
-    }
-    
-    return true;
-}
-
-bool 
-ClangExpressionDeclMap::DoMaterialize 
-(
-    bool dematerialize,
-    lldb::addr_t stack_frame_top,
-    lldb::addr_t stack_frame_bottom,
-    lldb::ClangExpressionVariableSP *result_sp_ptr,
-    Error &err
-)
-{
-    if (result_sp_ptr)
-        result_sp_ptr->reset();
-
-    assert (m_struct_vars.get());
-    
-    lldb::LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
-    
-    if (!m_struct_vars->m_struct_laid_out)
-    {
-        err.SetErrorString("Structure hasn't been laid out yet");
-        return false;
-    }
-    
-    StackFrame *frame = m_parser_vars->m_exe_ctx.GetFramePtr();
-    if (!frame)
-    {
-        err.SetErrorString("Received null execution frame");
-        return false;
-    }
-    Target *target = m_parser_vars->m_exe_ctx.GetTargetPtr();
-    
-    ClangPersistentVariables &persistent_vars = target->GetPersistentVariables();
-        
-    if (!m_struct_vars->m_struct_size)
-    {
-        if (log)
-            log->PutCString("Not bothering to allocate a struct because no arguments are needed");
-        
-        m_material_vars->m_allocated_area = NULL;
-        
-        return true;
-    }
-    
-    const SymbolContext &sym_ctx(frame->GetSymbolContext(lldb::eSymbolContextEverything));
-    
-    if (!dematerialize)
-    {
-        Process *process = m_parser_vars->m_exe_ctx.GetProcessPtr();
-        if (m_material_vars->m_materialized_location)
-        {
-            process->DeallocateMemory(m_material_vars->m_materialized_location);
-            m_material_vars->m_materialized_location = 0;
-        }
-        
-        if (log)
-            log->PutCString("Allocating memory for materialized argument struct");
-        
-        lldb::addr_t mem = process->AllocateMemory(m_struct_vars->m_struct_alignment + m_struct_vars->m_struct_size, 
-                                                   lldb::ePermissionsReadable | lldb::ePermissionsWritable,
-                                                   err);
-        
-        if (mem == LLDB_INVALID_ADDRESS)
-        {
-            err.SetErrorStringWithFormat("Couldn't allocate 0x%llx bytes for materialized argument struct", 
-                                         (unsigned long long)(m_struct_vars->m_struct_alignment + m_struct_vars->m_struct_size));
-            return false;
-        }
-            
-        m_material_vars->m_allocated_area = mem;
-    }
-    
-    m_material_vars->m_materialized_location = m_material_vars->m_allocated_area;
-    
-    if (m_material_vars->m_materialized_location % m_struct_vars->m_struct_alignment)
-        m_material_vars->m_materialized_location += (m_struct_vars->m_struct_alignment - (m_material_vars->m_materialized_location % m_struct_vars->m_struct_alignment));
-    
-    for (uint64_t member_index = 0, num_members = m_struct_members.GetSize();
-         member_index < num_members;
-         ++member_index)
-    {
-        ClangExpressionVariableSP member_sp(m_struct_members.GetVariableAtIndex(member_index));
-        
-        if (m_found_entities.ContainsVariable (member_sp))
-        {
-            RegisterInfo *reg_info = member_sp->GetRegisterInfo ();
-            if (reg_info)
-            {
-                // This is a register variable
-                
-                RegisterContext *reg_ctx = m_parser_vars->m_exe_ctx.GetRegisterContext();
-                
-                if (!reg_ctx)
-                {
-                    err.SetErrorString("Couldn't get register context");
-                    return false;
-                }
-                    
-                if (!DoMaterializeOneRegister (dematerialize, 
-                                               *reg_ctx, 
-                                               *reg_info, 
-                                               m_material_vars->m_materialized_location + member_sp->m_jit_vars->m_offset, 
-                                               err))
-                    return false;
-            }
-            else
-            {
-                if (!member_sp->m_jit_vars.get())
-                {
-                    err.SetErrorString("Variable being materialized doesn't have necessary state");
-                    return false;
-                }
-                
-                if (!DoMaterializeOneVariable (dematerialize, 
-                                               sym_ctx,
-                                               member_sp,
-                                               m_material_vars->m_materialized_location + member_sp->m_jit_vars->m_offset, 
-                                               err))
-                    return false;
-            }
-        }
-        else
-        {
-            // No need to look for presistent variables if the name doesn't start 
-            // with with a '$' character...
-            if (member_sp->GetName().AsCString ("!")[0] == '$' && persistent_vars.ContainsVariable(member_sp))
-            {
-                
-                if (member_sp->GetName() == m_struct_vars->m_result_name)
-                {
-                    if (log)
-                        log->PutCString("Found result member in the struct");
-
-                    if (result_sp_ptr)
-                        *result_sp_ptr = member_sp;
-                    
-                }
-
-                if (!DoMaterializeOnePersistentVariable (dematerialize, 
-                                                         member_sp, 
-                                                         m_material_vars->m_materialized_location + member_sp->m_jit_vars->m_offset,
-                                                         stack_frame_top,
-                                                         stack_frame_bottom,
-                                                         err))
-                    return false;
-            }
-            else
-            {
-                err.SetErrorStringWithFormat("Unexpected variable %s", member_sp->GetName().GetCString());
-                return false;
-            }
-        }
-    }
-    
-    return true;
-}
-
-bool
-ClangExpressionDeclMap::DoMaterializeOnePersistentVariable
-(
-    bool dematerialize,
-    ClangExpressionVariableSP &var_sp,
-    lldb::addr_t addr,
-    lldb::addr_t stack_frame_top,
-    lldb::addr_t stack_frame_bottom,
-    Error &err
-)
-{
-    lldb::LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
-
-    if (!var_sp)
-    {
-        err.SetErrorString("Invalid persistent variable");
-        return LLDB_INVALID_ADDRESS;
-    }
-    
-    const size_t pvar_byte_size = var_sp->GetByteSize();
-    
-    uint8_t *pvar_data = var_sp->GetValueBytes();
-    if (pvar_data == NULL)
-    {
-        err.SetErrorString("Persistent variable being materialized contains no data");
-        return false;
-    }
-    
-    Error error;
-    Process *process = m_parser_vars->m_exe_ctx.GetProcessPtr();
-
-    lldb::addr_t mem; // The address of a spare memory area used to hold the persistent variable.
-    
-    if (dematerialize)
-    {
-        if (log)
-            log->Printf("Dematerializing persistent variable with flags 0x%hx", var_sp->m_flags);
-        
-        if ((var_sp->m_flags & ClangExpressionVariable::EVIsLLDBAllocated) ||
-            (var_sp->m_flags & ClangExpressionVariable::EVIsProgramReference))
-        {
-            // Get the location of the target out of the struct.
-            
-            Error read_error;
-            mem = process->ReadPointerFromMemory (addr, read_error);
-            
-            if (mem == LLDB_INVALID_ADDRESS)
-            {
-                err.SetErrorStringWithFormat("Couldn't read address of %s from struct: %s", var_sp->GetName().GetCString(), error.AsCString());
-                return false;
-            }
-            
-            if (var_sp->m_flags & ClangExpressionVariable::EVIsProgramReference &&
-                !var_sp->m_live_sp)
-            {
-                // If the reference comes from the program, then the ClangExpressionVariable's
-                // live variable data hasn't been set up yet.  Do this now.
-                
-                var_sp->m_live_sp = ValueObjectConstResult::Create (m_parser_vars->m_exe_ctx.GetBestExecutionContextScope (),
-                                                                    var_sp->GetTypeFromUser().GetASTContext(),
-                                                                    var_sp->GetTypeFromUser().GetOpaqueQualType(),
-                                                                    var_sp->GetName(),
-                                                                    mem,
-                                                                    eAddressTypeLoad,
-                                                                    pvar_byte_size);
-            }
-            
-            if (!var_sp->m_live_sp)
-            {
-                err.SetErrorStringWithFormat("Couldn't find the memory area used to store %s", var_sp->GetName().GetCString());
-                return false;
-            }
-            
-            if (var_sp->m_live_sp->GetValue().GetValueAddressType() != eAddressTypeLoad)
-            {
-                err.SetErrorStringWithFormat("The address of the memory area for %s is in an incorrect format", var_sp->GetName().GetCString());
-                return false;
-            }
-            
-            if (var_sp->m_flags & ClangExpressionVariable::EVNeedsFreezeDry ||
-                var_sp->m_flags & ClangExpressionVariable::EVKeepInTarget)
-            {
-                mem = var_sp->m_live_sp->GetValue().GetScalar().ULongLong();
-                
-                if (log)
-                    log->Printf("Dematerializing %s from 0x%llx", var_sp->GetName().GetCString(), (uint64_t)mem);
-                
-                // Read the contents of the spare memory area
-                                
-                var_sp->ValueUpdated ();
-                if (process->ReadMemory (mem, pvar_data, pvar_byte_size, error) != pvar_byte_size)
-                {
-                    err.SetErrorStringWithFormat ("Couldn't read a composite type from the target: %s", error.AsCString());
-                    return false;
-                }
-                
-                if (stack_frame_top != LLDB_INVALID_ADDRESS &&
-                    stack_frame_bottom != LLDB_INVALID_ADDRESS &&
-                    mem >= stack_frame_bottom &&
-                    mem <= stack_frame_top)
-                {
-                    // If the variable is resident in the stack frame created by the expression,
-                    // then it cannot be relied upon to stay around.  We treat it as needing
-                    // reallocation.
-                    
-                    var_sp->m_flags |= ClangExpressionVariable::EVIsLLDBAllocated;
-                    var_sp->m_flags |= ClangExpressionVariable::EVNeedsAllocation;
-                    var_sp->m_flags &= ~ClangExpressionVariable::EVIsProgramReference;
-                }
-                
-                var_sp->m_flags &= ~ClangExpressionVariable::EVNeedsFreezeDry;
-            }
-            
-            if (var_sp->m_flags & ClangExpressionVariable::EVNeedsAllocation &&
-                !(var_sp->m_flags & ClangExpressionVariable::EVKeepInTarget))
-            {
-                if (m_keep_result_in_memory)
-                {
-                    var_sp->m_flags |= ClangExpressionVariable::EVKeepInTarget;
-                }
-                else
-                {
-                    Error deallocate_error = process->DeallocateMemory(mem);
-                    
-                    if (!err.Success())
-                    {
-                        err.SetErrorStringWithFormat ("Couldn't deallocate memory for %s: %s", var_sp->GetName().GetCString(), deallocate_error.AsCString());
-                        return false;
-                    }
-                }
-            }
-        }
-        else
-        {
-            err.SetErrorStringWithFormat("Persistent variables without separate allocations are not currently supported.");
-            return false;
-        }
-    }
-    else 
-    {
-        if (log)
-            log->Printf("Materializing persistent variable with flags 0x%hx", var_sp->m_flags);
-        
-        if (var_sp->m_flags & ClangExpressionVariable::EVNeedsAllocation)
-        {
-            // Allocate a spare memory area to store the persistent variable's contents.
-            
-            Error allocate_error;
-            
-            mem = process->AllocateMemory(pvar_byte_size, 
-                                          lldb::ePermissionsReadable | lldb::ePermissionsWritable, 
-                                          allocate_error);
-            
-            if (mem == LLDB_INVALID_ADDRESS)
-            {
-                err.SetErrorStringWithFormat("Couldn't allocate a memory area to store %s: %s", var_sp->GetName().GetCString(), allocate_error.AsCString());
-                return false;
-            }
-            
-            if (log)
-                log->Printf("Allocated %s (0x%llx) sucessfully", var_sp->GetName().GetCString(), mem);
-            
-            // Put the location of the spare memory into the live data of the ValueObject.
-            
-            var_sp->m_live_sp = ValueObjectConstResult::Create (m_parser_vars->m_exe_ctx.GetBestExecutionContextScope(),
-                                                                var_sp->GetTypeFromUser().GetASTContext(),
-                                                                var_sp->GetTypeFromUser().GetOpaqueQualType(),
-                                                                var_sp->GetName(),
-                                                                mem,
-                                                                eAddressTypeLoad,
-                                                                pvar_byte_size);
-            
-            // Clear the flag if the variable will never be deallocated.
-            
-            if (var_sp->m_flags & ClangExpressionVariable::EVKeepInTarget)
-                var_sp->m_flags &= ~ClangExpressionVariable::EVNeedsAllocation;
-            
-            // Write the contents of the variable to the area.
-            
-            if (process->WriteMemory (mem, pvar_data, pvar_byte_size, error) != pvar_byte_size)
-            {
-                err.SetErrorStringWithFormat ("Couldn't write a composite type to the target: %s", error.AsCString());
-                return false;
-            }
-        }
-        
-        if ((var_sp->m_flags & ClangExpressionVariable::EVIsProgramReference && var_sp->m_live_sp) ||
-            var_sp->m_flags & ClangExpressionVariable::EVIsLLDBAllocated)
-        {
-            // Now write the location of the area into the struct.
-            Error write_error;
-            if (!process->WriteScalarToMemory (addr, 
-                                               var_sp->m_live_sp->GetValue().GetScalar(), 
-                                               process->GetAddressByteSize(), 
-                                               write_error))
-            {
-                err.SetErrorStringWithFormat ("Couldn't write %s to the target: %s", var_sp->GetName().GetCString(), write_error.AsCString());
-                return false;
-            }
-            
-            if (log)
-                log->Printf("Materialized %s into 0x%llx", var_sp->GetName().GetCString(), var_sp->m_live_sp->GetValue().GetScalar().ULongLong());
-        }
-        else if (!(var_sp->m_flags & ClangExpressionVariable::EVIsProgramReference))
-        {
-            err.SetErrorStringWithFormat("Persistent variables without separate allocations are not currently supported.");
-            return false;
-        }
-    }
-    
-    return true;
-}
-
-bool 
-ClangExpressionDeclMap::DoMaterializeOneVariable
-(
-    bool dematerialize,
-    const SymbolContext &sym_ctx,
-    ClangExpressionVariableSP &expr_var,
-    lldb::addr_t addr, 
-    Error &err
-)
-{
-    lldb::LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
-    Target *target = m_parser_vars->m_exe_ctx.GetTargetPtr();
-    Process *process = m_parser_vars->m_exe_ctx.GetProcessPtr();
-    StackFrame *frame = m_parser_vars->m_exe_ctx.GetFramePtr();
-
-    if (!frame || !process || !target || !m_parser_vars.get() || !expr_var->m_parser_vars.get())
-    {
-        err.SetErrorString("Necessary state for variable materialization isn't present");
-        return false;
-    }
-    
-    // Vital information about the value
-    
-    const ConstString &name(expr_var->GetName());
-    TypeFromUser type(expr_var->GetTypeFromUser());
-    
-    VariableSP &var(expr_var->m_parser_vars->m_lldb_var);
-    lldb_private::Symbol *sym(expr_var->m_parser_vars->m_lldb_sym);
-    
-    bool is_reference(expr_var->m_flags & ClangExpressionVariable::EVTypeIsReference);
-    
-    std::auto_ptr<lldb_private::Value> location_value;
-
-    if (var)
-    {
-        location_value.reset(GetVariableValue(var,
-                                              NULL));
-    }
-    else if (sym)
-    {
-        addr_t location_load_addr = GetSymbolAddress(*target, name, lldb::eSymbolTypeAny);
-        
-        if (location_load_addr == LLDB_INVALID_ADDRESS)
-        {
-            if (log)
-                err.SetErrorStringWithFormat ("Couldn't find value for global symbol %s", 
-                                              name.GetCString());
-        }
-        
-        location_value.reset(new Value);
-        
-        location_value->SetValueType(Value::eValueTypeLoadAddress);
-        location_value->GetScalar() = location_load_addr;
-    }
-    else
-    {
-        err.SetErrorStringWithFormat ("Couldn't find %s with appropriate type", 
-                                      name.GetCString());
-        return false;
-    }
-    
-    if (log)
-    {
-        StreamString my_stream_string;
-        
-        ClangASTType::DumpTypeDescription (type.GetASTContext(),
-                                           type.GetOpaqueQualType(),
-                                           &my_stream_string);
-        
-        log->Printf ("%s %s with type %s", 
-                     dematerialize ? "Dematerializing" : "Materializing", 
-                     name.GetCString(), 
-                     my_stream_string.GetString().c_str());
-    }
-    
-    if (!location_value.get())
-    {
-        err.SetErrorStringWithFormat("Couldn't get value for %s", name.GetCString());
-        return false;
-    }
-
-    // The size of the type contained in addr
-    
-    size_t value_bit_size = ClangASTType::GetClangTypeBitWidth(type.GetASTContext(), type.GetOpaqueQualType());
-    size_t value_byte_size = value_bit_size % 8 ? ((value_bit_size + 8) / 8) : (value_bit_size / 8);
-    
-    Value::ValueType value_type = location_value->GetValueType();
-    
-    switch (value_type)
-    {
-    default:
-        {
-            StreamString ss;
-            
-            location_value->Dump(&ss);
-            
-            err.SetErrorStringWithFormat ("%s has a value of unhandled type: %s", 
-                                          name.GetCString(), 
-                                          ss.GetString().c_str());
-            return false;
-        }
-        break;
-    case Value::eValueTypeLoadAddress:
-        {
-            if (!dematerialize)
-            {
-                Error write_error;
-
-                if (is_reference)
-                {
-                    Error read_error;
-                    
-                    addr_t ref_value = process->ReadPointerFromMemory(location_value->GetScalar().ULongLong(), read_error);
-                    
-                    if (!read_error.Success())
-                    {
-                        err.SetErrorStringWithFormat ("Couldn't read reference to %s from the target: %s",
-                                                      name.GetCString(),
-                                                      read_error.AsCString());
-                        return false;
-                    }
-                    
-                    if (!process->WritePointerToMemory(addr,
-                                                       ref_value,
-                                                       write_error))
-                    {
-                        err.SetErrorStringWithFormat ("Couldn't write %s to the target: %s", 
-                                                      name.GetCString(), 
-                                                      write_error.AsCString());
-                        return false;
-                    }
-                }
-                else
-                {
-                    if (!process->WriteScalarToMemory (addr, 
-                                                       location_value->GetScalar(), 
-                                                       process->GetAddressByteSize(), 
-                                                       write_error))
-                    {
-                        err.SetErrorStringWithFormat ("Couldn't write %s to the target: %s", 
-                                                      name.GetCString(), 
-                                                      write_error.AsCString());
-                        return false;
-                    }
-                }
-            }
-        }
-        break;
-    case Value::eValueTypeScalar:
-        {
-            if (location_value->GetContextType() != Value::eContextTypeRegisterInfo)
-            {
-                StreamString ss;
-                location_value->Dump(&ss);
-                
-                err.SetErrorStringWithFormat ("%s is a scalar of unhandled type: %s", 
-                                              name.GetCString(), 
-                                              ss.GetString().c_str());
-                return false;
-            }
-            
-            RegisterInfo *reg_info = location_value->GetRegisterInfo();
-            
-            if (!reg_info)
-            {
-                err.SetErrorStringWithFormat ("Couldn't get the register information for %s", 
-                                              name.GetCString());
-                return false;
-            }
-            
-            RegisterValue reg_value;
-
-            RegisterContext *reg_ctx = m_parser_vars->m_exe_ctx.GetRegisterContext();
-            
-            if (!reg_ctx)
-            {
-                err.SetErrorStringWithFormat ("Couldn't read register context to read %s from %s", 
-                                              name.GetCString(), 
-                                              reg_info->name);
-                return false;
-            }
-            
-            uint32_t register_byte_size = reg_info->byte_size;
-            
-            if (dematerialize)
-            {
-                if (is_reference)
-                    return true; // reference types don't need demateralizing
-                
-                // Get the location of the spare memory area out of the variable's live data.
-                
-                if (!expr_var->m_live_sp)
-                {
-                    err.SetErrorStringWithFormat("Couldn't find the memory area used to store %s", name.GetCString());
-                    return false;
-                }
-                
-                if (expr_var->m_live_sp->GetValue().GetValueAddressType() != eAddressTypeLoad)
-                {
-                    err.SetErrorStringWithFormat("The address of the memory area for %s is in an incorrect format", name.GetCString());
-                    return false;
-                }
-                
-                Scalar &reg_addr = expr_var->m_live_sp->GetValue().GetScalar();
-                
-                err = reg_ctx->ReadRegisterValueFromMemory (reg_info, 
-                                                            reg_addr.ULongLong(), 
-                                                            value_byte_size, 
-                                                            reg_value);
-                if (err.Fail())
-                    return false;
-
-                if (!reg_ctx->WriteRegister (reg_info, reg_value))
-                {
-                    err.SetErrorStringWithFormat ("Couldn't write %s to register %s", 
-                                                  name.GetCString(), 
-                                                  reg_info->name);
-                    return false;
-                }
-                
-                // Deallocate the spare area and clear the variable's live data.
-                
-                Error deallocate_error = process->DeallocateMemory(reg_addr.ULongLong());
-                
-                if (!deallocate_error.Success())
-                {
-                    err.SetErrorStringWithFormat ("Couldn't deallocate spare memory area for %s: %s", 
-                                                  name.GetCString(), 
-                                                  deallocate_error.AsCString());
-                    return false;
-                }
-                
-                expr_var->m_live_sp.reset();
-            }
-            else
-            {
-                Error write_error;
-                
-                RegisterValue reg_value;
-                
-                if (!reg_ctx->ReadRegister (reg_info, reg_value))
-                {
-                    err.SetErrorStringWithFormat ("Couldn't read %s from %s", 
-                                                  name.GetCString(), 
-                                                  reg_info->name);
-                    return false;
-                }
-
-                if (is_reference)
-                {
-                    write_error = reg_ctx->WriteRegisterValueToMemory(reg_info, 
-                                                                      addr,
-                                                                      process->GetAddressByteSize(), 
-                                                                      reg_value);
-                    
-                    if (!write_error.Success())
-                    {
-                        err.SetErrorStringWithFormat ("Couldn't write %s from register %s to the target: %s", 
-                                                      name.GetCString(),
-                                                      reg_info->name,
-                                                      write_error.AsCString());
-                        return false;
-                    }
-                    
-                    return true;
-                }
-
-                // Allocate a spare memory area to place the register's contents into.  This memory area will be pointed to by the slot in the
-                // struct.
-                
-                Error allocate_error;
-                
-                Scalar reg_addr (process->AllocateMemory (value_byte_size, 
-                                                          lldb::ePermissionsReadable | lldb::ePermissionsWritable, 
-                                                          allocate_error));
-                
-                if (reg_addr.ULongLong() == LLDB_INVALID_ADDRESS)
-                {
-                    err.SetErrorStringWithFormat ("Couldn't allocate a memory area to store %s: %s", 
-                                                  name.GetCString(), 
-                                                  allocate_error.AsCString());
-                    return false;
-                }
-                
-                // Put the location of the spare memory into the live data of the ValueObject.
-                
-                expr_var->m_live_sp = ValueObjectConstResult::Create (m_parser_vars->m_exe_ctx.GetBestExecutionContextScope(),
-                                                                      type.GetASTContext(),
-                                                                      type.GetOpaqueQualType(),
-                                                                      name,
-                                                                      reg_addr.ULongLong(),
-                                                                      eAddressTypeLoad,
-                                                                      value_byte_size);
-                
-                // Now write the location of the area into the struct.
-                                
-                if (!process->WriteScalarToMemory (addr, 
-                                                   reg_addr, 
-                                                   process->GetAddressByteSize(), 
-                                                   write_error))
-                {
-                    err.SetErrorStringWithFormat ("Couldn't write %s to the target: %s", 
-                                                  name.GetCString(), 
-                                                  write_error.AsCString());
-                    return false;
-                }
-                
-                if (value_byte_size > register_byte_size)
-                {
-                    err.SetErrorStringWithFormat ("%s is too big to store in %s", 
-                                                  name.GetCString(), 
-                                                  reg_info->name);
-                    return false;
-                }
-
-                if (!reg_ctx->ReadRegister (reg_info, reg_value))
-                {
-                    err.SetErrorStringWithFormat ("Couldn't read %s from %s", 
-                                                  name.GetCString(), 
-                                                  reg_info->name);
-                    return false;
-                }
-                
-                err = reg_ctx->WriteRegisterValueToMemory (reg_info, 
-                                                           reg_addr.ULongLong(), 
-                                                           value_byte_size, 
-                                                           reg_value);
-                if (err.Fail())
-                    return false;
+                case eSymbolTypeInvalid:
+                case eSymbolTypeAbsolute:
+                case eSymbolTypeException:
+                case eSymbolTypeSourceFile:
+                case eSymbolTypeHeaderFile:
+                case eSymbolTypeObjectFile:
+                case eSymbolTypeCommonBlock:
+                case eSymbolTypeBlock:
+                case eSymbolTypeVariableType:
+                case eSymbolTypeLineEntry:
+                case eSymbolTypeLineHeader:
+                case eSymbolTypeScopeBegin:
+                case eSymbolTypeScopeEnd:
+                case eSymbolTypeAdditional:
+                case eSymbolTypeCompiler:
+                case eSymbolTypeInstrumentation:
+                case eSymbolTypeUndefined:
+                case eSymbolTypeObjCClass:
+                case eSymbolTypeObjCMetaClass:
+                case eSymbolTypeObjCIVar:
+                    symbol_load_addr = sym_address->GetLoadAddress (&target);
+                    break;
             }
         }
     }
     
-    return true;
-}
-
-bool 
-ClangExpressionDeclMap::DoMaterializeOneRegister
-(
-    bool dematerialize,
-    RegisterContext &reg_ctx,
-    const RegisterInfo &reg_info,
-    lldb::addr_t addr, 
-    Error &err
-)
-{
-    uint32_t register_byte_size = reg_info.byte_size;
-    RegisterValue reg_value;
-    if (dematerialize)
-    {
-        Error read_error (reg_ctx.ReadRegisterValueFromMemory(&reg_info, addr, register_byte_size, reg_value));
-        if (read_error.Fail())
-        {
-            err.SetErrorStringWithFormat ("Couldn't read %s from the target: %s", reg_info.name, read_error.AsCString());
-            return false;
-        }
-        
-        if (!reg_ctx.WriteRegister (&reg_info, reg_value))
-        {
-            err.SetErrorStringWithFormat("Couldn't write register %s (dematerialize)", reg_info.name);
-            return false;
-        }
-    }
-    else
+    if (symbol_load_addr == LLDB_INVALID_ADDRESS && process)
     {
+        ObjCLanguageRuntime *runtime = process->GetObjCLanguageRuntime();
         
-        if (!reg_ctx.ReadRegister(&reg_info, reg_value))
-        {
-            err.SetErrorStringWithFormat("Couldn't read %s (materialize)", reg_info.name);
-            return false;
-        }
-        
-        Error write_error (reg_ctx.WriteRegisterValueToMemory(&reg_info, addr, register_byte_size, reg_value));
-        if (write_error.Fail())
+        if (runtime)
         {
-            err.SetErrorStringWithFormat ("Couldn't write %s to the target: %s", reg_info.name, write_error.AsCString());
-            return false;
+            symbol_load_addr = runtime->LookupRuntimeSymbol(name);
         }
     }
     
-    return true;
+    return symbol_load_addr;
 }
 
-lldb::VariableSP
-ClangExpressionDeclMap::FindVariableInScope
-(
-    StackFrame &frame,
-    const ConstString &name,
-    TypeFromUser *type,
-    bool object_pointer
-)
-{    
-    lldb::LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
+addr_t
+ClangExpressionDeclMap::GetSymbolAddress (const ConstString &name, lldb::SymbolType symbol_type)
+{
+    assert (m_parser_vars.get());
     
-    ValueObjectSP valobj;
-    VariableSP var_sp;
-    Error err;
+    if (!m_parser_vars->m_exe_ctx.GetTargetPtr())
+        return false;
     
-    valobj = frame.GetValueForVariableExpressionPath(name.GetCString(), 
-                                                     eNoDynamicValues, 
-                                                     StackFrame::eExpressionPathOptionCheckPtrVsMember,
-                                                     var_sp,
-                                                     err);
-        
-    if (!err.Success() ||
-        !var_sp ||
-        !var_sp->IsInScope(&frame) ||
-        !var_sp->LocationIsValidForFrame (&frame))
-        return lldb::VariableSP();
-
-    if (var_sp)
-    {
-        if (!type)
-            return var_sp;
-        
-        TypeFromUser candidate_type(var_sp->GetType()->GetClangFullType(),
-                                    var_sp->GetType()->GetClangAST());
-        
-        if (candidate_type.GetASTContext() != type->GetASTContext())
-        {
-            if (log)
-                log->PutCString("Skipping a candidate variable because of different AST contexts");
-            return lldb::VariableSP();
-        }
-        
-        if (object_pointer)
-        {
-            clang::QualType desired_qual_type = clang::QualType::getFromOpaquePtr(type->GetOpaqueQualType());
-            clang::QualType candidate_qual_type = clang::QualType::getFromOpaquePtr(candidate_type.GetOpaqueQualType());
-            
-            const clang::ObjCObjectPointerType *desired_objc_ptr_type = desired_qual_type->getAs<clang::ObjCObjectPointerType>();
-            const clang::ObjCObjectPointerType *candidate_objc_ptr_type = desired_qual_type->getAs<clang::ObjCObjectPointerType>();
-            
-            if (desired_objc_ptr_type && candidate_objc_ptr_type) {
-                clang::QualType desired_target_type = desired_objc_ptr_type->getPointeeType().getUnqualifiedType();
-                clang::QualType candidate_target_type = candidate_objc_ptr_type->getPointeeType().getUnqualifiedType();
-                
-                if (ClangASTContext::AreTypesSame(type->GetASTContext(),
-                                                  desired_target_type.getAsOpaquePtr(),
-                                                  candidate_target_type.getAsOpaquePtr()))
-                    return var_sp;
-            }
-            
-            const clang::PointerType *desired_ptr_type = desired_qual_type->getAs<clang::PointerType>();
-            const clang::PointerType *candidate_ptr_type = candidate_qual_type->getAs<clang::PointerType>();
-            
-            if (desired_ptr_type && candidate_ptr_type) {
-                clang::QualType desired_target_type = desired_ptr_type->getPointeeType().getUnqualifiedType();
-                clang::QualType candidate_target_type = candidate_ptr_type->getPointeeType().getUnqualifiedType();
-                
-                if (ClangASTContext::AreTypesSame(type->GetASTContext(),
-                                                  desired_target_type.getAsOpaquePtr(),
-                                                  candidate_target_type.getAsOpaquePtr()))
-                    return var_sp;
-            }
-            
-            return lldb::VariableSP();
-        }
-        else
-        {
-            if (ClangASTContext::AreTypesSame(type->GetASTContext(),
-                                               type->GetOpaqueQualType(), 
-                                               var_sp->GetType()->GetClangFullType()))
-                return var_sp;
-        }
-    }
-
-    return lldb::VariableSP();
+    return GetSymbolAddress(m_parser_vars->m_exe_ctx.GetTargetRef(), m_parser_vars->m_exe_ctx.GetProcessPtr(), name, symbol_type);
 }
 
-Symbol *
-ClangExpressionDeclMap::FindGlobalDataSymbol
-(
-    Target &target,
-    const ConstString &name
-)
+const Symbol *
+ClangExpressionDeclMap::FindGlobalDataSymbol (Target &target,
+                                              const ConstString &name)
 {
     SymbolContextList sc_list;
     
-    target.GetImages().FindSymbolsWithNameAndType(name, 
-                                                  eSymbolTypeData, 
-                                                  sc_list);
+    target.GetImages().FindSymbolsWithNameAndType(name, eSymbolTypeAny, sc_list);
     
-    if (sc_list.GetSize())
+    const uint32_t matches = sc_list.GetSize();
+    for (uint32_t i=0; i<matches; ++i)
     {
         SymbolContext sym_ctx;
-        sc_list.GetContextAtIndex(0, sym_ctx);
-        
-        return sym_ctx.symbol;
+        sc_list.GetContextAtIndex(i, sym_ctx);
+        if (sym_ctx.symbol)
+        {
+            const Symbol *symbol = sym_ctx.symbol;
+            const Address *sym_address = &symbol->GetAddress();
+            
+            if (sym_address && sym_address->IsValid())
+            {
+                switch (symbol->GetType())
+                {
+                    case eSymbolTypeData:
+                    case eSymbolTypeRuntime:
+                    case eSymbolTypeAbsolute:
+                    case eSymbolTypeObjCClass:
+                    case eSymbolTypeObjCMetaClass:
+                    case eSymbolTypeObjCIVar:
+                        if (symbol->GetDemangledNameIsSynthesized())
+                        {
+                            // If the demangled name was synthesized, then don't use it
+                            // for expressions. Only let the symbol match if the mangled
+                            // named matches for these symbols.
+                            if (symbol->GetMangled().GetMangledName() != name)
+                                break;
+                        }
+                        return symbol;
+
+                    case eSymbolTypeCode: // We already lookup functions elsewhere
+                    case eSymbolTypeVariable:
+                    case eSymbolTypeLocal:
+                    case eSymbolTypeParam:
+                    case eSymbolTypeTrampoline:
+                    case eSymbolTypeInvalid:
+                    case eSymbolTypeException:
+                    case eSymbolTypeSourceFile:
+                    case eSymbolTypeHeaderFile:
+                    case eSymbolTypeObjectFile:
+                    case eSymbolTypeCommonBlock:
+                    case eSymbolTypeBlock:
+                    case eSymbolTypeVariableType:
+                    case eSymbolTypeLineEntry:
+                    case eSymbolTypeLineHeader:
+                    case eSymbolTypeScopeBegin:
+                    case eSymbolTypeScopeEnd:
+                    case eSymbolTypeAdditional:
+                    case eSymbolTypeCompiler:
+                    case eSymbolTypeInstrumentation:
+                    case eSymbolTypeUndefined:
+                    case eSymbolTypeResolver:
+                        break;
+                }
+            }
+        }
     }
     
     return NULL;
@@ -2328,9 +807,11 @@ ClangExpressionDeclMap::FindExternalVisi
 {
     assert (m_ast_context);
     
+    ClangASTMetrics::RegisterVisibleQuery();
+    
     const ConstString name(context.m_decl_name.getAsString().c_str());
     
-    lldb::LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
+    Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
     
     if (GetImportInProgress())
     {
@@ -2406,7 +887,7 @@ ClangExpressionDeclMap::FindExternalVisi
 {
     assert (m_ast_context);
     
-    lldb::LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
+    Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
     
     SymbolContextList sc_list;
     
@@ -2456,34 +937,106 @@ ClangExpressionDeclMap::FindExternalVisi
             
             clang::CXXMethodDecl *method_decl = llvm::dyn_cast<clang::CXXMethodDecl>(decl_context);
             
-            if (!method_decl)
-                return;
-            
-            clang::CXXRecordDecl *class_decl = method_decl->getParent();
-            
-            QualType class_qual_type(class_decl->getTypeForDecl(), 0);
-            
-            TypeFromUser class_user_type (class_qual_type.getAsOpaquePtr(),
-                                          &class_decl->getASTContext());
-            
-            if (log)
-            {
-                ASTDumper ast_dumper(class_qual_type);
-                log->Printf("  CEDM::FEVD[%u] Adding type for $__lldb_class: %s", current_id, ast_dumper.GetCString());
-            }
-            
-            AddOneType(context, class_user_type, current_id, true);
-            
-            if (method_decl->isInstance())
+            if (method_decl)
             {
-                // self is a pointer to the object
+                clang::CXXRecordDecl *class_decl = method_decl->getParent();
+                
+                QualType class_qual_type(class_decl->getTypeForDecl(), 0);
+                
+                TypeFromUser class_user_type (class_qual_type.getAsOpaquePtr(),
+                                              &class_decl->getASTContext());
+                
+                if (log)
+                {
+                    ASTDumper ast_dumper(class_qual_type);
+                    log->Printf("  CEDM::FEVD[%u] Adding type for $__lldb_class: %s", current_id, ast_dumper.GetCString());
+                }
+                
+                TypeFromParser class_type = CopyClassType(class_user_type, current_id);
+                
+                if (!class_type.IsValid())
+                    return;
+                
+                TypeSourceInfo *type_source_info = m_ast_context->getTrivialTypeSourceInfo(QualType::getFromOpaquePtr(class_type.GetOpaqueQualType()));
+                
+                if (!type_source_info)
+                    return;
                 
-                QualType class_pointer_type = method_decl->getASTContext().getPointerType(class_qual_type);
+                TypedefDecl *typedef_decl = TypedefDecl::Create(*m_ast_context,
+                                                                m_ast_context->getTranslationUnitDecl(),
+                                                                SourceLocation(),
+                                                                SourceLocation(),
+                                                                context.m_decl_name.getAsIdentifierInfo(),
+                                                                type_source_info);
                 
-                TypeFromUser self_user_type(class_pointer_type.getAsOpaquePtr(),
-                                            &method_decl->getASTContext());
                 
-                m_struct_vars->m_object_pointer_type = self_user_type;
+                if (!typedef_decl)
+                    return;
+                
+                context.AddNamedDecl(typedef_decl);
+                
+                if (method_decl->isInstance())
+                {
+                    // self is a pointer to the object
+                    
+                    QualType class_pointer_type = method_decl->getASTContext().getPointerType(class_qual_type);
+                    
+                    TypeFromUser self_user_type(class_pointer_type.getAsOpaquePtr(),
+                                                &method_decl->getASTContext());
+                    
+                    m_struct_vars->m_object_pointer_type = self_user_type;
+                }
+            }
+            else
+            {
+                // This branch will get hit if we are executing code in the context of a function that
+                // claims to have an object pointer (through DW_AT_object_pointer?) but is not formally a
+                // method of the class.  In that case, just look up the "this" variable in the the current
+                // scope and use its type.
+                // FIXME: This code is formally correct, but clang doesn't currently emit DW_AT_object_pointer
+                // for C++ so it hasn't actually been tested.
+                
+                VariableList *vars = frame->GetVariableList(false);
+                
+                lldb::VariableSP this_var = vars->FindVariable(ConstString("this"));
+                
+                if (this_var &&
+                    this_var->IsInScope(frame) &&
+                    this_var->LocationIsValidForFrame (frame))
+                {
+                    Type *this_type = this_var->GetType();
+                    
+                    if (!this_type)
+                        return;
+                    
+                    QualType this_qual_type = QualType::getFromOpaquePtr(this_type->GetClangFullType());
+                    const PointerType *class_pointer_type = this_qual_type->getAs<PointerType>();
+                    
+                    if (class_pointer_type)
+                    {
+                        QualType class_type = class_pointer_type->getPointeeType();
+                        
+                        if (!class_type.getAsOpaquePtr())
+                            return;
+                        
+                        if (log)
+                        {
+                            ASTDumper ast_dumper(this_type->GetClangFullType());
+                            log->Printf("  FEVD[%u] Adding type for $__lldb_objc_class: %s", current_id, ast_dumper.GetCString());
+                        }
+                        
+                        TypeFromUser class_user_type (class_type.getAsOpaquePtr(),
+                                                        this_type->GetClangAST());
+                        AddOneType(context, class_user_type, current_id);
+                                    
+                                    
+                        TypeFromUser this_user_type(this_type->GetClangFullType(),
+                                                    this_type->GetClangAST());
+                        
+                        m_struct_vars->m_object_pointer_type = this_user_type;
+                        return;
+                    }
+                }
             }
             
             return;
@@ -2515,65 +1068,106 @@ ClangExpressionDeclMap::FindExternalVisi
             
             clang::ObjCMethodDecl *method_decl = llvm::dyn_cast<clang::ObjCMethodDecl>(decl_context);
             
-            if (!method_decl)
-                return;
-
-            ObjCInterfaceDecl* self_interface = method_decl->getClassInterface();
-            
-            if (!self_interface)
-                return;
-            
-            const clang::Type *interface_type = self_interface->getTypeForDecl();
-                    
-            TypeFromUser class_user_type(QualType(interface_type, 0).getAsOpaquePtr(),
-                                         &method_decl->getASTContext());
-            
-            if (log)
+            if (method_decl)
             {
-                ASTDumper ast_dumper(interface_type);
-                log->Printf("  FEVD[%u] Adding type for $__lldb_objc_class: %s", current_id, ast_dumper.GetCString());
-            }
-                
-            AddOneType(context, class_user_type, current_id, false);
-            
-#if 0
-            VariableList *vars = frame->GetVariableList(false);
-            
-            lldb::VariableSP self_var = vars->FindVariable(ConstString("self"));
-            
-            if (self_var &&
-                self_var->IsInScope(frame) && 
-                self_var->LocationIsValidForFrame (frame)) {
-                Type *self_type = self_var->GetType();
+                ObjCInterfaceDecl* self_interface = method_decl->getClassInterface();
                 
-                if (!self_type)
+                if (!self_interface)
                     return;
                 
-                TypeFromUser self_user_type(self_type->GetClangFullType(),
-                                            self_type->GetClangAST());
-            }
-#endif
-            
-            if (method_decl->isInstanceMethod())
-            {
-                // self is a pointer to the object
+                const clang::Type *interface_type = self_interface->getTypeForDecl();
                 
-                QualType class_pointer_type = method_decl->getASTContext().getObjCObjectPointerType(QualType(interface_type, 0));
-            
-                TypeFromUser self_user_type(class_pointer_type.getAsOpaquePtr(),
-                                            &method_decl->getASTContext());
-            
-                m_struct_vars->m_object_pointer_type = self_user_type;
+                if (!interface_type)
+                    return; // This is unlikely, but we have seen crashes where this occurred
+                        
+                TypeFromUser class_user_type(QualType(interface_type, 0).getAsOpaquePtr(),
+                                             &method_decl->getASTContext());
+                
+                if (log)
+                {
+                    ASTDumper ast_dumper(interface_type);
+                    log->Printf("  FEVD[%u] Adding type for $__lldb_objc_class: %s", current_id, ast_dumper.GetCString());
+                }
+                    
+                AddOneType(context, class_user_type, current_id);
+                                
+                if (method_decl->isInstanceMethod())
+                {
+                    // self is a pointer to the object
+                    
+                    QualType class_pointer_type = method_decl->getASTContext().getObjCObjectPointerType(QualType(interface_type, 0));
+                
+                    TypeFromUser self_user_type(class_pointer_type.getAsOpaquePtr(),
+                                                &method_decl->getASTContext());
+                
+                    m_struct_vars->m_object_pointer_type = self_user_type;
+                }
+                else
+                {
+                    // self is a Class pointer
+                    QualType class_type = method_decl->getASTContext().getObjCClassType();
+                    
+                    TypeFromUser self_user_type(class_type.getAsOpaquePtr(),
+                                                &method_decl->getASTContext());
+                    
+                    m_struct_vars->m_object_pointer_type = self_user_type;
+                }
+
+                return;
             }
             else
             {
-                // self is a Class pointer
-                QualType class_type = method_decl->getASTContext().getObjCClassType();
+                // This branch will get hit if we are executing code in the context of a function that
+                // claims to have an object pointer (through DW_AT_object_pointer?) but is not formally a
+                // method of the class.  In that case, just look up the "self" variable in the the current
+                // scope and use its type.
+                
+                VariableList *vars = frame->GetVariableList(false);
                 
-                TypeFromUser self_user_type(class_type.getAsOpaquePtr(),
-                                            &method_decl->getASTContext());
+                lldb::VariableSP self_var = vars->FindVariable(ConstString("self"));
                 
-                m_struct_vars->m_object_pointer_type = self_user_type;
+                if (self_var &&
+                    self_var->IsInScope(frame) && 
+                    self_var->LocationIsValidForFrame (frame))
+                {
+                    Type *self_type = self_var->GetType();
+                    
+                    if (!self_type)
+                        return;
+                    
+                    QualType self_qual_type = QualType::getFromOpaquePtr(self_type->GetClangFullType());
+                    
+                    if (self_qual_type->isObjCClassType())
+                    {
+                        return;
+                    }
+                    else if (self_qual_type->isObjCObjectPointerType())
+                    {
+                        const ObjCObjectPointerType *class_pointer_type = self_qual_type->getAs<ObjCObjectPointerType>();
+                    
+                        QualType class_type = class_pointer_type->getPointeeType();
+                        
+                        if (!class_type.getAsOpaquePtr())
+                            return;
+                        
+                        if (log)
+                        {
+                            ASTDumper ast_dumper(self_type->GetClangFullType());
+                            log->Printf("  FEVD[%u] Adding type for $__lldb_objc_class: %s", current_id, ast_dumper.GetCString());
+                        }
+                        
+                        TypeFromUser class_user_type (class_type.getAsOpaquePtr(),
+                                                      self_type->GetClangAST());
+                        
+                        AddOneType(context, class_user_type, current_id);
+                                    
+                        TypeFromUser self_user_type(self_type->GetClangFullType(),
+                                                    self_type->GetClangAST());
+                        
+                        m_struct_vars->m_object_pointer_type = self_user_type;
+                        return;
+                    }
+                }
             }
 
             return;
@@ -2652,7 +1246,11 @@ ClangExpressionDeclMap::FindExternalVisi
         {
             valobj = frame->GetValueForVariableExpressionPath(name_unique_cstr, 
                                                               eNoDynamicValues, 
-                                                              StackFrame::eExpressionPathOptionCheckPtrVsMember,
+                                                              StackFrame::eExpressionPathOptionCheckPtrVsMember ||
+                                                              StackFrame::eExpressionPathOptionsAllowDirectIVarAccess ||
+                                                              StackFrame::eExpressionPathOptionsNoFragileObjcIvar ||
+                                                              StackFrame::eExpressionPathOptionsNoSyntheticChildren ||
+                                                              StackFrame::eExpressionPathOptionsNoSyntheticArrayRange,
                                                               var,
                                                               err);
             
@@ -2699,7 +1297,7 @@ ClangExpressionDeclMap::FindExternalVisi
                                          append,
                                          sc_list);
             }
-            else if (!namespace_decl)
+            else if (target && !namespace_decl)
             {
                 const bool include_symbols = true;
                 
@@ -2707,7 +1305,7 @@ ClangExpressionDeclMap::FindExternalVisi
                 //   instance methods for eFunctionNameTypeBase.
                 
                 target->GetImages().FindFunctions(name,
-                                                  eFunctionNameTypeBase,
+                                                  eFunctionNameTypeFull,
                                                   include_symbols,
                                                   include_inlines,
                                                   append, 
@@ -2730,16 +1328,16 @@ ClangExpressionDeclMap::FindExternalVisi
                     {
                         clang::DeclContext *decl_ctx = sym_ctx.function->GetClangDeclContext();
                         
+                        if (!decl_ctx)
+                            continue;
+                        
                         // Filter out class/instance methods.
                         if (dyn_cast<clang::ObjCMethodDecl>(decl_ctx))
                             continue;
                         if (dyn_cast<clang::CXXMethodDecl>(decl_ctx))
                             continue;
                         
-                        // TODO only do this if it's a C function; C++ functions may be
-                        // overloaded
-                        if (!context.m_found.function_with_type_info)
-                            AddOneFunction(context, sym_ctx.function, NULL, current_id);
+                        AddOneFunction(context, sym_ctx.function, NULL, current_id);
                         context.m_found.function_with_type_info = true;
                         context.m_found.function = true;
                     }
@@ -2767,12 +1365,12 @@ ClangExpressionDeclMap::FindExternalVisi
                 }
             }
             
-            if (!context.m_found.variable && !namespace_decl)
+            if (target && !context.m_found.variable && !namespace_decl)
             {
                 // We couldn't find a non-symbol variable for this.  Now we'll hunt for a generic 
                 // data symbol, and -- if it is found -- treat it as a variable.
                 
-                Symbol *data_symbol = FindGlobalDataSymbol(*target, name);
+                const Symbol *data_symbol = FindGlobalDataSymbol(*target, name);
                 
                 if (data_symbol)
                 {
@@ -2831,7 +1429,7 @@ ClangExpressionDeclMap::GetVariableValue
     TypeFromParser *parser_type
 )
 {
-    lldb::LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
+    Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
     
     Type *var_type = var->GetType();
     
@@ -2865,7 +1463,7 @@ ClangExpressionDeclMap::GetVariableValue
     
     DWARFExpression &var_location_expr = var->LocationExpression();
     
-    std::auto_ptr<Value> var_location(new Value);
+    std::unique_ptr<Value> var_location(new Value);
     
     lldb::addr_t loclist_base_load_addr = LLDB_INVALID_ADDRESS;
     
@@ -2879,13 +1477,23 @@ ClangExpressionDeclMap::GetVariableValue
     }
     Error err;
     
-    if (!var_location_expr.Evaluate(&m_parser_vars->m_exe_ctx, ast, NULL, NULL, NULL, loclist_base_load_addr, NULL, *var_location.get(), &err))
+    if (var->GetLocationIsConstantValueData())
     {
-        if (log)
-            log->Printf("Error evaluating location: %s", err.AsCString());
-        return NULL;
-    }
+        DataExtractor const_value_extractor;
         
+        if (var_location_expr.GetExpressionData(const_value_extractor))
+        {
+            var_location->operator=(Value(const_value_extractor.GetDataStart(), const_value_extractor.GetByteSize()));
+            var_location->SetValueType(Value::eValueTypeHostAddress);
+        }
+        else
+        {
+            if (log)
+                log->Printf("Error evaluating constant variable: %s", err.AsCString());
+            return NULL;
+        }
+    }
+    
     void *type_to_use = NULL;
     
     if (parser_ast_context)
@@ -2944,7 +1552,7 @@ ClangExpressionDeclMap::AddOneVariable (
 {
     assert (m_parser_vars.get());
     
-    lldb::LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
+    Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
         
     TypeFromUser ut;
     TypeFromParser pt;
@@ -2982,12 +1590,13 @@ ClangExpressionDeclMap::AddOneVariable (
     ClangExpressionVariableSP entity(m_found_entities.CreateVariable (valobj));
     
     assert (entity.get());
-    entity->EnableParserVars();
-    entity->m_parser_vars->m_parser_type = pt;
-    entity->m_parser_vars->m_named_decl  = var_decl;
-    entity->m_parser_vars->m_llvm_value  = NULL;
-    entity->m_parser_vars->m_lldb_value  = var_location;
-    entity->m_parser_vars->m_lldb_var    = var;
+    entity->EnableParserVars(GetParserID());
+    ClangExpressionVariable::ParserVars *parser_vars = entity->GetParserVars(GetParserID());
+    parser_vars->m_parser_type = pt;
+    parser_vars->m_named_decl  = var_decl;
+    parser_vars->m_llvm_value  = NULL;
+    parser_vars->m_lldb_value  = var_location;
+    parser_vars->m_lldb_var    = var;
     
     if (is_reference)
         entity->m_flags |= ClangExpressionVariable::EVTypeIsReference;
@@ -3005,7 +1614,7 @@ ClangExpressionDeclMap::AddOneVariable(N
                                        ClangExpressionVariableSP &pvar_sp, 
                                        unsigned int current_id)
 {
-    lldb::LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
+    Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
     
     TypeFromUser user_type (pvar_sp->GetTypeFromUser());
     
@@ -3023,11 +1632,12 @@ ClangExpressionDeclMap::AddOneVariable(N
     
     NamedDecl *var_decl = context.AddVarDecl(ClangASTContext::CreateLValueReferenceType(parser_type.GetASTContext(), parser_type.GetOpaqueQualType()));
     
-    pvar_sp->EnableParserVars();
-    pvar_sp->m_parser_vars->m_parser_type = parser_type;
-    pvar_sp->m_parser_vars->m_named_decl  = var_decl;
-    pvar_sp->m_parser_vars->m_llvm_value  = NULL;
-    pvar_sp->m_parser_vars->m_lldb_value  = NULL;
+    pvar_sp->EnableParserVars(GetParserID());
+    ClangExpressionVariable::ParserVars *parser_vars = pvar_sp->GetParserVars(GetParserID());
+    parser_vars->m_parser_type = parser_type;
+    parser_vars->m_named_decl  = var_decl;
+    parser_vars->m_llvm_value  = NULL;
+    parser_vars->m_lldb_value  = NULL;
     
     if (log)
     {
@@ -3038,12 +1648,12 @@ ClangExpressionDeclMap::AddOneVariable(N
 
 void
 ClangExpressionDeclMap::AddOneGenericVariable(NameSearchContext &context, 
-                                              Symbol &symbol, 
+                                              const Symbol &symbol,
                                               unsigned int current_id)
 {
     assert(m_parser_vars.get());
     
-    lldb::LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
+    Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
     
     Target *target = m_parser_vars->m_exe_ctx.GetTargetPtr();
 
@@ -3052,10 +1662,10 @@ ClangExpressionDeclMap::AddOneGenericVar
 
     ASTContext *scratch_ast_context = target->GetScratchClangASTContext()->getASTContext();
     
-    TypeFromUser user_type (ClangASTContext::CreateLValueReferenceType(scratch_ast_context, ClangASTContext::GetVoidPtrType(scratch_ast_context, true)),
+    TypeFromUser user_type (ClangASTContext::CreateLValueReferenceType(scratch_ast_context, ClangASTContext::GetVoidPtrType(scratch_ast_context, false)),
                             scratch_ast_context);
     
-    TypeFromParser parser_type (ClangASTContext::CreateLValueReferenceType(scratch_ast_context, ClangASTContext::GetVoidPtrType(m_ast_context, true)),
+    TypeFromParser parser_type (ClangASTContext::CreateLValueReferenceType(m_ast_context, ClangASTContext::GetVoidPtrType(m_ast_context, false)),
                                 m_ast_context);
     
     NamedDecl *var_decl = context.AddVarDecl(parser_type.GetOpaqueQualType());
@@ -3069,21 +1679,22 @@ ClangExpressionDeclMap::AddOneGenericVar
                                                                       m_parser_vars->m_target_info.address_byte_size));
     assert (entity.get());
     
-    std::auto_ptr<Value> symbol_location(new Value);
+    std::unique_ptr<Value> symbol_location(new Value);
     
-    Address &symbol_address = symbol.GetAddress();
+    const Address &symbol_address = symbol.GetAddress();
     lldb::addr_t symbol_load_addr = symbol_address.GetLoadAddress(target);
     
     symbol_location->SetContext(Value::eContextTypeClangType, user_type.GetOpaqueQualType());
     symbol_location->GetScalar() = symbol_load_addr;
     symbol_location->SetValueType(Value::eValueTypeLoadAddress);
     
-    entity->EnableParserVars();
-    entity->m_parser_vars->m_parser_type = parser_type;
-    entity->m_parser_vars->m_named_decl  = var_decl;
-    entity->m_parser_vars->m_llvm_value  = NULL;
-    entity->m_parser_vars->m_lldb_value  = symbol_location.release();
-    entity->m_parser_vars->m_lldb_sym    = &symbol;
+    entity->EnableParserVars(GetParserID());
+    ClangExpressionVariable::ParserVars *parser_vars = entity->GetParserVars(GetParserID());
+    parser_vars->m_parser_type = parser_type;
+    parser_vars->m_named_decl  = var_decl;
+    parser_vars->m_llvm_value  = NULL;
+    parser_vars->m_lldb_value  = symbol_location.release();
+    parser_vars->m_lldb_sym    = &symbol;
     
     if (log)
     {
@@ -3096,7 +1707,7 @@ ClangExpressionDeclMap::AddOneGenericVar
 bool 
 ClangExpressionDeclMap::ResolveUnknownTypes()
 {
-    lldb::LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
+    Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
     Target *target = m_parser_vars->m_exe_ctx.GetTargetPtr();
 
     ASTContext *scratch_ast_context = target->GetScratchClangASTContext()->getASTContext();
@@ -3107,9 +1718,11 @@ ClangExpressionDeclMap::ResolveUnknownTy
     {
         ClangExpressionVariableSP entity = m_found_entities.GetVariableAtIndex(index);
         
+        ClangExpressionVariable::ParserVars *parser_vars = entity->GetParserVars(GetParserID());
+        
         if (entity->m_flags & ClangExpressionVariable::EVUnknownType)
         {
-            const NamedDecl *named_decl = entity->m_parser_vars->m_named_decl;
+            const NamedDecl *named_decl = parser_vars->m_named_decl;
             const VarDecl *var_decl = dyn_cast<VarDecl>(named_decl);
             
             if (!var_decl)
@@ -3140,8 +1753,8 @@ ClangExpressionDeclMap::ResolveUnknownTy
             
             TypeFromUser user_type(copied_type, scratch_ast_context);
                         
-            entity->m_parser_vars->m_lldb_value->SetContext(Value::eContextTypeClangType, user_type.GetOpaqueQualType());
-            entity->m_parser_vars->m_parser_type = parser_type;
+            parser_vars->m_lldb_value->SetContext(Value::eContextTypeClangType, user_type.GetOpaqueQualType());
+            parser_vars->m_parser_type = parser_type;
             
             entity->SetClangAST(user_type.GetASTContext());
             entity->SetClangType(user_type.GetOpaqueQualType());
@@ -3158,7 +1771,7 @@ ClangExpressionDeclMap::AddOneRegister (
                                         const RegisterInfo *reg_info, 
                                         unsigned int current_id)
 {
-    lldb::LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
+    Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
     
     void *ast_type = ClangASTContext::GetBuiltinTypeForEncodingAndBitSize(m_ast_context,
                                                                           reg_info->encoding,
@@ -3180,14 +1793,16 @@ ClangExpressionDeclMap::AddOneRegister (
                                                                       m_parser_vars->m_target_info.byte_order,
                                                                       m_parser_vars->m_target_info.address_byte_size));
     assert (entity.get());
+    
     std::string decl_name(context.m_decl_name.getAsString());
     entity->SetName (ConstString (decl_name.c_str()));
     entity->SetRegisterInfo (reg_info);
-    entity->EnableParserVars();
-    entity->m_parser_vars->m_parser_type = parser_type;
-    entity->m_parser_vars->m_named_decl  = var_decl;
-    entity->m_parser_vars->m_llvm_value  = NULL;
-    entity->m_parser_vars->m_lldb_value  = NULL;
+    entity->EnableParserVars(GetParserID());
+    ClangExpressionVariable::ParserVars *parser_vars = entity->GetParserVars(GetParserID());
+    parser_vars->m_parser_type = parser_type;
+    parser_vars->m_named_decl  = var_decl;
+    parser_vars->m_llvm_value  = NULL;
+    parser_vars->m_lldb_value  = NULL;
     entity->m_flags |= ClangExpressionVariable::EVBareRegister;
     
     if (log)
@@ -3205,16 +1820,18 @@ ClangExpressionDeclMap::AddOneFunction (
 {
     assert (m_parser_vars.get());
     
-    lldb::LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
+    Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
     
     NamedDecl *fun_decl = NULL;
-    std::auto_ptr<Value> fun_location(new Value);
+    std::unique_ptr<Value> fun_location(new Value);
     const Address *fun_address = NULL;
     
     // only valid for Functions, not for Symbols
     void *fun_opaque_type = NULL;
     ASTContext *fun_ast_context = NULL;
-    
+
+    bool is_indirect_function = false;
+
     if (fun)
     {
         Type *fun_type = fun->GetType();
@@ -3242,13 +1859,25 @@ ClangExpressionDeclMap::AddOneFunction (
         if (copied_type)
         {
             fun_decl = context.AddFunDecl(copied_type);
+            
+            if (!fun_decl)
+            {
+                if (log)
+                {
+                    log->Printf ("  Failed to create a function decl for '%s' {0x%8.8" PRIx64 "}",
+                                 fun_type->GetName().GetCString(),
+                                 fun_type->GetID());
+                }
+                
+                return;
+            }
         }
         else
         {
             // We failed to copy the type we found
             if (log)
             {
-                log->Printf ("  Failed to import the function type '%s' {0x%8.8llx} into the expression parser AST contenxt",
+                log->Printf ("  Failed to import the function type '%s' {0x%8.8" PRIx64 "} into the expression parser AST contenxt",
                              fun_type->GetName().GetCString(), 
                              fun_type->GetID());
             }
@@ -3260,6 +1889,7 @@ ClangExpressionDeclMap::AddOneFunction (
     {
         fun_address = &symbol->GetAddress();
         fun_decl = context.AddGenericFunDecl();
+        is_indirect_function = symbol->IsIndirect();
     }
     else
     {
@@ -3270,9 +1900,22 @@ ClangExpressionDeclMap::AddOneFunction (
     
     Target *target = m_parser_vars->m_exe_ctx.GetTargetPtr();
 
-    lldb::addr_t load_addr = fun_address->GetCallableLoadAddress(target);
-    fun_location->SetValueType(Value::eValueTypeLoadAddress);
-    fun_location->GetScalar() = load_addr;
+    lldb::addr_t load_addr = fun_address->GetCallableLoadAddress(target, is_indirect_function);
+    
+    if (load_addr != LLDB_INVALID_ADDRESS)
+    {
+        fun_location->SetValueType(Value::eValueTypeLoadAddress);
+        fun_location->GetScalar() = load_addr;
+    }
+    else
+    {
+        // We have to try finding a file address.
+        
+        lldb::addr_t file_addr = fun_address->GetFileAddress();
+        
+        fun_location->SetValueType(Value::eValueTypeFileAddress);
+        fun_location->GetScalar() = file_addr;
+    }
     
     ClangExpressionVariableSP entity(m_found_entities.CreateVariable (m_parser_vars->m_exe_ctx.GetBestExecutionContextScope (),
                                                                       m_parser_vars->m_target_info.byte_order,
@@ -3283,10 +1926,11 @@ ClangExpressionDeclMap::AddOneFunction (
     entity->SetClangType (fun_opaque_type);
     entity->SetClangAST (fun_ast_context);
     
-    entity->EnableParserVars();
-    entity->m_parser_vars->m_named_decl  = fun_decl;
-    entity->m_parser_vars->m_llvm_value  = NULL;
-    entity->m_parser_vars->m_lldb_value  = fun_location.release();
+    entity->EnableParserVars(GetParserID());
+    ClangExpressionVariable::ParserVars *parser_vars = entity->GetParserVars(GetParserID());
+    parser_vars->m_named_decl  = fun_decl;
+    parser_vars->m_llvm_value  = NULL;
+    parser_vars->m_lldb_value  = fun_location.release();
         
     if (log)
     {
@@ -3305,28 +1949,26 @@ ClangExpressionDeclMap::AddOneFunction (
     }
 }
 
-void 
-ClangExpressionDeclMap::AddOneType(NameSearchContext &context, 
-                                   TypeFromUser &ut,
-                                   unsigned int current_id,
-                                   bool add_method)
+TypeFromParser
+ClangExpressionDeclMap::CopyClassType(TypeFromUser &ut,
+                                      unsigned int current_id)
 {
     ASTContext *parser_ast_context = m_ast_context;
     ASTContext *user_ast_context = ut.GetASTContext();
-    
+
     void *copied_type = GuardedCopyType(parser_ast_context, user_ast_context, ut.GetOpaqueQualType());
     
     if (!copied_type)
     {
-        lldb::LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
-
+        Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
+        
         if (log)
-            log->Printf("ClangExpressionDeclMap::AddOneType - Couldn't import the type");
+            log->Printf("ClangExpressionDeclMap::CopyClassType - Couldn't import the type");
         
-        return;
+        return TypeFromParser();
     }
-     
-    if (add_method && ClangASTContext::IsAggregateType(copied_type) && ClangASTContext::GetCompleteType (parser_ast_context, copied_type))
+
+    if (ClangASTContext::IsAggregateType(copied_type) && ClangASTContext::GetCompleteType (parser_ast_context, copied_type))
     {
         void *args[1];
         
@@ -3359,5 +2001,28 @@ ClangExpressionDeclMap::AddOneType(NameS
                                                    is_artificial);
     }
     
+    return TypeFromParser(copied_type, parser_ast_context);
+}
+
+void 
+ClangExpressionDeclMap::AddOneType(NameSearchContext &context, 
+                                   TypeFromUser &ut,
+                                   unsigned int current_id)
+{
+    ASTContext *parser_ast_context = m_ast_context;
+    ASTContext *user_ast_context = ut.GetASTContext();
+    
+    void *copied_type = GuardedCopyType(parser_ast_context, user_ast_context, ut.GetOpaqueQualType());
+    
+    if (!copied_type)
+    {
+        Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
+
+        if (log)
+            log->Printf("ClangExpressionDeclMap::AddOneType - Couldn't import the type");
+        
+        return;
+    }
+    
     context.AddTypeDecl(copied_type);
 }

Modified: lldb/branches/lldb-platform-work/source/Expression/ClangExpressionParser.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/lldb-platform-work/source/Expression/ClangExpressionParser.cpp?rev=183468&r1=183467&r2=183468&view=diff
==============================================================================
--- lldb/branches/lldb-platform-work/source/Expression/ClangExpressionParser.cpp (original)
+++ lldb/branches/lldb-platform-work/source/Expression/ClangExpressionParser.cpp Thu Jun  6 19:06:43 2013
@@ -7,6 +7,8 @@
 //
 //===----------------------------------------------------------------------===//
 
+#include "lldb/lldb-python.h"
+
 #include "lldb/Expression/ClangExpressionParser.h"
 
 #include "lldb/Core/ArchSpec.h"
@@ -18,8 +20,9 @@
 #include "lldb/Expression/ClangASTSource.h"
 #include "lldb/Expression/ClangExpression.h"
 #include "lldb/Expression/ClangExpressionDeclMap.h"
+#include "lldb/Expression/IRExecutionUnit.h"
 #include "lldb/Expression/IRDynamicChecks.h"
-#include "lldb/Expression/RecordingMemoryManager.h"
+#include "lldb/Expression/IRInterpreter.h"
 #include "lldb/Target/ExecutionContext.h"
 #include "lldb/Target/ObjCLanguageRuntime.h"
 #include "lldb/Target/Process.h"
@@ -43,15 +46,16 @@
 #include "clang/Frontend/TextDiagnosticPrinter.h"
 #include "clang/Lex/Preprocessor.h"
 #include "clang/Parse/ParseAST.h"
-#include "clang/Rewrite/FrontendActions.h"
+#include "clang/Rewrite/Frontend/FrontendActions.h"
 #include "clang/Sema/SemaConsumer.h"
 #include "clang/StaticAnalyzer/Frontend/FrontendActions.h"
 
 #include "llvm/ADT/StringRef.h"
 #include "llvm/ExecutionEngine/ExecutionEngine.h"
+#include "llvm/Support/Debug.h"
 #include "llvm/Support/TargetSelect.h"
 
-#if !defined(__APPLE__)
+#if defined(__FreeBSD__)
 #define USE_STANDARD_JIT
 #endif
 
@@ -60,8 +64,8 @@
 #else
 #include "llvm/ExecutionEngine/MCJIT.h"
 #endif
-#include "llvm/LLVMContext.h"
-#include "llvm/Module.h"
+#include "llvm/IR/LLVMContext.h"
+#include "llvm/IR/Module.h"
 #include "llvm/Support/ErrorHandling.h"
 #include "llvm/Support/MemoryBuffer.h"
 #include "llvm/Support/DynamicLibrary.h"
@@ -185,8 +189,7 @@ ClangExpressionParser::ClangExpressionPa
                                               ClangExpression &expr) :
     m_expr (expr),
     m_compiler (),
-    m_code_generator (NULL),
-    m_jitted_functions ()
+    m_code_generator ()
 {
     // Initialize targets first, so that --version shows registered targets.
     static struct InitializeLLVM {
@@ -195,13 +198,67 @@ ClangExpressionParser::ClangExpressionPa
             llvm::InitializeAllAsmPrinters();
             llvm::InitializeAllTargetMCs();
             llvm::InitializeAllDisassemblers();
+            
+            llvm::DisablePrettyStackTrace = true;
         }
     } InitializeLLVM;
-        
+    
     // 1. Create a new compiler instance.
     m_compiler.reset(new CompilerInstance());    
     
-    // 2. Set options.
+    // 2. Install the target.
+
+    lldb::TargetSP target_sp;
+    if (exe_scope)
+        target_sp = exe_scope->CalculateTarget();
+    
+    // TODO: figure out what to really do when we don't have a valid target.
+    // Sometimes this will be ok to just use the host target triple (when we
+    // evaluate say "2+3", but other expressions like breakpoint conditions
+    // and other things that _are_ target specific really shouldn't just be
+    // using the host triple. This needs to be fixed in a better way.
+    if (target_sp && target_sp->GetArchitecture().IsValid())
+    {
+        std::string triple = target_sp->GetArchitecture().GetTriple().str();
+        
+        int dash_count = 0;
+        for (size_t i = 0; i < triple.size(); ++i)
+        {
+            if (triple[i] == '-')
+                dash_count++;
+            if (dash_count == 3)
+            {
+                triple.resize(i);
+                break;
+            }
+        }
+        
+        m_compiler->getTargetOpts().Triple = triple;
+    }
+    else
+    {
+        m_compiler->getTargetOpts().Triple = llvm::sys::getDefaultTargetTriple();
+    }
+    
+    if (target_sp->GetArchitecture().GetMachine() == llvm::Triple::x86 ||
+        target_sp->GetArchitecture().GetMachine() == llvm::Triple::x86_64)
+    {
+        m_compiler->getTargetOpts().Features.push_back("+sse");
+        m_compiler->getTargetOpts().Features.push_back("+sse2");
+    }
+    
+    if (m_compiler->getTargetOpts().Triple.find("ios") != std::string::npos)
+        m_compiler->getTargetOpts().ABI = "apcs-gnu";
+    
+    m_compiler->createDiagnostics();
+    
+    // Create the target instance.
+    m_compiler->setTarget(TargetInfo::CreateTargetInfo(m_compiler->getDiagnostics(),
+                                                       &m_compiler->getTargetOpts()));
+    
+    assert (m_compiler->hasTarget());
+    
+    // 3. Set options.
     
     lldb::LanguageType language = expr.Language();
     
@@ -215,17 +272,20 @@ ClangExpressionParser::ClangExpressionPa
         break;
     case lldb::eLanguageTypeC_plus_plus:
         m_compiler->getLangOpts().CPlusPlus = true;
-        m_compiler->getLangOpts().CPlusPlus0x = true;
+        m_compiler->getLangOpts().CPlusPlus11 = true;
         break;
     case lldb::eLanguageTypeObjC_plus_plus:
     default:
         m_compiler->getLangOpts().ObjC1 = true;
         m_compiler->getLangOpts().ObjC2 = true;
         m_compiler->getLangOpts().CPlusPlus = true;
-        m_compiler->getLangOpts().CPlusPlus0x = true;
+        m_compiler->getLangOpts().CPlusPlus11 = true;
         break;
     }
     
+    m_compiler->getLangOpts().Bool = true;
+    m_compiler->getLangOpts().WChar = true;
+    m_compiler->getLangOpts().Blocks = true;
     m_compiler->getLangOpts().DebuggerSupport = true; // Features specifically for debugger clients
     if (expr.DesiredResultType() == ClangExpression::eResultTypeId)
         m_compiler->getLangOpts().DebuggerCastResultToId = true;
@@ -245,15 +305,12 @@ ClangExpressionParser::ClangExpressionPa
         if (process_sp->GetObjCLanguageRuntime())
         {
             if (process_sp->GetObjCLanguageRuntime()->GetRuntimeVersion() == eAppleObjC_V2)
-            {
-                m_compiler->getLangOpts().ObjCNonFragileABI = true;     // NOT i386
-                m_compiler->getLangOpts().ObjCNonFragileABI2 = true;    // NOT i386
-            }
+                m_compiler->getLangOpts().ObjCRuntime.set(ObjCRuntime::MacOSX, VersionTuple(10, 7));
+            else
+                m_compiler->getLangOpts().ObjCRuntime.set(ObjCRuntime::FragileMacOSX, VersionTuple(10, 7));
             
             if (process_sp->GetObjCLanguageRuntime()->HasNewLiteralsAndIndexing())
-            {
                 m_compiler->getLangOpts().DebuggerObjCLiteral = true;
-            }
         }
     }
 
@@ -266,52 +323,8 @@ ClangExpressionParser::ClangExpressionPa
     m_compiler->getCodeGenOpts().InstrumentFunctions = false;
     
     // Disable some warnings.
-    m_compiler->getDiagnosticOpts().Warnings.push_back("no-unused-value");
-    
-    // Set the target triple.
-    lldb::TargetSP target_sp;
-    if (exe_scope)
-        target_sp = exe_scope->CalculateTarget();
-
-    // TODO: figure out what to really do when we don't have a valid target.
-    // Sometimes this will be ok to just use the host target triple (when we
-    // evaluate say "2+3", but other expressions like breakpoint conditions
-    // and other things that _are_ target specific really shouldn't just be 
-    // using the host triple. This needs to be fixed in a better way.
-    if (target_sp && target_sp->GetArchitecture().IsValid())
-    {
-        std::string triple = target_sp->GetArchitecture().GetTriple().str();
-        
-        int dash_count = 0;
-        for (size_t i = 0; i < triple.size(); ++i)
-        {
-            if (triple[i] == '-')
-                dash_count++;
-            if (dash_count == 3)
-            {
-                triple.resize(i);
-                break;
-            }
-        }
-        
-        m_compiler->getTargetOpts().Triple = triple;
-    }
-    else
-    {
-        m_compiler->getTargetOpts().Triple = llvm::sys::getDefaultTargetTriple();
-    }
-    
-    if (m_compiler->getTargetOpts().Triple.find("ios") != std::string::npos)
-        m_compiler->getTargetOpts().ABI = "apcs-gnu";
-        
-    // 3. Set up various important bits of infrastructure.
-    m_compiler->createDiagnostics(0, 0);
-    
-    // Create the target instance.
-    m_compiler->setTarget(TargetInfo::CreateTargetInfo(m_compiler->getDiagnostics(),
-                                                       m_compiler->getTargetOpts()));
-    
-    assert (m_compiler->hasTarget());
+    m_compiler->getDiagnostics().setDiagnosticGroupMapping("unused-value", clang::diag::MAP_IGNORE, SourceLocation());
+    m_compiler->getDiagnostics().setDiagnosticGroupMapping("odr", clang::diag::MAP_IGNORE, SourceLocation());
     
     // Inform the target of the language options
     //
@@ -339,13 +352,13 @@ ClangExpressionParser::ClangExpressionPa
     m_selector_table.reset(new SelectorTable());
     m_builtin_context.reset(new Builtin::Context());
     
-    std::auto_ptr<clang::ASTContext> ast_context(new ASTContext(m_compiler->getLangOpts(),
-                                                                m_compiler->getSourceManager(),
-                                                                &m_compiler->getTarget(),
-                                                                m_compiler->getPreprocessor().getIdentifierTable(),
-                                                                *m_selector_table.get(),
-                                                                *m_builtin_context.get(),
-                                                                0));
+    std::unique_ptr<clang::ASTContext> ast_context(new ASTContext(m_compiler->getLangOpts(),
+                                                                 m_compiler->getSourceManager(),
+                                                                 &m_compiler->getTarget(),
+                                                                 m_compiler->getPreprocessor().getIdentifierTable(),
+                                                                 *m_selector_table.get(),
+                                                                 *m_builtin_context.get(),
+                                                                 0));
     
     ClangExpressionDeclMap *decl_map = m_expr.DeclMap();
     
@@ -364,6 +377,7 @@ ClangExpressionParser::ClangExpressionPa
     m_code_generator.reset(CreateLLVMCodeGen(m_compiler->getDiagnostics(),
                                              module_name,
                                              m_compiler->getCodeGenOpts(),
+                                             m_compiler->getTargetOpts(),
                                              *m_llvm_context));
 }
 
@@ -428,7 +442,7 @@ ClangExpressionParser::Parse (Stream &st
     return num_errors;
 }
 
-static bool FindFunctionInModule (std::string &mangled_name,
+static bool FindFunctionInModule (ConstString &mangled_name,
                                   llvm::Module *module,
                                   const char *orig_name)
 {
@@ -438,7 +452,7 @@ static bool FindFunctionInModule (std::s
     {        
         if (fi->getName().str().find(orig_name) != std::string::npos)
         {
-            mangled_name = fi->getName().str();
+            mangled_name.SetCString(fi->getName().str().c_str());
             return true;
         }
     }
@@ -447,27 +461,24 @@ static bool FindFunctionInModule (std::s
 }
 
 Error
-ClangExpressionParser::PrepareForExecution (lldb::addr_t &func_allocation_addr, 
-                                            lldb::addr_t &func_addr, 
-                                            lldb::addr_t &func_end, 
+ClangExpressionParser::PrepareForExecution (lldb::addr_t &func_addr, 
+                                            lldb::addr_t &func_end,
+                                            std::unique_ptr<IRExecutionUnit> &execution_unit_ap,
                                             ExecutionContext &exe_ctx,
-                                            IRForTarget::StaticDataAllocator *data_allocator,
-                                            bool &evaluated_statically,
-                                            lldb::ClangExpressionVariableSP &const_result,
+                                            bool &can_interpret,
                                             ExecutionPolicy execution_policy)
 {
-    func_allocation_addr = LLDB_INVALID_ADDRESS;
 	func_addr = LLDB_INVALID_ADDRESS;
 	func_end = LLDB_INVALID_ADDRESS;
-    lldb::LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
+    Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
 
-    std::auto_ptr<llvm::ExecutionEngine> execution_engine;
+    std::unique_ptr<llvm::ExecutionEngine> execution_engine_ap;
     
     Error err;
     
-    llvm::Module *module = m_code_generator->ReleaseModule();
+    std::unique_ptr<llvm::Module> module_ap (m_code_generator->ReleaseModule());
 
-    if (!module)
+    if (!module_ap.get())
     {
         err.SetErrorToGenericError();
         err.SetErrorString("IR doesn't contain a module");
@@ -476,9 +487,9 @@ ClangExpressionParser::PrepareForExecuti
     
     // Find the actual name of the function (it's often mangled somehow)
     
-    std::string function_name;
+    ConstString function_name;
     
-    if (!FindFunctionInModule(function_name, module, m_expr.FunctionName()))
+    if (!FindFunctionInModule(function_name, module_ap.get(), m_expr.FunctionName()))
     {
         err.SetErrorToGenericError();
         err.SetErrorStringWithFormat("Couldn't find %s() in the module", m_expr.FunctionName());
@@ -487,9 +498,15 @@ ClangExpressionParser::PrepareForExecuti
     else
     {
         if (log)
-            log->Printf("Found function %s for %s", function_name.c_str(), m_expr.FunctionName());
+            log->Printf("Found function %s for %s", function_name.AsCString(), m_expr.FunctionName());
     }
     
+    m_execution_unit.reset(new IRExecutionUnit(m_llvm_context, // handed off here
+                                               module_ap, // handed off here
+                                               function_name,
+                                               exe_ctx.GetTargetSP(),
+                                               m_compiler->getTargetOpts().Features));
+        
     ClangExpressionDeclMap *decl_map = m_expr.DeclMap(); // result can be NULL
     
     if (decl_map)
@@ -501,306 +518,81 @@ ClangExpressionParser::PrepareForExecuti
     
         IRForTarget ir_for_target(decl_map,
                                   m_expr.NeedsVariableResolution(),
-                                  execution_policy,
-                                  const_result,
-                                  data_allocator,
+                                  *m_execution_unit,
                                   error_stream,
-                                  function_name.c_str());
+                                  function_name.AsCString());
+        
+        bool ir_can_run = ir_for_target.runOnModule(*m_execution_unit->GetModule());
         
-        ir_for_target.runOnModule(*module);
+        Error interpret_error;
         
-        Error &interpreter_error(ir_for_target.getInterpreterError());
+        can_interpret = IRInterpreter::CanInterpret(*m_execution_unit->GetModule(), *m_execution_unit->GetFunction(), interpret_error);
         
-        if (execution_policy != eExecutionPolicyAlways && interpreter_error.Success())
+        Process *process = exe_ctx.GetProcessPtr();
+        
+        if (!ir_can_run)
         {
-            if (const_result)
-                const_result->TransferAddress();
-            evaluated_statically = true;
-            err.Clear();
+            err.SetErrorString("The expression could not be prepared to run in the target");
             return err;
         }
         
-        Process *process = exe_ctx.GetProcessPtr();
-
-        if (!process || execution_policy == eExecutionPolicyNever)
+        if (!can_interpret && execution_policy == eExecutionPolicyNever)
         {
-            err.SetErrorToGenericError();
-            if (execution_policy == eExecutionPolicyAlways)
-                err.SetErrorString("Execution needed to run in the target, but the target can't be run");
-            else
-                err.SetErrorStringWithFormat("Interpreting the expression locally failed: %s", interpreter_error.AsCString());
-
+            err.SetErrorStringWithFormat("Can't run the expression locally: %s", interpret_error.AsCString());
             return err;
         }
         
-        if (execution_policy != eExecutionPolicyNever &&
-            m_expr.NeedsValidation() && 
-            process)
+        if (!process && execution_policy == eExecutionPolicyAlways)
         {
-            if (!process->GetDynamicCheckers())
-            {                
-                DynamicCheckerFunctions *dynamic_checkers = new DynamicCheckerFunctions();
-                
-                StreamString install_errors;
-                
-                if (!dynamic_checkers->Install(install_errors, exe_ctx))
+            err.SetErrorString("Expression needed to run in the target, but the target can't be run");
+            return err;
+        }
+        
+        if (execution_policy == eExecutionPolicyAlways || !can_interpret)
+        {
+            if (m_expr.NeedsValidation() && process)
+            {
+                if (!process->GetDynamicCheckers())
                 {
-                    if (install_errors.GetString().empty())
-                        err.SetErrorString ("couldn't install checkers, unknown error");
-                    else
-                        err.SetErrorString (install_errors.GetString().c_str());
+                    DynamicCheckerFunctions *dynamic_checkers = new DynamicCheckerFunctions();
                     
-                    return err;
+                    StreamString install_errors;
+                    
+                    if (!dynamic_checkers->Install(install_errors, exe_ctx))
+                    {
+                        if (install_errors.GetString().empty())
+                            err.SetErrorString ("couldn't install checkers, unknown error");
+                        else
+                            err.SetErrorString (install_errors.GetString().c_str());
+                        
+                        return err;
+                    }
+                    
+                    process->SetDynamicCheckers(dynamic_checkers);
+                    
+                    if (log)
+                        log->Printf("== [ClangUserExpression::Evaluate] Finished installing dynamic checkers ==");
                 }
                 
-                process->SetDynamicCheckers(dynamic_checkers);
+                IRDynamicChecks ir_dynamic_checks(*process->GetDynamicCheckers(), function_name.AsCString());
                 
-                if (log)
-                    log->Printf("== [ClangUserExpression::Evaluate] Finished installing dynamic checkers ==");
+                if (!ir_dynamic_checks.runOnModule(*m_execution_unit->GetModule()))
+                {
+                    err.SetErrorToGenericError();
+                    err.SetErrorString("Couldn't add dynamic checks to the expression");
+                    return err;
+                }
             }
             
-            IRDynamicChecks ir_dynamic_checks(*process->GetDynamicCheckers(), function_name.c_str());
-        
-            if (!ir_dynamic_checks.runOnModule(*module))
-            {
-                err.SetErrorToGenericError();
-                err.SetErrorString("Couldn't add dynamic checks to the expression");
-                return err;
-            }
+            m_execution_unit->GetRunnableInfo(err, func_addr, func_end);
         }
     }
-    
-    // llvm will own this pointer when llvm::ExecutionEngine::createJIT is called 
-    // below so we don't need to free it.
-    RecordingMemoryManager *jit_memory_manager = new RecordingMemoryManager();
-    
-    std::string error_string;
-
-    if (log)
-    {
-        std::string s;
-        raw_string_ostream oss(s);
-        
-        module->print(oss, NULL);
-        
-        oss.flush();
-        
-        log->Printf ("Module being sent to JIT: \n%s", s.c_str());
-    }
-    
-    EngineBuilder builder(module);
-    builder.setEngineKind(EngineKind::JIT)
-        .setErrorStr(&error_string)
-        .setRelocationModel(llvm::Reloc::PIC_)
-        .setJITMemoryManager(jit_memory_manager)
-        .setOptLevel(CodeGenOpt::Less)
-        .setAllocateGVsWithCode(true)
-        .setCodeModel(CodeModel::Small)
-        .setUseMCJIT(true);
-    execution_engine.reset(builder.create());
-        
-    if (!execution_engine.get())
-    {
-        err.SetErrorToGenericError();
-        err.SetErrorStringWithFormat("Couldn't JIT the function: %s", error_string.c_str());
-        return err;
-    }
-    
-    execution_engine->DisableLazyCompilation();
-    
-    llvm::Function *function = module->getFunction (function_name.c_str());
-    
-    // We don't actually need the function pointer here, this just forces it to get resolved.
-    
-    void *fun_ptr = execution_engine->getPointerToFunction(function);
-        
-    // Errors usually cause failures in the JIT, but if we're lucky we get here.
-    
-    if (!function)
-    {
-        err.SetErrorToGenericError();
-        err.SetErrorStringWithFormat("Couldn't find '%s' in the JITted module", function_name.c_str());
-        return err;
-    }
-    
-    if (!fun_ptr)
-    {
-        err.SetErrorToGenericError();
-        err.SetErrorStringWithFormat("'%s' was in the JITted module but wasn't lowered", function_name.c_str());
-        return err;
-    }
-    
-    m_jitted_functions.push_back (ClangExpressionParser::JittedFunction(function_name.c_str(), (lldb::addr_t)fun_ptr));
-    
-
-    Process *process = exe_ctx.GetProcessPtr();
-    if (process == NULL)
-    {
-        err.SetErrorToGenericError();
-        err.SetErrorString("Couldn't write the JIT compiled code into the target because there is no target");
-        return err;
-    }
-        
-    jit_memory_manager->CommitAllocations(*process);
-    jit_memory_manager->ReportAllocations(*execution_engine);
-    jit_memory_manager->WriteData(*process);
-    
-    std::vector<JittedFunction>::iterator pos, end = m_jitted_functions.end();
-    
-    for (pos = m_jitted_functions.begin(); pos != end; pos++)
+    else
     {
-        (*pos).m_remote_addr = jit_memory_manager->GetRemoteAddressForLocal ((*pos).m_local_addr);
-    
-        if (!(*pos).m_name.compare(function_name.c_str()))
-        {
-            RecordingMemoryManager::AddrRange func_range = jit_memory_manager->GetRemoteRangeForLocal((*pos).m_local_addr);
-            func_end = func_range.first + func_range.second;
-            func_addr = (*pos).m_remote_addr;
-        }
+        m_execution_unit->GetRunnableInfo(err, func_addr, func_end);
     }
     
-    if (log)
-    {
-        log->Printf("Code can be run in the target.");
-        
-        StreamString disassembly_stream;
+    execution_unit_ap.reset (m_execution_unit.release());
         
-        Error err = DisassembleFunction(disassembly_stream, exe_ctx, jit_memory_manager);
-        
-        if (!err.Success())
-        {
-            log->Printf("Couldn't disassemble function : %s", err.AsCString("unknown error"));
-        }
-        else
-        {
-            log->Printf("Function disassembly:\n%s", disassembly_stream.GetData());
-        }
-    }
-    
-    execution_engine.reset();
-    
-    err.Clear();
     return err;
 }
-
-Error
-ClangExpressionParser::DisassembleFunction (Stream &stream, ExecutionContext &exe_ctx, RecordingMemoryManager *jit_memory_manager)
-{
-    lldb::LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
-    
-    const char *name = m_expr.FunctionName();
-    
-    Error ret;
-    
-    ret.Clear();
-    
-    lldb::addr_t func_local_addr = LLDB_INVALID_ADDRESS;
-    lldb::addr_t func_remote_addr = LLDB_INVALID_ADDRESS;
-    
-    std::vector<JittedFunction>::iterator pos, end = m_jitted_functions.end();
-    
-    for (pos = m_jitted_functions.begin(); pos < end; pos++)
-    {
-        if (strstr(pos->m_name.c_str(), name))
-        {
-            func_local_addr = pos->m_local_addr;
-            func_remote_addr = pos->m_remote_addr;
-        }
-    }
-    
-    if (func_local_addr == LLDB_INVALID_ADDRESS)
-    {
-        ret.SetErrorToGenericError();
-        ret.SetErrorStringWithFormat("Couldn't find function %s for disassembly", name);
-        return ret;
-    }
-    
-    if (log)
-        log->Printf("Found function, has local address 0x%llx and remote address 0x%llx", (uint64_t)func_local_addr, (uint64_t)func_remote_addr);
-    
-    std::pair <lldb::addr_t, lldb::addr_t> func_range;
-    
-    func_range = jit_memory_manager->GetRemoteRangeForLocal(func_local_addr);
-    
-    if (func_range.first == 0 && func_range.second == 0)
-    {
-        ret.SetErrorToGenericError();
-        ret.SetErrorStringWithFormat("Couldn't find code range for function %s", name);
-        return ret;
-    }
-    
-    if (log)
-        log->Printf("Function's code range is [0x%llx+0x%llx]", func_range.first, func_range.second);
-    
-    Target *target = exe_ctx.GetTargetPtr();
-    if (!target)
-    {
-        ret.SetErrorToGenericError();
-        ret.SetErrorString("Couldn't find the target");
-    }
-    
-    lldb::DataBufferSP buffer_sp(new DataBufferHeap(func_range.second, 0));
-    
-    Process *process = exe_ctx.GetProcessPtr();
-    Error err;
-    process->ReadMemory(func_remote_addr, buffer_sp->GetBytes(), buffer_sp->GetByteSize(), err);
-    
-    if (!err.Success())
-    {
-        ret.SetErrorToGenericError();
-        ret.SetErrorStringWithFormat("Couldn't read from process: %s", err.AsCString("unknown error"));
-        return ret;
-    }
-    
-    ArchSpec arch(target->GetArchitecture());
-    
-    lldb::DisassemblerSP disassembler = Disassembler::FindPlugin(arch, NULL);
-    
-    if (!disassembler)
-    {
-        ret.SetErrorToGenericError();
-        ret.SetErrorStringWithFormat("Unable to find disassembler plug-in for %s architecture.", arch.GetArchitectureName());
-        return ret;
-    }
-    
-    if (!process)
-    {
-        ret.SetErrorToGenericError();
-        ret.SetErrorString("Couldn't find the process");
-        return ret;
-    }
-    
-    DataExtractor extractor(buffer_sp, 
-                            process->GetByteOrder(),
-                            target->GetArchitecture().GetAddressByteSize());
-    
-    if (log)
-    {
-        log->Printf("Function data has contents:");
-        extractor.PutToLog (log.get(),
-                            0,
-                            extractor.GetByteSize(),
-                            func_remote_addr,
-                            16,
-                            DataExtractor::TypeUInt8);
-    }
-    
-    disassembler->DecodeInstructions (Address (func_remote_addr), extractor, 0, UINT32_MAX, false);
-    
-    InstructionList &instruction_list = disassembler->GetInstructionList();
-    const uint32_t max_opcode_byte_size = instruction_list.GetMaxOpcocdeByteSize();
-    for (uint32_t instruction_index = 0, num_instructions = instruction_list.GetSize(); 
-         instruction_index < num_instructions; 
-         ++instruction_index)
-    {
-        Instruction *instruction = instruction_list.GetInstructionAtIndex(instruction_index).get();
-        instruction->Dump (&stream,
-                           max_opcode_byte_size,
-                           true,
-                           true,
-                           &exe_ctx);
-        stream.PutChar('\n');
-    }
-    
-    return ret;
-}

Modified: lldb/branches/lldb-platform-work/source/Expression/ClangFunction.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/lldb-platform-work/source/Expression/ClangFunction.cpp?rev=183468&r1=183467&r2=183468&view=diff
==============================================================================
--- lldb/branches/lldb-platform-work/source/Expression/ClangFunction.cpp (original)
+++ lldb/branches/lldb-platform-work/source/Expression/ClangFunction.cpp Thu Jun  6 19:06:43 2013
@@ -19,12 +19,13 @@
 #include "llvm/ADT/StringRef.h"
 #include "llvm/ADT/Triple.h"
 #include "llvm/ExecutionEngine/ExecutionEngine.h"
-#include "llvm/Module.h"
+#include "llvm/IR/Module.h"
 
 // Project includes
 #include "lldb/Expression/ASTStructExtractor.h"
 #include "lldb/Expression/ClangExpressionParser.h"
 #include "lldb/Expression/ClangFunction.h"
+#include "lldb/Expression/IRExecutionUnit.h"
 #include "lldb/Symbol/Type.h"
 #include "lldb/Core/DataExtractor.h"
 #include "lldb/Core/State.h"
@@ -66,9 +67,9 @@ ClangFunction::ClangFunction
     m_compiled (false),
     m_JITted (false)
 {
-    m_jit_process_sp = exe_scope.CalculateProcess();
+    m_jit_process_wp = lldb::ProcessWP(exe_scope.CalculateProcess());
     // Can't make a ClangFunction without a process.
-    assert (m_jit_process_sp);
+    assert (m_jit_process_wp.lock());
 }
 
 ClangFunction::ClangFunction
@@ -89,9 +90,9 @@ ClangFunction::ClangFunction
     m_compiled (false),
     m_JITted (false)
 {
-    m_jit_process_sp = exe_scope.CalculateProcess();
+    m_jit_process_wp = lldb::ProcessWP(exe_scope.CalculateProcess());
     // Can't make a ClangFunction without a process.
-    assert (m_jit_process_sp);
+    assert (m_jit_process_wp.lock());
 
     m_function_addr = m_function_ptr->GetAddressRange().GetBaseAddress();
     m_function_return_qual_type = m_function_ptr->GetReturnClangType();
@@ -136,7 +137,7 @@ ClangFunction::CompileFunction (Stream &
     // to pull the defined arguments out of the function, then add the types from the
     // arguments list for the variable arguments.
 
-    uint32_t num_args = UINT32_MAX;
+    size_t num_args = UINT32_MAX;
     bool trust_function = false;
     // GetArgumentCount returns -1 for an unprototyped function.
     if (m_function_ptr)
@@ -186,7 +187,7 @@ ClangFunction::CompileFunction (Stream &
         char arg_buf[32];
         args_buffer.append ("    ");
         args_buffer.append (type_name);
-        snprintf(arg_buf, 31, "arg_%zd", i);
+        snprintf(arg_buf, 31, "arg_%" PRIu64, (uint64_t)i);
         args_buffer.push_back (' ');
         args_buffer.append (arg_buf);
         args_buffer.append (";\n");
@@ -214,15 +215,24 @@ ClangFunction::CompileFunction (Stream &
     m_wrapper_function_text.append (args_list_buffer);
     m_wrapper_function_text.append (");\n}\n");
 
-    lldb::LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
+    Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
     if (log)
         log->Printf ("Expression: \n\n%s\n\n", m_wrapper_function_text.c_str());
         
     // Okay, now compile this expression
-        
-    m_parser.reset(new ClangExpressionParser(m_jit_process_sp.get(), *this));
     
-    num_errors = m_parser->Parse (errors);
+    lldb::ProcessSP jit_process_sp(m_jit_process_wp.lock());
+    if (jit_process_sp)
+    {
+        m_parser.reset(new ClangExpressionParser(jit_process_sp.get(), *this));
+        
+        num_errors = m_parser->Parse (errors);
+    }
+    else
+    {
+        errors.Printf("no process - unable to inject function");
+        num_errors = 1;
+    }
     
     m_compiled = (num_errors == 0);
     
@@ -239,8 +249,10 @@ ClangFunction::WriteFunctionWrapper (Exe
 
     if (!process)
         return false;
-        
-    if (process != m_jit_process_sp.get())
+    
+    lldb::ProcessSP jit_process_sp(m_jit_process_wp.lock());
+    
+    if (process != jit_process_sp.get())
         return false;
     
     if (!m_compiled)
@@ -248,24 +260,23 @@ ClangFunction::WriteFunctionWrapper (Exe
 
     if (m_JITted)
         return true;
+        
+    bool can_interpret = false; // should stay that way
     
-    lldb::ClangExpressionVariableSP const_result;
-    
-    bool evaluated_statically = false; // should stay that way
-    
-    Error jit_error (m_parser->PrepareForExecution (m_jit_alloc,
-                                                    m_jit_start_addr,
+    Error jit_error (m_parser->PrepareForExecution (m_jit_start_addr,
                                                     m_jit_end_addr,
+                                                    m_execution_unit_ap,
                                                     exe_ctx, 
-                                                    NULL,
-                                                    evaluated_statically,
-                                                    const_result,
+                                                    can_interpret,
                                                     eExecutionPolicyAlways));
     
     if (!jit_error.Success())
         return false;
-    if (process && m_jit_alloc != LLDB_INVALID_ADDRESS)
-        m_jit_process_sp = process->shared_from_this();
+    
+    if (process && m_jit_start_addr)
+        m_jit_process_wp = lldb::ProcessWP(process->shared_from_this());
+    
+    m_JITted = true;
 
     return true;
 }
@@ -302,7 +313,9 @@ ClangFunction::WriteFunctionArguments (E
     if (process == NULL)
         return return_value;
 
-    if (process != m_jit_process_sp.get())
+    lldb::ProcessSP jit_process_sp(m_jit_process_wp.lock());
+    
+    if (process != jit_process_sp.get())
         return false;
                 
     if (args_addr_ref == LLDB_INVALID_ADDRESS)
@@ -323,7 +336,7 @@ ClangFunction::WriteFunctionArguments (E
 
     // TODO: verify fun_addr needs to be a callable address
     Scalar fun_addr (function_address.GetCallableLoadAddress(exe_ctx.GetTargetPtr()));
-    int first_offset = m_member_offsets[0];
+    uint64_t first_offset = m_member_offsets[0];
     process->WriteScalarToMemory(args_addr_ref + first_offset, fun_addr, process->GetAddressByteSize(), error);
 
     // FIXME: We will need to extend this for Variadic functions.
@@ -341,7 +354,7 @@ ClangFunction::WriteFunctionArguments (E
     {
         // FIXME: We should sanity check sizes.
 
-        int offset = m_member_offsets[i+1]; // Clang sizes are in bytes.
+        uint64_t offset = m_member_offsets[i+1]; // Clang sizes are in bytes.
         Value *arg_value = arg_values.GetValueAtIndex(i);
         
         // FIXME: For now just do scalars:
@@ -374,9 +387,9 @@ ClangFunction::InsertFunction (Execution
     if (!WriteFunctionArguments(exe_ctx, args_addr_ref, errors))
         return false;
 
-    lldb::LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_STEP));
+    Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_STEP));
     if (log)
-        log->Printf ("Call Address: 0x%llx Struct Address: 0x%llx.\n", m_jit_start_addr, args_addr_ref);
+        log->Printf ("Call Address: 0x%" PRIx64 " Struct Address: 0x%" PRIx64 ".\n", m_jit_start_addr, args_addr_ref);
         
     return true;
 }
@@ -387,10 +400,16 @@ ClangFunction::GetThreadPlanToCallFuncti
                                             lldb::addr_t &args_addr, 
                                             Stream &errors, 
                                             bool stop_others, 
-                                            bool discard_on_error, 
+                                            bool unwind_on_error,
+                                            bool ignore_breakpoints,
                                             lldb::addr_t *this_arg,
                                             lldb::addr_t *cmd_arg)
 {
+    Log *log(lldb_private::GetLogIfAnyCategoriesSet (LIBLLDB_LOG_EXPRESSIONS | LIBLLDB_LOG_STEP));
+    
+    if (log)
+        log->Printf("-- [ClangFunction::GetThreadPlanToCallFunction] Creating thread plan to call function --");
+    
     // FIXME: Use the errors Stream for better error reporting.
     Thread *thread = exe_ctx.GetThreadPtr();
     if (thread == NULL)
@@ -407,7 +426,8 @@ ClangFunction::GetThreadPlanToCallFuncti
                                                        ClangASTType(),
                                                        args_addr,
                                                        stop_others, 
-                                                       discard_on_error,
+                                                       unwind_on_error,
+                                                       ignore_breakpoints,
                                                        this_arg,
                                                        cmd_arg);
     new_plan->SetIsMasterPlan(true);
@@ -422,11 +442,20 @@ ClangFunction::FetchFunctionResults (Exe
     // FIXME: How does clang tell us there's no return value?  We need to handle that case.
     // FIXME: Create our ThreadPlanCallFunction with the return ClangASTType, and then use GetReturnValueObject
     // to fetch the value.  That way we can fetch any values we need.
+    
+    Log *log(lldb_private::GetLogIfAnyCategoriesSet (LIBLLDB_LOG_EXPRESSIONS | LIBLLDB_LOG_STEP));
+    
+    if (log)
+        log->Printf("-- [ClangFunction::FetchFunctionResults] Fetching function results --");
+    
     Process *process = exe_ctx.GetProcessPtr();
     
     if (process == NULL)
         return false;
-    if (process != m_jit_process_sp.get())
+
+    lldb::ProcessSP jit_process_sp(m_jit_process_wp.lock());
+    
+    if (process != jit_process_sp.get())
         return false;
                 
     Error error;
@@ -461,22 +490,25 @@ ExecutionResults
 ClangFunction::ExecuteFunction(ExecutionContext &exe_ctx, Stream &errors, bool stop_others, Value &results)
 {
     const bool try_all_threads = false;
-    const bool discard_on_error = true;
-    return ExecuteFunction (exe_ctx, NULL, errors, stop_others, NULL, try_all_threads, discard_on_error, results);
+    const bool unwind_on_error = true;
+    const bool ignore_breakpoints = true;
+    return ExecuteFunction (exe_ctx, NULL, errors, stop_others, 0UL, try_all_threads,
+                            unwind_on_error, ignore_breakpoints, results);
 }
 
 ExecutionResults
 ClangFunction::ExecuteFunction(
         ExecutionContext &exe_ctx, 
         Stream &errors, 
-        uint32_t single_thread_timeout_usec, 
+        uint32_t timeout_usec, 
         bool try_all_threads, 
         Value &results)
 {
     const bool stop_others = true;
-    const bool discard_on_error = true;
-    return ExecuteFunction (exe_ctx, NULL, errors, stop_others, single_thread_timeout_usec, 
-                            try_all_threads, discard_on_error, results);
+    const bool unwind_on_error = true;
+    const bool ignore_breakpoints = true;
+    return ExecuteFunction (exe_ctx, NULL, errors, stop_others, timeout_usec,
+                            try_all_threads, unwind_on_error, ignore_breakpoints, results);
 }
 
 // This is the static function
@@ -487,23 +519,28 @@ ClangFunction::ExecuteFunction (
         lldb::addr_t &void_arg,
         bool stop_others,
         bool try_all_threads,
-        bool discard_on_error,
-        uint32_t single_thread_timeout_usec,
+        bool unwind_on_error,
+        bool ignore_breakpoints,
+        uint32_t timeout_usec,
         Stream &errors,
         lldb::addr_t *this_arg)
 {
-    lldb::ThreadPlanSP call_plan_sp (ClangFunction::GetThreadPlanToCallFunction (exe_ctx, 
+    Log *log(lldb_private::GetLogIfAnyCategoriesSet (LIBLLDB_LOG_EXPRESSIONS | LIBLLDB_LOG_STEP));
+
+    if (log)
+        log->Printf("== [ClangFunction::ExecuteFunction] Executing function ==");
+    
+    lldb::ThreadPlanSP call_plan_sp (ClangFunction::GetThreadPlanToCallFunction (exe_ctx,
                                                                                  function_address, 
                                                                                  void_arg, 
                                                                                  errors, 
                                                                                  stop_others, 
-                                                                                 discard_on_error, 
+                                                                                 unwind_on_error,
+                                                                                 ignore_breakpoints,
                                                                                  this_arg));
     if (!call_plan_sp)
         return eExecutionSetupError;
-    
-    call_plan_sp->SetPrivate(true);
-    
+        
     // <rdar://problem/12027563> we need to make sure we record the fact that we are running an expression here
     // otherwise this fact will fail to be recorded when fetching an Objective-C object description
     if (exe_ctx.GetProcessPtr())
@@ -512,10 +549,23 @@ ClangFunction::ExecuteFunction (
     ExecutionResults results = exe_ctx.GetProcessRef().RunThreadPlan (exe_ctx, call_plan_sp,
                                                                       stop_others, 
                                                                       try_all_threads, 
-                                                                      discard_on_error,
-                                                                      single_thread_timeout_usec, 
+                                                                      unwind_on_error,
+                                                                      ignore_breakpoints,
+                                                                      timeout_usec,
                                                                       errors);
     
+    if (log)
+    {
+        if (results != eExecutionCompleted)
+        {
+            log->Printf("== [ClangFunction::ExecuteFunction] Execution completed abnormally ==");
+        }
+        else
+        {
+            log->Printf("== [ClangFunction::ExecuteFunction] Execution completed normally ==");
+        }
+    }
+    
     if (exe_ctx.GetProcessPtr())
         exe_ctx.GetProcessPtr()->SetRunningUserExpression(false);
     
@@ -528,9 +578,10 @@ ClangFunction::ExecuteFunction(
         lldb::addr_t *args_addr_ptr, 
         Stream &errors, 
         bool stop_others, 
-        uint32_t single_thread_timeout_usec, 
+        uint32_t timeout_usec, 
         bool try_all_threads,
-        bool discard_on_error, 
+        bool unwind_on_error,
+        bool ignore_breakpoints,
         Value &results)
 {
     using namespace clang;
@@ -557,8 +608,9 @@ ClangFunction::ExecuteFunction(
                                                    args_addr, 
                                                    stop_others, 
                                                    try_all_threads, 
-                                                   discard_on_error, 
-                                                   single_thread_timeout_usec, 
+                                                   unwind_on_error,
+                                                   ignore_breakpoints,
+                                                   timeout_usec, 
                                                    errors);
 
     if (args_addr_ptr != NULL)

Modified: lldb/branches/lldb-platform-work/source/Expression/ClangUserExpression.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/lldb-platform-work/source/Expression/ClangUserExpression.cpp?rev=183468&r1=183467&r2=183468&view=diff
==============================================================================
--- lldb/branches/lldb-platform-work/source/Expression/ClangUserExpression.cpp (original)
+++ lldb/branches/lldb-platform-work/source/Expression/ClangUserExpression.cpp Thu Jun  6 19:06:43 2013
@@ -29,7 +29,15 @@
 #include "lldb/Expression/ClangFunction.h"
 #include "lldb/Expression/ClangUserExpression.h"
 #include "lldb/Expression/ExpressionSourceCode.h"
+#include "lldb/Expression/IRExecutionUnit.h"
+#include "lldb/Expression/IRInterpreter.h"
+#include "lldb/Expression/Materializer.h"
 #include "lldb/Host/Host.h"
+#include "lldb/Symbol/Block.h"
+#include "lldb/Symbol/ClangASTContext.h"
+#include "lldb/Symbol/Function.h"
+#include "lldb/Symbol/Type.h"
+#include "lldb/Symbol/ClangExternalASTSourceCommon.h"
 #include "lldb/Symbol/VariableList.h"
 #include "lldb/Target/ExecutionContext.h"
 #include "lldb/Target/Process.h"
@@ -48,20 +56,22 @@ ClangUserExpression::ClangUserExpression
                                           lldb::LanguageType language,
                                           ResultType desired_type) :
     ClangExpression (),
+    m_stack_frame_bottom (LLDB_INVALID_ADDRESS),
+    m_stack_frame_top (LLDB_INVALID_ADDRESS),
     m_expr_text (expr),
     m_expr_prefix (expr_prefix ? expr_prefix : ""),
     m_language (language),
     m_transformed_text (),
     m_desired_type (desired_type),
-    m_enforce_valid_object (false),
+    m_enforce_valid_object (true),
     m_cplusplus (false),
     m_objectivec (false),
     m_static_method(false),
     m_needs_object_ptr (false),
     m_const_object (false),
     m_target (NULL),
-    m_evaluated_statically (false),
-    m_const_result ()
+    m_can_interpret (false),
+    m_materialized_address (LLDB_INVALID_ADDRESS)
 {
     switch (m_language)
     {
@@ -101,31 +111,56 @@ ClangUserExpression::ASTTransformer (cla
 void
 ClangUserExpression::ScanContext(ExecutionContext &exe_ctx, Error &err)
 {
+    Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
+
+    if (log)
+        log->Printf("ClangUserExpression::ScanContext()");
+    
     m_target = exe_ctx.GetTargetPtr();
     
     if (!(m_allow_cxx || m_allow_objc))
+    {
+        if (log)
+            log->Printf("  [CUE::SC] Settings inhibit C++ and Objective-C");
         return;
+    }
     
     StackFrame *frame = exe_ctx.GetFramePtr();
     if (frame == NULL)
+    {
+        if (log)
+            log->Printf("  [CUE::SC] Null stack frame");
         return;
+    }
     
     SymbolContext sym_ctx = frame->GetSymbolContext(lldb::eSymbolContextFunction | lldb::eSymbolContextBlock);
     
     if (!sym_ctx.function)
+    {
+        if (log)
+            log->Printf("  [CUE::SC] Null function");
         return;
+    }
     
     // Find the block that defines the function represented by "sym_ctx"
     Block *function_block = sym_ctx.GetFunctionBlock();
     
     if (!function_block)
+    {
+        if (log)
+            log->Printf("  [CUE::SC] Null function block");
         return;
+    }
 
     clang::DeclContext *decl_context = function_block->GetClangDeclContext();
 
     if (!decl_context)
+    {
+        if (log)
+            log->Printf("  [CUE::SC] Null decl context");
         return;
-            
+    }
+    
     if (clang::CXXMethodDecl *method_decl = llvm::dyn_cast<clang::CXXMethodDecl>(decl_context))
     {
         if (m_allow_cxx && method_decl->isInstance())
@@ -191,6 +226,158 @@ ClangUserExpression::ScanContext(Executi
                 m_static_method = true;
         }
     }
+    else if (clang::FunctionDecl *function_decl = llvm::dyn_cast<clang::FunctionDecl>(decl_context))
+    {
+        // We might also have a function that said in the debug information that it captured an
+        // object pointer.  The best way to deal with getting to the ivars at present it by pretending
+        // that this is a method of a class in whatever runtime the debug info says the object pointer
+        // belongs to.  Do that here.
+        
+        ClangASTMetadata *metadata = ClangASTContext::GetMetadata (&decl_context->getParentASTContext(), function_decl);
+        if (metadata && metadata->HasObjectPtr())
+        {
+            lldb::LanguageType language = metadata->GetObjectPtrLanguage();
+            if (language == lldb::eLanguageTypeC_plus_plus)
+            {
+                if (m_enforce_valid_object)
+                {
+                    lldb::VariableListSP variable_list_sp (function_block->GetBlockVariableList (true));
+                    
+                    const char *thisErrorString = "Stopped in a context claiming to capture a C++ object pointer, but 'this' isn't available; pretending we are in a generic context";
+                    
+                    if (!variable_list_sp)
+                    {
+                        err.SetErrorString(thisErrorString);
+                        return;
+                    }
+                    
+                    lldb::VariableSP this_var_sp (variable_list_sp->FindVariable(ConstString("this")));
+                    
+                    if (!this_var_sp ||
+                        !this_var_sp->IsInScope(frame) ||
+                        !this_var_sp->LocationIsValidForFrame (frame))
+                    {
+                        err.SetErrorString(thisErrorString);
+                        return;
+                    }
+                }
+                
+                m_cplusplus = true;
+                m_needs_object_ptr = true;
+            }
+            else if (language == lldb::eLanguageTypeObjC)
+            {
+                if (m_enforce_valid_object)
+                {
+                    lldb::VariableListSP variable_list_sp (function_block->GetBlockVariableList (true));
+                    
+                    const char *selfErrorString = "Stopped in a context claiming to capture an Objective-C object pointer, but 'self' isn't available; pretending we are in a generic context";
+                    
+                    if (!variable_list_sp)
+                    {
+                        err.SetErrorString(selfErrorString);
+                        return;
+                    }
+                    
+                    lldb::VariableSP self_variable_sp = variable_list_sp->FindVariable(ConstString("self"));
+                    
+                    if (!self_variable_sp ||
+                        !self_variable_sp->IsInScope(frame) ||
+                        !self_variable_sp->LocationIsValidForFrame (frame))
+                    {
+                        err.SetErrorString(selfErrorString);
+                        return;
+                    }
+                    
+                    Type *self_type = self_variable_sp->GetType();
+                    
+                    if (!self_type)
+                    {
+                        err.SetErrorString(selfErrorString);
+                        return;
+                    }
+                    
+                    lldb::clang_type_t self_opaque_type = self_type->GetClangForwardType();
+                    
+                    if (!self_opaque_type)
+                    {
+                        err.SetErrorString(selfErrorString);
+                        return;
+                    }
+                    
+                    clang::QualType self_qual_type = clang::QualType::getFromOpaquePtr(self_opaque_type);
+                    
+                    if (self_qual_type->isObjCClassType())
+                    {
+                        return;
+                    }
+                    else if (self_qual_type->isObjCObjectPointerType())
+                    {
+                        m_objectivec = true;
+                        m_needs_object_ptr = true;
+                    }
+                    else
+                    {
+                        err.SetErrorString(selfErrorString);
+                        return;
+                    }
+                }
+                else
+                {
+                    m_objectivec = true;
+                    m_needs_object_ptr = true;
+                }
+            }
+        }
+    }
+}
+
+void
+ClangUserExpression::InstallContext (ExecutionContext &exe_ctx)
+{
+    m_process_wp = exe_ctx.GetProcessSP();
+    
+    lldb::StackFrameSP frame_sp = exe_ctx.GetFrameSP();
+    
+    if (frame_sp)
+        m_address = frame_sp->GetFrameCodeAddress();
+}
+
+bool
+ClangUserExpression::LockAndCheckContext (ExecutionContext &exe_ctx,
+                                          lldb::TargetSP &target_sp,
+                                          lldb::ProcessSP &process_sp,
+                                          lldb::StackFrameSP &frame_sp)
+{
+    lldb::ProcessSP expected_process_sp = m_process_wp.lock();
+    process_sp = exe_ctx.GetProcessSP();
+
+    if (process_sp != expected_process_sp)
+        return false;
+    
+    process_sp = exe_ctx.GetProcessSP();
+    target_sp = exe_ctx.GetTargetSP();
+    frame_sp = exe_ctx.GetFrameSP();
+    
+    if (m_address.IsValid())
+    {
+        if (!frame_sp)
+            return false;
+        else
+            return (0 == Address::CompareLoadAddress(m_address, frame_sp->GetFrameCodeAddress(), target_sp.get()));
+    }
+    
+    return true;
+}
+
+bool
+ClangUserExpression::MatchesContext (ExecutionContext &exe_ctx)
+{
+    lldb::TargetSP target_sp;
+    lldb::ProcessSP process_sp;
+    lldb::StackFrameSP frame_sp;
+    
+    return LockAndCheckContext(exe_ctx, target_sp, process_sp, frame_sp);
 }
 
 // This is a really nasty hack, meant to fix Objective-C expressions of the form
@@ -238,7 +425,7 @@ ClangUserExpression::Parse (Stream &erro
                             lldb_private::ExecutionPolicy execution_policy,
                             bool keep_result_in_memory)
 {
-    lldb::LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
+    Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
     
     Error err;
  
@@ -260,7 +447,7 @@ ClangUserExpression::Parse (Stream &erro
     ApplyObjcCastHack(m_expr_text);
     //ApplyUnicharHack(m_expr_text);
 
-    std::auto_ptr <ExpressionSourceCode> source_code (ExpressionSourceCode::CreateWrapped(m_expr_prefix.c_str(), m_expr_text.c_str()));
+    std::unique_ptr<ExpressionSourceCode> source_code (ExpressionSourceCode::CreateWrapped(m_expr_prefix.c_str(), m_expr_text.c_str()));
     
     lldb::LanguageType lang_type;
     
@@ -296,9 +483,11 @@ ClangUserExpression::Parse (Stream &erro
     // Parse the expression
     //
         
+    m_materializer_ap.reset(new Materializer());
+        
     m_expr_decl_map.reset(new ClangExpressionDeclMap(keep_result_in_memory, exe_ctx));
     
-    if (!m_expr_decl_map->WillParse(exe_ctx))
+    if (!m_expr_decl_map->WillParse(exe_ctx, m_materializer_ap.get()))
     {
         error_stream.PutCString ("error: current process state is unsuitable for expression parsing\n");
         return false;
@@ -326,31 +515,18 @@ ClangUserExpression::Parse (Stream &erro
     //////////////////////////////////////////////////////////////////////////////////////////
     // Prepare the output of the parser for execution, evaluating it statically if possible
     //
-        
-    if (execution_policy != eExecutionPolicyNever && process)
-        m_data_allocator.reset(new ProcessDataAllocator(*process));
-    
-    Error jit_error = parser.PrepareForExecution (m_jit_alloc,
-                                                  m_jit_start_addr,
+            
+    Error jit_error = parser.PrepareForExecution (m_jit_start_addr,
                                                   m_jit_end_addr,
+                                                  m_execution_unit_ap,
                                                   exe_ctx,
-                                                  m_data_allocator.get(),
-                                                  m_evaluated_statically,
-                                                  m_const_result,
+                                                  m_can_interpret,
                                                   execution_policy);
-    
-    if (log && m_data_allocator.get())
-    {
-        StreamString dump_string;
-        m_data_allocator->Dump(dump_string);
-        
-        log->Printf("Data buffer contents:\n%s", dump_string.GetString().c_str());
-    }
         
     if (jit_error.Success())
     {
-        if (process && m_jit_alloc != LLDB_INVALID_ADDRESS)
-            m_jit_process_sp = process->shared_from_this();        
+        if (process && m_jit_start_addr != LLDB_INVALID_ADDRESS)
+            m_jit_process_wp = lldb::ProcessWP(process->shared_from_this());
         return true;
     }
     else
@@ -364,6 +540,46 @@ ClangUserExpression::Parse (Stream &erro
     }
 }
 
+static lldb::addr_t
+GetObjectPointer (lldb::StackFrameSP frame_sp,
+                  ConstString &object_name,
+                  Error &err)
+{
+    err.Clear();
+    
+    if (!frame_sp)
+    {
+        err.SetErrorStringWithFormat("Couldn't load '%s' because the context is incomplete", object_name.AsCString());
+        return LLDB_INVALID_ADDRESS;
+    }
+    
+    lldb::VariableSP var_sp;
+    lldb::ValueObjectSP valobj_sp;
+    
+    valobj_sp = frame_sp->GetValueForVariableExpressionPath(object_name.AsCString(),
+                                                            lldb::eNoDynamicValues,
+                                                            StackFrame::eExpressionPathOptionCheckPtrVsMember ||
+                                                            StackFrame::eExpressionPathOptionsAllowDirectIVarAccess ||
+                                                            StackFrame::eExpressionPathOptionsNoFragileObjcIvar ||
+                                                            StackFrame::eExpressionPathOptionsNoSyntheticChildren ||
+                                                            StackFrame::eExpressionPathOptionsNoSyntheticArrayRange,
+                                                            var_sp,
+                                                            err);
+    
+    if (!err.Success())
+        return LLDB_INVALID_ADDRESS;
+    
+    lldb::addr_t ret = valobj_sp->GetValueAsUnsigned(LLDB_INVALID_ADDRESS);
+    
+    if (ret == LLDB_INVALID_ADDRESS)
+    {
+        err.SetErrorStringWithFormat("Couldn't load '%s' because its value couldn't be evaluated", object_name.AsCString());
+        return LLDB_INVALID_ADDRESS;
+    }
+    
+    return ret;
+}
+
 bool
 ClangUserExpression::PrepareToExecuteJITExpression (Stream &error_stream,
                                                     ExecutionContext &exe_ctx,
@@ -371,8 +587,6 @@ ClangUserExpression::PrepareToExecuteJIT
                                                     lldb::addr_t &object_ptr,
                                                     lldb::addr_t &cmd_ptr)
 {
-    lldb::LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
-
     lldb::TargetSP target;
     lldb::ProcessSP process;
     lldb::StackFrameSP frame;
@@ -382,14 +596,12 @@ ClangUserExpression::PrepareToExecuteJIT
                              process, 
                              frame))
     {
-        error_stream.Printf("The context has changed before we could JIT the expression!");
+        error_stream.Printf("The context has changed before we could JIT the expression!\n");
         return false;
     }
     
-    if (m_jit_start_addr != LLDB_INVALID_ADDRESS)
-    {
-        Error materialize_error;
-        
+    if (m_jit_start_addr != LLDB_INVALID_ADDRESS || m_can_interpret)
+    {        
         if (m_needs_object_ptr)
         {
             ConstString object_name;
@@ -408,9 +620,13 @@ ClangUserExpression::PrepareToExecuteJIT
                 return false;
             }
             
-            if (!(m_expr_decl_map->GetObjectPointer(object_ptr, object_name, materialize_error)))
+            Error object_ptr_error;
+            
+            object_ptr = GetObjectPointer(frame, object_name, object_ptr_error);
+            
+            if (!object_ptr_error.Success())
             {
-                error_stream.Printf("warning: couldn't get required object pointer (substituting NULL): %s\n", materialize_error.AsCString());
+                error_stream.Printf("warning: couldn't get required object pointer (substituting NULL): %s\n", object_ptr_error.AsCString());
                 object_ptr = 0;
             }
             
@@ -418,53 +634,67 @@ ClangUserExpression::PrepareToExecuteJIT
             {
                 ConstString cmd_name("_cmd");
                 
-                if (!(m_expr_decl_map->GetObjectPointer(cmd_ptr, cmd_name, materialize_error, true)))
+                cmd_ptr = GetObjectPointer(frame, cmd_name, object_ptr_error);
+                
+                if (!object_ptr_error.Success())
                 {
-                    error_stream.Printf("warning: couldn't get object pointer (substituting NULL): %s\n", materialize_error.AsCString());
+                    error_stream.Printf("warning: couldn't get cmd pointer (substituting NULL): %s\n", object_ptr_error.AsCString());
                     cmd_ptr = 0;
                 }
             }
         }
-                
-        if (!m_expr_decl_map->Materialize(struct_address, materialize_error))
-        {
-            error_stream.Printf("Couldn't materialize struct: %s\n", materialize_error.AsCString());
-            return false;
-        }
-
-#if 0
-		// jingham: look here
-        StreamFile logfile ("/tmp/exprs.txt", "a");
-        logfile.Printf("0x%16.16llx: thread = 0x%4.4x, expr = '%s'\n", m_jit_start_addr, exe_ctx.thread ? exe_ctx.thread->GetID() : -1, m_expr_text.c_str());
-#endif
         
-        if (log)
+        if (m_materialized_address == LLDB_INVALID_ADDRESS)
         {
-            log->Printf("-- [ClangUserExpression::PrepareToExecuteJITExpression] Materializing for execution --");
+            Error alloc_error;
             
-            log->Printf("  Function address  : 0x%llx", (uint64_t)m_jit_start_addr);
+            IRMemoryMap::AllocationPolicy policy = m_can_interpret ? IRMemoryMap::eAllocationPolicyHostOnly : IRMemoryMap::eAllocationPolicyMirror;
             
-            if (m_needs_object_ptr)
-                log->Printf("  Object pointer    : 0x%llx", (uint64_t)object_ptr);
+            m_materialized_address = m_execution_unit_ap->Malloc(m_materializer_ap->GetStructByteSize(),
+                                                                 m_materializer_ap->GetStructAlignment(),
+                                                                 lldb::ePermissionsReadable | lldb::ePermissionsWritable,
+                                                                 policy,
+                                                                 alloc_error);
             
-            log->Printf("  Structure address : 0x%llx", (uint64_t)struct_address);
-                    
-            StreamString args;
+            if (!alloc_error.Success())
+            {
+                error_stream.Printf("Couldn't allocate space for materialized struct: %s\n", alloc_error.AsCString());
+                return false;
+            }
+        }
+        
+        struct_address = m_materialized_address;
+        
+        if (m_can_interpret && m_stack_frame_bottom == LLDB_INVALID_ADDRESS)
+        {
+            Error alloc_error;
+
+            const size_t stack_frame_size = 512 * 1024;
+            
+            m_stack_frame_bottom = m_execution_unit_ap->Malloc(stack_frame_size,
+                                                               8,
+                                                               lldb::ePermissionsReadable | lldb::ePermissionsWritable,
+                                                               IRMemoryMap::eAllocationPolicyHostOnly,
+                                                               alloc_error);
             
-            Error dump_error;
+            m_stack_frame_top = m_stack_frame_bottom + stack_frame_size;
             
-            if (struct_address)
+            if (!alloc_error.Success())
             {
-                if (!m_expr_decl_map->DumpMaterializedStruct(args, dump_error))
-                {
-                    log->Printf("  Couldn't extract variable values : %s", dump_error.AsCString("unknown error"));
-                }
-                else
-                {
-                    log->Printf("  Structure contents:\n%s", args.GetData());
-                }
+                error_stream.Printf("Couldn't allocate space for the stack frame: %s\n", alloc_error.AsCString());
+                return false;
             }
         }
+                
+        Error materialize_error;
+        
+        m_dematerializer_sp = m_materializer_ap->Materialize(frame, *m_execution_unit_ap, struct_address, materialize_error);
+        
+        if (!materialize_error.Success())
+        {
+            error_stream.Printf("Couldn't materialize struct: %s\n", materialize_error.AsCString());
+            return false;
+        }
     }
     return true;
 }
@@ -484,12 +714,16 @@ ClangUserExpression::GetThreadPlanToExec
     // ClangUserExpression resources before the thread plan finishes execution in the target.  But because we are 
     // forcing unwind_on_error to be true here, in practical terms that can't happen.
     
+    const bool stop_others = true;
+    const bool unwind_on_error = true;
+    const bool ignore_breakpoints = false;
     return ClangFunction::GetThreadPlanToCallFunction (exe_ctx, 
                                                        m_jit_start_addr, 
                                                        struct_address, 
                                                        error_stream,
-                                                       true,
-                                                       true, 
+                                                       stop_others,
+                                                       unwind_on_error,
+                                                       ignore_breakpoints,
                                                        (m_needs_object_ptr ? &object_ptr : NULL),
                                                        (m_needs_object_ptr && m_objectivec) ? &cmd_ptr : NULL);
 }
@@ -498,139 +732,196 @@ bool
 ClangUserExpression::FinalizeJITExecution (Stream &error_stream,
                                            ExecutionContext &exe_ctx,
                                            lldb::ClangExpressionVariableSP &result,
-                                           lldb::addr_t function_stack_pointer)
+                                           lldb::addr_t function_stack_bottom,
+                                           lldb::addr_t function_stack_top)
 {
     Error expr_error;
     
-    lldb::LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
+    Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
     
     if (log)
-    {
         log->Printf("-- [ClangUserExpression::FinalizeJITExecution] Dematerializing after execution --");
-    
-        StreamString args;
-        
-        Error dump_error;
         
-        if (!m_expr_decl_map->DumpMaterializedStruct(args, dump_error))
-        {
-            log->Printf("  Couldn't extract variable values : %s", dump_error.AsCString("unknown error"));
-        }
-        else
-        {
-            log->Printf("  Structure contents:\n%s", args.GetData());
-        }
+    if (!m_dematerializer_sp)
+    {
+        error_stream.Printf ("Couldn't dematerialize struct : no dematerializer is present");
+        return false;
     }
     
-    lldb::addr_t function_stack_bottom = function_stack_pointer - Host::GetPageSize();
+    Error dematerialize_error;
     
-        
-    if (!m_expr_decl_map->Dematerialize(result, function_stack_pointer, function_stack_bottom, expr_error))
+    m_dematerializer_sp->Dematerialize(dematerialize_error, result, function_stack_bottom, function_stack_top);
+
+    if (!dematerialize_error.Success())
     {
         error_stream.Printf ("Couldn't dematerialize struct : %s\n", expr_error.AsCString("unknown error"));
         return false;
     }
-    
+        
     if (result)
         result->TransferAddress();
     
+    m_dematerializer_sp.reset();
+    
     return true;
 }        
 
 ExecutionResults
 ClangUserExpression::Execute (Stream &error_stream,
                               ExecutionContext &exe_ctx,
-                              bool discard_on_error,
+                              bool unwind_on_error,
+                              bool ignore_breakpoints,
                               ClangUserExpression::ClangUserExpressionSP &shared_ptr_to_me,
                               lldb::ClangExpressionVariableSP &result,
-                              uint32_t single_thread_timeout_usec)
+                              bool run_others,
+                              uint32_t timeout_usec)
 {
     // The expression log is quite verbose, and if you're just tracking the execution of the
     // expression, it's quite convenient to have these logs come out with the STEP log as well.
-    lldb::LogSP log(lldb_private::GetLogIfAnyCategoriesSet (LIBLLDB_LOG_EXPRESSIONS | LIBLLDB_LOG_STEP));
+    Log *log(lldb_private::GetLogIfAnyCategoriesSet (LIBLLDB_LOG_EXPRESSIONS | LIBLLDB_LOG_STEP));
 
-    if (m_jit_start_addr != LLDB_INVALID_ADDRESS)
+    if (m_jit_start_addr != LLDB_INVALID_ADDRESS || m_can_interpret)
     {
-        lldb::addr_t struct_address;
+        lldb::addr_t struct_address = LLDB_INVALID_ADDRESS;
                 
         lldb::addr_t object_ptr = 0;
         lldb::addr_t cmd_ptr = 0;
         
         if (!PrepareToExecuteJITExpression (error_stream, exe_ctx, struct_address, object_ptr, cmd_ptr))
+        {
+            error_stream.Printf("Errored out in %s, couldn't PrepareToExecuteJITExpression", __FUNCTION__);
             return eExecutionSetupError;
+        }
         
-        const bool stop_others = true;
-        const bool try_all_threads = true;
-        
-        Address wrapper_address (m_jit_start_addr);
-        lldb::ThreadPlanSP call_plan_sp(new ThreadPlanCallUserExpression (exe_ctx.GetThreadRef(), 
-                                                                          wrapper_address, 
-                                                                          struct_address, 
-                                                                          stop_others, 
-                                                                          discard_on_error, 
-                                                                          (m_needs_object_ptr ? &object_ptr : NULL),
-                                                                          ((m_needs_object_ptr && m_objectivec) ? &cmd_ptr : NULL),
-                                                                          shared_ptr_to_me));
-        
-        if (!call_plan_sp || !call_plan_sp->ValidatePlan (NULL))
-            return eExecutionSetupError;
-        
-        lldb::addr_t function_stack_pointer = static_cast<ThreadPlanCallFunction *>(call_plan_sp.get())->GetFunctionStackPointer();
-    
-        call_plan_sp->SetPrivate(true);
-    
-        if (log)
-            log->Printf("-- [ClangUserExpression::Execute] Execution of expression begins --");
+        lldb::addr_t function_stack_bottom = LLDB_INVALID_ADDRESS;
+        lldb::addr_t function_stack_top = LLDB_INVALID_ADDRESS;
         
-        if (exe_ctx.GetProcessPtr())
-            exe_ctx.GetProcessPtr()->SetRunningUserExpression(true);
+        if (m_can_interpret)
+        {            
+            llvm::Module *module = m_execution_unit_ap->GetModule();
+            llvm::Function *function = m_execution_unit_ap->GetFunction();
             
-        ExecutionResults execution_result = exe_ctx.GetProcessRef().RunThreadPlan (exe_ctx, 
-                                                                                   call_plan_sp, 
-                                                                                   stop_others, 
-                                                                                   try_all_threads, 
-                                                                                   discard_on_error,
-                                                                                   single_thread_timeout_usec, 
-                                                                                   error_stream);
-        
-        if (exe_ctx.GetProcessPtr())
-            exe_ctx.GetProcessPtr()->SetRunningUserExpression(false);
-            
-        if (log)
-            log->Printf("-- [ClangUserExpression::Execute] Execution of expression completed --");
+            if (!module || !function)
+            {
+                error_stream.Printf("Supposed to interpret, but nothing is there");
+                return eExecutionSetupError;
+            }
 
-        if (execution_result == eExecutionInterrupted)
-        {
-            const char *error_desc = NULL;
+            Error interpreter_error;
+            
+            llvm::SmallVector <lldb::addr_t, 3> args;
             
-            if (call_plan_sp)
+            if (m_needs_object_ptr)
             {
-                lldb::StopInfoSP real_stop_info_sp = call_plan_sp->GetRealStopInfo();
-                if (real_stop_info_sp)
-                    error_desc = real_stop_info_sp->GetDescription();
-            }
-            if (error_desc)
-                error_stream.Printf ("Execution was interrupted, reason: %s.", error_desc);
-            else
-                error_stream.Printf ("Execution was interrupted.");
+                args.push_back(object_ptr);
                 
-            if (discard_on_error)
-                error_stream.Printf ("\nThe process has been returned to the state before execution.");
-            else
-                error_stream.Printf ("\nThe process has been left at the point where it was interrupted.");
-
-            return execution_result;
+                if (m_objectivec)
+                    args.push_back(cmd_ptr);
+            }
+            
+            args.push_back(struct_address);
+            
+            function_stack_bottom = m_stack_frame_bottom;
+            function_stack_top = m_stack_frame_top;
+            
+            IRInterpreter::Interpret (*module,
+                                      *function,
+                                      args,
+                                      *m_execution_unit_ap.get(),
+                                      interpreter_error,
+                                      function_stack_bottom,
+                                      function_stack_top);
+            
+            if (!interpreter_error.Success())
+            {
+                error_stream.Printf("Supposed to interpret, but failed: %s", interpreter_error.AsCString());
+                return eExecutionDiscarded;
+            }
         }
-        else if (execution_result != eExecutionCompleted)
+        else
         {
-            error_stream.Printf ("Couldn't execute function; result was %s\n", Process::ExecutionResultAsCString (execution_result));
-            return execution_result;
+            const bool stop_others = true;
+            const bool try_all_threads = run_others;
+            
+            Address wrapper_address (m_jit_start_addr);
+            lldb::ThreadPlanSP call_plan_sp(new ThreadPlanCallUserExpression (exe_ctx.GetThreadRef(), 
+                                                                              wrapper_address, 
+                                                                              struct_address, 
+                                                                              stop_others, 
+                                                                              unwind_on_error,
+                                                                              ignore_breakpoints,
+                                                                              (m_needs_object_ptr ? &object_ptr : NULL),
+                                                                              ((m_needs_object_ptr && m_objectivec) ? &cmd_ptr : NULL),
+                                                                              shared_ptr_to_me));
+            
+            if (!call_plan_sp || !call_plan_sp->ValidatePlan (&error_stream))
+                return eExecutionSetupError;
+            
+            lldb::addr_t function_stack_pointer = static_cast<ThreadPlanCallFunction *>(call_plan_sp.get())->GetFunctionStackPointer();
+
+            function_stack_bottom = function_stack_pointer - Host::GetPageSize();
+            function_stack_top = function_stack_pointer;
+            
+            if (log)
+                log->Printf("-- [ClangUserExpression::Execute] Execution of expression begins --");
+            
+            if (exe_ctx.GetProcessPtr())
+                exe_ctx.GetProcessPtr()->SetRunningUserExpression(true);
+                
+            ExecutionResults execution_result = exe_ctx.GetProcessRef().RunThreadPlan (exe_ctx, 
+                                                                                       call_plan_sp, 
+                                                                                       stop_others, 
+                                                                                       try_all_threads, 
+                                                                                       unwind_on_error,
+                                                                                       ignore_breakpoints,
+                                                                                       timeout_usec, 
+                                                                                       error_stream);
+            
+            if (exe_ctx.GetProcessPtr())
+                exe_ctx.GetProcessPtr()->SetRunningUserExpression(false);
+                
+            if (log)
+                log->Printf("-- [ClangUserExpression::Execute] Execution of expression completed --");
+
+            if (execution_result == eExecutionInterrupted || execution_result == eExecutionHitBreakpoint)
+            {
+                const char *error_desc = NULL;
+                
+                if (call_plan_sp)
+                {
+                    lldb::StopInfoSP real_stop_info_sp = call_plan_sp->GetRealStopInfo();
+                    if (real_stop_info_sp)
+                        error_desc = real_stop_info_sp->GetDescription();
+                }
+                if (error_desc)
+                    error_stream.Printf ("Execution was interrupted, reason: %s.", error_desc);
+                else
+                    error_stream.Printf ("Execution was interrupted.");
+                    
+                if ((execution_result == eExecutionInterrupted && unwind_on_error)
+                    || (execution_result == eExecutionHitBreakpoint && ignore_breakpoints))
+                    error_stream.Printf ("\nThe process has been returned to the state before expression evaluation.");
+                else
+                    error_stream.Printf ("\nThe process has been left at the point where it was interrupted, use \"thread return -x\" to return to the state before expression evaluation.");
+
+                return execution_result;
+            }
+            else if (execution_result != eExecutionCompleted)
+            {
+                error_stream.Printf ("Couldn't execute function; result was %s\n", Process::ExecutionResultAsCString (execution_result));
+                return execution_result;
+            }
         }
         
-        if  (FinalizeJITExecution (error_stream, exe_ctx, result, function_stack_pointer))
+        if  (FinalizeJITExecution (error_stream, exe_ctx, result, function_stack_bottom, function_stack_top))
+        {
             return eExecutionCompleted;
+        }
         else
+        {
+            error_stream.Printf("Errored out in %s: Couldn't FinalizeJITExpression", __FUNCTION__);
             return eExecutionSetupError;
+        }
     }
     else
     {
@@ -644,14 +935,27 @@ ClangUserExpression::Evaluate (Execution
                                lldb_private::ExecutionPolicy execution_policy,
                                lldb::LanguageType language,
                                ResultType desired_type,
-                               bool discard_on_error,
+                               bool unwind_on_error,
+                               bool ignore_breakpoints,
                                const char *expr_cstr,
                                const char *expr_prefix,
                                lldb::ValueObjectSP &result_valobj_sp,
-                               uint32_t single_thread_timeout_usec)
+                               bool run_others,
+                               uint32_t timeout_usec)
 {
     Error error;
-    return EvaluateWithError (exe_ctx, execution_policy, language, desired_type, discard_on_error, expr_cstr, expr_prefix, result_valobj_sp, error, single_thread_timeout_usec);
+    return EvaluateWithError (exe_ctx,
+                              execution_policy,
+                              language,
+                              desired_type,
+                              unwind_on_error,
+                              ignore_breakpoints,
+                              expr_cstr,
+                              expr_prefix,
+                              result_valobj_sp,
+                              error,
+                              run_others,
+                              timeout_usec);
 }
 
 ExecutionResults
@@ -659,14 +963,16 @@ ClangUserExpression::EvaluateWithError (
                                         lldb_private::ExecutionPolicy execution_policy,
                                         lldb::LanguageType language,
                                         ResultType desired_type,
-                                        bool discard_on_error,
+                                        bool unwind_on_error,
+                                        bool ignore_breakpoints,
                                         const char *expr_cstr,
                                         const char *expr_prefix,
                                         lldb::ValueObjectSP &result_valobj_sp,
                                         Error &error,
-                                        uint32_t single_thread_timeout_usec)
+                                        bool run_others,
+                                        uint32_t timeout_usec)
 {
-    lldb::LogSP log(lldb_private::GetLogIfAnyCategoriesSet (LIBLLDB_LOG_EXPRESSIONS | LIBLLDB_LOG_STEP));
+    Log *log(lldb_private::GetLogIfAnyCategoriesSet (LIBLLDB_LOG_EXPRESSIONS | LIBLLDB_LOG_STEP));
 
     ExecutionResults execution_results = eExecutionSetupError;
     
@@ -708,19 +1014,8 @@ ClangUserExpression::EvaluateWithError (
     {
         lldb::ClangExpressionVariableSP expr_result;
 
-        if (user_expression_sp->EvaluatedStatically())
-        {
-            if (log)
-                log->Printf("== [ClangUserExpression::Evaluate] Expression evaluated as a constant ==");
-            
-            if (user_expression_sp->m_const_result)
-                result_valobj_sp = user_expression_sp->m_const_result->GetValueObject();
-            else
-                error.SetError(ClangUserExpression::kNoResult, lldb::eErrorTypeGeneric);
-            
-            execution_results = eExecutionCompleted;
-        }
-        else if (execution_policy == eExecutionPolicyNever)
+        if (execution_policy == eExecutionPolicyNever &&
+            !user_expression_sp->CanInterpret())
         {
             if (log)
                 log->Printf("== [ClangUserExpression::Evaluate] Expression may not run, but is not constant ==");
@@ -737,10 +1032,12 @@ ClangUserExpression::EvaluateWithError (
 
             execution_results = user_expression_sp->Execute (error_stream, 
                                                              exe_ctx, 
-                                                             discard_on_error,
+                                                             unwind_on_error,
+                                                             ignore_breakpoints,
                                                              user_expression_sp, 
                                                              expr_result,
-                                                             single_thread_timeout_usec);
+                                                             run_others,
+                                                             timeout_usec);
             
             if (execution_results != eExecutionCompleted)
             {

Modified: lldb/branches/lldb-platform-work/source/Expression/ClangUtilityFunction.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/lldb-platform-work/source/Expression/ClangUtilityFunction.cpp?rev=183468&r1=183467&r2=183468&view=diff
==============================================================================
--- lldb/branches/lldb-platform-work/source/Expression/ClangUtilityFunction.cpp (original)
+++ lldb/branches/lldb-platform-work/source/Expression/ClangUtilityFunction.cpp Thu Jun  6 19:06:43 2013
@@ -22,6 +22,8 @@
 #include "lldb/Expression/ClangExpressionDeclMap.h"
 #include "lldb/Expression/ClangExpressionParser.h"
 #include "lldb/Expression/ClangUtilityFunction.h"
+#include "lldb/Expression/ExpressionSourceCode.h"
+#include "lldb/Expression/IRExecutionUnit.h"
 #include "lldb/Host/Host.h"
 #include "lldb/Target/ExecutionContext.h"
 #include "lldb/Target/Target.h"
@@ -40,9 +42,11 @@ using namespace lldb_private;
 ClangUtilityFunction::ClangUtilityFunction (const char *text, 
                                             const char *name) :
     ClangExpression (),
-    m_function_text (text),
+    m_function_text (ExpressionSourceCode::g_expression_prefix),
     m_function_name (name)
 {
+    if (text && text[0])
+        m_function_text.append (text);
 }
 
 ClangUtilityFunction::~ClangUtilityFunction ()
@@ -65,8 +69,6 @@ bool
 ClangUtilityFunction::Install (Stream &error_stream,
                                ExecutionContext &exe_ctx)
 {
-    lldb::LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
-    
     if (m_jit_start_addr != LLDB_INVALID_ADDRESS)
     {
         error_stream.PutCString("error: already installed\n");
@@ -101,9 +103,7 @@ ClangUtilityFunction::Install (Stream &e
     
     m_expr_decl_map.reset(new ClangExpressionDeclMap(keep_result_in_memory, exe_ctx));
     
-    m_data_allocator.reset(new ProcessDataAllocator(*process));
-    
-    if (!m_expr_decl_map->WillParse(exe_ctx))
+    if (!m_expr_decl_map->WillParse(exe_ctx, NULL))
     {
         error_stream.PutCString ("error: current process state is unsuitable for expression parsing\n");
         return false;
@@ -125,35 +125,23 @@ ClangUtilityFunction::Install (Stream &e
     //////////////////////////////////
     // JIT the output of the parser
     //
+        
+    bool can_interpret = false; // should stay that way
     
-    lldb::ClangExpressionVariableSP const_result;
-    
-    bool evaluated_statically = false; // should stay that way
-    
-    Error jit_error = parser.PrepareForExecution (m_jit_alloc, 
-                                                  m_jit_start_addr, 
-                                                  m_jit_end_addr, 
+    Error jit_error = parser.PrepareForExecution (m_jit_start_addr, 
+                                                  m_jit_end_addr,
+                                                  m_execution_unit_ap,
                                                   exe_ctx,
-                                                  m_data_allocator.get(),
-                                                  evaluated_statically,
-                                                  const_result,
+                                                  can_interpret,
                                                   eExecutionPolicyAlways);
     
-    if (log)
-    {
-        StreamString dump_string;
-        m_data_allocator->Dump(dump_string);
-        
-        log->Printf("Data buffer contents:\n%s", dump_string.GetString().c_str());
-    }
-    
     if (m_jit_start_addr != LLDB_INVALID_ADDRESS)
-        m_jit_process_sp = process->shared_from_this();
+        m_jit_process_wp = lldb::ProcessWP(process->shared_from_this());
     
 #if 0
 	// jingham: look here
     StreamFile logfile ("/tmp/exprs.txt", "a");
-    logfile.Printf ("0x%16.16llx: func = %s, source =\n%s\n", 
+    logfile.Printf ("0x%16.16" PRIx64 ": func = %s, source =\n%s\n",
                     m_jit_start_addr, 
                     m_function_name.c_str(), 
                     m_function_text.c_str());

Modified: lldb/branches/lldb-platform-work/source/Expression/DWARFExpression.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/lldb-platform-work/source/Expression/DWARFExpression.cpp?rev=183468&r1=183467&r2=183468&view=diff
==============================================================================
--- lldb/branches/lldb-platform-work/source/Expression/DWARFExpression.cpp (original)
+++ lldb/branches/lldb-platform-work/source/Expression/DWARFExpression.cpp Thu Jun  6 19:06:43 2013
@@ -233,7 +233,7 @@ DWARFExpression::DWARFExpression(const D
 }
 
 
-DWARFExpression::DWARFExpression(const DataExtractor& data, uint32_t data_offset, uint32_t data_length) :
+DWARFExpression::DWARFExpression(const DataExtractor& data, lldb::offset_t data_offset, lldb::offset_t data_length) :
     m_data(data, data_offset, data_length),
     m_reg_kind (eRegisterKindDWARF),
     m_loclist_slide(LLDB_INVALID_ADDRESS)
@@ -261,7 +261,7 @@ DWARFExpression::SetOpcodeData (const Da
 }
 
 void
-DWARFExpression::CopyOpcodeData (const DataExtractor& data, uint32_t data_offset, uint32_t data_length)
+DWARFExpression::CopyOpcodeData (const DataExtractor& data, lldb::offset_t data_offset, lldb::offset_t data_length)
 {
     const uint8_t *bytes = data.PeekData(data_offset, data_length);
     if (bytes)
@@ -273,21 +273,21 @@ DWARFExpression::CopyOpcodeData (const D
 }
 
 void
-DWARFExpression::SetOpcodeData (const DataExtractor& data, uint32_t data_offset, uint32_t data_length)
+DWARFExpression::SetOpcodeData (const DataExtractor& data, lldb::offset_t data_offset, lldb::offset_t data_length)
 {
     m_data.SetData(data, data_offset, data_length);
 }
 
 void
-DWARFExpression::DumpLocation (Stream *s, uint32_t offset, uint32_t length, lldb::DescriptionLevel level, ABI *abi) const
+DWARFExpression::DumpLocation (Stream *s, lldb::offset_t offset, lldb::offset_t length, lldb::DescriptionLevel level, ABI *abi) const
 {
     if (!m_data.ValidOffsetForDataOfSize(offset, length))
         return;
-    const uint32_t start_offset = offset;
-    const uint32_t end_offset = offset + length;
+    const lldb::offset_t start_offset = offset;
+    const lldb::offset_t end_offset = offset + length;
     while (m_data.ValidOffset(offset) && offset < end_offset)
     {
-        const uint32_t op_offset = offset;
+        const lldb::offset_t op_offset = offset;
         const uint8_t op = m_data.GetU8(&offset);
 
         switch (level)
@@ -308,7 +308,7 @@ DWARFExpression::DumpLocation (Stream *s
             if (level == lldb::eDescriptionLevelFull)
                 break;
             // Fall through for verbose and print offset and DW_OP prefix..
-            s->Printf("0x%8.8x: %s", op_offset, op >= DW_OP_APPLE_uninit ? "DW_OP_APPLE_" : "DW_OP_");
+            s->Printf("0x%8.8" PRIx64 ": %s", op_offset, op >= DW_OP_APPLE_uninit ? "DW_OP_APPLE_" : "DW_OP_");
             break;
         }
 
@@ -322,10 +322,10 @@ DWARFExpression::DumpLocation (Stream *s
         case DW_OP_const2s: s->Printf("DW_OP_const2s(0x%4.4x) ", m_data.GetU16(&offset)); break;      // 0x0b 1 2-byte constant
         case DW_OP_const4u: s->Printf("DW_OP_const4u(0x%8.8x) ", m_data.GetU32(&offset)); break;      // 0x0c 1 4-byte constant
         case DW_OP_const4s: s->Printf("DW_OP_const4s(0x%8.8x) ", m_data.GetU32(&offset)); break;      // 0x0d 1 4-byte constant
-        case DW_OP_const8u: s->Printf("DW_OP_const8u(0x%16.16llx) ", m_data.GetU64(&offset)); break;  // 0x0e 1 8-byte constant
-        case DW_OP_const8s: s->Printf("DW_OP_const8s(0x%16.16llx) ", m_data.GetU64(&offset)); break;  // 0x0f 1 8-byte constant
-        case DW_OP_constu:  s->Printf("DW_OP_constu(0x%llx) ", m_data.GetULEB128(&offset)); break;    // 0x10 1 ULEB128 constant
-        case DW_OP_consts:  s->Printf("DW_OP_consts(0x%lld) ", m_data.GetSLEB128(&offset)); break;    // 0x11 1 SLEB128 constant
+        case DW_OP_const8u: s->Printf("DW_OP_const8u(0x%16.16" PRIx64 ") ", m_data.GetU64(&offset)); break;  // 0x0e 1 8-byte constant
+        case DW_OP_const8s: s->Printf("DW_OP_const8s(0x%16.16" PRIx64 ") ", m_data.GetU64(&offset)); break;  // 0x0f 1 8-byte constant
+        case DW_OP_constu:  s->Printf("DW_OP_constu(0x%" PRIx64 ") ", m_data.GetULEB128(&offset)); break;    // 0x10 1 ULEB128 constant
+        case DW_OP_consts:  s->Printf("DW_OP_consts(0x%" PRId64 ") ", m_data.GetSLEB128(&offset)); break;    // 0x11 1 SLEB128 constant
         case DW_OP_dup:     s->PutCString("DW_OP_dup"); break;                                        // 0x12
         case DW_OP_drop:    s->PutCString("DW_OP_drop"); break;                                       // 0x13
         case DW_OP_over:    s->PutCString("DW_OP_over"); break;                                       // 0x14
@@ -344,7 +344,7 @@ DWARFExpression::DumpLocation (Stream *s
         case DW_OP_or:      s->PutCString("DW_OP_or"); break;                                         // 0x21
         case DW_OP_plus:    s->PutCString("DW_OP_plus"); break;                                       // 0x22
         case DW_OP_plus_uconst:                                                                 // 0x23 1 ULEB128 addend
-            s->Printf("DW_OP_plus_uconst(0x%llx) ", m_data.GetULEB128(&offset));
+            s->Printf("DW_OP_plus_uconst(0x%" PRIx64 ") ", m_data.GetULEB128(&offset));
             break;
 
         case DW_OP_shl:     s->PutCString("DW_OP_shl"); break;                                        // 0x24
@@ -490,23 +490,23 @@ DWARFExpression::DumpLocation (Stream *s
                     {
                         if (reg_info.name)
                         {
-                            s->Printf("[%s%+lli]", reg_info.name, reg_offset); 
+                            s->Printf("[%s%+" PRIi64 "]", reg_info.name, reg_offset);
                             break;
                         }
                         else if (reg_info.alt_name)
                         {
-                            s->Printf("[%s%+lli]", reg_info.alt_name, reg_offset); 
+                            s->Printf("[%s%+" PRIi64 "]", reg_info.alt_name, reg_offset);
                             break;
                         }
                     }
                 }
-                s->Printf("DW_OP_breg%i(0x%llx)", reg_num, reg_offset); 
+                s->Printf("DW_OP_breg%i(0x%" PRIx64 ")", reg_num, reg_offset);
             }
             break;
 
         case DW_OP_regx:                                                    // 0x90 1 ULEB128 register
             {
-                uint64_t reg_num = m_data.GetULEB128(&offset);
+                uint32_t reg_num = m_data.GetULEB128(&offset);
                 if (abi)
                 {
                     RegisterInfo reg_info;
@@ -524,11 +524,11 @@ DWARFExpression::DumpLocation (Stream *s
                         }
                     }
                 }
-                s->Printf("DW_OP_regx(%llu)", reg_num); break; 
+                s->Printf("DW_OP_regx(%" PRIu32 ")", reg_num); break;
             }
             break;
         case DW_OP_fbreg:                                                   // 0x91 1 SLEB128 offset
-            s->Printf("DW_OP_fbreg(%lli)",m_data.GetSLEB128(&offset));
+            s->Printf("DW_OP_fbreg(%" PRIi64 ")",m_data.GetSLEB128(&offset));
             break;
         case DW_OP_bregx:                                                   // 0x92 2 ULEB128 register followed by SLEB128 offset
             {
@@ -541,21 +541,21 @@ DWARFExpression::DumpLocation (Stream *s
                     {
                         if (reg_info.name)
                         {
-                            s->Printf("[%s%+lli]", reg_info.name, reg_offset); 
+                            s->Printf("[%s%+" PRIi64 "]", reg_info.name, reg_offset);
                             break;
                         }
                         else if (reg_info.alt_name)
                         {
-                            s->Printf("[%s%+lli]", reg_info.alt_name, reg_offset); 
+                            s->Printf("[%s%+" PRIi64 "]", reg_info.alt_name, reg_offset);
                             break;
                         }
                     }
                 }
-                s->Printf("DW_OP_bregx(reg=%u,offset=%lli)", reg_num, reg_offset); 
+                s->Printf("DW_OP_bregx(reg=%" PRIu32 ",offset=%" PRIi64 ")", reg_num, reg_offset);
             }
             break;
         case DW_OP_piece:                                                   // 0x93 1 ULEB128 size of piece addressed
-            s->Printf("DW_OP_piece(0x%llx)", m_data.GetULEB128(&offset));
+            s->Printf("DW_OP_piece(0x%" PRIx64 ")", m_data.GetULEB128(&offset));
             break;
         case DW_OP_deref_size:                                              // 0x94 1 1-byte size of data retrieved
             s->Printf("DW_OP_deref_size(0x%2.2x)", m_data.GetU8(&offset));
@@ -572,7 +572,7 @@ DWARFExpression::DumpLocation (Stream *s
             s->Printf("DW_OP_call4(0x%8.8x)", m_data.GetU32(&offset));
             break;
         case DW_OP_call_ref:                                                // 0x9a DWARF3 1 4- or 8-byte offset of DIE
-            s->Printf("DW_OP_call_ref(0x%8.8llx)", m_data.GetAddress(&offset));
+            s->Printf("DW_OP_call_ref(0x%8.8" PRIx64 ")", m_data.GetAddress(&offset));
             break;
 //      case DW_OP_form_tls_address: s << "form_tls_address"; break;        // 0x9b DWARF3
 //      case DW_OP_call_frame_cfa: s << "call_frame_cfa"; break;            // 0x9c DWARF3
@@ -582,7 +582,7 @@ DWARFExpression::DumpLocation (Stream *s
 //      case DW_OP_lo_user:     s->PutCString("DW_OP_lo_user"); break;                        // 0xe0
 //      case DW_OP_hi_user:     s->PutCString("DW_OP_hi_user"); break;                        // 0xff
 //        case DW_OP_APPLE_extern:
-//            s->Printf("DW_OP_APPLE_extern(%llu)", m_data.GetULEB128(&offset));
+//            s->Printf("DW_OP_APPLE_extern(%" PRIu64 ")", m_data.GetULEB128(&offset));
 //            break;
 //        case DW_OP_APPLE_array_ref:
 //            s->PutCString("DW_OP_APPLE_array_ref");
@@ -603,7 +603,7 @@ DWARFExpression::DumpLocation (Stream *s
 //            s->PutCString("DW_OP_APPLE_deref_type");
 //            break;
 //        case DW_OP_APPLE_expr_local:    // 0xF5 - ULEB128 expression local index
-//            s->Printf("DW_OP_APPLE_expr_local(%llu)", m_data.GetULEB128(&offset));
+//            s->Printf("DW_OP_APPLE_expr_local(%" PRIu64 ")", m_data.GetULEB128(&offset));
 //            break;
 //        case DW_OP_APPLE_constf:        // 0xF6 - 1 byte float size, followed by constant float data
 //            {
@@ -664,7 +664,7 @@ DWARFExpression::GetDescription (Stream
     if (IsLocationList())
     {
         // We have a location list
-        uint32_t offset = 0;
+        lldb::offset_t offset = 0;
         uint32_t count = 0;
         addr_t curr_base_addr = location_list_base_addr;
         while (m_data.ValidOffset(offset))
@@ -678,7 +678,7 @@ DWARFExpression::GetDescription (Stream
                 VMRange addr_range(curr_base_addr + begin_addr_offset, curr_base_addr + end_addr_offset);
                 addr_range.Dump(s, 0, 8);
                 s->PutChar('{');
-                uint32_t location_length = m_data.GetU16(&offset);
+                lldb::offset_t location_length = m_data.GetU16(&offset);
                 DumpLocation (s, offset, location_length, level, abi);
                 s->PutChar('}');
                 offset += location_length;
@@ -782,7 +782,7 @@ ReadRegisterValueAsScalar
 //
 //    if (IsLocationList())
 //    {
-//        uint32_t offset = 0;
+//        lldb::offset_t offset = 0;
 //
 //        addr_t loc_list_base_addr = m_loclist_slide.GetLoadAddress(process);
 //
@@ -811,10 +811,10 @@ ReadRegisterValueAsScalar
 //    return false;
 //}
 
-static uint32_t
-GetOpcodeDataSize (const DataExtractor &data, const uint32_t data_offset, const uint8_t op)
+static offset_t
+GetOpcodeDataSize (const DataExtractor &data, const lldb::offset_t data_offset, const uint8_t op)
 {
-    uint32_t offset = data_offset;
+    lldb::offset_t offset = data_offset;
     switch (op)
     {
         case DW_OP_addr:    
@@ -1006,32 +1006,33 @@ GetOpcodeDataSize (const DataExtractor &
         default:
             break;
     }
-    return UINT32_MAX;
+    return LLDB_INVALID_OFFSET;
 }
 
-bool
-DWARFExpression::LocationContains_DW_OP_addr (lldb::addr_t file_addr, bool &error) const
+lldb::addr_t
+DWARFExpression::GetLocation_DW_OP_addr (uint32_t op_addr_idx, bool &error) const
 {
     error = false;
     if (IsLocationList())
-        return false;
-    uint32_t offset = 0;
+        return LLDB_INVALID_ADDRESS;
+    lldb::offset_t offset = 0;
+    uint32_t curr_op_addr_idx = 0;
     while (m_data.ValidOffset(offset))
     {
         const uint8_t op = m_data.GetU8(&offset);
         
         if (op == DW_OP_addr)
         {
-            if (file_addr == LLDB_INVALID_ADDRESS)
-                return true;
-            addr_t op_file_addr = m_data.GetAddress(&offset);
-            if (op_file_addr == file_addr)
-                return true;
+            const lldb::addr_t op_file_addr = m_data.GetAddress(&offset);
+            if (curr_op_addr_idx == op_addr_idx)
+                return op_file_addr;
+            else
+                ++curr_op_addr_idx;
         }
         else
         {
-            const uint32_t op_arg_size = GetOpcodeDataSize (m_data, offset, op);
-            if (op_arg_size == UINT32_MAX)
+            const offset_t op_arg_size = GetOpcodeDataSize (m_data, offset, op);
+            if (op_arg_size == LLDB_INVALID_OFFSET)
             {
                 error = true;
                 break;
@@ -1039,7 +1040,7 @@ DWARFExpression::LocationContains_DW_OP_
             offset += op_arg_size;
         }
     }
-    return false;
+    return LLDB_INVALID_ADDRESS;
 }
 
 bool
@@ -1047,22 +1048,22 @@ DWARFExpression::Update_DW_OP_addr (lldb
 {
     if (IsLocationList())
         return false;
-    uint32_t offset = 0;
+    lldb::offset_t offset = 0;
     while (m_data.ValidOffset(offset))
     {
         const uint8_t op = m_data.GetU8(&offset);
         
         if (op == DW_OP_addr)
         {
-            const uint8_t addr_byte_size = m_data.GetAddressByteSize();
+            const uint32_t addr_byte_size = m_data.GetAddressByteSize();
             // We have to make a copy of the data as we don't know if this
             // data is from a read only memory mapped buffer, so we duplicate
             // all of the data first, then modify it, and if all goes well,
             // we then replace the data for this expression
             
             // So first we copy the data into a heap buffer
-            std::auto_ptr<DataBufferHeap> head_data_ap (new DataBufferHeap (m_data.GetDataStart(), 
-                                                                            m_data.GetByteSize()));
+            std::unique_ptr<DataBufferHeap> head_data_ap (new DataBufferHeap (m_data.GetDataStart(),
+                                                                             m_data.GetByteSize()));
             
             // Make en encoder so we can write the address into the buffer using
             // the correct byte order (endianness)
@@ -1083,8 +1084,8 @@ DWARFExpression::Update_DW_OP_addr (lldb
         }
         else
         {
-            const uint32_t op_arg_size = GetOpcodeDataSize (m_data, offset, op);
-            if (op_arg_size == UINT32_MAX)
+            const offset_t op_arg_size = GetOpcodeDataSize (m_data, offset, op);
+            if (op_arg_size == LLDB_INVALID_OFFSET)
                 break;
             offset += op_arg_size;
         }
@@ -1100,7 +1101,7 @@ DWARFExpression::LocationListContainsAdd
 
     if (IsLocationList())
     {
-        uint32_t offset = 0;
+        lldb::offset_t offset = 0;
 
         if (loclist_base_addr == LLDB_INVALID_ADDRESS)
             return false;
@@ -1128,7 +1129,7 @@ DWARFExpression::LocationListContainsAdd
 }
 
 bool
-DWARFExpression::GetLocation (addr_t base_addr, addr_t pc, uint32_t &offset, uint32_t &length)
+DWARFExpression::GetLocation (addr_t base_addr, addr_t pc, lldb::offset_t &offset, lldb::offset_t &length)
 {
     offset = 0;
     if (!IsLocationList())
@@ -1164,7 +1165,7 @@ DWARFExpression::GetLocation (addr_t bas
             }
         }
     }
-    offset = UINT32_MAX;
+    offset = LLDB_INVALID_OFFSET;
     length = 0;
     return false;
 }
@@ -1176,8 +1177,8 @@ DWARFExpression::DumpLocationForAddress
                                          addr_t address,
                                          ABI *abi)
 {
-    uint32_t offset = 0;
-    uint32_t length = 0;
+    lldb::offset_t offset = 0;
+    lldb::offset_t length = 0;
     
     if (GetLocation (base_addr, address, offset, length))
     {
@@ -1223,7 +1224,7 @@ DWARFExpression::Evaluate
 {
     if (IsLocationList())
     {
-        uint32_t offset = 0;
+        lldb::offset_t offset = 0;
         addr_t pc;
         StackFrame *frame = NULL;
         if (reg_ctx)
@@ -1294,14 +1295,21 @@ DWARFExpression::Evaluate
     ClangExpressionDeclMap *decl_map,
     RegisterContext *reg_ctx,
     const DataExtractor& opcodes,
-    const uint32_t opcodes_offset,
-    const uint32_t opcodes_length,
+    const lldb::offset_t opcodes_offset,
+    const lldb::offset_t opcodes_length,
     const uint32_t reg_kind,
     const Value* initial_value_ptr,
     Value& result,
     Error *error_ptr
 )
 {
+    
+    if (opcodes_length == 0)
+    {
+        if (error_ptr)
+            error_ptr->SetErrorString ("no location, value may have been optimized out");
+        return false;
+    }
     std::vector<Value> stack;
 
     Process *process = NULL;
@@ -1318,8 +1326,8 @@ DWARFExpression::Evaluate
     if (initial_value_ptr)
         stack.push_back(*initial_value_ptr);
 
-    uint32_t offset = opcodes_offset;
-    const uint32_t end_offset = opcodes_offset + opcodes_length;
+    lldb::offset_t offset = opcodes_offset;
+    const lldb::offset_t end_offset = opcodes_offset + opcodes_length;
     Value tmp;
     uint32_t reg_num;
 
@@ -1327,15 +1335,15 @@ DWARFExpression::Evaluate
     if (!opcodes.ValidOffsetForDataOfSize(opcodes_offset, opcodes_length))
     {
         if (error_ptr)
-            error_ptr->SetErrorString ("Invalid offset and/or length for opcodes buffer.");
+            error_ptr->SetErrorString ("invalid offset and/or length for opcodes buffer.");
         return false;
     }
-    LogSP log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS));
+    Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS));
 
 
     while (opcodes.ValidOffset(offset) && offset < end_offset)
     {
-        const uint32_t op_offset = offset;
+        const lldb::offset_t op_offset = offset;
         const uint8_t op = opcodes.GetU8(&offset);
 
         if (log && log->GetVerbose())
@@ -1345,11 +1353,11 @@ DWARFExpression::Evaluate
             for (size_t i=0; i<count; ++i)
             {
                 StreamString new_value;
-                new_value.Printf("[%zu]", i);
+                new_value.Printf("[%" PRIu64 "]", (uint64_t)i);
                 stack[i].Dump(&new_value);
                 log->Printf("  %s", new_value.GetData());
             }
-            log->Printf("0x%8.8x: %s", op_offset, DW_OP_value_to_name(op));
+            log->Printf("0x%8.8" PRIx64 ": %s", op_offset, DW_OP_value_to_name(op));
         }
         switch (op)
         {
@@ -1431,14 +1439,14 @@ DWARFExpression::Evaluate
                             if (process->ReadMemory(pointer_addr, &addr_bytes, addr_size, error) == addr_size)
                             {
                                 DataExtractor addr_data(addr_bytes, sizeof(addr_bytes), process->GetByteOrder(), addr_size);
-                                uint32_t addr_data_offset = 0;
+                                lldb::offset_t addr_data_offset = 0;
                                 stack.back().GetScalar() = addr_data.GetPointer(&addr_data_offset);
                                 stack.back().ClearContext();
                             }
                             else
                             {
                                 if (error_ptr)
-                                    error_ptr->SetErrorStringWithFormat ("Failed to dereference pointer from 0x%llx for DW_OP_deref: %s\n", 
+                                    error_ptr->SetErrorStringWithFormat ("Failed to dereference pointer from 0x%" PRIx64 " for DW_OP_deref: %s\n",
                                                                          pointer_addr,
                                                                          error.AsCString());
                                 return false;
@@ -1522,7 +1530,7 @@ DWARFExpression::Evaluate
                             if (process->ReadMemory(pointer_addr, &addr_bytes, size, error) == size)
                             {
                                 DataExtractor addr_data(addr_bytes, sizeof(addr_bytes), process->GetByteOrder(), size);
-                                uint32_t addr_data_offset = 0;
+                                lldb::offset_t addr_data_offset = 0;
                                 switch (size)
                                 {
                                     case 1: stack.back().GetScalar() = addr_data.GetU8(&addr_data_offset); break;
@@ -1536,7 +1544,7 @@ DWARFExpression::Evaluate
                             else
                             {
                                 if (error_ptr)
-                                    error_ptr->SetErrorStringWithFormat ("Failed to dereference pointer from 0x%llx for DW_OP_deref: %s\n", 
+                                    error_ptr->SetErrorStringWithFormat ("Failed to dereference pointer from 0x%" PRIx64 " for DW_OP_deref: %s\n",
                                                                          pointer_addr,
                                                                          error.AsCString());
                                 return false;
@@ -1996,7 +2004,7 @@ DWARFExpression::Evaluate
             }
             else
             {
-                uint32_t uconst_value = opcodes.GetULEB128(&offset);
+                const uint64_t uconst_value = opcodes.GetULEB128(&offset);
                 // Implicit conversion from a UINT to a Scalar...
                 stack.back().ResolveValue(exe_ctx, ast_context) += uconst_value;
                 if (!stack.back().ResolveValue(exe_ctx, ast_context).IsValid())
@@ -2113,7 +2121,7 @@ DWARFExpression::Evaluate
         case DW_OP_skip:
             {
                 int16_t skip_offset = (int16_t)opcodes.GetU16(&offset);
-                uint32_t new_offset = offset + skip_offset;
+                lldb::offset_t new_offset = offset + skip_offset;
                 if (new_offset >= opcodes_offset && new_offset < end_offset)
                     offset = new_offset;
                 else
@@ -2143,7 +2151,7 @@ DWARFExpression::Evaluate
                 Scalar zero(0);
                 if (tmp.ResolveValue(exe_ctx, ast_context) != zero)
                 {
-                    uint32_t new_offset = offset + bra_offset;
+                    lldb::offset_t new_offset = offset + bra_offset;
                     if (new_offset >= opcodes_offset && new_offset < end_offset)
                         offset = new_offset;
                     else
@@ -2611,6 +2619,18 @@ DWARFExpression::Evaluate
                 error_ptr->SetErrorString ("Unimplemented opcode DW_OP_call4.");
             return false;
 
+        //----------------------------------------------------------------------
+        // OPCODE: DW_OP_stack_value
+        // OPERANDS: None
+        // DESCRIPTION: Specifies that the object does not exist in memory but
+        // rather is a constant value.  The value from the top of the stack is
+        // the value to be used.  This is the actual object value and not the
+        // location.
+        //----------------------------------------------------------------------
+        case DW_OP_stack_value:
+            stack.back().SetValueType(Value::eValueTypeScalar);
+            break;
+
 #if 0
         //----------------------------------------------------------------------
         // OPCODE: DW_OP_call_ref
@@ -2709,7 +2729,7 @@ DWARFExpression::Evaluate
                 if (size && (index >= size || index < 0))
                 {
                     if (error_ptr)
-                        error_ptr->SetErrorStringWithFormat("Out of bounds array access.  %lld is not in [0, %llu]", index, size);
+                        error_ptr->SetErrorStringWithFormat("Out of bounds array access.  %" PRId64 " is not in [0, %" PRIu64 "]", index, size);
                     return false;
                 }
                 
@@ -2781,7 +2801,7 @@ DWARFExpression::Evaluate
                             addr_t source_addr = (addr_t)tmp.GetScalar().ULongLong();
                             addr_t target_addr = (addr_t)stack.back().GetScalar().ULongLong();
                             
-                            size_t byte_size = (ClangASTType::GetClangTypeBitWidth(ast_context, clang_type) + 7) / 8;
+                            const uint64_t byte_size = ClangASTType::GetTypeByteSize(ast_context, clang_type);
                             
                             switch (source_value_type)
                             {
@@ -2892,7 +2912,7 @@ DWARFExpression::Evaluate
                                                                           new_value))
                                     {
                                         if (error_ptr)
-                                            error_ptr->SetErrorStringWithFormat ("Failed to write value to memory at 0x%llx.\n", addr);
+                                            error_ptr->SetErrorStringWithFormat ("Failed to write value to memory at 0x%" PRIx64 ".\n", addr);
                                         return false;
                                     }
                                 }
@@ -3186,7 +3206,7 @@ DWARFExpression::Evaluate
         for (size_t i=0; i<count; ++i)
         {
             StreamString new_value;
-            new_value.Printf("[%zu]", i);
+            new_value.Printf("[%" PRIu64 "]", (uint64_t)i);
             stack[i].Dump(&new_value);
             log->Printf("  %s", new_value.GetData());
         }

Modified: lldb/branches/lldb-platform-work/source/Expression/ExpressionSourceCode.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/lldb-platform-work/source/Expression/ExpressionSourceCode.cpp?rev=183468&r1=183467&r2=183468&view=diff
==============================================================================
--- lldb/branches/lldb-platform-work/source/Expression/ExpressionSourceCode.cpp (original)
+++ lldb/branches/lldb-platform-work/source/Expression/ExpressionSourceCode.cpp Thu Jun  6 19:06:43 2013
@@ -13,6 +13,35 @@
 
 using namespace lldb_private;
 
+const char *
+ExpressionSourceCode::g_expression_prefix = R"(
+#undef NULL
+#undef Nil
+#undef nil
+#undef YES
+#undef NO
+#define NULL (__null)
+#define Nil (__null)
+#define nil (__null)
+#define YES ((BOOL)1)
+#define NO ((BOOL)0)
+typedef signed char BOOL;
+typedef signed __INT8_TYPE__ int8_t;
+typedef unsigned __INT8_TYPE__ uint8_t;
+typedef signed __INT16_TYPE__ int16_t;
+typedef unsigned __INT16_TYPE__ uint16_t;
+typedef signed __INT32_TYPE__ int32_t;
+typedef unsigned __INT32_TYPE__ uint32_t;
+typedef signed __INT64_TYPE__ int64_t;
+typedef unsigned __INT64_TYPE__ uint64_t;
+typedef signed __INTPTR_TYPE__ intptr_t;
+typedef unsigned __INTPTR_TYPE__ uintptr_t;
+typedef __SIZE_TYPE__ size_t;
+typedef __PTRDIFF_TYPE__ ptrdiff_t;
+typedef unsigned short unichar;
+)";
+
+
 bool ExpressionSourceCode::GetText (std::string &text, lldb::LanguageType wrapping_language, bool const_object, bool static_method) const
 {
     if (m_wrap)
@@ -35,33 +64,27 @@ bool ExpressionSourceCode::GetText (std:
             break;
         case lldb::eLanguageTypeC:
             wrap_stream.Printf("%s                             \n"
-                               "#undef NULL                    \n"
-                               "#define NULL 0                 \n"
-                               "#undef nil                     \n"
-                               "#define nil (id)0              \n"
-                               "typedef unsigned short unichar;\n"
+                               "%s                             \n"
                                "void                           \n"
                                "%s(void *$__lldb_arg)          \n"
                                "{                              \n"
                                "    %s;                        \n" 
                                "}                              \n",
                                m_prefix.c_str(),
+                               g_expression_prefix,
                                m_name.c_str(),
                                m_body.c_str());
             break;
         case lldb::eLanguageTypeC_plus_plus:
             wrap_stream.Printf("%s                                     \n"
-                               "#undef NULL                            \n"
-                               "#define NULL 0                         \n"
-                               "#undef nil                             \n"
-                               "#define nil (id)0                      \n"
-                               "typedef unsigned short unichar;        \n"
+                               "%s                                     \n"
                                "void                                   \n"
                                "$__lldb_class::%s(void *$__lldb_arg) %s\n"
                                "{                                      \n"
                                "    %s;                                \n" 
                                "}                                      \n",
                                m_prefix.c_str(),
+                               g_expression_prefix,
                                m_name.c_str(),
                                (const_object ? "const" : ""),
                                m_body.c_str());
@@ -70,33 +93,26 @@ bool ExpressionSourceCode::GetText (std:
             if (static_method)
             {
                 wrap_stream.Printf("%s                                                      \n"
-                                    "#undef NULL                                            \n"
-                                    "#define NULL 0                                         \n"
-                                    "#undef nil                                             \n"
-                                    "#define nil (id)0                                      \n"
-                                    "typedef unsigned short unichar;                        \n"
-                                    "@interface $__lldb_objc_class ($__lldb_category)       \n"
-                                    "+(void)%s:(void *)$__lldb_arg;                         \n"
-                                    "@end                                                   \n"
-                                    "@implementation $__lldb_objc_class ($__lldb_category)  \n"
-                                    "+(void)%s:(void *)$__lldb_arg                          \n"
-                                    "{                                                      \n"
-                                    "    %s;                                                \n"
-                                    "}                                                      \n"
-                                    "@end                                                   \n",
-                                    m_prefix.c_str(),
-                                    m_name.c_str(),
-                                    m_name.c_str(),
-                                    m_body.c_str());
+                                   "%s                                                      \n"
+                                   "@interface $__lldb_objc_class ($__lldb_category)        \n"
+                                   "+(void)%s:(void *)$__lldb_arg;                          \n"
+                                   "@end                                                    \n"
+                                   "@implementation $__lldb_objc_class ($__lldb_category)   \n"
+                                   "+(void)%s:(void *)$__lldb_arg                           \n"
+                                   "{                                                       \n"
+                                   "    %s;                                                 \n"
+                                   "}                                                       \n"
+                                   "@end                                                    \n",
+                                   m_prefix.c_str(),
+                                   g_expression_prefix,
+                                   m_name.c_str(),
+                                   m_name.c_str(),
+                                   m_body.c_str());
             }
             else
             {
                 wrap_stream.Printf("%s                                                     \n"
-                                   "#undef NULL                                            \n"
-                                   "#define NULL 0                                         \n"
-                                   "#undef nil                                             \n"
-                                   "#define nil (id)0                                      \n"
-                                   "typedef unsigned short unichar;                        \n"
+                                   "%s                                                     \n"
                                    "@interface $__lldb_objc_class ($__lldb_category)       \n"
                                    "-(void)%s:(void *)$__lldb_arg;                         \n"
                                    "@end                                                   \n"
@@ -107,6 +123,7 @@ bool ExpressionSourceCode::GetText (std:
                                    "}                                                      \n"
                                    "@end                                                   \n",
                                    m_prefix.c_str(),
+                                   g_expression_prefix,
                                    m_name.c_str(),
                                    m_name.c_str(),
                                    m_body.c_str());

Modified: lldb/branches/lldb-platform-work/source/Expression/IRDynamicChecks.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/lldb-platform-work/source/Expression/IRDynamicChecks.cpp?rev=183468&r1=183467&r2=183468&view=diff
==============================================================================
--- lldb/branches/lldb-platform-work/source/Expression/IRDynamicChecks.cpp (original)
+++ lldb/branches/lldb-platform-work/source/Expression/IRDynamicChecks.cpp Thu Jun  6 19:06:43 2013
@@ -18,11 +18,11 @@
 #include "lldb/Target/StackFrame.h"
 
 #include "llvm/Support/raw_ostream.h"
-#include "llvm/Constants.h"
-#include "llvm/Function.h"
-#include "llvm/Instructions.h"
-#include "llvm/Module.h"
-#include "llvm/Value.h"
+#include "llvm/IR/Constants.h"
+#include "llvm/IR/Function.h"
+#include "llvm/IR/Instructions.h"
+#include "llvm/IR/Module.h"
+#include "llvm/IR/Value.h"
 
 using namespace llvm;
 using namespace lldb_private;
@@ -356,7 +356,7 @@ public:
 private:
     bool InstrumentInstruction(llvm::Instruction *inst)
     {
-        lldb::LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
+        Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
 
         if (log)
             log->Printf("Instrumenting load/store instruction: %s\n", 
@@ -497,7 +497,7 @@ private:
     
     bool InspectInstruction(llvm::Instruction &i)
     {
-        lldb::LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
+        Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
 
         CallInst *call_inst = dyn_cast<CallInst>(&i);
         
@@ -517,23 +517,16 @@ private:
                 return false;
             }
             
-            ConstantDataArray *real_name = dyn_cast<ConstantDataArray>(metadata->getOperand(0));
+            MDString *real_name = dyn_cast<MDString>(metadata->getOperand(0));
             
             if (!real_name)
             {
                 if (log)
-                    log->Printf("Function call metadata is not a ConstantArray for [%p] %s", call_inst, PrintValue(call_inst).c_str());
+                    log->Printf("Function call metadata is not an MDString for [%p] %s", call_inst, PrintValue(call_inst).c_str());
                 return false;
             }
-            
-            if (!real_name->isString())
-            {
-                if (log)
-                    log->Printf("Function call metadata is not a string for [%p] %s", call_inst, PrintValue(call_inst).c_str());
-                return false;
-            }
-            
-            std::string name_str = real_name->getAsString();
+
+            std::string name_str = real_name->getString();
             const char* name_cstr = name_str.c_str();
             
             if (log)
@@ -604,7 +597,7 @@ IRDynamicChecks::~IRDynamicChecks()
 bool
 IRDynamicChecks::runOnModule(llvm::Module &M)
 {
-    lldb::LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
+    Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
     
     llvm::Function* function = M.getFunction(StringRef(m_func_name.c_str()));
     





More information about the llvm-branch-commits mailing list