diff options
author | dim <dim@FreeBSD.org> | 2016-12-26 20:36:37 +0000 |
---|---|---|
committer | dim <dim@FreeBSD.org> | 2016-12-26 20:36:37 +0000 |
commit | 06210ae42d418d50d8d9365d5c9419308ae9e7ee (patch) | |
tree | ab60b4cdd6e430dda1f292a46a77ddb744723f31 /contrib/llvm/tools/lldb/source/Interpreter/CommandObject.cpp | |
parent | 2dd166267f53df1c3748b4325d294b9b839de74b (diff) | |
download | FreeBSD-src-06210ae42d418d50d8d9365d5c9419308ae9e7ee.zip FreeBSD-src-06210ae42d418d50d8d9365d5c9419308ae9e7ee.tar.gz |
MFC r309124:
Upgrade our copies of clang, llvm, lldb, compiler-rt and libc++ to 3.9.0
release, and add lld 3.9.0. Also completely revamp the build system for
clang, llvm, lldb and their related tools.
Please note that from 3.5.0 onwards, clang, llvm and lldb require C++11
support to build; see UPDATING for more information.
Release notes for llvm, clang and lld are available here:
<http://llvm.org/releases/3.9.0/docs/ReleaseNotes.html>
<http://llvm.org/releases/3.9.0/tools/clang/docs/ReleaseNotes.html>
<http://llvm.org/releases/3.9.0/tools/lld/docs/ReleaseNotes.html>
Thanks to Ed Maste, Bryan Drewery, Andrew Turner, Antoine Brodin and Jan
Beich for their help.
Relnotes: yes
MFC r309147:
Pull in r282174 from upstream llvm trunk (by Krzysztof Parzyszek):
[PPC] Set SP after loading data from stack frame, if no red zone is
present
Follow-up to r280705: Make sure that the SP is only restored after
all data is loaded from the stack frame, if there is no red zone.
This completes the fix for
https://llvm.org/bugs/show_bug.cgi?id=26519.
Differential Revision: https://reviews.llvm.org/D24466
Reported by: Mark Millard
PR: 214433
MFC r309149:
Pull in r283060 from upstream llvm trunk (by Hal Finkel):
[PowerPC] Refactor soft-float support, and enable PPC64 soft float
This change enables soft-float for PowerPC64, and also makes
soft-float disable all vector instruction sets for both 32-bit and
64-bit modes. This latter part is necessary because the PPC backend
canonicalizes many Altivec vector types to floating-point types, and
so soft-float breaks scalarization support for many operations. Both
for embedded targets and for operating-system kernels desiring
soft-float support, it seems reasonable that disabling hardware
floating-point also disables vector instructions (embedded targets
without hardware floating point support are unlikely to have Altivec,
etc. and operating system kernels desiring not to use floating-point
registers to lower syscall cost are unlikely to want to use vector
registers either). If someone needs this to work, we'll need to
change the fact that we promote many Altivec operations to act on
v4f32. To make it possible to disable Altivec when soft-float is
enabled, hardware floating-point support needs to be expressed as a
positive feature, like the others, and not a negative feature,
because target features cannot have dependencies on the disabling of
some other feature. So +soft-float has now become -hard-float.
Fixes PR26970.
Pull in r283061 from upstream clang trunk (by Hal Finkel):
[PowerPC] Enable soft-float for PPC64, and +soft-float -> -hard-float
Enable soft-float support on PPC64, as the backend now supports it.
Also, the backend now uses -hard-float instead of +soft-float, so set
the target features accordingly.
Fixes PR26970.
Reported by: Mark Millard
PR: 214433
MFC r309212:
Add a few missed clang 3.9.0 files to OptionalObsoleteFiles.
MFC r309262:
Fix packaging for clang, lldb and lld 3.9.0
During the upgrade of clang/llvm etc to 3.9.0 in r309124, the PACKAGE
directive in the usr.bin/clang/*.mk files got dropped accidentally.
Restore it, with a few minor changes and additions:
* Correct license in clang.ucl to NCSA
* Add PACKAGE=clang for clang and most of the "ll" tools
* Put lldb in its own package
* Put lld in its own package
Reviewed by: gjb, jmallett
Differential Revision: https://reviews.freebsd.org/D8666
MFC r309656:
During the bootstrap phase, when building the minimal llvm library on
PowerPC, add lib/Support/Atomic.cpp. This is needed because upstream
llvm revision r271821 disabled the use of std::call_once, which causes
some fallback functions from Atomic.cpp to be used instead.
Reported by: Mark Millard
PR: 214902
MFC r309835:
Tentatively apply https://reviews.llvm.org/D18730 to work around gcc PR
70528 (bogus error: constructor required before non-static data member).
This should fix buildworld with the external gcc package.
Reported by: https://jenkins.freebsd.org/job/FreeBSD_HEAD_amd64_gcc/
MFC r310194:
Upgrade our copies of clang, llvm, lld, lldb, compiler-rt and libc++ to
3.9.1 release.
Please note that from 3.5.0 onwards, clang, llvm and lldb require C++11
support to build; see UPDATING for more information.
Release notes for llvm, clang and lld will be available here:
<http://releases.llvm.org/3.9.1/docs/ReleaseNotes.html>
<http://releases.llvm.org/3.9.1/tools/clang/docs/ReleaseNotes.html>
<http://releases.llvm.org/3.9.1/tools/lld/docs/ReleaseNotes.html>
Relnotes: yes
Diffstat (limited to 'contrib/llvm/tools/lldb/source/Interpreter/CommandObject.cpp')
-rw-r--r-- | contrib/llvm/tools/lldb/source/Interpreter/CommandObject.cpp | 265 |
1 files changed, 115 insertions, 150 deletions
diff --git a/contrib/llvm/tools/lldb/source/Interpreter/CommandObject.cpp b/contrib/llvm/tools/lldb/source/Interpreter/CommandObject.cpp index 616d3e3..75e4292 100644 --- a/contrib/llvm/tools/lldb/source/Interpreter/CommandObject.cpp +++ b/contrib/llvm/tools/lldb/source/Interpreter/CommandObject.cpp @@ -53,7 +53,6 @@ CommandObject::CommandObject m_cmd_help_short (), m_cmd_help_long (), m_cmd_syntax (), - m_is_alias (false), m_flags (flags), m_arguments(), m_deprecated_command_override_callback (nullptr), @@ -89,12 +88,12 @@ CommandObject::GetSyntax () { StreamString syntax_str; syntax_str.Printf ("%s", GetCommandName()); - if (GetOptions() != nullptr) + if (!IsDashDashCommand() && GetOptions() != nullptr) syntax_str.Printf (" <cmd-options>"); if (m_arguments.size() > 0) { syntax_str.Printf (" "); - if (WantsRawCommandString() && GetOptions() && GetOptions()->NumCommandOptions()) + if (!IsDashDashCommand() && WantsRawCommandString() && GetOptions() && GetOptions()->NumCommandOptions()) syntax_str.Printf("-- "); GetFormattedCommandArguments (syntax_str); } @@ -119,25 +118,19 @@ CommandObject::SetCommandName (const char *name) void CommandObject::SetHelp (const char *cstr) { - m_cmd_help_short = cstr; -} - -void -CommandObject::SetHelp (std::string str) -{ - m_cmd_help_short = str; + if (cstr) + m_cmd_help_short = cstr; + else + m_cmd_help_short.assign(""); } void CommandObject::SetHelpLong (const char *cstr) { - m_cmd_help_long = cstr; -} - -void -CommandObject::SetHelpLong (std::string str) -{ - m_cmd_help_long = str; + if (cstr) + m_cmd_help_long = cstr; + else + m_cmd_help_long.assign(""); } void @@ -283,7 +276,7 @@ CommandObject::CheckRequirements (CommandReturnObject &result) { Target *target = m_exe_ctx.GetTargetPtr(); if (target) - m_api_locker.Lock (target->GetAPIMutex()); + m_api_locker = std::unique_lock<std::recursive_mutex>(target->GetAPIMutex()); } } @@ -343,46 +336,8 @@ void CommandObject::Cleanup () { m_exe_ctx.Clear(); - m_api_locker.Unlock(); -} - - -class CommandDictCommandPartialMatch -{ - public: - CommandDictCommandPartialMatch (const char *match_str) - { - m_match_str = match_str; - } - bool operator() (const std::pair<std::string, lldb::CommandObjectSP> map_element) const - { - // A NULL or empty string matches everything. - if (m_match_str == nullptr || *m_match_str == '\0') - return true; - - return map_element.first.find (m_match_str, 0) == 0; - } - - private: - const char *m_match_str; -}; - -int -CommandObject::AddNamesMatchingPartialString (CommandObject::CommandMap &in_map, const char *cmd_str, - StringList &matches) -{ - int number_added = 0; - CommandDictCommandPartialMatch matcher(cmd_str); - - CommandObject::CommandMap::iterator matching_cmds = std::find_if (in_map.begin(), in_map.end(), matcher); - - while (matching_cmds != in_map.end()) - { - ++number_added; - matches.AppendString((*matching_cmds).first.c_str()); - matching_cmds = std::find_if (++matching_cmds, in_map.end(), matcher);; - } - return number_added; + if (m_api_locker.owns_lock()) + m_api_locker.unlock(); } int @@ -457,7 +412,11 @@ CommandObject::HandleCompletion } bool -CommandObject::HelpTextContainsWord (const char *search_word) +CommandObject::HelpTextContainsWord (const char *search_word, + bool search_short_help, + bool search_long_help, + bool search_syntax, + bool search_options) { std::string options_usage_help; @@ -467,14 +426,15 @@ CommandObject::HelpTextContainsWord (const char *search_word) const char *long_help = GetHelpLong(); const char *syntax_help = GetSyntax(); - if (short_help && strcasestr (short_help, search_word)) + if (search_short_help && short_help && strcasestr (short_help, search_word)) found_word = true; - else if (long_help && strcasestr (long_help, search_word)) + else if (search_long_help && long_help && strcasestr (long_help, search_word)) found_word = true; - else if (syntax_help && strcasestr (syntax_help, search_word)) + else if (search_syntax && syntax_help && strcasestr (syntax_help, search_word)) found_word = true; if (!found_word + && search_options && GetOptions() != nullptr) { StreamString usage_help; @@ -727,46 +687,47 @@ RegisterNameHelpTextCallback () static const char * BreakpointIDHelpTextCallback () { - return "Breakpoint ID's consist major and minor numbers; the major number " - "corresponds to the single entity that was created with a 'breakpoint set' " - "command; the minor numbers correspond to all the locations that were actually " - "found/set based on the major breakpoint. A full breakpoint ID might look like " - "3.14, meaning the 14th location set for the 3rd breakpoint. You can specify " - "all the locations of a breakpoint by just indicating the major breakpoint " - "number. A valid breakpoint id consists either of just the major id number, " - "or the major number, a dot, and the location number (e.g. 3 or 3.2 could " - "both be valid breakpoint ids)."; + return "Breakpoints are identified using major and minor numbers; the major " + "number corresponds to the single entity that was created with a 'breakpoint " + "set' command; the minor numbers correspond to all the locations that were " + "actually found/set based on the major breakpoint. A full breakpoint ID might " + "look like 3.14, meaning the 14th location set for the 3rd breakpoint. You " + "can specify all the locations of a breakpoint by just indicating the major " + "breakpoint number. A valid breakpoint ID consists either of just the major " + "number, or the major number followed by a dot and the location number (e.g. " + "3 or 3.2 could both be valid breakpoint IDs.)"; } static const char * BreakpointIDRangeHelpTextCallback () { - return "A 'breakpoint id list' is a manner of specifying multiple breakpoints. " - "This can be done through several mechanisms. The easiest way is to just " - "enter a space-separated list of breakpoint ids. To specify all the " - "breakpoint locations under a major breakpoint, you can use the major " - "breakpoint number followed by '.*', eg. '5.*' means all the locations under " - "breakpoint 5. You can also indicate a range of breakpoints by using " - "<start-bp-id> - <end-bp-id>. The start-bp-id and end-bp-id for a range can " - "be any valid breakpoint ids. It is not legal, however, to specify a range " - "using specific locations that cross major breakpoint numbers. I.e. 3.2 - 3.7" - " is legal; 2 - 5 is legal; but 3.2 - 4.4 is not legal."; + return "A 'breakpoint ID list' is a manner of specifying multiple breakpoints. " + "This can be done through several mechanisms. The easiest way is to just " + "enter a space-separated list of breakpoint IDs. To specify all the " + "breakpoint locations under a major breakpoint, you can use the major " + "breakpoint number followed by '.*', eg. '5.*' means all the locations under " + "breakpoint 5. You can also indicate a range of breakpoints by using " + "<start-bp-id> - <end-bp-id>. The start-bp-id and end-bp-id for a range can " + "be any valid breakpoint IDs. It is not legal, however, to specify a range " + "using specific locations that cross major breakpoint numbers. I.e. 3.2 - 3.7" + " is legal; 2 - 5 is legal; but 3.2 - 4.4 is not legal."; } static const char * BreakpointNameHelpTextCallback () { return "A name that can be added to a breakpoint when it is created, or later " - "on with the \"breakpoint name add\" command. " - "Breakpoint names can be used to specify breakpoints in all the places breakpoint ID's " - "and breakpoint ID ranges can be used. As such they provide a convenient way to group breakpoints, " - "and to operate on breakpoints you create without having to track the breakpoint number. " - "Note, the attributes you set when using a breakpoint name in a breakpoint command don't " - "adhere to the name, but instead are set individually on all the breakpoints currently tagged with that name. Future breakpoints " - "tagged with that name will not pick up the attributes previously given using that name. " - "In order to distinguish breakpoint names from breakpoint ID's and ranges, " - "names must start with a letter from a-z or A-Z and cannot contain spaces, \".\" or \"-\". " - "Also, breakpoint names can only be applied to breakpoints, not to breakpoint locations."; + "on with the \"breakpoint name add\" command. " + "Breakpoint names can be used to specify breakpoints in all the places breakpoint IDs " + "and breakpoint ID ranges can be used. As such they provide a convenient way to group breakpoints, " + "and to operate on breakpoints you create without having to track the breakpoint number. " + "Note, the attributes you set when using a breakpoint name in a breakpoint command don't " + "adhere to the name, but instead are set individually on all the breakpoints currently tagged with that " + "name. Future breakpoints " + "tagged with that name will not pick up the attributes previously given using that name. " + "In order to distinguish breakpoint names from breakpoint IDs and ranges, " + "names must start with a letter from a-z or A-Z and cannot contain spaces, \".\" or \"-\". " + "Also, breakpoint names can only be applied to breakpoints, not to breakpoint locations."; } static const char * @@ -956,68 +917,46 @@ void CommandObject::GenerateHelpText (Stream &output_strm) { CommandInterpreter& interpreter = GetCommandInterpreter(); - if (GetOptions() != nullptr) + if (WantsRawCommandString()) + { + std::string help_text(GetHelp()); + help_text.append(" Expects 'raw' input (see 'help raw-input'.)"); + interpreter.OutputFormattedHelpText(output_strm, "", "", help_text.c_str(), 1); + } + else + interpreter.OutputFormattedHelpText(output_strm, "", "", GetHelp(), 1); + output_strm.Printf("\nSyntax: %s\n", GetSyntax()); + Options *options = GetOptions(); + if (options != nullptr) + { + options->GenerateOptionUsage(output_strm, this); + } + const char *long_help = GetHelpLong(); + if ((long_help != nullptr) && (strlen(long_help) > 0)) + { + FormatLongHelpText(output_strm, long_help); + } + if (!IsDashDashCommand() && options && options->NumCommandOptions() > 0) { - if (WantsRawCommandString()) - { - std::string help_text (GetHelp()); - help_text.append (" This command takes 'raw' input (no need to quote stuff)."); - interpreter.OutputFormattedHelpText (output_strm, "", "", help_text.c_str(), 1); - } - else - interpreter.OutputFormattedHelpText (output_strm, "", "", GetHelp(), 1); - output_strm.Printf ("\nSyntax: %s\n", GetSyntax()); - GetOptions()->GenerateOptionUsage (output_strm, this); - const char *long_help = GetHelpLong(); - if ((long_help != nullptr) - && (strlen (long_help) > 0)) - FormatLongHelpText (output_strm, long_help); if (WantsRawCommandString() && !WantsCompletion()) { // Emit the message about using ' -- ' between the end of the command options and the raw input // conditionally, i.e., only if the command object does not want completion. - interpreter.OutputFormattedHelpText (output_strm, "", "", - "\nIMPORTANT NOTE: Because this command takes 'raw' input, if you use any command options" - " you must use ' -- ' between the end of the command options and the beginning of the raw input.", 1); + interpreter.OutputFormattedHelpText( + output_strm, "", "", + "\nImportant Note: Because this command takes 'raw' input, if you use any command options" + " you must use ' -- ' between the end of the command options and the beginning of the raw input.", + 1); } - else if (GetNumArgumentEntries() > 0 - && GetOptions() - && GetOptions()->NumCommandOptions() > 0) + else if (GetNumArgumentEntries() > 0) { // Also emit a warning about using "--" in case you are using a command that takes options and arguments. - interpreter.OutputFormattedHelpText (output_strm, "", "", - "\nThis command takes options and free-form arguments. If your arguments resemble" - " option specifiers (i.e., they start with a - or --), you must use ' -- ' between" - " the end of the command options and the beginning of the arguments.", 1); - } - } - else if (IsMultiwordObject()) - { - if (WantsRawCommandString()) - { - std::string help_text (GetHelp()); - help_text.append (" This command takes 'raw' input (no need to quote stuff)."); - interpreter.OutputFormattedHelpText (output_strm, "", "", help_text.c_str(), 1); - } - else - interpreter.OutputFormattedHelpText (output_strm, "", "", GetHelp(), 1); - GenerateHelpText (output_strm); - } - else - { - const char *long_help = GetHelpLong(); - if ((long_help != nullptr) - && (strlen (long_help) > 0)) - FormatLongHelpText (output_strm, long_help); - else if (WantsRawCommandString()) - { - std::string help_text (GetHelp()); - help_text.append (" This command takes 'raw' input (no need to quote stuff)."); - interpreter.OutputFormattedHelpText (output_strm, "", "", help_text.c_str(), 1); + interpreter.OutputFormattedHelpText( + output_strm, "", "", "\nThis command takes options and free-form arguments. If your arguments resemble" + " option specifiers (i.e., they start with a - or --), you must use ' -- ' between" + " the end of the command options and the beginning of the arguments.", + 1); } - else - interpreter.OutputFormattedHelpText (output_strm, "", "", GetHelp(), 1); - output_strm.Printf ("\nSyntax: %s\n", GetSyntax()); } } @@ -1067,6 +1006,31 @@ CommandObject::GetSelectedOrDummyTarget(bool prefer_dummy) return m_interpreter.GetDebugger().GetSelectedOrDummyTarget(prefer_dummy); } +Thread * +CommandObject::GetDefaultThread() +{ + Thread *thread_to_use = m_exe_ctx.GetThreadPtr(); + if (thread_to_use) + return thread_to_use; + + Process *process = m_exe_ctx.GetProcessPtr(); + if (!process) + { + Target *target = m_exe_ctx.GetTargetPtr(); + if (!target) + { + target = m_interpreter.GetDebugger().GetSelectedTarget().get(); + } + if (target) + process = target->GetProcessSP().get(); + } + + if (process) + return process->GetThreadList().GetSelectedThread().get(); + else + return nullptr; +} + bool CommandObjectParsed::Execute (const char *args_string, CommandReturnObject &result) { @@ -1138,9 +1102,8 @@ const char *arch_helper() return g_archs_help.GetData(); } -CommandObject::ArgumentTableEntry -CommandObject::g_arguments_data[] = -{ +CommandObject::ArgumentTableEntry CommandObject::g_arguments_data[] = { + // clang-format off { eArgTypeAddress, "address", CommandCompletions::eNoCompletion, { nullptr, false }, "A valid address in the target program's execution space." }, { eArgTypeAddressOrExpression, "address-expression", CommandCompletions::eNoCompletion, { nullptr, false }, "An expression that resolves to an address." }, { eArgTypeAliasName, "alias-name", CommandCompletions::eNoCompletion, { nullptr, false }, "The name of an abbreviation (alias) for a debugger command." }, @@ -1170,7 +1133,7 @@ CommandObject::g_arguments_data[] = { eArgTypeGDBFormat, "gdb-format", CommandCompletions::eNoCompletion, { GDBFormatHelpTextCallback, true }, nullptr }, { eArgTypeHelpText, "help-text", CommandCompletions::eNoCompletion, { nullptr, false }, "Text to be used as help for some other entity in LLDB" }, { eArgTypeIndex, "index", CommandCompletions::eNoCompletion, { nullptr, false }, "An index into a list." }, - { eArgTypeLanguage, "language", CommandCompletions::eNoCompletion, { LanguageTypeHelpTextCallback, true }, nullptr }, + { eArgTypeLanguage, "source-language", CommandCompletions::eNoCompletion, { LanguageTypeHelpTextCallback, true }, nullptr }, { eArgTypeLineNum, "linenum", CommandCompletions::eNoCompletion, { nullptr, false }, "Line number in a source file." }, { eArgTypeLogCategory, "log-category", CommandCompletions::eNoCompletion, { nullptr, false }, "The name of a category within a log channel, e.g. all (try \"log list\" to see a list of all channels and their categories." }, { eArgTypeLogChannel, "log-channel", CommandCompletions::eNoCompletion, { nullptr, false }, "The name of a log channel, e.g. process.gdb-remote (try \"log list\" to see a list of all channels and their categories)." }, @@ -1198,7 +1161,7 @@ CommandObject::g_arguments_data[] = { eArgTypeRunMode, "run-mode", CommandCompletions::eNoCompletion, { nullptr, false }, "Help text goes here." }, { eArgTypeScriptedCommandSynchronicity, "script-cmd-synchronicity", CommandCompletions::eNoCompletion, { nullptr, false }, "The synchronicity to use to run scripted commands with regard to LLDB event system." }, { eArgTypeScriptLang, "script-language", CommandCompletions::eNoCompletion, { nullptr, false }, "The scripting language to be used for script-based commands. Currently only Python is valid." }, - { eArgTypeSearchWord, "search-word", CommandCompletions::eNoCompletion, { nullptr, false }, "The word for which you wish to search for information about." }, + { eArgTypeSearchWord, "search-word", CommandCompletions::eNoCompletion, { nullptr, false }, "Any word of interest for search purposes." }, { eArgTypeSelector, "selector", CommandCompletions::eNoCompletion, { nullptr, false }, "An Objective-C selector name." }, { eArgTypeSettingIndex, "setting-index", CommandCompletions::eNoCompletion, { nullptr, false }, "An index into a settings variable that is an array (try 'settings list' to see all the possible settings variables and their types)." }, { eArgTypeSettingKey, "setting-key", CommandCompletions::eNoCompletion, { nullptr, false }, "A key into a settings variables that is a dictionary (try 'settings list' to see all the possible settings variables and their types)." }, @@ -1223,7 +1186,9 @@ CommandObject::g_arguments_data[] = { eArgTypePlatform, "platform-name", CommandCompletions::ePlatformPluginCompletion, { nullptr, false }, "The name of an installed platform plug-in . Type 'platform list' to see a complete list of installed platforms." }, { eArgTypeWatchpointID, "watchpt-id", CommandCompletions::eNoCompletion, { nullptr, false }, "Watchpoint IDs are positive integers." }, { eArgTypeWatchpointIDRange, "watchpt-id-list", CommandCompletions::eNoCompletion, { nullptr, false }, "For example, '1-3' or '1 to 3'." }, - { eArgTypeWatchType, "watch-type", CommandCompletions::eNoCompletion, { nullptr, false }, "Specify the type for a watchpoint." } + { eArgTypeWatchType, "watch-type", CommandCompletions::eNoCompletion, { nullptr, false }, "Specify the type for a watchpoint." }, + { eArgRawInput, "raw-input", CommandCompletions::eNoCompletion, { nullptr, false }, "Free-form text passed to a command without prior interpretation, allowing spaces without requiring quotes. To pass arguments and free form text put two dashes ' -- ' between the last argument and any raw input." } + // clang-format on }; const CommandObject::ArgumentTableEntry* |