Allow the built in ValueObject summary providers for C strings
use lldb_private::Target::ReadMemory(...) to allow constant strings
to be displayed in global variables prior on in between process
execution.

Centralized the variable declaration dumping into:

	bool
	Variable::DumpDeclaration (Stream *s, bool show_fullpaths, bool show_module);

Fixed an issue if you used "target variable --regex <regex>" where the
variable name would not be displayed, but the regular expression would.

Fixed an issue when viewing global variables through "target variable"
might not display correctly when doing DWARF in object files.



git-svn-id: https://llvm.org/svn/llvm-project/llvdb/trunk@134878 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/source/Commands/CommandObjectTarget.cpp b/source/Commands/CommandObjectTarget.cpp
index 510fe48..b957314 100644
--- a/source/Commands/CommandObjectTarget.cpp
+++ b/source/Commands/CommandObjectTarget.cpp
@@ -466,10 +466,12 @@
                 break;
         }
         
-        if (m_option_variable.show_decl && var_sp->GetDeclaration ().GetFile())
+        if (m_option_variable.show_decl)
         {
-            var_sp->GetDeclaration ().DumpStopContext (&s, false);
-            s.PutCString (": ");
+            bool show_fullpaths = false;
+            bool show_module = true;
+            if (var_sp->DumpDeclaration(&s, show_fullpaths, show_module))
+                s.PutCString (": ");
         }
         
         const Format format = m_option_variable.format;
@@ -528,6 +530,7 @@
 
                     const char *arg = args.GetArgumentAtIndex(idx);
                     uint32_t matches = 0;
+                    bool use_var_name = false;
                     if (m_option_variable.use_regex)
                     {
                         RegularExpression regex(arg);
@@ -537,6 +540,7 @@
                             result.SetStatus (eReturnStatusFailed);
                             return false;
                         }
+                        use_var_name = true;
                         matches = exe_ctx.target->GetImages().FindGlobalVariables (regex,
                                                                                    true, 
                                                                                    UINT32_MAX, 
@@ -573,10 +577,10 @@
                             {
                                 ValueObjectSP valobj_sp (valobj_list.GetValueObjectAtIndex(global_idx));
                                 if (!valobj_sp)
-                                    valobj_sp = ValueObjectVariable::Create (exe_ctx.target, var_sp);
+                                    valobj_sp = ValueObjectVariable::Create (exe_ctx.GetBestExecutionContextScope(), var_sp);
                                 
                                 if (valobj_sp)
-                                    DumpValueObject (s, var_sp, valobj_sp, arg);
+                                    DumpValueObject (s, var_sp, valobj_sp, use_var_name ? var_sp->GetName().GetCString() : arg);
                             }
                         }
                     }