[Lldb-commits] [PATCH] D89698: [lldb] Fix TestTargetAPI.py on Apple simulators

2020-10-22 Thread Raphael Isemann via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG30d5590d171c: [lldb] Fix TestTargetAPI.py on Apple 
simulators (authored by teemperor).
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D89698/new/

https://reviews.llvm.org/D89698

Files:
  lldb/test/API/python_api/target/TestTargetAPI.py


Index: lldb/test/API/python_api/target/TestTargetAPI.py
===
--- lldb/test/API/python_api/target/TestTargetAPI.py
+++ lldb/test/API/python_api/target/TestTargetAPI.py
@@ -331,7 +331,7 @@
 if not desc:
 self.fail("SBTarget.GetDescription() failed")
 self.expect(desc, exe=False,
-substrs=['a.out', 'Target', 'Module', 'Breakpoint'])
+substrs=['Target', 'Module', 'a.out', 'Breakpoint'])
 
 @not_remote_testsuite_ready
 @add_test_categories(['pyapi'])


Index: lldb/test/API/python_api/target/TestTargetAPI.py
===
--- lldb/test/API/python_api/target/TestTargetAPI.py
+++ lldb/test/API/python_api/target/TestTargetAPI.py
@@ -331,7 +331,7 @@
 if not desc:
 self.fail("SBTarget.GetDescription() failed")
 self.expect(desc, exe=False,
-substrs=['a.out', 'Target', 'Module', 'Breakpoint'])
+substrs=['Target', 'Module', 'a.out', 'Breakpoint'])
 
 @not_remote_testsuite_ready
 @add_test_categories(['pyapi'])
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D89056: [lldb] Explicitly use the configuration architecture when building test executables

2020-10-22 Thread Raphael Isemann via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG41185226f6d8: [lldb] Explicitly use the configuration 
architecture when building test… (authored by teemperor).
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D89056/new/

https://reviews.llvm.org/D89056

Files:
  lldb/packages/Python/lldbsuite/test/builders/builder.py
  lldb/packages/Python/lldbsuite/test/lldbtest.py


Index: lldb/packages/Python/lldbsuite/test/lldbtest.py
===
--- lldb/packages/Python/lldbsuite/test/lldbtest.py
+++ lldb/packages/Python/lldbsuite/test/lldbtest.py
@@ -2606,6 +2606,9 @@
 """Platform specific way to build the default binaries."""
 module = builder_module()
 
+if not architecture and configuration.arch:
+architecture = configuration.arch
+
 dictionary = lldbplatformutil.finalize_build_dictionary(dictionary)
 if self.getDebugInfo() is None:
 return self.buildDefault(architecture, compiler, dictionary)
Index: lldb/packages/Python/lldbsuite/test/builders/builder.py
===
--- lldb/packages/Python/lldbsuite/test/builders/builder.py
+++ lldb/packages/Python/lldbsuite/test/builders/builder.py
@@ -93,11 +93,7 @@
 Helper function to return the key-value string to specify the 
architecture
 used for the make system.
 """
-arch = architecture if architecture else None
-if not arch and configuration.arch:
-arch = configuration.arch
-
-return ("ARCH=" + arch) if arch else ""
+return ("ARCH=" + architecture) if architecture else ""
 
 def getCCSpec(self, compiler):
 """


Index: lldb/packages/Python/lldbsuite/test/lldbtest.py
===
--- lldb/packages/Python/lldbsuite/test/lldbtest.py
+++ lldb/packages/Python/lldbsuite/test/lldbtest.py
@@ -2606,6 +2606,9 @@
 """Platform specific way to build the default binaries."""
 module = builder_module()
 
+if not architecture and configuration.arch:
+architecture = configuration.arch
+
 dictionary = lldbplatformutil.finalize_build_dictionary(dictionary)
 if self.getDebugInfo() is None:
 return self.buildDefault(architecture, compiler, dictionary)
Index: lldb/packages/Python/lldbsuite/test/builders/builder.py
===
--- lldb/packages/Python/lldbsuite/test/builders/builder.py
+++ lldb/packages/Python/lldbsuite/test/builders/builder.py
@@ -93,11 +93,7 @@
 Helper function to return the key-value string to specify the architecture
 used for the make system.
 """
-arch = architecture if architecture else None
-if not arch and configuration.arch:
-arch = configuration.arch
-
-return ("ARCH=" + arch) if arch else ""
+return ("ARCH=" + architecture) if architecture else ""
 
 def getCCSpec(self, compiler):
 """
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D89428: Add support for more OS types to AddClangModuleCompilationOptionsForSDKType()

2020-10-15 Thread Raphael Isemann via Phabricator via lldb-commits
teemperor added a comment.

Thanks for refactoring this!


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D89428/new/

https://reviews.llvm.org/D89428

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


[Lldb-commits] [PATCH] D89428: Add support for more OS types to AddClangModuleCompilationOptionsForSDKType()

2020-10-15 Thread Raphael Isemann via Phabricator via lldb-commits
teemperor requested changes to this revision.
teemperor added inline comments.
This revision now requires changes to proceed.



Comment at: lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp:1525
+  // If the SDK type is for the host OS, use its version number.
+  auto get_host_os = []() { return HostInfo::GetTargetTriple().getOS(); };
   switch (sdk_type) {

`Triple::OSType host_os = HostInfo::GetTargetTriple().getOS();` ?



Comment at: lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp:1576
+case XcodeSDK::Type::AppleTVOS:
+  minimum_version_option.PutCString(opt_mtvos_simulator_version_min_EQ);
   break;

`opt_mtvos_version_min_EQ`



Comment at: lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp:1585
+case XcodeSDK::Type::bridgeOS:
+  minimum_version_option.PutCString(opt_mwatchos_version_min_EQ);
+  break;

If this is on purpose, then I think there should be a comment explaining why 
this is not `-mbridgeos-version-min=` ?


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D89428/new/

https://reviews.llvm.org/D89428

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


[Lldb-commits] [PATCH] D89310: [lldb] Reject redefinitions of persistent variables

2020-10-14 Thread Raphael Isemann via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGcb81e662a589: [lldb] Reject redefinitions of persistent 
variables (authored by teemperor).
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D89310/new/

https://reviews.llvm.org/D89310

Files:
  lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp
  lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.h
  lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp
  
lldb/test/API/commands/expression/persistent_variables/TestPersistentVariables.py

Index: lldb/test/API/commands/expression/persistent_variables/TestPersistentVariables.py
===
--- lldb/test/API/commands/expression/persistent_variables/TestPersistentVariables.py
+++ lldb/test/API/commands/expression/persistent_variables/TestPersistentVariables.py
@@ -41,3 +41,19 @@
 # Test that $200 wasn't created by the previous expression.
 self.expect("expr $200", error=True,
 substrs=["use of undeclared identifier '$200'"])
+
+# Try redeclaring the persistent variable with the same type.
+# This should be rejected as we treat them as if they are globals.
+self.expect("expr int $i = 123", error=True,
+substrs=["error: redefinition of persistent variable '$i'"])
+self.expect_expr("$i", result_type="int", result_value="5")
+
+# Try redeclaring the persistent variable with another type. Should
+# also be rejected.
+self.expect("expr long $i = 123", error=True,
+substrs=["error: redefinition of persistent variable '$i'"])
+self.expect_expr("$i", result_type="int", result_value="5")
+
+# Try assigning the persistent variable a new value.
+self.expect("expr $i = 55")
+self.expect_expr("$i", result_type="int", result_value="55")
Index: lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp
===
--- lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp
+++ lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp
@@ -1078,6 +1078,7 @@
   ClangExpressionDeclMap *decl_map = type_system_helper->DeclMap();
   if (decl_map) {
 decl_map->InstallCodeGenerator(_compiler->getASTConsumer());
+decl_map->InstallDiagnosticManager(diagnostic_manager);
 
 clang::ExternalASTSource *ast_source = decl_map->CreateProxy();
 
Index: lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.h
===
--- lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.h
+++ lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.h
@@ -102,6 +102,8 @@
 
   void InstallCodeGenerator(clang::ASTConsumer *code_gen);
 
+  void InstallDiagnosticManager(DiagnosticManager _manager);
+
   /// Disable the state needed for parsing and IR transformation.
   void DidParse();
 
@@ -330,6 +332,8 @@
 clang::ASTConsumer *m_code_gen = nullptr; ///< If non-NULL, a code generator
   ///that receives new top-level
   ///functions.
+DiagnosticManager *m_diagnostics = nullptr;
+
   private:
 ParserVars(const ParserVars &) = delete;
 const ParserVars =(const ParserVars &) = delete;
Index: lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp
===
--- lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp
+++ lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp
@@ -19,6 +19,7 @@
 #include "lldb/Core/ModuleSpec.h"
 #include "lldb/Core/ValueObjectConstResult.h"
 #include "lldb/Core/ValueObjectVariable.h"
+#include "lldb/Expression/DiagnosticManager.h"
 #include "lldb/Expression/Materializer.h"
 #include "lldb/Symbol/CompileUnit.h"
 #include "lldb/Symbol/CompilerDecl.h"
@@ -125,6 +126,12 @@
   m_parser_vars->m_code_gen = code_gen;
 }
 
+void ClangExpressionDeclMap::InstallDiagnosticManager(
+DiagnosticManager _manager) {
+  assert(m_parser_vars);
+  m_parser_vars->m_diagnostics = _manager;
+}
+
 void ClangExpressionDeclMap::DidParse() {
   if (m_parser_vars && m_parser_vars->m_persistent_vars) {
 for (size_t entity_index = 0, num_entities = m_found_entities.GetSize();
@@ -196,6 +203,17 @@
   if (ast == nullptr)
 return false;
 
+  // Check if we already declared a persistent variable with the same name.
+  if (lldb::ExpressionVariableSP conflicting_var =
+  m_parser_vars->m_persistent_vars->GetVariable(name)) {
+std::string msg = llvm::formatv("redefinition of persistent variable '{0}'",
+

[Lldb-commits] [PATCH] D89295: [lldb] Add /Users/jonas to Python's sys.path

2020-10-13 Thread Raphael Isemann via Phabricator via lldb-commits
teemperor added a comment.

In D89295#2327751 , @kastiglione wrote:

> For lldbinit files, and any file that gets `command source`'d, I think it 
> would be useful if they could perform `command script import 
> some/path/to/command.py`, where `some` is resolved relative to the dirname of 
> the lldb file. For example, given an lldbinit file at 
> `my/project/scripts/project.lldb`, it could load a python at 
> `my/project/scripts/commands/my.py` by running `command script import 
> commands/my.py`.

+1, I think that would be useful. Not sure about the right way to implement 
this though (and whether we should make this implicit a relative path vs for 
example some kind of placeholder 'variable' or something like that).


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D89295/new/

https://reviews.llvm.org/D89295

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


[Lldb-commits] [PATCH] D88950: [lldb][cmake] Remove custom logic for finding VCS file to fix LLDB's VCSVersion.inc generation

2020-10-13 Thread Raphael Isemann via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG6733b2544794: [lldb][cmake] Remove custom logic for finding 
VCS file to fix LLDBs VCSVersion. (authored by teemperor).
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D88950/new/

https://reviews.llvm.org/D88950

Files:
  lldb/source/CMakeLists.txt


Index: lldb/source/CMakeLists.txt
===
--- lldb/source/CMakeLists.txt
+++ lldb/source/CMakeLists.txt
@@ -4,16 +4,8 @@
 lldb.cpp
   )
 
-foreach(file
-"${LLDB_SOURCE_DIR}/.git/logs/HEAD" # Git
-"${LLDB_SOURCE_DIR}/.svn/wc.db" # SVN 1.7
-"${LLDB_SOURCE_DIR}/.svn/entries"   # SVN 1.6
-)
-  if(EXISTS "${file}")
-set(lldb_vc "${file}")
-break()
-  endif()
-endforeach()
+
+find_first_existing_vc_file("${LLDB_SOURCE_DIR}" lldb_vc)
 
 set(version_inc "${CMAKE_CURRENT_BINARY_DIR}/VCSVersion.inc")
 set(generate_vcs_version_script 
"${LLVM_CMAKE_PATH}/GenerateVersionFromVCS.cmake")


Index: lldb/source/CMakeLists.txt
===
--- lldb/source/CMakeLists.txt
+++ lldb/source/CMakeLists.txt
@@ -4,16 +4,8 @@
 lldb.cpp
   )
 
-foreach(file
-"${LLDB_SOURCE_DIR}/.git/logs/HEAD" # Git
-"${LLDB_SOURCE_DIR}/.svn/wc.db" # SVN 1.7
-"${LLDB_SOURCE_DIR}/.svn/entries"   # SVN 1.6
-)
-  if(EXISTS "${file}")
-set(lldb_vc "${file}")
-break()
-  endif()
-endforeach()
+
+find_first_existing_vc_file("${LLDB_SOURCE_DIR}" lldb_vc)
 
 set(version_inc "${CMAKE_CURRENT_BINARY_DIR}/VCSVersion.inc")
 set(generate_vcs_version_script "${LLVM_CMAKE_PATH}/GenerateVersionFromVCS.cmake")
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D88889: [lldb] Allow limiting the number of error diagnostics when parsing an expression

2020-10-13 Thread Raphael Isemann via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG02114e15daad: [lldb] Allow limiting the number of error 
diagnostics when parsing an expression (authored by teemperor).
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D9/new/

https://reviews.llvm.org/D9

Files:
  lldb/include/lldb/Target/Target.h
  lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp
  lldb/source/Target/Target.cpp
  lldb/source/Target/TargetProperties.td
  lldb/test/API/commands/expression/error-limit/Makefile
  lldb/test/API/commands/expression/error-limit/TestExprErrorLimit.py
  lldb/test/API/commands/expression/error-limit/main.cpp

Index: lldb/test/API/commands/expression/error-limit/main.cpp
===
--- /dev/null
+++ lldb/test/API/commands/expression/error-limit/main.cpp
@@ -0,0 +1,3 @@
+int main() {
+  return 0; // break here
+}
Index: lldb/test/API/commands/expression/error-limit/TestExprErrorLimit.py
===
--- /dev/null
+++ lldb/test/API/commands/expression/error-limit/TestExprErrorLimit.py
@@ -0,0 +1,60 @@
+"""
+Tests target.expr-error-limit.
+"""
+
+import lldb
+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):
+# FIXME: The only reason this test needs to create a real target is because
+# the settings of the dummy target can't be changed with `settings set`.
+self.build()
+target = self.dbg.CreateTarget(self.getBuildArtifact("a.out"))
+
+# Our test expression that is just several lines of malformed
+# integer literals (with a 'yerror' integer suffix). Every error
+# has its own unique string (1, 2, 3, 4) and is on its own line
+# that we can later find it when Clang prints the respective source
+# code for each error to the error output.
+# For example, in the error output below we would look for the
+# unique `1yerror` string:
+# error: :1:2: invalid suffix 'yerror' on integer constant
+# 1yerror
+# ^
+expr = "1yerror;\n2yerror;\n3yerror;\n4yerror;"
+
+options = lldb.SBExpressionOptions()
+options.SetAutoApplyFixIts(False)
+
+# Evaluate the expression and check that only the first 2 errors are
+# emitted.
+self.runCmd("settings set target.expr-error-limit 2")
+eval_result = target.EvaluateExpression(expr, options)
+self.assertIn("1yerror", str(eval_result.GetError()))
+self.assertIn("2yerror", str(eval_result.GetError()))
+self.assertNotIn("3yerror", str(eval_result.GetError()))
+self.assertNotIn("4yerror", str(eval_result.GetError()))
+
+# Change to a 3 errors and check again which errors are emitted.
+self.runCmd("settings set target.expr-error-limit 3")
+eval_result = target.EvaluateExpression(expr, options)
+self.assertIn("1yerror", str(eval_result.GetError()))
+self.assertIn("2yerror", str(eval_result.GetError()))
+self.assertIn("3yerror", str(eval_result.GetError()))
+self.assertNotIn("4yerror", str(eval_result.GetError()))
+
+# Disable the error limit and make sure all errors are emitted.
+self.runCmd("settings set target.expr-error-limit 0")
+eval_result = target.EvaluateExpression(expr, options)
+self.assertIn("1yerror", str(eval_result.GetError()))
+self.assertIn("2yerror", str(eval_result.GetError()))
+self.assertIn("3yerror", str(eval_result.GetError()))
+self.assertIn("4yerror", str(eval_result.GetError()))
Index: lldb/test/API/commands/expression/error-limit/Makefile
===
--- /dev/null
+++ lldb/test/API/commands/expression/error-limit/Makefile
@@ -0,0 +1,3 @@
+CXX_SOURCES := main.cpp
+
+include Makefile.rules
Index: lldb/source/Target/TargetProperties.td
===
--- lldb/source/Target/TargetProperties.td
+++ lldb/source/Target/TargetProperties.td
@@ -20,6 +20,10 @@
   def ExprPrefix: Property<"expr-prefix", "FileSpec">,
 DefaultStringValue<"">,
 Desc<"Path to a file containing expressions to be prepended to all expressions.">;
+  def ExprErrorLimit: Property<"expr-error-limit", "UInt64">,
+DefaultUnsignedValue<5>,
+Desc<"The maximum amount of errors to emit while parsing an expression. "
+ "A value of 0 means to always continue parsing if possible.">;
   def PreferDynamic: Property<"prefer-dynamic-value", "Enum">,
 

[Lldb-commits] [PATCH] D88490: [lldb] Remove all the RegisterInfo name constification code

2020-10-13 Thread Raphael Isemann via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG24e07570cc92: [lldb] Remove all the RegisterInfo name 
constification code (authored by teemperor).
Herald added subscribers: lldb-commits, jrtc27.
Herald added a project: LLDB.

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D88490/new/

https://reviews.llvm.org/D88490

Files:
  lldb/include/lldb/Target/ABI.h
  lldb/source/Plugins/ABI/ARM/ABIMacOSX_arm.cpp
  lldb/source/Plugins/ABI/ARM/ABISysV_arm.cpp
  lldb/source/Plugins/ABI/Hexagon/ABISysV_hexagon.cpp
  lldb/source/Plugins/ABI/Mips/ABISysV_mips.cpp
  lldb/source/Plugins/ABI/Mips/ABISysV_mips64.cpp
  lldb/source/Plugins/ABI/SystemZ/ABISysV_s390x.cpp
  lldb/source/Plugins/Process/Utility/DynamicRegisterInfo.cpp
  lldb/source/Plugins/Process/Utility/DynamicRegisterInfo.h
  lldb/source/Target/ABI.cpp

Index: lldb/source/Target/ABI.cpp
===
--- lldb/source/Target/ABI.cpp
+++ lldb/source/Target/ABI.cpp
@@ -42,27 +42,22 @@
 
 ABI::~ABI() = default;
 
-bool RegInfoBasedABI::GetRegisterInfoByName(ConstString name, RegisterInfo ) {
+bool RegInfoBasedABI::GetRegisterInfoByName(llvm::StringRef name,
+RegisterInfo ) {
   uint32_t count = 0;
   const RegisterInfo *register_info_array = GetRegisterInfoArray(count);
   if (register_info_array) {
-const char *unique_name_cstr = name.GetCString();
 uint32_t i;
 for (i = 0; i < count; ++i) {
   const char *reg_name = register_info_array[i].name;
-  assert(ConstString(reg_name).GetCString() == reg_name &&
- "register_info_array[i].name not from a ConstString?");
-  if (reg_name == unique_name_cstr) {
+  if (reg_name == name) {
 info = register_info_array[i];
 return true;
   }
 }
 for (i = 0; i < count; ++i) {
   const char *reg_alt_name = register_info_array[i].alt_name;
-  assert((reg_alt_name == nullptr ||
-  ConstString(reg_alt_name).GetCString() == reg_alt_name) &&
- "register_info_array[i].alt_name not from a ConstString?");
-  if (reg_alt_name == unique_name_cstr) {
+  if (reg_alt_name == name) {
 info = register_info_array[i];
 return true;
   }
@@ -224,7 +219,7 @@
 return;
 
   RegisterInfo abi_info;
-  if (!GetRegisterInfoByName(ConstString(info.name), abi_info))
+  if (!GetRegisterInfoByName(info.name, abi_info))
 return;
 
   if (info.kinds[eRegisterKindEHFrame] == LLDB_INVALID_REGNUM)
Index: lldb/source/Plugins/Process/Utility/DynamicRegisterInfo.h
===
--- lldb/source/Plugins/Process/Utility/DynamicRegisterInfo.h
+++ lldb/source/Plugins/Process/Utility/DynamicRegisterInfo.h
@@ -75,7 +75,7 @@
   typedef std::map dynamic_reg_size_map;
 
   const lldb_private::RegisterInfo *
-  GetRegisterInfo(lldb_private::ConstString reg_name) const;
+  GetRegisterInfo(llvm::StringRef reg_name) const;
 
   void MoveFrom(DynamicRegisterInfo &);
 
Index: lldb/source/Plugins/Process/Utility/DynamicRegisterInfo.cpp
===
--- lldb/source/Plugins/Process/Utility/DynamicRegisterInfo.cpp
+++ lldb/source/Plugins/Process/Utility/DynamicRegisterInfo.cpp
@@ -151,10 +151,8 @@
   const uint32_t msbyte = msbit / 8;
   const uint32_t lsbyte = lsbit / 8;
 
-  ConstString containing_reg_name(reg_name_str);
-
   const RegisterInfo *containing_reg_info =
-  GetRegisterInfo(containing_reg_name);
+  GetRegisterInfo(reg_name_str);
   if (containing_reg_info) {
 const uint32_t max_bit = containing_reg_info->byte_size * 8;
 if (msbit < max_bit && lsbit < max_bit) {
@@ -189,7 +187,7 @@
 }
   } else {
 printf("error: invalid concrete register \"%s\"\n",
-   containing_reg_name.GetCString());
+   reg_name_str.c_str());
   }
 } else {
   printf("error: msbit (%u) must be greater than lsbit (%u)\n",
@@ -217,7 +215,7 @@
   if (composite_reg_list->GetItemAtIndexAsString(
   composite_idx, composite_reg_name, nullptr)) {
 const RegisterInfo *composite_reg_info =
-GetRegisterInfo(composite_reg_name);
+GetRegisterInfo(composite_reg_name.GetStringRef());
 if (composite_reg_info) {
   composite_offset = std::min(composite_offset,
   composite_reg_info->byte_offset);
@@ -357,7 +355,7 @@
   if (invalidate_reg_list->GetItemAtIndexAsString(
   idx, invalidate_reg_name)) {
 const RegisterInfo *invalidate_reg_info =
-

[Lldb-commits] [PATCH] D88910: [lldb][NFC] Remove property predicate matcher

2020-10-13 Thread Raphael Isemann via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG4cd873c4bd7f: [lldb][NFC] Remove property predicate matcher 
(authored by teemperor).
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D88910/new/

https://reviews.llvm.org/D88910

Files:
  lldb/include/lldb/Interpreter/OptionValueProperties.h
  lldb/source/Interpreter/OptionValueProperties.cpp


Index: lldb/source/Interpreter/OptionValueProperties.cpp
===
--- lldb/source/Interpreter/OptionValueProperties.cpp
+++ lldb/source/Interpreter/OptionValueProperties.cpp
@@ -147,38 +147,6 @@
 }
 return return_val_sp;
   }
-  case '{':
-// Predicate matching for predicates like
-// "{}"
-// strings are parsed by the current OptionValueProperties subclass to mean
-// whatever they want to. For instance a subclass of OptionValueProperties
-// for a lldb_private::Target might implement: "target.run-
-// args{arch==i386}"   -- only set run args if the arch is i386 "target
-// .run-args{path=/tmp/a/b/c/a.out}" -- only set run args if the path
-// matches "target.run-args{basename==test&==x86_64}" -- only set run
-// args if executable basename is "test" and arch is "x86_64"
-if (sub_name[1]) {
-  llvm::StringRef predicate_start = sub_name.drop_front();
-  size_t pos = predicate_start.find('}');
-  if (pos != llvm::StringRef::npos) {
-auto predicate = predicate_start.take_front(pos);
-auto rest = predicate_start.drop_front(pos);
-if (PredicateMatches(exe_ctx, predicate)) {
-  if (!rest.empty()) {
-// Still more subvalue string to evaluate
-return value_sp->GetSubValue(exe_ctx, rest,
-  will_modify, error);
-  } else {
-// We have a match!
-break;
-  }
-}
-  }
-}
-// Predicate didn't match or wasn't correctly formed
-value_sp.reset();
-break;
-
   case '[':
 // Array or dictionary access for subvalues like: "[12]"   -- access
 // 12th array element "['hello']"  -- dictionary access of key named hello
Index: lldb/include/lldb/Interpreter/OptionValueProperties.h
===
--- lldb/include/lldb/Interpreter/OptionValueProperties.h
+++ lldb/include/lldb/Interpreter/OptionValueProperties.h
@@ -104,11 +104,6 @@
   Status SetSubValue(const ExecutionContext *exe_ctx, VarSetOperationType op,
  llvm::StringRef path, llvm::StringRef value) override;
 
-  virtual bool PredicateMatches(const ExecutionContext *exe_ctx,
-llvm::StringRef predicate) const {
-return false;
-  }
-
   OptionValueArch *
   GetPropertyAtIndexAsOptionValueArch(const ExecutionContext *exe_ctx,
   uint32_t idx) const;


Index: lldb/source/Interpreter/OptionValueProperties.cpp
===
--- lldb/source/Interpreter/OptionValueProperties.cpp
+++ lldb/source/Interpreter/OptionValueProperties.cpp
@@ -147,38 +147,6 @@
 }
 return return_val_sp;
   }
-  case '{':
-// Predicate matching for predicates like
-// "{}"
-// strings are parsed by the current OptionValueProperties subclass to mean
-// whatever they want to. For instance a subclass of OptionValueProperties
-// for a lldb_private::Target might implement: "target.run-
-// args{arch==i386}"   -- only set run args if the arch is i386 "target
-// .run-args{path=/tmp/a/b/c/a.out}" -- only set run args if the path
-// matches "target.run-args{basename==test&==x86_64}" -- only set run
-// args if executable basename is "test" and arch is "x86_64"
-if (sub_name[1]) {
-  llvm::StringRef predicate_start = sub_name.drop_front();
-  size_t pos = predicate_start.find('}');
-  if (pos != llvm::StringRef::npos) {
-auto predicate = predicate_start.take_front(pos);
-auto rest = predicate_start.drop_front(pos);
-if (PredicateMatches(exe_ctx, predicate)) {
-  if (!rest.empty()) {
-// Still more subvalue string to evaluate
-return value_sp->GetSubValue(exe_ctx, rest,
-  will_modify, error);
-  } else {
-// We have a match!
-break;
-  }
-}
-  }
-}
-// Predicate didn't match or wasn't correctly formed
-value_sp.reset();
-break;
-
   case '[':
 // Array or dictionary access for subvalues like: "[12]"   -- access
 // 12th array element "['hello']"  -- dictionary access of key named hello
Index: lldb/include/lldb/Interpreter/OptionValueProperties.h
===
--- 

[Lldb-commits] [PATCH] D89224: [lldb] Add targets for running test suite against Watch/TV/iPhone simulators

2020-10-13 Thread Raphael Isemann via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGef733d9df486: [lldb] Add targets for running test suite 
against Watch/TV/iPhone simulators (authored by teemperor).
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

Changed prior to commit:
  https://reviews.llvm.org/D89224?vs=297522=297861#toc

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D89224/new/

https://reviews.llvm.org/D89224

Files:
  lldb/test/API/lit.cfg.py
  lldb/test/CMakeLists.txt


Index: lldb/test/CMakeLists.txt
===
--- lldb/test/CMakeLists.txt
+++ lldb/test/CMakeLists.txt
@@ -214,6 +214,29 @@
   DEPENDS lldb-test-deps)
 add_dependencies(check-lldb-reproducers check-lldb-reproducers-capture)
 
+# Targets for running the test suite on the different Apple simulators.
+add_lit_testsuite(check-lldb-simulator-ios
+  "Running lldb test suite on the iOS simulator"
+  ${CMAKE_CURRENT_BINARY_DIR}/API
+  PARAMS "lldb-run-with-simulator=ios"
+  EXCLUDE_FROM_CHECK_ALL
+  DEPENDS lldb-test-deps)
+
+add_lit_testsuite(check-lldb-simulator-watchos
+  "Running lldb test suite on the watchOS simulator"
+  ${CMAKE_CURRENT_BINARY_DIR}/API
+  PARAMS "lldb-run-with-simulator=watchos"
+  EXCLUDE_FROM_CHECK_ALL
+  DEPENDS lldb-test-deps)
+
+add_lit_testsuite(check-lldb-simulator-tvos
+  "Running lldb test suite on the tvOS simulator"
+  ${CMAKE_CURRENT_BINARY_DIR}/API
+  PARAMS "lldb-run-with-simulator=tvos"
+  EXCLUDE_FROM_CHECK_ALL
+  DEPENDS lldb-test-deps)
+
+
 if(LLDB_BUILT_STANDALONE)
   # This has to happen *AFTER* add_lit_testsuite.
   if (EXISTS ${LLVM_MAIN_SRC_DIR}/utils/llvm-lit)
Index: lldb/test/API/lit.cfg.py
===
--- lldb/test/API/lit.cfg.py
+++ lldb/test/API/lit.cfg.py
@@ -146,6 +146,20 @@
   elif lldb_repro_mode == 'replay':
 config.available_features.add('lldb-repro-replay')
 
+lldb_use_simulator = lit_config.params.get('lldb-run-with-simulator', None)
+if lldb_use_simulator:
+  if lldb_use_simulator == "ios":
+lit_config.note("Running API tests on iOS simulator")
+config.available_features.add('lldb-simulator-ios')
+  elif lldb_use_simulator == "watchos":
+lit_config.note("Running API tests on watchOS simulator")
+config.available_features.add('lldb-simulator-watchos')
+  elif lldb_use_simulator == "tvos":
+lit_config.note("Running API tests on tvOS simulator")
+config.available_features.add('lldb-simulator-tvos')
+  else:
+lit_config.error("Unknown simulator id '{}'".format(lldb_use_simulator))
+
 # Set a default per-test timeout of 10 minutes. Setting a timeout per test
 # requires that killProcessAndChildren() is supported on the platform and
 # lit complains if the value is set but it is not supported.
@@ -216,6 +230,16 @@
 'lldb-repro-replay' in config.available_features:
   dotest_cmd += ['--skip-category=lldb-vscode', '--skip-category=std-module']
 
+if 'lldb-simulator-ios' in config.available_features:
+  dotest_cmd += ['--apple-sdk', 'iphonesimulator',
+ '--platform-name', 'ios-simulator']
+elif 'lldb-simulator-watchos' in config.available_features:
+  dotest_cmd += ['--apple-sdk', 'watchsimulator',
+ '--platform-name', 'watchos-simulator']
+elif 'lldb-simulator-tvos' in config.available_features:
+  dotest_cmd += ['--apple-sdk', 'appletvsimulator',
+ '--platform-name', 'tvos-simulator']
+
 if is_configured('enabled_plugins'):
   for plugin in config.enabled_plugins:
 dotest_cmd += ['--enable-plugin', plugin]


Index: lldb/test/CMakeLists.txt
===
--- lldb/test/CMakeLists.txt
+++ lldb/test/CMakeLists.txt
@@ -214,6 +214,29 @@
   DEPENDS lldb-test-deps)
 add_dependencies(check-lldb-reproducers check-lldb-reproducers-capture)
 
+# Targets for running the test suite on the different Apple simulators.
+add_lit_testsuite(check-lldb-simulator-ios
+  "Running lldb test suite on the iOS simulator"
+  ${CMAKE_CURRENT_BINARY_DIR}/API
+  PARAMS "lldb-run-with-simulator=ios"
+  EXCLUDE_FROM_CHECK_ALL
+  DEPENDS lldb-test-deps)
+
+add_lit_testsuite(check-lldb-simulator-watchos
+  "Running lldb test suite on the watchOS simulator"
+  ${CMAKE_CURRENT_BINARY_DIR}/API
+  PARAMS "lldb-run-with-simulator=watchos"
+  EXCLUDE_FROM_CHECK_ALL
+  DEPENDS lldb-test-deps)
+
+add_lit_testsuite(check-lldb-simulator-tvos
+  "Running lldb test suite on the tvOS simulator"
+  ${CMAKE_CURRENT_BINARY_DIR}/API
+  PARAMS "lldb-run-with-simulator=tvos"
+  EXCLUDE_FROM_CHECK_ALL
+  DEPENDS lldb-test-deps)
+
+
 if(LLDB_BUILT_STANDALONE)
   # This has to happen *AFTER* add_lit_testsuite.
   if (EXISTS ${LLVM_MAIN_SRC_DIR}/utils/llvm-lit)
Index: lldb/test/API/lit.cfg.py
===
--- lldb/test/API/lit.cfg.py
+++ lldb/test/API/lit.cfg.py

[Lldb-commits] [PATCH] D89052: [lldb] Don't add no-sandbox entitlement when running tests on simulator

2020-10-13 Thread Raphael Isemann via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGdfc72439529c: [lldb] Dont add no-sandbox entitlement 
when running tests on simulator (authored by teemperor).
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D89052/new/

https://reviews.llvm.org/D89052

Files:
  lldb/packages/Python/lldbsuite/test/builders/darwin.py
  lldb/packages/Python/lldbsuite/test/make/entitlements-simulator.plist


Index: lldb/packages/Python/lldbsuite/test/make/entitlements-simulator.plist
===
--- /dev/null
+++ lldb/packages/Python/lldbsuite/test/make/entitlements-simulator.plist
@@ -0,0 +1,8 @@
+
+http://www.apple.com/DTDs/PropertyList-1.0.dtd;>
+
+
+com.apple.security.get-task-allow
+
+
+
Index: lldb/packages/Python/lldbsuite/test/builders/darwin.py
===
--- lldb/packages/Python/lldbsuite/test/builders/darwin.py
+++ lldb/packages/Python/lldbsuite/test/builders/darwin.py
@@ -65,11 +65,15 @@
 if configuration.dsymutil:
 args['DSYMUTIL'] = configuration.dsymutil
 
-operating_system, _ = get_os_and_env()
+operating_system, env = get_os_and_env()
 if operating_system and operating_system != "macosx":
 builder_dir = os.path.dirname(os.path.abspath(__file__))
 test_dir = os.path.dirname(builder_dir)
-entitlements = os.path.join(test_dir, 'make', 'entitlements.plist')
+if env == "simulator":
+  entitlements_file = 'entitlements-simulator.plist'
+else:
+  entitlements_file = 'entitlements.plist'
+entitlements = os.path.join(test_dir, 'make', entitlements_file)
 args['CODESIGN'] = 'codesign --entitlements {}'.format(
 entitlements)
 


Index: lldb/packages/Python/lldbsuite/test/make/entitlements-simulator.plist
===
--- /dev/null
+++ lldb/packages/Python/lldbsuite/test/make/entitlements-simulator.plist
@@ -0,0 +1,8 @@
+
+http://www.apple.com/DTDs/PropertyList-1.0.dtd;>
+
+
+com.apple.security.get-task-allow
+
+
+
Index: lldb/packages/Python/lldbsuite/test/builders/darwin.py
===
--- lldb/packages/Python/lldbsuite/test/builders/darwin.py
+++ lldb/packages/Python/lldbsuite/test/builders/darwin.py
@@ -65,11 +65,15 @@
 if configuration.dsymutil:
 args['DSYMUTIL'] = configuration.dsymutil
 
-operating_system, _ = get_os_and_env()
+operating_system, env = get_os_and_env()
 if operating_system and operating_system != "macosx":
 builder_dir = os.path.dirname(os.path.abspath(__file__))
 test_dir = os.path.dirname(builder_dir)
-entitlements = os.path.join(test_dir, 'make', 'entitlements.plist')
+if env == "simulator":
+  entitlements_file = 'entitlements-simulator.plist'
+else:
+  entitlements_file = 'entitlements.plist'
+entitlements = os.path.join(test_dir, 'make', entitlements_file)
 args['CODESIGN'] = 'codesign --entitlements {}'.format(
 entitlements)
 
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D89053: [lldb] Don't let dotest silently fall back to default SDK if the specified one can't be found

2020-10-13 Thread Raphael Isemann via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG480c440f9a3c: [lldb] Dont let dotest silently fall 
back to default SDK if the specified one… (authored by teemperor).
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D89053/new/

https://reviews.llvm.org/D89053

Files:
  lldb/packages/Python/lldbsuite/test/dotest.py


Index: lldb/packages/Python/lldbsuite/test/dotest.py
===
--- lldb/packages/Python/lldbsuite/test/dotest.py
+++ lldb/packages/Python/lldbsuite/test/dotest.py
@@ -302,6 +302,11 @@
 configuration.sdkroot = seven.get_command_output(
 'xcrun --sdk "%s" --show-sdk-path 2> /dev/null' %
 (args.apple_sdk))
+if not configuration.sdkroot:
+logging.error(
+'No SDK found with the name %s; aborting...',
+args.apple_sdk)
+sys.exit(-1)
 
 if args.arch:
 configuration.arch = args.arch


Index: lldb/packages/Python/lldbsuite/test/dotest.py
===
--- lldb/packages/Python/lldbsuite/test/dotest.py
+++ lldb/packages/Python/lldbsuite/test/dotest.py
@@ -302,6 +302,11 @@
 configuration.sdkroot = seven.get_command_output(
 'xcrun --sdk "%s" --show-sdk-path 2> /dev/null' %
 (args.apple_sdk))
+if not configuration.sdkroot:
+logging.error(
+'No SDK found with the name %s; aborting...',
+args.apple_sdk)
+sys.exit(-1)
 
 if args.arch:
 configuration.arch = args.arch
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D89106: [lldb] Fill Watch/AppleTV simulator gaps in PlatformDarwin

2020-10-13 Thread Raphael Isemann via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGf4f4d54ae0d8: [lldb] Fill Watch/AppleTV simulator gaps in 
PlatformDarwin (authored by teemperor).
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D89106/new/

https://reviews.llvm.org/D89106

Files:
  lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp


Index: lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp
===
--- lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp
+++ lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp
@@ -1325,6 +1325,12 @@
   case XcodeSDK::Type::iPhoneOS:
 sdks_spec.AppendPathComponent("iPhoneOS.platform");
 break;
+  case XcodeSDK::Type::WatchSimulator:
+sdks_spec.AppendPathComponent("WatchSimulator.platform");
+break;
+  case XcodeSDK::Type::AppleTVSimulator:
+sdks_spec.AppendPathComponent("AppleTVSimulator.platform");
+break;
   default:
 llvm_unreachable("unsupported sdk");
   }
@@ -1567,6 +1573,14 @@
   minimum_version_option.PutCString("-mmacosx-version-min=");
   minimum_version_option.PutCString(version.getAsString());
   break;
+case XcodeSDK::Type::WatchSimulator:
+  minimum_version_option.PutCString("-mwatchos-simulator-version-min=");
+  minimum_version_option.PutCString(version.getAsString());
+  break;
+case XcodeSDK::Type::AppleTVSimulator:
+  minimum_version_option.PutCString("-mtvos-version-min=");
+  minimum_version_option.PutCString(version.getAsString());
+  break;
 default:
   llvm_unreachable("unsupported sdk");
 }


Index: lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp
===
--- lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp
+++ lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp
@@ -1325,6 +1325,12 @@
   case XcodeSDK::Type::iPhoneOS:
 sdks_spec.AppendPathComponent("iPhoneOS.platform");
 break;
+  case XcodeSDK::Type::WatchSimulator:
+sdks_spec.AppendPathComponent("WatchSimulator.platform");
+break;
+  case XcodeSDK::Type::AppleTVSimulator:
+sdks_spec.AppendPathComponent("AppleTVSimulator.platform");
+break;
   default:
 llvm_unreachable("unsupported sdk");
   }
@@ -1567,6 +1573,14 @@
   minimum_version_option.PutCString("-mmacosx-version-min=");
   minimum_version_option.PutCString(version.getAsString());
   break;
+case XcodeSDK::Type::WatchSimulator:
+  minimum_version_option.PutCString("-mwatchos-simulator-version-min=");
+  minimum_version_option.PutCString(version.getAsString());
+  break;
+case XcodeSDK::Type::AppleTVSimulator:
+  minimum_version_option.PutCString("-mtvos-version-min=");
+  minimum_version_option.PutCString(version.getAsString());
+  break;
 default:
   llvm_unreachable("unsupported sdk");
 }
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D89295: [lldb] Add /Users/jonas to Python's sys.path

2020-10-13 Thread Raphael Isemann via Phabricator via lldb-commits
teemperor added a comment.

In D89295#2327367 , @labath wrote:

> What exactly is the use case for this?

Xcode running a project-specific lldbinit file but users can't specify a 
`command script import relative/path/script.py` as the CWD for the 
lldb-rpc-server is `/`. This makes it impossible to check in custom LLDB Python 
scripts to an Xcode project that are loaded for all developers (as one can only 
specify the full path to the Python script).

I'm not sure if this patch is actually solving the problem. Now all devs need 
to have the project in the same path relative to their home directory.

I think we could solve this by having Xcode set the CWD to the project's source 
dir or we add the directories of .lldbinit files to Python's sys.path.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D89295/new/

https://reviews.llvm.org/D89295

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


[Lldb-commits] [PATCH] D88939: [lldb] Remove unused code in GetVersion (NFC)

2020-10-07 Thread Raphael Isemann via Phabricator via lldb-commits
teemperor accepted this revision.
teemperor added a comment.
This revision is now accepted and ready to land.

Yeah there isn't a lot of unused code left here. If you want you can make a 
follow up replacing all the C-string logic with `std::string` (and removing the 
static local result var as that seems unnecessary).


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D88939/new/

https://reviews.llvm.org/D88939

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


[Lldb-commits] [PATCH] D88939: [lldb] Remove unused code in GetVersion (NFC)

2020-10-07 Thread Raphael Isemann via Phabricator via lldb-commits
teemperor added a reviewer: JDevlieghere.
teemperor added a comment.

LLDB_REVISION and LLDB_REPOSITORY are coming from VCSVersion.inc where it 
should be defined as a string. However the generation of that file seems to be 
broken since the monorepo migration. I put up a patch here that gets this 
working again: D88950 

There is also the framework script that tries to define LLDB_REVISION but I 
assume that's only used for the headers we ship in the Framework? Not 100% sure 
what's going on with that.

Beside that, I think this code can really use some cleanup. I added some 
comments what else can be removed/updated.




Comment at: lldb/source/lldb.cpp:20
 
 static const char *GetLLDBRevision() {
 #ifdef LLDB_REVISION

This can return a string.



Comment at: lldb/source/lldb.cpp:29
 const char *lldb_private::GetVersion() {
   // On platforms other than Darwin, report a version number in the same style
   // as the clang tool.

You can remove that comment too, it's from a time where there was special 
Darwin version code.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D88939/new/

https://reviews.llvm.org/D88939

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


[Lldb-commits] [PATCH] D88581: [lldb] Symlink the Clang resource directory to the LLDB build directory in standalone builds

2020-10-06 Thread Raphael Isemann via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGce4d15fe142e: [lldb] Symlink the Clang resource directory to 
the LLDB build directory in… (authored by teemperor).
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D88581/new/

https://reviews.llvm.org/D88581

Files:
  lldb/cmake/modules/LLDBConfig.cmake
  lldb/cmake/modules/LLDBFramework.cmake
  lldb/source/API/CMakeLists.txt


Index: lldb/source/API/CMakeLists.txt
===
--- lldb/source/API/CMakeLists.txt
+++ lldb/source/API/CMakeLists.txt
@@ -195,8 +195,27 @@
   )
 endif()
 
-if (NOT LLDB_BUILT_STANDALONE)
+# The Clang expression parser in LLDB requires the Clang resource directory to 
function.
+if (TARGET clang-resource-headers)
+  # If building alongside Clang, just add a dependency to ensure it is build 
together with liblldb.
   add_dependencies(liblldb clang-resource-headers)
+else()
+  # In a standalone build create a symlink from the LLDB library directory 
that points to the
+  # resource directory in the Clang library directory. LLDB searches relative 
to its install path,
+  # and the symlink is created in the same relative path as the resource 
directory of Clang when
+  # building alongside Clang.
+  # When building the LLDB framework, this isn't necessary as there we copy 
everything we need into
+  # the framework (including the Clang resourece directory).
+  if(NOT LLDB_BUILD_FRAMEWORK)
+set(LLDB_CLANG_RESOURCE_DIR_PARENT "$/clang")
+file(MAKE_DIRECTORY "${LLDB_CLANG_RESOURCE_DIR_PARENT}")
+add_custom_command(TARGET liblldb POST_BUILD
+  COMMENT "Linking Clang resource dir into LLDB build directory: 
${LLDB_CLANG_RESOURCE_DIR_PARENT}"
+  COMMAND ${CMAKE_COMMAND} -E make_directory 
"${LLDB_CLANG_RESOURCE_DIR_PARENT}"
+  COMMAND ${CMAKE_COMMAND} -E create_symlink 
"${LLDB_EXTERNAL_CLANG_RESOURCE_DIR}"
+  
"${LLDB_CLANG_RESOURCE_DIR_PARENT}/${LLDB_CLANG_RESOURCE_DIR_NAME}"
+)
+  endif()
 endif()
 
 if(LLDB_BUILD_FRAMEWORK)
Index: lldb/cmake/modules/LLDBFramework.cmake
===
--- lldb/cmake/modules/LLDBFramework.cmake
+++ lldb/cmake/modules/LLDBFramework.cmake
@@ -110,20 +110,7 @@
 add_dependencies(liblldb clang-resource-headers)
 set(clang_resource_headers_dir 
$)
   else()
-# In standalone builds try the best possible guess
-if(Clang_DIR)
-  set(clang_lib_dir ${Clang_DIR}/../..)
-elseif(LLVM_DIR)
-  set(clang_lib_dir ${LLVM_DIR}/../..)
-elseif(LLVM_LIBRARY_DIRS)
-  set(clang_lib_dir ${LLVM_LIBRARY_DIRS})
-elseif(LLVM_BUILD_LIBRARY_DIR)
-  set(clang_lib_dir ${LLVM_BUILD_LIBRARY_DIR})
-elseif(LLVM_BINARY_DIR)
-  set(clang_lib_dir ${LLVM_BINARY_DIR}/lib${LLVM_LIBDIR_SUFFIX})
-endif()
-set(clang_version 
${LLVM_VERSION_MAJOR}.${LLVM_VERSION_MINOR}.${LLVM_VERSION_PATCH})
-set(clang_resource_headers_dir 
${clang_lib_dir}/clang/${clang_version}/include)
+set(clang_resource_headers_dir ${LLDB_EXTERNAL_CLANG_RESOURCE_DIR}/include)
 if(NOT EXISTS ${clang_resource_headers_dir})
   message(WARNING "Expected directory for clang-resource headers not 
found: ${clang_resource_headers_dir}")
 endif()
Index: lldb/cmake/modules/LLDBConfig.cmake
===
--- lldb/cmake/modules/LLDBConfig.cmake
+++ lldb/cmake/modules/LLDBConfig.cmake
@@ -250,6 +250,30 @@
   endif()
 endif()
 
+
+# If LLDB is building against a prebuilt Clang, then the Clang resource
+# directory that LLDB is using for its embedded Clang instance needs to point
+# to the resource directory of the used Clang installation.
+if (NOT TARGET clang-resource-headers)
+  set(LLDB_CLANG_RESOURCE_DIR_NAME 
"${LLVM_VERSION_MAJOR}.${LLVM_VERSION_MINOR}.${LLVM_VERSION_PATCH}")
+  # Iterate over the possible places where the external resource directory
+  # could be and pick the first that exists.
+  foreach(CANDIDATE "${Clang_DIR}/../.." "${LLVM_DIR}" "${LLVM_LIBRARY_DIRS}"
+"${LLVM_BUILD_LIBRARY_DIR}"
+"${LLVM_BINARY_DIR}/lib${LLVM_LIBDIR_SUFFIX}")
+# Build the resource directory path by appending 'clang/'.
+set(CANDIDATE_RESOURCE_DIR 
"${CANDIDATE}/clang/${LLDB_CLANG_RESOURCE_DIR_NAME}")
+if (IS_DIRECTORY "${CANDIDATE_RESOURCE_DIR}")
+  set(LLDB_EXTERNAL_CLANG_RESOURCE_DIR "${CANDIDATE_RESOURCE_DIR}")
+  break()
+endif()
+  endforeach()
+
+  if (NOT LLDB_EXTERNAL_CLANG_RESOURCE_DIR)
+message(FATAL_ERROR "Expected directory for clang-resource headers not 
found: ${LLDB_EXTERNAL_CLANG_RESOURCE_DIR}")
+  endif()
+endif()
+
 # Find Apple-specific libraries or frameworks that may be needed.
 if (APPLE)
   if(NOT APPLE_EMBEDDED)


Index: lldb/source/API/CMakeLists.txt

[Lldb-commits] [PATCH] D88792: [lldb/test] Catch invalid calls to expect()

2020-10-05 Thread Raphael Isemann via Phabricator via lldb-commits
teemperor accepted this revision.
teemperor added a comment.
This revision is now accepted and ready to land.

Thanks for fixing all of this! Beside the assertion this LGTM.




Comment at: lldb/packages/Python/lldbsuite/test/lldbtest.py:2440-2441
+assert "patterns must be a collection of strings" and False
+if isinstance(substrs, six.string_types):
+assert "substrs must be a collection of strings" and False
+

labath wrote:
> `assert isinstance(substrs, six.string_types), "substrs must be a collection 
> of strings"` ?
Or we could do `assertNotIsInstance` for a better error message that should 
show the actual type.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D88792/new/

https://reviews.llvm.org/D88792

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


[Lldb-commits] [PATCH] D88704: [lldb] Fix bug in fallback logic for finding the resource directory.

2020-10-02 Thread Raphael Isemann via Phabricator via lldb-commits
teemperor accepted this revision.
teemperor added a comment.
This revision is now accepted and ready to land.

LGTM


Repository:
  rLLDB LLDB

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D88704/new/

https://reviews.llvm.org/D88704

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


[Lldb-commits] [PATCH] D88375: Fix MIPS and MIPS64 ABI to use ConstString in thier register info arrays.

2020-09-28 Thread Raphael Isemann via Phabricator via lldb-commits
teemperor added a comment.

Yeah, this is just to prevent the MIPS backend from hitting the assert (well, 
and get the related code to actually do what it's supposed to do). This whole 
code on my "to refactor" list.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D88375/new/

https://reviews.llvm.org/D88375

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


[Lldb-commits] [PATCH] D88302: [lldb] Remove nothreadallow from SWIG's __str__ wrappers to work around a Python>=3.7 crash

2020-09-28 Thread Raphael Isemann via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG070a1d562b30: [lldb] Remove nothreadallow from SWIGs 
__str__ wrappers to work around a… (authored by teemperor).
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D88302/new/

https://reviews.llvm.org/D88302

Files:
  lldb/bindings/macros.swig
  
lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/deque/Makefile
  
lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/deque/TestDataFormatterLibcxxDeque.py
  
lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/deque/main.cpp


Index: 
lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/deque/main.cpp
===
--- /dev/null
+++ 
lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/deque/main.cpp
@@ -0,0 +1,8 @@
+#include 
+
+int main() {
+  std::deque empty;
+  std::deque deque_1 = {1};
+  std::deque deque_3 = {3, 1, 2};
+  return empty.size() + deque_1.front() + deque_3.front(); // break here
+}
Index: 
lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/deque/TestDataFormatterLibcxxDeque.py
===
--- /dev/null
+++ 
lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/deque/TestDataFormatterLibcxxDeque.py
@@ -0,0 +1,25 @@
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+
+class LibcxxDequeDataFormatterTestCase(TestBase):
+
+mydir = TestBase.compute_mydir(__file__)
+
+@add_test_categories(["libc++"])
+def test(self):
+self.build()
+lldbutil.run_to_source_breakpoint(self, "break here",
+  lldb.SBFileSpec("main.cpp"))
+
+self.expect_expr("empty", result_children=[])
+self.expect_expr("deque_1", result_children=[
+ValueCheck(name="[0]", value="1"),
+])
+self.expect_expr("deque_3", result_children=[
+ValueCheck(name="[0]", value="3"),
+ValueCheck(name="[1]", value="1"),
+ValueCheck(name="[2]", value="2")
+])
Index: 
lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/deque/Makefile
===
--- /dev/null
+++ 
lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/deque/Makefile
@@ -0,0 +1,5 @@
+CXX_SOURCES := main.cpp
+
+USE_LIBCPP := 1
+
+include Makefile.rules
Index: lldb/bindings/macros.swig
===
--- lldb/bindings/macros.swig
+++ lldb/bindings/macros.swig
@@ -1,6 +1,5 @@
 %define STRING_EXTENSION_LEVEL(Class, Level)
 %extend {
-  %nothreadallow;
   std::string lldb:: ## Class ## ::__str__(){
 lldb::SBStream stream;
 $self->GetDescription (stream, Level);
@@ -11,13 +10,11 @@
 }
 return std::string(desc, desc_len);
   }
-  %clearnothreadallow;
 }
 %enddef
 
 %define STRING_EXTENSION(Class)
 %extend {
-  %nothreadallow;
   std::string lldb:: ## Class ## ::__str__(){
 lldb::SBStream stream;
 $self->GetDescription (stream);
@@ -28,6 +25,5 @@
 }
 return std::string(desc, desc_len);
   }
-  %clearnothreadallow;
 }
 %enddef


Index: lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/deque/main.cpp
===
--- /dev/null
+++ lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/deque/main.cpp
@@ -0,0 +1,8 @@
+#include 
+
+int main() {
+  std::deque empty;
+  std::deque deque_1 = {1};
+  std::deque deque_3 = {3, 1, 2};
+  return empty.size() + deque_1.front() + deque_3.front(); // break here
+}
Index: lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/deque/TestDataFormatterLibcxxDeque.py
===
--- /dev/null
+++ lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/deque/TestDataFormatterLibcxxDeque.py
@@ -0,0 +1,25 @@
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+
+class LibcxxDequeDataFormatterTestCase(TestBase):
+
+mydir = TestBase.compute_mydir(__file__)
+
+@add_test_categories(["libc++"])
+def test(self):
+self.build()
+lldbutil.run_to_source_breakpoint(self, "break here",
+  lldb.SBFileSpec("main.cpp"))
+
+self.expect_expr("empty", result_children=[])
+self.expect_expr("deque_1", result_children=[
+ValueCheck(name="[0]", value="1"),
+])
+self.expect_expr("deque_3", result_children=[
+

[Lldb-commits] [PATCH] D88123: Add the ability to write 'target stop-hooks' in Python

2020-09-27 Thread Raphael Isemann via Phabricator via lldb-commits
teemperor added a comment.

This also doesn't work on my macOS system:

  FAIL: LLDB (/Users/teemperor/1llvm/rel/bin/clang-x86_64) :: 
test_stop_hooks_scripted_return_false (TestStopHookScripted.TestStopHooks)
  ==
  FAIL: test_stop_hooks_scripted_return_false 
(TestStopHookScripted.TestStopHooks)
 Test that the returning False from a stop hook works
  --
  Traceback (most recent call last):
File 
"/Users/teemperor/1llvm/llvm-project/lldb/test/API/commands/target/stop-hooks/TestStopHookScripted.py",
 line 54, in test_stop_hooks_scripted_return_false
  self.do_test_auto_continue(True)
File 
"/Users/teemperor/1llvm/llvm-project/lldb/test/API/commands/target/stop-hooks/TestStopHookScripted.py",
 line 91, in do_test_auto_continue
  self.assertEqual("main", func_name, "Didn't stop at the expected 
function.")
  AssertionError: 'main' != 'step_out_of_me'
  - main+ step_out_of_me : Didn't stop at the expected function.
  Config=x86_64-/Users/teemperor/1llvm/rel/bin/clang
  --


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D88123/new/

https://reviews.llvm.org/D88123

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


[Lldb-commits] [PATCH] D88375: Fix MIPS and MIPS64 ABI to use ConstString in thier register info arrays.

2020-09-27 Thread Raphael Isemann via Phabricator via lldb-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGe779427757f2: Fix MIPS and MIPS64 ABI to use ConstString in 
their register info arrays. (authored by tatsuo, committed by teemperor).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D88375/new/

https://reviews.llvm.org/D88375

Files:
  lldb/source/Plugins/ABI/Mips/ABISysV_mips.cpp
  lldb/source/Plugins/ABI/Mips/ABISysV_mips64.cpp


Index: lldb/source/Plugins/ABI/Mips/ABISysV_mips64.cpp
===
--- lldb/source/Plugins/ABI/Mips/ABISysV_mips64.cpp
+++ lldb/source/Plugins/ABI/Mips/ABISysV_mips64.cpp
@@ -75,7 +75,7 @@
   dwarf_pc
 };
 
-static const RegisterInfo g_register_infos_mips64[] = {
+static RegisterInfo g_register_infos_mips64[] = {
 //  NAME  ALTSZ OFF ENCODINGFORMAT EH_FRAME
 //  DWARF   GENERIC PROCESS PLUGIN
 //  LLDB NATIVE
@@ -542,9 +542,24 @@
 
 static const uint32_t k_num_register_infos =
 llvm::array_lengthof(g_register_infos_mips64);
+static bool g_register_info_names_constified = false;
 
 const lldb_private::RegisterInfo *
 ABISysV_mips64::GetRegisterInfoArray(uint32_t ) {
+  // Make the C-string names and alt_names for the register infos into const
+  // C-string values by having the ConstString unique the names in the global
+  // constant C-string pool.
+  if (!g_register_info_names_constified) {
+g_register_info_names_constified = true;
+for (uint32_t i = 0; i < k_num_register_infos; ++i) {
+  if (g_register_infos_mips64[i].name)
+g_register_infos_mips64[i].name =
+ConstString(g_register_infos_mips64[i].name).GetCString();
+  if (g_register_infos_mips64[i].alt_name)
+g_register_infos_mips64[i].alt_name =
+ConstString(g_register_infos_mips64[i].alt_name).GetCString();
+}
+  }
   count = k_num_register_infos;
   return g_register_infos_mips64;
 }
Index: lldb/source/Plugins/ABI/Mips/ABISysV_mips.cpp
===
--- lldb/source/Plugins/ABI/Mips/ABISysV_mips.cpp
+++ lldb/source/Plugins/ABI/Mips/ABISysV_mips.cpp
@@ -75,7 +75,7 @@
   dwarf_pc
 };
 
-static const RegisterInfo g_register_infos[] = {
+static RegisterInfo g_register_infos[] = {
 //  NAME  ALTSZ OFF ENCODINGFORMAT EH_FRAME
 //  DWARF   GENERIC PROCESS PLUGINS
 //  LLDB NATIVEVALUE REGS  INVALIDATE REGS
@@ -542,9 +542,24 @@
 
 static const uint32_t k_num_register_infos =
 llvm::array_lengthof(g_register_infos);
+static bool g_register_info_names_constified = false;
 
 const lldb_private::RegisterInfo *
 ABISysV_mips::GetRegisterInfoArray(uint32_t ) {
+  // Make the C-string names and alt_names for the register infos into const
+  // C-string values by having the ConstString unique the names in the global
+  // constant C-string pool.
+  if (!g_register_info_names_constified) {
+g_register_info_names_constified = true;
+for (uint32_t i = 0; i < k_num_register_infos; ++i) {
+  if (g_register_infos[i].name)
+g_register_infos[i].name =
+ConstString(g_register_infos[i].name).GetCString();
+  if (g_register_infos[i].alt_name)
+g_register_infos[i].alt_name =
+ConstString(g_register_infos[i].alt_name).GetCString();
+}
+  }
   count = k_num_register_infos;
   return g_register_infos;
 }


Index: lldb/source/Plugins/ABI/Mips/ABISysV_mips64.cpp
===
--- lldb/source/Plugins/ABI/Mips/ABISysV_mips64.cpp
+++ lldb/source/Plugins/ABI/Mips/ABISysV_mips64.cpp
@@ -75,7 +75,7 @@
   dwarf_pc
 };
 
-static const RegisterInfo g_register_infos_mips64[] = {
+static RegisterInfo g_register_infos_mips64[] = {
 //  NAME  ALTSZ OFF ENCODINGFORMAT EH_FRAME
 //  DWARF   GENERIC PROCESS PLUGIN
 //  LLDB NATIVE
@@ -542,9 +542,24 @@
 
 static const uint32_t k_num_register_infos =
 llvm::array_lengthof(g_register_infos_mips64);
+static bool g_register_info_names_constified = false;
 
 const lldb_private::RegisterInfo *
 ABISysV_mips64::GetRegisterInfoArray(uint32_t ) {
+  // Make the C-string names and alt_names for the register infos into const
+  // C-string values by having the ConstString unique the names in the global
+  // constant C-string pool.
+  if (!g_register_info_names_constified) {
+g_register_info_names_constified = true;
+for (uint32_t i = 0; i < k_num_register_infos; ++i) {
+  if (g_register_infos_mips64[i].name)
+g_register_infos_mips64[i].name =
+ConstString(g_register_infos_mips64[i].name).GetCString();
+  if (g_register_infos_mips64[i].alt_name)
+g_register_infos_mips64[i].alt_name 

[Lldb-commits] [PATCH] D88375: Fix MIPS and MIPS64 ABI to use ConstString in thier register info arrays.

2020-09-27 Thread Raphael Isemann via Phabricator via lldb-commits
teemperor added a comment.

Done. Thanks for the patch!


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D88375/new/

https://reviews.llvm.org/D88375

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


[Lldb-commits] [PATCH] D88375: Fix MIPS and MIPS64 ABI to use ConstString in thier register info arrays.

2020-09-27 Thread Raphael Isemann via Phabricator via lldb-commits
teemperor accepted this revision.
teemperor added a comment.
This revision is now accepted and ready to land.

To clarify the description a bit: `RegInfoBasedABI::GetRegisterInfoByName` is 
comparing the name/alt_name by doing a `const char *` pointer value comparison. 
That only works if both strings that are compared are coming from a 
ConstString. Since b0060c3a7868ef026d95d0cf8a076791ef74f474 
 
`GetRegisterInfoByName` is checking with an assert that both C strings came 
from a ConstString (which is failing as these ABI implementation changed here 
are lacking the ConstString'ification code).

Obviously copying this code around isn't ideal, so this patch is just to get 
the backend at least running again until I get around to refactor this code.

Anyway, this LGTM.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D88375/new/

https://reviews.llvm.org/D88375

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


[Lldb-commits] [PATCH] D87481: [lldb] Ignore certain Clang type sugar when creating the type name

2020-09-22 Thread Raphael Isemann via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGb5e49e91cb90: [lldb] Ignore certain Clang type sugar when 
creating the type name (authored by teemperor).
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D87481/new/

https://reviews.llvm.org/D87481

Files:
  lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
  lldb/test/API/lang/cpp/elaborated-types/Makefile
  lldb/test/API/lang/cpp/elaborated-types/TestElaboratedTypes.py
  lldb/test/API/lang/cpp/elaborated-types/main.cpp


Index: lldb/test/API/lang/cpp/elaborated-types/main.cpp
===
--- /dev/null
+++ lldb/test/API/lang/cpp/elaborated-types/main.cpp
@@ -0,0 +1,9 @@
+struct Struct {
+  int x;
+};
+
+int main() {
+  Struct use;
+  use.x = 3;
+  return use.x; // break here
+}
Index: lldb/test/API/lang/cpp/elaborated-types/TestElaboratedTypes.py
===
--- /dev/null
+++ lldb/test/API/lang/cpp/elaborated-types/TestElaboratedTypes.py
@@ -0,0 +1,40 @@
+"""
+Test elaborated types (e.g. Clang's ElaboratedType or TemplateType sugar).
+"""
+
+import lldb
+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):
+self.build()
+self.dbg.CreateTarget(self.getBuildArtifact("a.out"))
+
+# Add a type formatter for 'Struct'.
+self.expect("type summary add Struct --summary-string '(summary 
x=${var.x})'")
+# Check that creating an expr with an elaborated type ('::Struct')
+# triggers our formatter for 'Struct' while keeping the elaborated type
+# as the display type.
+result = self.expect_expr("::Struct s; s.x = 4; s",
+  result_type="::Struct",
+  result_summary="(summary x=4)")
+# Test that a plain elaborated type is only in the display type name 
but
+# not in the full type name.
+self.assertEqual(result.GetTypeName(), "Struct")
+
+# Test the same for template types (that also only act as sugar to 
better
+# show how the template was specified by the user).
+
+# Declare a template that can actually be instantiated.
+# FIXME: The error message here is incorrect.
+self.expect("expr --top-level -- template struct $V {};",
+error=True, substrs=["Couldn't find $__lldb_expr() in the 
module"])
+result = self.expect_expr("$V<::Struct> s; s",
+  result_type="$V< ::Struct>")
+self.assertEqual(result.GetTypeName(), "$V")
Index: lldb/test/API/lang/cpp/elaborated-types/Makefile
===
--- /dev/null
+++ lldb/test/API/lang/cpp/elaborated-types/Makefile
@@ -0,0 +1,3 @@
+CXX_SOURCES := main.cpp
+
+include Makefile.rules
Index: lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
===
--- lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
+++ lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
@@ -3639,6 +3639,16 @@
 
   clang::QualType qual_type(GetQualType(type));
 
+  // Remove certain type sugar from the name. Sugar such as elaborated types
+  // or template types which only serve to improve diagnostics shouldn't
+  // act as their own types from the user's perspective (e.g., formatter
+  // shouldn't format a variable differently depending on how the ser has
+  // specified the type. '::Type' and 'Type' should behave the same).
+  // Typedefs and atomic derived types are not removed as they are actually
+  // useful for identifiying specific types.
+  qual_type = RemoveWrappingTypes(qual_type,
+  {clang::Type::Typedef, clang::Type::Atomic});
+
   // For a typedef just return the qualified name.
   if (const auto *typedef_type = qual_type->getAs()) {
 const clang::TypedefNameDecl *typedef_decl = typedef_type->getDecl();


Index: lldb/test/API/lang/cpp/elaborated-types/main.cpp
===
--- /dev/null
+++ lldb/test/API/lang/cpp/elaborated-types/main.cpp
@@ -0,0 +1,9 @@
+struct Struct {
+  int x;
+};
+
+int main() {
+  Struct use;
+  use.x = 3;
+  return use.x; // break here
+}
Index: lldb/test/API/lang/cpp/elaborated-types/TestElaboratedTypes.py
===
--- /dev/null
+++ lldb/test/API/lang/cpp/elaborated-types/TestElaboratedTypes.py
@@ -0,0 +1,40 @@
+"""
+Test elaborated types (e.g. Clang's ElaboratedType or TemplateType sugar).
+"""
+
+import lldb
+from 

[Lldb-commits] [PATCH] D87327: [debugserver] Extract function for default launch flavor

2020-09-09 Thread Raphael Isemann via Phabricator via lldb-commits
teemperor added a comment.

In D87327#2263971 , @kastiglione wrote:

> @teemperor I'm not sure what these build errors mean, for example 
> https://reviews.llvm.org/B70998. Also there's the linux build failure, but 
> that's not relevant for debugserver, right?

You can usually ignore premerge checks that aren't clang-format complaining. 
And for linux buildbot failures I think that's also fine as they don't build 
debug server from what I know.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D87327/new/

https://reviews.llvm.org/D87327

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


[Lldb-commits] [PATCH] D87389: [flang][openacc] Lower clauses on loop construct to OpenACC dialect

2020-09-09 Thread Raphael Isemann via Phabricator via lldb-commits
teemperor requested changes to this revision.
teemperor added inline comments.
This revision now requires changes to proceed.



Comment at: lldb/tools/lldb-vscode/VSCode.cpp:41
   focus_tid(LLDB_INVALID_THREAD_ID), sent_terminated_event(false),
-  stop_at_entry(false), is_attach(false),
-  reverse_request_seq(0), waiting_for_run_in_terminal(false) {
+  stop_at_entry(false), is_attach(false), reverse_request_seq(0),
+  waiting_for_run_in_terminal(false) {

Unrelated reformatting?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D87389/new/

https://reviews.llvm.org/D87389

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


[Lldb-commits] [PATCH] D85141: [lldb] Enable std::pair in CxxModuleHandler

2020-09-09 Thread Raphael Isemann via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGb85222520f86: [lldb] Enable std::pair in CxxModuleHandler 
(authored by teemperor).
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D85141/new/

https://reviews.llvm.org/D85141

Files:
  lldb/source/Plugins/ExpressionParser/Clang/CxxModuleHandler.cpp
  lldb/test/API/commands/expression/import-std-module/pair/Makefile
  
lldb/test/API/commands/expression/import-std-module/pair/TestPairFromStdModule.py
  lldb/test/API/commands/expression/import-std-module/pair/main.cpp


Index: lldb/test/API/commands/expression/import-std-module/pair/main.cpp
===
--- /dev/null
+++ lldb/test/API/commands/expression/import-std-module/pair/main.cpp
@@ -0,0 +1,6 @@
+#include 
+
+int main(int argc, char **argv) {
+  std::pair pair_int(1234, 5678);
+  return 0; // Set break point at this line.
+}
Index: 
lldb/test/API/commands/expression/import-std-module/pair/TestPairFromStdModule.py
===
--- /dev/null
+++ 
lldb/test/API/commands/expression/import-std-module/pair/TestPairFromStdModule.py
@@ -0,0 +1,25 @@
+"""
+Test basic std::pair functionality.
+"""
+
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+class TestCase(TestBase):
+
+mydir = TestBase.compute_mydir(__file__)
+
+@add_test_categories(["libc++"])
+@skipIf(compiler=no_match("clang"))
+def test(self):
+self.build()
+
+lldbutil.run_to_source_breakpoint(self,
+"// Set break point at this line.", lldb.SBFileSpec("main.cpp"))
+
+self.runCmd("settings set target.import-std-module true")
+
+self.expect_expr("pair_int.first", result_type="int", 
result_value="1234")
+self.expect_expr("pair_int.second", result_type="int", 
result_value="5678")
+self.expect("expr pair_int", substrs=['first = 1234, second = 5678'])
\ No newline at end of file
Index: lldb/test/API/commands/expression/import-std-module/pair/Makefile
===
--- /dev/null
+++ lldb/test/API/commands/expression/import-std-module/pair/Makefile
@@ -0,0 +1,3 @@
+USE_LIBCPP := 1
+CXX_SOURCES := main.cpp
+include Makefile.rules
Index: lldb/source/Plugins/ExpressionParser/Clang/CxxModuleHandler.cpp
===
--- lldb/source/Plugins/ExpressionParser/Clang/CxxModuleHandler.cpp
+++ lldb/source/Plugins/ExpressionParser/Clang/CxxModuleHandler.cpp
@@ -34,6 +34,7 @@
   "weak_ptr",
   // utility
   "allocator",
+  "pair",
   };
   m_supported_templates.insert(supported_names.begin(), supported_names.end());
 }


Index: lldb/test/API/commands/expression/import-std-module/pair/main.cpp
===
--- /dev/null
+++ lldb/test/API/commands/expression/import-std-module/pair/main.cpp
@@ -0,0 +1,6 @@
+#include 
+
+int main(int argc, char **argv) {
+  std::pair pair_int(1234, 5678);
+  return 0; // Set break point at this line.
+}
Index: lldb/test/API/commands/expression/import-std-module/pair/TestPairFromStdModule.py
===
--- /dev/null
+++ lldb/test/API/commands/expression/import-std-module/pair/TestPairFromStdModule.py
@@ -0,0 +1,25 @@
+"""
+Test basic std::pair functionality.
+"""
+
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+class TestCase(TestBase):
+
+mydir = TestBase.compute_mydir(__file__)
+
+@add_test_categories(["libc++"])
+@skipIf(compiler=no_match("clang"))
+def test(self):
+self.build()
+
+lldbutil.run_to_source_breakpoint(self,
+"// Set break point at this line.", lldb.SBFileSpec("main.cpp"))
+
+self.runCmd("settings set target.import-std-module true")
+
+self.expect_expr("pair_int.first", result_type="int", result_value="1234")
+self.expect_expr("pair_int.second", result_type="int", result_value="5678")
+self.expect("expr pair_int", substrs=['first = 1234, second = 5678'])
\ No newline at end of file
Index: lldb/test/API/commands/expression/import-std-module/pair/Makefile
===
--- /dev/null
+++ lldb/test/API/commands/expression/import-std-module/pair/Makefile
@@ -0,0 +1,3 @@
+USE_LIBCPP := 1
+CXX_SOURCES := main.cpp
+include Makefile.rules
Index: lldb/source/Plugins/ExpressionParser/Clang/CxxModuleHandler.cpp
===
--- lldb/source/Plugins/ExpressionParser/Clang/CxxModuleHandler.cpp
+++ 

[Lldb-commits] [PATCH] D85648: [lldb] Fix a crash when the ASTImporter is giving us two Imported callbacks for the same target decl

2020-09-09 Thread Raphael Isemann via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG7866b9140569: [lldb] Fix a crash when the ASTImporter is 
giving us two Imported callbacks for… (authored by teemperor).
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D85648/new/

https://reviews.llvm.org/D85648

Files:
  lldb/source/Plugins/ExpressionParser/Clang/ClangASTImporter.cpp
  lldb/test/API/lang/c/record_decl_in_expr/TestRecordDeclInExpr.py


Index: lldb/test/API/lang/c/record_decl_in_expr/TestRecordDeclInExpr.py
===
--- /dev/null
+++ lldb/test/API/lang/c/record_decl_in_expr/TestRecordDeclInExpr.py
@@ -0,0 +1,34 @@
+"""
+Tests declaring RecordDecls in non-top-level expressions.
+"""
+
+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_fwd_decl(self):
+# Declare a forward decl and import it to the scratch AST.
+self.expect_expr("struct S; S *s = nullptr; s", result_type="S *")
+
+@no_debug_info_test
+def test_struct(self):
+# Declare a struct and import it to the scratch AST.
+self.expect("expr struct S {}; S s; s", substrs=["= {}"])
+
+@no_debug_info_test
+def test_struct_with_fwd_decl(self):
+# Import the forward decl to the scratch AST.
+self.expect_expr("struct S; S *s = nullptr; s", result_type="S *")
+# Merge the definition into the scratch AST.
+self.expect("expr struct S {}; S s; s", substrs=["= {}"])
+
+@no_debug_info_test
+def test_struct_with_fwd_decl_same_expr(self):
+# Test both a forward decl and a definition in one expression and
+# import them into the scratch AST.
+self.expect("expr struct S; struct S{}; S s; s", substrs=["= {}"])
Index: lldb/source/Plugins/ExpressionParser/Clang/ClangASTImporter.cpp
===
--- lldb/source/Plugins/ExpressionParser/Clang/ClangASTImporter.cpp
+++ lldb/source/Plugins/ExpressionParser/Clang/ClangASTImporter.cpp
@@ -216,7 +216,12 @@
 /// imported while completing the original Decls).
 class CompleteTagDeclsScope : public ClangASTImporter::NewDeclListener {
   ClangASTImporter::ImporterDelegateSP m_delegate;
-  llvm::SmallVector m_decls_to_complete;
+  /// List of declarations in the target context that need to be completed.
+  /// Every declaration should only be completed once and therefore should only
+  /// be once in this list.
+  llvm::SetVector m_decls_to_complete;
+  /// Set of declarations that already were successfully completed (not just
+  /// added to m_decls_to_complete).
   llvm::SmallPtrSet m_decls_already_completed;
   clang::ASTContext *m_dst_ctx;
   clang::ASTContext *m_src_ctx;
@@ -244,6 +249,9 @@
   NamedDecl *decl = m_decls_to_complete.pop_back_val();
   m_decls_already_completed.insert(decl);
 
+  // The decl that should be completed has to be imported into the target
+  // context from some other context.
+  assert(to_context_md->hasOrigin(decl));
   // We should only complete decls coming from the source context.
   assert(to_context_md->getOrigin(decl).ctx == m_src_ctx);
 
@@ -287,7 +295,8 @@
 // Check if we already completed this type.
 if (m_decls_already_completed.count(to_named_decl) != 0)
   return;
-m_decls_to_complete.push_back(to_named_decl);
+// Queue this type to be completed.
+m_decls_to_complete.insert(to_named_decl);
   }
 };
 } // namespace


Index: lldb/test/API/lang/c/record_decl_in_expr/TestRecordDeclInExpr.py
===
--- /dev/null
+++ lldb/test/API/lang/c/record_decl_in_expr/TestRecordDeclInExpr.py
@@ -0,0 +1,34 @@
+"""
+Tests declaring RecordDecls in non-top-level expressions.
+"""
+
+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_fwd_decl(self):
+# Declare a forward decl and import it to the scratch AST.
+self.expect_expr("struct S; S *s = nullptr; s", result_type="S *")
+
+@no_debug_info_test
+def test_struct(self):
+# Declare a struct and import it to the scratch AST.
+self.expect("expr struct S {}; S s; s", substrs=["= {}"])
+
+@no_debug_info_test
+def test_struct_with_fwd_decl(self):
+# Import the forward decl to the scratch AST.
+self.expect_expr("struct S; S *s = nullptr; s", result_type="S *")
+# Merge the definition into the scratch AST.
+self.expect("expr struct S {}; S s; s", substrs=["= {}"])
+
+

[Lldb-commits] [PATCH] D87289: [lldb] Don't infinite loop in SemaSourceWithPriorities::CompleteType when trying to complete a forward decl

2020-09-09 Thread Raphael Isemann via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG32c8da41dc0c: [lldb] Dont infinite loop in 
SemaSourceWithPriorities::CompleteType when… (authored by teemperor).
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

Changed prior to commit:
  https://reviews.llvm.org/D87289?vs=290492=290659#toc

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D87289/new/

https://reviews.llvm.org/D87289

Files:
  lldb/source/Plugins/ExpressionParser/Clang/ASTUtils.h
  
lldb/test/API/commands/expression/import-std-module/forward_decl_from_module/Makefile
  
lldb/test/API/commands/expression/import-std-module/forward_decl_from_module/TestForwardDeclFromStdModule.py
  
lldb/test/API/commands/expression/import-std-module/forward_decl_from_module/main.cpp
  
lldb/test/API/commands/expression/import-std-module/forward_decl_from_module/root/usr/include/c++/v1/module.modulemap
  
lldb/test/API/commands/expression/import-std-module/forward_decl_from_module/root/usr/include/c++/v1/vector
  
lldb/test/API/commands/expression/import-std-module/forward_decl_from_module/root/usr/include/libc_header.h

Index: lldb/test/API/commands/expression/import-std-module/forward_decl_from_module/root/usr/include/libc_header.h
===
--- /dev/null
+++ lldb/test/API/commands/expression/import-std-module/forward_decl_from_module/root/usr/include/libc_header.h
@@ -0,0 +1 @@
+struct libc_struct {};
Index: lldb/test/API/commands/expression/import-std-module/forward_decl_from_module/root/usr/include/c++/v1/vector
===
--- /dev/null
+++ lldb/test/API/commands/expression/import-std-module/forward_decl_from_module/root/usr/include/c++/v1/vector
@@ -0,0 +1,14 @@
+#include "libc_header.h"
+
+namespace std {
+  inline namespace __1 {
+// A forward decl of `vector`.
+template class vector;
+// Pretend to be a std::vector template we need to instantiate in LLDB
+// when import-std-module is enabled.
+template
+struct vector { class F; F *f; };
+// The definition of our forward declared nested class.
+template class vector::F { int x; };
+  }
+}
Index: lldb/test/API/commands/expression/import-std-module/forward_decl_from_module/root/usr/include/c++/v1/module.modulemap
===
--- /dev/null
+++ lldb/test/API/commands/expression/import-std-module/forward_decl_from_module/root/usr/include/c++/v1/module.modulemap
@@ -0,0 +1,3 @@
+module std {
+  module "vector" { header "vector" export * }
+}
Index: lldb/test/API/commands/expression/import-std-module/forward_decl_from_module/main.cpp
===
--- /dev/null
+++ lldb/test/API/commands/expression/import-std-module/forward_decl_from_module/main.cpp
@@ -0,0 +1,8 @@
+#include 
+
+int main(int argc, char **argv) {
+  // Makes sure we have the mock libc headers in the debug information.
+  libc_struct s;
+  std::vector v;
+  return 0; // Set break point at this line.
+}
Index: lldb/test/API/commands/expression/import-std-module/forward_decl_from_module/TestForwardDeclFromStdModule.py
===
--- /dev/null
+++ lldb/test/API/commands/expression/import-std-module/forward_decl_from_module/TestForwardDeclFromStdModule.py
@@ -0,0 +1,39 @@
+"""
+Tests forward declarations coming from the `std` module.
+"""
+
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+import os
+
+class TestCase(TestBase):
+
+mydir = TestBase.compute_mydir(__file__)
+
+# We only emulate a fake libc++ in this test and don't use the real libc++,
+# but we still add the libc++ category so that this test is only run in
+# test configurations where libc++ is actually supposed to be tested.
+@add_test_categories(["libc++"])
+@skipIfRemote
+@skipIf(compiler=no_match("clang"))
+def test(self):
+self.build()
+
+sysroot = os.path.join(os.getcwd(), "root")
+
+# Set the sysroot where our dummy libc++ exists.
+self.runCmd("platform select --sysroot '" + sysroot + "' host", CURRENT_EXECUTABLE_SET)
+
+lldbutil.run_to_source_breakpoint(self,
+"// Set break point at this line.", lldb.SBFileSpec("main.cpp"))
+
+self.runCmd("settings set target.import-std-module true")
+
+# Print the dummy `std::vector`. It only has the dummy member in it
+# so the standard `std::vector` formatter can't format it. Instead use
+# the raw output so LLDB has to show the member variable.
+# Both `std::vector` and the type of the member have forward
+# declarations before their definitions.
+self.expect("expr --raw -- v",
+

[Lldb-commits] [PATCH] D87345: [lldb/Docs] Correct LLDB_ENABLE_TESTS to LLDB_INCLUDE_TESTS

2020-09-09 Thread Raphael Isemann via Phabricator via lldb-commits
teemperor added a comment.

LGTM.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D87345/new/

https://reviews.llvm.org/D87345

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


[Lldb-commits] [PATCH] D87327: [debugserver] Extract function for default launch flavor

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

LGTM, thanks for the cleanup! (And also having the second list of comments no 
longer always stating 'SpringBoard' is even better).


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D87327/new/

https://reviews.llvm.org/D87327

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


[Lldb-commits] [PATCH] D86996: [lldb] Add -l/--language option to script command

2020-09-04 Thread Raphael Isemann via Phabricator via lldb-commits
teemperor added a comment.

I have to agree with @kastiglione that this isn't very intuitive. I doubt that 
more than a handful of users are aware that "raw commands" are a thing, so I 
think this inconsistency is for once in favor of the user. LLDB commands are 
anyway not meant to be stable, so we can just fix this if this ever turns out 
to be a real issue.

Having said that, I think this shouldn't be done here but in its own patch with 
a less ad hoc implementation and some dedicated parsing tests. Good thing the 
command parsing implementation is so great, so that will be lots of fun for 
@JDevlieghere




Comment at: lldb/source/Commands/CommandObjectScript.cpp:99
+  } else {
+// When no code is provided We want to be able to launch the interactive
+// script interpreter without having to require the -- after the language.

`We` -> `we`.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D86996/new/

https://reviews.llvm.org/D86996

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


[Lldb-commits] [PATCH] D87076: [lldb/Interpreter] Fix language detection for the REPL InitFile

2020-09-03 Thread Raphael Isemann via Phabricator via lldb-commits
teemperor accepted this revision.
teemperor added a comment.
This revision is now accepted and ready to land.

This patch sparks joy, but the fact that this all is dead code without Swift 
doesn't spark joy. But as it's up to me to revive this code and the downstream 
Swift test looks fine, I'll sign this off. Thanks!




Comment at: lldb/source/Interpreter/CommandInterpreter.cpp:2096
+  LanguageSet repl_languages = Language::GetLanguagesSupportingREPLs();
+  LanguageType language = {};
+  if (auto main_repl_language = repl_languages.GetSingularLanguage())

`= eLanguageTypeUnknown`? I don't think we usually initialise enums with braces 
and it makes the default value clearer.



Comment at: lldb/source/Interpreter/CommandInterpreter.cpp:2100
+
   if (language == LanguageType::eLanguageTypeUnknown)
 return;

This could now be `else return` to make the error control flow a bit clearer.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D87076/new/

https://reviews.llvm.org/D87076

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


[Lldb-commits] [PATCH] D87036: [lldb] Make symbol list output from `image dump symtab` not depend on internal ordering of DenseMap

2020-09-03 Thread Raphael Isemann via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG5b354d204d09: [lldb] Make symbol list output from `image 
dump symtab` not depend on internal… (authored by teemperor).
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D87036/new/

https://reviews.llvm.org/D87036

Files:
  lldb/source/Plugins/SymbolFile/Breakpad/SymbolFileBreakpad.cpp
  lldb/test/Shell/SymbolFile/Breakpad/symtab.test


Index: lldb/test/Shell/SymbolFile/Breakpad/symtab.test
===
--- lldb/test/Shell/SymbolFile/Breakpad/symtab.test
+++ lldb/test/Shell/SymbolFile/Breakpad/symtab.test
@@ -6,10 +6,10 @@
 # CHECK: Symtab, file = {{.*}}symtab.out, num_symbols = 5:
 # CHECK: Index   UserID DSX TypeFile Address/Value Load Address
   Size   Flags  Name
 # CHECK: [0]  0  SX Code0x0040 
   0x00b0 0x ___lldb_unnamed_symbol{{[0-9]*}}$$symtab.out
-# CHECK: [1]  0   X Code0x004000c0 
   0x0010 0x f2
-# CHECK: [2]  0   X Code0x004000d0 
   0x0022 0x _start
-# CHECK: [3]  0   X Code0x004000a0 
   0x000d 0x func_only
-# CHECK: [4]  0   X Code0x004000b0 
   0x000c 0x f1_func
+# CHECK: [1]  0   X Code0x004000b0 
   0x000c 0x f1_func
+# CHECK: [2]  0   X Code0x004000a0 
   0x000d 0x func_only
+# CHECK: [3]  0   X Code0x004000c0 
   0x0010 0x f2
+# CHECK: [4]  0   X Code0x004000d0 
   0x0022 0x _start
 
 # CHECK-LABEL: (lldb) image lookup -a 0x4000b0 -v
 # CHECK: Address: symtab.out[0x004000b0] (symtab.out.PT_LOAD[0]..text2 
+ 0)
Index: lldb/source/Plugins/SymbolFile/Breakpad/SymbolFileBreakpad.cpp
===
--- lldb/source/Plugins/SymbolFile/Breakpad/SymbolFileBreakpad.cpp
+++ lldb/source/Plugins/SymbolFile/Breakpad/SymbolFileBreakpad.cpp
@@ -326,7 +326,8 @@
   }
 
   const SectionList  = *module.GetSectionList();
-  llvm::DenseMap symbols;
+  llvm::DenseSet found_symbol_addresses;
+  std::vector symbols;
   auto add_symbol = [&](addr_t address, llvm::Optional size,
 llvm::StringRef name) {
 address += base;
@@ -338,8 +339,12 @@
name, address);
   return;
 }
-symbols.try_emplace(
-address, /*symID*/ 0, Mangled(name), eSymbolTypeCode,
+// Keep track of what addresses were already added so far and only add
+// the symbol with the first address.
+if (!found_symbol_addresses.insert(address).second)
+  return;
+symbols.emplace_back(
+/*symID*/ 0, Mangled(name), eSymbolTypeCode,
 /*is_global*/ true, /*is_debug*/ false,
 /*is_trampoline*/ false, /*is_artificial*/ false,
 AddressRange(section_sp, address - section_sp->GetFileAddress(),
@@ -359,8 +364,8 @@
   LLDB_LOG(log, "Failed to parse: {0}. Skipping record.", line);
   }
 
-  for (auto  : symbols)
-symtab.AddSymbol(std::move(KV.second));
+  for (Symbol  : symbols)
+symtab.AddSymbol(std::move(symbol));
   symtab.CalculateSymbolSizes();
 }
 


Index: lldb/test/Shell/SymbolFile/Breakpad/symtab.test
===
--- lldb/test/Shell/SymbolFile/Breakpad/symtab.test
+++ lldb/test/Shell/SymbolFile/Breakpad/symtab.test
@@ -6,10 +6,10 @@
 # CHECK: Symtab, file = {{.*}}symtab.out, num_symbols = 5:
 # CHECK: Index   UserID DSX TypeFile Address/Value Load Address   Size   Flags  Name
 # CHECK: [0]  0  SX Code0x00400x00b0 0x ___lldb_unnamed_symbol{{[0-9]*}}$$symtab.out
-# CHECK: [1]  0   X Code0x004000c00x0010 0x f2
-# CHECK: [2]  0   X Code0x004000d00x0022 0x _start
-# CHECK: [3]  0   X Code0x004000a00x000d 0x func_only
-# CHECK: [4]  0   X Code0x004000b00x000c 0x f1_func
+# CHECK: [1]  0   X Code0x004000b00x000c 0x f1_func
+# CHECK: [2]  0   X Code0x004000a00x000d 

[Lldb-commits] [PATCH] D86336: [debugserver] Fix that debugserver's stop reply packets always return signal code 0

2020-09-03 Thread Raphael Isemann via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGf0699d910914: [debugserver] Fix that debugservers stop 
reply packets always return signal… (authored by teemperor).
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D86336/new/

https://reviews.llvm.org/D86336

Files:
  lldb/test/Shell/Process/Inputs/abort.c
  lldb/test/Shell/Process/TestAbortExitCode.test
  lldb/tools/debugserver/source/RNBRemote.cpp


Index: lldb/tools/debugserver/source/RNBRemote.cpp
===
--- lldb/tools/debugserver/source/RNBRemote.cpp
+++ lldb/tools/debugserver/source/RNBRemote.cpp
@@ -3066,7 +3066,7 @@
  WEXITSTATUS(pid_status));
   else if (WIFSIGNALED(pid_status))
 snprintf(pid_exited_packet, sizeof(pid_exited_packet), "X%02x",
- WEXITSTATUS(pid_status));
+ WTERMSIG(pid_status));
   else if (WIFSTOPPED(pid_status))
 snprintf(pid_exited_packet, sizeof(pid_exited_packet), "S%02x",
  WSTOPSIG(pid_status));
Index: lldb/test/Shell/Process/TestAbortExitCode.test
===
--- /dev/null
+++ lldb/test/Shell/Process/TestAbortExitCode.test
@@ -0,0 +1,6 @@
+UNSUPPORTED: system-windows
+
+RUN: %clang_host %p/Inputs/abort.c -o %t
+RUN: %lldb %t -o run -o continue | FileCheck %s
+
+CHECK: status = 6 (0x0006) Terminated due to signal 6
Index: lldb/test/Shell/Process/Inputs/abort.c
===
--- /dev/null
+++ lldb/test/Shell/Process/Inputs/abort.c
@@ -0,0 +1,3 @@
+#include 
+
+int main(int argc, char **argv) { abort(); }


Index: lldb/tools/debugserver/source/RNBRemote.cpp
===
--- lldb/tools/debugserver/source/RNBRemote.cpp
+++ lldb/tools/debugserver/source/RNBRemote.cpp
@@ -3066,7 +3066,7 @@
  WEXITSTATUS(pid_status));
   else if (WIFSIGNALED(pid_status))
 snprintf(pid_exited_packet, sizeof(pid_exited_packet), "X%02x",
- WEXITSTATUS(pid_status));
+ WTERMSIG(pid_status));
   else if (WIFSTOPPED(pid_status))
 snprintf(pid_exited_packet, sizeof(pid_exited_packet), "S%02x",
  WSTOPSIG(pid_status));
Index: lldb/test/Shell/Process/TestAbortExitCode.test
===
--- /dev/null
+++ lldb/test/Shell/Process/TestAbortExitCode.test
@@ -0,0 +1,6 @@
+UNSUPPORTED: system-windows
+
+RUN: %clang_host %p/Inputs/abort.c -o %t
+RUN: %lldb %t -o run -o continue | FileCheck %s
+
+CHECK: status = 6 (0x0006) Terminated due to signal 6
Index: lldb/test/Shell/Process/Inputs/abort.c
===
--- /dev/null
+++ lldb/test/Shell/Process/Inputs/abort.c
@@ -0,0 +1,3 @@
+#include 
+
+int main(int argc, char **argv) { abort(); }
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D85993: [lldb] Set the access property on member function decls

2020-09-03 Thread Raphael Isemann via Phabricator via lldb-commits
teemperor added a comment.

In D85993#2253465 , @amccarth wrote:

> In D85993#2220724 , @labath wrote:
>
>> Dwarf parser uses `TypeSystemClang::AddMethodToCXXRecordType` instead of 
>> this function to create methods (which is why there are no assertions like 
>> this when using dwarf). Maybe it would be better to change the pdb parser to 
>> use that function instead (as it allows the user to specify not only 
>> accessibility, but also other potentially useful properties of the created 
>> method -- static, virtual, etc.).
>
> The NativePDB AST parser also uses `AddMethodToCXXRecordType`.  It's in 
> udtcompleter.cpp.
>
> But the bug is triggered while the plugin is trying to synthesize the 
> function declaration during a `ResolveSymbolContext` call.  It looks like the 
> DWARF implementation of `ResolveSymbolContext` relies on its AST parser, but 
> the NativePDB one does not.  I'm trying to figure out how to do that.
>
> Also note that `AddMethodToCXXRecordType` just sets whatever access type it's 
> asked to set.  Before calling `AddMethodToCXXRecordType`, the DWARF parser 
> has this gem:
>
>   // Neither GCC 4.2 nor clang++ currently set a valid
>   // accessibility in the DWARF for C++ methods...
>   // Default to public for now...
>   if (attrs.accessibility == eAccessNone)
> attrs.accessibility = eAccessPublic;
>
> That bit of logic is what prevents the assertion from failing for DWARF.  
> I'll can make the NativePDB AST parser do the same thing.
>
> But that won't fix the bug, since the NativePDB AST parser isn't involved (at 
> least, my breakpoints in the parser never hit during the course of the test). 
>  In the mean time, I'll try to figure out how to get the NativePDB plugin's 
> `ResolveSymbolContext` implementation to use `AddMethodToCXXRecord`.

No idea about the PDB parsing code, but 
`PdbAstBuilder::GetOrCreateFunctionDecl` seems to be the right place. It 
already has a check for when the context is a TagDecl or a namespace, so doing 
the same thing for the CreateFunctionDecl call below should do the trick 
(namespace -> CreateFunctionDecl, TagDecl -> AddMethodToCXXRecordType).

> I'll also assume that, since you don't want my access-fixup in 
> `TypeSystemClang::CreateFunctionDeclaration`, then you also would want me to 
> remove the already-existing such fixup from 
> `TypeSystemClang::CreateFunctionTemplateDecl`.  Does that make sense?

Confusingly FunctionTemplateDecls *can* be inside a record and the name is just 
misleading. The actual specialisations of a FunctionTemplateDecl in a record 
are again CXXMethodDecls, so `CreateFunctionTemplateDecl` is fine:

  struct Foo {  
  
template
  
int x() {   
  
  return 3; 
  
}   
  
int foo() { 
  
  return x();   
  
}   
  
  };
  $ clang -fsyntax-only -Xclang -ast-dump  foo.cpp
  ...
  `-CXXRecordDecl 0x7f9849077f50  line:1:8 struct Foo 
definition
|-FunctionTemplateDecl 0x7f98490782d0  line:3:7 x
| |-TemplateTypeParmDecl 0x7f98490780f8  col:21 typename 
depth 0 index 0 T
| |-CXXMethodDecl 0x7f9849078230  line:3:7 x 'int ()'
| `-CXXMethodDecl 0x7f98490785e0  line:3:7 used x 'int 
()'
  ...


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D85993/new/

https://reviews.llvm.org/D85993

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


[Lldb-commits] [PATCH] D86996: [lldb] Add -l/--language option to script command

2020-09-02 Thread Raphael Isemann via Phabricator via lldb-commits
teemperor accepted this revision.
teemperor added a comment.
This revision is now accepted and ready to land.

LGTM


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D86996/new/

https://reviews.llvm.org/D86996

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


[Lldb-commits] [PATCH] D86996: [lldb] Add -l/--language option to script command

2020-09-02 Thread Raphael Isemann via Phabricator via lldb-commits
teemperor requested changes to this revision.
teemperor added a comment.

So CommandObjectRaw does support arguments, but they way it works is that you 
need to have a delimiter for the 'raw' part which is `--`. If you have that, 
then you can just use invoke the normal option parsing like 
CommandObjectExpression does. The handcrafted implementation here adds a 
completely new lldb command syntax which has a 'raw' part without the `--` 
which seems inconsistent (not saying that the syntax here is worse or better 
than `script --language foo --`, but it's just inconsistent with the way the 
rest of LLDB works). It's obviously also missing the other quirky things that 
are part of the command syntax (e.g., quoting arguments isn't supported and so 
on).


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D86996/new/

https://reviews.llvm.org/D86996

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


[Lldb-commits] [PATCH] D86497: [lldb] Add reproducer verifier

2020-09-01 Thread Raphael Isemann via Phabricator via lldb-commits
teemperor reopened this revision.
teemperor added a comment.
This revision is now accepted and ready to land.

Don't see an obvious fix, so I reverted for Jonas in 
7c80f2da812e45bbdfa3c8f9ab24440f8ef3362a 



Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D86497/new/

https://reviews.llvm.org/D86497

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


[Lldb-commits] [PATCH] D86497: [lldb] Add reproducer verifier

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

One nit about naming and another small thing, but otherwise this LGTM.




Comment at: lldb/include/lldb/Utility/Reproducer.h:242
+struct ReplayOptions {
+  bool skip_verification = false;
+  bool skip_version_check = false;

I kinda like `verify = true` a bit better than `skip_verification = false`. 
'skip' feels like a negation, so you end up checks like `if 
(!skip_verification) (`= "if we should not not verify" instead of just `if 
(verify)`. Same below.

But that's just personal preference so I won't mind the name if you feel 
strongly about it (and it kinda fits the command line argument names)



Comment at: lldb/source/Utility/Reproducer.cpp:337
+  } else {
+llvm::consumeError(symbol_files.takeError());
+  }

Maybe log the error to llvm::errs? Or is there no symbol-files.yaml when the 
replay doesn't involve symbol files, so this is expected?


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D86497/new/

https://reviews.llvm.org/D86497

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


[Lldb-commits] [PATCH] D84142: [lldb] tab completion for class `CommandObjectTypeFormatterDelete`

2020-08-31 Thread Raphael Isemann via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG1cd99fe9d416: [lldb] tab completion for class 
`CommandObjectTypeFormatterDelete` (authored by MrHate, committed by teemperor).
Herald added a subscriber: lldb-commits.

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D84142/new/

https://reviews.llvm.org/D84142

Files:
  lldb/include/lldb/DataFormatters/FormattersContainer.h
  lldb/source/Commands/CommandObjectType.cpp
  lldb/test/API/functionalities/completion/TestCompletion.py

Index: lldb/test/API/functionalities/completion/TestCompletion.py
===
--- lldb/test/API/functionalities/completion/TestCompletion.py
+++ lldb/test/API/functionalities/completion/TestCompletion.py
@@ -581,6 +581,27 @@
 # (anonymous namespace)::Quux().
 self.complete_from_to('breakpoint set -n Qu', '')
 
+def test_completion_type_formatter_delete(self):
+self.runCmd('type filter add --child a Aoo')
+self.complete_from_to('type filter delete ', ['Aoo'])
+self.runCmd('type filter add --child b -x Boo')
+self.complete_from_to('type filter delete ', ['Boo'])
+
+self.runCmd('type format add -f hex Coo')
+self.complete_from_to('type format delete ', ['Coo'])
+self.runCmd('type format add -f hex -x Doo')
+self.complete_from_to('type format delete ', ['Doo'])
+
+self.runCmd('type summary add -c Eoo')
+self.complete_from_to('type summary delete ', ['Eoo'])
+self.runCmd('type summary add -x -c Foo')
+self.complete_from_to('type summary delete ', ['Foo'])
+
+self.runCmd('type synthetic add Goo -l test')
+self.complete_from_to('type synthetic delete ', ['Goo'])
+self.runCmd('type synthetic add -x Hoo -l test')
+self.complete_from_to('type synthetic delete ', ['Hoo'])
+
 @skipIf(archs=no_match(['x86_64']))
 def test_register_read_and_write_on_x86(self):
 """Test the completion of the commands register read and write on x86"""
Index: lldb/source/Commands/CommandObjectType.cpp
===
--- lldb/source/Commands/CommandObjectType.cpp
+++ lldb/source/Commands/CommandObjectType.cpp
@@ -37,6 +37,9 @@
 #include 
 #include 
 
+#define CHECK_FORMATTER_KIND_MASK(VAL) \
+  ((m_formatter_kind_mask & (VAL)) == (VAL))
+
 using namespace lldb;
 using namespace lldb_private;
 
@@ -777,6 +780,39 @@
 
   ~CommandObjectTypeFormatterDelete() override = default;
 
+  void
+  HandleArgumentCompletion(CompletionRequest ,
+   OptionElementVector _element_vector) override {
+if (request.GetCursorIndex())
+  return;
+
+DataVisualization::Categories::ForEach(
+[this, ](const lldb::TypeCategoryImplSP _sp) {
+  if (CHECK_FORMATTER_KIND_MASK(eFormatCategoryItemValue))
+category_sp->GetTypeFormatsContainer()->AutoComplete(request);
+  if (CHECK_FORMATTER_KIND_MASK(eFormatCategoryItemRegexValue))
+category_sp->GetRegexTypeFormatsContainer()->AutoComplete(request);
+
+  if (CHECK_FORMATTER_KIND_MASK(eFormatCategoryItemSummary))
+category_sp->GetTypeSummariesContainer()->AutoComplete(request);
+  if (CHECK_FORMATTER_KIND_MASK(eFormatCategoryItemRegexSummary))
+category_sp->GetRegexTypeSummariesContainer()->AutoComplete(
+request);
+
+  if (CHECK_FORMATTER_KIND_MASK(eFormatCategoryItemFilter))
+category_sp->GetTypeFiltersContainer()->AutoComplete(request);
+  if (CHECK_FORMATTER_KIND_MASK(eFormatCategoryItemRegexFilter))
+category_sp->GetRegexTypeFiltersContainer()->AutoComplete(request);
+
+  if (CHECK_FORMATTER_KIND_MASK(eFormatCategoryItemSynth))
+category_sp->GetTypeSyntheticsContainer()->AutoComplete(request);
+  if (CHECK_FORMATTER_KIND_MASK(eFormatCategoryItemRegexSynth))
+category_sp->GetRegexTypeSyntheticsContainer()->AutoComplete(
+request);
+  return true;
+});
+  }
+
 protected:
   virtual bool FormatterSpecificDeletion(ConstString typeCS) { return false; }
 
Index: lldb/include/lldb/DataFormatters/FormattersContainer.h
===
--- lldb/include/lldb/DataFormatters/FormattersContainer.h
+++ lldb/include/lldb/DataFormatters/FormattersContainer.h
@@ -202,6 +202,13 @@
 return m_map.size();
   }
 
+  void AutoComplete(CompletionRequest ) {
+ForEach([](const TypeMatcher , const ValueSP ) {
+  request.TryCompleteCurrentArg(matcher.GetMatchString().GetStringRef());
+  return true;
+});
+  }
+
 protected:
   FormattersContainer(const FormattersContainer &) = delete;
   const FormattersContainer =(const FormattersContainer &) = delete;

[Lldb-commits] [PATCH] D86593: [lldb] Don't crash when LLDB can't extract the tsan report

2020-08-31 Thread Raphael Isemann via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG1c5a0cb1c3bf: [lldb] Dont crash when LLDB cant 
extract the tsan report (authored by teemperor).
Herald added subscribers: lldb-commits, danielkiss.
Herald added a project: LLDB.

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D86593/new/

https://reviews.llvm.org/D86593

Files:
  lldb/source/Plugins/InstrumentationRuntime/TSan/InstrumentationRuntimeTSan.cpp


Index: 
lldb/source/Plugins/InstrumentationRuntime/TSan/InstrumentationRuntimeTSan.cpp
===
--- 
lldb/source/Plugins/InstrumentationRuntime/TSan/InstrumentationRuntimeTSan.cpp
+++ 
lldb/source/Plugins/InstrumentationRuntime/TSan/InstrumentationRuntimeTSan.cpp
@@ -809,7 +809,9 @@
 
   StructuredData::ObjectSP report =
   instance->RetrieveReportData(context->exe_ctx_ref);
-  std::string stop_reason_description;
+  std::string stop_reason_description =
+  "unknown thread sanitizer fault (unable to extract thread sanitizer "
+  "report)";
   if (report) {
 std::string issue_description = instance->FormatDescription(report);
 report->GetAsDictionary()->AddStringItem("description", issue_description);


Index: lldb/source/Plugins/InstrumentationRuntime/TSan/InstrumentationRuntimeTSan.cpp
===
--- lldb/source/Plugins/InstrumentationRuntime/TSan/InstrumentationRuntimeTSan.cpp
+++ lldb/source/Plugins/InstrumentationRuntime/TSan/InstrumentationRuntimeTSan.cpp
@@ -809,7 +809,9 @@
 
   StructuredData::ObjectSP report =
   instance->RetrieveReportData(context->exe_ctx_ref);
-  std::string stop_reason_description;
+  std::string stop_reason_description =
+  "unknown thread sanitizer fault (unable to extract thread sanitizer "
+  "report)";
   if (report) {
 std::string issue_description = instance->FormatDescription(report);
 report->GetAsDictionary()->AddStringItem("description", issue_description);
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D86497: [lldb] Add reproducer verifier

2020-08-26 Thread Raphael Isemann via Phabricator via lldb-commits
teemperor requested changes to this revision.
teemperor added a comment.
This revision now requires changes to proceed.

As discussed offline, I think the warnings here seem also useful when just 
replaying. I guess we should make it clear that things like missing files are 
fine when replaying a reproducer (e.g., just pointing that out as a 'note' and 
not warning/error). Beside that this LGTM.




Comment at: lldb/source/Commands/CommandObjectReproducer.cpp:146
+
+/// Create a loader form the given path if specified. Otherwise use the current
+/// loader used for replay.

`form` -> `from`



Comment at: lldb/source/Commands/CommandObjectReproducer.cpp:156
+if (Error err = loader->LoadIndex()) {
+  // This is a hard error and will set the result tot eReturnStatusFailed.
+  SetError(result, std::move(err));

`tot` -> `to`



Comment at: lldb/source/Commands/CommandObjectReproducer.cpp:603
+"If no reproducer is specified during replay, it "
+"dumps the content of the current reproducer.",
+nullptr) {}

Is that dumping implemented? It's also kind of surprising that `verify` dumps 
the current reproducer instead of verifying it.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D86497/new/

https://reviews.llvm.org/D86497

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


[Lldb-commits] [PATCH] D86616: [cmake] Make gtest include directories a part of the library interface

2020-08-26 Thread Raphael Isemann via Phabricator via lldb-commits
teemperor accepted this revision.
teemperor added a comment.

LGTM too


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D86616/new/

https://reviews.llvm.org/D86616

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


[Lldb-commits] [PATCH] D86603: [lldb] Correct wording of EXP_MSG

2020-08-26 Thread Raphael Isemann via Phabricator via lldb-commits
teemperor added a comment.

That's true, `EXP_MSG` is not used like the other messages so the only problem 
with it is the confusing error message.

IMHO this is still good to land as it improves the error message. If you want 
to implement Pavel's much nicer error message in a follow-up patch, that would 
be very much appreciated!


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D86603/new/

https://reviews.llvm.org/D86603

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


[Lldb-commits] [PATCH] D86603: [lldb] Correct wording of EXP_MSG

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

FWIW, I actually think this patch itself is perfectly fine. As these messages 
are only displayed when an assert failed they should be worded with the 
assumption that the assert did indeed fail. It would be nice to reword all the 
other messages around this change to also follow this style, but I'm not a fan 
of signing up others for tedious work and this is a step in the right 
direction, so LGTM.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D86603/new/

https://reviews.llvm.org/D86603

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


[Lldb-commits] [PATCH] D86603: [lldb] Correct wording of EXP_MSG

2020-08-26 Thread Raphael Isemann via Phabricator via lldb-commits
teemperor added a reviewer: LLDB.
teemperor added a comment.

If you look at the other "assert messages" above and below your patch you'll 
see that all (most?) of them use this very confusing "Say the opposite of what 
actually happened" style. Weirdly enough only around 70% of the "assertion 
messages" in the test suite are using this style, the others are using an 
"unexpected thing has happened" error message.

IMHO we should just completely remove all these assertion messages. Not once 
have they been useful to me when debugging a test. I would argue that 99% of 
them don't add any additional information that isn't obvious when looking at 
the assert itself. They also are usually just making the assertions longer and 
harder to read. Even worse, when I started hacking on LLDB they were often even 
suppressing the *actual error* which made it impossible to debug a test on a 
build bot (but that is thankfully fixed these days). And finally the fact that 
they can be worded in these two different ways just ends up causing confusion.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D86603/new/

https://reviews.llvm.org/D86603

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


[Lldb-commits] [PATCH] D86389: [lldb] Add a SymbolFileProvider to record and replay calls to dsymForUUID

2020-08-25 Thread Raphael Isemann via Phabricator via lldb-commits
teemperor added a comment.

Seems like this were just some missing calls to initialize/terminate. I added 
them in an ugly hotfix commit.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D86389/new/

https://reviews.llvm.org/D86389

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


[Lldb-commits] [PATCH] D86211: [lldb] Don't ask for QOS_CLASS_UNSPECIFIED queue in TestQueues

2020-08-25 Thread Raphael Isemann via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG7de7fe5d0e3f: [lldb] Dont ask for 
QOS_CLASS_UNSPECIFIED queue in TestQueues (authored by teemperor).
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D86211/new/

https://reviews.llvm.org/D86211

Files:
  lldb/test/API/macosx/queues/TestQueues.py
  lldb/test/API/macosx/queues/main.c


Index: lldb/test/API/macosx/queues/main.c
===
--- lldb/test/API/macosx/queues/main.c
+++ lldb/test/API/macosx/queues/main.c
@@ -136,15 +136,9 @@
 while (1)
 sleep (10);
   });
-dispatch_async (dispatch_get_global_queue(QOS_CLASS_UNSPECIFIED, 0), ^{
-pthread_setname_np ("unspecified QoS");
-atomic_fetch_add(_count, 1);
-while (1)
-sleep (10);
-  });
 
 // Unfortunately there is no pthread_barrier on darwin.
-while ((atomic_load(_count) < 13) || (finished_enqueueing_work == 
0))
+while ((atomic_load(_count) < 12) || (finished_enqueueing_work == 
0))
 sleep (1);
 
 stopper ();
Index: lldb/test/API/macosx/queues/TestQueues.py
===
--- lldb/test/API/macosx/queues/TestQueues.py
+++ lldb/test/API/macosx/queues/TestQueues.py
@@ -192,7 +192,6 @@
 user_initiated_thread = lldb.SBThread()
 user_interactive_thread = lldb.SBThread()
 utility_thread = lldb.SBThread()
-unspecified_thread = lldb.SBThread()
 background_thread = lldb.SBThread()
 for th in process.threads:
 if th.GetName() == "user initiated QoS":
@@ -201,8 +200,6 @@
 user_interactive_thread = th
 if th.GetName() == "utility QoS":
 utility_thread = th
-if th.GetName() == "unspecified QoS":
-unspecified_thread = th
 if th.GetName() == "background QoS":
 background_thread = th
 
@@ -213,9 +210,6 @@
 user_interactive_thread.IsValid(),
 "Found user interactive QoS thread")
 self.assertTrue(utility_thread.IsValid(), "Found utility QoS thread")
-self.assertTrue(
-unspecified_thread.IsValid(),
-"Found unspecified QoS thread")
 self.assertTrue(
 background_thread.IsValid(),
 "Found background QoS thread")
@@ -248,16 +242,6 @@
 stream.GetData(), "Utility",
 "utility QoS thread name is valid")
 stream.Clear()
-self.assertTrue(
-unspecified_thread.GetInfoItemByPathAsString(
-"requested_qos.printable_name",
-stream),
-"Get QoS printable string for unspecified QoS thread")
-qosName = stream.GetData()
-self.assertTrue(
-qosName == "User Initiated" or qosName == "Default",
-"unspecified QoS thread name is valid: " + str(qosName))
-stream.Clear()
 self.assertTrue(
 background_thread.GetInfoItemByPathAsString(
 "requested_qos.printable_name",


Index: lldb/test/API/macosx/queues/main.c
===
--- lldb/test/API/macosx/queues/main.c
+++ lldb/test/API/macosx/queues/main.c
@@ -136,15 +136,9 @@
 while (1)
 sleep (10);
   });
-dispatch_async (dispatch_get_global_queue(QOS_CLASS_UNSPECIFIED, 0), ^{
-pthread_setname_np ("unspecified QoS");
-atomic_fetch_add(_count, 1);
-while (1)
-sleep (10);
-  });
 
 // Unfortunately there is no pthread_barrier on darwin.
-while ((atomic_load(_count) < 13) || (finished_enqueueing_work == 0))
+while ((atomic_load(_count) < 12) || (finished_enqueueing_work == 0))
 sleep (1);
 
 stopper ();
Index: lldb/test/API/macosx/queues/TestQueues.py
===
--- lldb/test/API/macosx/queues/TestQueues.py
+++ lldb/test/API/macosx/queues/TestQueues.py
@@ -192,7 +192,6 @@
 user_initiated_thread = lldb.SBThread()
 user_interactive_thread = lldb.SBThread()
 utility_thread = lldb.SBThread()
-unspecified_thread = lldb.SBThread()
 background_thread = lldb.SBThread()
 for th in process.threads:
 if th.GetName() == "user initiated QoS":
@@ -201,8 +200,6 @@
 user_interactive_thread = th
 if th.GetName() == "utility QoS":
 utility_thread = th
-if th.GetName() == "unspecified QoS":
-unspecified_thread = th
 if th.GetName() == "background QoS":
 background_thread = th
 
@@ -213,9 +210,6 @@
 user_interactive_thread.IsValid(),

[Lldb-commits] [PATCH] D86389: [lldb] Add a SymbolFileProvider to record and replay calls to dsymForUUID

2020-08-25 Thread Raphael Isemann via Phabricator via lldb-commits
teemperor added a comment.

Pretty sure this broke some tests 
http://green.lab.llvm.org/green/view/LLDB/job/lldb-cmake/23476/

  Note: Google Test filter = 
SymbolsTest.LocateExecutableSymbolFileForUnknownExecutableAndMissingSymbolFile
  [==] Running 1 test from 1 test case.
  [--] Global test environment set-up.
  [--] 1 test from SymbolsTest
  [ RUN  ] 
SymbolsTest.LocateExecutableSymbolFileForUnknownExecutableAndMissingSymbolFile
  Assertion failed: (hasVal), function getValue, file 
/Users/buildslave/jenkins/workspace/lldb-cmake@2/llvm-project/llvm/include/llvm/ADT/Optional.h,
 line 73.
  0  SymbolTests  0x00010943f8a5 
llvm::sys::PrintStackTrace(llvm::raw_ostream&) + 37
  1  SymbolTests  0x00010943e836 llvm::sys::RunSignalHandlers() 
+ 198
  2  SymbolTests  0x00010943fe86 SignalHandler(int) + 262
  3  libsystem_platform.dylib 0x7fff6e8b35fd _sigtramp + 29
  4  libsystem_platform.dylib 0x _sigtramp + 
12297688647425029322
  5  libsystem_c.dylib0x7fff6e785808 abort + 120
  6  libsystem_c.dylib0x7fff6e784ac6 err + 0
  7  SymbolTests  0x00010a8f0bf5 
lldb_private::repro::Reproducer::Instance() + 133
  8  SymbolTests  0x0001094a7261 
LocateMacOSXFilesUsingDebugSymbols(lldb_private::ModuleSpec const&, 
lldb_private::ModuleSpec&) + 433
  9  SymbolTests  0x0001094894dd 
lldb_private::Symbols::LocateExecutableSymbolFile(lldb_private::ModuleSpec 
const&, lldb_private::FileSpecList const&) + 5741
  10 SymbolTests  0x00010932f232 
SymbolsTest_LocateExecutableSymbolFileForUnknownExecutableAndMissingSymbolFile_Test::TestBody()
 + 274
  11 SymbolTests  0x00010944869f testing::Test::Run() + 527
  12 SymbolTests  0x000109449516 testing::TestInfo::Run() + 566
  13 SymbolTests  0x000109449d47 testing::TestCase::Run() + 247
  14 SymbolTests  0x000109452877 
testing::internal::UnitTestImpl::RunAllTests() + 1287
  15 SymbolTests  0x0001094522fb testing::UnitTest::Run() + 171
  16 SymbolTests  0x000109441209 main + 121
  17 libdyld.dylib0x7fff6e6b6cc9 start + 1
  18 libdyld.dylib0x0002 start + 18446603338663629626


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D86389/new/

https://reviews.llvm.org/D86389

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


[Lldb-commits] [PATCH] D84124: [lldb] type category name common completion

2020-08-24 Thread Raphael Isemann via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG188f1ac301c5: [lldb] type category name common completion 
(authored by MrHate, committed by teemperor).
Herald added a subscriber: lldb-commits.

Changed prior to commit:
  https://reviews.llvm.org/D84124?vs=279085=287448#toc

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D84124/new/

https://reviews.llvm.org/D84124

Files:
  lldb/include/lldb/Interpreter/CommandCompletions.h
  lldb/source/Commands/CommandCompletions.cpp
  lldb/source/Commands/CommandObjectTarget.cpp
  lldb/source/Commands/CommandObjectType.cpp
  lldb/source/Interpreter/CommandObject.cpp
  lldb/test/API/functionalities/completion/TestCompletion.py

Index: lldb/test/API/functionalities/completion/TestCompletion.py
===
--- lldb/test/API/functionalities/completion/TestCompletion.py
+++ lldb/test/API/functionalities/completion/TestCompletion.py
@@ -468,6 +468,12 @@
 for subcommand in subcommands:
 self.complete_from_to('thread ' + subcommand + ' ', ['1'])
 
+def test_common_completion_type_category_name(self):
+subcommands = ['delete', 'list', 'enable', 'disable', 'define']
+for subcommand in subcommands:
+self.complete_from_to('type category ' + subcommand + ' ', ['default'])
+self.complete_from_to('type filter add -w ', ['default'])
+
 def test_command_argument_completion(self):
 """Test completion of command arguments"""
 self.complete_from_to("watchpoint set variable -", ["-w", "-s"])
Index: lldb/source/Interpreter/CommandObject.cpp
===
--- lldb/source/Interpreter/CommandObject.cpp
+++ lldb/source/Interpreter/CommandObject.cpp
@@ -1068,7 +1068,7 @@
 { eArgTypeLogCategory, "log-category", CommandCompletions::eNoCompletion, { nullptr, false }, "The name of a category within a log channel, e.g. all (try \"log list\" to see a list of all channels and their categories." },
 { eArgTypeLogChannel, "log-channel", CommandCompletions::eNoCompletion, { nullptr, false }, "The name of a log channel, e.g. process.gdb-remote (try \"log list\" to see a list of all channels and their categories)." },
 { eArgTypeMethod, "method", CommandCompletions::eNoCompletion, { nullptr, false }, "A C++ method name." },
-{ eArgTypeName, "name", CommandCompletions::eNoCompletion, { nullptr, false }, "Help text goes here." },
+{ eArgTypeName, "name", CommandCompletions::eTypeCategoryNameCompletion, { nullptr, false }, "Help text goes here." },
 { eArgTypeNewPathPrefix, "new-path-prefix", CommandCompletions::eNoCompletion, { nullptr, false }, "Help text goes here." },
 { eArgTypeNumLines, "num-lines", CommandCompletions::eNoCompletion, { nullptr, false }, "The number of lines to use." },
 { eArgTypeNumberPerLine, "number-per-line", CommandCompletions::eNoCompletion, { nullptr, false }, "The number of items per line to display." },
Index: lldb/source/Commands/CommandObjectType.cpp
===
--- lldb/source/Commands/CommandObjectType.cpp
+++ lldb/source/Commands/CommandObjectType.cpp
@@ -1769,6 +1769,14 @@
 
   ~CommandObjectTypeCategoryDefine() override = default;
 
+  void
+  HandleArgumentCompletion(CompletionRequest ,
+   OptionElementVector _element_vector) override {
+CommandCompletions::InvokeCommonCompletionCallbacks(
+GetCommandInterpreter(),
+CommandCompletions::eTypeCategoryNameCompletion, request, nullptr);
+  }
+
 protected:
   bool DoExecute(Args , CommandReturnObject ) override {
 const size_t argc = command.GetArgumentCount();
@@ -1865,6 +1873,14 @@
 
   ~CommandObjectTypeCategoryEnable() override = default;
 
+  void
+  HandleArgumentCompletion(CompletionRequest ,
+   OptionElementVector _element_vector) override {
+CommandCompletions::InvokeCommonCompletionCallbacks(
+GetCommandInterpreter(),
+CommandCompletions::eTypeCategoryNameCompletion, request, nullptr);
+  }
+
 protected:
   bool DoExecute(Args , CommandReturnObject ) override {
 const size_t argc = command.GetArgumentCount();
@@ -1927,6 +1943,14 @@
 
   ~CommandObjectTypeCategoryDelete() override = default;
 
+  void
+  HandleArgumentCompletion(CompletionRequest ,
+   OptionElementVector _element_vector) override {
+CommandCompletions::InvokeCommonCompletionCallbacks(
+GetCommandInterpreter(),
+CommandCompletions::eTypeCategoryNameCompletion, request, nullptr);
+  }
+
 protected:
   bool DoExecute(Args , CommandReturnObject ) override {
 const size_t argc = command.GetArgumentCount();
@@ -2032,6 +2056,14 @@
 
   ~CommandObjectTypeCategoryDisable() override = default;
 
+  void
+  HandleArgumentCompletion(CompletionRequest ,
+   

[Lldb-commits] [PATCH] D85284: [lldb] Remote disk file/directory completion for platform commands

2020-08-24 Thread Raphael Isemann via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG3cd8d7b1727f: [lldb] Remote disk file/directory completion 
for platform commands (authored by MrHate, committed by teemperor).
Herald added a subscriber: lldb-commits.

Changed prior to commit:
  https://reviews.llvm.org/D85284?vs=286611=287414#toc

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D85284/new/

https://reviews.llvm.org/D85284

Files:
  lldb/docs/lldb-platform-packets.txt
  lldb/include/lldb/Interpreter/CommandCompletions.h
  lldb/include/lldb/Target/Platform.h
  lldb/include/lldb/Utility/StringExtractorGDBRemote.h
  lldb/source/Commands/CommandCompletions.cpp
  lldb/source/Commands/CommandObjectPlatform.cpp
  lldb/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp
  lldb/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.h
  lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
  lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.h
  
lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerPlatform.cpp
  lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerPlatform.h
  lldb/source/Utility/StringExtractorGDBRemote.cpp
  
lldb/test/API/functionalities/gdb_remote_client/TestGDBRemoteDiskFileCompletion.py
  lldb/test/API/functionalities/gdb_remote_client/gdbclientutils.py
  lldb/test/API/tools/lldb-server/TestGdbRemoteCompletion.py

Index: lldb/test/API/tools/lldb-server/TestGdbRemoteCompletion.py
===
--- /dev/null
+++ lldb/test/API/tools/lldb-server/TestGdbRemoteCompletion.py
@@ -0,0 +1,63 @@
+import tempfile
+import gdbremote_testcase
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test.decorators import *
+from lldbgdbserverutils import *
+
+class GdbRemoteCompletionTestCase(gdbremote_testcase.GdbRemoteTestCaseBase):
+mydir = TestBase.compute_mydir(__file__)
+
+def init_lldb_server(self):
+self.debug_monitor_exe = get_lldb_server_exe()
+if not self.debug_monitor_exe:
+self.skipTest("lldb-server exe not found")
+port_file = tempfile.NamedTemporaryFile().name
+commandline_args = [
+"platform",
+"--listen",
+"*:0",
+"--socket-file",
+port_file
+]
+server = self.spawnSubprocess(
+get_lldb_server_exe(),
+commandline_args,
+install_remote=False)
+self.assertIsNotNone(server)
+self.stub_hostname = "localhost"
+self.port = int(lldbutil.wait_for_file_on_target(self, port_file))
+self.sock = self.create_socket()
+
+self.add_no_ack_remote_stream()
+
+def generate_hex_path(self, target):
+return str(os.path.join(self.getBuildDir(), target)).encode().hex()
+
+@skipIfDarwinEmbedded #  lldb-server tests not updated to work on ios etc yet
+@llgs_test
+def test_autocomplete_path(self):
+self.build()
+self.init_lldb_server()
+
+# Test file-included completion when flag is set to 0.
+self.test_sequence.add_log_lines(
+["read packet: $qPathComplete:0,{}#00".format(
+self.generate_hex_path("main")),
+ "send packet: $M{},{}#00".format(
+self.generate_hex_path("main.d"),
+self.generate_hex_path("main.o"))
+],
+True)
+
+# Test directory-only completion when flag is set to 1.
+os.makedirs(os.path.join(self.getBuildDir(), "test"))
+self.test_sequence.add_log_lines(
+["read packet: $qPathComplete:1,{}#00".format(
+self.generate_hex_path("tes")),
+ "send packet: $M{}{}#00".format(
+self.generate_hex_path("test"),
+os.path.sep.encode().hex()) # "test/" or "test\".
+],
+True)
+
+self.expect_gdbremote_sequence()
Index: lldb/test/API/functionalities/gdb_remote_client/gdbclientutils.py
===
--- lldb/test/API/functionalities/gdb_remote_client/gdbclientutils.py
+++ lldb/test/API/functionalities/gdb_remote_client/gdbclientutils.py
@@ -178,6 +178,8 @@
 return self.qsProcessInfo()
 if packet.startswith("qfProcessInfo"):
 return self.qfProcessInfo(packet)
+if packet.startswith("qPathComplete:"):
+return self.qPathComplete()
 
 return self.other(packet)
 
@@ -282,6 +284,9 @@
 def qMemoryRegionInfo(self):
 return ""
 
+def qPathComplete(self):
+return ""
+
 """
 Raised when we receive a packet for which there is no default action.
 Override the responder class to implement behavior suitable for the test at
Index: lldb/test/API/functionalities/gdb_remote_client/TestGDBRemoteDiskFileCompletion.py

[Lldb-commits] [PATCH] D80700: [lldb] common completion for process pids and process names

2020-08-24 Thread Raphael Isemann via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG19311f5c3e9a: [lldb] common completion for process pids and 
process names (authored by MrHate, committed by teemperor).
Herald added a subscriber: lldb-commits.

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D80700/new/

https://reviews.llvm.org/D80700

Files:
  lldb/include/lldb/Interpreter/CommandCompletions.h
  lldb/source/Commands/CommandCompletions.cpp
  lldb/source/Commands/CommandObjectPlatform.cpp
  lldb/source/Commands/CommandObjectProcess.cpp
  lldb/source/Interpreter/CommandObject.cpp
  lldb/test/API/functionalities/completion/TestCompletion.py
  lldb/test/API/functionalities/completion/main.cpp

Index: lldb/test/API/functionalities/completion/main.cpp
===
--- lldb/test/API/functionalities/completion/main.cpp
+++ lldb/test/API/functionalities/completion/main.cpp
@@ -1,3 +1,5 @@
+#include 
+
 class Foo
 {
 public:
@@ -11,14 +13,16 @@
 
 struct Container { int MemberVar; };
 
-int main()
-{
-Foo fooo;
-Foo *ptr_fooo = 
-fooo.Bar(1, 2);
+int main(int argc, char *argv[]) {
+  if (argc > 1 && std::string(argv[1]) == "-x")
+std::cin.get();
+
+  Foo fooo;
+  Foo *ptr_fooo = 
+  fooo.Bar(1, 2);
 
-Container container;
-Container *ptr_container = 
-int q = Quux();
-return container.MemberVar = 3; // Break here
+  Container container;
+  Container *ptr_container = 
+  int q = Quux();
+  return container.MemberVar = 3; // Break here
 }
Index: lldb/test/API/functionalities/completion/TestCompletion.py
===
--- lldb/test/API/functionalities/completion/TestCompletion.py
+++ lldb/test/API/functionalities/completion/TestCompletion.py
@@ -5,6 +5,8 @@
 
 
 import os
+from multiprocessing import Process
+import psutil
 import lldb
 from lldbsuite.test.decorators import *
 from lldbsuite.test.lldbtest import *
@@ -117,6 +119,27 @@
 self.complete_from_to('process ' + subcommand + ' mac',
   'process ' + subcommand + ' mach-o-core')
 
+@skipIfRemote
+def test_common_completion_process_pid_and_name(self):
+# The LLDB process itself and the process already attached to are both
+# ignored by the process discovery mechanism, thus we need a process known 
+# to us here.
+self.build()
+server = self.spawnSubprocess(
+self.getBuildArtifact("a.out"),
+["-x"], # Arg "-x" makes the subprocess wait for input thus it won't be terminated too early
+install_remote=False)
+self.assertIsNotNone(server)
+pid = server.pid
+
+self.complete_from_to('process attach -p ', [str(pid)])
+self.complete_from_to('platform process attach -p ', [str(pid)])
+self.complete_from_to('platform process info ', [str(pid)])
+
+pname = psutil.Process(pid).name()  # FIXME: psutil doesn't work for remote
+self.complete_from_to('process attach -n ', [str(pname)])
+self.complete_from_to('platform process attach -n ', [str(pname)])
+
 def test_process_signal(self):
 # The tab completion for "process signal"  won't work without a running process.
 self.complete_from_to('process signal ',
Index: lldb/source/Interpreter/CommandObject.cpp
===
--- lldb/source/Interpreter/CommandObject.cpp
+++ lldb/source/Interpreter/CommandObject.cpp
@@ -1078,9 +1078,9 @@
 { eArgTypePath, "path", CommandCompletions::eDiskFileCompletion, { nullptr, false }, "Path." },
 { eArgTypePermissionsNumber, "perms-numeric", CommandCompletions::eNoCompletion, { nullptr, false }, "Permissions given as an octal number (e.g. 755)." },
 { eArgTypePermissionsString, "perms=string", CommandCompletions::eNoCompletion, { nullptr, false }, "Permissions given as a string value (e.g. rw-r-xr--)." },
-{ eArgTypePid, "pid", CommandCompletions::eNoCompletion, { nullptr, false }, "The process ID number." },
+{ eArgTypePid, "pid", CommandCompletions::eProcessIDCompletion, { nullptr, false }, "The process ID number." },
 { eArgTypePlugin, "plugin", CommandCompletions::eProcessPluginCompletion, { nullptr, false }, "Help text goes here." },
-{ eArgTypeProcessName, "process-name", CommandCompletions::eNoCompletion, { nullptr, false }, "The name of the process." },
+{ eArgTypeProcessName, "process-name", CommandCompletions::eProcessNameCompletion, { nullptr, false }, "The name of the process." },
 { eArgTypePythonClass, "python-class", CommandCompletions::eNoCompletion, { nullptr, false }, "The name of a Python class." },
 { eArgTypePythonFunction, "python-function", CommandCompletions::eNoCompletion, { nullptr, false }, "The name of a Python function." },
 { eArgTypePythonScript, "python-script", 

[Lldb-commits] [PATCH] D86416: [lldb] -stdlib=libc++ for linking with lldb lib also if LLVM_ENABLE_LIBCXX

2020-08-24 Thread Raphael Isemann via Phabricator via lldb-commits
teemperor added a reviewer: JDevlieghere.
teemperor added a comment.

Thanks for working on this! This looks good to me, but I wonder if doing this 
with a dedicated flag instead of an environment variable would be better. But 
I'll leave that to the others who have a better idea how the dotest flags 
should work.

Out of curiosity, will this also fix the TestPluginCommands.py ?




Comment at: lldb/test/API/lit.site.cfg.py.in:23
 config.python_executable = "@Python3_EXECUTABLE@"
+config.libcxx_used = @LLVM_LIBCXX_USED@
 config.dotest_path = "@LLDB_SOURCE_DIR@/test/API/dotest.py"

Maybe move this below the `config.llvm_use_sanitizer` line, as this is 
currently in the middle of the python/dotest.py-related config flags.


Repository:
  rLLDB LLDB

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D86416/new/

https://reviews.llvm.org/D86416

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


[Lldb-commits] [PATCH] D79887: [lldb] Tab completion for process load/unload

2020-08-21 Thread Raphael Isemann via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGe1cd7cac8a36: [lldb] Tab completion for process load/unload 
(authored by MrHate, committed by teemperor).
Herald added a subscriber: lldb-commits.

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D79887/new/

https://reviews.llvm.org/D79887

Files:
  lldb/include/lldb/Target/Process.h
  lldb/source/Commands/CommandObjectProcess.cpp
  lldb/test/API/functionalities/completion/Makefile
  lldb/test/API/functionalities/completion/TestCompletion.py
  lldb/test/API/functionalities/completion/shared.cpp

Index: lldb/test/API/functionalities/completion/shared.cpp
===
--- /dev/null
+++ lldb/test/API/functionalities/completion/shared.cpp
@@ -0,0 +1,3 @@
+int foo() {
+  return 123;
+}
Index: lldb/test/API/functionalities/completion/TestCompletion.py
===
--- lldb/test/API/functionalities/completion/TestCompletion.py
+++ lldb/test/API/functionalities/completion/TestCompletion.py
@@ -85,6 +85,31 @@
   ['mips',
'arm64'])
 
+def test_process_load(self):
+self.build()
+lldbutil.run_to_source_breakpoint(self, '// Break here', lldb.SBFileSpec("main.cpp"))
+self.complete_from_to('process load Makef', 'process load Makefile')
+
+@skipUnlessPlatform(["linux"])
+def test_process_unload(self):
+"""Test the completion for "process unload " """
+# This tab completion should not work without a running process.
+self.complete_from_to('process unload ',
+  'process unload ')
+
+self.build()
+lldbutil.run_to_source_breakpoint(self, '// Break here', lldb.SBFileSpec("main.cpp"))
+err = lldb.SBError()
+self.process().LoadImage(lldb.SBFileSpec(self.getBuildArtifact("libshared.so")), err)
+self.assertSuccess(err)
+
+self.complete_from_to('process unload ',
+  'process unload 0')
+
+self.process().UnloadImage(0)
+self.complete_from_to('process unload ',
+  'process unload ')
+
 def test_process_plugin_completion(self):
 subcommands = ['attach -P', 'connect -p', 'launch -p']
 
Index: lldb/test/API/functionalities/completion/Makefile
===
--- lldb/test/API/functionalities/completion/Makefile
+++ lldb/test/API/functionalities/completion/Makefile
@@ -1,3 +1,10 @@
 CXX_SOURCES := main.cpp
+USE_LIBDL := 1
+
+a.out: lib_shared
+
+lib_shared:
+	$(MAKE) -f $(MAKEFILE_RULES) \
+		DYLIB_ONLY=YES DYLIB_CXX_SOURCES=shared.cpp DYLIB_NAME=shared
 
 include Makefile.rules
Index: lldb/source/Commands/CommandObjectProcess.cpp
===
--- lldb/source/Commands/CommandObjectProcess.cpp
+++ lldb/source/Commands/CommandObjectProcess.cpp
@@ -923,6 +923,17 @@
 
   ~CommandObjectProcessLoad() override = default;
 
+  void
+  HandleArgumentCompletion(CompletionRequest ,
+   OptionElementVector _element_vector) override {
+if (!m_exe_ctx.HasProcessScope())
+  return;
+
+CommandCompletions::InvokeCommonCompletionCallbacks(
+GetCommandInterpreter(), CommandCompletions::eDiskFileCompletion,
+request, nullptr);
+  }
+
   Options *GetOptions() override { return _options; }
 
 protected:
@@ -988,6 +999,24 @@
 
   ~CommandObjectProcessUnload() override = default;
 
+  void
+  HandleArgumentCompletion(CompletionRequest ,
+   OptionElementVector _element_vector) override {
+
+if (request.GetCursorIndex() || !m_exe_ctx.HasProcessScope())
+  return;
+
+Process *process = m_exe_ctx.GetProcessPtr();
+
+const std::vector  = process->GetImageTokens();
+const size_t token_num = tokens.size();
+for (size_t i = 0; i < token_num; ++i) {
+  if (tokens[i] == LLDB_INVALID_IMAGE_TOKEN)
+continue;
+  request.TryCompleteCurrentArg(std::to_string(i));
+}
+  }
+
 protected:
   bool DoExecute(Args , CommandReturnObject ) override {
 Process *process = m_exe_ctx.GetProcessPtr();
Index: lldb/include/lldb/Target/Process.h
===
--- lldb/include/lldb/Target/Process.h
+++ lldb/include/lldb/Target/Process.h
@@ -739,6 +739,12 @@
 
   void SetShouldDetach(bool b) { m_should_detach = b; }
 
+  /// Get the image vector for the current process.
+  ///
+  /// \return
+  /// The constant reference to the member m_image_tokens.
+  const std::vector& GetImageTokens() { return m_image_tokens; }
+
   /// Get the image information address for the current process.
   ///
   /// Some runtimes have system functions that can help dynamic loaders locate

[Lldb-commits] [PATCH] D80693: [lldb] tab completion for breakpoint names

2020-08-20 Thread Raphael Isemann via Phabricator via lldb-commits
This revision was not accepted when it landed; it landed in state "Needs 
Review".
This revision was automatically updated to reflect the committed changes.
Closed by commit rG22e63cba17e5: [lldb] tab completion for breakpoint names 
(authored by MrHate, committed by teemperor).
Herald added a subscriber: lldb-commits.

Changed prior to commit:
  https://reviews.llvm.org/D80693?vs=276295=286870#toc

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D80693/new/

https://reviews.llvm.org/D80693

Files:
  lldb/include/lldb/Interpreter/CommandCompletions.h
  lldb/source/Commands/CommandCompletions.cpp
  lldb/source/Commands/CommandObjectBreakpoint.cpp
  lldb/source/Interpreter/CommandObject.cpp
  lldb/test/API/functionalities/completion/TestCompletion.py
  lldb/test/API/functionalities/completion/breakpoints.json
  lldb/test/API/functionalities/completion/breakpoints_invalid.json

Index: lldb/test/API/functionalities/completion/breakpoints_invalid.json
===
--- /dev/null
+++ lldb/test/API/functionalities/completion/breakpoints_invalid.json
@@ -0,0 +1,6 @@
+[
+{
+"Breakpoint": {
+}
+}
+]
Index: lldb/test/API/functionalities/completion/breakpoints.json
===
--- /dev/null
+++ lldb/test/API/functionalities/completion/breakpoints.json
@@ -0,0 +1,34 @@
+[
+{
+"Breakpoint": {
+"BKPTOptions": {
+"AutoContinue": false,
+"ConditionText": "",
+"EnabledState": true,
+"IgnoreCount": 0,
+"OneShotState": false
+},
+"BKPTResolver": {
+"Options": {
+"NameMask": [
+56
+],
+"Offset": 0,
+"SkipPrologue": true,
+"SymbolNames": [
+"main"
+]
+},
+"Type": "SymbolName"
+},
+"Hardware": false,
+"Names": [
+"mm"
+],
+"SearchFilter": {
+"Options": {},
+"Type": "Unconstrained"
+}
+}
+}
+]
Index: lldb/test/API/functionalities/completion/TestCompletion.py
===
--- lldb/test/API/functionalities/completion/TestCompletion.py
+++ lldb/test/API/functionalities/completion/TestCompletion.py
@@ -644,3 +644,21 @@
   ['1',
'2'])
 
+def test_complete_breakpoint_with_names(self):
+self.build()
+target = self.dbg.CreateTarget(self.getBuildArtifact('a.out'))
+self.assertTrue(target, VALID_TARGET)
+
+# test breakpoint read dedicated
+self.complete_from_to('breakpoint read -N ', 'breakpoint read -N ')
+self.complete_from_to('breakpoint read -f breakpoints.json -N ', ['mm'])
+self.complete_from_to('breakpoint read -f breakpoints.json -N n', 'breakpoint read -f breakpoints.json -N n')
+self.complete_from_to('breakpoint read -f breakpoints_invalid.json -N ', 'breakpoint read -f breakpoints_invalid.json -N ')
+
+# test common breapoint name completion
+bp1 = target.BreakpointCreateByName('main', 'a.out')
+self.assertTrue(bp1)
+self.assertEqual(bp1.GetNumLocations(), 1)
+self.complete_from_to('breakpoint set -N n', 'breakpoint set -N n')
+self.assertTrue(bp1.AddNameWithErrorHandling("nn"))
+self.complete_from_to('breakpoint set -N ', 'breakpoint set -N nn')
Index: lldb/source/Interpreter/CommandObject.cpp
===
--- lldb/source/Interpreter/CommandObject.cpp
+++ lldb/source/Interpreter/CommandObject.cpp
@@ -1041,7 +1041,7 @@
 { eArgTypeBoolean, "boolean", CommandCompletions::eNoCompletion, { nullptr, false }, "A Boolean value: 'true' or 'false'" },
 { eArgTypeBreakpointID, "breakpt-id", CommandCompletions::eNoCompletion, { BreakpointIDHelpTextCallback, false }, nullptr },
 { eArgTypeBreakpointIDRange, "breakpt-id-list", CommandCompletions::eNoCompletion, { BreakpointIDRangeHelpTextCallback, false }, nullptr },
-{ eArgTypeBreakpointName, "breakpoint-name", CommandCompletions::eNoCompletion, { BreakpointNameHelpTextCallback, false }, nullptr },
+{ eArgTypeBreakpointName, "breakpoint-name", CommandCompletions::eBreakpointNameCompletion, { BreakpointNameHelpTextCallback, false }, nullptr },
 { eArgTypeByteSize, "byte-size", CommandCompletions::eNoCompletion, { nullptr, false }, "Number of bytes to use." },
 { eArgTypeClassName, "class-name", CommandCompletions::eNoCompletion, { nullptr, false }, "Then name of a class from the debug information in the program." },
 { 

[Lldb-commits] [PATCH] D86216: [lldb] Forcefully complete a type when adding typedefs

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

LGTM


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D86216/new/

https://reviews.llvm.org/D86216

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


[Lldb-commits] [PATCH] D85970: [lldb] Fix that log enable's -f parameter causes LLDB to crash when it can't open the log file

2020-08-17 Thread Raphael Isemann via Phabricator via lldb-commits
teemperor added a comment.

In D85970#2221899 , @max-kudr wrote:

> @teemperor LLDB Windows buildbot 
>  is failing after last 
> commit: Build 18298 
> .
>
> Please revert or fix.

Already fixed in c6cc566c8a95bb39c65f7b39649e804809fc8701 
, next 
build should be green again.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D85970/new/

https://reviews.llvm.org/D85970

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


[Lldb-commits] [PATCH] D83933: [lldb] Don't delete orphaned shared modules in SBDebugger::DeleteTarget

2020-08-17 Thread Raphael Isemann via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG24c74f5e8c2c: [lldb] Dont delete orphaned shared 
modules in SBDebugger::DeleteTarget (authored by teemperor).
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D83933/new/

https://reviews.llvm.org/D83933

Files:
  lldb/source/API/SBDebugger.cpp


Index: lldb/source/API/SBDebugger.cpp
===
--- lldb/source/API/SBDebugger.cpp
+++ lldb/source/API/SBDebugger.cpp
@@ -879,8 +879,6 @@
   result = m_opaque_sp->GetTargetList().DeleteTarget(target_sp);
   target_sp->Destroy();
   target.Clear();
-  const bool mandatory = true;
-  ModuleList::RemoveOrphanSharedModules(mandatory);
 }
   }
 


Index: lldb/source/API/SBDebugger.cpp
===
--- lldb/source/API/SBDebugger.cpp
+++ lldb/source/API/SBDebugger.cpp
@@ -879,8 +879,6 @@
   result = m_opaque_sp->GetTargetList().DeleteTarget(target_sp);
   target_sp->Destroy();
   target.Clear();
-  const bool mandatory = true;
-  ModuleList::RemoveOrphanSharedModules(mandatory);
 }
   }
 
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D85993: [lldb] Set the access property on member function decls

2020-08-17 Thread Raphael Isemann via Phabricator via lldb-commits
teemperor requested changes to this revision.
teemperor added a comment.
This revision now requires changes to proceed.

+1 for AddMethodToCXXRecordType. Calling CreateFunctionDeclaration creates a 
FunctionDecl which can't be inside a record. All (static/non-static) member 
functions in a record are always CXXMethodDecls.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D85993/new/

https://reviews.llvm.org/D85993

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


[Lldb-commits] [PATCH] D83876: [lldb] Add SBModule::GarbageCollectAllocatedModules and clear modules after each test run

2020-08-17 Thread Raphael Isemann via Phabricator via lldb-commits
This revision was not accepted when it landed; it landed in state "Needs 
Review".
This revision was automatically updated to reflect the committed changes.
Closed by commit rGc2f9454a16e4: [lldb] Add 
SBModule::GarbageCollectAllocatedModules and clear modules after… (authored by 
teemperor).
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D83876/new/

https://reviews.llvm.org/D83876

Files:
  lldb/bindings/interface/SBModule.i
  lldb/include/lldb/API/SBModule.h
  lldb/packages/Python/lldbsuite/test/lldbtest.py
  lldb/source/API/SBModule.cpp


Index: lldb/source/API/SBModule.cpp
===
--- lldb/source/API/SBModule.cpp
+++ lldb/source/API/SBModule.cpp
@@ -690,6 +690,13 @@
   return Module::GetNumberAllocatedModules();
 }
 
+void SBModule::GarbageCollectAllocatedModules() {
+  LLDB_RECORD_STATIC_METHOD_NO_ARGS(void, SBModule,
+GarbageCollectAllocatedModules);
+  const bool mandatory = false;
+  ModuleList::RemoveOrphanSharedModules(mandatory);
+}
+
 namespace lldb_private {
 namespace repro {
 
Index: lldb/packages/Python/lldbsuite/test/lldbtest.py
===
--- lldb/packages/Python/lldbsuite/test/lldbtest.py
+++ lldb/packages/Python/lldbsuite/test/lldbtest.py
@@ -1094,6 +1094,17 @@
 lldb.SBDebugger.Destroy(self.dbg)
 del self.dbg
 
+# All modules should be orphaned now so that they can be cleared from
+# the shared module cache.
+lldb.SBModule.GarbageCollectAllocatedModules()
+
+# Modules are not orphaned during reproducer replay because they're
+# leaked on purpose.
+if not configuration.is_reproducer():
+# Assert that the global module cache is empty.
+self.assertEqual(lldb.SBModule.GetNumberAllocatedModules(), 0)
+
+
 # =
 # Various callbacks to allow introspection of test progress
 # =
@@ -2068,13 +2079,9 @@
 for target in targets:
 self.dbg.DeleteTarget(target)
 
-# Modules are not orphaned during reproducer replay because they're
-# leaked on purpose.
 if not configuration.is_reproducer():
 # Assert that all targets are deleted.
-assert self.dbg.GetNumTargets() == 0
-# Assert that the global module cache is empty.
-assert lldb.SBModule.GetNumberAllocatedModules() == 0
+self.assertEqual(self.dbg.GetNumTargets(), 0)
 
 # Do this last, to make sure it's in reverse order from how we setup.
 Base.tearDown(self)
Index: lldb/include/lldb/API/SBModule.h
===
--- lldb/include/lldb/API/SBModule.h
+++ lldb/include/lldb/API/SBModule.h
@@ -291,6 +291,9 @@
   /// Get the number of global modules.
   static uint32_t GetNumberAllocatedModules();
 
+  /// Remove any global modules which are no longer needed.
+  static void GarbageCollectAllocatedModules();
+
 private:
   friend class SBAddress;
   friend class SBFrame;
Index: lldb/bindings/interface/SBModule.i
===
--- lldb/bindings/interface/SBModule.i
+++ lldb/bindings/interface/SBModule.i
@@ -353,6 +353,17 @@
 static uint32_t
 GetNumberAllocatedModules();
 
+%feature("docstring", "
+Removes all modules which are no longer needed by any part of LLDB from
+the module cache.
+
+This is an implementation detail exposed for testing and should not be
+relied upon. Use SBDebugger::MemoryPressureDetected instead to reduce
+LLDB's memory consumption during execution.
+") GarbageCollectAllocatedModules;
+static void
+GarbageCollectAllocatedModules();
+
 STRING_EXTENSION(SBModule)
 
 #ifdef SWIGPYTHON


Index: lldb/source/API/SBModule.cpp
===
--- lldb/source/API/SBModule.cpp
+++ lldb/source/API/SBModule.cpp
@@ -690,6 +690,13 @@
   return Module::GetNumberAllocatedModules();
 }
 
+void SBModule::GarbageCollectAllocatedModules() {
+  LLDB_RECORD_STATIC_METHOD_NO_ARGS(void, SBModule,
+GarbageCollectAllocatedModules);
+  const bool mandatory = false;
+  ModuleList::RemoveOrphanSharedModules(mandatory);
+}
+
 namespace lldb_private {
 namespace repro {
 
Index: lldb/packages/Python/lldbsuite/test/lldbtest.py
===
--- lldb/packages/Python/lldbsuite/test/lldbtest.py
+++ lldb/packages/Python/lldbsuite/test/lldbtest.py
@@ -1094,6 +1094,17 @@
 lldb.SBDebugger.Destroy(self.dbg)
 del self.dbg
 
+# All modules should be orphaned now so that 

[Lldb-commits] [PATCH] D83876: [lldb] Add SBModule::GarbageCollectAllocatedModules and clear modules after each test run

2020-08-17 Thread Raphael Isemann via Phabricator via lldb-commits
teemperor updated this revision to Diff 285938.
teemperor retitled this revision from "[lldb] Add SBModule::ClearCachedModules 
and clear modules after each test run" to "[lldb] Add 
SBModule::GarbageCollectAllocatedModules and clear modules after each test run".
teemperor edited the summary of this revision.
teemperor added a comment.

- Rename to GarbageCollectAllocatedModules


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D83876/new/

https://reviews.llvm.org/D83876

Files:
  lldb/bindings/interface/SBModule.i
  lldb/include/lldb/API/SBModule.h
  lldb/packages/Python/lldbsuite/test/lldbtest.py
  lldb/source/API/SBModule.cpp


Index: lldb/source/API/SBModule.cpp
===
--- lldb/source/API/SBModule.cpp
+++ lldb/source/API/SBModule.cpp
@@ -690,6 +690,13 @@
   return Module::GetNumberAllocatedModules();
 }
 
+void SBModule::GarbageCollectAllocatedModules() {
+  LLDB_RECORD_STATIC_METHOD_NO_ARGS(void, SBModule,
+GarbageCollectAllocatedModules);
+  const bool mandatory = false;
+  ModuleList::RemoveOrphanSharedModules(mandatory);
+}
+
 namespace lldb_private {
 namespace repro {
 
Index: lldb/packages/Python/lldbsuite/test/lldbtest.py
===
--- lldb/packages/Python/lldbsuite/test/lldbtest.py
+++ lldb/packages/Python/lldbsuite/test/lldbtest.py
@@ -1094,6 +1094,17 @@
 lldb.SBDebugger.Destroy(self.dbg)
 del self.dbg
 
+# All modules should be orphaned now so that they can be cleared from
+# the shared module cache.
+lldb.SBModule.GarbageCollectAllocatedModules()
+
+# Modules are not orphaned during reproducer replay because they're
+# leaked on purpose.
+if not configuration.is_reproducer():
+# Assert that the global module cache is empty.
+self.assertEqual(lldb.SBModule.GetNumberAllocatedModules(), 0)
+
+
 # =
 # Various callbacks to allow introspection of test progress
 # =
@@ -2068,13 +2079,9 @@
 for target in targets:
 self.dbg.DeleteTarget(target)
 
-# Modules are not orphaned during reproducer replay because they're
-# leaked on purpose.
 if not configuration.is_reproducer():
 # Assert that all targets are deleted.
-assert self.dbg.GetNumTargets() == 0
-# Assert that the global module cache is empty.
-assert lldb.SBModule.GetNumberAllocatedModules() == 0
+self.assertEqual(self.dbg.GetNumTargets(), 0)
 
 # Do this last, to make sure it's in reverse order from how we setup.
 Base.tearDown(self)
Index: lldb/include/lldb/API/SBModule.h
===
--- lldb/include/lldb/API/SBModule.h
+++ lldb/include/lldb/API/SBModule.h
@@ -291,6 +291,9 @@
   /// Get the number of global modules.
   static uint32_t GetNumberAllocatedModules();
 
+  /// Remove any global modules which are no longer needed.
+  static void GarbageCollectAllocatedModules();
+
 private:
   friend class SBAddress;
   friend class SBFrame;
Index: lldb/bindings/interface/SBModule.i
===
--- lldb/bindings/interface/SBModule.i
+++ lldb/bindings/interface/SBModule.i
@@ -353,6 +353,17 @@
 static uint32_t
 GetNumberAllocatedModules();
 
+%feature("docstring", "
+Removes all modules which are no longer needed by any part of LLDB from
+the module cache.
+
+This is an implementation detail exposed for testing and should not be
+relied upon. Use SBDebugger::MemoryPressureDetected instead to reduce
+LLDB's memory consumption during execution.
+") GarbageCollectAllocatedModules;
+static void
+GarbageCollectAllocatedModules();
+
 STRING_EXTENSION(SBModule)
 
 #ifdef SWIGPYTHON


Index: lldb/source/API/SBModule.cpp
===
--- lldb/source/API/SBModule.cpp
+++ lldb/source/API/SBModule.cpp
@@ -690,6 +690,13 @@
   return Module::GetNumberAllocatedModules();
 }
 
+void SBModule::GarbageCollectAllocatedModules() {
+  LLDB_RECORD_STATIC_METHOD_NO_ARGS(void, SBModule,
+GarbageCollectAllocatedModules);
+  const bool mandatory = false;
+  ModuleList::RemoveOrphanSharedModules(mandatory);
+}
+
 namespace lldb_private {
 namespace repro {
 
Index: lldb/packages/Python/lldbsuite/test/lldbtest.py
===
--- lldb/packages/Python/lldbsuite/test/lldbtest.py
+++ lldb/packages/Python/lldbsuite/test/lldbtest.py
@@ -1094,6 +1094,17 @@
 lldb.SBDebugger.Destroy(self.dbg)
 del self.dbg
 
+# All modules should be orphaned now so that they can be cleared 

[Lldb-commits] [PATCH] D85970: [lldb] Fix that log enable's -f parameter causes LLDB to crash when it can't open the log file

2020-08-17 Thread Raphael Isemann via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG867c347c32e2: [lldb] Fix that log enables -f parameter 
causes LLDB to crash when it cant… (authored by teemperor).
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D85970/new/

https://reviews.llvm.org/D85970

Files:
  lldb/source/Core/Debugger.cpp
  lldb/test/API/commands/log/invalid-args/TestInvalidArgsLog.py


Index: lldb/test/API/commands/log/invalid-args/TestInvalidArgsLog.py
===
--- lldb/test/API/commands/log/invalid-args/TestInvalidArgsLog.py
+++ lldb/test/API/commands/log/invalid-args/TestInvalidArgsLog.py
@@ -15,3 +15,8 @@
 def test_disable_empty(self):
 self.expect("log disable", error=True,
 substrs=["error: log disable takes a log channel and one 
or more log types."])
+
+@no_debug_info_test
+def test_enable_empty(self):
+self.expect("log enable lldb all -f this/is/not/a/valid/path", 
error=True,
+substrs=["Unable to open log file 
'this/is/not/a/valid/path': No such file or directory\n"])
Index: lldb/source/Core/Debugger.cpp
===
--- lldb/source/Core/Debugger.cpp
+++ lldb/source/Core/Debugger.cpp
@@ -1164,11 +1164,11 @@
 flags |= File::eOpenOptionAppend;
   else
 flags |= File::eOpenOptionTruncate;
-  auto file = FileSystem::Instance().Open(
+  llvm::Expected file = FileSystem::Instance().Open(
   FileSpec(log_file), flags, lldb::eFilePermissionsFileDefault, false);
   if (!file) {
-// FIXME: This gets garbled when called from the log command.
-error_stream << "Unable to open log file: " << log_file;
+error_stream << "Unable to open log file '" << log_file
+ << "': " << llvm::toString(file.takeError()) << "\n";
 return false;
   }
 


Index: lldb/test/API/commands/log/invalid-args/TestInvalidArgsLog.py
===
--- lldb/test/API/commands/log/invalid-args/TestInvalidArgsLog.py
+++ lldb/test/API/commands/log/invalid-args/TestInvalidArgsLog.py
@@ -15,3 +15,8 @@
 def test_disable_empty(self):
 self.expect("log disable", error=True,
 substrs=["error: log disable takes a log channel and one or more log types."])
+
+@no_debug_info_test
+def test_enable_empty(self):
+self.expect("log enable lldb all -f this/is/not/a/valid/path", error=True,
+substrs=["Unable to open log file 'this/is/not/a/valid/path': No such file or directory\n"])
Index: lldb/source/Core/Debugger.cpp
===
--- lldb/source/Core/Debugger.cpp
+++ lldb/source/Core/Debugger.cpp
@@ -1164,11 +1164,11 @@
 flags |= File::eOpenOptionAppend;
   else
 flags |= File::eOpenOptionTruncate;
-  auto file = FileSystem::Instance().Open(
+  llvm::Expected file = FileSystem::Instance().Open(
   FileSpec(log_file), flags, lldb::eFilePermissionsFileDefault, false);
   if (!file) {
-// FIXME: This gets garbled when called from the log command.
-error_stream << "Unable to open log file: " << log_file;
+error_stream << "Unable to open log file '" << log_file
+ << "': " << llvm::toString(file.takeError()) << "\n";
 return false;
   }
 
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D85890: [lldb] Get lldb-server platform's --socket-file working again

2020-08-17 Thread Raphael Isemann via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGc57ea1b48f26: [lldb] Get lldb-server platforms 
--socket-file working again (authored by teemperor).
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D85890/new/

https://reviews.llvm.org/D85890

Files:
  lldb/tools/lldb-server/lldb-platform.cpp


Index: lldb/tools/lldb-server/lldb-platform.cpp
===
--- lldb/tools/lldb-server/lldb-platform.cpp
+++ lldb/tools/lldb-server/lldb-platform.cpp
@@ -104,11 +104,12 @@
 
   llvm::SmallString<64> temp_file_path;
   temp_file_spec.AppendPathComponent("port-file.%%");
+  temp_file_path = temp_file_spec.GetPath();
 
   Status status;
   if (auto Err =
   handleErrors(llvm::writeFileAtomically(
-   temp_file_path, temp_file_spec.GetPath(), 
socket_id),
+   temp_file_path, file_spec.GetPath(), socket_id),
[, _spec](const AtomicFileWriteError ) {
  std::string ErrorMsgBuffer;
  llvm::raw_string_ostream S(ErrorMsgBuffer);


Index: lldb/tools/lldb-server/lldb-platform.cpp
===
--- lldb/tools/lldb-server/lldb-platform.cpp
+++ lldb/tools/lldb-server/lldb-platform.cpp
@@ -104,11 +104,12 @@
 
   llvm::SmallString<64> temp_file_path;
   temp_file_spec.AppendPathComponent("port-file.%%");
+  temp_file_path = temp_file_spec.GetPath();
 
   Status status;
   if (auto Err =
   handleErrors(llvm::writeFileAtomically(
-   temp_file_path, temp_file_spec.GetPath(), socket_id),
+   temp_file_path, file_spec.GetPath(), socket_id),
[, _spec](const AtomicFileWriteError ) {
  std::string ErrorMsgBuffer;
  llvm::raw_string_ostream S(ErrorMsgBuffer);
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D84299: [lldb][NFC] Remove stride parameter from GetArrayElementType

2020-08-17 Thread Raphael Isemann via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG5913f2591c45: [lldb][NFC] Remove stride parameter from 
GetArrayElementType (authored by teemperor).
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D84299/new/

https://reviews.llvm.org/D84299

Files:
  lldb/include/lldb/Symbol/CompilerType.h
  lldb/include/lldb/Symbol/TypeSystem.h
  lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
  lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h
  lldb/source/Symbol/CompilerType.cpp


Index: lldb/source/Symbol/CompilerType.cpp
===
--- lldb/source/Symbol/CompilerType.cpp
+++ lldb/source/Symbol/CompilerType.cpp
@@ -317,10 +317,10 @@
 
 // Creating related types
 
-CompilerType CompilerType::GetArrayElementType(ExecutionContextScope 
*exe_scope,
-   uint64_t *stride) const {
+CompilerType
+CompilerType::GetArrayElementType(ExecutionContextScope *exe_scope) const {
   if (IsValid()) {
-return m_type_system->GetArrayElementType(m_type, stride, exe_scope);
+return m_type_system->GetArrayElementType(m_type, exe_scope);
   }
   return CompilerType();
 }
Index: lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h
===
--- lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h
+++ lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h
@@ -689,7 +689,6 @@
 uint32_t opaque_payload);
 
   CompilerType GetArrayElementType(lldb::opaque_compiler_type_t type,
-   uint64_t *stride,
ExecutionContextScope *exe_scope) override;
 
   CompilerType GetArrayType(lldb::opaque_compiler_type_t type,
Index: lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
===
--- lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
+++ lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
@@ -4090,7 +4090,6 @@
 
 CompilerType
 TypeSystemClang::GetArrayElementType(lldb::opaque_compiler_type_t type,
- uint64_t *stride,
  ExecutionContextScope *exe_scope) {
   if (type) {
 clang::QualType qual_type(GetQualType(type));
@@ -4101,14 +4100,7 @@
 if (!array_eletype)
   return CompilerType();
 
-CompilerType element_type = GetType(clang::QualType(array_eletype, 0));
-
-// TODO: the real stride will be >= this value.. find the real one!
-if (stride)
-  if (Optional size = element_type.GetByteSize(exe_scope))
-*stride = *size;
-
-return element_type;
+return GetType(clang::QualType(array_eletype, 0));
   }
   return CompilerType();
 }
Index: lldb/include/lldb/Symbol/TypeSystem.h
===
--- lldb/include/lldb/Symbol/TypeSystem.h
+++ lldb/include/lldb/Symbol/TypeSystem.h
@@ -218,7 +218,7 @@
   // Creating related types
 
   virtual CompilerType
-  GetArrayElementType(lldb::opaque_compiler_type_t type, uint64_t *stride,
+  GetArrayElementType(lldb::opaque_compiler_type_t type,
   ExecutionContextScope *exe_scope) = 0;
 
   virtual CompilerType GetArrayType(lldb::opaque_compiler_type_t type,
Index: lldb/include/lldb/Symbol/CompilerType.h
===
--- lldb/include/lldb/Symbol/CompilerType.h
+++ lldb/include/lldb/Symbol/CompilerType.h
@@ -177,8 +177,7 @@
 
   /// Creating related types.
   /// \{
-  CompilerType GetArrayElementType(ExecutionContextScope *exe_scope,
-   uint64_t *stride = nullptr) const;
+  CompilerType GetArrayElementType(ExecutionContextScope *exe_scope) const;
 
   CompilerType GetArrayType(uint64_t size) const;
 


Index: lldb/source/Symbol/CompilerType.cpp
===
--- lldb/source/Symbol/CompilerType.cpp
+++ lldb/source/Symbol/CompilerType.cpp
@@ -317,10 +317,10 @@
 
 // Creating related types
 
-CompilerType CompilerType::GetArrayElementType(ExecutionContextScope *exe_scope,
-   uint64_t *stride) const {
+CompilerType
+CompilerType::GetArrayElementType(ExecutionContextScope *exe_scope) const {
   if (IsValid()) {
-return m_type_system->GetArrayElementType(m_type, stride, exe_scope);
+return m_type_system->GetArrayElementType(m_type, exe_scope);
   }
   return CompilerType();
 }
Index: lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h
===
--- lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h
+++ lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h
@@ -689,7 +689,6 @@
  

[Lldb-commits] [PATCH] D83874: [lldb] Print the exception traceback when hitting cleanup errors

2020-08-17 Thread Raphael Isemann via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG24fc3177c176: [lldb] Print the exception traceback when 
hitting cleanup errors (authored by teemperor).
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D83874/new/

https://reviews.llvm.org/D83874

Files:
  lldb/packages/Python/lldbsuite/test/test_result.py


Index: lldb/packages/Python/lldbsuite/test/test_result.py
===
--- lldb/packages/Python/lldbsuite/test/test_result.py
+++ lldb/packages/Python/lldbsuite/test/test_result.py
@@ -9,6 +9,7 @@
 
 # System modules
 import os
+import traceback
 
 # Third-party modules
 import unittest2
@@ -228,8 +229,8 @@
 if method:
 method()
 self.stream.write(
-"CLEANUP ERROR: LLDB (%s) :: %s\n" %
-(self._config_string(test), str(test)))
+"CLEANUP ERROR: LLDB (%s) :: %s\n%s\n" %
+(self._config_string(test), str(test), traceback.format_exc()))
 
 def addFailure(self, test, err):
 if (self.checkExclusion(


Index: lldb/packages/Python/lldbsuite/test/test_result.py
===
--- lldb/packages/Python/lldbsuite/test/test_result.py
+++ lldb/packages/Python/lldbsuite/test/test_result.py
@@ -9,6 +9,7 @@
 
 # System modules
 import os
+import traceback
 
 # Third-party modules
 import unittest2
@@ -228,8 +229,8 @@
 if method:
 method()
 self.stream.write(
-"CLEANUP ERROR: LLDB (%s) :: %s\n" %
-(self._config_string(test), str(test)))
+"CLEANUP ERROR: LLDB (%s) :: %s\n%s\n" %
+(self._config_string(test), str(test), traceback.format_exc()))
 
 def addFailure(self, test, err):
 if (self.checkExclusion(
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D85968: [lldb] Forcefully complete a type when adding nested classes

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

LGTM




Comment at: lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp:233
 
-static void CompleteExternalTagDeclType(TypeSystemClang ,
-ClangASTImporter _importer,
-clang::DeclContext *decl_ctx,
-DWARFDIE die,
-const char *type_name_cstr) {
+static void ForcefullyCompleteType(CompilerType type, TypeSystemClang ) {
+  bool started = TypeSystemClang::StartTagDeclarationDefinition(type);

You could just get the TypeSystemClang from the `type` (passing a different 
TypeSystemClang that is not `type.getTypeSystem()` would lead to strange bugs, 
so we might as well make that situation impossible by not giving the caller the 
option).


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D85968/new/

https://reviews.llvm.org/D85968

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


[Lldb-commits] [PATCH] D82537: [lldb] Deduplicate copy-pasted TypeSystemMap::GetTypeSystemForLanguage

2020-08-14 Thread Raphael Isemann via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGf974d64b372c: [lldb] Deduplicate copy-pasted 
TypeSystemMap::GetTypeSystemForLanguage (authored by teemperor).
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D82537/new/

https://reviews.llvm.org/D82537

Files:
  lldb/include/lldb/Symbol/TypeSystem.h
  lldb/source/Symbol/TypeSystem.cpp

Index: lldb/source/Symbol/TypeSystem.cpp
===
--- lldb/source/Symbol/TypeSystem.cpp
+++ lldb/source/Symbol/TypeSystem.cpp
@@ -224,9 +224,9 @@
   }
 }
 
-llvm::Expected
-TypeSystemMap::GetTypeSystemForLanguage(lldb::LanguageType language,
-Module *module, bool can_create) {
+llvm::Expected TypeSystemMap::GetTypeSystemForLanguage(
+lldb::LanguageType language,
+llvm::Optional create_callback) {
   llvm::Error error = llvm::Error::success();
   assert(!error); // Check the success value when assertions are enabled
   std::lock_guard guard(m_mutex);
@@ -268,7 +268,7 @@
   }
 }
 
-if (!can_create) {
+if (!create_callback) {
   error = llvm::make_error(
   "Unable to find type system for language " +
   llvm::StringRef(Language::GetNameForLanguageType(language)),
@@ -276,7 +276,7 @@
 } else {
   // Cache even if we get a shared pointer that contains a null type system
   // back
-  auto type_system_sp = TypeSystem::CreateInstance(language, module);
+  TypeSystemSP type_system_sp = (*create_callback)();
   m_map[language] = type_system_sp;
   if (type_system_sp.get()) {
 llvm::consumeError(std::move(error));
@@ -295,69 +295,24 @@
 
 llvm::Expected
 TypeSystemMap::GetTypeSystemForLanguage(lldb::LanguageType language,
-Target *target, bool can_create) {
-  llvm::Error error = llvm::Error::success();
-  assert(!error); // Check the success value when assertions are enabled
-  std::lock_guard guard(m_mutex);
-  if (m_clear_in_progress) {
-error = llvm::make_error(
-"Unable to get TypeSystem because TypeSystemMap is being cleared",
-llvm::inconvertibleErrorCode());
-  } else {
-collection::iterator pos = m_map.find(language);
-if (pos != m_map.end()) {
-  auto *type_system = pos->second.get();
-  if (type_system) {
-llvm::consumeError(std::move(error));
-return *type_system;
-  }
-  error = llvm::make_error(
-  "TypeSystem for language " +
-  llvm::StringRef(Language::GetNameForLanguageType(language)) +
-  " doesn't exist",
-  llvm::inconvertibleErrorCode());
-  return std::move(error);
-}
-
-for (const auto  : m_map) {
-  if (pair.second && pair.second->SupportsLanguage(language)) {
-// Add a new mapping for "language" to point to an already existing
-// TypeSystem that supports this language
-m_map[language] = pair.second;
-if (pair.second.get()) {
-  llvm::consumeError(std::move(error));
-  return *pair.second.get();
-}
-error = llvm::make_error(
-"TypeSystem for language " +
-llvm::StringRef(Language::GetNameForLanguageType(language)) +
-" doesn't exist",
-llvm::inconvertibleErrorCode());
-return std::move(error);
-  }
-}
-
-if (!can_create) {
-  error = llvm::make_error(
-  "Unable to find type system for language " +
-  llvm::StringRef(Language::GetNameForLanguageType(language)),
-  llvm::inconvertibleErrorCode());
-} else {
-  // Cache even if we get a shared pointer that contains a null type system
-  // back
-  auto type_system_sp = TypeSystem::CreateInstance(language, target);
-  m_map[language] = type_system_sp;
-  if (type_system_sp.get()) {
-llvm::consumeError(std::move(error));
-return *type_system_sp.get();
-  }
-  error = llvm::make_error(
-  "TypeSystem for language " +
-  llvm::StringRef(Language::GetNameForLanguageType(language)) +
-  " doesn't exist",
-  llvm::inconvertibleErrorCode());
-}
+Module *module, bool can_create) {
+  if (can_create) {
+return GetTypeSystemForLanguage(
+language, llvm::Optional([language, module]() {
+  return TypeSystem::CreateInstance(language, module);
+}));
   }
+  return GetTypeSystemForLanguage(language);
+}
 
-  return std::move(error);
+llvm::Expected
+TypeSystemMap::GetTypeSystemForLanguage(lldb::LanguageType language,
+Target *target, bool can_create) {
+  if (can_create) {
+return GetTypeSystemForLanguage(
+language, llvm::Optional([language, target]() {
+

[Lldb-commits] [PATCH] D85903: [lldb] Fix a crash when tab-completion an empty line in a function with only one local variable

2020-08-14 Thread Raphael Isemann via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGbbe3c479a6ad: [lldb] Fix a crash when tab-completion an 
empty line in a function with only… (authored by teemperor).
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D85903/new/

https://reviews.llvm.org/D85903

Files:
  lldb/source/Host/common/Editline.cpp
  
lldb/test/API/commands/expression/multiline-completion/TestMultilineCompletion.py
  lldb/test/API/commands/expression/multiline-completion/main.c


Index: lldb/test/API/commands/expression/multiline-completion/main.c
===
--- lldb/test/API/commands/expression/multiline-completion/main.c
+++ lldb/test/API/commands/expression/multiline-completion/main.c
@@ -1,4 +1,11 @@
+int single_local_func() {
+  // This function should always only have a single local variable and no
+  // parameters.
+  int only_local = 3;
+  return only_local; // break in single_local_func
+}
+
 int main(int argc, char **argv) {
   int to_complete = 0;
-  return to_complete;
+  return to_complete + single_local_func();
 }
Index: 
lldb/test/API/commands/expression/multiline-completion/TestMultilineCompletion.py
===
--- 
lldb/test/API/commands/expression/multiline-completion/TestMultilineCompletion.py
+++ 
lldb/test/API/commands/expression/multiline-completion/TestMultilineCompletion.py
@@ -11,6 +11,21 @@
 
 mydir = TestBase.compute_mydir(__file__)
 
+def start_expression_editor(self):
+""" Starts the multiline expression editor. """
+self.child.send("expression\n")
+self.child.expect_exact("terminate with an empty line to evaluate")
+
+def exit_expression_editor(self):
+""" Exits the multiline expression editor. """
+# Send a newline to finish the current line. The second newline will
+# finish the new empty line which will exit the editor. The space at 
the
+# start prevents that the first newline already exits the editor (in
+# case the current line of the editor is already empty when this
+# function is called).
+self.child.send(" \n\n")
+self.expect_prompt()
+
 # PExpect uses many timeouts internally and doesn't play well
 # under ASAN on a loaded machine..
 @skipIfAsan
@@ -21,14 +36,23 @@
 
 self.launch(executable=self.getBuildArtifact("a.out"), 
dimensions=(100,500))
 self.expect("b main", substrs=["Breakpoint 1", "address ="])
-self.expect("run", substrs=["stop reason ="])
+self.expect("run", substrs=["stop reason = breakpoint 1"])
 
-self.child.sendline("expr")
-self.child.expect_exact("terminate with an empty line to evaluate")
+self.start_expression_editor()
 self.child.send("to_\t")
 self.child.expect_exact("to_complete")
-
-self.child.send("\n\n")
-self.expect_prompt()
+self.exit_expression_editor()
+
+# Check that completion empty input in a function with only one
+# local variable works.
+self.expect("breakpoint set -p 'break in single_local_func'",
+substrs=["Breakpoint 2"])
+self.expect("continue", substrs=["stop reason = breakpoint 2"])
+self.start_expression_editor()
+self.child.send("\t")
+# Only one local, so this will directly insert 'only_local' with a
+# trailing space to signal a final completion.
+self.child.expect_exact("only_local ")
+self.exit_expression_editor()
 
 self.quit()
Index: lldb/source/Host/common/Editline.cpp
===
--- lldb/source/Host/common/Editline.cpp
+++ lldb/source/Host/common/Editline.cpp
@@ -1004,7 +1004,8 @@
 case CompletionMode::Normal: {
   std::string to_add = completion.GetCompletion();
   to_add = to_add.substr(request.GetCursorArgumentPrefix().size());
-  if (request.GetParsedArg().IsQuoted())
+  // Terminate the current argument with a quote if it started with a 
quote.
+  if (!request.GetParsedLine().empty() && 
request.GetParsedArg().IsQuoted())
 to_add.push_back(request.GetParsedArg().GetQuoteChar());
   to_add.push_back(' ');
   el_insertstr(m_editline, to_add.c_str());


Index: lldb/test/API/commands/expression/multiline-completion/main.c
===
--- lldb/test/API/commands/expression/multiline-completion/main.c
+++ lldb/test/API/commands/expression/multiline-completion/main.c
@@ -1,4 +1,11 @@
+int single_local_func() {
+  // This function should always only have a single local variable and no
+  // parameters.
+  int only_local = 3;
+  return only_local; // break in single_local_func
+}
+
 int main(int argc, char **argv) {

[Lldb-commits] [PATCH] D85915: [lldb] Use file to synchronize TestDeepBundle and TestBundleWithDotInFilename

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

This fills my heart with joy.


Repository:
  rLLDB LLDB

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D85915/new/

https://reviews.llvm.org/D85915

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


[Lldb-commits] [PATCH] D85904: [lldb] Check Decl kind when completing -flimit-debug-info types

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

Is it too late to claim that I did this on purpose to see if anyone noticed the 
bug? It probably is :/




Comment at: lldb/test/API/functionalities/limit-debug-info/main.cpp:31
 
+struct ShadowedOne : public func_shadow::One {
+  constexpr ShadowedOne() = default;

Nit: the `public` isn't necessary and you also omitted above.



Comment at: lldb/test/API/functionalities/limit-debug-info/main.cpp:32
+struct ShadowedOne : public func_shadow::One {
+  constexpr ShadowedOne() = default;
+  int member = 47;

I'm probably missing something obvious here, but why give every class in the 
test a defaulted constexpr constructor?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D85904/new/

https://reviews.llvm.org/D85904

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


[Lldb-commits] [PATCH] D85376: Fix how ValueObjectChild handles bit-fields stored in a Scalar in UpdateValue()

2020-08-12 Thread Raphael Isemann via Phabricator via lldb-commits
teemperor added a comment.

I'll leave the test review to Pavel who knows that much better, but I have two 
last nits about the test.




Comment at: lldb/test/Shell/SymbolFile/DWARF/valueobject-pass-by-reg.s:59
+#
+#  86dea1f39bd127776b999e10dff212003068d30a
+#

I think this was still generated with system clang. info_string below says this 
was compiled by `Apple clang version 12.0.0 (clang-1200.0.31.1)` and not the 
listed commit (which would create an info_string like `clang version 12.0.0 
(https://github.com/llvm/llvm-project 
86dea1f39bd127776b999e10dff212003068d30a)`.)



Comment at: lldb/test/Shell/SymbolFile/DWARF/valueobject-pass-by-reg.s:149
+   .asciz  "MacOSX10.15.sdk"   ## string offset=117
+   .asciz  "/Users/friss/dev/stash/xnu" ## string offset=133
+   .asciz  "ug"## string offset=160

You can avoid these system-specific paths by compiling the file in /tmp with 
your cwd in /tmp and passing `-isysroot /` to the clang invocation. This way 
this section would look like this for everyone independently of their system 
username or macOS version (which will make updating this much easier):
```
lang=python
  .asciz  "clang version 12.0.0 (https://github.com/llvm/llvm-project 
6acb897dfbc0ec22007cde50b3bc9c60f4674fb2)" ## string offset=0
  .asciz  "/tmp/weird.c"  ## string offset=101  
  .asciz  "/" ## string offset=114  
  .asciz  "/tmp"  ## string offset=116  
  .asciz  "ug"## string offset=121  
  .asciz  "U" ## string offset=124  
  .asciz  "raw"   ## string offset=126  
  .asciz  "unsigned int"  ## string offset=130  
  .asciz  "a" ## string offset=143 
```


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D85376/new/

https://reviews.llvm.org/D85376

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


[Lldb-commits] [PATCH] D81001: [lldb] Display autosuggestion part in gray if there is one possible suggestion

2020-08-12 Thread Raphael Isemann via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG246afe0cd17f: [lldb] Display autosuggestion part in gray if 
there is one possible suggestion (authored by gedatsu217, committed by 
teemperor).
Herald added a project: LLDB.

Changed prior to commit:
  https://reviews.llvm.org/D81001?vs=283686=285034#toc

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D81001/new/

https://reviews.llvm.org/D81001

Files:
  lldb/include/lldb/Core/Debugger.h
  lldb/include/lldb/Core/IOHandler.h
  lldb/include/lldb/Host/Editline.h
  lldb/include/lldb/Interpreter/CommandInterpreter.h
  lldb/source/Core/CoreProperties.td
  lldb/source/Core/Debugger.cpp
  lldb/source/Core/IOHandler.cpp
  lldb/source/Host/common/Editline.cpp
  lldb/source/Interpreter/CommandInterpreter.cpp
  lldb/test/API/iohandler/autosuggestion/TestAutosuggestion.py

Index: lldb/test/API/iohandler/autosuggestion/TestAutosuggestion.py
===
--- /dev/null
+++ lldb/test/API/iohandler/autosuggestion/TestAutosuggestion.py
@@ -0,0 +1,105 @@
+"""
+Tests autosuggestion using pexpect.
+"""
+
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test.lldbpexpect import PExpectTest
+
+def cursor_horizontal_abs(s):
+return "\x1b[" + str(len(s) + 1) + "G"
+
+
+
+class TestCase(PExpectTest):
+
+mydir = TestBase.compute_mydir(__file__)
+
+# PExpect uses many timeouts internally and doesn't play well
+# under ASAN on a loaded machine..
+@skipIfAsan
+@skipIfEditlineSupportMissing
+def test_autosuggestion_add_spaces(self):
+self.launch(extra_args=["-o", "settings set show-autosuggestion true", "-o", "settings set use-color true"])
+
+# Common input codes and escape sequences.
+faint_color = "\x1b[2m"
+reset = "\x1b[0m"
+
+# Check if spaces are added to hide the previous gray characters.
+self.expect("help frame var")
+self.expect("help frame info")
+self.child.send("help frame v")
+self.child.expect_exact(cursor_horizontal_abs("(lldb) help frame ") + "v" + faint_color + "ar" + reset + " ")
+
+self.quit()
+
+@skipIfAsan
+@skipIfEditlineSupportMissing
+def test_autosuggestion(self):
+self.launch(extra_args=["-o", "settings set show-autosuggestion true", "-o", "settings set use-color true"])
+
+# Common input codes and escape sequences.
+ctrl_f = "\x06"
+faint_color = "\x1b[2m"
+reset = "\x1b[0m"
+delete = chr(127)
+
+frame_output_needle = "Syntax: frame "
+# Run 'help frame' once to put it into the command history.
+self.expect("help frame", substrs=[frame_output_needle])
+
+# Check that LLDB shows the autosuggestion in gray behind the text.
+self.child.send("hel")
+self.child.expect_exact(cursor_horizontal_abs("(lldb) he") + "l" + faint_color + "p frame" + reset)
+
+# Apply the autosuggestion and press enter. This should print the
+# 'help frame' output if everything went correctly.
+self.child.send(ctrl_f + "\n")
+self.child.expect_exact(frame_output_needle)
+
+# Check that pressing Ctrl+F directly after Ctrl+F again does nothing.
+self.child.send("hel" + ctrl_f + ctrl_f + "\n")
+self.child.expect_exact(frame_output_needle)
+
+# Try autosuggestion using tab and ^f.
+# \t makes "help" and ^f makes "help frame". If everything went
+# correct we should see the 'help frame' output again.
+self.child.send("hel\t" + ctrl_f + "\n")
+self.child.expect_exact(frame_output_needle)
+
+# Check that autosuggestion works after delete.
+self.child.send("a1234" + 5 * delete + "hel" + ctrl_f + "\n")
+self.child.expect_exact(frame_output_needle)
+
+# Check that autosuggestion works after delete.
+self.child.send("help x" + delete + ctrl_f + "\n")
+self.child.expect_exact(frame_output_needle)
+
+# Check that autosuggestion complete to the most recent one.
+self.child.send("help frame variable\n")
+self.child.send("help fr")
+self.child.expect_exact(faint_color + "ame variable" + reset)
+self.child.send("\n")
+
+# Try another command.
+apropos_output_needle = "Syntax: apropos "
+# Run 'help frame' once to put it into the command history.
+self.expect("help apropos", substrs=[apropos_output_needle])
+
+# Check that 'hel' should have an autosuggestion for 'help apropos' now.
+self.child.send("hel")
+self.child.expect_exact(cursor_horizontal_abs("(lldb) he") + "l" + faint_color + "p apropos" + reset)
+
+# Run the command and expect the 'help apropos' output.
+self.child.send(ctrl_f + "\n")
+

[Lldb-commits] [PATCH] D83792: [lldb] Add support for checking children in expect_expr

2020-08-12 Thread Raphael Isemann via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGdd0fdf80301e: [lldb] Add support for checking children in 
expect_expr (authored by teemperor).
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D83792/new/

https://reviews.llvm.org/D83792

Files:
  lldb/packages/Python/lldbsuite/test/lldbtest.py
  
lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/map/TestDataFormatterLibccMap.py
  
lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/vector/TestDataFormatterLibcxxVector.py

Index: lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/vector/TestDataFormatterLibcxxVector.py
===
--- lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/vector/TestDataFormatterLibcxxVector.py
+++ lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/vector/TestDataFormatterLibcxxVector.py
@@ -26,16 +26,15 @@
  '[6] = 1234567',
  '}'])
 
-self.expect("p " + var_name,
-substrs=['$', 'size=7',
- '[0] = 1',
- '[1] = 12',
- '[2] = 123',
- '[3] = 1234',
- '[4] = 12345',
- '[5] = 123456',
- '[6] = 1234567',
- '}'])
+self.expect_expr(var_name, result_summary="size=7", result_children=[
+ValueCheck(value="1"),
+ValueCheck(value="12"),
+ValueCheck(value="123"),
+ValueCheck(value="1234"),
+ValueCheck(value="12345"),
+ValueCheck(value="123456"),
+ValueCheck(value="1234567"),
+])
 
 # check access-by-index
 self.expect("frame variable " + var_name + "[0]",
Index: lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/map/TestDataFormatterLibccMap.py
===
--- lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/map/TestDataFormatterLibccMap.py
+++ lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/map/TestDataFormatterLibccMap.py
@@ -19,6 +19,11 @@
 ns = 'ndk' if lldbplatformutil.target_is_android() else ''
 self.namespace = 'std'
 
+def check_pair(self, first_value, second_value):
+pair_children = [ValueCheck(name="first", value=first_value),
+ ValueCheck(name="second", value=second_value)]
+return ValueCheck(children=pair_children)
+
 @add_test_categories(["libc++"])
 def test_with_run_command(self):
 """Test that that file and class static variables display correctly."""
@@ -51,10 +56,8 @@
 self.addTearDownHook(cleanup)
 
 ns = self.namespace
-self.expect('p ii',
-substrs=['%s::map' % ns,
- 'size=0',
- '{}'])
+self.expect_expr("ii", result_summary="size=0", result_children=[])
+
 self.expect('frame var ii',
 substrs=['%s::map' % ns,
  'size=0',
@@ -62,14 +65,10 @@
 
 lldbutil.continue_to_breakpoint(self.process(), bkpt)
 
-self.expect('p ii',
-substrs=['%s::map' % ns, 'size=2',
- '[0] = ',
- 'first = 0',
- 'second = 0',
- '[1] = ',
- 'first = 1',
- 'second = 1'])
+self.expect_expr("ii", result_summary="size=2", result_children=[
+self.check_pair("0", "0"),
+self.check_pair("1", "1")
+])
 
 self.expect('frame variable ii',
 substrs=['%s::map' % ns, 'size=2',
Index: lldb/packages/Python/lldbsuite/test/lldbtest.py
===
--- lldb/packages/Python/lldbsuite/test/lldbtest.py
+++ lldb/packages/Python/lldbsuite/test/lldbtest.py
@@ -242,6 +242,77 @@
 return exe_file
 return None
 
+class ValueCheck:
+def __init__(self, name=None, value=None, type=None, summary=None,
+ children=None):
+"""
+:param name: The name that the SBValue should have. None if the summary
+ should not be checked.
+:param summary: The summary that the SBValue should have. None if the
+summary should not be checked.
+:param value: The value that the SBValue should have. None if the value
+  should not be checked.
+:param type: The 

[Lldb-commits] [PATCH] D82537: [lldb] Deduplicate copy-pasted TypeSystemMap::GetTypeSystemForLanguage

2020-08-11 Thread Raphael Isemann via Phabricator via lldb-commits
teemperor added reviewers: JDevlieghere, davide.
teemperor added a comment.

Ping


Repository:
  rLLDB LLDB

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D82537/new/

https://reviews.llvm.org/D82537

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


[Lldb-commits] [PATCH] D85132: [lldb] Add SubstTemplateTypeParm to RemoveWrappingTypes

2020-08-11 Thread Raphael Isemann via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG950f1bf976b3: [lldb] Add SubstTemplateTypeParm to 
RemoveWrappingTypes (authored by teemperor).
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

Changed prior to commit:
  https://reviews.llvm.org/D85132?vs=282610=284677#toc

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D85132/new/

https://reviews.llvm.org/D85132

Files:
  lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
  lldb/test/API/lang/cpp/subst_template_type_param/TestSubstTemplateTypeParam.py


Index: 
lldb/test/API/lang/cpp/subst_template_type_param/TestSubstTemplateTypeParam.py
===
--- /dev/null
+++ 
lldb/test/API/lang/cpp/subst_template_type_param/TestSubstTemplateTypeParam.py
@@ -0,0 +1,34 @@
+"""
+Test SubstTemplateTypeParam types which are produced as type sugar
+when template type parameters are used for example as field types.
+"""
+
+import lldb
+import lldbsuite.test.lldbutil as lldbutil
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import decorators
+
+class TestCase(TestBase):
+
+mydir = TestBase.compute_mydir(__file__)
+
+def test_typedef(self):
+target = self.dbg.GetDummyTarget()
+
+# Declare a template class with a field that uses the template type
+# parameter.
+opts = lldb.SBExpressionOptions()
+opts.SetTopLevel(True)
+result = target.EvaluateExpression("template  struct X { T 
f; };", opts)
+# FIXME: This fails with "Couldn't find $__lldb_expr() in the module"
+# but it should succeed. The fact that this code has nothing to run
+# shouldn't be an error.
+# self.assertSuccess(result.GetError())
+
+# Instantiate and produce a value with that template as the type.
+# The field in the value will have a SubstTemplateTypeParam that
+# should behave like a normal field.
+result = target.EvaluateExpression("X x; x.f = 123; x")
+self.assertEqual(result.GetNumChildren(), 1)
+self.assertEqual(result.GetChildAtIndex(0).GetTypeName(), "int")
+self.assertEqual(result.GetChildAtIndex(0).GetValue(), "123")
Index: lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
===
--- lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
+++ lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
@@ -2499,6 +2499,7 @@
 case clang::Type::Decltype:
 case clang::Type::Elaborated:
 case clang::Type::Paren:
+case clang::Type::SubstTemplateTypeParm:
 case clang::Type::TemplateSpecialization:
 case clang::Type::Typedef:
 case clang::Type::TypeOf:


Index: lldb/test/API/lang/cpp/subst_template_type_param/TestSubstTemplateTypeParam.py
===
--- /dev/null
+++ lldb/test/API/lang/cpp/subst_template_type_param/TestSubstTemplateTypeParam.py
@@ -0,0 +1,34 @@
+"""
+Test SubstTemplateTypeParam types which are produced as type sugar
+when template type parameters are used for example as field types.
+"""
+
+import lldb
+import lldbsuite.test.lldbutil as lldbutil
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import decorators
+
+class TestCase(TestBase):
+
+mydir = TestBase.compute_mydir(__file__)
+
+def test_typedef(self):
+target = self.dbg.GetDummyTarget()
+
+# Declare a template class with a field that uses the template type
+# parameter.
+opts = lldb.SBExpressionOptions()
+opts.SetTopLevel(True)
+result = target.EvaluateExpression("template  struct X { T f; };", opts)
+# FIXME: This fails with "Couldn't find $__lldb_expr() in the module"
+# but it should succeed. The fact that this code has nothing to run
+# shouldn't be an error.
+# self.assertSuccess(result.GetError())
+
+# Instantiate and produce a value with that template as the type.
+# The field in the value will have a SubstTemplateTypeParam that
+# should behave like a normal field.
+result = target.EvaluateExpression("X x; x.f = 123; x")
+self.assertEqual(result.GetNumChildren(), 1)
+self.assertEqual(result.GetChildAtIndex(0).GetTypeName(), "int")
+self.assertEqual(result.GetChildAtIndex(0).GetValue(), "123")
Index: lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
===
--- lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
+++ lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
@@ -2499,6 +2499,7 @@
 case clang::Type::Decltype:
 case clang::Type::Elaborated:
 case clang::Type::Paren:
+case clang::Type::SubstTemplateTypeParm:
 case clang::Type::TemplateSpecialization:
 case clang::Type::Typedef:
 case 

[Lldb-commits] [PATCH] D84104: [lldb] watchpoint ID common completion for commands `watchpoint delete/enable/disable/modify/ignore`

2020-08-11 Thread Raphael Isemann via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG4f3559db1f31: [lldb] watchpoint ID common completion for 
commands `watchpoint… (authored by MrHate, committed by teemperor).
Herald added a subscriber: lldb-commits.

Changed prior to commit:
  https://reviews.llvm.org/D84104?vs=279009=284675#toc

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D84104/new/

https://reviews.llvm.org/D84104

Files:
  lldb/include/lldb/Interpreter/CommandCompletions.h
  lldb/source/Commands/CommandCompletions.cpp
  lldb/source/Commands/CommandObjectWatchpoint.cpp
  lldb/test/API/functionalities/completion/TestCompletion.py

Index: lldb/test/API/functionalities/completion/TestCompletion.py
===
--- lldb/test/API/functionalities/completion/TestCompletion.py
+++ lldb/test/API/functionalities/completion/TestCompletion.py
@@ -232,6 +232,22 @@
 """Test that 'help watchpoint s' completes to 'help watchpoint set '."""
 self.complete_from_to('help watchpoint s', 'help watchpoint set ')
 
+def test_common_complete_watchpoint_ids(self):
+subcommands = ['enable', 'disable', 'delete', 'modify', 'ignore']
+
+# Completion should not work without a target.
+for subcommand in subcommands:
+self.complete_from_to('watchpoint ' + subcommand + ' ',
+  'watchpoint ' + subcommand + ' ')
+
+# Create a process to provide a target and enable watchpoint setting.
+self.build()
+lldbutil.run_to_source_breakpoint(self, '// Break here', lldb.SBFileSpec("main.cpp"))
+
+self.runCmd('watchpoint set variable ptr_fooo')
+for subcommand in subcommands:
+self.complete_from_to('watchpoint ' + subcommand + ' ', ['1'])
+
 def test_settings_append_target_er(self):
 """Test that 'settings append target.er' completes to 'settings append target.error-path'."""
 self.complete_from_to(
Index: lldb/source/Commands/CommandObjectWatchpoint.cpp
===
--- lldb/source/Commands/CommandObjectWatchpoint.cpp
+++ lldb/source/Commands/CommandObjectWatchpoint.cpp
@@ -292,6 +292,14 @@
 
   ~CommandObjectWatchpointEnable() override = default;
 
+  void
+  HandleArgumentCompletion(CompletionRequest ,
+   OptionElementVector _element_vector) override {
+CommandCompletions::InvokeCommonCompletionCallbacks(
+GetCommandInterpreter(), CommandCompletions::eWatchPointIDCompletion,
+request, nullptr);
+  }
+
 protected:
   bool DoExecute(Args , CommandReturnObject ) override {
 Target *target = ();
@@ -362,6 +370,14 @@
 
   ~CommandObjectWatchpointDisable() override = default;
 
+  void
+  HandleArgumentCompletion(CompletionRequest ,
+   OptionElementVector _element_vector) override {
+CommandCompletions::InvokeCommonCompletionCallbacks(
+GetCommandInterpreter(), CommandCompletions::eWatchPointIDCompletion,
+request, nullptr);
+  }
+
 protected:
   bool DoExecute(Args , CommandReturnObject ) override {
 Target *target = ();
@@ -439,6 +455,14 @@
 
   ~CommandObjectWatchpointDelete() override = default;
 
+  void
+  HandleArgumentCompletion(CompletionRequest ,
+   OptionElementVector _element_vector) override {
+CommandCompletions::InvokeCommonCompletionCallbacks(
+GetCommandInterpreter(), CommandCompletions::eWatchPointIDCompletion,
+request, nullptr);
+  }
+
   Options *GetOptions() override { return _options; }
 
   class CommandOptions : public Options {
@@ -557,6 +581,14 @@
 
   ~CommandObjectWatchpointIgnore() override = default;
 
+  void
+  HandleArgumentCompletion(CompletionRequest ,
+   OptionElementVector _element_vector) override {
+CommandCompletions::InvokeCommonCompletionCallbacks(
+GetCommandInterpreter(), CommandCompletions::eWatchPointIDCompletion,
+request, nullptr);
+  }
+
   Options *GetOptions() override { return _options; }
 
   class CommandOptions : public Options {
@@ -677,6 +709,14 @@
 
   ~CommandObjectWatchpointModify() override = default;
 
+  void
+  HandleArgumentCompletion(CompletionRequest ,
+   OptionElementVector _element_vector) override {
+CommandCompletions::InvokeCommonCompletionCallbacks(
+GetCommandInterpreter(), CommandCompletions::eWatchPointIDCompletion,
+request, nullptr);
+  }
+
   Options *GetOptions() override { return _options; }
 
   class CommandOptions : public Options {
Index: lldb/source/Commands/CommandCompletions.cpp
===
--- lldb/source/Commands/CommandCompletions.cpp
+++ lldb/source/Commands/CommandCompletions.cpp
@@ -9,6 +9,7 @@
 #include "llvm/ADT/SmallString.h"
 #include 

[Lldb-commits] [PATCH] D84088: [lldb] thread index common completion for commands like `thread select/step-over`

2020-08-11 Thread Raphael Isemann via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGa952fe236f99: [lldb] thread index common completion for 
commands like `thread select/step… (authored by MrHate, committed by teemperor).
Herald added a subscriber: lldb-commits.

Changed prior to commit:
  https://reviews.llvm.org/D84088?vs=279154=284650#toc

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D84088/new/

https://reviews.llvm.org/D84088

Files:
  lldb/include/lldb/Interpreter/CommandCompletions.h
  lldb/source/Commands/CommandCompletions.cpp
  lldb/source/Commands/CommandObjectThread.cpp
  lldb/test/API/functionalities/completion/TestCompletion.py

Index: lldb/test/API/functionalities/completion/TestCompletion.py
===
--- lldb/test/API/functionalities/completion/TestCompletion.py
+++ lldb/test/API/functionalities/completion/TestCompletion.py
@@ -388,6 +388,22 @@
 """Test that 'target va' completes to 'target variable '."""
 self.complete_from_to('target va', 'target variable ')
 
+def test_common_completion_thread_index(self):
+subcommands = ['continue', 'info', 'exception', 'select',
+   'step-in', 'step-inst', 'step-inst-over', 'step-out', 'step-over', 'step-script']
+
+# Completion should do nothing without threads.
+for subcommand in subcommands:
+self.complete_from_to('thread ' + subcommand + ' ',
+  'thread ' + subcommand + ' ')
+
+self.build()
+lldbutil.run_to_source_breakpoint(self, '// Break here', lldb.SBFileSpec("main.cpp"))
+
+# At least we have the thread at the index of 1 now.
+for subcommand in subcommands:
+self.complete_from_to('thread ' + subcommand + ' ', ['1'])
+
 def test_command_argument_completion(self):
 """Test completion of command arguments"""
 self.complete_from_to("watchpoint set variable -", ["-w", "-s"])
Index: lldb/source/Commands/CommandObjectThread.cpp
===
--- lldb/source/Commands/CommandObjectThread.cpp
+++ lldb/source/Commands/CommandObjectThread.cpp
@@ -549,6 +549,17 @@
 
   ~CommandObjectThreadStepWithTypeAndScope() override = default;
 
+  void
+  HandleArgumentCompletion(CompletionRequest ,
+   OptionElementVector _element_vector) override {
+if (request.GetCursorIndex())
+  return;
+
+CommandCompletions::InvokeCommonCompletionCallbacks(
+GetCommandInterpreter(), CommandCompletions::eThreadIndexCompletion,
+request, nullptr);
+  }
+
   Options *GetOptions() override { return _all_options; }
 
 protected:
@@ -815,6 +826,14 @@
 
   ~CommandObjectThreadContinue() override = default;
 
+  void
+  HandleArgumentCompletion(CompletionRequest ,
+   OptionElementVector _element_vector) override {
+CommandCompletions::InvokeCommonCompletionCallbacks(
+GetCommandInterpreter(), CommandCompletions::eThreadIndexCompletion,
+request, nullptr);
+  }
+
   bool DoExecute(Args , CommandReturnObject ) override {
 bool synchronous_execution = m_interpreter.GetSynchronous();
 
@@ -1307,6 +1326,17 @@
 
   ~CommandObjectThreadSelect() override = default;
 
+  void
+  HandleArgumentCompletion(CompletionRequest ,
+   OptionElementVector _element_vector) override {
+if (request.GetCursorIndex())
+  return;
+
+CommandCompletions::InvokeCommonCompletionCallbacks(
+GetCommandInterpreter(), CommandCompletions::eThreadIndexCompletion,
+request, nullptr);
+  }
+
 protected:
   bool DoExecute(Args , CommandReturnObject ) override {
 Process *process = m_exe_ctx.GetProcessPtr();
@@ -1438,6 +1468,14 @@
 
   ~CommandObjectThreadInfo() override = default;
 
+  void
+  HandleArgumentCompletion(CompletionRequest ,
+   OptionElementVector _element_vector) override {
+CommandCompletions::InvokeCommonCompletionCallbacks(
+GetCommandInterpreter(), CommandCompletions::eThreadIndexCompletion,
+request, nullptr);
+  }
+
   Options *GetOptions() override { return _options; }
 
   bool HandleOneThread(lldb::tid_t tid, CommandReturnObject ) override {
@@ -1482,6 +1520,14 @@
 
   ~CommandObjectThreadException() override = default;
 
+  void
+  HandleArgumentCompletion(CompletionRequest ,
+   OptionElementVector _element_vector) override {
+CommandCompletions::InvokeCommonCompletionCallbacks(
+GetCommandInterpreter(), CommandCompletions::eThreadIndexCompletion,
+request, nullptr);
+  }
+
   bool HandleOneThread(lldb::tid_t tid, CommandReturnObject ) override {
 ThreadSP thread_sp =
 m_exe_ctx.GetProcessPtr()->GetThreadList().FindThreadByID(tid);
Index: lldb/source/Commands/CommandCompletions.cpp

[Lldb-commits] [PATCH] D84123: [lldb] stop-hook ID common completion for commands `target stop-hook enable/disable/delete'

2020-08-11 Thread Raphael Isemann via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGb2b7dbb47aa9: [lldb] stop-hook ID common completion for 
commands `target stop-hook… (authored by MrHate, committed by teemperor).
Herald added a subscriber: lldb-commits.

Changed prior to commit:
  https://reviews.llvm.org/D84123?vs=283570=284645#toc

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D84123/new/

https://reviews.llvm.org/D84123

Files:
  lldb/include/lldb/Interpreter/CommandCompletions.h
  lldb/source/Commands/CommandCompletions.cpp
  lldb/source/Commands/CommandObjectTarget.cpp
  lldb/test/API/functionalities/completion/TestCompletion.py

Index: lldb/test/API/functionalities/completion/TestCompletion.py
===
--- lldb/test/API/functionalities/completion/TestCompletion.py
+++ lldb/test/API/functionalities/completion/TestCompletion.py
@@ -548,6 +548,26 @@
 self.complete_from_to('register write rbx ',
   [])
 
+def test_common_completion_target_stophook_ids(self):
+subcommands = ['delete', 'enable', 'disable']
+
+for subcommand in subcommands:
+self.complete_from_to('target stop-hook ' + subcommand + ' ',
+  'target stop-hook ' + subcommand + ' ')
+
+self.build()
+self.dbg.CreateTarget(self.getBuildArtifact("a.out"))
+self.runCmd('target stop-hook add test DONE')
+
+for subcommand in subcommands:
+self.complete_from_to('target stop-hook ' + subcommand + ' ',
+  'target stop-hook ' + subcommand + ' 1')
+
+# Completion should work only on the first argument.
+for subcommand in subcommands:
+self.complete_from_to('target stop-hook ' + subcommand + ' 1 ',
+  'target stop-hook ' + subcommand + ' 1 ')
+
 def test_common_completion_type_language(self):
 self.complete_from_to('type category -l ', ['c'])
 
Index: lldb/source/Commands/CommandObjectTarget.cpp
===
--- lldb/source/Commands/CommandObjectTarget.cpp
+++ lldb/source/Commands/CommandObjectTarget.cpp
@@ -4722,6 +4722,16 @@
 
   ~CommandObjectTargetStopHookDelete() override = default;
 
+  void
+  HandleArgumentCompletion(CompletionRequest ,
+   OptionElementVector _element_vector) override {
+if (request.GetCursorIndex())
+  return;
+CommandCompletions::InvokeCommonCompletionCallbacks(
+GetCommandInterpreter(), CommandCompletions::eStopHookIDCompletion,
+request, nullptr);
+  }
+
 protected:
   bool DoExecute(Args , CommandReturnObject ) override {
 Target  = GetSelectedOrDummyTarget();
@@ -4770,6 +4780,16 @@
 
   ~CommandObjectTargetStopHookEnableDisable() override = default;
 
+  void
+  HandleArgumentCompletion(CompletionRequest ,
+   OptionElementVector _element_vector) override {
+if (request.GetCursorIndex())
+  return;
+CommandCompletions::InvokeCommonCompletionCallbacks(
+GetCommandInterpreter(), CommandCompletions::eStopHookIDCompletion,
+request, nullptr);
+  }
+
 protected:
   bool DoExecute(Args , CommandReturnObject ) override {
 Target  = GetSelectedOrDummyTarget();
Index: lldb/source/Commands/CommandCompletions.cpp
===
--- lldb/source/Commands/CommandCompletions.cpp
+++ lldb/source/Commands/CommandCompletions.cpp
@@ -65,6 +65,7 @@
   {eDisassemblyFlavorCompletion, CommandCompletions::DisassemblyFlavors},
   {eTypeLanguageCompletion, CommandCompletions::TypeLanguages},
   {eFrameIndexCompletion, CommandCompletions::FrameIndexes},
+  {eStopHookIDCompletion, CommandCompletions::StopHookIDs},
   {eNoCompletion, nullptr} // This one has to be last in the list.
   };
 
@@ -656,3 +657,24 @@
 request.TryCompleteCurrentArg(std::to_string(i), strm.GetString());
   }
 }
+
+void CommandCompletions::StopHookIDs(CommandInterpreter ,
+ CompletionRequest ,
+ SearchFilter *searcher) {
+  const lldb::TargetSP target_sp =
+  interpreter.GetExecutionContext().GetTargetSP();
+  if (!target_sp)
+return;
+
+  const size_t num = target_sp->GetNumStopHooks();
+  for (size_t idx = 0; idx < num; ++idx) {
+StreamString strm;
+// The value 11 is an offset to make the completion description looks
+// neater.
+strm.SetIndentLevel(11);
+const Target::StopHookSP stophook_sp = target_sp->GetStopHookAtIndex(idx);
+stophook_sp->GetDescription(, lldb::eDescriptionLevelInitial);
+request.TryCompleteCurrentArg(std::to_string(stophook_sp->GetID()),
+  strm.GetString());
+  }
+}
Index: 

[Lldb-commits] [PATCH] D85719: Initialize static const fields in the AST for expression evaluation

2020-08-11 Thread Raphael Isemann via Phabricator via lldb-commits
teemperor added a comment.

There is actually https://reviews.llvm.org/D81471 that makes this fully work, 
but it's still waiting on someone to review it :)


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D85719/new/

https://reviews.llvm.org/D85719

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


[Lldb-commits] [PATCH] D83309: [lldb] tab completion for `target modules search-paths insert​`

2020-08-11 Thread Raphael Isemann via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG24bc8afd4baf: [lldb] tab completion for `target modules 
search-paths insert​` (authored by MrHate, committed by teemperor).
Herald added a subscriber: lldb-commits.

Changed prior to commit:
  https://reviews.llvm.org/D83309?vs=276069=284627#toc

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D83309/new/

https://reviews.llvm.org/D83309

Files:
  lldb/source/Commands/CommandObjectTarget.cpp
  lldb/test/API/functionalities/completion/TestCompletion.py


Index: lldb/test/API/functionalities/completion/TestCompletion.py
===
--- lldb/test/API/functionalities/completion/TestCompletion.py
+++ lldb/test/API/functionalities/completion/TestCompletion.py
@@ -368,6 +368,18 @@
 self.complete_from_to('target modules load a.ou',
   ['a.out'])
 
+def test_target_modules_search_paths_insert(self):
+# Completion won't work without a valid target.
+self.complete_from_to("target modules search-paths insert ", "target 
modules search-paths insert ")
+self.build()
+target = self.dbg.CreateTarget(self.getBuildArtifact('a.out'))
+self.assertTrue(target, VALID_TARGET)
+self.complete_from_to("target modules search-paths insert ", "target 
modules search-paths insert ")
+self.runCmd("target modules search-paths add a b")
+self.complete_from_to("target modules search-paths insert ", "target 
modules search-paths insert 0")
+# Completion only works for the first arg.
+self.complete_from_to("target modules search-paths insert 0 ", "target 
modules search-paths insert 0 ")
+
 def test_target_create_dash_co(self):
 """Test that 'target create --co' completes to 'target variable --core 
'."""
 self.complete_from_to('target create --co', 'target create --core ')
Index: lldb/source/Commands/CommandObjectTarget.cpp
===
--- lldb/source/Commands/CommandObjectTarget.cpp
+++ lldb/source/Commands/CommandObjectTarget.cpp
@@ -1157,6 +1157,25 @@
 
   ~CommandObjectTargetModulesSearchPathsInsert() override = default;
 
+  void
+  HandleArgumentCompletion(CompletionRequest ,
+   OptionElementVector _element_vector) override {
+if (!m_exe_ctx.HasTargetScope() || request.GetCursorIndex() != 0)
+  return;
+
+Target *target = m_exe_ctx.GetTargetPtr();
+const PathMappingList  = target->GetImageSearchPathList();
+const size_t num = list.GetSize();
+ConstString old_path, new_path;
+for (size_t i = 0; i < num; ++i) {
+  if (!list.GetPathsAtIndex(i, old_path, new_path))
+break;
+  StreamString strm;
+  strm << old_path << " -> " << new_path;
+  request.TryCompleteCurrentArg(std::to_string(i), strm.GetString());
+}
+  }
+
 protected:
   bool DoExecute(Args , CommandReturnObject ) override {
 Target *target = ();


Index: lldb/test/API/functionalities/completion/TestCompletion.py
===
--- lldb/test/API/functionalities/completion/TestCompletion.py
+++ lldb/test/API/functionalities/completion/TestCompletion.py
@@ -368,6 +368,18 @@
 self.complete_from_to('target modules load a.ou',
   ['a.out'])
 
+def test_target_modules_search_paths_insert(self):
+# Completion won't work without a valid target.
+self.complete_from_to("target modules search-paths insert ", "target modules search-paths insert ")
+self.build()
+target = self.dbg.CreateTarget(self.getBuildArtifact('a.out'))
+self.assertTrue(target, VALID_TARGET)
+self.complete_from_to("target modules search-paths insert ", "target modules search-paths insert ")
+self.runCmd("target modules search-paths add a b")
+self.complete_from_to("target modules search-paths insert ", "target modules search-paths insert 0")
+# Completion only works for the first arg.
+self.complete_from_to("target modules search-paths insert 0 ", "target modules search-paths insert 0 ")
+
 def test_target_create_dash_co(self):
 """Test that 'target create --co' completes to 'target variable --core '."""
 self.complete_from_to('target create --co', 'target create --core ')
Index: lldb/source/Commands/CommandObjectTarget.cpp
===
--- lldb/source/Commands/CommandObjectTarget.cpp
+++ lldb/source/Commands/CommandObjectTarget.cpp
@@ -1157,6 +1157,25 @@
 
   ~CommandObjectTargetModulesSearchPathsInsert() override = default;
 
+  void
+  HandleArgumentCompletion(CompletionRequest ,
+   OptionElementVector _element_vector) override {
+if (!m_exe_ctx.HasTargetScope() || 

[Lldb-commits] [PATCH] D81128: [lldb] tab completion for 'command delete/unalias'

2020-08-11 Thread Raphael Isemann via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG31fd64ac57a2: [lldb] tab completion for command 
delete/unalias (authored by MrHate, committed by teemperor).
Herald added a subscriber: lldb-commits.

Changed prior to commit:
  https://reviews.llvm.org/D81128?vs=268389=284604#toc

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D81128/new/

https://reviews.llvm.org/D81128

Files:
  lldb/include/lldb/Interpreter/CommandInterpreter.h
  lldb/source/Commands/CommandObjectCommands.cpp
  lldb/test/API/functionalities/completion/TestCompletion.py


Index: lldb/test/API/functionalities/completion/TestCompletion.py
===
--- lldb/test/API/functionalities/completion/TestCompletion.py
+++ lldb/test/API/functionalities/completion/TestCompletion.py
@@ -401,6 +401,13 @@
 self.runCmd("command script add -h test_desc -f none -s current 
usercmd1")
 self.check_completion_with_desc('command script delete ', 
[['usercmd1', 'test_desc']])
 
+def test_command_delete(self):
+self.runCmd(r"command regex test_command s/^$/finish/ 
's/([0-9]+)/frame select %1/'")
+self.complete_from_to('command delete test_c', 'command delete 
test_command')
+
+def test_command_unalias(self):
+self.complete_from_to('command unalias ima', 'command unalias image')
+
 def test_completion_description_commands(self):
 """Test descriptions of top-level command completions"""
 self.check_completion_with_desc("", [
Index: lldb/source/Commands/CommandObjectCommands.cpp
===
--- lldb/source/Commands/CommandObjectCommands.cpp
+++ lldb/source/Commands/CommandObjectCommands.cpp
@@ -618,6 +618,17 @@
 
   ~CommandObjectCommandsUnalias() override = default;
 
+  void
+  HandleArgumentCompletion(CompletionRequest ,
+   OptionElementVector _element_vector) override {
+if (!m_interpreter.HasCommands() || request.GetCursorIndex() != 0)
+  return;
+
+for (const auto  : m_interpreter.GetAliases()) {
+  request.TryCompleteCurrentArg(ent.first, ent.second->GetHelp());
+}
+  }
+
 protected:
   bool DoExecute(Args , CommandReturnObject ) override {
 CommandObject::CommandMap::iterator pos;
@@ -699,6 +710,18 @@
 
   ~CommandObjectCommandsDelete() override = default;
 
+  void
+  HandleArgumentCompletion(CompletionRequest ,
+   OptionElementVector _element_vector) override {
+if (!m_interpreter.HasCommands() || request.GetCursorIndex() != 0)
+  return;
+
+for (const auto  : m_interpreter.GetCommands()) {
+  if (ent.second->IsRemovable())
+request.TryCompleteCurrentArg(ent.first, ent.second->GetHelp());
+}
+  }
+
 protected:
   bool DoExecute(Args , CommandReturnObject ) override {
 CommandObject::CommandMap::iterator pos;
Index: lldb/include/lldb/Interpreter/CommandInterpreter.h
===
--- lldb/include/lldb/Interpreter/CommandInterpreter.h
+++ lldb/include/lldb/Interpreter/CommandInterpreter.h
@@ -501,6 +501,12 @@
 return m_user_dict;
   }
 
+  const CommandObject::CommandMap () const {
+return m_command_dict;
+  }
+
+  const CommandObject::CommandMap () const { return m_alias_dict; }
+
   /// Specify if the command interpreter should allow that the user can
   /// specify a custom exit code when calling 'quit'.
   void AllowExitCodeOnQuit(bool allow);


Index: lldb/test/API/functionalities/completion/TestCompletion.py
===
--- lldb/test/API/functionalities/completion/TestCompletion.py
+++ lldb/test/API/functionalities/completion/TestCompletion.py
@@ -401,6 +401,13 @@
 self.runCmd("command script add -h test_desc -f none -s current usercmd1")
 self.check_completion_with_desc('command script delete ', [['usercmd1', 'test_desc']])
 
+def test_command_delete(self):
+self.runCmd(r"command regex test_command s/^$/finish/ 's/([0-9]+)/frame select %1/'")
+self.complete_from_to('command delete test_c', 'command delete test_command')
+
+def test_command_unalias(self):
+self.complete_from_to('command unalias ima', 'command unalias image')
+
 def test_completion_description_commands(self):
 """Test descriptions of top-level command completions"""
 self.check_completion_with_desc("", [
Index: lldb/source/Commands/CommandObjectCommands.cpp
===
--- lldb/source/Commands/CommandObjectCommands.cpp
+++ lldb/source/Commands/CommandObjectCommands.cpp
@@ -618,6 +618,17 @@
 
   ~CommandObjectCommandsUnalias() override = default;
 
+  void
+  HandleArgumentCompletion(CompletionRequest ,
+   OptionElementVector _element_vector) override 

[Lldb-commits] [PATCH] D83234: [lldb] tab completion for `thread plan discard`

2020-08-11 Thread Raphael Isemann via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGf99a18bbaa02: [lldb] tab completion for `thread plan 
discard` (authored by MrHate, committed by teemperor).
Herald added a subscriber: lldb-commits.

Changed prior to commit:
  https://reviews.llvm.org/D83234?vs=283777=284602#toc

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D83234/new/

https://reviews.llvm.org/D83234

Files:
  lldb/include/lldb/Target/Thread.h
  lldb/source/Commands/CommandObjectThread.cpp
  lldb/source/Target/Thread.cpp
  lldb/test/API/functionalities/completion/TestCompletion.py
  lldb/test/API/functionalities/completion/thread_plan_script.py

Index: lldb/test/API/functionalities/completion/thread_plan_script.py
===
--- /dev/null
+++ lldb/test/API/functionalities/completion/thread_plan_script.py
@@ -0,0 +1,20 @@
+#
+# This script is just to provide a thread plan which won't be popped instantly
+# for the completion test. The thread plan class below won't really do anything
+# itself.
+
+import lldb
+
+class PushPlanStack:
+
+def __init__(self, thread_plan, dict):
+pass
+
+def explains_stop(self, event):
+return False
+
+def should_stop(self, event):
+return True
+
+def should_step(self):
+return True
Index: lldb/test/API/functionalities/completion/TestCompletion.py
===
--- lldb/test/API/functionalities/completion/TestCompletion.py
+++ lldb/test/API/functionalities/completion/TestCompletion.py
@@ -329,6 +329,19 @@
   ['target.process.thread.step-avoid-regexp',
'target.process.thread.trace-thread'])
 
+def test_thread_plan_discard(self):
+self.build()
+(_, _, thread, _) = lldbutil.run_to_source_breakpoint(self,
+  'ptr_foo', lldb.SBFileSpec("main.cpp"))
+self.assertTrue(thread)
+self.complete_from_to('thread plan discard ', 'thread plan discard ')
+
+source_path = os.path.join(self.getSourceDir(), "thread_plan_script.py")
+self.runCmd("command script import '%s'"%(source_path))
+self.runCmd("thread step-scripted -C thread_plan_script.PushPlanStack")
+self.complete_from_to('thread plan discard ', 'thread plan discard 1')
+self.runCmd('thread plan discard 1')
+
 def test_target_space(self):
 """Test that 'target ' completes to ['create', 'delete', 'list',
 'modules', 'select', 'stop-hook', 'variable']."""
Index: lldb/source/Target/Thread.cpp
===
--- lldb/source/Target/Thread.cpp
+++ lldb/source/Target/Thread.cpp
@@ -1103,6 +1103,22 @@
 discarded_plan_sp->GetThread().GetID());
 }
 
+void Thread::AutoCompleteThreadPlans(CompletionRequest ) const {
+  const ThreadPlanStack  = GetPlans();
+  if (!plans.AnyPlans())
+return;
+
+  // Iterate from the second plan (index: 1) to skip the base plan.
+  ThreadPlanSP p;
+  uint32_t i = 1;
+  while (p = plans.GetPlanByIndex(i, false)) {
+StreamString strm;
+p->GetDescription(, eDescriptionLevelInitial);
+request.TryCompleteCurrentArg(std::to_string(i), strm.GetString());
+i++;
+  }
+}
+
 ThreadPlan *Thread::GetCurrentPlan() const {
   return GetPlans().GetCurrentPlan().get();
 }
Index: lldb/source/Commands/CommandObjectThread.cpp
===
--- lldb/source/Commands/CommandObjectThread.cpp
+++ lldb/source/Commands/CommandObjectThread.cpp
@@ -1985,6 +1985,15 @@
 
   ~CommandObjectThreadPlanDiscard() override = default;
 
+  void
+  HandleArgumentCompletion(CompletionRequest ,
+   OptionElementVector _element_vector) override {
+if (!m_exe_ctx.HasThreadScope() || request.GetCursorIndex())
+  return;
+
+m_exe_ctx.GetThreadPtr()->AutoCompleteThreadPlans(request);
+  }
+
   bool DoExecute(Args , CommandReturnObject ) override {
 Thread *thread = m_exe_ctx.GetThreadPtr();
 if (args.GetArgumentCount() != 1) {
Index: lldb/include/lldb/Target/Thread.h
===
--- lldb/include/lldb/Target/Thread.h
+++ lldb/include/lldb/Target/Thread.h
@@ -19,6 +19,7 @@
 #include "lldb/Target/RegisterCheckpoint.h"
 #include "lldb/Target/StackFrameList.h"
 #include "lldb/Utility/Broadcaster.h"
+#include "lldb/Utility/CompletionRequest.h"
 #include "lldb/Utility/Event.h"
 #include "lldb/Utility/StructuredData.h"
 #include "lldb/Utility/UserID.h"
@@ -911,6 +912,12 @@
 
   // Thread Plan accessors:
 
+  /// Format the thread plan information for auto completion.
+  ///
+  /// \param[in] request
+  /// The reference to the completion handler.
+  void 

[Lldb-commits] [PATCH] D85633: [lldb][NFC] Remove unused custom reimplementation of realpath for Windows

2020-08-11 Thread Raphael Isemann via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG51117e3c5175: [lldb][NFC] Remove unused custom 
reimplementation of realpath for Windows (authored by teemperor).
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D85633/new/

https://reviews.llvm.org/D85633

Files:
  lldb/include/lldb/Host/windows/PosixApi.h
  lldb/source/Host/windows/Windows.cpp

Index: lldb/source/Host/windows/Windows.cpp
===
--- lldb/source/Host/windows/Windows.cpp
+++ lldb/source/Host/windows/Windows.cpp
@@ -82,89 +82,6 @@
   return const_cast(s);
 }
 
-char *realpath(const char *name, char *resolved) {
-  char *retname = NULL;
-
-  /* SUSv3 says we must set `errno = EINVAL', and return NULL,
-  * if `name' is passed as a NULL pointer.
-  */
-  if (name == NULL) {
-errno = EINVAL;
-return NULL;
-  }
-
-  /* Otherwise, `name' must refer to a readable filesystem object,
-  * if we are going to resolve its absolute path name.
-  */
-  wchar_t wideNameBuffer[PATH_MAX];
-  wchar_t *wideName = wideNameBuffer;
-  if (!utf8ToWide(name, wideName, PATH_MAX)) {
-errno = EINVAL;
-return NULL;
-  }
-
-  if (_waccess(wideName, 4) != 0)
-return NULL;
-
-  /* If `name' didn't point to an existing entity,
-  * then we don't get to here; we simply fall past this block,
-  * returning NULL, with `errno' appropriately set by `access'.
-  *
-  * When we _do_ get to here, then we can use `_fullpath' to
-  * resolve the full path for `name' into `resolved', but first,
-  * check that we have a suitable buffer, in which to return it.
-  */
-
-  if ((retname = resolved) == NULL) {
-/* Caller didn't give us a buffer, so we'll exercise the
-* option granted by SUSv3, and allocate one.
-*
-* `_fullpath' would do this for us, but it uses `malloc', and
-* Microsoft's implementation doesn't set `errno' on failure.
-* If we don't do this explicitly ourselves, then we will not
-* know if `_fullpath' fails on `malloc' failure, or for some
-* other reason, and we want to set `errno = ENOMEM' for the
-* `malloc' failure case.
-*/
-
-retname = (char *)malloc(PATH_MAX);
-if (retname == NULL) {
-  errno = ENOMEM;
-  return NULL;
-}
-  }
-
-  /* Otherwise, when we do have a valid buffer,
-  * `_fullpath' should only fail if the path name is too long.
-  */
-
-  wchar_t wideFullPathBuffer[PATH_MAX];
-  wchar_t *wideFullPath;
-  if ((wideFullPath = _wfullpath(wideFullPathBuffer, wideName, PATH_MAX)) ==
-  NULL) {
-errno = ENAMETOOLONG;
-return NULL;
-  }
-
-  // Do a LongPath<->ShortPath roundtrip so that case is resolved by OS
-  // FIXME: Check for failure
-  size_t initialLength = wcslen(wideFullPath);
-  GetShortPathNameW(wideFullPath, wideNameBuffer, PATH_MAX);
-  GetLongPathNameW(wideNameBuffer, wideFullPathBuffer, initialLength + 1);
-
-  // Convert back to UTF-8
-  if (!wideToUtf8(wideFullPathBuffer, retname, PATH_MAX)) {
-errno = EINVAL;
-return NULL;
-  }
-
-  // Force drive to be upper case
-  if (retname[1] == ':')
-retname[0] = toupper(retname[0]);
-
-  return retname;
-}
-
 #ifdef _MSC_VER
 
 char *basename(char *path) {
Index: lldb/include/lldb/Host/windows/PosixApi.h
===
--- lldb/include/lldb/Host/windows/PosixApi.h
+++ lldb/include/lldb/Host/windows/PosixApi.h
@@ -98,7 +98,6 @@
 // custom implementations.
 int vasprintf(char **ret, const char *fmt, va_list ap);
 char *strcasestr(const char *s, const char *find);
-char *realpath(const char *name, char *resolved);
 
 #ifdef _MSC_VER
 
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D84177: [lldb] tab completion for `watchpoint set variable`

2020-08-11 Thread Raphael Isemann via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG2e653327e364: [lldb] tab completion for `watchpoint set 
variable` (authored by MrHate, committed by teemperor).
Herald added a subscriber: lldb-commits.

Changed prior to commit:
  https://reviews.llvm.org/D84177?vs=279260=284596#toc

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D84177/new/

https://reviews.llvm.org/D84177

Files:
  lldb/source/Commands/CommandObjectWatchpoint.cpp
  lldb/test/API/functionalities/completion/TestCompletion.py


Index: lldb/test/API/functionalities/completion/TestCompletion.py
===
--- lldb/test/API/functionalities/completion/TestCompletion.py
+++ lldb/test/API/functionalities/completion/TestCompletion.py
@@ -209,6 +209,13 @@
 """Test that 'watchpoint set var' completes to 'watchpoint set 
variable '."""
 self.complete_from_to('watchpoint set var', 'watchpoint set variable ')
 
+def test_watchpoint_set_variable_foo(self):
+self.build()
+lldbutil.run_to_source_breakpoint(self, '// Break here', 
lldb.SBFileSpec("main.cpp"))
+self.complete_from_to('watchpoint set variable fo', 'watchpoint set 
variable fooo')
+# Only complete the first argument.
+self.complete_from_to('watchpoint set variable fooo ', 'watchpoint set 
variable fooo ')
+
 def test_help_fi(self):
 """Test that 'help fi' completes to ['file', 'finish']."""
 self.complete_from_to(
Index: lldb/source/Commands/CommandObjectWatchpoint.cpp
===
--- lldb/source/Commands/CommandObjectWatchpoint.cpp
+++ lldb/source/Commands/CommandObjectWatchpoint.cpp
@@ -823,6 +823,16 @@
 
   ~CommandObjectWatchpointSetVariable() override = default;
 
+  void
+  HandleArgumentCompletion(CompletionRequest ,
+   OptionElementVector _element_vector) override {
+if (request.GetCursorIndex() != 0)
+  return;
+CommandCompletions::InvokeCommonCompletionCallbacks(
+GetCommandInterpreter(), CommandCompletions::eVariablePathCompletion,
+request, nullptr);
+  }
+
   Options *GetOptions() override { return _option_group; }
 
 protected:


Index: lldb/test/API/functionalities/completion/TestCompletion.py
===
--- lldb/test/API/functionalities/completion/TestCompletion.py
+++ lldb/test/API/functionalities/completion/TestCompletion.py
@@ -209,6 +209,13 @@
 """Test that 'watchpoint set var' completes to 'watchpoint set variable '."""
 self.complete_from_to('watchpoint set var', 'watchpoint set variable ')
 
+def test_watchpoint_set_variable_foo(self):
+self.build()
+lldbutil.run_to_source_breakpoint(self, '// Break here', lldb.SBFileSpec("main.cpp"))
+self.complete_from_to('watchpoint set variable fo', 'watchpoint set variable fooo')
+# Only complete the first argument.
+self.complete_from_to('watchpoint set variable fooo ', 'watchpoint set variable fooo ')
+
 def test_help_fi(self):
 """Test that 'help fi' completes to ['file', 'finish']."""
 self.complete_from_to(
Index: lldb/source/Commands/CommandObjectWatchpoint.cpp
===
--- lldb/source/Commands/CommandObjectWatchpoint.cpp
+++ lldb/source/Commands/CommandObjectWatchpoint.cpp
@@ -823,6 +823,16 @@
 
   ~CommandObjectWatchpointSetVariable() override = default;
 
+  void
+  HandleArgumentCompletion(CompletionRequest ,
+   OptionElementVector _element_vector) override {
+if (request.GetCursorIndex() != 0)
+  return;
+CommandCompletions::InvokeCommonCompletionCallbacks(
+GetCommandInterpreter(), CommandCompletions::eVariablePathCompletion,
+request, nullptr);
+  }
+
   Options *GetOptions() override { return _option_group; }
 
 protected:
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D81001: [lldb] Display autosuggestion part in gray if there is one possible suggestion

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

Also signing this off as I think this is in a good enough state to land. The 
remaining issues can all be follow-up patches.

Also you might want to change your editor to remove trailing spaces from lines. 
The test file has a lot of them (I'll just fix that when merging for this 
patch).


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D81001/new/

https://reviews.llvm.org/D81001

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


[Lldb-commits] [PATCH] D84179: [lldb] tab completion for `platform target-install`

2020-08-10 Thread Raphael Isemann via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGe3820570d406: [lldb] tab completion for `platform 
target-install` (authored by MrHate, committed by teemperor).
Herald added a subscriber: lldb-commits.

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D84179/new/

https://reviews.llvm.org/D84179

Files:
  lldb/source/Commands/CommandObjectPlatform.cpp
  lldb/test/API/functionalities/completion/TestCompletion.py


Index: lldb/test/API/functionalities/completion/TestCompletion.py
===
--- lldb/test/API/functionalities/completion/TestCompletion.py
+++ lldb/test/API/functionalities/completion/TestCompletion.py
@@ -426,6 +426,9 @@
 self.runCmd("frame recognizer add -l py_class -s module_name -n 
recognizer_name")
 self.check_completion_with_desc('frame recognizer delete ', [['0', 
'py_class, module module_name, symbol recognizer_name']])
 
+def test_platform_install_local_file(self):
+self.complete_from_to('platform target-install main.cp', 'platform 
target-install main.cpp')
+
 @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24489")
 def test_symbol_name(self):
 self.build()
Index: lldb/source/Commands/CommandObjectPlatform.cpp
===
--- lldb/source/Commands/CommandObjectPlatform.cpp
+++ lldb/source/Commands/CommandObjectPlatform.cpp
@@ -1706,6 +1706,16 @@
 
   ~CommandObjectPlatformInstall() override = default;
 
+  void
+  HandleArgumentCompletion(CompletionRequest ,
+   OptionElementVector _element_vector) override {
+if (request.GetCursorIndex())
+  return;
+CommandCompletions::InvokeCommonCompletionCallbacks(
+GetCommandInterpreter(), CommandCompletions::eDiskFileCompletion,
+request, nullptr);
+  }
+
   bool DoExecute(Args , CommandReturnObject ) override {
 if (args.GetArgumentCount() != 2) {
   result.AppendError("platform target-install takes two arguments");


Index: lldb/test/API/functionalities/completion/TestCompletion.py
===
--- lldb/test/API/functionalities/completion/TestCompletion.py
+++ lldb/test/API/functionalities/completion/TestCompletion.py
@@ -426,6 +426,9 @@
 self.runCmd("frame recognizer add -l py_class -s module_name -n recognizer_name")
 self.check_completion_with_desc('frame recognizer delete ', [['0', 'py_class, module module_name, symbol recognizer_name']])
 
+def test_platform_install_local_file(self):
+self.complete_from_to('platform target-install main.cp', 'platform target-install main.cpp')
+
 @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24489")
 def test_symbol_name(self):
 self.build()
Index: lldb/source/Commands/CommandObjectPlatform.cpp
===
--- lldb/source/Commands/CommandObjectPlatform.cpp
+++ lldb/source/Commands/CommandObjectPlatform.cpp
@@ -1706,6 +1706,16 @@
 
   ~CommandObjectPlatformInstall() override = default;
 
+  void
+  HandleArgumentCompletion(CompletionRequest ,
+   OptionElementVector _element_vector) override {
+if (request.GetCursorIndex())
+  return;
+CommandCompletions::InvokeCommonCompletionCallbacks(
+GetCommandInterpreter(), CommandCompletions::eDiskFileCompletion,
+request, nullptr);
+  }
+
   bool DoExecute(Args , CommandReturnObject ) override {
 if (args.GetArgumentCount() != 2) {
   result.AppendError("platform target-install takes two arguments");
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D85376: Fix how ValueObjectChild handles bit-fields stored in a Scalar in UpdateValue()

2020-08-10 Thread Raphael Isemann via Phabricator via lldb-commits
teemperor added a comment.

I just have a small comment about the test. If you build the test with an 
llvm.org version of clang (best if it contains the git hash it was build from) 
and you don't include headers (they don't seem to be required for the test), 
then the file would be much easier to update/extend for other people.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D85376/new/

https://reviews.llvm.org/D85376

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


[Lldb-commits] [PATCH] D81001: [lldb] Display autosuggestion part in gray if there is one possible suggestion

2020-08-06 Thread Raphael Isemann via Phabricator via lldb-commits
teemperor added a comment.

Alright, let's see if the others see any other issues, otherwise I think this 
is finally good to go.




Comment at: lldb/source/Host/common/Editline.cpp:1011
   el_insertstr(m_editline, to_add.c_str());
-  break;
+  if (to_add == " ")
+return CC_REDISPLAY;

Without a comment this code is very mysterious to whoever will read it.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D81001/new/

https://reviews.llvm.org/D81001

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


[Lldb-commits] [PATCH] D81001: [lldb] Display autosuggestion part in gray if there is one possible suggestion

2020-08-06 Thread Raphael Isemann via Phabricator via lldb-commits
teemperor added a comment.

In D81001#2199450 , @gedatsu217 wrote:

>> So, if I would type "b" and then press tab, the autosuggestion would briefly 
>> disappear until I type the next character?
>
> Yes. Indeed, it may not be good.  I'll think of other ways.

This seems minor enough that I wouldn't block the whole patch over it, so this 
can be addresses in a follow-up patch.

Are there any other problems with the current state of the patch that haven't 
been resolved? (I went over the comments, but it's hard to say what has and 
hasn't been fixed until now).


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D81001/new/

https://reviews.llvm.org/D81001

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


[Lldb-commits] [PATCH] D81001: [lldb] Display autosuggestion part in gray if there is one possible suggestion

2020-08-06 Thread Raphael Isemann via Phabricator via lldb-commits
teemperor added a comment.

In D81001#2199205 , @gedatsu217 wrote:

>> So the way the issue with the single space is now solved is by doing 
>> CC_REDISPLAY when we're only adding the single space? Isn't that also 
>> deleting the whole autosuggestion?
>
> Yes. CC_REDISPLAY can delete all the gray characters left.

So, if I would type "b" and then press tab, the autosuggestion would briefly 
disappear until I type the next character?




Comment at: lldb/source/Host/common/Editline.cpp:1081
+if (spaces_to_print > 0) {
+  std::string spaces = std::string((int)spaces_to_print, ' ');
+  fputs(spaces.c_str(), m_output_file);

gedatsu217 wrote:
> teemperor wrote:
> > The `(int)` cast isn't necessary.
> I found that lldb crashed. Sorry, I should have checked more when I uploaded 
> this.
> 
> I use spaces_to_print as size_t, but this sometimes becomes less than zero. 
> So, I have to use this as int.
> 
> 
Yeah I see that spaces_to_print can overflow. How about this code instead that 
avoids all the casting and overflowing and so on:

```
lang=c++
size_t new_autosuggestion_size = line.size() + to_add->length();
// If the previous command line + autosuggestion was longer than the
// current autosuggestion, make sure that the autosuggestion is overwriting
// the old output by enough adding trailing spaces.
if (new_autosuggestion_size < m_previous_autosuggestion_size) {
  size_t spaces_to_print = m_previous_autosuggestion_size - 
new_autosuggestion_size;
  std::string spaces = std::string(spaces_to_print, ' ');
  fputs(spaces.c_str(), m_output_file);
}
m_previous_autosuggestion_size = new_autosuggestion_size;
```


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D81001/new/

https://reviews.llvm.org/D81001

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


[Lldb-commits] [PATCH] D85145: Use syntax highlighting also in gui mode

2020-08-06 Thread Raphael Isemann via Phabricator via lldb-commits
teemperor added a comment.

Same on Arch Linux. Should be fixed in 45f9fc890705a8272e5253602f5506fdef4586e2 
(I just removed the scope operator).


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D85145/new/

https://reviews.llvm.org/D85145

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


[Lldb-commits] [PATCH] D81001: [lldb] Display autosuggestion part in gray if there is one possible suggestion

2020-08-06 Thread Raphael Isemann via Phabricator via lldb-commits
teemperor added a comment.

So the way the issue with the single space is now solved is by doing 
CC_REDISPLAY when we're only adding the single space? Isn't that also deleting 
the whole autosuggestion?

In D81001#2190864 , @gedatsu217 wrote:

 I don't think the value of m_previous_autosuggestion_size should only grow 
 (which is what this if is doing), as this way we just keep printing a 
 longer and longer space buffer over time. Just printing enough to clear 
 the buffer of the previous completion is enough.
>>>
>>> If I keep the number of characters of the only previous command, I think 
>>> there is a problem. For example, If I type "help frame var" → "help frame 
>>> info" → "help frame v", the remains are hidden. However, If I type "help 
>>> frame var" → "help frame info" → "help" → "help frame v", the number of 
>>> characters of "help frame var" is more than that of "help", so "help frame 
>>> v[aro]" is displayed. What do you think?
>>
>> Not sure if I understand your example correctly, but as soon as you type 
>> "help frame ", you should have an autosuggestion of "help frame info" and 
>> then typing the "v" should clear the "nfo" part. The "help" autosuggestion 
>> should not be involved at all in any logic after you typed "help "?
>
> What I mean is that if I should keep the length of characters of the only 
> previous command, following thing occurs.
>
> 1. execution "help frame var" and m_previous_autosuggestion_size = len("help 
> frame var") = 14
> 2. execution "help frame info" and m_previous_autosuggestion_size = len("help 
> frame info") = 15
> 3. execution "help" and m_previous_autosuggestion_size = len("help") = 4
> 4. Typing "help frame v". Then, spaces_to_print = 
> m_previous_autosuggestion_size - line.size() - to_add.getValue().length() = 4 
> - 12 - 2 < 0. So, spaces are not added. (In short, "help frame v[aro]" is 
> displayed.)
>
> (Maybe, I do not understand what you say. )

I think you got it :). My point was that `m_previous_autosuggestion_size` is 
updated everytime you type a character from what I can see, so you don't see 
the `4` from step 3. It's more like this from what I can tell:

1. same as your step 1.
2. same as your step 2.
3. same asyour step 3: execution "help" and m_previous_autosuggestion_size = 
len("help") = 4

3.5 [new step]: Typing "help frame ". m_previous_autosuggestion_size = 
len("help frame info") = 15. This is because we update the size in 
TypedCharacter which gets triggered for every character.

4. Typing "help frame v". Then, spaces_to_print = 
m_previous_autosuggestion_size - line.size() - to_add.getValue().length() = 15 
- 12 - 2 = 1. (which is exactly the space needed to overwrite the 'o').




Comment at: lldb/source/Host/common/Editline.cpp:1009
 to_add.push_back(request.GetParsedArg().GetQuoteChar());
+  if (m_suggestion_callback && to_add.empty()) {
+to_add.push_back(' ');

I think this can be shortened to just:
```
lang=c++
  to_add.push_back(' ');
  el_insertstr(m_editline, to_add.c_str());
  // Clear autosuggestion from line buffer if we only added a space.
  if (to_add == " ")
return CC_REDISPLAY;
  return CC_REFRESH;
}
```



Comment at: lldb/source/Host/common/Editline.cpp:1081
+if (spaces_to_print > 0) {
+  std::string spaces = std::string((int)spaces_to_print, ' ');
+  fputs(spaces.c_str(), m_output_file);

The `(int)` cast isn't necessary.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D81001/new/

https://reviews.llvm.org/D81001

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


[Lldb-commits] [PATCH] D85145: Use syntax highlighting also in gui mode

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

Sorry was OOO.

The source code is user input, so you can have anything in it. LLDB will 
happily read and return any file contents as long as it matches the source 
path. Like, create a test.cpp, compile it, then just copy over some binary file 
to the source path. Not that we should do some complicated error handling in 
this case, but as long as we don't assert and end the whole debug session it's 
IMHO fine. This LGTM to me now, thanks for working on this!

In D85145#2192991 , @llunak wrote:

> I find some of the StringRef APIs flawed though: consume_front() returns true 
> on success, but consumeInteger() returns false; consume_front() modifies the 
> object, but drop_front() doesn't.

Yeah I had the same realization when I typed the example.


Repository:
  rLLDB LLDB

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D85145/new/

https://reviews.llvm.org/D85145

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


[Lldb-commits] [PATCH] D85145: Use syntax highlighting also in gui mode

2020-08-04 Thread Raphael Isemann via Phabricator via lldb-commits
teemperor requested changes to this revision.
teemperor added a comment.
This revision now requires changes to proceed.

In D85145#2191658 , @llunak wrote:

> In D85145#2191421 , @teemperor wrote:
>
>> Btw, the highlighter supports any kind of delimiter string when 
>> 'highlighting' source. So you could add a parameter for a custom highlighter 
>> too and then pass a more convenient highlighter 'style' in to make the 
>> parsing simpler. See the only call MakeVimStyle (which generates the style 
>> that adds the color escapes) and the HighlighterStyle where you can set any 
>> kind of delimiter.
>
> I think I don't want to do that. The gui mode should preferably use the same 
> highlighting as the non-gui one, so if I added a new style, the colors would 
> still need to be mapped somewhen. Moreover the ^[m style parser is 
> actually pretty simple, much simpler than I was originally afraid it'd be, 
> and possibly it could be later needed for something else too.

Yeah I just scrolled over the code and thought that could be simplified with 
dedicated format, but it seems the parsing logic is quite simple. The color 
parser could indeed be useful for getting colors to work on legacy Windows 
terminals, so that seems useful. I only have some small requests to the parsing 
implementation but otherwise this looks good to me. Thanks for working on this!

I wonder if there is a reasonable way to test this. From what I understand 
these attributes aren't in any output buffer that we could expect (e.g., with a 
pexpect test).




Comment at: lldb/source/Core/IOHandlerCursesGUI.cpp:461
+  // convert color escape sequences to curses color attributes.
+  void OutputColoredStringTruncated(int right_pad, const StringRef ,
+bool blue) {

StringRef is usually passed by-value. Also I think the `Truncated` suffix is 
what was used in other methods to indicate that it doesn't output a full 
CString, but here we anyway don't use C-Strings (yay).



Comment at: lldb/source/Core/IOHandlerCursesGUI.cpp:462
+  void OutputColoredStringTruncated(int right_pad, const StringRef ,
+bool blue) {
+int last_text = -1;  // Last position in string that's been written.

`blue` -> `use_blue_background` ?



Comment at: lldb/source/Core/IOHandlerCursesGUI.cpp:471
+  ::wattron(m_window, COLOR_PAIR(16));
+for (size_t i = 0; i < string.size(); ++i) {
+  if (string[i] != '\x1b') { // esc

StringRef has a bunch of parsing utilities (consume_front, etc.) that could 
help here (not tested if that code actually works, so maybe needs some fixes):

```
lang=c++
llvm::StringRef left_to_parse = string;
while (!left_to_parse.empty()) {
  if (!left_to_parse.consume_front("\x1b")) {
++text_length;
continue;
  }
  [...]
  if (!left_to_parse.consume_front("["))
   return llvm::createStringError(llvm::inconvertibleErrorCode(),
   "Missing '[' in color escape sequence");
  unsigned value;
  if (left_to_parse.consumeInteger(10, value))
   return llvm::createStringError(llvm::inconvertibleErrorCode(),
  "No valid color code in color escape 
sequence");
  if (!left_to_parse.consume_front("m"))
   return llvm::createStringError(llvm::inconvertibleErrorCode(),
  "No 'm' in color escape sequence");
  [...]
}
```

I just returned an llvm::Error here as it seems more appropriate for parsing 
errors. You can handle it in the caller with something like that:
```
lang=c++
handleAllErrors(
std::move(result_from_call)
[&](StringError ) { llvm::errs() << "Error while highlighting 
source: " << e.getMessage() << "\n"; },
```



Comment at: lldb/source/Core/IOHandlerCursesGUI.cpp:475
+continue;
+  } else {
+if (text_length > 0) {

else after continue



Comment at: lldb/source/Core/IOHandlerCursesGUI.cpp:492
+}
+const int value = atoi(string.data() + esc_start);
+if (value == 0) { // Reset.

There is also `llvm::to_integer` (and then you could also assert on an 
successful parse as it doesn't use magic return values for errors).



Comment at: lldb/source/Core/IOHandlerCursesGUI.cpp:1002
 bool underlined_shortcut = false;
-const attr_t hilgight_attr = A_REVERSE;
+const attr_t highlight_attr = A_REVERSE;
 if (highlight)

You can just land typo fixes like this without review.



Comment at: lldb/source/Core/IOHandlerCursesGUI.cpp:3632
+  StringRef line = lineStream.GetString();
+  if (!line.empty() && line.back() == '\n') // remove trailing \n
+line = StringRef(line.data(), line.size() 

[Lldb-commits] [PATCH] D85145: Use syntax highlighting also in gui mode

2020-08-03 Thread Raphael Isemann via Phabricator via lldb-commits
teemperor added a reviewer: teemperor.
teemperor added a comment.

Btw, the highlighter supports any kind of delimiter string when 'highlighting' 
source. So you could add a parameter for a custom highlighter too and then pass 
a more convenient highlighter 'style' in to make the parsing simpler. See the 
only call MakeVimStyle (which generates the style that adds the color escapes) 
and the HighlighterStyle where you can set any kind of delimiter.


Repository:
  rLLDB LLDB

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D85145/new/

https://reviews.llvm.org/D85145

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


[Lldb-commits] [PATCH] D81001: [lldb] Display autosuggestion part in gray if there is one possible suggestion

2020-08-03 Thread Raphael Isemann via Phabricator via lldb-commits
teemperor added a comment.

In D81001#2190646 , @gedatsu217 wrote:

>   @skipIfAsan
>   @skipIfEditlineSupportMissing
>   def test_hidden_autosuggestion(self):
>   @skipIfAsan
>   @skipIfEditlineSupportMissing
>   def test_autosuggestion(self):
>   self.launch(extra_args=["-o", "settings set show-autosuggestion true", 
> "-o", "settings set use-color true"])
>   self.expect("help frame v")
>   self.expect("help frame info")
>   [type 'help frame v' and check for the three space after the grey part 
> to cover up the "nfo" text]
>
> Sorry, would you tell me about this code in more detail? Does this mean that 
> I should make test_hidden_autosuggestion and test if there are spaces there? 
> What is the difference between test_hidden_autosuggestion and 
> test_autosuggestion?

Every `Test*.py` file can have multiple `test_` methods that are each their own 
separate test. First the test suite would run `test_autosuggestion ` and then 
would run `test_hidden_autosuggestion`, but each is its own isolated test. My 
point was that the test with the spaces relies on having exactly two commands 
in that order in the command history to work, so you probably should make a new 
subtest for this so that the test doesn't break if someone extends the test and 
runs another command. So, if you *would* add the test for the spaces to the 
existing test, then if someone would add a command like `help frame va` to the 
history it would break.

>> I don't think the value of m_previous_autosuggestion_size should only grow 
>> (which is what this if is doing), as this way we just keep printing a longer 
>> and longer space buffer over time. Just printing enough to clear the buffer 
>> of the previous completion is enough.
>
> If I keep the number of characters of the only previous command, I think 
> there is a problem.  For example, If I type "help frame var" → "help frame 
> info" → "help frame v", the remains are hidden. However, If I type  "help 
> frame var" → "help frame info" → "help" → "help frame v", the number of 
> characters of "help frame var" is more than that of "help", so "help frame 
> v[aro]" is displayed. What do you think?

Not sure if I understand your example correctly, but as soon as you type "help 
frame ", you should have an autosuggestion of "help frame info" and then typing 
the "v" should clear the "nfo" part. The "help" autosuggestion should not be 
involved at all in any logic after you typed "help "?

>> Also you can just do this calculation directly after you calculated int 
>> spaces_to_print above. This way this code is closer together which hopefully 
>> makes this easier to understand.
>
> For example, if the user executes a command directly after using 
> tab-completion, Editline::TypedCharacter is not called, so spaces_to_print is 
> not calculated. That is because I can calculate this here.

Can you give me an example input where this breaks? I'm not sure how the tab 
completion would influence until what column we would need to overwrite the 
line buffer (that should still be the same).

> By the way, I found a bug again. The gray characters remain when only one 
> character is completed by tab-completion.  
> For instance, when I type "b" and press tab-key after I execute "breakpoint", 
> b [eakpoint] is displayed. [eakpoint] should not be displayed.  This problem 
> will be probably solved by my previous diff 
> (https://reviews.llvm.org/D81001?id=276468). But this diff changes 
> Editline::TabCommand significantly. Would you tell me a good way if any?

That probably comes from the fact that "b" is a command and we just insert a 
space when you tab complete it. And it seems the space we insert into the 
el_insertstr function doesn't seem to overwrite the existing buffer:

  switch (completion.GetMode()) { 
  case CompletionMode::Normal: {  
std::string to_add = completion.GetCompletion();  
to_add = to_add.substr(request.GetCursorArgumentPrefix().size()); 
if (request.GetParsedArg().IsQuoted())
  to_add.push_back(request.GetParsedArg().GetQuoteChar());
to_add.push_back(' '); <- here we add the space. Changing this to another 
character seems to correctly overwrite the buffer.  
 
el_insertstr(m_editline, to_add.c_str()); <- This space doesn't seem to 
overwrite the buffer? 
return CC_REFRESH;
  }

Did you try if your previous code fixes this issue?


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D81001/new/

https://reviews.llvm.org/D81001

___
lldb-commits mailing list
lldb-commits@lists.llvm.org

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