From 3bcdfc0ec19df671655eeedb10da2ff9399b8b65 Mon Sep 17 00:00:00 2001 From: Greg Clayton Date: Tue, 4 Dec 2012 00:32:51 +0000 Subject: [PATCH] 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 --- .../lldb/Interpreter/OptionGroupBoolean.h | 2 +- .../lldb/Interpreter/OptionGroupFile.h | 4 +- .../lldb/Interpreter/OptionGroupString.h | 2 +- .../lldb/Interpreter/OptionGroupUInt64.h | 2 +- lldb/include/lldb/Interpreter/Options.h | 2 +- lldb/include/lldb/Symbol/VariableList.h | 2 +- lldb/include/lldb/lldb-private-types.h | 2 +- lldb/source/Commands/CommandObjectArgs.cpp | 2 +- .../Commands/CommandObjectBreakpoint.cpp | 8 +- .../CommandObjectBreakpointCommand.cpp | 2 +- .../source/Commands/CommandObjectCommands.cpp | 10 +- .../Commands/CommandObjectDisassemble.cpp | 2 +- .../Commands/CommandObjectExpression.cpp | 2 +- lldb/source/Commands/CommandObjectFrame.cpp | 2 +- lldb/source/Commands/CommandObjectHelp.h | 2 +- lldb/source/Commands/CommandObjectLog.cpp | 2 +- lldb/source/Commands/CommandObjectMemory.cpp | 4 +- .../source/Commands/CommandObjectPlatform.cpp | 2 +- lldb/source/Commands/CommandObjectProcess.cpp | 8 +- .../source/Commands/CommandObjectRegister.cpp | 2 +- .../source/Commands/CommandObjectSettings.cpp | 2 +- lldb/source/Commands/CommandObjectSource.cpp | 4 +- lldb/source/Commands/CommandObjectTarget.cpp | 199 ++++++++++--- lldb/source/Commands/CommandObjectThread.cpp | 6 +- lldb/source/Commands/CommandObjectType.cpp | 26 +- .../Commands/CommandObjectWatchpoint.cpp | 6 +- .../CommandObjectWatchpointCommand.cpp | 2 +- lldb/source/Core/Log.cpp | 2 +- lldb/source/Interpreter/Args.cpp | 30 +- .../Interpreter/OptionGroupArchitecture.cpp | 2 +- .../source/Interpreter/OptionGroupBoolean.cpp | 2 +- lldb/source/Interpreter/OptionGroupFile.cpp | 8 +- lldb/source/Interpreter/OptionGroupFormat.cpp | 2 +- .../Interpreter/OptionGroupOutputFile.cpp | 10 +- .../Interpreter/OptionGroupPlatform.cpp | 2 +- lldb/source/Interpreter/OptionGroupString.cpp | 2 +- lldb/source/Interpreter/OptionGroupUInt64.cpp | 2 +- lldb/source/Interpreter/OptionGroupUUID.cpp | 6 +- .../OptionGroupValueObjectDisplay.cpp | 2 +- .../Interpreter/OptionGroupVariable.cpp | 18 +- .../Interpreter/OptionGroupWatchpoint.cpp | 2 +- lldb/source/Interpreter/Options.cpp | 278 ++++++++++-------- lldb/source/Symbol/VariableList.cpp | 2 +- lldb/source/Target/Process.cpp | 2 +- .../formatters/TestFormatters.py | 6 +- .../TestBreakpointCommand.py | 4 +- .../TestBreakpointConditions.py | 8 +- .../TestDataFormatterAdv.py | 2 +- .../TestDataFormatterPythonSynth.py | 8 +- .../TestDataFormatterSkipSummary.py | 24 +- .../list/TestDataFormatterLibcxxList.py | 2 +- .../libcxx/map/TestDataFormatterLibccMap.py | 8 +- .../list/TestDataFormatterStdList.py | 2 +- .../libstdcpp/map/TestDataFormatterStdMap.py | 8 +- .../TestDataFormatterSynth.py | 16 +- .../rdar-11988289/TestRdar 11988289.py | 8 +- .../rdar-12437442/TestRdar12437442.py | 4 +- .../TestStopHookMultipleThreads.py | 2 +- .../command/TestWatchpointCommandLLDB.py | 2 +- .../command/TestWatchpointCommandPython.py | 2 +- .../condition/TestWatchpointConditionCmd.py | 2 +- .../test/lang/c/array_types/TestArrayTypes.py | 8 +- lldb/test/lang/c/bitfields/TestBitfields.py | 4 +- .../lang/c/forward/TestForwardDeclaration.py | 2 +- .../c/function_types/TestFunctionTypes.py | 2 +- .../c/global_variables/TestGlobalVariables.py | 8 +- lldb/test/lang/c/set_values/TestSetValues.py | 30 +- .../lang/cpp/class_types/TestClassTypes.py | 6 +- lldb/test/lang/cpp/namespace/TestNamespace.py | 4 +- .../lang/cpp/signed_types/TestSignedTypes.py | 2 +- .../lang/cpp/unique-types/TestUniqueTypes.py | 8 +- .../cpp/unsigned_types/TestUnsignedTypes.py | 2 +- .../lang/objc/foundation/TestObjCMethods.py | 8 +- .../objc/rdar-11355592/TestRdar11355592.py | 8 +- lldb/test/types/AbstractBase.py | 14 +- lldb/tools/driver/Driver.cpp | 4 +- 76 files changed, 520 insertions(+), 379 deletions(-) diff --git a/lldb/include/lldb/Interpreter/OptionGroupBoolean.h b/lldb/include/lldb/Interpreter/OptionGroupBoolean.h index 45f24640a2a7..0d861b241694 100644 --- a/lldb/include/lldb/Interpreter/OptionGroupBoolean.h +++ b/lldb/include/lldb/Interpreter/OptionGroupBoolean.h @@ -31,7 +31,7 @@ namespace lldb_private { 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/include/lldb/Interpreter/OptionGroupFile.h b/lldb/include/lldb/Interpreter/OptionGroupFile.h index 9730b5b74347..632a2dbdf220 100644 --- a/lldb/include/lldb/Interpreter/OptionGroupFile.h +++ b/lldb/include/lldb/Interpreter/OptionGroupFile.h @@ -31,7 +31,7 @@ public: 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); @@ -89,7 +89,7 @@ public: 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); diff --git a/lldb/include/lldb/Interpreter/OptionGroupString.h b/lldb/include/lldb/Interpreter/OptionGroupString.h index 9389f0d1864b..e62a81bc4118 100644 --- a/lldb/include/lldb/Interpreter/OptionGroupString.h +++ b/lldb/include/lldb/Interpreter/OptionGroupString.h @@ -29,7 +29,7 @@ namespace lldb_private { 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/include/lldb/Interpreter/OptionGroupUInt64.h b/lldb/include/lldb/Interpreter/OptionGroupUInt64.h index 428d927739a8..c5f9e85d2f8f 100644 --- a/lldb/include/lldb/Interpreter/OptionGroupUInt64.h +++ b/lldb/include/lldb/Interpreter/OptionGroupUInt64.h @@ -29,7 +29,7 @@ namespace lldb_private { 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/include/lldb/Interpreter/Options.h b/lldb/include/lldb/Interpreter/Options.h index 861c62245c2e..e1314450a0d1 100644 --- a/lldb/include/lldb/Interpreter/Options.h +++ b/lldb/include/lldb/Interpreter/Options.h @@ -296,7 +296,7 @@ public: protected: // This is a set of options expressed as indexes into the options table for this Option. - typedef std::set OptionSet; + typedef std::set OptionSet; typedef std::vector OptionSetVector; CommandInterpreter &m_interpreter; diff --git a/lldb/include/lldb/Symbol/VariableList.h b/lldb/include/lldb/Symbol/VariableList.h index 21f37e4fc9f0..e2b5722f1f66 100644 --- a/lldb/include/lldb/Symbol/VariableList.h +++ b/lldb/include/lldb/Symbol/VariableList.h @@ -42,7 +42,7 @@ public: Dump(Stream *s, bool show_context) const; lldb::VariableSP - GetVariableAtIndex(uint32_t idx); + GetVariableAtIndex(uint32_t idx) const; lldb::VariableSP RemoveVariableAtIndex (uint32_t idx); diff --git a/lldb/include/lldb/lldb-private-types.h b/lldb/include/lldb/lldb-private-types.h index 710e37cfd6b6..4340af114be3 100644 --- a/lldb/include/lldb/lldb-private-types.h +++ b/lldb/include/lldb/lldb-private-types.h @@ -58,7 +58,7 @@ namespace lldb_private // then this option belongs to option set n. bool required; // This option is required (in the current usage level) const char *long_option; // Full name for this option. - char short_option; // Single character for this option. + int short_option; // Single character for this option. int option_has_arg; // no_argument, required_argument or optional_argument OptionEnumValueElement *enum_values; // If non-NULL an array of enum values. uint32_t completion_type; // Cookie the option class can use to do define the argument completion. diff --git a/lldb/source/Commands/CommandObjectArgs.cpp b/lldb/source/Commands/CommandObjectArgs.cpp index 2ae91e10cb53..24cf9bc8b814 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 7c673f7fe674..bb8617f97805 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 f308ae3713cb..53b6b4e21716 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 5999f7c89355..e1bd287a8631 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 45fdda717315..bed64d42e370 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 a93d4e65fa08..1110c1f321cb 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 eab0d02c188c..53de2b144485 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 b66d69f476f4..91a40b529496 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 fb982972d267..35fcacc4b18b 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 fffbda1d1430..2f79e52b4cd7 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 3be46ab872eb..10700aa1bb68 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 68f577ffcf56..1fae2dee8b4b 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 6873450fc2e6..896b0187b9d4 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 e55da23bac75..7c578326511b 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 c4ccf2a2167b..5162d53ab1e3 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 2dc5fab48296..2a5b6c6d4c45 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; iGetName().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; iGetSize(); + 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 (!success) { - if (comp_unit) - result.AppendErrorWithFormat ("no global variables in current compile unit: %s/%s\n", - comp_unit->GetDirectory().GetCString(), - comp_unit->GetFilename().GetCString()); + 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 ("no debug information for frame %u\n", frame->GetFrameIndex()); - } + result.AppendError ("'target variable' takes one or more global variable names as arguments\n"); + result.SetStatus (eReturnStatusFailed); + } + } + else + { + SymbolContextList sc_list; + const bool append = true; + // We have one or more compile unit or shlib + if (num_shlibs > 0) + { + for (size_t shlib_idx=0; shlib_idxGetImages().FindFirstModule(module_spec)); + if (module_sp) + { + if (num_compile_units > 0) + { + for (size_t cu_idx=0; cu_idxFindCompileUnits(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_idxGetImages().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_idxGetVariableList(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 f555b624e11d..49167e8a09d8 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 ba2a9f3bd6b7..335b38c1215a 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 8d907ae57400..00a78837e4e6 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 eaf3b35f645d..2f4824959cd6 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 b8671f7ddc9a..9b4e4e076a03 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 1518968bd616..dde546c687b8 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 175605154ec8..af103bb0bd9d 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 58ac0f1def84..5b5b38478b02 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 4749087da6cc..6867395789c7 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 8af74ae6c43c..795fb038aca4 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 1ec31da0abf6..aa01bf54964f 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 '."}, + { LLDB_OPT_SET_1 , false, "append-outfile" , 'apnd', no_argument, NULL, 0, eArgTypeNone , "Append to the the file specified with '--outfile '."}, }; 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 358dc01a4280..152ab4dba055 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 7440fd4973bc..ee9623967c60 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 76d0260fc7e5..e6996f702558 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 48b0edf11a7f..14bdc8494e45 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 2d734a1babe1..532ddc6f1fef 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 9c1cf21728ce..151bc8942882 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 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 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 aa5b0001c02b..e352a0e705e3 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 4a04a4639fb8..dfb0ab7d2848 100644 --- a/lldb/source/Interpreter/Options.cpp +++ b/lldb/source/Interpreter/Options.cpp @@ -13,7 +13,7 @@ // C++ Includes #include #include -#include +#include // 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 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; - if (option_seen.test(short_opt) == false) + 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.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::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 options; - std::set::const_iterator options_pos, options_end; + std::set options; + std::set::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 options_seen; strm.IndentMore (5); - std::vector 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)) { - if (opt_defs[i].short_option == option) - { - found = true; - //Print out the help information for this option. - - // Put a newline separation between arguments - if (first_option_printed) - first_option_printed = 0; - 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); - } + PrintOption (opt_defs[i], eDisplayShortOption, NULL, NULL, false, strm); + PrintOption (opt_defs[i], eDisplayLongOption, " ( ", " )", false, strm); } + else + { + // 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++) + { + 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); } // Restore the indent level diff --git a/lldb/source/Symbol/VariableList.cpp b/lldb/source/Symbol/VariableList.cpp index 11eb46c407ca..9ab584fae2ca 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 ca13fad86f56..0f43040c7944 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) { diff --git a/lldb/test/expression_command/formatters/TestFormatters.py b/lldb/test/expression_command/formatters/TestFormatters.py index 8d13981b2409..83b7720bfcf1 100644 --- a/lldb/test/expression_command/formatters/TestFormatters.py +++ b/lldb/test/expression_command/formatters/TestFormatters.py @@ -52,9 +52,9 @@ class ExprFormattersTestCase(TestBase): self.runCmd("script import formatters") self.runCmd("script import foosynth") - self.runCmd("frame variable foo1 -T") - self.runCmd("frame variable foo1.b -T") - self.runCmd("frame variable foo1.b.b_ref -T") + self.runCmd("frame variable foo1 --show-types") + self.runCmd("frame variable foo1.b --show-types") + self.runCmd("frame variable foo1.b.b_ref --show-types") self.expect("expression *(new foo(47))", substrs = ['(int) a = 47', '(bar) b = {', '(int) i = 94', '(baz) b = {', '(int) k = 99']) diff --git a/lldb/test/functionalities/breakpoint/breakpoint_command/TestBreakpointCommand.py b/lldb/test/functionalities/breakpoint/breakpoint_command/TestBreakpointCommand.py index 372ee6b99ab3..e6fe72e73507 100644 --- a/lldb/test/functionalities/breakpoint/breakpoint_command/TestBreakpointCommand.py +++ b/lldb/test/functionalities/breakpoint/breakpoint_command/TestBreakpointCommand.py @@ -54,7 +54,7 @@ class BreakpointCommandTestCase(TestBase): lldbutil.run_break_set_by_file_and_line (self, "main.c", self.line, num_expected_locations=1, loc_exact=True) # Now add callbacks for the breakpoints just created. - self.runCmd("breakpoint command add -s command -o 'frame variable -T -s' 1") + self.runCmd("breakpoint command add -s command -o 'frame variable --show-types --scope' 1") self.runCmd("breakpoint command add -s python -o 'here = open(\"output.txt\", \"w\"); print >> here, \"lldb\"; here.close()' 2") self.runCmd("breakpoint command add --python-function bktptcmd.function 3") @@ -73,7 +73,7 @@ class BreakpointCommandTestCase(TestBase): self.expect("breakpoint command list 1", "Breakpoint 1 command ok", substrs = ["Breakpoint commands:", - "frame variable -T -s"]) + "frame variable --show-types --scope"]) self.expect("breakpoint command list 2", "Breakpoint 2 command ok", substrs = ["Breakpoint commands:", "here = open", diff --git a/lldb/test/functionalities/breakpoint/breakpoint_conditions/TestBreakpointConditions.py b/lldb/test/functionalities/breakpoint/breakpoint_conditions/TestBreakpointConditions.py index bb0e1773d347..786588bdfea3 100644 --- a/lldb/test/functionalities/breakpoint/breakpoint_conditions/TestBreakpointConditions.py +++ b/lldb/test/functionalities/breakpoint/breakpoint_conditions/TestBreakpointConditions.py @@ -85,8 +85,8 @@ class BreakpointConditionsTestCase(TestBase): self.expect("process status", PROCESS_STOPPED, patterns = ['Process .* stopped']) - # 'frame variable -T val' should return 3 due to breakpoint condition. - self.expect("frame variable -T val", VARIABLES_DISPLAYED_CORRECTLY, + # 'frame variable --show-types val' should return 3 due to breakpoint condition. + self.expect("frame variable --show-types val", VARIABLES_DISPLAYED_CORRECTLY, startstr = '(int) val = 3') # Also check the hit count, which should be 3, by design. @@ -116,8 +116,8 @@ class BreakpointConditionsTestCase(TestBase): self.expect("process status", PROCESS_STOPPED, patterns = ['Process .* stopped']) - # 'frame variable -T val' should return 1 since it is the first breakpoint hit. - self.expect("frame variable -T val", VARIABLES_DISPLAYED_CORRECTLY, + # 'frame variable --show-types val' should return 1 since it is the first breakpoint hit. + self.expect("frame variable --show-types val", VARIABLES_DISPLAYED_CORRECTLY, startstr = '(int) val = 1') diff --git a/lldb/test/functionalities/data-formatter/data-formatter-advanced/TestDataFormatterAdv.py b/lldb/test/functionalities/data-formatter/data-formatter-advanced/TestDataFormatterAdv.py index ce532fc26960..15596b316bc8 100644 --- a/lldb/test/functionalities/data-formatter/data-formatter-advanced/TestDataFormatterAdv.py +++ b/lldb/test/functionalities/data-formatter/data-formatter-advanced/TestDataFormatterAdv.py @@ -284,7 +284,7 @@ class AdvDataFormatterTestCase(TestBase): 'i_2', 'k_2', 'o_2']) - self.expect('frame variable a_long_guy -A', matching=False, + self.expect('frame variable a_long_guy --show-all-children', matching=False, substrs = ['...']) diff --git a/lldb/test/functionalities/data-formatter/data-formatter-python-synth/TestDataFormatterPythonSynth.py b/lldb/test/functionalities/data-formatter/data-formatter-python-synth/TestDataFormatterPythonSynth.py index efe64420dd80..8bd276e47daf 100644 --- a/lldb/test/functionalities/data-formatter/data-formatter-python-synth/TestDataFormatterPythonSynth.py +++ b/lldb/test/functionalities/data-formatter/data-formatter-python-synth/TestDataFormatterPythonSynth.py @@ -126,7 +126,7 @@ class PythonSynthDataFormatterTestCase(TestBase): 'a = 280']); # check that expanding a pointer does the right thing - self.expect("frame variable -P 1 f00_ptr", + self.expect("frame variable --ptr-depth 1 f00_ptr", substrs = ['r = 45', 'fake_a = 218103808', 'a = 12']) @@ -139,7 +139,7 @@ class PythonSynthDataFormatterTestCase(TestBase): self.expect('frame variable f00_1', matching=False, substrs = ['b = 1', 'j = 17']) - self.expect("frame variable -P 1 f00_ptr", + self.expect("frame variable --ptr-depth 1 f00_ptr", substrs = ['r = 45', 'fake_a = 218103808', 'a = 12']) @@ -151,7 +151,7 @@ class PythonSynthDataFormatterTestCase(TestBase): self.expect('frame variable f00_1', substrs = ['b = 1', 'j = 17']) - self.expect("frame variable -P 1 f00_ptr", matching=False, + self.expect("frame variable --ptr-depth 1 f00_ptr", matching=False, substrs = ['r = 45', 'fake_a = 218103808', 'a = 12']) @@ -176,7 +176,7 @@ class PythonSynthDataFormatterTestCase(TestBase): self.expect('frame variable f00_1', matching=False, substrs = ['b = 1', 'j = 17']) - self.expect("frame variable -P 1 f00_ptr", + self.expect("frame variable --ptr-depth 1 f00_ptr", substrs = ['r = 45', 'fake_a = 218103808', 'a = 12']) diff --git a/lldb/test/functionalities/data-formatter/data-formatter-skip-summary/TestDataFormatterSkipSummary.py b/lldb/test/functionalities/data-formatter/data-formatter-skip-summary/TestDataFormatterSkipSummary.py index 1ffcdbf13c8d..baf3f2d244bd 100644 --- a/lldb/test/functionalities/data-formatter/data-formatter-skip-summary/TestDataFormatterSkipSummary.py +++ b/lldb/test/functionalities/data-formatter/data-formatter-skip-summary/TestDataFormatterSkipSummary.py @@ -74,7 +74,7 @@ class SkipSummaryDataFormatterTestCase(TestBase): '}']) # Skip the default (should be 1) levels of summaries - self.expect('frame variable -Y', + self.expect('frame variable --no-summary-depth', substrs = ['(DeepData_1) data1 = {', 'm_child1 = 0x', '}', @@ -86,7 +86,7 @@ class SkipSummaryDataFormatterTestCase(TestBase): '}']) # Now skip 2 levels of summaries - self.expect('frame variable -Y2', + self.expect('frame variable --no-summary-depth=2', substrs = ['(DeepData_1) data1 = {', 'm_child1 = 0x', '}', @@ -99,15 +99,15 @@ class SkipSummaryDataFormatterTestCase(TestBase): '}']) # Check that no "Level 3" comes out - self.expect('frame variable data1.m_child1 -Y2', matching=False, + self.expect('frame variable data1.m_child1 --no-summary-depth=2', matching=False, substrs = ['Level 3']) # Now expand a pointer with 2 level of skipped summaries - self.expect('frame variable data1.m_child1 -Y2', + self.expect('frame variable data1.m_child1 --no-summary-depth=2', substrs = ['(DeepData_2 *) data1.m_child1 = 0x']) # Deref and expand said pointer - self.expect('frame variable *data1.m_child1 -Y2', + self.expect('frame variable *data1.m_child1 --no-summary-depth=2', substrs = ['(DeepData_2) *data1.m_child1 = {', 'm_child2 = {', 'm_child1 = 0x', @@ -115,7 +115,7 @@ class SkipSummaryDataFormatterTestCase(TestBase): '}']) # Expand an expression, skipping 2 layers of summaries - self.expect('frame variable data1.m_child1->m_child2 -Y2', + self.expect('frame variable data1.m_child1->m_child2 --no-summary-depth=2', substrs = ['(DeepData_3) data1.m_child1->m_child2 = {', 'm_child2 = {', 'm_child1 = Level 5', @@ -124,7 +124,7 @@ class SkipSummaryDataFormatterTestCase(TestBase): '}']) # Expand same expression, skipping only 1 layer of summaries - self.expect('frame variable data1.m_child1->m_child2 -Y1', + self.expect('frame variable data1.m_child1->m_child2 --no-summary-depth=1', substrs = ['(DeepData_3) data1.m_child1->m_child2 = {', 'm_child1 = 0x', 'Level 4', @@ -148,14 +148,14 @@ class SkipSummaryDataFormatterTestCase(TestBase): self.skipTest("rdar://problem/9804600 wrong namespace for std::string in debug info") # Expand same expression, skipping 3 layers of summaries - self.expect('frame variable data1.m_child1->m_child2 -T -Y3', + self.expect('frame variable data1.m_child1->m_child2 --show-types --no-summary-depth=3', substrs = ['(DeepData_3) data1.m_child1->m_child2 = {', 'm_some_text = "Just a test"', 'm_child2 = {', 'm_some_text = "Just a test"']) # Expand within a standard string (might depend on the implementation of the C++ stdlib you use) - self.expect('frame variable data1.m_child1->m_child2.m_child1.m_child2 -Y2', + self.expect('frame variable data1.m_child1->m_child2.m_child1.m_child2 --no-summary-depth=2', substrs = ['(DeepData_5) data1.m_child1->m_child2.m_child1.m_child2 = {', 'm_some_text = {', '_M_dataplus = {', @@ -163,18 +163,18 @@ class SkipSummaryDataFormatterTestCase(TestBase): '"Just a test"']) # Repeat the above, but only skip 1 level of summaries - self.expect('frame variable data1.m_child1->m_child2.m_child1.m_child2 -Y1', + self.expect('frame variable data1.m_child1->m_child2.m_child1.m_child2 --no-summary-depth=1', substrs = ['(DeepData_5) data1.m_child1->m_child2.m_child1.m_child2 = {', 'm_some_text = "Just a test"', '}']) - # Change summary and expand, first without -Y then with -Y + # Change summary and expand, first without --no-summary-depth then with --no-summary-depth self.runCmd("type summary add --summary-string \"${var.m_some_text}\" DeepData_5") self.expect('fr var data2.m_child4.m_child2.m_child2', substrs = ['(DeepData_5) data2.m_child4.m_child2.m_child2 = "Just a test"']) - self.expect('fr var data2.m_child4.m_child2.m_child2 -Y', + self.expect('fr var data2.m_child4.m_child2.m_child2 --no-summary-depth', substrs = ['(DeepData_5) data2.m_child4.m_child2.m_child2 = {', 'm_some_text = "Just a test"', '}']) diff --git a/lldb/test/functionalities/data-formatter/data-formatter-stl/libcxx/list/TestDataFormatterLibcxxList.py b/lldb/test/functionalities/data-formatter/data-formatter-stl/libcxx/list/TestDataFormatterLibcxxList.py index 5e14bbc7f213..394fd70be336 100644 --- a/lldb/test/functionalities/data-formatter/data-formatter-stl/libcxx/list/TestDataFormatterLibcxxList.py +++ b/lldb/test/functionalities/data-formatter/data-formatter-stl/libcxx/list/TestDataFormatterLibcxxList.py @@ -58,7 +58,7 @@ class LibcxxListDataFormatterTestCase(TestBase): # Execute the cleanup function during test case tear down. self.addTearDownHook(cleanup) - self.runCmd("frame variable numbers_list -T") + self.runCmd("frame variable numbers_list --show-types") self.runCmd("type summary add std::int_list std::string_list int_list string_list --summary-string \"list has ${svar%#} items\" -e") self.runCmd("type format add -f hex int") diff --git a/lldb/test/functionalities/data-formatter/data-formatter-stl/libcxx/map/TestDataFormatterLibccMap.py b/lldb/test/functionalities/data-formatter/data-formatter-stl/libcxx/map/TestDataFormatterLibccMap.py index aa53f3c3f973..e851b6370b12 100644 --- a/lldb/test/functionalities/data-formatter/data-formatter-stl/libcxx/map/TestDataFormatterLibccMap.py +++ b/lldb/test/functionalities/data-formatter/data-formatter-stl/libcxx/map/TestDataFormatterLibccMap.py @@ -58,7 +58,7 @@ class LibcxxMapDataFormatterTestCase(TestBase): self.expect('image list',substrs=['libc++.1.dylib','libc++abi.dylib']) - self.runCmd("frame variable ii -T") + self.runCmd("frame variable ii --show-types") self.runCmd("type summary add -x \"std::__1::map<\" --summary-string \"map has ${svar%#} items\" -e") @@ -135,7 +135,7 @@ class LibcxxMapDataFormatterTestCase(TestBase): substrs = ['map has 0 items', '{}']) - self.runCmd("frame variable si -T") + self.runCmd("frame variable si --show-types") self.expect('frame variable si', substrs = ['map has 0 items', @@ -206,7 +206,7 @@ class LibcxxMapDataFormatterTestCase(TestBase): '{}']) self.runCmd("n") - self.runCmd("frame variable is -T") + self.runCmd("frame variable is --show-types") self.expect('frame variable is', substrs = ['map has 0 items', @@ -267,7 +267,7 @@ class LibcxxMapDataFormatterTestCase(TestBase): '{}']) self.runCmd("n");self.runCmd("n"); - self.runCmd("frame variable ss -T") + self.runCmd("frame variable ss --show-types") self.expect('frame variable ss', substrs = ['map has 0 items', diff --git a/lldb/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/list/TestDataFormatterStdList.py b/lldb/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/list/TestDataFormatterStdList.py index 76afc20a7634..307d639449da 100644 --- a/lldb/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/list/TestDataFormatterStdList.py +++ b/lldb/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/list/TestDataFormatterStdList.py @@ -56,7 +56,7 @@ class StdListDataFormatterTestCase(TestBase): # Execute the cleanup function during test case tear down. self.addTearDownHook(cleanup) - self.runCmd("frame variable numbers_list -T") + self.runCmd("frame variable numbers_list --show-types") #self.runCmd("type synth add std::int_list std::string_list int_list string_list -l StdListSynthProvider") self.runCmd("type summary add std::int_list std::string_list int_list string_list --summary-string \"list has ${svar%#} items\" -e") self.runCmd("type format add -f hex int") diff --git a/lldb/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/map/TestDataFormatterStdMap.py b/lldb/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/map/TestDataFormatterStdMap.py index dee671b0e558..f3d3a80ace9f 100644 --- a/lldb/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/map/TestDataFormatterStdMap.py +++ b/lldb/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/map/TestDataFormatterStdMap.py @@ -56,7 +56,7 @@ class StdMapDataFormatterTestCase(TestBase): # Execute the cleanup function during test case tear down. self.addTearDownHook(cleanup) - self.runCmd("frame variable ii -T") + self.runCmd("frame variable ii --show-types") self.runCmd("type summary add -x \"std::map<\" --summary-string \"map has ${svar%#} items\" -e") @@ -136,7 +136,7 @@ class StdMapDataFormatterTestCase(TestBase): '{}']) self.runCmd("n") - self.runCmd("frame variable si -T") + self.runCmd("frame variable si --show-types") self.expect('frame variable si', substrs = ['map has 0 items', @@ -211,7 +211,7 @@ class StdMapDataFormatterTestCase(TestBase): '{}']) self.runCmd("n") - self.runCmd("frame variable is -T") + self.runCmd("frame variable is --show-types") self.expect('frame variable is', substrs = ['map has 0 items', @@ -272,7 +272,7 @@ class StdMapDataFormatterTestCase(TestBase): '{}']) self.runCmd("n") - self.runCmd("frame variable ss -T") + self.runCmd("frame variable ss --show-types") self.expect('frame variable ss', substrs = ['map has 0 items', diff --git a/lldb/test/functionalities/data-formatter/data-formatter-synth/TestDataFormatterSynth.py b/lldb/test/functionalities/data-formatter/data-formatter-synth/TestDataFormatterSynth.py index 0ffc29af9ff3..bd96049f5746 100644 --- a/lldb/test/functionalities/data-formatter/data-formatter-synth/TestDataFormatterSynth.py +++ b/lldb/test/functionalities/data-formatter/data-formatter-synth/TestDataFormatterSynth.py @@ -71,7 +71,7 @@ class SynthDataFormatterTestCase(TestBase): 'z = 8']) # if we skip synth and summary show y - self.expect("frame variable int_bag -S false -Y1", + self.expect("frame variable int_bag --synthetic-type false --no-summary-depth=1", substrs = ['x = 6', 'y = 7', 'z = 8']) @@ -97,7 +97,7 @@ class SynthDataFormatterTestCase(TestBase): 'z = 8']) # If I skip summaries, still give me the artificial children - self.expect("frame variable int_bag -Y1", + self.expect("frame variable int_bag --no-summary-depth=1", substrs = ['x = 6', 'z = 8']) @@ -135,14 +135,14 @@ class SynthDataFormatterTestCase(TestBase): # ...even bitfields self.runCmd("type filter add BagOfBags --child x.y --child \"y->z[1-2]\"") - self.expect('frame variable bag_bag -T', + self.expect('frame variable bag_bag --show-types', substrs = ['x.y = 70', '(int:2) y->z[1-2] = 2']) # ...even if we format the bitfields self.runCmd("type filter add BagOfBags --child x.y --child \"y->y[0-0]\"") self.runCmd("type format add \"int:1\" -f bool") - self.expect('frame variable bag_bag -T', + self.expect('frame variable bag_bag --show-types', substrs = ['x.y = 70', '(int:1) y->y[0-0] = true']) @@ -167,7 +167,7 @@ class SynthDataFormatterTestCase(TestBase): 'array[2] = 3']) # skip synthetic children - self.expect('frame variable plenty_of_stuff -S no', + self.expect('frame variable plenty_of_stuff --synthetic-type no', substrs = ['some_values = 0x0', 'array = 0x', 'array_size = 5']) @@ -180,19 +180,19 @@ class SynthDataFormatterTestCase(TestBase): '*(plenty_of_stuff.array) = 3']) # check that we do not lose location information for our children - self.expect('frame variable plenty_of_stuff -L', + self.expect('frame variable plenty_of_stuff --location', substrs = ['0x', ': bitfield = 17']) # check we work across pointer boundaries - self.expect('frame variable plenty_of_stuff.some_values -P1', + self.expect('frame variable plenty_of_stuff.some_values --ptr-depth=1', substrs = ['(BagOfInts *) plenty_of_stuff.some_values', 'x = 5', 'z = 7']) # but not if we don't want to self.runCmd("type filter add BagOfInts --child x --child z -p") - self.expect('frame variable plenty_of_stuff.some_values -P1', + self.expect('frame variable plenty_of_stuff.some_values --ptr-depth=1', substrs = ['(BagOfInts *) plenty_of_stuff.some_values', 'x = 5', 'y = 6', diff --git a/lldb/test/functionalities/data-formatter/rdar-11988289/TestRdar 11988289.py b/lldb/test/functionalities/data-formatter/rdar-11988289/TestRdar 11988289.py index 9b81705fadaf..ed3896188671 100644 --- a/lldb/test/functionalities/data-formatter/rdar-11988289/TestRdar 11988289.py +++ b/lldb/test/functionalities/data-formatter/rdar-11988289/TestRdar 11988289.py @@ -65,13 +65,13 @@ class DataFormatterRdar11988289TestCase(TestBase): substrs = ['3 key/value pairs','[0] = {','key = 0x','value = 0x','[1] = {','[2] = {']) self.expect('frame variable mutable --ptr-depth 1', substrs = ['4 key/value pairs','[0] = {','key = 0x','value = 0x','[1] = {','[2] = {','[3] = {']) - self.expect('frame variable dictionary --ptr-depth 1 -d no-run-target', + self.expect('frame variable dictionary --ptr-depth 1 --dynamic-type no-run-target', substrs = ['3 key/value pairs','@"bar"','@"2 objects"','@"baz"','2 key/value pairs']) - self.expect('frame variable mutable --ptr-depth 1 -d no-run-target', + self.expect('frame variable mutable --ptr-depth 1 --dynamic-type no-run-target', substrs = ['4 key/value pairs','(int)23','@"123"','@"http://www.apple.com"','@"puartist"','3 key/value pairs']) - self.expect('frame variable mutable --ptr-depth 2 -d no-run-target', + self.expect('frame variable mutable --ptr-depth 2 --dynamic-type no-run-target', substrs = ['4 key/value pairs','(int)23','@"123"','@"http://www.apple.com"','@"puartist"','3 key/value pairs {','@"bar"','@"2 objects"']) - self.expect('frame variable mutable --ptr-depth 3 -d no-run-target', + self.expect('frame variable mutable --ptr-depth 3 --dynamic-type no-run-target', substrs = ['4 key/value pairs','(int)23','@"123"','@"http://www.apple.com"','@"puartist"','3 key/value pairs {','@"bar"','@"2 objects"','(int)1','@"two"']) self.assertTrue(self.frame().FindVariable("dictionary").MightHaveChildren(), "dictionary says it does not have children!") diff --git a/lldb/test/functionalities/data-formatter/rdar-12437442/TestRdar12437442.py b/lldb/test/functionalities/data-formatter/rdar-12437442/TestRdar12437442.py index aa3c6b018e92..eed7b1196ddb 100644 --- a/lldb/test/functionalities/data-formatter/rdar-12437442/TestRdar12437442.py +++ b/lldb/test/functionalities/data-formatter/rdar-12437442/TestRdar12437442.py @@ -64,7 +64,7 @@ class DataFormatterRdar12437442TestCase(TestBase): id_x.SetPreferSyntheticValue(True) if self.TraceOn(): - self.runCmd("frame variable x -d run-target --ptr-depth 1") + self.runCmd("frame variable x --dynamic-type run-target --ptr-depth 1") self.assertTrue(id_x.GetSummary() == '@"5 objects"', "array does not get correct summary") @@ -75,7 +75,7 @@ class DataFormatterRdar12437442TestCase(TestBase): id_x.SetPreferSyntheticValue(True) if self.TraceOn(): - self.runCmd("frame variable x -d run-target --ptr-depth 1") + self.runCmd("frame variable x --dynamic-type run-target --ptr-depth 1") self.assertTrue(id_x.GetNumChildren() == 7, "dictionary does not have 7 children") id_x.SetPreferSyntheticValue(False) diff --git a/lldb/test/functionalities/stop-hook/multiple_threads/TestStopHookMultipleThreads.py b/lldb/test/functionalities/stop-hook/multiple_threads/TestStopHookMultipleThreads.py index 2ec84aee55a6..2710cf92c7d3 100644 --- a/lldb/test/functionalities/stop-hook/multiple_threads/TestStopHookMultipleThreads.py +++ b/lldb/test/functionalities/stop-hook/multiple_threads/TestStopHookMultipleThreads.py @@ -61,7 +61,7 @@ class StopHookForMultipleThreadsTestCase(TestBase): # Now run the program, expect to stop at the the first breakpoint which is within the stop-hook range. child.sendline('run') child.expect_exact(prompt) - child.sendline('target stop-hook add -o "frame variable -g g_val"') + child.sendline('target stop-hook add -o "frame variable --show-globals g_val"') child.expect_exact(prompt) # Continue and expect to find the output emitted by the firing of our stop hook. diff --git a/lldb/test/functionalities/watchpoint/watchpoint_commands/command/TestWatchpointCommandLLDB.py b/lldb/test/functionalities/watchpoint/watchpoint_commands/command/TestWatchpointCommandLLDB.py index c7a4fc137757..8da620a5a138 100644 --- a/lldb/test/functionalities/watchpoint/watchpoint_commands/command/TestWatchpointCommandLLDB.py +++ b/lldb/test/functionalities/watchpoint/watchpoint_commands/command/TestWatchpointCommandLLDB.py @@ -103,7 +103,7 @@ class WatchpointLLDBCommandTestCase(TestBase): 'new value:', ' = 1']) # The watchpoint command "forced" our global variable 'cookie' to become 777. - self.expect("frame variable -g cookie", + self.expect("frame variable --show-globals cookie", substrs = ['(int32_t)', 'cookie = 777']) def watchpoint_command_can_disable_a_watchpoint(self): diff --git a/lldb/test/functionalities/watchpoint/watchpoint_commands/command/TestWatchpointCommandPython.py b/lldb/test/functionalities/watchpoint/watchpoint_commands/command/TestWatchpointCommandPython.py index 814330f6e04e..96a3c619db5d 100644 --- a/lldb/test/functionalities/watchpoint/watchpoint_commands/command/TestWatchpointCommandPython.py +++ b/lldb/test/functionalities/watchpoint/watchpoint_commands/command/TestWatchpointCommandPython.py @@ -90,7 +90,7 @@ class WatchpointPythonCommandTestCase(TestBase): 'new value:', ' = 1']) # The watchpoint command "forced" our global variable 'cookie' to become 777. - self.expect("frame variable -g cookie", + self.expect("frame variable --show-globals cookie", substrs = ['(int32_t)', 'cookie = 777']) diff --git a/lldb/test/functionalities/watchpoint/watchpoint_commands/condition/TestWatchpointConditionCmd.py b/lldb/test/functionalities/watchpoint/watchpoint_commands/condition/TestWatchpointConditionCmd.py index 7964049826a6..f529ef969b15 100644 --- a/lldb/test/functionalities/watchpoint/watchpoint_commands/condition/TestWatchpointConditionCmd.py +++ b/lldb/test/functionalities/watchpoint/watchpoint_commands/condition/TestWatchpointConditionCmd.py @@ -77,7 +77,7 @@ class WatchpointConditionCmdTestCase(TestBase): # The stop reason of the thread should be watchpoint. self.expect("thread backtrace", STOPPED_DUE_TO_WATCHPOINT, substrs = ['stop reason = watchpoint']) - self.expect("frame variable -g global", + self.expect("frame variable --show-globals global", substrs = ['(int32_t)', 'global = 5']) # Use the '-v' option to do verbose listing of the watchpoint. diff --git a/lldb/test/lang/c/array_types/TestArrayTypes.py b/lldb/test/lang/c/array_types/TestArrayTypes.py index 2adb567a7cd4..9e8800366892 100644 --- a/lldb/test/lang/c/array_types/TestArrayTypes.py +++ b/lldb/test/lang/c/array_types/TestArrayTypes.py @@ -71,7 +71,7 @@ class ArrayTypesTestCase(TestBase): # Issue 'variable list' command on several array-type variables. - self.expect("frame variable -T strings", VARIABLES_DISPLAYED_CORRECTLY, + self.expect("frame variable --show-types strings", VARIABLES_DISPLAYED_CORRECTLY, startstr = '(char *[4])', substrs = ['(char *) [0]', '(char *) [1]', @@ -82,14 +82,14 @@ class ArrayTypesTestCase(TestBase): 'Bonjour', 'Guten Tag']) - self.expect("frame variable -T char_16", VARIABLES_DISPLAYED_CORRECTLY, + self.expect("frame variable --show-types char_16", VARIABLES_DISPLAYED_CORRECTLY, substrs = ['(char) [0]', '(char) [15]']) - self.expect("frame variable -T ushort_matrix", VARIABLES_DISPLAYED_CORRECTLY, + self.expect("frame variable --show-types ushort_matrix", VARIABLES_DISPLAYED_CORRECTLY, startstr = '(unsigned short [2][3])') - self.expect("frame variable -T long_6", VARIABLES_DISPLAYED_CORRECTLY, + self.expect("frame variable --show-types long_6", VARIABLES_DISPLAYED_CORRECTLY, startstr = '(long [6])') def array_types_python(self): diff --git a/lldb/test/lang/c/bitfields/TestBitfields.py b/lldb/test/lang/c/bitfields/TestBitfields.py index 177242305e85..e9bd2ee359a7 100644 --- a/lldb/test/lang/c/bitfields/TestBitfields.py +++ b/lldb/test/lang/c/bitfields/TestBitfields.py @@ -64,7 +64,7 @@ class BitfieldsTestCase(TestBase): substrs = [' resolved, hit count = 1']) # This should display correctly. - self.expect("frame variable -T bits", VARIABLES_DISPLAYED_CORRECTLY, + self.expect("frame variable --show-types bits", VARIABLES_DISPLAYED_CORRECTLY, substrs = ['(uint32_t:1) b1 = 1', '(uint32_t:2) b2 = 3', '(uint32_t:3) b3 = 7', @@ -76,7 +76,7 @@ class BitfieldsTestCase(TestBase): # And so should this. # rdar://problem/8348251 - self.expect("frame variable -T", VARIABLES_DISPLAYED_CORRECTLY, + self.expect("frame variable --show-types", VARIABLES_DISPLAYED_CORRECTLY, substrs = ['(uint32_t:1) b1 = 1', '(uint32_t:2) b2 = 3', '(uint32_t:3) b3 = 7', diff --git a/lldb/test/lang/c/forward/TestForwardDeclaration.py b/lldb/test/lang/c/forward/TestForwardDeclaration.py index ee37bc073938..9ae1fe063ccb 100644 --- a/lldb/test/lang/c/forward/TestForwardDeclaration.py +++ b/lldb/test/lang/c/forward/TestForwardDeclaration.py @@ -48,7 +48,7 @@ class ForwardDeclarationTestCase(TestBase): # This should display correctly. # Note that the member fields of a = 1 and b = 2 is by design. - self.expect("frame variable -T *bar_ptr", VARIABLES_DISPLAYED_CORRECTLY, + self.expect("frame variable --show-types *bar_ptr", VARIABLES_DISPLAYED_CORRECTLY, substrs = ['(bar) *bar_ptr = ', '(int) a = 1', '(int) b = 2']) diff --git a/lldb/test/lang/c/function_types/TestFunctionTypes.py b/lldb/test/lang/c/function_types/TestFunctionTypes.py index 009065a0e2b7..5cc6a8b6c91f 100644 --- a/lldb/test/lang/c/function_types/TestFunctionTypes.py +++ b/lldb/test/lang/c/function_types/TestFunctionTypes.py @@ -66,7 +66,7 @@ class FunctionTypesTestCase(TestBase): self.runToBreakpoint() # Check that the 'callback' variable display properly. - self.expect("frame variable -T callback", VARIABLES_DISPLAYED_CORRECTLY, + self.expect("frame variable --show-types callback", VARIABLES_DISPLAYED_CORRECTLY, startstr = '(int (*)(const char *)) callback =') # And that we can break on the callback function. diff --git a/lldb/test/lang/c/global_variables/TestGlobalVariables.py b/lldb/test/lang/c/global_variables/TestGlobalVariables.py index 27b0a7b25284..32a1501f1814 100644 --- a/lldb/test/lang/c/global_variables/TestGlobalVariables.py +++ b/lldb/test/lang/c/global_variables/TestGlobalVariables.py @@ -13,13 +13,13 @@ class GlobalVariablesTestCase(TestBase): @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin") @dsym_test def test_with_dsym(self): - """Test 'frame variable -s -a' which omits args and shows scopes.""" + """Test 'frame variable --scope --no-args' which omits args and shows scopes.""" self.buildDsym() self.global_variables() @dwarf_test def test_with_dwarf(self): - """Test 'frame variable -s -a' which omits args and shows scopes.""" + """Test 'frame variable --scope --no-args' which omits args and shows scopes.""" self.buildDwarf() self.global_variables() @@ -34,7 +34,7 @@ class GlobalVariablesTestCase(TestBase): self.addTearDownHook(lambda: self.runCmd("settings remove target.env-vars " + self.dylibPath)) def global_variables(self): - """Test 'frame variable -s -a' which omits args and shows scopes.""" + """Test 'frame variable --scope --no-args' which omits args and shows scopes.""" exe = os.path.join(os.getcwd(), "a.out") self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) @@ -53,7 +53,7 @@ class GlobalVariablesTestCase(TestBase): substrs = [' resolved, hit count = 1']) # Check that GLOBAL scopes are indicated for the variables. - self.expect("frame variable -T -s -g -a", VARIABLES_DISPLAYED_CORRECTLY, + self.expect("frame variable --show-types --scope --show-globals --no-args", VARIABLES_DISPLAYED_CORRECTLY, substrs = ['GLOBAL: (int) g_file_global_int = 42', 'GLOBAL: (const char *) g_file_global_cstr', '"g_file_global_cstr"', diff --git a/lldb/test/lang/c/set_values/TestSetValues.py b/lldb/test/lang/c/set_values/TestSetValues.py index 1fb6e7b161ae..5705a04d33cc 100644 --- a/lldb/test/lang/c/set_values/TestSetValues.py +++ b/lldb/test/lang/c/set_values/TestSetValues.py @@ -61,63 +61,63 @@ class SetValuesTestCase(TestBase): substrs = [' resolved, hit count = 1']) # main.c:15 - # Check that 'frame variable -T' displays the correct data type and value. - self.expect("frame variable -T", VARIABLES_DISPLAYED_CORRECTLY, + # Check that 'frame variable --show-types' displays the correct data type and value. + self.expect("frame variable --show-types", VARIABLES_DISPLAYED_CORRECTLY, startstr = "(char) i = 'a'") # Now set variable 'i' and check that it is correctly displayed. self.runCmd("expression i = 'b'") - self.expect("frame variable -T", VARIABLES_DISPLAYED_CORRECTLY, + self.expect("frame variable --show-types", VARIABLES_DISPLAYED_CORRECTLY, startstr = "(char) i = 'b'") self.runCmd("continue") # main.c:36 - # Check that 'frame variable -T' displays the correct data type and value. - self.expect("frame variable -T", VARIABLES_DISPLAYED_CORRECTLY, + # Check that 'frame variable --show-types' displays the correct data type and value. + self.expect("frame variable --show-types", VARIABLES_DISPLAYED_CORRECTLY, patterns = ["\((short unsigned int|unsigned short)\) i = 33"]) # Now set variable 'i' and check that it is correctly displayed. self.runCmd("expression i = 333") - self.expect("frame variable -T", VARIABLES_DISPLAYED_CORRECTLY, + self.expect("frame variable --show-types", VARIABLES_DISPLAYED_CORRECTLY, patterns = ["\((short unsigned int|unsigned short)\) i = 333"]) self.runCmd("continue") # main.c:57 - # Check that 'frame variable -T' displays the correct data type and value. - self.expect("frame variable -T", VARIABLES_DISPLAYED_CORRECTLY, + # Check that 'frame variable --show-types' displays the correct data type and value. + self.expect("frame variable --show-types", VARIABLES_DISPLAYED_CORRECTLY, startstr = "(long) i = 33") # Now set variable 'i' and check that it is correctly displayed. self.runCmd("expression i = 33333") - self.expect("frame variable -T", VARIABLES_DISPLAYED_CORRECTLY, + self.expect("frame variable --show-types", VARIABLES_DISPLAYED_CORRECTLY, startstr = "(long) i = 33333") self.runCmd("continue") # main.c:78 - # Check that 'frame variable -T' displays the correct data type and value. - self.expect("frame variable -T", VARIABLES_DISPLAYED_CORRECTLY, + # Check that 'frame variable --show-types' displays the correct data type and value. + self.expect("frame variable --show-types", VARIABLES_DISPLAYED_CORRECTLY, startstr = "(double) i = 3.14159") # Now set variable 'i' and check that it is correctly displayed. self.runCmd("expression i = 3.14") - self.expect("frame variable -T", VARIABLES_DISPLAYED_CORRECTLY, + self.expect("frame variable --show-types", VARIABLES_DISPLAYED_CORRECTLY, startstr = "(double) i = 3.14") self.runCmd("continue") # main.c:85 - # Check that 'frame variable -T' displays the correct data type and value. + # Check that 'frame variable --show-types' displays the correct data type and value. # rdar://problem/8422727 # set_values test directory: 'frame variable' shows only (long double) i = - self.expect("frame variable -T", VARIABLES_DISPLAYED_CORRECTLY, + self.expect("frame variable --show-types", VARIABLES_DISPLAYED_CORRECTLY, startstr = "(long double) i = 3.14159") # Now set variable 'i' and check that it is correctly displayed. self.runCmd("expression i = 3.1") - self.expect("frame variable -T", VARIABLES_DISPLAYED_CORRECTLY, + self.expect("frame variable --show-types", VARIABLES_DISPLAYED_CORRECTLY, startstr = "(long double) i = 3.1") diff --git a/lldb/test/lang/cpp/class_types/TestClassTypes.py b/lldb/test/lang/cpp/class_types/TestClassTypes.py index f64e778d2902..76e8ace4bf1e 100644 --- a/lldb/test/lang/cpp/class_types/TestClassTypes.py +++ b/lldb/test/lang/cpp/class_types/TestClassTypes.py @@ -92,7 +92,7 @@ class ClassTypesTestCase(TestBase): substrs = [' resolved, hit count = 1']) # We should be stopped on the ctor function of class C. - self.expect("frame variable -T this", VARIABLES_DISPLAYED_CORRECTLY, + self.expect("frame variable --show-types this", VARIABLES_DISPLAYED_CORRECTLY, substrs = ['C *', ' this = ']) @@ -188,10 +188,10 @@ class ClassTypesTestCase(TestBase): self.expect("frame variable this",VARIABLES_DISPLAYED_CORRECTLY, substrs = ['C *']) - # Verify that frame variable -T this->m_c_int behaves correctly. + # Verify that frame variable --show-types this->m_c_int behaves correctly. self.runCmd("register read pc") self.runCmd("expr m_c_int") - self.expect("frame variable -T this->m_c_int", VARIABLES_DISPLAYED_CORRECTLY, + self.expect("frame variable --show-types this->m_c_int", VARIABLES_DISPLAYED_CORRECTLY, startstr = '(int) this->m_c_int = 66') # Verify that 'expression this' gets the data type correct. diff --git a/lldb/test/lang/cpp/namespace/TestNamespace.py b/lldb/test/lang/cpp/namespace/TestNamespace.py index 9c2c6d75ce72..4bf08a4fc23d 100644 --- a/lldb/test/lang/cpp/namespace/TestNamespace.py +++ b/lldb/test/lang/cpp/namespace/TestNamespace.py @@ -66,12 +66,12 @@ class NamespaceTestCase(TestBase): substrs = slist) # 'frame variable' with basename 'i' should work. - self.expect("frame variable -c -g i", + self.expect("frame variable --show-declaration --show-globals i", startstr = "main.cpp:%d: (int) (anonymous namespace)::i = 3" % self.line_var_i) # main.cpp:12: (int) (anonymous namespace)::i = 3 # 'frame variable' with basename 'j' should work, too. - self.expect("frame variable -c -g j", + self.expect("frame variable --show-declaration --show-globals j", startstr = "main.cpp:%d: (int) A::B::j = 4" % self.line_var_j) # main.cpp:19: (int) A::B::j = 4 diff --git a/lldb/test/lang/cpp/signed_types/TestSignedTypes.py b/lldb/test/lang/cpp/signed_types/TestSignedTypes.py index d015c974b5c3..ebc2c3e6dbc9 100644 --- a/lldb/test/lang/cpp/signed_types/TestSignedTypes.py +++ b/lldb/test/lang/cpp/signed_types/TestSignedTypes.py @@ -54,7 +54,7 @@ class UnsignedTypesTestCase(TestBase): self.runCmd("thread step-over") # Test that signed types display correctly. - self.expect("frame variable -T -a", VARIABLES_DISPLAYED_CORRECTLY, + self.expect("frame variable --show-types --no-args", VARIABLES_DISPLAYED_CORRECTLY, patterns = ["\((short int|short)\) the_signed_short = 99"], substrs = ["(signed char) the_signed_char = 'c'", "(int) the_signed_int = 99", diff --git a/lldb/test/lang/cpp/unique-types/TestUniqueTypes.py b/lldb/test/lang/cpp/unique-types/TestUniqueTypes.py index 891d31dd6bc5..c1414c1e8be8 100644 --- a/lldb/test/lang/cpp/unique-types/TestUniqueTypes.py +++ b/lldb/test/lang/cpp/unique-types/TestUniqueTypes.py @@ -58,8 +58,8 @@ class UniqueTypesTestCase(TestBase): if clang_version < 3: self.skipTest("rdar://problem/9173060 lldb hangs while running unique-types for clang version < 3") - # Do a "frame variable -T longs" and verify "long" is in each line of output. - self.runCmd("frame variable -T longs") + # Do a "frame variable --show-types longs" and verify "long" is in each line of output. + self.runCmd("frame variable --show-types longs") output = self.res.GetOutput() for x in [line.strip() for line in output.split(os.linesep)]: # Skip empty line or closing brace. @@ -68,8 +68,8 @@ class UniqueTypesTestCase(TestBase): self.expect(x, "Expect type 'long'", exe=False, substrs = ['long']) - # Do a "frame variable -T shorts" and verify "short" is in each line of output. - self.runCmd("frame variable -T shorts") + # Do a "frame variable --show-types shorts" and verify "short" is in each line of output. + self.runCmd("frame variable --show-types shorts") output = self.res.GetOutput() for x in [line.strip() for line in output.split(os.linesep)]: # Skip empty line or closing brace. diff --git a/lldb/test/lang/cpp/unsigned_types/TestUnsignedTypes.py b/lldb/test/lang/cpp/unsigned_types/TestUnsignedTypes.py index 3ddc2510954e..6231673c54cf 100644 --- a/lldb/test/lang/cpp/unsigned_types/TestUnsignedTypes.py +++ b/lldb/test/lang/cpp/unsigned_types/TestUnsignedTypes.py @@ -51,7 +51,7 @@ class UnsignedTypesTestCase(TestBase): substrs = [' resolved, hit count = 1']) # Test that unsigned types display correctly. - self.expect("frame variable -T -a", VARIABLES_DISPLAYED_CORRECTLY, + self.expect("frame variable --show-types --no-args", VARIABLES_DISPLAYED_CORRECTLY, startstr = "(unsigned char) the_unsigned_char = 'c'", patterns = ["\((short unsigned int|unsigned short)\) the_unsigned_short = 99"], substrs = ["(unsigned int) the_unsigned_int = 99", diff --git a/lldb/test/lang/objc/foundation/TestObjCMethods.py b/lldb/test/lang/objc/foundation/TestObjCMethods.py index 0896fc4ed231..1d1c7ac5edec 100644 --- a/lldb/test/lang/objc/foundation/TestObjCMethods.py +++ b/lldb/test/lang/objc/foundation/TestObjCMethods.py @@ -146,7 +146,7 @@ class FoundationTestCase(TestBase): 'NSString * str;', 'NSDate * date;']) - self.expect("frame variable -T -s", VARIABLES_DISPLAYED_CORRECTLY, + self.expect("frame variable --show-types --scope", VARIABLES_DISPLAYED_CORRECTLY, substrs = ["ARG: (MyString *) self"], patterns = ["ARG: \(.*\) _cmd", "(objc_selector *)|(SEL)"]) @@ -158,16 +158,16 @@ class FoundationTestCase(TestBase): # rdar://problem/8492646 # test/foundation fails after updating to tot r115023 # self->str displays nothing as output - self.expect("frame variable -T self->str", VARIABLES_DISPLAYED_CORRECTLY, + self.expect("frame variable --show-types self->str", VARIABLES_DISPLAYED_CORRECTLY, startstr = "(NSString *) self->str") # rdar://problem/8447030 # 'frame variable self->date' displays the wrong data member - self.expect("frame variable -T self->date", VARIABLES_DISPLAYED_CORRECTLY, + self.expect("frame variable --show-types self->date", VARIABLES_DISPLAYED_CORRECTLY, startstr = "(NSDate *) self->date") # This should display the str and date member fields as well. - self.expect("frame variable -T *self", VARIABLES_DISPLAYED_CORRECTLY, + self.expect("frame variable --show-types *self", VARIABLES_DISPLAYED_CORRECTLY, substrs = ["(MyString) *self", "(NSString *) str", "(NSDate *) date"]) diff --git a/lldb/test/lang/objc/rdar-11355592/TestRdar11355592.py b/lldb/test/lang/objc/rdar-11355592/TestRdar11355592.py index ad0df1dd511b..16466d68cbb7 100644 --- a/lldb/test/lang/objc/rdar-11355592/TestRdar11355592.py +++ b/lldb/test/lang/objc/rdar-11355592/TestRdar11355592.py @@ -48,13 +48,13 @@ class Rdar10967107TestCase(TestBase): self.runCmd("run", RUN_SUCCEEDED) # check that we correctly see the const char*, even with dynamic types on self.expect("frame variable my_string", substrs = ['const char *']) - self.expect("frame variable my_string -d run-target", substrs = ['const char *']) + self.expect("frame variable my_string --dynamic-type run-target", substrs = ['const char *']) # check that expr also gets it right self.expect("expr my_string", substrs = ['const char *']) self.expect("expr -d true -- my_string", substrs = ['const char *']) # but check that we get the real Foolie as such self.expect("frame variable my_foolie", substrs = ['FoolMeOnce *']) - self.expect("frame variable my_foolie -d run-target", substrs = ['FoolMeOnce *']) + self.expect("frame variable my_foolie --dynamic-type run-target", substrs = ['FoolMeOnce *']) # check that expr also gets it right self.expect("expr my_foolie", substrs = ['FoolMeOnce *']) self.expect("expr -d true -- my_foolie", substrs = ['FoolMeOnce *']) @@ -62,13 +62,13 @@ class Rdar10967107TestCase(TestBase): self.runCmd("next") # check that we correctly see the const char*, even with dynamic types on self.expect("frame variable my_string", substrs = ['const char *']) - self.expect("frame variable my_string -d run-target", substrs = ['const char *']) + self.expect("frame variable my_string --dynamic-type run-target", substrs = ['const char *']) # check that expr also gets it right self.expect("expr my_string", substrs = ['const char *']) self.expect("expr -d true -- my_string", substrs = ['const char *']) # but check that we get the real Foolie as such self.expect("frame variable my_foolie", substrs = ['FoolMeOnce *']) - self.expect("frame variable my_foolie -d run-target", substrs = ['FoolMeOnce *']) + self.expect("frame variable my_foolie --dynamic-type run-target", substrs = ['FoolMeOnce *']) # check that expr also gets it right self.expect("expr my_foolie", substrs = ['FoolMeOnce *']) self.expect("expr -d true -- my_foolie", substrs = ['FoolMeOnce *']) diff --git a/lldb/test/types/AbstractBase.py b/lldb/test/types/AbstractBase.py index 5e7810f19bae..2ebc11261602 100644 --- a/lldb/test/types/AbstractBase.py +++ b/lldb/test/types/AbstractBase.py @@ -10,7 +10,7 @@ import lldbutil def Msg(var, val, using_frame_variable): return "'%s %s' matches the output (from compiled code): %s" % ( - 'frame variable -T' if using_frame_variable else 'expression' ,var, val) + 'frame variable --show-types' if using_frame_variable else 'expression' ,var, val) class GenericTester(TestBase): @@ -116,7 +116,7 @@ class GenericTester(TestBase): lambda: self.runCmd("settings set target.inline-breakpoint-strategy headers")) # Bring the program to the point where we can issue a series of - # 'frame variable -T' command. + # 'frame variable --show-types' command. if blockCaptured: break_line = line_number ("basic_type.cpp", "// Break here to test block captured variables.") else: @@ -128,19 +128,19 @@ class GenericTester(TestBase): substrs = [" at basic_type.cpp:%d" % break_line, "stop reason = breakpoint"]) - #self.runCmd("frame variable -T") + #self.runCmd("frame variable --show-types") # Now iterate through the golden list, comparing against the output from - # 'frame variable -T var'. + # 'frame variable --show-types var'. for var, val in gl: - self.runCmd("frame variable -T %s" % var) + self.runCmd("frame variable --show-types %s" % var) output = self.res.GetOutput() # The input type is in a canonical form as a set of named atoms. # The display type string must conatin each and every element. # # Example: - # runCmd: frame variable -T a_array_bounded[0] + # runCmd: frame variable --show-types a_array_bounded[0] # output: (char) a_array_bounded[0] = 'a' # try: @@ -209,7 +209,7 @@ class GenericTester(TestBase): substrs = [" at basic_type.cpp:%d" % break_line, "stop reason = breakpoint"]) - #self.runCmd("frame variable -T") + #self.runCmd("frame variable --show-types") # Now iterate through the golden list, comparing against the output from # 'expr var'. diff --git a/lldb/tools/driver/Driver.cpp b/lldb/tools/driver/Driver.cpp index b410f572a6e2..7a4eded45722 100644 --- a/lldb/tools/driver/Driver.cpp +++ b/lldb/tools/driver/Driver.cpp @@ -63,7 +63,7 @@ typedef struct // then this option belongs to option set n. bool required; // This option is required (in the current usage level) const char * long_option; // Full name for this option. - char short_option; // Single character for this option. + int short_option; // Single character for this option. int option_has_arg; // no_argument, required_argument or optional_argument uint32_t completion_type; // Cookie the option class can use to do define the argument completion. lldb::CommandArgumentType argument_type; // Type of argument this option takes @@ -578,7 +578,7 @@ Driver::ParseArgs (int argc, const char *argv[], FILE *out_fh, bool &exit) if (long_options_index >= 0) { - const char short_option = (char) g_options[long_options_index].short_option; + const int short_option = g_options[long_options_index].short_option; switch (short_option) {