[Lldb-commits] [lldb] db5074d - [lldb][NFC] Give some parameters in CommandInterpreter more descriptive names

2019-11-05 Thread Raphael Isemann via lldb-commits

Author: Raphael Isemann
Date: 2019-11-05T09:21:10+01:00
New Revision: db5074dc10222a8202adcd7c1da1acd2828fbecb

URL: 
https://github.com/llvm/llvm-project/commit/db5074dc10222a8202adcd7c1da1acd2828fbecb
DIFF: 
https://github.com/llvm/llvm-project/commit/db5074dc10222a8202adcd7c1da1acd2828fbecb.diff

LOG: [lldb][NFC] Give some parameters in CommandInterpreter more descriptive 
names

Added: 


Modified: 
lldb/include/lldb/Interpreter/CommandInterpreter.h
lldb/source/Interpreter/CommandInterpreter.cpp

Removed: 




diff  --git a/lldb/include/lldb/Interpreter/CommandInterpreter.h 
b/lldb/include/lldb/Interpreter/CommandInterpreter.h
index 3b98b2a521dd..080d635716f1 100644
--- a/lldb/include/lldb/Interpreter/CommandInterpreter.h
+++ b/lldb/include/lldb/Interpreter/CommandInterpreter.h
@@ -443,13 +443,13 @@ class CommandInterpreter : public Broadcaster,
 
   bool GetPromptOnQuit() const;
 
-  void SetPromptOnQuit(bool b);
+  void SetPromptOnQuit(bool enable);
 
   bool GetEchoCommands() const;
-  void SetEchoCommands(bool b);
+  void SetEchoCommands(bool enable);
 
   bool GetEchoCommentCommands() const;
-  void SetEchoCommentCommands(bool b);
+  void SetEchoCommentCommands(bool enable);
 
   /// Specify if the command interpreter should allow that the user can
   /// specify a custom exit code when calling 'quit'.

diff  --git a/lldb/source/Interpreter/CommandInterpreter.cpp 
b/lldb/source/Interpreter/CommandInterpreter.cpp
index 0c059096c6cd..e02248148413 100644
--- a/lldb/source/Interpreter/CommandInterpreter.cpp
+++ b/lldb/source/Interpreter/CommandInterpreter.cpp
@@ -137,9 +137,9 @@ bool CommandInterpreter::GetPromptOnQuit() const {
   nullptr, idx, g_interpreter_properties[idx].default_uint_value != 0);
 }
 
-void CommandInterpreter::SetPromptOnQuit(bool b) {
+void CommandInterpreter::SetPromptOnQuit(bool enable) {
   const uint32_t idx = ePropertyPromptOnQuit;
-  m_collection_sp->SetPropertyAtIndexAsBoolean(nullptr, idx, b);
+  m_collection_sp->SetPropertyAtIndexAsBoolean(nullptr, idx, enable);
 }
 
 bool CommandInterpreter::GetEchoCommands() const {
@@ -148,9 +148,9 @@ bool CommandInterpreter::GetEchoCommands() const {
   nullptr, idx, g_interpreter_properties[idx].default_uint_value != 0);
 }
 
-void CommandInterpreter::SetEchoCommands(bool b) {
+void CommandInterpreter::SetEchoCommands(bool enable) {
   const uint32_t idx = ePropertyEchoCommands;
-  m_collection_sp->SetPropertyAtIndexAsBoolean(nullptr, idx, b);
+  m_collection_sp->SetPropertyAtIndexAsBoolean(nullptr, idx, enable);
 }
 
 bool CommandInterpreter::GetEchoCommentCommands() const {
@@ -159,9 +159,9 @@ bool CommandInterpreter::GetEchoCommentCommands() const {
   nullptr, idx, g_interpreter_properties[idx].default_uint_value != 0);
 }
 
-void CommandInterpreter::SetEchoCommentCommands(bool b) {
+void CommandInterpreter::SetEchoCommentCommands(bool enable) {
   const uint32_t idx = ePropertyEchoCommentCommands;
-  m_collection_sp->SetPropertyAtIndexAsBoolean(nullptr, idx, b);
+  m_collection_sp->SetPropertyAtIndexAsBoolean(nullptr, idx, enable);
 }
 
 void CommandInterpreter::AllowExitCodeOnQuit(bool allow) {



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


[Lldb-commits] [lldb] 87bc320 - [lldb] Add -m option to 'target modules dump symtab' to disable demangling

2019-11-07 Thread Raphael Isemann via lldb-commits

Author: Raphael Isemann
Date: 2019-11-07T15:47:01+01:00
New Revision: 87bc320b510e91a1a71aa8a154c585db65579628

URL: 
https://github.com/llvm/llvm-project/commit/87bc320b510e91a1a71aa8a154c585db65579628
DIFF: 
https://github.com/llvm/llvm-project/commit/87bc320b510e91a1a71aa8a154c585db65579628.diff

LOG: [lldb] Add -m option to 'target modules dump symtab' to disable demangling

Summary: This option was added downstream in swift-lldb. This upstreams this 
option as it seems useful and also adds the missing tests.

Reviewers: #lldb, kwk, labath

Reviewed By: kwk, labath

Subscribers: labath, kwk, abidh, JDevlieghere, lldb-commits

Tags: #lldb, #upstreaming_lldb_s_downstream_patches

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

Added: 

lldb/packages/Python/lldbsuite/test/commands/target/dump-symtab-demangle/TestDumpSymtabDemangle.py

lldb/packages/Python/lldbsuite/test/commands/target/dump-symtab-demangle/a.yaml

Modified: 
lldb/include/lldb/Symbol/Symbol.h
lldb/include/lldb/Symbol/Symtab.h
lldb/source/Commands/CommandObjectTarget.cpp
lldb/source/Commands/Options.td
lldb/source/Symbol/Symbol.cpp
lldb/source/Symbol/Symtab.cpp

Removed: 




diff  --git a/lldb/include/lldb/Symbol/Symbol.h 
b/lldb/include/lldb/Symbol/Symbol.h
index b7f179d1449b..36f89c044ea9 100644
--- a/lldb/include/lldb/Symbol/Symbol.h
+++ b/lldb/include/lldb/Symbol/Symbol.h
@@ -43,7 +43,9 @@ class Symbol : public SymbolContextScope {
 
   bool Compare(ConstString name, lldb::SymbolType type) const;
 
-  void Dump(Stream *s, Target *target, uint32_t index) const;
+  void Dump(Stream *s, Target *target, uint32_t index,
+Mangled::NamePreference name_preference =
+Mangled::ePreferDemangled) const;
 
   bool ValueIsAddress() const;
 

diff  --git a/lldb/include/lldb/Symbol/Symtab.h 
b/lldb/include/lldb/Symbol/Symtab.h
index 99d15771ccc5..e42261ef11da 100644
--- a/lldb/include/lldb/Symbol/Symtab.h
+++ b/lldb/include/lldb/Symbol/Symtab.h
@@ -40,8 +40,12 @@ class Symtab {
   uint32_t AddSymbol(const Symbol &symbol);
   size_t GetNumSymbols() const;
   void SectionFileAddressesChanged();
-  void Dump(Stream *s, Target *target, SortOrder sort_type);
-  void Dump(Stream *s, Target *target, std::vector &indexes) const;
+  void
+  Dump(Stream *s, Target *target, SortOrder sort_type,
+   Mangled::NamePreference name_preference = Mangled::ePreferDemangled);
+  void Dump(Stream *s, Target *target, std::vector &indexes,
+Mangled::NamePreference name_preference =
+Mangled::ePreferDemangled) const;
   uint32_t GetIndexForSymbol(const Symbol *symbol) const;
   std::recursive_mutex &GetMutex() { return m_mutex; }
   Symbol *FindSymbolByID(lldb::user_id_t uid) const;

diff  --git 
a/lldb/packages/Python/lldbsuite/test/commands/target/dump-symtab-demangle/TestDumpSymtabDemangle.py
 
b/lldb/packages/Python/lldbsuite/test/commands/target/dump-symtab-demangle/TestDumpSymtabDemangle.py
new file mode 100644
index ..9f95a11f3875
--- /dev/null
+++ 
b/lldb/packages/Python/lldbsuite/test/commands/target/dump-symtab-demangle/TestDumpSymtabDemangle.py
@@ -0,0 +1,30 @@
+"""
+Test 'target modules dump symtab -m' doesn't demangle symbols.
+"""
+
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+class TestCase(TestBase):
+
+mydir = TestBase.compute_mydir(__file__)
+
+@no_debug_info_test
+def test(self):
+src_dir = self.getSourceDir()
+yaml_path = os.path.join(src_dir, "a.yaml")
+yaml_base, ext = os.path.splitext(yaml_path)
+obj_path = self.getBuildArtifact("main.o")
+self.yaml2obj(yaml_path, obj_path)
+
+# Create a target with the object file we just created from YAML
+target = self.dbg.CreateTarget(obj_path)
+self.assertTrue(target, VALID_TARGET)
+
+# First test that we demangle by default and our mangled symbol isn't 
in the output.
+self.expect("target modules dump symtab", substrs=["foo::bar(int)"])
+self.expect("target modules dump symtab", matching=False, 
substrs=["_ZN3foo3barEi"])
+
+# Turn off demangling and make sure that we now see the mangled name 
in the output.
+self.expect("target modules dump symtab -m", substrs=["_ZN3foo3barEi"])

diff  --git 
a/lldb/packages/Python/lldbsuite/test/commands/target/dump-symtab-demangle/a.yaml
 
b/lldb/packages/Python/lldbsuite/test/commands/target/dump-symtab-demangle/a.yaml
new file mode 100644
index ..ed591d7c1c19
--- /dev/null
+++ 
b/lldb/packages/Python/lldbsuite/test/commands/target/dump-symtab-demangle/a.yaml
@@ -0,0 +1,18 @@
+--- !ELF
+FileHeader:
+  Class:   ELFCLASS64
+  Data:ELFDATA2LSB
+  Type:ET_REL
+  Machine: EM_X86_64
+Sections:
+  - Name:.text
+Type:SHT_PRO

[Lldb-commits] [lldb] 79b3cce - [lldb][NFC] Refactor some IsClangType checks in ClangASTContext

2019-11-08 Thread Raphael Isemann via lldb-commits

Author: Raphael Isemann
Date: 2019-11-08T12:03:28+01:00
New Revision: 79b3cce7f143ebcbc57a3c4599cbd7a1541a742b

URL: 
https://github.com/llvm/llvm-project/commit/79b3cce7f143ebcbc57a3c4599cbd7a1541a742b
DIFF: 
https://github.com/llvm/llvm-project/commit/79b3cce7f143ebcbc57a3c4599cbd7a1541a742b.diff

LOG: [lldb][NFC] Refactor some IsClangType checks in ClangASTContext

Summary:
All type in these functions need be valid and Clang types, so
we might as well replace these checks with IsClangType.

Also lets IsClangType explicitly check for validity instead of
assuming that the TypeSystem is a nullptr.

Subscribers: abidh, JDevlieghere, lldb-commits

Tags: #lldb

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

Added: 


Modified: 
lldb/source/Symbol/ClangASTContext.cpp
lldb/source/Symbol/ClangUtil.cpp

Removed: 




diff  --git a/lldb/source/Symbol/ClangASTContext.cpp 
b/lldb/source/Symbol/ClangASTContext.cpp
index 61b08ab9f516..31b62ebb615e 100644
--- a/lldb/source/Symbol/ClangASTContext.cpp
+++ b/lldb/source/Symbol/ClangASTContext.cpp
@@ -3601,7 +3601,7 @@ bool 
ClangASTContext::IsDefined(lldb::opaque_compiler_type_t type) {
 }
 
 bool ClangASTContext::IsObjCClassType(const CompilerType &type) {
-  if (type) {
+  if (ClangUtil::IsClangType(type)) {
 clang::QualType qual_type(ClangUtil::GetCanonicalQualType(type));
 
 const clang::ObjCObjectPointerType *obj_pointer_type =
@@ -3886,7 +3886,7 @@ bool 
ClangASTContext::IsBeingDefined(lldb::opaque_compiler_type_t type) {
 
 bool ClangASTContext::IsObjCObjectPointerType(const CompilerType &type,
   CompilerType *class_type_ptr) {
-  if (!type)
+  if (!ClangUtil::IsClangType(type))
 return false;
 
   clang::QualType qual_type(ClangUtil::GetCanonicalQualType(type));

diff  --git a/lldb/source/Symbol/ClangUtil.cpp 
b/lldb/source/Symbol/ClangUtil.cpp
index 86be895fadcb..71ff36a5ebab 100644
--- a/lldb/source/Symbol/ClangUtil.cpp
+++ b/lldb/source/Symbol/ClangUtil.cpp
@@ -15,6 +15,10 @@ using namespace clang;
 using namespace lldb_private;
 
 bool ClangUtil::IsClangType(const CompilerType &ct) {
+  // Invalid types are never Clang types.
+  if (!ct)
+return false;
+
   if (llvm::dyn_cast_or_null(ct.GetTypeSystem()) == nullptr)
 return false;
 



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


[Lldb-commits] [lldb] 5a1bac4 - [lldb] Make Target* a Target& in CommandObjectExpression::DoExecute REPL logic

2019-11-08 Thread Raphael Isemann via lldb-commits

Author: Raphael Isemann
Date: 2019-11-08T12:28:49+01:00
New Revision: 5a1bac4d1daee2bcbf13365a8254a26d242d8c46

URL: 
https://github.com/llvm/llvm-project/commit/5a1bac4d1daee2bcbf13365a8254a26d242d8c46
DIFF: 
https://github.com/llvm/llvm-project/commit/5a1bac4d1daee2bcbf13365a8254a26d242d8c46.diff

LOG: [lldb] Make Target* a Target& in CommandObjectExpression::DoExecute REPL 
logic

Subscribers: JDevlieghere, lldb-commits

Tags: #lldb

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

Added: 


Modified: 
lldb/source/Commands/CommandObjectExpression.cpp

Removed: 




diff  --git a/lldb/source/Commands/CommandObjectExpression.cpp 
b/lldb/source/Commands/CommandObjectExpression.cpp
index 1f7bfd127dbf..ed63423b11e7 100644
--- a/lldb/source/Commands/CommandObjectExpression.cpp
+++ b/lldb/source/Commands/CommandObjectExpression.cpp
@@ -589,60 +589,58 @@ bool CommandObjectExpression::DoExecute(llvm::StringRef 
command,
   return false;
 
 if (m_repl_option.GetOptionValue().GetCurrentValue()) {
-  Target *target = m_interpreter.GetExecutionContext().GetTargetPtr();
-  if (target) {
-// Drop into REPL
-m_expr_lines.clear();
-m_expr_line_count = 0;
-
-Debugger &debugger = target->GetDebugger();
-
-// Check if the LLDB command interpreter is sitting on top of a REPL
-// that launched it...
-if 
(debugger.CheckTopIOHandlerTypes(IOHandler::Type::CommandInterpreter,
-IOHandler::Type::REPL)) {
-  // the LLDB command interpreter is sitting on top of a REPL that
-  // launched it, so just say the command interpreter is done and
-  // fall back to the existing REPL
-  m_interpreter.GetIOHandler(false)->SetIsDone(true);
-} else {
-  // We are launching the REPL on top of the current LLDB command
-  // interpreter, so just push one
-  bool initialize = false;
-  Status repl_error;
-  REPLSP repl_sp(target->GetREPL(repl_error, 
m_command_options.language,
- nullptr, false));
-
-  if (!repl_sp) {
-initialize = true;
-repl_sp = target->GetREPL(repl_error, m_command_options.language,
-  nullptr, true);
-if (!repl_error.Success()) {
-  result.SetError(repl_error);
-  return result.Succeeded();
-}
+  Target &target = GetSelectedOrDummyTarget();
+  // Drop into REPL
+  m_expr_lines.clear();
+  m_expr_line_count = 0;
+
+  Debugger &debugger = target.GetDebugger();
+
+  // Check if the LLDB command interpreter is sitting on top of a REPL
+  // that launched it...
+  if (debugger.CheckTopIOHandlerTypes(IOHandler::Type::CommandInterpreter,
+  IOHandler::Type::REPL)) {
+// the LLDB command interpreter is sitting on top of a REPL that
+// launched it, so just say the command interpreter is done and
+// fall back to the existing REPL
+m_interpreter.GetIOHandler(false)->SetIsDone(true);
+  } else {
+// We are launching the REPL on top of the current LLDB command
+// interpreter, so just push one
+bool initialize = false;
+Status repl_error;
+REPLSP repl_sp(target.GetREPL(repl_error, m_command_options.language,
+   nullptr, false));
+
+if (!repl_sp) {
+  initialize = true;
+  repl_sp = target.GetREPL(repl_error, m_command_options.language,
+nullptr, true);
+  if (!repl_error.Success()) {
+result.SetError(repl_error);
+return result.Succeeded();
   }
+}
 
-  if (repl_sp) {
-if (initialize) {
-  repl_sp->SetEvaluateOptions(
-  GetExprOptions(exe_ctx, m_command_options));
-  repl_sp->SetFormatOptions(m_format_options);
-  repl_sp->SetValueObjectDisplayOptions(m_varobj_options);
-}
+if (repl_sp) {
+  if (initialize) {
+repl_sp->SetEvaluateOptions(
+GetExprOptions(exe_ctx, m_command_options));
+repl_sp->SetFormatOptions(m_format_options);
+repl_sp->SetValueObjectDisplayOptions(m_varobj_options);
+  }
 
-IOHandlerSP io_handler_sp(repl_sp->GetIOHandler());
+  IOHandlerSP io_handler_sp(repl_sp->GetIOHandler());
 
-io_handler_sp->SetIsDone(false);
+  io_handler_sp->SetIsDone(false);
 
-debugger.PushIOHandler(io_handler_sp);
-  } else {
-repl_error.SetErrorStringWithFormat(
-"Couldn't create a REPL for %s",
-Language::GetNameForLanguageType(m_command_options.la

[Lldb-commits] [lldb] cdc38c9 - [lldb] Skip parts of TestCallOverriddenMethod.py on Linux

2019-11-08 Thread Raphael Isemann via lldb-commits

Author: Raphael Isemann
Date: 2019-11-08T15:55:02+01:00
New Revision: cdc38c93fa22f0bee1bd7b84a27c32abb4a3aba8

URL: 
https://github.com/llvm/llvm-project/commit/cdc38c93fa22f0bee1bd7b84a27c32abb4a3aba8
DIFF: 
https://github.com/llvm/llvm-project/commit/cdc38c93fa22f0bee1bd7b84a27c32abb4a3aba8.diff

LOG: [lldb] Skip parts of TestCallOverriddenMethod.py on Linux

The function call and the constructor call fail now several Linux
bots (Swift CI, my own bot and Stella's Debian system), so let's disable
the relevant test parts until we can figure out why it is failing.

Added: 


Modified: 

lldb/packages/Python/lldbsuite/test/commands/expression/call-overridden-method/TestCallOverriddenMethod.py

Removed: 




diff  --git 
a/lldb/packages/Python/lldbsuite/test/commands/expression/call-overridden-method/TestCallOverriddenMethod.py
 
b/lldb/packages/Python/lldbsuite/test/commands/expression/call-overridden-method/TestCallOverriddenMethod.py
index 09369f43819c..9c25597391de 100644
--- 
a/lldb/packages/Python/lldbsuite/test/commands/expression/call-overridden-method/TestCallOverriddenMethod.py
+++ 
b/lldb/packages/Python/lldbsuite/test/commands/expression/call-overridden-method/TestCallOverriddenMethod.py
@@ -26,7 +26,7 @@ def setUp(self):
 # Find the line number to break for main.c.
 self.line = line_number('main.cpp', '// Set breakpoint here')
 
-def test(self):
+def test_call_on_base(self):
 """Test calls to overridden methods in derived classes."""
 self.build()
 
@@ -42,14 +42,28 @@ def test(self):
 # class method is never an override).
 self.expect("expr b->foo()", substrs=["2"])
 
+# Test calling the base class.
+self.expect("expr realbase.foo()", substrs=["1"])
+
+@skipIfLinux # Returns wrong result code on some platforms.
+def test_call_on_derived(self):
+"""Test calls to overridden methods in derived classes."""
+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)
+
 # Test call to overridden method in derived class (this will fail if 
the
 # overrides table is not correctly set up, as Derived::foo will be 
assigned
 # a vtable entry that does not exist in the compiled program).
 self.expect("expr d.foo()", substrs=["2"])
 
-# Test calling the base class.
-self.expect("expr realbase.foo()", substrs=["1"])
-
+@skipIfLinux # Calling constructor causes SIGABRT
 @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr43707")
 def test_call_on_temporary(self):
 """Test calls to overridden methods in derived classes."""



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


[Lldb-commits] [lldb] bd7d9a8 - [lldb] Check if we actually have a Clang type in ObjCLanguage::GetPossibleFormattersMatches

2019-11-12 Thread Raphael Isemann via lldb-commits

Author: Raphael Isemann
Date: 2019-11-12T09:59:04+01:00
New Revision: bd7d9a85b8b09c945b98d374cc37cb374db012e6

URL: 
https://github.com/llvm/llvm-project/commit/bd7d9a85b8b09c945b98d374cc37cb374db012e6
DIFF: 
https://github.com/llvm/llvm-project/commit/bd7d9a85b8b09c945b98d374cc37cb374db012e6.diff

LOG: [lldb] Check if we actually have a Clang type in 
ObjCLanguage::GetPossibleFormattersMatches

We call IsPossibleDynamicType but we also need to check if this is a Clang type,
otherwise other languages with dynamic types (like Swift) might end up being 
interpreted
as potential Obj-C dynamic types.

Added: 


Modified: 
lldb/source/Plugins/Language/ObjC/ObjCLanguage.cpp

Removed: 




diff  --git a/lldb/source/Plugins/Language/ObjC/ObjCLanguage.cpp 
b/lldb/source/Plugins/Language/ObjC/ObjCLanguage.cpp
index c5bfb5747c13..0e0f8ae7fb0a 100644
--- a/lldb/source/Plugins/Language/ObjC/ObjCLanguage.cpp
+++ b/lldb/source/Plugins/Language/ObjC/ObjCLanguage.cpp
@@ -887,7 +887,7 @@ ObjCLanguage::GetPossibleFormattersMatches(ValueObject 
&valobj,
   bool canBeObjCDynamic =
   compiler_type.IsPossibleDynamicType(nullptr, check_cpp, check_objc);
 
-  if (canBeObjCDynamic) {
+  if (canBeObjCDynamic && ClangUtil::IsClangType(compiler_type)) {
 do {
   lldb::ProcessSP process_sp = valobj.GetProcessSP();
   if (!process_sp)



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


[Lldb-commits] [lldb] 6cc853b - [lldb][NFC] Remove unused CompilerType::IsPossibleCPlusPlusDynamicType

2019-11-12 Thread Raphael Isemann via lldb-commits

Author: Raphael Isemann
Date: 2019-11-12T10:02:59+01:00
New Revision: 6cc853b416a2b0d0b435d145988c5d3b6faaa712

URL: 
https://github.com/llvm/llvm-project/commit/6cc853b416a2b0d0b435d145988c5d3b6faaa712
DIFF: 
https://github.com/llvm/llvm-project/commit/6cc853b416a2b0d0b435d145988c5d3b6faaa712.diff

LOG: [lldb][NFC] Remove unused CompilerType::IsPossibleCPlusPlusDynamicType

Reviewers: davide, xiaobai

Reviewed By: davide, xiaobai

Subscribers: davide, JDevlieghere, lldb-commits

Tags: #lldb

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

Added: 


Modified: 
lldb/include/lldb/Symbol/CompilerType.h

Removed: 




diff  --git a/lldb/include/lldb/Symbol/CompilerType.h 
b/lldb/include/lldb/Symbol/CompilerType.h
index bb9881c0bae3..cedd2523a5a8 100644
--- a/lldb/include/lldb/Symbol/CompilerType.h
+++ b/lldb/include/lldb/Symbol/CompilerType.h
@@ -108,11 +108,6 @@ class CompilerType {
 
   bool IsPolymorphicClass() const;
 
-  bool
-  IsPossibleCPlusPlusDynamicType(CompilerType *target_type = nullptr) const {
-return IsPossibleDynamicType(target_type, true, false);
-  }
-
   bool IsPossibleDynamicType(CompilerType *target_type, // Can pass nullptr
  bool check_cplusplus, bool check_objc) const;
 



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


[Lldb-commits] [lldb] 52f3a2f - [lldb][NFC] Move LLVM RTTI implementation from enum to static ID variable

2019-11-12 Thread Raphael Isemann via lldb-commits

Author: Raphael Isemann
Date: 2019-11-12T10:04:32+01:00
New Revision: 52f3a2faf92c4d8efd0e626d52d5f64b7c5d468f

URL: 
https://github.com/llvm/llvm-project/commit/52f3a2faf92c4d8efd0e626d52d5f64b7c5d468f
DIFF: 
https://github.com/llvm/llvm-project/commit/52f3a2faf92c4d8efd0e626d52d5f64b7c5d468f.diff

LOG: [lldb][NFC] Move LLVM RTTI implementation from enum to static ID variable

Summary:
swift-lldb currently has to patch the ExpressionKind enum to add support for 
Swift expressions. If we implement LLVM's RTTI
with a static ID variable instead of a centralised enum we can drop that patch.

Reviewers: labath, davide

Reviewed By: labath

Subscribers: JDevlieghere, lldb-commits

Tags: #upstreaming_lldb_s_downstream_patches, #lldb

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

Added: 


Modified: 
lldb/include/lldb/Expression/Expression.h
lldb/include/lldb/Expression/FunctionCaller.h
lldb/include/lldb/Expression/LLVMUserExpression.h
lldb/include/lldb/Expression/UserExpression.h
lldb/include/lldb/Expression/UtilityFunction.h
lldb/source/Expression/Expression.cpp
lldb/source/Expression/FunctionCaller.cpp
lldb/source/Expression/LLVMUserExpression.cpp
lldb/source/Expression/UserExpression.cpp
lldb/source/Expression/UtilityFunction.cpp
lldb/source/Plugins/ExpressionParser/Clang/ClangFunctionCaller.cpp
lldb/source/Plugins/ExpressionParser/Clang/ClangFunctionCaller.h
lldb/source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp
lldb/source/Plugins/ExpressionParser/Clang/ClangUserExpression.h
lldb/source/Plugins/ExpressionParser/Clang/ClangUtilityFunction.cpp
lldb/source/Plugins/ExpressionParser/Clang/ClangUtilityFunction.h

Removed: 




diff  --git a/lldb/include/lldb/Expression/Expression.h 
b/lldb/include/lldb/Expression/Expression.h
index fca5fb9119cb..e0ea7e99f4f9 100644
--- a/lldb/include/lldb/Expression/Expression.h
+++ b/lldb/include/lldb/Expression/Expression.h
@@ -32,22 +32,11 @@ class RecordingMemoryManager;
 /// LLVM IR from the expression.
 class Expression {
 public:
-  /// Discriminator for LLVM-style RTTI (dyn_cast<> et al.)
-  enum ExpressionKind {
-eKindFunctionCaller,
-eKindClangFunctionCaller,
-eKindUserExpression,
-eKindLLVMUserExpression,
-eKindClangUserExpression,
-eKindUtilityFunction,
-eKindClangUtilityFunction,
-  };
-
   enum ResultType { eResultTypeAny, eResultTypeId };
 
-  Expression(Target &target, ExpressionKind kind);
+  Expression(Target &target);
 
-  Expression(ExecutionContextScope &exe_scope, ExpressionKind kind);
+  Expression(ExecutionContextScope &exe_scope);
 
   /// Destructor
   virtual ~Expression() {}
@@ -94,12 +83,9 @@ class Expression {
 
   virtual ExpressionTypeSystemHelper *GetTypeSystemHelper() { return nullptr; }
 
-  /// LLVM-style RTTI support.
-  ExpressionKind getKind() const { return m_kind; }
-  
-private:
-  /// LLVM-style RTTI support.
-  const ExpressionKind m_kind;
+  // LLVM RTTI support
+  virtual bool isA(const void *ClassID) const = 0;
+
 protected:
   lldb::TargetWP m_target_wp; /// Expression's always have to have a target...
   lldb::ProcessWP m_jit_process_wp; /// An expression might have a process, but

diff  --git a/lldb/include/lldb/Expression/FunctionCaller.h 
b/lldb/include/lldb/Expression/FunctionCaller.h
index ea9d0205bf86..6f60750febd1 100644
--- a/lldb/include/lldb/Expression/FunctionCaller.h
+++ b/lldb/include/lldb/Expression/FunctionCaller.h
@@ -54,12 +54,13 @@ namespace lldb_private {
 /// Any of the methods that take arg_addr_ptr can be passed nullptr, and the
 /// argument space will be managed for you.
 class FunctionCaller : public Expression {
+  // LLVM RTTI support
+  static char ID;
+
 public:
-  /// LLVM-style RTTI support.
-  static bool classof(const Expression *E) {
-return E->getKind() == eKindFunctionCaller;
-  }
-  
+  bool isA(const void *ClassID) const override { return ClassID == &ID; }
+  static bool classof(const Expression *obj) { return obj->isA(&ID); }
+
   /// Constructor
   ///
   /// \param[in] exe_scope

diff  --git a/lldb/include/lldb/Expression/LLVMUserExpression.h 
b/lldb/include/lldb/Expression/LLVMUserExpression.h
index 5f4c43cdea2e..2679c01a4e00 100644
--- a/lldb/include/lldb/Expression/LLVMUserExpression.h
+++ b/lldb/include/lldb/Expression/LLVMUserExpression.h
@@ -30,11 +30,14 @@ namespace lldb_private {
 /// implementations of LLVMUserExpression - which will be vended through the
 /// appropriate TypeSystem.
 class LLVMUserExpression : public UserExpression {
+  // LLVM RTTI support
+  static char ID;
+
 public:
-  /// LLVM-style RTTI support.
-  static bool classof(const Expression *E) {
-return E->getKind() == eKindLLVMUserExpression;
+  bool isA(const void *ClassID) const override {
+return ClassID == &ID || UserExpression::isA(ClassID);
   }
+  static bool classof(const Expression *obj) { ret

[Lldb-commits] [lldb] 874b649 - [lldb] Add missing include to ObjCLanguage.cpp to fix build

2019-11-12 Thread Raphael Isemann via lldb-commits

Author: Raphael Isemann
Date: 2019-11-12T10:21:49+01:00
New Revision: 874b6495b5fd6d7e2dc91d6a756eea67486ea7bb

URL: 
https://github.com/llvm/llvm-project/commit/874b6495b5fd6d7e2dc91d6a756eea67486ea7bb
DIFF: 
https://github.com/llvm/llvm-project/commit/874b6495b5fd6d7e2dc91d6a756eea67486ea7bb.diff

LOG: [lldb] Add missing include to ObjCLanguage.cpp to fix build

Added: 


Modified: 
lldb/source/Plugins/Language/ObjC/ObjCLanguage.cpp

Removed: 




diff  --git a/lldb/source/Plugins/Language/ObjC/ObjCLanguage.cpp 
b/lldb/source/Plugins/Language/ObjC/ObjCLanguage.cpp
index 0e0f8ae7fb0a..3be548ad4144 100644
--- a/lldb/source/Plugins/Language/ObjC/ObjCLanguage.cpp
+++ b/lldb/source/Plugins/Language/ObjC/ObjCLanguage.cpp
@@ -15,6 +15,7 @@
 #include "lldb/DataFormatters/DataVisualization.h"
 #include "lldb/DataFormatters/FormattersHelpers.h"
 #include "lldb/Symbol/ClangASTContext.h"
+#include "lldb/Symbol/ClangUtil.h"
 #include "lldb/Symbol/CompilerType.h"
 #include "lldb/Target/Target.h"
 #include "lldb/Utility/ConstString.h"



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


[Lldb-commits] [lldb] ec4c96d - [lldb][NFC] Simplify a return in ThreadPlanStepInRange::DefaultShouldStopHereCallback

2019-11-12 Thread Raphael Isemann via lldb-commits

Author: Raphael Isemann
Date: 2019-11-12T10:58:54+01:00
New Revision: ec4c96d68566debcc4588c4189b4ef8a5f78729a

URL: 
https://github.com/llvm/llvm-project/commit/ec4c96d68566debcc4588c4189b4ef8a5f78729a
DIFF: 
https://github.com/llvm/llvm-project/commit/ec4c96d68566debcc4588c4189b4ef8a5f78729a.diff

LOG: [lldb][NFC] Simplify a return in 
ThreadPlanStepInRange::DefaultShouldStopHereCallback

We know should_stop_here is false here, so we might as well return false 
directly.

Added: 


Modified: 
lldb/source/Target/ThreadPlanStepInRange.cpp

Removed: 




diff  --git a/lldb/source/Target/ThreadPlanStepInRange.cpp 
b/lldb/source/Target/ThreadPlanStepInRange.cpp
index 71045cc7a990..2aed516b 100644
--- a/lldb/source/Target/ThreadPlanStepInRange.cpp
+++ b/lldb/source/Target/ThreadPlanStepInRange.cpp
@@ -392,7 +392,7 @@ bool ThreadPlanStepInRange::DefaultShouldStopHereCallback(
   should_stop_here = ThreadPlanShouldStopHere::DefaultShouldStopHereCallback(
   current_plan, flags, operation, status, baton);
   if (!should_stop_here)
-return should_stop_here;
+return false;
 
   if (should_stop_here && current_plan->GetKind() == eKindStepInRange &&
   operation == eFrameCompareYounger) {



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


[Lldb-commits] [lldb] ea2ba51 - [lldb][NFC] Simplify IOHandler constructor/destructor setup

2019-11-14 Thread Raphael Isemann via lldb-commits

Author: Raphael Isemann
Date: 2019-11-14T09:59:00+01:00
New Revision: ea2ba51b0b2f5bc0bea650bf64e5cbd63476563f

URL: 
https://github.com/llvm/llvm-project/commit/ea2ba51b0b2f5bc0bea650bf64e5cbd63476563f
DIFF: 
https://github.com/llvm/llvm-project/commit/ea2ba51b0b2f5bc0bea650bf64e5cbd63476563f.diff

LOG: [lldb][NFC] Simplify IOHandler constructor/destructor setup

We only need a default constructor because of DISALLOW_COPY_AND_ASSIGN,
but the non-virtual destructor isn't needed.

Added: 


Modified: 
lldb/include/lldb/Core/IOHandler.h

Removed: 




diff  --git a/lldb/include/lldb/Core/IOHandler.h 
b/lldb/include/lldb/Core/IOHandler.h
index 37142a5a8396..04b94da3a8c1 100644
--- a/lldb/include/lldb/Core/IOHandler.h
+++ b/lldb/include/lldb/Core/IOHandler.h
@@ -495,9 +495,7 @@ class IOHandlerCursesValueObjectList : public IOHandler {
 
 class IOHandlerStack {
 public:
-  IOHandlerStack() : m_stack(), m_mutex(), m_top(nullptr) {}
-
-  ~IOHandlerStack() = default;
+  IOHandlerStack() = default;
 
   size_t GetSize() const {
 std::lock_guard guard(m_mutex);
@@ -574,7 +572,7 @@ class IOHandlerStack {
   typedef std::vector collection;
   collection m_stack;
   mutable std::recursive_mutex m_mutex;
-  IOHandler *m_top;
+  IOHandler *m_top = nullptr;
 
 private:
   DISALLOW_COPY_AND_ASSIGN(IOHandlerStack);



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


[Lldb-commits] [lldb] 8715ffd - [lldb] Fix that trailing backslashes in source lines break the Clang highlighter

2019-11-14 Thread Raphael Isemann via lldb-commits

Author: Raphael Isemann
Date: 2019-11-14T11:11:20+01:00
New Revision: 8715ffdf1aafbfca7c3d7f1622fe586243f31df1

URL: 
https://github.com/llvm/llvm-project/commit/8715ffdf1aafbfca7c3d7f1622fe586243f31df1
DIFF: 
https://github.com/llvm/llvm-project/commit/8715ffdf1aafbfca7c3d7f1622fe586243f31df1.diff

LOG: [lldb] Fix that trailing backslashes in source lines break the Clang 
highlighter

Summary:
Clang's raw Lexer doesn't produce any tokens for trailing backslashes in a 
line. This doesn't work with
LLDB's Clang highlighter which builds the source code to display from the list 
of tokens the Lexer returns.
This causes that lines with trailing backslashes are lacking the backslash and 
the following newline when
rendering source code in LLDB.

This patch removes the trailing newline from the current line we are 
highlighting. This way Clang doesn't
drop the backslash token and we just restore the newline after tokenising.

Fixes rdar://57091487

Reviewers: JDevlieghere, labath

Reviewed By: JDevlieghere, labath

Subscribers: labath, lldb-commits

Tags: #lldb

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

Added: 


Modified: 
lldb/source/Plugins/Language/ClangCommon/ClangHighlighter.cpp
lldb/unittests/Language/Highlighting/HighlighterTest.cpp

Removed: 




diff  --git a/lldb/source/Plugins/Language/ClangCommon/ClangHighlighter.cpp 
b/lldb/source/Plugins/Language/ClangCommon/ClangHighlighter.cpp
index a9a1b44731f2..3e77b1646739 100644
--- a/lldb/source/Plugins/Language/ClangCommon/ClangHighlighter.cpp
+++ b/lldb/source/Plugins/Language/ClangCommon/ClangHighlighter.cpp
@@ -139,6 +139,22 @@ void ClangHighlighter::Highlight(const HighlightStyle 
&options,
   FileManager file_mgr(file_opts,
FileSystem::Instance().GetVirtualFileSystem());
 
+  // The line might end in a backslash which would cause Clang to drop the
+  // backslash and the terminating new line. This makes sense when parsing C++,
+  // but when highlighting we care about preserving the backslash/newline. To
+  // not lose this information we remove the new line here so that Clang knows
+  // this is just a single line we are highlighting. We add back the newline
+  // after tokenizing.
+  llvm::StringRef line_ending = "";
+  // There are a few legal line endings Clang recognizes and we need to
+  // temporarily remove from the string.
+  if (line.consume_back("\r\n"))
+line_ending = "\r\n";
+  else if (line.consume_back("\n"))
+line_ending = "\n";
+  else if (line.consume_back("\r"))
+line_ending = "\r";
+
   unsigned line_number = previous_lines.count('\n') + 1U;
 
   // Let's build the actual source code Clang needs and setup some utility
@@ -227,6 +243,9 @@ void ClangHighlighter::Highlight(const HighlightStyle 
&options,
 color.Apply(result, to_print);
   }
 
+  // Add the line ending we trimmed before tokenizing.
+  result << line_ending;
+
   // If we went over the whole file but couldn't find our own file, then
   // somehow our setup was wrong. When we're in release mode we just give the
   // user the normal line and pretend we don't know how to highlight it. In

diff  --git a/lldb/unittests/Language/Highlighting/HighlighterTest.cpp 
b/lldb/unittests/Language/Highlighting/HighlighterTest.cpp
index 71457ed61892..ebcc6122245f 100644
--- a/lldb/unittests/Language/Highlighting/HighlighterTest.cpp
+++ b/lldb/unittests/Language/Highlighting/HighlighterTest.cpp
@@ -205,6 +205,44 @@ TEST_F(HighlighterTest, ClangPPDirectives) {
 highlightC("#include \"foo\" //c", s));
 }
 
+TEST_F(HighlighterTest, ClangPreserveNewLine) {
+  HighlightStyle s;
+  s.comment.Set("", "");
+
+  EXPECT_EQ("//\n", highlightC("//\n", s));
+}
+
+TEST_F(HighlighterTest, ClangTrailingBackslashBeforeNewline) {
+  HighlightStyle s;
+
+  EXPECT_EQ("\\\n", highlightC("\\\n", s));
+  EXPECT_EQ("\\\r\n", highlightC("\\\r\n", s));
+
+  EXPECT_EQ("#define a \\\n", highlightC("#define a \\\n", s));
+  EXPECT_EQ("#define a \\\r\n", highlightC("#define a \\\r\n", s));
+  EXPECT_EQ("#define a \\\r", highlightC("#define a \\\r", s));
+}
+
+TEST_F(HighlighterTest, ClangTrailingBackslashWithWhitespace) {
+  HighlightStyle s;
+
+  EXPECT_EQ("\\  \n", highlightC("\\  \n", s));
+  EXPECT_EQ("\\ \t\n", highlightC("\\ \t\n", s));
+  EXPECT_EQ("\\ \n", highlightC("\\ \n", s));
+  EXPECT_EQ("\\\t\n", highlightC("\\\t\n", s));
+
+  EXPECT_EQ("#define a \\  \n", highlightC("#define a \\  \n", s));
+  EXPECT_EQ("#define a \\ \t\n", highlightC("#define a \\ \t\n", s));
+  EXPECT_EQ("#define a \\ \n", highlightC("#define a \\ \n", s));
+  EXPECT_EQ("#define a \\\t\n", highlightC("#define a \\\t\n", s));
+}
+
+TEST_F(HighlighterTest, ClangTrailingBackslashMissingNewLine) {
+  HighlightStyle s;
+  EXPECT_EQ("\\", highlightC("\\", s));
+  EXPECT_EQ("#define a\\", highlightC("#define a\\", s));
+}
+
 TEST_F(HighlighterTest, ClangComments) {
   HighlightS

[Lldb-commits] [lldb] 869d904 - [lldb][NFC] Cleanup comments in ClangASTSource.h

2019-11-18 Thread Raphael Isemann via lldb-commits

Author: Raphael Isemann
Date: 2019-11-18T14:17:35+01:00
New Revision: 869d904df76c9e74e040b072b4bc8114fd20f5bc

URL: 
https://github.com/llvm/llvm-project/commit/869d904df76c9e74e040b072b4bc8114fd20f5bc
DIFF: 
https://github.com/llvm/llvm-project/commit/869d904df76c9e74e040b072b4bc8114fd20f5bc.diff

LOG: [lldb][NFC] Cleanup comments in ClangASTSource.h

The current file doesn't follow the 80 character limit and uses this
cramped comment style that is hard to read.

Added: 


Modified: 
lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.h

Removed: 




diff  --git a/lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.h 
b/lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.h
index cfb81482d832..d8e784f49b10 100644
--- a/lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.h
+++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.h
@@ -404,15 +404,16 @@ class ClangASTSource : public 
ClangExternalASTSourceCommon,
   bool m_import_in_progress;
   bool m_lookups_enabled;
 
-  const lldb::TargetSP
-  m_target; ///< The target to use in finding variables and types.
-  clang::ASTContext
-  *m_ast_context; ///< The AST context requests are coming in for.
-  clang::FileManager
-  *m_file_manager; ///< The file manager paired with the AST context.
-  lldb::ClangASTImporterSP m_ast_importer_sp; ///< The target's AST importer.
+  /// The target to use in finding variables and types.
+  const lldb::TargetSP m_target;
+  /// The AST context requests are coming in for.
+  clang::ASTContext *m_ast_context;
+  /// The file manager paired with the AST context.
+  clang::FileManager *m_file_manager;
+  /// The target's AST importer.
+  lldb::ClangASTImporterSP m_ast_importer_sp;
+  /// The ExternalASTMerger for this parse.
   std::unique_ptr m_merger_up;
-  ///< The ExternalASTMerger for this parse.
   std::set m_active_lexical_decls;
   std::set m_active_lookups;
 };
@@ -425,20 +426,20 @@ class ClangASTSource : public 
ClangExternalASTSourceCommon,
 /// what name is being searched for and provides helper functions to construct
 /// Decls given appropriate type information.
 struct NameSearchContext {
-  ClangASTSource &m_ast_source; ///< The AST source making the request
-  llvm::SmallVectorImpl
-  &m_decls; ///< The list of declarations already constructed
-  ClangASTImporter::NamespaceMapSP m_namespace_map; ///< The mapping of all
-///namespaces found for 
this
-///request back to their
-///modules
-  const clang::DeclarationName &m_decl_name; ///< The name being looked for
-  const clang::DeclContext
-  *m_decl_context; ///< The DeclContext to put declarations into
-  llvm::SmallSet m_function_types; ///< All the types of
-///functions that have been
-///reported, so we don't
-///report conflicts
+  /// The AST source making the request.
+  ClangASTSource &m_ast_source;
+  /// The list of declarations already constructed.
+  llvm::SmallVectorImpl &m_decls;
+  /// The mapping of all namespaces found for this request back to their
+  /// modules.
+  ClangASTImporter::NamespaceMapSP m_namespace_map;
+  /// The name being looked for.
+  const clang::DeclarationName &m_decl_name;
+  /// The DeclContext to put declarations into.
+  const clang::DeclContext *m_decl_context;
+  /// All the types of functions that have been reported, so we don't
+  /// report conflicts.
+  llvm::SmallSet m_function_types;
 
   struct {
 bool variable : 1;



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


[Lldb-commits] [lldb] 10b8514 - [lldb] Fix JSON parser to allow empty arrays

2019-11-18 Thread Raphael Isemann via lldb-commits

Author: Alex Cameron
Date: 2019-11-18T15:12:55+01:00
New Revision: 10b851434324f82e9ad11d39f501f2d8b921642a

URL: 
https://github.com/llvm/llvm-project/commit/10b851434324f82e9ad11d39f501f2d8b921642a
DIFF: 
https://github.com/llvm/llvm-project/commit/10b851434324f82e9ad11d39f501f2d8b921642a.diff

LOG: [lldb] Fix JSON parser to allow empty arrays

Summary:
Bugzilla: https://bugs.llvm.org/show_bug.cgi?id=39405
```
alexc@kitty:~/work/wiredtiger/build_posix$ cat breakpoint.json
[{"Breakpoint" : {"BKPTOptions" : {"AutoContinue" : false,"ConditionText" : 
"","EnabledState" : true,"IgnoreCount" : 0,"OneShotState" : 
false},"BKPTResolver" : {"Options" : {"NameMask" : [56],"Offset" : 
0,"SkipPrologue" : true,"SymbolNames" : ["__wt_btcur_search"]},"Type" : 
"SymbolName"},"Hardware" : false,"SearchFilter" : {"Options" : {},"Type" : 
"Unconstrained","Foo" : []}}}]
```
**Before**
```
(lldb) breakpoint read --file breakpoint.json
error: Invalid JSON from input file: 
/home/alexc/work/wiredtiger/build_posix/breakpoint.json.
```
**After**
```
(lldb) breakpoint read --file breakpoint.json
New breakpoints:
Breakpoint 1: where = libwiredtiger-3.2.2.so`__wt_btcur_search + 15 at 
bt_cursor.c:522:5, address = 0x7576ab2f
```

Reviewers: xbolva00, davide, labath

Reviewed By: davide, labath

Subscribers: mgorny, jingham, labath, davide, JDevlieghere, lldb-commits

Tags: #llvm, #lldb

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

Added: 
lldb/unittests/debugserver/JSONTest.cpp

Modified: 
lldb/tools/debugserver/source/JSON.cpp
lldb/tools/debugserver/source/JSON.h
lldb/unittests/debugserver/CMakeLists.txt

Removed: 




diff  --git a/lldb/tools/debugserver/source/JSON.cpp 
b/lldb/tools/debugserver/source/JSON.cpp
index 1b37767256d7..12d96d4ed4db 100644
--- a/lldb/tools/debugserver/source/JSON.cpp
+++ b/lldb/tools/debugserver/source/JSON.cpp
@@ -516,13 +516,16 @@ JSONValue::SP JSONParser::ParseJSONArray() {
   std::string value;
   std::string key;
   while (true) {
-JSONValue::SP value_sp = ParseJSONValue();
+JSONParser::Token token = GetToken(value);
+if (token == JSONParser::Token::ArrayEnd)
+  return JSONValue::SP(array_up.release());
+JSONValue::SP value_sp = ParseJSONValue(value, token);
 if (value_sp)
   array_up->AppendObject(value_sp);
 else
   break;
 
-JSONParser::Token token = GetToken(value);
+token = GetToken(value);
 if (token == JSONParser::Token::Comma) {
   continue;
 } else if (token == JSONParser::Token::ArrayEnd) {
@@ -537,6 +540,11 @@ JSONValue::SP JSONParser::ParseJSONArray() {
 JSONValue::SP JSONParser::ParseJSONValue() {
   std::string value;
   const JSONParser::Token token = GetToken(value);
+  return ParseJSONValue(value, token);
+}
+
+JSONValue::SP JSONParser::ParseJSONValue(const std::string &value,
+ const Token &token) {
   switch (token) {
   case JSONParser::Token::ObjectStart:
 return ParseJSONObject();

diff  --git a/lldb/tools/debugserver/source/JSON.h 
b/lldb/tools/debugserver/source/JSON.h
index b1c4a4c9db82..70bfdd7259ac 100644
--- a/lldb/tools/debugserver/source/JSON.h
+++ b/lldb/tools/debugserver/source/JSON.h
@@ -292,6 +292,8 @@ class JSONParser : public StdStringExtractor {
   JSONValue::SP ParseJSONValue();
 
 protected:
+  JSONValue::SP ParseJSONValue(const std::string &value, const Token &token);
+
   JSONValue::SP ParseJSONObject();
 
   JSONValue::SP ParseJSONArray();

diff  --git a/lldb/unittests/debugserver/CMakeLists.txt 
b/lldb/unittests/debugserver/CMakeLists.txt
index adb8fb00ddac..a72b805c65b1 100644
--- a/lldb/unittests/debugserver/CMakeLists.txt
+++ b/lldb/unittests/debugserver/CMakeLists.txt
@@ -8,6 +8,7 @@ include_directories(${LLDB_SOURCE_DIR}/tools/debugserver/source
 ${LLDB_SOURCE_DIR}/tools/debugserver/source/MacOSX)
 
 add_lldb_unittest(debugserverTests
+  JSONTest.cpp
   RNBSocketTest.cpp
   debugserver_LogCallback.cpp
 
@@ -24,8 +25,9 @@ if(IOS)
   WITH_FBS
   WITH_BKS
   )
-  
+
   add_lldb_unittest(debugserverNonUITests
+JSONTest.cpp
 RNBSocketTest.cpp
 debugserver_LogCallback.cpp
 

diff  --git a/lldb/unittests/debugserver/JSONTest.cpp 
b/lldb/unittests/debugserver/JSONTest.cpp
new file mode 100644
index ..54f6f96068ee
--- /dev/null
+++ b/lldb/unittests/debugserver/JSONTest.cpp
@@ -0,0 +1,89 @@
+//===-- JSONTest.cpp *- C++ 
-*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "gmock/gmock.h"
+#include "gtest/gtest.h"
+
+#include "JSON.h"
+
+template 
+void TestJSON(JSONValue *json_val, const s

[Lldb-commits] [lldb] 96d814a - [lldb] Remove ClangExpressionDeclMap::ResolveUnknownTypes

2019-11-19 Thread Raphael Isemann via lldb-commits

Author: Raphael Isemann
Date: 2019-11-19T12:44:27+01:00
New Revision: 96d814a5fe0a333bc53f52e8f290d1ac009c85fe

URL: 
https://github.com/llvm/llvm-project/commit/96d814a5fe0a333bc53f52e8f290d1ac009c85fe
DIFF: 
https://github.com/llvm/llvm-project/commit/96d814a5fe0a333bc53f52e8f290d1ac009c85fe.diff

LOG: [lldb] Remove ClangExpressionDeclMap::ResolveUnknownTypes

Summary:
This is some really shady code. It's supposed to kick in after an expression 
already failed and then try to look
up "unknown types" that for some undocumented reason can't be resolved 
during/before parsing. Beside the
fact that we never mark any type as `EVUnknownType` in either swift-lldb or 
lldb (which means this code is unreachable),
this code doesn't even make the expression evaluation succeed if if would ever 
be executed but instead seems
to try to load more debug info that maybe any following expression evaluations 
might succeed.

This patch removes ClangExpressionDeclMap::ResolveUnknownTypes and the related 
data structures/checks/calls.

Reviewers: davide

Reviewed By: davide

Subscribers: aprantl, abidh, JDevlieghere, lldb-commits

Tags: #lldb

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

Added: 


Modified: 
lldb/include/lldb/Expression/ExpressionVariable.h
lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp
lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.h
lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp

Removed: 




diff  --git a/lldb/include/lldb/Expression/ExpressionVariable.h 
b/lldb/include/lldb/Expression/ExpressionVariable.h
index 08c987270bfe..c20c2301bb54 100644
--- a/lldb/include/lldb/Expression/ExpressionVariable.h
+++ b/lldb/include/lldb/Expression/ExpressionVariable.h
@@ -98,9 +98,7 @@ class ExpressionVariable
 EVTypeIsReference = 1 << 6, ///< The original type of this variable is a
 ///reference, so materialize the value rather
 ///than the location
-EVUnknownType = 1 << 7, ///< This is a symbol of unknown type, and the type
-///must be resolved after parsing is complete
-EVBareRegister = 1 << 8 ///< This variable is a direct reference to $pc or
+EVBareRegister = 1 << 7 ///< This variable is a direct reference to $pc or
 ///some other entity.
   };
 

diff  --git 
a/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp 
b/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp
index f4457fc1b740..35a50c8fed16 100644
--- a/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp
+++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp
@@ -1769,80 +1769,6 @@ void 
ClangExpressionDeclMap::AddOneGenericVariable(NameSearchContext &context,
   }
 }
 
-bool ClangExpressionDeclMap::ResolveUnknownTypes() {
-  Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS));
-  Target *target = m_parser_vars->m_exe_ctx.GetTargetPtr();
-
-  ClangASTContextForExpressions *scratch_ast_context =
-  static_cast(
-  target->GetScratchClangASTContext());
-
-  for (size_t index = 0, num_entities = m_found_entities.GetSize();
-   index < num_entities; ++index) {
-ExpressionVariableSP entity = m_found_entities.GetVariableAtIndex(index);
-
-ClangExpressionVariable::ParserVars *parser_vars =
-llvm::cast(entity.get())
-->GetParserVars(GetParserID());
-
-if (entity->m_flags & ClangExpressionVariable::EVUnknownType) {
-  const NamedDecl *named_decl = parser_vars->m_named_decl;
-  const VarDecl *var_decl = dyn_cast(named_decl);
-
-  if (!var_decl) {
-LLDB_LOGF(log, "Entity of unknown type does not have a VarDecl");
-return false;
-  }
-
-  if (log) {
-ASTDumper ast_dumper(const_cast(var_decl));
-LLDB_LOGF(log, "Variable of unknown type now has Decl %s",
-  ast_dumper.GetCString());
-  }
-
-  QualType var_type = var_decl->getType();
-  TypeFromParser parser_type(
-  var_type.getAsOpaquePtr(),
-  ClangASTContext::GetASTContext(&var_decl->getASTContext()));
-
-  lldb::opaque_compiler_type_t copied_type = nullptr;
-  if (m_ast_importer_sp) {
-copied_type = m_ast_importer_sp->CopyType(
-scratch_ast_context->getASTContext(), &var_decl->getASTContext(),
-var_type.getAsOpaquePtr());
-  } else if (HasMerger()) {
-copied_type = CopyTypeWithMerger(
-  var_decl->getASTContext(),
-  scratch_ast_context->GetMergerUnchecked(), var_type)
-  .getAsOpaquePtr();
-  } else {
-lldbassert(0 && "No mechanism to copy a resolved unknown type!");
-return false;
-  }
-
-  if (!copied_type) {
- 

[Lldb-commits] [lldb] f6ffe6f - [lldb] Also test Get[De]mangledName of SBType in TestSBTypeClassMembers.py

2019-11-19 Thread Raphael Isemann via lldb-commits

Author: Raphael Isemann
Date: 2019-11-19T14:04:02+01:00
New Revision: f6ffe6fc9d9b8b0e197500b5b61f3e8d55599d7a

URL: 
https://github.com/llvm/llvm-project/commit/f6ffe6fc9d9b8b0e197500b5b61f3e8d55599d7a
DIFF: 
https://github.com/llvm/llvm-project/commit/f6ffe6fc9d9b8b0e197500b5b61f3e8d55599d7a.diff

LOG: [lldb] Also test Get[De]mangledName of SBType in TestSBTypeClassMembers.py

I just used the mangled names as this test is anyway a Darwin-only ObjC++ test.
We probably should also test this on other platforms but that will be
another commit as we need to untangle the ObjC and C++ parts first.

Added: 


Modified: 

lldb/packages/Python/lldbsuite/test/python_api/class_members/TestSBTypeClassMembers.py

Removed: 




diff  --git 
a/lldb/packages/Python/lldbsuite/test/python_api/class_members/TestSBTypeClassMembers.py
 
b/lldb/packages/Python/lldbsuite/test/python_api/class_members/TestSBTypeClassMembers.py
index 960df3f184db..3517abb1ebb9 100644
--- 
a/lldb/packages/Python/lldbsuite/test/python_api/class_members/TestSBTypeClassMembers.py
+++ 
b/lldb/packages/Python/lldbsuite/test/python_api/class_members/TestSBTypeClassMembers.py
@@ -102,3 +102,17 @@ def test(self):
 self.assertEquals("int",
 Thingy.GetMemberFunctionAtIndex(1).GetArgumentTypeAtIndex(
 0).GetName(), "Thingy::foo takes an int")
+
+self.assertEquals("Derived::dImpl()", 
Derived.GetMemberFunctionAtIndex(0).GetDemangledName())
+self.assertEquals("Derived::baz(float)", 
Derived.GetMemberFunctionAtIndex(1).GetDemangledName())
+self.assertEquals("Base::foo(int, int)", 
Base.GetMemberFunctionAtIndex(0).GetDemangledName())
+self.assertEquals("Base::bar(int, char)", 
Base.GetMemberFunctionAtIndex(1).GetDemangledName())
+self.assertEquals("Base::dat()", 
Base.GetMemberFunctionAtIndex(2).GetDemangledName())
+self.assertEquals("Base::sfunc(char, int, float)", 
Base.GetMemberFunctionAtIndex(3).GetDemangledName())
+
+self.assertEquals("_ZN7Derived5dImplEv", 
Derived.GetMemberFunctionAtIndex(0).GetMangledName())
+self.assertEquals("_ZN7Derived3bazEf", 
Derived.GetMemberFunctionAtIndex(1).GetMangledName())
+self.assertEquals("_ZN4Base3fooEii", 
Base.GetMemberFunctionAtIndex(0).GetMangledName())
+self.assertEquals("_ZN4Base3barEic", 
Base.GetMemberFunctionAtIndex(1).GetMangledName())
+self.assertEquals("_ZN4Base3datEv", 
Base.GetMemberFunctionAtIndex(2).GetMangledName())
+self.assertEquals("_ZN4Base5sfuncEcif", 
Base.GetMemberFunctionAtIndex(3).GetMangledName())



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


[Lldb-commits] [lldb] c54d21c - [lldb][NFC] Early exit in IRExecutionUnit::GetStaticInitializers

2019-11-19 Thread Raphael Isemann via lldb-commits

Author: Raphael Isemann
Date: 2019-11-19T15:06:30+01:00
New Revision: c54d21c848d350e85cd8f95a725fc12f6fa3ab19

URL: 
https://github.com/llvm/llvm-project/commit/c54d21c848d350e85cd8f95a725fc12f6fa3ab19
DIFF: 
https://github.com/llvm/llvm-project/commit/c54d21c848d350e85cd8f95a725fc12f6fa3ab19.diff

LOG: [lldb][NFC] Early exit in IRExecutionUnit::GetStaticInitializers

Added: 


Modified: 
lldb/source/Expression/IRExecutionUnit.cpp

Removed: 




diff  --git a/lldb/source/Expression/IRExecutionUnit.cpp 
b/lldb/source/Expression/IRExecutionUnit.cpp
index b10628e10cc5..105f875fa1d2 100644
--- a/lldb/source/Expression/IRExecutionUnit.cpp
+++ b/lldb/source/Expression/IRExecutionUnit.cpp
@@ -977,30 +977,34 @@ IRExecutionUnit::FindSymbol(lldb_private::ConstString 
name, bool &missing_weak)
 
 void IRExecutionUnit::GetStaticInitializers(
 std::vector &static_initializers) {
-  if (llvm::GlobalVariable *global_ctors =
-  m_module->getNamedGlobal("llvm.global_ctors")) {
-if (llvm::ConstantArray *ctor_array = llvm::dyn_cast(
-global_ctors->getInitializer())) {
-  for (llvm::Use &ctor_use : ctor_array->operands()) {
-if (llvm::ConstantStruct *ctor_struct =
-llvm::dyn_cast(ctor_use)) {
-  lldbassert(ctor_struct->getNumOperands() ==
- 3); // this is standardized
-  if (llvm::Function *ctor_function =
-  llvm::dyn_cast(ctor_struct->getOperand(1))) {
-ConstString ctor_function_name_cs(ctor_function->getName().str());
-
-for (JittedFunction &jitted_function : m_jitted_functions) {
-  if (ctor_function_name_cs == jitted_function.m_name) {
-if (jitted_function.m_remote_addr != LLDB_INVALID_ADDRESS) {
-  static_initializers.push_back(jitted_function.m_remote_addr);
-}
-break;
-  }
-}
-  }
-}
-  }
+  llvm::GlobalVariable *global_ctors =
+  m_module->getNamedGlobal("llvm.global_ctors");
+  if (!global_ctors)
+return;
+  auto *ctor_array =
+  llvm::dyn_cast(global_ctors->getInitializer());
+  if (!ctor_array)
+return;
+
+  for (llvm::Use &ctor_use : ctor_array->operands()) {
+auto *ctor_struct = llvm::dyn_cast(ctor_use);
+if (!ctor_struct)
+  continue;
+// this is standardized
+lldbassert(ctor_struct->getNumOperands() == 3);
+auto *ctor_function =
+llvm::dyn_cast(ctor_struct->getOperand(1));
+if (!ctor_function)
+  continue;
+ConstString ctor_function_name_cs(ctor_function->getName().str());
+
+for (JittedFunction &jitted_function : m_jitted_functions) {
+  if (ctor_function_name_cs != jitted_function.m_name)
+continue;
+  if (jitted_function.m_remote_addr == LLDB_INVALID_ADDRESS)
+continue;
+  static_initializers.push_back(jitted_function.m_remote_addr);
+  break;
 }
   }
 }



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


[Lldb-commits] [lldb] 4a6d03a - [lldb] Add logging to IRExecutionUnit::GetStaticInitializers

2019-11-19 Thread Raphael Isemann via lldb-commits

Author: Raphael Isemann
Date: 2019-11-19T15:52:01+01:00
New Revision: 4a6d03ad0e00c75c18d5740438d49918f99cb4f2

URL: 
https://github.com/llvm/llvm-project/commit/4a6d03ad0e00c75c18d5740438d49918f99cb4f2
DIFF: 
https://github.com/llvm/llvm-project/commit/4a6d03ad0e00c75c18d5740438d49918f99cb4f2.diff

LOG: [lldb] Add logging to IRExecutionUnit::GetStaticInitializers

Added: 


Modified: 
lldb/source/Expression/IRExecutionUnit.cpp

Removed: 




diff  --git a/lldb/source/Expression/IRExecutionUnit.cpp 
b/lldb/source/Expression/IRExecutionUnit.cpp
index 105f875fa1d2..33d48842f869 100644
--- a/lldb/source/Expression/IRExecutionUnit.cpp
+++ b/lldb/source/Expression/IRExecutionUnit.cpp
@@ -977,14 +977,20 @@ IRExecutionUnit::FindSymbol(lldb_private::ConstString 
name, bool &missing_weak)
 
 void IRExecutionUnit::GetStaticInitializers(
 std::vector &static_initializers) {
+  Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS));
+
   llvm::GlobalVariable *global_ctors =
   m_module->getNamedGlobal("llvm.global_ctors");
-  if (!global_ctors)
+  if (!global_ctors) {
+LLDB_LOG(log, "Couldn't find llvm.global_ctors.");
 return;
+  }
   auto *ctor_array =
   llvm::dyn_cast(global_ctors->getInitializer());
-  if (!ctor_array)
+  if (!ctor_array) {
+LLDB_LOG(log, "llvm.global_ctors not a ConstantArray.");
 return;
+  }
 
   for (llvm::Use &ctor_use : ctor_array->operands()) {
 auto *ctor_struct = llvm::dyn_cast(ctor_use);
@@ -994,16 +1000,25 @@ void IRExecutionUnit::GetStaticInitializers(
 lldbassert(ctor_struct->getNumOperands() == 3);
 auto *ctor_function =
 llvm::dyn_cast(ctor_struct->getOperand(1));
-if (!ctor_function)
+if (!ctor_function) {
+  LLDB_LOG(log, "global_ctor doesn't contain an llvm::Function");
   continue;
-ConstString ctor_function_name_cs(ctor_function->getName().str());
+}
+
+ConstString ctor_function_name(ctor_function->getName().str());
+LLDB_LOG(log, "Looking for callable jitted function with name {0}.",
+ ctor_function_name);
 
 for (JittedFunction &jitted_function : m_jitted_functions) {
-  if (ctor_function_name_cs != jitted_function.m_name)
+  if (ctor_function_name != jitted_function.m_name)
 continue;
-  if (jitted_function.m_remote_addr == LLDB_INVALID_ADDRESS)
+  if (jitted_function.m_remote_addr == LLDB_INVALID_ADDRESS) {
+LLDB_LOG(log, "Found jitted function with invalid address.");
 continue;
+  }
   static_initializers.push_back(jitted_function.m_remote_addr);
+  LLDB_LOG(log, "Calling function at address {0:x}.",
+   jitted_function.m_remote_addr);
   break;
 }
   }



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


[Lldb-commits] [lldb] r366783 - [lldb][NFC] Tablegenify disassemble

2019-07-23 Thread Raphael Isemann via lldb-commits
Author: teemperor
Date: Tue Jul 23 00:15:54 2019
New Revision: 366783

URL: http://llvm.org/viewvc/llvm-project?rev=366783&view=rev
Log:
[lldb][NFC] Tablegenify disassemble

Modified:
lldb/trunk/source/Commands/CommandObjectDisassemble.cpp
lldb/trunk/source/Commands/Options.td

Modified: lldb/trunk/source/Commands/CommandObjectDisassemble.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectDisassemble.cpp?rev=366783&r1=366782&r2=366783&view=diff
==
--- lldb/trunk/source/Commands/CommandObjectDisassemble.cpp (original)
+++ lldb/trunk/source/Commands/CommandObjectDisassemble.cpp Tue Jul 23 00:15:54 
2019
@@ -31,30 +31,8 @@ using namespace lldb;
 using namespace lldb_private;
 
 static constexpr OptionDefinition g_disassemble_options[] = {
-// clang-format off
-  { LLDB_OPT_SET_ALL, false, "bytes", 'b', OptionParser::eNoArgument,  
 nullptr, {}, 0, eArgTypeNone,  
  "Show opcode bytes when disassembling." },
-  { LLDB_OPT_SET_ALL, false, "context",   'C', 
OptionParser::eRequiredArgument, nullptr, {}, 0,
 eArgTypeNumLines,"Number of context lines of source to show." 
},
-  { LLDB_OPT_SET_ALL, false, "mixed", 'm', OptionParser::eNoArgument,  
 nullptr, {}, 0, eArgTypeNone,  
  "Enable mixed source and assembly display." },
-  { LLDB_OPT_SET_ALL, false, "raw",   'r', OptionParser::eNoArgument,  
 nullptr, {}, 0, eArgTypeNone,  
  "Print raw disassembly with no symbol information." },
-  { LLDB_OPT_SET_ALL, false, "plugin",'P', 
OptionParser::eRequiredArgument, nullptr, {}, 0,
 eArgTypePlugin,  "Name of the disassembler plugin you want to 
use." },
-  { LLDB_OPT_SET_ALL, false, "flavor",'F', 
OptionParser::eRequiredArgument, nullptr, {}, 0,
 eArgTypeDisassemblyFlavor,   "Name of the disassembly flavor you want to 
use.  "
-  "Currently the only valid options are default, and for Intel "
-  "architectures, att and intel." },
-  { LLDB_OPT_SET_ALL, false, "arch",  'A', 
OptionParser::eRequiredArgument, nullptr, {}, 0,
 eArgTypeArchitecture,"Specify the architecture to use from cross 
disassembly." },
-  { LLDB_OPT_SET_1 |
-  LLDB_OPT_SET_2,   true,  "start-address", 's', 
OptionParser::eRequiredArgument, nullptr, {}, 0,
 eArgTypeAddressOrExpression, "Address at which to start disassembling." },
-  { LLDB_OPT_SET_1,   false, "end-address",   'e', 
OptionParser::eRequiredArgument, nullptr, {}, 0,
 eArgTypeAddressOrExpression, "Address at which to end disassembling." },
-  { LLDB_OPT_SET_2 |
-  LLDB_OPT_SET_3 |
-  LLDB_OPT_SET_4 |
-  LLDB_OPT_SET_5,   false, "count", 'c', 
OptionParser::eRequiredArgument, nullptr, {}, 0,
 eArgTypeNumLines,"Number of instructions to display." },
-  { LLDB_OPT_SET_3,   false, "name",  'n', 
OptionParser::eRequiredArgument, nullptr, {}, 
CommandCompletions::eSymbolCompletion, eArgTypeFunctionName,
"Disassemble entire contents of the given function name." },
-  { LLDB_OPT_SET_4,   false, "frame", 'f', OptionParser::eNoArgument,  
 nullptr, {}, 0, eArgTypeNone,  
  "Disassemble from the start of the current frame's function." },
-  { LLDB_OPT_SET_5,   false, "pc",'p', OptionParser::eNoArgument,  
 nullptr, {}, 0, eArgTypeNone,  
  "Disassemble around the current pc." },
-  { LLDB_OPT_SET_6,   false, "line",  'l', OptionParser::eNoArgument,  
 nullptr, {}, 0, eArgTypeNone,  
  "Disassemble the current frame's current source line instructions if 
there is debug line "
-  "table information, else disassemble around the pc." },
-  { LLDB_OPT_SET_7,   false, "address",   'a', 
OptionParser::eRequiredArgument, nullptr, {}, 0,
 eArgTypeAddressOrExpression, "Disassemble function containing this 
address." },
-// clang-format on
+#define LLDB_OPTIONS_disassemble
+#include "CommandOptions.inc"
 };
 
 CommandObjectDisassemble::CommandOptions::CommandOptions()

Modified: lldb/trunk/source/Commands/Options.td
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/Options.td?rev=366783&r1=366782&r2=366783&view=diff
==
--- lldb/trunk/source/Commands/Options.td (original)
+++ lldb/trunk/source/Commands/Options.td Tue Jul 23 00:15:54 2019
@@ -295,6 +295,45

[Lldb-commits] [lldb] r366795 - [lldb][NFC] Tablegenify source

2019-07-23 Thread Raphael Isemann via lldb-commits
Author: teemperor
Date: Tue Jul 23 04:08:12 2019
New Revision: 366795

URL: http://llvm.org/viewvc/llvm-project?rev=366795&view=rev
Log:
[lldb][NFC] Tablegenify source

Modified:
lldb/trunk/source/Commands/CommandObjectSource.cpp
lldb/trunk/source/Commands/Options.td

Modified: lldb/trunk/source/Commands/CommandObjectSource.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectSource.cpp?rev=366795&r1=366794&r2=366795&view=diff
==
--- lldb/trunk/source/Commands/CommandObjectSource.cpp (original)
+++ lldb/trunk/source/Commands/CommandObjectSource.cpp Tue Jul 23 04:08:12 2019
@@ -35,15 +35,8 @@ using namespace lldb_private;
 // CommandObjectSourceInfo - debug line entries dumping command
 
 static constexpr OptionDefinition g_source_info_options[] = {
-// clang-format off
-  { LLDB_OPT_SET_ALL,false, "count",'c', 
OptionParser::eRequiredArgument, nullptr, {}, 0,
 eArgTypeCount,   "The number of line entries to display." 
},
-  { LLDB_OPT_SET_1 | LLDB_OPT_SET_2, false, "shlib",'s', 
OptionParser::eRequiredArgument, nullptr, {}, 
CommandCompletions::eModuleCompletion, eArgTypeShlibName,   "Look 
up the source in the given module or shared library (can be specified more than 
once)." },
-  { LLDB_OPT_SET_1,  false, "file", 'f', 
OptionParser::eRequiredArgument, nullptr, {}, 
CommandCompletions::eSourceFileCompletion, eArgTypeFilename,"The 
file from which to display source." },
-  { LLDB_OPT_SET_1,  false, "line", 'l', 
OptionParser::eRequiredArgument, nullptr, {}, 0,
 eArgTypeLineNum, "The line number at which to start the 
displaying lines." },
-  { LLDB_OPT_SET_1,  false, "end-line", 'e', 
OptionParser::eRequiredArgument, nullptr, {}, 0,
 eArgTypeLineNum, "The line number at which to stop 
displaying lines." },
-  { LLDB_OPT_SET_2,  false, "name", 'n', 
OptionParser::eRequiredArgument, nullptr, {}, 
CommandCompletions::eSymbolCompletion, eArgTypeSymbol,  "The 
name of a function whose source to display." },
-  { LLDB_OPT_SET_3,  false, "address",  'a', 
OptionParser::eRequiredArgument, nullptr, {}, 0,
 eArgTypeAddressOrExpression, "Lookup the address and display the 
source information for the corresponding file and line." },
-// clang-format on
+#define LLDB_OPTIONS_source_info
+#include "CommandOptions.inc"
 };
 
 class CommandObjectSourceInfo : public CommandObjectParsed {
@@ -645,16 +638,8 @@ protected:
 // CommandObjectSourceList
 
 static constexpr OptionDefinition g_source_list_options[] = {
-// clang-format off
-  { LLDB_OPT_SET_ALL,false, "count",'c', 
OptionParser::eRequiredArgument, nullptr, {}, 0,
 eArgTypeCount,   "The number of source lines to display." 
},
-  { LLDB_OPT_SET_1 | LLDB_OPT_SET_2, false, "shlib",'s', 
OptionParser::eRequiredArgument, nullptr, {}, 
CommandCompletions::eModuleCompletion, eArgTypeShlibName,   "Look 
up the source file in the given shared library." },
-  { LLDB_OPT_SET_ALL,false, "show-breakpoints", 'b', 
OptionParser::eNoArgument,   nullptr, {}, 0,
 eArgTypeNone,"Show the line table locations from the 
debug information that indicate valid places to set source level breakpoints." 
},
-  { LLDB_OPT_SET_1,  false, "file", 'f', 
OptionParser::eRequiredArgument, nullptr, {}, 
CommandCompletions::eSourceFileCompletion, eArgTypeFilename,"The 
file from which to display source." },
-  { LLDB_OPT_SET_1,  false, "line", 'l', 
OptionParser::eRequiredArgument, nullptr, {}, 0,
 eArgTypeLineNum, "The line number at which to start the 
display source." },
-  { LLDB_OPT_SET_2,  false, "name", 'n', 
OptionParser::eRequiredArgument, nullptr, {}, 
CommandCompletions::eSymbolCompletion, eArgTypeSymbol,  "The 
name of a function whose source to display." },
-  { LLDB_OPT_SET_3,  false, "address",  'a', 
OptionParser::eRequiredArgument, nullptr, {}, 0,
 eArgTypeAddressOrExpression, "Lookup the address and display the 
source information for the corresponding file and line." },
-  { LLDB_OPT_SET_4,  false, "reverse",  'r', 
OptionParser::eNoArgument,   nullptr, {}, 0,
 eArgTypeNone,"Reverse the listing to look backwards 
from the last 

[Lldb-commits] [lldb] r366804 - [lldb][NFC] Tablegenify process

2019-07-23 Thread Raphael Isemann via lldb-commits
Author: teemperor
Date: Tue Jul 23 05:54:33 2019
New Revision: 366804

URL: http://llvm.org/viewvc/llvm-project?rev=366804&view=rev
Log:
[lldb][NFC] Tablegenify process

Modified:
lldb/trunk/source/Commands/CommandObjectProcess.cpp
lldb/trunk/source/Commands/Options.td

Modified: lldb/trunk/source/Commands/CommandObjectProcess.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectProcess.cpp?rev=366804&r1=366803&r2=366804&view=diff
==
--- lldb/trunk/source/Commands/CommandObjectProcess.cpp (original)
+++ lldb/trunk/source/Commands/CommandObjectProcess.cpp Tue Jul 23 05:54:33 2019
@@ -256,14 +256,8 @@ protected:
 };
 
 static constexpr OptionDefinition g_process_attach_options[] = {
-// clang-format off
-  { LLDB_OPT_SET_ALL, false, "continue", 'c', 
OptionParser::eNoArgument,   nullptr, {}, 0, eArgTypeNone, 
"Immediately continue the process once attached." },
-  { LLDB_OPT_SET_ALL, false, "plugin",   'P', 
OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypePlugin,   "Name of 
the process plugin you want to use." },
-  { LLDB_OPT_SET_1,   false, "pid",  'p', 
OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypePid,  "The 
process ID of an existing process to attach to." },
-  { LLDB_OPT_SET_2,   false, "name", 'n', 
OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypeProcessName,  "The 
name of the process to attach to." },
-  { LLDB_OPT_SET_2,   false, "include-existing", 'i', 
OptionParser::eNoArgument,   nullptr, {}, 0, eArgTypeNone, "Include 
existing processes when doing attach -w." },
-  { LLDB_OPT_SET_2,   false, "waitfor",  'w', 
OptionParser::eNoArgument,   nullptr, {}, 0, eArgTypeNone, "Wait 
for the process with  to launch." },
-// clang-format on
+#define LLDB_OPTIONS_process_attach
+#include "CommandOptions.inc"
 };
 
 #pragma mark CommandObjectProcessAttach
@@ -506,9 +500,8 @@ protected:
 // CommandObjectProcessContinue
 
 static constexpr OptionDefinition g_process_continue_options[] = {
-// clang-format off
-  { LLDB_OPT_SET_ALL, false, "ignore-count",'i', 
OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypeUnsignedInteger, 
"Ignore  crossings of the breakpoint (if it exists) for the currently 
selected thread." }
-// clang-format on
+#define LLDB_OPTIONS_process_continue
+#include "CommandOptions.inc"
 };
 
 #pragma mark CommandObjectProcessContinue
@@ -667,9 +660,8 @@ protected:
 
 // CommandObjectProcessDetach
 static constexpr OptionDefinition g_process_detach_options[] = {
-// clang-format off
-  { LLDB_OPT_SET_1, false, "keep-stopped", 's', 
OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypeBoolean, "Whether or 
not the process should be kept stopped on detach (if possible)." },
-// clang-format on
+#define LLDB_OPTIONS_process_detach
+#include "CommandOptions.inc"
 };
 
 #pragma mark CommandObjectProcessDetach
@@ -764,9 +756,8 @@ protected:
 // CommandObjectProcessConnect
 
 static constexpr OptionDefinition g_process_connect_options[] = {
-// clang-format off
-  { LLDB_OPT_SET_ALL, false, "plugin", 'p', OptionParser::eRequiredArgument, 
nullptr, {}, 0, eArgTypePlugin, "Name of the process plugin you want to use." },
-// clang-format on
+#define LLDB_OPTIONS_process_connect
+#include "CommandOptions.inc"
 };
 
 #pragma mark CommandObjectProcessConnect
@@ -889,9 +880,8 @@ public:
 // CommandObjectProcessLoad
 
 static constexpr OptionDefinition g_process_load_options[] = {
-// clang-format off
-  { LLDB_OPT_SET_ALL, false, "install", 'i', OptionParser::eOptionalArgument, 
nullptr, {}, 0, eArgTypePath, "Install the shared library to the target. If 
specified without an argument then the library will installed in the current 
working directory." },
-// clang-format on
+#define LLDB_OPTIONS_process_load
+#include "CommandOptions.inc"
 };
 
 #pragma mark CommandObjectProcessLoad
@@ -1273,11 +1263,8 @@ public:
 // CommandObjectProcessHandle
 
 static constexpr OptionDefinition g_process_handle_options[] = {
-// clang-format off
-  { LLDB_OPT_SET_1, false, "stop",   's', OptionParser::eRequiredArgument, 
nullptr, {}, 0, eArgTypeBoolean, "Whether or not the process should be stopped 
if the signal is received." },
-  { LLDB_OPT_SET_1, false, "notify", 'n', OptionParser::eRequiredArgument, 
nullptr, {}, 0, eArgTypeBoolean, "Whether or not the debugger should notify the 
user if the signal is received." },
-  { LLDB_OPT_SET_1, false, "pass",   'p', OptionParser::eRequiredArgument, 
nullptr, {}, 0, eArgTypeBoolean, "Whether or not the signal should be passed to 
the process." }
-// clang-format on
+#define LLDB_OPTIONS_process_handle
+#include "CommandOptions.inc"
 };
 
 #pragma mark CommandObjectProcessHandle

Modified: lldb/trunk/source/Commands/Options.td
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/

[Lldb-commits] [lldb] r366891 - [lldb][NFC] Tablegenify platform

2019-07-24 Thread Raphael Isemann via lldb-commits
Author: teemperor
Date: Wed Jul 24 05:05:42 2019
New Revision: 366891

URL: http://llvm.org/viewvc/llvm-project?rev=366891&view=rev
Log:
[lldb][NFC] Tablegenify platform

Modified:
lldb/trunk/source/Commands/CommandObjectPlatform.cpp
lldb/trunk/source/Commands/Options.td

Modified: lldb/trunk/source/Commands/CommandObjectPlatform.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectPlatform.cpp?rev=366891&r1=366890&r2=366891&view=diff
==
--- lldb/trunk/source/Commands/CommandObjectPlatform.cpp (original)
+++ lldb/trunk/source/Commands/CommandObjectPlatform.cpp Wed Jul 24 05:05:42 
2019
@@ -59,19 +59,8 @@ static mode_t ParsePermissionString(llvm
 }
 
 static constexpr OptionDefinition g_permissions_options[] = {
-// clang-format off
-  {LLDB_OPT_SET_ALL, false, "permissions-value",   'v', 
OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypePermissionsNumber, 
"Give out the numeric value for permissions (e.g. 757)"},
-  {LLDB_OPT_SET_ALL, false, "permissions-string",  's', 
OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypePermissionsString, 
"Give out the string value for permissions (e.g. rwxr-xr--)."},
-  {LLDB_OPT_SET_ALL, false, "user-read",   'r', 
OptionParser::eNoArgument,   nullptr, {}, 0, eArgTypeNone,  
"Allow user to read."},
-  {LLDB_OPT_SET_ALL, false, "user-write",  'w', 
OptionParser::eNoArgument,   nullptr, {}, 0, eArgTypeNone,  
"Allow user to write."},
-  {LLDB_OPT_SET_ALL, false, "user-exec",   'x', 
OptionParser::eNoArgument,   nullptr, {}, 0, eArgTypeNone,  
"Allow user to execute."},
-  {LLDB_OPT_SET_ALL, false, "group-read",  'R', 
OptionParser::eNoArgument,   nullptr, {}, 0, eArgTypeNone,  
"Allow group to read."},
-  {LLDB_OPT_SET_ALL, false, "group-write", 'W', 
OptionParser::eNoArgument,   nullptr, {}, 0, eArgTypeNone,  
"Allow group to write."},
-  {LLDB_OPT_SET_ALL, false, "group-exec",  'X', 
OptionParser::eNoArgument,   nullptr, {}, 0, eArgTypeNone,  
"Allow group to execute."},
-  {LLDB_OPT_SET_ALL, false, "world-read",  'd', 
OptionParser::eNoArgument,   nullptr, {}, 0, eArgTypeNone,  
"Allow world to read."},
-  {LLDB_OPT_SET_ALL, false, "world-write", 't', 
OptionParser::eNoArgument,   nullptr, {}, 0, eArgTypeNone,  
"Allow world to write."},
-  {LLDB_OPT_SET_ALL, false, "world-exec",  'e', 
OptionParser::eNoArgument,   nullptr, {}, 0, eArgTypeNone,  
"Allow world to execute."},
-// clang-format on
+#define LLDB_OPTIONS_permissions
+#include "CommandObject.inc"
 };
 
 class OptionPermissions : public OptionGroup {
@@ -586,10 +575,8 @@ public:
 // "platform fread"
 
 static constexpr OptionDefinition g_platform_fread_options[] = {
-// clang-format off
-  { LLDB_OPT_SET_1, false, "offset", 'o', OptionParser::eRequiredArgument, 
nullptr, {}, 0, eArgTypeIndex, "Offset into the file at which to start 
reading." },
-  { LLDB_OPT_SET_1, false, "count",  'c', OptionParser::eRequiredArgument, 
nullptr, {}, 0, eArgTypeCount, "Number of bytes to read from the file." },
-// clang-format on
+#define LLDB_OPTIONS_platform_fread
+#include "CommandOptions.inc"
 };
 
 class CommandObjectPlatformFRead : public CommandObjectParsed {
@@ -679,10 +666,8 @@ protected:
 // "platform fwrite"
 
 static constexpr OptionDefinition g_platform_fwrite_options[] = {
-// clang-format off
-  { LLDB_OPT_SET_1, false, "offset", 'o', OptionParser::eRequiredArgument, 
nullptr, {}, 0, eArgTypeIndex, "Offset into the file at which to start 
reading." },
-  { LLDB_OPT_SET_1, false, "data",   'd', OptionParser::eRequiredArgument, 
nullptr, {}, 0, eArgTypeValue, "Text to write to the file." },
-// clang-format on
+#define LLDB_OPTIONS_platform_fwrite
+#include "CommandOptions.inc"
 };
 
 class CommandObjectPlatformFWrite : public CommandObjectParsed {
@@ -1057,22 +1042,8 @@ protected:
 // "platform process list"
 
 static OptionDefinition g_platform_process_list_options[] = {
-// clang-format off
-  { LLDB_OPT_SET_1, false, "pid", 'p', 
OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypePid,   
"List the process info for a specific process ID." },
-  { LLDB_OPT_SET_2, true,  "name",'n', 
OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypeProcessName,   
"Find processes with executable basenames that match a string." },
-  { LLDB_OPT_SET_3, true,  "ends-with",   'e', 
OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypeProcessName,   
"Find processes with executable basenames that end with a string." },
-  { LLDB_OPT_SET_4, true,  "starts-with", 's', 
OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypeProcessName,   
"Find processes with ex

[Lldb-commits] [lldb] r366892 - [lldb] Fix build errors from tablegenify platform commit

2019-07-24 Thread Raphael Isemann via lldb-commits
Author: teemperor
Date: Wed Jul 24 05:08:08 2019
New Revision: 366892

URL: http://llvm.org/viewvc/llvm-project?rev=366892&view=rev
Log:
[lldb] Fix build errors from tablegenify platform commit

Forgot to stage some changes...

Modified:
lldb/trunk/source/Commands/CommandObjectPlatform.cpp
lldb/trunk/source/Commands/Options.td

Modified: lldb/trunk/source/Commands/CommandObjectPlatform.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectPlatform.cpp?rev=366892&r1=366891&r2=366892&view=diff
==
--- lldb/trunk/source/Commands/CommandObjectPlatform.cpp (original)
+++ lldb/trunk/source/Commands/CommandObjectPlatform.cpp Wed Jul 24 05:08:08 
2019
@@ -60,7 +60,7 @@ static mode_t ParsePermissionString(llvm
 
 static constexpr OptionDefinition g_permissions_options[] = {
 #define LLDB_OPTIONS_permissions
-#include "CommandObject.inc"
+#include "CommandOptions.inc"
 };
 
 class OptionPermissions : public OptionGroup {

Modified: lldb/trunk/source/Commands/Options.td
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/Options.td?rev=366892&r1=366891&r2=366892&view=diff
==
--- lldb/trunk/source/Commands/Options.td (original)
+++ lldb/trunk/source/Commands/Options.td Wed Jul 24 05:08:08 2019
@@ -430,27 +430,27 @@ let Command = "platform process list" in
 Arg<"RegularExpression">, Required,
 Desc<"Find processes with executable basenames that match a regular "
 "expression.">;
-  def platform_process_list_parent : Option<"parent", "P">, OptionRange<2, 6>,
+  def platform_process_list_parent : Option<"parent", "P">, GroupRange<2, 6>,
 Arg<"Pid">, Desc<"Find processes that have a matching parent process ID.">;
-  def platform_process_list_uid : Option<"uid", "u">, OptionRange<2, 6>,
+  def platform_process_list_uid : Option<"uid", "u">, GroupRange<2, 6>,
 Arg<"UnsignedInteger">,
 Desc<"Find processes that have a matching user ID.">;
-  def platform_process_list_euid : Option<"euid", "U">, OptionRange<2, 6>,
+  def platform_process_list_euid : Option<"euid", "U">, GroupRange<2, 6>,
 Arg<"UnsignedInteger">,
 Desc<"Find processes that have a matching effective user ID.">;
-  def platform_process_list_gid : Option<"gid", "g">, OptionRange<2, 6>,
+  def platform_process_list_gid : Option<"gid", "g">, GroupRange<2, 6>,
 Arg<"UnsignedInteger">,
 Desc<"Find processes that have a matching group ID.">;
-  def platform_process_list_egid : Option<"egid", "G">, OptionRange<2, 6>,
+  def platform_process_list_egid : Option<"egid", "G">, GroupRange<2, 6>,
 Arg<"UnsignedInteger">,
 Desc<"Find processes that have a matching effective group ID.">;
-  def platform_process_list_arch : Option<"arch", "a">, OptionRange<2, 6>,
+  def platform_process_list_arch : Option<"arch", "a">, GroupRange<2, 6>,
 Arg<"Architecture">,
 Desc<"Find processes that have a matching architecture.">;
   def platform_process_list_show_args : Option<"show-args", "A">,
-OptionRange<1, 6>,
+GroupRange<1, 6>,
 Desc<"Show process arguments instead of the process executable basename.">;
-  def platform_process_list_verbose : Option<"verbose", "v">, OptionRange<1, 
6>,
+  def platform_process_list_verbose : Option<"verbose", "v">, GroupRange<1, 6>,
 Desc<"Enable verbose output.">;
 }
 


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


[Lldb-commits] [lldb] r367009 - [lldb] Tablegenify expr/frame/log/register/memory

2019-07-25 Thread Raphael Isemann via lldb-commits
Author: teemperor
Date: Thu Jul 25 04:22:46 2019
New Revision: 367009

URL: http://llvm.org/viewvc/llvm-project?rev=367009&view=rev
Log:
[lldb] Tablegenify expr/frame/log/register/memory

Modified:
lldb/trunk/source/Commands/CommandObjectExpression.cpp
lldb/trunk/source/Commands/CommandObjectFrame.cpp
lldb/trunk/source/Commands/CommandObjectLog.cpp
lldb/trunk/source/Commands/CommandObjectMemory.cpp
lldb/trunk/source/Commands/CommandObjectRegister.cpp
lldb/trunk/source/Commands/Options.td

Modified: lldb/trunk/source/Commands/CommandObjectExpression.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectExpression.cpp?rev=367009&r1=367008&r2=367009&view=diff
==
--- lldb/trunk/source/Commands/CommandObjectExpression.cpp (original)
+++ lldb/trunk/source/Commands/CommandObjectExpression.cpp Thu Jul 25 04:22:46 
2019
@@ -48,23 +48,8 @@ static constexpr OptionEnumValues Descri
 }
 
 static constexpr OptionDefinition g_expression_options[] = {
-// clang-format off
-  {LLDB_OPT_SET_1 | LLDB_OPT_SET_2, false, "all-threads",   'a', 
OptionParser::eRequiredArgument, nullptr, {},  0, 
eArgTypeBoolean,  "Should we run all threads if the execution 
doesn't complete on one thread."},
-  {LLDB_OPT_SET_1 | LLDB_OPT_SET_2, false, "ignore-breakpoints",'i', 
OptionParser::eRequiredArgument, nullptr, {},  0, 
eArgTypeBoolean,  "Ignore breakpoint hits while running 
expressions"},
-  {LLDB_OPT_SET_1 | LLDB_OPT_SET_2, false, "timeout",   't', 
OptionParser::eRequiredArgument, nullptr, {},  0, 
eArgTypeUnsignedInteger,  "Timeout value (in microseconds) for running the 
expression."},
-  {LLDB_OPT_SET_1 | LLDB_OPT_SET_2, false, "unwind-on-error",   'u', 
OptionParser::eRequiredArgument, nullptr, {},  0, 
eArgTypeBoolean,  "Clean up program state if the expression causes 
a crash, or raises a signal.  "
-   

   "Note, unlike gdb hitting a breakpoint is controlled by 
another option (-i)."},
-  {LLDB_OPT_SET_1 | LLDB_OPT_SET_2, false, "debug", 'g', 
OptionParser::eNoArgument,   nullptr, {},  0, 
eArgTypeNone, "When specified, debug the JIT code by setting a 
breakpoint on the first instruction "
-   

   "and forcing breakpoints to not be ignored (-i0) and no 
unwinding to happen on error (-u0)."},
-  {LLDB_OPT_SET_1 | LLDB_OPT_SET_2, false, "language",  'l', 
OptionParser::eRequiredArgument, nullptr, {},  0, 
eArgTypeLanguage, "Specifies the Language to use when parsing the 
expression.  If not set the target.language "
-   

   "setting is used." },
-  {LLDB_OPT_SET_1 | LLDB_OPT_SET_2, false, "apply-fixits",  'X', 
OptionParser::eRequiredArgument, nullptr, {},  0, 
eArgTypeLanguage, "If true, simple fix-it hints will be 
automatically applied to the expression." },
-  {LLDB_OPT_SET_1,  false, "description-verbosity", 'v', 
OptionParser::eOptionalArgument, nullptr, DescriptionVerbosityTypes(), 0, 
eArgTypeDescriptionVerbosity, "How verbose should the output of this expression 
be, if the object description is asked for."},
-  {LLDB_OPT_SET_1 | LLDB_OPT_SET_2, false, "top-level", 'p', 
OptionParser::eNoArgument,   nullptr, {},  0, 
eArgTypeNone, "Interpret the expression as a complete 
translation unit, without injecting it into the local "
-   

   "context.  Allows declaration of persistent, top-level 
entities without a $ prefix."},
-  {LLDB_OPT_SET_1 | LLDB_OPT_SET_2, false, "allow-jit", 'j', 
OptionParser::eRequiredArgument, nullptr, {},  0, 
eArgTypeBoolean,  "Controls whether the expression can fall back to 
being JITted if it's not supported by "
-   

   "the interpreter (defaults to true)."}
-// clang-format on
+#d

[Lldb-commits] [lldb] r367102 - [lldb] Don't dynamically allocate the posix option validator.

2019-07-26 Thread Raphael Isemann via lldb-commits
Author: teemperor
Date: Fri Jul 26 04:46:21 2019
New Revision: 367102

URL: http://llvm.org/viewvc/llvm-project?rev=367102&view=rev
Log:
[lldb] Don't dynamically allocate the posix option validator.

We dynamically allocate the option validator which means we
can't mark this list of OptionDefinitions as constexpr. It's also
more complicated than necessary.

Modified:
lldb/trunk/source/Commands/CommandObjectPlatform.cpp
lldb/trunk/source/Commands/Options.td
lldb/trunk/source/Commands/OptionsBase.td
lldb/trunk/utils/TableGen/LLDBOptionDefEmitter.cpp

Modified: lldb/trunk/source/Commands/CommandObjectPlatform.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectPlatform.cpp?rev=367102&r1=367101&r2=367102&view=diff
==
--- lldb/trunk/source/Commands/CommandObjectPlatform.cpp (original)
+++ lldb/trunk/source/Commands/CommandObjectPlatform.cpp Fri Jul 26 04:46:21 
2019
@@ -1041,7 +1041,8 @@ protected:
 
 // "platform process list"
 
-static OptionDefinition g_platform_process_list_options[] = {
+static PosixPlatformCommandOptionValidator posix_validator;
+static constexpr OptionDefinition g_platform_process_list_options[] = {
 #define LLDB_OPTIONS_platform_process_list
 #include "CommandOptions.inc"
 };
@@ -1166,23 +1167,6 @@ protected:
   public:
 CommandOptions()
 : Options(), match_info(), show_args(false), verbose(false) {
-  static llvm::once_flag g_once_flag;
-  llvm::call_once(g_once_flag, []() {
-PosixPlatformCommandOptionValidator *posix_validator =
-new PosixPlatformCommandOptionValidator();
-for (auto &Option : g_platform_process_list_options) {
-  switch (Option.short_option) {
-  case 'u':
-  case 'U':
-  case 'g':
-  case 'G':
-Option.validator = posix_validator;
-break;
-  default:
-break;
-  }
-}
-  });
 }
 
 ~CommandOptions() override = default;

Modified: lldb/trunk/source/Commands/Options.td
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/Options.td?rev=367102&r1=367101&r2=367102&view=diff
==
--- lldb/trunk/source/Commands/Options.td (original)
+++ lldb/trunk/source/Commands/Options.td Fri Jul 26 04:46:21 2019
@@ -576,16 +576,16 @@ let Command = "platform process list" in
   def platform_process_list_parent : Option<"parent", "P">, GroupRange<2, 6>,
 Arg<"Pid">, Desc<"Find processes that have a matching parent process ID.">;
   def platform_process_list_uid : Option<"uid", "u">, GroupRange<2, 6>,
-Arg<"UnsignedInteger">,
+Arg<"UnsignedInteger">, Validator<"&posix_validator">,
 Desc<"Find processes that have a matching user ID.">;
   def platform_process_list_euid : Option<"euid", "U">, GroupRange<2, 6>,
-Arg<"UnsignedInteger">,
+Arg<"UnsignedInteger">, Validator<"&posix_validator">,
 Desc<"Find processes that have a matching effective user ID.">;
   def platform_process_list_gid : Option<"gid", "g">, GroupRange<2, 6>,
-Arg<"UnsignedInteger">,
+Arg<"UnsignedInteger">, Validator<"&posix_validator">,
 Desc<"Find processes that have a matching group ID.">;
   def platform_process_list_egid : Option<"egid", "G">, GroupRange<2, 6>,
-Arg<"UnsignedInteger">,
+Arg<"UnsignedInteger">, Validator<"&posix_validator">,
 Desc<"Find processes that have a matching effective group ID.">;
   def platform_process_list_arch : Option<"arch", "a">, GroupRange<2, 6>,
 Arg<"Architecture">,

Modified: lldb/trunk/source/Commands/OptionsBase.td
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/OptionsBase.td?rev=367102&r1=367101&r2=367102&view=diff
==
--- lldb/trunk/source/Commands/OptionsBase.td (original)
+++ lldb/trunk/source/Commands/OptionsBase.td Fri Jul 26 04:46:21 2019
@@ -46,7 +46,9 @@
 

 // Field: validator
 // Default value: 0 (No validator for option)
-// Set by: Nothing. This is currently only set after initialization in LLDB.
+// Set by:
+//  - `Validator`: Sets the value to a given validator (which has to exist in
+// the surrounding code.
 

 // Field: enum_values
 // Default value: {} (No enum associated with this option)
@@ -169,3 +171,8 @@ class Completions completio
 class Completion {
   list Completions = [completion];
 }
+
+// Sets the validator for a given option.
+class Validator {
+  string Validator = validator;
+}

Modified: lldb/trunk/utils/TableGen/LLDBOptionDefEmitter.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/utils/TableGen/LLDBOptionDefEmitter.cpp?rev=367102&r1=367101&r2=367102&v

[Lldb-commits] [lldb] r367110 - [lldb][NFC] Remove eDiagnosticOriginGo

2019-07-26 Thread Raphael Isemann via lldb-commits
Author: teemperor
Date: Fri Jul 26 07:00:13 2019
New Revision: 367110

URL: http://llvm.org/viewvc/llvm-project?rev=367110&view=rev
Log:
[lldb][NFC] Remove eDiagnosticOriginGo

This enum value is unused as we removed Go support.

Modified:
lldb/trunk/include/lldb/Expression/DiagnosticManager.h

Modified: lldb/trunk/include/lldb/Expression/DiagnosticManager.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Expression/DiagnosticManager.h?rev=367110&r1=367109&r2=367110&view=diff
==
--- lldb/trunk/include/lldb/Expression/DiagnosticManager.h (original)
+++ lldb/trunk/include/lldb/Expression/DiagnosticManager.h Fri Jul 26 07:00:13 
2019
@@ -23,7 +23,6 @@ enum DiagnosticOrigin {
   eDiagnosticOriginUnknown = 0,
   eDiagnosticOriginLLDB,
   eDiagnosticOriginClang,
-  eDiagnosticOriginGo,
   eDiagnosticOriginSwift,
   eDiagnosticOriginLLVM
 };
@@ -47,7 +46,6 @@ public:
 switch (kind) {
 case eDiagnosticOriginUnknown:
 case eDiagnosticOriginLLDB:
-case eDiagnosticOriginGo:
 case eDiagnosticOriginLLVM:
   return true;
 case eDiagnosticOriginClang:


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


[Lldb-commits] [lldb] r367186 - [lldb] Also include the array definition in CommandOptions.inc

2019-07-27 Thread Raphael Isemann via lldb-commits
Author: teemperor
Date: Sat Jul 27 23:24:07 2019
New Revision: 367186

URL: http://llvm.org/viewvc/llvm-project?rev=367186&view=rev
Log:
[lldb] Also include the array definition in CommandOptions.inc

Summary:
Right now our CommandOptions.inc only generates the initializer for the options 
list but
not the array declaration boilerplate around it. As the array definition is 
identical for all arrays,
we might as well also let the CommandOptions.inc generate it alongside the 
initializers.

This patch will also allow us to generate additional declarations related to 
that option list in
the future (e.g. a enum class representing the specific options which would 
make our
handling code less prone).

This patch also fixes a few option tables that didn't follow our naming style.

Reviewers: JDevlieghere

Reviewed By: JDevlieghere

Subscribers: abidh, lldb-commits

Tags: #lldb

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

Modified:
lldb/trunk/source/Commands/CommandObjectBreakpoint.cpp
lldb/trunk/source/Commands/CommandObjectBreakpointCommand.cpp
lldb/trunk/source/Commands/CommandObjectCommands.cpp
lldb/trunk/source/Commands/CommandObjectDisassemble.cpp
lldb/trunk/source/Commands/CommandObjectExpression.cpp
lldb/trunk/source/Commands/CommandObjectFrame.cpp
lldb/trunk/source/Commands/CommandObjectHelp.cpp
lldb/trunk/source/Commands/CommandObjectLog.cpp
lldb/trunk/source/Commands/CommandObjectMemory.cpp
lldb/trunk/source/Commands/CommandObjectPlatform.cpp
lldb/trunk/source/Commands/CommandObjectProcess.cpp
lldb/trunk/source/Commands/CommandObjectRegister.cpp
lldb/trunk/source/Commands/CommandObjectSettings.cpp
lldb/trunk/source/Commands/CommandObjectSource.cpp
lldb/trunk/source/Commands/CommandObjectTarget.cpp
lldb/trunk/source/Commands/CommandObjectThread.cpp
lldb/trunk/source/Commands/CommandObjectType.cpp
lldb/trunk/source/Commands/CommandObjectWatchpoint.cpp
lldb/trunk/source/Commands/CommandObjectWatchpointCommand.cpp
lldb/trunk/utils/TableGen/LLDBOptionDefEmitter.cpp

Modified: lldb/trunk/source/Commands/CommandObjectBreakpoint.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectBreakpoint.cpp?rev=367186&r1=367185&r2=367186&view=diff
==
--- lldb/trunk/source/Commands/CommandObjectBreakpoint.cpp (original)
+++ lldb/trunk/source/Commands/CommandObjectBreakpoint.cpp Sat Jul 27 23:24:07 
2019
@@ -44,10 +44,9 @@ static void AddBreakpointDescription(Str
 
 // Modifiable Breakpoint Options
 #pragma mark Modify::CommandOptions
-static constexpr OptionDefinition g_breakpoint_modify_options[] = {
 #define LLDB_OPTIONS_breakpoint_modify
 #include "CommandOptions.inc"
-};
+
 class lldb_private::BreakpointOptionGroup : public OptionGroup
 {
 public:
@@ -181,10 +180,9 @@ public:
   BreakpointOptions m_bp_opts;
 
 };
-static constexpr OptionDefinition g_breakpoint_dummy_options[] = {
+
 #define LLDB_OPTIONS_breakpoint_dummy
 #include "CommandOptions.inc"
-};
 
 class BreakpointDummyOptionGroup : public OptionGroup
 {
@@ -224,10 +222,8 @@ public:
 
 };
 
-static constexpr OptionDefinition g_breakpoint_set_options[] = {
 #define LLDB_OPTIONS_breakpoint_set
 #include "CommandOptions.inc"
-};
 
 // CommandObjectBreakpointSet
 
@@ -1154,10 +1150,8 @@ protected:
 // CommandObjectBreakpointList
 
 #pragma mark List::CommandOptions
-static constexpr OptionDefinition g_breakpoint_list_options[] = {
 #define LLDB_OPTIONS_breakpoint_list
 #include "CommandOptions.inc"
-};
 
 #pragma mark List
 
@@ -1311,10 +1305,8 @@ private:
 // CommandObjectBreakpointClear
 #pragma mark Clear::CommandOptions
 
-static constexpr OptionDefinition g_breakpoint_clear_options[] = {
 #define LLDB_OPTIONS_breakpoint_clear
 #include "CommandOptions.inc"
-};
 
 #pragma mark Clear
 
@@ -1462,10 +1454,8 @@ private:
 };
 
 // CommandObjectBreakpointDelete
-static constexpr OptionDefinition g_breakpoint_delete_options[] = {
 #define LLDB_OPTIONS_breakpoint_delete
 #include "CommandOptions.inc"
-};
 
 #pragma mark Delete
 
@@ -1614,11 +1604,9 @@ private:
 };
 
 // CommandObjectBreakpointName
-
-static constexpr OptionDefinition g_breakpoint_name_options[] = {
 #define LLDB_OPTIONS_breakpoint_name
 #include "CommandOptions.inc"
-};
+
 class BreakpointNameOptionGroup : public OptionGroup {
 public:
   BreakpointNameOptionGroup()
@@ -1680,10 +1668,8 @@ public:
   OptionValueString m_help_string;
 };
 
-static constexpr OptionDefinition g_breakpoint_access_options[] = {
 #define LLDB_OPTIONS_breakpoint_access
 #include "CommandOptions.inc"
-};
 
 class BreakpointAccessOptionGroup : public OptionGroup {
 public:
@@ -2142,10 +2128,8 @@ public:
 
 // CommandObjectBreakpointRead
 #pragma mark Read::CommandOptions
-static constexpr OptionDefinition g_breakpoint_read_options[] = {
 #define LLDB_OPTIONS_breakpoint_read
 #include "CommandOptions.inc"
-};
 
 #pragma mark Read
 

[Lldb-commits] [lldb] r367201 - [lldb][NFC] Remove DiagnosticManager::CopyDiagnostics

2019-07-29 Thread Raphael Isemann via lldb-commits
Author: teemperor
Date: Mon Jul 29 00:37:17 2019
New Revision: 367201

URL: http://llvm.org/viewvc/llvm-project?rev=367201&view=rev
Log:
[lldb][NFC] Remove DiagnosticManager::CopyDiagnostics

The Diagnostic class in LLDB is suppossed to be inherited from,
so just copying the diagnostics like this is wrong. The function
is also unused, so lets just get rid of it instead of creating
some cloning facility for it.

Modified:
lldb/trunk/include/lldb/Expression/DiagnosticManager.h
lldb/trunk/source/Expression/DiagnosticManager.cpp

Modified: lldb/trunk/include/lldb/Expression/DiagnosticManager.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Expression/DiagnosticManager.h?rev=367201&r1=367200&r2=367201&view=diff
==
--- lldb/trunk/include/lldb/Expression/DiagnosticManager.h (original)
+++ lldb/trunk/include/lldb/Expression/DiagnosticManager.h Mon Jul 29 00:37:17 
2019
@@ -125,8 +125,6 @@ public:
 m_diagnostics.push_back(diagnostic);
   }
 
-  void CopyDiagnostics(DiagnosticManager &otherDiagnostics);
-
   size_t Printf(DiagnosticSeverity severity, const char *format, ...)
   __attribute__((format(printf, 3, 4)));
   size_t PutString(DiagnosticSeverity severity, llvm::StringRef str);

Modified: lldb/trunk/source/Expression/DiagnosticManager.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/DiagnosticManager.cpp?rev=367201&r1=367200&r2=367201&view=diff
==
--- lldb/trunk/source/Expression/DiagnosticManager.cpp (original)
+++ lldb/trunk/source/Expression/DiagnosticManager.cpp Mon Jul 29 00:37:17 2019
@@ -77,12 +77,3 @@ size_t DiagnosticManager::PutString(Diag
   AddDiagnostic(str, severity, eDiagnosticOriginLLDB);
   return str.size();
 }
-
-void DiagnosticManager::CopyDiagnostics(DiagnosticManager &otherDiagnostics) {
-  for (const DiagnosticList::value_type &other_diagnostic:
-   otherDiagnostics.Diagnostics()) {
-AddDiagnostic(
-other_diagnostic->GetMessage(), other_diagnostic->GetSeverity(),
-other_diagnostic->getKind(), other_diagnostic->GetCompilerID());
-  }
-}


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


[Lldb-commits] [lldb] r367207 - [lldb][NFC] Split emitting and parsing in LLDBOptionDefEmitter

2019-07-29 Thread Raphael Isemann via lldb-commits
Author: teemperor
Date: Mon Jul 29 01:22:41 2019
New Revision: 367207

URL: http://llvm.org/viewvc/llvm-project?rev=367207&view=rev
Log:
[lldb][NFC] Split emitting and parsing in LLDBOptionDefEmitter

Splitting the different logic is cleaner and we it will be easier
to implement the enum emitting (which otherwise would have to
reimplement the Record parsing).

Modified:
lldb/trunk/utils/TableGen/LLDBOptionDefEmitter.cpp

Modified: lldb/trunk/utils/TableGen/LLDBOptionDefEmitter.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/utils/TableGen/LLDBOptionDefEmitter.cpp?rev=367207&r1=367206&r2=367207&view=diff
==
--- lldb/trunk/utils/TableGen/LLDBOptionDefEmitter.cpp (original)
+++ lldb/trunk/utils/TableGen/LLDBOptionDefEmitter.cpp Mon Jul 29 01:22:41 2019
@@ -33,49 +33,85 @@ static RecordsByCommand getCommandList(s
   return result;
 }
 
-static void emitOption(Record *Option, raw_ostream &OS) {
-  OS << "  {";
-
-  // List of option groups this option is in.
+namespace {
+struct CommandOption {
   std::vector GroupsArg;
+  bool Required = false;
+  std::string FullName;
+  std::string ShortName;
+  std::string ArgType;
+  bool OptionalArg = false;
+  std::string Validator;
+  std::string ArgEnum;
+  std::vector Completions;
+  std::string Description;
+
+  CommandOption() = default;
+  CommandOption(Record *Option) {
+if (Option->getValue("Groups")) {
+  // The user specified a list of groups.
+  auto Groups = Option->getValueAsListOfInts("Groups");
+  for (int Group : Groups)
+GroupsArg.push_back("LLDB_OPT_SET_" + std::to_string(Group));
+} else if (Option->getValue("GroupStart")) {
+  // The user specified a range of groups (with potentially only one
+  // element).
+  int GroupStart = Option->getValueAsInt("GroupStart");
+  int GroupEnd = Option->getValueAsInt("GroupEnd");
+  for (int i = GroupStart; i <= GroupEnd; ++i)
+GroupsArg.push_back("LLDB_OPT_SET_" + std::to_string(i));
+}
+
+// Check if this option is required.
+Required = Option->getValue("Required");
+
+// Add the full and short name for this option.
+FullName = Option->getValueAsString("FullName");
+ShortName = Option->getValueAsString("ShortName");
+
+if (auto A = Option->getValue("ArgType"))
+  ArgType = A->getValue()->getAsUnquotedString();
+OptionalArg = Option->getValue("OptionalArg") != nullptr;
+
+if (Option->getValue("Validator"))
+  Validator = Option->getValueAsString("Validator");
+
+if (Option->getValue("ArgEnum"))
+  ArgEnum = Option->getValueAsString("ArgEnum");
 
-  if (Option->getValue("Groups")) {
-// The user specified a list of groups.
-auto Groups = Option->getValueAsListOfInts("Groups");
-for (int Group : Groups)
-  GroupsArg.push_back("LLDB_OPT_SET_" + std::to_string(Group));
-  } else if (Option->getValue("GroupStart")) {
-// The user specified a range of groups (with potentially only one 
element).
-int GroupStart = Option->getValueAsInt("GroupStart");
-int GroupEnd = Option->getValueAsInt("GroupEnd");
-for (int i = GroupStart; i <= GroupEnd; ++i)
-  GroupsArg.push_back("LLDB_OPT_SET_" + std::to_string(i));
+if (Option->getValue("Completions"))
+  Completions = Option->getValueAsListOfStrings("Completions");
+
+if (auto D = Option->getValue("Description"))
+  Description = D->getValue()->getAsUnquotedString();
   }
+};
+} // namespace
+
+static void emitOption(const CommandOption &O, raw_ostream &OS) {
+  OS << "  {";
 
   // If we have any groups, we merge them. Otherwise we move this option into
   // the all group.
-  if (GroupsArg.empty())
+  if (O.GroupsArg.empty())
 OS << "LLDB_OPT_SET_ALL";
   else
-OS << llvm::join(GroupsArg.begin(), GroupsArg.end(), " | ");
+OS << llvm::join(O.GroupsArg.begin(), O.GroupsArg.end(), " | ");
 
   OS << ", ";
 
   // Check if this option is required.
-  OS << (Option->getValue("Required") ? "true" : "false");
+  OS << (O.Required ? "true" : "false");
 
   // Add the full and short name for this option.
-  OS << ", \"" << Option->getValueAsString("FullName") << "\", ";
-  OS << '\'' << Option->getValueAsString("ShortName") << "'";
-
-  auto ArgType = Option->getValue("ArgType");
-  bool IsOptionalArg = Option->getValue("OptionalArg") != nullptr;
+  OS << ", \"" << O.FullName << "\", ";
+  OS << '\'' << O.ShortName << "'";
 
   // Decide if we have either an option, required or no argument for this
   // option.
   OS << ", OptionParser::";
-  if (ArgType) {
-if (IsOptionalArg)
+  if (!O.ArgType.empty()) {
+if (O.OptionalArg)
   OS << "eOptionalArgument";
 else
   OS << "eRequiredArgument";
@@ -83,43 +119,41 @@ static void emitOption(Record *Option, r
 OS << "eNoArgument";
   OS << ", ";
 
-  if (Option->getValue("Validator"))
-OS << Option->getValueAsString("Validator");
+  if (!O.Validator.empty())
+ 

[Lldb-commits] [lldb] r367307 - [lldb][NFC] Check in crashing test case

2019-07-30 Thread Raphael Isemann via lldb-commits
Author: teemperor
Date: Tue Jul 30 05:20:03 2019
New Revision: 367307

URL: http://llvm.org/viewvc/llvm-project?rev=367307&view=rev
Log:
[lldb][NFC] Check in crashing test case

Added:

lldb/trunk/packages/Python/lldbsuite/test/expression_command/completion-crash1/

lldb/trunk/packages/Python/lldbsuite/test/expression_command/completion-crash1/Makefile

lldb/trunk/packages/Python/lldbsuite/test/expression_command/completion-crash1/TestCompletionCrash1.py

lldb/trunk/packages/Python/lldbsuite/test/expression_command/completion-crash1/main.cpp

Added: 
lldb/trunk/packages/Python/lldbsuite/test/expression_command/completion-crash1/Makefile
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/expression_command/completion-crash1/Makefile?rev=367307&view=auto
==
--- 
lldb/trunk/packages/Python/lldbsuite/test/expression_command/completion-crash1/Makefile
 (added)
+++ 
lldb/trunk/packages/Python/lldbsuite/test/expression_command/completion-crash1/Makefile
 Tue Jul 30 05:20:03 2019
@@ -0,0 +1,3 @@
+LEVEL = ../../make
+CXX_SOURCES := main.cpp
+include $(LEVEL)/Makefile.rules

Added: 
lldb/trunk/packages/Python/lldbsuite/test/expression_command/completion-crash1/TestCompletionCrash1.py
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/expression_command/completion-crash1/TestCompletionCrash1.py?rev=367307&view=auto
==
--- 
lldb/trunk/packages/Python/lldbsuite/test/expression_command/completion-crash1/TestCompletionCrash1.py
 (added)
+++ 
lldb/trunk/packages/Python/lldbsuite/test/expression_command/completion-crash1/TestCompletionCrash1.py
 Tue Jul 30 05:20:03 2019
@@ -0,0 +1,4 @@
+from lldbsuite.test import lldbinline
+from lldbsuite.test import decorators
+
+lldbinline.MakeInlineTest(__file__, globals(), 
[decorators.skipIf(bugnumber="rdar://53659341")])

Added: 
lldb/trunk/packages/Python/lldbsuite/test/expression_command/completion-crash1/main.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/expression_command/completion-crash1/main.cpp?rev=367307&view=auto
==
--- 
lldb/trunk/packages/Python/lldbsuite/test/expression_command/completion-crash1/main.cpp
 (added)
+++ 
lldb/trunk/packages/Python/lldbsuite/test/expression_command/completion-crash1/main.cpp
 Tue Jul 30 05:20:03 2019
@@ -0,0 +1,12 @@
+namespace std {
+struct a {
+  a() {}
+  a(a &&);
+};
+template  struct au {
+  a ay;
+  ~au() { //%self.dbg.GetCommandInterpreter().HandleCompletion("e ", len("e 
"), 0, -1, lldb.SBStringList())
+  }
+};
+}
+int main() { std::au{}; }


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


[Lldb-commits] [lldb] r367308 - [lldb] Fix crash when tab-completing in multi-line expr

2019-07-30 Thread Raphael Isemann via lldb-commits
Author: teemperor
Date: Tue Jul 30 05:31:24 2019
New Revision: 367308

URL: http://llvm.org/viewvc/llvm-project?rev=367308&view=rev
Log:
[lldb] Fix crash when tab-completing in multi-line expr

Summary:
Tab completing inside the multiline expression command can cause LLDB to crash. 
The easiest way
to do this is to go inside a frame with at least one local variable and then 
try to complete:

(lldb) expr
1. a[tab]

Reason for this was some mixup when we calculate the cursor position. Obviously 
we should calculate
the offset inside the string by doing 'end - start', but we are doing 'start - 
end' (which causes the offset to
become -1 which will lead to some out-of-bounds reading).

Fixes rdar://51754005

I don't see any way to test this as the *multiline* expression completion is 
completely untested at the moment
and I don't think we have any existing code for testing infrastructure for it.

Reviewers: shafik, davide, labath

Reviewed By: labath

Subscribers: abidh, lldb-commits, davide, clayborg, labath

Tags: #lldb

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

Added:

lldb/trunk/packages/Python/lldbsuite/test/expression_command/multiline-completion/

lldb/trunk/packages/Python/lldbsuite/test/expression_command/multiline-completion/Makefile

lldb/trunk/packages/Python/lldbsuite/test/expression_command/multiline-completion/TestMultilineCompletion.py

lldb/trunk/packages/Python/lldbsuite/test/expression_command/multiline-completion/main.c
Modified:
lldb/trunk/source/Core/IOHandler.cpp

Added: 
lldb/trunk/packages/Python/lldbsuite/test/expression_command/multiline-completion/Makefile
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/expression_command/multiline-completion/Makefile?rev=367308&view=auto
==
--- 
lldb/trunk/packages/Python/lldbsuite/test/expression_command/multiline-completion/Makefile
 (added)
+++ 
lldb/trunk/packages/Python/lldbsuite/test/expression_command/multiline-completion/Makefile
 Tue Jul 30 05:31:24 2019
@@ -0,0 +1,3 @@
+LEVEL = ../../make
+C_SOURCES := main.c
+include $(LEVEL)/Makefile.rules

Added: 
lldb/trunk/packages/Python/lldbsuite/test/expression_command/multiline-completion/TestMultilineCompletion.py
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/expression_command/multiline-completion/TestMultilineCompletion.py?rev=367308&view=auto
==
--- 
lldb/trunk/packages/Python/lldbsuite/test/expression_command/multiline-completion/TestMultilineCompletion.py
 (added)
+++ 
lldb/trunk/packages/Python/lldbsuite/test/expression_command/multiline-completion/TestMultilineCompletion.py
 Tue Jul 30 05:31:24 2019
@@ -0,0 +1,52 @@
+"""
+Test completion for multiline expressions.
+"""
+
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+
+class MultilineCompletionTest(TestBase):
+
+mydir = TestBase.compute_mydir(__file__)
+NO_DEBUG_INFO_TESTCASE = True
+
+def setUp(self):
+TestBase.setUp(self)
+self.source = 'main.c'
+
+def expect_string(self, string):
+import pexpect
+"""This expects for "string", with timeout & EOF being test fails."""
+try:
+self.child.expect_exact(string)
+except pexpect.EOF:
+self.fail("Got EOF waiting for '%s'" % (string))
+except pexpect.TIMEOUT:
+self.fail("Timed out waiting for '%s'" % (string))
+
+@expectedFailureAll(
+oslist=["windows"],
+bugnumber="llvm.org/pr22274: need a pexpect replacement for windows")
+def test_basic_completion(self):
+"""Test that we can complete a simple multiline expression"""
+self.build()
+self.setTearDownCleanup()
+
+import pexpect
+exe = self.getBuildArtifact("a.out")
+prompt = "(lldb) "
+
+run_commands = ' -o "b main" -o "r"'
+self.child = pexpect.spawn(
+'%s %s %s %s' %
+(lldbtest_config.lldbExec, self.lldbOption, run_commands, exe))
+child = self.child
+
+self.expect_string(prompt)
+self.child.sendline("expr")
+self.expect_string("terminate with an empty line to evaluate")
+self.child.send("to_\t")
+self.expect_string("to_complete")
+
+self.deletePexpectChild()

Added: 
lldb/trunk/packages/Python/lldbsuite/test/expression_command/multiline-completion/main.c
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/expression_command/multiline-completion/main.c?rev=367308&view=auto
==
--- 
lldb/trunk/packages/Python/lldbsuite/test/expression_command/multiline-completion/main.c
 (added)
+++ 
lldb/trunk/packages/Python/lldbsuite/test/expression_command/multiline-completi

[Lldb-commits] [lldb] r367309 - [lldb][NFC] Fix import-std-module tests that relied on fix-its to pass

2019-07-30 Thread Raphael Isemann via lldb-commits
Author: teemperor
Date: Tue Jul 30 06:11:59 2019
New Revision: 367309

URL: http://llvm.org/viewvc/llvm-project?rev=367309&view=rev
Log:
[lldb][NFC] Fix import-std-module tests that relied on fix-its to pass

These tests currently pass, but they rely on fix-its in our expression
parser to pass because they have some typos.

Modified:

lldb/trunk/packages/Python/lldbsuite/test/expression_command/import-std-module/deque-dbg-info-content/TestDbgInfoContentDeque.py

lldb/trunk/packages/Python/lldbsuite/test/expression_command/import-std-module/forward_list-dbg-info-content/TestDbgInfoContentForwardList.py

Modified: 
lldb/trunk/packages/Python/lldbsuite/test/expression_command/import-std-module/deque-dbg-info-content/TestDbgInfoContentDeque.py
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/expression_command/import-std-module/deque-dbg-info-content/TestDbgInfoContentDeque.py?rev=367309&r1=367308&r2=367309&view=diff
==
--- 
lldb/trunk/packages/Python/lldbsuite/test/expression_command/import-std-module/deque-dbg-info-content/TestDbgInfoContentDeque.py
 (original)
+++ 
lldb/trunk/packages/Python/lldbsuite/test/expression_command/import-std-module/deque-dbg-info-content/TestDbgInfoContentDeque.py
 Tue Jul 30 06:11:59 2019
@@ -25,12 +25,12 @@ class TestDbgInfoContentDeque(TestBase):
 self.runCmd("settings set target.import-std-module true")
 
 self.expect("expr (size_t)a.size()", substrs=['(size_t) $0 = 3'])
-self.expect("expr (int)a.front()->a", substrs=['(int) $1 = 3'])
-self.expect("expr (int)a.back()->a", substrs=['(int) $2 = 2'])
+self.expect("expr (int)a.front().a", substrs=['(int) $1 = 3'])
+self.expect("expr (int)a.back().a", substrs=['(int) $2 = 2'])
 
 self.expect("expr std::reverse(a.begin(), a.end())")
-self.expect("expr (int)a.front()->a", substrs=['(int) $3 = 2'])
-self.expect("expr (int)a.back()->a", substrs=['(int) $4 = 3'])
+self.expect("expr (int)a.front().a", substrs=['(int) $3 = 2'])
+self.expect("expr (int)a.back().a", substrs=['(int) $4 = 3'])
 
 self.expect("expr (int)(a.begin()->a)", substrs=['(int) $5 = 2'])
 self.expect("expr (int)(a.rbegin()->a)", substrs=['(int) $6 = 3'])

Modified: 
lldb/trunk/packages/Python/lldbsuite/test/expression_command/import-std-module/forward_list-dbg-info-content/TestDbgInfoContentForwardList.py
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/expression_command/import-std-module/forward_list-dbg-info-content/TestDbgInfoContentForwardList.py?rev=367309&r1=367308&r2=367309&view=diff
==
--- 
lldb/trunk/packages/Python/lldbsuite/test/expression_command/import-std-module/forward_list-dbg-info-content/TestDbgInfoContentForwardList.py
 (original)
+++ 
lldb/trunk/packages/Python/lldbsuite/test/expression_command/import-std-module/forward_list-dbg-info-content/TestDbgInfoContentForwardList.py
 Tue Jul 30 06:11:59 2019
@@ -25,7 +25,7 @@ class TestDbgInfoContentForwardList(Test
 self.runCmd("settings set target.import-std-module true")
 
 self.expect("expr (size_t)std::distance(a.begin(), a.end())", 
substrs=['(size_t) $0 = 3'])
-self.expect("expr (int)a.front()->a", substrs=['(int) $1 = 3'])
+self.expect("expr (int)a.front().a", substrs=['(int) $1 = 3'])
 
 self.expect("expr (int)(a.begin()->a)", substrs=['(int) $2 = 3'])
 


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


[Lldb-commits] [lldb] r367411 - [lldb][NFC] Check in completion crash test in lambda

2019-07-31 Thread Raphael Isemann via lldb-commits
Author: teemperor
Date: Wed Jul 31 04:33:16 2019
New Revision: 367411

URL: http://llvm.org/viewvc/llvm-project?rev=367411&view=rev
Log:
[lldb][NFC] Check in completion crash test in lambda

Added:

lldb/trunk/packages/Python/lldbsuite/test/expression_command/completion-crash-lambda/

lldb/trunk/packages/Python/lldbsuite/test/expression_command/completion-crash-lambda/Makefile

lldb/trunk/packages/Python/lldbsuite/test/expression_command/completion-crash-lambda/TestCompletionCrashInLambda.py

lldb/trunk/packages/Python/lldbsuite/test/expression_command/completion-crash-lambda/main.cpp

Added: 
lldb/trunk/packages/Python/lldbsuite/test/expression_command/completion-crash-lambda/Makefile
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/expression_command/completion-crash-lambda/Makefile?rev=367411&view=auto
==
--- 
lldb/trunk/packages/Python/lldbsuite/test/expression_command/completion-crash-lambda/Makefile
 (added)
+++ 
lldb/trunk/packages/Python/lldbsuite/test/expression_command/completion-crash-lambda/Makefile
 Wed Jul 31 04:33:16 2019
@@ -0,0 +1,3 @@
+LEVEL = ../../make
+CXX_SOURCES := main.cpp
+include $(LEVEL)/Makefile.rules

Added: 
lldb/trunk/packages/Python/lldbsuite/test/expression_command/completion-crash-lambda/TestCompletionCrashInLambda.py
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/expression_command/completion-crash-lambda/TestCompletionCrashInLambda.py?rev=367411&view=auto
==
--- 
lldb/trunk/packages/Python/lldbsuite/test/expression_command/completion-crash-lambda/TestCompletionCrashInLambda.py
 (added)
+++ 
lldb/trunk/packages/Python/lldbsuite/test/expression_command/completion-crash-lambda/TestCompletionCrashInLambda.py
 Wed Jul 31 04:33:16 2019
@@ -0,0 +1,4 @@
+from lldbsuite.test import lldbinline
+from lldbsuite.test import decorators
+
+lldbinline.MakeInlineTest(__file__, globals(), 
[decorators.skipIf(bugnumber="rdar://53755023")])

Added: 
lldb/trunk/packages/Python/lldbsuite/test/expression_command/completion-crash-lambda/main.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/expression_command/completion-crash-lambda/main.cpp?rev=367411&view=auto
==
--- 
lldb/trunk/packages/Python/lldbsuite/test/expression_command/completion-crash-lambda/main.cpp
 (added)
+++ 
lldb/trunk/packages/Python/lldbsuite/test/expression_command/completion-crash-lambda/main.cpp
 Wed Jul 31 04:33:16 2019
@@ -0,0 +1,6 @@
+int main() {
+  []()
+  { //%self.dbg.GetCommandInterpreter().HandleCompletion("e ", len("e "), 0, 
-1, lldb.SBStringList())
+  }
+  ();
+}


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


[Lldb-commits] [lldb] r367416 - [lldb][NFC] Check in another crashing test case

2019-07-31 Thread Raphael Isemann via lldb-commits
Author: teemperor
Date: Wed Jul 31 05:06:22 2019
New Revision: 367416

URL: http://llvm.org/viewvc/llvm-project?rev=367416&view=rev
Log:
[lldb][NFC] Check in another crashing test case

Added:

lldb/trunk/packages/Python/lldbsuite/test/expression_command/completion-crash2/

lldb/trunk/packages/Python/lldbsuite/test/expression_command/completion-crash2/Makefile

lldb/trunk/packages/Python/lldbsuite/test/expression_command/completion-crash2/TestCompletionCrash2.py

lldb/trunk/packages/Python/lldbsuite/test/expression_command/completion-crash2/main.cpp

Added: 
lldb/trunk/packages/Python/lldbsuite/test/expression_command/completion-crash2/Makefile
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/expression_command/completion-crash2/Makefile?rev=367416&view=auto
==
--- 
lldb/trunk/packages/Python/lldbsuite/test/expression_command/completion-crash2/Makefile
 (added)
+++ 
lldb/trunk/packages/Python/lldbsuite/test/expression_command/completion-crash2/Makefile
 Wed Jul 31 05:06:22 2019
@@ -0,0 +1,3 @@
+LEVEL = ../../make
+CXX_SOURCES := main.cpp
+include $(LEVEL)/Makefile.rules

Added: 
lldb/trunk/packages/Python/lldbsuite/test/expression_command/completion-crash2/TestCompletionCrash2.py
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/expression_command/completion-crash2/TestCompletionCrash2.py?rev=367416&view=auto
==
--- 
lldb/trunk/packages/Python/lldbsuite/test/expression_command/completion-crash2/TestCompletionCrash2.py
 (added)
+++ 
lldb/trunk/packages/Python/lldbsuite/test/expression_command/completion-crash2/TestCompletionCrash2.py
 Wed Jul 31 05:06:22 2019
@@ -0,0 +1,4 @@
+from lldbsuite.test import lldbinline
+from lldbsuite.test import decorators
+
+lldbinline.MakeInlineTest(__file__, globals(), 
[decorators.skipIf(bugnumber="rdar://53754063")])

Added: 
lldb/trunk/packages/Python/lldbsuite/test/expression_command/completion-crash2/main.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/expression_command/completion-crash2/main.cpp?rev=367416&view=auto
==
--- 
lldb/trunk/packages/Python/lldbsuite/test/expression_command/completion-crash2/main.cpp
 (added)
+++ 
lldb/trunk/packages/Python/lldbsuite/test/expression_command/completion-crash2/main.cpp
 Wed Jul 31 05:06:22 2019
@@ -0,0 +1,11 @@
+namespace n {
+template  class a {};
+template  struct shared_ptr {
+  template 
+  static void make_shared() { 
//%self.dbg.GetCommandInterpreter().HandleCompletion("e ", len("e "), 0, -1, 
lldb.SBStringList())
+typedef a c;
+c d;
+  }
+};
+} // namespace n
+int main() { n::shared_ptr::make_shared(); }


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


[Lldb-commits] [lldb] r367420 - [lldb][NFC] Check in completion crash test case

2019-07-31 Thread Raphael Isemann via lldb-commits
Author: teemperor
Date: Wed Jul 31 05:15:21 2019
New Revision: 367420

URL: http://llvm.org/viewvc/llvm-project?rev=367420&view=rev
Log:
[lldb][NFC] Check in completion crash test case

Added:

lldb/trunk/packages/Python/lldbsuite/test/expression_command/completion-crash-incomplete-record/

lldb/trunk/packages/Python/lldbsuite/test/expression_command/completion-crash-incomplete-record/Makefile

lldb/trunk/packages/Python/lldbsuite/test/expression_command/completion-crash-incomplete-record/TestCompletionCrashIncompleteRecord.py

lldb/trunk/packages/Python/lldbsuite/test/expression_command/completion-crash-incomplete-record/main.cpp

Added: 
lldb/trunk/packages/Python/lldbsuite/test/expression_command/completion-crash-incomplete-record/Makefile
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/expression_command/completion-crash-incomplete-record/Makefile?rev=367420&view=auto
==
--- 
lldb/trunk/packages/Python/lldbsuite/test/expression_command/completion-crash-incomplete-record/Makefile
 (added)
+++ 
lldb/trunk/packages/Python/lldbsuite/test/expression_command/completion-crash-incomplete-record/Makefile
 Wed Jul 31 05:15:21 2019
@@ -0,0 +1,3 @@
+LEVEL = ../../make
+CXX_SOURCES := main.cpp
+include $(LEVEL)/Makefile.rules

Added: 
lldb/trunk/packages/Python/lldbsuite/test/expression_command/completion-crash-incomplete-record/TestCompletionCrashIncompleteRecord.py
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/expression_command/completion-crash-incomplete-record/TestCompletionCrashIncompleteRecord.py?rev=367420&view=auto
==
--- 
lldb/trunk/packages/Python/lldbsuite/test/expression_command/completion-crash-incomplete-record/TestCompletionCrashIncompleteRecord.py
 (added)
+++ 
lldb/trunk/packages/Python/lldbsuite/test/expression_command/completion-crash-incomplete-record/TestCompletionCrashIncompleteRecord.py
 Wed Jul 31 05:15:21 2019
@@ -0,0 +1,4 @@
+from lldbsuite.test import lldbinline
+from lldbsuite.test import decorators
+
+lldbinline.MakeInlineTest(__file__, globals(), 
[decorators.skipIf(bugnumber="rdar://53756116")])

Added: 
lldb/trunk/packages/Python/lldbsuite/test/expression_command/completion-crash-incomplete-record/main.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/expression_command/completion-crash-incomplete-record/main.cpp?rev=367420&view=auto
==
--- 
lldb/trunk/packages/Python/lldbsuite/test/expression_command/completion-crash-incomplete-record/main.cpp
 (added)
+++ 
lldb/trunk/packages/Python/lldbsuite/test/expression_command/completion-crash-incomplete-record/main.cpp
 Wed Jul 31 05:15:21 2019
@@ -0,0 +1,11 @@
+int i;
+struct F {
+  int &r;
+  F() : r(i) {}
+};
+template  struct unique_ptr {
+  F i;
+  unique_ptr() : i() {//%self.dbg.GetCommandInterpreter().HandleCompletion("e 
", len("e "), 0, -1, lldb.SBStringList())
+}
+};
+int main() {unique_ptr u; }


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


Re: [Lldb-commits] [lldb] r367441 - Don't crash when pass by value struct has no definition.

2019-07-31 Thread Raphael Isemann via lldb-commits
It seems that patch is lacking a test (which doesn't seem too hard to provide).

Am Mi., 31. Juli 2019 um 18:24 Uhr schrieb Greg Clayton via
lldb-commits :
>
> Author: gclayton
> Date: Wed Jul 31 09:24:55 2019
> New Revision: 367441
>
> URL: http://llvm.org/viewvc/llvm-project?rev=367441&view=rev
> Log:
> Don't crash when pass by value struct has no definition.
>
>
> Modified:
> lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
>
> Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp?rev=367441&r1=367440&r2=367441&view=diff
> ==
> --- lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp 
> (original)
> +++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp Wed 
> Jul 31 09:24:55 2019
> @@ -1010,7 +1010,7 @@ TypeSP DWARFASTParserClang::ParseTypeFro
>  if (attrs.calling_convention == llvm::dwarf::DW_CC_pass_by_value) {
>clang::CXXRecordDecl *record_decl =
>m_ast.GetAsCXXRecordDecl(clang_type.GetOpaqueQualType());
> -  if (record_decl) {
> +  if (record_decl && record_decl->getDefinition()) {
>  record_decl->setHasTrivialSpecialMemberForCall();
>}
>  }
>
>
> ___
> lldb-commits mailing list
> lldb-commits@lists.llvm.org
> https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] r367542 - [lldb][NFC] Make ClangDiagnostic::m_fixit_vec private

2019-08-01 Thread Raphael Isemann via lldb-commits
Author: teemperor
Date: Thu Aug  1 04:05:47 2019
New Revision: 367542

URL: http://llvm.org/viewvc/llvm-project?rev=367542&view=rev
Log:
[lldb][NFC] Make ClangDiagnostic::m_fixit_vec private

Modified:
lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangDiagnostic.h

Modified: lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangDiagnostic.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangDiagnostic.h?rev=367542&r1=367541&r2=367542&view=diff
==
--- lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangDiagnostic.h 
(original)
+++ lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangDiagnostic.h Thu Aug  
1 04:05:47 2019
@@ -42,6 +42,7 @@ public:
   }
 
   const FixItList &FixIts() const { return m_fixit_vec; }
+private:
   FixItList m_fixit_vec;
 };
 


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


Re: [Lldb-commits] [lldb] r367549 - [lit] Use ld.lld -z separate-code to work around a debug_line parsing bug

2019-08-01 Thread Raphael Isemann via lldb-commits
This breaks the tests on my machine:


FAIL: LLDB :: SymbolFile/DWARF/dir-separator-no-comp-dir.s (114 of 1660)
 TEST 'LLDB ::
SymbolFile/DWARF/dir-separator-no-comp-dir.s' FAILED

Script:
--
: 'RUN: at line 6';   /home/teemperor/work/3llvm/rel/bin/llvm-mc
-triple x86_64-pc-linux
/home/teemperor/work/3llvm/llvm/lldb/lit/SymbolFile/DWARF/dir-separator-no-comp-dir.s
-filetype=obj >
/home/teemperor/work/3llvm/rel/tools/lldb/lit/SymbolFile/DWARF/Output/dir-separator-no-comp-dir.s.tmp.o
: 'RUN: at line 7';   /usr/bin/ld.lld -z separate-code
/home/teemperor/work/3llvm/rel/tools/lldb/lit/SymbolFile/DWARF/Output/dir-separator-no-comp-dir.s.tmp.o
-o /home/teemperor/work/3llvm/re
l/tools/lldb/lit/SymbolFile/DWARF/Output/dir-separator-no-comp-dir.s.tmp
: 'RUN: at line 8';   /home/teemperor/work/3llvm/rel/bin/lldb
--no-lldbinit -S
/home/teemperor/work/3llvm/rel/tools/lldb/lit/lit-lldb-init
/home/teemperor/work/3llvm/rel/tools/lldb/lit/Symbol
File/DWARF/Output/dir-separator-no-comp-dir.s.tmp -s
/home/teemperor/work/3llvm/llvm/lldb/lit/SymbolFile/DWARF/Inputs/dir-separator-windows.lldbinit
-o exit | /home/teemperor/work/3llvm/rel/b
in/FileCheck 
/home/teemperor/work/3llvm/llvm/lldb/lit/SymbolFile/DWARF/dir-separator-no-comp-dir.s
--
Exit Code: 1

Command Output (stderr):
--
ld.lld: error: unknown -z value: separate-code

--

> ld.lld -v
LLD 8.0.1 (compatible with GNU linkers)

Do I need 9.0.0 for this to pass?

Am Do., 1. Aug. 2019 um 14:38 Uhr schrieb Pavel Labath via
lldb-commits :
>
> On 01/08/2019 14:34, Fangrui Song via lldb-commits wrote:
> > Author: maskray
> > Date: Thu Aug  1 05:34:43 2019
> > New Revision: 367549
> >
> > URL: http://llvm.org/viewvc/llvm-project?rev=367549&view=rev
> > Log:
> > [lit] Use ld.lld -z separate-code to work around a debug_line parsing bug
> >
> > The issue was exposed by D64903/r367537.
> > http://lab.llvm.org:8011/builders/lldb-x64-windows-ninja/builds/7321/
> >
> > In these tests, .debug_str immediately follows .text.
> > The last section of last RX PT_LOAD was originally padded with trap
> > instructions and .debug_str started at a new page (actually
> > common-page-size). Now, .debug_str immediately follows .test.
> > Add -z separate-code to use the old layout.
> >
>
>
> Thanks, I was about to commit the same patch.
>
> For future reference, here is my analysis I was going to put into the
> commit message:
>
> ---
> The lld patch changed how it lays out data in segments, which was
> resulted in the tiny test funclets being at the very end of a PT_LOAD
> segment. This exposed a bug where lldb does not correctly handle line
> table end-of-sequence entries to the very end of a section (so the byte
> they point to does not actually belong to any section).
>
> This is mostly bening in practice, as the code handling line tables will
> terminate as soon as it is not able to resolve an address, which is
> something that would happen after reading the end-of-sequence entry
> anyway. However, these tests assert that we are actually able to parse
> and display the end entry itself, and so they fail.
> ---
> ___
> lldb-commits mailing list
> lldb-commits@lists.llvm.org
> https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] r367830 - [lldb][NFC] Remove unimplemented ClangExpressionSourceCode::GetNumBodyLines

2019-08-05 Thread Raphael Isemann via lldb-commits
Author: teemperor
Date: Mon Aug  5 04:08:47 2019
New Revision: 367830

URL: http://llvm.org/viewvc/llvm-project?rev=367830&view=rev
Log:
[lldb][NFC] Remove unimplemented ClangExpressionSourceCode::GetNumBodyLines

Modified:
lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangExpressionSourceCode.h

Modified: 
lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangExpressionSourceCode.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangExpressionSourceCode.h?rev=367830&r1=367829&r2=367830&view=diff
==
--- 
lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangExpressionSourceCode.h 
(original)
+++ 
lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangExpressionSourceCode.h 
Mon Aug  5 04:08:47 2019
@@ -30,8 +30,6 @@ public:
 return new ClangExpressionSourceCode("$__lldb_expr", prefix, body, true);
   }
 
-  uint32_t GetNumBodyLines();
-
   /// Generates the source code that will evaluate the expression.
   ///
   /// \param text output parameter containing the source code string.


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


[Lldb-commits] [lldb] r367842 - [lldb] Move redundant persistent variable counter to ClangPersistentVariables

2019-08-05 Thread Raphael Isemann via lldb-commits
Author: teemperor
Date: Mon Aug  5 05:32:59 2019
New Revision: 367842

URL: http://llvm.org/viewvc/llvm-project?rev=367842&view=rev
Log:
[lldb] Move redundant persistent variable counter to ClangPersistentVariables

Currently Target::m_next_persistent_variable_index is counting up
for our persistent variables ($0, $1, ...) but we also have a
unused counter that is supposed to do this in
ClangPersistentVariables but that stays always at 0 (because
we currently increase the target counter when we should increase
that unused counter).

This patch removes the counter in Target and lets the documented
counter in ClangPersistentVariables do the variable counting.

Patch *should* be NFC, but it might unexpectedly bring LLDB to
new code paths that could contain exciting new bugs to fix.

Modified:
lldb/trunk/include/lldb/Expression/ExpressionVariable.h
lldb/trunk/include/lldb/Target/Target.h
lldb/trunk/source/Expression/ExpressionVariable.cpp
lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangPersistentVariables.h

Modified: lldb/trunk/include/lldb/Expression/ExpressionVariable.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Expression/ExpressionVariable.h?rev=367842&r1=367841&r2=367842&view=diff
==
--- lldb/trunk/include/lldb/Expression/ExpressionVariable.h (original)
+++ lldb/trunk/include/lldb/Expression/ExpressionVariable.h Mon Aug  5 05:32:59 
2019
@@ -223,8 +223,8 @@ public:
uint32_t addr_byte_size) = 0;
 
   /// Return a new persistent variable name with the specified prefix.
-  ConstString GetNextPersistentVariableName(Target &target,
-llvm::StringRef prefix);
+  virtual ConstString GetNextPersistentVariableName(Target &target,
+llvm::StringRef prefix) = 0;
 
   virtual llvm::StringRef
   GetPersistentVariablePrefix(bool is_error = false) const = 0;

Modified: lldb/trunk/include/lldb/Target/Target.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/Target.h?rev=367842&r1=367841&r2=367842&view=diff
==
--- lldb/trunk/include/lldb/Target/Target.h (original)
+++ lldb/trunk/include/lldb/Target/Target.h Mon Aug  5 05:32:59 2019
@@ -1106,11 +1106,6 @@ public:
 
   lldb::ExpressionVariableSP GetPersistentVariable(ConstString name);
 
-  /// Return the next available number for numbered persistent variables.
-  unsigned GetNextPersistentVariableIndex() {
-return m_next_persistent_variable_index++;
-  }
-
   lldb::addr_t GetPersistentSymbol(ConstString name);
 
   /// This method will return the address of the starting function for
@@ -1320,7 +1315,6 @@ protected:
   bool m_valid;
   bool m_suppress_stop_hooks;
   bool m_is_dummy_target;
-  unsigned m_next_persistent_variable_index = 0;
 
   static void ImageSearchPathsChanged(const PathMappingList &path_list,
   void *baton);

Modified: lldb/trunk/source/Expression/ExpressionVariable.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/ExpressionVariable.cpp?rev=367842&r1=367841&r2=367842&view=diff
==
--- lldb/trunk/source/Expression/ExpressionVariable.cpp (original)
+++ lldb/trunk/source/Expression/ExpressionVariable.cpp Mon Aug  5 05:32:59 2019
@@ -76,13 +76,3 @@ void PersistentExpressionState::Register
 }
   }
 }
-
-ConstString PersistentExpressionState::GetNextPersistentVariableName(
-Target &target, llvm::StringRef Prefix) {
-  llvm::SmallString<64> name;
-  {
-llvm::raw_svector_ostream os(name);
-os << Prefix << target.GetNextPersistentVariableIndex();
-  }
-  return ConstString(name);
-}

Modified: 
lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangPersistentVariables.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangPersistentVariables.h?rev=367842&r1=367841&r2=367842&view=diff
==
--- lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangPersistentVariables.h 
(original)
+++ lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangPersistentVariables.h 
Mon Aug  5 05:32:59 2019
@@ -45,8 +45,18 @@ public:
   uint32_t addr_byte_size) override;
 
   void RemovePersistentVariable(lldb::ExpressionVariableSP variable) override;
-  llvm::StringRef
-  GetPersistentVariablePrefix(bool is_error) const override {
+
+  ConstString GetNextPersistentVariableName(Target &target,
+  llvm::StringRef prefix) override {
+llvm::SmallString<64> name;
+{
+  llvm::raw_svector_ostream os(name);
+  os << prefix << m_next_persistent_variable_id++;
+}
+return ConstString(name);
+  }
+
+  llvm::StringRef GetPersistentVariablePrefix(bool is_error) const override {
 return "$";

[Lldb-commits] [lldb] r367843 - [lldb][NFC] Clang format GetNextPersistentVariableName signature

2019-08-05 Thread Raphael Isemann via lldb-commits
Author: teemperor
Date: Mon Aug  5 05:37:54 2019
New Revision: 367843

URL: http://llvm.org/viewvc/llvm-project?rev=367843&view=rev
Log:
[lldb][NFC] Clang format GetNextPersistentVariableName signature

Modified:
lldb/trunk/include/lldb/Expression/ExpressionVariable.h
lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangPersistentVariables.h

Modified: lldb/trunk/include/lldb/Expression/ExpressionVariable.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Expression/ExpressionVariable.h?rev=367843&r1=367842&r2=367843&view=diff
==
--- lldb/trunk/include/lldb/Expression/ExpressionVariable.h (original)
+++ lldb/trunk/include/lldb/Expression/ExpressionVariable.h Mon Aug  5 05:37:54 
2019
@@ -224,7 +224,7 @@ public:
 
   /// Return a new persistent variable name with the specified prefix.
   virtual ConstString GetNextPersistentVariableName(Target &target,
-llvm::StringRef prefix) = 0;
+llvm::StringRef prefix) = 
0;
 
   virtual llvm::StringRef
   GetPersistentVariablePrefix(bool is_error = false) const = 0;

Modified: 
lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangPersistentVariables.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangPersistentVariables.h?rev=367843&r1=367842&r2=367843&view=diff
==
--- lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangPersistentVariables.h 
(original)
+++ lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangPersistentVariables.h 
Mon Aug  5 05:37:54 2019
@@ -47,7 +47,7 @@ public:
   void RemovePersistentVariable(lldb::ExpressionVariableSP variable) override;
 
   ConstString GetNextPersistentVariableName(Target &target,
-  llvm::StringRef prefix) override {
+llvm::StringRef prefix) override {
 llvm::SmallString<64> name;
 {
   llvm::raw_svector_ostream os(name);


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


[Lldb-commits] [lldb] r367857 - [lldb][NFC] Fix documentation for ClangPersistentVariables::m_next_persistent_variable_id

2019-08-05 Thread Raphael Isemann via lldb-commits
Author: teemperor
Date: Mon Aug  5 06:40:39 2019
New Revision: 367857

URL: http://llvm.org/viewvc/llvm-project?rev=367857&view=rev
Log:
[lldb][NFC] Fix documentation for 
ClangPersistentVariables::m_next_persistent_variable_id

Modified:

lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangPersistentVariables.cpp
lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangPersistentVariables.h

Modified: 
lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangPersistentVariables.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangPersistentVariables.cpp?rev=367857&r1=367856&r2=367857&view=diff
==
--- 
lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangPersistentVariables.cpp 
(original)
+++ 
lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangPersistentVariables.cpp 
Mon Aug  5 06:40:39 2019
@@ -23,8 +23,7 @@ using namespace lldb;
 using namespace lldb_private;
 
 ClangPersistentVariables::ClangPersistentVariables()
-: lldb_private::PersistentExpressionState(LLVMCastKind::eKindClang),
-  m_next_persistent_variable_id(0) {}
+: lldb_private::PersistentExpressionState(LLVMCastKind::eKindClang) {}
 
 ExpressionVariableSP ClangPersistentVariables::CreatePersistentVariable(
 const lldb::ValueObjectSP &valobj_sp) {

Modified: 
lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangPersistentVariables.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangPersistentVariables.h?rev=367857&r1=367856&r2=367857&view=diff
==
--- lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangPersistentVariables.h 
(original)
+++ lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangPersistentVariables.h 
Mon Aug  5 06:40:39 2019
@@ -76,8 +76,8 @@ public:
   }
 
 private:
-  uint32_t m_next_persistent_variable_id; ///< The counter used by
-  ///GetNextResultName().
+  // The counter used by GetNextPersistentVariableName
+  uint32_t m_next_persistent_variable_id = 0;
 
   typedef llvm::DenseMap PersistentDeclMap;
   PersistentDeclMap


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


[Lldb-commits] [lldb] r367922 - [lldb][NFC] Refactor ClangUserExpression::UpdateLanguageForExpr

2019-08-05 Thread Raphael Isemann via lldb-commits
Author: teemperor
Date: Mon Aug  5 13:31:47 2019
New Revision: 367922

URL: http://llvm.org/viewvc/llvm-project?rev=367922&view=rev
Log:
[lldb][NFC] Refactor ClangUserExpression::UpdateLanguageForExpr

The UpdateLanguageForExpr should only update the language, but over
time it started to do also do different things related to the generation
of the expression source code. This patch refactors all the source code
generation part into its own function.

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=367922&r1=367921&r2=367922&view=diff
==
--- lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp 
(original)
+++ lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp 
Mon Aug  5 13:31:47 2019
@@ -378,10 +378,21 @@ static void SetupDeclVendor(ExecutionCon
   }
 }
 
-void ClangUserExpression::UpdateLanguageForExpr(
+void ClangUserExpression::UpdateLanguageForExpr() {
+  m_expr_lang = lldb::LanguageType::eLanguageTypeUnknown;
+  if (m_options.GetExecutionPolicy() == eExecutionPolicyTopLevel)
+return;
+  if (m_in_cplusplus_method)
+m_expr_lang = lldb::eLanguageTypeC_plus_plus;
+  else if (m_in_objectivec_method)
+m_expr_lang = lldb::eLanguageTypeObjC;
+  else
+m_expr_lang = lldb::eLanguageTypeC;
+}
+
+void ClangUserExpression::CreateSourceCode(
 DiagnosticManager &diagnostic_manager, ExecutionContext &exe_ctx,
 std::vector modules_to_import, bool for_completion) {
-  m_expr_lang = lldb::LanguageType::eLanguageTypeUnknown;
 
   std::string prefix = m_expr_prefix;
 
@@ -390,14 +401,7 @@ void ClangUserExpression::UpdateLanguage
   } else {
 std::unique_ptr source_code(
 ClangExpressionSourceCode::CreateWrapped(prefix.c_str(),
-m_expr_text.c_str()));
-
-if (m_in_cplusplus_method)
-  m_expr_lang = lldb::eLanguageTypeC_plus_plus;
-else if (m_in_objectivec_method)
-  m_expr_lang = lldb::eLanguageTypeObjC;
-else
-  m_expr_lang = lldb::eLanguageTypeC;
+ m_expr_text.c_str()));
 
 if (!source_code->GetText(m_transformed_text, m_expr_lang,
   m_in_static_method, exe_ctx, !m_ctx_obj,
@@ -506,8 +510,8 @@ bool ClangUserExpression::PrepareForPars
   LLDB_LOG(log, "List of imported modules in expression: {0}",
llvm::make_range(used_modules.begin(), used_modules.end()));
 
-  UpdateLanguageForExpr(diagnostic_manager, exe_ctx, used_modules,
-for_completion);
+  UpdateLanguageForExpr();
+  CreateSourceCode(diagnostic_manager, exe_ctx, used_modules, for_completion);
   return true;
 }
 

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=367922&r1=367921&r2=367922&view=diff
==
--- lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangUserExpression.h 
(original)
+++ lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangUserExpression.h Mon 
Aug  5 13:31:47 2019
@@ -176,10 +176,11 @@ private:
 DiagnosticManager &diagnostic_manager) override;
 
   std::vector GetModulesToImport(ExecutionContext &exe_ctx);
-  void UpdateLanguageForExpr(DiagnosticManager &diagnostic_manager,
- ExecutionContext &exe_ctx,
- std::vector modules_to_import,
- bool for_completion);
+  void CreateSourceCode(DiagnosticManager &diagnostic_manager,
+ExecutionContext &exe_ctx,
+std::vector modules_to_import,
+bool for_completion);
+  void UpdateLanguageForExpr();
   bool SetupPersistentState(DiagnosticManager &diagnostic_manager,
ExecutionContext &exe_ctx);
   bool PrepareForParsing(DiagnosticManager &diagnostic_manager,


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


[Lldb-commits] [lldb] r367936 - [lldb][NFC] Document and refactor ClangPersistentVariables::RemovePersistentVariable

2019-08-05 Thread Raphael Isemann via lldb-commits
Author: teemperor
Date: Mon Aug  5 14:43:53 2019
New Revision: 367936

URL: http://llvm.org/viewvc/llvm-project?rev=367936&view=rev
Log:
[lldb][NFC] Document and refactor 
ClangPersistentVariables::RemovePersistentVariable

Modified:

lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangPersistentVariables.cpp

Modified: 
lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangPersistentVariables.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangPersistentVariables.cpp?rev=367936&r1=367935&r2=367936&view=diff
==
--- 
lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangPersistentVariables.cpp 
(original)
+++ 
lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangPersistentVariables.cpp 
Mon Aug  5 14:43:53 2019
@@ -42,13 +42,25 @@ void ClangPersistentVariables::RemovePer
 lldb::ExpressionVariableSP variable) {
   RemoveVariable(variable);
 
-  const char *name = variable->GetName().AsCString();
+  // Check if the removed variable was the last one that was created. If yes,
+  // reuse the variable id for the next variable.
 
-  if (*name != '$')
+  // Nothing to do if we have not assigned a variable id so far.
+  if (m_next_persistent_variable_id == 0)
 return;
-  name++;
 
-  if (strtoul(name, nullptr, 0) == m_next_persistent_variable_id - 1)
+  llvm::StringRef name = variable->GetName().GetStringRef();
+  // Remove the prefix from the variable that only the indes is left.
+  if (!name.consume_front(GetPersistentVariablePrefix(false)))
+return;
+
+  // Check if the variable contained a variable id.
+  uint32_t variable_id;
+  if (name.getAsInteger(10, variable_id))
+return;
+  // If it's the most recent variable id that was assigned, make sure that this
+  // variable id will be used for the next persistent variable.
+  if (variable_id == m_next_persistent_variable_id - 1)
 m_next_persistent_variable_id--;
 }
 


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


[Lldb-commits] [lldb] r367989 - [lldb][NFC] Remove unnecessary cast in ClangUserExpression

2019-08-06 Thread Raphael Isemann via lldb-commits
Author: teemperor
Date: Tue Aug  6 01:07:45 2019
New Revision: 367989

URL: http://llvm.org/viewvc/llvm-project?rev=367989&view=rev
Log:
[lldb][NFC] Remove unnecessary cast in ClangUserExpression

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=367989&r1=367988&r2=367989&view=diff
==
--- lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp 
(original)
+++ lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp 
Tue Aug  6 01:07:45 2019
@@ -645,12 +645,10 @@ bool ClangUserExpression::Parse(Diagnost
   register_execution_unit = true;
 }
 
-if (register_execution_unit) {
-  llvm::cast(
-  exe_ctx.GetTargetPtr()->GetPersistentExpressionStateForLanguage(
-  m_language))
+if (register_execution_unit)
+  exe_ctx.GetTargetPtr()
+  ->GetPersistentExpressionStateForLanguage(m_language)
   ->RegisterExecutionUnit(m_execution_unit_sp);
-}
   }
 
   if (generate_debug_info) {


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


[Lldb-commits] [lldb] r368082 - [lldb][NFC] Minor refactorings to (Clang)ExpressionSourceCode

2019-08-06 Thread Raphael Isemann via lldb-commits
Author: teemperor
Date: Tue Aug  6 13:25:02 2019
New Revision: 368082

URL: http://llvm.org/viewvc/llvm-project?rev=368082&view=rev
Log:
[lldb][NFC] Minor refactorings to (Clang)ExpressionSourceCode

Modified:
lldb/trunk/include/lldb/Expression/ExpressionSourceCode.h
lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangExpressionSourceCode.h

Modified: lldb/trunk/include/lldb/Expression/ExpressionSourceCode.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Expression/ExpressionSourceCode.h?rev=368082&r1=368081&r2=368082&view=diff
==
--- lldb/trunk/include/lldb/Expression/ExpressionSourceCode.h (original)
+++ lldb/trunk/include/lldb/Expression/ExpressionSourceCode.h Tue Aug  6 
13:25:02 2019
@@ -17,20 +17,27 @@
 namespace lldb_private {
 
 class ExpressionSourceCode {
+protected:
+  enum Wrapping : bool {
+Wrap = true,
+NoWrap = false,
+  };
+
 public:
-  bool NeedsWrapping() const { return m_wrap; }
+  bool NeedsWrapping() const { return m_wrap == Wrap; }
 
   const char *GetName() const { return m_name.c_str(); }
 
 protected:
-  ExpressionSourceCode(const char *name, const char *prefix, const char *body,
-   bool wrap)
-  : m_name(name), m_prefix(prefix), m_body(body), m_wrap(wrap) {}
+  ExpressionSourceCode(llvm::StringRef name, llvm::StringRef prefix,
+   llvm::StringRef body, Wrapping wrap)
+  : m_name(name.str()), m_prefix(prefix.str()), m_body(body.str()),
+m_wrap(wrap) {}
 
   std::string m_name;
   std::string m_prefix;
   std::string m_body;
-  bool m_wrap;
+  Wrapping m_wrap;
 };
 
 } // namespace lldb_private

Modified: 
lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangExpressionSourceCode.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangExpressionSourceCode.h?rev=368082&r1=368081&r2=368082&view=diff
==
--- 
lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangExpressionSourceCode.h 
(original)
+++ 
lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangExpressionSourceCode.h 
Tue Aug  6 13:25:02 2019
@@ -25,9 +25,9 @@ class ClangExpressionSourceCode : public
 public:
   static const char *g_expression_prefix;
 
-  static ClangExpressionSourceCode *CreateWrapped(const char *prefix,
- const char *body) {
-return new ClangExpressionSourceCode("$__lldb_expr", prefix, body, true);
+  static ClangExpressionSourceCode *CreateWrapped(llvm::StringRef prefix,
+  llvm::StringRef body) {
+return new ClangExpressionSourceCode("$__lldb_expr", prefix, body, Wrap);
   }
 
   /// Generates the source code that will evaluate the expression.
@@ -59,9 +59,9 @@ public:
 size_t &start_loc, size_t &end_loc);
 
 protected:
-  ClangExpressionSourceCode(const char *name, const char *prefix, const char 
*body,
-   bool wrap) :
-  ExpressionSourceCode(name, prefix, body, wrap) {}
+  ClangExpressionSourceCode(llvm::StringRef name, llvm::StringRef prefix,
+llvm::StringRef body, Wrapping wrap)
+  : ExpressionSourceCode(name, prefix, body, wrap) {}
 };
 
 } // namespace lldb_private


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


[Lldb-commits] [lldb] r368150 - [lldb][NFC] Remove commented out code in ClangASTContext::AddMethodToCXXRecordType

2019-08-07 Thread Raphael Isemann via lldb-commits
Author: teemperor
Date: Wed Aug  7 03:59:34 2019
New Revision: 368150

URL: http://llvm.org/viewvc/llvm-project?rev=368150&view=rev
Log:
[lldb][NFC] Remove commented out code in 
ClangASTContext::AddMethodToCXXRecordType

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=368150&r1=368149&r2=368150&view=diff
==
--- lldb/trunk/source/Symbol/ClangASTContext.cpp (original)
+++ lldb/trunk/source/Symbol/ClangASTContext.cpp Wed Aug  7 03:59:34 2019
@@ -8330,24 +8330,6 @@ clang::CXXMethodDecl *ClangASTContext::A
   VerifyDecl(cxx_method_decl);
 #endif
 
-  //printf ("decl->isPolymorphic() = %i\n",
-  //cxx_record_decl->isPolymorphic());
-  //printf ("decl->isAggregate()   = %i\n",
-  //cxx_record_decl->isAggregate());
-  //printf ("decl->isPOD() = %i\n",
-  //cxx_record_decl->isPOD());
-  //printf ("decl->isEmpty()   = %i\n",
-  //cxx_record_decl->isEmpty());
-  //printf ("decl->isAbstract()= %i\n",
-  //cxx_record_decl->isAbstract());
-  //printf ("decl->hasTrivialConstructor() = %i\n",
-  //cxx_record_decl->hasTrivialConstructor());
-  //printf ("decl->hasTrivialCopyConstructor() = %i\n",
-  //cxx_record_decl->hasTrivialCopyConstructor());
-  //printf ("decl->hasTrivialCopyAssignment()  = %i\n",
-  //cxx_record_decl->hasTrivialCopyAssignment());
-  //printf ("decl->hasTrivialDestructor()  = %i\n",
-  //cxx_record_decl->hasTrivialDestructor());
   return cxx_method_decl;
 }
 


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


[Lldb-commits] [lldb] r368309 - [lldb][NFC] Simplify return in MaybeHandleVariable

2019-08-08 Thread Raphael Isemann via lldb-commits
Author: teemperor
Date: Thu Aug  8 09:41:32 2019
New Revision: 368309

URL: http://llvm.org/viewvc/llvm-project?rev=368309&view=rev
Log:
[lldb][NFC] Simplify return in MaybeHandleVariable

This function anyway returns true, no need to do this extra work.

Modified:
lldb/trunk/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp

Modified: lldb/trunk/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp?rev=368309&r1=368308&r2=368309&view=diff
==
--- lldb/trunk/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp (original)
+++ lldb/trunk/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp Thu Aug  8 
09:41:32 2019
@@ -1387,15 +1387,10 @@ bool IRForTarget::MaybeHandleVariable(Va
 PrintType(value_type).c_str(), *value_size, value_alignment);
 }
 
-if (named_decl &&
-!m_decl_map->AddValueToStruct(
-named_decl, lldb_private::ConstString(name.c_str()), 
llvm_value_ptr,
-*value_size, value_alignment)) {
-  if (!global_variable->hasExternalLinkage())
-return true;
-  else
-return true;
-}
+if (named_decl)
+  m_decl_map->AddValueToStruct(
+  named_decl, lldb_private::ConstString(name.c_str()), llvm_value_ptr,
+  *value_size, value_alignment);
   } else if (dyn_cast(llvm_value_ptr)) {
 if (log)
   LLDB_LOGF(log, "Function pointers aren't handled right now");


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


[Lldb-commits] [lldb] r368346 - [lldb][NFC] Directly use StringRef instead of temporary std::string

2019-08-08 Thread Raphael Isemann via lldb-commits
Author: teemperor
Date: Thu Aug  8 14:22:21 2019
New Revision: 368346

URL: http://llvm.org/viewvc/llvm-project?rev=368346&view=rev
Log:
[lldb][NFC] Directly use StringRef instead of temporary std::string

Modified:
lldb/trunk/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp

Modified: lldb/trunk/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp?rev=368346&r1=368345&r2=368346&view=diff
==
--- lldb/trunk/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp (original)
+++ lldb/trunk/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp Thu Aug  8 
14:22:21 2019
@@ -1342,7 +1342,7 @@ bool IRForTarget::MaybeHandleVariable(Va
   return false;
 }
 
-std::string name(named_decl->getName().str());
+llvm::StringRef name(named_decl->getName());
 
 clang::ValueDecl *value_decl = dyn_cast(named_decl);
 if (value_decl == nullptr)
@@ -1353,7 +1353,7 @@ bool IRForTarget::MaybeHandleVariable(Va
 
 const Type *value_type = nullptr;
 
-if (name[0] == '$') {
+if (name.startswith("$")) {
   // The $__lldb_expr_result name indicates the return value has allocated
   // as a static variable.  Per the comment at
   // ASTResultSynthesizer::SynthesizeBodyResult, accesses to this static
@@ -1377,20 +1377,19 @@ bool IRForTarget::MaybeHandleVariable(Va
 (compiler_type.GetTypeBitAlign() + 7ull) / 8ull;
 
 if (log) {
-  LLDB_LOGF(log,
-"Type of \"%s\" is [clang \"%s\", llvm \"%s\"] [size %" PRIu64
-", align %" PRIu64 "]",
-name.c_str(),
-lldb_private::ClangUtil::GetQualType(compiler_type)
-.getAsString()
-.c_str(),
-PrintType(value_type).c_str(), *value_size, value_alignment);
+  LLDB_LOG(
+  log,
+  "Type of \"{0}\" is [clang \"{1}\", llvm \"{2}\"] [size {3}, "
+  "align {4}]",
+  name,
+  lldb_private::ClangUtil::GetQualType(compiler_type).getAsString(),
+  PrintType(value_type), *value_size, value_alignment);
 }
 
 if (named_decl)
-  m_decl_map->AddValueToStruct(
-  named_decl, lldb_private::ConstString(name.c_str()), llvm_value_ptr,
-  *value_size, value_alignment);
+  m_decl_map->AddValueToStruct(named_decl, lldb_private::ConstString(name),
+   llvm_value_ptr, *value_size,
+   value_alignment);
   } else if (dyn_cast(llvm_value_ptr)) {
 if (log)
   LLDB_LOGF(log, "Function pointers aren't handled right now");


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


[Lldb-commits] [lldb] r368353 - [lldb][NFC] Move to StringRef in some places in IRForTarget

2019-08-08 Thread Raphael Isemann via lldb-commits
Author: teemperor
Date: Thu Aug  8 14:43:21 2019
New Revision: 368353

URL: http://llvm.org/viewvc/llvm-project?rev=368353&view=rev
Log:
[lldb][NFC] Move to StringRef in some places in IRForTarget

Modified:
lldb/trunk/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp

Modified: lldb/trunk/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp?rev=368353&r1=368352&r2=368353&view=diff
==
--- lldb/trunk/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp (original)
+++ lldb/trunk/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp Thu Aug  8 
14:43:21 2019
@@ -1579,31 +1579,28 @@ bool IRForTarget::ResolveExternals(Funct
   lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS));
 
   for (GlobalVariable &global_var : m_module->globals()) {
-std::string global_name = global_var.getName().str();
+llvm::StringRef global_name = global_var.getName();
 
 if (log)
-  LLDB_LOGF(log, "Examining %s, DeclForGlobalValue returns %p",
-global_name.c_str(),
-static_cast(DeclForGlobal(&global_var)));
+  LLDB_LOG(log, "Examining {0}, DeclForGlobalValue returns {1}",
+   global_name, static_cast(DeclForGlobal(&global_var)));
 
-if (global_name.find("OBJC_IVAR") == 0) {
+if (global_name.startswith("OBJC_IVAR")) {
   if (!HandleSymbol(&global_var)) {
-m_error_stream.Printf("Error [IRForTarget]: Couldn't find Objective-C "
-  "indirect ivar symbol %s\n",
-  global_name.c_str());
+m_error_stream.Format("Error [IRForTarget]: Couldn't find Objective-C "
+  "indirect ivar symbol {0}\n",
+  global_name);
 
 return false;
   }
-} else if (global_name.find("OBJC_CLASSLIST_REFERENCES_$") !=
-   global_name.npos) {
+} else if (global_name.contains("OBJC_CLASSLIST_REFERENCES_$")) {
   if (!HandleObjCClass(&global_var)) {
 m_error_stream.Printf("Error [IRForTarget]: Couldn't resolve the class 
"
   "for an Objective-C static method call\n");
 
 return false;
   }
-} else if (global_name.find("OBJC_CLASSLIST_SUP_REFS_$") !=
-   global_name.npos) {
+} else if (global_name.contains("OBJC_CLASSLIST_SUP_REFS_$")) {
   if (!HandleObjCClass(&global_var)) {
 m_error_stream.Printf("Error [IRForTarget]: Couldn't resolve the class 
"
   "for an Objective-C static method call\n");
@@ -1612,9 +1609,9 @@ bool IRForTarget::ResolveExternals(Funct
   }
 } else if (DeclForGlobal(&global_var)) {
   if (!MaybeHandleVariable(&global_var)) {
-m_error_stream.Printf("Internal error [IRForTarget]: Couldn't rewrite "
-  "external variable %s\n",
-  global_name.c_str());
+m_error_stream.Format("Internal error [IRForTarget]: Couldn't rewrite "
+  "external variable {0}\n",
+  global_name);
 
 return false;
   }
@@ -1872,9 +1869,9 @@ bool IRForTarget::ReplaceVariables(Funct
 }
 
 if (!iter->getName().equals("_cmd")) {
-  m_error_stream.Printf("Internal error [IRForTarget]: Wrapper takes '%s' "
+  m_error_stream.Format("Internal error [IRForTarget]: Wrapper takes '{0}' 
"
 "after 'self' argument (should take '_cmd')",
-iter->getName().str().c_str());
+iter->getName());
 
   return false;
 }
@@ -1893,15 +1890,15 @@ bool IRForTarget::ReplaceVariables(Funct
   }
 
   if (!argument->getName().equals("$__lldb_arg")) {
-m_error_stream.Printf("Internal error [IRForTarget]: Wrapper takes an "
-  "argument named '%s' instead of the struct pointer",
-  argument->getName().str().c_str());
+m_error_stream.Format("Internal error [IRForTarget]: Wrapper takes an "
+  "argument named '{0}' instead of the struct pointer",
+  argument->getName());
 
 return false;
   }
 
   if (log)
-LLDB_LOGF(log, "Arg: \"%s\"", PrintValue(argument).c_str());
+LLDB_LOG(log, "Arg: \"{0}\"", PrintValue(argument));
 
   BasicBlock &entry_block(llvm_function.getEntryBlock());
   Instruction *FirstEntryInstruction(entry_block.getFirstNonPHIOrDbg());
@@ -1939,12 +1936,12 @@ bool IRForTarget::ReplaceVariables(Funct
 }
 
 if (log)
-  LLDB_LOGF(log, "  \"%s\" (\"%s\") placed at %" PRIu64, name.GetCString(),
-decl->getNameAsString().c_str(), offset);
+  LLDB_LOG(log, "  \"{0}\" (\"{1}\") placed at %" PRIu64, name,
+   decl->getNameAsString(), offset);
 
  

[Lldb-commits] [lldb] r368359 - [lldb][NFC] Modernize IRForTarget::CreateResultVariable

2019-08-08 Thread Raphael Isemann via lldb-commits
Author: teemperor
Date: Thu Aug  8 15:19:16 2019
New Revision: 368359

URL: http://llvm.org/viewvc/llvm-project?rev=368359&view=rev
Log:
[lldb][NFC] Modernize IRForTarget::CreateResultVariable

Modified:
lldb/trunk/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp

Modified: lldb/trunk/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp?rev=368359&r1=368358&r2=368359&view=diff
==
--- lldb/trunk/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp (original)
+++ lldb/trunk/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp Thu Aug  8 
15:19:16 2019
@@ -164,38 +164,37 @@ bool IRForTarget::CreateResultVariable(l
 
   ValueSymbolTable &value_symbol_table = m_module->getValueSymbolTable();
 
-  std::string result_name_str;
-  const char *result_name = nullptr;
+  llvm::StringRef result_name;
+  bool found_result = false;
 
   for (ValueSymbolTable::iterator vi = value_symbol_table.begin(),
   ve = value_symbol_table.end();
vi != ve; ++vi) {
-result_name_str = vi->first().str();
-const char *value_name = result_name_str.c_str();
+result_name = vi->first();
 
-if (strstr(value_name, "$__lldb_expr_result_ptr") &&
-strncmp(value_name, "_ZGV", 4)) {
-  result_name = value_name;
+if (result_name.contains("$__lldb_expr_result_ptr") &&
+!result_name.startswith("_ZGV")) {
+  found_result = true;
   m_result_is_pointer = true;
   break;
 }
 
-if (strstr(value_name, "$__lldb_expr_result") &&
-strncmp(value_name, "_ZGV", 4)) {
-  result_name = value_name;
+if (result_name.contains("$__lldb_expr_result") &&
+!result_name.startswith("_ZGV")) {
+  found_result = true;
   m_result_is_pointer = false;
   break;
 }
   }
 
-  if (!result_name) {
+  if (!found_result) {
 if (log)
   log->PutCString("Couldn't find result variable");
 
 return true;
   }
 
-  LLDB_LOGF(log, "Result name: \"%s\"", result_name);
+  LLDB_LOG(log, "Result name: \"{0}\"", result_name);
 
   Value *result_value = m_module->getNamedValue(result_name);
 
@@ -203,8 +202,8 @@ bool IRForTarget::CreateResultVariable(l
 if (log)
   log->PutCString("Result variable had no data");
 
-m_error_stream.Printf("Internal error [IRForTarget]: Result variable's "
-  "name (%s) exists, but not its definition\n",
+m_error_stream.Format("Internal error [IRForTarget]: Result variable's "
+  "name ({0}) exists, but not its definition\n",
   result_name);
 
 return false;
@@ -219,7 +218,7 @@ bool IRForTarget::CreateResultVariable(l
 if (log)
   log->PutCString("Result variable isn't a GlobalVariable");
 
-m_error_stream.Printf("Internal error [IRForTarget]: Result variable (%s) "
+m_error_stream.Format("Internal error [IRForTarget]: Result variable ({0}) 
"
   "is defined, but is not a global variable\n",
   result_name);
 
@@ -231,7 +230,7 @@ bool IRForTarget::CreateResultVariable(l
 if (log)
   log->PutCString("Result variable doesn't have a corresponding Decl");
 
-m_error_stream.Printf("Internal error [IRForTarget]: Result variable (%s) "
+m_error_stream.Format("Internal error [IRForTarget]: Result variable ({0}) 
"
   "does not have a corresponding Clang entity\n",
   result_name);
 
@@ -252,8 +251,8 @@ bool IRForTarget::CreateResultVariable(l
 if (log)
   log->PutCString("Result variable Decl isn't a VarDecl");
 
-m_error_stream.Printf("Internal error [IRForTarget]: Result variable "
-  "(%s)'s corresponding Clang entity isn't a "
+m_error_stream.Format("Internal error [IRForTarget]: Result variable "
+  "({0})'s corresponding Clang entity isn't a "
   "variable\n",
   result_name);
 
@@ -293,7 +292,7 @@ bool IRForTarget::CreateResultVariable(l
   if (log)
 log->PutCString("Expected result to have pointer type, but it did 
not");
 
-  m_error_stream.Printf("Internal error [IRForTarget]: Lvalue result (%s) "
+  m_error_stream.Format("Internal error [IRForTarget]: Lvalue result ({0}) 
"
 "is not a pointer variable\n",
 result_name);
 
@@ -382,8 +381,8 @@ bool IRForTarget::CreateResultVariable(l
 if (!result_global->hasInitializer()) {
   LLDB_LOGF(log, "Couldn't find initializer for unused variable");
 
-  m_error_stream.Printf("Internal error [IRForTarget]: Result variable "
-"(%s) has no writes and no initializer\n",
+  m_error_stream.Format("Internal error [IRForTarget]: Result variabl

[Lldb-commits] [lldb] r368405 - [lldb][NFC] Use range-based for-loops in IRForTarget

2019-08-09 Thread Raphael Isemann via lldb-commits
Author: teemperor
Date: Fri Aug  9 00:59:18 2019
New Revision: 368405

URL: http://llvm.org/viewvc/llvm-project?rev=368405&view=rev
Log:
[lldb][NFC] Use range-based for-loops in IRForTarget

Modified:
lldb/trunk/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp

Modified: lldb/trunk/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp?rev=368405&r1=368404&r2=368405&view=diff
==
--- lldb/trunk/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp (original)
+++ lldb/trunk/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp Fri Aug  9 
00:59:18 2019
@@ -167,10 +167,8 @@ bool IRForTarget::CreateResultVariable(l
   llvm::StringRef result_name;
   bool found_result = false;
 
-  for (ValueSymbolTable::iterator vi = value_symbol_table.begin(),
-  ve = value_symbol_table.end();
-   vi != ve; ++vi) {
-result_name = vi->first();
+  for (StringMapEntry &value_symbol : value_symbol_table) {
+result_name = value_symbol.first();
 
 if (result_name.contains("$__lldb_expr_result_ptr") &&
 !result_name.startswith("_ZGV")) {
@@ -555,14 +553,12 @@ bool IRForTarget::RewriteObjCConstString
 
   ValueSymbolTable &value_symbol_table = m_module->getValueSymbolTable();
 
-  for (ValueSymbolTable::iterator vi = value_symbol_table.begin(),
-  ve = value_symbol_table.end();
-   vi != ve; ++vi) {
-std::string value_name = vi->first().str();
+  for (StringMapEntry &value_symbol : value_symbol_table) {
+std::string value_name = value_symbol.first().str();
 const char *value_name_cstr = value_name.c_str();
 
 if (strstr(value_name_cstr, "_unnamed_cfstring_")) {
-  Value *nsstring_value = vi->second;
+  Value *nsstring_value = value_symbol.second;
 
   GlobalVariable *nsstring_global =
   dyn_cast(nsstring_value);
@@ -741,14 +737,12 @@ bool IRForTarget::RewriteObjCConstString
 }
   }
 
-  for (ValueSymbolTable::iterator vi = value_symbol_table.begin(),
-  ve = value_symbol_table.end();
-   vi != ve; ++vi) {
-std::string value_name = vi->first().str();
+  for (StringMapEntry &value_symbol : value_symbol_table) {
+std::string value_name = value_symbol.first().str();
 const char *value_name_cstr = value_name.c_str();
 
 if (!strcmp(value_name_cstr, "__CFConstantStringClassReference")) {
-  GlobalVariable *gv = dyn_cast(vi->second);
+  GlobalVariable *gv = dyn_cast(value_symbol.second);
 
   if (!gv) {
 if (log)
@@ -911,26 +905,18 @@ bool IRForTarget::RewriteObjCSelector(In
 bool IRForTarget::RewriteObjCSelectors(BasicBlock &basic_block) {
   lldb_private::Log *log(
   lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS));
-
-  BasicBlock::iterator ii;
-
   typedef SmallVector InstrList;
-  typedef InstrList::iterator InstrIterator;
 
   InstrList selector_loads;
 
-  for (ii = basic_block.begin(); ii != basic_block.end(); ++ii) {
-Instruction &inst = *ii;
-
+  for (Instruction &inst : basic_block) {
 if (LoadInst *load = dyn_cast(&inst))
   if (IsObjCSelectorRef(load->getPointerOperand()))
 selector_loads.push_back(&inst);
   }
 
-  InstrIterator iter;
-
-  for (iter = selector_loads.begin(); iter != selector_loads.end(); ++iter) {
-if (!RewriteObjCSelector(*iter)) {
+  for (Instruction *inst : selector_loads) {
+if (!RewriteObjCSelector(inst)) {
   m_error_stream.Printf("Internal error [IRForTarget]: Couldn't change a "
 "static reference to an Objective-C selector to a "
 "dynamic reference\n");
@@ -1076,25 +1062,18 @@ bool IRForTarget::RewriteObjCClassRefere
   lldb_private::Log *log(
   lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS));
 
-  BasicBlock::iterator ii;
-
   typedef SmallVector InstrList;
-  typedef InstrList::iterator InstrIterator;
 
   InstrList class_loads;
 
-  for (ii = basic_block.begin(); ii != basic_block.end(); ++ii) {
-Instruction &inst = *ii;
-
+  for (Instruction &inst : basic_block) {
 if (LoadInst *load = dyn_cast(&inst))
   if (IsObjCClassReference(load->getPointerOperand()))
 class_loads.push_back(&inst);
   }
 
-  InstrIterator iter;
-
-  for (iter = class_loads.begin(); iter != class_loads.end(); ++iter) {
-if (!RewriteObjCClassReference(*iter)) {
+  for (Instruction *inst : class_loads) {
+if (!RewriteObjCClassReference(inst)) {
   m_error_stream.Printf("Internal error [IRForTarget]: Couldn't change a "
 "static reference to an Objective-C class to a "
 "dynamic reference\n");
@@ -1187,15 +1166,11 @@ bool IRForTarget::RewritePersistentAlloc
   lldb_private::Log *log(
   lldb_private::GetLogIfAllCategorie

[Lldb-commits] [lldb] r368406 - [lldb][NFC] Remove last C string uses from IRForTarget

2019-08-09 Thread Raphael Isemann via lldb-commits
Author: teemperor
Date: Fri Aug  9 01:10:02 2019
New Revision: 368406

URL: http://llvm.org/viewvc/llvm-project?rev=368406&view=rev
Log:
[lldb][NFC] Remove last C string uses from IRForTarget

Modified:
lldb/trunk/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp

Modified: lldb/trunk/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp?rev=368406&r1=368405&r2=368406&view=diff
==
--- lldb/trunk/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp (original)
+++ lldb/trunk/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp Fri Aug  9 
01:10:02 2019
@@ -554,10 +554,9 @@ bool IRForTarget::RewriteObjCConstString
   ValueSymbolTable &value_symbol_table = m_module->getValueSymbolTable();
 
   for (StringMapEntry &value_symbol : value_symbol_table) {
-std::string value_name = value_symbol.first().str();
-const char *value_name_cstr = value_name.c_str();
+llvm::StringRef value_name = value_symbol.first();
 
-if (strstr(value_name_cstr, "_unnamed_cfstring_")) {
+if (value_name.contains("_unnamed_cfstring_")) {
   Value *nsstring_value = value_symbol.second;
 
   GlobalVariable *nsstring_global =
@@ -715,11 +714,11 @@ bool IRForTarget::RewriteObjCConstString
 
   if (log) {
 if (cstr_array)
-  LLDB_LOGF(log, "Found NSString constant %s, which contains \"%s\"",
-value_name_cstr, cstr_array->getAsString().str().c_str());
+  LLDB_LOG(log, "Found NSString constant {0}, which contains \"{1}\"",
+   value_name, cstr_array->getAsString());
 else
-  LLDB_LOGF(log, "Found NSString constant %s, which contains \"\"",
-value_name_cstr);
+  LLDB_LOG(log, "Found NSString constant {0}, which contains \"\"",
+   value_name);
   }
 
   if (!cstr_array)
@@ -738,10 +737,9 @@ bool IRForTarget::RewriteObjCConstString
   }
 
   for (StringMapEntry &value_symbol : value_symbol_table) {
-std::string value_name = value_symbol.first().str();
-const char *value_name_cstr = value_name.c_str();
+llvm::StringRef value_name = value_symbol.first();
 
-if (!strcmp(value_name_cstr, "__CFConstantStringClassReference")) {
+if (value_name == "__CFConstantStringClassReference") {
   GlobalVariable *gv = dyn_cast(value_symbol.second);
 
   if (!gv) {


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


[Lldb-commits] [lldb] r368415 - [lldb][NFC] Clean up logging in IRForTarget

2019-08-09 Thread Raphael Isemann via lldb-commits
Author: teemperor
Date: Fri Aug  9 01:54:01 2019
New Revision: 368415

URL: http://llvm.org/viewvc/llvm-project?rev=368415&view=rev
Log:
[lldb][NFC] Clean up logging in IRForTarget

Modified:
lldb/trunk/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp

Modified: lldb/trunk/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp?rev=368415&r1=368414&r2=368415&view=diff
==
--- lldb/trunk/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp (original)
+++ lldb/trunk/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp Fri Aug  9 
01:54:01 2019
@@ -186,8 +186,7 @@ bool IRForTarget::CreateResultVariable(l
   }
 
   if (!found_result) {
-if (log)
-  log->PutCString("Couldn't find result variable");
+LLDB_LOG(log, "Couldn't find result variable");
 
 return true;
   }
@@ -197,8 +196,7 @@ bool IRForTarget::CreateResultVariable(l
   Value *result_value = m_module->getNamedValue(result_name);
 
   if (!result_value) {
-if (log)
-  log->PutCString("Result variable had no data");
+LLDB_LOG(log, "Result variable had no data");
 
 m_error_stream.Format("Internal error [IRForTarget]: Result variable's "
   "name ({0}) exists, but not its definition\n",
@@ -207,14 +205,13 @@ bool IRForTarget::CreateResultVariable(l
 return false;
   }
 
-  LLDB_LOGF(log, "Found result in the IR: \"%s\"",
-PrintValue(result_value, false).c_str());
+  LLDB_LOG(log, "Found result in the IR: \"{0}\"",
+   PrintValue(result_value, false));
 
   GlobalVariable *result_global = dyn_cast(result_value);
 
   if (!result_global) {
-if (log)
-  log->PutCString("Result variable isn't a GlobalVariable");
+LLDB_LOG(log, "Result variable isn't a GlobalVariable");
 
 m_error_stream.Format("Internal error [IRForTarget]: Result variable ({0}) 
"
   "is defined, but is not a global variable\n",
@@ -225,8 +222,7 @@ bool IRForTarget::CreateResultVariable(l
 
   clang::NamedDecl *result_decl = DeclForGlobal(result_global);
   if (!result_decl) {
-if (log)
-  log->PutCString("Result variable doesn't have a corresponding Decl");
+LLDB_LOG(log, "Result variable doesn't have a corresponding Decl");
 
 m_error_stream.Format("Internal error [IRForTarget]: Result variable ({0}) 
"
   "does not have a corresponding Clang entity\n",
@@ -241,13 +237,12 @@ bool IRForTarget::CreateResultVariable(l
 result_decl->print(decl_desc_stream);
 decl_desc_stream.flush();
 
-LLDB_LOGF(log, "Found result decl: \"%s\"", decl_desc_str.c_str());
+LLDB_LOG(log, "Found result decl: \"{0}\"", decl_desc_str);
   }
 
   clang::VarDecl *result_var = dyn_cast(result_decl);
   if (!result_var) {
-if (log)
-  log->PutCString("Result variable Decl isn't a VarDecl");
+LLDB_LOG(log, "Result variable Decl isn't a VarDecl");
 
 m_error_stream.Format("Internal error [IRForTarget]: Result variable "
   "({0})'s corresponding Clang entity isn't a "
@@ -287,8 +282,7 @@ bool IRForTarget::CreateResultVariable(l
   lldb_private::ClangASTContext::GetASTContext(
   &result_decl->getASTContext()));
 } else {
-  if (log)
-log->PutCString("Expected result to have pointer type, but it did 
not");
+  LLDB_LOG(log, "Expected result to have pointer type, but it did not");
 
   m_error_stream.Format("Internal error [IRForTarget]: Lvalue result ({0}) 
"
 "is not a pointer variable\n",
@@ -311,7 +305,7 @@ bool IRForTarget::CreateResultVariable(l
 lldb_private::StreamString type_desc_stream;
 m_result_type.DumpTypeDescription(&type_desc_stream);
 
-LLDB_LOGF(log, "Result type has unknown size");
+LLDB_LOG(log, "Result type has unknown size");
 
 m_error_stream.Printf("Error [IRForTarget]: Size of result type '%s' "
   "couldn't be determined\n",
@@ -323,14 +317,13 @@ bool IRForTarget::CreateResultVariable(l
 lldb_private::StreamString type_desc_stream;
 m_result_type.DumpTypeDescription(&type_desc_stream);
 
-LLDB_LOGF(log, "Result decl type: \"%s\"", type_desc_stream.GetData());
+LLDB_LOG(log, "Result decl type: \"{0}\"", type_desc_stream.GetData());
   }
 
   m_result_name = lldb_private::ConstString("$RESULT_NAME");
 
-  LLDB_LOGF(log, "Creating a new result global: \"%s\" with size 0x%" PRIx64,
-m_result_name.GetCString(),
-m_result_type.GetByteSize(nullptr).getValueOr(0));
+  LLDB_LOG(log, "Creating a new result global: \"{0}\" with size {1}",
+   m_result_name, m_result_type.GetByteSize(nullptr).getValueOr(0));
 
   // Construct a new result global and set up its metadata
 
@@ -362,9 +355,8 @@ bool IRForTarget::CreateResultVariable(l
   m_module->g

[Lldb-commits] [lldb] r368417 - [lldb] Refactor guard variable checks in IRForTarget

2019-08-09 Thread Raphael Isemann via lldb-commits
Author: teemperor
Date: Fri Aug  9 02:27:04 2019
New Revision: 368417

URL: http://llvm.org/viewvc/llvm-project?rev=368417&view=rev
Log:
[lldb] Refactor guard variable checks in IRForTarget

Not NFC as this will probably fix a wrong guard variable check
on Windows. Not sure though what Windows test can now be safely
enabled.

Modified:
lldb/trunk/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp

Modified: lldb/trunk/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp?rev=368417&r1=368416&r2=368417&view=diff
==
--- lldb/trunk/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp (original)
+++ lldb/trunk/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp Fri Aug  9 
02:27:04 2019
@@ -153,6 +153,12 @@ clang::NamedDecl *IRForTarget::DeclForGl
   return DeclForGlobal(global_val, m_module);
 }
 
+/// Returns true iff the mangled symbol is for a static guard variable.
+static bool isGuardVariableSymbol(llvm::StringRef mangled_symbol) {
+  return mangled_symbol.startswith("_ZGV") || // Itanium ABI guard variable
+ mangled_symbol.startswith("@4IA");   // Microsoft ABI guard variable
+}
+
 bool IRForTarget::CreateResultVariable(llvm::Function &llvm_function) {
   lldb_private::Log *log(
   lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS));
@@ -171,14 +177,14 @@ bool IRForTarget::CreateResultVariable(l
 result_name = value_symbol.first();
 
 if (result_name.contains("$__lldb_expr_result_ptr") &&
-!result_name.startswith("_ZGV")) {
+!isGuardVariableSymbol(result_name)) {
   found_result = true;
   m_result_is_pointer = true;
   break;
 }
 
 if (result_name.contains("$__lldb_expr_result") &&
-!result_name.startswith("_ZGV")) {
+!isGuardVariableSymbol(result_name)) {
   found_result = true;
   m_result_is_pointer = false;
   break;
@@ -1529,14 +1535,12 @@ bool IRForTarget::ResolveExternals(Funct
 }
 
 static bool isGuardVariableRef(Value *V) {
-  Constant *Old = nullptr;
+  Constant *Old = dyn_cast(V);
 
-  if (!(Old = dyn_cast(V)))
+  if (!Old)
 return false;
 
-  ConstantExpr *CE = nullptr;
-
-  if ((CE = dyn_cast(V))) {
+  if (auto CE = dyn_cast(V)) {
 if (CE->getOpcode() != Instruction::BitCast)
   return false;
 
@@ -1545,12 +1549,8 @@ static bool isGuardVariableRef(Value *V)
 
   GlobalVariable *GV = dyn_cast(Old);
 
-  if (!GV || !GV->hasName() ||
-  (!GV->getName().startswith("_ZGV") && // Itanium ABI guard variable
-   !GV->getName().endswith("@4IA")))// Microsoft ABI guard variable
-  {
+  if (!GV || !GV->hasName() || !isGuardVariableSymbol(GV->getName()))
 return false;
-  }
 
   return true;
 }


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


[Lldb-commits] [lldb] r368424 - [lldb][NFC] Fix warning about missing switch cases

2019-08-09 Thread Raphael Isemann via lldb-commits
Author: teemperor
Date: Fri Aug  9 02:58:47 2019
New Revision: 368424

URL: http://llvm.org/viewvc/llvm-project?rev=368424&view=rev
Log:
[lldb][NFC] Fix warning about missing switch cases

These types were recently added in D62960 but it seems the patch didn't
consider LLDB which causes a bunch of compiler warnings about
missing enum values. It seems this feature isn't fully implemented yet,
so I don't think we can write any test for this. For now lets just add
the missing types to our usual list of unsupported types.

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=368424&r1=368423&r2=368424&view=diff
==
--- lldb/trunk/source/Symbol/ClangASTContext.cpp (original)
+++ lldb/trunk/source/Symbol/ClangASTContext.cpp Fri Aug  9 02:58:47 2019
@@ -5258,6 +5258,20 @@ lldb::Encoding ClangASTContext::GetEncod
 case clang::BuiltinType::OCLIntelSubgroupAVCImeSingleRefStreamin:
 case clang::BuiltinType::OCLIntelSubgroupAVCImeDualRefStreamin:
   break;
+
+case clang::BuiltinType::SveBool:
+case clang::BuiltinType::SveInt8:
+case clang::BuiltinType::SveInt16:
+case clang::BuiltinType::SveInt32:
+case clang::BuiltinType::SveInt64:
+case clang::BuiltinType::SveUint8:
+case clang::BuiltinType::SveUint16:
+case clang::BuiltinType::SveUint32:
+case clang::BuiltinType::SveUint64:
+case clang::BuiltinType::SveFloat16:
+case clang::BuiltinType::SveFloat32:
+case clang::BuiltinType::SveFloat64:
+  break;
 }
 break;
   // All pointer types are represented as unsigned integer encodings. We may


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


[Lldb-commits] [lldb] r368425 - [lldb][NFC] Unify InstrList typedef in IRForTarget

2019-08-09 Thread Raphael Isemann via lldb-commits
Author: teemperor
Date: Fri Aug  9 03:01:51 2019
New Revision: 368425

URL: http://llvm.org/viewvc/llvm-project?rev=368425&view=rev
Log:
[lldb][NFC] Unify InstrList typedef in IRForTarget

Modified:
lldb/trunk/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp

Modified: lldb/trunk/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp?rev=368425&r1=368424&r2=368425&view=diff
==
--- lldb/trunk/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp (original)
+++ lldb/trunk/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp Fri Aug  9 
03:01:51 2019
@@ -43,6 +43,8 @@ using namespace llvm;
 
 static char ID;
 
+typedef SmallVector InstrList;
+
 IRForTarget::FunctionValueCache::FunctionValueCache(Maker const &maker)
 : m_maker(maker), m_values() {}
 
@@ -885,7 +887,6 @@ bool IRForTarget::RewriteObjCSelector(In
 bool IRForTarget::RewriteObjCSelectors(BasicBlock &basic_block) {
   lldb_private::Log *log(
   lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS));
-  typedef SmallVector InstrList;
 
   InstrList selector_loads;
 
@@ -1038,8 +1039,6 @@ bool IRForTarget::RewriteObjCClassRefere
   lldb_private::Log *log(
   lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS));
 
-  typedef SmallVector InstrList;
-
   InstrList class_loads;
 
   for (Instruction &inst : basic_block) {
@@ -1139,8 +1138,6 @@ bool IRForTarget::RewritePersistentAlloc
   lldb_private::Log *log(
   lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS));
 
-  typedef SmallVector InstrList;
-
   InstrList pvar_allocs;
 
   for (Instruction &inst : basic_block) {
@@ -1567,7 +1564,6 @@ static void ExciseGuardStore(Instruction
 
 bool IRForTarget::RemoveGuards(BasicBlock &basic_block) {
   // Eliminate any reference to guard variables found.
-  typedef SmallVector InstrList;
 
   InstrList guard_loads;
   InstrList guard_stores;


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


[Lldb-commits] [lldb] r368442 - [lldb][NFC] Remove unused IRForTarget::BuildRelocation

2019-08-09 Thread Raphael Isemann via lldb-commits
Author: teemperor
Date: Fri Aug  9 07:21:27 2019
New Revision: 368442

URL: http://llvm.org/viewvc/llvm-project?rev=368442&view=rev
Log:
[lldb][NFC] Remove unused IRForTarget::BuildRelocation

Modified:
lldb/trunk/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp
lldb/trunk/source/Plugins/ExpressionParser/Clang/IRForTarget.h

Modified: lldb/trunk/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp?rev=368442&r1=368441&r2=368442&view=diff
==
--- lldb/trunk/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp (original)
+++ lldb/trunk/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp Fri Aug  9 
07:21:27 2019
@@ -1896,28 +1896,6 @@ bool IRForTarget::ReplaceVariables(Funct
   return true;
 }
 
-llvm::Constant *IRForTarget::BuildRelocation(llvm::Type *type,
- uint64_t offset) {
-  llvm::Constant *offset_int = ConstantInt::get(m_intptr_ty, offset);
-
-  llvm::Constant *offset_array[1];
-
-  offset_array[0] = offset_int;
-
-  llvm::ArrayRef offsets(offset_array, 1);
-  llvm::Type *char_type = llvm::Type::getInt8Ty(m_module->getContext());
-  llvm::Type *char_pointer_type = char_type->getPointerTo();
-
-  llvm::Constant *reloc_placeholder_bitcast =
-  ConstantExpr::getBitCast(m_reloc_placeholder, char_pointer_type);
-  llvm::Constant *reloc_getelementptr = ConstantExpr::getGetElementPtr(
-  char_type, reloc_placeholder_bitcast, offsets);
-  llvm::Constant *reloc_bitcast =
-  ConstantExpr::getBitCast(reloc_getelementptr, type);
-
-  return reloc_bitcast;
-}
-
 bool IRForTarget::runOnModule(Module &llvm_module) {
   lldb_private::Log *log(
   lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS));

Modified: lldb/trunk/source/Plugins/ExpressionParser/Clang/IRForTarget.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ExpressionParser/Clang/IRForTarget.h?rev=368442&r1=368441&r2=368442&view=diff
==
--- lldb/trunk/source/Plugins/ExpressionParser/Clang/IRForTarget.h (original)
+++ lldb/trunk/source/Plugins/ExpressionParser/Clang/IRForTarget.h Fri Aug  9 
07:21:27 2019
@@ -539,20 +539,6 @@ private:
  FunctionValueCache &entry_instruction_finder,
  lldb_private::Stream &error_stream);
 
-  /// Construct a reference to m_reloc_placeholder with a given type and
-  /// offset.  This typically happens after inserting data into
-  /// m_data_allocator.
-  ///
-  /// \param[in] type
-  /// The type of the value being loaded.
-  ///
-  /// \param[in] offset
-  /// The offset of the value from the base of m_data_allocator.
-  ///
-  /// \return
-  /// The Constant for the reference, usually a ConstantExpr.
-  llvm::Constant *BuildRelocation(llvm::Type *type, uint64_t offset);
-
   /// Commit the allocation in m_data_allocator and use its final location to
   /// replace m_reloc_placeholder.
   ///


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


[Lldb-commits] [lldb] r368444 - [lldb][NFC] Assert on invalid cursors positions when creating CompletionRequest

2019-08-09 Thread Raphael Isemann via lldb-commits
Author: teemperor
Date: Fri Aug  9 07:32:50 2019
New Revision: 368444

URL: http://llvm.org/viewvc/llvm-project?rev=368444&view=rev
Log:
[lldb][NFC] Assert on invalid cursors positions when creating CompletionRequest

Before we just triggered undefined behavior on invalid positions.

Modified:
lldb/trunk/source/Utility/CompletionRequest.cpp

Modified: lldb/trunk/source/Utility/CompletionRequest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Utility/CompletionRequest.cpp?rev=368444&r1=368443&r2=368444&view=diff
==
--- lldb/trunk/source/Utility/CompletionRequest.cpp (original)
+++ lldb/trunk/source/Utility/CompletionRequest.cpp Fri Aug  9 07:32:50 2019
@@ -16,6 +16,7 @@ CompletionRequest::CompletionRequest(llv
  CompletionResult &result)
 : m_command(command_line), m_raw_cursor_pos(raw_cursor_pos),
   m_result(result) {
+  assert(raw_cursor_pos <= command_line.size() && "Out of bounds cursor?");
 
   // We parse the argument up to the cursor, so the last argument in
   // parsed_line is the one containing the cursor, and the cursor is after the


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


[Lldb-commits] [lldb] r368511 - [lldb] Fix dynamic_cast by no longer failing on variable without metadata

2019-08-10 Thread Raphael Isemann via lldb-commits
Author: teemperor
Date: Sat Aug 10 03:56:17 2019
New Revision: 368511

URL: http://llvm.org/viewvc/llvm-project?rev=368511&view=rev
Log:
[lldb] Fix dynamic_cast by no longer failing on variable without metadata

Summary:
Our IR rewriting infrastructure currently fails when it encounters a variable 
which has no metadata associated.
This causes dynamic_cast to fail as in this case IRForTarget considers the type 
info pointers ('@_ZTI...') to be
variables without associated metadata. As there are no variables for these 
internal variables, this is actually
not an error and dynamic_cast would work fine if we didn't throw this error.

This patch fixes this by removing this diagnostics code. In case we would 
actually hit a variable that has no
metadata (but is supposed to have), we still have the error in the expression 
log so this shouldn't make it
harder to diagnose any missing metadata errors.

This patch should fix dynamic_cast and also adds a bunch of test coverage to 
that language feature.

Fixes rdar://10813639

Reviewers: davide, labath

Reviewed By: labath

Subscribers: friss, labath, abidh, lldb-commits

Tags: #lldb

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

Added:
lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/dynamic_cast/
lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/dynamic_cast/ExtBase.cpp
lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/dynamic_cast/ExtBase.h
lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/dynamic_cast/Makefile

lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/dynamic_cast/TestDynamicCast.py
lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/dynamic_cast/main.cpp
Modified:
lldb/trunk/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp

Added: 
lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/dynamic_cast/ExtBase.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/dynamic_cast/ExtBase.cpp?rev=368511&view=auto
==
--- lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/dynamic_cast/ExtBase.cpp 
(added)
+++ lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/dynamic_cast/ExtBase.cpp 
Sat Aug 10 03:56:17 2019
@@ -0,0 +1,5 @@
+#include "ExtBase.h"
+
+char ExtBase::bar() {
+  return 'x';
+}

Added: lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/dynamic_cast/ExtBase.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/dynamic_cast/ExtBase.h?rev=368511&view=auto
==
--- lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/dynamic_cast/ExtBase.h 
(added)
+++ lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/dynamic_cast/ExtBase.h 
Sat Aug 10 03:56:17 2019
@@ -0,0 +1,3 @@
+class ExtBase {
+  virtual char bar();
+};

Added: lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/dynamic_cast/Makefile
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/dynamic_cast/Makefile?rev=368511&view=auto
==
--- lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/dynamic_cast/Makefile 
(added)
+++ lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/dynamic_cast/Makefile 
Sat Aug 10 03:56:17 2019
@@ -0,0 +1,3 @@
+LEVEL = ../../../make
+CXX_SOURCES := main.cpp ExtBase.cpp
+include $(LEVEL)/Makefile.rules

Added: 
lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/dynamic_cast/TestDynamicCast.py
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/dynamic_cast/TestDynamicCast.py?rev=368511&view=auto
==
--- 
lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/dynamic_cast/TestDynamicCast.py
 (added)
+++ 
lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/dynamic_cast/TestDynamicCast.py
 Sat Aug 10 03:56:17 2019
@@ -0,0 +1,3 @@
+from lldbsuite.test import lldbinline
+
+lldbinline.MakeInlineTest(__file__, globals(), [])

Added: lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/dynamic_cast/main.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/dynamic_cast/main.cpp?rev=368511&view=auto
==
--- lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/dynamic_cast/main.cpp 
(added)
+++ lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/dynamic_cast/main.cpp 
Sat Aug 10 03:56:17 2019
@@ -0,0 +1,51 @@
+#include "ExtBase.h"
+
+class Base {
+public:
+  virtual char foo() {
+return 'b';
+  }
+};
+
+class Derived : public Base {
+public:
+  char foo() override {
+return 'd';
+  }
+};
+
+class NonOverrideDerived : public Base {
+};
+
+class ExtDerived : public ExtBase {
+public:
+  char bar() override {
+return 'y';
+  }
+};
+
+int main() {
+  Derived d;
+  NonOverrideDer

[Lldb-commits] [lldb] r368567 - [lldb][NFC] Add unit test for lldb_private::DiagnosticManager

2019-08-12 Thread Raphael Isemann via lldb-commits
Author: teemperor
Date: Mon Aug 12 06:31:45 2019
New Revision: 368567

URL: http://llvm.org/viewvc/llvm-project?rev=368567&view=rev
Log:
[lldb][NFC] Add unit test for lldb_private::DiagnosticManager

Added:
lldb/trunk/unittests/Expression/DiagnosticManagerTest.cpp
Modified:
lldb/trunk/unittests/Expression/CMakeLists.txt

Modified: lldb/trunk/unittests/Expression/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/unittests/Expression/CMakeLists.txt?rev=368567&r1=368566&r2=368567&view=diff
==
--- lldb/trunk/unittests/Expression/CMakeLists.txt (original)
+++ lldb/trunk/unittests/Expression/CMakeLists.txt Mon Aug 12 06:31:45 2019
@@ -1,4 +1,5 @@
 add_lldb_unittest(ExpressionTests
+  DiagnosticManagerTest.cpp
   DWARFExpressionTest.cpp
   ClangParserTest.cpp
 

Added: lldb/trunk/unittests/Expression/DiagnosticManagerTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/unittests/Expression/DiagnosticManagerTest.cpp?rev=368567&view=auto
==
--- lldb/trunk/unittests/Expression/DiagnosticManagerTest.cpp (added)
+++ lldb/trunk/unittests/Expression/DiagnosticManagerTest.cpp Mon Aug 12 
06:31:45 2019
@@ -0,0 +1,194 @@
+//===-- DiagnosticManagerTest.cpp *- 
C++-*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "lldb/Expression/DiagnosticManager.h"
+#include "gtest/gtest.h"
+
+using namespace lldb_private;
+
+static const uint32_t custom_diag_id = 42;
+
+namespace {
+class FixItDiag : public Diagnostic {
+  bool m_has_fixits;
+
+public:
+  FixItDiag(llvm::StringRef msg, bool has_fixits)
+  : Diagnostic(msg, DiagnosticSeverity::eDiagnosticSeverityError,
+   DiagnosticOrigin::eDiagnosticOriginLLDB, custom_diag_id),
+m_has_fixits(has_fixits) {}
+  bool HasFixIts() const override { return m_has_fixits; }
+};
+} // namespace
+
+namespace {
+class TextDiag : public Diagnostic {
+public:
+  TextDiag(llvm::StringRef msg, DiagnosticSeverity severity)
+  : Diagnostic(msg, severity, DiagnosticOrigin::eDiagnosticOriginLLDB,
+   custom_diag_id) {}
+};
+} // namespace
+
+TEST(DiagnosticManagerTest, AddDiagnostic) {
+  DiagnosticManager mgr;
+  EXPECT_EQ(0U, mgr.Diagnostics().size());
+
+  Diagnostic *diag = new Diagnostic(
+  "foo bar has happened", DiagnosticSeverity::eDiagnosticSeverityError,
+  DiagnosticOrigin::eDiagnosticOriginLLDB, custom_diag_id);
+  mgr.AddDiagnostic(diag);
+  EXPECT_EQ(1U, mgr.Diagnostics().size());
+  Diagnostic *got = mgr.Diagnostics().front();
+  EXPECT_EQ(diag->getKind(), got->getKind());
+  EXPECT_EQ(diag->GetMessage(), got->GetMessage());
+  EXPECT_EQ(diag->GetSeverity(), got->GetSeverity());
+  EXPECT_EQ(diag->GetCompilerID(), got->GetCompilerID());
+  EXPECT_EQ(diag->HasFixIts(), got->HasFixIts());
+}
+
+TEST(DiagnosticManagerTest, HasFixits) {
+  DiagnosticManager mgr;
+  // By default we shouldn't have any fixits.
+  EXPECT_FALSE(mgr.HasFixIts());
+  // Adding a diag without fixits shouldn't make HasFixIts return true.
+  mgr.AddDiagnostic(new FixItDiag("no fixit", false));
+  EXPECT_FALSE(mgr.HasFixIts());
+  // Adding a diag with fixits will mark the manager as containing fixits.
+  mgr.AddDiagnostic(new FixItDiag("fixit", true));
+  EXPECT_TRUE(mgr.HasFixIts());
+  // Adding another diag without fixit shouldn't make it return false.
+  mgr.AddDiagnostic(new FixItDiag("no fixit", false));
+  EXPECT_TRUE(mgr.HasFixIts());
+  // Adding a diag with fixits. The manager should still return true.
+  mgr.AddDiagnostic(new FixItDiag("fixit", true));
+  EXPECT_TRUE(mgr.HasFixIts());
+}
+
+TEST(DiagnosticManagerTest, GetStringNoDiags) {
+  DiagnosticManager mgr;
+  EXPECT_EQ("", mgr.GetString());
+}
+
+TEST(DiagnosticManagerTest, GetStringBasic) {
+  DiagnosticManager mgr;
+  mgr.AddDiagnostic(new TextDiag("abc", eDiagnosticSeverityError));
+  EXPECT_EQ("error: abc\n", mgr.GetString());
+}
+
+TEST(DiagnosticManagerTest, GetStringMultiline) {
+  DiagnosticManager mgr;
+
+  // Multiline diagnostics should only get one severity label.
+  mgr.AddDiagnostic(new TextDiag("b\nc", eDiagnosticSeverityError));
+  EXPECT_EQ("error: b\nc\n", mgr.GetString());
+}
+
+TEST(DiagnosticManagerTest, GetStringMultipleDiags) {
+  DiagnosticManager mgr;
+  mgr.AddDiagnostic(new TextDiag("abc", eDiagnosticSeverityError));
+  EXPECT_EQ("error: abc\n", mgr.GetString());
+  mgr.AddDiagnostic(new TextDiag("def", eDiagnosticSeverityError));
+  EXPECT_EQ("error: abc\nerror: def\n", mgr.GetString());
+}
+
+TEST(DiagnosticManagerTest, GetStringSeverityLabels) {
+  DiagnosticManager mgr;
+
+  // Different seve

[Lldb-commits] [lldb] r368577 - [lldb] Remove undocumented return value from DiagnosticManager::PutString

2019-08-12 Thread Raphael Isemann via lldb-commits
Author: teemperor
Date: Mon Aug 12 07:11:37 2019
New Revision: 368577

URL: http://llvm.org/viewvc/llvm-project?rev=368577&view=rev
Log:
[lldb] Remove undocumented return value from DiagnosticManager::PutString

The returned value is currently unused. It also seems to imply that
it somehow represents 'printf-style' the number of characters/bytes
written to some output stream (which is incorrect, as we only know
the actual size of the written message when we have rendered it,
e.g. via GetString and DiagnosticManagers have no associated
output stream).

Modified:
lldb/trunk/include/lldb/Expression/DiagnosticManager.h
lldb/trunk/source/Expression/DiagnosticManager.cpp

Modified: lldb/trunk/include/lldb/Expression/DiagnosticManager.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Expression/DiagnosticManager.h?rev=368577&r1=368576&r2=368577&view=diff
==
--- lldb/trunk/include/lldb/Expression/DiagnosticManager.h (original)
+++ lldb/trunk/include/lldb/Expression/DiagnosticManager.h Mon Aug 12 07:11:37 
2019
@@ -127,7 +127,7 @@ public:
 
   size_t Printf(DiagnosticSeverity severity, const char *format, ...)
   __attribute__((format(printf, 3, 4)));
-  size_t PutString(DiagnosticSeverity severity, llvm::StringRef str);
+  void PutString(DiagnosticSeverity severity, llvm::StringRef str);
 
   void AppendMessageToDiagnostic(llvm::StringRef str) {
 if (!m_diagnostics.empty()) {

Modified: lldb/trunk/source/Expression/DiagnosticManager.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/DiagnosticManager.cpp?rev=368577&r1=368576&r2=368577&view=diff
==
--- lldb/trunk/source/Expression/DiagnosticManager.cpp (original)
+++ lldb/trunk/source/Expression/DiagnosticManager.cpp Mon Aug 12 07:11:37 2019
@@ -70,10 +70,9 @@ size_t DiagnosticManager::Printf(Diagnos
   return result;
 }
 
-size_t DiagnosticManager::PutString(DiagnosticSeverity severity,
-llvm::StringRef str) {
+void DiagnosticManager::PutString(DiagnosticSeverity severity,
+  llvm::StringRef str) {
   if (str.empty())
-return 0;
+return;
   AddDiagnostic(str, severity, eDiagnosticOriginLLDB);
-  return str.size();
 }


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


[Lldb-commits] [lldb] r368582 - [lldb][NFC] Minor fixes for lldb_private::DiagnosticManager

2019-08-12 Thread Raphael Isemann via lldb-commits
Author: teemperor
Date: Mon Aug 12 07:37:12 2019
New Revision: 368582

URL: http://llvm.org/viewvc/llvm-project?rev=368582&view=rev
Log:
[lldb][NFC] Minor fixes for lldb_private::DiagnosticManager

Modified:
lldb/trunk/include/lldb/Expression/DiagnosticManager.h

Modified: lldb/trunk/include/lldb/Expression/DiagnosticManager.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Expression/DiagnosticManager.h?rev=368582&r1=368581&r2=368582&view=diff
==
--- lldb/trunk/include/lldb/Expression/DiagnosticManager.h (original)
+++ lldb/trunk/include/lldb/Expression/DiagnosticManager.h Mon Aug 12 07:37:12 
2019
@@ -106,7 +106,7 @@ public:
 }
   }
 
-  bool HasFixIts() {
+  bool HasFixIts() const {
 for (Diagnostic *diag : m_diagnostics) {
   if (diag->HasFixIts())
 return true;
@@ -130,9 +130,8 @@ public:
   void PutString(DiagnosticSeverity severity, llvm::StringRef str);
 
   void AppendMessageToDiagnostic(llvm::StringRef str) {
-if (!m_diagnostics.empty()) {
+if (!m_diagnostics.empty())
   m_diagnostics.back()->AppendMessage(str);
-}
   }
 
   // Returns a string containing errors in this format:
@@ -149,7 +148,6 @@ public:
   // Moves fixed_expression to the internal storage.
   void SetFixedExpression(std::string fixed_expression) {
 m_fixed_expression = std::move(fixed_expression);
-fixed_expression.clear();
   }
 
 protected:


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


[Lldb-commits] [lldb] r368679 - [lldb][NFC] Add basic IOHandler completion test

2019-08-13 Thread Raphael Isemann via lldb-commits
Author: teemperor
Date: Tue Aug 13 05:12:19 2019
New Revision: 368679

URL: http://llvm.org/viewvc/llvm-project?rev=368679&view=rev
Log:
[lldb][NFC] Add basic IOHandler completion test

We have no test coverage for the IOHandler code that is doing the
completion in the command line. This is adding a pexpect-based test
as a preparation for the switch to using CompletionRequest in the
whole completion machinery.

Added:
lldb/trunk/packages/Python/lldbsuite/test/iohandler/
lldb/trunk/packages/Python/lldbsuite/test/iohandler/completion/

lldb/trunk/packages/Python/lldbsuite/test/iohandler/completion/TestIOHandlerCompletion.py
lldb/trunk/packages/Python/lldbsuite/test/iohandler/completion/main.c

Added: 
lldb/trunk/packages/Python/lldbsuite/test/iohandler/completion/TestIOHandlerCompletion.py
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/iohandler/completion/TestIOHandlerCompletion.py?rev=368679&view=auto
==
--- 
lldb/trunk/packages/Python/lldbsuite/test/iohandler/completion/TestIOHandlerCompletion.py
 (added)
+++ 
lldb/trunk/packages/Python/lldbsuite/test/iohandler/completion/TestIOHandlerCompletion.py
 Tue Aug 13 05:12:19 2019
@@ -0,0 +1,58 @@
+"""
+Test completion in our IOHandlers.
+"""
+
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+
+class IOHandlerCompletionTest(TestBase):
+
+mydir = TestBase.compute_mydir(__file__)
+NO_DEBUG_INFO_TESTCASE = True
+
+def setUp(self):
+TestBase.setUp(self)
+
+def expect_string(self, string):
+import pexpect
+"""This expects for "string", with timeout & EOF being test fails."""
+try:
+self.child.expect_exact(string)
+except pexpect.EOF:
+self.fail("Got EOF waiting for '%s'" % (string))
+except pexpect.TIMEOUT:
+self.fail("Timed out waiting for '%s'" % (string))
+
+@expectedFailureAll(
+oslist=["windows"],
+bugnumber="llvm.org/pr22274: need a pexpect replacement for windows")
+def test_completion(self):
+self.setTearDownCleanup()
+
+import pexpect
+exe = self.getBuildArtifact("a.out")
+prompt = "(lldb) "
+
+self.child = pexpect.spawn(
+'%s %s %s %s' %
+(lldbtest_config.lldbExec, self.lldbOption, "", exe))
+
+self.expect_string(prompt)
+self.child.send("\t\t\t")
+self.expect_string("register")
+
+self.child.send("regi\t")
+self.expect_string(prompt + "register")
+self.child.send("\n")
+
+self.child.send("\t")
+self.expect_string("More (Y/n/a)")
+self.child.send("n")
+self.expect_string(prompt)
+
+# Shouldn't crash or anything like that.
+self.child.send("regoinvalid\t")
+self.expect_string(prompt)
+
+self.deletePexpectChild()

Added: lldb/trunk/packages/Python/lldbsuite/test/iohandler/completion/main.c
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/iohandler/completion/main.c?rev=368679&view=auto
==
--- lldb/trunk/packages/Python/lldbsuite/test/iohandler/completion/main.c 
(added)
+++ lldb/trunk/packages/Python/lldbsuite/test/iohandler/completion/main.c Tue 
Aug 13 05:12:19 2019
@@ -0,0 +1,5 @@
+int main(int argc, char **argv) {
+  lldb_enable_attach();
+  int to_complete = 0;
+  return to_complete;
+}


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


[Lldb-commits] [lldb] r368688 - [lldb] Reland "Refactor guard variable checks in IRForTarget"

2019-08-13 Thread Raphael Isemann via lldb-commits
Author: teemperor
Date: Tue Aug 13 06:09:18 2019
New Revision: 368688

URL: http://llvm.org/viewvc/llvm-project?rev=368688&view=rev
Log:
[lldb] Reland "Refactor guard variable checks in IRForTarget"

It seems the broken guard variable check for Windows was a feature(TM)
and not a bug, so let's keep add a flag to the guard check that keeps
the old behavior in the places where we ignored guard variables before.

Modified:
lldb/trunk/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp

Modified: lldb/trunk/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp?rev=368688&r1=368687&r2=368688&view=diff
==
--- lldb/trunk/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp (original)
+++ lldb/trunk/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp Tue Aug 13 
06:09:18 2019
@@ -155,6 +155,15 @@ clang::NamedDecl *IRForTarget::DeclForGl
   return DeclForGlobal(global_val, m_module);
 }
 
+/// Returns true iff the mangled symbol is for a static guard variable.
+static bool isGuardVariableSymbol(llvm::StringRef mangled_symbol,
+  bool check_ms_abi = true) {
+  bool result = mangled_symbol.startswith("_ZGV"); // Itanium ABI guard 
variable
+  if (check_ms_abi)
+result |= mangled_symbol.startswith("@4IA"); // Microsoft ABI
+  return result;
+}
+
 bool IRForTarget::CreateResultVariable(llvm::Function &llvm_function) {
   lldb_private::Log *log(
   lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS));
@@ -172,15 +181,17 @@ bool IRForTarget::CreateResultVariable(l
   for (StringMapEntry &value_symbol : value_symbol_table) {
 result_name = value_symbol.first();
 
-if (result_name.contains("$__lldb_expr_result_ptr") &&
-!result_name.startswith("_ZGV")) {
+// Check if this is a guard variable. It seems this causes some hiccups
+// on Windows, so let's only check for Itanium guard variables.
+bool is_guard_var = isGuardVariableSymbol(result_name, /*MS ABI*/ false);
+
+if (result_name.contains("$__lldb_expr_result_ptr") && !is_guard_var) {
   found_result = true;
   m_result_is_pointer = true;
   break;
 }
 
-if (result_name.contains("$__lldb_expr_result") &&
-!result_name.startswith("_ZGV")) {
+if (result_name.contains("$__lldb_expr_result") && !is_guard_var) {
   found_result = true;
   m_result_is_pointer = false;
   break;
@@ -1528,14 +1539,12 @@ bool IRForTarget::ResolveExternals(Funct
 }
 
 static bool isGuardVariableRef(Value *V) {
-  Constant *Old = nullptr;
+  Constant *Old = dyn_cast(V);
 
-  if (!(Old = dyn_cast(V)))
+  if (!Old)
 return false;
 
-  ConstantExpr *CE = nullptr;
-
-  if ((CE = dyn_cast(V))) {
+  if (auto CE = dyn_cast(V)) {
 if (CE->getOpcode() != Instruction::BitCast)
   return false;
 
@@ -1544,12 +1553,8 @@ static bool isGuardVariableRef(Value *V)
 
   GlobalVariable *GV = dyn_cast(Old);
 
-  if (!GV || !GV->hasName() ||
-  (!GV->getName().startswith("_ZGV") && // Itanium ABI guard variable
-   !GV->getName().endswith("@4IA")))// Microsoft ABI guard variable
-  {
+  if (!GV || !GV->hasName() || !isGuardVariableSymbol(GV->getName()))
 return false;
-  }
 
   return true;
 }


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


[Lldb-commits] [lldb] r368695 - [lldb] Fix Microsoft guard variable detection

2019-08-13 Thread Raphael Isemann via lldb-commits
Author: teemperor
Date: Tue Aug 13 07:13:39 2019
New Revision: 368695

URL: http://llvm.org/viewvc/llvm-project?rev=368695&view=rev
Log:
[lldb] Fix Microsoft guard variable detection

Apparently we need to check for a suffix, not a prefix. This broke
probably broke expression evaluation on Windows.

Modified:
lldb/trunk/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp

Modified: lldb/trunk/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp?rev=368695&r1=368694&r2=368695&view=diff
==
--- lldb/trunk/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp (original)
+++ lldb/trunk/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp Tue Aug 13 
07:13:39 2019
@@ -160,7 +160,7 @@ static bool isGuardVariableSymbol(llvm::
   bool check_ms_abi = true) {
   bool result = mangled_symbol.startswith("_ZGV"); // Itanium ABI guard 
variable
   if (check_ms_abi)
-result |= mangled_symbol.startswith("@4IA"); // Microsoft ABI
+result |= mangled_symbol.endswith("@4IA"); // Microsoft ABI
   return result;
 }
 


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


[Lldb-commits] [lldb] r368802 - [lldb] Reinstate original guard variable check

2019-08-13 Thread Raphael Isemann via lldb-commits
Author: teemperor
Date: Tue Aug 13 22:52:33 2019
New Revision: 368802

URL: http://llvm.org/viewvc/llvm-project?rev=368802&view=rev
Log:
[lldb] Reinstate original guard variable check

The isGuardVariableSymbol option for ignoring Microsoft's ABI
was originally added to get the bots green, but now that we found
the actual issue (that we checked for prefix instead of suffix
in the MS ABI check), we should be able to properly implement
the guard variable check without any strange Microsoft exceptions.

Modified:
lldb/trunk/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp

Modified: lldb/trunk/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp?rev=368802&r1=368801&r2=368802&view=diff
==
--- lldb/trunk/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp (original)
+++ lldb/trunk/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp Tue Aug 13 
22:52:33 2019
@@ -156,12 +156,9 @@ clang::NamedDecl *IRForTarget::DeclForGl
 }
 
 /// Returns true iff the mangled symbol is for a static guard variable.
-static bool isGuardVariableSymbol(llvm::StringRef mangled_symbol,
-  bool check_ms_abi = true) {
-  bool result = mangled_symbol.startswith("_ZGV"); // Itanium ABI guard 
variable
-  if (check_ms_abi)
-result |= mangled_symbol.endswith("@4IA"); // Microsoft ABI
-  return result;
+static bool isGuardVariableSymbol(llvm::StringRef mangled_symbol) {
+  return mangled_symbol.startswith("_ZGV") || // Itanium ABI
+ mangled_symbol.endswith("@4IA"); // Microsoft ABI
 }
 
 bool IRForTarget::CreateResultVariable(llvm::Function &llvm_function) {
@@ -181,9 +178,8 @@ bool IRForTarget::CreateResultVariable(l
   for (StringMapEntry &value_symbol : value_symbol_table) {
 result_name = value_symbol.first();
 
-// Check if this is a guard variable. It seems this causes some hiccups
-// on Windows, so let's only check for Itanium guard variables.
-bool is_guard_var = isGuardVariableSymbol(result_name, /*MS ABI*/ false);
+// Check if this is a guard variable.
+const bool is_guard_var = isGuardVariableSymbol(result_name);
 
 if (result_name.contains("$__lldb_expr_result_ptr") && !is_guard_var) {
   found_result = true;


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


[Lldb-commits] [lldb] r368920 - Revert "[lldb] Reinstate original guard variable check"

2019-08-14 Thread Raphael Isemann via lldb-commits
Author: teemperor
Date: Wed Aug 14 14:21:14 2019
New Revision: 368920

URL: http://llvm.org/viewvc/llvm-project?rev=368920&view=rev
Log:
Revert "[lldb] Reinstate original guard variable check"

It seems this breaks the following tests:
lldb-Suite :: 
expression_command/call-function/TestCallUserDefinedFunction.py
lldb-Suite :: expression_command/rdar42038760/TestScalarURem.py

Let's revert this patch and wait until we find an actual issue that could be
fixed by also doing the guard variable check on Windows.

Modified:
lldb/trunk/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp

Modified: lldb/trunk/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp?rev=368920&r1=368919&r2=368920&view=diff
==
--- lldb/trunk/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp (original)
+++ lldb/trunk/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp Wed Aug 14 
14:21:14 2019
@@ -156,9 +156,12 @@ clang::NamedDecl *IRForTarget::DeclForGl
 }
 
 /// Returns true iff the mangled symbol is for a static guard variable.
-static bool isGuardVariableSymbol(llvm::StringRef mangled_symbol) {
-  return mangled_symbol.startswith("_ZGV") || // Itanium ABI
- mangled_symbol.endswith("@4IA"); // Microsoft ABI
+static bool isGuardVariableSymbol(llvm::StringRef mangled_symbol,
+  bool check_ms_abi = true) {
+  bool result = mangled_symbol.startswith("_ZGV"); // Itanium ABI guard 
variable
+  if (check_ms_abi)
+result |= mangled_symbol.endswith("@4IA"); // Microsoft ABI
+  return result;
 }
 
 bool IRForTarget::CreateResultVariable(llvm::Function &llvm_function) {
@@ -178,8 +181,9 @@ bool IRForTarget::CreateResultVariable(l
   for (StringMapEntry &value_symbol : value_symbol_table) {
 result_name = value_symbol.first();
 
-// Check if this is a guard variable.
-const bool is_guard_var = isGuardVariableSymbol(result_name);
+// Check if this is a guard variable. It seems this causes some hiccups
+// on Windows, so let's only check for Itanium guard variables.
+bool is_guard_var = isGuardVariableSymbol(result_name, /*MS ABI*/ false);
 
 if (result_name.contains("$__lldb_expr_result_ptr") && !is_guard_var) {
   found_result = true;


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


[Lldb-commits] [lldb] r368975 - [lldb] Let LLDB depend on intrinsics_gen to fix non-deterministic module build failures

2019-08-15 Thread Raphael Isemann via lldb-commits
Author: teemperor
Date: Thu Aug 15 00:29:53 2019
New Revision: 368975

URL: http://llvm.org/viewvc/llvm-project?rev=368975&view=rev
Log:
[lldb] Let LLDB depend on intrinsics_gen to fix non-deterministic module build 
failures

Summary:
When building with modules we currently fail randomly to build LLDB's modules 
and get error messages like below:
```
In file included from :1:
In file included from llvm-project/llvm/include/llvm/IR/Argument.h:18:
llvm-project/llvm/include/llvm/IR/Attributes.h:74:14: fatal error: 
'llvm/IR/Attributes.inc' file not found
#include "llvm/IR/Attributes.inc"
 ^~~~
...
In file included from 
llvm-project/lldb/source/Plugins/ABI/SysV-arm/ABISysV_arm.cpp:9:
llvm-project/lldb/source/Plugins/ABI/SysV-arm/ABISysV_arm.h:12:10: fatal error: 
could not build module 'lldb_Wrapper'
```

The reason for this is that our source files can include Clang headers which in 
turn include files like Attributes.inc which
are generated by intrinsics_gen. However, it seems Clang can't express this 
dependency in its CMake code, so intrinsics_gen
is actually not guaranteed to be built before we start parsing LLDB source 
files and Clang headers. Clang worked around this
by letting all libraries depend on intrinsics_gen, which at least lets their 
builds pass.

As I haven't figured out how to solve these dependencies properly and I want to 
get the LLDB+Modules build green,
I suggest we copy Clang's hack until we figure out how to get Clang's 
dependencies right.

Reviewers: sgraenitz, aprantl, JDevlieghere

Reviewed By: JDevlieghere

Subscribers: mgorny, javed.absar, kristof.beyls, mgrang, lldb-commits

Tags: #lldb

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

Modified:
lldb/trunk/CMakeLists.txt

Modified: lldb/trunk/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/CMakeLists.txt?rev=368975&r1=368974&r2=368975&view=diff
==
--- lldb/trunk/CMakeLists.txt (original)
+++ lldb/trunk/CMakeLists.txt Thu Aug 15 00:29:53 2019
@@ -40,6 +40,15 @@ if (NOT LLDB_DISABLE_PYTHON)
   add_subdirectory(scripts)
 endif ()
 
+# We need the headers generated by instrinsics_gen before we can compile
+# any source file in LLDB as the imported Clang modules might include
+# some of these generated headers. This approach is copied from Clang's main
+# CMakeLists.txt, so it should kept in sync the code in Clang which was added
+# in llvm-svn 308844.
+if(LLVM_ENABLE_MODULES AND NOT LLDB_BUILT_STANDALONE)
+  list(APPEND LLVM_COMMON_DEPENDS intrinsics_gen)
+endif()
+
 if(CMAKE_CROSSCOMPILING AND LLDB_BUILT_STANDALONE)
   set(LLVM_USE_HOST_TOOLS ON)
   include(CrossCompile)


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


[Lldb-commits] [lldb] r369000 - [lldb][NFC] Refactor remaining completion logic to use CompletionRequests

2019-08-15 Thread Raphael Isemann via lldb-commits
Author: teemperor
Date: Thu Aug 15 06:14:10 2019
New Revision: 369000

URL: http://llvm.org/viewvc/llvm-project?rev=369000&view=rev
Log:
[lldb][NFC] Refactor remaining completion logic to use CompletionRequests

This patch moves the remaining completion functions from the
old completion API (that used several variables) to just
passing a single CompletionRequest.

This is for the most part a simple change as we just replace
the old arguments with a single CompletionRequest argument.

There are a few places where I had to create new CompletionRequests
in the called functions as CompletionRequests itself are immutable
and don't expose their internal match list anymore. This means that
if a function wanted to change the CompletionRequest or directly
access the result list, we need to work around this by creating
a new CompletionRequest and a temporary match/description list.

Preparation work for rdar://53769355

Modified:
lldb/trunk/include/lldb/Core/IOHandler.h
lldb/trunk/include/lldb/Expression/REPL.h
lldb/trunk/include/lldb/Host/Editline.h
lldb/trunk/include/lldb/Interpreter/CommandInterpreter.h
lldb/trunk/include/lldb/Utility/CompletionRequest.h
lldb/trunk/source/API/SBCommandInterpreter.cpp
lldb/trunk/source/Core/IOHandler.cpp
lldb/trunk/source/Expression/REPL.cpp
lldb/trunk/source/Host/common/Editline.cpp
lldb/trunk/source/Interpreter/CommandInterpreter.cpp

Modified: lldb/trunk/include/lldb/Core/IOHandler.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/IOHandler.h?rev=369000&r1=368999&r2=369000&view=diff
==
--- lldb/trunk/include/lldb/Core/IOHandler.h (original)
+++ lldb/trunk/include/lldb/Core/IOHandler.h Thu Aug 15 06:14:10 2019
@@ -10,6 +10,7 @@
 #define liblldb_IOHandler_h_
 
 #include "lldb/Core/ValueObjectList.h"
+#include "lldb/Utility/CompletionRequest.h"
 #include "lldb/Utility/ConstString.h"
 #include "lldb/Utility/Flags.h"
 #include "lldb/Utility/Predicate.h"
@@ -198,9 +199,8 @@ public:
 
   virtual void IOHandlerDeactivated(IOHandler &io_handler) {}
 
-  virtual int IOHandlerComplete(IOHandler &io_handler, const char 
*current_line,
-const char *cursor, const char *last_char,
-StringList &matches, StringList &descriptions);
+  virtual int IOHandlerComplete(IOHandler &io_handler,
+CompletionRequest &request);
 
   virtual const char *IOHandlerGetFixIndentationCharacters() { return nullptr; 
}
 
@@ -414,10 +414,7 @@ private:
   static int FixIndentationCallback(Editline *editline, const StringList 
&lines,
 int cursor_position, void *baton);
 
-  static int AutoCompleteCallback(const char *current_line, const char *cursor,
-  const char *last_char,
-  StringList &matches, StringList 
&descriptions,
-  void *baton);
+  static int AutoCompleteCallback(CompletionRequest &request, void *baton);
 #endif
 
 protected:
@@ -448,9 +445,8 @@ public:
 
   bool GetResponse() const { return m_user_response; }
 
-  int IOHandlerComplete(IOHandler &io_handler, const char *current_line,
-const char *cursor, const char *last_char,
-StringList &matches, StringList &descriptions) 
override;
+  int IOHandlerComplete(IOHandler &io_handler,
+CompletionRequest &request) override;
 
   void IOHandlerInputComplete(IOHandler &io_handler,
   std::string &data) override;

Modified: lldb/trunk/include/lldb/Expression/REPL.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Expression/REPL.h?rev=369000&r1=368999&r2=369000&view=diff
==
--- lldb/trunk/include/lldb/Expression/REPL.h (original)
+++ lldb/trunk/include/lldb/Expression/REPL.h Thu Aug 15 06:14:10 2019
@@ -103,9 +103,8 @@ public:
   void IOHandlerInputComplete(IOHandler &io_handler,
   std::string &line) override;
 
-  int IOHandlerComplete(IOHandler &io_handler, const char *current_line,
-const char *cursor, const char *last_char,
-StringList &matches, StringList &descriptions) 
override;
+  int IOHandlerComplete(IOHandler &io_handler,
+CompletionRequest &request) override;
 
 protected:
   static int CalculateActualIndentation(const StringList &lines);

Modified: lldb/trunk/include/lldb/Host/Editline.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Host/Editline.h?rev=369000&r1=368999&r2=369000&view=diff
==
--- lldb/trunk/include/lldb/Host/Editline.h (original)
+++ lldb/trunk/include/lldb/Host/Editline.h Thu Aug 15 06:1

[Lldb-commits] [lldb] r369113 - [lldb][NFC] Allow for-ranges on StringList

2019-08-16 Thread Raphael Isemann via lldb-commits
Author: teemperor
Date: Fri Aug 16 07:27:35 2019
New Revision: 369113

URL: http://llvm.org/viewvc/llvm-project?rev=369113&view=rev
Log:
[lldb][NFC] Allow for-ranges on StringList

Modified:
lldb/trunk/include/lldb/Utility/CompletionRequest.h
lldb/trunk/include/lldb/Utility/StringList.h
lldb/trunk/source/Breakpoint/WatchpointOptions.cpp
lldb/trunk/source/Commands/CommandObjectApropos.cpp
lldb/trunk/source/Commands/CommandObjectCommands.cpp
lldb/trunk/source/Commands/CommandObjectMultiword.cpp
lldb/trunk/source/Commands/CommandObjectType.cpp
lldb/trunk/source/Utility/Args.cpp
lldb/trunk/source/Utility/StringList.cpp
lldb/trunk/unittests/Editline/EditlineTest.cpp
lldb/trunk/unittests/Utility/StringListTest.cpp

Modified: lldb/trunk/include/lldb/Utility/CompletionRequest.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Utility/CompletionRequest.h?rev=369113&r1=369112&r2=369113&view=diff
==
--- lldb/trunk/include/lldb/Utility/CompletionRequest.h (original)
+++ lldb/trunk/include/lldb/Utility/CompletionRequest.h Fri Aug 16 07:27:35 2019
@@ -116,8 +116,8 @@ public:
   ///
   /// \see AddCompletion
   void AddCompletions(const StringList &completions) {
-for (std::size_t i = 0; i < completions.GetSize(); ++i)
-  AddCompletion(completions.GetStringAtIndex(i));
+for (const std::string &completion : completions)
+  AddCompletion(completion);
   }
 
   /// Adds multiple possible completion strings alongside their descriptions.

Modified: lldb/trunk/include/lldb/Utility/StringList.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Utility/StringList.h?rev=369113&r1=369112&r2=369113&view=diff
==
--- lldb/trunk/include/lldb/Utility/StringList.h (original)
+++ lldb/trunk/include/lldb/Utility/StringList.h Fri Aug 16 07:27:35 2019
@@ -23,6 +23,8 @@ class Stream;
 namespace lldb_private {
 
 class StringList {
+  typedef std::vector StorageType;
+
 public:
   StringList();
 
@@ -52,6 +54,14 @@ public:
 
   size_t GetMaxStringLength() const;
 
+  typedef StorageType::iterator iterator;
+  typedef StorageType::const_iterator const_iterator;
+
+  iterator begin() { return m_strings.begin(); }
+  iterator end() { return m_strings.end(); }
+  const_iterator begin() const { return m_strings.begin(); }
+  const_iterator end() const { return m_strings.end(); }
+
   std::string &operator[](size_t idx) {
 // No bounds checking, verify "idx" is good prior to calling this function
 return m_strings[idx];
@@ -125,7 +135,7 @@ public:
   }
 
 private:
-  std::vector m_strings;
+  StorageType m_strings;
 };
 
 } // namespace lldb_private

Modified: lldb/trunk/source/Breakpoint/WatchpointOptions.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Breakpoint/WatchpointOptions.cpp?rev=369113&r1=369112&r2=369113&view=diff
==
--- lldb/trunk/source/Breakpoint/WatchpointOptions.cpp (original)
+++ lldb/trunk/source/Breakpoint/WatchpointOptions.cpp Fri Aug 16 07:27:35 2019
@@ -170,9 +170,8 @@ void WatchpointOptions::CommandBaton::Ge
 
   s->IndentMore();
   if (data && data->user_source.GetSize() > 0) {
-const size_t num_strings = data->user_source.GetSize();
-for (size_t i = 0; i < num_strings; ++i) {
-  s->Indent(data->user_source.GetStringAtIndex(i));
+for (const std::string &line : data->user_source) {
+  s->Indent(line);
   s->EOL();
 }
   } else {

Modified: lldb/trunk/source/Commands/CommandObjectApropos.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectApropos.cpp?rev=369113&r1=369112&r2=369113&view=diff
==
--- lldb/trunk/source/Commands/CommandObjectApropos.cpp (original)
+++ lldb/trunk/source/Commands/CommandObjectApropos.cpp Fri Aug 16 07:27:35 2019
@@ -65,10 +65,8 @@ bool CommandObjectApropos::DoExecute(Arg
   "The following commands may relate to '%s':\n", args[0].c_str());
   size_t max_len = 0;
 
-  for (size_t i = 0; i < commands_found.GetSize(); ++i) {
-size_t len = strlen(commands_found.GetStringAtIndex(i));
-if (len > max_len)
-  max_len = len;
+  for (const std::string &command : commands_found) {
+max_len = std::max(max_len, command.size());
   }
 
   for (size_t i = 0; i < commands_found.GetSize(); ++i)

Modified: lldb/trunk/source/Commands/CommandObjectCommands.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectCommands.cpp?rev=369113&r1=369112&r2=369113&view=diff
==
--- lldb/trunk/source/Commands/CommandObjectCommands.cpp (original)
+++ lldb/t

[Lldb-commits] [lldb] r369198 - [lldb][NFC] Remove unused MaterializeInitializer and MaterializeInternalVariable

2019-08-17 Thread Raphael Isemann via lldb-commits
Author: teemperor
Date: Sat Aug 17 14:57:51 2019
New Revision: 369198

URL: http://llvm.org/viewvc/llvm-project?rev=369198&view=rev
Log:
[lldb][NFC] Remove unused MaterializeInitializer and MaterializeInternalVariable

Modified:
lldb/trunk/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp
lldb/trunk/source/Plugins/ExpressionParser/Clang/IRForTarget.h

Modified: lldb/trunk/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp?rev=369198&r1=369197&r2=369198&view=diff
==
--- lldb/trunk/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp (original)
+++ lldb/trunk/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp Sat Aug 17 
14:57:51 2019
@@ -1180,71 +1180,6 @@ bool IRForTarget::RewritePersistentAlloc
   return true;
 }
 
-bool IRForTarget::MaterializeInitializer(uint8_t *data, Constant *initializer) 
{
-  if (!initializer)
-return true;
-
-  lldb_private::Log *log(
-  lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS));
-
-  LLDB_LOGV(log, "  MaterializeInitializer({0}, {1})", (void *)data,
-PrintValue(initializer));
-
-  Type *initializer_type = initializer->getType();
-
-  if (ConstantInt *int_initializer = dyn_cast(initializer)) {
-size_t constant_size = m_target_data->getTypeStoreSize(initializer_type);
-lldb_private::Scalar scalar = int_initializer->getValue().zextOrTrunc(
-llvm::NextPowerOf2(constant_size) * 8);
-
-lldb_private::Status get_data_error;
-return scalar.GetAsMemoryData(data, constant_size,
-  lldb_private::endian::InlHostByteOrder(),
-  get_data_error) != 0;
-  } else if (ConstantDataArray *array_initializer =
- dyn_cast(initializer)) {
-if (array_initializer->isString()) {
-  std::string array_initializer_string = array_initializer->getAsString();
-  memcpy(data, array_initializer_string.c_str(),
- m_target_data->getTypeStoreSize(initializer_type));
-} else {
-  ArrayType *array_initializer_type = array_initializer->getType();
-  Type *array_element_type = array_initializer_type->getElementType();
-
-  size_t element_size = 
m_target_data->getTypeAllocSize(array_element_type);
-
-  for (unsigned i = 0; i < array_initializer->getNumOperands(); ++i) {
-Value *operand_value = array_initializer->getOperand(i);
-Constant *operand_constant = dyn_cast(operand_value);
-
-if (!operand_constant)
-  return false;
-
-if (!MaterializeInitializer(data + (i * element_size),
-operand_constant))
-  return false;
-  }
-}
-return true;
-  } else if (ConstantStruct *struct_initializer =
- dyn_cast(initializer)) {
-StructType *struct_initializer_type = struct_initializer->getType();
-const StructLayout *struct_layout =
-m_target_data->getStructLayout(struct_initializer_type);
-
-for (unsigned i = 0; i < struct_initializer->getNumOperands(); ++i) {
-  if (!MaterializeInitializer(data + struct_layout->getElementOffset(i),
-  struct_initializer->getOperand(i)))
-return false;
-}
-return true;
-  } else if (isa(initializer)) {
-memset(data, 0, m_target_data->getTypeStoreSize(initializer_type));
-return true;
-  }
-  return false;
-}
-
 // This function does not report errors; its callers are responsible.
 bool IRForTarget::MaybeHandleVariable(Value *llvm_value_ptr) {
   lldb_private::Log *log(

Modified: lldb/trunk/source/Plugins/ExpressionParser/Clang/IRForTarget.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ExpressionParser/Clang/IRForTarget.h?rev=369198&r1=369197&r2=369198&view=diff
==
--- lldb/trunk/source/Plugins/ExpressionParser/Clang/IRForTarget.h (original)
+++ lldb/trunk/source/Plugins/ExpressionParser/Clang/IRForTarget.h Sat Aug 17 
14:57:51 2019
@@ -332,27 +332,6 @@ private:
   /// a call to a function pointer whose value is the address of the function
   /// in the target process.
 
-  /// Write an initializer to a memory array of assumed sufficient size.
-  ///
-  /// \param[in] data
-  /// A pointer to the data to write to.
-  ///
-  /// \param[in] initializer
-  /// The initializer itself.
-  ///
-  /// \return
-  /// True on success; false otherwise
-  bool MaterializeInitializer(uint8_t *data, llvm::Constant *initializer);
-
-  /// Move an internal variable into the static allocation section.
-  ///
-  /// \param[in] global_variable
-  /// The variable.
-  ///
-  /// \return
-  /// True on success; false otherwise
-  bool MaterializeInternalVariable(llvm::GlobalVariable *global_variable);
-
   /// Handle a single exte

[Lldb-commits] [lldb] r369237 - [lldb][NFC] Address review comments to StringList for-loop support

2019-08-19 Thread Raphael Isemann via lldb-commits
Author: teemperor
Date: Mon Aug 19 00:22:19 2019
New Revision: 369237

URL: http://llvm.org/viewvc/llvm-project?rev=369237&view=rev
Log:
[lldb][NFC] Address review comments to StringList for-loop support

Modified:
lldb/trunk/include/lldb/Utility/StringList.h
lldb/trunk/source/Commands/CommandObjectType.cpp
lldb/trunk/source/Utility/StringList.cpp
lldb/trunk/unittests/Utility/StringListTest.cpp

Modified: lldb/trunk/include/lldb/Utility/StringList.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Utility/StringList.h?rev=369237&r1=369236&r2=369237&view=diff
==
--- lldb/trunk/include/lldb/Utility/StringList.h (original)
+++ lldb/trunk/include/lldb/Utility/StringList.h Mon Aug 19 00:22:19 2019
@@ -23,7 +23,7 @@ class Stream;
 namespace lldb_private {
 
 class StringList {
-  typedef std::vector StorageType;
+  typedef std::vector collection;
 
 public:
   StringList();
@@ -54,8 +54,8 @@ public:
 
   size_t GetMaxStringLength() const;
 
-  typedef StorageType::iterator iterator;
-  typedef StorageType::const_iterator const_iterator;
+  typedef collection::iterator iterator;
+  typedef collection::const_iterator const_iterator;
 
   iterator begin() { return m_strings.begin(); }
   iterator end() { return m_strings.end(); }
@@ -135,7 +135,7 @@ public:
   }
 
 private:
-  StorageType m_strings;
+  collection m_strings;
 };
 
 } // namespace lldb_private

Modified: lldb/trunk/source/Commands/CommandObjectType.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectType.cpp?rev=369237&r1=369236&r2=369237&view=diff
==
--- lldb/trunk/source/Commands/CommandObjectType.cpp (original)
+++ lldb/trunk/source/Commands/CommandObjectType.cpp Mon Aug 19 00:22:19 2019
@@ -436,10 +436,9 @@ protected:
 Status error;
 
 for (const std::string &type_name : options->m_target_types) {
-  ConstString const_type_name(type_name);
-  if (const_type_name) {
+  if (!type_name.empty()) {
 if (!CommandObjectTypeSynthAdd::AddSynth(
-const_type_name, synth_provider,
+ConstString(type_name), synth_provider,
 options->m_regex
 ? CommandObjectTypeSynthAdd::eRegexSynth
 : CommandObjectTypeSynthAdd::eRegularSynth,

Modified: lldb/trunk/source/Utility/StringList.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Utility/StringList.cpp?rev=369237&r1=369236&r2=369237&view=diff
==
--- lldb/trunk/source/Utility/StringList.cpp (original)
+++ lldb/trunk/source/Utility/StringList.cpp Mon Aug 19 00:22:19 2019
@@ -61,6 +61,7 @@ void StringList::AppendList(const char *
 }
 
 void StringList::AppendList(StringList strings) {
+  m_strings.reserve(m_strings.size() + strings.GetSize());
   m_strings.insert(m_strings.end(), strings.begin(), strings.end());
 }
 

Modified: lldb/trunk/unittests/Utility/StringListTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/unittests/Utility/StringListTest.cpp?rev=369237&r1=369236&r2=369237&view=diff
==
--- lldb/trunk/unittests/Utility/StringListTest.cpp (original)
+++ lldb/trunk/unittests/Utility/StringListTest.cpp Mon Aug 19 00:22:19 2019
@@ -512,7 +512,7 @@ TEST(StringListTest, ForRangeEmpty) {
 FAIL() << "Shouldn't have hit an element in for range" << e;
 }
 
-TEST(StringListTest, ForRangeSingle) {
+TEST(StringListTest, ForRange) {
   StringList s;
   s.AppendString("a");
   s.AppendString("b");


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


[Lldb-commits] [lldb] r369240 - [lldb][NFC] Use GetMaxStringLength in CommandObjectApropos::DoExecute

2019-08-19 Thread Raphael Isemann via lldb-commits
Author: teemperor
Date: Mon Aug 19 00:59:44 2019
New Revision: 369240

URL: http://llvm.org/viewvc/llvm-project?rev=369240&view=rev
Log:
[lldb][NFC] Use GetMaxStringLength in CommandObjectApropos::DoExecute

Modified:
lldb/trunk/source/Commands/CommandObjectApropos.cpp

Modified: lldb/trunk/source/Commands/CommandObjectApropos.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectApropos.cpp?rev=369240&r1=369239&r2=369240&view=diff
==
--- lldb/trunk/source/Commands/CommandObjectApropos.cpp (original)
+++ lldb/trunk/source/Commands/CommandObjectApropos.cpp Mon Aug 19 00:59:44 2019
@@ -63,11 +63,7 @@ bool CommandObjectApropos::DoExecute(Arg
 if (commands_found.GetSize() > 0) {
   result.AppendMessageWithFormat(
   "The following commands may relate to '%s':\n", args[0].c_str());
-  size_t max_len = 0;
-
-  for (const std::string &command : commands_found) {
-max_len = std::max(max_len, command.size());
-  }
+  const size_t max_len = commands_found.GetMaxStringLength();
 
   for (size_t i = 0; i < commands_found.GetSize(); ++i)
 m_interpreter.OutputFormattedHelpText(


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


[Lldb-commits] [lldb] r369242 - [lldb][NFC] Remove StringList::AutoComplete

2019-08-19 Thread Raphael Isemann via lldb-commits
Author: teemperor
Date: Mon Aug 19 01:15:46 2019
New Revision: 369242

URL: http://llvm.org/viewvc/llvm-project?rev=369242&view=rev
Log:
[lldb][NFC] Remove StringList::AutoComplete

We don't need this very specific function in StringList that
we only call once in LLDB.

Modified:
lldb/trunk/include/lldb/Utility/StringList.h
lldb/trunk/source/Commands/CommandCompletions.cpp
lldb/trunk/source/Utility/StringList.cpp

Modified: lldb/trunk/include/lldb/Utility/StringList.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Utility/StringList.h?rev=369242&r1=369241&r2=369242&view=diff
==
--- lldb/trunk/include/lldb/Utility/StringList.h (original)
+++ lldb/trunk/include/lldb/Utility/StringList.h Mon Aug 19 01:15:46 2019
@@ -107,14 +107,6 @@ public:
   // Copy assignment for a vector of strings
   StringList &operator=(const std::vector &rhs);
 
-  // This string list contains a list of valid auto completion strings, and the
-  // "s" is passed in. "matches" is filled in with zero or more string values
-  // that start with "s", and the first string to exactly match one of the
-  // string values in this collection, will have "exact_matches_idx" filled in
-  // to match the index, or "exact_matches_idx" will have SIZE_MAX
-  size_t AutoComplete(llvm::StringRef s, StringList &matches,
-  size_t &exact_matches_idx) const;
-
   // Dump the StringList to the given lldb_private::Log, `log`, one item per
   // line. If given, `name` will be used to identify the start and end of the
   // list in the output.

Modified: lldb/trunk/source/Commands/CommandCompletions.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandCompletions.cpp?rev=369242&r1=369241&r2=369242&view=diff
==
--- lldb/trunk/source/Commands/CommandCompletions.cpp (original)
+++ lldb/trunk/source/Commands/CommandCompletions.cpp Mon Aug 19 01:15:46 2019
@@ -309,12 +309,18 @@ int CommandCompletions::SettingsNames(Co
 }
   }
 
-  size_t exact_matches_idx = SIZE_MAX;
-  StringList matches;
-  g_property_names.AutoComplete(request.GetCursorArgumentPrefix(), matches,
-exact_matches_idx);
-  request.SetWordComplete(exact_matches_idx != SIZE_MAX);
-  request.AddCompletions(matches);
+  bool exact_match = false;
+
+  for (const std::string &s : g_property_names) {
+if (llvm::StringRef(s).startswith(request.GetCursorArgumentPrefix())) {
+  if (request.GetCursorArgumentPrefix() == s)
+exact_match = true;
+  request.AddCompletion(s);
+}
+  }
+
+  request.SetWordComplete(exact_match);
+
   return request.GetNumberOfMatches();
 }
 

Modified: lldb/trunk/source/Utility/StringList.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Utility/StringList.cpp?rev=369242&r1=369241&r2=369242&view=diff
==
--- lldb/trunk/source/Utility/StringList.cpp (original)
+++ lldb/trunk/source/Utility/StringList.cpp Mon Aug 19 01:15:46 2019
@@ -223,29 +223,6 @@ StringList &StringList::operator=(const
   return *this;
 }
 
-size_t StringList::AutoComplete(llvm::StringRef s, StringList &matches,
-size_t &exact_idx) const {
-  matches.Clear();
-  exact_idx = SIZE_MAX;
-  if (s.empty()) {
-// No string, so it matches everything
-matches = *this;
-return matches.GetSize();
-  }
-
-  const size_t s_len = s.size();
-  const size_t num_strings = m_strings.size();
-
-  for (size_t i = 0; i < num_strings; ++i) {
-if (m_strings[i].find(s) == 0) {
-  if (exact_idx == SIZE_MAX && m_strings[i].size() == s_len)
-exact_idx = matches.GetSize();
-  matches.AppendString(m_strings[i]);
-}
-  }
-  return matches.GetSize();
-}
-
 void StringList::LogDump(Log *log, const char *name) {
   if (!log)
 return;


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


[Lldb-commits] [lldb] r369249 - [lldb][NFC] Add a few more completion tests to increase test coverage

2019-08-19 Thread Raphael Isemann via lldb-commits
Author: teemperor
Date: Mon Aug 19 03:46:38 2019
New Revision: 369249

URL: http://llvm.org/viewvc/llvm-project?rev=369249&view=rev
Log:
[lldb][NFC] Add a few more completion tests to increase test coverage

These tests are mostly trying to reach the different completion functions
in CommandCompletions.cpp (::ArchitectureNames, ::DiskFiles, ::Modules).

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=369249&r1=369248&r2=369249&view=diff
==
--- 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/completion/TestCompletion.py
 (original)
+++ 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/completion/TestCompletion.py
 Mon Aug 19 03:46:38 2019
@@ -84,6 +84,29 @@ class CommandLineCompletionTestCase(Test
 'process attach --con',
 'process attach --continue ')
 
+@skipIfFreeBSD  # timing out on the FreeBSD buildbot
+def test_process_launch_arch(self):
+self.complete_from_to('process launch --arch ',
+  ['mips',
+   'arm64'])
+
+@skipIfFreeBSD  # timing out on the FreeBSD buildbot
+def test_process_launch_arch_arm(self):
+self.complete_from_to('process launch --arch arm',
+  ['arm64'])
+
+@skipIfFreeBSD  # timing out on the FreeBSD buildbot
+def test_target_symbols_add_shlib(self):
+# Doesn't seem to work, but at least it shouldn't crash.
+self.complete_from_to('target symbols add --shlib ', [])
+
+@skipIfFreeBSD  # timing out on the FreeBSD buildbot
+def test_log_file(self):
+# Complete in our source directory which contains a 'main.cpp' file.
+src_dir =  os.path.dirname(os.path.realpath(__file__)) + '/'
+self.complete_from_to('log enable lldb expr -f ' + src_dir,
+  ['main.cpp'])
+
 # 
 @skipIfFreeBSD  # timing out on the FreeBSD buildbot
 def test_infinite_loop_while_completing(self):


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


[Lldb-commits] [lldb] r369252 - [lldb][NFC] Use CompletionRequest in Variable::AutoComplete

2019-08-19 Thread Raphael Isemann via lldb-commits
Author: teemperor
Date: Mon Aug 19 04:49:43 2019
New Revision: 369252

URL: http://llvm.org/viewvc/llvm-project?rev=369252&view=rev
Log:
[lldb][NFC] Use CompletionRequest in Variable::AutoComplete

Modified:
lldb/trunk/source/Symbol/Variable.cpp

Modified: lldb/trunk/source/Symbol/Variable.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/Variable.cpp?rev=369252&r1=369251&r2=369252&view=diff
==
--- lldb/trunk/source/Symbol/Variable.cpp (original)
+++ lldb/trunk/source/Symbol/Variable.cpp Mon Aug 19 04:49:43 2019
@@ -488,24 +488,21 @@ static void PrivateAutoComplete(
 StackFrame *frame, llvm::StringRef partial_path,
 const llvm::Twine
 &prefix_path, // Anything that has been resolved already will be in 
here
-const CompilerType &compiler_type,
-StringList &matches, bool &word_complete);
+const CompilerType &compiler_type, CompletionRequest &request);
 
 static void PrivateAutoCompleteMembers(
 StackFrame *frame, const std::string &partial_member_name,
 llvm::StringRef partial_path,
 const llvm::Twine
 &prefix_path, // Anything that has been resolved already will be in 
here
-const CompilerType &compiler_type,
-StringList &matches, bool &word_complete);
+const CompilerType &compiler_type, CompletionRequest &request);
 
 static void PrivateAutoCompleteMembers(
 StackFrame *frame, const std::string &partial_member_name,
 llvm::StringRef partial_path,
 const llvm::Twine
 &prefix_path, // Anything that has been resolved already will be in 
here
-const CompilerType &compiler_type,
-StringList &matches, bool &word_complete) {
+const CompilerType &compiler_type, CompletionRequest &request) {
 
   // We are in a type parsing child members
   const uint32_t num_bases = compiler_type.GetNumDirectBaseClasses();
@@ -515,9 +512,9 @@ static void PrivateAutoCompleteMembers(
   CompilerType base_class_type =
   compiler_type.GetDirectBaseClassAtIndex(i, nullptr);
 
-  PrivateAutoCompleteMembers(
-  frame, partial_member_name, partial_path, prefix_path,
-  base_class_type.GetCanonicalType(), matches, word_complete);
+  PrivateAutoCompleteMembers(frame, partial_member_name, partial_path,
+ prefix_path,
+ base_class_type.GetCanonicalType(), request);
 }
   }
 
@@ -528,9 +525,9 @@ static void PrivateAutoCompleteMembers(
   CompilerType vbase_class_type =
   compiler_type.GetVirtualBaseClassAtIndex(i, nullptr);
 
-  PrivateAutoCompleteMembers(
-  frame, partial_member_name, partial_path, prefix_path,
-  vbase_class_type.GetCanonicalType(), matches, word_complete);
+  PrivateAutoCompleteMembers(frame, partial_member_name, partial_path,
+ prefix_path,
+ vbase_class_type.GetCanonicalType(), request);
 }
   }
 
@@ -551,9 +548,9 @@ static void PrivateAutoCompleteMembers(
   frame, partial_path,
   prefix_path + member_name, // Anything that has been resolved
  // already will be in here
-  member_compiler_type.GetCanonicalType(), matches, word_complete);
+  member_compiler_type.GetCanonicalType(), request);
 } else {
-  matches.AppendString((prefix_path + member_name).str());
+  request.AddCompletion((prefix_path + member_name).str());
 }
   }
 }
@@ -564,8 +561,7 @@ static void PrivateAutoComplete(
 StackFrame *frame, llvm::StringRef partial_path,
 const llvm::Twine
 &prefix_path, // Anything that has been resolved already will be in 
here
-const CompilerType &compiler_type,
-StringList &matches, bool &word_complete) {
+const CompilerType &compiler_type, CompletionRequest &request) {
   //printf ("\nPrivateAutoComplete()\n\tprefix_path = '%s'\n\tpartial_path 
=
   //'%s'\n", prefix_path.c_str(), partial_path.c_str());
   std::string remaining_partial_path;
@@ -586,15 +582,15 @@ static void PrivateAutoComplete(
   case eTypeClassReference:
   case eTypeClassTypedef:
   case eTypeClassVector: {
-matches.AppendString(prefix_path.str());
-word_complete = matches.GetSize() == 1;
+request.AddCompletion(prefix_path.str());
+request.SetWordComplete(true);
   } break;
 
   case eTypeClassClass:
   case eTypeClassStruct:
   case eTypeClassUnion:
 if (prefix_path.str().back() != '.')
-  matches.AppendString((prefix_path + ".").str());
+  request.AddCompletion((prefix_path + ".").str());
 break;
 
   case eTypeClassObjCObject:
@@ -604,10 +600,10 @@ static void PrivateAutoComplete(
   case eTypeClassPointer: {
 bool omit_empty_base_classes = true;
 if (compiler_type.GetNumChildr

[Lldb-commits] [lldb] r369267 - [lldb][NFC] Stop using GetNumberOfMatches in CompletionRequest test

2019-08-19 Thread Raphael Isemann via lldb-commits
Author: teemperor
Date: Mon Aug 19 07:52:48 2019
New Revision: 369267

URL: http://llvm.org/viewvc/llvm-project?rev=369267&view=rev
Log:
[lldb][NFC] Stop using GetNumberOfMatches in CompletionRequest test

This function is just a wrapper for GetNumberOfResults and will
be removed soon. This patch just changes all calls to GetNumberOfResults
where possible (which is currently just the unit test).

Modified:
lldb/trunk/unittests/Utility/CompletionRequestTest.cpp

Modified: lldb/trunk/unittests/Utility/CompletionRequestTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/unittests/Utility/CompletionRequestTest.cpp?rev=369267&r1=369266&r2=369267&view=diff
==
--- lldb/trunk/unittests/Utility/CompletionRequestTest.cpp (original)
+++ lldb/trunk/unittests/Utility/CompletionRequestTest.cpp Mon Aug 19 07:52:48 
2019
@@ -41,20 +41,20 @@ TEST(CompletionRequest, DuplicateFilteri
   CompletionRequest request(command, cursor_pos, result);
   result.GetMatches(matches);
 
-  EXPECT_EQ(0U, request.GetNumberOfMatches());
+  EXPECT_EQ(0U, result.GetNumberOfResults());
 
   // Add foo twice
   request.AddCompletion("foo");
   result.GetMatches(matches);
 
-  EXPECT_EQ(1U, request.GetNumberOfMatches());
+  EXPECT_EQ(1U, result.GetNumberOfResults());
   EXPECT_EQ(1U, matches.GetSize());
   EXPECT_STREQ("foo", matches.GetStringAtIndex(0));
 
   request.AddCompletion("foo");
   result.GetMatches(matches);
 
-  EXPECT_EQ(1U, request.GetNumberOfMatches());
+  EXPECT_EQ(1U, result.GetNumberOfResults());
   EXPECT_EQ(1U, matches.GetSize());
   EXPECT_STREQ("foo", matches.GetStringAtIndex(0));
 
@@ -62,7 +62,7 @@ TEST(CompletionRequest, DuplicateFilteri
   request.AddCompletion("bar");
   result.GetMatches(matches);
 
-  EXPECT_EQ(2U, request.GetNumberOfMatches());
+  EXPECT_EQ(2U, result.GetNumberOfResults());
   EXPECT_EQ(2U, matches.GetSize());
   EXPECT_STREQ("foo", matches.GetStringAtIndex(0));
   EXPECT_STREQ("bar", matches.GetStringAtIndex(1));
@@ -70,7 +70,7 @@ TEST(CompletionRequest, DuplicateFilteri
   request.AddCompletion("bar");
   result.GetMatches(matches);
 
-  EXPECT_EQ(2U, request.GetNumberOfMatches());
+  EXPECT_EQ(2U, result.GetNumberOfResults());
   EXPECT_EQ(2U, matches.GetSize());
   EXPECT_STREQ("foo", matches.GetStringAtIndex(0));
   EXPECT_STREQ("bar", matches.GetStringAtIndex(1));
@@ -79,7 +79,7 @@ TEST(CompletionRequest, DuplicateFilteri
   request.AddCompletion("foo");
   result.GetMatches(matches);
 
-  EXPECT_EQ(2U, request.GetNumberOfMatches());
+  EXPECT_EQ(2U, result.GetNumberOfResults());
   EXPECT_EQ(2U, matches.GetSize());
   EXPECT_STREQ("foo", matches.GetStringAtIndex(0));
   EXPECT_STREQ("bar", matches.GetStringAtIndex(1));
@@ -88,7 +88,7 @@ TEST(CompletionRequest, DuplicateFilteri
   request.AddCompletion("foobar");
   result.GetMatches(matches);
 
-  EXPECT_EQ(3U, request.GetNumberOfMatches());
+  EXPECT_EQ(3U, result.GetNumberOfResults());
   EXPECT_EQ(3U, matches.GetSize());
   EXPECT_STREQ("foo", matches.GetStringAtIndex(0));
   EXPECT_STREQ("bar", matches.GetStringAtIndex(1));
@@ -105,14 +105,14 @@ TEST(CompletionRequest, DuplicateFilteri
   result.GetMatches(matches);
   result.GetDescriptions(descriptions);
 
-  EXPECT_EQ(0U, request.GetNumberOfMatches());
+  EXPECT_EQ(0U, result.GetNumberOfResults());
 
   // Add foo twice with same comment
   request.AddCompletion("foo", "comment");
   result.GetMatches(matches);
   result.GetDescriptions(descriptions);
 
-  EXPECT_EQ(1U, request.GetNumberOfMatches());
+  EXPECT_EQ(1U, result.GetNumberOfResults());
   EXPECT_EQ(1U, matches.GetSize());
   EXPECT_EQ(1U, descriptions.GetSize());
   EXPECT_STREQ("foo", matches.GetStringAtIndex(0));
@@ -122,7 +122,7 @@ TEST(CompletionRequest, DuplicateFilteri
   result.GetMatches(matches);
   result.GetDescriptions(descriptions);
 
-  EXPECT_EQ(1U, request.GetNumberOfMatches());
+  EXPECT_EQ(1U, result.GetNumberOfResults());
   EXPECT_EQ(1U, matches.GetSize());
   EXPECT_EQ(1U, descriptions.GetSize());
   EXPECT_STREQ("foo", matches.GetStringAtIndex(0));
@@ -133,7 +133,7 @@ TEST(CompletionRequest, DuplicateFilteri
   result.GetMatches(matches);
   result.GetDescriptions(descriptions);
 
-  EXPECT_EQ(2U, request.GetNumberOfMatches());
+  EXPECT_EQ(2U, result.GetNumberOfResults());
   EXPECT_EQ(2U, matches.GetSize());
   EXPECT_EQ(2U, descriptions.GetSize());
   EXPECT_STREQ("foo", matches.GetStringAtIndex(0));
@@ -143,7 +143,7 @@ TEST(CompletionRequest, DuplicateFilteri
   result.GetMatches(matches);
   result.GetDescriptions(descriptions);
 
-  EXPECT_EQ(3U, request.GetNumberOfMatches());
+  EXPECT_EQ(3U, result.GetNumberOfResults());
   EXPECT_EQ(3U, matches.GetSize());
   EXPECT_EQ(3U, descriptions.GetSize());
   EXPECT_STREQ("foo", matches.GetStringAtIndex(0));
@@ -158,7 +158,7 @@ TEST(CompletionRequest, DuplicateFilteri
   result.GetMatches(matches);
   result.GetDescriptions(descriptions);
 
-  EXPECT_EQ(4U, reques

[Lldb-commits] [lldb] r369293 - [lldb] Make TestIOHandlerCompletion more stable and document it

2019-08-19 Thread Raphael Isemann via lldb-commits
Author: teemperor
Date: Mon Aug 19 12:13:26 2019
New Revision: 369293

URL: http://llvm.org/viewvc/llvm-project?rev=369293&view=rev
Log:
[lldb] Make TestIOHandlerCompletion more stable and document it

Instead of relying that three tabs show all completions, we should
show all remaining completions which will always stop the mode
where we show completions. Should fix this test on systems that
somehow have more completions that our normal LLDB (as they
would end up being stuck in the mode where we show completions).

Modified:

lldb/trunk/packages/Python/lldbsuite/test/iohandler/completion/TestIOHandlerCompletion.py

Modified: 
lldb/trunk/packages/Python/lldbsuite/test/iohandler/completion/TestIOHandlerCompletion.py
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/iohandler/completion/TestIOHandlerCompletion.py?rev=369293&r1=369292&r2=369293&view=diff
==
--- 
lldb/trunk/packages/Python/lldbsuite/test/iohandler/completion/TestIOHandlerCompletion.py
 (original)
+++ 
lldb/trunk/packages/Python/lldbsuite/test/iohandler/completion/TestIOHandlerCompletion.py
 Mon Aug 19 12:13:26 2019
@@ -39,13 +39,16 @@ class IOHandlerCompletionTest(TestBase):
 (lldbtest_config.lldbExec, self.lldbOption, "", exe))
 
 self.expect_string(prompt)
-self.child.send("\t\t\t")
+# Start tab completion, go to the next page and then display all with 
'a'.
+self.child.send("\t\ta")
 self.expect_string("register")
 
+# Try tab completing regi to register.
 self.child.send("regi\t")
 self.expect_string(prompt + "register")
 self.child.send("\n")
 
+# Start tab completion and abort showing more commands with 'n'.
 self.child.send("\t")
 self.expect_string("More (Y/n/a)")
 self.child.send("n")


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


[Lldb-commits] [lldb] r369353 - [lldb][NFC] Test quotes when completing

2019-08-20 Thread Raphael Isemann via lldb-commits
Author: teemperor
Date: Tue Aug 20 02:26:58 2019
New Revision: 369353

URL: http://llvm.org/viewvc/llvm-project?rev=369353&view=rev
Log:
[lldb][NFC] Test quotes when completing

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=369353&r1=369352&r2=369353&view=diff
==
--- 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/completion/TestCompletion.py
 (original)
+++ 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/completion/TestCompletion.py
 Tue Aug 20 02:26:58 2019
@@ -91,6 +91,32 @@ class CommandLineCompletionTestCase(Test
'arm64'])
 
 @skipIfFreeBSD  # timing out on the FreeBSD buildbot
+def test_quoted_command(self):
+self.complete_from_to('"set',
+  ['"settings" '])
+
+@skipIfFreeBSD  # timing out on the FreeBSD buildbot
+def test_quoted_arg_with_quoted_command(self):
+self.complete_from_to('"settings" "repl',
+  ['"replace" '])
+
+@skipIfFreeBSD  # timing out on the FreeBSD buildbot
+def test_quoted_arg_without_quoted_command(self):
+self.complete_from_to('settings "repl',
+  ['"replace" '])
+
+@skipIfFreeBSD  # timing out on the FreeBSD buildbot
+def test_single_quote_command(self):
+self.complete_from_to("'set",
+  ["'settings' "])
+
+@skipIfFreeBSD  # timing out on the FreeBSD buildbot
+def test_terminated_quote_command(self):
+# This should not crash, but we don't get any
+# reasonable completions from this.
+self.complete_from_to("'settings'", [])
+
+@skipIfFreeBSD  # timing out on the FreeBSD buildbot
 def test_process_launch_arch_arm(self):
 self.complete_from_to('process launch --arch arm',
   ['arm64'])


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


[Lldb-commits] [lldb] r369506 - [lldb][NFC] Add tests for invalid command invocations

2019-08-21 Thread Raphael Isemann via lldb-commits
Author: teemperor
Date: Wed Aug 21 02:15:44 2019
New Revision: 369506

URL: http://llvm.org/viewvc/llvm-project?rev=369506&view=rev
Log:
[lldb][NFC] Add tests for invalid command invocations

Added:
lldb/trunk/packages/Python/lldbsuite/test/functionalities/apropos/

lldb/trunk/packages/Python/lldbsuite/test/functionalities/apropos/TestApropos.py

lldb/trunk/packages/Python/lldbsuite/test/functionalities/reproducer/TestReproducer.py
lldb/trunk/packages/Python/lldbsuite/test/functionalities/version/

lldb/trunk/packages/Python/lldbsuite/test/functionalities/version/TestVersion.py
Modified:

lldb/trunk/packages/Python/lldbsuite/test/functionalities/completion/TestCompletion.py

lldb/trunk/packages/Python/lldbsuite/test/functionalities/plugins/commands/TestPluginCommands.py
lldb/trunk/packages/Python/lldbsuite/test/help/TestHelp.py

Added: 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/apropos/TestApropos.py
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/functionalities/apropos/TestApropos.py?rev=369506&view=auto
==
--- 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/apropos/TestApropos.py
 (added)
+++ 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/apropos/TestApropos.py
 Wed Aug 21 02:15:44 2019
@@ -0,0 +1,19 @@
+import lldb
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test.decorators import *
+
+class AproposTestCase(TestBase):
+
+mydir = TestBase.compute_mydir(__file__)
+
+def setUp(self):
+TestBase.setUp(self)
+
+@no_debug_info_test
+def test_apropos(self):
+self.expect("apropos", error=True,
+substrs=[' must be called with exactly one argument'])
+self.expect("apropos a b", error=True,
+substrs=[' must be called with exactly one argument'])
+self.expect("apropos ''", error=True,
+substrs=['\'\' is not a valid search word'])

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=369506&r1=369505&r2=369506&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 21 02:15:44 2019
@@ -91,6 +91,10 @@ class CommandLineCompletionTestCase(Test
'arm64'])
 
 @skipIfFreeBSD  # timing out on the FreeBSD buildbot
+def test_plugin_load(self):
+self.complete_from_to('plugin load ', [])
+
+@skipIfFreeBSD  # timing out on the FreeBSD buildbot
 def test_quoted_command(self):
 self.complete_from_to('"set',
   ['"settings" '])

Modified: 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/plugins/commands/TestPluginCommands.py
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/functionalities/plugins/commands/TestPluginCommands.py?rev=369506&r1=369505&r2=369506&view=diff
==
--- 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/plugins/commands/TestPluginCommands.py
 (original)
+++ 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/plugins/commands/TestPluginCommands.py
 Wed Aug 21 02:15:44 2019
@@ -64,3 +64,15 @@ class PluginCommandTestCase(TestBase):
 print(retobj.GetOutput())
 
 self.expect(retobj, substrs=['abc def ghi'], exe=False)
+
+@no_debug_info_test
+def test_invalid_plugin_invocation(self):
+self.expect("plugin load a b",
+error=True, startstr="error: 'plugin load' requires one 
argument")
+self.expect("plugin load",
+error=True, startstr="error: 'plugin load' requires one 
argument")
+
+@no_debug_info_test
+def test_invalid_plugin_target(self):
+self.expect("plugin load ThisIsNotAValidPluginName",
+error=True, startstr="error: no such file")

Added: 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/reproducer/TestReproducer.py
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/functionalities/reproducer/TestReproducer.py?rev=369506&view=auto
==
--- 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/reproducer/TestReproducer.py
 (added)
+++ 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/reproducer/TestReproducer.py
 Wed Aug 21 02:15:44 2019
@@ -0,0 +1,20 @@
+import lldb
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test.decorators imp

[Lldb-commits] [lldb] r369513 - [lldb][NFC] Add tests for register command

2019-08-21 Thread Raphael Isemann via lldb-commits
Author: teemperor
Date: Wed Aug 21 03:40:05 2019
New Revision: 369513

URL: http://llvm.org/viewvc/llvm-project?rev=369513&view=rev
Log:
[lldb][NFC] Add tests for register command

Modified:

lldb/trunk/packages/Python/lldbsuite/test/functionalities/register/register_command/TestRegisters.py

Modified: 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/register/register_command/TestRegisters.py
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/functionalities/register/register_command/TestRegisters.py?rev=369513&r1=369512&r2=369513&view=diff
==
--- 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/register/register_command/TestRegisters.py
 (original)
+++ 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/register/register_command/TestRegisters.py
 Wed Aug 21 03:40:05 2019
@@ -475,3 +475,16 @@ class RegisterCommandsTestCase(TestBase)
 if test_16bit_regs:
 self.expect("expr -- $ax == (($ah << 8) | $al)",
 substrs=['true'])
+
+@skipIfiOSSimulator
+@skipIf(archs=no_match(['amd64', 'arm', 'i386', 'x86_64']))
+@expectedFailureNetBSD
+def test_invalid_invocation(self):
+self.build()
+self.common_setup()
+
+self.expect("register read -a arg", error=True,
+substrs=["the --all option can't be used when registers 
names are supplied as arguments"])
+
+self.expect("register read --set 0 r", error=True,
+substrs=["the --set  option can't be used when 
registers names are supplied as arguments"])


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


[Lldb-commits] [lldb] r369521 - [lldb] Add tests for setting completions and enable 'settings remove' completion

2019-08-21 Thread Raphael Isemann via lldb-commits
Author: teemperor
Date: Wed Aug 21 05:57:06 2019
New Revision: 369521

URL: http://llvm.org/viewvc/llvm-project?rev=369521&view=rev
Log:
[lldb] Add tests for setting completions and enable 'settings remove' completion

Modified:

lldb/trunk/packages/Python/lldbsuite/test/functionalities/completion/TestCompletion.py
lldb/trunk/source/Commands/CommandObjectSettings.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=369521&r1=369520&r2=369521&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 21 05:57:06 2019
@@ -216,6 +216,24 @@ class CommandLineCompletionTestCase(Test
 'settings replace target.run-args')
 
 @skipIfFreeBSD  # timing out on the FreeBSD buildbot
+def test_settings_show_term(self):
+self.complete_from_to(
+'settings show term-',
+'settings show term-width')
+
+@skipIfFreeBSD  # timing out on the FreeBSD buildbot
+def test_settings_list_term(self):
+self.complete_from_to(
+'settings list term-',
+'settings list term-width')
+
+@skipIfFreeBSD  # timing out on the FreeBSD buildbot
+def test_settings_remove_term(self):
+self.complete_from_to(
+'settings remove term-',
+'settings remove term-width')
+
+@skipIfFreeBSD  # timing out on the FreeBSD buildbot
 def test_settings_s(self):
 """Test that 'settings s' completes to ['set', 'show']."""
 self.complete_from_to(

Modified: lldb/trunk/source/Commands/CommandObjectSettings.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectSettings.cpp?rev=369521&r1=369520&r2=369521&view=diff
==
--- lldb/trunk/source/Commands/CommandObjectSettings.cpp (original)
+++ lldb/trunk/source/Commands/CommandObjectSettings.cpp Wed Aug 21 05:57:06 
2019
@@ -613,6 +613,8 @@ public:
 
   ~CommandObjectSettingsRemove() override = default;
 
+  bool WantsCompletion() override { return true; }
+
   int HandleArgumentCompletion(
   CompletionRequest &request,
   OptionElementVector &opt_element_vector) override {


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


[Lldb-commits] [lldb] r369524 - [lldb] Add tests for 'settings remove' and fix error message typos

2019-08-21 Thread Raphael Isemann via lldb-commits
Author: teemperor
Date: Wed Aug 21 06:24:21 2019
New Revision: 369524

URL: http://llvm.org/viewvc/llvm-project?rev=369524&view=rev
Log:
[lldb] Add tests for 'settings remove' and fix error message typos

Modified:
lldb/trunk/packages/Python/lldbsuite/test/settings/TestSettings.py
lldb/trunk/source/Commands/CommandObjectSettings.cpp

Modified: lldb/trunk/packages/Python/lldbsuite/test/settings/TestSettings.py
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/settings/TestSettings.py?rev=369524&r1=369523&r2=369524&view=diff
==
--- lldb/trunk/packages/Python/lldbsuite/test/settings/TestSettings.py 
(original)
+++ lldb/trunk/packages/Python/lldbsuite/test/settings/TestSettings.py Wed Aug 
21 06:24:21 2019
@@ -481,6 +481,45 @@ class SettingsCommandTestCase(TestBase):
 substrs=['disassembly-format (format-string) = "foo "'])
 self.runCmd("settings clear disassembly-format", check=False)
 
+def test_settings_list(self):
+# List settings (and optionally test the filter to only show 'target' 
settings).
+self.expect("settings list target", substrs=["language", "arg0", 
"detach-on-error"])
+self.expect("settings list target", matching=False, 
substrs=["packet-timeout"])
+self.expect("settings list", substrs=["language", "arg0", 
"detach-on-error", "packet-timeout"])
+
+def test_settings_remove_single(self):
+# Set some environment variables and use 'remove' to delete them.
+self.runCmd("settings set target.env-vars a=b c=d")
+self.expect("settings show target.env-vars", substrs=["a=b", "c=d"])
+self.runCmd("settings remove target.env-vars a")
+self.expect("settings show target.env-vars", matching=False, 
substrs=["a=b"])
+self.expect("settings show target.env-vars", substrs=["c=d"])
+self.runCmd("settings remove target.env-vars c")
+self.expect("settings show target.env-vars", matching=False, 
substrs=["a=b", "c=d"])
+
+def test_settings_remove_multiple(self):
+self.runCmd("settings set target.env-vars a=b c=d e=f")
+self.expect("settings show target.env-vars", substrs=["a=b", "c=d", 
"e=f"])
+self.runCmd("settings remove target.env-vars a e")
+self.expect("settings show target.env-vars", matching=False, 
substrs=["a=b", "e=f"])
+self.expect("settings show target.env-vars", substrs=["c=d"])
+
+def test_settings_remove_nonexistent_value(self):
+self.expect("settings remove target.env-vars doesntexist", error=True,
+substrs=["no value found named 'doesntexist'"])
+
+def test_settings_remove_nonexistent_settings(self):
+self.expect("settings remove doesntexist alsodoesntexist", error=True,
+substrs=["error: invalid value path 'doesntexist'"])
+
+def test_settings_remove_missing_arg(self):
+self.expect("settings remove", error=True,
+substrs=["'settings remove' takes an array or dictionary 
item, or"])
+
+def test_settings_remove_empty_arg(self):
+self.expect("settings remove ''", error=True,
+substrs=["'settings remove' command requires a valid 
variable name"])
+
 def test_all_settings_exist(self):
 self.expect("settings show",
 substrs=["auto-confirm",

Modified: lldb/trunk/source/Commands/CommandObjectSettings.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectSettings.cpp?rev=369524&r1=369523&r2=369524&view=diff
==
--- lldb/trunk/source/Commands/CommandObjectSettings.cpp (original)
+++ lldb/trunk/source/Commands/CommandObjectSettings.cpp Wed Aug 21 06:24:21 
2019
@@ -638,8 +638,8 @@ protected:
 
 const size_t argc = cmd_args.GetArgumentCount();
 if (argc == 0) {
-  result.AppendError("'settings set' takes an array or dictionary item, or 
"
- "an array followed by one or more indexes, or a "
+  result.AppendError("'settings remove' takes an array or dictionary item, 
"
+ "or an array followed by one or more indexes, or a "
  "dictionary followed by one or more key names to "
  "remove");
   result.SetStatus(eReturnStatusFailed);
@@ -649,7 +649,7 @@ protected:
 const char *var_name = cmd_args.GetArgumentAtIndex(0);
 if ((var_name == nullptr) || (var_name[0] == '\0')) {
   result.AppendError(
-  "'settings set' command requires a valid variable name");
+  "'settings remove' command requires a valid variable name");
   result.SetStatus(eReturnStatusFailed);
   return false;
 }


___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/m

[Lldb-commits] [lldb] r369530 - [lldb][NFC] Merge multiple TestApropos.py

2019-08-21 Thread Raphael Isemann via lldb-commits
Author: teemperor
Date: Wed Aug 21 07:22:59 2019
New Revision: 369530

URL: http://llvm.org/viewvc/llvm-project?rev=369530&view=rev
Log:
[lldb][NFC] Merge multiple TestApropos.py

That's cleaner and makes lldb-dotest no longer fail due to conflicting names.

Removed:
lldb/trunk/packages/Python/lldbsuite/test/help/TestApropos.py
Modified:

lldb/trunk/packages/Python/lldbsuite/test/functionalities/apropos/TestApropos.py

Modified: 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/apropos/TestApropos.py
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/functionalities/apropos/TestApropos.py?rev=369530&r1=369529&r2=369530&view=diff
==
--- 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/apropos/TestApropos.py
 (original)
+++ 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/apropos/TestApropos.py
 Wed Aug 21 07:22:59 2019
@@ -17,3 +17,13 @@ class AproposTestCase(TestBase):
 substrs=[' must be called with exactly one argument'])
 self.expect("apropos ''", error=True,
 substrs=['\'\' is not a valid search word'])
+
+@no_debug_info_test
+def test_apropos_variable(self):
+"""Test that 'apropos variable' prints the fully qualified command 
name"""
+self.expect(
+'apropos variable',
+substrs=[
+'frame variable',
+'target variable',
+'watchpoint set variable'])

Removed: lldb/trunk/packages/Python/lldbsuite/test/help/TestApropos.py
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/help/TestApropos.py?rev=369529&view=auto
==
--- lldb/trunk/packages/Python/lldbsuite/test/help/TestApropos.py (original)
+++ lldb/trunk/packages/Python/lldbsuite/test/help/TestApropos.py (removed)
@@ -1,26 +0,0 @@
-"""
-Test some lldb apropos commands.
-"""
-
-from __future__ import print_function
-
-
-import lldb
-from lldbsuite.test.decorators import *
-from lldbsuite.test.lldbtest import *
-from lldbsuite.test import lldbutil
-
-
-class AproposCommandTestCase(TestBase):
-
-mydir = TestBase.compute_mydir(__file__)
-
-@no_debug_info_test
-def test_apropos_variable(self):
-"""Test that 'apropos variable' prints the fully qualified command 
name"""
-self.expect(
-'apropos variable',
-substrs=[
-'frame variable',
-'target variable',
-'watchpoint set variable'])


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


[Lldb-commits] [lldb] r369625 - [lldb][NFC] Remove dead code that is supposed to handle invalid command options

2019-08-22 Thread Raphael Isemann via lldb-commits
Author: teemperor
Date: Thu Aug 22 01:08:05 2019
New Revision: 369625

URL: http://llvm.org/viewvc/llvm-project?rev=369625&view=rev
Log:
[lldb][NFC] Remove dead code that is supposed to handle invalid command options

Summary:
We currently have a bunch of code that is supposed to handle invalid command 
options, but
all this code is unreachable because invalid options are already handled in 
`Options::Parse`.
The only way we can reach this code is when we declare but then not implement 
an option
(which will be made impossible with D65386, which is also when we can 
completely remove
the `default` cases).

This patch replaces all this code with `llvm_unreachable` to make clear this is 
dead code
that can't be reached.

Reviewers: JDevlieghere

Reviewed By: JDevlieghere

Subscribers: lldb-commits

Tags: #lldb

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

Modified:
lldb/trunk/source/Commands/CommandObjectBreakpoint.cpp
lldb/trunk/source/Commands/CommandObjectBreakpointCommand.cpp
lldb/trunk/source/Commands/CommandObjectCommands.cpp
lldb/trunk/source/Commands/CommandObjectDisassemble.cpp
lldb/trunk/source/Commands/CommandObjectExpression.cpp
lldb/trunk/source/Commands/CommandObjectFrame.cpp
lldb/trunk/source/Commands/CommandObjectHelp.h
lldb/trunk/source/Commands/CommandObjectLog.cpp
lldb/trunk/source/Commands/CommandObjectMemory.cpp
lldb/trunk/source/Commands/CommandObjectPlatform.cpp
lldb/trunk/source/Commands/CommandObjectProcess.cpp
lldb/trunk/source/Commands/CommandObjectRegister.cpp
lldb/trunk/source/Commands/CommandObjectSettings.cpp
lldb/trunk/source/Commands/CommandObjectSource.cpp
lldb/trunk/source/Commands/CommandObjectTarget.cpp
lldb/trunk/source/Commands/CommandObjectThread.cpp
lldb/trunk/source/Commands/CommandObjectType.cpp
lldb/trunk/source/Commands/CommandObjectWatchpoint.cpp
lldb/trunk/source/Commands/CommandObjectWatchpointCommand.cpp
lldb/trunk/source/Interpreter/OptionGroupArchitecture.cpp
lldb/trunk/source/Interpreter/OptionGroupFormat.cpp
lldb/trunk/source/Interpreter/OptionGroupOutputFile.cpp
lldb/trunk/source/Interpreter/OptionGroupPlatform.cpp
lldb/trunk/source/Interpreter/OptionGroupUUID.cpp
lldb/trunk/source/Interpreter/OptionGroupValueObjectDisplay.cpp
lldb/trunk/source/Interpreter/OptionGroupVariable.cpp
lldb/trunk/source/Interpreter/OptionGroupWatchpoint.cpp

Modified: lldb/trunk/source/Commands/CommandObjectBreakpoint.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectBreakpoint.cpp?rev=369625&r1=369624&r2=369625&view=diff
==
--- lldb/trunk/source/Commands/CommandObjectBreakpoint.cpp (original)
+++ lldb/trunk/source/Commands/CommandObjectBreakpoint.cpp Thu Aug 22 01:08:05 
2019
@@ -141,9 +141,7 @@ public:
 }
 break;
 default:
-  error.SetErrorStringWithFormat("unrecognized option '%c'",
- short_option);
-  break;
+  llvm_unreachable("Unimplemented option");
 }
 
 return error;
@@ -206,9 +204,7 @@ public:
 m_use_dummy = true;
 break;
 default:
-  error.SetErrorStringWithFormat("unrecognized option '%c'",
- short_option);
-  break;
+  llvm_unreachable("Unimplemented option");
 }
 
 return error;
@@ -486,9 +482,7 @@ public:
 break;
 
   default:
-error.SetErrorStringWithFormat("unrecognized option '%c'",
-   short_option);
-break;
+llvm_unreachable("Unimplemented option");
   }
 
   return error;
@@ -1208,9 +1202,7 @@ public:
 m_internal = true;
 break;
   default:
-error.SetErrorStringWithFormat("unrecognized option '%c'",
-   short_option);
-break;
+llvm_unreachable("Unimplemented option");
   }
 
   return error;
@@ -1342,9 +1334,7 @@ public:
 break;
 
   default:
-error.SetErrorStringWithFormat("unrecognized option '%c'",
-   short_option);
-break;
+llvm_unreachable("Unimplemented option");
   }
 
   return error;
@@ -1496,9 +1486,7 @@ public:
 break;
 
   default:
-error.SetErrorStringWithFormat("unrecognized option '%c'",
-   short_option);
-break;
+llvm_unreachable("Unimplemented option");
   }
 
   return error;
@@ -1643,9 +1631,7 @@ public:
   break;
 
 default:
-  error.SetErrorStringWithFormat("unrecognized short option '%c'",
- short_option);
-  break;
+  llvm_unreachable("Unimplemented option");
 }
 return error;
   }
@@ -1713,7 +1699,8 @@ public:
   "invalid boolean value '%s' passed for -L option",

[Lldb-commits] [lldb] r369632 - [lldb][NFC] NFC cleanup for the completion code

2019-08-22 Thread Raphael Isemann via lldb-commits
Author: teemperor
Date: Thu Aug 22 02:02:54 2019
New Revision: 369632

URL: http://llvm.org/viewvc/llvm-project?rev=369632&view=rev
Log:
[lldb][NFC] NFC cleanup for the completion code

Modified:
lldb/trunk/source/Commands/CommandObjectHelp.cpp
lldb/trunk/source/Commands/CommandObjectMultiword.cpp
lldb/trunk/source/Commands/CommandObjectPlatform.cpp
lldb/trunk/source/Commands/CommandObjectProcess.cpp
lldb/trunk/source/Commands/CommandObjectSettings.cpp
lldb/trunk/source/Core/IOHandler.cpp
lldb/trunk/source/Interpreter/OptionValueEnumeration.cpp
lldb/trunk/source/Interpreter/OptionValueUUID.cpp

Modified: lldb/trunk/source/Commands/CommandObjectHelp.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectHelp.cpp?rev=369632&r1=369631&r2=369632&view=diff
==
--- lldb/trunk/source/Commands/CommandObjectHelp.cpp (original)
+++ lldb/trunk/source/Commands/CommandObjectHelp.cpp Thu Aug 22 02:02:54 2019
@@ -205,20 +205,20 @@ void CommandObjectHelp::HandleCompletion
   // Return the completions of the commands in the help system:
   if (request.GetCursorIndex() == 0) {
 m_interpreter.HandleCompletionMatches(request);
-  } else {
-CommandObject *cmd_obj =
-m_interpreter.GetCommandObject(request.GetParsedLine()[0].ref);
+return;
+  }
+  CommandObject *cmd_obj =
+  m_interpreter.GetCommandObject(request.GetParsedLine()[0].ref);
 
-// The command that they are getting help on might be ambiguous, in which
-// case we should complete that, otherwise complete with the command the
-// user is getting help on...
+  // The command that they are getting help on might be ambiguous, in which
+  // case we should complete that, otherwise complete with the command the
+  // user is getting help on...
 
-if (cmd_obj) {
-  request.GetParsedLine().Shift();
-  request.SetCursorIndex(request.GetCursorIndex() - 1);
-  cmd_obj->HandleCompletion(request);
-} else {
-  m_interpreter.HandleCompletionMatches(request);
-}
+  if (cmd_obj) {
+request.GetParsedLine().Shift();
+request.SetCursorIndex(request.GetCursorIndex() - 1);
+cmd_obj->HandleCompletion(request);
+return;
   }
+  m_interpreter.HandleCompletionMatches(request);
 }

Modified: lldb/trunk/source/Commands/CommandObjectMultiword.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectMultiword.cpp?rev=369632&r1=369631&r2=369632&view=diff
==
--- lldb/trunk/source/Commands/CommandObjectMultiword.cpp (original)
+++ lldb/trunk/source/Commands/CommandObjectMultiword.cpp Thu Aug 22 02:02:54 
2019
@@ -201,20 +201,22 @@ void CommandObjectMultiword::HandleCompl
 }
   }
 }
-  } else {
-StringList new_matches;
-CommandObject *sub_command_object = GetSubcommandObject(arg0, 
&new_matches);
-if (sub_command_object == nullptr) {
-  request.AddCompletions(new_matches);
-} else {
-  // Remove the one match that we got from calling GetSubcommandObject.
-  new_matches.DeleteStringAtIndex(0);
-  request.AddCompletions(new_matches);
-  request.GetParsedLine().Shift();
-  request.SetCursorIndex(request.GetCursorIndex() - 1);
-  return sub_command_object->HandleCompletion(request);
-}
+return;
+  }
+
+  StringList new_matches;
+  CommandObject *sub_command_object = GetSubcommandObject(arg0, &new_matches);
+  if (sub_command_object == nullptr) {
+request.AddCompletions(new_matches);
+return;
   }
+
+  // Remove the one match that we got from calling GetSubcommandObject.
+  new_matches.DeleteStringAtIndex(0);
+  request.AddCompletions(new_matches);
+  request.GetParsedLine().Shift();
+  request.SetCursorIndex(request.GetCursorIndex() - 1);
+  sub_command_object->HandleCompletion(request);
 }
 
 const char *CommandObjectMultiword::GetRepeatCommand(Args 
¤t_command_args,

Modified: lldb/trunk/source/Commands/CommandObjectPlatform.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectPlatform.cpp?rev=369632&r1=369631&r2=369632&view=diff
==
--- lldb/trunk/source/Commands/CommandObjectPlatform.cpp (original)
+++ lldb/trunk/source/Commands/CommandObjectPlatform.cpp Thu Aug 22 02:02:54 
2019
@@ -1440,36 +1440,37 @@ public:
 
   // We are only completing the name option for now...
 
-  if (GetDefinitions()[opt_defs_index].short_option == 'n') {
-// Are we in the name?
-
-// Look to see if there is a -P argument provided, and if so use that
-// plugin, otherwise use the default plugin.
-
-const char *partial_name = nullptr;
-partial_name = request.GetParsedLine().GetArgumentAtIndex(opt_arg_pos);
-
-PlatformSP platform_sp(interpreter.GetPlatform(true));
-

[Lldb-commits] [lldb] r369635 - [lldb][NFC] Remove unused return value from HandleOptionArgumentCompletion

2019-08-22 Thread Raphael Isemann via lldb-commits
Author: teemperor
Date: Thu Aug 22 02:14:42 2019
New Revision: 369635

URL: http://llvm.org/viewvc/llvm-project?rev=369635&view=rev
Log:
[lldb][NFC] Remove unused return value from HandleOptionArgumentCompletion

Modified:
lldb/trunk/include/lldb/Interpreter/Options.h
lldb/trunk/source/Commands/CommandObjectPlatform.cpp
lldb/trunk/source/Commands/CommandObjectProcess.cpp
lldb/trunk/source/Interpreter/Options.cpp

Modified: lldb/trunk/include/lldb/Interpreter/Options.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Interpreter/Options.h?rev=369635&r1=369634&r2=369635&view=diff
==
--- lldb/trunk/include/lldb/Interpreter/Options.h (original)
+++ lldb/trunk/include/lldb/Interpreter/Options.h Thu Aug 22 02:14:42 2019
@@ -187,14 +187,7 @@ public:
   ///
   /// \param[in] interpreter
   ///The command interpreter doing the completion.
-  ///
-  /// FIXME: This is the wrong return value, since we also need to
-  /// make a distinction between total number of matches, and the window the
-  /// user wants returned.
-  ///
-  /// \return
-  /// \btrue if we were in an option, \bfalse otherwise.
-  virtual bool
+  virtual void
   HandleOptionArgumentCompletion(lldb_private::CompletionRequest &request,
  OptionElementVector &opt_element_vector,
  int opt_element_index,

Modified: lldb/trunk/source/Commands/CommandObjectPlatform.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectPlatform.cpp?rev=369635&r1=369634&r2=369635&view=diff
==
--- lldb/trunk/source/Commands/CommandObjectPlatform.cpp (original)
+++ lldb/trunk/source/Commands/CommandObjectPlatform.cpp Thu Aug 22 02:14:42 
2019
@@ -1432,7 +1432,7 @@ public:
   return llvm::makeArrayRef(g_platform_process_attach_options);
 }
 
-bool HandleOptionArgumentCompletion(
+void HandleOptionArgumentCompletion(
 CompletionRequest &request, OptionElementVector &opt_element_vector,
 int opt_element_index, CommandInterpreter &interpreter) override {
   int opt_arg_pos = opt_element_vector[opt_element_index].opt_arg_pos;
@@ -1442,7 +1442,7 @@ public:
 
   // Are we in the name?
   if (GetDefinitions()[opt_defs_index].short_option != 'n')
-return false;
+return;
 
   // Look to see if there is a -P argument provided, and if so use that
   // plugin, otherwise use the default plugin.
@@ -1452,7 +1452,7 @@ public:
 
   PlatformSP platform_sp(interpreter.GetPlatform(true));
   if (!platform_sp)
-return false;
+return;
 
   ProcessInstanceInfoList process_infos;
   ProcessInstanceInfoMatch match_info;
@@ -1464,14 +1464,14 @@ public:
   platform_sp->FindProcesses(match_info, process_infos);
   const uint32_t num_matches = process_infos.GetSize();
   if (num_matches == 0)
-return false;
+return;
 
   for (uint32_t i = 0; i < num_matches; ++i) {
 request.AddCompletion(
 llvm::StringRef(process_infos.GetProcessNameAtIndex(i),
 process_infos.GetProcessNameLengthAtIndex(i)));
   }
-  return false;
+  return;
 }
 
 // Options table: Required for subclasses of Options.

Modified: lldb/trunk/source/Commands/CommandObjectProcess.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectProcess.cpp?rev=369635&r1=369634&r2=369635&view=diff
==
--- lldb/trunk/source/Commands/CommandObjectProcess.cpp (original)
+++ lldb/trunk/source/Commands/CommandObjectProcess.cpp Thu Aug 22 02:14:42 2019
@@ -320,7 +320,7 @@ public:
   return llvm::makeArrayRef(g_process_attach_options);
 }
 
-bool HandleOptionArgumentCompletion(
+void HandleOptionArgumentCompletion(
 CompletionRequest &request, OptionElementVector &opt_element_vector,
 int opt_element_index, CommandInterpreter &interpreter) override {
   int opt_arg_pos = opt_element_vector[opt_element_index].opt_arg_pos;
@@ -330,7 +330,7 @@ public:
 
   // Are we in the name?
   if (GetDefinitions()[opt_defs_index].short_option != 'n')
-return false;
+return;
 
   // Look to see if there is a -P argument provided, and if so use that
   // plugin, otherwise use the default plugin.
@@ -340,7 +340,7 @@ public:
 
   PlatformSP platform_sp(interpreter.GetPlatform(true));
   if (!platform_sp)
-return false;
+return;
   ProcessInstanceInfoList process_infos;
   ProcessInstanceInfoMatch match_info;
   if (partial_name) {
@@ -351,14 +351,12 @@ public:
   platform_sp->FindProcesses(match_info, process_infos);
   const size_t num_matches = process_infos.GetSize();

[Lldb-commits] [lldb] r369646 - [lldb][NFC] Add test for target stop-hook disable/enable/delete

2019-08-22 Thread Raphael Isemann via lldb-commits
Author: teemperor
Date: Thu Aug 22 06:09:02 2019
New Revision: 369646

URL: http://llvm.org/viewvc/llvm-project?rev=369646&view=rev
Log:
[lldb][NFC] Add test for target stop-hook disable/enable/delete

Modified:

lldb/trunk/packages/Python/lldbsuite/test/functionalities/target_command/TestTargetCommand.py

Modified: 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/target_command/TestTargetCommand.py
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/functionalities/target_command/TestTargetCommand.py?rev=369646&r1=369645&r2=369646&view=diff
==
--- 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/target_command/TestTargetCommand.py
 (original)
+++ 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/target_command/TestTargetCommand.py
 Thu Aug 22 06:09:02 2019
@@ -22,20 +22,25 @@ class targetCommandTestCase(TestBase):
 self.line_b = line_number('b.c', '// Set break point at this line.')
 self.line_c = line_number('c.c', '// Set break point at this line.')
 
-def test_target_command(self):
-"""Test some target commands: create, list, select."""
+def buildB(self):
+db = {'C_SOURCES': 'b.c', 'EXE': self.getBuildArtifact('b.out')}
+self.build(dictionary=db)
+self.addTearDownCleanup(dictionary=db)
+
+def buildAll(self):
 da = {'C_SOURCES': 'a.c', 'EXE': self.getBuildArtifact('a.out')}
 self.build(dictionary=da)
 self.addTearDownCleanup(dictionary=da)
 
-db = {'C_SOURCES': 'b.c', 'EXE': self.getBuildArtifact('b.out')}
-self.build(dictionary=db)
-self.addTearDownCleanup(dictionary=db)
+self.buildB()
 
 dc = {'C_SOURCES': 'c.c', 'EXE': self.getBuildArtifact('c.out')}
 self.build(dictionary=dc)
 self.addTearDownCleanup(dictionary=dc)
 
+def test_target_command(self):
+"""Test some target commands: create, list, select."""
+self.buildAll()
 self.do_target_command()
 
 def test_target_variable_command(self):
@@ -270,3 +275,21 @@ class targetCommandTestCase(TestBase):
 substrs=[
 "my_global_char",
 "'X'"])
+
+@no_debug_info_test
+def test_target_stop_hook_disable_enable(self):
+self.buildB()
+self.runCmd("file " + self.getBuildArtifact("b.out"), 
CURRENT_EXECUTABLE_SET)
+
+self.expect("target stop-hook disable 1", error=True, 
substrs=['unknown stop hook id: "1"'])
+self.expect("target stop-hook disable blub", error=True, 
substrs=['invalid stop hook id: "blub"'])
+self.expect("target stop-hook enable 1", error=True, substrs=['unknown 
stop hook id: "1"'])
+self.expect("target stop-hook enable blub", error=True, 
substrs=['invalid stop hook id: "blub"'])
+
+@no_debug_info_test
+def test_target_stop_hook_delete(self):
+self.buildB()
+self.runCmd("file " + self.getBuildArtifact("b.out"), 
CURRENT_EXECUTABLE_SET)
+
+self.expect("target stop-hook delete 1", error=True, substrs=['unknown 
stop hook id: "1"'])
+self.expect("target stop-hook delete blub", error=True, 
substrs=['invalid stop hook id: "blub"'])


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


[Lldb-commits] [lldb] r369652 - [lldb][NFC] Fix indentation in CommandObjectProcess

2019-08-22 Thread Raphael Isemann via lldb-commits
Author: teemperor
Date: Thu Aug 22 06:50:54 2019
New Revision: 369652

URL: http://llvm.org/viewvc/llvm-project?rev=369652&view=rev
Log:
[lldb][NFC] Fix indentation in CommandObjectProcess

Modified:
lldb/trunk/source/Commands/CommandObjectProcess.cpp

Modified: lldb/trunk/source/Commands/CommandObjectProcess.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectProcess.cpp?rev=369652&r1=369651&r2=369652&view=diff
==
--- lldb/trunk/source/Commands/CommandObjectProcess.cpp (original)
+++ lldb/trunk/source/Commands/CommandObjectProcess.cpp Thu Aug 22 06:50:54 2019
@@ -348,15 +348,15 @@ public:
 partial_name, FileSpec::Style::native);
 match_info.SetNameMatchType(NameMatch::StartsWith);
   }
-  platform_sp->FindProcesses(match_info, process_infos);
-  const size_t num_matches = process_infos.GetSize();
-  if (num_matches == 0)
-return;
-  for (size_t i = 0; i < num_matches; ++i) {
-request.AddCompletion(
-llvm::StringRef(process_infos.GetProcessNameAtIndex(i),
-process_infos.GetProcessNameLengthAtIndex(i)));
-  }
+  platform_sp->FindProcesses(match_info, process_infos);
+  const size_t num_matches = process_infos.GetSize();
+  if (num_matches == 0)
+return;
+  for (size_t i = 0; i < num_matches; ++i) {
+request.AddCompletion(
+llvm::StringRef(process_infos.GetProcessNameAtIndex(i),
+process_infos.GetProcessNameLengthAtIndex(i;
+  }
 }
 
 // Instance variables to hold the values for command options.


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


[Lldb-commits] [lldb] r369660 - [lldb] Remove ')' to fix the build

2019-08-22 Thread Raphael Isemann via lldb-commits
Author: teemperor
Date: Thu Aug 22 08:18:40 2019
New Revision: 369660

URL: http://llvm.org/viewvc/llvm-project?rev=369660&view=rev
Log:
[lldb] Remove ')' to fix the build

That ')' slipped in by accident in the reformatting commit.

Modified:
lldb/trunk/source/Commands/CommandObjectProcess.cpp

Modified: lldb/trunk/source/Commands/CommandObjectProcess.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectProcess.cpp?rev=369660&r1=369659&r2=369660&view=diff
==
--- lldb/trunk/source/Commands/CommandObjectProcess.cpp (original)
+++ lldb/trunk/source/Commands/CommandObjectProcess.cpp Thu Aug 22 08:18:40 2019
@@ -355,7 +355,7 @@ public:
   for (size_t i = 0; i < num_matches; ++i) {
 request.AddCompletion(
 llvm::StringRef(process_infos.GetProcessNameAtIndex(i),
-process_infos.GetProcessNameLengthAtIndex(i;
+process_infos.GetProcessNameLengthAtIndex(i)));
   }
 }
 


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


[Lldb-commits] [lldb] r369880 - [lldb][NFC] Add ProcessInfo::GetNameAsStringRef to simplify some code

2019-08-26 Thread Raphael Isemann via lldb-commits
Author: teemperor
Date: Mon Aug 26 01:22:52 2019
New Revision: 369880

URL: http://llvm.org/viewvc/llvm-project?rev=369880&view=rev
Log:
[lldb][NFC] Add ProcessInfo::GetNameAsStringRef to simplify some code

Modified:
lldb/trunk/include/lldb/Utility/ProcessInfo.h
lldb/trunk/source/Commands/CommandObjectPlatform.cpp
lldb/trunk/source/Commands/CommandObjectProcess.cpp
lldb/trunk/source/Utility/ProcessInfo.cpp

Modified: lldb/trunk/include/lldb/Utility/ProcessInfo.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Utility/ProcessInfo.h?rev=369880&r1=369879&r2=369880&view=diff
==
--- lldb/trunk/include/lldb/Utility/ProcessInfo.h (original)
+++ lldb/trunk/include/lldb/Utility/ProcessInfo.h Mon Aug 26 01:22:52 2019
@@ -38,7 +38,7 @@ public:
 
   const char *GetName() const;
 
-  size_t GetNameLength() const;
+  llvm::StringRef GetNameAsStringRef() const;
 
   FileSpec &GetExecutableFile() { return m_executable; }
 
@@ -165,12 +165,8 @@ public:
 
   void Append(const ProcessInstanceInfo &info) { m_infos.push_back(info); }
 
-  const char *GetProcessNameAtIndex(size_t idx) {
-return ((idx < m_infos.size()) ? m_infos[idx].GetName() : nullptr);
-  }
-
-  size_t GetProcessNameLengthAtIndex(size_t idx) {
-return ((idx < m_infos.size()) ? m_infos[idx].GetNameLength() : 0);
+  llvm::StringRef GetProcessNameAtIndex(size_t idx) {
+return ((idx < m_infos.size()) ? m_infos[idx].GetNameAsStringRef() : "");
   }
 
   lldb::pid_t GetProcessIDAtIndex(size_t idx) {

Modified: lldb/trunk/source/Commands/CommandObjectPlatform.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectPlatform.cpp?rev=369880&r1=369879&r2=369880&view=diff
==
--- lldb/trunk/source/Commands/CommandObjectPlatform.cpp (original)
+++ lldb/trunk/source/Commands/CommandObjectPlatform.cpp Mon Aug 26 01:22:52 
2019
@@ -1467,9 +1467,7 @@ public:
 return;
 
   for (uint32_t i = 0; i < num_matches; ++i) {
-request.AddCompletion(
-llvm::StringRef(process_infos.GetProcessNameAtIndex(i),
-process_infos.GetProcessNameLengthAtIndex(i)));
+request.AddCompletion(process_infos.GetProcessNameAtIndex(i));
   }
   return;
 }

Modified: lldb/trunk/source/Commands/CommandObjectProcess.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectProcess.cpp?rev=369880&r1=369879&r2=369880&view=diff
==
--- lldb/trunk/source/Commands/CommandObjectProcess.cpp (original)
+++ lldb/trunk/source/Commands/CommandObjectProcess.cpp Mon Aug 26 01:22:52 2019
@@ -353,9 +353,7 @@ public:
   if (num_matches == 0)
 return;
   for (size_t i = 0; i < num_matches; ++i) {
-request.AddCompletion(
-llvm::StringRef(process_infos.GetProcessNameAtIndex(i),
-process_infos.GetProcessNameLengthAtIndex(i)));
+request.AddCompletion(process_infos.GetProcessNameAtIndex(i));
   }
 }
 

Modified: lldb/trunk/source/Utility/ProcessInfo.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Utility/ProcessInfo.cpp?rev=369880&r1=369879&r2=369880&view=diff
==
--- lldb/trunk/source/Utility/ProcessInfo.cpp (original)
+++ lldb/trunk/source/Utility/ProcessInfo.cpp Mon Aug 26 01:22:52 2019
@@ -42,8 +42,8 @@ const char *ProcessInfo::GetName() const
   return m_executable.GetFilename().GetCString();
 }
 
-size_t ProcessInfo::GetNameLength() const {
-  return m_executable.GetFilename().GetLength();
+llvm::StringRef ProcessInfo::GetNameAsStringRef() const {
+  return m_executable.GetFilename().GetStringRef();
 }
 
 void ProcessInfo::Dump(Stream &s, Platform *platform) const {


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


[Lldb-commits] [lldb] r369885 - [lldb] Construct the dummy target when the first Debugger object is constructed

2019-08-26 Thread Raphael Isemann via lldb-commits
Author: teemperor
Date: Mon Aug 26 02:20:59 2019
New Revision: 369885

URL: http://llvm.org/viewvc/llvm-project?rev=369885&view=rev
Log:
[lldb] Construct the dummy target when the first Debugger object is constructed

Summary:
We should always have a dummy target, so we might as well construct it directly 
when we create a Debugger object.

The idea is that if this patch doesn't cause any problems that we can get rid 
of all the logic
that handles situations where we don't have a dummy target (as all that code is 
currently
untested as there seems to be no way to have no dummy target in LLDB).

Reviewers: labath, jingham

Reviewed By: labath, jingham

Subscribers: jingham, abidh, lldb-commits

Tags: #lldb

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

Modified:
lldb/trunk/include/lldb/Core/Debugger.h
lldb/trunk/source/Core/Debugger.cpp

Modified: lldb/trunk/include/lldb/Core/Debugger.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/Debugger.h?rev=369885&r1=369884&r2=369885&view=diff
==
--- lldb/trunk/include/lldb/Core/Debugger.h (original)
+++ lldb/trunk/include/lldb/Core/Debugger.h Mon Aug 26 02:20:59 2019
@@ -311,7 +311,7 @@ public:
   // selected target, or if no target is present you want to prime the dummy
   // target with entities that will be copied over to new targets.
   Target *GetSelectedOrDummyTarget(bool prefer_dummy = false);
-  Target *GetDummyTarget();
+  Target *GetDummyTarget() { return m_dummy_target_sp.get(); }
 
   lldb::BroadcasterManagerSP GetBroadcasterManager() {
 return m_broadcaster_manager_sp;
@@ -400,6 +400,7 @@ protected:
   Broadcaster m_sync_broadcaster;
   lldb::ListenerSP m_forward_listener_sp;
   llvm::once_flag m_clear_once;
+  lldb::TargetSP m_dummy_target_sp;
 
   // Events for m_sync_broadcaster
   enum {

Modified: lldb/trunk/source/Core/Debugger.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/Debugger.cpp?rev=369885&r1=369884&r2=369885&view=diff
==
--- lldb/trunk/source/Core/Debugger.cpp (original)
+++ lldb/trunk/source/Core/Debugger.cpp Mon Aug 26 02:20:59 2019
@@ -721,6 +721,9 @@ Debugger::Debugger(lldb::LogOutputCallba
   assert(default_platform_sp);
   m_platform_list.Append(default_platform_sp, true);
 
+  m_dummy_target_sp = m_target_list.GetDummyTarget(*this);
+  assert(m_dummy_target_sp.get() && "Couldn't construct dummy target?");
+
   m_collection_sp->Initialize(g_debugger_properties);
   m_collection_sp->AppendProperty(
   ConstString("target"),
@@ -1603,10 +1606,6 @@ void Debugger::JoinIOHandlerThread() {
   }
 }
 
-Target *Debugger::GetDummyTarget() {
-  return m_target_list.GetDummyTarget(*this).get();
-}
-
 Target *Debugger::GetSelectedOrDummyTarget(bool prefer_dummy) {
   Target *target = nullptr;
   if (!prefer_dummy) {


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


[Lldb-commits] [lldb] r369939 - [lldb][NFC] Remove dead code that handles situations where LLDB has no dummy target

2019-08-26 Thread Raphael Isemann via lldb-commits
Author: teemperor
Date: Mon Aug 26 11:12:44 2019
New Revision: 369939

URL: http://llvm.org/viewvc/llvm-project?rev=369939&view=rev
Log:
[lldb][NFC] Remove dead code that handles situations where LLDB has no dummy 
target

Summary:
We always have a dummy target, so any error handling regarding a missing dummy 
target is dead code now.
Also makes the CommandObject methods that return Target& to express this fact 
in the API.

This patch just for the CommandObject part of LLDB. I'll migrate the rest of 
LLDB in a follow-up patch that's WIP.

Reviewers: labath

Reviewed By: labath

Subscribers: abidh, lldb-commits

Tags: #lldb

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

Modified:
lldb/trunk/include/lldb/Interpreter/CommandObject.h
lldb/trunk/source/Commands/CommandObjectBreakpoint.cpp
lldb/trunk/source/Commands/CommandObjectBreakpointCommand.cpp
lldb/trunk/source/Commands/CommandObjectExpression.cpp
lldb/trunk/source/Commands/CommandObjectFrame.cpp
lldb/trunk/source/Commands/CommandObjectStats.cpp
lldb/trunk/source/Commands/CommandObjectTarget.cpp
lldb/trunk/source/Interpreter/CommandObject.cpp

lldb/trunk/source/Plugins/StructuredData/DarwinLog/StructuredDataDarwinLog.cpp

Modified: lldb/trunk/include/lldb/Interpreter/CommandObject.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Interpreter/CommandObject.h?rev=369939&r1=369938&r2=369939&view=diff
==
--- lldb/trunk/include/lldb/Interpreter/CommandObject.h (original)
+++ lldb/trunk/include/lldb/Interpreter/CommandObject.h Mon Aug 26 11:12:44 2019
@@ -340,8 +340,8 @@ protected:
   // This is for use in the command interpreter, when you either want the
   // selected target, or if no target is present you want to prime the dummy
   // target with entities that will be copied over to new targets.
-  Target *GetSelectedOrDummyTarget(bool prefer_dummy = false);
-  Target *GetDummyTarget();
+  Target &GetSelectedOrDummyTarget(bool prefer_dummy = false);
+  Target &GetDummyTarget();
 
   // If a command needs to use the "current" thread, use this call. Command
   // objects will have an ExecutionContext to use, and that may or may not have

Modified: lldb/trunk/source/Commands/CommandObjectBreakpoint.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectBreakpoint.cpp?rev=369939&r1=369938&r2=369939&view=diff
==
--- lldb/trunk/source/Commands/CommandObjectBreakpoint.cpp (original)
+++ lldb/trunk/source/Commands/CommandObjectBreakpoint.cpp Mon Aug 26 11:12:44 
2019
@@ -550,14 +550,7 @@ public:
 
 protected:
   bool DoExecute(Args &command, CommandReturnObject &result) override {
-Target *target = GetSelectedOrDummyTarget(m_dummy_options.m_use_dummy);
-
-if (target == nullptr) {
-  result.AppendError("Invalid target.  Must set target before setting "
- "breakpoints (see 'target create' command).");
-  result.SetStatus(eReturnStatusFailed);
-  return false;
-}
+Target &target = GetSelectedOrDummyTarget(m_dummy_options.m_use_dummy);
 
 // The following are the various types of breakpoints that could be set:
 //   1).  -f -l -p  [-s -g]   (setting breakpoint by source location)
@@ -619,16 +612,11 @@ protected:
   // Only check for inline functions if
   LazyBool check_inlines = eLazyBoolCalculate;
 
-  bp_sp = target->CreateBreakpoint(&(m_options.m_modules), 
-   file,
-   m_options.m_line_num,
-   m_options.m_column,
-   m_options.m_offset_addr,
-   check_inlines, 
-   m_options.m_skip_prologue,
-   internal, 
-   m_options.m_hardware,
-   m_options.m_move_to_nearest_code);
+  bp_sp = target.CreateBreakpoint(
+  &(m_options.m_modules), file, m_options.m_line_num,
+  m_options.m_column, m_options.m_offset_addr, check_inlines,
+  m_options.m_skip_prologue, internal, m_options.m_hardware,
+  m_options.m_move_to_nearest_code);
 } break;
 
 case eSetTypeAddress: // Breakpoint by address
@@ -640,12 +628,11 @@ protected:
   if (num_modules_specified == 1) {
 const FileSpec *file_spec =
 m_options.m_modules.GetFileSpecPointerAtIndex(0);
-bp_sp = target->CreateAddressInModuleBreakpoint(m_options.m_load_addr,
-internal, file_spec,
-m_options.m_hardware);
+bp_sp = target.CreateAddressInModuleBreakpoint(
+m_options.m_load_addr, internal, file_

[Lldb-commits] [lldb] r370043 - [lldb] Allow partial completions to fix directory completion.

2019-08-27 Thread Raphael Isemann via lldb-commits
Author: teemperor
Date: Tue Aug 27 04:32:22 2019
New Revision: 370043

URL: http://llvm.org/viewvc/llvm-project?rev=370043&view=rev
Log:
[lldb] Allow partial completions to fix directory completion.

On the command line we usually insert a space after a completion to indicate 
that
the completion was successful. After the completion API refactoring, this also
happens with directories which essentially breaks file path completion (as
adding a space terminates the path and starts a new arg). This patch restores 
the old
behavior by again allowing partial completions. Also extends the iohandler
and SB API tests as the implementation for this is different in Editline
and SB API.

Modified:
lldb/trunk/include/lldb/Utility/CompletionRequest.h

lldb/trunk/packages/Python/lldbsuite/test/functionalities/completion/TestCompletion.py

lldb/trunk/packages/Python/lldbsuite/test/iohandler/completion/TestIOHandlerCompletion.py
lldb/trunk/source/Commands/CommandCompletions.cpp
lldb/trunk/source/Host/common/Editline.cpp

Modified: lldb/trunk/include/lldb/Utility/CompletionRequest.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Utility/CompletionRequest.h?rev=370043&r1=370042&r2=370043&view=diff
==
--- lldb/trunk/include/lldb/Utility/CompletionRequest.h (original)
+++ lldb/trunk/include/lldb/Utility/CompletionRequest.h Tue Aug 27 04:32:22 2019
@@ -17,7 +17,15 @@
 
 namespace lldb_private {
 enum class CompletionMode {
+  // The current token has been completed.
   Normal,
+  // The current token has been partially completed. This means that we found
+  // a completion, but that the completed token is still incomplete. Examples
+  // for this are file paths, where we want to complete "/bi" to "/bin/", but
+  // the file path token is still incomplete after the completion. Clients
+  // should not indicate to the user that this is a full completion (e.g. by
+  // not inserting the usual trailing space after a successful completion).
+  Partial,
   // The full line has been rewritten by the completion.
   RewriteLine,
 };

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=370043&r1=370042&r2=370043&view=diff
==
--- 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/completion/TestCompletion.py
 (original)
+++ 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/completion/TestCompletion.py
 Tue Aug 27 04:32:22 2019
@@ -137,6 +137,13 @@ class CommandLineCompletionTestCase(Test
 self.complete_from_to('log enable lldb expr -f ' + src_dir,
   ['main.cpp'])
 
+@skipIfFreeBSD  # timing out on the FreeBSD buildbot
+def test_log_file(self):
+# Complete in our source directory which contains a 'main.cpp' file.
+src_dir =  os.path.dirname(os.path.realpath(__file__))
+self.complete_from_to('log enable lldb expr -f ' + src_dir,
+  [src_dir + "/"])
+
 # 
 @skipIfFreeBSD  # timing out on the FreeBSD buildbot
 def test_infinite_loop_while_completing(self):

Modified: 
lldb/trunk/packages/Python/lldbsuite/test/iohandler/completion/TestIOHandlerCompletion.py
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/iohandler/completion/TestIOHandlerCompletion.py?rev=370043&r1=370042&r2=370043&view=diff
==
--- 
lldb/trunk/packages/Python/lldbsuite/test/iohandler/completion/TestIOHandlerCompletion.py
 (original)
+++ 
lldb/trunk/packages/Python/lldbsuite/test/iohandler/completion/TestIOHandlerCompletion.py
 Tue Aug 27 04:32:22 2019
@@ -2,6 +2,8 @@
 Test completion in our IOHandlers.
 """
 
+import os
+
 import lldb
 from lldbsuite.test.decorators import *
 from lldbsuite.test.lldbtest import *
@@ -48,6 +50,18 @@ class IOHandlerCompletionTest(TestBase):
 self.expect_string(prompt + "register")
 self.child.send("\n")
 
+# Try tab completing directories and files. Also tests the partial
+# completion where LLDB shouldn't print a space after the directory
+# completion (as it didn't completed the full token).
+dir_without_slashes = 
os.path.realpath(os.path.dirname(__file__)).rstrip("/")
+self.child.send("file " + dir_without_slashes + "\t")
+self.expect_string("iohandler/completion/")
+# If we get a correct partial completion without a trailing space, 
then this
+# should complete the current test file.
+self.child.send("TestIOHandler\t")
+self.expect_string("TestIOHandlerCompletion.py")
+self.child.send("\n")
+
 # Start tab completion and abort showing 

[Lldb-commits] [lldb] r370047 - [lldb][NFC] Give added test method a unique name

2019-08-27 Thread Raphael Isemann via lldb-commits
Author: teemperor
Date: Tue Aug 27 04:43:54 2019
New Revision: 370047

URL: http://llvm.org/viewvc/llvm-project?rev=370047&view=rev
Log:
[lldb][NFC] Give added test method a unique name

Otherwise dotest doesn't run the test and just lets it always pass.
Also update the comment to explain that we do directory and not
file completion.

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=370047&r1=370046&r2=370047&view=diff
==
--- 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/completion/TestCompletion.py
 (original)
+++ 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/completion/TestCompletion.py
 Tue Aug 27 04:43:54 2019
@@ -138,8 +138,8 @@ class CommandLineCompletionTestCase(Test
   ['main.cpp'])
 
 @skipIfFreeBSD  # timing out on the FreeBSD buildbot
-def test_log_file(self):
-# Complete in our source directory which contains a 'main.cpp' file.
+def test_log_dir(self):
+# Complete our source directory.
 src_dir =  os.path.dirname(os.path.realpath(__file__))
 self.complete_from_to('log enable lldb expr -f ' + src_dir,
   [src_dir + "/"])


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


[Lldb-commits] [lldb] r370050 - [lldb][NFC] Add some tests for the target subcommands

2019-08-27 Thread Raphael Isemann via lldb-commits
Author: teemperor
Date: Tue Aug 27 04:57:26 2019
New Revision: 370050

URL: http://llvm.org/viewvc/llvm-project?rev=370050&view=rev
Log:
[lldb][NFC] Add some tests for the target subcommands

Modified:

lldb/trunk/packages/Python/lldbsuite/test/functionalities/target_command/TestTargetCommand.py

Modified: 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/target_command/TestTargetCommand.py
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/functionalities/target_command/TestTargetCommand.py?rev=370050&r1=370049&r2=370050&view=diff
==
--- 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/target_command/TestTargetCommand.py
 (original)
+++ 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/target_command/TestTargetCommand.py
 Tue Aug 27 04:57:26 2019
@@ -3,7 +3,9 @@ Test some target commands: create, list,
 """
 
 from __future__ import print_function
-
+import os
+import stat
+import tempfile
 
 import lldb
 from lldbsuite.test.decorators import *
@@ -293,3 +295,145 @@ class targetCommandTestCase(TestBase):
 
 self.expect("target stop-hook delete 1", error=True, substrs=['unknown 
stop hook id: "1"'])
 self.expect("target stop-hook delete blub", error=True, 
substrs=['invalid stop hook id: "blub"'])
+
+@no_debug_info_test
+def test_target_list_args(self):
+self.expect("target list blub", error=True,
+substrs=["the 'target list' command takes no arguments"])
+
+@no_debug_info_test
+def test_target_select_no_index(self):
+self.expect("target select", error=True,
+substrs=["'target select' takes a single argument: a 
target index"])
+
+@no_debug_info_test
+def test_target_select_invalid_index(self):
+self.runCmd("target delete --all")
+self.expect("target select 0", error=True,
+substrs=["index 0 is out of range since there are no 
active targets"])
+self.buildB()
+self.runCmd("file " + self.getBuildArtifact("b.out"), 
CURRENT_EXECUTABLE_SET)
+self.expect("target select 1", error=True,
+substrs=["index 1 is out of range, valid target indexes 
are 0 - 0"])
+
+
+@no_debug_info_test
+def test_target_create_multiple_args(self):
+self.expect("target create a b", error=True,
+substrs=["'target create' takes exactly one executable 
path"])
+
+@no_debug_info_test
+def test_target_create_nonexistent_core_file(self):
+self.expect("target create -c doesntexist", error=True,
+substrs=["core file 'doesntexist' doesn't exist"])
+
+# Write only files don't seem to be supported on Windows.
+@skipIfWindows
+@no_debug_info_test
+def test_target_create_unreadable_core_file(self):
+tf = tempfile.NamedTemporaryFile()
+os.chmod(tf.name, stat.S_IWRITE)
+self.expect("target create -c '" + tf.name + "'", error=True,
+substrs=["core file '", "' is not readable"])
+
+@no_debug_info_test
+def test_target_create_nonexistent_sym_file(self):
+self.expect("target create -s doesntexist doesntexisteither", 
error=True,
+substrs=["invalid symbol file path 'doesntexist'"])
+
+@no_debug_info_test
+def test_target_create_invalid_core_file(self):
+invalid_core_path = os.path.join(self.getSourceDir(), 
"invalid_core_file")
+self.expect("target create -c '" + invalid_core_path + "'", error=True,
+substrs=["Unable to find process plug-in for core file '"])
+
+
+# Write only files don't seem to be supported on Windows.
+@skipIfWindows
+@no_debug_info_test
+def test_target_create_unreadable_sym_file(self):
+tf = tempfile.NamedTemporaryFile()
+os.chmod(tf.name, stat.S_IWRITE)
+self.expect("target create -s '" + tf.name + "' no_exe", error=True,
+substrs=["symbol file '", "' is not readable"])
+
+@no_debug_info_test
+def test_target_delete_all(self):
+self.buildAll()
+self.runCmd("file " + self.getBuildArtifact("a.out"), 
CURRENT_EXECUTABLE_SET)
+self.runCmd("file " + self.getBuildArtifact("b.out"), 
CURRENT_EXECUTABLE_SET)
+self.expect("target delete --all")
+self.expect("target list", substrs=["No targets."])
+
+@no_debug_info_test
+def test_target_delete_by_index(self):
+self.buildAll()
+self.runCmd("file " + self.getBuildArtifact("a.out"), 
CURRENT_EXECUTABLE_SET)
+self.runCmd("file " + self.getBuildArtifact("b.out"), 
CURRENT_EXECUTABLE_SET)
+self.runCmd("file " + self.getBuildArtifact("c.out"), 
CURRENT_EXECUTABLE_SET)
+self.expect("target delete 3", error=True,
+substrs=["target index 3 is out of range, valid target 
indexes are 0 - 2"])
+
+self.runC

[Lldb-commits] [lldb] r370057 - [lldb][NFC] Add missing invalid_core_file to TestTargetCommand test

2019-08-27 Thread Raphael Isemann via lldb-commits
Author: teemperor
Date: Tue Aug 27 06:34:15 2019
New Revision: 370057

URL: http://llvm.org/viewvc/llvm-project?rev=370057&view=rev
Log:
[lldb][NFC] Add missing invalid_core_file to TestTargetCommand test

Added:

lldb/trunk/packages/Python/lldbsuite/test/functionalities/target_command/invalid_core_file

Added: 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/target_command/invalid_core_file
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/functionalities/target_command/invalid_core_file?rev=370057&view=auto
==
--- 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/target_command/invalid_core_file
 (added)
+++ 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/target_command/invalid_core_file
 Tue Aug 27 06:34:15 2019
@@ -0,0 +1 @@
+stub


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


[Lldb-commits] [lldb] r370174 - [lldb][NFC] Update documentation of Handle[Argument]Completion

2019-08-28 Thread Raphael Isemann via lldb-commits
Author: teemperor
Date: Wed Aug 28 02:02:32 2019
New Revision: 370174

URL: http://llvm.org/viewvc/llvm-project?rev=370174&view=rev
Log:
[lldb][NFC] Update documentation of Handle[Argument]Completion

We no longer have return values or any of the mentioned arguments
in these functions since the introduction of CompletionRequest.

Modified:
lldb/trunk/include/lldb/Interpreter/CommandObject.h

Modified: lldb/trunk/include/lldb/Interpreter/CommandObject.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Interpreter/CommandObject.h?rev=370174&r1=370173&r2=370174&view=diff
==
--- lldb/trunk/include/lldb/Interpreter/CommandObject.h (original)
+++ lldb/trunk/include/lldb/Interpreter/CommandObject.h Wed Aug 28 02:02:32 2019
@@ -228,25 +228,15 @@ public:
   ///
   /// \param[in/out] request
   ///The completion request that needs to be answered.
-  ///
-  /// FIXME: This is the wrong return value, since we also need to make a
-  /// distinction between
-  /// total number of matches, and the window the user wants returned.
   virtual void HandleCompletion(CompletionRequest &request);
 
-  /// The input array contains a parsed version of the line.  The insertion
-  /// point is given by cursor_index (the index in input of the word containing
-  /// the cursor) and cursor_char_position (the position of the cursor in that
-  /// word.)
+  /// The input array contains a parsed version of the line.
+  ///
   /// We've constructed the map of options and their arguments as well if that
   /// is helpful for the completion.
   ///
   /// \param[in/out] request
   ///The completion request that needs to be answered.
-  ///
-  /// FIXME: This is the wrong return value, since we also need to make a
-  /// distinction between
-  /// total number of matches, and the window the user wants returned.
   virtual void
   HandleArgumentCompletion(CompletionRequest &request,
OptionElementVector &opt_element_vector) {}


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


[Lldb-commits] [lldb] r370179 - [lldb][NFC] Get rid of C-strings in HandleOptionCompletion

2019-08-28 Thread Raphael Isemann via lldb-commits
Author: teemperor
Date: Wed Aug 28 02:32:30 2019
New Revision: 370179

URL: http://llvm.org/viewvc/llvm-project?rev=370179&view=rev
Log:
[lldb][NFC] Get rid of C-strings in HandleOptionCompletion

Modified:
lldb/trunk/source/Interpreter/Options.cpp

Modified: lldb/trunk/source/Interpreter/Options.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/Options.cpp?rev=370179&r1=370178&r2=370179&view=diff
==
--- lldb/trunk/source/Interpreter/Options.cpp (original)
+++ lldb/trunk/source/Interpreter/Options.cpp Wed Aug 28 02:32:30 2019
@@ -652,8 +652,7 @@ bool Options::HandleOptionCompletion(Com
 
   auto opt_defs = GetDefinitions();
 
-  std::string cur_opt_std_str = request.GetCursorArgumentPrefix().str();
-  const char *cur_opt_str = cur_opt_std_str.c_str();
+  llvm::StringRef cur_opt_str = request.GetCursorArgumentPrefix();
 
   for (size_t i = 0; i < opt_element_vector.size(); i++) {
 int opt_pos = opt_element_vector[i].opt_pos;
@@ -667,7 +666,7 @@ bool Options::HandleOptionCompletion(Com
 // FIXME: We should scan the other options provided and only complete
 // options
 // within the option group they belong to.
-char opt_str[3] = {'-', 'a', '\0'};
+std::string opt_str = "-a";
 
 for (auto &def : opt_defs) {
   if (!def.short_option)
@@ -685,7 +684,7 @@ bool Options::HandleOptionCompletion(Com
 
   full_name.erase(full_name.begin() + 2, full_name.end());
   full_name.append(def.long_option);
-  request.AddCompletion(full_name.c_str());
+  request.AddCompletion(full_name);
 }
 return true;
   } else if (opt_defs_index != OptionArgElement::eUnrecognizedArg) {
@@ -693,17 +692,13 @@ bool Options::HandleOptionCompletion(Com
 // anyway (getopt_long_only is happy with shortest unique string, but
 // it's still a nice thing to do.)  Otherwise return The string so the
 // upper level code will know this is a full match and add the " ".
-if (cur_opt_str && strlen(cur_opt_str) > 2 && cur_opt_str[0] == '-' &&
-cur_opt_str[1] == '-' &&
-strcmp(opt_defs[opt_defs_index].long_option, cur_opt_str) != 0) {
-  std::string full_name("--");
-  full_name.append(opt_defs[opt_defs_index].long_option);
-  request.AddCompletion(full_name.c_str());
+llvm::StringRef long_option = opt_defs[opt_defs_index].long_option;
+if (cur_opt_str.startswith("--") && cur_opt_str != long_option) {
+  request.AddCompletion("--" + long_option.str());
   return true;
-} else {
+} else
   request.AddCompletion(request.GetCursorArgument());
-  return true;
-}
+return true;
   } else {
 // FIXME - not handling wrong options yet:
 // Check to see if they are writing a long option & complete it.
@@ -712,16 +707,15 @@ bool Options::HandleOptionCompletion(Com
 // that are not unique up to this point.  getopt_long_only does
 // shortest unique match for long options already.
 
-if (cur_opt_str && strlen(cur_opt_str) > 2 && cur_opt_str[0] == '-' &&
-cur_opt_str[1] == '-') {
+if (cur_opt_str.startswith("--")) {
   for (auto &def : opt_defs) {
 if (!def.long_option)
   continue;
 
-if (strstr(def.long_option, cur_opt_str + 2) == def.long_option) {
+if (cur_opt_str.startswith(def.long_option)) {
   std::string full_name("--");
   full_name.append(def.long_option);
-  request.AddCompletion(full_name.c_str());
+  request.AddCompletion(full_name);
 }
   }
 }


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


<    2   3   4   5   6   7   8   9   10   11   >