[Lldb-commits] [lldb] r342804 - Change type of m_user_expression_start_pos to size_t
Author: teemperor Date: Sat Sep 22 06:33:08 2018 New Revision: 342804 URL: http://llvm.org/viewvc/llvm-project?rev=342804&view=rev Log: Change type of m_user_expression_start_pos to size_t AbsPosToLineColumnPos is the only reader of m_user_expression_start_pos and actually treats it like a size_t. Also the value we store in m_user_expression_start_pos is originally a size_t, so it makes sense to change the type of this variable to size_t. Modified: lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangUserExpression.h Modified: lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp?rev=342804&r1=342803&r2=342804&view=diff == --- lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp (original) +++ lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp Sat Sep 22 06:33:08 2018 @@ -620,7 +620,7 @@ bool ClangUserExpression::Parse(Diagnost /// The column in the line that contains the absolute position. /// The first character in a line is indexed as 0. //-- -static void AbsPosToLineColumnPos(unsigned abs_pos, llvm::StringRef code, +static void AbsPosToLineColumnPos(size_t abs_pos, llvm::StringRef code, unsigned &line, unsigned &column) { // Reset to code position to beginning of the file. line = 0; Modified: lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangUserExpression.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangUserExpression.h?rev=342804&r1=342803&r2=342804&view=diff == --- lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangUserExpression.h (original) +++ lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangUserExpression.h Sat Sep 22 06:33:08 2018 @@ -204,7 +204,7 @@ private: /// The absolute character position in the transformed source code where the /// user code (as typed by the user) starts. If the variable is empty, then we /// were not able to calculate this position. - llvm::Optional m_user_expression_start_pos; + llvm::Optional m_user_expression_start_pos; ResultDelegate m_result_delegate; }; ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
Re: [Lldb-commits] [PATCH] D52139: [lldb-mi] Fix hanging of target-select-so-path.test
> AFAIR, adding an exit(...) to ConnectToRemote won't solve this problem. The > test will still be failing on Arch. I was more hoping it would at least turn the deadlock into a fail, this way I could at least run the test suit. Anyway, the actual issue is related Python 3: Arch Linux (and probably some other distributions that "already" upgraded to Python 3 as default) will launch Python 3 when the test script calls `python ...`. And for some reason in Python 3.7, we will not inherit our FD from our pipe to the subprocess, which causes this strange behavior when write to the unrelated FD number in ConnectToRemote. When I explicitly call Python 2.7 from the test, everything runs as expected. The python docs don't see to mention this change (and it seems like a bug to me), so I'm open for ideas how to fix this properly. In any case this problem doesn't block this review. (I hope this comment shows up in Phabricator, as it seems reviews.llvm.org is currently having some internal errors). Am So., 23. Sep. 2018 um 01:03 Uhr schrieb Alexander Polyakov via Phabricator : > > apolyakov added a comment. > > AFAIR, adding an `exit(...)` to `ConnectToRemote` won't solve this problem. > The test will still be failing on Arch. > > > https://reviews.llvm.org/D52139 > > > ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] r343191 - Refactor ClangUserExpression::GetLanguageForExpr
Author: teemperor Date: Thu Sep 27 03:12:54 2018 New Revision: 343191 URL: http://llvm.org/viewvc/llvm-project?rev=343191&view=rev Log: Refactor ClangUserExpression::GetLanguageForExpr Summary: The `ClangUserExpression::GetLanguageForExpr` method is currently a big source of sadness, as it's name implies that it's an accessor method, but it actually is also initializing some variables that we need for parsing. This caused that we currently call this getter just for it's side effects while ignoring it's return value, which is confusing for the reader. This patch renames it to `UpdateLanguageForExpr` and merges all calls to the method into a single call in `ClangUserExpression::PrepareForParsing` (as calling this method is anyway mandatory for parsing to succeed) While looking at the code, I also found that we actually have two language variables in this class hierarchy. The normal `Language` from the UserExpression class and the `LanguageForExpr` that we implemented in this subclass. Both don't seem to actually contain the same value, so we probably should look at this next. Reviewers: xbolva00 Reviewed By: xbolva00 Subscribers: lldb-commits Differential Revision: https://reviews.llvm.org/D52561 Modified: lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangUserExpression.h Modified: lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp?rev=343191&r1=343190&r2=343191&view=diff == --- lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp (original) +++ lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp Thu Sep 27 03:12:54 2018 @@ -376,9 +376,9 @@ static void SetupDeclVendor(ExecutionCon } } -llvm::Optional ClangUserExpression::GetLanguageForExpr( +void ClangUserExpression::UpdateLanguageForExpr( DiagnosticManager &diagnostic_manager, ExecutionContext &exe_ctx) { - lldb::LanguageType lang_type = lldb::LanguageType::eLanguageTypeUnknown; + m_expr_lang = lldb::LanguageType::eLanguageTypeUnknown; std::string prefix = m_expr_prefix; @@ -390,17 +390,17 @@ llvm::Optional Clang m_expr_text.c_str())); if (m_in_cplusplus_method) - lang_type = lldb::eLanguageTypeC_plus_plus; + m_expr_lang = lldb::eLanguageTypeC_plus_plus; else if (m_in_objectivec_method) - lang_type = lldb::eLanguageTypeObjC; + m_expr_lang = lldb::eLanguageTypeObjC; else - lang_type = lldb::eLanguageTypeC; + m_expr_lang = lldb::eLanguageTypeC; -if (!source_code->GetText(m_transformed_text, lang_type, m_in_static_method, - exe_ctx)) { +if (!source_code->GetText(m_transformed_text, m_expr_lang, + m_in_static_method, exe_ctx)) { diagnostic_manager.PutString(eDiagnosticSeverityError, "couldn't construct expression body"); - return llvm::Optional(); + return; } // Find and store the start position of the original code inside the @@ -408,12 +408,11 @@ llvm::Optional Clang std::size_t original_start; std::size_t original_end; bool found_bounds = source_code->GetOriginalBodyBounds( -m_transformed_text, lang_type, original_start, original_end); +m_transformed_text, m_expr_lang, original_start, original_end); if (found_bounds) { m_user_expression_start_pos = original_start; } } - return lang_type; } bool ClangUserExpression::PrepareForParsing( @@ -437,6 +436,8 @@ bool ClangUserExpression::PrepareForPars ApplyObjcCastHack(m_expr_text); SetupDeclVendor(exe_ctx, m_target); + + UpdateLanguageForExpr(diagnostic_manager, exe_ctx); return true; } @@ -450,11 +451,6 @@ bool ClangUserExpression::Parse(Diagnost if (!PrepareForParsing(diagnostic_manager, exe_ctx)) return false; - lldb::LanguageType lang_type = lldb::LanguageType::eLanguageTypeUnknown; - if (auto new_lang = GetLanguageForExpr(diagnostic_manager, exe_ctx)) { -lang_type = new_lang.getValue(); - } - if (log) log->Printf("Parsing the following code:\n%s", m_transformed_text.c_str()); @@ -514,7 +510,7 @@ bool ClangUserExpression::Parse(Diagnost const std::string &fixed_expression = diagnostic_manager.GetFixedExpression(); if (ExpressionSourceCode::GetOriginalBodyBounds( -fixed_expression, lang_type, fixed_start, fixed_end)) +fixed_expression, m_expr_lang, fixed_start, fixed_end)) m_fixed_text = fixed_expression.substr(fixed_start, fixed_end - fixed_start); } @@ -655,8 +651,6 @@ bool ClangUserExpression::Complete(Execu if (!PrepareForP
Re: [Lldb-commits] [lldb] r344982 - [ValueObject] Stop assuming types are non-zero sized.
You maybe able to add a test for that in C++: Clang types can have 0 size, the padding from 0 to 1 happens in the CodeGen IIRC. See also this bug: https://bugs.llvm.org/show_bug.cgi?id=31612 - Raphael Am Di., 23. Okt. 2018 um 02:33 Uhr schrieb Davide Italiano via lldb-commits : > > Author: davide > Date: Mon Oct 22 17:31:46 2018 > New Revision: 344982 > > URL: http://llvm.org/viewvc/llvm-project?rev=344982&view=rev > Log: > [ValueObject] Stop assuming types are non-zero sized. > > Some backends might violate this assumption. No test case > upstream unfortunately as this is not the case with C++, > but I'm going to add a test in swift language support. > > > > Modified: > lldb/trunk/source/Core/ValueObjectConstResultImpl.cpp > > Modified: lldb/trunk/source/Core/ValueObjectConstResultImpl.cpp > URL: > http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/ValueObjectConstResultImpl.cpp?rev=344982&r1=344981&r2=344982&view=diff > == > --- lldb/trunk/source/Core/ValueObjectConstResultImpl.cpp (original) > +++ lldb/trunk/source/Core/ValueObjectConstResultImpl.cpp Mon Oct 22 17:31:46 > 2018 > @@ -77,7 +77,13 @@ ValueObject *ValueObjectConstResultImpl: >ignore_array_bounds, child_name_str, child_byte_size, > child_byte_offset, >child_bitfield_bit_size, child_bitfield_bit_offset, > child_is_base_class, >child_is_deref_of_parent, m_impl_backend, language_flags); > - if (child_compiler_type && child_byte_size) { > + > + // One might think we should check that the size of the children > + // is always strictly positive, hence we could avoid creating a > + // ValueObject if that's not the case, but it turns out there > + // are languages out there which allow zero-size types with > + // children (e.g. Swift). > + if (child_compiler_type) { > if (synthetic_index) >child_byte_offset += child_byte_size * synthetic_index; > > > > ___ > lldb-commits mailing list > lldb-commits@lists.llvm.org > http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] r350675 - Fix unused private field warning.
Author: teemperor Date: Tue Jan 8 14:55:02 2019 New Revision: 350675 URL: http://llvm.org/viewvc/llvm-project?rev=350675&view=rev Log: Fix unused private field warning. Summary: The member is private and unused if HAVE_LIBCOMPRESSION is undefined, which triggers Clang's -Wunused-private-field warning. Subscribers: lldb-commits Differential Revision: https://reviews.llvm.org/D56458 Modified: lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp Modified: lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp?rev=350675&r1=350674&r2=350675&view=diff == --- lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp (original) +++ lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp Tue Jan 8 14:55:02 2019 @@ -69,8 +69,9 @@ GDBRemoteCommunication::GDBRemoteCommuni m_echo_number(0), m_supports_qEcho(eLazyBoolCalculate), m_history(512), m_send_acks(true), m_compression_type(CompressionType::None), m_listen_url(), m_decompression_scratch_type(CompressionType::None), - m_decompression_scratch(nullptr) -{ + m_decompression_scratch(nullptr) { + // Unused unless HAVE_LIBCOMPRESSION is defined. + (void)m_decompression_scratch_type; } //-- ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] r333342 - Forward declare DumpValueObjectOptions in ValueObject.h
Author: teemperor Date: Sat May 26 07:34:49 2018 New Revision: 42 URL: http://llvm.org/viewvc/llvm-project?rev=42&view=rev Log: Forward declare DumpValueObjectOptions in ValueObject.h Summary: This resolves unnecessary the header dependency from Core to DataFormatters. Patch is necessary for the introduction of C++ modules to the LLDB build system. Subscribers: lldb-commits Differential Revision: https://reviews.llvm.org/D47409 Modified: lldb/trunk/include/lldb/Core/ValueObject.h lldb/trunk/source/Core/ValueObject.cpp Modified: lldb/trunk/include/lldb/Core/ValueObject.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/ValueObject.h?rev=42&r1=41&r2=42&view=diff == --- lldb/trunk/include/lldb/Core/ValueObject.h (original) +++ lldb/trunk/include/lldb/Core/ValueObject.h Sat May 26 07:34:49 2018 @@ -11,7 +11,6 @@ #define liblldb_ValueObject_h_ #include "lldb/Core/Value.h" -#include "lldb/DataFormatters/DumpValueObjectOptions.h" // for DumpValueObj... #include "lldb/Symbol/CompilerType.h" #include "lldb/Symbol/Type.h" // for TypeImpl #include "lldb/Target/ExecutionContext.h" @@ -45,6 +44,9 @@ namespace lldb_private { class Declaration; } namespace lldb_private { +class DumpValueObjectOptions; +} +namespace lldb_private { class EvaluateExpressionOptions; } namespace lldb_private { Modified: lldb/trunk/source/Core/ValueObject.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/ValueObject.cpp?rev=42&r1=41&r2=42&view=diff == --- lldb/trunk/source/Core/ValueObject.cpp (original) +++ lldb/trunk/source/Core/ValueObject.cpp Sat May 26 07:34:49 2018 @@ -19,6 +19,7 @@ #include "lldb/Core/ValueObjectMemory.h" #include "lldb/Core/ValueObjectSyntheticFilter.h" #include "lldb/DataFormatters/DataVisualization.h" +#include "lldb/DataFormatters/DumpValueObjectOptions.h" // for DumpValueObj... #include "lldb/DataFormatters/FormatManager.h" // for FormatManager #include "lldb/DataFormatters/StringPrinter.h" #include "lldb/DataFormatters/TypeFormat.h"// for TypeFormatImpl_F... ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] r333343 - Don't include headers from inside a namespace in MIUtilSingletonHelper.h
Author: teemperor Date: Sat May 26 07:39:35 2018 New Revision: 43 URL: http://llvm.org/viewvc/llvm-project?rev=43&view=rev Log: Don't include headers from inside a namespace in MIUtilSingletonHelper.h Subscribers: ki.stfu, lldb-commits Differential Revision: https://reviews.llvm.org/D47410 Modified: lldb/trunk/tools/lldb-mi/MIUtilSingletonHelper.h Modified: lldb/trunk/tools/lldb-mi/MIUtilSingletonHelper.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/lldb-mi/MIUtilSingletonHelper.h?rev=43&r1=42&r2=43&view=diff == --- lldb/trunk/tools/lldb-mi/MIUtilSingletonHelper.h (original) +++ lldb/trunk/tools/lldb-mi/MIUtilSingletonHelper.h Sat May 26 07:39:35 2018 @@ -9,12 +9,12 @@ #pragma once -namespace MI { - // In house headers: #include "MICmnResources.h" #include "MIUtilString.h" +namespace MI { + //++ // // Details: Short cut helper function to simplify repeated initialisation of ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] r333345 - Add missing includes to some LLDB headers.
Author: teemperor Date: Sat May 26 07:59:14 2018 New Revision: 45 URL: http://llvm.org/viewvc/llvm-project?rev=45&view=rev Log: Add missing includes to some LLDB headers. Summary: When compiling with modules, these missing includes cause the build to fail (as the header can't be compiled into a module). Subscribers: ki.stfu, lldb-commits Differential Revision: https://reviews.llvm.org/D47412 Modified: lldb/trunk/source/Plugins/DynamicLoader/Hexagon-DYLD/HexagonDYLDRendezvous.h lldb/trunk/source/Plugins/Process/Utility/InstructionUtils.h lldb/trunk/source/Plugins/Process/Utility/UnwindLLDB.h lldb/trunk/tools/lldb-mi/MICmnLLDBDebuggerHandleEvents.h Modified: lldb/trunk/source/Plugins/DynamicLoader/Hexagon-DYLD/HexagonDYLDRendezvous.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/DynamicLoader/Hexagon-DYLD/HexagonDYLDRendezvous.h?rev=45&r1=44&r2=45&view=diff == --- lldb/trunk/source/Plugins/DynamicLoader/Hexagon-DYLD/HexagonDYLDRendezvous.h (original) +++ lldb/trunk/source/Plugins/DynamicLoader/Hexagon-DYLD/HexagonDYLDRendezvous.h Sat May 26 07:59:14 2018 @@ -11,8 +11,10 @@ #define liblldb_HexagonDYLDRendezvous_H_ // C Includes +#include // for PATH_MAX // C++ Includes #include +#include #include // Other libraries and framework includes Modified: lldb/trunk/source/Plugins/Process/Utility/InstructionUtils.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Utility/InstructionUtils.h?rev=45&r1=44&r2=45&view=diff == --- lldb/trunk/source/Plugins/Process/Utility/InstructionUtils.h (original) +++ lldb/trunk/source/Plugins/Process/Utility/InstructionUtils.h Sat May 26 07:59:14 2018 @@ -10,6 +10,9 @@ #ifndef lldb_InstructionUtils_h_ #define lldb_InstructionUtils_h_ +#include +#include + // Common utilities for manipulating instruction bit fields. namespace lldb_private { Modified: lldb/trunk/source/Plugins/Process/Utility/UnwindLLDB.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Utility/UnwindLLDB.h?rev=45&r1=44&r2=45&view=diff == --- lldb/trunk/source/Plugins/Process/Utility/UnwindLLDB.h (original) +++ lldb/trunk/source/Plugins/Process/Utility/UnwindLLDB.h Sat May 26 07:59:14 2018 @@ -17,6 +17,7 @@ // Other libraries and framework includes // Project includes #include "lldb/Symbol/FuncUnwinders.h" +#include "lldb/Symbol/SymbolContext.h" #include "lldb/Symbol/UnwindPlan.h" #include "lldb/Target/RegisterContext.h" #include "lldb/Target/Unwind.h" Modified: lldb/trunk/tools/lldb-mi/MICmnLLDBDebuggerHandleEvents.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/lldb-mi/MICmnLLDBDebuggerHandleEvents.h?rev=45&r1=44&r2=45&view=diff == --- lldb/trunk/tools/lldb-mi/MICmnLLDBDebuggerHandleEvents.h (original) +++ lldb/trunk/tools/lldb-mi/MICmnLLDBDebuggerHandleEvents.h Sat May 26 07:59:14 2018 @@ -14,6 +14,7 @@ #include "MICmnMIValueList.h" #include "MICmnMIValueTuple.h" #include "MIUtilSingletonBase.h" +#include "lldb/API/SBEvent.h" // Declarations: class CMICmnLLDBDebugSessionInfo; ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] r333353 - Fix memory leak in SubsPrimitiveParmItanium
Author: teemperor Date: Sun May 27 00:31:06 2018 New Revision: 53 URL: http://llvm.org/viewvc/llvm-project?rev=53&view=rev Log: Fix memory leak in SubsPrimitiveParmItanium Summary: FastDemangle gives us a C-string that we own (which is allocated in SymbolDemangler::GetDemangledCopy). As we are not deleting the string, we leak memory whenever we call SubsPrimitiveParmItanium. Reviewers: javed.absar Subscribers: kristof.beyls, chrib, lldb-commits Differential Revision: https://reviews.llvm.org/D47418 Modified: lldb/trunk/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp Modified: lldb/trunk/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp?rev=53&r1=52&r2=53&view=diff == --- lldb/trunk/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp (original) +++ lldb/trunk/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp Sun May 27 00:31:06 2018 @@ -309,13 +309,15 @@ static ConstString SubsPrimitiveParmItan // FastDemangle will call our hook for each instance of a primitive type, // allowing us to perform substitution - const char *const demangled = + char *const demangled = FastDemangle(mangled.str().c_str(), mangled.size(), swap_parms_hook); if (log) log->Printf("substituted mangling for %s:{%s} %s:{%s}\n", mangled.str().c_str(), demangled, output_buf.c_str(), FastDemangle(output_buf.c_str())); + // FastDemangle malloc'd this string. + free(demangled); return output_buf == mangled ? ConstString() : ConstString(output_buf); } ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] r334259 - Added missing include to LoadedModuleInfoList.h
Author: teemperor Date: Thu Jun 7 19:00:27 2018 New Revision: 334259 URL: http://llvm.org/viewvc/llvm-project?rev=334259&view=rev Log: Added missing include to LoadedModuleInfoList.h Subscribers: lldb-commits Differential Revision: https://reviews.llvm.org/D47923 Modified: lldb/trunk/include/lldb/Core/LoadedModuleInfoList.h Modified: lldb/trunk/include/lldb/Core/LoadedModuleInfoList.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/LoadedModuleInfoList.h?rev=334259&r1=334258&r2=334259&view=diff == --- lldb/trunk/include/lldb/Core/LoadedModuleInfoList.h (original) +++ lldb/trunk/include/lldb/Core/LoadedModuleInfoList.h Thu Jun 7 19:00:27 2018 @@ -14,6 +14,7 @@ // C++ Includes #include +#include #include // Other libraries and framework includes ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] r334549 - Added modulemap for lldb-mi
Author: teemperor Date: Tue Jun 12 14:22:52 2018 New Revision: 334549 URL: http://llvm.org/viewvc/llvm-project?rev=334549&view=rev Log: Added modulemap for lldb-mi Summary: This patch allows building a C++ module for the lldb-mi headers. Reviewers: bruno, aprantl Reviewed By: aprantl Subscribers: lldb-commits, ki.stfu Differential Revision: https://reviews.llvm.org/D47996 Added: lldb/trunk/tools/lldb-mi/module.modulemap Added: lldb/trunk/tools/lldb-mi/module.modulemap URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/lldb-mi/module.modulemap?rev=334549&view=auto == --- lldb/trunk/tools/lldb-mi/module.modulemap (added) +++ lldb/trunk/tools/lldb-mi/module.modulemap Tue Jun 12 14:22:52 2018 @@ -0,0 +1,79 @@ +module lldb_mi { + module MICmdArgContext { header "MICmdArgContext.h" export * } + module MICmdArgSet { header "MICmdArgSet.h" export * } + module MICmdArgValBase { header "MICmdArgValBase.h" export * } + module MICmdArgValConsume { header "MICmdArgValConsume.h" export * } + module MICmdArgValFile { header "MICmdArgValFile.h" export * } + module MICmdArgValListBase { header "MICmdArgValListBase.h" export * } + module MICmdArgValListOfN { header "MICmdArgValListOfN.h" export * } + module MICmdArgValNumber { header "MICmdArgValNumber.h" export * } + module MICmdArgValOptionLong { header "MICmdArgValOptionLong.h" export * } + module MICmdArgValOptionShort { header "MICmdArgValOptionShort.h" export * } + module MICmdArgValPrintValues { header "MICmdArgValPrintValues.h" export * } + module MICmdArgValString { header "MICmdArgValString.h" export * } + module MICmdArgValThreadGrp { header "MICmdArgValThreadGrp.h" export * } + module MICmdBase { header "MICmdBase.h" export * } + module MICmdCmdBreak { header "MICmdCmdBreak.h" export * } + module MICmdCmdData { header "MICmdCmdData.h" export * } + module MICmdCmdEnviro { header "MICmdCmdEnviro.h" export * } + module MICmdCmdExec { header "MICmdCmdExec.h" export * } + module MICmdCmdFile { header "MICmdCmdFile.h" export * } + module MICmdCmdGdbInfo { header "MICmdCmdGdbInfo.h" export * } + module MICmdCmdGdbSet { header "MICmdCmdGdbSet.h" export * } + module MICmdCmdGdbShow { header "MICmdCmdGdbShow.h" export * } + module MICmdCmdGdbThread { header "MICmdCmdGdbThread.h" export * } + module MICmdCmd { header "MICmdCmd.h" export * } + module MICmdCmdMiscellanous { header "MICmdCmdMiscellanous.h" export * } + module MICmdCmdStack { header "MICmdCmdStack.h" export * } + module MICmdCmdSupportInfo { header "MICmdCmdSupportInfo.h" export * } + module MICmdCmdSupportList { header "MICmdCmdSupportList.h" export * } + module MICmdCmdSymbol { header "MICmdCmdSymbol.h" export * } + module MICmdCmdTarget { header "MICmdCmdTarget.h" export * } + module MICmdCmdThread { header "MICmdCmdThread.h" export * } + module MICmdCmdTrace { header "MICmdCmdTrace.h" export * } + module MICmdCmdVar { header "MICmdCmdVar.h" export * } + module MICmdCommands { header "MICmdCommands.h" export * } + module MICmdData { header "MICmdData.h" export * } + module MICmdFactory { header "MICmdFactory.h" export * } + module MICmdInterpreter { header "MICmdInterpreter.h" export * } + module MICmdInvoker { header "MICmdInvoker.h" export * } + module MICmdMgr { header "MICmdMgr.h" export * } + module MICmdMgrSetCmdDeleteCallback { header "MICmdMgrSetCmdDeleteCallback.h" export * } + module MICmnBase { header "MICmnBase.h" export * } + module MICmnConfig { header "MICmnConfig.h" export * } + module MICmnLLDBBroadcaster { header "MICmnLLDBBroadcaster.h" export * } + module MICmnLLDBDebugger { header "MICmnLLDBDebugger.h" export * } + module MICmnLLDBDebuggerHandleEvents { header "MICmnLLDBDebuggerHandleEvents.h" export * } + module MICmnLLDBDebugSessionInfo { header "MICmnLLDBDebugSessionInfo.h" export * } + module MICmnLLDBDebugSessionInfoVarObj { header "MICmnLLDBDebugSessionInfoVarObj.h" export * } + module MICmnLLDBProxySBValue { header "MICmnLLDBProxySBValue.h" export * } + module MICmnLLDBUtilSBValue { header "MICmnLLDBUtilSBValue.h" export * } + module MICmnLog { header "MICmnLog.h" export * } + module MICmnLogMediumFile { header "MICmnLogMediumFile.h" export * } + module MICmnMIOutOfBandRecord { header "MICmnMIOutOfBandRecord.h" export * } + module MICmnMIResultRecord { header "MICmnMIResultRecord.h" export * } + module MICmnMIValueConst { header "MICmnMIValueConst.h" export * } + module MICmnMIValue { header "MICmnMIValue.h" export * } + module MICmnMIValueList { header "MICmnMIValueList.h" export * } + module MICmnMIValueResult { header "MICmnMIValueResult.h" export * } + module MICmnMIValueTuple { header "MICmnMIValueTuple.h" export * } + module MICmnResources { header "MICmnResources.h" export * } + module MICmnStreamStderr { header "MICmnStreamStderr.h" export * } + module MICmnStreamStdin { header "MICmnStreamStdin.h" export * } + m
[Lldb-commits] [lldb] r334557 - Disable warnings for the generated LLDB wrapper source
Author: teemperor Date: Tue Jun 12 15:51:20 2018 New Revision: 334557 URL: http://llvm.org/viewvc/llvm-project?rev=334557&view=rev Log: Disable warnings for the generated LLDB wrapper source Summary: This source files emits all kind of compiler warnings on different platforms. As the source code in the file is generated and we therefore can't actually fix the warnings, we might as well disable them. Reviewers: aprantl, davide Reviewed By: davide Subscribers: davide, mgorny, lldb-commits Differential Revision: https://reviews.llvm.org/D48096 Modified: lldb/trunk/source/API/CMakeLists.txt Modified: lldb/trunk/source/API/CMakeLists.txt URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/CMakeLists.txt?rev=334557&r1=334556&r2=334557&view=diff == --- lldb/trunk/source/API/CMakeLists.txt (original) +++ lldb/trunk/source/API/CMakeLists.txt Tue Jun 12 15:51:20 2018 @@ -101,13 +101,12 @@ add_lldb_library(liblldb SHARED Support ) -if (LLVM_ENABLE_WERROR) - if (MSVC) -set_property(SOURCE ${LLDB_WRAP_PYTHON} APPEND_STRING PROPERTY COMPILE_FLAGS " /W0") - else() -set_property(SOURCE ${LLDB_WRAP_PYTHON} APPEND_STRING PROPERTY COMPILE_FLAGS " -w") - endif() +if (MSVC) + set_property(SOURCE ${LLDB_WRAP_PYTHON} APPEND_STRING PROPERTY COMPILE_FLAGS " /W0") +else() + set_property(SOURCE ${LLDB_WRAP_PYTHON} APPEND_STRING PROPERTY COMPILE_FLAGS " -w") endif() + set_source_files_properties(${LLDB_WRAP_PYTHON} PROPERTIES GENERATED 1) if (CLANG_CL) set_property(SOURCE ${LLDB_WRAP_PYTHON} APPEND_STRING ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] r334611 - Add modules support for lldb headers in include/
Author: teemperor Date: Wed Jun 13 08:50:45 2018 New Revision: 334611 URL: http://llvm.org/viewvc/llvm-project?rev=334611&view=rev Log: Add modules support for lldb headers in include/ Summary: This patch adds a modulemap which allows compiling the lldb headers into C++ modules (for example in builds with LLVM_ENABLE_MODULES=On). Even though most of the affected code has been cleaned up to work with the more strict C++ module semantics, there are still some workarounds left in the current modulemap (the most obvious one is the big `lldb` wrapper module). It also moves the Obj-C++ files in lldb to their own subdirectories. This was necessary because we need to filter out the modules flags for this code. Note: With the latest clang and libstdc++ it seems necessary to have a STL C++ module to get a working LLVM_ENABLE_MODULES build for lldb. Otherwise clang will falsely detect ODR violations in the textually included STL code inside the lldb modules. Reviewers: aprantl, bruno Reviewed By: aprantl, bruno Subscribers: mgorny, yamaguchi, v.g.vassilev, lldb-commits Differential Revision: https://reviews.llvm.org/D47929 Added: lldb/trunk/include/lldb/module.modulemap lldb/trunk/source/Host/macosx/objcxx/ lldb/trunk/source/Host/macosx/objcxx/CMakeLists.txt lldb/trunk/source/Host/macosx/objcxx/Host.mm - copied, changed from r334557, lldb/trunk/source/Host/macosx/Host.mm lldb/trunk/source/Host/macosx/objcxx/HostInfoMacOSX.mm - copied, changed from r334557, lldb/trunk/source/Host/macosx/HostInfoMacOSX.mm lldb/trunk/source/Host/macosx/objcxx/HostThreadMacOSX.mm - copied, changed from r334557, lldb/trunk/source/Host/macosx/HostThreadMacOSX.mm lldb/trunk/source/Plugins/Platform/MacOSX/objcxx/ lldb/trunk/source/Plugins/Platform/MacOSX/objcxx/CMakeLists.txt lldb/trunk/source/Plugins/Platform/MacOSX/objcxx/PlatformiOSSimulatorCoreSimulatorSupport.mm - copied, changed from r334557, lldb/trunk/source/Plugins/Platform/MacOSX/PlatformiOSSimulatorCoreSimulatorSupport.mm Removed: lldb/trunk/source/Host/macosx/Host.mm lldb/trunk/source/Host/macosx/HostInfoMacOSX.mm lldb/trunk/source/Host/macosx/HostThreadMacOSX.mm lldb/trunk/source/Plugins/Platform/MacOSX/PlatformiOSSimulatorCoreSimulatorSupport.mm Modified: lldb/trunk/source/Host/CMakeLists.txt lldb/trunk/source/Host/common/Terminal.cpp lldb/trunk/source/Plugins/Platform/MacOSX/CMakeLists.txt Added: lldb/trunk/include/lldb/module.modulemap URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/module.modulemap?rev=334611&view=auto == --- lldb/trunk/include/lldb/module.modulemap (added) +++ lldb/trunk/include/lldb/module.modulemap Wed Jun 13 08:50:45 2018 @@ -0,0 +1,139 @@ + +module lldb_API { + requires cplusplus + + umbrella "API" + module * { export * } +} + +module lldb_Host { + requires cplusplus + + // Because we have OS-specific headers in Host, we just list + // all OS-independent headers here that will include the correct + // OS-specific header for us. + module ConnectionFileDescriptor { header "Host/ConnectionFileDescriptor.h" export * } + module Debug { header "Host/Debug.h" export * } + module Editline { header "Host/Editline.h" export * } + module FileCache { header "Host/FileCache.h" export * } + module File { header "Host/File.h" export * } + module FileSystem { header "Host/FileSystem.h" export * } + module HostGetOpt { header "Host/HostGetOpt.h" export * } + module Host { header "Host/Host.h" export * } + module HostInfoBase { header "Host/HostInfoBase.h" export * } + module HostInfo { header "Host/HostInfo.h" export * } + module HostNativeProcessBase { header "Host/HostNativeProcessBase.h" export * } + module HostNativeProcess { header "Host/HostNativeProcess.h" export * } + module HostNativeThreadBase { header "Host/HostNativeThreadBase.h" export * } + module HostNativeThreadForward { header "Host/HostNativeThreadForward.h" export * } + module HostNativeThread { header "Host/HostNativeThread.h" export * } + module HostProcess { header "Host/HostProcess.h" export * } + module HostThread { header "Host/HostThread.h" export * } + module LockFileBase { header "Host/LockFileBase.h" export * } + module LockFile { header "Host/LockFile.h" export * } + module MainLoopBase { header "Host/MainLoopBase.h" export * } + module MainLoop { header "Host/MainLoop.h" export * } + module MonitoringProcessLauncher { header "Host/MonitoringProcessLauncher.h" export * } + module OptionParser { header "Host/OptionParser.h" export * } + module PipeBase { header "Host/PipeBase.h" export * } + module Pipe { header "Host/Pipe.h" export * } + module PosixApi { header "Host/PosixApi.h" export * } + module Predicate { header "Host/Predicate.h" export * } + module ProcessLauncher { header "Host/ProcessLauncher.h" export * } + module ProcessRunLock { header "
[Lldb-commits] [lldb] r334978 - Fixed file completion for paths that start with '~'.
Author: teemperor Date: Mon Jun 18 13:11:38 2018 New Revision: 334978 URL: http://llvm.org/viewvc/llvm-project?rev=334978&view=rev Log: Fixed file completion for paths that start with '~'. We didn't add the remaining path behind the '~' to the completion string, causing it to just complete directories inside the user home directory. This patch just adds the directory of the remaining path if there is one. Fixes rdar://problem/40147002 Modified: lldb/trunk/source/Commands/CommandCompletions.cpp Modified: lldb/trunk/source/Commands/CommandCompletions.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandCompletions.cpp?rev=334978&r1=334977&r2=334978&view=diff == --- lldb/trunk/source/Commands/CommandCompletions.cpp (original) +++ lldb/trunk/source/Commands/CommandCompletions.cpp Mon Jun 18 13:11:38 2018 @@ -164,6 +164,12 @@ static int DiskFilesOrDirectories(const // search in the fully resolved directory, but CompletionBuffer keeps the // unmodified form that the user typed. Storage = Resolved; +llvm::StringRef RemainderDir = path::parent_path(Remainder.str()); +if (!RemainderDir.empty()) { + // Append the remaining path to the resolved directory. + Storage.append(path::get_separator()); + Storage.append(RemainderDir); +} SearchDir = Storage; } else { SearchDir = path::parent_path(CompletionBuffer); ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] r335078 - Refactor OnExit utility class in ClangUserExpression
Author: teemperor Date: Tue Jun 19 14:25:59 2018 New Revision: 335078 URL: http://llvm.org/viewvc/llvm-project?rev=335078&view=rev Log: Refactor OnExit utility class in ClangUserExpression Summary: OnExit ensures we call `ResetDeclMap` before this method ends. However, we also have a few manual calls to ResetDeclMap in there that are actually unnecessary because of this (calling the method multiple times has no effect). This patch also moves the class out of the method that we can reuse it for the upcoming method that handles parsing for completion. Subscribers: lldb-commits Differential Revision: https://reviews.llvm.org/D48337 Modified: lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp Modified: lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp?rev=335078&r1=335077&r2=335078&view=diff == --- lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp (original) +++ lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp Tue Jun 19 14:25:59 2018 @@ -307,6 +307,21 @@ static void ApplyObjcCastHack(std::strin #undef OBJC_CAST_HACK_FROM } +namespace { +// Utility guard that calls a callback when going out of scope. +class OnExit { +public: + typedef std::function Callback; + + OnExit(Callback const &callback) : m_callback(callback) {} + + ~OnExit() { m_callback(); } + +private: + Callback m_callback; +}; +} // namespace + bool ClangUserExpression::Parse(DiagnosticManager &diagnostic_manager, ExecutionContext &exe_ctx, lldb_private::ExecutionPolicy execution_policy, @@ -426,28 +441,12 @@ bool ClangUserExpression::Parse(Diagnost ResetDeclMap(exe_ctx, m_result_delegate, keep_result_in_memory); - class OnExit { - public: -typedef std::function Callback; - -OnExit(Callback const &callback) : m_callback(callback) {} - -~OnExit() { m_callback(); } - - private: -Callback m_callback; - }; - OnExit on_exit([this]() { ResetDeclMap(); }); if (!DeclMap()->WillParse(exe_ctx, m_materializer_ap.get())) { diagnostic_manager.PutString( eDiagnosticSeverityError, "current process state is unsuitable for expression parsing"); - -ResetDeclMap(); // We are being careful here in the case of breakpoint -// conditions. - return false; } @@ -484,10 +483,6 @@ bool ClangUserExpression::Parse(Diagnost fixed_expression.substr(fixed_start, fixed_end - fixed_start); } } - -ResetDeclMap(); // We are being careful here in the case of breakpoint -// conditions. - return false; } @@ -565,10 +560,6 @@ bool ClangUserExpression::Parse(Diagnost } } - ResetDeclMap(); // Make this go away since we don't need any of its state - // after parsing. This also gets rid of any - // ClangASTImporter::Minions. - if (process && m_jit_start_addr != LLDB_INVALID_ADDRESS) m_jit_process_wp = lldb::ProcessWP(process->shared_from_this()); return true; ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] r323064 - [modules] Fix missing includes/typo in LLDB's includes. [NFC]
Author: teemperor Date: Sun Jan 21 01:54:19 2018 New Revision: 323064 URL: http://llvm.org/viewvc/llvm-project?rev=323064&view=rev Log: [modules] Fix missing includes/typo in LLDB's includes. [NFC] Summary: This patch adds missing includes to the LLDB headers inside `include/` as a first step of building LLDB's source with C++ modules. It also fixes this single `stds::` typo. Some quick map why some non-obvious includes were necessary: * lldb/lldb-defines.h for LLDB_INVALID_ADDRESS * lldb/lldb-types.h for addr_t * lldb/lldb-defines.h for DISALLOW_COPY_AND_ASSIG * lldb/DataFormatters/TypeSynthetic.h for SyntheticChildrenFrontEnd Reviewers: aprantl Reviewed By: aprantl Subscribers: zturner, lldb-commits Differential Revision: https://reviews.llvm.org/D42340 Modified: lldb/trunk/include/lldb/Core/LoadedModuleInfoList.h lldb/trunk/include/lldb/Core/ThreadSafeDenseSet.h lldb/trunk/include/lldb/Core/ThreadSafeValue.h lldb/trunk/include/lldb/DataFormatters/VectorIterator.h lldb/trunk/include/lldb/Target/ProcessStructReader.h lldb/trunk/include/lldb/Utility/AnsiTerminal.h lldb/trunk/include/lldb/Utility/SharedCluster.h Modified: lldb/trunk/include/lldb/Core/LoadedModuleInfoList.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/LoadedModuleInfoList.h?rev=323064&r1=323063&r2=323064&view=diff == --- lldb/trunk/include/lldb/Core/LoadedModuleInfoList.h (original) +++ lldb/trunk/include/lldb/Core/LoadedModuleInfoList.h Sun Jan 21 01:54:19 2018 @@ -13,10 +13,13 @@ // C Includes // C++ Includes +#include #include // Other libraries and framework includes +#include "lldb/lldb-defines.h" #include "lldb/lldb-private-forward.h" +#include "lldb/lldb-types.h" namespace lldb_private { class LoadedModuleInfoList { Modified: lldb/trunk/include/lldb/Core/ThreadSafeDenseSet.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/ThreadSafeDenseSet.h?rev=323064&r1=323063&r2=323064&view=diff == --- lldb/trunk/include/lldb/Core/ThreadSafeDenseSet.h (original) +++ lldb/trunk/include/lldb/Core/ThreadSafeDenseSet.h Sun Jan 21 01:54:19 2018 @@ -46,7 +46,7 @@ public: } void Clear() { -stds::lock_guard<_MutexType> guard(m_mutex); +std::lock_guard<_MutexType> guard(m_mutex); m_set.clear(); } Modified: lldb/trunk/include/lldb/Core/ThreadSafeValue.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/ThreadSafeValue.h?rev=323064&r1=323063&r2=323064&view=diff == --- lldb/trunk/include/lldb/Core/ThreadSafeValue.h (original) +++ lldb/trunk/include/lldb/Core/ThreadSafeValue.h Sun Jan 21 01:54:19 2018 @@ -17,6 +17,7 @@ // Other libraries and framework includes // Project includes +#include "lldb/lldb-defines.h" namespace lldb_private { Modified: lldb/trunk/include/lldb/DataFormatters/VectorIterator.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/DataFormatters/VectorIterator.h?rev=323064&r1=323063&r2=323064&view=diff == --- lldb/trunk/include/lldb/DataFormatters/VectorIterator.h (original) +++ lldb/trunk/include/lldb/DataFormatters/VectorIterator.h Sun Jan 21 01:54:19 2018 @@ -13,6 +13,7 @@ #include "lldb/lldb-forward.h" +#include "lldb/DataFormatters/TypeSynthetic.h" #include "lldb/Target/ExecutionContext.h" #include "lldb/Utility/ConstString.h" Modified: lldb/trunk/include/lldb/Target/ProcessStructReader.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/ProcessStructReader.h?rev=323064&r1=323063&r2=323064&view=diff == --- lldb/trunk/include/lldb/Target/ProcessStructReader.h (original) +++ lldb/trunk/include/lldb/Target/ProcessStructReader.h Sun Jan 21 01:54:19 2018 @@ -16,6 +16,7 @@ #include "lldb/Symbol/CompilerType.h" #include "lldb/Target/Process.h" #include "lldb/Utility/ConstString.h" +#include "lldb/Utility/DataBufferHeap.h" #include "lldb/Utility/DataExtractor.h" #include "lldb/Utility/Status.h" Modified: lldb/trunk/include/lldb/Utility/AnsiTerminal.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Utility/AnsiTerminal.h?rev=323064&r1=323063&r2=323064&view=diff == --- lldb/trunk/include/lldb/Utility/AnsiTerminal.h (original) +++ lldb/trunk/include/lldb/Utility/AnsiTerminal.h Sun Jan 21 01:54:19 2018 @@ -50,6 +50,7 @@ #define ANSI_1_CTRL(ctrl1) "\033["##ctrl1 ANSI_ESC_END #define ANSI_2_CTRL(ctrl1, ctrl2) "\033["##ctrl1 ";"##ctrl2 ANSI_ESC_END +#include "llvm/ADT/ArrayRef.h" #include "llvm/ADT/STLExtras.h" #include "llvm/ADT/StringRef.h" Modified: lldb/tru
[Lldb-commits] [lldb] r335905 - Added test case for: r334978 - Fixed file completion for paths that start with '~'
Author: teemperor Date: Thu Jun 28 12:34:49 2018 New Revision: 335905 URL: http://llvm.org/viewvc/llvm-project?rev=335905&view=rev Log: Added test case for: r334978 - Fixed file completion for paths that start with '~' Reviewers: labath Reviewed By: labath Subscribers: lldb-commits Differential Revision: https://reviews.llvm.org/D48665 Modified: lldb/trunk/unittests/Interpreter/TestCompletion.cpp Modified: lldb/trunk/unittests/Interpreter/TestCompletion.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/unittests/Interpreter/TestCompletion.cpp?rev=335905&r1=335904&r2=335905&view=diff == --- lldb/trunk/unittests/Interpreter/TestCompletion.cpp (original) +++ lldb/trunk/unittests/Interpreter/TestCompletion.cpp Thu Jun 28 12:34:49 2018 @@ -51,6 +51,7 @@ protected: static SmallString<128> DirBar; static SmallString<128> DirBaz; static SmallString<128> DirTestFolder; + static SmallString<128> DirNested; static SmallString<128> FileAA; static SmallString<128> FileAB; @@ -65,17 +66,17 @@ protected: llvm::sys::fs::current_path(OriginalWorkingDir); ASSERT_NO_ERROR(fs::createUniqueDirectory("FsCompletion", BaseDir)); -const char *DirNames[] = {"foo", "fooa", "foob", "fooc", - "bar", "baz", "test_folder"}; +const char *DirNames[] = {"foo", "fooa", "foob","fooc", + "bar", "baz", "test_folder", "foo/nested"}; const char *FileNames[] = {"aa1234.tmp", "ab1234.tmp", "ac1234.tmp", "foo1234.tmp", "bar1234.tmp", "baz1234.tmp"}; -SmallString<128> *Dirs[] = {&DirFoo, &DirFooA, &DirFooB, &DirFooC, -&DirBar, &DirBaz, &DirTestFolder}; +SmallString<128> *Dirs[] = {&DirFoo, &DirFooA, &DirFooB, &DirFooC, +&DirBar, &DirBaz, &DirTestFolder, &DirNested}; for (auto Dir : llvm::zip(DirNames, Dirs)) { auto &Path = *std::get<1>(Dir); Path = BaseDir; path::append(Path, std::get<0>(Dir)); - ASSERT_NO_ERROR(fs::create_directory(Path)); + ASSERT_NO_ERROR(fs::create_directories(Path)); } SmallString<128> *Files[] = {&FileAA, &FileAB, &FileAC, @@ -146,6 +147,7 @@ SmallString<128> CompletionTest::DirFooC SmallString<128> CompletionTest::DirBar; SmallString<128> CompletionTest::DirBaz; SmallString<128> CompletionTest::DirTestFolder; +SmallString<128> CompletionTest::DirNested; SmallString<128> CompletionTest::FileAA; SmallString<128> CompletionTest::FileAB; @@ -280,6 +282,20 @@ TEST_F(CompletionTest, DirCompletionUser EXPECT_TRUE(ContainsExactString( Twine("~/test_folder") + path::get_separator(), Results)); + // Check that we can complete directories in nested paths + Count = CommandCompletions::DiskDirectories("~/foo/", Results, Resolver); + ASSERT_EQ(1u, Count); + ASSERT_EQ(Count, Results.GetSize()); + EXPECT_TRUE(ContainsExactString(Twine("~/foo") + path::get_separator() + + "nested" + path::get_separator(), + Results)); + Count = CommandCompletions::DiskDirectories("~/foo/nes", Results, Resolver); + ASSERT_EQ(1u, Count); + ASSERT_EQ(Count, Results.GetSize()); + EXPECT_TRUE(ContainsExactString(Twine("~/foo") + path::get_separator() + + "nested" + path::get_separator(), + Results)); + // With ~username syntax it should return one match if there is an exact // match. // It shouldn't translate to the actual directory, it should keep the form the ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
Re: [Lldb-commits] [lldb] r334978 - Fixed file completion for paths that start with '~'.
Woops, didn't see that. Seems my email filters were a bit too strict on messages with lldb-commits in the CC... See https://reviews.llvm.org/D48665 Am Mi., 27. Juni 2018 um 07:15 Uhr schrieb Pavel Labath : > > Ping. > On Tue, 19 Jun 2018 at 16:04, Pavel Labath wrote: > > > > A test? > > > > It looks like it should be possible to test this in a similar way to > > other CommandCompletion tests > > (unittests/Interpreter/TestCompletion.cpp). > > On Mon, 18 Jun 2018 at 21:16, Raphael Isemann via lldb-commits > > wrote: > > > > > > Author: teemperor > > > Date: Mon Jun 18 13:11:38 2018 > > > New Revision: 334978 > > > > > > URL: http://llvm.org/viewvc/llvm-project?rev=334978&view=rev > > > Log: > > > Fixed file completion for paths that start with '~'. > > > > > > We didn't add the remaining path behind the '~' to the completion string, > > > causing it to just complete directories inside the user home directory. > > > This > > > patch just adds the directory of the remaining path if there is one. > > > > > > Fixes rdar://problem/40147002 > > > > > > Modified: > > > lldb/trunk/source/Commands/CommandCompletions.cpp > > > > > > Modified: lldb/trunk/source/Commands/CommandCompletions.cpp > > > URL: > > > http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandCompletions.cpp?rev=334978&r1=334977&r2=334978&view=diff > > > == > > > --- lldb/trunk/source/Commands/CommandCompletions.cpp (original) > > > +++ lldb/trunk/source/Commands/CommandCompletions.cpp Mon Jun 18 13:11:38 > > > 2018 > > > @@ -164,6 +164,12 @@ static int DiskFilesOrDirectories(const > > > // search in the fully resolved directory, but CompletionBuffer > > > keeps the > > > // unmodified form that the user typed. > > > Storage = Resolved; > > > +llvm::StringRef RemainderDir = path::parent_path(Remainder.str()); > > > +if (!RemainderDir.empty()) { > > > + // Append the remaining path to the resolved directory. > > > + Storage.append(path::get_separator()); > > > + Storage.append(RemainderDir); > > > +} > > > SearchDir = Storage; > > >} else { > > > SearchDir = path::parent_path(CompletionBuffer); > > > > > > > > > ___ > > > lldb-commits mailing list > > > lldb-commits@lists.llvm.org > > > http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] r336377 - Fixed redefinition warnings with LLVM_ENABLE_MODULES
Author: teemperor Date: Thu Jul 5 10:12:11 2018 New Revision: 336377 URL: http://llvm.org/viewvc/llvm-project?rev=336377&view=rev Log: Fixed redefinition warnings with LLVM_ENABLE_MODULES Summary: It seems we both have the HAVE_LIBCOMPRESSION define in the config header and in the source files definitions of some files. This causes that the Config.h header emits the following warning when we compile the Host module: ``` In file included from :21: In file included from /Users/teemperor/llvm/llvm/tools/lldb/include/lldb/Host/MainLoop.h:13: tools/lldb/include/lldb/Host/Config.h:33:9: warning: 'HAVE_LIBCOMPRESSION' macro redefined [-Wmacro-redefined] ^ :1:9: note: previous definition is here ^ ``` It's not really clear why the define is in both places (the commit message just says it fixes some unspecified bug), but we can easily work around this by just guarding our define in Config.h. Reviewers: aprantl Reviewed By: aprantl Subscribers: mgorny, lldb-commits Differential Revision: https://reviews.llvm.org/D48977 Modified: lldb/trunk/include/lldb/Host/Config.h.cmake Modified: lldb/trunk/include/lldb/Host/Config.h.cmake URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Host/Config.h.cmake?rev=336377&r1=336376&r2=336377&view=diff == --- lldb/trunk/include/lldb/Host/Config.h.cmake (original) +++ lldb/trunk/include/lldb/Host/Config.h.cmake Thu Jul 5 10:12:11 2018 @@ -30,6 +30,8 @@ #cmakedefine01 HAVE_NR_PROCESS_VM_READV +#ifndef HAVE_LIBCOMPRESSION #cmakedefine HAVE_LIBCOMPRESSION +#endif #endif // #ifndef LLDB_HOST_CONFIG_H ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] r336149 - Fixed compilation failure after the code completion refactor patch
Author: teemperor Date: Mon Jul 2 15:18:18 2018 New Revision: 336149 URL: http://llvm.org/viewvc/llvm-project?rev=336149&view=rev Log: Fixed compilation failure after the code completion refactor patch Subscribers: lldb-commits Differential Revision: https://reviews.llvm.org/D48855 Modified: lldb/trunk/include/lldb/Interpreter/CommandObject.h lldb/trunk/include/lldb/Utility/CompletionRequest.h Modified: lldb/trunk/include/lldb/Interpreter/CommandObject.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Interpreter/CommandObject.h?rev=336149&r1=336148&r2=336149&view=diff == --- lldb/trunk/include/lldb/Interpreter/CommandObject.h (original) +++ lldb/trunk/include/lldb/Interpreter/CommandObject.h Mon Jul 2 15:18:18 2018 @@ -16,7 +16,7 @@ #include #include -#include +#include "lldb/Utility/CompletionRequest.h" // Other libraries and framework includes // Project includes Modified: lldb/trunk/include/lldb/Utility/CompletionRequest.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Utility/CompletionRequest.h?rev=336149&r1=336148&r2=336149&view=diff == --- lldb/trunk/include/lldb/Utility/CompletionRequest.h (original) +++ lldb/trunk/include/lldb/Utility/CompletionRequest.h Mon Jul 2 15:18:18 2018 @@ -10,9 +10,9 @@ #ifndef LLDB_UTILITY_COMPLETIONREQUEST_H #define LLDB_UTILITY_COMPLETIONREQUEST_H -#include -#include -#include +#include "lldb/Utility/Args.h" +#include "lldb/Utility/StringList.h" +#include "llvm/ADT/StringRef.h" namespace lldb_private { ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] r336146 - Refactoring for for the internal command line completion API (NFC)
Author: teemperor Date: Mon Jul 2 14:29:56 2018 New Revision: 336146 URL: http://llvm.org/viewvc/llvm-project?rev=336146&view=rev Log: Refactoring for for the internal command line completion API (NFC) Summary: This patch refactors the internal completion API. It now takes (as far as possible) a single CompletionRequest object instead o half a dozen in/out/in-out parameters. The CompletionRequest contains a common superset of the different parameters as far as it makes sense. This includes the raw command line string and raw cursor position, which should make the `expr` command possible to implement (at least without hacks that reconstruct the command line from the args). This patch is not intended to change the observable behavior of lldb in any way. It's also as minimal as possible and doesn't attempt to fix all the problems the API has. Some Q&A: Q: Why is this not fixing all the problems in the completion API? A: Because is a blocker for the expr command completion which I want to get in ASAP. This is the smallest patch that unblocks the expr completion patch and which allows trivial refactoring in the future. The patch also doesn't really change the internal information flow in the API, so that hopefully saves us from ever having to revert and resubmit this humongous patch. Q: Can we merge all the copy-pasted code in the completion methods (like computing the current incomplete arg) into CompletionRequest class? A: Yes, but it's out of scope for this patch. Q: Why the `word_complete = request.GetWordComplete(); ... ` pattern? A: I don't want to add a getter that returns a reference to the internal integer. So we have to use a temporary variable and the Getter/Setter instead. We don't throw exceptions from what I can tell, so the behavior doesn't change. Q: Why are we not owning the list of matches? A: Because that's how the previous API works. But that should be fixed too (in another patch). Q: Can we make the constructor simpler and compute some of the values from the plain command? A: I think this works, but I rather want to have this in a follow up commit. Especially when making nested request it's a bit awkward that the parsed arguments behave as both input/output (as we should in theory propagate the changes on the nested request back to the parent request if we don't want to change the behavior too much). Q: Can't we pass one const request object and then just return another result object instead of mixing them together in one in/out parameter? A: It's hard to get keep the same behavior with that pattern, but I think we can also get a nice API with just a single request object. If we make all input parameters read-only, we have a clear separation between what is actually an input and what an output parameter (and hopefully we get rid of the in-out parameters). Q: Can we throw out the 'match' variables that are not implemented according to the comment? A: We currently just forward them as in the old code to the different methods, even though I think they are really not used. We can easily remove and readd them once every single completion method just takes a CompletionRequest, but for now I prefer NFC behavior from the perspective of the API user. Reviewers: davide, jingham, labath Reviewed By: jingham Subscribers: mgorny, friss, lldb-commits Differential Revision: https://reviews.llvm.org/D48796 Added: lldb/trunk/include/lldb/Utility/CompletionRequest.h lldb/trunk/source/Utility/CompletionRequest.cpp lldb/trunk/unittests/Utility/CompletionRequestTest.cpp Modified: lldb/trunk/include/lldb/Interpreter/CommandAlias.h lldb/trunk/include/lldb/Interpreter/CommandInterpreter.h lldb/trunk/include/lldb/Interpreter/CommandObject.h lldb/trunk/include/lldb/Interpreter/CommandObjectMultiword.h lldb/trunk/include/lldb/Interpreter/CommandObjectRegexCommand.h lldb/trunk/source/Commands/CommandObjectCommands.cpp lldb/trunk/source/Commands/CommandObjectFrame.cpp lldb/trunk/source/Commands/CommandObjectHelp.cpp lldb/trunk/source/Commands/CommandObjectHelp.h lldb/trunk/source/Commands/CommandObjectMultiword.cpp lldb/trunk/source/Commands/CommandObjectPlatform.cpp lldb/trunk/source/Commands/CommandObjectPlugin.cpp lldb/trunk/source/Commands/CommandObjectProcess.cpp lldb/trunk/source/Commands/CommandObjectSettings.cpp lldb/trunk/source/Commands/CommandObjectTarget.cpp lldb/trunk/source/Interpreter/CommandAlias.cpp lldb/trunk/source/Interpreter/CommandInterpreter.cpp lldb/trunk/source/Interpreter/CommandObject.cpp lldb/trunk/source/Interpreter/CommandObjectRegexCommand.cpp lldb/trunk/source/Utility/CMakeLists.txt lldb/trunk/unittests/Utility/CMakeLists.txt Modified: lldb/trunk/include/lldb/Interpreter/CommandAlias.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Interpreter/CommandAlias.h?rev=336146&r1=336145&r2=336146&view=diff ===
[Lldb-commits] [lldb] r336154 - FIx XCode project files for lldb
Author: teemperor Date: Mon Jul 2 16:27:29 2018 New Revision: 336154 URL: http://llvm.org/viewvc/llvm-project?rev=336154&view=rev Log: FIx XCode project files for lldb Summary: Fixes the XCode builds that started failing when i added CompletionRequest.cpp/.h. The patch is so large because XCode decided to write the lines back in its own order, but essentially we only added on e file. Subscribers: srhines, lldb-commits Differential Revision: https://reviews.llvm.org/D48858 Modified: lldb/trunk/lldb.xcodeproj/project.pbxproj ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] r335934 - Fix path completion test case added in rL335905 on Windows
Author: teemperor Date: Thu Jun 28 15:40:10 2018 New Revision: 335934 URL: http://llvm.org/viewvc/llvm-project?rev=335934&view=rev Log: Fix path completion test case added in rL335905 on Windows Summary: The test fails because we don't rewrite the slash behind `foo` to the OS specific separator (as the completion API doesn't support this kind of rewriting). However, we assume that this part of the string is rewritten in the test case, which broke on Windows. Reviewers: stella.stamenova Reviewed By: stella.stamenova Subscribers: lldb-commits Differential Revision: https://reviews.llvm.org/D48746 Modified: lldb/trunk/unittests/Interpreter/TestCompletion.cpp Modified: lldb/trunk/unittests/Interpreter/TestCompletion.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/unittests/Interpreter/TestCompletion.cpp?rev=335934&r1=335933&r2=335934&view=diff == --- lldb/trunk/unittests/Interpreter/TestCompletion.cpp (original) +++ lldb/trunk/unittests/Interpreter/TestCompletion.cpp Thu Jun 28 15:40:10 2018 @@ -286,14 +286,12 @@ TEST_F(CompletionTest, DirCompletionUser Count = CommandCompletions::DiskDirectories("~/foo/", Results, Resolver); ASSERT_EQ(1u, Count); ASSERT_EQ(Count, Results.GetSize()); - EXPECT_TRUE(ContainsExactString(Twine("~/foo") + path::get_separator() + - "nested" + path::get_separator(), + EXPECT_TRUE(ContainsExactString(Twine("~/foo/nested") + path::get_separator(), Results)); Count = CommandCompletions::DiskDirectories("~/foo/nes", Results, Resolver); ASSERT_EQ(1u, Count); ASSERT_EQ(Count, Results.GetSize()); - EXPECT_TRUE(ContainsExactString(Twine("~/foo") + path::get_separator() + - "nested" + path::get_separator(), + EXPECT_TRUE(ContainsExactString(Twine("~/foo/nested") + path::get_separator(), Results)); // With ~username syntax it should return one match if there is an exact ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] r336582 - Don't take the address of an xvalue when printing an expr result
Author: teemperor Date: Mon Jul 9 11:57:11 2018 New Revision: 336582 URL: http://llvm.org/viewvc/llvm-project?rev=336582&view=rev Log: Don't take the address of an xvalue when printing an expr result Summary: If we have an xvalue here, we will always hit the `err_typecheck_invalid_lvalue_addrof` error in 'Sema::CheckAddressOfOperand' when trying to take the address of the result. This patch uses the fallback code path where we store the result in a local variable instead when we hit this case. Fixes rdar://problem/40613277 Reviewers: jingham, vsk Reviewed By: vsk Subscribers: vsk, friss, lldb-commits Differential Revision: https://reviews.llvm.org/D48303 Added: lldb/trunk/packages/Python/lldbsuite/test/expression_command/xvalue/ lldb/trunk/packages/Python/lldbsuite/test/expression_command/xvalue/Makefile lldb/trunk/packages/Python/lldbsuite/test/expression_command/xvalue/TestXValuePrinting.py lldb/trunk/packages/Python/lldbsuite/test/expression_command/xvalue/main.cpp Modified: lldb/trunk/source/Plugins/ExpressionParser/Clang/ASTResultSynthesizer.cpp Added: lldb/trunk/packages/Python/lldbsuite/test/expression_command/xvalue/Makefile URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/expression_command/xvalue/Makefile?rev=336582&view=auto == --- lldb/trunk/packages/Python/lldbsuite/test/expression_command/xvalue/Makefile (added) +++ lldb/trunk/packages/Python/lldbsuite/test/expression_command/xvalue/Makefile Mon Jul 9 11:57:11 2018 @@ -0,0 +1,5 @@ +LEVEL = ../../make + +CXX_SOURCES := main.cpp + +include $(LEVEL)/Makefile.rules Added: lldb/trunk/packages/Python/lldbsuite/test/expression_command/xvalue/TestXValuePrinting.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/expression_command/xvalue/TestXValuePrinting.py?rev=336582&view=auto == --- lldb/trunk/packages/Python/lldbsuite/test/expression_command/xvalue/TestXValuePrinting.py (added) +++ lldb/trunk/packages/Python/lldbsuite/test/expression_command/xvalue/TestXValuePrinting.py Mon Jul 9 11:57:11 2018 @@ -0,0 +1,37 @@ +from __future__ import print_function + + +import lldb +from lldbsuite.test.decorators import * +from lldbsuite.test.lldbtest import * +from lldbsuite.test import lldbutil + + +class ExprXValuePrintingTestCase(TestBase): + +mydir = TestBase.compute_mydir(__file__) + +def setUp(self): +# Call super's setUp(). +TestBase.setUp(self) + +self.main_source = "main.cpp" +self.main_source_spec = lldb.SBFileSpec(self.main_source) + +def do_test(self, dictionary=None): +"""Printing an xvalue should work.""" +self.build(dictionary=dictionary) + +(target, process, thread, bkpt) = lldbutil.run_to_source_breakpoint(self, + '// Break here', self.main_source_spec) +frame = thread.GetFrameAtIndex(0) + +value = frame.EvaluateExpression("foo().data") +self.assertTrue(value.IsValid()) +self.assertTrue(value.GetError().Success()) +self.assertEqual(value.GetValueAsSigned(), 1234) + +@expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr21765") +def test(self): +self.do_test() + Added: lldb/trunk/packages/Python/lldbsuite/test/expression_command/xvalue/main.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/expression_command/xvalue/main.cpp?rev=336582&view=auto == --- lldb/trunk/packages/Python/lldbsuite/test/expression_command/xvalue/main.cpp (added) +++ lldb/trunk/packages/Python/lldbsuite/test/expression_command/xvalue/main.cpp Mon Jul 9 11:57:11 2018 @@ -0,0 +1,12 @@ +struct Tmp +{ + int data = 1234; +}; + +Tmp foo() { return Tmp(); } + +int main(int argc, char const *argv[]) +{ + int something = foo().data; + return 0; // Break here +} Modified: lldb/trunk/source/Plugins/ExpressionParser/Clang/ASTResultSynthesizer.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ExpressionParser/Clang/ASTResultSynthesizer.cpp?rev=336582&r1=336581&r2=336582&view=diff == --- lldb/trunk/source/Plugins/ExpressionParser/Clang/ASTResultSynthesizer.cpp (original) +++ lldb/trunk/source/Plugins/ExpressionParser/Clang/ASTResultSynthesizer.cpp Mon Jul 9 11:57:11 2018 @@ -292,9 +292,8 @@ bool ASTResultSynthesizer::SynthesizeBod // // - During dematerialization, $0 is ignored. - bool is_lvalue = (last_expr->getValueKind() == VK_LValue || -last_expr->getValueKind() == VK_XValue) && - (last_expr->getObjectKind() == OK_Ordinary); + bool is_lvalue = last_expr->getValueKind() == VK_
[Lldb-commits] [lldb] r336723 - Refactor parsing of option lists with a raw string suffix.
Author: teemperor Date: Tue Jul 10 13:17:38 2018 New Revision: 336723 URL: http://llvm.org/viewvc/llvm-project?rev=336723&view=rev Log: Refactor parsing of option lists with a raw string suffix. Summary: A subset of the LLDB commands follows this command line interface style: [arguments] -- The parsing code for this interface has been so far been duplicated into the different command objects which makes it hard to maintain and reuse elsewhere. This patches improves the situation by adding a OptionsWithRaw class that centralizes the parsing logic and allows easier testing. The different commands now just call this class to extract the arguments and the raw suffix from the provided user input. Reviewers: jingham Reviewed By: jingham Subscribers: mgorny, lldb-commits Differential Revision: https://reviews.llvm.org/D49106 Added: lldb/trunk/unittests/Utility/OptionsWithRawTest.cpp Modified: lldb/trunk/include/lldb/Interpreter/CommandObject.h lldb/trunk/include/lldb/Utility/Args.h lldb/trunk/source/Commands/CommandObjectCommands.cpp lldb/trunk/source/Commands/CommandObjectExpression.cpp lldb/trunk/source/Commands/CommandObjectPlatform.cpp lldb/trunk/source/Commands/CommandObjectType.cpp lldb/trunk/source/Commands/CommandObjectWatchpoint.cpp lldb/trunk/source/Interpreter/CommandObject.cpp lldb/trunk/source/Interpreter/Options.cpp lldb/trunk/source/Utility/Args.cpp lldb/trunk/unittests/Utility/CMakeLists.txt Modified: lldb/trunk/include/lldb/Interpreter/CommandObject.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Interpreter/CommandObject.h?rev=336723&r1=336722&r2=336723&view=diff == --- lldb/trunk/include/lldb/Interpreter/CommandObject.h (original) +++ lldb/trunk/include/lldb/Interpreter/CommandObject.h Tue Jul 10 13:17:38 2018 @@ -337,6 +337,10 @@ public: CommandReturnObject &result) = 0; protected: + bool ParseOptionsAndNotify(Args &args, CommandReturnObject &result, + OptionGroupOptions &group_options, + ExecutionContext &exe_ctx); + virtual const char *GetInvalidTargetDescription() { return "invalid target, create a target using the 'target create' command"; } Modified: lldb/trunk/include/lldb/Utility/Args.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Utility/Args.h?rev=336723&r1=336722&r2=336723&view=diff == --- lldb/trunk/include/lldb/Utility/Args.h (original) +++ lldb/trunk/include/lldb/Utility/Args.h Tue Jul 10 13:17:38 2018 @@ -48,6 +48,11 @@ public: llvm::StringRef ref; char quote; const char *c_str() const { return ptr.get(); } + +//-- +/// Returns true if this argument was quoted in any way. +//-- +bool IsQuoted() const { return quote != '\0'; } }; //-- @@ -353,6 +358,106 @@ private: std::vector m_argv; }; +//-- +/// @class OptionsWithRaw Args.h "lldb/Utility/Args.h" +/// A pair of an option list with a 'raw' string as a suffix. +/// +/// This class works similar to Args, but handles the case where we have a +/// trailing string that shouldn't be interpreted as a list of arguments but +/// preserved as is. It is also only useful for handling command line options +/// (e.g. '-foo bar -i0') that start with a dash. +/// +/// The leading option list is optional. If the first non-space character +/// in the string starts with a dash, and the string contains an argument +/// that is an unquoted double dash (' -- '), then everything up to the double +/// dash is parsed as a list of arguments. Everything after the double dash +/// is interpreted as the raw suffix string. Note that the space behind the +/// double dash is not part of the raw suffix. +/// +/// All strings not matching the above format as considered to be just a raw +/// string without any options. +/// +/// @see Args +//-- +class OptionsWithRaw { +public: + //-- + /// Parse the given string as a list of optional arguments with a raw suffix. + /// + /// See the class description for a description of the input format. + /// + /// @param[in] argument_string + /// The string that should be parsed. + //-- + explicit OptionsWithRaw(llvm::StringRef argument_string); + + //-- + /// Returns true if there are any arguments before the ra
[Lldb-commits] [lldb] r336734 - Refactor ClangUserExpression::Parse [NFC]
Author: teemperor Date: Tue Jul 10 15:12:39 2018 New Revision: 336734 URL: http://llvm.org/viewvc/llvm-project?rev=336734&view=rev Log: Refactor ClangUserExpression::Parse [NFC] Summary: This patch splits out functionality from the `Parse` method into different methods. This benefits the code completion work (which should reuse those methods) and makes the code a bit more readable. Note that this patch is as minimal as possible. Some of the code in the new methods definitely needs more refactoring. Subscribers: lldb-commits Differential Revision: https://reviews.llvm.org/D48339 Modified: lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangUserExpression.h Modified: lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp?rev=336734&r1=336733&r2=336734&view=diff == --- lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp (original) +++ lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp Tue Jul 10 15:12:39 2018 @@ -322,17 +322,8 @@ private: }; } // namespace -bool ClangUserExpression::Parse(DiagnosticManager &diagnostic_manager, -ExecutionContext &exe_ctx, -lldb_private::ExecutionPolicy execution_policy, -bool keep_result_in_memory, -bool generate_debug_info) { - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS)); - - Status err; - - InstallContext(exe_ctx); - +bool ClangUserExpression::SetupPersistentState(DiagnosticManager &diagnostic_manager, + ExecutionContext &exe_ctx) { if (Target *target = exe_ctx.GetTargetPtr()) { if (PersistentExpressionState *persistent_state = target->GetPersistentExpressionStateForLanguage( @@ -349,26 +340,15 @@ bool ClangUserExpression::Parse(Diagnost "error: couldn't start parsing (no target)"); return false; } + return true; +} - ScanContext(exe_ctx, err); - - if (!err.Success()) { -diagnostic_manager.PutString(eDiagnosticSeverityWarning, err.AsCString()); - } - - - // Generate the expression - // - - ApplyObjcCastHack(m_expr_text); - - std::string prefix = m_expr_prefix; - +static void SetupDeclVendor(ExecutionContext &exe_ctx, Target *target) { if (ClangModulesDeclVendor *decl_vendor = - m_target->GetClangModulesDeclVendor()) { + target->GetClangModulesDeclVendor()) { const ClangModulesDeclVendor::ModuleVector &hand_imported_modules = llvm::cast( -m_target->GetPersistentExpressionStateForLanguage( +target->GetPersistentExpressionStateForLanguage( lldb::eLanguageTypeC)) ->GetHandLoadedClangModules(); ClangModulesDeclVendor::ModuleVector modules_for_macros; @@ -377,7 +357,7 @@ bool ClangUserExpression::Parse(Diagnost modules_for_macros.push_back(module); } -if (m_target->GetEnableAutoImportClangModules()) { +if (target->GetEnableAutoImportClangModules()) { if (StackFrame *frame = exe_ctx.GetFramePtr()) { if (Block *block = frame->GetFrameBlock()) { SymbolContext sc; @@ -394,8 +374,13 @@ bool ClangUserExpression::Parse(Diagnost } } } +} - lldb::LanguageType lang_type = lldb::eLanguageTypeUnknown; +llvm::Optional ClangUserExpression::GetLanguageForExpr( +DiagnosticManager &diagnostic_manager, ExecutionContext &exe_ctx) { + lldb::LanguageType lang_type = lldb::LanguageType::eLanguageTypeUnknown; + + std::string prefix = m_expr_prefix; if (m_options.GetExecutionPolicy() == eExecutionPolicyTopLevel) { m_transformed_text = m_expr_text; @@ -415,9 +400,50 @@ bool ClangUserExpression::Parse(Diagnost exe_ctx)) { diagnostic_manager.PutString(eDiagnosticSeverityError, "couldn't construct expression body"); - return false; + return llvm::Optional(); } } + return lang_type; +} + +bool ClangUserExpression::PrepareForParsing( +DiagnosticManager &diagnostic_manager, ExecutionContext &exe_ctx) { + InstallContext(exe_ctx); + + if (!SetupPersistentState(diagnostic_manager, exe_ctx)) +return false; + + Status err; + ScanContext(exe_ctx, err); + + if (!err.Success()) { +diagnostic_manager.PutString(eDiagnosticSeverityWarning, err.AsCString()); + } + + + // Generate the expression + // + + ApplyObjcCastHack(m_expr_text); + + SetupDeclVendor(exe_ctx, m_target); + return true; +} + +bool ClangUserExpression::Parse(DiagnosticManager &diagn
[Lldb-commits] [lldb] r336824 - Allow specifying an exit code for the 'quit' command
Author: teemperor Date: Wed Jul 11 10:18:01 2018 New Revision: 336824 URL: http://llvm.org/viewvc/llvm-project?rev=336824&view=rev Log: Allow specifying an exit code for the 'quit' command Summary: This patch adds the possibility to specify an exit code when calling quit. We accept any int, even though it depends on the user what happens if the int is out of the range of what the operating system supports as exit codes. Fixes rdar://problem/38452312 Reviewers: davide, jingham, clayborg Reviewed By: jingham Subscribers: clayborg, jingham, lldb-commits Differential Revision: https://reviews.llvm.org/D48659 Added: lldb/trunk/lit/Quit/ lldb/trunk/lit/Quit/TestQuitExitCode-30.test lldb/trunk/lit/Quit/TestQuitExitCode0.test lldb/trunk/lit/Quit/TestQuitExitCode30.test lldb/trunk/lit/Quit/TestQuitExitCodeHex0.test lldb/trunk/lit/Quit/TestQuitExitCodeHexA.test lldb/trunk/lit/Quit/TestQuitExitCodeImplicit0.test lldb/trunk/lit/Quit/TestQuitExitCodeNonInt.test lldb/trunk/lit/Quit/TestQuitExitCodeTooManyArgs.test lldb/trunk/lit/Quit/expect_exit_code.py (with props) lldb/trunk/lit/Quit/lit.local.cfg lldb/trunk/packages/Python/lldbsuite/test/quit/ lldb/trunk/packages/Python/lldbsuite/test/quit/TestQuit.py Modified: lldb/trunk/include/lldb/API/SBCommandInterpreter.h lldb/trunk/include/lldb/Interpreter/CommandInterpreter.h lldb/trunk/scripts/interface/SBCommandInterpreter.i lldb/trunk/source/API/SBCommandInterpreter.cpp lldb/trunk/source/Commands/CommandObjectQuit.cpp lldb/trunk/source/Interpreter/CommandInterpreter.cpp lldb/trunk/tools/driver/Driver.cpp lldb/trunk/tools/driver/Driver.h Modified: lldb/trunk/include/lldb/API/SBCommandInterpreter.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBCommandInterpreter.h?rev=336824&r1=336823&r2=336824&view=diff == --- lldb/trunk/include/lldb/API/SBCommandInterpreter.h (original) +++ lldb/trunk/include/lldb/API/SBCommandInterpreter.h Wed Jul 11 10:18:01 2018 @@ -208,6 +208,25 @@ public: void SetPromptOnQuit(bool b); //-- + /// Sets whether the command interpreter should allow custom exit codes + /// for the 'quit' command. + //-- + void AllowExitCodeOnQuit(bool allow); + + //-- + /// Returns true if the user has called the 'quit' command with a custom exit + /// code. + //-- + bool HasCustomQuitExitCode(); + + //-- + /// Returns the exit code that the user has specified when running the + /// 'quit' command. Returns 0 if the user hasn't called 'quit' at all or + /// without a custom exit code. + //-- + int GetQuitStatus(); + + //-- /// Resolve the command just as HandleCommand would, expanding abbreviations /// and aliases. If successful, result->GetOutput has the full expansion. //-- Modified: lldb/trunk/include/lldb/Interpreter/CommandInterpreter.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Interpreter/CommandInterpreter.h?rev=336824&r1=336823&r2=336824&view=diff == --- lldb/trunk/include/lldb/Interpreter/CommandInterpreter.h (original) +++ lldb/trunk/include/lldb/Interpreter/CommandInterpreter.h Wed Jul 11 10:18:01 2018 @@ -455,6 +455,30 @@ public: void SetPromptOnQuit(bool b); + //-- + /// Specify if the command interpreter should allow that the user can + /// specify a custom exit code when calling 'quit'. + //-- + void AllowExitCodeOnQuit(bool allow); + + //-- + /// Sets the exit code for the quit command. + /// @param[in] exit_code + /// The exit code that the driver should return on exit. + /// @return True if the exit code was successfully set; false if the + /// interpreter doesn't allow custom exit codes. + /// @see AllowExitCodeOnQuit + //-- + LLVM_NODISCARD bool SetQuitExitCode(int exit_code); + + //-- + /// Returns the exit code that the user has specified when running the + /// 'quit' command. + /// @param[out] exited + /// Set to true if the user has ca
[Lldb-commits] [lldb] r336955 - Get rid of the C-string parameter in DoExecute
Author: teemperor Date: Thu Jul 12 15:28:52 2018 New Revision: 336955 URL: http://llvm.org/viewvc/llvm-project?rev=336955&view=rev Log: Get rid of the C-string parameter in DoExecute Summary: This patch gets rid of the C-string parameter in the RawCommandObject::DoExecute function, making the code simpler and less memory unsafe. There seems to be a assumption in some command objects that this parameter could be a nullptr, but from what I can see the rest of the API doesn't actually allow this (and other command objects and related code pieces dereference this parameter without any checks). Especially CommandObjectRegexCommand has error handling code for a nullptr that is now gone. Reviewers: davide, jingham, teemperor Reviewed By: teemperor Subscribers: jingham, lldb-commits Differential Revision: https://reviews.llvm.org/D49207 Modified: lldb/trunk/include/lldb/Interpreter/CommandObject.h lldb/trunk/include/lldb/Interpreter/CommandObjectRegexCommand.h lldb/trunk/include/lldb/Interpreter/ScriptInterpreter.h lldb/trunk/source/Commands/CommandObjectCommands.cpp lldb/trunk/source/Commands/CommandObjectExpression.cpp lldb/trunk/source/Commands/CommandObjectExpression.h lldb/trunk/source/Commands/CommandObjectPlatform.cpp lldb/trunk/source/Commands/CommandObjectSettings.cpp lldb/trunk/source/Commands/CommandObjectThread.cpp lldb/trunk/source/Commands/CommandObjectType.cpp lldb/trunk/source/Commands/CommandObjectWatchpoint.cpp lldb/trunk/source/Interpreter/CommandObjectRegexCommand.cpp lldb/trunk/source/Interpreter/CommandObjectScript.cpp lldb/trunk/source/Interpreter/CommandObjectScript.h lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp lldb/trunk/source/Plugins/ScriptInterpreter/None/ScriptInterpreterNone.cpp lldb/trunk/source/Plugins/ScriptInterpreter/None/ScriptInterpreterNone.h lldb/trunk/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp lldb/trunk/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.h Modified: lldb/trunk/include/lldb/Interpreter/CommandObject.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Interpreter/CommandObject.h?rev=336955&r1=336954&r2=336955&view=diff == --- lldb/trunk/include/lldb/Interpreter/CommandObject.h (original) +++ lldb/trunk/include/lldb/Interpreter/CommandObject.h Thu Jul 12 15:28:52 2018 @@ -434,7 +434,8 @@ public: bool Execute(const char *args_string, CommandReturnObject &result) override; protected: - virtual bool DoExecute(const char *command, CommandReturnObject &result) = 0; + virtual bool DoExecute(llvm::StringRef command, + CommandReturnObject &result) = 0; bool WantsRawCommandString() override { return true; } }; Modified: lldb/trunk/include/lldb/Interpreter/CommandObjectRegexCommand.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Interpreter/CommandObjectRegexCommand.h?rev=336955&r1=336954&r2=336955&view=diff == --- lldb/trunk/include/lldb/Interpreter/CommandObjectRegexCommand.h (original) +++ lldb/trunk/include/lldb/Interpreter/CommandObjectRegexCommand.h Thu Jul 12 15:28:52 2018 @@ -43,7 +43,7 @@ public: int HandleCompletion(CompletionRequest &request) override; protected: - bool DoExecute(const char *command, CommandReturnObject &result) override; + bool DoExecute(llvm::StringRef command, CommandReturnObject &result) override; struct Entry { RegularExpression regex; Modified: lldb/trunk/include/lldb/Interpreter/ScriptInterpreter.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Interpreter/ScriptInterpreter.h?rev=336955&r1=336954&r2=336955&view=diff == --- lldb/trunk/include/lldb/Interpreter/ScriptInterpreter.h (original) +++ lldb/trunk/include/lldb/Interpreter/ScriptInterpreter.h Thu Jul 12 15:28:52 2018 @@ -96,13 +96,13 @@ public: virtual bool Interrupt() { return false; } virtual bool ExecuteOneLine( - const char *command, CommandReturnObject *result, + llvm::StringRef command, CommandReturnObject *result, const ExecuteScriptOptions &options = ExecuteScriptOptions()) = 0; virtual void ExecuteInterpreterLoop() = 0; virtual bool ExecuteOneLineWithReturn( - const char *in_string, ScriptReturnType return_type, void *ret_value, + llvm::StringRef in_string, ScriptReturnType return_type, void *ret_value, const ExecuteScriptOptions &options = ExecuteScriptOptions()) { return true; } @@ -343,7 +343,7 @@ public: } virtual bool - RunScriptBasedCommand(const char *impl_function, const char *args, + RunScriptBasedCommand(const char *impl_function, llvm::StringRef args, ScriptedCommandSynchronicity syn
[Lldb-commits] [lldb] r337030 - No longer pass a StringRef to the Python API
Author: teemperor Date: Fri Jul 13 11:13:46 2018 New Revision: 337030 URL: http://llvm.org/viewvc/llvm-project?rev=337030&view=rev Log: No longer pass a StringRef to the Python API Summary: The refactoring patch for DoExecute missed this case of a variadic function that just silently accepts a StringRef which it then tries to reinterpret as a C-string. This should fix the Windows builds. Reviewers: stella.stamenova Reviewed By: stella.stamenova Subscribers: lldb-commits Differential Revision: https://reviews.llvm.org/D49309 Modified: lldb/trunk/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp Modified: lldb/trunk/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp?rev=337030&r1=337029&r2=337030&view=diff == --- lldb/trunk/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp (original) +++ lldb/trunk/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp Fri Jul 13 11:13:46 2018 @@ -753,6 +753,8 @@ static void ReadThreadBytesReceived(void bool ScriptInterpreterPython::ExecuteOneLine( llvm::StringRef command, CommandReturnObject *result, const ExecuteScriptOptions &options) { + std::string command_str = command.str(); + if (!m_valid_session) return false; @@ -855,7 +857,7 @@ bool ScriptInterpreterPython::ExecuteOne if (PyCallable_Check(m_run_one_line_function.get())) { PythonObject pargs( PyRefType::Owned, -Py_BuildValue("(Os)", session_dict.get(), command)); +Py_BuildValue("(Os)", session_dict.get(), command_str.c_str())); if (pargs.IsValid()) { PythonObject return_value( PyRefType::Owned, @@ -895,7 +897,6 @@ bool ScriptInterpreterPython::ExecuteOne // The one-liner failed. Append the error message. if (result) { - std::string command_str = command.str(); result->AppendErrorWithFormat( "python failed attempting to evaluate '%s'\n", command_str.c_str()); } ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] r337031 - Replaced more boilerplate code with CompletionRequest (NFC)
Author: teemperor Date: Fri Jul 13 11:28:14 2018 New Revision: 337031 URL: http://llvm.org/viewvc/llvm-project?rev=337031&view=rev Log: Replaced more boilerplate code with CompletionRequest (NFC) Summary: As suggested in D48796, this patch replaces even more internal calls that were using the old completion API style with a single CompletionRequest. In some cases we also pass an option vector/index, but as we don't always have this information, it currently is not part of the CompletionRequest class. The constructor of the CompletionRequest is now also more sensible. You only pass the user input, cursor position and your list of matches to the request and the rest will be inferred (using the same code we used before to calculate this). You also have to pass these match window parameters to it, even though they are unused right now. The patch shouldn't change any behavior. Reviewers: jingham Reviewed By: jingham Subscribers: lldb-commits Differential Revision: https://reviews.llvm.org/D48976 Modified: lldb/trunk/include/lldb/Core/FormatEntity.h lldb/trunk/include/lldb/Interpreter/CommandCompletions.h lldb/trunk/include/lldb/Interpreter/OptionValue.h lldb/trunk/include/lldb/Interpreter/OptionValueArch.h lldb/trunk/include/lldb/Interpreter/OptionValueBoolean.h lldb/trunk/include/lldb/Interpreter/OptionValueEnumeration.h lldb/trunk/include/lldb/Interpreter/OptionValueFileSpec.h lldb/trunk/include/lldb/Interpreter/OptionValueFormatEntity.h lldb/trunk/include/lldb/Interpreter/OptionValueUUID.h lldb/trunk/include/lldb/Interpreter/Options.h lldb/trunk/include/lldb/Symbol/Variable.h lldb/trunk/include/lldb/Utility/ArchSpec.h lldb/trunk/include/lldb/Utility/CompletionRequest.h lldb/trunk/source/Commands/CommandCompletions.cpp lldb/trunk/source/Commands/CommandObjectCommands.cpp lldb/trunk/source/Commands/CommandObjectFrame.cpp lldb/trunk/source/Commands/CommandObjectPlatform.cpp lldb/trunk/source/Commands/CommandObjectPlugin.cpp lldb/trunk/source/Commands/CommandObjectProcess.cpp lldb/trunk/source/Commands/CommandObjectSettings.cpp lldb/trunk/source/Commands/CommandObjectTarget.cpp lldb/trunk/source/Core/FormatEntity.cpp lldb/trunk/source/Core/IOHandler.cpp lldb/trunk/source/Interpreter/CommandInterpreter.cpp lldb/trunk/source/Interpreter/CommandObject.cpp lldb/trunk/source/Interpreter/CommandObjectRegexCommand.cpp lldb/trunk/source/Interpreter/OptionValue.cpp lldb/trunk/source/Interpreter/OptionValueArch.cpp lldb/trunk/source/Interpreter/OptionValueBoolean.cpp lldb/trunk/source/Interpreter/OptionValueEnumeration.cpp lldb/trunk/source/Interpreter/OptionValueFileSpec.cpp lldb/trunk/source/Interpreter/OptionValueFormatEntity.cpp lldb/trunk/source/Interpreter/OptionValueUUID.cpp lldb/trunk/source/Interpreter/Options.cpp lldb/trunk/source/Symbol/Variable.cpp lldb/trunk/source/Utility/ArchSpec.cpp lldb/trunk/source/Utility/CompletionRequest.cpp lldb/trunk/unittests/Utility/CompletionRequestTest.cpp Modified: lldb/trunk/include/lldb/Core/FormatEntity.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/FormatEntity.h?rev=337031&r1=337030&r2=337031&view=diff == --- lldb/trunk/include/lldb/Core/FormatEntity.h (original) +++ lldb/trunk/include/lldb/Core/FormatEntity.h Fri Jul 13 11:28:14 2018 @@ -10,6 +10,7 @@ #ifndef liblldb_FormatEntity_h_ #define liblldb_FormatEntity_h_ +#include "lldb/Utility/CompletionRequest.h" #include "lldb/Utility/FileSpec.h" // for FileSpec #include "lldb/Utility/Status.h" #include "lldb/lldb-enumerations.h" // for Format::eFormatDefault, Format @@ -211,9 +212,7 @@ public: llvm::StringRef &variable_name, llvm::StringRef &variable_format); - static size_t AutoComplete(llvm::StringRef s, int match_start_point, - int max_return_elements, bool &word_complete, - StringList &matches); + static size_t AutoComplete(lldb_private::CompletionRequest &request); //-- // Format the current elements into the stream \a s. Modified: lldb/trunk/include/lldb/Interpreter/CommandCompletions.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Interpreter/CommandCompletions.h?rev=337031&r1=337030&r2=337031&view=diff == --- lldb/trunk/include/lldb/Interpreter/CommandCompletions.h (original) +++ lldb/trunk/include/lldb/Interpreter/CommandCompletions.h Fri Jul 13 11:28:14 2018 @@ -18,6 +18,7 @@ // Project includes #include "lldb/Core/FileSpecList.h" #include "lldb/Core/SearchFilter.h" +#include "lldb/Utility/CompletionRequest.h" #include "lldb/Utility/Regu
[Lldb-commits] [lldb] r337032 - Add includes for CompletionRequest to every file that uses it
Author: teemperor Date: Fri Jul 13 11:54:55 2018 New Revision: 337032 URL: http://llvm.org/viewvc/llvm-project?rev=337032&view=rev Log: Add includes for CompletionRequest to every file that uses it Summary: Should fix the builds (and prevent future builds from failing when people try to reduce includes). Reviewers: jingham Reviewed By: jingham Subscribers: jingham, lldb-commits Differential Revision: https://reviews.llvm.org/D49311 Modified: lldb/trunk/include/lldb/Interpreter/CommandAlias.h lldb/trunk/include/lldb/Interpreter/CommandInterpreter.h lldb/trunk/include/lldb/Interpreter/CommandObject.h lldb/trunk/include/lldb/Interpreter/CommandObjectMultiword.h lldb/trunk/include/lldb/Interpreter/CommandObjectRegexCommand.h lldb/trunk/include/lldb/Interpreter/OptionValueArch.h lldb/trunk/include/lldb/Interpreter/Options.h lldb/trunk/include/lldb/Symbol/Variable.h Modified: lldb/trunk/include/lldb/Interpreter/CommandAlias.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Interpreter/CommandAlias.h?rev=337032&r1=337031&r2=337032&view=diff == --- lldb/trunk/include/lldb/Interpreter/CommandAlias.h (original) +++ lldb/trunk/include/lldb/Interpreter/CommandAlias.h Fri Jul 13 11:54:55 2018 @@ -18,6 +18,7 @@ // Project includes #include "lldb/Interpreter/CommandObject.h" #include "lldb/Utility/Args.h" +#include "lldb/Utility/CompletionRequest.h" #include "lldb/lldb-forward.h" namespace lldb_private { Modified: lldb/trunk/include/lldb/Interpreter/CommandInterpreter.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Interpreter/CommandInterpreter.h?rev=337032&r1=337031&r2=337032&view=diff == --- lldb/trunk/include/lldb/Interpreter/CommandInterpreter.h (original) +++ lldb/trunk/include/lldb/Interpreter/CommandInterpreter.h Fri Jul 13 11:54:55 2018 @@ -24,6 +24,7 @@ #include "lldb/Interpreter/CommandObject.h" #include "lldb/Interpreter/ScriptInterpreter.h" #include "lldb/Utility/Args.h" +#include "lldb/Utility/CompletionRequest.h" #include "lldb/Utility/Log.h" #include "lldb/Utility/StringList.h" #include "lldb/lldb-forward.h" Modified: lldb/trunk/include/lldb/Interpreter/CommandObject.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Interpreter/CommandObject.h?rev=337032&r1=337031&r2=337032&view=diff == --- lldb/trunk/include/lldb/Interpreter/CommandObject.h (original) +++ lldb/trunk/include/lldb/Interpreter/CommandObject.h Fri Jul 13 11:54:55 2018 @@ -16,8 +16,6 @@ #include #include -#include "lldb/Utility/CompletionRequest.h" - // Other libraries and framework includes // Project includes #include "lldb/Utility/Flags.h" @@ -26,6 +24,7 @@ #include "lldb/Interpreter/Options.h" #include "lldb/Target/ExecutionContext.h" #include "lldb/Utility/Args.h" +#include "lldb/Utility/CompletionRequest.h" #include "lldb/Utility/StringList.h" #include "lldb/lldb-private.h" Modified: lldb/trunk/include/lldb/Interpreter/CommandObjectMultiword.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Interpreter/CommandObjectMultiword.h?rev=337032&r1=337031&r2=337032&view=diff == --- lldb/trunk/include/lldb/Interpreter/CommandObjectMultiword.h (original) +++ lldb/trunk/include/lldb/Interpreter/CommandObjectMultiword.h Fri Jul 13 11:54:55 2018 @@ -15,6 +15,7 @@ // Other libraries and framework includes // Project includes #include "lldb/Interpreter/CommandObject.h" +#include "lldb/Utility/CompletionRequest.h" namespace lldb_private { Modified: lldb/trunk/include/lldb/Interpreter/CommandObjectRegexCommand.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Interpreter/CommandObjectRegexCommand.h?rev=337032&r1=337031&r2=337032&view=diff == --- lldb/trunk/include/lldb/Interpreter/CommandObjectRegexCommand.h (original) +++ lldb/trunk/include/lldb/Interpreter/CommandObjectRegexCommand.h Fri Jul 13 11:54:55 2018 @@ -17,6 +17,7 @@ // Other libraries and framework includes // Project includes #include "lldb/Interpreter/CommandObject.h" +#include "lldb/Utility/CompletionRequest.h" #include "lldb/Utility/RegularExpression.h" namespace lldb_private { Modified: lldb/trunk/include/lldb/Interpreter/OptionValueArch.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Interpreter/OptionValueArch.h?rev=337032&r1=337031&r2=337032&view=diff == --- lldb/trunk/include/lldb/Interpreter/OptionValueArch.h (original) +++ lldb/trunk/include/lldb/Interpreter/OptionValueArch.h Fri Jul 13 11:54:55 2018 @@ -12,6 +12,7 @@ #include "
[Lldb-commits] [lldb] r337189 - Fix some crashes and deadlocks in FormatAnsiTerminalCodes
Author: teemperor Date: Mon Jul 16 09:38:30 2018 New Revision: 337189 URL: http://llvm.org/viewvc/llvm-project?rev=337189&view=rev Log: Fix some crashes and deadlocks in FormatAnsiTerminalCodes Summary: This patch fixes a few problems with the FormatAnsiTerminalCodes function: * It does an infinite loop on an unknown color value. * It crashes when the color value is at the end of the string. * It deletes the first character behind the color token. Also added a few tests that reproduce those problems (and test some other corner cases). Reviewers: davide, labath Reviewed By: labath Subscribers: labath, lldb-commits, mgorny Differential Revision: https://reviews.llvm.org/D49307 Added: lldb/trunk/unittests/Utility/AnsiTerminalTest.cpp Modified: lldb/trunk/include/lldb/Utility/AnsiTerminal.h lldb/trunk/unittests/Utility/CMakeLists.txt Modified: lldb/trunk/include/lldb/Utility/AnsiTerminal.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Utility/AnsiTerminal.h?rev=337189&r1=337188&r2=337189&view=diff == --- lldb/trunk/include/lldb/Utility/AnsiTerminal.h (original) +++ lldb/trunk/include/lldb/Utility/AnsiTerminal.h Mon Jul 16 09:38:30 2018 @@ -119,17 +119,21 @@ inline std::string FormatAnsiTerminalCod break; } +bool found_code = false; for (const auto &code : codes) { if (!right.consume_front(code.name)) continue; if (do_color) fmt.append(code.value); - format = right; + found_code = true; break; } - -format = format.drop_front(); +format = right; +// If we haven't found a valid replacement value, we just copy the string +// to the result without any modifications. +if (!found_code) + fmt.append(tok_hdr); } return fmt; } Added: lldb/trunk/unittests/Utility/AnsiTerminalTest.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/unittests/Utility/AnsiTerminalTest.cpp?rev=337189&view=auto == --- lldb/trunk/unittests/Utility/AnsiTerminalTest.cpp (added) +++ lldb/trunk/unittests/Utility/AnsiTerminalTest.cpp Mon Jul 16 09:38:30 2018 @@ -0,0 +1,55 @@ +//===-- AnsiTerminalTest.cpp *- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===--===// + +#include "gtest/gtest.h" + +#include "lldb/Utility/AnsiTerminal.h" + +using namespace lldb_utility; + +TEST(AnsiTerminal, Empty) { EXPECT_EQ("", ansi::FormatAnsiTerminalCodes("")); } + +TEST(AnsiTerminal, WhiteSpace) { + EXPECT_EQ(" ", ansi::FormatAnsiTerminalCodes(" ")); +} + +TEST(AnsiTerminal, AtEnd) { + EXPECT_EQ("abc\x1B[30m", +ansi::FormatAnsiTerminalCodes("abc${ansi.fg.black}")); +} + +TEST(AnsiTerminal, AtStart) { + EXPECT_EQ("\x1B[30mabc", +ansi::FormatAnsiTerminalCodes("${ansi.fg.black}abc")); +} + +TEST(AnsiTerminal, KnownPrefix) { + EXPECT_EQ("${ansi.fg.redish}abc", +ansi::FormatAnsiTerminalCodes("${ansi.fg.redish}abc")); +} + +TEST(AnsiTerminal, Unknown) { + EXPECT_EQ("${ansi.fg.foo}abc", +ansi::FormatAnsiTerminalCodes("${ansi.fg.foo}abc")); +} + +TEST(AnsiTerminal, Incomplete) { + EXPECT_EQ("abc${ansi.", ansi::FormatAnsiTerminalCodes("abc${ansi.")); +} + +TEST(AnsiTerminal, Twice) { + EXPECT_EQ("\x1B[30m\x1B[31mabc", + ansi::FormatAnsiTerminalCodes("${ansi.fg.black}${ansi.fg.red}abc")); +} + +TEST(AnsiTerminal, Basic) { + EXPECT_EQ( + "abc\x1B[31mabc\x1B[0mabc", + ansi::FormatAnsiTerminalCodes("abc${ansi.fg.red}abc${ansi.normal}abc")); +} Modified: lldb/trunk/unittests/Utility/CMakeLists.txt URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/unittests/Utility/CMakeLists.txt?rev=337189&r1=337188&r2=337189&view=diff == --- lldb/trunk/unittests/Utility/CMakeLists.txt (original) +++ lldb/trunk/unittests/Utility/CMakeLists.txt Mon Jul 16 09:38:30 2018 @@ -1,4 +1,5 @@ add_lldb_unittest(UtilityTests + AnsiTerminalTest.cpp ArgsTest.cpp OptionsWithRawTest.cpp ArchSpecTest.cpp ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] r337475 - Added unit tests for Flags
Author: teemperor Date: Thu Jul 19 10:45:51 2018 New Revision: 337475 URL: http://llvm.org/viewvc/llvm-project?rev=337475&view=rev Log: Added unit tests for Flags Reviewers: labath Reviewed By: labath Subscribers: labath, mgorny, lldb-commits Differential Revision: https://reviews.llvm.org/D49435 Added: lldb/trunk/unittests/Utility/FlagsTest.cpp Modified: lldb/trunk/unittests/Utility/CMakeLists.txt Modified: lldb/trunk/unittests/Utility/CMakeLists.txt URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/unittests/Utility/CMakeLists.txt?rev=337475&r1=337474&r2=337475&view=diff == --- lldb/trunk/unittests/Utility/CMakeLists.txt (original) +++ lldb/trunk/unittests/Utility/CMakeLists.txt Thu Jul 19 10:45:51 2018 @@ -8,6 +8,7 @@ add_lldb_unittest(UtilityTests CompletionRequestTest.cpp EnvironmentTest.cpp FileSpecTest.cpp + FlagsTest.cpp JSONTest.cpp LogTest.cpp NameMatchesTest.cpp Added: lldb/trunk/unittests/Utility/FlagsTest.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/unittests/Utility/FlagsTest.cpp?rev=337475&view=auto == --- lldb/trunk/unittests/Utility/FlagsTest.cpp (added) +++ lldb/trunk/unittests/Utility/FlagsTest.cpp Thu Jul 19 10:45:51 2018 @@ -0,0 +1,199 @@ +//===-- FlagsTest.cpp ---===-*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===--===// + +#include "gtest/gtest.h" + +#include "lldb/Utility/Flags.h" + +using namespace lldb_private; + +enum DummyFlags { + eFlag0 = 1 << 0, + eFlag1 = 1 << 1, + eFlag2 = 1 << 2, + eAllFlags = (eFlag0 | eFlag1 | eFlag2) +}; + +TEST(Flags, GetBitSize) { + Flags f; + // Methods like ClearCount depend on this specific value, so we test + // against it here. + EXPECT_EQ(32U, f.GetBitSize()); +} + +TEST(Flags, Reset) { + Flags f; + f.Reset(0x3); + EXPECT_EQ(0x3U, f.Get()); + EXPECT_EQ(2U, f.SetCount()); +} + +TEST(Flags, Clear) { + Flags f; + f.Reset(0x3); + EXPECT_EQ(2U, f.SetCount()); + + f.Clear(0x5); + EXPECT_EQ(1U, f.SetCount()); + + f.Clear(); + EXPECT_EQ(0U, f.SetCount()); +} + +TEST(Flags, AllSet) { + Flags f; + + EXPECT_FALSE(f.AllSet(eFlag0 | eFlag1)); + + f.Set(eFlag0); + EXPECT_FALSE(f.AllSet(eFlag0 | eFlag1)); + + f.Set(eFlag1); + EXPECT_TRUE(f.AllSet(eFlag0 | eFlag1)); + + f.Clear(eFlag1); + EXPECT_FALSE(f.AllSet(eFlag0 | eFlag1)); + + f.Clear(eFlag0); + EXPECT_FALSE(f.AllSet(eFlag0 | eFlag1)); +} + +TEST(Flags, AnySet) { + Flags f; + + EXPECT_FALSE(f.AnySet(eFlag0 | eFlag1)); + + f.Set(eFlag0); + EXPECT_TRUE(f.AnySet(eFlag0 | eFlag1)); + + f.Set(eFlag1); + EXPECT_TRUE(f.AnySet(eFlag0 | eFlag1)); + + f.Clear(eFlag1); + EXPECT_TRUE(f.AnySet(eFlag0 | eFlag1)); + + f.Clear(eFlag0); + EXPECT_FALSE(f.AnySet(eFlag0 | eFlag1)); +} + +TEST(Flags, Test) { + Flags f; + + EXPECT_FALSE(f.Test(eFlag0)); + EXPECT_FALSE(f.Test(eFlag1)); + EXPECT_FALSE(f.Test(eFlag2)); + + f.Set(eFlag0); + EXPECT_TRUE(f.Test(eFlag0)); + EXPECT_FALSE(f.Test(eFlag1)); + EXPECT_FALSE(f.Test(eFlag2)); + + f.Set(eFlag1); + EXPECT_TRUE(f.Test(eFlag0)); + EXPECT_TRUE(f.Test(eFlag1)); + EXPECT_FALSE(f.Test(eFlag2)); + + f.Clear(eFlag0); + EXPECT_FALSE(f.Test(eFlag0)); + EXPECT_TRUE(f.Test(eFlag1)); + EXPECT_FALSE(f.Test(eFlag2)); + + // FIXME: Should Flags assert on Test(eFlag0 | eFlag1) (more than one bit)? +} + +TEST(Flags, AllClear) { + Flags f; + + EXPECT_TRUE(f.AllClear(eFlag0 | eFlag1)); + + f.Set(eFlag0); + EXPECT_FALSE(f.AllClear(eFlag0 | eFlag1)); + + f.Set(eFlag1); + f.Clear(eFlag0); + EXPECT_FALSE(f.AllClear(eFlag0 | eFlag1)); + + f.Clear(eFlag1); + EXPECT_TRUE(f.AnyClear(eFlag0 | eFlag1)); +} + +TEST(Flags, AnyClear) { + Flags f; + EXPECT_TRUE(f.AnyClear(eFlag0 | eFlag1)); + + f.Set(eFlag0); + EXPECT_TRUE(f.AnyClear(eFlag0 | eFlag1)); + + f.Set(eFlag1); + f.Set(eFlag0); + EXPECT_FALSE(f.AnyClear(eFlag0 | eFlag1)); + + f.Clear(eFlag1); + EXPECT_TRUE(f.AnyClear(eFlag0 | eFlag1)); + + f.Clear(eFlag0); + EXPECT_TRUE(f.AnyClear(eFlag0 | eFlag1)); +} + +TEST(Flags, IsClear) { + Flags f; + + EXPECT_TRUE(f.IsClear(eFlag0)); + EXPECT_TRUE(f.IsClear(eFlag1)); + + f.Set(eFlag0); + EXPECT_FALSE(f.IsClear(eFlag0)); + EXPECT_TRUE(f.IsClear(eFlag1)); + + f.Set(eFlag1); + EXPECT_FALSE(f.IsClear(eFlag0)); + EXPECT_FALSE(f.IsClear(eFlag1)); + + f.Clear(eFlag0); + EXPECT_TRUE(f.IsClear(eFlag0)); + EXPECT_FALSE(f.IsClear(eFlag1)); + + f.Clear(eFlag1); + EXPECT_TRUE(f.IsClear(eFlag0)); + EXPECT_TRUE(f.IsClear(eFlag1)); +} + +TEST(Flags, ClearCount) { + Flags f; + EXPECT_EQ(32U, f.ClearCount()); + + f.Set(eFlag0); + EXPECT_EQ(31U, f.ClearCount()); +
[Lldb-commits] [lldb] r337737 - [NFC] Minor code refactoring.
Author: teemperor Date: Mon Jul 23 13:56:49 2018 New Revision: 337737 URL: http://llvm.org/viewvc/llvm-project?rev=337737&view=rev Log: [NFC] Minor code refactoring. Subscribers: lldb-commits Differential Revision: https://reviews.llvm.org/D49696 Modified: lldb/trunk/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp Modified: lldb/trunk/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp?rev=337737&r1=337736&r2=337737&view=diff == --- lldb/trunk/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp (original) +++ lldb/trunk/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp Mon Jul 23 13:56:49 2018 @@ -1163,10 +1163,7 @@ bool ScriptInterpreterPython::ExecuteOne } } -if (success) - ret_success = true; -else - ret_success = false; +ret_success = success; } py_error.Reset(PyRefType::Borrowed, PyErr_Occurred()); ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] r337741 - [cmake] Remove unused ${LLDB_PLUGINS} dependency from our Objective-C++ CMake config
Author: teemperor Date: Mon Jul 23 14:14:52 2018 New Revision: 337741 URL: http://llvm.org/viewvc/llvm-project?rev=337741&view=rev Log: [cmake] Remove unused ${LLDB_PLUGINS} dependency from our Objective-C++ CMake config Summary: LLDB_PLUGINS doesn't exist as a variable, so this line doesn't add any dependencies and is just confusing. It seems this slipped in from the gdb-remote CMake I was using as a CMake template. The gdb-remote CMake itself is using a local LLDB_PLUGINS variable, so that code is fine. Reviewers: davide Reviewed By: davide Subscribers: davide, mgorny, lldb-commits Differential Revision: https://reviews.llvm.org/D49695 Modified: lldb/trunk/source/Host/macosx/objcxx/CMakeLists.txt lldb/trunk/source/Plugins/Platform/MacOSX/objcxx/CMakeLists.txt Modified: lldb/trunk/source/Host/macosx/objcxx/CMakeLists.txt URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/macosx/objcxx/CMakeLists.txt?rev=337741&r1=337740&r2=337741&view=diff == --- lldb/trunk/source/Host/macosx/objcxx/CMakeLists.txt (original) +++ lldb/trunk/source/Host/macosx/objcxx/CMakeLists.txt Mon Jul 23 14:14:52 2018 @@ -12,7 +12,6 @@ add_lldb_library(lldbHostMacOSXObjCXX lldbSymbol lldbTarget lldbUtility -${LLDB_PLUGINS} ${EXTRA_LIBS} LINK_COMPONENTS Modified: lldb/trunk/source/Plugins/Platform/MacOSX/objcxx/CMakeLists.txt URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Platform/MacOSX/objcxx/CMakeLists.txt?rev=337741&r1=337740&r2=337741&view=diff == --- lldb/trunk/source/Plugins/Platform/MacOSX/objcxx/CMakeLists.txt (original) +++ lldb/trunk/source/Plugins/Platform/MacOSX/objcxx/CMakeLists.txt Mon Jul 23 14:14:52 2018 @@ -9,7 +9,6 @@ add_lldb_library(lldbPluginPlatformMacOS lldbSymbol lldbTarget lldbUtility -${LLDB_PLUGINS} ${EXTRA_LIBS} LINK_COMPONENTS ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] r337778 - Added unit test for StreamTee
Author: teemperor Date: Mon Jul 23 17:01:32 2018 New Revision: 337778 URL: http://llvm.org/viewvc/llvm-project?rev=337778&view=rev Log: Added unit test for StreamTee Reviewers: davide Reviewed By: davide Subscribers: davide, mgorny, lldb-commits Differential Revision: https://reviews.llvm.org/D49708 Added: lldb/trunk/unittests/Utility/StreamTeeTest.cpp Modified: lldb/trunk/lldb.xcodeproj/project.pbxproj lldb/trunk/unittests/Utility/CMakeLists.txt Modified: lldb/trunk/lldb.xcodeproj/project.pbxproj URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/lldb.xcodeproj/project.pbxproj?rev=337778&r1=33&r2=337778&view=diff == --- lldb/trunk/lldb.xcodeproj/project.pbxproj (original) +++ lldb/trunk/lldb.xcodeproj/project.pbxproj Mon Jul 23 17:01:32 2018 @@ -867,6 +867,7 @@ 2689004F13353E0400698AC0 /* StreamFile.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26BC7E9210F1B85900F91463 /* StreamFile.cpp */; }; AFC2DCF91E6E318000283714 /* StreamGDBRemote.cpp in Sources */ = {isa = PBXBuildFile; fileRef = AFC2DCF81E6E318000283714 /* StreamGDBRemote.cpp */; }; 26764CA21E48F547008D3573 /* StreamString.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26764CA11E48F547008D3573 /* StreamString.cpp */; }; + 58EAC73F2106A07B0029571E /* StreamTeeTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 58EAC73D2106A0740029571E /* StreamTeeTest.cpp */; }; 33E5E8471A674FB60024ED68 /* StringConvert.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 33E5E8411A672A240024ED68 /* StringConvert.cpp */; }; 268903353E8200698AC0 /* StringExtractor.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2660D9F611922A1300958FBD /* StringExtractor.cpp */; }; 2689011213353E8200698AC0 /* StringExtractorGDBRemote.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2676A093119C93C8008A98EF /* StringExtractorGDBRemote.cpp */; }; @@ -2885,6 +2886,7 @@ 26764CA11E48F547008D3573 /* StreamString.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = StreamString.cpp; path = source/Utility/StreamString.cpp; sourceTree = ""; }; 26764CA31E48F550008D3573 /* StreamString.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = StreamString.h; path = include/lldb/Utility/StreamString.h; sourceTree = ""; }; 26764CA41E48F566008D3573 /* StreamTee.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = StreamTee.h; path = include/lldb/Utility/StreamTee.h; sourceTree = ""; }; + 58EAC73D2106A0740029571E /* StreamTeeTest.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = StreamTeeTest.cpp; sourceTree = ""; }; 33E5E8411A672A240024ED68 /* StringConvert.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = StringConvert.cpp; sourceTree = ""; }; 33E5E8451A6736D30024ED68 /* StringConvert.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = StringConvert.h; path = include/lldb/Host/StringConvert.h; sourceTree = SOURCE_ROOT; }; 2660D9F611922A1300958FBD /* StringExtractor.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = StringExtractor.cpp; path = source/Utility/StringExtractor.cpp; sourceTree = ""; }; @@ -3495,6 +3497,7 @@ 2321F9421BDD343A00BA9A93 /* Utility */ = { isa = PBXGroup; children = ( + 58EAC73D2106A0740029571E /* StreamTeeTest.cpp */, 7F94D7172040A13A006EE3EA /* CleanUpTest.cpp */, 23E2E5161D903689006F38BB /* ArchSpecTest.cpp */, 9A3D43C81F3150D200EB767C /* ConstStringTest.cpp */, @@ -7426,6 +7429,7 @@ 23CB15371D66DA9300EDDDE1 /* PythonTestSuite.cpp in Sources */, 23E2E5321D903832006F38BB /* BreakpointIDTest.cpp in Sources */, 4CEC86A7204738EB009B37B1 /* TestPPC64InstEmulation.cpp in Sources */, + 58EAC73F2106A07B0029571E /* StreamTeeTest.cpp in Sources */, 23CB15381D66DA9300EDDDE1 /* PythonExceptionStateTests.cpp in Sources */, 9A3D43D81F3151C400EB767C /* NameMatchesTest.cpp in Sources */, 23CB15391D66DA9300EDDDE1 /* DataExtractorTest.cpp in Sources */, Modified: lldb/trunk/unittests/Utility/CMakeLists.txt URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/unittests/Utility/CMakeLists.txt?rev=337778&r1=33&r2=337778&view=diff =
[Lldb-commits] [lldb] r337855 - Remove unused History class
Author: teemperor Date: Tue Jul 24 14:09:17 2018 New Revision: 337855 URL: http://llvm.org/viewvc/llvm-project?rev=337855&view=rev Log: Remove unused History class Summary: This class doesn't seem to be used anywhere, so we might as well remove the code. Reviewers: labath Reviewed By: labath Subscribers: labath, mgorny, lldb-commits Differential Revision: https://reviews.llvm.org/D49755 Removed: lldb/trunk/include/lldb/Utility/History.h lldb/trunk/source/Utility/History.cpp Modified: lldb/trunk/lldb.xcodeproj/project.pbxproj lldb/trunk/source/Utility/CMakeLists.txt Removed: lldb/trunk/include/lldb/Utility/History.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Utility/History.h?rev=337854&view=auto == --- lldb/trunk/include/lldb/Utility/History.h (original) +++ lldb/trunk/include/lldb/Utility/History.h (removed) @@ -1,136 +0,0 @@ -//===-- History.h ---*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===--===// - -#ifndef lldb_History_h_ -#define lldb_History_h_ - -#include "lldb/lldb-defines.h" // for DISALLOW_COPY_AND_ASSIGN - -// C++ Includes -#include -#include -#include - -#include // for size_t -#include - -namespace lldb_private { -class Stream; -} - -namespace lldb_private { - -//-- -/// @class HistorySource History.h "lldb/Core/History.h" -/// A class that defines history events. -//-- - -class HistorySource { -public: - typedef const void *HistoryEvent; - - HistorySource() : m_mutex(), m_events() {} - - virtual ~HistorySource() {} - - // Create a new history event. Subclasses should use any data or members in - // the subclass of this class to produce a history event and push it onto the - // end of the history stack. - - virtual HistoryEvent CreateHistoryEvent() = 0; - - virtual void DeleteHistoryEvent(HistoryEvent event) = 0; - - virtual void DumpHistoryEvent(Stream &strm, HistoryEvent event) = 0; - - virtual size_t GetHistoryEventCount() = 0; - - virtual HistoryEvent GetHistoryEventAtIndex(uint32_t idx) = 0; - - virtual HistoryEvent GetCurrentHistoryEvent() = 0; - - // Return 0 when lhs == rhs, 1 if lhs > rhs, or -1 if lhs < rhs. - virtual int CompareHistoryEvents(const HistoryEvent lhs, - const HistoryEvent rhs) = 0; - - virtual bool IsCurrentHistoryEvent(const HistoryEvent event) = 0; - -private: - typedef std::stack collection; - - std::recursive_mutex m_mutex; - collection m_events; - - DISALLOW_COPY_AND_ASSIGN(HistorySource); -}; - -//-- -/// @class HistorySourceUInt History.h "lldb/Core/History.h" -/// A class that defines history events that are represented by -/// unsigned integers. -/// -/// Any history event that is defined by a unique monotonically increasing -/// unsigned integer -//-- - -class HistorySourceUInt : public HistorySource { - HistorySourceUInt(const char *id_name, uintptr_t start_value = 0u) - : HistorySource(), m_name(id_name), m_curr_id(start_value) {} - - ~HistorySourceUInt() override {} - - // Create a new history event. Subclasses should use any data or members in - // the subclass of this class to produce a history event and push it onto the - // end of the history stack. - - HistoryEvent CreateHistoryEvent() override { -++m_curr_id; -return (HistoryEvent)m_curr_id; - } - - void DeleteHistoryEvent(HistoryEvent event) override { -// Nothing to delete, the event contains the integer - } - - void DumpHistoryEvent(Stream &strm, HistoryEvent event) override; - - size_t GetHistoryEventCount() override { return m_curr_id; } - - HistoryEvent GetHistoryEventAtIndex(uint32_t idx) override { -return (HistoryEvent)((uintptr_t)idx); - } - - HistoryEvent GetCurrentHistoryEvent() override { -return (HistoryEvent)m_curr_id; - } - - // Return 0 when lhs == rhs, 1 if lhs > rhs, or -1 if lhs < rhs. - int CompareHistoryEvents(const HistoryEvent lhs, - const HistoryEvent rhs) override { -uintptr_t lhs_uint = (uintptr_t)lhs; -uintptr_t rhs_uint = (uintptr_t)rhs; -if (lhs_uint < rhs_uint) - return -1; -if (lhs_uint > rhs_uint) - return +1; -return 0; - } - - bool IsCurrentHistoryEvent(const HistoryEvent event) override { -return (uintptr_t)event == m_curr_id; - } - -protected: - std::string m_name; // The name of the history unsigned integer - uintptr_t m_curr_id; // The curr
[Lldb-commits] [lldb] r337873 - Add unit tests for VMRange
Author: teemperor Date: Tue Jul 24 16:52:39 2018 New Revision: 337873 URL: http://llvm.org/viewvc/llvm-project?rev=337873&view=rev Log: Add unit tests for VMRange Subscribers: clayborg, labath, mgorny, lldb-commits Differential Revision: https://reviews.llvm.org/D49415 Added: lldb/trunk/unittests/Utility/VMRangeTest.cpp Modified: lldb/trunk/unittests/Utility/CMakeLists.txt Modified: lldb/trunk/unittests/Utility/CMakeLists.txt URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/unittests/Utility/CMakeLists.txt?rev=337873&r1=337872&r2=337873&view=diff == --- lldb/trunk/unittests/Utility/CMakeLists.txt (original) +++ lldb/trunk/unittests/Utility/CMakeLists.txt Tue Jul 24 16:52:39 2018 @@ -22,6 +22,7 @@ add_lldb_unittest(UtilityTests UriParserTest.cpp UUIDTest.cpp VASprintfTest.cpp + VMRangeTest.cpp LINK_LIBS lldbUtility Added: lldb/trunk/unittests/Utility/VMRangeTest.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/unittests/Utility/VMRangeTest.cpp?rev=337873&view=auto == --- lldb/trunk/unittests/Utility/VMRangeTest.cpp (added) +++ lldb/trunk/unittests/Utility/VMRangeTest.cpp Tue Jul 24 16:52:39 2018 @@ -0,0 +1,152 @@ +//===-- VMRangeTest.cpp -*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===--===// + +#include "gtest/gtest.h" + +#include + +#include "lldb/Utility/VMRange.h" + +using namespace lldb_private; + +namespace lldb_private { +void PrintTo(const VMRange &v, std::ostream *os) { + (*os) << "VMRange(" << v.GetBaseAddress() << ", " << v.GetEndAddress() << ")"; +} +} // namespace lldb_private + +TEST(VMRange, IsValid) { + VMRange range; + EXPECT_FALSE(range.IsValid()); + + range.Reset(0x1, 0x100); + EXPECT_TRUE(range.IsValid()); + + range.Reset(0x1, 0x1); + EXPECT_FALSE(range.IsValid()); +} + +TEST(VMRange, Clear) { + VMRange range(0x100, 0x200); + EXPECT_NE(VMRange(), range); + range.Clear(); + EXPECT_EQ(VMRange(), range); +} + +TEST(VMRange, Comparison) { + VMRange range1(0x100, 0x200); + VMRange range2(0x100, 0x200); + EXPECT_EQ(range1, range2); + + EXPECT_NE(VMRange(0x100, 0x1ff), range1); + EXPECT_NE(VMRange(0x100, 0x201), range1); + EXPECT_NE(VMRange(0x0ff, 0x200), range1); + EXPECT_NE(VMRange(0x101, 0x200), range1); + + range2.Clear(); + EXPECT_NE(range1, range2); +} + +TEST(VMRange, Reset) { + VMRange range(0x100, 0x200); + EXPECT_FALSE(VMRange(0x200, 0x200) == range); + range.Reset(0x200, 0x200); + EXPECT_TRUE(VMRange(0x200, 0x200) == range); +} + +TEST(VMRange, SetEndAddress) { + VMRange range(0x100, 0x200); + + range.SetEndAddress(0xFF); + EXPECT_EQ(0U, range.GetByteSize()); + EXPECT_FALSE(range.IsValid()); + + range.SetEndAddress(0x101); + EXPECT_EQ(1U, range.GetByteSize()); + EXPECT_TRUE(range.IsValid()); +} + +TEST(VMRange, ContainsAddr) { + VMRange range(0x100, 0x200); + + EXPECT_FALSE(range.Contains(0x00)); + EXPECT_FALSE(range.Contains(0xFF)); + EXPECT_TRUE(range.Contains(0x100)); + EXPECT_TRUE(range.Contains(0x101)); + EXPECT_TRUE(range.Contains(0x1FF)); + EXPECT_FALSE(range.Contains(0x200)); + EXPECT_FALSE(range.Contains(0x201)); + EXPECT_FALSE(range.Contains(0xFFF)); + EXPECT_FALSE(range.Contains(std::numeric_limits::max())); +} + +TEST(VMRange, ContainsRange) { + VMRange range(0x100, 0x200); + + EXPECT_FALSE(range.Contains(VMRange(0x0, 0x0))); + + EXPECT_FALSE(range.Contains(VMRange(0x0, 0x100))); + EXPECT_FALSE(range.Contains(VMRange(0x0, 0x101))); + EXPECT_TRUE(range.Contains(VMRange(0x100, 0x105))); + EXPECT_TRUE(range.Contains(VMRange(0x101, 0x105))); + EXPECT_TRUE(range.Contains(VMRange(0x100, 0x1FF))); + EXPECT_TRUE(range.Contains(VMRange(0x105, 0x200))); + EXPECT_FALSE(range.Contains(VMRange(0x105, 0x201))); + EXPECT_FALSE(range.Contains(VMRange(0x200, 0x201))); + EXPECT_TRUE(range.Contains(VMRange(0x100, 0x200))); + EXPECT_FALSE( + range.Contains(VMRange(0x105, std::numeric_limits::max(; + + // Empty range. + EXPECT_TRUE(range.Contains(VMRange(0x100, 0x100))); + + range.Clear(); + EXPECT_FALSE(range.Contains(VMRange(0x0, 0x0))); +} + +TEST(VMRange, Ordering) { + VMRange range1(0x44, 0x200); + VMRange range2(0x100, 0x1FF); + VMRange range3(0x100, 0x200); + + EXPECT_LE(range1, range1); + EXPECT_GE(range1, range1); + + EXPECT_LT(range1, range2); + EXPECT_LT(range2, range3); + + EXPECT_GT(range2, range1); + EXPECT_GT(range3, range2); + + // Ensure that < and > are always false when comparing ranges with themselves. + EXPECT_FALSE(range1 < range1); + EXPECT_FALSE(range2 < range2); + EXPECT_FALSE(range3 < range3); + + EXPECT_FALSE(range1 > range
[Lldb-commits] [lldb] r338040 - Don't print two errors for unknown commands.
Author: teemperor Date: Thu Jul 26 09:32:05 2018 New Revision: 338040 URL: http://llvm.org/viewvc/llvm-project?rev=338040&view=rev Log: Don't print two errors for unknown commands. Summary: We always print two error messages when we hit an unknown command. As the function `CommandInterpreter::HandleCommand` that prints the second error message unconditionally called the `CommandInterpreter::ResolveCommandImpl` before (which prints the first error message), we can just remove that second error message. Fixes https://bugs.llvm.org/show_bug.cgi?id=38312 Reviewers: labath Reviewed By: labath Subscribers: labath, lldb-commits Differential Revision: https://reviews.llvm.org/D49831 Added: lldb/trunk/packages/Python/lldbsuite/test/functionalities/wrong_commands/ lldb/trunk/packages/Python/lldbsuite/test/functionalities/wrong_commands/.categories lldb/trunk/packages/Python/lldbsuite/test/functionalities/wrong_commands/TestWrongCommands.py Modified: lldb/trunk/source/Interpreter/CommandInterpreter.cpp Added: lldb/trunk/packages/Python/lldbsuite/test/functionalities/wrong_commands/.categories URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/functionalities/wrong_commands/.categories?rev=338040&view=auto == --- lldb/trunk/packages/Python/lldbsuite/test/functionalities/wrong_commands/.categories (added) +++ lldb/trunk/packages/Python/lldbsuite/test/functionalities/wrong_commands/.categories Thu Jul 26 09:32:05 2018 @@ -0,0 +1 @@ +cmdline Added: lldb/trunk/packages/Python/lldbsuite/test/functionalities/wrong_commands/TestWrongCommands.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/functionalities/wrong_commands/TestWrongCommands.py?rev=338040&view=auto == --- lldb/trunk/packages/Python/lldbsuite/test/functionalities/wrong_commands/TestWrongCommands.py (added) +++ lldb/trunk/packages/Python/lldbsuite/test/functionalities/wrong_commands/TestWrongCommands.py Thu Jul 26 09:32:05 2018 @@ -0,0 +1,39 @@ +""" +Test how lldb reacts to wrong commands +""" + +from __future__ import print_function + +import os +import time +import lldb +from lldbsuite.test.decorators import * +from lldbsuite.test.lldbtest import * +from lldbsuite.test import lldbutil + +class UnknownCommandTestCase(TestBase): + +mydir = TestBase.compute_mydir(__file__) + +@no_debug_info_test +def test_ambiguous_command(self): +command_interpreter = self.dbg.GetCommandInterpreter() +self.assertTrue(command_interpreter, VALID_COMMAND_INTERPRETER) +result = lldb.SBCommandReturnObject() + +command_interpreter.HandleCommand("g", result) +self.assertFalse(result.Succeeded()) +self.assertRegexpMatches(result.GetError(), "Ambiguous command 'g'. Possible matches:") +self.assertRegexpMatches(result.GetError(), "gui") +self.assertRegexpMatches(result.GetError(), "gdb-remote") +# FIXME: Somehow we get 'gui' and 'gdb-remote' twice in the output. + +@no_debug_info_test +def test_unknown_command(self): +command_interpreter = self.dbg.GetCommandInterpreter() +self.assertTrue(command_interpreter, VALID_COMMAND_INTERPRETER) +result = lldb.SBCommandReturnObject() + +command_interpreter.HandleCommand("qbert", result) +self.assertFalse(result.Succeeded()) +self.assertEquals(result.GetError(), "error: 'qbert' is not a valid command.\n") Modified: lldb/trunk/source/Interpreter/CommandInterpreter.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/CommandInterpreter.cpp?rev=338040&r1=338039&r2=338040&view=diff == --- lldb/trunk/source/Interpreter/CommandInterpreter.cpp (original) +++ lldb/trunk/source/Interpreter/CommandInterpreter.cpp Thu Jul 26 09:32:05 2018 @@ -1693,33 +1693,6 @@ bool CommandInterpreter::HandleCommand(c remainder.c_str()); cmd_obj->Execute(remainder.c_str(), result); - } else { -// We didn't find the first command object, so complete the first argument. -Args command_args(command_string); -StringList matches; -unsigned cursor_char_position = strlen(command_args.GetArgumentAtIndex(0)); -CompletionRequest request(command_line, cursor_char_position, 0, -1, - matches); -int num_matches = HandleCompletionMatches(request); - -if (num_matches > 0) { - std::string error_msg; - error_msg.assign("ambiguous command '"); - error_msg.append(command_args.GetArgumentAtIndex(0)); - error_msg.append("'."); - - error_msg.append(" Possible completions:"); - for (int i = 0; i < num_matches; i++) { -error_msg.append("\n\t"); -error_msg.append(matches.GetStringAtIndex(
[Lldb-commits] [lldb] r338043 - Fix duplicate suggestions after an ambiguous command
Author: teemperor Date: Thu Jul 26 10:14:18 2018 New Revision: 338043 URL: http://llvm.org/viewvc/llvm-project?rev=338043&view=rev Log: Fix duplicate suggestions after an ambiguous command Summary: So far lldb is printing this when it finds an ambiguous command: ``` (lldb) g Ambiguous command 'g'. Possible matches: gdb-remote gui gdb-remote gui ``` The duplicates come from the fact that we call the same query twice with the same parameters and add it to the same list. This patch just removes the second query call to `GetCommandObject`. As `GetCommandObject` is const and the name parameter is also not modified, this shouldn't break anything else. I didn't merge the remaining if statement into the else as I think otherwise the `if obj==nullptr do X else Y` pattern in there becomes hard to recognize. Reviewers: davide Reviewed By: davide Subscribers: lldb-commits Differential Revision: https://reviews.llvm.org/D49866 Modified: lldb/trunk/packages/Python/lldbsuite/test/functionalities/wrong_commands/TestWrongCommands.py lldb/trunk/source/Interpreter/CommandInterpreter.cpp Modified: lldb/trunk/packages/Python/lldbsuite/test/functionalities/wrong_commands/TestWrongCommands.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/functionalities/wrong_commands/TestWrongCommands.py?rev=338043&r1=338042&r2=338043&view=diff == --- lldb/trunk/packages/Python/lldbsuite/test/functionalities/wrong_commands/TestWrongCommands.py (original) +++ lldb/trunk/packages/Python/lldbsuite/test/functionalities/wrong_commands/TestWrongCommands.py Thu Jul 26 10:14:18 2018 @@ -26,7 +26,7 @@ class UnknownCommandTestCase(TestBase): self.assertRegexpMatches(result.GetError(), "Ambiguous command 'g'. Possible matches:") self.assertRegexpMatches(result.GetError(), "gui") self.assertRegexpMatches(result.GetError(), "gdb-remote") -# FIXME: Somehow we get 'gui' and 'gdb-remote' twice in the output. +self.assertEquals(1, result.GetError().count("gdb-remote")) @no_debug_info_test def test_unknown_command(self): Modified: lldb/trunk/source/Interpreter/CommandInterpreter.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/CommandInterpreter.cpp?rev=338043&r1=338042&r2=338043&view=diff == --- lldb/trunk/source/Interpreter/CommandInterpreter.cpp (original) +++ lldb/trunk/source/Interpreter/CommandInterpreter.cpp Thu Jul 26 10:14:18 2018 @@ -2932,8 +2932,6 @@ CommandInterpreter::ResolveCommandImpl(s actual_cmd_name_len = cmd_obj->GetCommandName().size(); } } else { -if (!cmd_obj) - cmd_obj = GetCommandObject(next_word, &matches); if (cmd_obj) { llvm::StringRef cmd_name = cmd_obj->GetCommandName(); actual_cmd_name_len += cmd_name.size(); ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] r338151 - Narrow the CompletionRequest API to being append-only.
Author: teemperor Date: Fri Jul 27 11:42:46 2018 New Revision: 338151 URL: http://llvm.org/viewvc/llvm-project?rev=338151&view=rev Log: Narrow the CompletionRequest API to being append-only. Summary: We currently allow any completion handler to read and manipulate the list of matches we calculated so far. This leads to a few problems: Firstly, a completion handler's logic can now depend on previously calculated results by another handlers. No completion handler should have such an implicit dependency, but the current API makes it likely that this could happen (or already happens). Especially the fact that some completion handler deleted all previously calculated results can mess things up right now. Secondly, all completion handlers have knowledge about our internal data structures with this API. This makes refactoring this internal data structure much harder than it should be. Especially planned changes like the support of descriptions for completions are currently giant patches because we have to refactor every single completion handler. This patch narrows the contract the CompletionRequest has with the different handlers to: 1. A handler can suggest a completion. 2. A handler can ask how many suggestions we already have. Point 2 obviously means we still have a dependency left between the different handlers, but getting rid of this is too large to just append it to this patch. Otherwise this patch just completely hides the internal StringList to the different handlers. The CompletionRequest API now also ensures that the list of completions is unique and we don't suggest the same value multiple times to the user. This property has been so far only been ensured by the `Option` handler, but is now applied globally. This is part of this patch as the OptionHandler is no longer able to implement this functionality itself. Reviewers: jingham, davide, labath Reviewed By: davide Subscribers: lldb-commits Differential Revision: https://reviews.llvm.org/D49322 Modified: lldb/trunk/include/lldb/Utility/CompletionRequest.h lldb/trunk/source/Commands/CommandCompletions.cpp lldb/trunk/source/Commands/CommandObjectCommands.cpp lldb/trunk/source/Commands/CommandObjectFrame.cpp lldb/trunk/source/Commands/CommandObjectMultiword.cpp lldb/trunk/source/Commands/CommandObjectPlatform.cpp lldb/trunk/source/Commands/CommandObjectPlugin.cpp lldb/trunk/source/Commands/CommandObjectProcess.cpp lldb/trunk/source/Commands/CommandObjectSettings.cpp lldb/trunk/source/Commands/CommandObjectTarget.cpp lldb/trunk/source/Core/FormatEntity.cpp lldb/trunk/source/Core/IOHandler.cpp lldb/trunk/source/Interpreter/CommandInterpreter.cpp lldb/trunk/source/Interpreter/CommandObject.cpp lldb/trunk/source/Interpreter/CommandObjectRegexCommand.cpp lldb/trunk/source/Interpreter/OptionValue.cpp lldb/trunk/source/Interpreter/OptionValueArch.cpp lldb/trunk/source/Interpreter/OptionValueBoolean.cpp lldb/trunk/source/Interpreter/OptionValueEnumeration.cpp lldb/trunk/source/Interpreter/OptionValueFileSpec.cpp lldb/trunk/source/Interpreter/OptionValueUUID.cpp lldb/trunk/source/Interpreter/Options.cpp lldb/trunk/source/Symbol/Variable.cpp lldb/trunk/source/Utility/ArchSpec.cpp lldb/trunk/source/Utility/CompletionRequest.cpp lldb/trunk/unittests/Utility/CompletionRequestTest.cpp Modified: lldb/trunk/include/lldb/Utility/CompletionRequest.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Utility/CompletionRequest.h?rev=338151&r1=338150&r2=338151&view=diff == --- lldb/trunk/include/lldb/Utility/CompletionRequest.h (original) +++ lldb/trunk/include/lldb/Utility/CompletionRequest.h Fri Jul 27 11:42:46 2018 @@ -13,6 +13,7 @@ #include "lldb/Utility/Args.h" #include "lldb/Utility/StringList.h" #include "llvm/ADT/StringRef.h" +#include "llvm/ADT/StringSet.h" namespace lldb_private { @@ -77,8 +78,29 @@ public: void SetWordComplete(bool v) { m_word_complete = v; } - /// The array of matches returned. - StringList &GetMatches() { return *m_matches; } + /// Adds a possible completion string. If the completion was already + /// suggested before, it will not be added to the list of results. A copy of + /// the suggested completion is stored, so the given string can be free'd + /// afterwards. + /// + /// @param match The suggested completion. + void AddCompletion(llvm::StringRef completion) { +// Add the completion if we haven't seen the same value before. +if (m_match_set.insert(completion).second) + m_matches->AppendString(completion); + } + + /// Adds multiple possible completion strings. + /// + /// \param completions The list of completions. + /// + /// @see AddCompletion + void AddCompletions(const StringList &completions) { +for (std::size_t i = 0; i < completions.GetSize(); ++i) + AddComple
[Lldb-commits] [lldb] r338171 - Fix whitespace in the python test suite.
Author: teemperor Date: Fri Jul 27 15:20:59 2018 New Revision: 338171 URL: http://llvm.org/viewvc/llvm-project?rev=338171&view=rev Log: Fix whitespace in the python test suite. Summary: The test suite has often unnecessary trailing whitespace, and sometimes unnecessary trailing lines or a missing final new line. This patch just strips trailing whitespace/lines and adds missing newlines at the end. Subscribers: ki.stfu, JDevlieghere, christof, lldb-commits Differential Revision: https://reviews.llvm.org/D49943 Modified: lldb/trunk/packages/Python/lldbsuite/test/api/multiple-debuggers/TestMultipleDebuggers.py lldb/trunk/packages/Python/lldbsuite/test/api/multithreaded/TestMultithreaded.py lldb/trunk/packages/Python/lldbsuite/test/decorators.py lldb/trunk/packages/Python/lldbsuite/test/expression_command/call-function/TestCallStdStringFunction.py lldb/trunk/packages/Python/lldbsuite/test/expression_command/call-restarts/TestCallThatRestarts.py lldb/trunk/packages/Python/lldbsuite/test/expression_command/call-throws/TestCallThatThrows.py lldb/trunk/packages/Python/lldbsuite/test/expression_command/char/TestExprsChar.py lldb/trunk/packages/Python/lldbsuite/test/expression_command/fixits/TestFixIts.py lldb/trunk/packages/Python/lldbsuite/test/expression_command/issue_11588/Test11588.py lldb/trunk/packages/Python/lldbsuite/test/expression_command/pr35310/TestExprsBug35310.py lldb/trunk/packages/Python/lldbsuite/test/expression_command/save_jit_objects/TestSaveJITObjects.py lldb/trunk/packages/Python/lldbsuite/test/expression_command/unwind_expression/TestUnwindExpression.py lldb/trunk/packages/Python/lldbsuite/test/expression_command/xvalue/TestXValuePrinting.py lldb/trunk/packages/Python/lldbsuite/test/functionalities/breakpoint/address_breakpoints/TestBadAddressBreakpoints.py lldb/trunk/packages/Python/lldbsuite/test/functionalities/breakpoint/auto_continue/TestBreakpointAutoContinue.py lldb/trunk/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_locations/TestBreakpointLocations.py lldb/trunk/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_names/TestBreakpointNames.py lldb/trunk/packages/Python/lldbsuite/test/functionalities/breakpoint/hardware_breakpoints/hardware_breakpoint_on_multiple_threads/TestHWBreakMultiThread.py lldb/trunk/packages/Python/lldbsuite/test/functionalities/breakpoint/serialize/TestBreakpointSerialization.py lldb/trunk/packages/Python/lldbsuite/test/functionalities/breakpoint/step_over_breakpoint/TestStepOverBreakpoint.py lldb/trunk/packages/Python/lldbsuite/test/functionalities/completion/TestCompletion.py lldb/trunk/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/bitset/TestDataFormatterLibcxxBitset.py lldb/trunk/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/list/TestDataFormatterLibcxxList.py lldb/trunk/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/multiset/TestDataFormatterLibcxxMultiSet.py lldb/trunk/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/set/TestDataFormatterLibcxxSet.py lldb/trunk/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/vector/TestDataFormatterLibcxxVector.py lldb/trunk/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/tuple/TestDataFormatterStdTuple.py lldb/trunk/packages/Python/lldbsuite/test/functionalities/exec/TestExec.py lldb/trunk/packages/Python/lldbsuite/test/functionalities/frame-language/TestGuessLanguage.py lldb/trunk/packages/Python/lldbsuite/test/functionalities/frame_var/TestFrameVar.py lldb/trunk/packages/Python/lldbsuite/test/functionalities/gdb_remote_client/TestTargetXMLArch.py lldb/trunk/packages/Python/lldbsuite/test/functionalities/gdb_remote_client/gdbclientutils.py lldb/trunk/packages/Python/lldbsuite/test/functionalities/history/TestHistoryRecall.py lldb/trunk/packages/Python/lldbsuite/test/functionalities/load_unload/TestLoadUnload.py lldb/trunk/packages/Python/lldbsuite/test/functionalities/load_using_paths/TestLoadUsingPaths.py lldb/trunk/packages/Python/lldbsuite/test/functionalities/pre_run_dylibs/TestPreRunDylibs.py lldb/trunk/packages/Python/lldbsuite/test/functionalities/register/intel_avx/TestZMMRegister.py lldb/trunk/packages/Python/lldbsuite/test/functionalities/return-value/TestReturnValue.py lldb/trunk/packages/Python/lldbsuite/test/functionalities/thread/create_during_step/TestCreateDuringStep.py lldb/trunk/packages/Python/lldbsuite/test/functionalities/thread/num_threads/TestNumThreads.py lldb/trunk/packages/Python/lldbsuite/test/functionalities/thread/step_until/TestStepUntil.py lldb/trunk/packages/Python/lldbsuite/test/functionalities/w
[Lldb-commits] [lldb] r338177 - Add missing boundary checks to variable completion.
Author: teemperor Date: Fri Jul 27 16:37:08 2018 New Revision: 338177 URL: http://llvm.org/viewvc/llvm-project?rev=338177&view=rev Log: Add missing boundary checks to variable completion. Summary: Stopgap patch to at least stop all the crashes I get from this code. Subscribers: lldb-commits Differential Revision: https://reviews.llvm.org/D49949 Modified: lldb/trunk/packages/Python/lldbsuite/test/functionalities/completion/TestCompletion.py lldb/trunk/packages/Python/lldbsuite/test/functionalities/completion/main.cpp lldb/trunk/source/Symbol/Variable.cpp Modified: lldb/trunk/packages/Python/lldbsuite/test/functionalities/completion/TestCompletion.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/functionalities/completion/TestCompletion.py?rev=338177&r1=338176&r2=338177&view=diff == --- lldb/trunk/packages/Python/lldbsuite/test/functionalities/completion/TestCompletion.py (original) +++ lldb/trunk/packages/Python/lldbsuite/test/functionalities/completion/TestCompletion.py Fri Jul 27 16:37:08 2018 @@ -39,6 +39,46 @@ class CommandLineCompletionTestCase(Test self.complete_from_to('de', 'detach ') @skipIfFreeBSD # timing out on the FreeBSD buildbot +def test_frame_variable(self): +self.build() +self.main_source = "main.cpp" +self.main_source_spec = lldb.SBFileSpec(self.main_source) +self.dbg.CreateTarget(self.getBuildArtifact("a.out")) + +(target, process, thread, bkpt) = lldbutil.run_to_source_breakpoint(self, + '// Break here', self.main_source_spec) +self.assertEquals(process.GetState(), lldb.eStateStopped) +# FIXME: This pulls in the debug information to make the completions work, +# but the completions should also work without. +self.runCmd("frame variable fooo") + +self.complete_from_to('frame variable fo', + 'frame variable fooo') +self.complete_from_to('frame variable fooo.', + 'frame variable fooo.') +self.complete_from_to('frame variable fooo.dd', + 'frame variable fooo.dd') + +self.complete_from_to('frame variable ptr_fooo->', + 'frame variable ptr_fooo->') +self.complete_from_to('frame variable ptr_fooo->dd', + 'frame variable ptr_fooo->dd') + +self.complete_from_to('frame variable cont', + 'frame variable container') +self.complete_from_to('frame variable container.', + 'frame variable container.MemberVar') +self.complete_from_to('frame variable container.Mem', + 'frame variable container.MemberVar') + +self.complete_from_to('frame variable ptr_cont', + 'frame variable ptr_container') +self.complete_from_to('frame variable ptr_container->', + 'frame variable ptr_container->MemberVar') +self.complete_from_to('frame variable ptr_container->Mem', + 'frame variable ptr_container->MemberVar') + +@skipIfFreeBSD # timing out on the FreeBSD buildbot def test_process_attach_dash_dash_con(self): """Test that 'process attach --con' completes to 'process attach --continue '.""" self.complete_from_to( Modified: lldb/trunk/packages/Python/lldbsuite/test/functionalities/completion/main.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/functionalities/completion/main.cpp?rev=338177&r1=338176&r2=338177&view=diff == --- lldb/trunk/packages/Python/lldbsuite/test/functionalities/completion/main.cpp (original) +++ lldb/trunk/packages/Python/lldbsuite/test/functionalities/completion/main.cpp Fri Jul 27 16:37:08 2018 @@ -7,8 +7,15 @@ public: } }; +struct Container { int MemberVar; }; + int main() { -Foo f; -f.Bar(1, 2); +Foo fooo; +Foo *ptr_fooo = &fooo; +fooo.Bar(1, 2); + +Container container; +Container *ptr_container = &container; +return container.MemberVar = 3; // Break here } Modified: lldb/trunk/source/Symbol/Variable.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/Variable.cpp?rev=338177&r1=338176&r2=338177&view=diff == --- lldb/trunk/source/Symbol/Variable.cpp (original) +++ lldb/trunk/source/Symbol/Variable.cpp Fri Jul 27 16:37:08 2018 @@ -644,11 +644,12 @@ static void PrivateAutoComplete( break; case '-': - if (partial_path[1] == '>' && !prefix_path.str().empty()) { + if (partial_path.size() > 1 && partial_path[1] == '>' && +
[Lldb-commits] [lldb] r338179 - Add the actually calculated completions to COMPLETION_MSG
Author: teemperor Date: Fri Jul 27 16:42:34 2018 New Revision: 338179 URL: http://llvm.org/viewvc/llvm-project?rev=338179&view=rev Log: Add the actually calculated completions to COMPLETION_MSG Summary: Otherwise this assertion message is not very useful to whoever is reading the log. Subscribers: lldb-commits Differential Revision: https://reviews.llvm.org/D49947 Modified: lldb/trunk/packages/Python/lldbsuite/test/functionalities/completion/TestCompletion.py lldb/trunk/packages/Python/lldbsuite/test/lldbtest.py Modified: lldb/trunk/packages/Python/lldbsuite/test/functionalities/completion/TestCompletion.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/functionalities/completion/TestCompletion.py?rev=338179&r1=338178&r2=338179&view=diff == --- lldb/trunk/packages/Python/lldbsuite/test/functionalities/completion/TestCompletion.py (original) +++ lldb/trunk/packages/Python/lldbsuite/test/functionalities/completion/TestCompletion.py Fri Jul 27 16:42:34 2018 @@ -313,8 +313,8 @@ class CommandLineCompletionTestCase(Test if turn_off_re_match: self.expect( compare_string, msg=COMPLETION_MSG( -str_input, p), exe=False, substrs=[p]) +str_input, p, match_strings), exe=False, substrs=[p]) else: self.expect( compare_string, msg=COMPLETION_MSG( -str_input, p), exe=False, patterns=[p]) +str_input, p, match_strings), exe=False, patterns=[p]) Modified: lldb/trunk/packages/Python/lldbsuite/test/lldbtest.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/lldbtest.py?rev=338179&r1=338178&r2=338179&view=diff == --- lldb/trunk/packages/Python/lldbsuite/test/lldbtest.py (original) +++ lldb/trunk/packages/Python/lldbsuite/test/lldbtest.py Fri Jul 27 16:42:34 2018 @@ -184,9 +184,10 @@ def CMD_MSG(str): return "Command '%s' returns successfully" % str -def COMPLETION_MSG(str_before, str_after): +def COMPLETION_MSG(str_before, str_after, completions): '''A generic message generator for the completion mechanism.''' -return "'%s' successfully completes to '%s'" % (str_before, str_after) +return ("'%s' successfully completes to '%s', but completions were:\n%s" + % (str_before, str_after, "\n".join(completions))) def EXP_MSG(str, actual, exe): ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] r338311 - Remove unnecessary newlines from break command help text.
Author: teemperor Date: Mon Jul 30 14:41:13 2018 New Revision: 338311 URL: http://llvm.org/viewvc/llvm-project?rev=338311&view=rev Log: Remove unnecessary newlines from break command help text. Summary: We usually don't have trailing newlines in the short help strings. This just adds unnecessary extra lines when printing the help text of these commands. Subscribers: lldb-commits Differential Revision: https://reviews.llvm.org/D50015 Modified: lldb/trunk/source/Interpreter/CommandInterpreter.cpp Modified: lldb/trunk/source/Interpreter/CommandInterpreter.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/CommandInterpreter.cpp?rev=338311&r1=338310&r2=338311&view=diff == --- lldb/trunk/source/Interpreter/CommandInterpreter.cpp (original) +++ lldb/trunk/source/Interpreter/CommandInterpreter.cpp Mon Jul 30 14:41:13 2018 @@ -478,7 +478,7 @@ void CommandInterpreter::LoadCommandDict std::unique_ptr break_regex_cmd_ap( new CommandObjectRegexCommand( *this, "_regexp-break", - "Set a breakpoint using one of several shorthand formats.\n", + "Set a breakpoint using one of several shorthand formats.", "\n" "_regexp-break :\n" " main.c:12 // Break at line 12 of " @@ -527,7 +527,7 @@ void CommandInterpreter::LoadCommandDict std::unique_ptr tbreak_regex_cmd_ap( new CommandObjectRegexCommand( *this, "_regexp-tbreak", - "Set a one-shot breakpoint using one of several shorthand formats.\n", + "Set a one-shot breakpoint using one of several shorthand formats.", "\n" "_regexp-break :\n" " main.c:12 // Break at line 12 of " ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] r338345 - Remove Stream::UnitTest
Author: teemperor Date: Mon Jul 30 18:21:36 2018 New Revision: 338345 URL: http://llvm.org/viewvc/llvm-project?rev=338345&view=rev Log: Remove Stream::UnitTest Summary: No one is using this method, and it also doesn't really make a lot of sense to have it around. Reviewers: davide Reviewed By: davide Subscribers: davide, lldb-commits Differential Revision: https://reviews.llvm.org/D50026 Modified: lldb/trunk/include/lldb/Utility/Stream.h lldb/trunk/source/Utility/Stream.cpp Modified: lldb/trunk/include/lldb/Utility/Stream.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Utility/Stream.h?rev=338345&r1=338344&r2=338345&view=diff == --- lldb/trunk/include/lldb/Utility/Stream.h (original) +++ lldb/trunk/include/lldb/Utility/Stream.h Mon Jul 30 18:21:36 2018 @@ -524,8 +524,6 @@ public: //-- size_t PutULEB128(uint64_t uval); - static void UnitTest(Stream *s); - protected: //-- // Member variables Modified: lldb/trunk/source/Utility/Stream.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Utility/Stream.cpp?rev=338345&r1=338344&r2=338345&view=diff == --- lldb/trunk/source/Utility/Stream.cpp (original) +++ lldb/trunk/source/Utility/Stream.cpp Mon Jul 30 18:21:36 2018 @@ -526,48 +526,3 @@ size_t Stream::PutCStringAsRawHex8(const m_flags.Set(eBinary); return bytes_written; } - -void Stream::UnitTest(Stream *s) { - s->PutHex8(0x12); - - s->PutChar(' '); - s->PutHex16(0x3456, endian::InlHostByteOrder()); - s->PutChar(' '); - s->PutHex16(0x3456, eByteOrderBig); - s->PutChar(' '); - s->PutHex16(0x3456, eByteOrderLittle); - - s->PutChar(' '); - s->PutHex32(0x789abcde, endian::InlHostByteOrder()); - s->PutChar(' '); - s->PutHex32(0x789abcde, eByteOrderBig); - s->PutChar(' '); - s->PutHex32(0x789abcde, eByteOrderLittle); - - s->PutChar(' '); - s->PutHex64(0x1122334455667788ull, endian::InlHostByteOrder()); - s->PutChar(' '); - s->PutHex64(0x1122334455667788ull, eByteOrderBig); - s->PutChar(' '); - s->PutHex64(0x1122334455667788ull, eByteOrderLittle); - - const char *hola = "Hello World!!!"; - s->PutChar(' '); - s->PutCString(hola); - - s->PutChar(' '); - s->Write(hola, 5); - - s->PutChar(' '); - s->PutCStringAsRawHex8(hola); - - s->PutChar(' '); - s->PutCStringAsRawHex8("01234"); - - s->PutChar(' '); - s->Printf("pid=%i", 12733); - - s->PutChar(' '); - s->PrintfAsRawHex8("pid=%i", 12733); - s->PutChar('\n'); -} ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] r338488 - Added initial unit test for LLDB's Stream class.
Author: teemperor Date: Tue Jul 31 23:04:48 2018 New Revision: 338488 URL: http://llvm.org/viewvc/llvm-project?rev=338488&view=rev Log: Added initial unit test for LLDB's Stream class. Summary: This adds an initial small unit test for LLDB's Stream class, which should at least cover most of the functions in the Stream class. StreamString is always in big endian mode, so that's the only stream byte order path this test covers as of now. Also, the binary mode still needs to be tested for all print methods. Also adds some FIXMEs for wrong/strange result values of the Stream class that we hit while testing those functions. Reviewers: labath Reviewed By: labath Subscribers: probinson, labath, mgorny, lldb-commits Differential Revision: https://reviews.llvm.org/D50027 Added: lldb/trunk/unittests/Utility/StreamTest.cpp Modified: lldb/trunk/unittests/Utility/CMakeLists.txt Modified: lldb/trunk/unittests/Utility/CMakeLists.txt URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/unittests/Utility/CMakeLists.txt?rev=338488&r1=338487&r2=338488&view=diff == --- lldb/trunk/unittests/Utility/CMakeLists.txt (original) +++ lldb/trunk/unittests/Utility/CMakeLists.txt Tue Jul 31 23:04:48 2018 @@ -14,6 +14,7 @@ add_lldb_unittest(UtilityTests NameMatchesTest.cpp StatusTest.cpp StreamTeeTest.cpp + StreamTest.cpp StringExtractorTest.cpp StructuredDataTest.cpp TildeExpressionResolverTest.cpp Added: lldb/trunk/unittests/Utility/StreamTest.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/unittests/Utility/StreamTest.cpp?rev=338488&view=auto == --- lldb/trunk/unittests/Utility/StreamTest.cpp (added) +++ lldb/trunk/unittests/Utility/StreamTest.cpp Tue Jul 31 23:04:48 2018 @@ -0,0 +1,480 @@ +//===-- StreamTest.cpp --*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===--===// + +#include "lldb/Utility/StreamString.h" +#include "gtest/gtest.h" + +using namespace lldb_private; + +namespace { +struct StreamTest : ::testing::Test { + // Note: Stream is an abstract class, so we use StreamString to test it. To + // make it easier to change this later, only methods in this class explicitly + // refer to the StringStream class. + StreamString s; + // We return here a std::string because that way gtest can print better + // assertion messages. + std::string TakeValue() { +std::string result = s.GetString().str(); +s.Clear(); +return result; + } +}; +} + +namespace { +// A StreamTest where we expect the Stream output to be binary. +struct BinaryStreamTest : StreamTest { + void SetUp() override { +s.GetFlags().Set(Stream::eBinary); + } +}; +} + +TEST_F(StreamTest, ChangingByteOrder) { + s.SetByteOrder(lldb::eByteOrderPDP); + EXPECT_EQ(lldb::eByteOrderPDP, s.GetByteOrder()); +} + +TEST_F(StreamTest, PutChar) { + s.PutChar('a'); + EXPECT_EQ("a", TakeValue()); + + s.PutChar('1'); + EXPECT_EQ("1", TakeValue()); +} + +TEST_F(StreamTest, PutCharWhitespace) { + s.PutChar(' '); + EXPECT_EQ(" ", TakeValue()); + + s.PutChar('\n'); + EXPECT_EQ("\n", TakeValue()); + + s.PutChar('\r'); + EXPECT_EQ("\r", TakeValue()); + + s.PutChar('\t'); + EXPECT_EQ("\t", TakeValue()); +} + +TEST_F(StreamTest, PutCString) { + s.PutCString(""); + EXPECT_EQ("", TakeValue()); + + s.PutCString("foobar"); + EXPECT_EQ("foobar", TakeValue()); + + s.PutCString(" "); + EXPECT_EQ(" ", TakeValue()); +} + +TEST_F(StreamTest, PutCStringWithStringRef) { + s.PutCString(llvm::StringRef("")); + EXPECT_EQ("", TakeValue()); + + s.PutCString(llvm::StringRef("foobar")); + EXPECT_EQ("foobar", TakeValue()); + + s.PutCString(llvm::StringRef(" ")); + EXPECT_EQ(" ", TakeValue()); +} + +TEST_F(StreamTest, QuotedCString) { + s.QuotedCString("foo"); + EXPECT_EQ(R"("foo")", TakeValue()); + + s.QuotedCString("ba r"); + EXPECT_EQ(R"("ba r")", TakeValue()); + + s.QuotedCString(" "); + EXPECT_EQ(R"(" ")", TakeValue()); +} + +TEST_F(StreamTest, PutCharNull) { + s.PutChar('\0'); + EXPECT_EQ(std::string("\0", 1), TakeValue()); + + s.PutChar('a'); + EXPECT_EQ(std::string("a", 1), TakeValue()); +} + +TEST_F(StreamTest, PutCStringAsRawHex8) { + s.PutCStringAsRawHex8(""); + // FIXME: Check that printing 00 on an empty string is the intended behavior. + // It seems kind of unexpected that we print the trailing 0 byte for empty + // strings, but not for non-empty strings. + EXPECT_EQ("00", TakeValue()); + + s.PutCStringAsRawHex8("foobar"); + EXPECT_EQ("666f6f626172", TakeValue()); + + s.PutCStringAsRawHex8(" "); + EXPECT_EQ("20", TakeValue()); +} + +TEST_F(StreamTest, PutHex8) { + s.PutHex8
[Lldb-commits] [lldb] r338491 - Removed failing StreamTest case
Author: teemperor Date: Tue Jul 31 23:35:27 2018 New Revision: 338491 URL: http://llvm.org/viewvc/llvm-project?rev=338491&view=rev Log: Removed failing StreamTest case The suspicious behavior is obviously because this method reads OOB memory, so I'll remove it for now and re-add the test alongside the fix later. Modified: lldb/trunk/unittests/Utility/StreamTest.cpp Modified: lldb/trunk/unittests/Utility/StreamTest.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/unittests/Utility/StreamTest.cpp?rev=338491&r1=338490&r2=338491&view=diff == --- lldb/trunk/unittests/Utility/StreamTest.cpp (original) +++ lldb/trunk/unittests/Utility/StreamTest.cpp Tue Jul 31 23:35:27 2018 @@ -106,12 +106,6 @@ TEST_F(StreamTest, PutCharNull) { } TEST_F(StreamTest, PutCStringAsRawHex8) { - s.PutCStringAsRawHex8(""); - // FIXME: Check that printing 00 on an empty string is the intended behavior. - // It seems kind of unexpected that we print the trailing 0 byte for empty - // strings, but not for non-empty strings. - EXPECT_EQ("00", TakeValue()); - s.PutCStringAsRawHex8("foobar"); EXPECT_EQ("666f6f626172", TakeValue()); ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] r338591 - Don't ignore byte_order in Stream::PutMaxHex64
Author: teemperor Date: Wed Aug 1 10:12:58 2018 New Revision: 338591 URL: http://llvm.org/viewvc/llvm-project?rev=338591&view=rev Log: Don't ignore byte_order in Stream::PutMaxHex64 Reviewers: labath Reviewed By: labath Subscribers: zturner, lldb-commits Differential Revision: https://reviews.llvm.org/D50025 Modified: lldb/trunk/source/Utility/Stream.cpp lldb/trunk/unittests/Utility/StreamTest.cpp Modified: lldb/trunk/source/Utility/Stream.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Utility/Stream.cpp?rev=338591&r1=338590&r2=338591&view=diff == --- lldb/trunk/source/Utility/Stream.cpp (original) +++ lldb/trunk/source/Utility/Stream.cpp Wed Aug 1 10:12:58 2018 @@ -427,11 +427,11 @@ size_t Stream::PutMaxHex64(uint64_t uval case 1: return PutHex8((uint8_t)uvalue); case 2: -return PutHex16((uint16_t)uvalue); +return PutHex16((uint16_t)uvalue, byte_order); case 4: -return PutHex32((uint32_t)uvalue); +return PutHex32((uint32_t)uvalue, byte_order); case 8: -return PutHex64(uvalue); +return PutHex64(uvalue, byte_order); } return 0; } Modified: lldb/trunk/unittests/Utility/StreamTest.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/unittests/Utility/StreamTest.cpp?rev=338591&r1=338590&r2=338591&view=diff == --- lldb/trunk/unittests/Utility/StreamTest.cpp (original) +++ lldb/trunk/unittests/Utility/StreamTest.cpp Wed Aug 1 10:12:58 2018 @@ -187,6 +187,32 @@ TEST_F(StreamTest, PutHex64ByteOrderBig) EXPECT_EQ("", TakeValue()); } +TEST_F(StreamTest, PutMaxHex64ByteOrderBig) { + std::size_t bytes; + bytes = s.PutMaxHex64(0x12U, 1, lldb::eByteOrderBig); + EXPECT_EQ(2U, bytes); + bytes = s.PutMaxHex64(0x1234U, 2, lldb::eByteOrderBig); + EXPECT_EQ(4U, bytes); + bytes = s.PutMaxHex64(0x12345678U, 4, lldb::eByteOrderBig); + EXPECT_EQ(8U, bytes); + bytes = s.PutMaxHex64(0x1234567890ABCDEFU, 8, lldb::eByteOrderBig); + EXPECT_EQ(16U, bytes); + EXPECT_EQ("121234123456781234567890abcdef", TakeValue()); +} + +TEST_F(StreamTest, PutMaxHex64ByteOrderLittle) { + std::size_t bytes; + bytes = s.PutMaxHex64(0x12U, 1, lldb::eByteOrderLittle); + EXPECT_EQ(2U, bytes); + bytes = s.PutMaxHex64(0x1234U, 2, lldb::eByteOrderLittle); + EXPECT_EQ(4U, bytes); + bytes = s.PutMaxHex64(0x12345678U, 4, lldb::eByteOrderLittle); + EXPECT_EQ(8U, bytes); + bytes = s.PutMaxHex64(0x1234567890ABCDEFU, 8, lldb::eByteOrderLittle); + EXPECT_EQ(16U, bytes); + EXPECT_EQ("12341278563412efcdab9078563412", TakeValue()); +} + //-- // Shift operator tests. //-- ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] r338605 - Remove outdated documentation for Stream's LEB128 methods
Author: teemperor Date: Wed Aug 1 11:28:54 2018 New Revision: 338605 URL: http://llvm.org/viewvc/llvm-project?rev=338605&view=rev Log: Remove outdated documentation for Stream's LEB128 methods There is no format parameter for any of these methods. Modified: lldb/trunk/include/lldb/Utility/Stream.h Modified: lldb/trunk/include/lldb/Utility/Stream.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Utility/Stream.h?rev=338605&r1=338604&r2=338605&view=diff == --- lldb/trunk/include/lldb/Utility/Stream.h (original) +++ lldb/trunk/include/lldb/Utility/Stream.h Wed Aug 1 11:28:54 2018 @@ -504,9 +504,6 @@ public: /// /// @param[in] uval /// A uint64_t value that was extracted as a SLEB128 value. - /// - /// @param[in] format - /// The optional printf format that can be overridden. //-- size_t PutSLEB128(int64_t uval); @@ -518,9 +515,6 @@ public: /// /// @param[in] uval /// A uint64_t value that was extracted as a ULEB128 value. - /// - /// @param[in] format - /// The optional printf format that can be overridden. //-- size_t PutULEB128(uint64_t uval); ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] r338611 - Fixed documentation for PutHex8 [NFC]
Author: teemperor Date: Wed Aug 1 11:38:19 2018 New Revision: 338611 URL: http://llvm.org/viewvc/llvm-project?rev=338611&view=rev Log: Fixed documentation for PutHex8 [NFC] The previous documentation was just copied from PrintfAsRawHex8 but doesn't actually fit to the PutHex8 method. Modified: lldb/trunk/include/lldb/Utility/Stream.h Modified: lldb/trunk/include/lldb/Utility/Stream.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Utility/Stream.h?rev=338611&r1=338610&r2=338611&view=diff == --- lldb/trunk/include/lldb/Utility/Stream.h (original) +++ lldb/trunk/include/lldb/Utility/Stream.h Wed Aug 1 11:38:19 2018 @@ -121,14 +121,10 @@ public: __attribute__((__format__(__printf__, 2, 3))); //-- - /// Format a C string from a printf style format and variable arguments and - /// encode and append the resulting C string as hex bytes. + /// Append an uint8_t value in the hexadecimal format to the stream. /// - /// @param[in] format - /// A printf style format string. - /// - /// @param[in] ... - /// Any additional arguments needed for the printf format string. + /// @param[in] uvalue + /// The value to append. /// /// @return /// The number of bytes that were appended to the stream. ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] r338637 - Fix out-of-bounds read in Stream::PutCStringAsRawHex8
Author: teemperor Date: Wed Aug 1 14:07:18 2018 New Revision: 338637 URL: http://llvm.org/viewvc/llvm-project?rev=338637&view=rev Log: Fix out-of-bounds read in Stream::PutCStringAsRawHex8 Summary: When I added the Stream unit test (r338488), the build bots failed due to an out-of- bound reads when passing an empty string to the PutCStringAsRawHex8 method. In r338491 I removed the test case to fix the bots. This patch fixes this in PutCStringAsRawHex8 by always checking for the terminating null character in the given string (instead of skipping it the first time). It also re-adds the test case I removed. Reviewers: vsk Reviewed By: vsk Subscribers: vsk, lldb-commits Differential Revision: https://reviews.llvm.org/D50149 Modified: lldb/trunk/source/Utility/Stream.cpp lldb/trunk/unittests/Utility/StreamTest.cpp Modified: lldb/trunk/source/Utility/Stream.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Utility/Stream.cpp?rev=338637&r1=338636&r2=338637&view=diff == --- lldb/trunk/source/Utility/Stream.cpp (original) +++ lldb/trunk/source/Utility/Stream.cpp Wed Aug 1 14:07:18 2018 @@ -518,10 +518,10 @@ size_t Stream::PutCStringAsRawHex8(const size_t bytes_written = 0; bool binary_is_set = m_flags.Test(eBinary); m_flags.Clear(eBinary); - do { + while(*s) { bytes_written += _PutHex8(*s, false); ++s; - } while (*s); + } if (binary_is_set) m_flags.Set(eBinary); return bytes_written; Modified: lldb/trunk/unittests/Utility/StreamTest.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/unittests/Utility/StreamTest.cpp?rev=338637&r1=338636&r2=338637&view=diff == --- lldb/trunk/unittests/Utility/StreamTest.cpp (original) +++ lldb/trunk/unittests/Utility/StreamTest.cpp Wed Aug 1 14:07:18 2018 @@ -106,6 +106,9 @@ TEST_F(StreamTest, PutCharNull) { } TEST_F(StreamTest, PutCStringAsRawHex8) { + s.PutCStringAsRawHex8(""); + EXPECT_EQ("", TakeValue()); + s.PutCStringAsRawHex8("foobar"); EXPECT_EQ("666f6f626172", TakeValue()); ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] r338657 - Remove unnecessary target from TestCompletion patch
Author: teemperor Date: Wed Aug 1 16:54:37 2018 New Revision: 338657 URL: http://llvm.org/viewvc/llvm-project?rev=338657&view=rev Log: Remove unnecessary target from TestCompletion patch As Jim pointed out, we don't need to manually create a target here because we already create a target implicitly in the very next line (which means we just created a target and don't use it). This patch just removes the line that creates the first unused target. Modified: lldb/trunk/packages/Python/lldbsuite/test/functionalities/completion/TestCompletion.py Modified: lldb/trunk/packages/Python/lldbsuite/test/functionalities/completion/TestCompletion.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/functionalities/completion/TestCompletion.py?rev=338657&r1=338656&r2=338657&view=diff == --- lldb/trunk/packages/Python/lldbsuite/test/functionalities/completion/TestCompletion.py (original) +++ lldb/trunk/packages/Python/lldbsuite/test/functionalities/completion/TestCompletion.py Wed Aug 1 16:54:37 2018 @@ -43,7 +43,6 @@ class CommandLineCompletionTestCase(Test self.build() self.main_source = "main.cpp" self.main_source_spec = lldb.SBFileSpec(self.main_source) -self.dbg.CreateTarget(self.getBuildArtifact("a.out")) (target, process, thread, bkpt) = lldbutil.run_to_source_breakpoint(self, '// Break here', self.main_source_spec) ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] r338662 - [LLDB] Added syntax highlighting support
Author: teemperor Date: Wed Aug 1 17:30:15 2018 New Revision: 338662 URL: http://llvm.org/viewvc/llvm-project?rev=338662&view=rev Log: [LLDB] Added syntax highlighting support Summary: This patch adds syntax highlighting support to LLDB. When enabled (and lldb is allowed to use colors), printed source code is annotated with the ANSI color escape sequences. So far we have only one highlighter which is based on Clang and is responsible for all languages that are supported by Clang. It essentially just runs the raw lexer over the input and then surrounds the specific tokens with the configured escape sequences. Reviewers: zturner, davide Reviewed By: davide Subscribers: labath, teemperor, llvm-commits, mgorny, lldb-commits Tags: #lldb Differential Revision: https://reviews.llvm.org/D49334 Added: lldb/trunk/include/lldb/Core/Highlighter.h lldb/trunk/source/Core/Highlighter.cpp lldb/trunk/source/Plugins/Language/ClangCommon/ lldb/trunk/source/Plugins/Language/ClangCommon/CMakeLists.txt lldb/trunk/source/Plugins/Language/ClangCommon/ClangHighlighter.cpp lldb/trunk/source/Plugins/Language/ClangCommon/ClangHighlighter.h lldb/trunk/unittests/Language/Highlighting/ lldb/trunk/unittests/Language/Highlighting/CMakeLists.txt lldb/trunk/unittests/Language/Highlighting/HighlighterTest.cpp Modified: lldb/trunk/include/lldb/Core/Debugger.h lldb/trunk/include/lldb/Target/Language.h lldb/trunk/packages/Python/lldbsuite/test/source-manager/TestSourceManager.py lldb/trunk/source/Core/CMakeLists.txt lldb/trunk/source/Core/Debugger.cpp lldb/trunk/source/Core/SourceManager.cpp lldb/trunk/source/Plugins/Language/CMakeLists.txt lldb/trunk/source/Plugins/Language/CPlusPlus/CMakeLists.txt lldb/trunk/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp lldb/trunk/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.h lldb/trunk/source/Plugins/Language/Go/GoLanguage.cpp lldb/trunk/source/Plugins/Language/Go/GoLanguage.h lldb/trunk/source/Plugins/Language/Java/JavaLanguage.cpp lldb/trunk/source/Plugins/Language/Java/JavaLanguage.h lldb/trunk/source/Plugins/Language/OCaml/OCamlLanguage.cpp lldb/trunk/source/Plugins/Language/OCaml/OCamlLanguage.h lldb/trunk/source/Plugins/Language/ObjC/CMakeLists.txt lldb/trunk/source/Plugins/Language/ObjC/ObjCLanguage.cpp lldb/trunk/source/Plugins/Language/ObjC/ObjCLanguage.h lldb/trunk/source/Plugins/Language/ObjCPlusPlus/CMakeLists.txt lldb/trunk/source/Plugins/Language/ObjCPlusPlus/ObjCPlusPlusLanguage.cpp lldb/trunk/source/Plugins/Language/ObjCPlusPlus/ObjCPlusPlusLanguage.h lldb/trunk/source/Target/Language.cpp lldb/trunk/unittests/Language/CMakeLists.txt Modified: lldb/trunk/include/lldb/Core/Debugger.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/Debugger.h?rev=338662&r1=338661&r2=338662&view=diff == --- lldb/trunk/include/lldb/Core/Debugger.h (original) +++ lldb/trunk/include/lldb/Core/Debugger.h Wed Aug 1 17:30:15 2018 @@ -272,6 +272,8 @@ public: bool SetUseColor(bool use_color); + bool GetHighlightSource() const; + lldb::StopShowColumn GetStopShowColumn() const; const FormatEntity::Entry *GetStopShowColumnAnsiPrefix() const; Added: lldb/trunk/include/lldb/Core/Highlighter.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/Highlighter.h?rev=338662&view=auto == --- lldb/trunk/include/lldb/Core/Highlighter.h (added) +++ lldb/trunk/include/lldb/Core/Highlighter.h Wed Aug 1 17:30:15 2018 @@ -0,0 +1,159 @@ +//===-- Highlighter.h ---*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===--===// + +#ifndef liblldb_Highlighter_h_ +#define liblldb_Highlighter_h_ + +#include +#include + +#include "lldb/Utility/Stream.h" +#include "lldb/lldb-enumerations.h" +#include "llvm/ADT/StringRef.h" + +namespace lldb_private { + +//-- +/// Represents style that the highlighter should apply to the given source code. +/// Stores information about how every kind of token should be annotated. +//-- +struct HighlightStyle { + + //-- + /// A pair of strings that should be placed around a certain token. Usually + /// stores color codes in these strings (the suffix string is often used for + /// resetting the terminal attributes back to normal). + //-
[Lldb-commits] [lldb] r338669 - Added missing highlighter files to XCode project
Author: teemperor Date: Wed Aug 1 20:01:09 2018 New Revision: 338669 URL: http://llvm.org/viewvc/llvm-project?rev=338669&view=rev Log: Added missing highlighter files to XCode project Modified: lldb/trunk/lldb.xcodeproj/project.pbxproj Modified: lldb/trunk/lldb.xcodeproj/project.pbxproj URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/lldb.xcodeproj/project.pbxproj?rev=338669&r1=338668&r2=338669&view=diff == --- lldb/trunk/lldb.xcodeproj/project.pbxproj (original) +++ lldb/trunk/lldb.xcodeproj/project.pbxproj Wed Aug 1 20:01:09 2018 @@ -158,6 +158,8 @@ 268900D313353E6F00698AC0 /* ClangExternalASTSourceCallbacks.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26E69030129C6BEF00DDECD9 /* ClangExternalASTSourceCallbacks.cpp */; }; 4966DCC4148978A10028481B /* ClangExternalASTSourceCommon.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4966DCC3148978A10028481B /* ClangExternalASTSourceCommon.cpp */; }; 2689005F13353E0E00698AC0 /* ClangFunctionCaller.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4C98D3DA118FB96F00E575D0 /* ClangFunctionCaller.cpp */; }; + 58A080AC2112AABB00D5580F /* ClangHighlighter.cpp in CopyFiles */ = {isa = PBXBuildFile; fileRef = 58A080AB2112AABB00D5580F /* ClangHighlighter.cpp */; }; + 58A080AE2112AAC500D5580F /* ClangHighlighter.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = 58A080AD2112AAC500D5580F /* ClangHighlighter.h */; }; 4CD44D5820C603CB0003557C /* ClangHost.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4CD44D5620C603A80003557C /* ClangHost.cpp */; }; 4959511F1A1BC4BC00F6F8FC /* ClangModulesDeclVendor.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4959511E1A1BC4BC00F6F8FC /* ClangModulesDeclVendor.cpp */; }; 2689006313353E0E00698AC0 /* ClangPersistentVariables.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 49D4FE871210B61C00CDB854 /* ClangPersistentVariables.cpp */; }; @@ -336,6 +338,8 @@ AE44FB301BB07EB20033EB62 /* GoUserExpression.cpp in Sources */ = {isa = PBXBuildFile; fileRef = AE44FB2C1BB07DD80033EB62 /* GoUserExpression.cpp */; }; 6D95DC011B9DC057000E318A /* HashedNameToDIE.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 6D95DBFE1B9DC057000E318A /* HashedNameToDIE.cpp */; }; 2666ADC81B3CB675001FAFD3 /* HexagonDYLDRendezvous.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2666ADC31B3CB675001FAFD3 /* HexagonDYLDRendezvous.cpp */; }; + 58A080B42112AB3800D5580F /* Highlighter.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 58A080A92112AA9400D5580F /* Highlighter.cpp */; }; + 58A080B32112AB2900D5580F /* HighlighterTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 58A080B12112AB2200D5580F /* HighlighterTest.cpp */; }; AF1729D6182C907200E0AB97 /* HistoryThread.cpp in Sources */ = {isa = PBXBuildFile; fileRef = AF1729D4182C907200E0AB97 /* HistoryThread.cpp */; }; AF1729D7182C907200E0AB97 /* HistoryUnwind.cpp in Sources */ = {isa = PBXBuildFile; fileRef = AF1729D5182C907200E0AB97 /* HistoryUnwind.cpp */; }; 2689007113353E1A00698AC0 /* Host.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 69A01E1C1236C5D400C660B5 /* Host.cpp */; }; @@ -1279,6 +1283,8 @@ dstPath = "$(DEVELOPER_INSTALL_DIR)/usr/share/man/man1"; dstSubfolderSpec = 0; files = ( + 58A080AE2112AAC500D5580F /* ClangHighlighter.h in CopyFiles */, + 58A080AC2112AABB00D5580F /* ClangHighlighter.cpp in CopyFiles */, AF90106515AB7D3600FF120D /* lldb.1 in CopyFiles */, ); runOnlyForDeploymentPostprocessing = 1; @@ -1518,6 +1524,8 @@ 26BC7D5510F1B77400F91463 /* ClangForward.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ClangForward.h; path = include/lldb/Core/ClangForward.h; sourceTree = ""; }; 4C98D3DA118FB96F00E575D0 /* ClangFunctionCaller.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ClangFunctionCaller.cpp; path = ExpressionParser/Clang/ClangFunctionCaller.cpp; sourceTree = ""; }; 4C98D3E0118FB98F00E575D0 /* ClangFunctionCaller.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ClangFunctionCaller.h; path = ExpressionParser/Clang/ClangFunctionCaller.h; sourceTree = ""; }; + 58A080AB2112AABB00D5580F /* ClangHighlighter.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ClangHighlighter.cpp; path = Language/ClangCommon/ClangHighlighter.cpp; sourceTree = ""
[Lldb-commits] [lldb] r338733 - Add byte counting mechanism to LLDB's Stream class.
Author: teemperor Date: Thu Aug 2 09:38:34 2018 New Revision: 338733 URL: http://llvm.org/viewvc/llvm-project?rev=338733&view=rev Log: Add byte counting mechanism to LLDB's Stream class. Summary: This patch allows LLDB's Stream class to count the bytes it has written to so far. There are two major motivations for this patch: The first one is that this will allow us to get rid of all the handwritten byte counting code we have in LLDB so far. Examples for this are pretty much all functions in LLDB that take a Stream to write to and return a size_t, which usually represents the bytes written. By moving to this centralized byte counting mechanism, we hopefully can avoid some tricky errors that happen when some code forgets to count the written bytes while writing something to a stream. The second motivation is that this is needed for the migration away from LLDB's `Stream` and towards LLVM's `raw_ostream`. My current plan is to start offering a fake raw_ostream class that just forwards to a LLDB Stream. However, for this raw_ostream wrapper we need to fulfill the raw_ostream interface with LLDB's Stream, which currently lacks the ability to count the bytes written so far (which raw_ostream exposes by it's `tell()` method). By adding this functionality it is trivial to start rolling out our raw_ostream wrapper (and then eventually completely move to raw_ostream). Also, once this fake raw_ostream is available, we can start replacing our own code writing to LLDB's Stream by LLVM code writing to raw_ostream. The best example for this is the LEB128 encoding we currently ship, which can be replaced with by LLVM's version which accepts an raw_ostream. From the point of view of the pure source changes this test does, we essentially just renamed the Write implementation in Stream to `WriteImpl` while the `Write` method everyone is using to write its raw bytes is now just forwarding and counting the written bytes. Reviewers: labath, davide Reviewed By: labath Subscribers: JDevlieghere, lldb-commits Differential Revision: https://reviews.llvm.org/D50159 Modified: lldb/trunk/include/lldb/Core/StreamAsynchronousIO.h lldb/trunk/include/lldb/Core/StreamBuffer.h lldb/trunk/include/lldb/Core/StreamFile.h lldb/trunk/include/lldb/Utility/Stream.h lldb/trunk/include/lldb/Utility/StreamString.h lldb/trunk/include/lldb/Utility/StreamTee.h lldb/trunk/source/Core/StreamAsynchronousIO.cpp lldb/trunk/source/Core/StreamFile.cpp lldb/trunk/source/Utility/StreamString.cpp lldb/trunk/unittests/Utility/StreamTeeTest.cpp lldb/trunk/unittests/Utility/StreamTest.cpp Modified: lldb/trunk/include/lldb/Core/StreamAsynchronousIO.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/StreamAsynchronousIO.h?rev=338733&r1=338732&r2=338733&view=diff == --- lldb/trunk/include/lldb/Core/StreamAsynchronousIO.h (original) +++ lldb/trunk/include/lldb/Core/StreamAsynchronousIO.h Thu Aug 2 09:38:34 2018 @@ -30,7 +30,8 @@ public: void Flush() override; - size_t Write(const void *src, size_t src_len) override; +protected: + size_t WriteImpl(const void *src, size_t src_len) override; private: Debugger &m_debugger; Modified: lldb/trunk/include/lldb/Core/StreamBuffer.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/StreamBuffer.h?rev=338733&r1=338732&r2=338733&view=diff == --- lldb/trunk/include/lldb/Core/StreamBuffer.h (original) +++ lldb/trunk/include/lldb/Core/StreamBuffer.h Thu Aug 2 09:38:34 2018 @@ -30,12 +30,6 @@ public: // Nothing to do when flushing a buffer based stream... } - virtual size_t Write(const void *s, size_t length) { -if (s && length) - m_packet.append((const char *)s, ((const char *)s) + length); -return length; - } - void Clear() { m_packet.clear(); } // Beware, this might not be NULL terminated as you can expect from @@ -48,6 +42,12 @@ public: protected: llvm::SmallVector m_packet; + + virtual size_t WriteImpl(const void *s, size_t length) { +if (s && length) + m_packet.append((const char *)s, ((const char *)s) + length); +return length; + } }; } // namespace lldb_private Modified: lldb/trunk/include/lldb/Core/StreamFile.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/StreamFile.h?rev=338733&r1=338732&r2=338733&view=diff == --- lldb/trunk/include/lldb/Core/StreamFile.h (original) +++ lldb/trunk/include/lldb/Core/StreamFile.h Thu Aug 2 09:38:34 2018 @@ -46,13 +46,13 @@ public: void Flush() override; - size_t Write(const void *s, size_t length) override; protected: //-- // Classes that inherit from StreamFile can see an
[Lldb-commits] [lldb] r338901 - Add raw_ostream wrapper to the Stream class
Author: teemperor Date: Fri Aug 3 09:56:33 2018 New Revision: 338901 URL: http://llvm.org/viewvc/llvm-project?rev=338901&view=rev Log: Add raw_ostream wrapper to the Stream class Summary: This wrapper will allow us in the future to reuse LLVM methods from within the Stream class. Currently no test as this is intended to be an internal class that shouldn't have any NFC. The test for this change will be the follow up patch that migrates LLDB's LEB128 implementation to the one from LLVM. This change also adds custom move/assignment methods to Stream, as LLVM raw_ostream doesn't support these. As our internal stream has anyway no state, we can just keep the same stream object around. Reviewers: davide, labath Reviewed By: labath Subscribers: xiaobai, labath, lldb-commits Differential Revision: https://reviews.llvm.org/D50161 Modified: lldb/trunk/include/lldb/Utility/Stream.h lldb/trunk/source/Utility/Stream.cpp Modified: lldb/trunk/include/lldb/Utility/Stream.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Utility/Stream.h?rev=338901&r1=338900&r2=338901&view=diff == --- lldb/trunk/include/lldb/Utility/Stream.h (original) +++ lldb/trunk/include/lldb/Utility/Stream.h Fri Aug 3 09:56:33 2018 @@ -15,6 +15,7 @@ #include "lldb/lldb-enumerations.h" // for ByteOrder::eByteOrderInvalid #include "llvm/ADT/StringRef.h" // for StringRef #include "llvm/Support/FormatVariadic.h" +#include "llvm/Support/raw_ostream.h" #include #include // for size_t @@ -52,6 +53,17 @@ public: //-- Stream(); + // FIXME: Streams should not be copyable. + Stream(const Stream &other) : m_forwarder(*this) { (*this) = other; } + + Stream &operator=(const Stream &rhs) { +m_flags = rhs.m_flags; +m_addr_size = rhs.m_addr_size; +m_byte_order = rhs.m_byte_order; +m_indent_level = rhs.m_indent_level; +return *this; + } + //-- /// Destructor //-- @@ -520,6 +532,13 @@ public: //-- size_t PutULEB128(uint64_t uval); + //-- + /// Returns a raw_ostream that forwards the data to this Stream object. + //-- + llvm::raw_ostream &AsRawOstream() { +return m_forwarder; + } + protected: //-- // Member variables @@ -548,6 +567,34 @@ protected: /// The number of bytes that were appended to the stream. //-- virtual size_t WriteImpl(const void *src, size_t src_len) = 0; + + //-- + /// @class RawOstreamForward Stream.h "lldb/Utility/Stream.h" + /// This is a wrapper class that exposes a raw_ostream interface that just + /// forwards to an LLDB stream, allowing to reuse LLVM algorithms that take + /// a raw_ostream within the LLDB code base. + //-- + class RawOstreamForward : public llvm::raw_ostream { +// Note: This stream must *not* maintain its own buffer, but instead +// directly write everything to the internal Stream class. Without this, +// we would run into the problem that the Stream written byte count would +// differ from the actually written bytes by the size of the internal +// raw_ostream buffer. + +Stream &m_target; +void write_impl(const char *Ptr, size_t Size) override { + m_target.Write(Ptr, Size); +} + +uint64_t current_pos() const override { + return m_target.GetWrittenBytes(); +} + + public: +RawOstreamForward(Stream &target) +: llvm::raw_ostream(/*unbuffered*/ true), m_target(target) {} + }; + RawOstreamForward m_forwarder; }; } // namespace lldb_private Modified: lldb/trunk/source/Utility/Stream.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Utility/Stream.cpp?rev=338901&r1=338900&r2=338901&view=diff == --- lldb/trunk/source/Utility/Stream.cpp (original) +++ lldb/trunk/source/Utility/Stream.cpp Fri Aug 3 09:56:33 2018 @@ -23,11 +23,11 @@ using namespace lldb_private; Stream::Stream(uint32_t flags, uint32_t addr_size, ByteOrder byte_order) : m_flags(flags), m_addr_size(addr_size), m_byte_order(byte_order), - m_indent_level(0) {} + m_indent_level(0), m_forwarder(*this) {} Stream::Stream() : m_flags(0), m_addr_size(4), m_byte_order(endian::InlHostByteOrder()), - m_indent_level(0) {} + m_indent_level(0), m_fo
[Lldb-commits] [lldb] r338920 - Replace LLDB's LEB128 implementation with the one from LLVM
Author: teemperor Date: Fri Aug 3 13:51:31 2018 New Revision: 338920 URL: http://llvm.org/viewvc/llvm-project?rev=338920&view=rev Log: Replace LLDB's LEB128 implementation with the one from LLVM Reviewers: davide, labath Reviewed By: labath Subscribers: lldb-commits Differential Revision: https://reviews.llvm.org/D50162 Modified: lldb/trunk/source/Utility/Stream.cpp Modified: lldb/trunk/source/Utility/Stream.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Utility/Stream.cpp?rev=338920&r1=338919&r2=338920&view=diff == --- lldb/trunk/source/Utility/Stream.cpp (original) +++ lldb/trunk/source/Utility/Stream.cpp Fri Aug 3 13:51:31 2018 @@ -12,6 +12,7 @@ #include "lldb/Utility/Endian.h" #include "lldb/Utility/VASPrintf.h" #include "llvm/ADT/SmallString.h" // for SmallString +#include "llvm/Support/LEB128.h" #include @@ -49,47 +50,20 @@ void Stream::Offset(uint32_t uval, const // Put an SLEB128 "uval" out to the stream using the printf format in "format". //-- size_t Stream::PutSLEB128(int64_t sval) { - size_t bytes_written = 0; - if (m_flags.Test(eBinary)) { -bool more = true; -while (more) { - uint8_t byte = sval & 0x7fu; - sval >>= 7; - /* sign bit of byte is 2nd high order bit (0x40) */ - if ((sval == 0 && !(byte & 0x40)) || (sval == -1 && (byte & 0x40))) -more = false; - else -// more bytes to come -byte |= 0x80u; - bytes_written += Write(&byte, 1); -} - } else { -bytes_written = Printf("0x%" PRIi64, sval); - } - - return bytes_written; + if (m_flags.Test(eBinary)) +return llvm::encodeSLEB128(sval, m_forwarder); + else +return Printf("0x%" PRIi64, sval); } //-- // Put an ULEB128 "uval" out to the stream using the printf format in "format". //-- size_t Stream::PutULEB128(uint64_t uval) { - size_t bytes_written = 0; - if (m_flags.Test(eBinary)) { -do { - - uint8_t byte = uval & 0x7fu; - uval >>= 7; - if (uval != 0) { -// more bytes to come -byte |= 0x80u; - } - bytes_written += Write(&byte, 1); -} while (uval != 0); - } else { -bytes_written = Printf("0x%" PRIx64, uval); - } - return bytes_written; + if (m_flags.Test(eBinary)) +return llvm::encodeULEB128(uval, m_forwarder); + else +return Printf("0x%" PRIx64, uval); } //-- ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] r338952 - Fixed header of StringLexer.h
Author: teemperor Date: Fri Aug 3 22:53:07 2018 New Revision: 338952 URL: http://llvm.org/viewvc/llvm-project?rev=338952&view=rev Log: Fixed header of StringLexer.h Modified: lldb/trunk/include/lldb/Utility/StringLexer.h Modified: lldb/trunk/include/lldb/Utility/StringLexer.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Utility/StringLexer.h?rev=338952&r1=338951&r2=338952&view=diff == --- lldb/trunk/include/lldb/Utility/StringLexer.h (original) +++ lldb/trunk/include/lldb/Utility/StringLexer.h Fri Aug 3 22:53:07 2018 @@ -1,5 +1,4 @@ -//===- StringLexer.h -*- C++ -//-*-===// +//===- StringLexer.h *- C++ -*-===// // // The LLVM Compiler Infrastructure // ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] r338961 - Added unit test for StringList
Author: teemperor Date: Sat Aug 4 10:28:21 2018 New Revision: 338961 URL: http://llvm.org/viewvc/llvm-project?rev=338961&view=rev Log: Added unit test for StringList Reviewers: labath Reviewed By: labath Subscribers: mgorny, lldb-commits Differential Revision: https://reviews.llvm.org/D50293 Added: lldb/trunk/unittests/Utility/StringListTest.cpp Modified: lldb/trunk/unittests/Utility/CMakeLists.txt Modified: lldb/trunk/unittests/Utility/CMakeLists.txt URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/unittests/Utility/CMakeLists.txt?rev=338961&r1=338960&r2=338961&view=diff == --- lldb/trunk/unittests/Utility/CMakeLists.txt (original) +++ lldb/trunk/unittests/Utility/CMakeLists.txt Sat Aug 4 10:28:21 2018 @@ -16,6 +16,7 @@ add_lldb_unittest(UtilityTests StreamTeeTest.cpp StreamTest.cpp StringExtractorTest.cpp + StringListTest.cpp StructuredDataTest.cpp TildeExpressionResolverTest.cpp TimeoutTest.cpp Added: lldb/trunk/unittests/Utility/StringListTest.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/unittests/Utility/StringListTest.cpp?rev=338961&view=auto == --- lldb/trunk/unittests/Utility/StringListTest.cpp (added) +++ lldb/trunk/unittests/Utility/StringListTest.cpp Sat Aug 4 10:28:21 2018 @@ -0,0 +1,512 @@ +//===-- StringListTest.cpp ---*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===--===// + +#include "lldb/Utility/StringList.h" +#include "lldb/Utility/StreamString.h" +#include "gtest/gtest.h" + +using namespace lldb_private; + +TEST(StringListTest, DefaultConstructor) { + StringList s; + EXPECT_EQ(0U, s.GetSize()); +} + +TEST(StringListTest, Assignment) { + StringList orig; + orig.AppendString("foo"); + orig.AppendString("bar"); + + StringList s = orig; + + ASSERT_EQ(2U, s.GetSize()); + EXPECT_STREQ("foo", s.GetStringAtIndex(0)); + EXPECT_STREQ("bar", s.GetStringAtIndex(1)); + + ASSERT_EQ(2U, orig.GetSize()); + EXPECT_STREQ("foo", orig.GetStringAtIndex(0)); + EXPECT_STREQ("bar", orig.GetStringAtIndex(1)); +} + +TEST(StringListTest, AppendStringStdString) { + StringList s; + s.AppendString("foo"); + ASSERT_EQ(1U, s.GetSize()); + EXPECT_STREQ("foo", s.GetStringAtIndex(0)); + + s.AppendString("bar"); + ASSERT_EQ(2U, s.GetSize()); + EXPECT_STREQ("foo", s.GetStringAtIndex(0)); + EXPECT_STREQ("bar", s.GetStringAtIndex(1)); +} + +TEST(StringListTest, AppendStringCString) { + StringList s; + s.AppendString("foo", strlen("foo")); + ASSERT_EQ(1U, s.GetSize()); + EXPECT_STREQ("foo", s.GetStringAtIndex(0)); + + s.AppendString("bar", strlen("bar")); + ASSERT_EQ(2U, s.GetSize()); + EXPECT_STREQ("foo", s.GetStringAtIndex(0)); + EXPECT_STREQ("bar", s.GetStringAtIndex(1)); +} + +TEST(StringListTest, AppendStringMove) { + StringList s; + std::string foo = "foo"; + std::string bar = "bar"; + + s.AppendString(std::move(foo)); + ASSERT_EQ(1U, s.GetSize()); + EXPECT_STREQ("foo", s.GetStringAtIndex(0)); + + s.AppendString(std::move(bar)); + ASSERT_EQ(2U, s.GetSize()); + EXPECT_STREQ("foo", s.GetStringAtIndex(0)); + EXPECT_STREQ("bar", s.GetStringAtIndex(1)); +} + +TEST(StringListTest, ShiftStdString) { + StringList s; + std::string foo = "foo"; + std::string bar = "bar"; + + s << foo; + ASSERT_EQ(1U, s.GetSize()); + EXPECT_STREQ("foo", s.GetStringAtIndex(0)); + + s << bar; + ASSERT_EQ(2U, s.GetSize()); + EXPECT_STREQ("foo", s.GetStringAtIndex(0)); + EXPECT_STREQ("bar", s.GetStringAtIndex(1)); +} + +TEST(StringListTest, ShiftCString) { + StringList s; + s << "foo"; + ASSERT_EQ(1U, s.GetSize()); + EXPECT_STREQ("foo", s.GetStringAtIndex(0)); + + s << "bar"; + ASSERT_EQ(2U, s.GetSize()); + EXPECT_STREQ("foo", s.GetStringAtIndex(0)); + EXPECT_STREQ("bar", s.GetStringAtIndex(1)); +} + +TEST(StringListTest, ShiftMove) { + StringList s; + std::string foo = "foo"; + std::string bar = "bar"; + + s << std::move(foo); + ASSERT_EQ(1U, s.GetSize()); + EXPECT_STREQ("foo", s.GetStringAtIndex(0)); + + s << std::move(bar); + ASSERT_EQ(2U, s.GetSize()); + EXPECT_STREQ("foo", s.GetStringAtIndex(0)); + EXPECT_STREQ("bar", s.GetStringAtIndex(1)); +} + +TEST(StringListTest, AppendListCStringArrayEmpty) { + StringList s; + s.AppendList(nullptr, 0); + EXPECT_EQ(0U, s.GetSize()); +} + +TEST(StringListTest, AppendListCStringArray) { + StringList s; + const char *items[3] = {"foo", "", "bar"}; + s.AppendList(items, 3); + + EXPECT_EQ(3U, s.GetSize()); + EXPECT_STREQ("foo", s.GetStringAtIndex(0)); + EXPECT_STREQ("", s.GetStringAtIndex(1)); + EXPECT_STREQ("bar", s.GetStringAtIndex(2)); +} + +TEST(StringListTest, AppendList)
[Lldb-commits] [lldb] r338976 - Remove duplicated code in CommandObjectQuit
Author: teemperor Date: Sun Aug 5 17:04:51 2018 New Revision: 338976 URL: http://llvm.org/viewvc/llvm-project?rev=338976&view=rev Log: Remove duplicated code in CommandObjectQuit Summary: We already have the same check directly before, so this code can never be reached (as seen in the test coverage). Subscribers: lldb-commits Differential Revision: https://reviews.llvm.org/D50317 Modified: lldb/trunk/source/Commands/CommandObjectQuit.cpp Modified: lldb/trunk/source/Commands/CommandObjectQuit.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectQuit.cpp?rev=338976&r1=338975&r2=338976&view=diff == --- lldb/trunk/source/Commands/CommandObjectQuit.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectQuit.cpp Sun Aug 5 17:04:51 2018 @@ -86,13 +86,6 @@ bool CommandObjectQuit::DoExecute(Args & return false; } - if (command.GetArgumentCount() > 1) { -result.AppendError("Too many arguments for 'quit'. Only an optional exit " - "code is allowed"); -result.SetStatus(eReturnStatusFailed); -return false; - } - // We parse the exit code argument if there is one. if (command.GetArgumentCount() == 1) { llvm::StringRef arg = command.GetArgumentAtIndex(0); ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] r339202 - Removed duplicated commented-out code [NFC]
Author: teemperor Date: Tue Aug 7 16:24:24 2018 New Revision: 339202 URL: http://llvm.org/viewvc/llvm-project?rev=339202&view=rev Log: Removed duplicated commented-out code [NFC] Modified: lldb/trunk/source/Symbol/ClangASTContext.cpp Modified: lldb/trunk/source/Symbol/ClangASTContext.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/ClangASTContext.cpp?rev=339202&r1=339201&r2=339202&view=diff == --- lldb/trunk/source/Symbol/ClangASTContext.cpp (original) +++ lldb/trunk/source/Symbol/ClangASTContext.cpp Tue Aug 7 16:24:24 2018 @@ -628,7 +628,6 @@ void ClangASTContext::SetExternalSource( if (ast) { ast->setExternalSource(ast_source_ap); ast->getTranslationUnitDecl()->setHasExternalLexicalStorage(true); -// ast->getTranslationUnitDecl()->setHasExternalVisibleStorage(true); } } @@ -639,7 +638,6 @@ void ClangASTContext::RemoveExternalSour llvm::IntrusiveRefCntPtr empty_ast_source_ap; ast->setExternalSource(empty_ast_source_ap); ast->getTranslationUnitDecl()->setHasExternalLexicalStorage(false); -// ast->getTranslationUnitDecl()->setHasExternalVisibleStorage(false); } } ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] r339204 - Removed doxygen comment that doesn't fit to function signature
Author: teemperor Date: Tue Aug 7 16:47:05 2018 New Revision: 339204 URL: http://llvm.org/viewvc/llvm-project?rev=339204&view=rev Log: Removed doxygen comment that doesn't fit to function signature Modified: lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.h Modified: lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.h?rev=339204&r1=339203&r2=339204&view=diff == --- lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.h (original) +++ lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.h Tue Aug 7 16:47:05 2018 @@ -325,12 +325,6 @@ public: /// @param[in] namespace_decl /// If valid and module is non-NULL, the parent namespace. /// - /// @param[in] name - /// The name as a plain C string. The NameSearchContext contains - /// a DeclarationName for the name so at first the name may seem - /// redundant, but ClangExpressionDeclMap operates in RTTI land so - /// it can't access DeclarationName. - /// /// @param[in] current_id /// The ID for the current FindExternalVisibleDecls invocation, /// for logging purposes. ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] r339351 - Also display the output and error output of a failed command
Author: teemperor Date: Thu Aug 9 08:29:32 2018 New Revision: 339351 URL: http://llvm.org/viewvc/llvm-project?rev=339351&view=rev Log: Also display the output and error output of a failed command Summary: Instead of just printing the current "False is not True, ..." message when we fail to run a certain command, this patch also adds the actual command output or error output that we received to the assertion message. Reviewers: davide Reviewed By: davide Subscribers: lldb-commits Differential Revision: https://reviews.llvm.org/D50492 Modified: lldb/trunk/packages/Python/lldbsuite/test/lldbtest.py Modified: lldb/trunk/packages/Python/lldbsuite/test/lldbtest.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/lldbtest.py?rev=339351&r1=339350&r2=339351&view=diff == --- lldb/trunk/packages/Python/lldbsuite/test/lldbtest.py (original) +++ lldb/trunk/packages/Python/lldbsuite/test/lldbtest.py Thu Aug 9 08:29:32 2018 @@ -2074,8 +2074,13 @@ class TestBase(Base): print("Command '" + cmd + "' failed!", file=sbuf) if check: +output = "" +if self.res.GetOutput(): + output += "\nCommand output:\n" + self.res.GetOutput() +if self.res.GetError(): + output += "\nError output:\n" + self.res.GetError() self.assertTrue(self.res.Succeeded(), -msg if msg else CMD_MSG(cmd)) +msg if (msg + output) else CMD_MSG(cmd + output)) def match( self, ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] r339353 - Added missing null checks to fix r339351
Author: teemperor Date: Thu Aug 9 08:57:43 2018 New Revision: 339353 URL: http://llvm.org/viewvc/llvm-project?rev=339353&view=rev Log: Added missing null checks to fix r339351 Modified: lldb/trunk/packages/Python/lldbsuite/test/lldbtest.py Modified: lldb/trunk/packages/Python/lldbsuite/test/lldbtest.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/lldbtest.py?rev=339353&r1=339352&r2=339353&view=diff == --- lldb/trunk/packages/Python/lldbsuite/test/lldbtest.py (original) +++ lldb/trunk/packages/Python/lldbsuite/test/lldbtest.py Thu Aug 9 08:57:43 2018 @@ -2079,8 +2079,12 @@ class TestBase(Base): output += "\nCommand output:\n" + self.res.GetOutput() if self.res.GetError(): output += "\nError output:\n" + self.res.GetError() +if msg: + msg += output +if cmd: + cmd += output self.assertTrue(self.res.Succeeded(), -msg if (msg + output) else CMD_MSG(cmd + output)) +msg if (msg) else CMD_MSG(cmd)) def match( self, ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] r339473 - Remove copy-pasted and unrelated comment [NFC]
Author: teemperor Date: Fri Aug 10 14:31:44 2018 New Revision: 339473 URL: http://llvm.org/viewvc/llvm-project?rev=339473&view=rev Log: Remove copy-pasted and unrelated comment [NFC] That comment was copied from the CombineConsecutiveEntriesWithEqualData() implementation below, and doesn't actually describe what's happening in the current function. Modified: lldb/trunk/include/lldb/Core/RangeMap.h Modified: lldb/trunk/include/lldb/Core/RangeMap.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/RangeMap.h?rev=339473&r1=339472&r2=339473&view=diff == --- lldb/trunk/include/lldb/Core/RangeMap.h (original) +++ lldb/trunk/include/lldb/Core/RangeMap.h Fri Aug 10 14:31:44 2018 @@ -169,8 +169,6 @@ public: #ifdef ASSERT_RANGEMAP_ARE_SORTED bool IsSorted() const { typename Collection::const_iterator pos, end, prev; -// First we determine if we can combine any of the Entry objects so we -// don't end up allocating and making a new collection for no reason for (pos = m_entries.begin(), end = m_entries.end(), prev = end; pos != end; prev = pos++) { if (prev != end && *pos < *prev) ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] r339504 - Use a DenseMap for looking up functions by UID in CompileUnit::FindFunctionByUID
Author: teemperor Date: Sat Aug 11 16:40:27 2018 New Revision: 339504 URL: http://llvm.org/viewvc/llvm-project?rev=339504&view=rev Log: Use a DenseMap for looking up functions by UID in CompileUnit::FindFunctionByUID Summary: Instead of iterating over our vector of functions, we might as well use a map here to directly get the function we need. Thanks to Vedant for pointing this out. Reviewers: vsk Reviewed By: vsk Subscribers: mgrang, lldb-commits Differential Revision: https://reviews.llvm.org/D50225 Modified: lldb/trunk/include/lldb/Symbol/CompileUnit.h lldb/trunk/source/Core/Module.cpp lldb/trunk/source/Symbol/CompileUnit.cpp Modified: lldb/trunk/include/lldb/Symbol/CompileUnit.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/CompileUnit.h?rev=339504&r1=339503&r2=339504&view=diff == --- lldb/trunk/include/lldb/Symbol/CompileUnit.h (original) +++ lldb/trunk/include/lldb/Symbol/CompileUnit.h Sat Aug 11 16:40:27 2018 @@ -18,6 +18,8 @@ #include "lldb/Utility/UserID.h" #include "lldb/lldb-enumerations.h" +#include "llvm/ADT/DenseMap.h" + namespace lldb_private { //-- /// @class CompileUnit CompileUnit.h "lldb/Symbol/CompileUnit.h" @@ -163,21 +165,19 @@ public: void GetDescription(Stream *s, lldb::DescriptionLevel level) const; //-- - /// Get a shared pointer to a function in this compile unit by index. + /// Apply a lambda to each function in this compile unit. /// - /// Typically called when iterating though all functions in a compile unit - /// after all functions have been parsed. This provides raw access to the - /// function shared pointer list and will not cause the SymbolFile plug-in - /// to parse any unparsed functions. + /// This provides raw access to the function shared pointer list and will not + /// cause the SymbolFile plug-in to parse any unparsed functions. /// - /// @param[in] idx - /// An index into the function list. + /// @note Prefer using FindFunctionByUID over this if possible. /// - /// @return - /// A shared pointer to a function that might contain a NULL - /// Function class pointer. + /// @param[in] lambda + /// The lambda that should be applied to every function. The lambda can + /// return true if the iteration should be aborted earlier. //-- - lldb::FunctionSP GetFunctionAtIndex(size_t idx); + void ForeachFunction( + llvm::function_ref lambda) const; //-- /// Dump the compile unit contents to the stream \a s. @@ -415,9 +415,9 @@ protected: lldb::LanguageType m_language; ///< The programming language enumeration value. Flags m_flags; ///< Compile unit flags that help with partial parsing. - std::vector m_functions; ///< The sparsely populated list of - ///shared pointers to functions - ///< that gets populated as functions get partially parsed. + + /// Maps UIDs to functions. + llvm::DenseMap m_functions_by_uid; std::vector m_imported_modules; ///< All modules, including the ///current module, imported by ///this Modified: lldb/trunk/source/Core/Module.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/Module.cpp?rev=339504&r1=339503&r2=339504&view=diff == --- lldb/trunk/source/Core/Module.cpp (original) +++ lldb/trunk/source/Core/Module.cpp Sat Aug 11 16:40:27 2018 @@ -371,15 +371,13 @@ void Module::ParseAllDebugSymbols() { symbols->ParseCompileUnitFunctions(sc); - for (size_t func_idx = 0; - (sc.function = sc.comp_unit->GetFunctionAtIndex(func_idx).get()) != - nullptr; - ++func_idx) { + sc.comp_unit->ForeachFunction([&sc, &symbols](const FunctionSP &f) { +sc.function = f.get(); symbols->ParseFunctionBlocks(sc); - // Parse the variables for this function and all its blocks symbols->ParseVariablesForContext(sc); - } +return false; + }); // Parse all types for this compile unit sc.function = nullptr; Modified: lldb/trunk/source/Symbol/CompileUnit.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/CompileUnit.cpp?rev=339504&r1=339503&r2=339504&view=diff == --- lldb/trunk/source/Symbol/CompileUnit.cpp (original) +++ lldb/trunk/source/Symbol/CompileUnit.cpp Sat Aug 11 16:40:27 2018 @@ -22,7 +22,7 @@ CompileUnit::CompileUnit(const lldb::Mod
[Lldb-commits] [lldb] r339611 - Added test for Core/Range class.
Author: teemperor Date: Mon Aug 13 13:43:06 2018 New Revision: 339611 URL: http://llvm.org/viewvc/llvm-project?rev=339611&view=rev Log: Added test for Core/Range class. Summary: We can optimize and refactor some of the classes in RangeMap.h, but first we should have some tests for all the data structures in there. This adds a first batch of tests for the Range class itself. There are some unexpected results happening when mixing invalid and valid ranges, so I added some FIXME's for that in the tests. Reviewers: vsk Reviewed By: vsk Subscribers: mgorny, lldb-commits Differential Revision: https://reviews.llvm.org/D50620 Added: lldb/trunk/unittests/Core/RangeTest.cpp Modified: lldb/trunk/unittests/Core/CMakeLists.txt Modified: lldb/trunk/unittests/Core/CMakeLists.txt URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/unittests/Core/CMakeLists.txt?rev=339611&r1=339610&r2=339611&view=diff == --- lldb/trunk/unittests/Core/CMakeLists.txt (original) +++ lldb/trunk/unittests/Core/CMakeLists.txt Mon Aug 13 13:43:06 2018 @@ -4,6 +4,7 @@ add_lldb_unittest(LLDBCoreTests EventTest.cpp ListenerTest.cpp MangledTest.cpp + RangeTest.cpp RichManglingContextTest.cpp StreamCallbackTest.cpp Added: lldb/trunk/unittests/Core/RangeTest.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/unittests/Core/RangeTest.cpp?rev=339611&view=auto == --- lldb/trunk/unittests/Core/RangeTest.cpp (added) +++ lldb/trunk/unittests/Core/RangeTest.cpp Mon Aug 13 13:43:06 2018 @@ -0,0 +1,330 @@ +//===-- RangeTest.cpp *- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===--===// + +#include "lldb/Core/RangeMap.h" + +#include +#include + +#include "gtest/gtest.h" + +using namespace lldb; +using namespace lldb_private; + +TEST(RangeTest, SizeTypes) { + Range r; + static_assert(std::is_same::value, +"RangeBase type is not equal to the given one."); + static_assert(std::is_same::value, +"RangeEnd type is not equal to the given one."); + static_assert(std::is_same::value, +"Size type is not equal to the given one."); +} + +typedef Range RangeT; + +TEST(RangeTest, DefaultConstructor) { + RangeT r; + EXPECT_FALSE(r.IsValid()); + EXPECT_EQ(0U, r.GetByteSize()); + EXPECT_EQ(0U, r.GetRangeBase()); + EXPECT_EQ(0U, r.GetRangeEnd()); +} + +TEST(RangeTest, Constructor) { + RangeT r(3, 5); + EXPECT_TRUE(r.IsValid()); + EXPECT_EQ(5U, r.GetByteSize()); + EXPECT_EQ(3U, r.GetRangeBase()); + EXPECT_EQ(8U, r.GetRangeEnd()); +} + +TEST(RangeTest, Copy) { + RangeT orig(3, 5); + RangeT r = orig; + EXPECT_TRUE(r.IsValid()); + EXPECT_EQ(5U, r.GetByteSize()); + EXPECT_EQ(3U, r.GetRangeBase()); + EXPECT_EQ(8U, r.GetRangeEnd()); +} + +TEST(RangeTest, Clear) { + RangeT r(3, 5); + r.Clear(); + EXPECT_TRUE(r == RangeT()); +} + +TEST(RangeTest, ClearWithStarAddress) { + RangeT r(3, 5); + r.Clear(4); + EXPECT_TRUE(r == RangeT(4, 0)); +} + +TEST(RangeTest, SetRangeBase) { + RangeT r(3, 5); + r.SetRangeBase(6); + EXPECT_EQ(6U, r.GetRangeBase()); + EXPECT_EQ(11U, r.GetRangeEnd()); + EXPECT_EQ(5U, r.GetByteSize()); +} + +TEST(RangeTest, Slide) { + RangeT r(3, 5); + r.Slide(1); + EXPECT_EQ(4U, r.GetRangeBase()); + EXPECT_EQ(9U, r.GetRangeEnd()); + EXPECT_EQ(5U, r.GetByteSize()); + + r.Slide(2); + EXPECT_EQ(6U, r.GetRangeBase()); + EXPECT_EQ(11U, r.GetRangeEnd()); + EXPECT_EQ(5U, r.GetByteSize()); +} + +TEST(RangeTest, SlideZero) { + RangeT r(3, 5); + r.Slide(0); + EXPECT_EQ(3U, r.GetRangeBase()); + EXPECT_EQ(8U, r.GetRangeEnd()); + EXPECT_EQ(5U, r.GetByteSize()); +} + +TEST(RangeTest, ContainsAddr) { + RangeT r(3, 5); + EXPECT_FALSE(r.Contains(0)); + EXPECT_FALSE(r.Contains(1)); + EXPECT_FALSE(r.Contains(2)); + EXPECT_TRUE(r.Contains(3)); + EXPECT_TRUE(r.Contains(4)); + EXPECT_TRUE(r.Contains(5)); + EXPECT_TRUE(r.Contains(6)); + EXPECT_TRUE(r.Contains(7)); + EXPECT_FALSE(r.Contains(8)); + EXPECT_FALSE(r.Contains(9)); + EXPECT_FALSE(r.Contains(10)); +} + +TEST(RangeTest, ContainsAddrInvalid) { + RangeT r; + EXPECT_FALSE(r.Contains(0)); + EXPECT_FALSE(r.Contains(1)); + EXPECT_FALSE(r.Contains(2)); + EXPECT_FALSE(r.Contains(3)); + EXPECT_FALSE(r.Contains(4)); +} + +TEST(RangeTest, ContainsEndInclusive) { + RangeT r(3, 5); + EXPECT_FALSE(r.ContainsEndInclusive(0)); + EXPECT_FALSE(r.ContainsEndInclusive(1)); + EXPECT_FALSE(r.ContainsEndInclusive(2)); + EXPECT_TRUE(r.ContainsEndInclusive(3)); + EXPECT_TRUE(r.ContainsEndInclusive(4)); + EXPECT_TRUE(r.ContainsEndInclusive(5)); + EXPECT_TRUE(r.ContainsEndInclusive(6)); + EXPECT_
[Lldb-commits] [lldb] r339695 - Remove manual byte counting from Highlighter code.
Author: teemperor Date: Tue Aug 14 10:12:54 2018 New Revision: 339695 URL: http://llvm.org/viewvc/llvm-project?rev=339695&view=rev Log: Remove manual byte counting from Highlighter code. Summary: This removes the manual byte counting mechanism from the syntax highlighting code. This is no longer necessary as the Stream class now has built-in support for automatically counting the bytes that were written to it so far. The advantage of automatic byte counting via Stream is that it is less error-prone than the manual version and we need to write less boilerplate code. Reviewers: labath Reviewed By: labath Subscribers: labath, lldb-commits Differential Revision: https://reviews.llvm.org/D50676 Modified: lldb/trunk/include/lldb/Core/Highlighter.h lldb/trunk/source/Core/Highlighter.cpp lldb/trunk/source/Core/SourceManager.cpp lldb/trunk/source/Plugins/Language/ClangCommon/ClangHighlighter.cpp lldb/trunk/source/Plugins/Language/ClangCommon/ClangHighlighter.h Modified: lldb/trunk/include/lldb/Core/Highlighter.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/Highlighter.h?rev=339695&r1=339694&r2=339695&view=diff == --- lldb/trunk/include/lldb/Core/Highlighter.h (original) +++ lldb/trunk/include/lldb/Core/Highlighter.h Tue Aug 14 10:12:54 2018 @@ -45,9 +45,7 @@ struct HighlightStyle { /// The stream to which the result should be appended. /// \param value /// The value that we should place our strings around. -/// \return -/// The number of bytes that have been written to the given stream. -std::size_t Apply(Stream &s, llvm::StringRef value) const; +void Apply(Stream &s, llvm::StringRef value) const; /// Sets the prefix and suffix strings. /// @param prefix @@ -114,12 +112,8 @@ public: /// \param s /// The stream to which the highlighted version of the user string should /// be written. - /// \return - /// The number of bytes that have been written to the stream. - virtual std::size_t Highlight(const HighlightStyle &options, -llvm::StringRef line, -llvm::StringRef previous_lines, -Stream &s) const = 0; + virtual void Highlight(const HighlightStyle &options, llvm::StringRef line, + llvm::StringRef previous_lines, Stream &s) const = 0; /// Utility method for calling Highlight without a stream. std::string Highlight(const HighlightStyle &options, llvm::StringRef line, @@ -131,9 +125,8 @@ class NoHighlighter : public Highlighter public: llvm::StringRef GetName() const override { return "none"; } - std::size_t Highlight(const HighlightStyle &options, llvm::StringRef line, -llvm::StringRef previous_lines, -Stream &s) const override; + void Highlight(const HighlightStyle &options, llvm::StringRef line, + llvm::StringRef previous_lines, Stream &s) const override; }; /// Manages the available highlighters. Modified: lldb/trunk/source/Core/Highlighter.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/Highlighter.cpp?rev=339695&r1=339694&r2=339695&view=diff == --- lldb/trunk/source/Core/Highlighter.cpp (original) +++ lldb/trunk/source/Core/Highlighter.cpp Tue Aug 14 10:12:54 2018 @@ -15,11 +15,8 @@ using namespace lldb_private; -std::size_t HighlightStyle::ColorStyle::Apply(Stream &s, - llvm::StringRef value) const { +void HighlightStyle::ColorStyle::Apply(Stream &s, llvm::StringRef value) const { s << m_prefix << value << m_suffix; - // Calculate how many bytes we have written. - return m_prefix.size() + value.size() + m_suffix.size(); } void HighlightStyle::ColorStyle::Set(llvm::StringRef prefix, @@ -28,13 +25,11 @@ void HighlightStyle::ColorStyle::Set(llv m_suffix = lldb_utility::ansi::FormatAnsiTerminalCodes(suffix); } -std::size_t NoHighlighter::Highlight(const HighlightStyle &options, - llvm::StringRef line, - llvm::StringRef previous_lines, - Stream &s) const { +void NoHighlighter::Highlight(const HighlightStyle &options, + llvm::StringRef line, + llvm::StringRef previous_lines, Stream &s) const { // We just forward the input to the output and do no highlighting. s << line; - return line.size(); } static HighlightStyle::ColorStyle GetColor(const char *c) { Modified: lldb/trunk/source/Core/SourceManager.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/SourceManager.cpp?rev=339695&r1=339694&r2=339695&view=diff ===
[Lldb-commits] [lldb] r339715 - Stability improvements for CompletionTest
Author: teemperor Date: Tue Aug 14 12:36:58 2018 New Revision: 339715 URL: http://llvm.org/viewvc/llvm-project?rev=339715&view=rev Log: Stability improvements for CompletionTest Summary: CompletionTest.DirCompletionAbsolute had a random failure on a CI node (in the failure, the completion count was 0, while we expected it to be 1), but there seems no good reason for it to fail. The sanitizers don't complain about the test when it's run, so I think we don't have some uninitialized memory that we access here. My best bet is that the unique directory selection randomly failed on the CI node because maybe the FS there doesn't actually guarantee the atomic fopen assumptions we make in the LLVM code (or some other funny race condition). In this case a different test run could get the same directory and clean its contents which would lead to 0 results. The other possible explanation is that someone changed the CI configuration on the node and changed the working dir to something very long, which would make our PATH_MAX test fail (which also leads to 0 results), but I think that case is unlikely. This patch is just a stab in the dark that (hopefully) fixes this random failure by giving each test a (more) unique working directory by appending the unique test name to the temp-dir prefix. Also adds one more ASSERT_NO_ERROR to one of our chdir calls just in case that is the reason for failing. The good thing is that this refactor gets rid of most of the static variables and files that we previously had as shared state between the different tests. Potentially fixes rdar://problem/43150260 Reviewers: aprantl Reviewed By: aprantl Subscribers: jfb, lldb-commits Differential Revision: https://reviews.llvm.org/D50722 Modified: lldb/trunk/unittests/Interpreter/TestCompletion.cpp Modified: lldb/trunk/unittests/Interpreter/TestCompletion.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/unittests/Interpreter/TestCompletion.cpp?rev=339715&r1=339714&r2=339715&view=diff == --- lldb/trunk/unittests/Interpreter/TestCompletion.cpp (original) +++ lldb/trunk/unittests/Interpreter/TestCompletion.cpp Tue Aug 14 12:36:58 2018 @@ -41,32 +41,41 @@ class CompletionTest : public testing::T protected: /// Unique temporary directory in which all created filesystem entities must /// be placed. It is removed at the end of the test suite. - static SmallString<128> BaseDir; + SmallString<128> BaseDir; + /// The working directory that we got when starting the test. Every test + /// should chdir into this directory first because some tests maybe chdir + /// into another one during their run. static SmallString<128> OriginalWorkingDir; - static SmallString<128> DirFoo; - static SmallString<128> DirFooA; - static SmallString<128> DirFooB; - static SmallString<128> DirFooC; - static SmallString<128> DirBar; - static SmallString<128> DirBaz; - static SmallString<128> DirTestFolder; - static SmallString<128> DirNested; - - static SmallString<128> FileAA; - static SmallString<128> FileAB; - static SmallString<128> FileAC; - static SmallString<128> FileFoo; - static SmallString<128> FileBar; - static SmallString<128> FileBaz; + SmallString<128> DirFoo; + SmallString<128> DirFooA; + SmallString<128> DirFooB; + SmallString<128> DirFooC; + SmallString<128> DirBar; + SmallString<128> DirBaz; + SmallString<128> DirTestFolder; + SmallString<128> DirNested; + + SmallString<128> FileAA; + SmallString<128> FileAB; + SmallString<128> FileAC; + SmallString<128> FileFoo; + SmallString<128> FileBar; + SmallString<128> FileBaz; + + void SetUp() override { +// chdir back into the original working dir this test binary started with. +// A previous test may have have changed the working dir. +ASSERT_NO_ERROR(fs::set_current_path(OriginalWorkingDir)); + +// Get the name of the current test. To prevent that by chance two tests +// get the same temporary directory if createUniqueDirectory fails. +auto test_info = ::testing::UnitTest::GetInstance()->current_test_info(); +ASSERT_TRUE(test_info != nullptr); +std::string name = test_info->name(); +ASSERT_NO_ERROR(fs::createUniqueDirectory("FsCompletion-" + name, BaseDir)); - void SetUp() override { llvm::sys::fs::set_current_path(OriginalWorkingDir); } - - static void SetUpTestCase() { -llvm::sys::fs::current_path(OriginalWorkingDir); - -ASSERT_NO_ERROR(fs::createUniqueDirectory("FsCompletion", BaseDir)); const char *DirNames[] = {"foo", "fooa", "foob","fooc", "bar", "baz", "test_folder", "foo/nested"}; const char *FileNames[] = {"aa1234.tmp", "ab1234.tmp", "ac1234.tmp", @@ -92,10 +101,12 @@ protected: } } - static void TearDownTestCase() { -ASSERT_NO_ERROR(fs::remove_directories(BaseDir)); + static void SetUpTestCase() { +ASSERT_NO_ERROR(fs::current_path(Origina
[Lldb-commits] [lldb] r339825 - [ASTImporter] Add test for IfStmt
Author: teemperor Date: Wed Aug 15 15:31:44 2018 New Revision: 339825 URL: http://llvm.org/viewvc/llvm-project?rev=339825&view=rev Log: [ASTImporter] Add test for IfStmt Reviewers: a.sidorin, hiraditya Reviewed By: hiraditya Subscribers: hiraditya, martong, cfe-commits Differential Revision: https://reviews.llvm.org/D50796 Added: lldb/trunk/test/Import/ lldb/trunk/test/Import/if-stmt/ lldb/trunk/test/Import/if-stmt/Inputs/ lldb/trunk/test/Import/if-stmt/Inputs/F.cpp lldb/trunk/test/Import/if-stmt/test.cpp Added: lldb/trunk/test/Import/if-stmt/Inputs/F.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/Import/if-stmt/Inputs/F.cpp?rev=339825&view=auto == --- lldb/trunk/test/Import/if-stmt/Inputs/F.cpp (added) +++ lldb/trunk/test/Import/if-stmt/Inputs/F.cpp Wed Aug 15 15:31:44 2018 @@ -0,0 +1,21 @@ +void f() { + if (true) +return; + + if (int j = 3) +return; + + if (int j; true) +return; + + if (true) +return; + else +return; + + if (true) { +return; + } else { +return; + } +} Added: lldb/trunk/test/Import/if-stmt/test.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/Import/if-stmt/test.cpp?rev=339825&view=auto == --- lldb/trunk/test/Import/if-stmt/test.cpp (added) +++ lldb/trunk/test/Import/if-stmt/test.cpp Wed Aug 15 15:31:44 2018 @@ -0,0 +1,47 @@ +// RUN: clang-import-test -dump-ast -import %S/Inputs/F.cpp -expression %s | FileCheck %s + +// CHECK: IfStmt +// CHECK-NEXT: <> +// CHECK-NEXT: <> +// CHECK-NEXT: CXXBoolLiteralExpr +// CHECK-NEXT: ReturnStmt +// CHECK-NEXT: <> + +// CHECK: IfStmt +// CHECK-NEXT: <> +// CHECK-NEXT: DeclStmt +// CHECK-NEXT: VarDecl +// CHECK-NEXT: IntegerLiteral +// CHECK-NEXT: ImplicitCastExpr +// CHECK-NEXT: ImplicitCastExpr +// CHECK-NEXT: DeclRefExpr +// CHECK-NEXT: ReturnStmt +// CHECK-NEXT: <> + +// CHECK: IfStmt +// CHECK-NEXT: DeclStmt +// CHECK-NEXT: VarDecl +// CHECK-NEXT: <> +// CHECK-NEXT: CXXBoolLiteralExpr +// CHECK-NEXT: ReturnStmt +// CHECK-NEXT: <> + +// CHECK: IfStmt +// CHECK-NEXT: <> +// CHECK-NEXT: <> +// CHECK-NEXT: CXXBoolLiteralExpr +// CHECK-NEXT: ReturnStmt +// CHECK-NEXT: ReturnStmt + +// CHECK: IfStmt +// CHECK-NEXT: <> +// CHECK-NEXT: <> +// CHECK-NEXT: CXXBoolLiteralExpr +// CHECK-NEXT: CompoundStmt +// CHECK-NEXT: ReturnStmt +// CHECK-NEXT: CompoundStmt +// CHECK-NEXT: ReturnStmt + +void expr() { + f(); +} ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] r339826 - Revert "[ASTImporter] Add test for IfStmt"
Author: teemperor Date: Wed Aug 15 15:32:35 2018 New Revision: 339826 URL: http://llvm.org/viewvc/llvm-project?rev=339826&view=rev Log: Revert "[ASTImporter] Add test for IfStmt" That's actually a clang patch, sorry. Removed: lldb/trunk/test/Import/if-stmt/Inputs/F.cpp lldb/trunk/test/Import/if-stmt/test.cpp Removed: lldb/trunk/test/Import/if-stmt/Inputs/F.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/Import/if-stmt/Inputs/F.cpp?rev=339825&view=auto == --- lldb/trunk/test/Import/if-stmt/Inputs/F.cpp (original) +++ lldb/trunk/test/Import/if-stmt/Inputs/F.cpp (removed) @@ -1,21 +0,0 @@ -void f() { - if (true) -return; - - if (int j = 3) -return; - - if (int j; true) -return; - - if (true) -return; - else -return; - - if (true) { -return; - } else { -return; - } -} Removed: lldb/trunk/test/Import/if-stmt/test.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/Import/if-stmt/test.cpp?rev=339825&view=auto == --- lldb/trunk/test/Import/if-stmt/test.cpp (original) +++ lldb/trunk/test/Import/if-stmt/test.cpp (removed) @@ -1,47 +0,0 @@ -// RUN: clang-import-test -dump-ast -import %S/Inputs/F.cpp -expression %s | FileCheck %s - -// CHECK: IfStmt -// CHECK-NEXT: <> -// CHECK-NEXT: <> -// CHECK-NEXT: CXXBoolLiteralExpr -// CHECK-NEXT: ReturnStmt -// CHECK-NEXT: <> - -// CHECK: IfStmt -// CHECK-NEXT: <> -// CHECK-NEXT: DeclStmt -// CHECK-NEXT: VarDecl -// CHECK-NEXT: IntegerLiteral -// CHECK-NEXT: ImplicitCastExpr -// CHECK-NEXT: ImplicitCastExpr -// CHECK-NEXT: DeclRefExpr -// CHECK-NEXT: ReturnStmt -// CHECK-NEXT: <> - -// CHECK: IfStmt -// CHECK-NEXT: DeclStmt -// CHECK-NEXT: VarDecl -// CHECK-NEXT: <> -// CHECK-NEXT: CXXBoolLiteralExpr -// CHECK-NEXT: ReturnStmt -// CHECK-NEXT: <> - -// CHECK: IfStmt -// CHECK-NEXT: <> -// CHECK-NEXT: <> -// CHECK-NEXT: CXXBoolLiteralExpr -// CHECK-NEXT: ReturnStmt -// CHECK-NEXT: ReturnStmt - -// CHECK: IfStmt -// CHECK-NEXT: <> -// CHECK-NEXT: <> -// CHECK-NEXT: CXXBoolLiteralExpr -// CHECK-NEXT: CompoundStmt -// CHECK-NEXT: ReturnStmt -// CHECK-NEXT: CompoundStmt -// CHECK-NEXT: ReturnStmt - -void expr() { - f(); -} ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] r340179 - Remove manual byte counting from Opcode::Dump
Author: teemperor Date: Mon Aug 20 08:51:14 2018 New Revision: 340179 URL: http://llvm.org/viewvc/llvm-project?rev=340179&view=rev Log: Remove manual byte counting from Opcode::Dump Summary: Stream now has byte-counting functionality, so let's use this instead of manual byte counting. Reviewers: clayborg, davide Reviewed By: davide Subscribers: davide, lldb-commits Differential Revision: https://reviews.llvm.org/D50677 Modified: lldb/trunk/source/Core/Opcode.cpp Modified: lldb/trunk/source/Core/Opcode.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/Opcode.cpp?rev=340179&r1=340178&r2=340179&view=diff == --- lldb/trunk/source/Core/Opcode.cpp (original) +++ lldb/trunk/source/Core/Opcode.cpp Mon Aug 20 08:51:14 2018 @@ -23,40 +23,41 @@ using namespace lldb; using namespace lldb_private; int Opcode::Dump(Stream *s, uint32_t min_byte_width) { - int bytes_written = 0; + const uint32_t previous_bytes = s->GetWrittenBytes(); switch (m_type) { case Opcode::eTypeInvalid: -bytes_written = s->PutCString(""); +s->PutCString(""); break; case Opcode::eType8: -bytes_written = s->Printf("0x%2.2x", m_data.inst8); +s->Printf("0x%2.2x", m_data.inst8); break; case Opcode::eType16: -bytes_written = s->Printf("0x%4.4x", m_data.inst16); +s->Printf("0x%4.4x", m_data.inst16); break; case Opcode::eType16_2: case Opcode::eType32: -bytes_written = s->Printf("0x%8.8x", m_data.inst32); +s->Printf("0x%8.8x", m_data.inst32); break; case Opcode::eType64: -bytes_written = s->Printf("0x%16.16" PRIx64, m_data.inst64); +s->Printf("0x%16.16" PRIx64, m_data.inst64); break; case Opcode::eTypeBytes: for (uint32_t i = 0; i < m_data.inst.length; ++i) { if (i > 0) -bytes_written += s->PutChar(' '); - bytes_written += s->Printf("%2.2x", m_data.inst.bytes[i]); +s->PutChar(' '); + s->Printf("%2.2x", m_data.inst.bytes[i]); } break; } - // Add spaces to make sure bytes dispay comes out even in case opcodes aren't - // all the same size - if (static_cast(bytes_written) < min_byte_width) -bytes_written = s->Printf("%*s", min_byte_width - bytes_written, ""); - return bytes_written; + uint32_t bytes_written_so_far = s->GetWrittenBytes() - previous_bytes; + // Add spaces to make sure bytes display comes out even in case opcodes aren't + // all the same size. + if (bytes_written_so_far < min_byte_width) +s->Printf("%*s", min_byte_width - bytes_written_so_far, ""); + return s->GetWrittenBytes() - previous_bytes; } lldb::ByteOrder Opcode::GetDataByteOrder() const { ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] r340448 - Add unit test for StringLexer
Author: teemperor Date: Wed Aug 22 13:22:34 2018 New Revision: 340448 URL: http://llvm.org/viewvc/llvm-project?rev=340448&view=rev Log: Add unit test for StringLexer Reviewers: labath, #lldb Reviewed By: labath Subscribers: jloser, mgorny, lldb-commits Differential Revision: https://reviews.llvm.org/D50298 Added: lldb/trunk/unittests/Utility/StringLexerTest.cpp Modified: lldb/trunk/unittests/Utility/CMakeLists.txt Modified: lldb/trunk/unittests/Utility/CMakeLists.txt URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/unittests/Utility/CMakeLists.txt?rev=340448&r1=340447&r2=340448&view=diff == --- lldb/trunk/unittests/Utility/CMakeLists.txt (original) +++ lldb/trunk/unittests/Utility/CMakeLists.txt Wed Aug 22 13:22:34 2018 @@ -19,6 +19,7 @@ add_lldb_unittest(UtilityTests StreamTeeTest.cpp StreamTest.cpp StringExtractorTest.cpp + StringLexerTest.cpp StringListTest.cpp StructuredDataTest.cpp TildeExpressionResolverTest.cpp Added: lldb/trunk/unittests/Utility/StringLexerTest.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/unittests/Utility/StringLexerTest.cpp?rev=340448&view=auto == --- lldb/trunk/unittests/Utility/StringLexerTest.cpp (added) +++ lldb/trunk/unittests/Utility/StringLexerTest.cpp Wed Aug 22 13:22:34 2018 @@ -0,0 +1,141 @@ +//===-- StringLexerTest.cpp -*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===--===// + +#include "lldb/Utility/StringLexer.h" +#include "gtest/gtest.h" + +using namespace lldb_utility; + +TEST(StringLexerTest, GetUnlexed) { + StringLexer l("foo"); + EXPECT_EQ("foo", l.GetUnlexed()); + l.Next(); + EXPECT_EQ("oo", l.GetUnlexed()); + l.Next(); + l.Next(); + EXPECT_EQ("", l.GetUnlexed()); +} + +TEST(StringLexerTest, HasAtLeast) { + StringLexer l("foo"); + EXPECT_FALSE(l.HasAtLeast(5)); + EXPECT_FALSE(l.HasAtLeast(4)); + EXPECT_TRUE(l.HasAtLeast(3)); + EXPECT_TRUE(l.HasAtLeast(2)); + EXPECT_TRUE(l.HasAtLeast(1)); + + l.Next(); + EXPECT_FALSE(l.HasAtLeast(5)); + EXPECT_FALSE(l.HasAtLeast(4)); + EXPECT_FALSE(l.HasAtLeast(3)); + EXPECT_TRUE(l.HasAtLeast(2)); + EXPECT_TRUE(l.HasAtLeast(1)); + + l.Next(); + l.Next(); + EXPECT_FALSE(l.HasAtLeast(5)); + EXPECT_FALSE(l.HasAtLeast(4)); + EXPECT_FALSE(l.HasAtLeast(3)); + EXPECT_FALSE(l.HasAtLeast(2)); + EXPECT_FALSE(l.HasAtLeast(1)); +} + +TEST(StringLexerTest, AdvanceIf) { + StringLexer l("foobar"); + + EXPECT_FALSE(l.AdvanceIf("oo")); + // Skip the "fo" part. + EXPECT_TRUE(l.AdvanceIf("fo")); + EXPECT_FALSE(l.AdvanceIf("obarz")); + // Skip the remaining string. + EXPECT_TRUE(l.AdvanceIf("obar")); + + EXPECT_FALSE(l.AdvanceIf("obarz")); + EXPECT_FALSE(l.AdvanceIf("foo")); + EXPECT_FALSE(l.AdvanceIf("o")); + EXPECT_FALSE(l.AdvanceIf(" ")); +} + +TEST(StringLexerTest, PutBack) { + StringLexer l("foo"); + + l.Next(); + l.PutBack(1); + EXPECT_EQ("foo", l.GetUnlexed()); + + l.Next(); + l.Next(); + l.Next(); + l.PutBack(2); + EXPECT_EQ("oo", l.GetUnlexed()); + + l.PutBack(1); + EXPECT_EQ("foo", l.GetUnlexed()); +} + +TEST(StringLexerTest, Peek) { + StringLexer l("foo"); + + EXPECT_EQ('f', l.Peek()); + l.Next(); + EXPECT_EQ('o', l.Peek()); + l.Next(); + EXPECT_EQ('o', l.Peek()); +} + +TEST(StringLexerTest, Next) { + StringLexer l("foo"); + EXPECT_EQ('f', l.Next()); + EXPECT_EQ('o', l.Next()); + EXPECT_EQ('o', l.Next()); +} + +TEST(StringLexerTest, NextIf) { + StringLexer l("foo"); + + EXPECT_FALSE(l.NextIf('\0')); + EXPECT_FALSE(l.NextIf(' ')); + EXPECT_FALSE(l.NextIf('o')); + + EXPECT_TRUE(l.NextIf('f')); + + EXPECT_FALSE(l.NextIf('\0')); + EXPECT_FALSE(l.NextIf(' ')); + EXPECT_FALSE(l.NextIf('f')); + + EXPECT_TRUE(l.NextIf('o')); + + EXPECT_FALSE(l.NextIf('\0')); + EXPECT_FALSE(l.NextIf(' ')); + EXPECT_FALSE(l.NextIf('f')); + + EXPECT_TRUE(l.NextIf('o')); +} + +TEST(StringLexerTest, NextIfList) { + StringLexer l("foo"); + + EXPECT_FALSE(l.NextIf({'\0', ' ', 'o'}).first); + + auto r = l.NextIf({'f'}); + EXPECT_TRUE(r.first); + EXPECT_EQ('f', r.second); + + EXPECT_FALSE(l.NextIf({'\0', ' ', 'f'}).first); + + r = l.NextIf({'f', 'o'}); + EXPECT_TRUE(r.first); + EXPECT_EQ('o', r.second); + + EXPECT_FALSE(l.NextIf({'\0', ' ', 'f'}).first); + + r = l.NextIf({'*', 'f', 'o', 'o'}); + EXPECT_TRUE(r.first); + EXPECT_EQ('o', r.second); +} ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] r340571 - Fix broken builtin functions in the expression command
Author: teemperor Date: Thu Aug 23 13:40:45 2018 New Revision: 340571 URL: http://llvm.org/viewvc/llvm-project?rev=340571&view=rev Log: Fix broken builtin functions in the expression command Summary: Calling any non-libc builtin function in the expression command currently just causes Clang to state that the function is not known. The reason for this is that we actually never initialize the list of builtin functions in the Builtin::Context. This patch just calls the initializer for the builtins in the preprocessor. Also adds some tests for the new builtins. It also gets rid of the extra list of builtins in the ClangExpressionParser, as we can just reuse the existing list in the Preprocessor for the ASTContext. Having just one list of builtins around is also closer to the standard Clang behavior. Reviewers: #lldb, vsk Reviewed By: vsk Subscribers: sgraenitz, clayborg, vsk, lldb-commits Differential Revision: https://reviews.llvm.org/D50481 Added: lldb/trunk/packages/Python/lldbsuite/test/expression_command/call-function/TestCallBuiltinFunction.py Modified: lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.h Added: lldb/trunk/packages/Python/lldbsuite/test/expression_command/call-function/TestCallBuiltinFunction.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/expression_command/call-function/TestCallBuiltinFunction.py?rev=340571&view=auto == --- lldb/trunk/packages/Python/lldbsuite/test/expression_command/call-function/TestCallBuiltinFunction.py (added) +++ lldb/trunk/packages/Python/lldbsuite/test/expression_command/call-function/TestCallBuiltinFunction.py Thu Aug 23 13:40:45 2018 @@ -0,0 +1,53 @@ +""" +Tests calling builtin functions using expression evaluation. +""" + +from __future__ import print_function + + +import lldb +from lldbsuite.test.decorators import * +from lldbsuite.test.lldbtest import * +from lldbsuite.test import lldbutil + + +class ExprCommandCallBuiltinFunction(TestBase): + +mydir = TestBase.compute_mydir(__file__) + +# Builtins are expanded by Clang, so debug info shouldn't matter. +NO_DEBUG_INFO_TESTCASE = True + +def setUp(self): +TestBase.setUp(self) +# Find the line number to break for main.c. +self.line = line_number( +'main.cpp', +'// Please test these expressions while stopped at this line:') + +def test(self): +self.build() + +# Set breakpoint in main and run exe +self.runCmd("file " + self.getBuildArtifact("a.out"), CURRENT_EXECUTABLE_SET) +lldbutil.run_break_set_by_file_and_line( +self, "main.cpp", self.line, num_expected_locations=-1, loc_exact=True) + +self.runCmd("run", RUN_SUCCEEDED) + +interp = self.dbg.GetCommandInterpreter() +result = lldb.SBCommandReturnObject() + +# Test different builtin functions. + +interp.HandleCommand("expr __builtin_isinf(0.0f)", result) +self.assertEqual(result.GetOutput(), "(int) $0 = 0\n") + +interp.HandleCommand("expr __builtin_isnormal(0.0f)", result) +self.assertEqual(result.GetOutput(), "(int) $1 = 0\n") + +interp.HandleCommand("expr __builtin_constant_p(1)", result) +self.assertEqual(result.GetOutput(), "(int) $2 = 1\n") + +interp.HandleCommand("expr __builtin_abs(-14)", result) +self.assertEqual(result.GetOutput(), "(int) $3 = 14\n") Modified: lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp?rev=340571&r1=340570&r2=340571&view=diff == --- lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp (original) +++ lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp Thu Aug 23 13:40:45 2018 @@ -508,12 +508,21 @@ ClangExpressionParser::ClangExpressionPa // 8. Most of this we get from the CompilerInstance, but we also want to give // the context an ExternalASTSource. m_selector_table.reset(new SelectorTable()); - m_builtin_context.reset(new Builtin::Context()); + + // We enable all builtin functions beside the builtins from libc/libm (e.g. + // 'fopen'). Those libc functions are already correctly handled by LLDB, and + // additionally enabling them as expandable builtins is breaking Clang. + m_compiler->getLangOpts().NoBuiltin = true; + + auto &PP = m_compiler->getPreprocessor(); + auto &builtin_context = PP.getBuiltinInfo(); + builtin_context.initializeBuiltins(PP.getIdentifierTable(), + m_compiler->getLangOpts()); std::unique_ptr ast_context( new ASTContext(m_compiler->getLa
[Lldb-commits] [lldb] r340585 - Reuse the SelectorTable from Clang's Preprocessor
Author: teemperor Date: Thu Aug 23 15:40:54 2018 New Revision: 340585 URL: http://llvm.org/viewvc/llvm-project?rev=340585&view=rev Log: Reuse the SelectorTable from Clang's Preprocessor Summary: At the moment we create our own SelectorTable even though the Preprocessor always creates one for us that we can (and should) reuse. Reviewers: vsk Reviewed By: vsk Subscribers: lldb-commits Differential Revision: https://reviews.llvm.org/D51185 Modified: lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.h Modified: lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp?rev=340585&r1=340584&r2=340585&view=diff == --- lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp (original) +++ lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp Thu Aug 23 15:40:54 2018 @@ -507,8 +507,6 @@ ClangExpressionParser::ClangExpressionPa // 8. Most of this we get from the CompilerInstance, but we also want to give // the context an ExternalASTSource. - m_selector_table.reset(new SelectorTable()); - // We enable all builtin functions beside the builtins from libc/libm (e.g. // 'fopen'). Those libc functions are already correctly handled by LLDB, and // additionally enabling them as expandable builtins is breaking Clang. @@ -522,7 +520,7 @@ ClangExpressionParser::ClangExpressionPa std::unique_ptr ast_context( new ASTContext(m_compiler->getLangOpts(), m_compiler->getSourceManager(), m_compiler->getPreprocessor().getIdentifierTable(), - *m_selector_table.get(), builtin_context)); + PP.getSelectorTable(), builtin_context)); ast_context->InitBuiltinTypes(m_compiler->getTarget()); Modified: lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.h?rev=340585&r1=340584&r2=340585&view=diff == --- lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.h (original) +++ lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.h Thu Aug 23 15:40:54 2018 @@ -149,8 +149,6 @@ private: m_file_manager; ///< The Clang file manager object used by the compiler std::unique_ptr m_compiler; ///< The Clang compiler used to parse expressions into IR - std::unique_ptr - m_selector_table; ///< Selector table for Objective-C methods std::unique_ptr m_code_generator; ///< The Clang object that generates IR ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] r340589 - Add more pre-run asserts for the DirCompletionAbsolute test
Author: teemperor Date: Thu Aug 23 16:21:52 2018 New Revision: 340589 URL: http://llvm.org/viewvc/llvm-project?rev=340589&view=rev Log: Add more pre-run asserts for the DirCompletionAbsolute test Summary: The DirCompletionAbsolute is still randomly failing on the nodes even after D50722, so this patch adds more asserts that verify certain properties on which the actual completion implementation relies on. The first assert checks that the directory we complete on actually exists. If the directory doesn't exist on the next CI failure, this assert should catch it and we know that the 0 matches come from a missing base directory. The second assert is just checking that we are below the PATH_MAX limit that the completion checks against. This check could randomly fail if the temporary directories we generate are sometimes longer than PATH_MAX, and the assert can tell us that this is the reason we failed (instead of the mysterious '0 matches'). (As a sidenote: We shouldn't be checking against PATH_MAX anyway in the code (as this is just wrong). Also the disk completion API really needs a better error mechanism than returning 0 on both error or no-results.) Reviewers: aprantl, friss Reviewed By: aprantl Subscribers: abidh Differential Revision: https://reviews.llvm.org/D5 Modified: lldb/trunk/unittests/Interpreter/TestCompletion.cpp Modified: lldb/trunk/unittests/Interpreter/TestCompletion.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/unittests/Interpreter/TestCompletion.cpp?rev=340589&r1=340588&r2=340589&view=diff == --- lldb/trunk/unittests/Interpreter/TestCompletion.cpp (original) +++ lldb/trunk/unittests/Interpreter/TestCompletion.cpp Thu Aug 23 16:21:52 2018 @@ -163,6 +163,9 @@ TEST_F(CompletionTest, DirCompletionAbso // When a directory is specified that doesn't end in a slash, it searches // for that directory, not items under it. + // Sanity check that the path we complete on exists and isn't too long. + ASSERT_TRUE(llvm::sys::fs::exists(BaseDir)); + ASSERT_LE(BaseDir.size(), static_cast(PATH_MAX)); size_t Count = CommandCompletions::DiskDirectories(BaseDir, Results, Resolver); ASSERT_EQ(1u, Count); ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] r340652 - Fixed windows bots that were failing because of PATH_MAX
Author: teemperor Date: Fri Aug 24 13:55:23 2018 New Revision: 340652 URL: http://llvm.org/viewvc/llvm-project?rev=340652&view=rev Log: Fixed windows bots that were failing because of PATH_MAX As we only use PATH_MAX for an assert in a unit test that is supposed to catch the random failures on the Swift CI bots, we might as well just ifdef this assert out on Windows. Modified: lldb/trunk/unittests/Interpreter/TestCompletion.cpp Modified: lldb/trunk/unittests/Interpreter/TestCompletion.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/unittests/Interpreter/TestCompletion.cpp?rev=340652&r1=340651&r2=340652&view=diff == --- lldb/trunk/unittests/Interpreter/TestCompletion.cpp (original) +++ lldb/trunk/unittests/Interpreter/TestCompletion.cpp Fri Aug 24 13:55:23 2018 @@ -165,7 +165,9 @@ TEST_F(CompletionTest, DirCompletionAbso // for that directory, not items under it. // Sanity check that the path we complete on exists and isn't too long. ASSERT_TRUE(llvm::sys::fs::exists(BaseDir)); +#ifdef PATH_MAX ASSERT_LE(BaseDir.size(), static_cast(PATH_MAX)); +#endif size_t Count = CommandCompletions::DiskDirectories(BaseDir, Results, Resolver); ASSERT_EQ(1u, Count); ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] r340747 - Disable use-color if the output stream is not a terminal with color support.
Author: teemperor Date: Mon Aug 27 08:16:25 2018 New Revision: 340747 URL: http://llvm.org/viewvc/llvm-project?rev=340747&view=rev Log: Disable use-color if the output stream is not a terminal with color support. Summary: LLDB currently only checks the output terminal for color support by looking at the `TERM` environment variable and comparing it to `"dumb"`. This causes that when running LLDB on a CI node, the syntax highlighter will not be deactivated by LLDB and the output log is filled with color codes (unless the terminal emulator actually exposes itself as dumb). This patch now relies on the LLVM code for detecting color support which is more reliable. We now also correctly actually initialize the `m_supports_colors` variable in `File`. `m_supports_colors` was so far uninitialized, but the code path that uses `m_supports_colors` was also dead so the sanitizers didn't sound an alarm. The old check that compares `TERM` is not removed by this patch as the new LLVM code doesn't seem to handle this case (and it's a good thing to check for "dumb" terminals). Reviewers: aprantl, javed.absar Reviewed By: aprantl Subscribers: kristof.beyls, abidh, lldb-commits Differential Revision: https://reviews.llvm.org/D51243 Added: lldb/trunk/lit/Settings/ lldb/trunk/lit/Settings/TestDisableColor.test lldb/trunk/lit/Settings/lit.local.cfg Modified: lldb/trunk/include/lldb/Host/File.h lldb/trunk/source/Core/Debugger.cpp Modified: lldb/trunk/include/lldb/Host/File.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Host/File.h?rev=340747&r1=340746&r2=340747&view=diff == --- lldb/trunk/include/lldb/Host/File.h (original) +++ lldb/trunk/include/lldb/Host/File.h Mon Aug 27 08:16:25 2018 @@ -54,13 +54,15 @@ public: : IOObject(eFDTypeFile, false), m_descriptor(kInvalidDescriptor), m_stream(kInvalidStream), m_options(0), m_own_stream(false), m_is_interactive(eLazyBoolCalculate), -m_is_real_terminal(eLazyBoolCalculate) {} +m_is_real_terminal(eLazyBoolCalculate), +m_supports_colors(eLazyBoolCalculate) {} File(FILE *fh, bool transfer_ownership) : IOObject(eFDTypeFile, false), m_descriptor(kInvalidDescriptor), m_stream(fh), m_options(0), m_own_stream(transfer_ownership), m_is_interactive(eLazyBoolCalculate), -m_is_real_terminal(eLazyBoolCalculate) {} +m_is_real_terminal(eLazyBoolCalculate), +m_supports_colors(eLazyBoolCalculate) {} //-- /// Constructor with path. Added: lldb/trunk/lit/Settings/TestDisableColor.test URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/lit/Settings/TestDisableColor.test?rev=340747&view=auto == --- lldb/trunk/lit/Settings/TestDisableColor.test (added) +++ lldb/trunk/lit/Settings/TestDisableColor.test Mon Aug 27 08:16:25 2018 @@ -0,0 +1,7 @@ +# RUN: %lldb -x -b -s %s | FileCheck %s +settings show use-color +q +# This tests that LLDB turns off use-color if the output file is not an +# interactive terminal. In this example, use-color should be off because LLDB +# is run just by the non-interactive lit test runner. +# CHECK: use-color (boolean) = false Added: lldb/trunk/lit/Settings/lit.local.cfg URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/lit/Settings/lit.local.cfg?rev=340747&view=auto == --- lldb/trunk/lit/Settings/lit.local.cfg (added) +++ lldb/trunk/lit/Settings/lit.local.cfg Mon Aug 27 08:16:25 2018 @@ -0,0 +1 @@ +config.suffixes = ['.test'] Modified: lldb/trunk/source/Core/Debugger.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/Debugger.cpp?rev=340747&r1=340746&r2=340747&view=diff == --- lldb/trunk/source/Core/Debugger.cpp (original) +++ lldb/trunk/source/Core/Debugger.cpp Mon Aug 27 08:16:25 2018 @@ -804,6 +804,9 @@ Debugger::Debugger(lldb::LogOutputCallba const char *term = getenv("TERM"); if (term && !strcmp(term, "dumb")) SetUseColor(false); + // Turn off use-color if we don't write to a terminal with color support. + if (!m_output_file_sp->GetFile().GetIsTerminalWithColors()) +SetUseColor(false); } Debugger::~Debugger() { Clear(); } ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] r340748 - Let the CompilerInstance create our clang ASTContext
Author: teemperor Date: Mon Aug 27 08:18:33 2018 New Revision: 340748 URL: http://llvm.org/viewvc/llvm-project?rev=340748&view=rev Log: Let the CompilerInstance create our clang ASTContext Summary: Now that we moved the BuiltinContext and SelectorTable to the CompilerInstance, we can also get rid of manually creating our own ASTContext, but just use the one from the CompilerInstance (which will be created with the same settings). Reviewers: vsk, aprantl, davide Reviewed By: davide Subscribers: lldb-commits Differential Revision: https://reviews.llvm.org/D51253 Modified: lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp Modified: lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp?rev=340748&r1=340747&r2=340748&view=diff == --- lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp (original) +++ lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp Mon Aug 27 08:18:33 2018 @@ -517,12 +517,8 @@ ClangExpressionParser::ClangExpressionPa builtin_context.initializeBuiltins(PP.getIdentifierTable(), m_compiler->getLangOpts()); - std::unique_ptr ast_context( - new ASTContext(m_compiler->getLangOpts(), m_compiler->getSourceManager(), - m_compiler->getPreprocessor().getIdentifierTable(), - PP.getSelectorTable(), builtin_context)); - - ast_context->InitBuiltinTypes(m_compiler->getTarget()); + m_compiler->createASTContext(); + clang::ASTContext &ast_context = m_compiler->getASTContext(); ClangExpressionHelper *type_system_helper = dyn_cast(m_expr.GetTypeSystemHelper()); @@ -531,14 +527,13 @@ ClangExpressionParser::ClangExpressionPa if (decl_map) { llvm::IntrusiveRefCntPtr ast_source( decl_map->CreateProxy()); -decl_map->InstallASTContext(*ast_context, m_compiler->getFileManager()); -ast_context->setExternalSource(ast_source); +decl_map->InstallASTContext(ast_context, m_compiler->getFileManager()); +ast_context.setExternalSource(ast_source); } m_ast_context.reset( new ClangASTContext(m_compiler->getTargetOpts().Triple.c_str())); - m_ast_context->setASTContext(ast_context.get()); - m_compiler->setASTContext(ast_context.release()); + m_ast_context->setASTContext(&ast_context); std::string module_name("$__lldb_module"); ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] r340835 - Use a RAII guard to control access to DisassemblerLLVMC.
Author: teemperor Date: Tue Aug 28 08:31:01 2018 New Revision: 340835 URL: http://llvm.org/viewvc/llvm-project?rev=340835&view=rev Log: Use a RAII guard to control access to DisassemblerLLVMC. Summary: This patch replaces the manual lock/unlock calls for gaining exclusive access to the disassembler with a RAII-powered access scope. This should prevent that we somehow skip over these trailing Unlock calls (e.g. with early returns). We also have a second `GetDisasmToUse` method now that takes an already constructed access scope to prevent deadlocks when we call this from other methods. Reviewers: #lldb, davide, vsk Reviewed By: #lldb, davide, vsk Subscribers: davide, vsk, lldb-commits Differential Revision: https://reviews.llvm.org/D51319 Modified: lldb/trunk/source/Plugins/Disassembler/llvm/DisassemblerLLVMC.cpp lldb/trunk/source/Plugins/Disassembler/llvm/DisassemblerLLVMC.h Modified: lldb/trunk/source/Plugins/Disassembler/llvm/DisassemblerLLVMC.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Disassembler/llvm/DisassemblerLLVMC.cpp?rev=340835&r1=340834&r2=340835&view=diff == --- lldb/trunk/source/Plugins/Disassembler/llvm/DisassemblerLLVMC.cpp (original) +++ lldb/trunk/source/Plugins/Disassembler/llvm/DisassemblerLLVMC.cpp Tue Aug 28 08:31:01 2018 @@ -98,16 +98,15 @@ public: bool DoesBranch() override { if (m_does_branch == eLazyBoolCalculate) { - std::shared_ptr disasm_sp(GetDisassembler()); - if (disasm_sp) { -disasm_sp->Lock(this, NULL); + DisassemblerScope disasm(*this); + if (disasm) { DataExtractor data; if (m_opcode.GetData(data)) { bool is_alternate_isa; lldb::addr_t pc = m_address.GetFileAddress(); DisassemblerLLVMC::MCDisasmInstance *mc_disasm_ptr = - GetDisasmToUse(is_alternate_isa); + GetDisasmToUse(is_alternate_isa, disasm); const uint8_t *opcode_data = data.GetDataStart(); const size_t opcode_data_len = data.GetByteSize(); llvm::MCInst inst; @@ -125,7 +124,6 @@ public: m_does_branch = eLazyBoolNo; } } -disasm_sp->Unlock(); } } return m_does_branch == eLazyBoolYes; @@ -133,16 +131,15 @@ public: bool HasDelaySlot() override { if (m_has_delay_slot == eLazyBoolCalculate) { - std::shared_ptr disasm_sp(GetDisassembler()); - if (disasm_sp) { -disasm_sp->Lock(this, NULL); + DisassemblerScope disasm(*this); + if (disasm) { DataExtractor data; if (m_opcode.GetData(data)) { bool is_alternate_isa; lldb::addr_t pc = m_address.GetFileAddress(); DisassemblerLLVMC::MCDisasmInstance *mc_disasm_ptr = - GetDisasmToUse(is_alternate_isa); + GetDisasmToUse(is_alternate_isa, disasm); const uint8_t *opcode_data = data.GetDataStart(); const size_t opcode_data_len = data.GetByteSize(); llvm::MCInst inst; @@ -160,27 +157,14 @@ public: m_has_delay_slot = eLazyBoolNo; } } -disasm_sp->Unlock(); } } return m_has_delay_slot == eLazyBoolYes; } DisassemblerLLVMC::MCDisasmInstance *GetDisasmToUse(bool &is_alternate_isa) { -is_alternate_isa = false; -std::shared_ptr disasm_sp(GetDisassembler()); -if (disasm_sp) { - if (disasm_sp->m_alternate_disasm_up) { -const AddressClass address_class = GetAddressClass(); - -if (address_class == AddressClass::eCodeAlternateISA) { - is_alternate_isa = true; - return disasm_sp->m_alternate_disasm_up.get(); -} - } - return disasm_sp->m_disasm_up.get(); -} -return nullptr; +DisassemblerScope disasm(*this); +return GetDisasmToUse(is_alternate_isa, disasm); } size_t Decode(const lldb_private::Disassembler &disassembler, @@ -189,9 +173,9 @@ public: // All we have to do is read the opcode which can be easy for some // architectures bool got_op = false; -std::shared_ptr disasm_sp(GetDisassembler()); -if (disasm_sp) { - const ArchSpec &arch = disasm_sp->GetArchitecture(); +DisassemblerScope disasm(*this); +if (disasm) { + const ArchSpec &arch = disasm->GetArchitecture(); const lldb::ByteOrder byte_order = data.GetByteOrder(); const uint32_t min_op_byte_size = arch.GetMinimumOpcodeByteSize(); @@ -232,7 +216,7 @@ public: if (!got_op) { bool is_alternate_isa = false; DisassemblerLLVMC::MCDisasmInstance *mc_disasm_ptr = -GetDisasmToUse(is_alternate_isa); +GetDisasmToUse(is_alternate_isa, disasm); const llvm::Triple::ArchType machine = arch.GetMachine(); if (machine == llvm::Triple::arm || machine == llvm::Triple::thumb) { @@ -261,10 +245,8 @@ public:
[Lldb-commits] [lldb] r340876 - [lldb] Fix lldb build on musl
Author: teemperor Date: Tue Aug 28 15:17:28 2018 New Revision: 340876 URL: http://llvm.org/viewvc/llvm-project?rev=340876&view=rev Log: [lldb] Fix lldb build on musl Summary: limits.h is needed for getting PATH_MAX definition, this comes to fore with musl libc where limits.h is not included indirectly via other system headers. Patch by Khem Raj, thanks! Reviewers: compnerd Reviewed By: compnerd Subscribers: llvm-commits Tags: #lldb Differential Revision: https://reviews.llvm.org/D31275 Modified: lldb/trunk/source/Utility/FileSpec.cpp Modified: lldb/trunk/source/Utility/FileSpec.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Utility/FileSpec.cpp?rev=340876&r1=340875&r2=340876&view=diff == --- lldb/trunk/source/Utility/FileSpec.cpp (original) +++ lldb/trunk/source/Utility/FileSpec.cpp Tue Aug 28 15:17:28 2018 @@ -27,6 +27,7 @@ #include// for vector #include // for assert +#include // for PATH_MAX #include // for size_t, NULL, snpr... #include // for strcmp ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] r340958 - Removed commented out includes [NFC]
Author: teemperor Date: Wed Aug 29 12:55:33 2018 New Revision: 340958 URL: http://llvm.org/viewvc/llvm-project?rev=340958&view=rev Log: Removed commented out includes [NFC] Modified: lldb/trunk/include/lldb/DataFormatters/ValueObjectPrinter.h Modified: lldb/trunk/include/lldb/DataFormatters/ValueObjectPrinter.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/DataFormatters/ValueObjectPrinter.h?rev=340958&r1=340957&r2=340958&view=diff == --- lldb/trunk/include/lldb/DataFormatters/ValueObjectPrinter.h (original) +++ lldb/trunk/include/lldb/DataFormatters/ValueObjectPrinter.h Wed Aug 29 12:55:33 2018 @@ -24,10 +24,6 @@ #include "lldb/DataFormatters/DumpValueObjectOptions.h" #include "lldb/Symbol/CompilerType.h" -//#include -//#include -//#include - namespace lldb_private { class ValueObjectPrinter { ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] r340988 - Don't cancel the current IOHandler when we push a handler for an utility function run.
Author: teemperor Date: Wed Aug 29 15:50:54 2018 New Revision: 340988 URL: http://llvm.org/viewvc/llvm-project?rev=340988&view=rev Log: Don't cancel the current IOHandler when we push a handler for an utility function run. Summary: D48465 is currently blocked by the fact that tab-completing the first expression is deadlocking LLDB. The reason for this deadlock is that when we push the ProcessIO handler for reading the Objective-C runtime information from the executable (which is triggered when we parse the an expression for the first time), the IOHandler can't be pushed as the Editline::Cancel method is deadlocking. The deadlock in Editline is coming from the m_output_mutex, which is locked before we go into tab completion. Even without this lock, calling Cancel on Editline will mean that Editline cleans up behind itself and deletes the current user-input, which is screws up the console when we are tab-completing at the same time. I think for now the most reasonable way of fixing this is to just not call Cancel on the current IOHandler when we push the IOHandler for running an internal utility function. As we can't really write unit tests for IOHandler itself (due to the hard dependency on an initialized Debugger including all its global state) and Editline completion is currently also not really testable in an automatic fashion, the test for this has to be that the expression command completion in D48465 doesn't fail when requesting completion the first time. A more precise test plan for this is: 1. Apply D48465. 2. Start lldb and break in some function. 3. Type `expr foo` and press tab to request completion. 4. Without this patch, we deadlock and LLDB stops responding. I'll provide an actual unit test for this once I got around and made the IOHandler code testable, but for now unblocking D48465 is more critical. Thanks to Jim for helping me debugging this. Reviewers: jingham Reviewed By: jingham Subscribers: emaste, clayborg, abidh, lldb-commits Differential Revision: https://reviews.llvm.org/D50912 Modified: lldb/trunk/include/lldb/Core/Debugger.h lldb/trunk/include/lldb/Target/Process.h lldb/trunk/include/lldb/Target/Target.h lldb/trunk/source/Core/Debugger.cpp lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp lldb/trunk/source/Plugins/Platform/POSIX/PlatformPOSIX.cpp lldb/trunk/source/Plugins/SystemRuntime/MacOSX/AppleGetItemInfoHandler.cpp lldb/trunk/source/Plugins/SystemRuntime/MacOSX/AppleGetPendingItemsHandler.cpp lldb/trunk/source/Plugins/SystemRuntime/MacOSX/AppleGetQueuesHandler.cpp lldb/trunk/source/Plugins/SystemRuntime/MacOSX/AppleGetThreadItemInfoHandler.cpp lldb/trunk/source/Target/Process.cpp Modified: lldb/trunk/include/lldb/Core/Debugger.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/Debugger.h?rev=340988&r1=340987&r2=340988&view=diff == --- lldb/trunk/include/lldb/Core/Debugger.h (original) +++ lldb/trunk/include/lldb/Core/Debugger.h Wed Aug 29 15:50:54 2018 @@ -192,7 +192,8 @@ public: lldb::StreamFileSP &out, lldb::StreamFileSP &err); - void PushIOHandler(const lldb::IOHandlerSP &reader_sp); + void PushIOHandler(const lldb::IOHandlerSP &reader_sp, + bool cancel_top_handler = true); bool PopIOHandler(const lldb::IOHandlerSP &reader_sp); Modified: lldb/trunk/include/lldb/Target/Process.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/Process.h?rev=340988&r1=340987&r2=340988&view=diff == --- lldb/trunk/include/lldb/Target/Process.h (original) +++ lldb/trunk/include/lldb/Target/Process.h Wed Aug 29 15:50:54 2018 @@ -402,7 +402,8 @@ class ProcessModID { public: ProcessModID() : m_stop_id(0), m_last_natural_stop_id(0), m_resume_id(0), m_memory_id(0), -m_last_user_expression_resume(0), m_running_user_expression(false) {} +m_last_user_expression_resume(0), m_running_user_expression(false), +m_running_utility_function(0) {} ProcessModID(const ProcessModID &rhs) : m_stop_id(rhs.m_stop_id), m_memory_id(rhs.m_memory_id) {} @@ -431,6 +432,10 @@ public: m_last_user_expression_resume = m_resume_id; } + bool IsRunningUtilityFunction() const { +return m_running_utility_function > 0; + } + uint32_t GetStopID() const { return m_stop_id; } uint32_t GetLastNaturalStopID() const { return m_last_natural_stop_id; } uint32_t GetMemoryID() const { return m_memory_id; } @@ -467,6 +472,17 @@ public: m_running_user_expression--; } + void SetRunningUtilityFunction(bool on) { +if (on) + m_running_utility_functio
[Lldb-commits] [lldb] r341003 - Move the column marking functionality to the Highlighter framework
Author: teemperor Date: Wed Aug 29 17:09:21 2018 New Revision: 341003 URL: http://llvm.org/viewvc/llvm-project?rev=341003&view=rev Log: Move the column marking functionality to the Highlighter framework Summary: The syntax highlighting feature so far is mutually exclusive with the lldb feature that marks the current column in the line by underlining it via an ANSI color code. Meaning that if you enable one, the other is automatically disabled by LLDB. This was caused by the fact that both features inserted color codes into the the source code and were likely to interfere with each other (which would result in a broken source code printout to the user). This patch moves the cursor code into the highlighting framework, which provides the same feature to the user in normal non-C source code. For any source code that is highlighted by Clang, we now also have cursor marking for the whole token that is under the current source location. E.g., before we underlined only the '!' in the expression '1 != 2', but now the whole token '!=' is underlined. The same for function calls and so on. Below you can see two examples where we before only underlined the first character of the token, but now underline the whole token. {F7075400} {F7075414} It also simplifies the DisplaySourceLines method in the SourceManager as most of the code in there was essentially just for getting this column marker to work as a FormatEntity. Reviewers: aprantl Reviewed By: aprantl Subscribers: lldb-commits Differential Revision: https://reviews.llvm.org/D51466 Modified: lldb/trunk/include/lldb/Core/Debugger.h lldb/trunk/include/lldb/Core/Highlighter.h lldb/trunk/include/lldb/Core/SourceManager.h lldb/trunk/packages/Python/lldbsuite/test/source-manager/TestSourceManager.py lldb/trunk/source/Core/Debugger.cpp lldb/trunk/source/Core/Highlighter.cpp lldb/trunk/source/Core/SourceManager.cpp lldb/trunk/source/Plugins/Language/ClangCommon/ClangHighlighter.cpp lldb/trunk/source/Plugins/Language/ClangCommon/ClangHighlighter.h lldb/trunk/unittests/Language/Highlighting/HighlighterTest.cpp Modified: lldb/trunk/include/lldb/Core/Debugger.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/Debugger.h?rev=341003&r1=341002&r2=341003&view=diff == --- lldb/trunk/include/lldb/Core/Debugger.h (original) +++ lldb/trunk/include/lldb/Core/Debugger.h Wed Aug 29 17:09:21 2018 @@ -277,9 +277,9 @@ public: lldb::StopShowColumn GetStopShowColumn() const; - const FormatEntity::Entry *GetStopShowColumnAnsiPrefix() const; + llvm::StringRef GetStopShowColumnAnsiPrefix() const; - const FormatEntity::Entry *GetStopShowColumnAnsiSuffix() const; + llvm::StringRef GetStopShowColumnAnsiSuffix() const; uint32_t GetStopSourceLineCount(bool before) const; Modified: lldb/trunk/include/lldb/Core/Highlighter.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/Highlighter.h?rev=341003&r1=341002&r2=341003&view=diff == --- lldb/trunk/include/lldb/Core/Highlighter.h (original) +++ lldb/trunk/include/lldb/Core/Highlighter.h Wed Aug 29 17:09:21 2018 @@ -53,6 +53,11 @@ struct HighlightStyle { void Set(llvm::StringRef prefix, llvm::StringRef suffix); }; + /// The style for the token which is below the cursor of the user. Note that + /// this style is overwritten by the SourceManager with the values of + /// stop-show-column-ansi-prefix/stop-show-column-ansi-suffix. + ColorStyle selected; + /// Matches identifiers to variable or functions. ColorStyle identifier; /// Matches any string or character literals in the language: "foo" or 'f' @@ -106,6 +111,9 @@ public: /// \param options /// \param line /// The user supplied line that needs to be highlighted. + /// \param cursor_pos + /// The cursor position of the user in this line, starting at 0 (which + /// means the cursor is on the first character in 'line'). /// \param previous_lines /// Any previous lines the user has written which we should only use /// for getting the context of the Highlighting right. @@ -113,25 +121,29 @@ public: /// The stream to which the highlighted version of the user string should /// be written. virtual void Highlight(const HighlightStyle &options, llvm::StringRef line, + llvm::Optional cursor_pos, llvm::StringRef previous_lines, Stream &s) const = 0; /// Utility method for calling Highlight without a stream. std::string Highlight(const HighlightStyle &options, llvm::StringRef line, +llvm::Optional cursor_pos, llvm::StringRef previous_lines = "") const; }; -/// A default highlighter that does nothing. Used as a fallback. -class NoHighlighter : public Highlighter
[Lldb-commits] [lldb] r341086 - Added initial code completion support for the `expr` command
Author: teemperor Date: Thu Aug 30 10:29:37 2018 New Revision: 341086 URL: http://llvm.org/viewvc/llvm-project?rev=341086&view=rev Log: Added initial code completion support for the `expr` command Summary: This patch adds initial code completion support for the `expr` command. We now have a completion handler in the expression CommandObject that essentially just attempts to parse the given user expression with Clang with an attached code completion consumer. We filter and prepare the code completions provided by Clang and send them back to the completion API. The current completion is limited to variables that are in the current scope. This includes local variables and all types used by local variables. We however don't do any completion of symbols that are not used in the local scope (or in some other way already in the ASTContext). This is partly because there is not yet any code that manually searches for additiona information in the debug information. Another cause is that for some reason the existing code for loading these additional symbols when requested by Clang doesn't seem to work. This will be fixed in a future patch. Reviewers: jingham, teemperor Reviewed By: teemperor Subscribers: labath, aprantl, JDevlieghere, friss, lldb-commits Differential Revision: https://reviews.llvm.org/D48465 Added: lldb/trunk/packages/Python/lldbsuite/test/expression_command/completion/ lldb/trunk/packages/Python/lldbsuite/test/expression_command/completion/.categories lldb/trunk/packages/Python/lldbsuite/test/expression_command/completion/Makefile lldb/trunk/packages/Python/lldbsuite/test/expression_command/completion/TestExprCompletion.py lldb/trunk/packages/Python/lldbsuite/test/expression_command/completion/main.cpp lldb/trunk/packages/Python/lldbsuite/test/expression_command/completion/other.cpp Modified: lldb/trunk/include/lldb/Expression/ExpressionParser.h lldb/trunk/include/lldb/Expression/UserExpression.h lldb/trunk/packages/Python/lldbsuite/test/functionalities/completion/TestCompletion.py lldb/trunk/packages/Python/lldbsuite/test/lldbtest.py lldb/trunk/source/Commands/CommandObjectExpression.cpp lldb/trunk/source/Commands/CommandObjectExpression.h lldb/trunk/source/Plugins/ExpressionParser/Clang/ASTResultSynthesizer.cpp lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.h lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangUserExpression.h Modified: lldb/trunk/include/lldb/Expression/ExpressionParser.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Expression/ExpressionParser.h?rev=341086&r1=341085&r2=341086&view=diff == --- lldb/trunk/include/lldb/Expression/ExpressionParser.h (original) +++ lldb/trunk/include/lldb/Expression/ExpressionParser.h Thu Aug 30 10:29:37 2018 @@ -50,6 +50,41 @@ public: virtual ~ExpressionParser(){}; //-- + /// Attempts to find possible command line completions for the given + /// expression. + /// + /// @param[out] matches + /// The list of completions that should be appended with string + /// that would complete the current token at the cursor position. + /// Note that the string in the list replaces the current token + /// in the command line. + /// + /// @param[in] line + /// The line with the completion cursor inside the expression as a string. + /// The first line in the expression has the number 0. + /// + /// @param[in] pos + /// The character position in the line with the completion cursor. + /// If the value is 0, then the cursor is on top of the first character + /// in the line (i.e. the user has requested completion from the start of + /// the expression). + /// + /// @param[in] typed_pos + /// The cursor position in the line as typed by the user. If the user + /// expression has not been transformed in some form (e.g. wrapping it + /// in a function body for C languages), then this is equal to the + /// 'pos' parameter. The semantics of this value are otherwise equal to + /// 'pos' (e.g. a value of 0 means the cursor is at start of the + /// expression). + /// + /// @return + /// True if we added any completion results to the output; + /// false otherwise. + //-- + virtual bool Complete(StringList &matches, unsigned line, unsigned pos, +unsigned typed_pos) = 0; + + //-- /// Parse a single expression and convert it to IR using Clang. Don't wrap /// the expression in anything at all. ///
[Lldb-commits] [lldb] r341089 - Move Predicate.h from Host to Utility
Author: teemperor Date: Thu Aug 30 10:51:10 2018 New Revision: 341089 URL: http://llvm.org/viewvc/llvm-project?rev=341089&view=rev Log: Move Predicate.h from Host to Utility Summary: This class was initially in Host because its implementation used to be very OS-specific. However, with C++11, it has become a very simple std::condition_variable wrapper, with no host-specific code. It is also a general purpose utility class, so it makes sense for it to live in a place where it can be used by everyone. This has no effect on the layering right now, but it enables me to later move the Listener+Broadcaster+Event combo to a lower layer, which is important, as these are used in a lot of places (notably for launching a process in Host code). Reviewers: jingham, zturner, teemperor Reviewed By: zturner Subscribers: xiaobai, mgorny, lldb-commits Differential Revision: https://reviews.llvm.org/D50384 Added: lldb/trunk/include/lldb/Utility/Predicate.h - copied, changed from r341086, lldb/trunk/include/lldb/Host/Predicate.h lldb/trunk/unittests/Utility/PredicateTest.cpp - copied, changed from r341086, lldb/trunk/unittests/Host/PredicateTest.cpp Removed: lldb/trunk/include/lldb/Host/Predicate.h lldb/trunk/unittests/Host/PredicateTest.cpp Modified: lldb/trunk/include/lldb/Core/Event.h lldb/trunk/include/lldb/Core/IOHandler.h lldb/trunk/include/lldb/Host/Editline.h lldb/trunk/include/lldb/Host/Socket.h lldb/trunk/include/lldb/Host/posix/ConnectionFileDescriptorPosix.h lldb/trunk/include/lldb/module.modulemap lldb/trunk/source/Core/IOHandler.cpp lldb/trunk/source/Host/common/Host.cpp lldb/trunk/source/Plugins/Process/MacOSX-Kernel/CommunicationKDP.h lldb/trunk/source/Plugins/Process/Windows/Common/DebuggerThread.cpp lldb/trunk/source/Plugins/Process/Windows/Common/DebuggerThread.h lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.h lldb/trunk/unittests/Core/BroadcasterTest.cpp lldb/trunk/unittests/Host/CMakeLists.txt lldb/trunk/unittests/Utility/CMakeLists.txt Modified: lldb/trunk/include/lldb/Core/Event.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/Event.h?rev=341089&r1=341088&r2=341089&view=diff == --- lldb/trunk/include/lldb/Core/Event.h (original) +++ lldb/trunk/include/lldb/Core/Event.h Thu Aug 30 10:51:10 2018 @@ -11,8 +11,8 @@ #define liblldb_Event_h_ #include "lldb/Core/Broadcaster.h" -#include "lldb/Host/Predicate.h" #include "lldb/Utility/ConstString.h" +#include "lldb/Utility/Predicate.h" #include "lldb/Utility/StructuredData.h" #include "lldb/lldb-defines.h" // for DISALLOW_COPY_AND_ASSIGN #include "lldb/lldb-forward.h" // for EventDataSP, ProcessSP, Struct... Modified: lldb/trunk/include/lldb/Core/IOHandler.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/IOHandler.h?rev=341089&r1=341088&r2=341089&view=diff == --- lldb/trunk/include/lldb/Core/IOHandler.h (original) +++ lldb/trunk/include/lldb/Core/IOHandler.h Thu Aug 30 10:51:10 2018 @@ -11,9 +11,9 @@ #define liblldb_IOHandler_h_ #include "lldb/Core/ValueObjectList.h" -#include "lldb/Host/Predicate.h" #include "lldb/Utility/ConstString.h" #include "lldb/Utility/Flags.h" +#include "lldb/Utility/Predicate.h" #include "lldb/Utility/Stream.h" #include "lldb/Utility/StringList.h" #include "lldb/lldb-defines.h" // for DISALLOW_COPY_AND_ASSIGN Modified: lldb/trunk/include/lldb/Host/Editline.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Host/Editline.h?rev=341089&r1=341088&r2=341089&view=diff == --- lldb/trunk/include/lldb/Host/Editline.h (original) +++ lldb/trunk/include/lldb/Host/Editline.h Thu Aug 30 10:51:10 2018 @@ -54,8 +54,8 @@ #include #include "lldb/Host/ConnectionFileDescriptor.h" -#include "lldb/Host/Predicate.h" #include "lldb/Utility/FileSpec.h" +#include "lldb/Utility/Predicate.h" namespace lldb_private { namespace line_editor { Removed: lldb/trunk/include/lldb/Host/Predicate.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Host/Predicate.h?rev=341088&view=auto == --- lldb/trunk/include/lldb/Host/Predicate.h (original) +++ lldb/trunk/include/lldb/Host/Predicate.h (removed) @@ -1,260 +0,0 @@ -//===-- Predicate.h -*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===--===// - -#ifndef liblldb_Predicate_h_ -#define liblldb_Predicate_h_ - -// C Includes -#include -
[Lldb-commits] [lldb] r341105 - Fixed code style for the CodeCompletion members [NFC]
Author: teemperor Date: Thu Aug 30 12:47:53 2018 New Revision: 341105 URL: http://llvm.org/viewvc/llvm-project?rev=341105&view=rev Log: Fixed code style for the CodeCompletion members [NFC] This code is in LLDB, so it should also follow the LLDB code style and use the m_ prefix for members. Modified: lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp Modified: lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp?rev=341105&r1=341104&r2=341105&view=diff == --- lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp (original) +++ lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp Thu Aug 30 12:47:53 2018 @@ -558,11 +558,11 @@ namespace { /// of an incomplete `expr` invocation. //-- class CodeComplete : public CodeCompleteConsumer { - CodeCompletionTUInfo CCTUInfo; + CodeCompletionTUInfo m_info; - std::string expr; - unsigned position = 0; - StringList &matches; + std::string m_expr; + unsigned m_position = 0; + StringList &m_matches; /// Returns true if the given character can be used in an identifier. /// This also returns true for numbers because for completion we usually @@ -639,8 +639,8 @@ public: /// CodeComplete(StringList &matches, std::string expr, unsigned position) : CodeCompleteConsumer(CodeCompleteOptions(), false), -CCTUInfo(std::make_shared()), expr(expr), -position(position), matches(matches) {} +m_info(std::make_shared()), m_expr(expr), +m_position(position), m_matches(matches) {} /// Deregisters and destroys this code-completion consumer. virtual ~CodeComplete() {} @@ -734,8 +734,8 @@ public: // Merge the suggested Token into the existing command line to comply // with the kind of result the lldb API expects. std::string CompletionSuggestion = -mergeCompletion(expr, position, ToInsert); -matches.AppendString(CompletionSuggestion); +mergeCompletion(m_expr, m_position, ToInsert); +m_matches.AppendString(CompletionSuggestion); } } } @@ -756,10 +756,10 @@ public: } CodeCompletionAllocator &getAllocator() override { -return CCTUInfo.getAllocator(); +return m_info.getAllocator(); } - CodeCompletionTUInfo &getCodeCompletionTUInfo() override { return CCTUInfo; } + CodeCompletionTUInfo &getCodeCompletionTUInfo() override { return m_info; } }; } // namespace ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] r341109 - Added missing include to for 'std::isalnum'
Author: teemperor Date: Thu Aug 30 13:14:22 2018 New Revision: 341109 URL: http://llvm.org/viewvc/llvm-project?rev=341109&view=rev Log: Added missing include to for 'std::isalnum' Should fix the failing Windows bots. Modified: lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp Modified: lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp?rev=341109&r1=341108&r2=341109&view=diff == --- lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp (original) +++ lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp Thu Aug 30 13:14:22 2018 @@ -9,6 +9,7 @@ // C Includes // C++ Includes +#include // for alnum // Other libraries and framework includes #include "clang/AST/ASTContext.h" #include "clang/AST/ASTDiagnostic.h" ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] r341112 - Adjusting some comments in ClangExpressionParser.cpp
Author: teemperor Date: Thu Aug 30 13:19:57 2018 New Revision: 341112 URL: http://llvm.org/viewvc/llvm-project?rev=341112&view=rev Log: Adjusting some comments in ClangExpressionParser.cpp Modified: lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp Modified: lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp?rev=341112&r1=34&r2=341112&view=diff == --- lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp (original) +++ lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp Thu Aug 30 13:19:57 2018 @@ -706,7 +706,7 @@ public: else ToInsert += "("; } -// If we try to complete a namespace, then we directly can append +// If we try to complete a namespace, then we can directly append // the '::'. if (const NamespaceDecl *N = dyn_cast(D)) { if (!N->isAnonymousNamespace()) @@ -718,7 +718,6 @@ public: ToInsert = R.Keyword; break; case CodeCompletionResult::RK_Macro: -// It's not clear if we want to complete any macros in the ToInsert = R.Macro->getName().str(); break; case CodeCompletionResult::RK_Pattern: ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] r341121 - Move NoBuiltin=true closer to the other LangOpts code [NFC]
Author: teemperor Date: Thu Aug 30 13:56:58 2018 New Revision: 341121 URL: http://llvm.org/viewvc/llvm-project?rev=341121&view=rev Log: Move NoBuiltin=true closer to the other LangOpts code [NFC] Modified: lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp Modified: lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp?rev=341121&r1=341120&r2=341121&view=diff == --- lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp (original) +++ lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp Thu Aug 30 13:56:58 2018 @@ -455,6 +455,10 @@ ClangExpressionParser::ClangExpressionPa false; // Debuggers get universal access m_compiler->getLangOpts().DollarIdents = true; // $ indicates a persistent variable name + // We enable all builtin functions beside the builtins from libc/libm (e.g. + // 'fopen'). Those libc functions are already correctly handled by LLDB, and + // additionally enabling them as expandable builtins is breaking Clang. + m_compiler->getLangOpts().NoBuiltin = true; // Set CodeGen options m_compiler->getCodeGenOpts().EmitDeclMetadata = true; @@ -510,10 +514,6 @@ ClangExpressionParser::ClangExpressionPa // 8. Most of this we get from the CompilerInstance, but we also want to give // the context an ExternalASTSource. - // We enable all builtin functions beside the builtins from libc/libm (e.g. - // 'fopen'). Those libc functions are already correctly handled by LLDB, and - // additionally enabling them as expandable builtins is breaking Clang. - m_compiler->getLangOpts().NoBuiltin = true; auto &PP = m_compiler->getPreprocessor(); auto &builtin_context = PP.getBuiltinInfo(); ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] r341124 - Use a CompletionRequest in the expression command completion [NFC]
Author: teemperor Date: Thu Aug 30 14:26:32 2018 New Revision: 341124 URL: http://llvm.org/viewvc/llvm-project?rev=341124&view=rev Log: Use a CompletionRequest in the expression command completion [NFC] The patch was originally written before we had a CompletionRequest, so it still used a StringList to pass back the completions to the request. Modified: lldb/trunk/include/lldb/Expression/ExpressionParser.h lldb/trunk/include/lldb/Expression/UserExpression.h lldb/trunk/source/Commands/CommandObjectExpression.cpp lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.h lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangUserExpression.h Modified: lldb/trunk/include/lldb/Expression/ExpressionParser.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Expression/ExpressionParser.h?rev=341124&r1=341123&r2=341124&view=diff == --- lldb/trunk/include/lldb/Expression/ExpressionParser.h (original) +++ lldb/trunk/include/lldb/Expression/ExpressionParser.h Thu Aug 30 14:26:32 2018 @@ -10,6 +10,7 @@ #ifndef liblldb_ExpressionParser_h_ #define liblldb_ExpressionParser_h_ +#include "lldb/Utility/CompletionRequest.h" #include "lldb/Utility/Status.h" #include "lldb/lldb-private-enumerations.h" #include "lldb/lldb-public.h" @@ -53,8 +54,8 @@ public: /// Attempts to find possible command line completions for the given /// expression. /// - /// @param[out] matches - /// The list of completions that should be appended with string + /// @param[out] request + /// The completion request to fill out. The completion should be a string /// that would complete the current token at the cursor position. /// Note that the string in the list replaces the current token /// in the command line. @@ -81,7 +82,7 @@ public: /// True if we added any completion results to the output; /// false otherwise. //-- - virtual bool Complete(StringList &matches, unsigned line, unsigned pos, + virtual bool Complete(CompletionRequest &request, unsigned line, unsigned pos, unsigned typed_pos) = 0; //-- Modified: lldb/trunk/include/lldb/Expression/UserExpression.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Expression/UserExpression.h?rev=341124&r1=341123&r2=341124&view=diff == --- lldb/trunk/include/lldb/Expression/UserExpression.h (original) +++ lldb/trunk/include/lldb/Expression/UserExpression.h Thu Aug 30 14:26:32 2018 @@ -121,7 +121,7 @@ public: /// True if we added any completion results to the output; /// false otherwise. //-- - virtual bool Complete(ExecutionContext &exe_ctx, StringList &matches, + virtual bool Complete(ExecutionContext &exe_ctx, CompletionRequest &request, unsigned complete_pos) { return false; } Modified: lldb/trunk/source/Commands/CommandObjectExpression.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectExpression.cpp?rev=341124&r1=341123&r2=341124&view=diff == --- lldb/trunk/source/Commands/CommandObjectExpression.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectExpression.cpp Thu Aug 30 14:26:32 2018 @@ -369,9 +369,7 @@ int CommandObjectExpression::HandleCompl if (error.Fail()) return 0; - StringList matches; - expr->Complete(exe_ctx, matches, cursor_pos); - request.AddCompletions(matches); + expr->Complete(exe_ctx, request, cursor_pos); return request.GetNumberOfMatches(); } Modified: lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp?rev=341124&r1=341123&r2=341124&view=diff == --- lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp (original) +++ lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp Thu Aug 30 14:26:32 2018 @@ -563,7 +563,7 @@ class CodeComplete : public CodeComplete std::string m_expr; unsigned m_position = 0; - StringList &m_matches; + CompletionRequest &m_request; /// Returns true if the given character can be used in an identifier. /// This also returns true for numbers because for completion we usually @@ -638,10 +638,10 @@ public: /// @param[out] position ///
[Lldb-commits] [lldb] r341126 - Fixed comment for UserExpression::Complete [NFC]
Author: teemperor Date: Thu Aug 30 14:31:04 2018 New Revision: 341126 URL: http://llvm.org/viewvc/llvm-project?rev=341126&view=rev Log: Fixed comment for UserExpression::Complete [NFC] Modified: lldb/trunk/include/lldb/Expression/UserExpression.h Modified: lldb/trunk/include/lldb/Expression/UserExpression.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Expression/UserExpression.h?rev=341126&r1=341125&r2=341126&view=diff == --- lldb/trunk/include/lldb/Expression/UserExpression.h (original) +++ lldb/trunk/include/lldb/Expression/UserExpression.h Thu Aug 30 14:31:04 2018 @@ -107,8 +107,8 @@ public: /// are needed for parsing and completing (locations of functions, types /// of variables, persistent variables, etc.) /// - /// @param[out] matches - /// The list of completions that should be appended with string + /// @param[out] request + /// The completion request to fill out. The completion should be a string /// that would complete the current token at the cursor position. /// Note that the string in the list replaces the current token /// in the command line. ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] r341157 - Fixed missing sidebars on the website
Author: teemperor Date: Thu Aug 30 19:07:05 2018 New Revision: 341157 URL: http://llvm.org/viewvc/llvm-project?rev=341157&view=rev Log: Fixed missing sidebars on the website We didn't mark these HTML files as executable, which means that the SSI includes for including the sidebar didn't work. Modified: lldb/trunk/www/SB-api-coding-rules.html (contents, props changed) lldb/trunk/www/remote.html (contents, props changed) lldb/trunk/www/test.html (contents, props changed) Modified: lldb/trunk/www/SB-api-coding-rules.html URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/www/SB-api-coding-rules.html?rev=341157&r1=341156&r2=341157&view=diff == (empty) Propchange: lldb/trunk/www/SB-api-coding-rules.html -- svn:executable = * Modified: lldb/trunk/www/remote.html URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/www/remote.html?rev=341157&r1=341156&r2=341157&view=diff == (empty) Propchange: lldb/trunk/www/remote.html -- svn:executable = * Modified: lldb/trunk/www/test.html URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/www/test.html?rev=341157&r1=341156&r2=341157&view=diff == (empty) Propchange: lldb/trunk/www/test.html -- svn:executable = * ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] r341471 - [www] Updated outdated download links [NFC]
Author: teemperor Date: Wed Sep 5 07:27:48 2018 New Revision: 341471 URL: http://llvm.org/viewvc/llvm-project?rev=341471&view=rev Log: [www] Updated outdated download links [NFC] Also added ubuntu and Arch Linux links. Modified: lldb/trunk/www/download.html Modified: lldb/trunk/www/download.html URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/www/download.html?rev=341471&r1=341470&r2=341471&view=diff == --- lldb/trunk/www/download.html (original) +++ lldb/trunk/www/download.html Wed Sep 5 07:27:48 2018 @@ -36,16 +36,19 @@ LLDB releases - Debian packages are available for LLDB 3.2 and later. + Debian packages are available for LLDB 3.5 and later. - http://packages.debian.org/experimental/lldb-3.4";>LLDB 3.4 - incremental release (experimental) - - http://packages.debian.org/experimental/amd64/lldb-3.4/download";>amd64 (x86-64) - http://packages.debian.org/experimental/s390/lldb-3.4/download";>System/390 (i386) - - http://packages.debian.org/unstable/lldb-3.3";>LLDB 3.3 (unstable) - http://packages.debian.org/unstable/lldb-3.2";>LLDB 3.2 (unstable) + https://packages.debian.org/jessie/lldb";>jessie - LLDB 3.5 + https://packages.debian.org/stretch/lldb";>stretch - LLDB 3.8 + https://packages.debian.org/buster/lldb";>buster - LLDB 6.0 + https://packages.debian.org/sid/lldb";>sid - LLDB 6.0 + ubuntu packages are available for LLDB 3.8 and later. + + https://packages.ubuntu.com/xenial/lldb";>ubuntu 16.04LTS - LLDB 3.8 + https://packages.ubuntu.com/bionic/lldb";>ubuntu 18.04LTS - LLDB 6.0 + + Arch Linux packages the latest https://www.archlinux.org/packages/extra/x86_64/lldb/";>LLDB 6.0 ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] r341532 - Revert "[ClangUserExpression][NFC] Removed unused code"
Author: teemperor Date: Thu Sep 6 02:42:44 2018 New Revision: 341532 URL: http://llvm.org/viewvc/llvm-project?rev=341532&view=rev Log: Revert "[ClangUserExpression][NFC] Removed unused code" GetLanguageForExpr has side effects, so this actually breaks the completion. Should fix TestExprCompletion. Modified: lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp Modified: lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp?rev=341532&r1=341531&r2=341532&view=diff == --- lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp (original) +++ lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp Thu Sep 6 02:42:44 2018 @@ -655,6 +655,10 @@ bool ClangUserExpression::Complete(Execu if (!PrepareForParsing(diagnostic_manager, exe_ctx)) return false; + lldb::LanguageType lang_type = lldb::LanguageType::eLanguageTypeUnknown; + if (auto new_lang = GetLanguageForExpr(diagnostic_manager, exe_ctx)) +lang_type = new_lang.getValue(); + if (log) log->Printf("Parsing the following code:\n%s", m_transformed_text.c_str()); ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] r341535 - Reland [ClangUserExpression][NFC] Removed unused code
Author: teemperor Date: Thu Sep 6 03:24:11 2018 New Revision: 341535 URL: http://llvm.org/viewvc/llvm-project?rev=341535&view=rev Log: Reland [ClangUserExpression][NFC] Removed unused code The GetLanguageForExpr has side effects, so we can't remove this call without breaking the completion mechanism. However, we can keep the change that gets rid of this unnecessary variable. Modified: lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp Modified: lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp?rev=341535&r1=341534&r2=341535&view=diff == --- lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp (original) +++ lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp Thu Sep 6 03:24:11 2018 @@ -655,9 +655,7 @@ bool ClangUserExpression::Complete(Execu if (!PrepareForParsing(diagnostic_manager, exe_ctx)) return false; - lldb::LanguageType lang_type = lldb::LanguageType::eLanguageTypeUnknown; - if (auto new_lang = GetLanguageForExpr(diagnostic_manager, exe_ctx)) -lang_type = new_lang.getValue(); + GetLanguageForExpr(diagnostic_manager, exe_ctx); if (log) log->Printf("Parsing the following code:\n%s", m_transformed_text.c_str()); ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
Re: [Lldb-commits] [lldb] r341535 - Reland [ClangUserExpression][NFC] Removed unused code
Yeah, and we might as well refactor this function. I fell for the same trap as Dávid when I touched this code for the first time. It's just unexpected that a getter is doing important work... I'll prepare a patch. - Raphael Am Do., 6. Sep. 2018 um 16:05 Uhr schrieb Greg Clayton : > > Might be a good idea to add a comment in the code for this explaining the > desired side effects? > > > > On Sep 6, 2018, at 3:24 AM, Raphael Isemann via lldb-commits > > wrote: > > > > Author: teemperor > > Date: Thu Sep 6 03:24:11 2018 > > New Revision: 341535 > > > > URL: http://llvm.org/viewvc/llvm-project?rev=341535&view=rev > > Log: > > Reland [ClangUserExpression][NFC] Removed unused code > > > > The GetLanguageForExpr has side effects, so we can't remove this > > call without breaking the completion mechanism. However, we can > > keep the change that gets rid of this unnecessary variable. > > > > Modified: > >lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp > > > > Modified: > > lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp > > URL: > > http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp?rev=341535&r1=341534&r2=341535&view=diff > > == > > --- > > lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp > > (original) > > +++ > > lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp > > Thu Sep 6 03:24:11 2018 > > @@ -655,9 +655,7 @@ bool ClangUserExpression::Complete(Execu > > if (!PrepareForParsing(diagnostic_manager, exe_ctx)) > > return false; > > > > - lldb::LanguageType lang_type = lldb::LanguageType::eLanguageTypeUnknown; > > - if (auto new_lang = GetLanguageForExpr(diagnostic_manager, exe_ctx)) > > -lang_type = new_lang.getValue(); > > + GetLanguageForExpr(diagnostic_manager, exe_ctx); > > > > if (log) > > log->Printf("Parsing the following code:\n%s", > > m_transformed_text.c_str()); > > > > > > ___ > > lldb-commits mailing list > > lldb-commits@lists.llvm.org > > http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits > ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] r341931 - [NFC] Fix compiler warning in TestArmv7Disassembly.cpp
Author: teemperor Date: Tue Sep 11 05:45:22 2018 New Revision: 341931 URL: http://llvm.org/viewvc/llvm-project?rev=341931&view=rev Log: [NFC] Fix compiler warning in TestArmv7Disassembly.cpp The warning is comparison of integers of different signs: 'const int' and 'const unsigned long' and triggered by EXPECT_EQ (num_of_instructions, inst_list.GetSize()); as num_of_instructions is an int in this comparison (and the RHS is size_t). Modified: lldb/trunk/unittests/Disassembler/TestArmv7Disassembly.cpp Modified: lldb/trunk/unittests/Disassembler/TestArmv7Disassembly.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/unittests/Disassembler/TestArmv7Disassembly.cpp?rev=341931&r1=341930&r2=341931&view=diff == --- lldb/trunk/unittests/Disassembler/TestArmv7Disassembly.cpp (original) +++ lldb/trunk/unittests/Disassembler/TestArmv7Disassembly.cpp Tue Sep 11 05:45:22 2018 @@ -48,7 +48,7 @@ void TestArmv7Disassembly::TearDownTestC TEST_F(TestArmv7Disassembly, TestCortexFPDisass) { ArchSpec arch("armv7em--"); - const int num_of_instructions = 3; + const unsigned num_of_instructions = 3; uint8_t data[] = { 0x00, 0xee, 0x10, 0x2a, // 0xee002a10 : vmov s0, r2 0xb8, 0xee, 0xc0, 0x0b, // 0xeeb80bc0 : vcvt.f64.s32 d0, s0 ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] r341940 - Print the correct error when our DynamicCheckerFunctions fail to install
Author: teemperor Date: Tue Sep 11 06:59:47 2018 New Revision: 341940 URL: http://llvm.org/viewvc/llvm-project?rev=341940&view=rev Log: Print the correct error when our DynamicCheckerFunctions fail to install Summary: The check is inverted here: If we have error messages, we should print those instead of our default error message. But currently we print the default message when we actually have a sensible error to print. Fixes https://bugs.llvm.org/show_bug.cgi?id=38383 Thanks Nat for the patch! Reviewers: #lldb, JDevlieghere Reviewed By: JDevlieghere Subscribers: JDevlieghere, lldb-commits Differential Revision: https://reviews.llvm.org/D51602 Modified: lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp Modified: lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp?rev=341940&r1=341939&r2=341940&view=diff == --- lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp (original) +++ lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp Tue Sep 11 06:59:47 2018 @@ -1162,9 +1162,9 @@ lldb_private::Status ClangExpressionPars if (!dynamic_checkers->Install(install_diagnostics, exe_ctx)) { if (install_diagnostics.Diagnostics().size()) - err.SetErrorString("couldn't install checkers, unknown error"); -else err.SetErrorString(install_diagnostics.GetString().c_str()); +else + err.SetErrorString("couldn't install checkers, unknown error"); return err; } ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits