[Lldb-commits] [PATCH] D32167: Add support for type units (.debug_types) to LLDB in a way that is compatible with DWARF 5

2018-08-30 Thread Jan Kratochvil via Phabricator via lldb-commits
jankratochvil added a comment.

Just to clarify - I guess `DWARFConcatenatingDataExtractor` should replace all 
uses of `DWARFDataExtractor` in the `DWARF/` subdirectory, whenever 
`lldb::offset_t offset` is used, right?
As the other option would be to remap just `lldb::user_id_t` but that would not 
solve much.
BTW my https://reviews.llvm.org/D40474 patch: DWZ is using DWARF references in 
both main file `.debug_info` and in DWZ common file `.debug_info` so at least 
one of them always needs to get the read-in DWARF offsets adjusted anyway in 
`DWARFFormValue::Reference()`. Then I needed adjustments also in 
`DWARFDebugInfo::GetCompileUnitAranges()` as the DWZ common file I had to place 
from offset 0 so that it can be shared between multiple DWARF files using it, 
therefore `.debug_info` of the main files (users of DWZ common file) need to be 
shifted.
Also the DWZ common file is a separate DWARFDebugInfo so there needs to be some 
dispatcher (`DWARFDebugInfo::DWZRedirect()` in my 
https://reviews.llvm.org/D40474 DWZ patch) for it anyway, which is why I do not 
find `DWARFConcatenatingDataExtractor` as much a win for DWZ.
OTOH I do not think the DWARF parsing performance matters too much after 
`.debug_names` (or the Apple index which I haven't/cannot test) is used, why it 
should?


https://reviews.llvm.org/D32167



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D51162: [PDB] Restore AST from PDB symbols

2018-08-30 Thread Aleksandr Urakov via Phabricator via lldb-commits
aleksandr.urakov added a comment.
Herald added a subscriber: teemperor.

Ping!

Can you review this, please?


Repository:
  rLLDB LLDB

https://reviews.llvm.org/D51162



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] r341078 - Support setting a breakpoint by FileSpec+Line+Column in the SBAPI.

2018-08-30 Thread Adrian Prantl via lldb-commits
Author: adrian
Date: Thu Aug 30 08:11:00 2018
New Revision: 341078

URL: http://llvm.org/viewvc/llvm-project?rev=341078&view=rev
Log:
Support setting a breakpoint by FileSpec+Line+Column in the SBAPI.

This patch extends the SBAPI to allow for setting a breakpoint not
only at a specific line, but also at a specific (minimum) column. When
a column is specified, it will try to find an exact match or the
closest match on the same line that comes after the specified
location.

Differential Revision: https://reviews.llvm.org/D51461

Added:

lldb/trunk/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_by_line_and_column/

lldb/trunk/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_by_line_and_column/Makefile

lldb/trunk/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_by_line_and_column/TestBreakpointByLineAndColumn.py

lldb/trunk/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_by_line_and_column/main.c
Modified:
lldb/trunk/include/lldb/API/SBTarget.h
lldb/trunk/include/lldb/Breakpoint/BreakpointResolver.h
lldb/trunk/include/lldb/Breakpoint/BreakpointResolverFileLine.h
lldb/trunk/include/lldb/Target/Target.h

lldb/trunk/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_command/TestBreakpointCommand.py

lldb/trunk/packages/Python/lldbsuite/test/functionalities/breakpoint/serialize/TestBreakpointSerialization.py
lldb/trunk/packages/Python/lldbsuite/test/lldbutil.py
lldb/trunk/scripts/interface/SBTarget.i
lldb/trunk/source/API/SBTarget.cpp
lldb/trunk/source/Breakpoint/BreakpointResolver.cpp
lldb/trunk/source/Breakpoint/BreakpointResolverFileLine.cpp
lldb/trunk/source/Commands/CommandObjectBreakpoint.cpp
lldb/trunk/source/Core/IOHandler.cpp
lldb/trunk/source/Symbol/LineEntry.cpp
lldb/trunk/source/Target/Target.cpp

Modified: lldb/trunk/include/lldb/API/SBTarget.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBTarget.h?rev=341078&r1=341077&r2=341078&view=diff
==
--- lldb/trunk/include/lldb/API/SBTarget.h (original)
+++ lldb/trunk/include/lldb/API/SBTarget.h Thu Aug 30 08:11:00 2018
@@ -580,6 +580,11 @@ public:
   BreakpointCreateByLocation(const lldb::SBFileSpec &file_spec, uint32_t line,
  lldb::addr_t offset, SBFileSpecList &module_list);
 
+  lldb::SBBreakpoint
+  BreakpointCreateByLocation(const lldb::SBFileSpec &file_spec, uint32_t line,
+ uint32_t column, lldb::addr_t offset,
+ SBFileSpecList &module_list);
+
   lldb::SBBreakpoint BreakpointCreateByName(const char *symbol_name,
 const char *module_name = nullptr);
 

Modified: lldb/trunk/include/lldb/Breakpoint/BreakpointResolver.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Breakpoint/BreakpointResolver.h?rev=341078&r1=341077&r2=341078&view=diff
==
--- lldb/trunk/include/lldb/Breakpoint/BreakpointResolver.h (original)
+++ lldb/trunk/include/lldb/Breakpoint/BreakpointResolver.h Thu Aug 30 08:11:00 
2018
@@ -200,6 +200,7 @@ protected:
 Inlines,
 LanguageName,
 LineNumber,
+Column,
 ModuleName,
 NameMaskArray,
 Offset,
@@ -224,8 +225,11 @@ protected:
   /// number that matches, and then filter down the matching addresses to
   /// unique entries, and skip the prologue if asked to do so, and then set
   /// breakpoint locations in this breakpoint for all the resultant addresses.
+  /// When \p column is nonzero the \p line and \p column args are used to
+  /// filter the results to find the first breakpoint >= (line, column).
   void SetSCMatchesByLine(SearchFilter &filter, SymbolContextList &sc_list,
-  bool skip_prologue, llvm::StringRef log_ident);
+  bool skip_prologue, llvm::StringRef log_ident,
+  uint32_t line = 0, uint32_t column = 0);
   void SetSCMatchesByLine(SearchFilter &, SymbolContextList &, bool,
   const char *) = delete;
 

Modified: lldb/trunk/include/lldb/Breakpoint/BreakpointResolverFileLine.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Breakpoint/BreakpointResolverFileLine.h?rev=341078&r1=341077&r2=341078&view=diff
==
--- lldb/trunk/include/lldb/Breakpoint/BreakpointResolverFileLine.h (original)
+++ lldb/trunk/include/lldb/Breakpoint/BreakpointResolverFileLine.h Thu Aug 30 
08:11:00 2018
@@ -28,9 +28,9 @@ namespace lldb_private {
 class BreakpointResolverFileLine : public BreakpointResolver {
 public:
   BreakpointResolverFileLine(Breakpoint *bkpt, const FileSpec &resolver,
- uint32_t line_no, lldb::addr_

[Lldb-commits] [PATCH] D51461: Support setting a breakpoint by FileSpec+Line+Column in the SBAPI.

2018-08-30 Thread Phabricator via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL341078: Support setting a breakpoint by FileSpec+Line+Column 
in the SBAPI. (authored by adrian, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D51461?vs=163231&id=163341#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D51461

Files:
  lldb/trunk/include/lldb/API/SBTarget.h
  lldb/trunk/include/lldb/Breakpoint/BreakpointResolver.h
  lldb/trunk/include/lldb/Breakpoint/BreakpointResolverFileLine.h
  lldb/trunk/include/lldb/Target/Target.h
  
lldb/trunk/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_by_line_and_column/Makefile
  
lldb/trunk/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_by_line_and_column/TestBreakpointByLineAndColumn.py
  
lldb/trunk/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_by_line_and_column/main.c
  
lldb/trunk/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_command/TestBreakpointCommand.py
  
lldb/trunk/packages/Python/lldbsuite/test/functionalities/breakpoint/serialize/TestBreakpointSerialization.py
  lldb/trunk/packages/Python/lldbsuite/test/lldbutil.py
  lldb/trunk/scripts/interface/SBTarget.i
  lldb/trunk/source/API/SBTarget.cpp
  lldb/trunk/source/Breakpoint/BreakpointResolver.cpp
  lldb/trunk/source/Breakpoint/BreakpointResolverFileLine.cpp
  lldb/trunk/source/Commands/CommandObjectBreakpoint.cpp
  lldb/trunk/source/Core/IOHandler.cpp
  lldb/trunk/source/Symbol/LineEntry.cpp
  lldb/trunk/source/Target/Target.cpp

Index: lldb/trunk/source/Commands/CommandObjectBreakpoint.cpp
===
--- lldb/trunk/source/Commands/CommandObjectBreakpoint.cpp
+++ lldb/trunk/source/Commands/CommandObjectBreakpoint.cpp
@@ -696,7 +696,8 @@
 
   bp_sp = target->CreateBreakpoint(&(m_options.m_modules), 
file,
-   m_options.m_line_num, 
+   m_options.m_line_num,
+   m_options.m_column,
m_options.m_offset_addr,
check_inlines, 
m_options.m_skip_prologue,
Index: lldb/trunk/source/Breakpoint/BreakpointResolverFileLine.cpp
===
--- lldb/trunk/source/Breakpoint/BreakpointResolverFileLine.cpp
+++ lldb/trunk/source/Breakpoint/BreakpointResolverFileLine.cpp
@@ -28,19 +28,21 @@
 //--
 BreakpointResolverFileLine::BreakpointResolverFileLine(
 Breakpoint *bkpt, const FileSpec &file_spec, uint32_t line_no,
-lldb::addr_t offset, bool check_inlines, bool skip_prologue,
-bool exact_match)
+uint32_t column, lldb::addr_t offset, bool check_inlines,
+bool skip_prologue, bool exact_match)
 : BreakpointResolver(bkpt, BreakpointResolver::FileLineResolver, offset),
-  m_file_spec(file_spec), m_line_number(line_no), m_inlines(check_inlines),
-  m_skip_prologue(skip_prologue), m_exact_match(exact_match) {}
+  m_file_spec(file_spec), m_line_number(line_no), m_column(column),
+  m_inlines(check_inlines), m_skip_prologue(skip_prologue),
+  m_exact_match(exact_match) {}
 
 BreakpointResolverFileLine::~BreakpointResolverFileLine() {}
 
 BreakpointResolver *BreakpointResolverFileLine::CreateFromStructuredData(
 Breakpoint *bkpt, const StructuredData::Dictionary &options_dict,
 Status &error) {
   llvm::StringRef filename;
   uint32_t line_no;
+  uint32_t column;
   bool check_inlines;
   bool skip_prologue;
   bool exact_match;
@@ -62,6 +64,13 @@
 return nullptr;
   }
 
+  success =
+  options_dict.GetValueForKeyAsInteger(GetKey(OptionNames::Column), column);
+  if (!success) {
+// Backwards compatibility.
+column = 0;
+  }
+
   success = options_dict.GetValueForKeyAsBoolean(GetKey(OptionNames::Inlines),
  check_inlines);
   if (!success) {
@@ -85,8 +94,8 @@
 
   FileSpec file_spec(filename, false);
 
-  return new BreakpointResolverFileLine(bkpt, file_spec, line_no, offset,
-check_inlines, skip_prologue,
+  return new BreakpointResolverFileLine(bkpt, file_spec, line_no, column,
+offset, check_inlines, skip_prologue,
 exact_match);
 }
 
@@ -99,6 +108,8 @@
  m_file_spec.GetPath());
   options_dict_sp->AddIntegerItem(GetKey(OptionNames::LineNumber),
   m_line_number);
+  options_dict_sp->AddIntegerItem(GetKey(OptionNames::Column),
+  m_column);
   options_dict_sp->AddBooleanItem(GetKey(OptionNames::Inlines), m_in

[Lldb-commits] [lldb] r341080 - Remove redundant initialization

2018-08-30 Thread Adrian Prantl via lldb-commits
Author: adrian
Date: Thu Aug 30 08:39:08 2018
New Revision: 341080

URL: http://llvm.org/viewvc/llvm-project?rev=341080&view=rev
Log:
Remove redundant initialization

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=341080&r1=341079&r2=341080&view=diff
==
--- lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp 
(original)
+++ lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp 
Thu Aug 30 08:39:08 2018
@@ -222,7 +222,7 @@ ClangExpressionParser::ClangExpressionPa
  Expression &expr,
  bool generate_debug_info)
 : ExpressionParser(exe_scope, expr, generate_debug_info), m_compiler(),
-  m_code_generator(), m_pp_callbacks(nullptr) {
+  m_pp_callbacks(nullptr) {
   Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS));
 
   // We can't compile expressions without a target.  So if the exe_scope is


___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D50384: Move Predicate.h from Host to Utility

2018-08-30 Thread Pavel Labath via Phabricator via lldb-commits
labath added a comment.

Also, to answer Zachary's question:

A lot of the existing uses of Predicate class could be replaced by 
`std::future` (often `future`). The one in the Event class is in this 
category. However, there are some uses (these tend to be hacks of various 
magnitudes), which are not as easy to replace.


https://reviews.llvm.org/D50384



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


Re: [Lldb-commits] [lldb] r341080 - Remove redundant initialization

2018-08-30 Thread Leonard Mosescu via lldb-commits
Just curious, what prompted this change? (compiler diagnostic? forcing
value initialization in the member initializer list is harmless in this
case)

Also, if we want to do this kind of cleanup, m_compiler initialization is
also redundant.

On Thu, Aug 30, 2018 at 8:39 AM, Adrian Prantl via lldb-commits <
lldb-commits@lists.llvm.org> wrote:

> Author: adrian
> Date: Thu Aug 30 08:39:08 2018
> New Revision: 341080
>
> URL: http://llvm.org/viewvc/llvm-project?rev=341080&view=rev
> Log:
> Remove redundant initialization
>
> 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=341080&r1=341079&r2=341080&view=diff
> 
> ==
> --- lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp
> (original)
> +++ lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp
> Thu Aug 30 08:39:08 2018
> @@ -222,7 +222,7 @@ ClangExpressionParser::ClangExpressionPa
>   Expression &expr,
>   bool generate_debug_info)
>  : ExpressionParser(exe_scope, expr, generate_debug_info),
> m_compiler(),
> -  m_code_generator(), m_pp_callbacks(nullptr) {
> +  m_pp_callbacks(nullptr) {
>Log *log(lldb_private::GetLogIfAllCategoriesSet(
> LIBLLDB_LOG_EXPRESSIONS));
>
>// We can't compile expressions without a target.  So if the exe_scope
> is
>
>
> ___
> 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


Re: [Lldb-commits] [lldb] r341080 - Remove redundant initialization

2018-08-30 Thread Adrian Prantl via lldb-commits


> On Aug 30, 2018, at 9:43 AM, Leonard Mosescu  wrote:
> 
> Just curious, what prompted this change? (compiler diagnostic? forcing value 
> initialization in the member initializer list is harmless in this case)

This particular change was (for whatever reason) in the swift.org 
 branch of LLDB and I'm always trying to remove pointless 
differences between the two branches.

> 
> Also, if we want to do this kind of cleanup, m_compiler initialization is 
> also redundant.

That's a fair point!

-- adrian


> 
> On Thu, Aug 30, 2018 at 8:39 AM, Adrian Prantl via lldb-commits 
> mailto:lldb-commits@lists.llvm.org>> wrote:
> Author: adrian
> Date: Thu Aug 30 08:39:08 2018
> New Revision: 341080
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=341080&view=rev 
> 
> Log:
> Remove redundant initialization
> 
> 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=341080&r1=341079&r2=341080&view=diff
>  
> 
> ==
> --- 
> lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp 
> (original)
> +++ 
> lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp 
> Thu Aug 30 08:39:08 2018
> @@ -222,7 +222,7 @@ ClangExpressionParser::ClangExpressionPa
>   Expression &expr,
>   bool generate_debug_info)
>  : ExpressionParser(exe_scope, expr, generate_debug_info), m_compiler(),
> -  m_code_generator(), m_pp_callbacks(nullptr) {
> +  m_pp_callbacks(nullptr) {
>Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS));
> 
>// We can't compile expressions without a target.  So if the exe_scope is
> 
> 
> ___
> 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] [PATCH] D48465: Added initial code completion support for the `expr` command

2018-08-30 Thread Raphael Isemann via Phabricator via lldb-commits
teemperor updated this revision to Diff 163366.
teemperor added a comment.

- Rebased patch.


https://reviews.llvm.org/D48465

Files:
  include/lldb/Expression/ExpressionParser.h
  include/lldb/Expression/UserExpression.h
  packages/Python/lldbsuite/test/expression_command/completion/.categories
  packages/Python/lldbsuite/test/expression_command/completion/Makefile
  
packages/Python/lldbsuite/test/expression_command/completion/TestExprCompletion.py
  packages/Python/lldbsuite/test/expression_command/completion/main.cpp
  packages/Python/lldbsuite/test/expression_command/completion/other.cpp
  packages/Python/lldbsuite/test/functionalities/completion/TestCompletion.py
  packages/Python/lldbsuite/test/lldbtest.py
  source/Commands/CommandObjectExpression.cpp
  source/Commands/CommandObjectExpression.h
  source/Plugins/ExpressionParser/Clang/ASTResultSynthesizer.cpp
  source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp
  source/Plugins/ExpressionParser/Clang/ClangExpressionParser.h
  source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp
  source/Plugins/ExpressionParser/Clang/ClangUserExpression.h

Index: source/Plugins/ExpressionParser/Clang/ClangUserExpression.h
===
--- source/Plugins/ExpressionParser/Clang/ClangUserExpression.h
+++ source/Plugins/ExpressionParser/Clang/ClangUserExpression.h
@@ -143,6 +143,9 @@
  lldb_private::ExecutionPolicy execution_policy,
  bool keep_result_in_memory, bool generate_debug_info) override;
 
+  bool Complete(ExecutionContext &exe_ctx, StringList &matches,
+unsigned complete_pos) override;
+
   ExpressionTypeSystemHelper *GetTypeSystemHelper() override {
 return &m_type_system_helper;
   }
@@ -198,6 +201,10 @@
 lldb::TargetSP m_target_sp;
   };
 
+  /// 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;
   ResultDelegate m_result_delegate;
 };
 
Index: source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp
===
--- source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp
+++ source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp
@@ -402,6 +402,16 @@
"couldn't construct expression body");
   return llvm::Optional();
 }
+
+// Find and store the start position of the original code inside the
+// transformed code. We need this later for the code completion.
+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);
+if (found_bounds) {
+  m_user_expression_start_pos = original_start;
+}
   }
   return lang_type;
 }
@@ -591,6 +601,119 @@
   return true;
 }
 
+//--
+/// Converts an absolute position inside a given code string into
+/// a column/line pair.
+///
+/// @param[in] abs_pos
+/// A absolute position in the code string that we want to convert
+/// to a column/line pair.
+///
+/// @param[in] code
+/// A multi-line string usually representing source code.
+///
+/// @param[out] line
+/// The line in the code that contains the given absolute position.
+/// The first line in the string is indexed as 1.
+///
+/// @param[out] column
+/// 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,
+  unsigned &line, unsigned &column) {
+  // Reset to code position to beginning of the file.
+  line = 0;
+  column = 0;
+
+  assert(abs_pos <= code.size() && "Absolute position outside code string?");
+
+  // We have to walk up to the position and count lines/columns.
+  for (std::size_t i = 0; i < abs_pos; ++i) {
+// If we hit a line break, we go back to column 0 and enter a new line.
+// We only handle \n because that's what we internally use to make new
+// lines for our temporary code strings.
+if (code[i] == '\n') {
+  ++line;
+  column = 0;
+  continue;
+}
+++column;
+  }
+}
+
+bool ClangUserExpression::Complete(ExecutionContext &exe_ctx,
+   StringList &matches, unsigned complete_pos) {
+  Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS));
+
+  // We don't want any visible feedback when completing an expression. Mostly
+  // because the results we get from an incomplete invocation are probably not
+  // correct.
+  DiagnosticManager diagnostic_manager;
+
+  if (!Pre

[Lldb-commits] [PATCH] D48465: Added initial code completion support for the `expr` command

2018-08-30 Thread Raphael Isemann via Phabricator via lldb-commits
teemperor accepted this revision.
teemperor added a comment.
This revision is now accepted and ready to land.

(Just pressing the green button for Jim)


https://reviews.llvm.org/D48465



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] r341086 - Added initial code completion support for the `expr` command

2018-08-30 Thread Raphael Isemann via lldb-commits
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] [PATCH] D48465: Added initial code completion support for the `expr` command

2018-08-30 Thread Raphael Isemann via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL341086: Added initial code completion support for the `expr` 
command (authored by teemperor, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D48465?vs=163366&id=163367#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D48465

Files:
  lldb/trunk/include/lldb/Expression/ExpressionParser.h
  lldb/trunk/include/lldb/Expression/UserExpression.h
  
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
  
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

Index: lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangUserExpression.h
===
--- lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangUserExpression.h
+++ lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangUserExpression.h
@@ -143,6 +143,9 @@
  lldb_private::ExecutionPolicy execution_policy,
  bool keep_result_in_memory, bool generate_debug_info) override;
 
+  bool Complete(ExecutionContext &exe_ctx, StringList &matches,
+unsigned complete_pos) override;
+
   ExpressionTypeSystemHelper *GetTypeSystemHelper() override {
 return &m_type_system_helper;
   }
@@ -198,6 +201,10 @@
 lldb::TargetSP m_target_sp;
   };
 
+  /// 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;
   ResultDelegate m_result_delegate;
 };
 
Index: lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp
===
--- lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp
+++ lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp
@@ -402,6 +402,16 @@
"couldn't construct expression body");
   return llvm::Optional();
 }
+
+// Find and store the start position of the original code inside the
+// transformed code. We need this later for the code completion.
+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);
+if (found_bounds) {
+  m_user_expression_start_pos = original_start;
+}
   }
   return lang_type;
 }
@@ -591,6 +601,119 @@
   return true;
 }
 
+//--
+/// Converts an absolute position inside a given code string into
+/// a column/line pair.
+///
+/// @param[in] abs_pos
+/// A absolute position in the code string that we want to convert
+/// to a column/line pair.
+///
+/// @param[in] code
+/// A multi-line string usually representing source code.
+///
+/// @param[out] line
+/// The line in the code that contains the given absolute position.
+/// The first line in the string is indexed as 1.
+///
+/// @param[out] column
+/// 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,
+  unsigned &line, unsigned &column) {
+  // Reset to code position to beginning of the file.
+  line = 0;
+  column = 0;
+
+  assert(abs_pos <= code.size() && "Absolute position outside code string?");
+
+  // We have to walk up to the position and count lines/columns.
+  for (std::size_t i = 0; i < abs_pos; ++i) {
+// If we hit a line break, we go back to column 0 and enter a new line.
+// We only handle \n because that's what we internally use to make new
+// lines for our temporary code strings.
+if (code[i] == '\n') {
+  ++line;
+  column = 0

[Lldb-commits] [lldb] r341089 - Move Predicate.h from Host to Utility

2018-08-30 Thread Raphael Isemann via lldb-commits
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] [PATCH] D50384: Move Predicate.h from Host to Utility

2018-08-30 Thread Raphael Isemann via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rLLDB341089: Move Predicate.h from Host to Utility (authored 
by teemperor, committed by ).
Herald added a subscriber: jfb.

Changed prior to commit:
  https://reviews.llvm.org/D50384?vs=159649&id=163371#toc

Repository:
  rLLDB LLDB

https://reviews.llvm.org/D50384

Files:
  include/lldb/Core/Event.h
  include/lldb/Core/IOHandler.h
  include/lldb/Host/Editline.h
  include/lldb/Host/Predicate.h
  include/lldb/Host/Socket.h
  include/lldb/Host/posix/ConnectionFileDescriptorPosix.h
  include/lldb/Utility/Predicate.h
  include/lldb/module.modulemap
  source/Core/IOHandler.cpp
  source/Host/common/Host.cpp
  source/Plugins/Process/MacOSX-Kernel/CommunicationKDP.h
  source/Plugins/Process/Windows/Common/DebuggerThread.cpp
  source/Plugins/Process/Windows/Common/DebuggerThread.h
  source/Plugins/Process/gdb-remote/GDBRemoteCommunication.h
  unittests/Core/BroadcasterTest.cpp
  unittests/Host/CMakeLists.txt
  unittests/Host/PredicateTest.cpp
  unittests/Utility/CMakeLists.txt
  unittests/Utility/PredicateTest.cpp

Index: unittests/Host/CMakeLists.txt
===
--- unittests/Host/CMakeLists.txt
+++ unittests/Host/CMakeLists.txt
@@ -3,7 +3,6 @@
   HostInfoTest.cpp
   HostTest.cpp
   MainLoopTest.cpp
-  PredicateTest.cpp
   SocketAddressTest.cpp
   SocketTest.cpp
   SymbolsTest.cpp
Index: unittests/Utility/PredicateTest.cpp
===
--- unittests/Utility/PredicateTest.cpp
+++ unittests/Utility/PredicateTest.cpp
@@ -0,0 +1,34 @@
+//===-- PredicateTest.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/Predicate.h"
+#include "gtest/gtest.h"
+#include 
+
+using namespace lldb_private;
+
+TEST(Predicate, WaitForValueEqualTo) {
+  Predicate P(0);
+  EXPECT_TRUE(P.WaitForValueEqualTo(0));
+  EXPECT_FALSE(P.WaitForValueEqualTo(1, std::chrono::milliseconds(10)));
+
+  std::thread Setter([&P] {
+std::this_thread::sleep_for(std::chrono::milliseconds(100));
+P.SetValue(1, eBroadcastAlways);
+  });
+  EXPECT_TRUE(P.WaitForValueEqualTo(1));
+  Setter.join();
+}
+
+TEST(Predicate, WaitForValueNotEqualTo) {
+  Predicate P(0);
+  EXPECT_EQ(0, P.WaitForValueNotEqualTo(1));
+  EXPECT_EQ(llvm::None,
+P.WaitForValueNotEqualTo(0, std::chrono::milliseconds(10)));
+}
Index: unittests/Utility/CMakeLists.txt
===
--- unittests/Utility/CMakeLists.txt
+++ unittests/Utility/CMakeLists.txt
@@ -12,6 +12,7 @@
   JSONTest.cpp
   LogTest.cpp
   NameMatchesTest.cpp
+  PredicateTest.cpp
   RegisterValueTest.cpp
   ScalarTest.cpp
   StateTest.cpp
Index: unittests/Core/BroadcasterTest.cpp
===
--- unittests/Core/BroadcasterTest.cpp
+++ unittests/Core/BroadcasterTest.cpp
@@ -12,7 +12,7 @@
 #include "lldb/Core/Broadcaster.h"
 #include "lldb/Core/Event.h"
 #include "lldb/Core/Listener.h"
-#include "lldb/Host/Predicate.h"
+#include "lldb/Utility/Predicate.h"
 
 #include 
 
Index: source/Host/common/Host.cpp
===
--- source/Host/common/Host.cpp
+++ source/Host/common/Host.cpp
@@ -52,7 +52,6 @@
 #include "lldb/Host/HostInfo.h"
 #include "lldb/Host/HostProcess.h"
 #include "lldb/Host/MonitoringProcessLauncher.h"
-#include "lldb/Host/Predicate.h"
 #include "lldb/Host/ProcessLauncher.h"
 #include "lldb/Host/ThreadLauncher.h"
 #include "lldb/Host/posix/ConnectionFileDescriptorPosix.h"
@@ -62,6 +61,7 @@
 #include "lldb/Utility/DataBufferLLVM.h"
 #include "lldb/Utility/FileSpec.h"
 #include "lldb/Utility/Log.h"
+#include "lldb/Utility/Predicate.h"
 #include "lldb/Utility/Status.h"
 #include "lldb/lldb-private-forward.h"
 #include "llvm/ADT/SmallString.h"
Index: source/Core/IOHandler.cpp
===
--- source/Core/IOHandler.cpp
+++ source/Core/IOHandler.cpp
@@ -26,7 +26,7 @@
 #include "lldb/Core/Debugger.h"
 #include "lldb/Core/StreamFile.h"
 #include "lldb/Host/File.h"// for File
-#include "lldb/Host/Predicate.h"   // for Predicate, ::eBroad...
+#include "lldb/Utility/Predicate.h"// for Predicate, ::eBroad...
 #include "lldb/Utility/Status.h"   // for Status
 #include "lldb/Utility/StreamString.h" // for StreamString
 #include "lldb/Utility/StringList.h"   // for StringList
Index: source/Plugins/Process/Windows/Common/DebuggerThread.h
===
--- source/Plugins/Process/Windows/Common/DebuggerThread.h
+++ source/Plugins/Pr

[Lldb-commits] [PATCH] D50802: Expression autocompletion with variables and symbols

2018-08-30 Thread Raphael Isemann via Phabricator via lldb-commits
teemperor added a comment.

@acoomans https://reviews.llvm.org/D48465 has landed, so feel free to file bugs 
for any completions that are not provided by this. Thanks!


Repository:
  rLLDB LLDB

https://reviews.llvm.org/D50802



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D51387: Allow Template argument accessors to automatically unwrap parameter packs

2018-08-30 Thread Frederic Riss via Phabricator via lldb-commits
friss marked 2 inline comments as done.
friss added inline comments.



Comment at: include/lldb/Symbol/ClangASTContext.h:284
+ ((bool)pack_name == (bool)packed_args) &&
+ (!packed_args || !packed_args->args.empty());
 }

friss wrote:
> shafik wrote:
> > Is this saying that an empty parameter pack is invalid? We can have an 
> > empty parameter pack
> > 
> > https://godbolt.org/z/8zCFz9
> That's a good question. I need to check what the DWARF looks like for an 
> empty parameter pack. I would expect it not to be mentioned at all, but if 
> it's there we need to support it.
This was a good catch. The fact that there is an empty pack was recorded in the 
debug info and this made us consider the type as invalid. I've added a test to 
cover this.



Comment at: include/lldb/Symbol/ClangASTContext.h:792
+  GetTemplateArgumentKind(lldb::opaque_compiler_type_t type, size_t idx,
+  bool expand_pack) override;
   CompilerType GetTypeTemplateArgument(lldb::opaque_compiler_type_t type,

shafik wrote:
> Why not default to `false` here?
I added the defaults at the top to keep the semantics for the existing code, 
but it turns out there's no code using those interfaces that I haven't updated. 
I'll remove the defaults from everywhere.



Comment at: source/Symbol/ClangASTContext.cpp:7664
+
+  assert(args.size() &&
+ "We shouldn't have a template specialization without any args");

shafik wrote:
> The asset before we do math making this assumption i.e. `args.size() - 1`
The assert is also wrong because of the empty pack issue. I'll update the patch.


https://reviews.llvm.org/D51387



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D51387: Allow Template argument accessors to automatically unwrap parameter packs

2018-08-30 Thread Frederic Riss via Phabricator via lldb-commits
friss added inline comments.



Comment at: source/Symbol/ClangASTContext.cpp:7664
+
+  assert(args.size() &&
+ "We shouldn't have a template specialization without any args");

friss wrote:
> shafik wrote:
> > The asset before we do math making this assumption i.e. `args.size() - 1`
> The assert is also wrong because of the empty pack issue. I'll update the 
> patch.
Actually, this is not true. The Decl will always have at least one argument 
which is the pack. The pack can be empty, but the Decl still records it as one 
argument. The assert should be hoisted though.


https://reviews.llvm.org/D51387



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] r341096 - Fix deadlock in gdb-client tests

2018-08-30 Thread Pavel Labath via lldb-commits
Author: labath
Date: Thu Aug 30 12:14:02 2018
New Revision: 341096

URL: http://llvm.org/viewvc/llvm-project?rev=341096&view=rev
Log:
Fix deadlock in gdb-client tests

Using a listen queue of length 0 caused a deadlock on my machine in the
gdb-client tests while attempting to establish the loopback socket
connection.

I am not sure if this is down to a different python or kernel version,
but in either case, having queue of length zero sounds like a bad idea,
so I'm bumping that to one (which also fixes the deadlock).

Modified:

lldb/trunk/packages/Python/lldbsuite/test/functionalities/gdb_remote_client/gdbclientutils.py

Modified: 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/gdb_remote_client/gdbclientutils.py
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/functionalities/gdb_remote_client/gdbclientutils.py?rev=341096&r1=341095&r2=341096&view=diff
==
--- 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/gdb_remote_client/gdbclientutils.py
 (original)
+++ 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/gdb_remote_client/gdbclientutils.py
 Thu Aug 30 12:14:02 2018
@@ -246,7 +246,7 @@ class MockGDBServer:
 addr = ("127.0.0.1", self.port)
 self._socket.bind(addr)
 self.port = self._socket.getsockname()[1]
-self._socket.listen(0)
+self._socket.listen(1)
 self._thread = threading.Thread(target=self._run)
 self._thread.start()
 


___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] r341105 - Fixed code style for the CodeCompletion members [NFC]

2018-08-30 Thread Raphael Isemann via lldb-commits
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'

2018-08-30 Thread Raphael Isemann via lldb-commits
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

2018-08-30 Thread Raphael Isemann via lldb-commits
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] [PATCH] D51387: Allow Template argument accessors to automatically unwrap parameter packs

2018-08-30 Thread Frederic Riss via Phabricator via lldb-commits
friss updated this revision to Diff 163399.
friss added a comment.

Address feedback


https://reviews.llvm.org/D51387

Files:
  include/lldb/Symbol/ClangASTContext.h
  include/lldb/Symbol/CompilerType.h
  include/lldb/Symbol/TypeSystem.h
  
packages/Python/lldbsuite/test/lang/cpp/class-template-parameter-pack/TestTemplatePackArgs.py
  packages/Python/lldbsuite/test/lang/cpp/class-template-parameter-pack/main.cpp
  source/API/SBType.cpp
  source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
  source/Symbol/ClangASTContext.cpp
  source/Symbol/CompilerType.cpp
  source/Symbol/TypeSystem.cpp

Index: source/Symbol/TypeSystem.cpp
===
--- source/Symbol/TypeSystem.cpp
+++ source/Symbol/TypeSystem.cpp
@@ -101,23 +101,25 @@
   return CompilerType(this, type);
 }
 
-size_t TypeSystem::GetNumTemplateArguments(lldb::opaque_compiler_type_t type) {
+size_t TypeSystem::GetNumTemplateArguments(lldb::opaque_compiler_type_t type,
+   bool expand_pack) {
   return 0;
 }
 
 TemplateArgumentKind
-TypeSystem::GetTemplateArgumentKind(opaque_compiler_type_t type, size_t idx) {
+TypeSystem::GetTemplateArgumentKind(opaque_compiler_type_t type, size_t idx,
+bool expand_pack) {
   return eTemplateArgumentKindNull;
 }
 
 CompilerType TypeSystem::GetTypeTemplateArgument(opaque_compiler_type_t type,
- size_t idx) {
+ size_t idx, bool expand_pack) {
   return CompilerType();
 }
 
 llvm::Optional
-TypeSystem::GetIntegralTemplateArgument(opaque_compiler_type_t type,
-size_t idx) {
+TypeSystem::GetIntegralTemplateArgument(opaque_compiler_type_t type, size_t idx,
+bool expand_pack) {
   return llvm::None;
 }
 
Index: source/Symbol/CompilerType.cpp
===
--- source/Symbol/CompilerType.cpp
+++ source/Symbol/CompilerType.cpp
@@ -680,30 +680,32 @@
   return 0;
 }
 
-size_t CompilerType::GetNumTemplateArguments() const {
+size_t CompilerType::GetNumTemplateArguments(bool expand_pack) const {
   if (IsValid()) {
-return m_type_system->GetNumTemplateArguments(m_type);
+return m_type_system->GetNumTemplateArguments(m_type, expand_pack);
   }
   return 0;
 }
 
-TemplateArgumentKind CompilerType::GetTemplateArgumentKind(size_t idx) const {
+TemplateArgumentKind
+CompilerType::GetTemplateArgumentKind(size_t idx, bool expand_pack) const {
   if (IsValid())
-return m_type_system->GetTemplateArgumentKind(m_type, idx);
+return m_type_system->GetTemplateArgumentKind(m_type, idx, expand_pack);
   return eTemplateArgumentKindNull;
 }
 
-CompilerType CompilerType::GetTypeTemplateArgument(size_t idx) const {
+CompilerType CompilerType::GetTypeTemplateArgument(size_t idx,
+   bool expand_pack) const {
   if (IsValid()) {
-return m_type_system->GetTypeTemplateArgument(m_type, idx);
+return m_type_system->GetTypeTemplateArgument(m_type, idx, expand_pack);
   }
   return CompilerType();
 }
 
 llvm::Optional
-CompilerType::GetIntegralTemplateArgument(size_t idx) const {
+CompilerType::GetIntegralTemplateArgument(size_t idx, bool expand_pack) const {
   if (IsValid())
-return m_type_system->GetIntegralTemplateArgument(m_type, idx);
+return m_type_system->GetIntegralTemplateArgument(m_type, idx, expand_pack);
   return llvm::None;
 }
 
Index: source/Symbol/ClangASTContext.cpp
===
--- source/Symbol/ClangASTContext.cpp
+++ source/Symbol/ClangASTContext.cpp
@@ -7546,7 +7546,8 @@
 }
 
 size_t
-ClangASTContext::GetNumTemplateArguments(lldb::opaque_compiler_type_t type) {
+ClangASTContext::GetNumTemplateArguments(lldb::opaque_compiler_type_t type,
+ bool expand_pack) {
   if (!type)
 return 0;
 
@@ -7561,8 +7562,19 @@
 const clang::ClassTemplateSpecializationDecl *template_decl =
 llvm::dyn_cast(
 cxx_record_decl);
-if (template_decl)
-  return template_decl->getTemplateArgs().size();
+if (template_decl) {
+  const auto &template_arg_list = template_decl->getTemplateArgs();
+  int num_args = template_arg_list.size();
+  assert(
+  num_args &&
+  "We shouldn't have a template specialization without any args");
+  if (expand_pack) {
+auto &pack = template_arg_list[num_args - 1];
+if (pack.getKind() == clang::TemplateArgument::Pack)
+  num_args += pack.pack_size() - 1;
+  }
+  return num_args;
+}
   }
 }
 break;
@@ -7644,15 +7656,37 @@
   }
 }
 
+const TemplateArgument *
+GetNthTemplateArgument(const clang::ClassTemplateSpecialization

[Lldb-commits] [PATCH] D51387: Allow Template argument accessors to automatically unwrap parameter packs

2018-08-30 Thread Greg Clayton via Phabricator via lldb-commits
clayborg accepted this revision.
clayborg added a comment.
This revision is now accepted and ready to land.

Looks good to me. Jim should take a look as well.


https://reviews.llvm.org/D51387



___
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]

2018-08-30 Thread Raphael Isemann via lldb-commits
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]

2018-08-30 Thread Raphael Isemann via lldb-commits
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]

2018-08-30 Thread Raphael Isemann via lldb-commits
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] [PATCH] D51520: Add libc++ data formatter for std::variant

2018-08-30 Thread Shafik Yaghmour via Phabricator via lldb-commits
shafik created this revision.
shafik added reviewers: jingham, davide.
Herald added subscribers: christof, mgorny.
Herald added a reviewer: EricWF.

Adding data formatter for libc++ std::variant and appropriate tests


https://reviews.llvm.org/D51520

Files:
  lldb.xcodeproj/project.pbxproj
  
packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/variant/Makefile
  
packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/variant/TestDataFormatterLibcxxVariant.py
  
packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/variant/main.cpp
  source/Plugins/Language/CPlusPlus/CMakeLists.txt
  source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
  source/Plugins/Language/CPlusPlus/LibCxx.cpp
  source/Plugins/Language/CPlusPlus/LibCxx.h
  source/Plugins/Language/CPlusPlus/LibCxxVariant.cpp
  source/Plugins/Language/CPlusPlus/LibCxxVariant.h

Index: source/Plugins/Language/CPlusPlus/LibCxxVariant.h
===
--- /dev/null
+++ source/Plugins/Language/CPlusPlus/LibCxxVariant.h
@@ -0,0 +1,32 @@
+//===-- LibCxxVariant.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_LibCxxVariant_h_
+#define liblldb_LibCxxVariant_h_
+
+#include "lldb/Core/ValueObject.h"
+#include "lldb/DataFormatters/TypeSummary.h"
+#include "lldb/DataFormatters/TypeSynthetic.h"
+#include "lldb/Utility/Stream.h"
+
+namespace lldb_private {
+namespace formatters {
+bool LibcxxVariantSummaryProvider(
+ValueObject &valobj, Stream &stream,
+const TypeSummaryOptions &options); // libc++ std::variant<>
+
+SyntheticChildrenFrontEnd *
+LibcxxVariantFrontEndCreator(CXXSyntheticChildren *,
+ lldb::ValueObjectSP);
+
+} // namespace formatters
+} // namespace lldb_private
+
+#endif // liblldb_LibCxxVariant_h_
Index: source/Plugins/Language/CPlusPlus/LibCxxVariant.cpp
===
--- /dev/null
+++ source/Plugins/Language/CPlusPlus/LibCxxVariant.cpp
@@ -0,0 +1,282 @@
+//===-- LibCxxVariant.cpp --*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#include "LibCxxVariant.h"
+#include "lldb/DataFormatters/FormattersHelpers.h"
+
+#include "llvm/ADT/Optional.h"
+#include "llvm/ADT/ScopeExit.h"
+
+using namespace lldb;
+using namespace lldb_private;
+
+// libc++ variant implementation contains two members that we care about both
+// are contained in the __impl member.
+// - __index which tells us which of the variadic template types is the active
+//   type for the variant
+// - __data is a variadic union which recursively contains itself as member
+//   which refers to the tailing variadic types.
+//   - __head which refers to the leading non pack type
+// - __value refers to the actual value contained
+//   - __tail which refers to the remaining pack types and
+//
+// e.g. given std::variant v1
+//
+// (lldb) frame var -R v1.__impl.__data
+//(... __union<... 0, int, double, char>) v1.__impl.__data = {
+// ...
+//  __head = {
+//__value = ...
+//  }
+//  __tail = {
+//  ...
+//__head = {
+//  __value = ...
+//}
+//__tail = {
+//...
+//  __head = {
+//__value = ...
+//  ...
+//
+// So given
+// - __index equal to 0 the active value is contained in
+//
+// __data.__head.__value
+//
+// - __index equal to 1 the active value is contained in
+//
+// __data.__tail.__head.__value
+//
+// - __index equal to 2 the active value is contained in
+//
+//  __data.__tail.__tail.__head.__value
+//
+
+namespace {
+// libc++ std::variant index could have one of three states
+// 1) VALID, we can obtain it and its not variant_npos
+// 2) INVALID, we can't obtian it or it is not a type we expect
+// 3) NPOS, its value is variant_npos which means the variant has no value
+enum class LibcxxVariantIndexValidity {
+ VALID,
+ INVALID,
+ NPOS
+};
+
+LibcxxVariantIndexValidity LibcxxVariantGetIndexValidity( ValueObjectSP &impl_sp ) {
+ValueObjectSP index_sp(
+   impl_sp->GetChildMemberWithName(ConstString("__index"), true));
+
+if (!index_sp)
+return LibcxxVariantIndexValidity::INVALID ;
+
+uint64_t index_value = index_sp->GetValueAsUnsigned(0) ;
+
+CompilerType index_compiler_type = index_sp->GetCompilerType() ;
+
+// We are expecting to layers of typedefs before we obtain the b

[Lldb-commits] [PATCH] D51445: Remove undefined behavior around the use of StateType

2018-08-30 Thread Shafik Yaghmour via Phabricator via lldb-commits
shafik marked 3 inline comments as done.
shafik added a comment.

@jingham I am switching to the @aprantl suggestions which feels cleaner and 
removes this issue.




Comment at: include/lldb/lldb-enumerations.h:60
///< or threads get the chance to run.
+  kNumStateType
 };

aprantl wrote:
> I think we usually do something like eLastsState = eStateSuspended. This 
> avoid having to add the case to all the switches.
This approach seems like a much better idiom, I will switch to that.


https://reviews.llvm.org/D51445



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D51445: Remove undefined behavior around the use of StateType

2018-08-30 Thread Shafik Yaghmour via Phabricator via lldb-commits
shafik updated this revision to Diff 163450.
shafik marked an inline comment as done.
shafik added a comment.

Switching enum guard to kLastStateType which references the last valid enum 
which lead to cleaner code instead of inventing a new value which does not have 
a good meaning in many cases.


https://reviews.llvm.org/D51445

Files:
  include/lldb/lldb-enumerations.h
  scripts/Python/python-typemaps.swig
  unittests/Utility/StateTest.cpp


Index: unittests/Utility/StateTest.cpp
===
--- unittests/Utility/StateTest.cpp
+++ unittests/Utility/StateTest.cpp
@@ -15,7 +15,17 @@
 using namespace lldb_private;
 
 TEST(StateTest, Formatv) {
-  EXPECT_EQ("exited", llvm::formatv("{0}", eStateExited).str());
+  EXPECT_EQ("invalid", llvm::formatv("{0}", eStateInvalid).str());
+  EXPECT_EQ("unloaded", llvm::formatv("{0}", eStateUnloaded).str());
+  EXPECT_EQ("connected", llvm::formatv("{0}", eStateConnected).str());
+  EXPECT_EQ("attaching", llvm::formatv("{0}", eStateAttaching).str());
+  EXPECT_EQ("launching", llvm::formatv("{0}", eStateLaunching).str());
   EXPECT_EQ("stopped", llvm::formatv("{0}", eStateStopped).str());
-  EXPECT_EQ("unknown", llvm::formatv("{0}", StateType(-1)).str());
+  EXPECT_EQ("running", llvm::formatv("{0}", eStateRunning).str());
+  EXPECT_EQ("stepping", llvm::formatv("{0}", eStateStepping).str());
+  EXPECT_EQ("crashed", llvm::formatv("{0}", eStateCrashed).str());
+  EXPECT_EQ("detached", llvm::formatv("{0}", eStateDetached).str());
+  EXPECT_EQ("exited", llvm::formatv("{0}", eStateExited).str());
+  EXPECT_EQ("suspended", llvm::formatv("{0}", eStateSuspended).str());
+  
 }
Index: scripts/Python/python-typemaps.swig
===
--- scripts/Python/python-typemaps.swig
+++ scripts/Python/python-typemaps.swig
@@ -77,6 +77,26 @@
   }
 }
 
+%typemap(in) lldb::StateType {
+  using namespace lldb_private;
+  if (PythonInteger::Check($input))
+  {
+PythonInteger py_int(PyRefType::Borrowed, $input);
+int64_t state_type_value = py_int.GetInteger() ;
+
+if (state_type_value > lldb::StateType::kLastStateType) {
+  PyErr_SetString(PyExc_ValueError, "Not a valid StateType value");
+  return nullptr;
+}
+$1 = static_cast(state_type_value);
+  }
+  else
+  {
+PyErr_SetString(PyExc_ValueError, "Expecting an integer");
+return nullptr;
+  }
+}
+
 /* Typemap definitions to allow SWIG to properly handle char buffer. */
 
 // typemap for a char buffer
Index: include/lldb/lldb-enumerations.h
===
--- include/lldb/lldb-enumerations.h
+++ include/lldb/lldb-enumerations.h
@@ -54,9 +54,10 @@
   eStateCrashed,   ///< Process or thread has crashed and can be examined.
   eStateDetached,  ///< Process has been detached and can't be examined.
   eStateExited,///< Process has exited and can't be examined.
-  eStateSuspended  ///< Process or thread is in a suspended state as far
+  eStateSuspended, ///< Process or thread is in a suspended state as far
///< as the debugger is concerned while other processes
///< or threads get the chance to run.
+  kLastStateType = eStateSuspended  
 };
 
 //--


Index: unittests/Utility/StateTest.cpp
===
--- unittests/Utility/StateTest.cpp
+++ unittests/Utility/StateTest.cpp
@@ -15,7 +15,17 @@
 using namespace lldb_private;
 
 TEST(StateTest, Formatv) {
-  EXPECT_EQ("exited", llvm::formatv("{0}", eStateExited).str());
+  EXPECT_EQ("invalid", llvm::formatv("{0}", eStateInvalid).str());
+  EXPECT_EQ("unloaded", llvm::formatv("{0}", eStateUnloaded).str());
+  EXPECT_EQ("connected", llvm::formatv("{0}", eStateConnected).str());
+  EXPECT_EQ("attaching", llvm::formatv("{0}", eStateAttaching).str());
+  EXPECT_EQ("launching", llvm::formatv("{0}", eStateLaunching).str());
   EXPECT_EQ("stopped", llvm::formatv("{0}", eStateStopped).str());
-  EXPECT_EQ("unknown", llvm::formatv("{0}", StateType(-1)).str());
+  EXPECT_EQ("running", llvm::formatv("{0}", eStateRunning).str());
+  EXPECT_EQ("stepping", llvm::formatv("{0}", eStateStepping).str());
+  EXPECT_EQ("crashed", llvm::formatv("{0}", eStateCrashed).str());
+  EXPECT_EQ("detached", llvm::formatv("{0}", eStateDetached).str());
+  EXPECT_EQ("exited", llvm::formatv("{0}", eStateExited).str());
+  EXPECT_EQ("suspended", llvm::formatv("{0}", eStateSuspended).str());
+  
 }
Index: scripts/Python/python-typemaps.swig
===
--- scripts/Python/python-typemaps.swig
+++ scripts/Python/python-typemaps.swig
@@ -77,6 +77,26 @@
   }
 }
 
+%typemap(in) lldb::StateType {
+  using namespace lldb_private;
+  if (PythonInteger::Check($input))
+  {
+PythonInteger py_int(PyRefType::Borrowed, $input);
+int6

[Lldb-commits] [lldb] r341157 - Fixed missing sidebars on the website

2018-08-30 Thread Raphael Isemann via lldb-commits
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] r341163 - Silence some "control reaches end of non-void function" warnings with gcc

2018-08-30 Thread Pavel Labath via lldb-commits
Author: labath
Date: Thu Aug 30 22:18:11 2018
New Revision: 341163

URL: http://llvm.org/viewvc/llvm-project?rev=341163&view=rev
Log:
Silence some "control reaches end of non-void function" warnings with gcc

Modified:
lldb/trunk/source/Core/Mangled.cpp
lldb/trunk/source/Core/RichManglingContext.cpp

Modified: lldb/trunk/source/Core/Mangled.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/Mangled.cpp?rev=341163&r1=341162&r2=341163&view=diff
==
--- lldb/trunk/source/Core/Mangled.cpp (original)
+++ lldb/trunk/source/Core/Mangled.cpp Thu Aug 30 22:18:11 2018
@@ -354,6 +354,7 @@ bool Mangled::DemangleWithRichManglingIn
 }
   }
   }
+  llvm_unreachable("Fully covered switch above!");
 }
 
 //--

Modified: lldb/trunk/source/Core/RichManglingContext.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/RichManglingContext.cpp?rev=341163&r1=341162&r2=341163&view=diff
==
--- lldb/trunk/source/Core/RichManglingContext.cpp (original)
+++ lldb/trunk/source/Core/RichManglingContext.cpp Thu Aug 30 22:18:11 2018
@@ -74,6 +74,7 @@ bool RichManglingContext::IsCtorOrDtor()
   case None:
 return false;
   }
+  llvm_unreachable("Fully covered switch above!");
 }
 
 bool RichManglingContext::IsFunction() const {
@@ -86,6 +87,7 @@ bool RichManglingContext::IsFunction() c
   case None:
 return false;
   }
+  llvm_unreachable("Fully covered switch above!");
 }
 
 void RichManglingContext::processIPDStrResult(char *ipd_res, size_t res_size) {


___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] r341164 - Increase qHostInfo packet timeout

2018-08-30 Thread Pavel Labath via lldb-commits
Author: labath
Date: Thu Aug 30 22:34:03 2018
New Revision: 341164

URL: http://llvm.org/viewvc/llvm-project?rev=341164&view=rev
Log:
Increase qHostInfo packet timeout

Host info computation can involve DNS traffic (to compute the remote
host name). On very unreliable networks (such as free WiFi on trains),
this can take several seconds to complete or timeout. Increase the
qHostInfo timeout to account for this.

Modified:

lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp

Modified: 
lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp?rev=341164&r1=341163&r2=341164&view=diff
==
--- 
lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp 
(original)
+++ 
lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp 
Thu Aug 30 22:34:03 2018
@@ -1134,6 +1134,9 @@ bool GDBRemoteCommunicationClient::GetHo
   Log *log(ProcessGDBRemoteLog::GetLogIfAnyCategoryIsSet(GDBR_LOG_PROCESS));
 
   if (force || m_qHostInfo_is_valid == eLazyBoolCalculate) {
+// host info computation can require DNS traffic and shelling out to 
external processes.
+// Increase the timeout to account for that.
+ScopedTimeout timeout(*this, seconds(10));
 m_qHostInfo_is_valid = eLazyBoolNo;
 StringExtractorGDBRemote response;
 if (SendPacketAndWaitForResponse("qHostInfo", response, false) ==


___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] r341167 - Fix a typo in mac SIP workaround

2018-08-30 Thread Pavel Labath via lldb-commits
Author: labath
Date: Thu Aug 30 23:01:02 2018
New Revision: 341167

URL: http://llvm.org/viewvc/llvm-project?rev=341167&view=rev
Log:
Fix a typo in mac SIP workaround

presumably the or subexpression was meant to be evaluated first. The way
it is now means that we apply the workaround for any python in `/usr`,
which matches pretty much every unix system.

Modified:
lldb/trunk/lit/Suite/lldbtest.py

Modified: lldb/trunk/lit/Suite/lldbtest.py
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/lit/Suite/lldbtest.py?rev=341167&r1=341166&r2=341167&view=diff
==
--- lldb/trunk/lit/Suite/lldbtest.py (original)
+++ lldb/trunk/lit/Suite/lldbtest.py Thu Aug 30 23:01:02 2018
@@ -71,8 +71,8 @@ class LLDBTest(TestFormat):
 # libraries into system binaries, but this can be worked around by
 # copying the binary into a different location.
 if 'DYLD_INSERT_LIBRARIES' in test.config.environment and \
-sys.executable.startswith('/System/') or \
-sys.executable.startswith('/usr/'):
+(sys.executable.startswith('/System/') or \
+sys.executable.startswith('/usr/')):
 builddir = getBuildDir(cmd)
 mkdir_p(builddir)
 copied_python = os.path.join(builddir, 'copied-system-python')


___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits