summaryrefslogtreecommitdiffstats
path: root/lldb/source
diff options
context:
space:
mode:
authorGreg Clayton <gclayton@apple.com>2012-12-04 00:32:51 +0000
committerGreg Clayton <gclayton@apple.com>2012-12-04 00:32:51 +0000
commit3bcdfc0ec19df671655eeedb10da2ff9399b8b65 (patch)
tree53fa965c5bbacdfccbef6aff6e5db359ad8fa668 /lldb/source
parent1dd82dd3fc608ee600652a8bf34f6c345354e3b0 (diff)
downloadbcm5719-llvm-3bcdfc0ec19df671655eeedb10da2ff9399b8b65.tar.gz
bcm5719-llvm-3bcdfc0ec19df671655eeedb10da2ff9399b8b65.zip
<rdar://problem/12798131>
Cleaned up the option parsing code to always pass around the short options as integers. Previously we cast this down to "char" and lost some information. I recently added an assert that would detect duplicate short character options which was firing during the test suite. This fix does the following: - make sure all short options are treated as "int" - make sure that short options can be non-printable values when a short option is not required or when an option group is mixed into many commands and a short option is not desired - fix the help printing to "do the right thing" in all cases. Previously if there were duplicate short character options, it would just not emit help for the duplicates - fix option parsing when there are duplicates to parse options correctly. Previously the option parsing, when done for an OptionGroup, would just start parsing options incorrectly by omitting table entries and it would end up setting the wrong option value llvm-svn: 169189
Diffstat (limited to 'lldb/source')
-rw-r--r--lldb/source/Commands/CommandObjectArgs.cpp2
-rw-r--r--lldb/source/Commands/CommandObjectBreakpoint.cpp8
-rw-r--r--lldb/source/Commands/CommandObjectBreakpointCommand.cpp2
-rw-r--r--lldb/source/Commands/CommandObjectCommands.cpp10
-rw-r--r--lldb/source/Commands/CommandObjectDisassemble.cpp2
-rw-r--r--lldb/source/Commands/CommandObjectExpression.cpp2
-rw-r--r--lldb/source/Commands/CommandObjectFrame.cpp2
-rw-r--r--lldb/source/Commands/CommandObjectHelp.h2
-rw-r--r--lldb/source/Commands/CommandObjectLog.cpp2
-rw-r--r--lldb/source/Commands/CommandObjectMemory.cpp4
-rw-r--r--lldb/source/Commands/CommandObjectPlatform.cpp2
-rw-r--r--lldb/source/Commands/CommandObjectProcess.cpp8
-rw-r--r--lldb/source/Commands/CommandObjectRegister.cpp2
-rw-r--r--lldb/source/Commands/CommandObjectSettings.cpp2
-rw-r--r--lldb/source/Commands/CommandObjectSource.cpp4
-rw-r--r--lldb/source/Commands/CommandObjectTarget.cpp197
-rw-r--r--lldb/source/Commands/CommandObjectThread.cpp6
-rw-r--r--lldb/source/Commands/CommandObjectType.cpp26
-rw-r--r--lldb/source/Commands/CommandObjectWatchpoint.cpp6
-rw-r--r--lldb/source/Commands/CommandObjectWatchpointCommand.cpp2
-rw-r--r--lldb/source/Core/Log.cpp2
-rw-r--r--lldb/source/Interpreter/Args.cpp30
-rw-r--r--lldb/source/Interpreter/OptionGroupArchitecture.cpp2
-rw-r--r--lldb/source/Interpreter/OptionGroupBoolean.cpp2
-rw-r--r--lldb/source/Interpreter/OptionGroupFile.cpp8
-rw-r--r--lldb/source/Interpreter/OptionGroupFormat.cpp2
-rw-r--r--lldb/source/Interpreter/OptionGroupOutputFile.cpp10
-rw-r--r--lldb/source/Interpreter/OptionGroupPlatform.cpp2
-rw-r--r--lldb/source/Interpreter/OptionGroupString.cpp2
-rw-r--r--lldb/source/Interpreter/OptionGroupUInt64.cpp2
-rw-r--r--lldb/source/Interpreter/OptionGroupUUID.cpp6
-rw-r--r--lldb/source/Interpreter/OptionGroupValueObjectDisplay.cpp2
-rw-r--r--lldb/source/Interpreter/OptionGroupVariable.cpp18
-rw-r--r--lldb/source/Interpreter/OptionGroupWatchpoint.cpp2
-rw-r--r--lldb/source/Interpreter/Options.cpp272
-rw-r--r--lldb/source/Symbol/VariableList.cpp2
-rw-r--r--lldb/source/Target/Process.cpp2
37 files changed, 399 insertions, 258 deletions
diff --git a/lldb/source/Commands/CommandObjectArgs.cpp b/lldb/source/Commands/CommandObjectArgs.cpp
index 2ae91e10cb5..24cf9bc8b81 100644
--- a/lldb/source/Commands/CommandObjectArgs.cpp
+++ b/lldb/source/Commands/CommandObjectArgs.cpp
@@ -54,7 +54,7 @@ CommandObjectArgs::CommandOptions::SetOptionValue (uint32_t option_idx, const ch
{
Error error;
- char short_option = (char) m_getopt_table[option_idx].val;
+ const int short_option = m_getopt_table[option_idx].val;
switch (short_option)
{
diff --git a/lldb/source/Commands/CommandObjectBreakpoint.cpp b/lldb/source/Commands/CommandObjectBreakpoint.cpp
index 7c673f7fe67..bb8617f9780 100644
--- a/lldb/source/Commands/CommandObjectBreakpoint.cpp
+++ b/lldb/source/Commands/CommandObjectBreakpoint.cpp
@@ -118,7 +118,7 @@ public:
SetOptionValue (uint32_t option_idx, const char *option_arg)
{
Error error;
- char short_option = (char) m_getopt_table[option_idx].val;
+ const int short_option = m_getopt_table[option_idx].val;
switch (short_option)
{
@@ -746,7 +746,7 @@ public:
SetOptionValue (uint32_t option_idx, const char *option_arg)
{
Error error;
- char short_option = (char) m_getopt_table[option_idx].val;
+ const int short_option = m_getopt_table[option_idx].val;
switch (short_option)
{
@@ -1253,7 +1253,7 @@ public:
SetOptionValue (uint32_t option_idx, const char *option_arg)
{
Error error;
- char short_option = (char) m_getopt_table[option_idx].val;
+ const int short_option = m_getopt_table[option_idx].val;
switch (short_option)
{
@@ -1441,7 +1441,7 @@ public:
SetOptionValue (uint32_t option_idx, const char *option_arg)
{
Error error;
- char short_option = (char) m_getopt_table[option_idx].val;
+ const int short_option = m_getopt_table[option_idx].val;
switch (short_option)
{
diff --git a/lldb/source/Commands/CommandObjectBreakpointCommand.cpp b/lldb/source/Commands/CommandObjectBreakpointCommand.cpp
index f308ae3713c..53b6b4e2171 100644
--- a/lldb/source/Commands/CommandObjectBreakpointCommand.cpp
+++ b/lldb/source/Commands/CommandObjectBreakpointCommand.cpp
@@ -413,7 +413,7 @@ one command per line.\n" );
SetOptionValue (uint32_t option_idx, const char *option_arg)
{
Error error;
- char short_option = (char) m_getopt_table[option_idx].val;
+ const int short_option = m_getopt_table[option_idx].val;
switch (short_option)
{
diff --git a/lldb/source/Commands/CommandObjectCommands.cpp b/lldb/source/Commands/CommandObjectCommands.cpp
index 5999f7c8935..e1bd287a863 100644
--- a/lldb/source/Commands/CommandObjectCommands.cpp
+++ b/lldb/source/Commands/CommandObjectCommands.cpp
@@ -72,7 +72,7 @@ protected:
SetOptionValue (uint32_t option_idx, const char *option_arg)
{
Error error;
- char short_option = (char) m_getopt_table[option_idx].val;
+ const int short_option = m_getopt_table[option_idx].val;
bool success;
switch (short_option)
@@ -234,7 +234,7 @@ protected:
SetOptionValue (uint32_t option_idx, const char *option_arg)
{
Error error;
- char short_option = (char) m_getopt_table[option_idx].val;
+ const int short_option = m_getopt_table[option_idx].val;
bool success;
switch (short_option)
@@ -1082,7 +1082,7 @@ private:
SetOptionValue (uint32_t option_idx, const char *option_arg)
{
Error error;
- char short_option = (char) m_getopt_table[option_idx].val;
+ const int short_option = m_getopt_table[option_idx].val;
switch (short_option)
{
@@ -1335,7 +1335,7 @@ protected:
SetOptionValue (uint32_t option_idx, const char *option_arg)
{
Error error;
- char short_option = (char) m_getopt_table[option_idx].val;
+ const int short_option = m_getopt_table[option_idx].val;
switch (short_option)
{
@@ -1478,7 +1478,7 @@ protected:
SetOptionValue (uint32_t option_idx, const char *option_arg)
{
Error error;
- char short_option = (char) m_getopt_table[option_idx].val;
+ const int short_option = m_getopt_table[option_idx].val;
switch (short_option)
{
diff --git a/lldb/source/Commands/CommandObjectDisassemble.cpp b/lldb/source/Commands/CommandObjectDisassemble.cpp
index 45fdda71731..bed64d42e37 100644
--- a/lldb/source/Commands/CommandObjectDisassemble.cpp
+++ b/lldb/source/Commands/CommandObjectDisassemble.cpp
@@ -59,7 +59,7 @@ CommandObjectDisassemble::CommandOptions::SetOptionValue (uint32_t option_idx, c
{
Error error;
- char short_option = (char) m_getopt_table[option_idx].val;
+ const int short_option = m_getopt_table[option_idx].val;
bool success;
diff --git a/lldb/source/Commands/CommandObjectExpression.cpp b/lldb/source/Commands/CommandObjectExpression.cpp
index a93d4e65fa0..1110c1f321c 100644
--- a/lldb/source/Commands/CommandObjectExpression.cpp
+++ b/lldb/source/Commands/CommandObjectExpression.cpp
@@ -71,7 +71,7 @@ CommandObjectExpression::CommandOptions::SetOptionValue (CommandInterpreter &int
{
Error error;
- const char short_option = (char) g_option_table[option_idx].short_option;
+ const int short_option = g_option_table[option_idx].short_option;
switch (short_option)
{
diff --git a/lldb/source/Commands/CommandObjectFrame.cpp b/lldb/source/Commands/CommandObjectFrame.cpp
index eab0d02c188..53de2b14448 100644
--- a/lldb/source/Commands/CommandObjectFrame.cpp
+++ b/lldb/source/Commands/CommandObjectFrame.cpp
@@ -120,7 +120,7 @@ public:
{
Error error;
bool success = false;
- char short_option = (char) m_getopt_table[option_idx].val;
+ const int short_option = m_getopt_table[option_idx].val;
switch (short_option)
{
case 'r':
diff --git a/lldb/source/Commands/CommandObjectHelp.h b/lldb/source/Commands/CommandObjectHelp.h
index b66d69f476f..91a40b52949 100644
--- a/lldb/source/Commands/CommandObjectHelp.h
+++ b/lldb/source/Commands/CommandObjectHelp.h
@@ -57,7 +57,7 @@ public:
SetOptionValue (uint32_t option_idx, const char *option_arg)
{
Error error;
- char short_option = (char) m_getopt_table[option_idx].val;
+ const int short_option = m_getopt_table[option_idx].val;
switch (short_option)
{
diff --git a/lldb/source/Commands/CommandObjectLog.cpp b/lldb/source/Commands/CommandObjectLog.cpp
index fb982972d26..35fcacc4b18 100644
--- a/lldb/source/Commands/CommandObjectLog.cpp
+++ b/lldb/source/Commands/CommandObjectLog.cpp
@@ -132,7 +132,7 @@ public:
SetOptionValue (uint32_t option_idx, const char *option_arg)
{
Error error;
- char short_option = (char) m_getopt_table[option_idx].val;
+ const int short_option = m_getopt_table[option_idx].val;
switch (short_option)
{
diff --git a/lldb/source/Commands/CommandObjectMemory.cpp b/lldb/source/Commands/CommandObjectMemory.cpp
index fffbda1d143..2f79e52b4cd 100644
--- a/lldb/source/Commands/CommandObjectMemory.cpp
+++ b/lldb/source/Commands/CommandObjectMemory.cpp
@@ -82,7 +82,7 @@ public:
const char *option_arg)
{
Error error;
- char short_option = (char) g_option_table[option_idx].short_option;
+ const int short_option = g_option_table[option_idx].short_option;
switch (short_option)
{
@@ -861,7 +861,7 @@ public:
const char *option_arg)
{
Error error;
- char short_option = (char) g_memory_write_option_table[option_idx].short_option;
+ const int short_option = g_memory_write_option_table[option_idx].short_option;
switch (short_option)
{
diff --git a/lldb/source/Commands/CommandObjectPlatform.cpp b/lldb/source/Commands/CommandObjectPlatform.cpp
index 3be46ab872e..10700aa1bb6 100644
--- a/lldb/source/Commands/CommandObjectPlatform.cpp
+++ b/lldb/source/Commands/CommandObjectPlatform.cpp
@@ -606,7 +606,7 @@ protected:
SetOptionValue (uint32_t option_idx, const char *option_arg)
{
Error error;
- char short_option = (char) m_getopt_table[option_idx].val;
+ const int short_option = m_getopt_table[option_idx].val;
bool success = false;
switch (short_option)
diff --git a/lldb/source/Commands/CommandObjectProcess.cpp b/lldb/source/Commands/CommandObjectProcess.cpp
index 68f577ffcf5..1fae2dee8b4 100644
--- a/lldb/source/Commands/CommandObjectProcess.cpp
+++ b/lldb/source/Commands/CommandObjectProcess.cpp
@@ -355,7 +355,7 @@ public:
SetOptionValue (uint32_t option_idx, const char *option_arg)
{
Error error;
- char short_option = (char) m_getopt_table[option_idx].val;
+ const int short_option = m_getopt_table[option_idx].val;
bool success = false;
switch (short_option)
{
@@ -715,7 +715,7 @@ protected:
SetOptionValue (uint32_t option_idx, const char *option_arg)
{
Error error;
- char short_option = (char) m_getopt_table[option_idx].val;
+ const int short_option = m_getopt_table[option_idx].val;
bool success = false;
switch (short_option)
{
@@ -941,7 +941,7 @@ public:
SetOptionValue (uint32_t option_idx, const char *option_arg)
{
Error error;
- char short_option = (char) m_getopt_table[option_idx].val;
+ const int short_option = m_getopt_table[option_idx].val;
switch (short_option)
{
@@ -1533,7 +1533,7 @@ public:
SetOptionValue (uint32_t option_idx, const char *option_arg)
{
Error error;
- char short_option = (char) m_getopt_table[option_idx].val;
+ const int short_option = m_getopt_table[option_idx].val;
switch (short_option)
{
diff --git a/lldb/source/Commands/CommandObjectRegister.cpp b/lldb/source/Commands/CommandObjectRegister.cpp
index 6873450fc2e..896b0187b9d 100644
--- a/lldb/source/Commands/CommandObjectRegister.cpp
+++ b/lldb/source/Commands/CommandObjectRegister.cpp
@@ -289,7 +289,7 @@ protected:
const char *option_value)
{
Error error;
- const char short_option = (char) g_option_table[option_idx].short_option;
+ const int short_option = g_option_table[option_idx].short_option;
switch (short_option)
{
case 's':
diff --git a/lldb/source/Commands/CommandObjectSettings.cpp b/lldb/source/Commands/CommandObjectSettings.cpp
index e55da23bac7..7c578326511 100644
--- a/lldb/source/Commands/CommandObjectSettings.cpp
+++ b/lldb/source/Commands/CommandObjectSettings.cpp
@@ -119,7 +119,7 @@ insert-before or insert-after.\n");
SetOptionValue (uint32_t option_idx, const char *option_arg)
{
Error error;
- char short_option = (char) m_getopt_table[option_idx].val;
+ const int short_option = m_getopt_table[option_idx].val;
switch (short_option)
{
diff --git a/lldb/source/Commands/CommandObjectSource.cpp b/lldb/source/Commands/CommandObjectSource.cpp
index c4ccf2a2167..5162d53ab1e 100644
--- a/lldb/source/Commands/CommandObjectSource.cpp
+++ b/lldb/source/Commands/CommandObjectSource.cpp
@@ -54,7 +54,7 @@ class CommandObjectSourceInfo : public CommandObjectParsed
SetOptionValue (uint32_t option_idx, const char *option_arg)
{
Error error;
- const char short_option = g_option_table[option_idx].short_option;
+ const int short_option = g_option_table[option_idx].short_option;
switch (short_option)
{
case 'l':
@@ -162,7 +162,7 @@ class CommandObjectSourceList : public CommandObjectParsed
SetOptionValue (uint32_t option_idx, const char *option_arg)
{
Error error;
- const char short_option = g_option_table[option_idx].short_option;
+ const int short_option = g_option_table[option_idx].short_option;
switch (short_option)
{
case 'l':
diff --git a/lldb/source/Commands/CommandObjectTarget.cpp b/lldb/source/Commands/CommandObjectTarget.cpp
index 2dc5fab4829..2a5b6c6d4c4 100644
--- a/lldb/source/Commands/CommandObjectTarget.cpp
+++ b/lldb/source/Commands/CommandObjectTarget.cpp
@@ -602,8 +602,8 @@ public:
m_option_group (interpreter),
m_option_variable (false), // Don't include frame options
m_option_format (eFormatDefault),
- m_option_compile_units (LLDB_OPT_SET_1, false, "file", 'f', 0, eArgTypeFilename, "A basename or fullpath to a file that contains global variables. This option can be specified multiple times."),
- m_option_shared_libraries (LLDB_OPT_SET_1, false, "shlib",'s', 0, eArgTypeFilename, "A basename or fullpath to a shared library to use in the search for global variables. This option can be specified multiple times."),
+ m_option_compile_units (LLDB_OPT_SET_1, false, "file", 'file', 0, eArgTypeFilename, "A basename or fullpath to a file that contains global variables. This option can be specified multiple times."),
+ m_option_shared_libraries (LLDB_OPT_SET_1, false, "shlib",'shlb', 0, eArgTypeFilename, "A basename or fullpath to a shared library to use in the search for global variables. This option can be specified multiple times."),
m_varobj_options()
{
CommandArgumentEntry arg;
@@ -719,6 +719,51 @@ public:
}
protected:
+
+ void
+ DumpGlobalVariableList(const ExecutionContext &exe_ctx, const SymbolContext &sc, const VariableList &variable_list, Stream &s)
+ {
+ size_t count = variable_list.GetSize();
+ if (count > 0)
+ {
+ if (sc.module_sp)
+ {
+ if (sc.comp_unit)
+ {
+ s.Printf ("Global variables for %s/%s in %s/%s:\n",
+ sc.comp_unit->GetDirectory().GetCString(),
+ sc.comp_unit->GetFilename().GetCString(),
+ sc.module_sp->GetFileSpec().GetDirectory().GetCString(),
+ sc.module_sp->GetFileSpec().GetFilename().GetCString());
+ }
+ else
+ {
+ s.Printf ("Global variables for %s/%s\n",
+ sc.module_sp->GetFileSpec().GetDirectory().GetCString(),
+ sc.module_sp->GetFileSpec().GetFilename().GetCString());
+ }
+ }
+ else if (sc.comp_unit)
+ {
+ s.Printf ("Global variables for %s/%s\n",
+ sc.comp_unit->GetDirectory().GetCString(),
+ sc.comp_unit->GetFilename().GetCString());
+ }
+
+ for (uint32_t i=0; i<count; ++i)
+ {
+ VariableSP var_sp (variable_list.GetVariableAtIndex(i));
+ if (var_sp)
+ {
+ ValueObjectSP valobj_sp (ValueObjectVariable::Create (exe_ctx.GetBestExecutionContextScope(), var_sp));
+
+ if (valobj_sp)
+ DumpValueObject (s, var_sp, valobj_sp, var_sp->GetName().GetCString());
+ }
+ }
+ }
+
+ }
virtual bool
DoExecute (Args& args, CommandReturnObject &result)
{
@@ -728,6 +773,7 @@ protected:
{
const size_t argc = args.GetArgumentCount();
Stream &s = result.GetOutputStream();
+
if (argc > 0)
{
@@ -791,55 +837,120 @@ protected:
}
else
{
- bool success = false;
- StackFrame *frame = exe_ctx.GetFramePtr();
- CompileUnit *comp_unit = NULL;
- if (frame)
+ const FileSpecList &compile_units = m_option_compile_units.GetOptionValue().GetCurrentValue();
+ const FileSpecList &shlibs = m_option_shared_libraries.GetOptionValue().GetCurrentValue();
+ SymbolContextList sc_list;
+ const size_t num_compile_units = compile_units.GetSize();
+ const size_t num_shlibs = shlibs.GetSize();
+ if (num_compile_units == 0 && num_shlibs == 0)
{
- comp_unit = frame->GetSymbolContext (eSymbolContextCompUnit).comp_unit;
- if (comp_unit)
+ bool success = false;
+ StackFrame *frame = exe_ctx.GetFramePtr();
+ CompileUnit *comp_unit = NULL;
+ if (frame)
{
- const bool can_create = true;
- VariableListSP comp_unit_varlist_sp (comp_unit->GetVariableList(can_create));
- if (comp_unit_varlist_sp)
+ SymbolContext sc = frame->GetSymbolContext (eSymbolContextCompUnit);
+ if (sc.comp_unit)
{
- size_t count = comp_unit_varlist_sp->GetSize();
- if (count > 0)
+ const bool can_create = true;
+ VariableListSP comp_unit_varlist_sp (sc.comp_unit->GetVariableList(can_create));
+ if (comp_unit_varlist_sp)
{
- s.Printf ("Global variables for %s/%s:\n",
- comp_unit->GetDirectory().GetCString(),
- comp_unit->GetFilename().GetCString());
-
- success = true;
- for (uint32_t i=0; i<count; ++i)
+ size_t count = comp_unit_varlist_sp->GetSize();
+ if (count > 0)
{
- VariableSP var_sp (comp_unit_varlist_sp->GetVariableAtIndex(i));
- if (var_sp)
- {
- ValueObjectSP valobj_sp (ValueObjectVariable::Create (exe_ctx.GetBestExecutionContextScope(), var_sp));
-
- if (valobj_sp)
- DumpValueObject (s, var_sp, valobj_sp, var_sp->GetName().GetCString());
- }
+ DumpGlobalVariableList(exe_ctx, sc, *comp_unit_varlist_sp, s);
+ success = true;
}
}
}
}
+ if (!success)
+ {
+ if (frame)
+ {
+ if (comp_unit)
+ result.AppendErrorWithFormat ("no global variables in current compile unit: %s/%s\n",
+ comp_unit->GetDirectory().GetCString(),
+ comp_unit->GetFilename().GetCString());
+ else
+ result.AppendError ("no debug information for frame %u\n", frame->GetFrameIndex());
+ }
+ else
+ result.AppendError ("'target variable' takes one or more global variable names as arguments\n");
+ result.SetStatus (eReturnStatusFailed);
+ }
}
- if (!success)
+ else
{
- if (frame)
+ SymbolContextList sc_list;
+ const bool append = true;
+ // We have one or more compile unit or shlib
+ if (num_shlibs > 0)
{
- if (comp_unit)
- result.AppendErrorWithFormat ("no global variables in current compile unit: %s/%s\n",
- comp_unit->GetDirectory().GetCString(),
- comp_unit->GetFilename().GetCString());
- else
- result.AppendError ("no debug information for frame %u\n", frame->GetFrameIndex());
- }
+ for (size_t shlib_idx=0; shlib_idx<num_shlibs; ++shlib_idx)
+ {
+ const FileSpec module_file(shlibs.GetFileSpecAtIndex(shlib_idx));
+ ModuleSpec module_spec (module_file);
+
+ ModuleSP module_sp (target->GetImages().FindFirstModule(module_spec));
+ if (module_sp)
+ {
+ if (num_compile_units > 0)
+ {
+ for (size_t cu_idx=0; cu_idx<num_compile_units; ++cu_idx)
+ module_sp->FindCompileUnits(compile_units.GetFileSpecAtIndex(cu_idx), append, sc_list);
+ }
+ else
+ {
+ SymbolContext sc;
+ sc.module_sp = module_sp;
+ sc_list.Append(sc);
+ }
+ }
+ else
+ {
+ // Didn't find matching shlib/module in target...
+ result.AppendErrorWithFormat ("target doesn't contain the specified shared library: %s%s%s\n",
+ module_file.GetDirectory().GetCString(),
+ module_file.GetDirectory() ? "/" : "",
+ module_file.GetFilename().GetCString());
+ }
+ }
+ }
else
- result.AppendError ("'target variable' takes one or more global variable names as arguments\n");
- result.SetStatus (eReturnStatusFailed);
+ {
+ // No shared libraries, we just want to find globals for the compile units files that were specified
+ for (size_t cu_idx=0; cu_idx<num_compile_units; ++cu_idx)
+ target->GetImages().FindCompileUnits(compile_units.GetFileSpecAtIndex(cu_idx), append, sc_list);
+ }
+
+ const uint32_t num_scs = sc_list.GetSize();
+ if (num_scs > 0)
+ {
+ SymbolContext sc;
+ for (uint32_t sc_idx=0; sc_idx<num_scs; ++sc_idx)
+ {
+ if (sc_list.GetContextAtIndex(sc_idx, sc))
+ {
+ if (sc.comp_unit)
+ {
+ const bool can_create = true;
+ VariableListSP comp_unit_varlist_sp (sc.comp_unit->GetVariableList(can_create));
+ if (comp_unit_varlist_sp)
+ DumpGlobalVariableList(exe_ctx, sc, *comp_unit_varlist_sp, s);
+ }
+ else if (sc.module_sp)
+ {
+ // Get all global variables for this module
+ lldb_private::RegularExpression all_globals_regex("."); // Any global with at least one character
+ VariableList variable_list;
+ sc.module_sp->FindGlobalVariables(all_globals_regex, append, UINT32_MAX, variable_list);
+ DumpGlobalVariableList(exe_ctx, sc, variable_list, s);
+ }
+ }
+ }
+ }
}
}
}
@@ -1980,7 +2091,7 @@ public:
SetOptionValue (uint32_t option_idx, const char *option_arg)
{
Error error;
- char short_option = (char) m_getopt_table[option_idx].val;
+ const int short_option = m_getopt_table[option_idx].val;
switch (short_option)
{
@@ -2913,7 +3024,7 @@ public:
virtual Error
SetOptionValue (uint32_t option_idx, const char *option_arg)
{
- char short_option = (char) m_getopt_table[option_idx].val;
+ const int short_option = m_getopt_table[option_idx].val;
if (short_option == 'g')
{
m_use_global_module_list = true;
@@ -3368,7 +3479,7 @@ public:
{
Error error;
- char short_option = (char) m_getopt_table[option_idx].val;
+ const int short_option = m_getopt_table[option_idx].val;
switch (short_option)
{
@@ -3601,7 +3712,7 @@ public:
{
Error error;
- char short_option = (char) m_getopt_table[option_idx].val;
+ const int short_option = m_getopt_table[option_idx].val;
switch (short_option)
{
@@ -4489,7 +4600,7 @@ public:
SetOptionValue (uint32_t option_idx, const char *option_arg)
{
Error error;
- char short_option = (char) m_getopt_table[option_idx].val;
+ const int short_option = m_getopt_table[option_idx].val;
bool success;
switch (short_option)
diff --git a/lldb/source/Commands/CommandObjectThread.cpp b/lldb/source/Commands/CommandObjectThread.cpp
index f555b624e11..49167e8a09d 100644
--- a/lldb/source/Commands/CommandObjectThread.cpp
+++ b/lldb/source/Commands/CommandObjectThread.cpp
@@ -67,7 +67,7 @@ public:
SetOptionValue (uint32_t option_idx, const char *option_arg)
{
Error error;
- char short_option = (char) m_getopt_table[option_idx].val;
+ const int short_option = m_getopt_table[option_idx].val;
switch (short_option)
{
@@ -296,7 +296,7 @@ public:
SetOptionValue (uint32_t option_idx, const char *option_arg)
{
Error error;
- char short_option = (char) m_getopt_table[option_idx].val;
+ const int short_option = m_getopt_table[option_idx].val;
switch (short_option)
{
@@ -818,7 +818,7 @@ public:
SetOptionValue (uint32_t option_idx, const char *option_arg)
{
Error error;
- char short_option = (char) m_getopt_table[option_idx].val;
+ const int short_option = m_getopt_table[option_idx].val;
switch (short_option)
{
diff --git a/lldb/source/Commands/CommandObjectType.cpp b/lldb/source/Commands/CommandObjectType.cpp
index ba2a9f3bd6b..335b38c1215 100644
--- a/lldb/source/Commands/CommandObjectType.cpp
+++ b/lldb/source/Commands/CommandObjectType.cpp
@@ -209,7 +209,7 @@ private:
SetOptionValue (uint32_t option_idx, const char *option_arg)
{
Error error;
- char short_option = (char) m_getopt_table[option_idx].val;
+ const int short_option = m_getopt_table[option_idx].val;
bool success;
switch (short_option)
@@ -374,7 +374,7 @@ private:
const char *option_value)
{
Error error;
- const char short_option = (char) g_option_table[option_idx].short_option;
+ const int short_option = g_option_table[option_idx].short_option;
bool success;
switch (short_option)
@@ -915,7 +915,7 @@ Error
CommandObjectTypeSummaryAdd::CommandOptions::SetOptionValue (uint32_t option_idx, const char *option_arg)
{
Error error;
- char short_option = (char) m_getopt_table[option_idx].val;
+ const int short_option = m_getopt_table[option_idx].val;
bool success;
switch (short_option)
@@ -1417,7 +1417,7 @@ private:
SetOptionValue (uint32_t option_idx, const char *option_arg)
{
Error error;
- char short_option = (char) m_getopt_table[option_idx].val;
+ const int short_option = m_getopt_table[option_idx].val;
switch (short_option)
{
@@ -1580,7 +1580,7 @@ private:
SetOptionValue (uint32_t option_idx, const char *option_arg)
{
Error error;
- char short_option = (char) m_getopt_table[option_idx].val;
+ const int short_option = m_getopt_table[option_idx].val;
switch (short_option)
{
@@ -1724,7 +1724,7 @@ class CommandObjectTypeSummaryList : public CommandObjectParsed
SetOptionValue (uint32_t option_idx, const char *option_arg)
{
Error error;
- char short_option = (char) m_getopt_table[option_idx].val;
+ const int short_option = m_getopt_table[option_idx].val;
switch (short_option)
{
@@ -2287,7 +2287,7 @@ class CommandObjectTypeFilterList : public CommandObjectParsed
SetOptionValue (uint32_t option_idx, const char *option_arg)
{
Error error;
- char short_option = (char) m_getopt_table[option_idx].val;
+ const int short_option = m_getopt_table[option_idx].val;
switch (short_option)
{
@@ -2501,7 +2501,7 @@ class CommandObjectTypeSynthList : public CommandObjectParsed
SetOptionValue (uint32_t option_idx, const char *option_arg)
{
Error error;
- char short_option = (char) m_getopt_table[option_idx].val;
+ const int short_option = m_getopt_table[option_idx].val;
switch (short_option)
{
@@ -2699,7 +2699,7 @@ private:
SetOptionValue (uint32_t option_idx, const char *option_arg)
{
Error error;
- char short_option = (char) m_getopt_table[option_idx].val;
+ const int short_option = m_getopt_table[option_idx].val;
switch (short_option)
{
@@ -2865,7 +2865,7 @@ private:
SetOptionValue (uint32_t option_idx, const char *option_arg)
{
Error error;
- char short_option = (char) m_getopt_table[option_idx].val;
+ const int short_option = m_getopt_table[option_idx].val;
switch (short_option)
{
@@ -3032,7 +3032,7 @@ private:
SetOptionValue (uint32_t option_idx, const char *option_arg)
{
Error error;
- char short_option = (char) m_getopt_table[option_idx].val;
+ const int short_option = m_getopt_table[option_idx].val;
switch (short_option)
{
@@ -3161,7 +3161,7 @@ private:
SetOptionValue (uint32_t option_idx, const char *option_arg)
{
Error error;
- char short_option = (char) m_getopt_table[option_idx].val;
+ const int short_option = m_getopt_table[option_idx].val;
switch (short_option)
{
@@ -3658,7 +3658,7 @@ private:
SetOptionValue (uint32_t option_idx, const char *option_arg)
{
Error error;
- char short_option = (char) m_getopt_table[option_idx].val;
+ const int short_option = m_getopt_table[option_idx].val;
bool success;
switch (short_option)
diff --git a/lldb/source/Commands/CommandObjectWatchpoint.cpp b/lldb/source/Commands/CommandObjectWatchpoint.cpp
index 8d907ae5740..00a78837e4e 100644
--- a/lldb/source/Commands/CommandObjectWatchpoint.cpp
+++ b/lldb/source/Commands/CommandObjectWatchpoint.cpp
@@ -213,7 +213,7 @@ public:
SetOptionValue (uint32_t option_idx, const char *option_arg)
{
Error error;
- char short_option = (char) m_getopt_table[option_idx].val;
+ const int short_option = m_getopt_table[option_idx].val;
switch (short_option)
{
@@ -642,7 +642,7 @@ public:
SetOptionValue (uint32_t option_idx, const char *option_arg)
{
Error error;
- char short_option = (char) m_getopt_table[option_idx].val;
+ const int short_option = m_getopt_table[option_idx].val;
switch (short_option)
{
@@ -799,7 +799,7 @@ public:
SetOptionValue (uint32_t option_idx, const char *option_arg)
{
Error error;
- char short_option = (char) m_getopt_table[option_idx].val;
+ const int short_option = m_getopt_table[option_idx].val;
switch (short_option)
{
diff --git a/lldb/source/Commands/CommandObjectWatchpointCommand.cpp b/lldb/source/Commands/CommandObjectWatchpointCommand.cpp
index eaf3b35f645..2f4824959cd 100644
--- a/lldb/source/Commands/CommandObjectWatchpointCommand.cpp
+++ b/lldb/source/Commands/CommandObjectWatchpointCommand.cpp
@@ -396,7 +396,7 @@ but do NOT enter more than one command per line. \n" );
SetOptionValue (uint32_t option_idx, const char *option_arg)
{
Error error;
- char short_option = (char) m_getopt_table[option_idx].val;
+ const int short_option = m_getopt_table[option_idx].val;
switch (short_option)
{
diff --git a/lldb/source/Core/Log.cpp b/lldb/source/Core/Log.cpp
index b8671f7ddc9..9b4e4e076a0 100644
--- a/lldb/source/Core/Log.cpp
+++ b/lldb/source/Core/Log.cpp
@@ -100,7 +100,7 @@ Log::PrintfWithFlagsVarArg (uint32_t flags, const char *format, va_list args)
if (m_options.Test (LLDB_LOG_OPTION_PREPEND_TIMESTAMP))
{
struct timeval tv = TimeValue::Now().GetAsTimeVal();
- header.Printf ("%9ld.%6.6ld ", tv.tv_sec, tv.tv_usec);
+ header.Printf ("%9ld.%6.6" PRIi32 " ", tv.tv_sec, tv.tv_usec);
}
// Add the process and thread if requested
diff --git a/lldb/source/Interpreter/Args.cpp b/lldb/source/Interpreter/Args.cpp
index 1518968bd61..dde546c687b 100644
--- a/lldb/source/Interpreter/Args.cpp
+++ b/lldb/source/Interpreter/Args.cpp
@@ -625,13 +625,16 @@ Args::ParseOptions (Options &options)
{
if (long_options[i].flag == NULL)
{
- sstr << (char)long_options[i].val;
- switch (long_options[i].has_arg)
+ if (isprint(long_options[i].val))
{
- default:
- case no_argument: break;
- case required_argument: sstr << ':'; break;
- case optional_argument: sstr << "::"; break;
+ sstr << (char)long_options[i].val;
+ switch (long_options[i].has_arg)
+ {
+ default:
+ case no_argument: break;
+ case required_argument: sstr << ':'; break;
+ case optional_argument: sstr << "::"; break;
+ }
}
}
}
@@ -645,7 +648,10 @@ Args::ParseOptions (Options &options)
while (1)
{
int long_options_index = -1;
- val = ::getopt_long(GetArgumentCount(), GetArgumentVector(), sstr.GetData(), long_options,
+ val = ::getopt_long(GetArgumentCount(),
+ GetArgumentVector(),
+ sstr.GetData(),
+ long_options,
&long_options_index);
if (val == -1)
break;
@@ -1092,7 +1098,7 @@ Args::FindArgumentIndexForOption (struct option *long_options, int long_options_
{
char short_buffer[3];
char long_buffer[255];
- ::snprintf (short_buffer, sizeof (short_buffer), "-%c", (char) long_options[long_options_index].val);
+ ::snprintf (short_buffer, sizeof (short_buffer), "-%c", long_options[long_options_index].val);
::snprintf (long_buffer, sizeof (long_buffer), "--%s", long_options[long_options_index].name);
size_t end = GetArgumentCount ();
size_t idx = 0;
@@ -1216,7 +1222,7 @@ Args::ParseAliasOptions (Options &options,
if (long_options_index >= 0)
{
StreamString option_str;
- option_str.Printf ("-%c", (char) val);
+ option_str.Printf ("-%c", val);
switch (long_options[long_options_index].has_arg)
{
@@ -1256,16 +1262,14 @@ Args::ParseAliasOptions (Options &options,
}
break;
default:
- result.AppendErrorWithFormat
- ("error with options table; invalid value in has_arg field for option '%c'.\n",
- (char) val);
+ result.AppendErrorWithFormat ("error with options table; invalid value in has_arg field for option '%c'.\n", val);
result.SetStatus (eReturnStatusFailed);
break;
}
}
else
{
- result.AppendErrorWithFormat ("Invalid option with value '%c'.\n", (char) val);
+ result.AppendErrorWithFormat ("Invalid option with value '%c'.\n", val);
result.SetStatus (eReturnStatusFailed);
}
diff --git a/lldb/source/Interpreter/OptionGroupArchitecture.cpp b/lldb/source/Interpreter/OptionGroupArchitecture.cpp
index 175605154ec..af103bb0bd9 100644
--- a/lldb/source/Interpreter/OptionGroupArchitecture.cpp
+++ b/lldb/source/Interpreter/OptionGroupArchitecture.cpp
@@ -62,7 +62,7 @@ OptionGroupArchitecture::SetOptionValue (CommandInterpreter &interpreter,
const char *option_arg)
{
Error error;
- char short_option = (char) g_option_table[option_idx].short_option;
+ const int short_option = g_option_table[option_idx].short_option;
switch (short_option)
{
diff --git a/lldb/source/Interpreter/OptionGroupBoolean.cpp b/lldb/source/Interpreter/OptionGroupBoolean.cpp
index 58ac0f1def8..5b5b38478b0 100644
--- a/lldb/source/Interpreter/OptionGroupBoolean.cpp
+++ b/lldb/source/Interpreter/OptionGroupBoolean.cpp
@@ -20,7 +20,7 @@ using namespace lldb_private;
OptionGroupBoolean::OptionGroupBoolean (uint32_t usage_mask,
bool required,
const char *long_option,
- char short_option,
+ int short_option,
const char *usage_text,
bool default_value,
bool no_argument_toggle_default) :
diff --git a/lldb/source/Interpreter/OptionGroupFile.cpp b/lldb/source/Interpreter/OptionGroupFile.cpp
index 4749087da6c..6867395789c 100644
--- a/lldb/source/Interpreter/OptionGroupFile.cpp
+++ b/lldb/source/Interpreter/OptionGroupFile.cpp
@@ -20,7 +20,7 @@ using namespace lldb_private;
OptionGroupFile::OptionGroupFile (uint32_t usage_mask,
bool required,
const char *long_option,
- char short_option,
+ int short_option,
uint32_t completion_type,
lldb::CommandArgumentType argument_type,
const char *usage_text) :
@@ -60,7 +60,7 @@ OptionGroupFile::OptionParsingStarting (CommandInterpreter &interpreter)
OptionGroupFileList::OptionGroupFileList (uint32_t usage_mask,
bool required,
const char *long_option,
- char short_option,
+ int short_option,
uint32_t completion_type,
lldb::CommandArgumentType argument_type,
const char *usage_text) :
@@ -83,8 +83,8 @@ OptionGroupFileList::~OptionGroupFileList ()
Error
OptionGroupFileList::SetOptionValue (CommandInterpreter &interpreter,
- uint32_t option_idx,
- const char *option_arg)
+ uint32_t option_idx,
+ const char *option_arg)
{
Error error (m_file_list.SetValueFromCString (option_arg));
return error;
diff --git a/lldb/source/Interpreter/OptionGroupFormat.cpp b/lldb/source/Interpreter/OptionGroupFormat.cpp
index 8af74ae6c43..795fb038aca 100644
--- a/lldb/source/Interpreter/OptionGroupFormat.cpp
+++ b/lldb/source/Interpreter/OptionGroupFormat.cpp
@@ -67,7 +67,7 @@ OptionGroupFormat::SetOptionValue (CommandInterpreter &interpreter,
const char *option_arg)
{
Error error;
- char short_option = (char) g_option_table[option_idx].short_option;
+ const int short_option = g_option_table[option_idx].short_option;
switch (short_option)
{
diff --git a/lldb/source/Interpreter/OptionGroupOutputFile.cpp b/lldb/source/Interpreter/OptionGroupOutputFile.cpp
index 1ec31da0abf..aa01bf54964 100644
--- a/lldb/source/Interpreter/OptionGroupOutputFile.cpp
+++ b/lldb/source/Interpreter/OptionGroupOutputFile.cpp
@@ -32,7 +32,7 @@ static OptionDefinition
g_option_table[] =
{
{ LLDB_OPT_SET_1 , false, "outfile", 'o', required_argument, NULL, 0, eArgTypeFilename , "Specify a path for capturing command output."},
- { LLDB_OPT_SET_1 , false, "append-outfile" , 'A', no_argument, NULL, 0, eArgTypeNone , "Append to the the file specified with '--outfile <path>'."},
+ { LLDB_OPT_SET_1 , false, "append-outfile" , 'apnd', no_argument, NULL, 0, eArgTypeNone , "Append to the the file specified with '--outfile <path>'."},
};
uint32_t
@@ -49,11 +49,11 @@ OptionGroupOutputFile::GetDefinitions ()
Error
OptionGroupOutputFile::SetOptionValue (CommandInterpreter &interpreter,
- uint32_t option_idx,
- const char *option_arg)
+ uint32_t option_idx,
+ const char *option_arg)
{
Error error;
- char short_option = (char) g_option_table[option_idx].short_option;
+ const int short_option = g_option_table[option_idx].short_option;
switch (short_option)
{
@@ -61,7 +61,7 @@ OptionGroupOutputFile::SetOptionValue (CommandInterpreter &interpreter,
error = m_file.SetValueFromCString (option_arg);
break;
- case 'A':
+ case 'apnd':
m_append.SetCurrentValue(true);
break;
diff --git a/lldb/source/Interpreter/OptionGroupPlatform.cpp b/lldb/source/Interpreter/OptionGroupPlatform.cpp
index 358dc01a428..152ab4dba05 100644
--- a/lldb/source/Interpreter/OptionGroupPlatform.cpp
+++ b/lldb/source/Interpreter/OptionGroupPlatform.cpp
@@ -113,7 +113,7 @@ OptionGroupPlatform::SetOptionValue (CommandInterpreter &interpreter,
if (!m_include_platform_option)
++option_idx;
- char short_option = (char) g_option_table[option_idx].short_option;
+ const int short_option = g_option_table[option_idx].short_option;
switch (short_option)
{
diff --git a/lldb/source/Interpreter/OptionGroupString.cpp b/lldb/source/Interpreter/OptionGroupString.cpp
index 7440fd4973b..ee9623967c6 100644
--- a/lldb/source/Interpreter/OptionGroupString.cpp
+++ b/lldb/source/Interpreter/OptionGroupString.cpp
@@ -20,7 +20,7 @@ using namespace lldb_private;
OptionGroupString::OptionGroupString (uint32_t usage_mask,
bool required,
const char *long_option,
- char short_option,
+ int short_option,
uint32_t completion_type,
lldb::CommandArgumentType argument_type,
const char *usage_text,
diff --git a/lldb/source/Interpreter/OptionGroupUInt64.cpp b/lldb/source/Interpreter/OptionGroupUInt64.cpp
index 76d0260fc7e..e6996f70255 100644
--- a/lldb/source/Interpreter/OptionGroupUInt64.cpp
+++ b/lldb/source/Interpreter/OptionGroupUInt64.cpp
@@ -20,7 +20,7 @@ using namespace lldb_private;
OptionGroupUInt64::OptionGroupUInt64 (uint32_t usage_mask,
bool required,
const char *long_option,
- char short_option,
+ int short_option,
uint32_t completion_type,
lldb::CommandArgumentType argument_type,
const char *usage_text,
diff --git a/lldb/source/Interpreter/OptionGroupUUID.cpp b/lldb/source/Interpreter/OptionGroupUUID.cpp
index 48b0edf11a7..14bdc8494e4 100644
--- a/lldb/source/Interpreter/OptionGroupUUID.cpp
+++ b/lldb/source/Interpreter/OptionGroupUUID.cpp
@@ -47,11 +47,11 @@ OptionGroupUUID::GetDefinitions ()
Error
OptionGroupUUID::SetOptionValue (CommandInterpreter &interpreter,
- uint32_t option_idx,
- const char *option_arg)
+ uint32_t option_idx,
+ const char *option_arg)
{
Error error;
- char short_option = (char) g_option_table[option_idx].short_option;
+ const int short_option = g_option_table[option_idx].short_option;
switch (short_option)
{
diff --git a/lldb/source/Interpreter/OptionGroupValueObjectDisplay.cpp b/lldb/source/Interpreter/OptionGroupValueObjectDisplay.cpp
index 2d734a1babe..532ddc6f1fe 100644
--- a/lldb/source/Interpreter/OptionGroupValueObjectDisplay.cpp
+++ b/lldb/source/Interpreter/OptionGroupValueObjectDisplay.cpp
@@ -64,7 +64,7 @@ OptionGroupValueObjectDisplay::SetOptionValue (CommandInterpreter &interpreter,
const char *option_arg)
{
Error error;
- char short_option = (char) g_option_table[option_idx].short_option;
+ const int short_option = g_option_table[option_idx].short_option;
bool success = false;
switch (short_option)
diff --git a/lldb/source/Interpreter/OptionGroupVariable.cpp b/lldb/source/Interpreter/OptionGroupVariable.cpp
index 9c1cf21728c..151bc894288 100644
--- a/lldb/source/Interpreter/OptionGroupVariable.cpp
+++ b/lldb/source/Interpreter/OptionGroupVariable.cpp
@@ -24,14 +24,14 @@ using namespace lldb_private;
static OptionDefinition
g_option_table[] =
{
- { LLDB_OPT_SET_1 | LLDB_OPT_SET_2, false, "no-args", 'a', no_argument, NULL, 0, eArgTypeNone, "Omit function arguments."},
- { LLDB_OPT_SET_1 | LLDB_OPT_SET_2, false, "no-locals", 'l', no_argument, NULL, 0, eArgTypeNone, "Omit local variables."},
- { LLDB_OPT_SET_1 | LLDB_OPT_SET_2, false, "show-globals", 'g', no_argument, NULL, 0, eArgTypeNone, "Show the current frame source file global and static variables."},
- { LLDB_OPT_SET_1 | LLDB_OPT_SET_2, false, "show-declaration",'c', no_argument, NULL, 0, eArgTypeNone, "Show variable declaration information (source file and line where the variable was declared)."},
- { LLDB_OPT_SET_1 | LLDB_OPT_SET_2, false, "regex", 'r', no_argument, NULL, 0, eArgTypeRegularExpression, "The <variable-name> argument for name lookups are regular expressions."},
- { LLDB_OPT_SET_1 | LLDB_OPT_SET_2, false, "scope", 's', no_argument, NULL, 0, eArgTypeNone, "Show variable scope (argument, local, global, static)."},
- { LLDB_OPT_SET_1, false, "summary", 'y', required_argument, NULL, 0, eArgTypeName, "Specify the summary that the variable output should use."},
- { LLDB_OPT_SET_2, false, "summary-string", 'z', required_argument, NULL, 0, eArgTypeName, "Specify a summary string to use to format the variable output."},
+ { LLDB_OPT_SET_1 | LLDB_OPT_SET_2, false, "no-args", 'a', no_argument, NULL, 0, eArgTypeNone, "Omit function arguments."},
+ { LLDB_OPT_SET_1 | LLDB_OPT_SET_2, false, "no-locals", 'l', no_argument, NULL, 0, eArgTypeNone, "Omit local variables."},
+ { LLDB_OPT_SET_1 | LLDB_OPT_SET_2, false, "show-globals", 'g', no_argument, NULL, 0, eArgTypeNone, "Show the current frame source file global and static variables."},
+ { LLDB_OPT_SET_1 | LLDB_OPT_SET_2, false, "show-declaration",'c', no_argument, NULL, 0, eArgTypeNone, "Show variable declaration information (source file and line where the variable was declared)."},
+ { LLDB_OPT_SET_1 | LLDB_OPT_SET_2, false, "regex", 'r', no_argument, NULL, 0, eArgTypeRegularExpression, "The <variable-name> argument for name lookups are regular expressions."},
+ { LLDB_OPT_SET_1 | LLDB_OPT_SET_2, false, "scope", 's', no_argument, NULL, 0, eArgTypeNone, "Show variable scope (argument, local, global, static)."},
+ { LLDB_OPT_SET_1, false, "summary", 'y', required_argument, NULL, 0, eArgTypeName, "Specify the summary that the variable output should use."},
+ { LLDB_OPT_SET_2, false, "summary-string", 'z', required_argument, NULL, 0, eArgTypeName, "Specify a summary string to use to format the variable output."},
};
@@ -53,7 +53,7 @@ OptionGroupVariable::SetOptionValue (CommandInterpreter &interpreter,
Error error;
if (!include_frame_options)
option_idx += 3;
- char short_option = (char) g_option_table[option_idx].short_option;
+ const int short_option = g_option_table[option_idx].short_option;
switch (short_option)
{
case 'r': use_regex = true; break;
diff --git a/lldb/source/Interpreter/OptionGroupWatchpoint.cpp b/lldb/source/Interpreter/OptionGroupWatchpoint.cpp
index aa5b0001c02..e352a0e705e 100644
--- a/lldb/source/Interpreter/OptionGroupWatchpoint.cpp
+++ b/lldb/source/Interpreter/OptionGroupWatchpoint.cpp
@@ -73,7 +73,7 @@ OptionGroupWatchpoint::SetOptionValue (CommandInterpreter &interpreter,
const char *option_arg)
{
Error error;
- char short_option = (char) g_option_table[option_idx].short_option;
+ const int short_option = g_option_table[option_idx].short_option;
switch (short_option)
{
case 'w':
diff --git a/lldb/source/Interpreter/Options.cpp b/lldb/source/Interpreter/Options.cpp
index 4a04a4639fb..dfb0ab7d284 100644
--- a/lldb/source/Interpreter/Options.cpp
+++ b/lldb/source/Interpreter/Options.cpp
@@ -13,7 +13,7 @@
// C++ Includes
#include <algorithm>
#include <bitset>
-#include <set>
+#include <map>
// Other libraries and framework includes
// Project includes
@@ -58,7 +58,7 @@ Options::NotifyOptionParsingFinished ()
void
Options::OptionSeen (int option_idx)
{
- m_seen_options.insert ((char) option_idx);
+ m_seen_options.insert (option_idx);
}
// Returns true is set_a is a subset of set_b; Otherwise returns false.
@@ -266,37 +266,54 @@ Options::GetLongOptions ()
return NULL;
uint32_t i;
- uint32_t j;
const OptionDefinition *opt_defs = GetDefinitions();
- std::bitset<256> option_seen;
+ std::map<int, uint32_t> option_seen;
m_getopt_table.resize(num_options + 1);
- for (i = 0, j = 0; i < num_options; ++i)
+ for (i = 0; i < num_options; ++i)
{
- const char short_opt = opt_defs[i].short_option;
+ const int short_opt = opt_defs[i].short_option;
+
+ m_getopt_table[i].name = opt_defs[i].long_option;
+ m_getopt_table[i].has_arg = opt_defs[i].option_has_arg;
+ m_getopt_table[i].flag = NULL;
+ m_getopt_table[i].val = short_opt;
- if (option_seen.test(short_opt) == false)
+ if (option_seen.find(short_opt) == option_seen.end())
{
- m_getopt_table[j].name = opt_defs[i].long_option;
- m_getopt_table[j].has_arg = opt_defs[i].option_has_arg;
- m_getopt_table[j].flag = NULL;
- m_getopt_table[j].val = short_opt;
- option_seen.set(short_opt);
- ++j;
+ option_seen[short_opt] = i;
}
- else
+ else if (short_opt)
{
- assert (!"duplicate short option character");
+ m_getopt_table[i].val = 0;
+ std::map<int, uint32_t>::const_iterator pos = option_seen.find(short_opt);
+ StreamString strm;
+ if (isprint(short_opt))
+ Host::SystemLog (Host::eSystemLogError, "option[%u] --%s has a short option -%c that conflicts with option[%u] --%s, short option won't be used for --%s\n",
+ i,
+ opt_defs[i].long_option,
+ short_opt,
+ pos->second,
+ m_getopt_table[pos->second].name,
+ opt_defs[i].long_option);
+ else
+ Host::SystemLog (Host::eSystemLogError, "option[%u] --%s has a short option 0x%x that conflicts with option[%u] --%s, short option won't be used for --%s\n",
+ i,
+ opt_defs[i].long_option,
+ short_opt,
+ pos->second,
+ m_getopt_table[pos->second].name,
+ opt_defs[i].long_option);
}
}
//getopt_long requires a NULL final entry in the table:
- m_getopt_table[j].name = NULL;
- m_getopt_table[j].has_arg = 0;
- m_getopt_table[j].flag = NULL;
- m_getopt_table[j].val = 0;
+ m_getopt_table[i].name = NULL;
+ m_getopt_table[i].has_arg = 0;
+ m_getopt_table[i].flag = NULL;
+ m_getopt_table[i].val = 0;
}
if (m_getopt_table.empty())
@@ -393,6 +410,57 @@ Options::SupportsLongOption (const char *long_option)
return false;
}
+enum OptionDisplayType
+{
+ eDisplayBestOption,
+ eDisplayShortOption,
+ eDisplayLongOption
+};
+
+static bool
+PrintOption (const OptionDefinition &opt_def,
+ OptionDisplayType display_type,
+ const char *header,
+ const char *footer,
+ bool show_optional,
+ Stream &strm)
+{
+ const bool has_short_option = isprint(opt_def.short_option) != 0;
+
+ if (display_type == eDisplayShortOption && !has_short_option)
+ return false;
+
+ if (header && header[0])
+ strm.PutCString(header);
+
+ if (show_optional && !opt_def.required)
+ strm.PutChar('[');
+ const bool show_short_option = has_short_option && display_type != eDisplayLongOption;
+ if (show_short_option)
+ strm.Printf ("-%c", opt_def.short_option);
+ else
+ strm.Printf ("--%s", opt_def.long_option);
+ switch (opt_def.option_has_arg)
+ {
+ case no_argument:
+ break;
+ case required_argument:
+ strm.Printf (" <%s>", CommandObject::GetArgumentName (opt_def.argument_type));
+ break;
+
+ case optional_argument:
+ strm.Printf ("%s[<%s>]",
+ show_short_option ? "" : "=",
+ CommandObject::GetArgumentName (opt_def.argument_type));
+ break;
+ }
+ if (show_optional && !opt_def.required)
+ strm.PutChar(']');
+ if (footer && footer[0])
+ strm.PutCString(footer);
+ return true;
+}
+
void
Options::GenerateOptionUsage
(
@@ -450,12 +518,12 @@ Options::GenerateOptionUsage
// a single string. If a command has "-a" "-b" and "-c", this will show
// up as [-abc]
- std::set<char> options;
- std::set<char>::const_iterator options_pos, options_end;
+ std::set<int> options;
+ std::set<int>::const_iterator options_pos, options_end;
bool first;
for (i = 0, first = true; i < num_options; ++i)
{
- if (opt_defs[i].usage_mask & opt_set_mask)
+ if (opt_defs[i].usage_mask & opt_set_mask && isprint(opt_defs[i].short_option))
{
// Add current option to the end of out_stream.
@@ -476,17 +544,17 @@ Options::GenerateOptionUsage
options_pos != options_end;
++options_pos)
{
- if (i==0 && ::isupper (*options_pos))
+ if (i==0 && ::islower (*options_pos))
continue;
- if (i==1 && ::islower (*options_pos))
+ if (i==1 && ::isupper (*options_pos))
continue;
- strm << *options_pos;
+ strm << (char)*options_pos;
}
}
for (i = 0, options.clear(); i < num_options; ++i)
{
- if (opt_defs[i].usage_mask & opt_set_mask)
+ if (opt_defs[i].usage_mask & opt_set_mask && isprint(opt_defs[i].short_option))
{
// Add current option to the end of out_stream.
@@ -507,11 +575,11 @@ Options::GenerateOptionUsage
options_pos != options_end;
++options_pos)
{
- if (i==0 && ::isupper (*options_pos))
+ if (i==0 && ::islower (*options_pos))
continue;
- if (i==1 && ::islower (*options_pos))
+ if (i==1 && ::isupper (*options_pos))
continue;
- strm << *options_pos;
+ strm << (char)*options_pos;
}
strm.PutChar(']');
}
@@ -520,26 +588,10 @@ Options::GenerateOptionUsage
for (i = 0; i < num_options; ++i)
{
- if (opt_defs[i].usage_mask & opt_set_mask)
+ if (opt_defs[i].usage_mask & opt_set_mask && isprint(opt_defs[i].short_option))
{
- // Add current option to the end of out_stream.
- CommandArgumentType arg_type = opt_defs[i].argument_type;
-
- if (opt_defs[i].required)
- {
- if (opt_defs[i].option_has_arg == required_argument)
- {
- strm.Printf (" -%c <%s>",
- opt_defs[i].short_option,
- CommandObject::GetArgumentName (arg_type));
- }
- else if (opt_defs[i].option_has_arg == optional_argument)
- {
- strm.Printf (" -%c [<%s>]",
- opt_defs[i].short_option,
- CommandObject::GetArgumentName (arg_type));
- }
- }
+ if (opt_defs[i].required && opt_defs[i].option_has_arg != no_argument)
+ PrintOption (opt_defs[i], eDisplayBestOption, " ", NULL, true, strm);
}
}
@@ -551,17 +603,8 @@ Options::GenerateOptionUsage
{
// Add current option to the end of out_stream.
- CommandArgumentType arg_type = opt_defs[i].argument_type;
-
- if (! opt_defs[i].required)
- {
- if (opt_defs[i].option_has_arg == required_argument)
- strm.Printf (" [-%c <%s>]", opt_defs[i].short_option,
- CommandObject::GetArgumentName (arg_type));
- else if (opt_defs[i].option_has_arg == optional_argument)
- strm.Printf (" [-%c [<%s>]]", opt_defs[i].short_option,
- CommandObject::GetArgumentName (arg_type));
- }
+ if (!opt_defs[i].required && opt_defs[i].option_has_arg != no_argument)
+ PrintOption (opt_defs[i], eDisplayBestOption, " ", NULL, true, strm);
}
}
@@ -592,86 +635,69 @@ Options::GenerateOptionUsage
// This variable is used to keep track of which options' info we've printed out, because some options can be in
// more than one usage level, but we only want to print the long form of its information once.
- OptionSet options_seen;
- OptionSet::iterator pos;
+ std::multimap<int, uint32_t> options_seen;
strm.IndentMore (5);
- std::vector<char> sorted_options;
-
-
// Put the unique command options in a vector & sort it, so we can output them alphabetically (by short_option)
// when writing out detailed help for each option.
for (i = 0; i < num_options; ++i)
- {
- pos = options_seen.find (opt_defs[i].short_option);
- if (pos == options_seen.end())
- {
- options_seen.insert (opt_defs[i].short_option);
- sorted_options.push_back (opt_defs[i].short_option);
- }
- }
-
- std::sort (sorted_options.begin(), sorted_options.end());
+ options_seen.insert(std::make_pair(opt_defs[i].short_option, i));
// Go through the unique'd and alphabetically sorted vector of options, find the table entry for each option
// and write out the detailed help information for that option.
- int first_option_printed = 1;
- size_t end = sorted_options.size();
- for (size_t j = 0; j < end; ++j)
+ bool first_option_printed = false;;
+
+ for (auto pos : options_seen)
{
- char option = sorted_options[j];
- bool found = false;
- for (i = 0; i < num_options && !found; ++i)
+ i = pos.second;
+ //Print out the help information for this option.
+
+ // Put a newline separation between arguments
+ if (first_option_printed)
+ strm.EOL();
+ else
+ first_option_printed = true;
+
+ CommandArgumentType arg_type = opt_defs[i].argument_type;
+
+ StreamString arg_name_str;
+ arg_name_str.Printf ("<%s>", CommandObject::GetArgumentName (arg_type));
+
+ strm.Indent ();
+ if (opt_defs[i].short_option && isprint(opt_defs[i].short_option))
+ {
+ PrintOption (opt_defs[i], eDisplayShortOption, NULL, NULL, false, strm);
+ PrintOption (opt_defs[i], eDisplayLongOption, " ( ", " )", false, strm);
+ }
+ else
{
- if (opt_defs[i].short_option == option)
+ // Short option is not printable, just print long option
+ PrintOption (opt_defs[i], eDisplayLongOption, NULL, NULL, false, strm);
+ }
+ strm.EOL();
+
+ strm.IndentMore (5);
+
+ if (opt_defs[i].usage_text)
+ OutputFormattedUsageText (strm,
+ opt_defs[i].usage_text,
+ screen_width);
+ if (opt_defs[i].enum_values != NULL)
+ {
+ strm.Indent ();
+ strm.Printf("Values: ");
+ for (int k = 0; opt_defs[i].enum_values[k].string_value != NULL; k++)
{
- found = true;
- //Print out the help information for this option.
-
- // Put a newline separation between arguments
- if (first_option_printed)
- first_option_printed = 0;
+ if (k == 0)
+ strm.Printf("%s", opt_defs[i].enum_values[k].string_value);
else
- strm.EOL();
-
- CommandArgumentType arg_type = opt_defs[i].argument_type;
-
- StreamString arg_name_str;
- arg_name_str.Printf ("<%s>", CommandObject::GetArgumentName (arg_type));
-
- strm.Indent ();
- strm.Printf ("-%c", opt_defs[i].short_option);
- if (arg_type != eArgTypeNone)
- strm.Printf (" <%s>", CommandObject::GetArgumentName (arg_type));
- strm.Printf (" ( --%s", opt_defs[i].long_option);
- if (arg_type != eArgTypeNone)
- strm.Printf (" <%s>", CommandObject::GetArgumentName (arg_type));
- strm.PutCString(" )\n");
-
- strm.IndentMore (5);
-
- if (opt_defs[i].usage_text)
- OutputFormattedUsageText (strm,
- opt_defs[i].usage_text,
- screen_width);
- if (opt_defs[i].enum_values != NULL)
- {
- strm.Indent ();
- strm.Printf("Values: ");
- for (int k = 0; opt_defs[i].enum_values[k].string_value != NULL; k++)
- {
- if (k == 0)
- strm.Printf("%s", opt_defs[i].enum_values[k].string_value);
- else
- strm.Printf(" | %s", opt_defs[i].enum_values[k].string_value);
- }
- strm.EOL();
- }
- strm.IndentLess (5);
+ strm.Printf(" | %s", opt_defs[i].enum_values[k].string_value);
}
+ strm.EOL();
}
+ strm.IndentLess (5);
}
// Restore the indent level
diff --git a/lldb/source/Symbol/VariableList.cpp b/lldb/source/Symbol/VariableList.cpp
index 11eb46c407c..9ab584fae2c 100644
--- a/lldb/source/Symbol/VariableList.cpp
+++ b/lldb/source/Symbol/VariableList.cpp
@@ -67,7 +67,7 @@ VariableList::Clear()
}
VariableSP
-VariableList::GetVariableAtIndex(uint32_t idx)
+VariableList::GetVariableAtIndex(uint32_t idx) const
{
VariableSP var_sp;
if (idx < m_variables.size())
diff --git a/lldb/source/Target/Process.cpp b/lldb/source/Target/Process.cpp
index ca13fad86f5..0f43040c794 100644
--- a/lldb/source/Target/Process.cpp
+++ b/lldb/source/Target/Process.cpp
@@ -681,7 +681,7 @@ Error
ProcessLaunchCommandOptions::SetOptionValue (uint32_t option_idx, const char *option_arg)
{
Error error;
- char short_option = (char) m_getopt_table[option_idx].val;
+ const int short_option = m_getopt_table[option_idx].val;
switch (short_option)
{
OpenPOWER on IntegriCloud