[Lldb-commits] [PATCH] D47929: Add modulemap to lldb include directory

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

I generated a report for the remaining cyclic dependencies in the `lldb` module 
here .

Note that I'll provide a modulemap for the `source/` headers in another patch, 
so this is out of scope for this review. The reason is that this modulemap 
seems to barely affect compilation time and is quite verbose (as I can't use 
umbrellas with the mixed source/header files in the same directory).


https://reviews.llvm.org/D47929



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


[Lldb-commits] [PATCH] D47929: Add modulemap to lldb include directory

2018-06-08 Thread Raphael Isemann via Phabricator via lldb-commits
teemperor created this revision.
teemperor added a reviewer: aprantl.

This patch adds a modulemap which allows compiling the lldb headers into C++ 
modules
(for example in builds with LLVM_ENABLE_MODULES=On).

Even though most of the affected code has been cleaned up to work with the more 
strict
C++ module semantics, there are still some workarounds left in the current 
modulemap
(the most obvious one is the big `lldb` wrapper module).

Note: With the latest clang and libstdc++ it seems necessary to have a STL C++ 
module
to get a working LLVM_ENABLE_MODULES build for lldb. Otherwise clang will 
falsely
detect ODR violations in the textually included STL code inside the lldb 
modules.


https://reviews.llvm.org/D47929

Files:
  include/lldb/module.modulemap

Index: include/lldb/module.modulemap
===
--- /dev/null
+++ include/lldb/module.modulemap
@@ -0,0 +1,139 @@
+
+module lldb_API {
+  requires cplusplus
+
+  umbrella "API"
+  module * { export * }
+}
+
+module lldb_Host {
+  requires cplusplus
+
+  // Because we have OS-specific headers in Host, we just list
+  // all OS-independent headers here that will include the correct
+  // OS-specific header for us.
+  module ConnectionFileDescriptor { header "Host/ConnectionFileDescriptor.h" export * }
+  module Debug { header "Host/Debug.h" export * }
+  module Editline { header "Host/Editline.h" export * }
+  module FileCache { header "Host/FileCache.h" export * }
+  module File { header "Host/File.h" export * }
+  module FileSystem { header "Host/FileSystem.h" export * }
+  module HostGetOpt { header "Host/HostGetOpt.h" export * }
+  module Host { header "Host/Host.h" export * }
+  module HostInfoBase { header "Host/HostInfoBase.h" export * }
+  module HostInfo { header "Host/HostInfo.h" export * }
+  module HostNativeProcessBase { header "Host/HostNativeProcessBase.h" export * }
+  module HostNativeProcess { header "Host/HostNativeProcess.h" export * }
+  module HostNativeThreadBase { header "Host/HostNativeThreadBase.h" export * }
+  module HostNativeThreadForward { header "Host/HostNativeThreadForward.h" export * }
+  module HostNativeThread { header "Host/HostNativeThread.h" export * }
+  module HostProcess { header "Host/HostProcess.h" export * }
+  module HostThread { header "Host/HostThread.h" export * }
+  module LockFileBase { header "Host/LockFileBase.h" export * }
+  module LockFile { header "Host/LockFile.h" export * }
+  module MainLoopBase { header "Host/MainLoopBase.h" export * }
+  module MainLoop { header "Host/MainLoop.h" export * }
+  module MonitoringProcessLauncher { header "Host/MonitoringProcessLauncher.h" export * }
+  module OptionParser { header "Host/OptionParser.h" export * }
+  module PipeBase { header "Host/PipeBase.h" export * }
+  module Pipe { header "Host/Pipe.h" export * }
+  module PosixApi { header "Host/PosixApi.h" export * }
+  module Predicate { header "Host/Predicate.h" export * }
+  module ProcessLauncher { header "Host/ProcessLauncher.h" export * }
+  module ProcessRunLock { header "Host/ProcessRunLock.h" export * }
+  module PseudoTerminal { header "Host/PseudoTerminal.h" export * }
+  module SocketAddress { header "Host/SocketAddress.h" export * }
+  module Socket { header "Host/Socket.h" export * }
+  module StringConvert { header "Host/StringConvert.h" export * }
+  module Symbols { header "Host/Symbols.h" export * }
+  module TaskPool { header "Host/TaskPool.h" export * }
+  module Terminal { header "Host/Terminal.h" export * }
+  module ThreadLauncher { header "Host/ThreadLauncher.h" export * }
+  module Time { header "Host/Time.h" export * }
+  module XML { header "Host/XML.h" export * }
+
+  export *
+}
+
+module lldb_Initialization {
+  requires cplusplus
+
+  umbrella "Initialization"
+  module * { export * }
+}
+
+// This big module is necessary to work around the cyclic dependencies
+// between its submodules.
+module lldb {
+  module Breakpoint {
+requires cplusplus
+
+umbrella "Breakpoint"
+module * { export * }
+  }
+
+  module Core {
+requires cplusplus
+
+umbrella "Core"
+module * { export * }
+  }
+
+
+  module DataFormatters {
+requires cplusplus
+
+umbrella "DataFormatters"
+module * { export * }
+  }
+
+  module Expression {
+requires cplusplus
+
+umbrella "Expression"
+module * { export * }
+// TODO: This file includes a non-public header.
+exclude header "Expression/REPL.h"
+  }
+
+  module Interpreter {
+requires cplusplus
+
+umbrella "Interpreter"
+module * { export * }
+  }
+
+  module Symbol {
+requires cplusplus
+
+umbrella "Symbol"
+module * { export * }
+  }
+  module Target {
+requires cplusplus
+
+umbrella "Target"
+module * { export * }
+  }
+}
+
+
+module lldb_Utility {
+  requires cplusplus
+
+  umbrella "Utility"
+  module * { export * }
+
+  module defines { header "lldb-defines.h" export * }
+  module enumerations { header 

[Lldb-commits] [PATCH] D48303: Don't take the address of an xvalue when printing an expr result

2018-06-18 Thread Raphael Isemann via Phabricator via lldb-commits
teemperor updated this revision to Diff 151827.
teemperor added a comment.

- Added test case


https://reviews.llvm.org/D48303

Files:
  packages/Python/lldbsuite/test/expression_command/xvalue/Makefile
  packages/Python/lldbsuite/test/expression_command/xvalue/TestXValuePrinting.py
  packages/Python/lldbsuite/test/expression_command/xvalue/main.cpp
  source/Plugins/ExpressionParser/Clang/ASTResultSynthesizer.cpp


Index: source/Plugins/ExpressionParser/Clang/ASTResultSynthesizer.cpp
===
--- source/Plugins/ExpressionParser/Clang/ASTResultSynthesizer.cpp
+++ source/Plugins/ExpressionParser/Clang/ASTResultSynthesizer.cpp
@@ -292,8 +292,7 @@
   //
   //   - During dematerialization, $0 is ignored.
 
-  bool is_lvalue = (last_expr->getValueKind() == VK_LValue ||
-last_expr->getValueKind() == VK_XValue) &&
+  bool is_lvalue = (last_expr->getValueKind() == VK_LValue) &&
(last_expr->getObjectKind() == OK_Ordinary);
 
   QualType expr_qual_type = last_expr->getType();
Index: packages/Python/lldbsuite/test/expression_command/xvalue/main.cpp
===
--- /dev/null
+++ packages/Python/lldbsuite/test/expression_command/xvalue/main.cpp
@@ -0,0 +1,14 @@
+#include 
+
+struct StringRef
+{
+  const char *data = 0;
+};
+
+StringRef foo() { return StringRef(); }
+
+int main(int argc, char const *argv[])
+{
+  const char *something = foo().data;
+  return 0; // Break here
+}
Index: 
packages/Python/lldbsuite/test/expression_command/xvalue/TestXValuePrinting.py
===
--- /dev/null
+++ 
packages/Python/lldbsuite/test/expression_command/xvalue/TestXValuePrinting.py
@@ -0,0 +1,37 @@
+from __future__ import print_function
+
+
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+
+class ExprXValuePrintingTestCase(TestBase):
+
+mydir = TestBase.compute_mydir(__file__)
+
+def setUp(self):
+# Call super's setUp().
+TestBase.setUp(self)
+
+self.main_source = "main.cpp"
+self.main_source_spec = lldb.SBFileSpec(self.main_source)
+
+def do_test(self, dictionary=None):
+"""Printing an xvalue should work."""
+self.build(dictionary=dictionary)
+
+(target, process, thread, bkpt) = 
lldbutil.run_to_source_breakpoint(self, 
+  '// Break here', 
self.main_source_spec)
+frame = thread.GetFrameAtIndex(0)
+
+value = frame.EvaluateExpression("foo().data")
+self.assertTrue(value.IsValid())
+self.assertTrue(value.GetError().Success())
+self.assertEqual(value.GetValueAsUnsigned(), 0)
+
+@expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr21765")
+def test(self):
+self.do_test()
+
Index: packages/Python/lldbsuite/test/expression_command/xvalue/Makefile
===
--- /dev/null
+++ packages/Python/lldbsuite/test/expression_command/xvalue/Makefile
@@ -0,0 +1,5 @@
+LEVEL = ../../make
+
+CXX_SOURCES := main.cpp
+
+include $(LEVEL)/Makefile.rules


Index: source/Plugins/ExpressionParser/Clang/ASTResultSynthesizer.cpp
===
--- source/Plugins/ExpressionParser/Clang/ASTResultSynthesizer.cpp
+++ source/Plugins/ExpressionParser/Clang/ASTResultSynthesizer.cpp
@@ -292,8 +292,7 @@
   //
   //   - During dematerialization, $0 is ignored.
 
-  bool is_lvalue = (last_expr->getValueKind() == VK_LValue ||
-last_expr->getValueKind() == VK_XValue) &&
+  bool is_lvalue = (last_expr->getValueKind() == VK_LValue) &&
(last_expr->getObjectKind() == OK_Ordinary);
 
   QualType expr_qual_type = last_expr->getType();
Index: packages/Python/lldbsuite/test/expression_command/xvalue/main.cpp
===
--- /dev/null
+++ packages/Python/lldbsuite/test/expression_command/xvalue/main.cpp
@@ -0,0 +1,14 @@
+#include 
+
+struct StringRef
+{
+  const char *data = 0;
+};
+
+StringRef foo() { return StringRef(); }
+
+int main(int argc, char const *argv[])
+{
+  const char *something = foo().data;
+  return 0; // Break here
+}
Index: packages/Python/lldbsuite/test/expression_command/xvalue/TestXValuePrinting.py
===
--- /dev/null
+++ packages/Python/lldbsuite/test/expression_command/xvalue/TestXValuePrinting.py
@@ -0,0 +1,37 @@
+from __future__ import print_function
+
+
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+
+class ExprXValuePrintingTestCase(TestBase):
+
+mydir = TestBase.compute_mydir(__file__)
+
+def setUp(self):
+# Call super's 

[Lldb-commits] [PATCH] D48303: Don't take the address of an xvalue when printing an expr result

2018-06-18 Thread Raphael Isemann via Phabricator via lldb-commits
teemperor created this revision.

If we have an xvalue here, we will always hit the 
`err_typecheck_invalid_lvalue_addrof` error
in 'Sema::CheckAddressOfOperand' when trying to take the address of the result. 
This patch
uses the fallback code path where we store the result in a local variable 
instead when we hit
this case.

This fixes rdar://problem/40613277


https://reviews.llvm.org/D48303

Files:
  source/Plugins/ExpressionParser/Clang/ASTResultSynthesizer.cpp


Index: source/Plugins/ExpressionParser/Clang/ASTResultSynthesizer.cpp
===
--- source/Plugins/ExpressionParser/Clang/ASTResultSynthesizer.cpp
+++ source/Plugins/ExpressionParser/Clang/ASTResultSynthesizer.cpp
@@ -292,8 +292,7 @@
   //
   //   - During dematerialization, $0 is ignored.
 
-  bool is_lvalue = (last_expr->getValueKind() == VK_LValue ||
-last_expr->getValueKind() == VK_XValue) &&
+  bool is_lvalue = (last_expr->getValueKind() == VK_LValue) &&
(last_expr->getObjectKind() == OK_Ordinary);
 
   QualType expr_qual_type = last_expr->getType();


Index: source/Plugins/ExpressionParser/Clang/ASTResultSynthesizer.cpp
===
--- source/Plugins/ExpressionParser/Clang/ASTResultSynthesizer.cpp
+++ source/Plugins/ExpressionParser/Clang/ASTResultSynthesizer.cpp
@@ -292,8 +292,7 @@
   //
   //   - During dematerialization, $0 is ignored.
 
-  bool is_lvalue = (last_expr->getValueKind() == VK_LValue ||
-last_expr->getValueKind() == VK_XValue) &&
+  bool is_lvalue = (last_expr->getValueKind() == VK_LValue) &&
(last_expr->getObjectKind() == OK_Ordinary);
 
   QualType expr_qual_type = last_expr->getType();
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D48303: Don't take the address of an xvalue when printing an expr result

2018-06-18 Thread Raphael Isemann via Phabricator via lldb-commits
teemperor planned changes to this revision.
teemperor added a comment.

- Needs a test


https://reviews.llvm.org/D48303



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


[Lldb-commits] [PATCH] D48303: Don't take the address of an xvalue when printing an expr result

2018-06-18 Thread Raphael Isemann via Phabricator via lldb-commits
teemperor updated this revision to Diff 151828.
teemperor added a comment.

- Removed now unnecessary brackets.


https://reviews.llvm.org/D48303

Files:
  packages/Python/lldbsuite/test/expression_command/xvalue/Makefile
  packages/Python/lldbsuite/test/expression_command/xvalue/TestXValuePrinting.py
  packages/Python/lldbsuite/test/expression_command/xvalue/main.cpp
  source/Plugins/ExpressionParser/Clang/ASTResultSynthesizer.cpp


Index: source/Plugins/ExpressionParser/Clang/ASTResultSynthesizer.cpp
===
--- source/Plugins/ExpressionParser/Clang/ASTResultSynthesizer.cpp
+++ source/Plugins/ExpressionParser/Clang/ASTResultSynthesizer.cpp
@@ -292,9 +292,8 @@
   //
   //   - During dematerialization, $0 is ignored.
 
-  bool is_lvalue = (last_expr->getValueKind() == VK_LValue ||
-last_expr->getValueKind() == VK_XValue) &&
-   (last_expr->getObjectKind() == OK_Ordinary);
+  bool is_lvalue = last_expr->getValueKind() == VK_LValue &&
+   last_expr->getObjectKind() == OK_Ordinary;
 
   QualType expr_qual_type = last_expr->getType();
   const clang::Type *expr_type = expr_qual_type.getTypePtr();
Index: packages/Python/lldbsuite/test/expression_command/xvalue/main.cpp
===
--- /dev/null
+++ packages/Python/lldbsuite/test/expression_command/xvalue/main.cpp
@@ -0,0 +1,14 @@
+#include 
+
+struct StringRef
+{
+  const char *data = 0;
+};
+
+StringRef foo() { return StringRef(); }
+
+int main(int argc, char const *argv[])
+{
+  const char *something = foo().data;
+  return 0; // Break here
+}
Index: 
packages/Python/lldbsuite/test/expression_command/xvalue/TestXValuePrinting.py
===
--- /dev/null
+++ 
packages/Python/lldbsuite/test/expression_command/xvalue/TestXValuePrinting.py
@@ -0,0 +1,37 @@
+from __future__ import print_function
+
+
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+
+class ExprXValuePrintingTestCase(TestBase):
+
+mydir = TestBase.compute_mydir(__file__)
+
+def setUp(self):
+# Call super's setUp().
+TestBase.setUp(self)
+
+self.main_source = "main.cpp"
+self.main_source_spec = lldb.SBFileSpec(self.main_source)
+
+def do_test(self, dictionary=None):
+"""Printing an xvalue should work."""
+self.build(dictionary=dictionary)
+
+(target, process, thread, bkpt) = 
lldbutil.run_to_source_breakpoint(self, 
+  '// Break here', 
self.main_source_spec)
+frame = thread.GetFrameAtIndex(0)
+
+value = frame.EvaluateExpression("foo().data")
+self.assertTrue(value.IsValid())
+self.assertTrue(value.GetError().Success())
+self.assertEqual(value.GetValueAsUnsigned(), 0)
+
+@expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr21765")
+def test(self):
+self.do_test()
+
Index: packages/Python/lldbsuite/test/expression_command/xvalue/Makefile
===
--- /dev/null
+++ packages/Python/lldbsuite/test/expression_command/xvalue/Makefile
@@ -0,0 +1,5 @@
+LEVEL = ../../make
+
+CXX_SOURCES := main.cpp
+
+include $(LEVEL)/Makefile.rules


Index: source/Plugins/ExpressionParser/Clang/ASTResultSynthesizer.cpp
===
--- source/Plugins/ExpressionParser/Clang/ASTResultSynthesizer.cpp
+++ source/Plugins/ExpressionParser/Clang/ASTResultSynthesizer.cpp
@@ -292,9 +292,8 @@
   //
   //   - During dematerialization, $0 is ignored.
 
-  bool is_lvalue = (last_expr->getValueKind() == VK_LValue ||
-last_expr->getValueKind() == VK_XValue) &&
-   (last_expr->getObjectKind() == OK_Ordinary);
+  bool is_lvalue = last_expr->getValueKind() == VK_LValue &&
+   last_expr->getObjectKind() == OK_Ordinary;
 
   QualType expr_qual_type = last_expr->getType();
   const clang::Type *expr_type = expr_qual_type.getTypePtr();
Index: packages/Python/lldbsuite/test/expression_command/xvalue/main.cpp
===
--- /dev/null
+++ packages/Python/lldbsuite/test/expression_command/xvalue/main.cpp
@@ -0,0 +1,14 @@
+#include 
+
+struct StringRef
+{
+  const char *data = 0;
+};
+
+StringRef foo() { return StringRef(); }
+
+int main(int argc, char const *argv[])
+{
+  const char *something = foo().data;
+  return 0; // Break here
+}
Index: packages/Python/lldbsuite/test/expression_command/xvalue/TestXValuePrinting.py
===
--- /dev/null
+++ packages/Python/lldbsuite/test/expression_command/xvalue/TestXValuePrinting.py
@@ -0,0 +1,37 @@
+from __future__ import print_function
+
+
+import lldb

[Lldb-commits] [PATCH] D48096: Disable warnings for the generated LLDB wrapper source

2018-06-12 Thread Raphael Isemann via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL334557: Disable warnings for the generated LLDB wrapper 
source (authored by teemperor, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D48096?vs=151026=151058#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D48096

Files:
  lldb/trunk/source/API/CMakeLists.txt


Index: lldb/trunk/source/API/CMakeLists.txt
===
--- lldb/trunk/source/API/CMakeLists.txt
+++ lldb/trunk/source/API/CMakeLists.txt
@@ -101,13 +101,12 @@
 Support
   )
 
-if (LLVM_ENABLE_WERROR)
-  if (MSVC)
-set_property(SOURCE ${LLDB_WRAP_PYTHON} APPEND_STRING PROPERTY 
COMPILE_FLAGS " /W0")
-  else()
-set_property(SOURCE ${LLDB_WRAP_PYTHON} APPEND_STRING PROPERTY 
COMPILE_FLAGS " -w")
-  endif()
+if (MSVC)
+  set_property(SOURCE ${LLDB_WRAP_PYTHON} APPEND_STRING PROPERTY COMPILE_FLAGS 
" /W0")
+else()
+  set_property(SOURCE ${LLDB_WRAP_PYTHON} APPEND_STRING PROPERTY COMPILE_FLAGS 
" -w")
 endif()
+
 set_source_files_properties(${LLDB_WRAP_PYTHON} PROPERTIES GENERATED 1)
 if (CLANG_CL)
   set_property(SOURCE ${LLDB_WRAP_PYTHON} APPEND_STRING


Index: lldb/trunk/source/API/CMakeLists.txt
===
--- lldb/trunk/source/API/CMakeLists.txt
+++ lldb/trunk/source/API/CMakeLists.txt
@@ -101,13 +101,12 @@
 Support
   )
 
-if (LLVM_ENABLE_WERROR)
-  if (MSVC)
-set_property(SOURCE ${LLDB_WRAP_PYTHON} APPEND_STRING PROPERTY COMPILE_FLAGS " /W0")
-  else()
-set_property(SOURCE ${LLDB_WRAP_PYTHON} APPEND_STRING PROPERTY COMPILE_FLAGS " -w")
-  endif()
+if (MSVC)
+  set_property(SOURCE ${LLDB_WRAP_PYTHON} APPEND_STRING PROPERTY COMPILE_FLAGS " /W0")
+else()
+  set_property(SOURCE ${LLDB_WRAP_PYTHON} APPEND_STRING PROPERTY COMPILE_FLAGS " -w")
 endif()
+
 set_source_files_properties(${LLDB_WRAP_PYTHON} PROPERTIES GENERATED 1)
 if (CLANG_CL)
   set_property(SOURCE ${LLDB_WRAP_PYTHON} APPEND_STRING
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D47929: Add modules support for lldb headers in include/

2018-06-12 Thread Raphael Isemann via Phabricator via lldb-commits
teemperor updated this revision to Diff 151077.
teemperor added a comment.

- The regex that removes the modules cache now actually removes the whole flag 
+ path.
- Fixed more typos.


https://reviews.llvm.org/D47929

Files:
  include/lldb/module.modulemap
  source/Host/CMakeLists.txt
  source/Host/common/Terminal.cpp
  source/Host/macosx/Host.mm
  source/Host/macosx/HostInfoMacOSX.mm
  source/Host/macosx/HostThreadMacOSX.mm
  source/Host/macosx/objcxx/CMakeLists.txt
  source/Host/macosx/objcxx/Host.mm
  source/Host/macosx/objcxx/HostInfoMacOSX.mm
  source/Host/macosx/objcxx/HostThreadMacOSX.mm
  source/Plugins/Platform/MacOSX/CMakeLists.txt
  source/Plugins/Platform/MacOSX/PlatformiOSSimulatorCoreSimulatorSupport.mm
  source/Plugins/Platform/MacOSX/objcxx/CMakeLists.txt
  
source/Plugins/Platform/MacOSX/objcxx/PlatformiOSSimulatorCoreSimulatorSupport.mm

Index: source/Plugins/Platform/MacOSX/objcxx/CMakeLists.txt
===
--- /dev/null
+++ source/Plugins/Platform/MacOSX/objcxx/CMakeLists.txt
@@ -0,0 +1,18 @@
+remove_module_flags()
+include_directories(..)
+
+add_lldb_library(lldbPluginPlatformMacOSXObjCXX
+  PlatformiOSSimulatorCoreSimulatorSupport.mm
+
+  LINK_LIBS
+lldbCore
+lldbSymbol
+lldbTarget
+lldbUtility
+${LLDB_PLUGINS}
+${EXTRA_LIBS}
+
+  LINK_COMPONENTS
+Object
+Support
+  )
Index: source/Plugins/Platform/MacOSX/CMakeLists.txt
===
--- source/Plugins/Platform/MacOSX/CMakeLists.txt
+++ source/Plugins/Platform/MacOSX/CMakeLists.txt
@@ -11,13 +11,14 @@
 list(APPEND PLUGIN_PLATFORM_MACOSX_DARWIN_ONLY_SOURCES
   PlatformAppleSimulator.cpp
   PlatformiOSSimulator.cpp
-  PlatformiOSSimulatorCoreSimulatorSupport.mm
   PlatformAppleTVSimulator.cpp
   PlatformAppleWatchSimulator.cpp
   )
 
 if(CMAKE_SYSTEM_NAME MATCHES "Darwin")
   include_directories(${LIBXML2_INCLUDE_DIR})
+  add_subdirectory(objcxx)
+  set(OBJC_LIBS "lldbPluginPlatformMacOSXObjCXX")
   list(APPEND PLUGIN_PLATFORM_MACOSX_SOURCES
 ${PLUGIN_PLATFORM_MACOSX_DARWIN_ONLY_SOURCES})
 else()
@@ -38,6 +39,7 @@
 lldbTarget
 lldbUtility
 lldbPluginPlatformPOSIX
+${OBJC_LIBS}
   LINK_COMPONENTS
 Support
 )
Index: source/Host/macosx/objcxx/CMakeLists.txt
===
--- /dev/null
+++ source/Host/macosx/objcxx/CMakeLists.txt
@@ -0,0 +1,21 @@
+
+remove_module_flags()
+include_directories(..)
+
+add_lldb_library(lldbHostMacOSXObjCXX
+  Host.mm
+  HostInfoMacOSX.mm
+  HostThreadMacOSX.mm
+
+  LINK_LIBS
+lldbCore
+lldbSymbol
+lldbTarget
+lldbUtility
+${LLDB_PLUGINS}
+${EXTRA_LIBS}
+
+  LINK_COMPONENTS
+Object
+Support
+  )
Index: source/Host/common/Terminal.cpp
===
--- source/Host/common/Terminal.cpp
+++ source/Host/common/Terminal.cpp
@@ -9,6 +9,7 @@
 
 #include "lldb/Host/Terminal.h"
 
+#include "lldb/Host/Config.h"
 #include "lldb/Host/PosixApi.h"
 #include "llvm/ADT/STLExtras.h"
 
Index: source/Host/CMakeLists.txt
===
--- source/Host/CMakeLists.txt
+++ source/Host/CMakeLists.txt
@@ -3,6 +3,18 @@
   source_group(${group} FILES ${ARGN})
 endmacro()
 
+# Removes all module flags from the current CMAKE_CXX_FLAGS. Used for
+# the Objective C++ code in lldb which we don't want to build with modules.
+# Reasons for this are that modules with Objective C++ would require that
+# all LLVM/Clang modules are Objective C++ compatible (which they are likely
+# not) and we would have rebuild a second set of modules just for the few
+# Objective C++ files in lldb (which slows down the build process).
+macro(remove_module_flags)
+  string(REGEX REPLACE "-fmodules-cache-path=[^ ]+" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
+  string(REGEX REPLACE "-fmodules" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
+  string(REGEX REPLACE "-fcxx-modules" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
+endmacro()
+
 add_host_subdirectory(common
   common/File.cpp
   common/FileCache.cpp
@@ -92,10 +104,9 @@
 
   if (CMAKE_SYSTEM_NAME MATCHES "Darwin")
 include_directories(SYSTEM ${LIBXML2_INCLUDE_DIR})
-add_host_subdirectory(macosx
-  macosx/Host.mm
-  macosx/HostInfoMacOSX.mm
-  macosx/HostThreadMacOSX.mm
+add_subdirectory(macosx/objcxx)
+set(LLDBObjCLibs lldbHostMacOSXObjCXX)
+add_host_subdirectory(maqcosx
   macosx/Symbols.cpp
   macosx/cfcpp/CFCBundle.cpp
   macosx/cfcpp/CFCData.cpp
@@ -177,15 +188,16 @@
 
 add_lldb_library(lldbHost
   ${HOST_SOURCES}
-  
+
   LINK_LIBS
 lldbCore
 lldbSymbol
 lldbTarget
 lldbUtility
 ${LLDB_PLUGINS}
 ${EXTRA_LIBS}
-  
+${LLDBObjCLibs}
+
   LINK_COMPONENTS
 Object
 Support
Index: include/lldb/module.modulemap
===
--- 

[Lldb-commits] [PATCH] D47929: Add modules support for lldb headers in include/

2018-06-12 Thread Raphael Isemann via Phabricator via lldb-commits
teemperor updated this revision to Diff 151004.
teemperor retitled this revision from "Add modulemap to lldb include directory" 
to "Add modules support for lldb headers in include/".
teemperor edited the summary of this revision.
teemperor added a comment.
This revision is now accepted and ready to land.
Herald added a subscriber: mgorny.

- All Obj-C files are now in their own subdirectory. This way we can filter out 
the modules flags for them.


https://reviews.llvm.org/D47929

Files:
  include/lldb/module.modulemap
  source/Host/CMakeLists.txt
  source/Host/common/Terminal.cpp
  source/Host/macosx/Host.mm
  source/Host/macosx/HostInfoMacOSX.mm
  source/Host/macosx/HostThreadMacOSX.mm
  source/Host/macosx/objc/CMakeLists.txt
  source/Host/macosx/objc/Host.mm
  source/Host/macosx/objc/HostInfoMacOSX.mm
  source/Host/macosx/objc/HostThreadMacOSX.mm
  source/Plugins/Platform/MacOSX/CMakeLists.txt
  source/Plugins/Platform/MacOSX/PlatformiOSSimulatorCoreSimulatorSupport.mm
  source/Plugins/Platform/MacOSX/objc/CMakeLists.txt
  
source/Plugins/Platform/MacOSX/objc/PlatformiOSSimulatorCoreSimulatorSupport.mm

Index: source/Plugins/Platform/MacOSX/objc/CMakeLists.txt
===
--- /dev/null
+++ source/Plugins/Platform/MacOSX/objc/CMakeLists.txt
@@ -0,0 +1,18 @@
+remove_module_flags()
+include_directories(..)
+
+add_lldb_library(lldbPluginPlatformMacOSXObjC
+  PlatformiOSSimulatorCoreSimulatorSupport.mm
+
+  LINK_LIBS
+lldbCore
+lldbSymbol
+lldbTarget
+lldbUtility
+${LLDB_PLUGINS}
+${EXTRA_LIBS}
+
+  LINK_COMPONENTS
+Object
+Support
+  )
Index: source/Plugins/Platform/MacOSX/CMakeLists.txt
===
--- source/Plugins/Platform/MacOSX/CMakeLists.txt
+++ source/Plugins/Platform/MacOSX/CMakeLists.txt
@@ -11,13 +11,14 @@
 list(APPEND PLUGIN_PLATFORM_MACOSX_DARWIN_ONLY_SOURCES
   PlatformAppleSimulator.cpp
   PlatformiOSSimulator.cpp
-  PlatformiOSSimulatorCoreSimulatorSupport.mm
   PlatformAppleTVSimulator.cpp
   PlatformAppleWatchSimulator.cpp
   )
 
 if(CMAKE_SYSTEM_NAME MATCHES "Darwin")
   include_directories(${LIBXML2_INCLUDE_DIR})
+  add_subdirectory(objc)
+  set(OBJC_LIBS "lldbPluginPlatformMacOSXObjC")
   list(APPEND PLUGIN_PLATFORM_MACOSX_SOURCES
 ${PLUGIN_PLATFORM_MACOSX_DARWIN_ONLY_SOURCES})
 else()
@@ -38,6 +39,7 @@
 lldbTarget
 lldbUtility
 lldbPluginPlatformPOSIX
+${OBJC_LIBS}
   LINK_COMPONENTS
 Support
 )
Index: source/Host/macosx/objc/CMakeLists.txt
===
--- /dev/null
+++ source/Host/macosx/objc/CMakeLists.txt
@@ -0,0 +1,21 @@
+
+remove_module_flags()
+include_directories(..)
+
+add_lldb_library(lldbHostMacOSXObjC
+  Host.mm
+  HostInfoMacOSX.mm
+  HostThreadMacOSX.mm
+
+  LINK_LIBS
+lldbCore
+lldbSymbol
+lldbTarget
+lldbUtility
+${LLDB_PLUGINS}
+${EXTRA_LIBS}
+
+  LINK_COMPONENTS
+Object
+Support
+  )
Index: source/Host/common/Terminal.cpp
===
--- source/Host/common/Terminal.cpp
+++ source/Host/common/Terminal.cpp
@@ -9,6 +9,7 @@
 
 #include "lldb/Host/Terminal.h"
 
+#include "lldb/Host/Config.h"
 #include "lldb/Host/PosixApi.h"
 #include "llvm/ADT/STLExtras.h"
 
Index: source/Host/CMakeLists.txt
===
--- source/Host/CMakeLists.txt
+++ source/Host/CMakeLists.txt
@@ -3,6 +3,18 @@
   source_group(${group} FILES ${ARGN})
 endmacro()
 
+# Removes all module flags from the current CMAKE_CXX_FLAGS. Used for
+# the Obj-C++ code in lldb which we don't want to build with modules.
+# Reasons for this are that modules with Obj-C++ would require that all
+# LLVM/Clang modules are Obj-C++ compatible (which they are most likely
+# not) and we would have rebuild a second set of modules just for the few
+# Obj-C++ files in lldb (which slows down the build process).
+macro(remove_module_flags)
+  string(REGEX REPLACE "-fmodules-cache-path=[\\S]*" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
+  string(REGEX REPLACE "-fmodules" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
+  string(REGEX REPLACE "-fcxx-modules" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
+endmacro()
+
 add_host_subdirectory(common
   common/File.cpp
   common/FileCache.cpp
@@ -92,10 +104,9 @@
 
   if (CMAKE_SYSTEM_NAME MATCHES "Darwin")
 include_directories(SYSTEM ${LIBXML2_INCLUDE_DIR})
-add_host_subdirectory(macosx
-  macosx/Host.mm
-  macosx/HostInfoMacOSX.mm
-  macosx/HostThreadMacOSX.mm
+add_subdirectory(macosx/objc)
+set(LLDBObjCLibs lldbHostMacOSXObjC)
+add_host_subdirectory(maqcosx
   macosx/Symbols.cpp
   macosx/cfcpp/CFCBundle.cpp
   macosx/cfcpp/CFCData.cpp
@@ -177,15 +188,16 @@
 
 add_lldb_library(lldbHost
   ${HOST_SOURCES}
-  
+
   LINK_LIBS
 lldbCore
 lldbSymbol
 lldbTarget
 lldbUtility
 

[Lldb-commits] [PATCH] D47929: Add modules support for lldb headers in include/

2018-06-12 Thread Raphael Isemann via Phabricator via lldb-commits
teemperor added inline comments.



Comment at: include/lldb/module.modulemap:66
+// This big module is necessary to work around the cyclic dependencies
+// between its submodules.
+module lldb {

teemperor wrote:
> bruno wrote:
> > Will this trick be enough for local submodules visibility mode as well? 
> From my (very limited) experience with disabled local submodule visibility I 
> would say yes, but I can't test it on my current system (compilation already 
> fails at the first LLVM module without LSV).
It seems to work!


https://reviews.llvm.org/D47929



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


[Lldb-commits] [PATCH] D47929: Add modules support for lldb headers in include/

2018-06-12 Thread Raphael Isemann via Phabricator via lldb-commits
teemperor updated this revision to Diff 151023.
teemperor added a comment.

- Obj-C -> Obj-C++


https://reviews.llvm.org/D47929

Files:
  include/lldb/module.modulemap
  source/Host/CMakeLists.txt
  source/Host/common/Terminal.cpp
  source/Host/macosx/Host.mm
  source/Host/macosx/HostInfoMacOSX.mm
  source/Host/macosx/HostThreadMacOSX.mm
  source/Host/macosx/objcxx/CMakeLists.txt
  source/Host/macosx/objcxx/Host.mm
  source/Host/macosx/objcxx/HostInfoMacOSX.mm
  source/Host/macosx/objcxx/HostThreadMacOSX.mm
  source/Plugins/Platform/MacOSX/CMakeLists.txt
  source/Plugins/Platform/MacOSX/PlatformiOSSimulatorCoreSimulatorSupport.mm
  source/Plugins/Platform/MacOSX/objcxx/CMakeLists.txt
  
source/Plugins/Platform/MacOSX/objcxx/PlatformiOSSimulatorCoreSimulatorSupport.mm

Index: source/Plugins/Platform/MacOSX/objcxx/CMakeLists.txt
===
--- /dev/null
+++ source/Plugins/Platform/MacOSX/objcxx/CMakeLists.txt
@@ -0,0 +1,18 @@
+remove_module_flags()
+include_directories(..)
+
+add_lldb_library(lldbPluginPlatformMacOSXObjCxx
+  PlatformiOSSimulatorCoreSimulatorSupport.mm
+
+  LINK_LIBS
+lldbCore
+lldbSymbol
+lldbTarget
+lldbUtility
+${LLDB_PLUGINS}
+${EXTRA_LIBS}
+
+  LINK_COMPONENTS
+Object
+Support
+  )
Index: source/Plugins/Platform/MacOSX/CMakeLists.txt
===
--- source/Plugins/Platform/MacOSX/CMakeLists.txt
+++ source/Plugins/Platform/MacOSX/CMakeLists.txt
@@ -11,13 +11,14 @@
 list(APPEND PLUGIN_PLATFORM_MACOSX_DARWIN_ONLY_SOURCES
   PlatformAppleSimulator.cpp
   PlatformiOSSimulator.cpp
-  PlatformiOSSimulatorCoreSimulatorSupport.mm
   PlatformAppleTVSimulator.cpp
   PlatformAppleWatchSimulator.cpp
   )
 
 if(CMAKE_SYSTEM_NAME MATCHES "Darwin")
   include_directories(${LIBXML2_INCLUDE_DIR})
+  add_subdirectory(objcxx)
+  set(OBJC_LIBS "lldbPluginPlatformMacOSXObjCxx")
   list(APPEND PLUGIN_PLATFORM_MACOSX_SOURCES
 ${PLUGIN_PLATFORM_MACOSX_DARWIN_ONLY_SOURCES})
 else()
@@ -38,6 +39,7 @@
 lldbTarget
 lldbUtility
 lldbPluginPlatformPOSIX
+${OBJC_LIBS}
   LINK_COMPONENTS
 Support
 )
Index: source/Host/macosx/objcxx/CMakeLists.txt
===
--- /dev/null
+++ source/Host/macosx/objcxx/CMakeLists.txt
@@ -0,0 +1,21 @@
+
+remove_module_flags()
+include_directories(..)
+
+add_lldb_library(lldbHostMacOSXObjCxx
+  Host.mm
+  HostInfoMacOSX.mm
+  HostThreadMacOSX.mm
+
+  LINK_LIBS
+lldbCore
+lldbSymbol
+lldbTarget
+lldbUtility
+${LLDB_PLUGINS}
+${EXTRA_LIBS}
+
+  LINK_COMPONENTS
+Object
+Support
+  )
Index: source/Host/common/Terminal.cpp
===
--- source/Host/common/Terminal.cpp
+++ source/Host/common/Terminal.cpp
@@ -9,6 +9,7 @@
 
 #include "lldb/Host/Terminal.h"
 
+#include "lldb/Host/Config.h"
 #include "lldb/Host/PosixApi.h"
 #include "llvm/ADT/STLExtras.h"
 
Index: source/Host/CMakeLists.txt
===
--- source/Host/CMakeLists.txt
+++ source/Host/CMakeLists.txt
@@ -3,6 +3,18 @@
   source_group(${group} FILES ${ARGN})
 endmacro()
 
+# Removes all module flags from the current CMAKE_CXX_FLAGS. Used for
+# the Obj-C++ code in lldb which we don't want to build with modules.
+# Reasons for this are that modules with Obj-C++ would require that all
+# LLVM/Clang modules are Obj-C++ compatible (which they are most likely
+# not) and we would have rebuild a second set of modules just for the few
+# Obj-C++ files in lldb (which slows down the build process).
+macro(remove_module_flags)
+  string(REGEX REPLACE "-fmodules-cache-path=[\\S]*" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
+  string(REGEX REPLACE "-fmodules" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
+  string(REGEX REPLACE "-fcxx-modules" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
+endmacro()
+
 add_host_subdirectory(common
   common/File.cpp
   common/FileCache.cpp
@@ -92,10 +104,9 @@
 
   if (CMAKE_SYSTEM_NAME MATCHES "Darwin")
 include_directories(SYSTEM ${LIBXML2_INCLUDE_DIR})
-add_host_subdirectory(macosx
-  macosx/Host.mm
-  macosx/HostInfoMacOSX.mm
-  macosx/HostThreadMacOSX.mm
+add_subdirectory(macosx/objcxx)
+set(LLDBObjCLibs lldbHostMacOSXObjCxx)
+add_host_subdirectory(maqcosx
   macosx/Symbols.cpp
   macosx/cfcpp/CFCBundle.cpp
   macosx/cfcpp/CFCData.cpp
@@ -177,15 +188,16 @@
 
 add_lldb_library(lldbHost
   ${HOST_SOURCES}
-  
+
   LINK_LIBS
 lldbCore
 lldbSymbol
 lldbTarget
 lldbUtility
 ${LLDB_PLUGINS}
 ${EXTRA_LIBS}
-  
+${LLDBObjCLibs}
+
   LINK_COMPONENTS
 Object
 Support
Index: include/lldb/module.modulemap
===
--- /dev/null
+++ include/lldb/module.modulemap
@@ -0,0 +1,139 @@
+
+module lldb_API {
+  requires cplusplus
+
+  

[Lldb-commits] [PATCH] D47411: Mute some compiler warnings in the generated python wrapper code.

2018-06-12 Thread Raphael Isemann via Phabricator via lldb-commits
teemperor abandoned this revision.
teemperor added a comment.

It seems people are also in favor of completely disabling the warnings, so that 
patch will replace this one.


https://reviews.llvm.org/D47411



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


[Lldb-commits] [PATCH] D47996: Added modulemap for lldb-mi

2018-06-12 Thread Raphael Isemann via Phabricator via lldb-commits
teemperor edited subscribers, added: lldb-commits; removed: cfe-commits.
teemperor added a comment.

- Fixed mailing list subscriber.


https://reviews.llvm.org/D47996



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


[Lldb-commits] [PATCH] D48096: Disable warnings for the generated LLDB wrapper source

2018-06-12 Thread Raphael Isemann via Phabricator via lldb-commits
teemperor created this revision.
teemperor added a reviewer: aprantl.
Herald added a subscriber: mgorny.

This source files emits all kind of compiler warnings on different platforms. 
As the source code
in the file is generated and we therefore can't actually fix the warnings, we 
might as well disable
them.


https://reviews.llvm.org/D48096

Files:
  source/API/CMakeLists.txt


Index: source/API/CMakeLists.txt
===
--- source/API/CMakeLists.txt
+++ source/API/CMakeLists.txt
@@ -101,13 +101,12 @@
 Support
   )
 
-if (LLVM_ENABLE_WERROR)
-  if (MSVC)
-set_property(SOURCE ${LLDB_WRAP_PYTHON} APPEND_STRING PROPERTY 
COMPILE_FLAGS " /W0")
-  else()
-set_property(SOURCE ${LLDB_WRAP_PYTHON} APPEND_STRING PROPERTY 
COMPILE_FLAGS " -w")
-  endif()
+if (MSVC)
+  set_property(SOURCE ${LLDB_WRAP_PYTHON} APPEND_STRING PROPERTY COMPILE_FLAGS 
" /W0")
+else()
+  set_property(SOURCE ${LLDB_WRAP_PYTHON} APPEND_STRING PROPERTY COMPILE_FLAGS 
" -w")
 endif()
+
 set_source_files_properties(${LLDB_WRAP_PYTHON} PROPERTIES GENERATED 1)
 if (CLANG_CL)
   set_property(SOURCE ${LLDB_WRAP_PYTHON} APPEND_STRING


Index: source/API/CMakeLists.txt
===
--- source/API/CMakeLists.txt
+++ source/API/CMakeLists.txt
@@ -101,13 +101,12 @@
 Support
   )
 
-if (LLVM_ENABLE_WERROR)
-  if (MSVC)
-set_property(SOURCE ${LLDB_WRAP_PYTHON} APPEND_STRING PROPERTY COMPILE_FLAGS " /W0")
-  else()
-set_property(SOURCE ${LLDB_WRAP_PYTHON} APPEND_STRING PROPERTY COMPILE_FLAGS " -w")
-  endif()
+if (MSVC)
+  set_property(SOURCE ${LLDB_WRAP_PYTHON} APPEND_STRING PROPERTY COMPILE_FLAGS " /W0")
+else()
+  set_property(SOURCE ${LLDB_WRAP_PYTHON} APPEND_STRING PROPERTY COMPILE_FLAGS " -w")
 endif()
+
 set_source_files_properties(${LLDB_WRAP_PYTHON} PROPERTIES GENERATED 1)
 if (CLANG_CL)
   set_property(SOURCE ${LLDB_WRAP_PYTHON} APPEND_STRING
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D47929: Add modules support for lldb headers in include/

2018-06-12 Thread Raphael Isemann via Phabricator via lldb-commits
teemperor updated this revision to Diff 151025.
teemperor marked an inline comment as done.
teemperor added a comment.

- Fixed a typo.


https://reviews.llvm.org/D47929

Files:
  include/lldb/module.modulemap
  source/Host/CMakeLists.txt
  source/Host/common/Terminal.cpp
  source/Host/macosx/Host.mm
  source/Host/macosx/HostInfoMacOSX.mm
  source/Host/macosx/HostThreadMacOSX.mm
  source/Host/macosx/objcxx/CMakeLists.txt
  source/Host/macosx/objcxx/Host.mm
  source/Host/macosx/objcxx/HostInfoMacOSX.mm
  source/Host/macosx/objcxx/HostThreadMacOSX.mm
  source/Plugins/Platform/MacOSX/CMakeLists.txt
  source/Plugins/Platform/MacOSX/PlatformiOSSimulatorCoreSimulatorSupport.mm
  source/Plugins/Platform/MacOSX/objcxx/CMakeLists.txt
  
source/Plugins/Platform/MacOSX/objcxx/PlatformiOSSimulatorCoreSimulatorSupport.mm

Index: source/Plugins/Platform/MacOSX/objcxx/CMakeLists.txt
===
--- /dev/null
+++ source/Plugins/Platform/MacOSX/objcxx/CMakeLists.txt
@@ -0,0 +1,18 @@
+remove_module_flags()
+include_directories(..)
+
+add_lldb_library(lldbPluginPlatformMacOSXObjCxx
+  PlatformiOSSimulatorCoreSimulatorSupport.mm
+
+  LINK_LIBS
+lldbCore
+lldbSymbol
+lldbTarget
+lldbUtility
+${LLDB_PLUGINS}
+${EXTRA_LIBS}
+
+  LINK_COMPONENTS
+Object
+Support
+  )
Index: source/Plugins/Platform/MacOSX/CMakeLists.txt
===
--- source/Plugins/Platform/MacOSX/CMakeLists.txt
+++ source/Plugins/Platform/MacOSX/CMakeLists.txt
@@ -11,13 +11,14 @@
 list(APPEND PLUGIN_PLATFORM_MACOSX_DARWIN_ONLY_SOURCES
   PlatformAppleSimulator.cpp
   PlatformiOSSimulator.cpp
-  PlatformiOSSimulatorCoreSimulatorSupport.mm
   PlatformAppleTVSimulator.cpp
   PlatformAppleWatchSimulator.cpp
   )
 
 if(CMAKE_SYSTEM_NAME MATCHES "Darwin")
   include_directories(${LIBXML2_INCLUDE_DIR})
+  add_subdirectory(objcxx)
+  set(OBJC_LIBS "lldbPluginPlatformMacOSXObjCxx")
   list(APPEND PLUGIN_PLATFORM_MACOSX_SOURCES
 ${PLUGIN_PLATFORM_MACOSX_DARWIN_ONLY_SOURCES})
 else()
@@ -38,6 +39,7 @@
 lldbTarget
 lldbUtility
 lldbPluginPlatformPOSIX
+${OBJC_LIBS}
   LINK_COMPONENTS
 Support
 )
Index: source/Host/macosx/objcxx/CMakeLists.txt
===
--- /dev/null
+++ source/Host/macosx/objcxx/CMakeLists.txt
@@ -0,0 +1,21 @@
+
+remove_module_flags()
+include_directories(..)
+
+add_lldb_library(lldbHostMacOSXObjCxx
+  Host.mm
+  HostInfoMacOSX.mm
+  HostThreadMacOSX.mm
+
+  LINK_LIBS
+lldbCore
+lldbSymbol
+lldbTarget
+lldbUtility
+${LLDB_PLUGINS}
+${EXTRA_LIBS}
+
+  LINK_COMPONENTS
+Object
+Support
+  )
Index: source/Host/common/Terminal.cpp
===
--- source/Host/common/Terminal.cpp
+++ source/Host/common/Terminal.cpp
@@ -9,6 +9,7 @@
 
 #include "lldb/Host/Terminal.h"
 
+#include "lldb/Host/Config.h"
 #include "lldb/Host/PosixApi.h"
 #include "llvm/ADT/STLExtras.h"
 
Index: source/Host/CMakeLists.txt
===
--- source/Host/CMakeLists.txt
+++ source/Host/CMakeLists.txt
@@ -3,6 +3,18 @@
   source_group(${group} FILES ${ARGN})
 endmacro()
 
+# Removes all module flags from the current CMAKE_CXX_FLAGS. Used for
+# the Obj-C++ code in lldb which we don't want to build with modules.
+# Reasons for this are that modules with Obj-C++ would require that all
+# LLVM/Clang modules are Obj-C++ compatible (which they are most likely
+# not) and we would have rebuild a second set of modules just for the few
+# Objective C++ files in lldb (which slows down the build process).
+macro(remove_module_flags)
+  string(REGEX REPLACE "-fmodules-cache-path=[\\S]*" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
+  string(REGEX REPLACE "-fmodules" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
+  string(REGEX REPLACE "-fcxx-modules" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
+endmacro()
+
 add_host_subdirectory(common
   common/File.cpp
   common/FileCache.cpp
@@ -92,10 +104,9 @@
 
   if (CMAKE_SYSTEM_NAME MATCHES "Darwin")
 include_directories(SYSTEM ${LIBXML2_INCLUDE_DIR})
-add_host_subdirectory(macosx
-  macosx/Host.mm
-  macosx/HostInfoMacOSX.mm
-  macosx/HostThreadMacOSX.mm
+add_subdirectory(macosx/objcxx)
+set(LLDBObjCLibs lldbHostMacOSXObjCxx)
+add_host_subdirectory(maqcosx
   macosx/Symbols.cpp
   macosx/cfcpp/CFCBundle.cpp
   macosx/cfcpp/CFCData.cpp
@@ -177,15 +188,16 @@
 
 add_lldb_library(lldbHost
   ${HOST_SOURCES}
-  
+
   LINK_LIBS
 lldbCore
 lldbSymbol
 lldbTarget
 lldbUtility
 ${LLDB_PLUGINS}
 ${EXTRA_LIBS}
-  
+${LLDBObjCLibs}
+
   LINK_COMPONENTS
 Object
 Support
Index: include/lldb/module.modulemap
===
--- /dev/null
+++ include/lldb/module.modulemap
@@ -0,0 +1,139 @@
+

[Lldb-commits] [PATCH] D47996: Added modulemap for lldb-mi

2018-06-12 Thread Raphael Isemann via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL334549: Added modulemap for lldb-mi (authored by teemperor, 
committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D47996?vs=150663=151033#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D47996

Files:
  lldb/trunk/tools/lldb-mi/module.modulemap


Index: lldb/trunk/tools/lldb-mi/module.modulemap
===
--- lldb/trunk/tools/lldb-mi/module.modulemap
+++ lldb/trunk/tools/lldb-mi/module.modulemap
@@ -0,0 +1,79 @@
+module lldb_mi {
+  module MICmdArgContext { header "MICmdArgContext.h" export * }
+  module MICmdArgSet { header "MICmdArgSet.h" export * }
+  module MICmdArgValBase { header "MICmdArgValBase.h" export * }
+  module MICmdArgValConsume { header "MICmdArgValConsume.h" export * }
+  module MICmdArgValFile { header "MICmdArgValFile.h" export * }
+  module MICmdArgValListBase { header "MICmdArgValListBase.h" export * }
+  module MICmdArgValListOfN { header "MICmdArgValListOfN.h" export * }
+  module MICmdArgValNumber { header "MICmdArgValNumber.h" export * }
+  module MICmdArgValOptionLong { header "MICmdArgValOptionLong.h" export * }
+  module MICmdArgValOptionShort { header "MICmdArgValOptionShort.h" export * }
+  module MICmdArgValPrintValues { header "MICmdArgValPrintValues.h" export * }
+  module MICmdArgValString { header "MICmdArgValString.h" export * }
+  module MICmdArgValThreadGrp { header "MICmdArgValThreadGrp.h" export * }
+  module MICmdBase { header "MICmdBase.h" export * }
+  module MICmdCmdBreak { header "MICmdCmdBreak.h" export * }
+  module MICmdCmdData { header "MICmdCmdData.h" export * }
+  module MICmdCmdEnviro { header "MICmdCmdEnviro.h" export * }
+  module MICmdCmdExec { header "MICmdCmdExec.h" export * }
+  module MICmdCmdFile { header "MICmdCmdFile.h" export * }
+  module MICmdCmdGdbInfo { header "MICmdCmdGdbInfo.h" export * }
+  module MICmdCmdGdbSet { header "MICmdCmdGdbSet.h" export * }
+  module MICmdCmdGdbShow { header "MICmdCmdGdbShow.h" export * }
+  module MICmdCmdGdbThread { header "MICmdCmdGdbThread.h" export * }
+  module MICmdCmd { header "MICmdCmd.h" export * }
+  module MICmdCmdMiscellanous { header "MICmdCmdMiscellanous.h" export * }
+  module MICmdCmdStack { header "MICmdCmdStack.h" export * }
+  module MICmdCmdSupportInfo { header "MICmdCmdSupportInfo.h" export * }
+  module MICmdCmdSupportList { header "MICmdCmdSupportList.h" export * }
+  module MICmdCmdSymbol { header "MICmdCmdSymbol.h" export * }
+  module MICmdCmdTarget { header "MICmdCmdTarget.h" export * }
+  module MICmdCmdThread { header "MICmdCmdThread.h" export * }
+  module MICmdCmdTrace { header "MICmdCmdTrace.h" export * }
+  module MICmdCmdVar { header "MICmdCmdVar.h" export * }
+  module MICmdCommands { header "MICmdCommands.h" export * }
+  module MICmdData { header "MICmdData.h" export * }
+  module MICmdFactory { header "MICmdFactory.h" export * }
+  module MICmdInterpreter { header "MICmdInterpreter.h" export * }
+  module MICmdInvoker { header "MICmdInvoker.h" export * }
+  module MICmdMgr { header "MICmdMgr.h" export * }
+  module MICmdMgrSetCmdDeleteCallback { header 
"MICmdMgrSetCmdDeleteCallback.h" export * }
+  module MICmnBase { header "MICmnBase.h" export * }
+  module MICmnConfig { header "MICmnConfig.h" export * }
+  module MICmnLLDBBroadcaster { header "MICmnLLDBBroadcaster.h" export * }
+  module MICmnLLDBDebugger { header "MICmnLLDBDebugger.h" export * }
+  module MICmnLLDBDebuggerHandleEvents { header 
"MICmnLLDBDebuggerHandleEvents.h" export * }
+  module MICmnLLDBDebugSessionInfo { header "MICmnLLDBDebugSessionInfo.h" 
export * }
+  module MICmnLLDBDebugSessionInfoVarObj { header 
"MICmnLLDBDebugSessionInfoVarObj.h" export * }
+  module MICmnLLDBProxySBValue { header "MICmnLLDBProxySBValue.h" export * }
+  module MICmnLLDBUtilSBValue { header "MICmnLLDBUtilSBValue.h" export * }
+  module MICmnLog { header "MICmnLog.h" export * }
+  module MICmnLogMediumFile { header "MICmnLogMediumFile.h" export * }
+  module MICmnMIOutOfBandRecord { header "MICmnMIOutOfBandRecord.h" export * }
+  module MICmnMIResultRecord { header "MICmnMIResultRecord.h" export * }
+  module MICmnMIValueConst { header "MICmnMIValueConst.h" export * }
+  module MICmnMIValue { header "MICmnMIValue.h" export * }
+  module MICmnMIValueList { header "MICmnMIValueList.h" export * }
+  module MICmnMIValueResult { header "MICmnMIValueResult.h" export * }
+  module MICmnMIValueTuple { header "MICmnMIValueTuple.h" export * }
+  module MICmnResources { header "MICmnResources.h" export * }
+  module MICmnStreamStderr { header "MICmnStreamStderr.h" export * }
+  module MICmnStreamStdin { header "MICmnStreamStdin.h" export * }
+  module MICmnStreamStdout { header "MICmnStreamStdout.h" export * }
+  module MICmnThreadMgrStd { header "MICmnThreadMgrStd.h" export * }
+  module MIDataTypes { header "MIDataTypes.h" 

[Lldb-commits] [PATCH] D47929: Add modules support for lldb headers in include/

2018-06-13 Thread Raphael Isemann via Phabricator via lldb-commits
teemperor updated this revision to Diff 151181.
teemperor added a comment.

- Finally found the one and only way to spell "Objective-C++"


https://reviews.llvm.org/D47929

Files:
  include/lldb/module.modulemap
  source/Host/CMakeLists.txt
  source/Host/common/Terminal.cpp
  source/Host/macosx/Host.mm
  source/Host/macosx/HostInfoMacOSX.mm
  source/Host/macosx/HostThreadMacOSX.mm
  source/Host/macosx/objcxx/CMakeLists.txt
  source/Host/macosx/objcxx/Host.mm
  source/Host/macosx/objcxx/HostInfoMacOSX.mm
  source/Host/macosx/objcxx/HostThreadMacOSX.mm
  source/Plugins/Platform/MacOSX/CMakeLists.txt
  source/Plugins/Platform/MacOSX/PlatformiOSSimulatorCoreSimulatorSupport.mm
  source/Plugins/Platform/MacOSX/objcxx/CMakeLists.txt
  
source/Plugins/Platform/MacOSX/objcxx/PlatformiOSSimulatorCoreSimulatorSupport.mm

Index: source/Plugins/Platform/MacOSX/objcxx/CMakeLists.txt
===
--- /dev/null
+++ source/Plugins/Platform/MacOSX/objcxx/CMakeLists.txt
@@ -0,0 +1,18 @@
+remove_module_flags()
+include_directories(..)
+
+add_lldb_library(lldbPluginPlatformMacOSXObjCXX
+  PlatformiOSSimulatorCoreSimulatorSupport.mm
+
+  LINK_LIBS
+lldbCore
+lldbSymbol
+lldbTarget
+lldbUtility
+${LLDB_PLUGINS}
+${EXTRA_LIBS}
+
+  LINK_COMPONENTS
+Object
+Support
+  )
Index: source/Plugins/Platform/MacOSX/CMakeLists.txt
===
--- source/Plugins/Platform/MacOSX/CMakeLists.txt
+++ source/Plugins/Platform/MacOSX/CMakeLists.txt
@@ -11,13 +11,14 @@
 list(APPEND PLUGIN_PLATFORM_MACOSX_DARWIN_ONLY_SOURCES
   PlatformAppleSimulator.cpp
   PlatformiOSSimulator.cpp
-  PlatformiOSSimulatorCoreSimulatorSupport.mm
   PlatformAppleTVSimulator.cpp
   PlatformAppleWatchSimulator.cpp
   )
 
 if(CMAKE_SYSTEM_NAME MATCHES "Darwin")
   include_directories(${LIBXML2_INCLUDE_DIR})
+  add_subdirectory(objcxx)
+  set(OBJC_LIBS "lldbPluginPlatformMacOSXObjCXX")
   list(APPEND PLUGIN_PLATFORM_MACOSX_SOURCES
 ${PLUGIN_PLATFORM_MACOSX_DARWIN_ONLY_SOURCES})
 else()
@@ -38,6 +39,7 @@
 lldbTarget
 lldbUtility
 lldbPluginPlatformPOSIX
+${OBJC_LIBS}
   LINK_COMPONENTS
 Support
 )
Index: source/Host/macosx/objcxx/CMakeLists.txt
===
--- /dev/null
+++ source/Host/macosx/objcxx/CMakeLists.txt
@@ -0,0 +1,21 @@
+
+remove_module_flags()
+include_directories(..)
+
+add_lldb_library(lldbHostMacOSXObjCXX
+  Host.mm
+  HostInfoMacOSX.mm
+  HostThreadMacOSX.mm
+
+  LINK_LIBS
+lldbCore
+lldbSymbol
+lldbTarget
+lldbUtility
+${LLDB_PLUGINS}
+${EXTRA_LIBS}
+
+  LINK_COMPONENTS
+Object
+Support
+  )
Index: source/Host/common/Terminal.cpp
===
--- source/Host/common/Terminal.cpp
+++ source/Host/common/Terminal.cpp
@@ -9,6 +9,7 @@
 
 #include "lldb/Host/Terminal.h"
 
+#include "lldb/Host/Config.h"
 #include "lldb/Host/PosixApi.h"
 #include "llvm/ADT/STLExtras.h"
 
Index: source/Host/CMakeLists.txt
===
--- source/Host/CMakeLists.txt
+++ source/Host/CMakeLists.txt
@@ -3,6 +3,18 @@
   source_group(${group} FILES ${ARGN})
 endmacro()
 
+# Removes all module flags from the current CMAKE_CXX_FLAGS. Used for
+# the Objective-C++ code in lldb which we don't want to build with modules.
+# Reasons for this are that modules with Objective-C++ would require that
+# all LLVM/Clang modules are Objective-C++ compatible (which they are likely
+# not) and we would have rebuild a second set of modules just for the few
+# Objective-C++ files in lldb (which slows down the build process).
+macro(remove_module_flags)
+  string(REGEX REPLACE "-fmodules-cache-path=[^ ]+" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
+  string(REGEX REPLACE "-fmodules" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
+  string(REGEX REPLACE "-fcxx-modules" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
+endmacro()
+
 add_host_subdirectory(common
   common/File.cpp
   common/FileCache.cpp
@@ -92,10 +104,9 @@
 
   if (CMAKE_SYSTEM_NAME MATCHES "Darwin")
 include_directories(SYSTEM ${LIBXML2_INCLUDE_DIR})
-add_host_subdirectory(macosx
-  macosx/Host.mm
-  macosx/HostInfoMacOSX.mm
-  macosx/HostThreadMacOSX.mm
+add_subdirectory(macosx/objcxx)
+set(LLDBObjCLibs lldbHostMacOSXObjCXX)
+add_host_subdirectory(maqcosx
   macosx/Symbols.cpp
   macosx/cfcpp/CFCBundle.cpp
   macosx/cfcpp/CFCData.cpp
@@ -177,15 +188,16 @@
 
 add_lldb_library(lldbHost
   ${HOST_SOURCES}
-  
+
   LINK_LIBS
 lldbCore
 lldbSymbol
 lldbTarget
 lldbUtility
 ${LLDB_PLUGINS}
 ${EXTRA_LIBS}
-  
+${LLDBObjCLibs}
+
   LINK_COMPONENTS
 Object
 Support
Index: include/lldb/module.modulemap
===
--- /dev/null
+++ include/lldb/module.modulemap
@@ -0,0 

[Lldb-commits] [PATCH] D47929: Add modulemap to lldb include directory

2018-06-12 Thread Raphael Isemann via Phabricator via lldb-commits
teemperor planned changes to this revision.
teemperor added a comment.

It seems the compilation fails on OS X with this modulemap (or any modulemap). 
The reason seems to be that on OS X we compile Obj-C++ as part of lldb which 
assumes that Clang/LLVM is valid Obj-C++. However, the Obj-C parsing code in 
Clang is *not* valid Obj-C++ as some parts of the code use variables named like 
`IBAction` for describing, well, `IBAction` in Obj-C.

So we either try to disable modules for the Obj-C++ code or we make Clang's 
source code Obj-C++ compatible.


https://reviews.llvm.org/D47929



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


[Lldb-commits] [PATCH] D47929: Add modulemap to lldb include directory

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

@aprantl It's good for build times and more importantly it's consistent with 
the way Clang/LLVM are naming/organizing their modules. But I actually don't 
have a strong opinion on how the modules are named/organized.

@bruno Breaking up the lldb module in the future is the plan. I'm just not sure 
when I get around to do that. But the modulemap in the current state should 
bring most of the module benefits to LLDB (build time, better code checks), so 
I just opened a review for it.

Someone else with more LLDB experience could also break the cyclic 
dependencies. The report I linked should point out quite well what exactly the 
problematic includes are, so that person wouldn't even need to enable modules 
for that.




Comment at: include/lldb/module.modulemap:66
+// This big module is necessary to work around the cyclic dependencies
+// between its submodules.
+module lldb {

bruno wrote:
> Will this trick be enough for local submodules visibility mode as well? 
From my (very limited) experience with disabled local submodule visibility I 
would say yes, but I can't test it on my current system (compilation already 
fails at the first LLVM module without LSV).


https://reviews.llvm.org/D47929



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


[Lldb-commits] [PATCH] D47929: Add modulemap to lldb include directory

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

- Removed some inconsistent white space.


https://reviews.llvm.org/D47929

Files:
  include/lldb/module.modulemap

Index: include/lldb/module.modulemap
===
--- /dev/null
+++ include/lldb/module.modulemap
@@ -0,0 +1,137 @@
+
+module lldb_API {
+  requires cplusplus
+
+  umbrella "API"
+  module * { export * }
+}
+
+module lldb_Host {
+  requires cplusplus
+
+  // Because we have OS-specific headers in Host, we just list
+  // all OS-independent headers here that will include the correct
+  // OS-specific header for us.
+  module ConnectionFileDescriptor { header "Host/ConnectionFileDescriptor.h" export * }
+  module Debug { header "Host/Debug.h" export * }
+  module Editline { header "Host/Editline.h" export * }
+  module FileCache { header "Host/FileCache.h" export * }
+  module File { header "Host/File.h" export * }
+  module FileSystem { header "Host/FileSystem.h" export * }
+  module HostGetOpt { header "Host/HostGetOpt.h" export * }
+  module Host { header "Host/Host.h" export * }
+  module HostInfoBase { header "Host/HostInfoBase.h" export * }
+  module HostInfo { header "Host/HostInfo.h" export * }
+  module HostNativeProcessBase { header "Host/HostNativeProcessBase.h" export * }
+  module HostNativeProcess { header "Host/HostNativeProcess.h" export * }
+  module HostNativeThreadBase { header "Host/HostNativeThreadBase.h" export * }
+  module HostNativeThreadForward { header "Host/HostNativeThreadForward.h" export * }
+  module HostNativeThread { header "Host/HostNativeThread.h" export * }
+  module HostProcess { header "Host/HostProcess.h" export * }
+  module HostThread { header "Host/HostThread.h" export * }
+  module LockFileBase { header "Host/LockFileBase.h" export * }
+  module LockFile { header "Host/LockFile.h" export * }
+  module MainLoopBase { header "Host/MainLoopBase.h" export * }
+  module MainLoop { header "Host/MainLoop.h" export * }
+  module MonitoringProcessLauncher { header "Host/MonitoringProcessLauncher.h" export * }
+  module OptionParser { header "Host/OptionParser.h" export * }
+  module PipeBase { header "Host/PipeBase.h" export * }
+  module Pipe { header "Host/Pipe.h" export * }
+  module PosixApi { header "Host/PosixApi.h" export * }
+  module Predicate { header "Host/Predicate.h" export * }
+  module ProcessLauncher { header "Host/ProcessLauncher.h" export * }
+  module ProcessRunLock { header "Host/ProcessRunLock.h" export * }
+  module PseudoTerminal { header "Host/PseudoTerminal.h" export * }
+  module SocketAddress { header "Host/SocketAddress.h" export * }
+  module Socket { header "Host/Socket.h" export * }
+  module StringConvert { header "Host/StringConvert.h" export * }
+  module Symbols { header "Host/Symbols.h" export * }
+  module TaskPool { header "Host/TaskPool.h" export * }
+  module Terminal { header "Host/Terminal.h" export * }
+  module ThreadLauncher { header "Host/ThreadLauncher.h" export * }
+  module Time { header "Host/Time.h" export * }
+  module XML { header "Host/XML.h" export * }
+
+  export *
+}
+
+module lldb_Initialization {
+  requires cplusplus
+
+  umbrella "Initialization"
+  module * { export * }
+}
+
+// This big module is necessary to work around the cyclic dependencies
+// between its submodules.
+module lldb {
+  module Breakpoint {
+requires cplusplus
+
+umbrella "Breakpoint"
+module * { export * }
+  }
+
+  module Core {
+requires cplusplus
+
+umbrella "Core"
+module * { export * }
+  }
+
+  module DataFormatters {
+requires cplusplus
+
+umbrella "DataFormatters"
+module * { export * }
+  }
+
+  module Expression {
+requires cplusplus
+
+umbrella "Expression"
+module * { export * }
+// TODO: This file includes a non-public header.
+exclude header "Expression/REPL.h"
+  }
+
+  module Interpreter {
+requires cplusplus
+
+umbrella "Interpreter"
+module * { export * }
+  }
+
+  module Symbol {
+requires cplusplus
+
+umbrella "Symbol"
+module * { export * }
+  }
+  module Target {
+requires cplusplus
+
+umbrella "Target"
+module * { export * }
+  }
+}
+
+module lldb_Utility {
+  requires cplusplus
+
+  umbrella "Utility"
+  module * { export * }
+
+  module defines { header "lldb-defines.h" export * }
+  module enumerations { header "lldb-enumerations.h" export * }
+  module forward { header "lldb-forward.h" export * }
+  module private_enumerations { header "lldb-private-enumerations.h" export * }
+  module private_defines { header "lldb-private-defines.h" export * }
+  module private_forward { header "lldb-private-forward.h" export * }
+  module lldb_private { header "lldb-private.h" export * }
+  module private_interfaces { header "lldb-private-interfaces.h" export * }
+  module private_types { header "lldb-private-types.h" export * }
+  module public { header "lldb-public.h" export * }
+  module types 

[Lldb-commits] [PATCH] D48339: Refactor ClangUserExpression::Parse [NFC]

2018-06-19 Thread Raphael Isemann via Phabricator via lldb-commits
teemperor created this revision.

This patch splits out functionality from the `Parse` method into different 
methods.
This benefits the code completion work (which should reuse those methods) and 
makes the
code a bit more readable.

Note that this patch is as minimal as possible. Some of the code in the new 
methods definitely
needs more refactoring.


https://reviews.llvm.org/D48339

Files:
  source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp
  source/Plugins/ExpressionParser/Clang/ClangUserExpression.h

Index: source/Plugins/ExpressionParser/Clang/ClangUserExpression.h
===
--- source/Plugins/ExpressionParser/Clang/ClangUserExpression.h
+++ source/Plugins/ExpressionParser/Clang/ClangUserExpression.h
@@ -174,6 +174,13 @@
 lldb::addr_t struct_address,
 DiagnosticManager _manager) override;
 
+  llvm::Optional GetLanguageForExpr(
+  DiagnosticManager _manager, ExecutionContext _ctx);
+  bool SetupPersistentState(DiagnosticManager _manager,
+   ExecutionContext _ctx);
+  bool PrepareForParsing(DiagnosticManager _manager,
+ ExecutionContext _ctx);
+
   ClangUserExpressionHelper m_type_system_helper;
 
   class ResultDelegate : public Materializer::PersistentVariableDelegate {
Index: source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp
===
--- source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp
+++ source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp
@@ -322,17 +322,8 @@
 };
 } // namespace
 
-bool ClangUserExpression::Parse(DiagnosticManager _manager,
-ExecutionContext _ctx,
-lldb_private::ExecutionPolicy execution_policy,
-bool keep_result_in_memory,
-bool generate_debug_info) {
-  Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS));
-
-  Status err;
-
-  InstallContext(exe_ctx);
-
+bool ClangUserExpression::SetupPersistentState(DiagnosticManager _manager,
+ ExecutionContext _ctx) {
   if (Target *target = exe_ctx.GetTargetPtr()) {
 if (PersistentExpressionState *persistent_state =
 target->GetPersistentExpressionStateForLanguage(
@@ -349,35 +340,24 @@
  "error: couldn't start parsing (no target)");
 return false;
   }
+  return true;
+}
 
-  ScanContext(exe_ctx, err);
-
-  if (!err.Success()) {
-diagnostic_manager.PutString(eDiagnosticSeverityWarning, err.AsCString());
-  }
-
-  
-  // Generate the expression
-  //
-
-  ApplyObjcCastHack(m_expr_text);
-
-  std::string prefix = m_expr_prefix;
-
+static void SetupDeclVendor(ExecutionContext _ctx, Target *target) {
   if (ClangModulesDeclVendor *decl_vendor =
-  m_target->GetClangModulesDeclVendor()) {
+  target->GetClangModulesDeclVendor()) {
 const ClangModulesDeclVendor::ModuleVector _imported_modules =
 llvm::cast(
-m_target->GetPersistentExpressionStateForLanguage(
+target->GetPersistentExpressionStateForLanguage(
 lldb::eLanguageTypeC))
 ->GetHandLoadedClangModules();
 ClangModulesDeclVendor::ModuleVector modules_for_macros;
 
 for (ClangModulesDeclVendor::ModuleID module : hand_imported_modules) {
   modules_for_macros.push_back(module);
 }
 
-if (m_target->GetEnableAutoImportClangModules()) {
+if (target->GetEnableAutoImportClangModules()) {
   if (StackFrame *frame = exe_ctx.GetFramePtr()) {
 if (Block *block = frame->GetFrameBlock()) {
   SymbolContext sc;
@@ -394,8 +374,13 @@
   }
 }
   }
+}
+
+llvm::Optional ClangUserExpression::GetLanguageForExpr(
+DiagnosticManager _manager, ExecutionContext _ctx) {
+  lldb::LanguageType lang_type = lldb::LanguageType::eLanguageTypeUnknown;
 
-  lldb::LanguageType lang_type = lldb::eLanguageTypeUnknown;
+  std::string prefix = m_expr_prefix;
 
   if (m_options.GetExecutionPolicy() == eExecutionPolicyTopLevel) {
 m_transformed_text = m_expr_text;
@@ -415,9 +400,50 @@
   exe_ctx)) {
   diagnostic_manager.PutString(eDiagnosticSeverityError,
"couldn't construct expression body");
-  return false;
+  return llvm::Optional();
 }
   }
+  return lang_type;
+}
+
+bool ClangUserExpression::PrepareForParsing(
+DiagnosticManager _manager, ExecutionContext _ctx) {
+  InstallContext(exe_ctx);
+
+  if (!SetupPersistentState(diagnostic_manager, exe_ctx))
+return false;
+
+  Status err;
+  ScanContext(exe_ctx, err);
+
+  if (!err.Success()) {
+diagnostic_manager.PutString(eDiagnosticSeverityWarning, err.AsCString());
+  }
+
+  
+  // 

[Lldb-commits] [PATCH] D48303: Don't take the address of an xvalue when printing an expr result

2018-06-19 Thread Raphael Isemann via Phabricator via lldb-commits
teemperor updated this revision to Diff 151967.
teemperor added a comment.

- Generalized test case a bit more and no longer checking only for 0.


https://reviews.llvm.org/D48303

Files:
  packages/Python/lldbsuite/test/expression_command/xvalue/Makefile
  packages/Python/lldbsuite/test/expression_command/xvalue/TestXValuePrinting.py
  packages/Python/lldbsuite/test/expression_command/xvalue/main.cpp
  source/Plugins/ExpressionParser/Clang/ASTResultSynthesizer.cpp


Index: source/Plugins/ExpressionParser/Clang/ASTResultSynthesizer.cpp
===
--- source/Plugins/ExpressionParser/Clang/ASTResultSynthesizer.cpp
+++ source/Plugins/ExpressionParser/Clang/ASTResultSynthesizer.cpp
@@ -292,9 +292,8 @@
   //
   //   - During dematerialization, $0 is ignored.
 
-  bool is_lvalue = (last_expr->getValueKind() == VK_LValue ||
-last_expr->getValueKind() == VK_XValue) &&
-   (last_expr->getObjectKind() == OK_Ordinary);
+  bool is_lvalue = last_expr->getValueKind() == VK_LValue &&
+   last_expr->getObjectKind() == OK_Ordinary;
 
   QualType expr_qual_type = last_expr->getType();
   const clang::Type *expr_type = expr_qual_type.getTypePtr();
Index: packages/Python/lldbsuite/test/expression_command/xvalue/main.cpp
===
--- /dev/null
+++ packages/Python/lldbsuite/test/expression_command/xvalue/main.cpp
@@ -0,0 +1,14 @@
+#include 
+
+struct Tmp
+{
+  int data = 1234;
+};
+
+Tmp foo() { return Tmp(); }
+
+int main(int argc, char const *argv[])
+{
+  int something = foo().data;
+  return 0; // Break here
+}
Index: 
packages/Python/lldbsuite/test/expression_command/xvalue/TestXValuePrinting.py
===
--- /dev/null
+++ 
packages/Python/lldbsuite/test/expression_command/xvalue/TestXValuePrinting.py
@@ -0,0 +1,37 @@
+from __future__ import print_function
+
+
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+
+class ExprXValuePrintingTestCase(TestBase):
+
+mydir = TestBase.compute_mydir(__file__)
+
+def setUp(self):
+# Call super's setUp().
+TestBase.setUp(self)
+
+self.main_source = "main.cpp"
+self.main_source_spec = lldb.SBFileSpec(self.main_source)
+
+def do_test(self, dictionary=None):
+"""Printing an xvalue should work."""
+self.build(dictionary=dictionary)
+
+(target, process, thread, bkpt) = 
lldbutil.run_to_source_breakpoint(self, 
+  '// Break here', 
self.main_source_spec)
+frame = thread.GetFrameAtIndex(0)
+
+value = frame.EvaluateExpression("foo().data")
+self.assertTrue(value.IsValid())
+self.assertTrue(value.GetError().Success())
+self.assertEqual(value.GetValueAsSigned(), 1234)
+
+@expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr21765")
+def test(self):
+self.do_test()
+
Index: packages/Python/lldbsuite/test/expression_command/xvalue/Makefile
===
--- /dev/null
+++ packages/Python/lldbsuite/test/expression_command/xvalue/Makefile
@@ -0,0 +1,5 @@
+LEVEL = ../../make
+
+CXX_SOURCES := main.cpp
+
+include $(LEVEL)/Makefile.rules


Index: source/Plugins/ExpressionParser/Clang/ASTResultSynthesizer.cpp
===
--- source/Plugins/ExpressionParser/Clang/ASTResultSynthesizer.cpp
+++ source/Plugins/ExpressionParser/Clang/ASTResultSynthesizer.cpp
@@ -292,9 +292,8 @@
   //
   //   - During dematerialization, $0 is ignored.
 
-  bool is_lvalue = (last_expr->getValueKind() == VK_LValue ||
-last_expr->getValueKind() == VK_XValue) &&
-   (last_expr->getObjectKind() == OK_Ordinary);
+  bool is_lvalue = last_expr->getValueKind() == VK_LValue &&
+   last_expr->getObjectKind() == OK_Ordinary;
 
   QualType expr_qual_type = last_expr->getType();
   const clang::Type *expr_type = expr_qual_type.getTypePtr();
Index: packages/Python/lldbsuite/test/expression_command/xvalue/main.cpp
===
--- /dev/null
+++ packages/Python/lldbsuite/test/expression_command/xvalue/main.cpp
@@ -0,0 +1,14 @@
+#include 
+
+struct Tmp
+{
+  int data = 1234;
+};
+
+Tmp foo() { return Tmp(); }
+
+int main(int argc, char const *argv[])
+{
+  int something = foo().data;
+  return 0; // Break here
+}
Index: packages/Python/lldbsuite/test/expression_command/xvalue/TestXValuePrinting.py
===
--- /dev/null
+++ packages/Python/lldbsuite/test/expression_command/xvalue/TestXValuePrinting.py
@@ -0,0 +1,37 @@
+from __future__ import print_function
+
+
+import lldb
+from 

[Lldb-commits] [PATCH] D48337: Refactor OnExit utility class in ClangUserExpression

2018-06-19 Thread Raphael Isemann via Phabricator via lldb-commits
teemperor created this revision.

OnExit ensures we call `ResetDeclMap` before this method ends. However,
we also have a few manual calls to ResetDeclMap in there that are actually 
unnecessary
because of this (calling the method multiple times has no effect). This patch 
also moves
the class out of the method that we can reuse it for the upcoming method that 
handles
parsing for completion.


https://reviews.llvm.org/D48337

Files:
  source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp


Index: source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp
===
--- source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp
+++ source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp
@@ -307,6 +307,21 @@
 #undef OBJC_CAST_HACK_FROM
 }
 
+namespace {
+// Utility guard that calls a callback when going out of scope.
+class OnExit {
+public:
+  typedef std::function Callback;
+
+  OnExit(Callback const ) : m_callback(callback) {}
+
+  ~OnExit() { m_callback(); }
+
+private:
+  Callback m_callback;
+};
+} // namespace
+
 bool ClangUserExpression::Parse(DiagnosticManager _manager,
 ExecutionContext _ctx,
 lldb_private::ExecutionPolicy execution_policy,
@@ -426,28 +441,12 @@
 
   ResetDeclMap(exe_ctx, m_result_delegate, keep_result_in_memory);
 
-  class OnExit {
-  public:
-typedef std::function Callback;
-
-OnExit(Callback const ) : m_callback(callback) {}
-
-~OnExit() { m_callback(); }
-
-  private:
-Callback m_callback;
-  };
-
   OnExit on_exit([this]() { ResetDeclMap(); });
 
   if (!DeclMap()->WillParse(exe_ctx, m_materializer_ap.get())) {
 diagnostic_manager.PutString(
 eDiagnosticSeverityError,
 "current process state is unsuitable for expression parsing");
-
-ResetDeclMap(); // We are being careful here in the case of breakpoint
-// conditions.
-
 return false;
   }
 
@@ -484,10 +483,6 @@
   fixed_expression.substr(fixed_start, fixed_end - fixed_start);
   }
 }
-
-ResetDeclMap(); // We are being careful here in the case of breakpoint
-// conditions.
-
 return false;
   }
 
@@ -565,10 +560,6 @@
 }
   }
 
-  ResetDeclMap(); // Make this go away since we don't need any of its state
-  // after parsing.  This also gets rid of any
-  // ClangASTImporter::Minions.
-
   if (process && m_jit_start_addr != LLDB_INVALID_ADDRESS)
 m_jit_process_wp = lldb::ProcessWP(process->shared_from_this());
   return true;


Index: source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp
===
--- source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp
+++ source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp
@@ -307,6 +307,21 @@
 #undef OBJC_CAST_HACK_FROM
 }
 
+namespace {
+// Utility guard that calls a callback when going out of scope.
+class OnExit {
+public:
+  typedef std::function Callback;
+
+  OnExit(Callback const ) : m_callback(callback) {}
+
+  ~OnExit() { m_callback(); }
+
+private:
+  Callback m_callback;
+};
+} // namespace
+
 bool ClangUserExpression::Parse(DiagnosticManager _manager,
 ExecutionContext _ctx,
 lldb_private::ExecutionPolicy execution_policy,
@@ -426,28 +441,12 @@
 
   ResetDeclMap(exe_ctx, m_result_delegate, keep_result_in_memory);
 
-  class OnExit {
-  public:
-typedef std::function Callback;
-
-OnExit(Callback const ) : m_callback(callback) {}
-
-~OnExit() { m_callback(); }
-
-  private:
-Callback m_callback;
-  };
-
   OnExit on_exit([this]() { ResetDeclMap(); });
 
   if (!DeclMap()->WillParse(exe_ctx, m_materializer_ap.get())) {
 diagnostic_manager.PutString(
 eDiagnosticSeverityError,
 "current process state is unsuitable for expression parsing");
-
-ResetDeclMap(); // We are being careful here in the case of breakpoint
-// conditions.
-
 return false;
   }
 
@@ -484,10 +483,6 @@
   fixed_expression.substr(fixed_start, fixed_end - fixed_start);
   }
 }
-
-ResetDeclMap(); // We are being careful here in the case of breakpoint
-// conditions.
-
 return false;
   }
 
@@ -565,10 +560,6 @@
 }
   }
 
-  ResetDeclMap(); // Make this go away since we don't need any of its state
-  // after parsing.  This also gets rid of any
-  // ClangASTImporter::Minions.
-
   if (process && m_jit_start_addr != LLDB_INVALID_ADDRESS)
 m_jit_process_wp = lldb::ProcessWP(process->shared_from_this());
   return true;
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D48337: Refactor OnExit utility class in ClangUserExpression

2018-06-19 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 rL335078: Refactor OnExit utility class in ClangUserExpression 
(authored by teemperor, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D48337?vs=151978=151980#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D48337

Files:
  lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp


Index: lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp
===
--- lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp
+++ lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp
@@ -307,6 +307,21 @@
 #undef OBJC_CAST_HACK_FROM
 }
 
+namespace {
+// Utility guard that calls a callback when going out of scope.
+class OnExit {
+public:
+  typedef std::function Callback;
+
+  OnExit(Callback const ) : m_callback(callback) {}
+
+  ~OnExit() { m_callback(); }
+
+private:
+  Callback m_callback;
+};
+} // namespace
+
 bool ClangUserExpression::Parse(DiagnosticManager _manager,
 ExecutionContext _ctx,
 lldb_private::ExecutionPolicy execution_policy,
@@ -426,28 +441,12 @@
 
   ResetDeclMap(exe_ctx, m_result_delegate, keep_result_in_memory);
 
-  class OnExit {
-  public:
-typedef std::function Callback;
-
-OnExit(Callback const ) : m_callback(callback) {}
-
-~OnExit() { m_callback(); }
-
-  private:
-Callback m_callback;
-  };
-
   OnExit on_exit([this]() { ResetDeclMap(); });
 
   if (!DeclMap()->WillParse(exe_ctx, m_materializer_ap.get())) {
 diagnostic_manager.PutString(
 eDiagnosticSeverityError,
 "current process state is unsuitable for expression parsing");
-
-ResetDeclMap(); // We are being careful here in the case of breakpoint
-// conditions.
-
 return false;
   }
 
@@ -484,10 +483,6 @@
   fixed_expression.substr(fixed_start, fixed_end - fixed_start);
   }
 }
-
-ResetDeclMap(); // We are being careful here in the case of breakpoint
-// conditions.
-
 return false;
   }
 
@@ -565,10 +560,6 @@
 }
   }
 
-  ResetDeclMap(); // Make this go away since we don't need any of its state
-  // after parsing.  This also gets rid of any
-  // ClangASTImporter::Minions.
-
   if (process && m_jit_start_addr != LLDB_INVALID_ADDRESS)
 m_jit_process_wp = lldb::ProcessWP(process->shared_from_this());
   return true;


Index: lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp
===
--- lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp
+++ lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp
@@ -307,6 +307,21 @@
 #undef OBJC_CAST_HACK_FROM
 }
 
+namespace {
+// Utility guard that calls a callback when going out of scope.
+class OnExit {
+public:
+  typedef std::function Callback;
+
+  OnExit(Callback const ) : m_callback(callback) {}
+
+  ~OnExit() { m_callback(); }
+
+private:
+  Callback m_callback;
+};
+} // namespace
+
 bool ClangUserExpression::Parse(DiagnosticManager _manager,
 ExecutionContext _ctx,
 lldb_private::ExecutionPolicy execution_policy,
@@ -426,28 +441,12 @@
 
   ResetDeclMap(exe_ctx, m_result_delegate, keep_result_in_memory);
 
-  class OnExit {
-  public:
-typedef std::function Callback;
-
-OnExit(Callback const ) : m_callback(callback) {}
-
-~OnExit() { m_callback(); }
-
-  private:
-Callback m_callback;
-  };
-
   OnExit on_exit([this]() { ResetDeclMap(); });
 
   if (!DeclMap()->WillParse(exe_ctx, m_materializer_ap.get())) {
 diagnostic_manager.PutString(
 eDiagnosticSeverityError,
 "current process state is unsuitable for expression parsing");
-
-ResetDeclMap(); // We are being careful here in the case of breakpoint
-// conditions.
-
 return false;
   }
 
@@ -484,10 +483,6 @@
   fixed_expression.substr(fixed_start, fixed_end - fixed_start);
   }
 }
-
-ResetDeclMap(); // We are being careful here in the case of breakpoint
-// conditions.
-
 return false;
   }
 
@@ -565,10 +560,6 @@
 }
   }
 
-  ResetDeclMap(); // Make this go away since we don't need any of its state
-  // after parsing.  This also gets rid of any
-  // ClangASTImporter::Minions.
-
   if (process && m_jit_start_addr != LLDB_INVALID_ADDRESS)
 m_jit_process_wp = lldb::ProcessWP(process->shared_from_this());
   return true;
___
lldb-commits mailing list
lldb-commits@lists.llvm.org

[Lldb-commits] [PATCH] D47923: Added missing include to LoadedModuleInfoList.h

2018-06-07 Thread Raphael Isemann via Phabricator via lldb-commits
teemperor created this revision.

https://reviews.llvm.org/D47923

Files:
  include/lldb/Core/LoadedModuleInfoList.h


Index: include/lldb/Core/LoadedModuleInfoList.h
===
--- include/lldb/Core/LoadedModuleInfoList.h
+++ include/lldb/Core/LoadedModuleInfoList.h
@@ -14,6 +14,7 @@
 
 // C++ Includes
 #include 
+#include 
 #include 
 
 // Other libraries and framework includes


Index: include/lldb/Core/LoadedModuleInfoList.h
===
--- include/lldb/Core/LoadedModuleInfoList.h
+++ include/lldb/Core/LoadedModuleInfoList.h
@@ -14,6 +14,7 @@
 
 // C++ Includes
 #include 
+#include 
 #include 
 
 // Other libraries and framework includes
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D47923: Added missing include to LoadedModuleInfoList.h

2018-06-07 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 rL334259: Added missing include to LoadedModuleInfoList.h 
(authored by teemperor, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D47923?vs=150441=150442#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D47923

Files:
  lldb/trunk/include/lldb/Core/LoadedModuleInfoList.h


Index: lldb/trunk/include/lldb/Core/LoadedModuleInfoList.h
===
--- lldb/trunk/include/lldb/Core/LoadedModuleInfoList.h
+++ lldb/trunk/include/lldb/Core/LoadedModuleInfoList.h
@@ -14,6 +14,7 @@
 
 // C++ Includes
 #include 
+#include 
 #include 
 
 // Other libraries and framework includes


Index: lldb/trunk/include/lldb/Core/LoadedModuleInfoList.h
===
--- lldb/trunk/include/lldb/Core/LoadedModuleInfoList.h
+++ lldb/trunk/include/lldb/Core/LoadedModuleInfoList.h
@@ -14,6 +14,7 @@
 
 // C++ Includes
 #include 
+#include 
 #include 
 
 // Other libraries and framework includes
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D47410: Don't include headers from inside a namespace in MIUtilSingletonHelper.h

2018-05-26 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 rL43: Dont include headers from inside a namespace 
in MIUtilSingletonHelper.h (authored by teemperor, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D47410?vs=148716=148717#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D47410

Files:
  lldb/trunk/tools/lldb-mi/MIUtilSingletonHelper.h


Index: lldb/trunk/tools/lldb-mi/MIUtilSingletonHelper.h
===
--- lldb/trunk/tools/lldb-mi/MIUtilSingletonHelper.h
+++ lldb/trunk/tools/lldb-mi/MIUtilSingletonHelper.h
@@ -9,12 +9,12 @@
 
 #pragma once
 
-namespace MI {
-
 // In house headers:
 #include "MICmnResources.h"
 #include "MIUtilString.h"
 
+namespace MI {
+
 //++
 //
 // Details: Short cut helper function to simplify repeated initialisation of


Index: lldb/trunk/tools/lldb-mi/MIUtilSingletonHelper.h
===
--- lldb/trunk/tools/lldb-mi/MIUtilSingletonHelper.h
+++ lldb/trunk/tools/lldb-mi/MIUtilSingletonHelper.h
@@ -9,12 +9,12 @@
 
 #pragma once
 
-namespace MI {
-
 // In house headers:
 #include "MICmnResources.h"
 #include "MIUtilString.h"
 
+namespace MI {
+
 //++
 //
 // Details: Short cut helper function to simplify repeated initialisation of
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D47411: Mute some compiler warnings in the generated python wrapper code.

2018-05-26 Thread Raphael Isemann via Phabricator via lldb-commits
teemperor created this revision.
teemperor added a reviewer: zturner.
Herald added a subscriber: mgorny.

With SWIG 3.0.12 I get the following compiler warnings when compiling LLDB:

  tools/lldb/scripts/LLDBWrapPython.cpp:23699:52: warning: format string is not 
a string literal (potentially insecure) [-Wformat-security]
  result = (int)(arg1)->SetErrorStringWithFormat((char const *)arg2);
 ^ 
  tools/lldb/scripts/LLDBWrapPython.cpp:23699:52: note: treat the string as an 
argument to avoid this
  result = (int)(arg1)->SetErrorStringWithFormat((char const *)arg2);
 ^
 "%s", 
  tools/lldb/scripts/LLDBWrapPython.cpp:52418:21: warning: comparison of 
integers of different signs: 'int' and 'uint32_t' (aka 'unsigned int') 
[-Wsign-compare]
for (i = 0; i < arg3; i++) {
~ ^ 
  tools/lldb/scripts/LLDBWrapPython.cpp:52510:21: warning: comparison of 
integers of different signs: 'int' and 'uint32_t' (aka 'unsigned int') 
[-Wsign-compare]
for (i = 0; i < arg3; i++) {
~ ^ 
  tools/lldb/scripts/LLDBWrapPython.cpp:52611:21: warning: comparison of 
integers of different signs: 'int' and 'uint32_t' (aka 'unsigned int') 
[-Wsign-compare]
for (i = 0; i < arg3; i++) {
~ ^ 

As the code is anyway generated we probably should disable those two warnings 
for the source file.


https://reviews.llvm.org/D47411

Files:
  source/API/CMakeLists.txt


Index: source/API/CMakeLists.txt
===
--- source/API/CMakeLists.txt
+++ source/API/CMakeLists.txt
@@ -108,6 +108,12 @@
 set_property(SOURCE ${LLDB_WRAP_PYTHON} APPEND_STRING PROPERTY 
COMPILE_FLAGS " -w")
   endif()
 endif()
+
+if (NOT MSVC)
+  # The generated code triggers some compiler warnings that we can ignore.
+  set_property(SOURCE ${LLDB_WRAP_PYTHON} APPEND_STRING PROPERTY COMPILE_FLAGS 
" -Wno-sign-compare -Wno-format-security")
+endif()
+
 set_source_files_properties(${LLDB_WRAP_PYTHON} PROPERTIES GENERATED 1)
 if (CLANG_CL)
   set_property(SOURCE ${LLDB_WRAP_PYTHON} APPEND_STRING


Index: source/API/CMakeLists.txt
===
--- source/API/CMakeLists.txt
+++ source/API/CMakeLists.txt
@@ -108,6 +108,12 @@
 set_property(SOURCE ${LLDB_WRAP_PYTHON} APPEND_STRING PROPERTY COMPILE_FLAGS " -w")
   endif()
 endif()
+
+if (NOT MSVC)
+  # The generated code triggers some compiler warnings that we can ignore.
+  set_property(SOURCE ${LLDB_WRAP_PYTHON} APPEND_STRING PROPERTY COMPILE_FLAGS " -Wno-sign-compare -Wno-format-security")
+endif()
+
 set_source_files_properties(${LLDB_WRAP_PYTHON} PROPERTIES GENERATED 1)
 if (CLANG_CL)
   set_property(SOURCE ${LLDB_WRAP_PYTHON} APPEND_STRING
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D47409: Forward declare DumpValueObjectOptions in ValueObject.h

2018-05-26 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 rL42: Forward declare DumpValueObjectOptions in 
ValueObject.h (authored by teemperor, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D47409?vs=148714=148715#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D47409

Files:
  lldb/trunk/include/lldb/Core/ValueObject.h
  lldb/trunk/source/Core/ValueObject.cpp


Index: lldb/trunk/include/lldb/Core/ValueObject.h
===
--- lldb/trunk/include/lldb/Core/ValueObject.h
+++ lldb/trunk/include/lldb/Core/ValueObject.h
@@ -11,7 +11,6 @@
 #define liblldb_ValueObject_h_
 
 #include "lldb/Core/Value.h"
-#include "lldb/DataFormatters/DumpValueObjectOptions.h" // for DumpValueObj...
 #include "lldb/Symbol/CompilerType.h"
 #include "lldb/Symbol/Type.h" // for TypeImpl
 #include "lldb/Target/ExecutionContext.h"
@@ -45,6 +44,9 @@
 class Declaration;
 }
 namespace lldb_private {
+class DumpValueObjectOptions;
+}
+namespace lldb_private {
 class EvaluateExpressionOptions;
 }
 namespace lldb_private {
Index: lldb/trunk/source/Core/ValueObject.cpp
===
--- lldb/trunk/source/Core/ValueObject.cpp
+++ lldb/trunk/source/Core/ValueObject.cpp
@@ -19,6 +19,7 @@
 #include "lldb/Core/ValueObjectMemory.h"
 #include "lldb/Core/ValueObjectSyntheticFilter.h"
 #include "lldb/DataFormatters/DataVisualization.h"
+#include "lldb/DataFormatters/DumpValueObjectOptions.h" // for DumpValueObj...
 #include "lldb/DataFormatters/FormatManager.h" // for FormatManager
 #include "lldb/DataFormatters/StringPrinter.h"
 #include "lldb/DataFormatters/TypeFormat.h"// for TypeFormatImpl_F...


Index: lldb/trunk/include/lldb/Core/ValueObject.h
===
--- lldb/trunk/include/lldb/Core/ValueObject.h
+++ lldb/trunk/include/lldb/Core/ValueObject.h
@@ -11,7 +11,6 @@
 #define liblldb_ValueObject_h_
 
 #include "lldb/Core/Value.h"
-#include "lldb/DataFormatters/DumpValueObjectOptions.h" // for DumpValueObj...
 #include "lldb/Symbol/CompilerType.h"
 #include "lldb/Symbol/Type.h" // for TypeImpl
 #include "lldb/Target/ExecutionContext.h"
@@ -45,6 +44,9 @@
 class Declaration;
 }
 namespace lldb_private {
+class DumpValueObjectOptions;
+}
+namespace lldb_private {
 class EvaluateExpressionOptions;
 }
 namespace lldb_private {
Index: lldb/trunk/source/Core/ValueObject.cpp
===
--- lldb/trunk/source/Core/ValueObject.cpp
+++ lldb/trunk/source/Core/ValueObject.cpp
@@ -19,6 +19,7 @@
 #include "lldb/Core/ValueObjectMemory.h"
 #include "lldb/Core/ValueObjectSyntheticFilter.h"
 #include "lldb/DataFormatters/DataVisualization.h"
+#include "lldb/DataFormatters/DumpValueObjectOptions.h" // for DumpValueObj...
 #include "lldb/DataFormatters/FormatManager.h" // for FormatManager
 #include "lldb/DataFormatters/StringPrinter.h"
 #include "lldb/DataFormatters/TypeFormat.h"// for TypeFormatImpl_F...
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D47412: Add missing includes to some LLDB headers.

2018-05-26 Thread Raphael Isemann via Phabricator via lldb-commits
teemperor created this revision.
Herald added a subscriber: ki.stfu.

When compiling with modules, these missing includes cause the build to fail (as 
the header can't be compiled into a module).


https://reviews.llvm.org/D47412

Files:
  source/Plugins/DynamicLoader/Hexagon-DYLD/HexagonDYLDRendezvous.h
  source/Plugins/Process/Utility/InstructionUtils.h
  source/Plugins/Process/Utility/UnwindLLDB.h
  tools/lldb-mi/MICmnLLDBDebuggerHandleEvents.h


Index: tools/lldb-mi/MICmnLLDBDebuggerHandleEvents.h
===
--- tools/lldb-mi/MICmnLLDBDebuggerHandleEvents.h
+++ tools/lldb-mi/MICmnLLDBDebuggerHandleEvents.h
@@ -14,6 +14,7 @@
 #include "MICmnMIValueList.h"
 #include "MICmnMIValueTuple.h"
 #include "MIUtilSingletonBase.h"
+#include "lldb/API/SBEvent.h"
 
 // Declarations:
 class CMICmnLLDBDebugSessionInfo;
Index: source/Plugins/Process/Utility/UnwindLLDB.h
===
--- source/Plugins/Process/Utility/UnwindLLDB.h
+++ source/Plugins/Process/Utility/UnwindLLDB.h
@@ -17,6 +17,7 @@
 // Other libraries and framework includes
 // Project includes
 #include "lldb/Symbol/FuncUnwinders.h"
+#include "lldb/Symbol/SymbolContext.h"
 #include "lldb/Symbol/UnwindPlan.h"
 #include "lldb/Target/RegisterContext.h"
 #include "lldb/Target/Unwind.h"
Index: source/Plugins/Process/Utility/InstructionUtils.h
===
--- source/Plugins/Process/Utility/InstructionUtils.h
+++ source/Plugins/Process/Utility/InstructionUtils.h
@@ -10,6 +10,9 @@
 #ifndef lldb_InstructionUtils_h_
 #define lldb_InstructionUtils_h_
 
+#include 
+#include 
+
 // Common utilities for manipulating instruction bit fields.
 
 namespace lldb_private {
Index: source/Plugins/DynamicLoader/Hexagon-DYLD/HexagonDYLDRendezvous.h
===
--- source/Plugins/DynamicLoader/Hexagon-DYLD/HexagonDYLDRendezvous.h
+++ source/Plugins/DynamicLoader/Hexagon-DYLD/HexagonDYLDRendezvous.h
@@ -11,8 +11,10 @@
 #define liblldb_HexagonDYLDRendezvous_H_
 
 // C Includes
+#include  // for PATH_MAX
 // C++ Includes
 #include 
+#include 
 #include 
 
 // Other libraries and framework includes


Index: tools/lldb-mi/MICmnLLDBDebuggerHandleEvents.h
===
--- tools/lldb-mi/MICmnLLDBDebuggerHandleEvents.h
+++ tools/lldb-mi/MICmnLLDBDebuggerHandleEvents.h
@@ -14,6 +14,7 @@
 #include "MICmnMIValueList.h"
 #include "MICmnMIValueTuple.h"
 #include "MIUtilSingletonBase.h"
+#include "lldb/API/SBEvent.h"
 
 // Declarations:
 class CMICmnLLDBDebugSessionInfo;
Index: source/Plugins/Process/Utility/UnwindLLDB.h
===
--- source/Plugins/Process/Utility/UnwindLLDB.h
+++ source/Plugins/Process/Utility/UnwindLLDB.h
@@ -17,6 +17,7 @@
 // Other libraries and framework includes
 // Project includes
 #include "lldb/Symbol/FuncUnwinders.h"
+#include "lldb/Symbol/SymbolContext.h"
 #include "lldb/Symbol/UnwindPlan.h"
 #include "lldb/Target/RegisterContext.h"
 #include "lldb/Target/Unwind.h"
Index: source/Plugins/Process/Utility/InstructionUtils.h
===
--- source/Plugins/Process/Utility/InstructionUtils.h
+++ source/Plugins/Process/Utility/InstructionUtils.h
@@ -10,6 +10,9 @@
 #ifndef lldb_InstructionUtils_h_
 #define lldb_InstructionUtils_h_
 
+#include 
+#include 
+
 // Common utilities for manipulating instruction bit fields.
 
 namespace lldb_private {
Index: source/Plugins/DynamicLoader/Hexagon-DYLD/HexagonDYLDRendezvous.h
===
--- source/Plugins/DynamicLoader/Hexagon-DYLD/HexagonDYLDRendezvous.h
+++ source/Plugins/DynamicLoader/Hexagon-DYLD/HexagonDYLDRendezvous.h
@@ -11,8 +11,10 @@
 #define liblldb_HexagonDYLDRendezvous_H_
 
 // C Includes
+#include  // for PATH_MAX
 // C++ Includes
 #include 
+#include 
 #include 
 
 // Other libraries and framework includes
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D47409: Forward declare DumpValueObjectOptions in ValueObject.h

2018-05-26 Thread Raphael Isemann via Phabricator via lldb-commits
teemperor created this revision.

This resolves unnecessary the header dependency from Core to DataFormatters. 
Patch is necessary for the introduction of C++ modules to the LLDB build system.


https://reviews.llvm.org/D47409

Files:
  include/lldb/Core/ValueObject.h
  source/Core/ValueObject.cpp


Index: source/Core/ValueObject.cpp
===
--- source/Core/ValueObject.cpp
+++ source/Core/ValueObject.cpp
@@ -19,6 +19,7 @@
 #include "lldb/Core/ValueObjectMemory.h"
 #include "lldb/Core/ValueObjectSyntheticFilter.h"
 #include "lldb/DataFormatters/DataVisualization.h"
+#include "lldb/DataFormatters/DumpValueObjectOptions.h" // for DumpValueObj...
 #include "lldb/DataFormatters/FormatManager.h" // for FormatManager
 #include "lldb/DataFormatters/StringPrinter.h"
 #include "lldb/DataFormatters/TypeFormat.h"// for TypeFormatImpl_F...
Index: include/lldb/Core/ValueObject.h
===
--- include/lldb/Core/ValueObject.h
+++ include/lldb/Core/ValueObject.h
@@ -11,7 +11,6 @@
 #define liblldb_ValueObject_h_
 
 #include "lldb/Core/Value.h"
-#include "lldb/DataFormatters/DumpValueObjectOptions.h" // for DumpValueObj...
 #include "lldb/Symbol/CompilerType.h"
 #include "lldb/Symbol/Type.h" // for TypeImpl
 #include "lldb/Target/ExecutionContext.h"
@@ -45,6 +44,9 @@
 class Declaration;
 }
 namespace lldb_private {
+class DumpValueObjectOptions;
+}
+namespace lldb_private {
 class EvaluateExpressionOptions;
 }
 namespace lldb_private {


Index: source/Core/ValueObject.cpp
===
--- source/Core/ValueObject.cpp
+++ source/Core/ValueObject.cpp
@@ -19,6 +19,7 @@
 #include "lldb/Core/ValueObjectMemory.h"
 #include "lldb/Core/ValueObjectSyntheticFilter.h"
 #include "lldb/DataFormatters/DataVisualization.h"
+#include "lldb/DataFormatters/DumpValueObjectOptions.h" // for DumpValueObj...
 #include "lldb/DataFormatters/FormatManager.h" // for FormatManager
 #include "lldb/DataFormatters/StringPrinter.h"
 #include "lldb/DataFormatters/TypeFormat.h"// for TypeFormatImpl_F...
Index: include/lldb/Core/ValueObject.h
===
--- include/lldb/Core/ValueObject.h
+++ include/lldb/Core/ValueObject.h
@@ -11,7 +11,6 @@
 #define liblldb_ValueObject_h_
 
 #include "lldb/Core/Value.h"
-#include "lldb/DataFormatters/DumpValueObjectOptions.h" // for DumpValueObj...
 #include "lldb/Symbol/CompilerType.h"
 #include "lldb/Symbol/Type.h" // for TypeImpl
 #include "lldb/Target/ExecutionContext.h"
@@ -45,6 +44,9 @@
 class Declaration;
 }
 namespace lldb_private {
+class DumpValueObjectOptions;
+}
+namespace lldb_private {
 class EvaluateExpressionOptions;
 }
 namespace lldb_private {
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D47412: Add missing includes to some LLDB headers.

2018-05-26 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 rL45: Add missing includes to some LLDB headers. (authored 
by teemperor, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D47412?vs=148721=148722#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D47412

Files:
  lldb/trunk/source/Plugins/DynamicLoader/Hexagon-DYLD/HexagonDYLDRendezvous.h
  lldb/trunk/source/Plugins/Process/Utility/InstructionUtils.h
  lldb/trunk/source/Plugins/Process/Utility/UnwindLLDB.h
  lldb/trunk/tools/lldb-mi/MICmnLLDBDebuggerHandleEvents.h


Index: lldb/trunk/source/Plugins/Process/Utility/InstructionUtils.h
===
--- lldb/trunk/source/Plugins/Process/Utility/InstructionUtils.h
+++ lldb/trunk/source/Plugins/Process/Utility/InstructionUtils.h
@@ -10,6 +10,9 @@
 #ifndef lldb_InstructionUtils_h_
 #define lldb_InstructionUtils_h_
 
+#include 
+#include 
+
 // Common utilities for manipulating instruction bit fields.
 
 namespace lldb_private {
Index: lldb/trunk/source/Plugins/Process/Utility/UnwindLLDB.h
===
--- lldb/trunk/source/Plugins/Process/Utility/UnwindLLDB.h
+++ lldb/trunk/source/Plugins/Process/Utility/UnwindLLDB.h
@@ -17,6 +17,7 @@
 // Other libraries and framework includes
 // Project includes
 #include "lldb/Symbol/FuncUnwinders.h"
+#include "lldb/Symbol/SymbolContext.h"
 #include "lldb/Symbol/UnwindPlan.h"
 #include "lldb/Target/RegisterContext.h"
 #include "lldb/Target/Unwind.h"
Index: 
lldb/trunk/source/Plugins/DynamicLoader/Hexagon-DYLD/HexagonDYLDRendezvous.h
===
--- lldb/trunk/source/Plugins/DynamicLoader/Hexagon-DYLD/HexagonDYLDRendezvous.h
+++ lldb/trunk/source/Plugins/DynamicLoader/Hexagon-DYLD/HexagonDYLDRendezvous.h
@@ -11,8 +11,10 @@
 #define liblldb_HexagonDYLDRendezvous_H_
 
 // C Includes
+#include  // for PATH_MAX
 // C++ Includes
 #include 
+#include 
 #include 
 
 // Other libraries and framework includes
Index: lldb/trunk/tools/lldb-mi/MICmnLLDBDebuggerHandleEvents.h
===
--- lldb/trunk/tools/lldb-mi/MICmnLLDBDebuggerHandleEvents.h
+++ lldb/trunk/tools/lldb-mi/MICmnLLDBDebuggerHandleEvents.h
@@ -14,6 +14,7 @@
 #include "MICmnMIValueList.h"
 #include "MICmnMIValueTuple.h"
 #include "MIUtilSingletonBase.h"
+#include "lldb/API/SBEvent.h"
 
 // Declarations:
 class CMICmnLLDBDebugSessionInfo;


Index: lldb/trunk/source/Plugins/Process/Utility/InstructionUtils.h
===
--- lldb/trunk/source/Plugins/Process/Utility/InstructionUtils.h
+++ lldb/trunk/source/Plugins/Process/Utility/InstructionUtils.h
@@ -10,6 +10,9 @@
 #ifndef lldb_InstructionUtils_h_
 #define lldb_InstructionUtils_h_
 
+#include 
+#include 
+
 // Common utilities for manipulating instruction bit fields.
 
 namespace lldb_private {
Index: lldb/trunk/source/Plugins/Process/Utility/UnwindLLDB.h
===
--- lldb/trunk/source/Plugins/Process/Utility/UnwindLLDB.h
+++ lldb/trunk/source/Plugins/Process/Utility/UnwindLLDB.h
@@ -17,6 +17,7 @@
 // Other libraries and framework includes
 // Project includes
 #include "lldb/Symbol/FuncUnwinders.h"
+#include "lldb/Symbol/SymbolContext.h"
 #include "lldb/Symbol/UnwindPlan.h"
 #include "lldb/Target/RegisterContext.h"
 #include "lldb/Target/Unwind.h"
Index: lldb/trunk/source/Plugins/DynamicLoader/Hexagon-DYLD/HexagonDYLDRendezvous.h
===
--- lldb/trunk/source/Plugins/DynamicLoader/Hexagon-DYLD/HexagonDYLDRendezvous.h
+++ lldb/trunk/source/Plugins/DynamicLoader/Hexagon-DYLD/HexagonDYLDRendezvous.h
@@ -11,8 +11,10 @@
 #define liblldb_HexagonDYLDRendezvous_H_
 
 // C Includes
+#include  // for PATH_MAX
 // C++ Includes
 #include 
+#include 
 #include 
 
 // Other libraries and framework includes
Index: lldb/trunk/tools/lldb-mi/MICmnLLDBDebuggerHandleEvents.h
===
--- lldb/trunk/tools/lldb-mi/MICmnLLDBDebuggerHandleEvents.h
+++ lldb/trunk/tools/lldb-mi/MICmnLLDBDebuggerHandleEvents.h
@@ -14,6 +14,7 @@
 #include "MICmnMIValueList.h"
 #include "MICmnMIValueTuple.h"
 #include "MIUtilSingletonBase.h"
+#include "lldb/API/SBEvent.h"
 
 // Declarations:
 class CMICmnLLDBDebugSessionInfo;
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D47410: Don't include headers from inside a namespace in MIUtilSingletonHelper.h

2018-05-26 Thread Raphael Isemann via Phabricator via lldb-commits
teemperor created this revision.
Herald added a subscriber: ki.stfu.

https://reviews.llvm.org/D47410

Files:
  tools/lldb-mi/MIUtilSingletonHelper.h


Index: tools/lldb-mi/MIUtilSingletonHelper.h
===
--- tools/lldb-mi/MIUtilSingletonHelper.h
+++ tools/lldb-mi/MIUtilSingletonHelper.h
@@ -9,12 +9,12 @@
 
 #pragma once
 
-namespace MI {
-
 // In house headers:
 #include "MICmnResources.h"
 #include "MIUtilString.h"
 
+namespace MI {
+
 //++
 //
 // Details: Short cut helper function to simplify repeated initialisation of


Index: tools/lldb-mi/MIUtilSingletonHelper.h
===
--- tools/lldb-mi/MIUtilSingletonHelper.h
+++ tools/lldb-mi/MIUtilSingletonHelper.h
@@ -9,12 +9,12 @@
 
 #pragma once
 
-namespace MI {
-
 // In house headers:
 #include "MICmnResources.h"
 #include "MIUtilString.h"
 
+namespace MI {
+
 //++
 //
 // Details: Short cut helper function to simplify repeated initialisation of
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D47418: Fix memory leak in SubsPrimitiveParmItanium

2018-05-27 Thread Raphael Isemann via Phabricator via lldb-commits
teemperor created this revision.
Herald added a reviewer: javed.absar.
Herald added subscribers: chrib, kristof.beyls.

FastDemangle gives us a C-string that we own (which is allocated in 
SymbolDemangler::GetDemangledCopy).
As we are not deleting the string, we leak memory whenever we call 
SubsPrimitiveParmItanium.


https://reviews.llvm.org/D47418

Files:
  source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp


Index: source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
===
--- source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
+++ source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
@@ -309,13 +309,15 @@
 
   // FastDemangle will call our hook for each instance of a primitive type,
   // allowing us to perform substitution
-  const char *const demangled =
+  char *const demangled =
   FastDemangle(mangled.str().c_str(), mangled.size(), swap_parms_hook);
 
   if (log)
 log->Printf("substituted mangling for %s:{%s} %s:{%s}\n",
 mangled.str().c_str(), demangled, output_buf.c_str(),
 FastDemangle(output_buf.c_str()));
+  // FastDemangle malloc'd this string.
+  free(demangled);
 
   return output_buf == mangled ? ConstString() : ConstString(output_buf);
 }


Index: source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
===
--- source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
+++ source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
@@ -309,13 +309,15 @@
 
   // FastDemangle will call our hook for each instance of a primitive type,
   // allowing us to perform substitution
-  const char *const demangled =
+  char *const demangled =
   FastDemangle(mangled.str().c_str(), mangled.size(), swap_parms_hook);
 
   if (log)
 log->Printf("substituted mangling for %s:{%s} %s:{%s}\n",
 mangled.str().c_str(), demangled, output_buf.c_str(),
 FastDemangle(output_buf.c_str()));
+  // FastDemangle malloc'd this string.
+  free(demangled);
 
   return output_buf == mangled ? ConstString() : ConstString(output_buf);
 }
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D47418: Fix memory leak in SubsPrimitiveParmItanium

2018-05-27 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 rL53: Fix memory leak in SubsPrimitiveParmItanium 
(authored by teemperor, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D47418?vs=148742=148743#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D47418

Files:
  lldb/trunk/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp


Index: lldb/trunk/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
===
--- lldb/trunk/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
+++ lldb/trunk/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
@@ -309,13 +309,15 @@
 
   // FastDemangle will call our hook for each instance of a primitive type,
   // allowing us to perform substitution
-  const char *const demangled =
+  char *const demangled =
   FastDemangle(mangled.str().c_str(), mangled.size(), swap_parms_hook);
 
   if (log)
 log->Printf("substituted mangling for %s:{%s} %s:{%s}\n",
 mangled.str().c_str(), demangled, output_buf.c_str(),
 FastDemangle(output_buf.c_str()));
+  // FastDemangle malloc'd this string.
+  free(demangled);
 
   return output_buf == mangled ? ConstString() : ConstString(output_buf);
 }


Index: lldb/trunk/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
===
--- lldb/trunk/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
+++ lldb/trunk/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
@@ -309,13 +309,15 @@
 
   // FastDemangle will call our hook for each instance of a primitive type,
   // allowing us to perform substitution
-  const char *const demangled =
+  char *const demangled =
   FastDemangle(mangled.str().c_str(), mangled.size(), swap_parms_hook);
 
   if (log)
 log->Printf("substituted mangling for %s:{%s} %s:{%s}\n",
 mangled.str().c_str(), demangled, output_buf.c_str(),
 FastDemangle(output_buf.c_str()));
+  // FastDemangle malloc'd this string.
+  free(demangled);
 
   return output_buf == mangled ? ConstString() : ConstString(output_buf);
 }
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D48796: Refactoring for for the internal command line completion API (NFC)

2018-06-29 Thread Raphael Isemann via Phabricator via lldb-commits
teemperor created this revision.
teemperor added reviewers: davide, jingham, labath.
Herald added a subscriber: mgorny.

This patch refactors the internal completion API. It now takes (as far as 
possible) a single
CompletionRequest object instead o half a dozen in/out/in-out parameters. The 
CompletionRequest
contains a common superset of the different parameters as far as it makes 
sense. This includes
the raw command line string and raw cursor position, which should make the 
`expr` command
possible to implement (at least without hacks that reconstruct the command line 
from the args).

This patch is not intended to change the observable behavior of lldb in any 
way. It's also as
minimal as possible and doesn't attempt to fix all the problems the API has.

Some Q:

Q: Why is this not fixing all the problems in the completion API?
A: Because is a blocker for the expr command completion which I want to get in 
ASAP. This is the

  smallest patch that unblocks the expr completion patch and which allows 
trivial refactoring in the future.
  The patch also doesn't really change the internal information flow in the 
API, so that hopefully
  saves us from ever having to revert and resubmit this humongous patch.

Q: Can we merge all the copy-pasted code in the completion methods

  (like computing the current incomplete arg) into CompletionRequest class?

A: Yes, but it's out of scope for this patch.

Q: Why the `word_complete = request.GetWordComplete(); ... ` pattern?
A: I don't want to add a getter that returns a reference to the internal 
integer. So we have

  to use a temporary variable and the Getter/Setter instead. We don't throw 
exceptions
  from what I can tell, so the behavior doesn't change.

Q: Why are we not owning the list of matches?
A: Because that's how the previous API works. But that should be fixed too (in 
another patch).

Q: Can we make the constructor simpler and compute some of the values from the 
plain command?
A: I think this works, but I rather want to have this in a follow up commit. 
Especially when making nested

  request it's a bit awkward that the parsed arguments behave as both 
input/output (as we should in theory
  propagate the changes on the nested request back to the parent request if we 
don't want to change the
  behavior too much).

Q: Can't we pass one const request object and then just return another result 
object instead of mixing

  them together in one in/out parameter?

A: It's hard to get keep the same behavior with that pattern, but I think we 
can also get a nice API with just

  a single request object. If we make all input parameters read-only, we have a 
clear separation between what
  is actually an input and what an output parameter (and hopefully we get rid 
of the in-out parameters).

Q: Can we throw out the 'match' variables that are not implemented according to 
the comment?
A: We currently just forward them as in the old code to the different methods, 
even though I think

  they are really not used. We can easily remove and readd them once every 
single completion method just
  takes a CompletionRequest, but for now I prefer NFC behavior from the 
perspective of the API user.


https://reviews.llvm.org/D48796

Files:
  include/lldb/Interpreter/CommandAlias.h
  include/lldb/Interpreter/CommandInterpreter.h
  include/lldb/Interpreter/CommandObject.h
  include/lldb/Interpreter/CommandObjectMultiword.h
  include/lldb/Interpreter/CommandObjectRegexCommand.h
  include/lldb/Utility/CompletionRequest.h
  source/Commands/CommandObjectCommands.cpp
  source/Commands/CommandObjectFrame.cpp
  source/Commands/CommandObjectHelp.cpp
  source/Commands/CommandObjectHelp.h
  source/Commands/CommandObjectMultiword.cpp
  source/Commands/CommandObjectPlatform.cpp
  source/Commands/CommandObjectPlugin.cpp
  source/Commands/CommandObjectProcess.cpp
  source/Commands/CommandObjectSettings.cpp
  source/Commands/CommandObjectTarget.cpp
  source/Interpreter/CommandAlias.cpp
  source/Interpreter/CommandInterpreter.cpp
  source/Interpreter/CommandObject.cpp
  source/Interpreter/CommandObjectRegexCommand.cpp
  source/Utility/CMakeLists.txt
  source/Utility/CompletionRequest.cpp
  unittests/Utility/CMakeLists.txt
  unittests/Utility/CompletionRequestTest.cpp

Index: unittests/Utility/CompletionRequestTest.cpp
===
--- /dev/null
+++ unittests/Utility/CompletionRequestTest.cpp
@@ -0,0 +1,38 @@
+//===-- CompletionRequestTest.cpp ---*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#include "gtest/gtest.h"
+
+#include "lldb/Utility/CompletionRequest.h"
+using namespace lldb_private;
+
+TEST(CompletionRequest, Constructor) {
+  std::string command = "a b";
+  

[Lldb-commits] [PATCH] D48463: Prevent dead locking when calling PrintAsync

2018-06-27 Thread Raphael Isemann via Phabricator via lldb-commits
teemperor updated this revision to Diff 153126.
teemperor added a comment.

- We now also handle the case where a guarded mutex is manually unlocked from a 
nested call.
- Refactoring based on review comments.


https://reviews.llvm.org/D48463

Files:
  include/lldb/Core/Debugger.h
  include/lldb/Host/Editline.h
  source/Core/Debugger.cpp
  source/Core/IOHandler.cpp
  source/Host/common/Editline.cpp
  unittests/Editline/EditlineTest.cpp

Index: unittests/Editline/EditlineTest.cpp
===
--- unittests/Editline/EditlineTest.cpp
+++ unittests/Editline/EditlineTest.cpp
@@ -123,9 +123,9 @@
 return;
 
   // Create an Editline instance.
-  _editline_sp.reset(new lldb_private::Editline("gtest editor", *_el_slave_file,
-*_el_slave_file,
-*_el_slave_file, false));
+  _editline_sp.reset(new lldb_private::Editline(
+  "gtest editor", *_el_slave_file, *_el_slave_file, *_el_slave_file, false,
+  nullptr));
   _editline_sp->SetPrompt("> ");
 
   // Hookup our input complete callback.
Index: source/Host/common/Editline.cpp
===
--- source/Host/common/Editline.cpp
+++ source/Host/common/Editline.cpp
@@ -11,6 +11,7 @@
 #include 
 #include 
 
+#include "lldb/Core/Debugger.h"
 #include "lldb/Host/ConnectionFileDescriptor.h"
 #include "lldb/Host/Editline.h"
 #include "lldb/Host/Host.h"
@@ -507,9 +508,15 @@
 // indefinitely. This gives a chance for someone to interrupt us. After
 // Read returns, immediately lock the mutex again and check if we were
 // interrupted.
+int read_count;
 m_output_mutex.unlock();
-int read_count = m_input_connection.Read(, 1, llvm::None, status, NULL);
+{
+  // We also disable the message delaying while we have the mutex unlocked.
+  lldb_private::Debugger::DisableMessageDelayScope guard(m_debugger);
+  read_count = m_input_connection.Read(, 1, llvm::None, status, NULL);
+}
 m_output_mutex.lock();
+
 if (m_editor_status == EditorStatus::Interrupted) {
   while (read_count > 0 && status == lldb::eConnectionStatusSuccess)
 read_count = m_input_connection.Read(, 1, llvm::None, status, NULL);
@@ -1128,10 +1135,12 @@
 }
 
 Editline::Editline(const char *editline_name, FILE *input_file,
-   FILE *output_file, FILE *error_file, bool color_prompts)
+   FILE *output_file, FILE *error_file, bool color_prompts,
+   Debugger *debugger)
 : m_editor_status(EditorStatus::Complete), m_color_prompts(color_prompts),
   m_input_file(input_file), m_output_file(output_file),
-  m_error_file(error_file), m_input_connection(fileno(input_file), false) {
+  m_error_file(error_file), m_input_connection(fileno(input_file), false),
+  m_debugger(debugger) {
   // Get a shared history instance
   m_editor_name = (editline_name == nullptr) ? "lldb-tmp" : editline_name;
   m_history_sp = EditlineHistory::GetHistory(m_editor_name);
@@ -1264,6 +1273,12 @@
   m_input_lines = std::vector();
   m_input_lines.insert(m_input_lines.begin(), EditLineConstString(""));
 
+  // While we own the output mutex, we delay all messages that are printed via
+  // PrintAsync until we release the mutex again. This prevents dead locks that
+  // are caused when someone calls PrintAsync (which also needs to aquire
+  // the output mutex). Note that Editline::GetCharacter unlocks the guarded
+  // mutex from a nested call and also temporarily disables the message delay.
+  Debugger::MessageDelayScope msg_guard(m_debugger);
   std::lock_guard guard(m_output_mutex);
 
   lldbassert(m_editor_status != EditorStatus::Editing);
@@ -1309,6 +1324,9 @@
   m_input_lines = std::vector();
   m_input_lines.insert(m_input_lines.begin(), EditLineConstString(""));
 
+  // We delay all message printing until we release the output mutex. See
+  // Editline::GetLine for a more detailed explanation.
+  Debugger::MessageDelayScope msg_guard(m_debugger);
   std::lock_guard guard(m_output_mutex);
   // Begin the line editing loop
   DisplayInput();
Index: source/Core/IOHandler.cpp
===
--- source/Core/IOHandler.cpp
+++ source/Core/IOHandler.cpp
@@ -313,7 +313,7 @@
   if (use_editline) {
 m_editline_ap.reset(new Editline(editline_name, GetInputFILE(),
  GetOutputFILE(), GetErrorFILE(),
- m_color_prompts));
+ m_color_prompts, nullptr));
 m_editline_ap->SetIsInputCompleteCallback(IsInputCompleteCallback, this);
 m_editline_ap->SetAutoCompleteCallback(AutoCompleteCallback, this);
 // See if the delegate supports fixing indentation
Index: source/Core/Debugger.cpp
===
--- 

[Lldb-commits] [PATCH] D48659: Allow specifying an exit code for the 'quit' command

2018-06-27 Thread Raphael Isemann via Phabricator via lldb-commits
teemperor created this revision.
teemperor added a reviewer: davide.

This patch adds the possibility to specify an exit code when calling quit.
We accept any int, even though it depends on the user what happens if the int is
out of the range of what the operating system supports as exit codes.

Fixes rdar://problem/38452312


https://reviews.llvm.org/D48659

Files:
  include/lldb/API/SBDebugger.h
  include/lldb/Core/Debugger.h
  lit/Quit/TestQuitExitCode-30.test
  lit/Quit/TestQuitExitCode0.test
  lit/Quit/TestQuitExitCode30.test
  lit/Quit/TestQuitExitCodeHex0.test
  lit/Quit/TestQuitExitCodeHexA.test
  lit/Quit/TestQuitExitCodeImplicit0.test
  lit/Quit/TestQuitExitCodeNonInt.test
  lit/Quit/TestQuitExitCodeTooManyArgs.test
  lit/Quit/expect_exit_code.py
  lit/Quit/lit.local.cfg
  source/API/SBDebugger.cpp
  source/Commands/CommandObjectQuit.cpp
  tools/driver/Driver.cpp
  tools/driver/Driver.h

Index: tools/driver/Driver.h
===
--- tools/driver/Driver.h
+++ tools/driver/Driver.h
@@ -37,7 +37,10 @@
 
   virtual ~Driver();
 
-  void MainLoop();
+  /// Runs the main loop.
+  ///
+  /// @return The exit code that the process should return.
+  int MainLoop();
 
   lldb::SBError ParseArgs(int argc, const char *argv[], FILE *out_fh,
   bool _exit);
Index: tools/driver/Driver.cpp
===
--- tools/driver/Driver.cpp
+++ tools/driver/Driver.cpp
@@ -962,7 +962,7 @@
   return '"' + arg + '"';
 }
 
-void Driver::MainLoop() {
+int Driver::MainLoop() {
   if (::tcgetattr(STDIN_FILENO, _old_stdin_termios) == 0) {
 g_old_stdin_termios_is_valid = true;
 atexit(reset_stdin_termios);
@@ -1159,7 +1159,9 @@
   reset_stdin_termios();
   fclose(stdin);
 
+  int exit_code = m_debugger.GetExitCode();
   SBDebugger::Destroy(m_debugger);
+  return exit_code;
 }
 
 void Driver::ResizeWindow(unsigned short col) {
@@ -1237,22 +1239,24 @@
   signal(SIGCONT, sigcont_handler);
 #endif
 
+  int exit_code = 0;
   // Create a scope for driver so that the driver object will destroy itself
   // before SBDebugger::Terminate() is called.
   {
 Driver driver;
 
 bool exiting = false;
 SBError error(driver.ParseArgs(argc, argv, stdout, exiting));
 if (error.Fail()) {
+  exit_code = 1;
   const char *error_cstr = error.GetCString();
   if (error_cstr)
 ::fprintf(stderr, "error: %s\n", error_cstr);
 } else if (!exiting) {
-  driver.MainLoop();
+  exit_code = driver.MainLoop();
 }
   }
 
   SBDebugger::Terminate();
-  return 0;
+  return exit_code;
 }
Index: source/Commands/CommandObjectQuit.cpp
===
--- source/Commands/CommandObjectQuit.cpp
+++ source/Commands/CommandObjectQuit.cpp
@@ -16,6 +16,7 @@
 #include "lldb/Interpreter/CommandInterpreter.h"
 #include "lldb/Interpreter/CommandReturnObject.h"
 #include "lldb/Target/Process.h"
+#include "lldb/Utility/StreamString.h"
 
 using namespace lldb;
 using namespace lldb_private;
@@ -26,7 +27,7 @@
 
 CommandObjectQuit::CommandObjectQuit(CommandInterpreter )
 : CommandObjectParsed(interpreter, "quit", "Quit the LLDB debugger.",
-  "quit") {}
+  "quit [exit-code]") {}
 
 CommandObjectQuit::~CommandObjectQuit() {}
 
@@ -77,6 +78,29 @@
   return false;
 }
   }
+
+  if (command.GetArgumentCount() > 1) {
+result.AppendError("Too many arguments for 'quit'. Only an optional exit "
+   "code is allowed");
+result.SetStatus(eReturnStatusFailed);
+return false;
+  }
+
+  // We parse the exit code argument if there is one.
+  if (command.GetArgumentCount() == 1) {
+llvm::StringRef arg = command.GetArgumentAtIndex(0);
+int exit_code;
+if (arg.getAsInteger(/*autodetect radix*/ 0, exit_code)) {
+  lldb_private::StreamString s;
+  std::string arg_str = arg.str();
+  s.Printf("Couldn't parse '%s' as integer for exit code.", arg_str.data());
+  result.AppendError(s.GetString());
+  result.SetStatus(eReturnStatusFailed);
+  return false;
+}
+m_interpreter.GetDebugger().SetExitCode(exit_code);
+  }
+
   const uint32_t event_type =
   CommandInterpreter::eBroadcastBitQuitCommandReceived;
   m_interpreter.BroadcastEvent(event_type);
Index: source/API/SBDebugger.cpp
===
--- source/API/SBDebugger.cpp
+++ source/API/SBDebugger.cpp
@@ -1081,6 +1081,10 @@
   return (m_opaque_sp ? m_opaque_sp->GetID() : LLDB_INVALID_UID);
 }
 
+int SBDebugger::GetExitCode() {
+  return (m_opaque_sp ? m_opaque_sp->GetExitCode() : 0);
+}
+
 SBError SBDebugger::SetCurrentPlatform(const char *platform_name_cstr) {
   SBError sb_error;
   if (m_opaque_sp) {
Index: lit/Quit/lit.local.cfg
===
--- /dev/null
+++ 

[Lldb-commits] [PATCH] D48463: Prevent dead locking when calling PrintAsync

2018-06-27 Thread Raphael Isemann via Phabricator via lldb-commits
teemperor marked 2 inline comments as done.
teemperor added a comment.

@labath Thanks for the explanation! Well in theory we could poke more holes in 
our guard from some nested function, but this only fixes the deadlock symptom. 
PrintAsync would still be blocking whenever the mutex is hold by someone.




Comment at: source/Core/Debugger.cpp:988-1004
+  bool should_forward = false;
+  {
+// We check if any user requested to delay output to a later time
+// (which is designated by m_delayed_output_counter being not 0).
+std::lock_guard guard(m_delayed_output_mutex);
+if (m_delayed_output_counter != 0) {
+  // We want to delay messages, so push them to the buffer.

clayborg wrote:
> Can this code become:
> 
> ```
> // We check if any user requested to delay output to a later time
> // (which is designated by m_delayed_output_counter being not 0).
> {
>   std::lock_guard guard(m_delayed_output_mutex);
>   if (m_delayed_output_counter != 0) {
> // We want to delay messages, so push them to the buffer.
> m_delayed_output.emplace_back(std::string(s, len), is_stdout);
>   return;
>   }
> }
> lldb::StreamFileSP stream = is_stdout ? GetOutputFile() : GetErrorFile();
> m_input_reader_stack.PrintAsync(stream.get(), s, len);
> ```
It can and did. Removed the same pattern from the TryFlushingDelayedMessages 
method.



Comment at: source/Core/IOHandler.cpp:358
+  // lldb code that will be called from here (possibly in another thread).
+  Debugger::MessageDelayScope buffer_scope(m_debugger);
+

clayborg wrote:
> So anytime we have a "(lldb)" prompt we won't be able to output something?
Yes, that was the unintended effect of this patch (which was caught by the test 
suite actually). I didn't see until after I submitted that we actually manually 
unlock the guarded mutex from a called function. This now has been fixed by 
doing something like the unlock/lock code with the DisableMessageDelayScope in 
`EditLine::GetCharacter`.


https://reviews.llvm.org/D48463



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


[Lldb-commits] [PATCH] D48463: Prevent dead locking when calling PrintAsync

2018-06-27 Thread Raphael Isemann via Phabricator via lldb-commits
teemperor updated this revision to Diff 153129.
teemperor edited the summary of this revision.
teemperor added a comment.

- Fixed that we only pass a nullptr as a debugger to the real editline object 
(which now fixes the deadlock in the code completion patch).


https://reviews.llvm.org/D48463

Files:
  include/lldb/Core/Debugger.h
  include/lldb/Host/Editline.h
  source/Core/Debugger.cpp
  source/Core/IOHandler.cpp
  source/Host/common/Editline.cpp
  unittests/Editline/EditlineTest.cpp

Index: unittests/Editline/EditlineTest.cpp
===
--- unittests/Editline/EditlineTest.cpp
+++ unittests/Editline/EditlineTest.cpp
@@ -123,9 +123,9 @@
 return;
 
   // Create an Editline instance.
-  _editline_sp.reset(new lldb_private::Editline("gtest editor", *_el_slave_file,
-*_el_slave_file,
-*_el_slave_file, false));
+  _editline_sp.reset(new lldb_private::Editline(
+  "gtest editor", *_el_slave_file, *_el_slave_file, *_el_slave_file, false,
+  nullptr));
   _editline_sp->SetPrompt("> ");
 
   // Hookup our input complete callback.
Index: source/Host/common/Editline.cpp
===
--- source/Host/common/Editline.cpp
+++ source/Host/common/Editline.cpp
@@ -11,6 +11,7 @@
 #include 
 #include 
 
+#include "lldb/Core/Debugger.h"
 #include "lldb/Host/ConnectionFileDescriptor.h"
 #include "lldb/Host/Editline.h"
 #include "lldb/Host/Host.h"
@@ -507,9 +508,15 @@
 // indefinitely. This gives a chance for someone to interrupt us. After
 // Read returns, immediately lock the mutex again and check if we were
 // interrupted.
+int read_count;
 m_output_mutex.unlock();
-int read_count = m_input_connection.Read(, 1, llvm::None, status, NULL);
+{
+  // We also disable the message delaying while we have the mutex unlocked.
+  lldb_private::Debugger::DisableMessageDelayScope guard(m_debugger);
+  read_count = m_input_connection.Read(, 1, llvm::None, status, NULL);
+}
 m_output_mutex.lock();
+
 if (m_editor_status == EditorStatus::Interrupted) {
   while (read_count > 0 && status == lldb::eConnectionStatusSuccess)
 read_count = m_input_connection.Read(, 1, llvm::None, status, NULL);
@@ -1128,10 +1135,12 @@
 }
 
 Editline::Editline(const char *editline_name, FILE *input_file,
-   FILE *output_file, FILE *error_file, bool color_prompts)
+   FILE *output_file, FILE *error_file, bool color_prompts,
+   Debugger *debugger)
 : m_editor_status(EditorStatus::Complete), m_color_prompts(color_prompts),
   m_input_file(input_file), m_output_file(output_file),
-  m_error_file(error_file), m_input_connection(fileno(input_file), false) {
+  m_error_file(error_file), m_input_connection(fileno(input_file), false),
+  m_debugger(debugger) {
   // Get a shared history instance
   m_editor_name = (editline_name == nullptr) ? "lldb-tmp" : editline_name;
   m_history_sp = EditlineHistory::GetHistory(m_editor_name);
@@ -1264,6 +1273,12 @@
   m_input_lines = std::vector();
   m_input_lines.insert(m_input_lines.begin(), EditLineConstString(""));
 
+  // While we own the output mutex, we delay all messages that are printed via
+  // PrintAsync until we release the mutex again. This prevents dead locks that
+  // are caused when someone calls PrintAsync (which also needs to aquire
+  // the output mutex). Note that Editline::GetCharacter unlocks the guarded
+  // mutex from a nested call and also temporarily disables the message delay.
+  Debugger::MessageDelayScope msg_guard(m_debugger);
   std::lock_guard guard(m_output_mutex);
 
   lldbassert(m_editor_status != EditorStatus::Editing);
@@ -1309,6 +1324,9 @@
   m_input_lines = std::vector();
   m_input_lines.insert(m_input_lines.begin(), EditLineConstString(""));
 
+  // We delay all message printing until we release the output mutex. See
+  // Editline::GetLine for a more detailed explanation.
+  Debugger::MessageDelayScope msg_guard(m_debugger);
   std::lock_guard guard(m_output_mutex);
   // Begin the line editing loop
   DisplayInput();
Index: source/Core/IOHandler.cpp
===
--- source/Core/IOHandler.cpp
+++ source/Core/IOHandler.cpp
@@ -313,7 +313,7 @@
   if (use_editline) {
 m_editline_ap.reset(new Editline(editline_name, GetInputFILE(),
  GetOutputFILE(), GetErrorFILE(),
- m_color_prompts));
+ m_color_prompts, _debugger));
 m_editline_ap->SetIsInputCompleteCallback(IsInputCompleteCallback, this);
 m_editline_ap->SetAutoCompleteCallback(AutoCompleteCallback, this);
 // See if the delegate supports fixing indentation
Index: source/Core/Debugger.cpp

[Lldb-commits] [PATCH] D48665: Added test case for: r334978 - Fixed file completion for paths that start with '~'

2018-06-27 Thread Raphael Isemann via Phabricator via lldb-commits
teemperor created this revision.
teemperor added a reviewer: labath.

https://reviews.llvm.org/D48665

Files:
  unittests/Interpreter/TestCompletion.cpp


Index: unittests/Interpreter/TestCompletion.cpp
===
--- unittests/Interpreter/TestCompletion.cpp
+++ unittests/Interpreter/TestCompletion.cpp
@@ -51,6 +51,7 @@
   static SmallString<128> DirBar;
   static SmallString<128> DirBaz;
   static SmallString<128> DirTestFolder;
+  static SmallString<128> DirNested;
 
   static SmallString<128> FileAA;
   static SmallString<128> FileAB;
@@ -65,17 +66,17 @@
 llvm::sys::fs::current_path(OriginalWorkingDir);
 
 ASSERT_NO_ERROR(fs::createUniqueDirectory("FsCompletion", BaseDir));
-const char *DirNames[] = {"foo", "fooa", "foob",   "fooc",
-  "bar", "baz",  "test_folder"};
+const char *DirNames[] = {"foo", "fooa", "foob","fooc",
+  "bar", "baz",  "test_folder", "foo/nested"};
 const char *FileNames[] = {"aa1234.tmp",  "ab1234.tmp",  "ac1234.tmp",
"foo1234.tmp", "bar1234.tmp", "baz1234.tmp"};
-SmallString<128> *Dirs[] = {, , ,  ,
-, ,  };
+SmallString<128> *Dirs[] = {, , ,   ,
+, ,  , };
 for (auto Dir : llvm::zip(DirNames, Dirs)) {
   auto  = *std::get<1>(Dir);
   Path = BaseDir;
   path::append(Path, std::get<0>(Dir));
-  ASSERT_NO_ERROR(fs::create_directory(Path));
+  ASSERT_NO_ERROR(fs::create_directories(Path));
 }
 
 SmallString<128> *Files[] = {,  ,  ,
@@ -146,6 +147,7 @@
 SmallString<128> CompletionTest::DirBar;
 SmallString<128> CompletionTest::DirBaz;
 SmallString<128> CompletionTest::DirTestFolder;
+SmallString<128> CompletionTest::DirNested;
 
 SmallString<128> CompletionTest::FileAA;
 SmallString<128> CompletionTest::FileAB;
@@ -280,6 +282,20 @@
   EXPECT_TRUE(ContainsExactString(
   Twine("~/test_folder") + path::get_separator(), Results));
 
+  // Check that we can complete directories in nested paths
+  Count = CommandCompletions::DiskDirectories("~/foo/", Results, Resolver);
+  ASSERT_EQ(1u, Count);
+  ASSERT_EQ(Count, Results.GetSize());
+  EXPECT_TRUE(ContainsExactString(Twine("~/foo") + path::get_separator() +
+  "nested" + path::get_separator(),
+  Results));
+  Count = CommandCompletions::DiskDirectories("~/foo/nes", Results, Resolver);
+  ASSERT_EQ(1u, Count);
+  ASSERT_EQ(Count, Results.GetSize());
+  EXPECT_TRUE(ContainsExactString(Twine("~/foo") + path::get_separator() +
+  "nested" + path::get_separator(),
+  Results));
+
   // With ~username syntax it should return one match if there is an exact
   // match.
   // It shouldn't translate to the actual directory, it should keep the form 
the


Index: unittests/Interpreter/TestCompletion.cpp
===
--- unittests/Interpreter/TestCompletion.cpp
+++ unittests/Interpreter/TestCompletion.cpp
@@ -51,6 +51,7 @@
   static SmallString<128> DirBar;
   static SmallString<128> DirBaz;
   static SmallString<128> DirTestFolder;
+  static SmallString<128> DirNested;
 
   static SmallString<128> FileAA;
   static SmallString<128> FileAB;
@@ -65,17 +66,17 @@
 llvm::sys::fs::current_path(OriginalWorkingDir);
 
 ASSERT_NO_ERROR(fs::createUniqueDirectory("FsCompletion", BaseDir));
-const char *DirNames[] = {"foo", "fooa", "foob",   "fooc",
-  "bar", "baz",  "test_folder"};
+const char *DirNames[] = {"foo", "fooa", "foob","fooc",
+  "bar", "baz",  "test_folder", "foo/nested"};
 const char *FileNames[] = {"aa1234.tmp",  "ab1234.tmp",  "ac1234.tmp",
"foo1234.tmp", "bar1234.tmp", "baz1234.tmp"};
-SmallString<128> *Dirs[] = {, , ,  ,
-, ,  };
+SmallString<128> *Dirs[] = {, , ,   ,
+, ,  , };
 for (auto Dir : llvm::zip(DirNames, Dirs)) {
   auto  = *std::get<1>(Dir);
   Path = BaseDir;
   path::append(Path, std::get<0>(Dir));
-  ASSERT_NO_ERROR(fs::create_directory(Path));
+  ASSERT_NO_ERROR(fs::create_directories(Path));
 }
 
 SmallString<128> *Files[] = {,  ,  ,
@@ -146,6 +147,7 @@
 SmallString<128> CompletionTest::DirBar;
 SmallString<128> CompletionTest::DirBaz;
 SmallString<128> CompletionTest::DirTestFolder;
+SmallString<128> CompletionTest::DirNested;
 
 SmallString<128> CompletionTest::FileAA;
 SmallString<128> CompletionTest::FileAB;
@@ -280,6 +282,20 @@
   EXPECT_TRUE(ContainsExactString(
   Twine("~/test_folder") + path::get_separator(), Results));
 
+  // Check that we can complete directories in nested paths
+  Count = 

[Lldb-commits] [PATCH] D48463: Prevent dead locking when calling PrintAsync

2018-06-22 Thread Raphael Isemann via Phabricator via lldb-commits
teemperor added a reviewer: labath.
teemperor added a subscriber: labath.
teemperor added a comment.

Adding Pavel because he wrote the PrintAsync code.

Also @labath: Can you tell me what variables/functionality the `m_output_mutex` 
in Editline.cpp is supposed to shield? I don't see any documentation for that.

The `m_output_mutex` name suggests its related to console output, but we 
actually take the lock also when reading *input*. Especially in 
`EditLine::GetLine` we take a guard on the lock but then somehow unlock the 
guarded mutex from inside  `Editline::GetCharacter` that we call afterwards 
(which completely breaks this patch):

  // This mutex is locked by our caller (GetLine). Unlock it while we read a
  // character (blocking operation), so we do not hold the mutex
  // indefinitely. This gives a chance for someone to interrupt us. After
  // Read returns, immediately lock the mutex again and check if we were
  // interrupted.
  m_output_mutex.unlock();
  int read_count = m_input_connection.Read(, 1, llvm::None, status, NULL);
  m_output_mutex.lock();
  if (m_editor_status == EditorStatus::Interrupted) {
while (read_count > 0 && status == lldb::eConnectionStatusSuccess)
  read_count = m_input_connection.Read(, 1, llvm::None, status, NULL);
lldbassert(status == lldb::eConnectionStatusInterrupted);
return 0;
  }


https://reviews.llvm.org/D48463



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


[Lldb-commits] [PATCH] D48796: Refactoring for for the internal command line completion API (NFC)

2018-07-02 Thread Raphael Isemann via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL336146: Refactoring for for the internal command line 
completion API (NFC) (authored by teemperor, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D48796?vs=153562=153800#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D48796

Files:
  lldb/trunk/include/lldb/Interpreter/CommandAlias.h
  lldb/trunk/include/lldb/Interpreter/CommandInterpreter.h
  lldb/trunk/include/lldb/Interpreter/CommandObject.h
  lldb/trunk/include/lldb/Interpreter/CommandObjectMultiword.h
  lldb/trunk/include/lldb/Interpreter/CommandObjectRegexCommand.h
  lldb/trunk/include/lldb/Utility/CompletionRequest.h
  lldb/trunk/source/Commands/CommandObjectCommands.cpp
  lldb/trunk/source/Commands/CommandObjectFrame.cpp
  lldb/trunk/source/Commands/CommandObjectHelp.cpp
  lldb/trunk/source/Commands/CommandObjectHelp.h
  lldb/trunk/source/Commands/CommandObjectMultiword.cpp
  lldb/trunk/source/Commands/CommandObjectPlatform.cpp
  lldb/trunk/source/Commands/CommandObjectPlugin.cpp
  lldb/trunk/source/Commands/CommandObjectProcess.cpp
  lldb/trunk/source/Commands/CommandObjectSettings.cpp
  lldb/trunk/source/Commands/CommandObjectTarget.cpp
  lldb/trunk/source/Interpreter/CommandAlias.cpp
  lldb/trunk/source/Interpreter/CommandInterpreter.cpp
  lldb/trunk/source/Interpreter/CommandObject.cpp
  lldb/trunk/source/Interpreter/CommandObjectRegexCommand.cpp
  lldb/trunk/source/Utility/CMakeLists.txt
  lldb/trunk/source/Utility/CompletionRequest.cpp
  lldb/trunk/unittests/Utility/CMakeLists.txt
  lldb/trunk/unittests/Utility/CompletionRequestTest.cpp

Index: lldb/trunk/unittests/Utility/CompletionRequestTest.cpp
===
--- lldb/trunk/unittests/Utility/CompletionRequestTest.cpp
+++ lldb/trunk/unittests/Utility/CompletionRequestTest.cpp
@@ -0,0 +1,38 @@
+//===-- CompletionRequestTest.cpp ---*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#include "gtest/gtest.h"
+
+#include "lldb/Utility/CompletionRequest.h"
+using namespace lldb_private;
+
+TEST(CompletionRequest, Constructor) {
+  std::string command = "a b";
+  const unsigned cursor_pos = 2;
+  Args args(command);
+  const int arg_index = 1;
+  const int arg_cursor_pos = 0;
+  const int match_start = 2345;
+  const int match_max_return = 12345;
+  bool word_complete = false;
+  StringList matches;
+  CompletionRequest request(command, cursor_pos, args, arg_index,
+arg_cursor_pos, match_start, match_max_return,
+word_complete, matches);
+
+  EXPECT_STREQ(request.GetRawLine().str().c_str(), command.c_str());
+  EXPECT_EQ(request.GetRawCursorPos(), cursor_pos);
+  EXPECT_EQ(request.GetCursorIndex(), arg_index);
+  EXPECT_EQ(request.GetCursorCharPosition(), arg_cursor_pos);
+  EXPECT_EQ(request.GetMatchStartPoint(), match_start);
+  EXPECT_EQ(request.GetMaxReturnElements(), match_max_return);
+  EXPECT_EQ(request.GetWordComplete(), word_complete);
+  // This is the generated matches should be equal to our passed string list.
+  EXPECT_EQ((), );
+}
Index: lldb/trunk/unittests/Utility/CMakeLists.txt
===
--- lldb/trunk/unittests/Utility/CMakeLists.txt
+++ lldb/trunk/unittests/Utility/CMakeLists.txt
@@ -3,6 +3,7 @@
   ArchSpecTest.cpp
   CleanUpTest.cpp
   ConstStringTest.cpp
+  CompletionRequestTest.cpp
   EnvironmentTest.cpp
   FileSpecTest.cpp
   JSONTest.cpp
Index: lldb/trunk/source/Utility/CompletionRequest.cpp
===
--- lldb/trunk/source/Utility/CompletionRequest.cpp
+++ lldb/trunk/source/Utility/CompletionRequest.cpp
@@ -0,0 +1,26 @@
+//===-- CompletionRequest.cpp ---*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#include "lldb/Utility/CompletionRequest.h"
+
+using namespace lldb;
+using namespace lldb_private;
+
+CompletionRequest::CompletionRequest(llvm::StringRef command,
+ unsigned raw_cursor_pos, Args _line,
+ int cursor_index, int cursor_char_position,
+ int match_start_point,
+ int max_return_elements,
+ bool word_complete, StringList )
+: m_command(command), m_raw_cursor_pos(raw_cursor_pos),

[Lldb-commits] [PATCH] D48796: Refactoring for for the internal command line completion API (NFC)

2018-07-02 Thread Raphael Isemann via Phabricator via lldb-commits
teemperor added a comment.

@jingham Just trying to keep this patch as minimal/NFC as possible because we 
can't revert it once the expr completion patch is merged. I'll open reviews for 
all these other refactorings once this is in.


https://reviews.llvm.org/D48796



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


[Lldb-commits] [PATCH] D48855: Fixed compilation failure after the code completion refactor patch

2018-07-02 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 rL336149: Fixed compilation failure after the code completion 
refactor patch (authored by teemperor, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D48855?vs=153809=153812#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D48855

Files:
  lldb/trunk/include/lldb/Interpreter/CommandObject.h
  lldb/trunk/include/lldb/Utility/CompletionRequest.h


Index: lldb/trunk/include/lldb/Interpreter/CommandObject.h
===
--- lldb/trunk/include/lldb/Interpreter/CommandObject.h
+++ lldb/trunk/include/lldb/Interpreter/CommandObject.h
@@ -16,7 +16,7 @@
 #include 
 #include 
 
-#include 
+#include "lldb/Utility/CompletionRequest.h"
 
 // Other libraries and framework includes
 // Project includes
Index: lldb/trunk/include/lldb/Utility/CompletionRequest.h
===
--- lldb/trunk/include/lldb/Utility/CompletionRequest.h
+++ lldb/trunk/include/lldb/Utility/CompletionRequest.h
@@ -10,9 +10,9 @@
 #ifndef LLDB_UTILITY_COMPLETIONREQUEST_H
 #define LLDB_UTILITY_COMPLETIONREQUEST_H
 
-#include 
-#include 
-#include 
+#include "lldb/Utility/Args.h"
+#include "lldb/Utility/StringList.h"
+#include "llvm/ADT/StringRef.h"
 
 namespace lldb_private {
 


Index: lldb/trunk/include/lldb/Interpreter/CommandObject.h
===
--- lldb/trunk/include/lldb/Interpreter/CommandObject.h
+++ lldb/trunk/include/lldb/Interpreter/CommandObject.h
@@ -16,7 +16,7 @@
 #include 
 #include 
 
-#include 
+#include "lldb/Utility/CompletionRequest.h"
 
 // Other libraries and framework includes
 // Project includes
Index: lldb/trunk/include/lldb/Utility/CompletionRequest.h
===
--- lldb/trunk/include/lldb/Utility/CompletionRequest.h
+++ lldb/trunk/include/lldb/Utility/CompletionRequest.h
@@ -10,9 +10,9 @@
 #ifndef LLDB_UTILITY_COMPLETIONREQUEST_H
 #define LLDB_UTILITY_COMPLETIONREQUEST_H
 
-#include 
-#include 
-#include 
+#include "lldb/Utility/Args.h"
+#include "lldb/Utility/StringList.h"
+#include "llvm/ADT/StringRef.h"
 
 namespace lldb_private {
 
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D48855: Fixed compilation failure after the code completion refactor patch

2018-07-02 Thread Raphael Isemann via Phabricator via lldb-commits
teemperor created this revision.

https://reviews.llvm.org/D48855

Files:
  include/lldb/Interpreter/CommandObject.h
  include/lldb/Utility/CompletionRequest.h


Index: include/lldb/Utility/CompletionRequest.h
===
--- include/lldb/Utility/CompletionRequest.h
+++ include/lldb/Utility/CompletionRequest.h
@@ -10,9 +10,9 @@
 #ifndef LLDB_UTILITY_COMPLETIONREQUEST_H
 #define LLDB_UTILITY_COMPLETIONREQUEST_H
 
-#include 
-#include 
-#include 
+#include "lldb/Utility/Args.h"
+#include "lldb/Utility/StringList.h"
+#include "llvm/ADT/StringRef.h"
 
 namespace lldb_private {
 
Index: include/lldb/Interpreter/CommandObject.h
===
--- include/lldb/Interpreter/CommandObject.h
+++ include/lldb/Interpreter/CommandObject.h
@@ -16,7 +16,7 @@
 #include 
 #include 
 
-#include 
+#include "lldb/Utility/CompletionRequest.h"
 
 // Other libraries and framework includes
 // Project includes


Index: include/lldb/Utility/CompletionRequest.h
===
--- include/lldb/Utility/CompletionRequest.h
+++ include/lldb/Utility/CompletionRequest.h
@@ -10,9 +10,9 @@
 #ifndef LLDB_UTILITY_COMPLETIONREQUEST_H
 #define LLDB_UTILITY_COMPLETIONREQUEST_H
 
-#include 
-#include 
-#include 
+#include "lldb/Utility/Args.h"
+#include "lldb/Utility/StringList.h"
+#include "llvm/ADT/StringRef.h"
 
 namespace lldb_private {
 
Index: include/lldb/Interpreter/CommandObject.h
===
--- include/lldb/Interpreter/CommandObject.h
+++ include/lldb/Interpreter/CommandObject.h
@@ -16,7 +16,7 @@
 #include 
 #include 
 
-#include 
+#include "lldb/Utility/CompletionRequest.h"
 
 // Other libraries and framework includes
 // Project includes
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D48858: FIx XCode project files for lldb

2018-07-02 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 rL336154: FIx XCode project files for lldb (authored by 
teemperor, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D48858?vs=153826=153827#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D48858

Files:
  lldb/trunk/lldb.xcodeproj/project.pbxproj



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


[Lldb-commits] [PATCH] D48858: FIx XCode project files for lldb

2018-07-02 Thread Raphael Isemann via Phabricator via lldb-commits
teemperor created this revision.
Herald added a subscriber: srhines.

Fixes the XCode builds that started failing when i added 
CompletionRequest.cpp/.h.

The patch is so large because XCode decided to write the lines back in its own 
order, but essentially we only added on e file.


https://reviews.llvm.org/D48858

Files:
  lldb.xcodeproj/project.pbxproj



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


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

2018-07-02 Thread Raphael Isemann via Phabricator via lldb-commits
teemperor added inline comments.



Comment at: 
packages/Python/lldbsuite/test/functionalities/expr_completion/TestExprCompletion.py:177-215
+def generate_random_expr(self, run_index):
+"""
+Generates a random expression. run_index seeds the rng, so
+the output of this method is always the same for the same run_index 
value
+"""
+# Some random tokens we built our expression from.
+tokens = [".", ",", "(", ")", "{", "}", "foo", "a", "some_expr",

labath wrote:
> I don't think a test like this has place in the test suite. It tests a 
> different thing every time it's run and it will be impossible to debug if it 
> starts to fail/be flaky on the build bots.
I don't see how a seeded PRNG is flaky, but I think that test is also not 
important enough that I really want to push for merging it in. I just removed 
it.



Comment at: source/Commands/CommandObjectExpression.cpp:419-423
+// We got the index of the arg and the cursor index inside that arg as
+// parameters, but for completing the whole expression we need to revert
+// this back to the absolute offset of the cursor in the whole expression.
+int absolute_pos =
+WordPosToAbsolutePos(arg, cursor_index, cursor_char_position);

labath wrote:
> Will this work correctly if the expression command contains arguments (`expr 
> -i0 -- my_expression`)? What about quoted strings (`expr "string with 
> spaces`)?
> 
> Have you looked at whether it would be possible to refactor the completion 
> api to provide the absolute position (it has to exist at some point), instead 
> of trying to reverse-engineer it here?
> 
> I think the problem here is that the completion api has this built-in 
> assumption that you're only ever going to be completing "parsed" commands, 
> which is why you get the input as an `Args` array and a two-dimensional 
> cursor position. "expr" command takes "raw" input, which means it does not go 
> through the usual word-splitting and getopt parsing. You can see that because 
> CommandObjectExpression::DoExecute takes a `const char *command`, whereas for 
> "parsed" commands (e.g. "frame variable") the DoExecute function takes the 
> argument as `Args `.
> 
> I think it would make sense to start this by refactoring the completion api 
> to behave the same way as the "DoExecute" api. For "raw" commands , the 
> HandleCompletion function would take a raw string + absolute position in that 
> string, and the parsed commands would get the an `Args` array plus the 
> two-dimensional position. Without that, you're going to get subtle 
> differences in how the expression is treated for completion purposes and for 
> actual evaluation.
I added another parent revision that gives us access to the raw command string, 
which removes all the cmd rebuilding code and fixes the cases you pointed out 
(which are now also in the test suite). I have to see how we can get rid of the 
string search for `--` in both the completion/execute, but that's OOS.



Comment at: source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp:590
+// to completing the current token.
+StringRef to_remove = cmd;
+while (!to_remove.empty() && !IsTokenSeparator(to_remove.back())) {

aprantl wrote:
> Should this perhaps use some form of StringRef::dropWhile or similar?
> (https://llvm.org/doxygen/classllvm_1_1StringRef.html#aed7897c6ee084440516a7bb5e79a2094)
Most of the functions are for working on the start of the string, but I don't 
see anything like dropWhile for the end of the string. There is not even a 
reverse find_if or something like that :(



Comment at: source/Plugins/ExpressionParser/Clang/ClangExpressionParser.h:172
+  ///The number of parsing errors.
+  //---
+  unsigned ParseInternal(DiagnosticManager _manager,

aprantl wrote:
> Perhaps return an llvm::Error instead of an unsigned?
Agreed. But I'll do that in a follow up revision because I didn't actually 
write the ParseInternal for this commit. It's just the renamed `Parse` function 
and added the missing documentation and completion parameters.


https://reviews.llvm.org/D48465



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


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

2018-07-02 Thread Raphael Isemann via Phabricator via lldb-commits
teemperor planned changes to this revision.
teemperor added a comment.

Actually, because both @labath and @jingham requested refactoring to get rid of 
the `--` search (even though Phabricator couldn't parse Jim's comment), I'll 
first also refactor this one. Thanks for the feedback!


https://reviews.llvm.org/D48465



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


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

2018-07-02 Thread Raphael Isemann via Phabricator via lldb-commits
teemperor updated this revision to Diff 153748.
teemperor marked 13 inline comments as done.
teemperor added a comment.

- Addresses the problems pointed out by Adrian and Pavel (Thanks!)
- Now using the completion API patch to get rid of the code that rebuilds the 
command line string from the args.


https://reviews.llvm.org/D48465

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

Index: source/Plugins/ExpressionParser/Clang/ClangUserExpression.h
===
--- source/Plugins/ExpressionParser/Clang/ClangUserExpression.h
+++ source/Plugins/ExpressionParser/Clang/ClangUserExpression.h
@@ -143,6 +143,9 @@
  lldb_private::ExecutionPolicy execution_policy,
  bool keep_result_in_memory, bool generate_debug_info) override;
 
+  bool Complete(ExecutionContext _ctx, StringList ,
+unsigned complete_pos) override;
+
   ExpressionTypeSystemHelper *GetTypeSystemHelper() override {
 return _type_system_helper;
   }
@@ -199,6 +202,10 @@
 lldb::TargetSP m_target_sp;
   };
 
+  /// The absolute character position in the transformed source code where the
+  /// user code (as typed by the user) starts. If the variable is empty, then we
+  /// were not able to calculate this position.
+  llvm::Optional m_user_expression_start_pos;
   ResultDelegate m_result_delegate;
 };
 
Index: source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp
===
--- source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp
+++ source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp
@@ -403,6 +403,16 @@
"couldn't construct expression body");
   return llvm::Optional();
 }
+
+// Find and store the start position of the original code inside the
+// transformed code. We need this later for the code completion.
+std::size_t original_start;
+std::size_t original_end;
+bool found_bounds = source_code->GetOriginalBodyBounds(
+m_transformed_text, lang_type, original_start, original_end);
+if (found_bounds) {
+  m_user_expression_start_pos = original_start;
+}
   }
   return lang_type;
 }
@@ -592,6 +602,119 @@
   return true;
 }
 
+//--
+/// Converts an absolute position inside a given code string into
+/// a column/line pair.
+///
+/// @param[in] abs_pos
+/// A absolute position in the code string that we want to convert
+/// to a column/line pair.
+///
+/// @param[in] code
+/// A multi-line string usually representing source code.
+///
+/// @param[out] line
+/// The line in the code that contains the given absolute position.
+/// The first line in the string is indexed as 1.
+///
+/// @param[out] column
+/// The column in the line that contains the absolute position.
+/// The first character in a line is indexed as 0.
+//--
+static void AbsPosToLineColumnPos(unsigned abs_pos, llvm::StringRef code,
+  unsigned , unsigned ) {
+  // Reset to code position to beginning of the file.
+  line = 0;
+  column = 0;
+
+  assert(abs_pos <= code.size() && "Absolute position outside code string?");
+
+  // We have to walk up to the position and count lines/columns.
+  for (std::size_t i = 0; i < abs_pos; ++i) {
+// If we hit a line break, we go back to column 0 and enter a new line.
+// We only handle \n because that's what we internally use to make new
+// lines for our temporary code strings.
+if (code[i] == '\n') {
+  ++line;
+  column = 0;
+  continue;
+}
+++column;
+  }
+}
+
+bool ClangUserExpression::Complete(ExecutionContext _ctx,
+   StringList , unsigned complete_pos) {
+  Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS));
+
+  // We don't want any visible feedback when completing an expression. Mostly
+  // because the results we get from an 

[Lldb-commits] [PATCH] D42338: Fix unrepresentable float value in ScalarTest

2018-01-20 Thread Raphael Isemann via Phabricator via lldb-commits
teemperor created this revision.
teemperor added a reviewer: uweigand.

float can't represent the given value in the literal, so we get this UB error: 
`runtime error: 1.23457e+48 is outside the range of representable values of 
type 'float'`. The test seems to not rely on this specific value, so let's just 
choose a smaller one that can be represented.


https://reviews.llvm.org/D42338

Files:
  unittests/Core/ScalarTest.cpp


Index: unittests/Core/ScalarTest.cpp
===
--- unittests/Core/ScalarTest.cpp
+++ unittests/Core/ScalarTest.cpp
@@ -31,7 +31,7 @@
 TEST(ScalarTest, GetBytes) {
   int a = 0x01020304;
   long long b = 0x0102030405060708LL;
-  float c = 1234567.89e42;
+  float c = 1234567.89e32;
   double d = 1234567.89e42;
   char e[16] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16};
   char f[32] = {1,  2,  3,  4,  5,  6,  7,  8,  9,  10, 11, 12, 13, 14, 15, 16,


Index: unittests/Core/ScalarTest.cpp
===
--- unittests/Core/ScalarTest.cpp
+++ unittests/Core/ScalarTest.cpp
@@ -31,7 +31,7 @@
 TEST(ScalarTest, GetBytes) {
   int a = 0x01020304;
   long long b = 0x0102030405060708LL;
-  float c = 1234567.89e42;
+  float c = 1234567.89e32;
   double d = 1234567.89e42;
   char e[16] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16};
   char f[32] = {1,  2,  3,  4,  5,  6,  7,  8,  9,  10, 11, 12, 13, 14, 15, 16,
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D42339: Fix uninitialized variable in GoParser

2018-01-20 Thread Raphael Isemann via Phabricator via lldb-commits
teemperor created this revision.
teemperor added a reviewer: ribrdb.
teemperor edited the summary of this revision.

`m_last_tok` isn't initialized anywhere before it's used the first time (most 
likely in the `GoParser::Rule::error` method), which causes most of the 
GoParser tests to fail with sanitizers enabled with errors like this:

  GoParser.cpp:52:21: runtime error: load of value , which is not 
a valid value for type 'GoLexer::TokenType'
  UndefinedBehaviorSanitizer: undefined-behavior GoParser.cpp:52:21


https://reviews.llvm.org/D42339

Files:
  source/Plugins/ExpressionParser/Go/GoParser.cpp


Index: source/Plugins/ExpressionParser/Go/GoParser.cpp
===
--- source/Plugins/ExpressionParser/Go/GoParser.cpp
+++ source/Plugins/ExpressionParser/Go/GoParser.cpp
@@ -67,7 +67,9 @@
   size_t m_pos;
 };
 
-GoParser::GoParser(const char *src) : m_lexer(src), m_pos(0), m_failed(false) 
{}
+GoParser::GoParser(const char *src)
+: m_lexer(src), m_pos(0), m_last_tok(GoLexer::TOK_INVALID),
+  m_failed(false) {}
 
 GoASTStmt *GoParser::Statement() {
   Rule r("Statement", this);


Index: source/Plugins/ExpressionParser/Go/GoParser.cpp
===
--- source/Plugins/ExpressionParser/Go/GoParser.cpp
+++ source/Plugins/ExpressionParser/Go/GoParser.cpp
@@ -67,7 +67,9 @@
   size_t m_pos;
 };
 
-GoParser::GoParser(const char *src) : m_lexer(src), m_pos(0), m_failed(false) {}
+GoParser::GoParser(const char *src)
+: m_lexer(src), m_pos(0), m_last_tok(GoLexer::TOK_INVALID),
+  m_failed(false) {}
 
 GoASTStmt *GoParser::Statement() {
   Rule r("Statement", this);
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D42336: Fix memory leaks in TestArm64InstEmulation

2018-01-20 Thread Raphael Isemann via Phabricator via lldb-commits
teemperor created this revision.
teemperor added a reviewer: jasonmolenda.
Herald added subscribers: kristof.beyls, javed.absar, aemerson.

We never delete the created instances, so those test fail with the memory 
sanitizer.


https://reviews.llvm.org/D42336

Files:
  unittests/UnwindAssembly/InstEmulation/TestArm64InstEmulation.cpp


Index: unittests/UnwindAssembly/InstEmulation/TestArm64InstEmulation.cpp
===
--- unittests/UnwindAssembly/InstEmulation/TestArm64InstEmulation.cpp
+++ unittests/UnwindAssembly/InstEmulation/TestArm64InstEmulation.cpp
@@ -56,9 +56,9 @@
 
 TEST_F(TestArm64InstEmulation, TestSimpleDarwinFunction) {
   ArchSpec arch("arm64-apple-ios10");
-  UnwindAssemblyInstEmulation *engine =
+  std::unique_ptr engine(
   static_cast(
-  UnwindAssemblyInstEmulation::CreateInstance(arch));
+  UnwindAssemblyInstEmulation::CreateInstance(arch)));
   ASSERT_NE(nullptr, engine);
 
   UnwindPlan::RowSP row_sp;
@@ -152,9 +152,9 @@
 
 TEST_F(TestArm64InstEmulation, TestMediumDarwinFunction) {
   ArchSpec arch("arm64-apple-ios10");
-  UnwindAssemblyInstEmulation *engine =
+  std::unique_ptr engine(
   static_cast(
-  UnwindAssemblyInstEmulation::CreateInstance(arch));
+  UnwindAssemblyInstEmulation::CreateInstance(arch)));
   ASSERT_NE(nullptr, engine);
 
   UnwindPlan::RowSP row_sp;
@@ -314,9 +314,9 @@
 
 TEST_F(TestArm64InstEmulation, TestFramelessThreeEpilogueFunction) {
   ArchSpec arch("arm64-apple-ios10");
-  UnwindAssemblyInstEmulation *engine =
+  std::unique_ptr engine(
   static_cast(
-  UnwindAssemblyInstEmulation::CreateInstance(arch));
+  UnwindAssemblyInstEmulation::CreateInstance(arch)));
   ASSERT_NE(nullptr, engine);
 
   UnwindPlan::RowSP row_sp;
@@ -409,9 +409,9 @@
 
 TEST_F(TestArm64InstEmulation, TestRegisterSavedTwice) {
   ArchSpec arch("arm64-apple-ios10");
-  UnwindAssemblyInstEmulation *engine =
+  std::unique_ptr engine(
   static_cast(
-  UnwindAssemblyInstEmulation::CreateInstance(arch));
+  UnwindAssemblyInstEmulation::CreateInstance(arch)));
   ASSERT_NE(nullptr, engine);
 
   UnwindPlan::RowSP row_sp;
@@ -511,9 +511,9 @@
 
 TEST_F(TestArm64InstEmulation, TestRegisterDoubleSpills) {
   ArchSpec arch("arm64-apple-ios10");
-  UnwindAssemblyInstEmulation *engine =
+  std::unique_ptr engine(
   static_cast(
-  UnwindAssemblyInstEmulation::CreateInstance(arch));
+  UnwindAssemblyInstEmulation::CreateInstance(arch)));
   ASSERT_NE(nullptr, engine);
 
   UnwindPlan::RowSP row_sp;


Index: unittests/UnwindAssembly/InstEmulation/TestArm64InstEmulation.cpp
===
--- unittests/UnwindAssembly/InstEmulation/TestArm64InstEmulation.cpp
+++ unittests/UnwindAssembly/InstEmulation/TestArm64InstEmulation.cpp
@@ -56,9 +56,9 @@
 
 TEST_F(TestArm64InstEmulation, TestSimpleDarwinFunction) {
   ArchSpec arch("arm64-apple-ios10");
-  UnwindAssemblyInstEmulation *engine =
+  std::unique_ptr engine(
   static_cast(
-  UnwindAssemblyInstEmulation::CreateInstance(arch));
+  UnwindAssemblyInstEmulation::CreateInstance(arch)));
   ASSERT_NE(nullptr, engine);
 
   UnwindPlan::RowSP row_sp;
@@ -152,9 +152,9 @@
 
 TEST_F(TestArm64InstEmulation, TestMediumDarwinFunction) {
   ArchSpec arch("arm64-apple-ios10");
-  UnwindAssemblyInstEmulation *engine =
+  std::unique_ptr engine(
   static_cast(
-  UnwindAssemblyInstEmulation::CreateInstance(arch));
+  UnwindAssemblyInstEmulation::CreateInstance(arch)));
   ASSERT_NE(nullptr, engine);
 
   UnwindPlan::RowSP row_sp;
@@ -314,9 +314,9 @@
 
 TEST_F(TestArm64InstEmulation, TestFramelessThreeEpilogueFunction) {
   ArchSpec arch("arm64-apple-ios10");
-  UnwindAssemblyInstEmulation *engine =
+  std::unique_ptr engine(
   static_cast(
-  UnwindAssemblyInstEmulation::CreateInstance(arch));
+  UnwindAssemblyInstEmulation::CreateInstance(arch)));
   ASSERT_NE(nullptr, engine);
 
   UnwindPlan::RowSP row_sp;
@@ -409,9 +409,9 @@
 
 TEST_F(TestArm64InstEmulation, TestRegisterSavedTwice) {
   ArchSpec arch("arm64-apple-ios10");
-  UnwindAssemblyInstEmulation *engine =
+  std::unique_ptr engine(
   static_cast(
-  UnwindAssemblyInstEmulation::CreateInstance(arch));
+  UnwindAssemblyInstEmulation::CreateInstance(arch)));
   ASSERT_NE(nullptr, engine);
 
   UnwindPlan::RowSP row_sp;
@@ -511,9 +511,9 @@
 
 TEST_F(TestArm64InstEmulation, TestRegisterDoubleSpills) {
   ArchSpec arch("arm64-apple-ios10");
-  UnwindAssemblyInstEmulation *engine =
+  std::unique_ptr engine(
   static_cast(
-  UnwindAssemblyInstEmulation::CreateInstance(arch));
+  UnwindAssemblyInstEmulation::CreateInstance(arch)));
   ASSERT_NE(nullptr, engine);
 
   UnwindPlan::RowSP row_sp;
___
lldb-commits mailing list
lldb-commits@lists.llvm.org

[Lldb-commits] [PATCH] D42340: [modules] Fix missing includes/typo in LLDB's includes. [NFC]

2018-01-20 Thread Raphael Isemann via Phabricator via lldb-commits
teemperor created this revision.
teemperor added a reviewer: aprantl.

This patch adds missing includes to the LLDB headers inside `include/` as a 
first step of building LLDB's source with C++ modules. Includes in lldb seem to 
be commented if the reason for the include is not obvious (`// for addr_t`), so 
I tried to keep the same style here. It also fixes this single `stds::` typo.


https://reviews.llvm.org/D42340

Files:
  include/lldb/Core/LoadedModuleInfoList.h
  include/lldb/Core/ThreadSafeDenseSet.h
  include/lldb/Core/ThreadSafeValue.h
  include/lldb/DataFormatters/VectorIterator.h
  include/lldb/Target/ProcessStructReader.h
  include/lldb/Utility/AnsiTerminal.h
  include/lldb/Utility/SharedCluster.h


Index: include/lldb/Utility/SharedCluster.h
===
--- include/lldb/Utility/SharedCluster.h
+++ include/lldb/Utility/SharedCluster.h
@@ -15,6 +15,8 @@
 
 #include "llvm/ADT/SmallPtrSet.h"
 
+#include 
+
 namespace lldb_private {
 
 namespace imp {
Index: include/lldb/Utility/AnsiTerminal.h
===
--- include/lldb/Utility/AnsiTerminal.h
+++ include/lldb/Utility/AnsiTerminal.h
@@ -50,6 +50,7 @@
 #define ANSI_1_CTRL(ctrl1) "\033["##ctrl1 ANSI_ESC_END
 #define ANSI_2_CTRL(ctrl1, ctrl2) "\033["##ctrl1 ";"##ctrl2 ANSI_ESC_END
 
+#include "llvm/ADT/ArrayRef.h"
 #include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/StringRef.h"
 
Index: include/lldb/Target/ProcessStructReader.h
===
--- include/lldb/Target/ProcessStructReader.h
+++ include/lldb/Target/ProcessStructReader.h
@@ -16,6 +16,7 @@
 #include "lldb/Symbol/CompilerType.h"
 #include "lldb/Target/Process.h"
 #include "lldb/Utility/ConstString.h"
+#include "lldb/Utility/DataBufferHeap.h"
 #include "lldb/Utility/DataExtractor.h"
 #include "lldb/Utility/Status.h"
 
Index: include/lldb/DataFormatters/VectorIterator.h
===
--- include/lldb/DataFormatters/VectorIterator.h
+++ include/lldb/DataFormatters/VectorIterator.h
@@ -13,6 +13,7 @@
 
 #include "lldb/lldb-forward.h"
 
+#include "lldb/DataFormatters/TypeSynthetic.h" // for SyntheticChildrenFrontEnd
 #include "lldb/Target/ExecutionContext.h"
 #include "lldb/Utility/ConstString.h"
 
Index: include/lldb/Core/ThreadSafeValue.h
===
--- include/lldb/Core/ThreadSafeValue.h
+++ include/lldb/Core/ThreadSafeValue.h
@@ -17,6 +17,7 @@
 
 // Other libraries and framework includes
 // Project includes
+#include "lldb/lldb-defines.h" // for DISALLOW_COPY_AND_ASSIGN
 
 namespace lldb_private {
 
Index: include/lldb/Core/ThreadSafeDenseSet.h
===
--- include/lldb/Core/ThreadSafeDenseSet.h
+++ include/lldb/Core/ThreadSafeDenseSet.h
@@ -46,7 +46,7 @@
   }
 
   void Clear() {
-stds::lock_guard<_MutexType> guard(m_mutex);
+std::lock_guard<_MutexType> guard(m_mutex);
 m_set.clear();
   }
 
Index: include/lldb/Core/LoadedModuleInfoList.h
===
--- include/lldb/Core/LoadedModuleInfoList.h
+++ include/lldb/Core/LoadedModuleInfoList.h
@@ -13,10 +13,13 @@
 // C Includes
 
 // C++ Includes
+#include 
 #include 
 
 // Other libraries and framework includes
+#include "lldb/lldb-defines.h" // for LLDB_INVALID_ADDRESS
 #include "lldb/lldb-private-forward.h"
+#include "lldb/lldb-types.h" // for addr_t
 
 namespace lldb_private {
 class LoadedModuleInfoList {


Index: include/lldb/Utility/SharedCluster.h
===
--- include/lldb/Utility/SharedCluster.h
+++ include/lldb/Utility/SharedCluster.h
@@ -15,6 +15,8 @@
 
 #include "llvm/ADT/SmallPtrSet.h"
 
+#include 
+
 namespace lldb_private {
 
 namespace imp {
Index: include/lldb/Utility/AnsiTerminal.h
===
--- include/lldb/Utility/AnsiTerminal.h
+++ include/lldb/Utility/AnsiTerminal.h
@@ -50,6 +50,7 @@
 #define ANSI_1_CTRL(ctrl1) "\033["##ctrl1 ANSI_ESC_END
 #define ANSI_2_CTRL(ctrl1, ctrl2) "\033["##ctrl1 ";"##ctrl2 ANSI_ESC_END
 
+#include "llvm/ADT/ArrayRef.h"
 #include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/StringRef.h"
 
Index: include/lldb/Target/ProcessStructReader.h
===
--- include/lldb/Target/ProcessStructReader.h
+++ include/lldb/Target/ProcessStructReader.h
@@ -16,6 +16,7 @@
 #include "lldb/Symbol/CompilerType.h"
 #include "lldb/Target/Process.h"
 #include "lldb/Utility/ConstString.h"
+#include "lldb/Utility/DataBufferHeap.h"
 #include "lldb/Utility/DataExtractor.h"
 #include "lldb/Utility/Status.h"
 
Index: include/lldb/DataFormatters/VectorIterator.h
===
--- 

[Lldb-commits] [PATCH] D42347: Fix memory leaks in MinidumpParserTest

2018-01-20 Thread Raphael Isemann via Phabricator via lldb-commits
teemperor created this revision.
teemperor added a reviewer: dvlahovski.

We never delete the allocated RegisterContext objects, causing those tests to 
fail with enabled memory sanitizer.


https://reviews.llvm.org/D42347

Files:
  unittests/Process/minidump/MinidumpParserTest.cpp


Index: unittests/Process/minidump/MinidumpParserTest.cpp
===
--- unittests/Process/minidump/MinidumpParserTest.cpp
+++ unittests/Process/minidump/MinidumpParserTest.cpp
@@ -315,9 +315,10 @@
   llvm::ArrayRef registers(parser->GetThreadContext(thread));
 
   ArchSpec arch = parser->GetArchitecture();
-  RegisterInfoInterface *reg_interface = new RegisterContextLinux_i386(arch);
+  std::unique_ptr reg_interface(
+  new RegisterContextLinux_i386(arch));
   lldb::DataBufferSP buf =
-  ConvertMinidumpContext_x86_32(registers, reg_interface);
+  ConvertMinidumpContext_x86_32(registers, reg_interface.get());
   ASSERT_EQ(reg_interface->GetGPRSize(), buf->GetByteSize());
 
   const RegisterInfo *reg_info = reg_interface->GetRegisterInfo();
@@ -357,9 +358,10 @@
   llvm::ArrayRef registers(parser->GetThreadContext(thread));
 
   ArchSpec arch = parser->GetArchitecture();
-  RegisterInfoInterface *reg_interface = new RegisterContextLinux_x86_64(arch);
+  std::unique_ptr reg_interface(
+  new RegisterContextLinux_x86_64(arch));
   lldb::DataBufferSP buf =
-  ConvertMinidumpContext_x86_64(registers, reg_interface);
+  ConvertMinidumpContext_x86_64(registers, reg_interface.get());
   ASSERT_EQ(reg_interface->GetGPRSize(), buf->GetByteSize());
 
   const RegisterInfo *reg_info = reg_interface->GetRegisterInfo();
@@ -407,9 +409,10 @@
   llvm::ArrayRef registers(parser->GetThreadContextWow64(thread));
 
   ArchSpec arch = parser->GetArchitecture();
-  RegisterInfoInterface *reg_interface = new RegisterContextLinux_i386(arch);
+  std::unique_ptr reg_interface(
+  new RegisterContextLinux_i386(arch));
   lldb::DataBufferSP buf =
-  ConvertMinidumpContext_x86_32(registers, reg_interface);
+  ConvertMinidumpContext_x86_32(registers, reg_interface.get());
   ASSERT_EQ(reg_interface->GetGPRSize(), buf->GetByteSize());
 
   const RegisterInfo *reg_info = reg_interface->GetRegisterInfo();


Index: unittests/Process/minidump/MinidumpParserTest.cpp
===
--- unittests/Process/minidump/MinidumpParserTest.cpp
+++ unittests/Process/minidump/MinidumpParserTest.cpp
@@ -315,9 +315,10 @@
   llvm::ArrayRef registers(parser->GetThreadContext(thread));
 
   ArchSpec arch = parser->GetArchitecture();
-  RegisterInfoInterface *reg_interface = new RegisterContextLinux_i386(arch);
+  std::unique_ptr reg_interface(
+  new RegisterContextLinux_i386(arch));
   lldb::DataBufferSP buf =
-  ConvertMinidumpContext_x86_32(registers, reg_interface);
+  ConvertMinidumpContext_x86_32(registers, reg_interface.get());
   ASSERT_EQ(reg_interface->GetGPRSize(), buf->GetByteSize());
 
   const RegisterInfo *reg_info = reg_interface->GetRegisterInfo();
@@ -357,9 +358,10 @@
   llvm::ArrayRef registers(parser->GetThreadContext(thread));
 
   ArchSpec arch = parser->GetArchitecture();
-  RegisterInfoInterface *reg_interface = new RegisterContextLinux_x86_64(arch);
+  std::unique_ptr reg_interface(
+  new RegisterContextLinux_x86_64(arch));
   lldb::DataBufferSP buf =
-  ConvertMinidumpContext_x86_64(registers, reg_interface);
+  ConvertMinidumpContext_x86_64(registers, reg_interface.get());
   ASSERT_EQ(reg_interface->GetGPRSize(), buf->GetByteSize());
 
   const RegisterInfo *reg_info = reg_interface->GetRegisterInfo();
@@ -407,9 +409,10 @@
   llvm::ArrayRef registers(parser->GetThreadContextWow64(thread));
 
   ArchSpec arch = parser->GetArchitecture();
-  RegisterInfoInterface *reg_interface = new RegisterContextLinux_i386(arch);
+  std::unique_ptr reg_interface(
+  new RegisterContextLinux_i386(arch));
   lldb::DataBufferSP buf =
-  ConvertMinidumpContext_x86_32(registers, reg_interface);
+  ConvertMinidumpContext_x86_32(registers, reg_interface.get());
   ASSERT_EQ(reg_interface->GetGPRSize(), buf->GetByteSize());
 
   const RegisterInfo *reg_info = reg_interface->GetRegisterInfo();
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D42340: [modules] Fix missing includes/typo in LLDB's includes. [NFC]

2018-01-21 Thread Raphael Isemann via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL323064: [modules] Fix missing includes/typo in LLDBs 
includes. [NFC] (authored by teemperor, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D42340?vs=130784=130800#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D42340

Files:
  lldb/trunk/include/lldb/Core/LoadedModuleInfoList.h
  lldb/trunk/include/lldb/Core/ThreadSafeDenseSet.h
  lldb/trunk/include/lldb/Core/ThreadSafeValue.h
  lldb/trunk/include/lldb/DataFormatters/VectorIterator.h
  lldb/trunk/include/lldb/Target/ProcessStructReader.h
  lldb/trunk/include/lldb/Utility/AnsiTerminal.h
  lldb/trunk/include/lldb/Utility/SharedCluster.h


Index: lldb/trunk/include/lldb/DataFormatters/VectorIterator.h
===
--- lldb/trunk/include/lldb/DataFormatters/VectorIterator.h
+++ lldb/trunk/include/lldb/DataFormatters/VectorIterator.h
@@ -13,6 +13,7 @@
 
 #include "lldb/lldb-forward.h"
 
+#include "lldb/DataFormatters/TypeSynthetic.h"
 #include "lldb/Target/ExecutionContext.h"
 #include "lldb/Utility/ConstString.h"
 
Index: lldb/trunk/include/lldb/Utility/SharedCluster.h
===
--- lldb/trunk/include/lldb/Utility/SharedCluster.h
+++ lldb/trunk/include/lldb/Utility/SharedCluster.h
@@ -15,6 +15,8 @@
 
 #include "llvm/ADT/SmallPtrSet.h"
 
+#include 
+
 namespace lldb_private {
 
 namespace imp {
Index: lldb/trunk/include/lldb/Utility/AnsiTerminal.h
===
--- lldb/trunk/include/lldb/Utility/AnsiTerminal.h
+++ lldb/trunk/include/lldb/Utility/AnsiTerminal.h
@@ -50,6 +50,7 @@
 #define ANSI_1_CTRL(ctrl1) "\033["##ctrl1 ANSI_ESC_END
 #define ANSI_2_CTRL(ctrl1, ctrl2) "\033["##ctrl1 ";"##ctrl2 ANSI_ESC_END
 
+#include "llvm/ADT/ArrayRef.h"
 #include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/StringRef.h"
 
Index: lldb/trunk/include/lldb/Core/LoadedModuleInfoList.h
===
--- lldb/trunk/include/lldb/Core/LoadedModuleInfoList.h
+++ lldb/trunk/include/lldb/Core/LoadedModuleInfoList.h
@@ -13,10 +13,13 @@
 // C Includes
 
 // C++ Includes
+#include 
 #include 
 
 // Other libraries and framework includes
+#include "lldb/lldb-defines.h"
 #include "lldb/lldb-private-forward.h"
+#include "lldb/lldb-types.h"
 
 namespace lldb_private {
 class LoadedModuleInfoList {
Index: lldb/trunk/include/lldb/Core/ThreadSafeValue.h
===
--- lldb/trunk/include/lldb/Core/ThreadSafeValue.h
+++ lldb/trunk/include/lldb/Core/ThreadSafeValue.h
@@ -17,6 +17,7 @@
 
 // Other libraries and framework includes
 // Project includes
+#include "lldb/lldb-defines.h"
 
 namespace lldb_private {
 
Index: lldb/trunk/include/lldb/Core/ThreadSafeDenseSet.h
===
--- lldb/trunk/include/lldb/Core/ThreadSafeDenseSet.h
+++ lldb/trunk/include/lldb/Core/ThreadSafeDenseSet.h
@@ -46,7 +46,7 @@
   }
 
   void Clear() {
-stds::lock_guard<_MutexType> guard(m_mutex);
+std::lock_guard<_MutexType> guard(m_mutex);
 m_set.clear();
   }
 
Index: lldb/trunk/include/lldb/Target/ProcessStructReader.h
===
--- lldb/trunk/include/lldb/Target/ProcessStructReader.h
+++ lldb/trunk/include/lldb/Target/ProcessStructReader.h
@@ -16,6 +16,7 @@
 #include "lldb/Symbol/CompilerType.h"
 #include "lldb/Target/Process.h"
 #include "lldb/Utility/ConstString.h"
+#include "lldb/Utility/DataBufferHeap.h"
 #include "lldb/Utility/DataExtractor.h"
 #include "lldb/Utility/Status.h"
 


Index: lldb/trunk/include/lldb/DataFormatters/VectorIterator.h
===
--- lldb/trunk/include/lldb/DataFormatters/VectorIterator.h
+++ lldb/trunk/include/lldb/DataFormatters/VectorIterator.h
@@ -13,6 +13,7 @@
 
 #include "lldb/lldb-forward.h"
 
+#include "lldb/DataFormatters/TypeSynthetic.h"
 #include "lldb/Target/ExecutionContext.h"
 #include "lldb/Utility/ConstString.h"
 
Index: lldb/trunk/include/lldb/Utility/SharedCluster.h
===
--- lldb/trunk/include/lldb/Utility/SharedCluster.h
+++ lldb/trunk/include/lldb/Utility/SharedCluster.h
@@ -15,6 +15,8 @@
 
 #include "llvm/ADT/SmallPtrSet.h"
 
+#include 
+
 namespace lldb_private {
 
 namespace imp {
Index: lldb/trunk/include/lldb/Utility/AnsiTerminal.h
===
--- lldb/trunk/include/lldb/Utility/AnsiTerminal.h
+++ lldb/trunk/include/lldb/Utility/AnsiTerminal.h
@@ -50,6 +50,7 @@
 #define ANSI_1_CTRL(ctrl1) "\033["##ctrl1 ANSI_ESC_END
 #define ANSI_2_CTRL(ctrl1, ctrl2) "\033["##ctrl1 ";"##ctrl2 ANSI_ESC_END
 
+#include "llvm/ADT/ArrayRef.h"
 #include 

[Lldb-commits] [PATCH] D42345: Make loop counter unsigned in SymbolFilePDB::GetCompileUnitIndex

2018-01-20 Thread Raphael Isemann via Phabricator via lldb-commits
teemperor created this revision.

This fixes a clang warning.


https://reviews.llvm.org/D42345

Files:
  source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp


Index: source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp
===
--- source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp
+++ source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp
@@ -211,7 +211,7 @@
   if (!results_up)
 return;
   auto uid = pdb_compiland->getSymIndexId();
-  for (int cu_idx = 0; cu_idx < GetNumCompileUnits(); ++cu_idx) {
+  for (uint32_t cu_idx = 0; cu_idx < GetNumCompileUnits(); ++cu_idx) {
 auto compiland_up = results_up->getChildAtIndex(cu_idx);
 if (!compiland_up)
   continue;


Index: source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp
===
--- source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp
+++ source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp
@@ -211,7 +211,7 @@
   if (!results_up)
 return;
   auto uid = pdb_compiland->getSymIndexId();
-  for (int cu_idx = 0; cu_idx < GetNumCompileUnits(); ++cu_idx) {
+  for (uint32_t cu_idx = 0; cu_idx < GetNumCompileUnits(); ++cu_idx) {
 auto compiland_up = results_up->getChildAtIndex(cu_idx);
 if (!compiland_up)
   continue;
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D42346: Fix use after free in DiskFilesOrDirectories

2018-01-20 Thread Raphael Isemann via Phabricator via lldb-commits
teemperor created this revision.
teemperor added a reviewer: zturner.

We copy the local variable `Resolved` into `Storage` to keep it around. 
However, we then still let the `SearchDir` ref point to `Resolved` which then 
is used to access the already freed memory later on. With this patch we point 
to `Storage` which doesn't get deleted after the current scope exits.

Discovered by memory sanitizer in the CompletionTest.DirCompletionUsername test.


https://reviews.llvm.org/D42346

Files:
  source/Commands/CommandCompletions.cpp


Index: source/Commands/CommandCompletions.cpp
===
--- source/Commands/CommandCompletions.cpp
+++ source/Commands/CommandCompletions.cpp
@@ -165,7 +165,7 @@
 // search in the fully resolved directory, but CompletionBuffer keeps the
 // unmodified form that the user typed.
 Storage = Resolved;
-SearchDir = Resolved;
+SearchDir = Storage;
   } else {
 SearchDir = path::parent_path(CompletionBuffer);
   }


Index: source/Commands/CommandCompletions.cpp
===
--- source/Commands/CommandCompletions.cpp
+++ source/Commands/CommandCompletions.cpp
@@ -165,7 +165,7 @@
 // search in the fully resolved directory, but CompletionBuffer keeps the
 // unmodified form that the user typed.
 Storage = Resolved;
-SearchDir = Resolved;
+SearchDir = Storage;
   } else {
 SearchDir = path::parent_path(CompletionBuffer);
   }
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D42348: Prevent unaligned memory read in parseMinidumpString

2018-01-20 Thread Raphael Isemann via Phabricator via lldb-commits
teemperor created this revision.
teemperor added reviewers: dvlahovski, zturner.

It's possible to hit an unaligned memory read when reading `source_length` as 
the `data` array is only aligned with 2 bytes (it's actually a UTF16 array). 
This patch memcpy's `source_length` into a local variable to prevent this:

  MinidumpTypes.cpp:49:23: runtime error: load of misaligned address 
0x7f0f4792692a for type 'const uint32_t' (aka 'const unsigned int'), which 
requires 4 byte alignment


https://reviews.llvm.org/D42348

Files:
  source/Plugins/Process/minidump/MinidumpTypes.cpp


Index: source/Plugins/Process/minidump/MinidumpTypes.cpp
===
--- source/Plugins/Process/minidump/MinidumpTypes.cpp
+++ source/Plugins/Process/minidump/MinidumpTypes.cpp
@@ -44,19 +44,24 @@
 lldb_private::minidump::parseMinidumpString(llvm::ArrayRef ) {
   std::string result;
 
-  const uint32_t *source_length;
-  Status error = consumeObject(data, source_length);
-  if (error.Fail() || *source_length > data.size() || *source_length % 2 != 0)
+  const uint32_t *source_length_ptr;
+  Status error = consumeObject(data, source_length_ptr);
+
+  // Copy non-aligned source_length data into aligned memory.
+  uint32_t source_length;
+  std::memcpy(_length, source_length_ptr, sizeof(source_length));
+
+  if (error.Fail() || source_length > data.size() || source_length % 2 != 0)
 return llvm::None;
 
   auto source_start = reinterpret_cast(data.data());
   // source_length is the length of the string in bytes
   // we need the length of the string in UTF-16 characters/code points (16 bits
   // per char)
   // that's why it's divided by 2
-  const auto source_end = source_start + (*source_length) / 2;
+  const auto source_end = source_start + source_length / 2;
   // resize to worst case length
-  result.resize(UNI_MAX_UTF8_BYTES_PER_CODE_POINT * (*source_length) / 2);
+  result.resize(UNI_MAX_UTF8_BYTES_PER_CODE_POINT * source_length / 2);
   auto result_start = reinterpret_cast([0]);
   const auto result_end = result_start + result.size();
   llvm::ConvertUTF16toUTF8(_start, source_end, _start, 
result_end,


Index: source/Plugins/Process/minidump/MinidumpTypes.cpp
===
--- source/Plugins/Process/minidump/MinidumpTypes.cpp
+++ source/Plugins/Process/minidump/MinidumpTypes.cpp
@@ -44,19 +44,24 @@
 lldb_private::minidump::parseMinidumpString(llvm::ArrayRef ) {
   std::string result;
 
-  const uint32_t *source_length;
-  Status error = consumeObject(data, source_length);
-  if (error.Fail() || *source_length > data.size() || *source_length % 2 != 0)
+  const uint32_t *source_length_ptr;
+  Status error = consumeObject(data, source_length_ptr);
+
+  // Copy non-aligned source_length data into aligned memory.
+  uint32_t source_length;
+  std::memcpy(_length, source_length_ptr, sizeof(source_length));
+
+  if (error.Fail() || source_length > data.size() || source_length % 2 != 0)
 return llvm::None;
 
   auto source_start = reinterpret_cast(data.data());
   // source_length is the length of the string in bytes
   // we need the length of the string in UTF-16 characters/code points (16 bits
   // per char)
   // that's why it's divided by 2
-  const auto source_end = source_start + (*source_length) / 2;
+  const auto source_end = source_start + source_length / 2;
   // resize to worst case length
-  result.resize(UNI_MAX_UTF8_BYTES_PER_CODE_POINT * (*source_length) / 2);
+  result.resize(UNI_MAX_UTF8_BYTES_PER_CODE_POINT * source_length / 2);
   auto result_start = reinterpret_cast([0]);
   const auto result_end = result_start + result.size();
   llvm::ConvertUTF16toUTF8(_start, source_end, _start, result_end,
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D42346: Fix use after free in DiskFilesOrDirectories

2018-01-22 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 rL323082: Fix use after free in DiskFilesOrDirectories 
(authored by teemperor, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D42346?vs=130796=130841#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D42346

Files:
  lldb/trunk/source/Commands/CommandCompletions.cpp


Index: lldb/trunk/source/Commands/CommandCompletions.cpp
===
--- lldb/trunk/source/Commands/CommandCompletions.cpp
+++ lldb/trunk/source/Commands/CommandCompletions.cpp
@@ -165,7 +165,7 @@
 // search in the fully resolved directory, but CompletionBuffer keeps the
 // unmodified form that the user typed.
 Storage = Resolved;
-SearchDir = Resolved;
+SearchDir = Storage;
   } else {
 SearchDir = path::parent_path(CompletionBuffer);
   }


Index: lldb/trunk/source/Commands/CommandCompletions.cpp
===
--- lldb/trunk/source/Commands/CommandCompletions.cpp
+++ lldb/trunk/source/Commands/CommandCompletions.cpp
@@ -165,7 +165,7 @@
 // search in the fully resolved directory, but CompletionBuffer keeps the
 // unmodified form that the user typed.
 Storage = Resolved;
-SearchDir = Resolved;
+SearchDir = Storage;
   } else {
 SearchDir = path::parent_path(CompletionBuffer);
   }
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D42345: Make loop counter unsigned in SymbolFilePDB::GetCompileUnitIndex

2018-01-21 Thread Raphael Isemann via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL323075: Make loop counter unsigned in 
SymbolFilePDB::GetCompileUnitIndex (authored by teemperor, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D42345?vs=130794=130831#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D42345

Files:
  lldb/trunk/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp


Index: lldb/trunk/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp
===
--- lldb/trunk/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp
+++ lldb/trunk/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp
@@ -211,7 +211,7 @@
   if (!results_up)
 return;
   auto uid = pdb_compiland->getSymIndexId();
-  for (int cu_idx = 0; cu_idx < GetNumCompileUnits(); ++cu_idx) {
+  for (uint32_t cu_idx = 0; cu_idx < GetNumCompileUnits(); ++cu_idx) {
 auto compiland_up = results_up->getChildAtIndex(cu_idx);
 if (!compiland_up)
   continue;


Index: lldb/trunk/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp
===
--- lldb/trunk/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp
+++ lldb/trunk/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp
@@ -211,7 +211,7 @@
   if (!results_up)
 return;
   auto uid = pdb_compiland->getSymIndexId();
-  for (int cu_idx = 0; cu_idx < GetNumCompileUnits(); ++cu_idx) {
+  for (uint32_t cu_idx = 0; cu_idx < GetNumCompileUnits(); ++cu_idx) {
 auto compiland_up = results_up->getChildAtIndex(cu_idx);
 if (!compiland_up)
   continue;
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D42336: Fix memory leaks in TestArm64InstEmulation

2018-01-21 Thread Raphael Isemann via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL323076: Fix memory leaks in TestArm64InstEmulation (authored 
by teemperor, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D42336?vs=130777=130835#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D42336

Files:
  lldb/trunk/unittests/UnwindAssembly/InstEmulation/TestArm64InstEmulation.cpp


Index: 
lldb/trunk/unittests/UnwindAssembly/InstEmulation/TestArm64InstEmulation.cpp
===
--- lldb/trunk/unittests/UnwindAssembly/InstEmulation/TestArm64InstEmulation.cpp
+++ lldb/trunk/unittests/UnwindAssembly/InstEmulation/TestArm64InstEmulation.cpp
@@ -56,9 +56,9 @@
 
 TEST_F(TestArm64InstEmulation, TestSimpleDarwinFunction) {
   ArchSpec arch("arm64-apple-ios10");
-  UnwindAssemblyInstEmulation *engine =
+  std::unique_ptr engine(
   static_cast(
-  UnwindAssemblyInstEmulation::CreateInstance(arch));
+  UnwindAssemblyInstEmulation::CreateInstance(arch)));
   ASSERT_NE(nullptr, engine);
 
   UnwindPlan::RowSP row_sp;
@@ -152,9 +152,9 @@
 
 TEST_F(TestArm64InstEmulation, TestMediumDarwinFunction) {
   ArchSpec arch("arm64-apple-ios10");
-  UnwindAssemblyInstEmulation *engine =
+  std::unique_ptr engine(
   static_cast(
-  UnwindAssemblyInstEmulation::CreateInstance(arch));
+  UnwindAssemblyInstEmulation::CreateInstance(arch)));
   ASSERT_NE(nullptr, engine);
 
   UnwindPlan::RowSP row_sp;
@@ -314,9 +314,9 @@
 
 TEST_F(TestArm64InstEmulation, TestFramelessThreeEpilogueFunction) {
   ArchSpec arch("arm64-apple-ios10");
-  UnwindAssemblyInstEmulation *engine =
+  std::unique_ptr engine(
   static_cast(
-  UnwindAssemblyInstEmulation::CreateInstance(arch));
+  UnwindAssemblyInstEmulation::CreateInstance(arch)));
   ASSERT_NE(nullptr, engine);
 
   UnwindPlan::RowSP row_sp;
@@ -409,9 +409,9 @@
 
 TEST_F(TestArm64InstEmulation, TestRegisterSavedTwice) {
   ArchSpec arch("arm64-apple-ios10");
-  UnwindAssemblyInstEmulation *engine =
+  std::unique_ptr engine(
   static_cast(
-  UnwindAssemblyInstEmulation::CreateInstance(arch));
+  UnwindAssemblyInstEmulation::CreateInstance(arch)));
   ASSERT_NE(nullptr, engine);
 
   UnwindPlan::RowSP row_sp;
@@ -511,9 +511,9 @@
 
 TEST_F(TestArm64InstEmulation, TestRegisterDoubleSpills) {
   ArchSpec arch("arm64-apple-ios10");
-  UnwindAssemblyInstEmulation *engine =
+  std::unique_ptr engine(
   static_cast(
-  UnwindAssemblyInstEmulation::CreateInstance(arch));
+  UnwindAssemblyInstEmulation::CreateInstance(arch)));
   ASSERT_NE(nullptr, engine);
 
   UnwindPlan::RowSP row_sp;


Index: lldb/trunk/unittests/UnwindAssembly/InstEmulation/TestArm64InstEmulation.cpp
===
--- lldb/trunk/unittests/UnwindAssembly/InstEmulation/TestArm64InstEmulation.cpp
+++ lldb/trunk/unittests/UnwindAssembly/InstEmulation/TestArm64InstEmulation.cpp
@@ -56,9 +56,9 @@
 
 TEST_F(TestArm64InstEmulation, TestSimpleDarwinFunction) {
   ArchSpec arch("arm64-apple-ios10");
-  UnwindAssemblyInstEmulation *engine =
+  std::unique_ptr engine(
   static_cast(
-  UnwindAssemblyInstEmulation::CreateInstance(arch));
+  UnwindAssemblyInstEmulation::CreateInstance(arch)));
   ASSERT_NE(nullptr, engine);
 
   UnwindPlan::RowSP row_sp;
@@ -152,9 +152,9 @@
 
 TEST_F(TestArm64InstEmulation, TestMediumDarwinFunction) {
   ArchSpec arch("arm64-apple-ios10");
-  UnwindAssemblyInstEmulation *engine =
+  std::unique_ptr engine(
   static_cast(
-  UnwindAssemblyInstEmulation::CreateInstance(arch));
+  UnwindAssemblyInstEmulation::CreateInstance(arch)));
   ASSERT_NE(nullptr, engine);
 
   UnwindPlan::RowSP row_sp;
@@ -314,9 +314,9 @@
 
 TEST_F(TestArm64InstEmulation, TestFramelessThreeEpilogueFunction) {
   ArchSpec arch("arm64-apple-ios10");
-  UnwindAssemblyInstEmulation *engine =
+  std::unique_ptr engine(
   static_cast(
-  UnwindAssemblyInstEmulation::CreateInstance(arch));
+  UnwindAssemblyInstEmulation::CreateInstance(arch)));
   ASSERT_NE(nullptr, engine);
 
   UnwindPlan::RowSP row_sp;
@@ -409,9 +409,9 @@
 
 TEST_F(TestArm64InstEmulation, TestRegisterSavedTwice) {
   ArchSpec arch("arm64-apple-ios10");
-  UnwindAssemblyInstEmulation *engine =
+  std::unique_ptr engine(
   static_cast(
-  UnwindAssemblyInstEmulation::CreateInstance(arch));
+  UnwindAssemblyInstEmulation::CreateInstance(arch)));
   ASSERT_NE(nullptr, engine);
 
   UnwindPlan::RowSP row_sp;
@@ -511,9 +511,9 @@
 
 TEST_F(TestArm64InstEmulation, TestRegisterDoubleSpills) {
   ArchSpec arch("arm64-apple-ios10");
-  UnwindAssemblyInstEmulation *engine =
+  std::unique_ptr engine(
   static_cast(
-  UnwindAssemblyInstEmulation::CreateInstance(arch));
+  

[Lldb-commits] [PATCH] D42338: Fix unrepresentable float value in ScalarTest

2018-01-22 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 rL323081: Fix unrepresentable float value in ScalarTest 
(authored by teemperor, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D42338?vs=130778=130838#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D42338

Files:
  lldb/trunk/unittests/Core/ScalarTest.cpp


Index: lldb/trunk/unittests/Core/ScalarTest.cpp
===
--- lldb/trunk/unittests/Core/ScalarTest.cpp
+++ lldb/trunk/unittests/Core/ScalarTest.cpp
@@ -31,7 +31,7 @@
 TEST(ScalarTest, GetBytes) {
   int a = 0x01020304;
   long long b = 0x0102030405060708LL;
-  float c = 1234567.89e42;
+  float c = 1234567.89e32;
   double d = 1234567.89e42;
   char e[16] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16};
   char f[32] = {1,  2,  3,  4,  5,  6,  7,  8,  9,  10, 11, 12, 13, 14, 15, 16,


Index: lldb/trunk/unittests/Core/ScalarTest.cpp
===
--- lldb/trunk/unittests/Core/ScalarTest.cpp
+++ lldb/trunk/unittests/Core/ScalarTest.cpp
@@ -31,7 +31,7 @@
 TEST(ScalarTest, GetBytes) {
   int a = 0x01020304;
   long long b = 0x0102030405060708LL;
-  float c = 1234567.89e42;
+  float c = 1234567.89e32;
   double d = 1234567.89e42;
   char e[16] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16};
   char f[32] = {1,  2,  3,  4,  5,  6,  7,  8,  9,  10, 11, 12, 13, 14, 15, 16,
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D42347: Fix memory leaks in MinidumpParserTest

2018-01-22 Thread Raphael Isemann via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL323085: Fix memory leaks in MinidumpParserTest (authored by 
teemperor, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D42347?vs=130846=130847#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D42347

Files:
  lldb/trunk/unittests/Process/minidump/MinidumpParserTest.cpp


Index: lldb/trunk/unittests/Process/minidump/MinidumpParserTest.cpp
===
--- lldb/trunk/unittests/Process/minidump/MinidumpParserTest.cpp
+++ lldb/trunk/unittests/Process/minidump/MinidumpParserTest.cpp
@@ -315,9 +315,9 @@
   llvm::ArrayRef registers(parser->GetThreadContext(thread));
 
   ArchSpec arch = parser->GetArchitecture();
-  RegisterInfoInterface *reg_interface = new RegisterContextLinux_i386(arch);
+  auto reg_interface = llvm::make_unique(arch);
   lldb::DataBufferSP buf =
-  ConvertMinidumpContext_x86_32(registers, reg_interface);
+  ConvertMinidumpContext_x86_32(registers, reg_interface.get());
   ASSERT_EQ(reg_interface->GetGPRSize(), buf->GetByteSize());
 
   const RegisterInfo *reg_info = reg_interface->GetRegisterInfo();
@@ -357,9 +357,9 @@
   llvm::ArrayRef registers(parser->GetThreadContext(thread));
 
   ArchSpec arch = parser->GetArchitecture();
-  RegisterInfoInterface *reg_interface = new RegisterContextLinux_x86_64(arch);
+  auto reg_interface = llvm::make_unique(arch);
   lldb::DataBufferSP buf =
-  ConvertMinidumpContext_x86_64(registers, reg_interface);
+  ConvertMinidumpContext_x86_64(registers, reg_interface.get());
   ASSERT_EQ(reg_interface->GetGPRSize(), buf->GetByteSize());
 
   const RegisterInfo *reg_info = reg_interface->GetRegisterInfo();
@@ -407,9 +407,9 @@
   llvm::ArrayRef registers(parser->GetThreadContextWow64(thread));
 
   ArchSpec arch = parser->GetArchitecture();
-  RegisterInfoInterface *reg_interface = new RegisterContextLinux_i386(arch);
+  auto reg_interface = llvm::make_unique(arch);
   lldb::DataBufferSP buf =
-  ConvertMinidumpContext_x86_32(registers, reg_interface);
+  ConvertMinidumpContext_x86_32(registers, reg_interface.get());
   ASSERT_EQ(reg_interface->GetGPRSize(), buf->GetByteSize());
 
   const RegisterInfo *reg_info = reg_interface->GetRegisterInfo();


Index: lldb/trunk/unittests/Process/minidump/MinidumpParserTest.cpp
===
--- lldb/trunk/unittests/Process/minidump/MinidumpParserTest.cpp
+++ lldb/trunk/unittests/Process/minidump/MinidumpParserTest.cpp
@@ -315,9 +315,9 @@
   llvm::ArrayRef registers(parser->GetThreadContext(thread));
 
   ArchSpec arch = parser->GetArchitecture();
-  RegisterInfoInterface *reg_interface = new RegisterContextLinux_i386(arch);
+  auto reg_interface = llvm::make_unique(arch);
   lldb::DataBufferSP buf =
-  ConvertMinidumpContext_x86_32(registers, reg_interface);
+  ConvertMinidumpContext_x86_32(registers, reg_interface.get());
   ASSERT_EQ(reg_interface->GetGPRSize(), buf->GetByteSize());
 
   const RegisterInfo *reg_info = reg_interface->GetRegisterInfo();
@@ -357,9 +357,9 @@
   llvm::ArrayRef registers(parser->GetThreadContext(thread));
 
   ArchSpec arch = parser->GetArchitecture();
-  RegisterInfoInterface *reg_interface = new RegisterContextLinux_x86_64(arch);
+  auto reg_interface = llvm::make_unique(arch);
   lldb::DataBufferSP buf =
-  ConvertMinidumpContext_x86_64(registers, reg_interface);
+  ConvertMinidumpContext_x86_64(registers, reg_interface.get());
   ASSERT_EQ(reg_interface->GetGPRSize(), buf->GetByteSize());
 
   const RegisterInfo *reg_info = reg_interface->GetRegisterInfo();
@@ -407,9 +407,9 @@
   llvm::ArrayRef registers(parser->GetThreadContextWow64(thread));
 
   ArchSpec arch = parser->GetArchitecture();
-  RegisterInfoInterface *reg_interface = new RegisterContextLinux_i386(arch);
+  auto reg_interface = llvm::make_unique(arch);
   lldb::DataBufferSP buf =
-  ConvertMinidumpContext_x86_32(registers, reg_interface);
+  ConvertMinidumpContext_x86_32(registers, reg_interface.get());
   ASSERT_EQ(reg_interface->GetGPRSize(), buf->GetByteSize());
 
   const RegisterInfo *reg_info = reg_interface->GetRegisterInfo();
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D42347: Fix memory leaks in MinidumpParserTest

2018-01-22 Thread Raphael Isemann via Phabricator via lldb-commits
teemperor updated this revision to Diff 130846.
teemperor added a comment.

- Using make_unique now.


https://reviews.llvm.org/D42347

Files:
  unittests/Process/minidump/MinidumpParserTest.cpp


Index: unittests/Process/minidump/MinidumpParserTest.cpp
===
--- unittests/Process/minidump/MinidumpParserTest.cpp
+++ unittests/Process/minidump/MinidumpParserTest.cpp
@@ -315,9 +315,9 @@
   llvm::ArrayRef registers(parser->GetThreadContext(thread));
 
   ArchSpec arch = parser->GetArchitecture();
-  RegisterInfoInterface *reg_interface = new RegisterContextLinux_i386(arch);
+  auto reg_interface = llvm::make_unique(arch);
   lldb::DataBufferSP buf =
-  ConvertMinidumpContext_x86_32(registers, reg_interface);
+  ConvertMinidumpContext_x86_32(registers, reg_interface.get());
   ASSERT_EQ(reg_interface->GetGPRSize(), buf->GetByteSize());
 
   const RegisterInfo *reg_info = reg_interface->GetRegisterInfo();
@@ -357,9 +357,9 @@
   llvm::ArrayRef registers(parser->GetThreadContext(thread));
 
   ArchSpec arch = parser->GetArchitecture();
-  RegisterInfoInterface *reg_interface = new RegisterContextLinux_x86_64(arch);
+  auto reg_interface = llvm::make_unique(arch);
   lldb::DataBufferSP buf =
-  ConvertMinidumpContext_x86_64(registers, reg_interface);
+  ConvertMinidumpContext_x86_64(registers, reg_interface.get());
   ASSERT_EQ(reg_interface->GetGPRSize(), buf->GetByteSize());
 
   const RegisterInfo *reg_info = reg_interface->GetRegisterInfo();
@@ -407,9 +407,9 @@
   llvm::ArrayRef registers(parser->GetThreadContextWow64(thread));
 
   ArchSpec arch = parser->GetArchitecture();
-  RegisterInfoInterface *reg_interface = new RegisterContextLinux_i386(arch);
+  auto reg_interface = llvm::make_unique(arch);
   lldb::DataBufferSP buf =
-  ConvertMinidumpContext_x86_32(registers, reg_interface);
+  ConvertMinidumpContext_x86_32(registers, reg_interface.get());
   ASSERT_EQ(reg_interface->GetGPRSize(), buf->GetByteSize());
 
   const RegisterInfo *reg_info = reg_interface->GetRegisterInfo();


Index: unittests/Process/minidump/MinidumpParserTest.cpp
===
--- unittests/Process/minidump/MinidumpParserTest.cpp
+++ unittests/Process/minidump/MinidumpParserTest.cpp
@@ -315,9 +315,9 @@
   llvm::ArrayRef registers(parser->GetThreadContext(thread));
 
   ArchSpec arch = parser->GetArchitecture();
-  RegisterInfoInterface *reg_interface = new RegisterContextLinux_i386(arch);
+  auto reg_interface = llvm::make_unique(arch);
   lldb::DataBufferSP buf =
-  ConvertMinidumpContext_x86_32(registers, reg_interface);
+  ConvertMinidumpContext_x86_32(registers, reg_interface.get());
   ASSERT_EQ(reg_interface->GetGPRSize(), buf->GetByteSize());
 
   const RegisterInfo *reg_info = reg_interface->GetRegisterInfo();
@@ -357,9 +357,9 @@
   llvm::ArrayRef registers(parser->GetThreadContext(thread));
 
   ArchSpec arch = parser->GetArchitecture();
-  RegisterInfoInterface *reg_interface = new RegisterContextLinux_x86_64(arch);
+  auto reg_interface = llvm::make_unique(arch);
   lldb::DataBufferSP buf =
-  ConvertMinidumpContext_x86_64(registers, reg_interface);
+  ConvertMinidumpContext_x86_64(registers, reg_interface.get());
   ASSERT_EQ(reg_interface->GetGPRSize(), buf->GetByteSize());
 
   const RegisterInfo *reg_info = reg_interface->GetRegisterInfo();
@@ -407,9 +407,9 @@
   llvm::ArrayRef registers(parser->GetThreadContextWow64(thread));
 
   ArchSpec arch = parser->GetArchitecture();
-  RegisterInfoInterface *reg_interface = new RegisterContextLinux_i386(arch);
+  auto reg_interface = llvm::make_unique(arch);
   lldb::DataBufferSP buf =
-  ConvertMinidumpContext_x86_32(registers, reg_interface);
+  ConvertMinidumpContext_x86_32(registers, reg_interface.get());
   ASSERT_EQ(reg_interface->GetGPRSize(), buf->GetByteSize());
 
   const RegisterInfo *reg_info = reg_interface->GetRegisterInfo();
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D42386: Fix memory leak in TestClangASTContext.TestRecordHasFields

2018-01-22 Thread Raphael Isemann via Phabricator via lldb-commits
teemperor created this revision.

We can't use unique_ptr's here because we use those variables as `out` 
parameters to some functions. Discovered by the memory sanitizer.


https://reviews.llvm.org/D42386

Files:
  unittests/Symbol/TestClangASTContext.cpp


Index: unittests/Symbol/TestClangASTContext.cpp
===
--- unittests/Symbol/TestClangASTContext.cpp
+++ unittests/Symbol/TestClangASTContext.cpp
@@ -11,6 +11,8 @@
 
 #include "gtest/gtest.h"
 
+#include "clang/AST/DeclCXX.h"
+
 #include "lldb/Host/HostInfo.h"
 #include "lldb/Symbol/ClangASTContext.h"
 #include "lldb/Symbol/ClangUtil.h"
@@ -375,6 +377,9 @@
empty_derived_non_empty_vbase_cxx_decl, false));
   EXPECT_TRUE(
   ClangASTContext::RecordHasFields(empty_derived_non_empty_vbase_decl));
+
+  delete non_empty_base_spec;
+  delete non_empty_vbase_spec;
 }
 
 TEST_F(TestClangASTContext, TemplateArguments) {


Index: unittests/Symbol/TestClangASTContext.cpp
===
--- unittests/Symbol/TestClangASTContext.cpp
+++ unittests/Symbol/TestClangASTContext.cpp
@@ -11,6 +11,8 @@
 
 #include "gtest/gtest.h"
 
+#include "clang/AST/DeclCXX.h"
+
 #include "lldb/Host/HostInfo.h"
 #include "lldb/Symbol/ClangASTContext.h"
 #include "lldb/Symbol/ClangUtil.h"
@@ -375,6 +377,9 @@
empty_derived_non_empty_vbase_cxx_decl, false));
   EXPECT_TRUE(
   ClangASTContext::RecordHasFields(empty_derived_non_empty_vbase_decl));
+
+  delete non_empty_base_spec;
+  delete non_empty_vbase_spec;
 }
 
 TEST_F(TestClangASTContext, TemplateArguments) {
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D42386: Fix memory leak in TestClangASTContext.TestRecordHasFields

2018-01-22 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 rL323138: Fix memory leak in 
TestClangASTContext.TestRecordHasFields (authored by teemperor, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D42386?vs=130926=130928#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D42386

Files:
  lldb/trunk/unittests/Symbol/TestClangASTContext.cpp


Index: lldb/trunk/unittests/Symbol/TestClangASTContext.cpp
===
--- lldb/trunk/unittests/Symbol/TestClangASTContext.cpp
+++ lldb/trunk/unittests/Symbol/TestClangASTContext.cpp
@@ -11,6 +11,8 @@
 
 #include "gtest/gtest.h"
 
+#include "clang/AST/DeclCXX.h"
+
 #include "lldb/Host/HostInfo.h"
 #include "lldb/Symbol/ClangASTContext.h"
 #include "lldb/Symbol/ClangUtil.h"
@@ -375,6 +377,9 @@
empty_derived_non_empty_vbase_cxx_decl, false));
   EXPECT_TRUE(
   ClangASTContext::RecordHasFields(empty_derived_non_empty_vbase_decl));
+
+  delete non_empty_base_spec;
+  delete non_empty_vbase_spec;
 }
 
 TEST_F(TestClangASTContext, TemplateArguments) {


Index: lldb/trunk/unittests/Symbol/TestClangASTContext.cpp
===
--- lldb/trunk/unittests/Symbol/TestClangASTContext.cpp
+++ lldb/trunk/unittests/Symbol/TestClangASTContext.cpp
@@ -11,6 +11,8 @@
 
 #include "gtest/gtest.h"
 
+#include "clang/AST/DeclCXX.h"
+
 #include "lldb/Host/HostInfo.h"
 #include "lldb/Symbol/ClangASTContext.h"
 #include "lldb/Symbol/ClangUtil.h"
@@ -375,6 +377,9 @@
empty_derived_non_empty_vbase_cxx_decl, false));
   EXPECT_TRUE(
   ClangASTContext::RecordHasFields(empty_derived_non_empty_vbase_decl));
+
+  delete non_empty_base_spec;
+  delete non_empty_vbase_spec;
 }
 
 TEST_F(TestClangASTContext, TemplateArguments) {
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D42348: Prevent unaligned memory read in parseMinidumpString

2018-01-23 Thread Raphael Isemann via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL323181: Prevent unaligned memory read in parseMinidumpString 
(authored by teemperor, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D42348?vs=130798=131008#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D42348

Files:
  lldb/trunk/source/Plugins/Process/minidump/MinidumpTypes.cpp


Index: lldb/trunk/source/Plugins/Process/minidump/MinidumpTypes.cpp
===
--- lldb/trunk/source/Plugins/Process/minidump/MinidumpTypes.cpp
+++ lldb/trunk/source/Plugins/Process/minidump/MinidumpTypes.cpp
@@ -44,19 +44,24 @@
 lldb_private::minidump::parseMinidumpString(llvm::ArrayRef ) {
   std::string result;
 
-  const uint32_t *source_length;
-  Status error = consumeObject(data, source_length);
-  if (error.Fail() || *source_length > data.size() || *source_length % 2 != 0)
+  const uint32_t *source_length_ptr;
+  Status error = consumeObject(data, source_length_ptr);
+
+  // Copy non-aligned source_length data into aligned memory.
+  uint32_t source_length;
+  std::memcpy(_length, source_length_ptr, sizeof(source_length));
+
+  if (error.Fail() || source_length > data.size() || source_length % 2 != 0)
 return llvm::None;
 
   auto source_start = reinterpret_cast(data.data());
   // source_length is the length of the string in bytes
   // we need the length of the string in UTF-16 characters/code points (16 bits
   // per char)
   // that's why it's divided by 2
-  const auto source_end = source_start + (*source_length) / 2;
+  const auto source_end = source_start + source_length / 2;
   // resize to worst case length
-  result.resize(UNI_MAX_UTF8_BYTES_PER_CODE_POINT * (*source_length) / 2);
+  result.resize(UNI_MAX_UTF8_BYTES_PER_CODE_POINT * source_length / 2);
   auto result_start = reinterpret_cast([0]);
   const auto result_end = result_start + result.size();
   llvm::ConvertUTF16toUTF8(_start, source_end, _start, 
result_end,


Index: lldb/trunk/source/Plugins/Process/minidump/MinidumpTypes.cpp
===
--- lldb/trunk/source/Plugins/Process/minidump/MinidumpTypes.cpp
+++ lldb/trunk/source/Plugins/Process/minidump/MinidumpTypes.cpp
@@ -44,19 +44,24 @@
 lldb_private::minidump::parseMinidumpString(llvm::ArrayRef ) {
   std::string result;
 
-  const uint32_t *source_length;
-  Status error = consumeObject(data, source_length);
-  if (error.Fail() || *source_length > data.size() || *source_length % 2 != 0)
+  const uint32_t *source_length_ptr;
+  Status error = consumeObject(data, source_length_ptr);
+
+  // Copy non-aligned source_length data into aligned memory.
+  uint32_t source_length;
+  std::memcpy(_length, source_length_ptr, sizeof(source_length));
+
+  if (error.Fail() || source_length > data.size() || source_length % 2 != 0)
 return llvm::None;
 
   auto source_start = reinterpret_cast(data.data());
   // source_length is the length of the string in bytes
   // we need the length of the string in UTF-16 characters/code points (16 bits
   // per char)
   // that's why it's divided by 2
-  const auto source_end = source_start + (*source_length) / 2;
+  const auto source_end = source_start + source_length / 2;
   // resize to worst case length
-  result.resize(UNI_MAX_UTF8_BYTES_PER_CODE_POINT * (*source_length) / 2);
+  result.resize(UNI_MAX_UTF8_BYTES_PER_CODE_POINT * source_length / 2);
   auto result_start = reinterpret_cast([0]);
   const auto result_end = result_start + result.size();
   llvm::ConvertUTF16toUTF8(_start, source_end, _start, result_end,
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D42409: Fix memory leaks in GoParser

2018-01-23 Thread Raphael Isemann via Phabricator via lldb-commits
teemperor created this revision.
teemperor added reviewers: labath, davide.

The GoParser is leaking memory in the tests due to not freeing allocated nodes 
when encountering some parsing errors. With this patch all GoParser tests are 
passing with enabled memory sanitizers/ubsan.


https://reviews.llvm.org/D42409

Files:
  source/Plugins/ExpressionParser/Go/GoParser.cpp


Index: source/Plugins/ExpressionParser/Go/GoParser.cpp
===
--- source/Plugins/ExpressionParser/Go/GoParser.cpp
+++ source/Plugins/ExpressionParser/Go/GoParser.cpp
@@ -439,8 +439,10 @@
   if (!type)
 return r.error();
   GoASTCompositeLit *lit = LiteralValue();
-  if (!lit)
+  if (!lit) {
+delete type;
 return r.error();
+  }
   lit->SetType(type);
   return lit;
 }
@@ -548,6 +550,7 @@
 GoASTExpr *GoParser::Conversion() {
   Rule r("Conversion", this);
   if (GoASTExpr *t = Type2()) {
+std::unique_ptr owner(t);
 if (match(GoLexer::OP_LPAREN)) {
   GoASTExpr *v = Expression();
   if (!v)
@@ -557,6 +560,7 @@
 return r.error();
   GoASTCallExpr *call = new GoASTCallExpr(false);
   call->SetFun(t);
+  owner.release();
   call->AddArgs(v);
   return call;
 }


Index: source/Plugins/ExpressionParser/Go/GoParser.cpp
===
--- source/Plugins/ExpressionParser/Go/GoParser.cpp
+++ source/Plugins/ExpressionParser/Go/GoParser.cpp
@@ -439,8 +439,10 @@
   if (!type)
 return r.error();
   GoASTCompositeLit *lit = LiteralValue();
-  if (!lit)
+  if (!lit) {
+delete type;
 return r.error();
+  }
   lit->SetType(type);
   return lit;
 }
@@ -548,6 +550,7 @@
 GoASTExpr *GoParser::Conversion() {
   Rule r("Conversion", this);
   if (GoASTExpr *t = Type2()) {
+std::unique_ptr owner(t);
 if (match(GoLexer::OP_LPAREN)) {
   GoASTExpr *v = Expression();
   if (!v)
@@ -557,6 +560,7 @@
 return r.error();
   GoASTCallExpr *call = new GoASTCallExpr(false);
   call->SetFun(t);
+  owner.release();
   call->AddArgs(v);
   return call;
 }
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


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

2018-06-21 Thread Raphael Isemann via Phabricator via lldb-commits
teemperor added a comment.

Note that there are two parent revisions. One is just refactoring because I 
needed to reuse some of the parsing setup code. The other patch (the AsyncPrint 
one) fixes a deadlock that affected this patch. The deadlock can be reproduces 
by starting lldb, going to a random breakpoint in a C++ program and then trying 
to complete a simple expression like `expr some_local_var`. lldb will fail to 
read some Objective C class information from the executable and attempts to 
print a warning, but this deadlocks everything as we hold the IO locks while 
completing arguments.


https://reviews.llvm.org/D48465



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


[Lldb-commits] [PATCH] D48463: Prevent dead locking when calling PrintAsync

2018-06-21 Thread Raphael Isemann via Phabricator via lldb-commits
teemperor created this revision.

While working on the `expr` completion, I've encountered the issue that 
sometimes lldb
deadlocks when doing input/output. The underlying cause for this is that we 
seem to expect
that we can always call `Debugger::PrintAsync` from any point of lldb and that 
this call will
always return at some point.

However this is not always the case. For example, when calling the completion 
handler, we
obviously hold locks that make the console IO thread safe. The expression 
parsing
code then tries to parse the user expression to provide possible completions. 
It's possible
that while parsing our expression, we hit a case where some code decides to 
print
information to the debugger output (for example to inform the user that some 
functionality
has failed unexpectedly). If this call now happens from another thread, then 
even our
recursive_mutex won't protect us and we get a deadlock.

To prevent this issue in the future, this patch introduces the notion of 
delayed output scopes,
that essentially act as safe zones in which all calls to PrintAsync for a given 
debugger
are safe independently of the locking inside the IOHandlers or related issues. 
While printing in
this scope, we queue messages and then actually print them once we leave the 
scope.

So far I only use this feature in the Editline code (because that's the case 
where it solves my problem
with the deadlocked expr completion), but it might be more fitting in another 
place.


https://reviews.llvm.org/D48463

Files:
  include/lldb/Core/Debugger.h
  source/Core/Debugger.cpp
  source/Core/IOHandler.cpp

Index: source/Core/IOHandler.cpp
===
--- source/Core/IOHandler.cpp
+++ source/Core/IOHandler.cpp
@@ -348,6 +348,15 @@
 }
 
 bool IOHandlerEditline::GetLine(std::string , bool ) {
+  // For safety reasons let's delay all messages that might be printed
+  // to the output until we are done with this method. Printing to the
+  // standard output while we are working with EditLine could cause
+  // problems. Especially any held locks that are needed for printing
+  // to the console are problematic. We might take those locks here
+  // because we want to do console output and they might be requested by any
+  // lldb code that will be called from here (possibly in another thread).
+  Debugger::MessageDelayScope buffer_scope(m_debugger);
+
 #ifndef LLDB_DISABLE_LIBEDIT
   if (m_editline_ap) {
 return m_editline_ap->GetLine(line, interrupted);
Index: source/Core/Debugger.cpp
===
--- source/Core/Debugger.cpp
+++ source/Core/Debugger.cpp
@@ -985,6 +985,21 @@
 }
 
 void Debugger::PrintAsync(const char *s, size_t len, bool is_stdout) {
+  bool ShouldForward = false;
+  {
+// We check if any user requested to delay output to a later time
+// (which is designated by m_delayed_output_counter being not 0).
+std::lock_guard guard(m_delayed_output_mutex);
+if (m_delayed_output_counter != 0) {
+  // We want to delay messages, so push them to the buffer.
+  m_delayed_output.emplace_back(std::string(s, len), is_stdout);
+} else {
+  // Allow direct forwarding to the IOHandlers.
+  ShouldForward = true;
+}
+  }
+  if (!ShouldForward)
+return;
   lldb::StreamFileSP stream = is_stdout ? GetOutputFile() : GetErrorFile();
   m_input_reader_stack.PrintAsync(stream.get(), s, len);
 }
Index: include/lldb/Core/Debugger.h
===
--- include/lldb/Core/Debugger.h
+++ include/lldb/Core/Debugger.h
@@ -204,6 +204,26 @@
   bool CheckTopIOHandlerTypes(IOHandler::Type top_type,
   IOHandler::Type second_top_type);
 
+  //--
+  /// Guard class that delays the output printing from the given debugger
+  /// until the end of the scope. Useful if you aquire any IOHandler locks
+  /// in the current scope and also call code that might print via an IOHandler
+  /// (which could lead to deadlocks).
+  ///
+  /// This guard can be used in nested scopes. Multiple guards on the
+  /// same debugger behave the same as if only the top-most guard
+  /// requested to delay the messages.
+  ///
+  /// @see EnableDelayedPrinting() and TryFlushingDelayedMessages().
+  //--
+  struct MessageDelayScope {
+Debugger _debugger;
+MessageDelayScope(Debugger ) : m_debugger(d) {
+  m_debugger.EnableDelayedPrinting();
+}
+~MessageDelayScope() { m_debugger.TryFlushingDelayedMessages(); }
+  };
+
   void PrintAsync(const char *s, size_t len, bool is_stdout);
 
   ConstString GetTopIOHandlerControlSequence(char ch);
@@ -417,6 +437,74 @@
   // object
   Debugger(lldb::LogOutputCallback m_log_callback, void *baton);
 
+  

[Lldb-commits] [PATCH] D48463: Prevent dead locking when calling PrintAsync

2018-06-21 Thread Raphael Isemann via Phabricator via lldb-commits
teemperor updated this revision to Diff 152402.
teemperor added a comment.

- Small code style adjustment.


https://reviews.llvm.org/D48463

Files:
  include/lldb/Core/Debugger.h
  source/Core/Debugger.cpp
  source/Core/IOHandler.cpp

Index: source/Core/IOHandler.cpp
===
--- source/Core/IOHandler.cpp
+++ source/Core/IOHandler.cpp
@@ -348,6 +348,15 @@
 }
 
 bool IOHandlerEditline::GetLine(std::string , bool ) {
+  // For safety reasons let's delay all messages that might be printed
+  // to the output until we are done with this method. Printing to the
+  // standard output while we are working with EditLine could cause
+  // problems. Especially any held locks that are needed for printing
+  // to the console are problematic. We might take those locks here
+  // because we want to do console output and they might be requested by any
+  // lldb code that will be called from here (possibly in another thread).
+  Debugger::MessageDelayScope buffer_scope(m_debugger);
+
 #ifndef LLDB_DISABLE_LIBEDIT
   if (m_editline_ap) {
 return m_editline_ap->GetLine(line, interrupted);
Index: source/Core/Debugger.cpp
===
--- source/Core/Debugger.cpp
+++ source/Core/Debugger.cpp
@@ -985,6 +985,21 @@
 }
 
 void Debugger::PrintAsync(const char *s, size_t len, bool is_stdout) {
+  bool should_forward = false;
+  {
+// We check if any user requested to delay output to a later time
+// (which is designated by m_delayed_output_counter being not 0).
+std::lock_guard guard(m_delayed_output_mutex);
+if (m_delayed_output_counter != 0) {
+  // We want to delay messages, so push them to the buffer.
+  m_delayed_output.emplace_back(std::string(s, len), is_stdout);
+} else {
+  // Allow direct forwarding to the IOHandlers.
+  should_forward = true;
+}
+  }
+  if (!should_forward)
+return;
   lldb::StreamFileSP stream = is_stdout ? GetOutputFile() : GetErrorFile();
   m_input_reader_stack.PrintAsync(stream.get(), s, len);
 }
Index: include/lldb/Core/Debugger.h
===
--- include/lldb/Core/Debugger.h
+++ include/lldb/Core/Debugger.h
@@ -204,6 +204,26 @@
   bool CheckTopIOHandlerTypes(IOHandler::Type top_type,
   IOHandler::Type second_top_type);
 
+  //--
+  /// Guard class that delays the output printing from the given debugger
+  /// until the end of the scope. Useful if you aquire any IOHandler locks
+  /// in the current scope and also call code that might print via an IOHandler
+  /// (which could lead to deadlocks).
+  ///
+  /// This guard can be used in nested scopes. Multiple guards on the
+  /// same debugger behave the same as if only the top-most guard
+  /// requested to delay the messages.
+  ///
+  /// @see EnableDelayedPrinting() and TryFlushingDelayedMessages().
+  //--
+  struct MessageDelayScope {
+Debugger _debugger;
+MessageDelayScope(Debugger ) : m_debugger(d) {
+  m_debugger.EnableDelayedPrinting();
+}
+~MessageDelayScope() { m_debugger.TryFlushingDelayedMessages(); }
+  };
+
   void PrintAsync(const char *s, size_t len, bool is_stdout);
 
   ConstString GetTopIOHandlerControlSequence(char ch);
@@ -417,6 +437,74 @@
   // object
   Debugger(lldb::LogOutputCallback m_log_callback, void *baton);
 
+  //--
+  /// A message sent via PrintAsync that we store to delay the actual
+  /// call until later.
+  //--
+  struct DelayedMessage {
+DelayedMessage(std::string data, bool for_stdout)
+: m_data(data), m_for_stdout(for_stdout) {}
+std::string m_data;
+bool m_for_stdout;
+  };
+
+  //--
+  /// Starts delaying any calls to PrintAsync until a matching call
+  /// to FlushDelayedMessages occurs. This function should only be
+  /// called before a matching call to FlushDelayedMessages.
+  ///
+  /// This method is intentionally private. Use MessageDelayScope to
+  /// call this method (and the matching FlushDelayedMessage()) method
+  /// below.
+  //--
+  void EnableDelayedPrinting() {
+std::lock_guard guard(m_delayed_output_mutex);
+++m_delayed_output_counter;
+  }
+
+  //--
+  /// Tries to flush any delayed messages to PrintAsync. This might
+  /// not be possible if it was requested by multiple users to
+  /// delay messages and not all have given consent at this point for
+  /// forwarding the messages.
+  //--

[Lldb-commits] [PATCH] D48463: Prevent dead locking when calling PrintAsync

2018-06-21 Thread Raphael Isemann via Phabricator via lldb-commits
teemperor added subscribers: friss, jingham.
teemperor added a comment.

Not sure who should review this, but maybe Fred or Jim know :)


https://reviews.llvm.org/D48463



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


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

2018-06-21 Thread Raphael Isemann via Phabricator via lldb-commits
teemperor created this revision.
teemperor added a reviewer: jingham.
Herald added subscribers: JDevlieghere, aprantl.

This patch adds initial code completion support for the `expr` command.

We now have a completion handler in the expression CommandObject that
essentially just attempts to parse the given user expression with Clang with
an attached code completion consumer. We filter and prepare the
code completions provided by Clang and send them back to the completion
API.

The current completion is limited to variables that are in the current scope.
This includes local variables and all types used by local variables. We however
don't do any completion of symbols that are not used in the local scope (or
in some other way already in the ASTContext).

This is partly because there is not yet any code that manually searches for 
additiona
information in the debug information. Another cause is that for some reason the 
existing
code for loading these additional symbols when requested by Clang doesn't seem 
to work.
This will be fixed in a future patch.


https://reviews.llvm.org/D48465

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

Index: source/Plugins/ExpressionParser/Clang/ClangUserExpression.h
===
--- source/Plugins/ExpressionParser/Clang/ClangUserExpression.h
+++ source/Plugins/ExpressionParser/Clang/ClangUserExpression.h
@@ -143,6 +143,9 @@
  lldb_private::ExecutionPolicy execution_policy,
  bool keep_result_in_memory, bool generate_debug_info) override;
 
+  bool Complete(ExecutionContext _ctx, StringList ,
+unsigned complete_pos) override;
+
   ExpressionTypeSystemHelper *GetTypeSystemHelper() override {
 return _type_system_helper;
   }
@@ -199,6 +202,10 @@
 lldb::TargetSP m_target_sp;
   };
 
+  /// The absolute character position in the transformed source code where the
+  /// user code (as typed by the user) starts. If the variable is empty, then we
+  /// were not able to calculate this position.
+  llvm::Optional m_user_expression_start_pos;
   ResultDelegate m_result_delegate;
 };
 
Index: source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp
===
--- source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp
+++ source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp
@@ -403,6 +403,16 @@
"couldn't construct expression body");
   return llvm::Optional();
 }
+
+// Find and store the start position of the original code inside the
+// transformed code. We need this later for the code completion.
+std::size_t original_start;
+std::size_t original_end;
+bool found_bounds = source_code->GetOriginalBodyBounds(
+m_transformed_text, lang_type, original_start, original_end);
+if (found_bounds) {
+  m_user_expression_start_pos = original_start;
+}
   }
   return lang_type;
 }
@@ -592,6 +602,121 @@
   return true;
 }
 
+//--
+/// Converts an absolute position inside a given code string into
+/// a column/line pair.
+///
+/// @param[in] abs_pos
+/// A absolute position in the code string that we want to convert
+/// to a column/line pair.
+///
+/// @param[in] code
+/// A multi-line string usually representing source code.
+///
+/// @param[out] line
+/// The line in the code that contains the given absolute position.
+/// The first line in the string is indexed as 1.
+///
+/// @param[out] column
+/// The column in the line that contains the absolute position.
+/// The first character in a line is indexed as 0.
+//--
+static void AbsPosToLineColumnPos(unsigned abs_pos, llvm::StringRef code,
+  unsigned , unsigned ) {
+  // Reset to code position to beginning of the file.
+  line = 1;
+  column = 0;
+
+  assert(abs_pos <= code.size() && "Absolute position outside code string?");
+
+  // We have to walk up to the position and count lines/columns.
+  

[Lldb-commits] [PATCH] D49949: Add missing boundary checks to variable completion.

2018-07-27 Thread Raphael Isemann via Phabricator via lldb-commits
teemperor created this revision.

Stopgap patch to at least stop all the crashes I get from this code.


https://reviews.llvm.org/D49949

Files:
  packages/Python/lldbsuite/test/functionalities/completion/TestCompletion.py
  packages/Python/lldbsuite/test/functionalities/completion/main.cpp
  source/Symbol/Variable.cpp


Index: source/Symbol/Variable.cpp
===
--- source/Symbol/Variable.cpp
+++ source/Symbol/Variable.cpp
@@ -644,11 +644,11 @@
   break;
 
 case '-':
-  if (partial_path[1] == '>' && !prefix_path.str().empty()) {
+  if (partial_path.size() > 1 && partial_path[1] == '>' && 
!prefix_path.str().empty()) {
 switch (type_class) {
 case lldb::eTypeClassPointer: {
   CompilerType pointee_type(compiler_type.GetPointeeType());
-  if (partial_path[2]) {
+  if (partial_path.size() > 2 && partial_path[2]) {
 // If there is more after the "->", then search deeper
 PrivateAutoComplete(
 frame, partial_path.substr(2), prefix_path + "->",
@@ -672,7 +672,7 @@
 case lldb::eTypeClassUnion:
 case lldb::eTypeClassStruct:
 case lldb::eTypeClassClass:
-  if (partial_path[1]) {
+  if (partial_path.size() > 1 && partial_path[1]) {
 // If there is more after the ".", then search deeper
 PrivateAutoComplete(frame, partial_path.substr(1),
 prefix_path + ".", compiler_type, matches,
Index: packages/Python/lldbsuite/test/functionalities/completion/main.cpp
===
--- packages/Python/lldbsuite/test/functionalities/completion/main.cpp
+++ packages/Python/lldbsuite/test/functionalities/completion/main.cpp
@@ -7,8 +7,15 @@
 }
 };
 
+struct Container { int MemberVar; };
+
 int main()
 {
-Foo f;
-f.Bar(1, 2);
+Foo fooo;
+Foo *ptr_fooo = 
+fooo.Bar(1, 2);
+
+Container container;
+Container *ptr_container = 
+return container.MemberVar = 3; // Break here
 }
Index: 
packages/Python/lldbsuite/test/functionalities/completion/TestCompletion.py
===
--- packages/Python/lldbsuite/test/functionalities/completion/TestCompletion.py
+++ packages/Python/lldbsuite/test/functionalities/completion/TestCompletion.py
@@ -38,6 +38,35 @@
 """Test that 'de' completes to 'detach '."""
 self.complete_from_to('de', 'detach ')
 
+@skipIfFreeBSD  # timing out on the FreeBSD buildbot
+def test_frame_variable(self):
+self.build()
+self.main_source = "main.cpp"
+self.main_source_spec = lldb.SBFileSpec(self.main_source)
+self.dbg.CreateTarget(self.getBuildArtifact("a.out"))
+
+(target, process, thread, bkpt) = 
lldbutil.run_to_source_breakpoint(self,
+  '// Break here', 
self.main_source_spec)
+self.assertEquals(process.GetState(), lldb.eStateStopped)
+# FIXME: This pulls in the debug information to make the completions 
work,
+# but the completions should also work without.
+self.runCmd("frame variable fooo")
+
+self.complete_from_to('frame variable fo', 'frame variable fooo')
+self.complete_from_to('frame variable fooo.', 'frame variable fooo.')
+self.complete_from_to('frame variable fooo.dd', 'frame variable 
fooo.dd')
+
+self.complete_from_to('frame variable ptr_fooo->', 'frame variable 
ptr_fooo->')
+self.complete_from_to('frame variable ptr_fooo->dd', 'frame variable 
ptr_fooo->dd')
+
+self.complete_from_to('frame variable cont', 'frame variable 
container')
+self.complete_from_to('frame variable container.', 'frame variable 
container.MemberVar')
+self.complete_from_to('frame variable container.Mem', 'frame variable 
container.MemberVar')
+
+self.complete_from_to('frame variable ptr_cont', 'frame variable 
ptr_container')
+self.complete_from_to('frame variable ptr_container->', 'frame 
variable ptr_container->MemberVar')
+self.complete_from_to('frame variable ptr_container->Mem', 'frame 
variable ptr_container->MemberVar')
+
 @skipIfFreeBSD  # timing out on the FreeBSD buildbot
 def test_process_attach_dash_dash_con(self):
 """Test that 'process attach --con' completes to 'process attach 
--continue '."""


Index: source/Symbol/Variable.cpp
===
--- source/Symbol/Variable.cpp
+++ source/Symbol/Variable.cpp
@@ -644,11 +644,11 @@
   break;
 
 case '-':
-  if (partial_path[1] == '>' && !prefix_path.str().empty()) {
+  if (partial_path.size() > 1 && partial_path[1] == '>' && !prefix_path.str().empty()) {
 switch (type_class) {
 case lldb::eTypeClassPointer: {
   CompilerType 

[Lldb-commits] [PATCH] D49947: Add the actually calculated completions to COMPLETION_MSG

2018-07-27 Thread Raphael Isemann via Phabricator via lldb-commits
teemperor created this revision.

Otherwise this assertion message is not very useful to whoever is reading the 
log.


https://reviews.llvm.org/D49947

Files:
  packages/Python/lldbsuite/test/functionalities/completion/TestCompletion.py
  packages/Python/lldbsuite/test/lldbtest.py


Index: packages/Python/lldbsuite/test/lldbtest.py
===
--- packages/Python/lldbsuite/test/lldbtest.py
+++ packages/Python/lldbsuite/test/lldbtest.py
@@ -184,9 +184,9 @@
 return "Command '%s' returns successfully" % str
 
 
-def COMPLETION_MSG(str_before, str_after):
+def COMPLETION_MSG(str_before, str_after, completions):
 '''A generic message generator for the completion mechanism.'''
-return "'%s' successfully completes to '%s'" % (str_before, str_after)
+return "'%s' successfully completes to '%s', but completions were:\n%s" % 
(str_before, str_after, "\n".join(completions))
 
 
 def EXP_MSG(str, actual, exe):
Index: 
packages/Python/lldbsuite/test/functionalities/completion/TestCompletion.py
===
--- packages/Python/lldbsuite/test/functionalities/completion/TestCompletion.py
+++ packages/Python/lldbsuite/test/functionalities/completion/TestCompletion.py
@@ -273,8 +273,8 @@
 if turn_off_re_match:
 self.expect(
 compare_string, msg=COMPLETION_MSG(
-str_input, p), exe=False, substrs=[p])
+str_input, p, match_strings), exe=False, substrs=[p])
 else:
 self.expect(
 compare_string, msg=COMPLETION_MSG(
-str_input, p), exe=False, patterns=[p])
+str_input, p, match_strings), exe=False, patterns=[p])


Index: packages/Python/lldbsuite/test/lldbtest.py
===
--- packages/Python/lldbsuite/test/lldbtest.py
+++ packages/Python/lldbsuite/test/lldbtest.py
@@ -184,9 +184,9 @@
 return "Command '%s' returns successfully" % str
 
 
-def COMPLETION_MSG(str_before, str_after):
+def COMPLETION_MSG(str_before, str_after, completions):
 '''A generic message generator for the completion mechanism.'''
-return "'%s' successfully completes to '%s'" % (str_before, str_after)
+return "'%s' successfully completes to '%s', but completions were:\n%s" % (str_before, str_after, "\n".join(completions))
 
 
 def EXP_MSG(str, actual, exe):
Index: packages/Python/lldbsuite/test/functionalities/completion/TestCompletion.py
===
--- packages/Python/lldbsuite/test/functionalities/completion/TestCompletion.py
+++ packages/Python/lldbsuite/test/functionalities/completion/TestCompletion.py
@@ -273,8 +273,8 @@
 if turn_off_re_match:
 self.expect(
 compare_string, msg=COMPLETION_MSG(
-str_input, p), exe=False, substrs=[p])
+str_input, p, match_strings), exe=False, substrs=[p])
 else:
 self.expect(
 compare_string, msg=COMPLETION_MSG(
-str_input, p), exe=False, patterns=[p])
+str_input, p, match_strings), exe=False, patterns=[p])
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D49947: Add the actually calculated completions to COMPLETION_MSG

2018-07-27 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 rL338179: Add the actually calculated completions to 
COMPLETION_MSG (authored by teemperor, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D49947?vs=157806=157807#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D49947

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


Index: lldb/trunk/packages/Python/lldbsuite/test/lldbtest.py
===
--- lldb/trunk/packages/Python/lldbsuite/test/lldbtest.py
+++ lldb/trunk/packages/Python/lldbsuite/test/lldbtest.py
@@ -184,9 +184,10 @@
 return "Command '%s' returns successfully" % str
 
 
-def COMPLETION_MSG(str_before, str_after):
+def COMPLETION_MSG(str_before, str_after, completions):
 '''A generic message generator for the completion mechanism.'''
-return "'%s' successfully completes to '%s'" % (str_before, str_after)
+return ("'%s' successfully completes to '%s', but completions were:\n%s"
+   % (str_before, str_after, "\n".join(completions)))
 
 
 def EXP_MSG(str, actual, exe):
Index: 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/completion/TestCompletion.py
===
--- 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/completion/TestCompletion.py
+++ 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/completion/TestCompletion.py
@@ -313,8 +313,8 @@
 if turn_off_re_match:
 self.expect(
 compare_string, msg=COMPLETION_MSG(
-str_input, p), exe=False, substrs=[p])
+str_input, p, match_strings), exe=False, substrs=[p])
 else:
 self.expect(
 compare_string, msg=COMPLETION_MSG(
-str_input, p), exe=False, patterns=[p])
+str_input, p, match_strings), exe=False, patterns=[p])


Index: lldb/trunk/packages/Python/lldbsuite/test/lldbtest.py
===
--- lldb/trunk/packages/Python/lldbsuite/test/lldbtest.py
+++ lldb/trunk/packages/Python/lldbsuite/test/lldbtest.py
@@ -184,9 +184,10 @@
 return "Command '%s' returns successfully" % str
 
 
-def COMPLETION_MSG(str_before, str_after):
+def COMPLETION_MSG(str_before, str_after, completions):
 '''A generic message generator for the completion mechanism.'''
-return "'%s' successfully completes to '%s'" % (str_before, str_after)
+return ("'%s' successfully completes to '%s', but completions were:\n%s"
+   % (str_before, str_after, "\n".join(completions)))
 
 
 def EXP_MSG(str, actual, exe):
Index: lldb/trunk/packages/Python/lldbsuite/test/functionalities/completion/TestCompletion.py
===
--- lldb/trunk/packages/Python/lldbsuite/test/functionalities/completion/TestCompletion.py
+++ lldb/trunk/packages/Python/lldbsuite/test/functionalities/completion/TestCompletion.py
@@ -313,8 +313,8 @@
 if turn_off_re_match:
 self.expect(
 compare_string, msg=COMPLETION_MSG(
-str_input, p), exe=False, substrs=[p])
+str_input, p, match_strings), exe=False, substrs=[p])
 else:
 self.expect(
 compare_string, msg=COMPLETION_MSG(
-str_input, p), exe=False, patterns=[p])
+str_input, p, match_strings), exe=False, patterns=[p])
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D49949: Add missing boundary checks to variable completion.

2018-07-27 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 rL338177: Add missing boundary checks to variable completion. 
(authored by teemperor, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D49949?vs=157803=157805#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D49949

Files:
  
lldb/trunk/packages/Python/lldbsuite/test/functionalities/completion/TestCompletion.py
  lldb/trunk/packages/Python/lldbsuite/test/functionalities/completion/main.cpp
  lldb/trunk/source/Symbol/Variable.cpp

Index: lldb/trunk/source/Symbol/Variable.cpp
===
--- lldb/trunk/source/Symbol/Variable.cpp
+++ lldb/trunk/source/Symbol/Variable.cpp
@@ -644,11 +644,12 @@
   break;
 
 case '-':
-  if (partial_path[1] == '>' && !prefix_path.str().empty()) {
+  if (partial_path.size() > 1 && partial_path[1] == '>' &&
+  !prefix_path.str().empty()) {
 switch (type_class) {
 case lldb::eTypeClassPointer: {
   CompilerType pointee_type(compiler_type.GetPointeeType());
-  if (partial_path[2]) {
+  if (partial_path.size() > 2 && partial_path[2]) {
 // If there is more after the "->", then search deeper
 PrivateAutoComplete(
 frame, partial_path.substr(2), prefix_path + "->",
@@ -672,7 +673,7 @@
 case lldb::eTypeClassUnion:
 case lldb::eTypeClassStruct:
 case lldb::eTypeClassClass:
-  if (partial_path[1]) {
+  if (partial_path.size() > 1 && partial_path[1]) {
 // If there is more after the ".", then search deeper
 PrivateAutoComplete(frame, partial_path.substr(1),
 prefix_path + ".", compiler_type, matches,
Index: lldb/trunk/packages/Python/lldbsuite/test/functionalities/completion/main.cpp
===
--- lldb/trunk/packages/Python/lldbsuite/test/functionalities/completion/main.cpp
+++ lldb/trunk/packages/Python/lldbsuite/test/functionalities/completion/main.cpp
@@ -7,8 +7,15 @@
 }
 };
 
+struct Container { int MemberVar; };
+
 int main()
 {
-Foo f;
-f.Bar(1, 2);
+Foo fooo;
+Foo *ptr_fooo = 
+fooo.Bar(1, 2);
+
+Container container;
+Container *ptr_container = 
+return container.MemberVar = 3; // Break here
 }
Index: lldb/trunk/packages/Python/lldbsuite/test/functionalities/completion/TestCompletion.py
===
--- lldb/trunk/packages/Python/lldbsuite/test/functionalities/completion/TestCompletion.py
+++ lldb/trunk/packages/Python/lldbsuite/test/functionalities/completion/TestCompletion.py
@@ -39,6 +39,46 @@
 self.complete_from_to('de', 'detach ')
 
 @skipIfFreeBSD  # timing out on the FreeBSD buildbot
+def test_frame_variable(self):
+self.build()
+self.main_source = "main.cpp"
+self.main_source_spec = lldb.SBFileSpec(self.main_source)
+self.dbg.CreateTarget(self.getBuildArtifact("a.out"))
+
+(target, process, thread, bkpt) = lldbutil.run_to_source_breakpoint(self,
+  '// Break here', self.main_source_spec)
+self.assertEquals(process.GetState(), lldb.eStateStopped)
+# FIXME: This pulls in the debug information to make the completions work,
+# but the completions should also work without.
+self.runCmd("frame variable fooo")
+
+self.complete_from_to('frame variable fo',
+  'frame variable fooo')
+self.complete_from_to('frame variable fooo.',
+  'frame variable fooo.')
+self.complete_from_to('frame variable fooo.dd',
+  'frame variable fooo.dd')
+
+self.complete_from_to('frame variable ptr_fooo->',
+  'frame variable ptr_fooo->')
+self.complete_from_to('frame variable ptr_fooo->dd',
+  'frame variable ptr_fooo->dd')
+
+self.complete_from_to('frame variable cont',
+  'frame variable container')
+self.complete_from_to('frame variable container.',
+  'frame variable container.MemberVar')
+self.complete_from_to('frame variable container.Mem',
+  'frame variable container.MemberVar')
+
+self.complete_from_to('frame variable ptr_cont',
+  'frame variable ptr_container')
+self.complete_from_to('frame variable ptr_container->',
+  'frame variable ptr_container->MemberVar')
+self.complete_from_to('frame variable ptr_container->Mem',
+  'frame variable 

[Lldb-commits] [PATCH] D49949: Add missing boundary checks to variable completion.

2018-07-27 Thread Raphael Isemann via Phabricator via lldb-commits
teemperor updated this revision to Diff 157803.
teemperor added a comment.

- Fixed formatting.


https://reviews.llvm.org/D49949

Files:
  packages/Python/lldbsuite/test/functionalities/completion/TestCompletion.py
  packages/Python/lldbsuite/test/functionalities/completion/main.cpp
  source/Symbol/Variable.cpp

Index: source/Symbol/Variable.cpp
===
--- source/Symbol/Variable.cpp
+++ source/Symbol/Variable.cpp
@@ -644,11 +644,12 @@
   break;
 
 case '-':
-  if (partial_path[1] == '>' && !prefix_path.str().empty()) {
+  if (partial_path.size() > 1 && partial_path[1] == '>' &&
+  !prefix_path.str().empty()) {
 switch (type_class) {
 case lldb::eTypeClassPointer: {
   CompilerType pointee_type(compiler_type.GetPointeeType());
-  if (partial_path[2]) {
+  if (partial_path.size() > 2 && partial_path[2]) {
 // If there is more after the "->", then search deeper
 PrivateAutoComplete(
 frame, partial_path.substr(2), prefix_path + "->",
@@ -672,7 +673,7 @@
 case lldb::eTypeClassUnion:
 case lldb::eTypeClassStruct:
 case lldb::eTypeClassClass:
-  if (partial_path[1]) {
+  if (partial_path.size() > 1 && partial_path[1]) {
 // If there is more after the ".", then search deeper
 PrivateAutoComplete(frame, partial_path.substr(1),
 prefix_path + ".", compiler_type, matches,
Index: packages/Python/lldbsuite/test/functionalities/completion/main.cpp
===
--- packages/Python/lldbsuite/test/functionalities/completion/main.cpp
+++ packages/Python/lldbsuite/test/functionalities/completion/main.cpp
@@ -7,8 +7,15 @@
 }
 };
 
+struct Container { int MemberVar; };
+
 int main()
 {
-Foo f;
-f.Bar(1, 2);
+Foo fooo;
+Foo *ptr_fooo = 
+fooo.Bar(1, 2);
+
+Container container;
+Container *ptr_container = 
+return container.MemberVar = 3; // Break here
 }
Index: packages/Python/lldbsuite/test/functionalities/completion/TestCompletion.py
===
--- packages/Python/lldbsuite/test/functionalities/completion/TestCompletion.py
+++ packages/Python/lldbsuite/test/functionalities/completion/TestCompletion.py
@@ -38,6 +38,46 @@
 """Test that 'de' completes to 'detach '."""
 self.complete_from_to('de', 'detach ')
 
+@skipIfFreeBSD  # timing out on the FreeBSD buildbot
+def test_frame_variable(self):
+self.build()
+self.main_source = "main.cpp"
+self.main_source_spec = lldb.SBFileSpec(self.main_source)
+self.dbg.CreateTarget(self.getBuildArtifact("a.out"))
+
+(target, process, thread, bkpt) = lldbutil.run_to_source_breakpoint(self,
+  '// Break here', self.main_source_spec)
+self.assertEquals(process.GetState(), lldb.eStateStopped)
+# FIXME: This pulls in the debug information to make the completions work,
+# but the completions should also work without.
+self.runCmd("frame variable fooo")
+
+self.complete_from_to('frame variable fo',
+  'frame variable fooo')
+self.complete_from_to('frame variable fooo.',
+  'frame variable fooo.')
+self.complete_from_to('frame variable fooo.dd',
+  'frame variable fooo.dd')
+
+self.complete_from_to('frame variable ptr_fooo->',
+  'frame variable ptr_fooo->')
+self.complete_from_to('frame variable ptr_fooo->dd',
+  'frame variable ptr_fooo->dd')
+
+self.complete_from_to('frame variable cont',
+  'frame variable container')
+self.complete_from_to('frame variable container.',
+  'frame variable container.MemberVar')
+self.complete_from_to('frame variable container.Mem',
+  'frame variable container.MemberVar')
+
+self.complete_from_to('frame variable ptr_cont',
+  'frame variable ptr_container')
+self.complete_from_to('frame variable ptr_container->',
+  'frame variable ptr_container->MemberVar')
+self.complete_from_to('frame variable ptr_container->Mem',
+  'frame variable ptr_container->MemberVar')
+
 @skipIfFreeBSD  # timing out on the FreeBSD buildbot
 def test_process_attach_dash_dash_con(self):
 """Test that 'process attach --con' completes to 'process attach --continue '."""
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D49947: Add the actually calculated completions to COMPLETION_MSG

2018-07-27 Thread Raphael Isemann via Phabricator via lldb-commits
teemperor updated this revision to Diff 157806.
teemperor added a comment.

- FIxed formatting.


https://reviews.llvm.org/D49947

Files:
  packages/Python/lldbsuite/test/functionalities/completion/TestCompletion.py
  packages/Python/lldbsuite/test/lldbtest.py


Index: packages/Python/lldbsuite/test/lldbtest.py
===
--- packages/Python/lldbsuite/test/lldbtest.py
+++ packages/Python/lldbsuite/test/lldbtest.py
@@ -184,9 +184,10 @@
 return "Command '%s' returns successfully" % str
 
 
-def COMPLETION_MSG(str_before, str_after):
+def COMPLETION_MSG(str_before, str_after, completions):
 '''A generic message generator for the completion mechanism.'''
-return "'%s' successfully completes to '%s'" % (str_before, str_after)
+return ("'%s' successfully completes to '%s', but completions were:\n%s"
+   % (str_before, str_after, "\n".join(completions)))
 
 
 def EXP_MSG(str, actual, exe):
Index: 
packages/Python/lldbsuite/test/functionalities/completion/TestCompletion.py
===
--- packages/Python/lldbsuite/test/functionalities/completion/TestCompletion.py
+++ packages/Python/lldbsuite/test/functionalities/completion/TestCompletion.py
@@ -273,8 +273,8 @@
 if turn_off_re_match:
 self.expect(
 compare_string, msg=COMPLETION_MSG(
-str_input, p), exe=False, substrs=[p])
+str_input, p, match_strings), exe=False, substrs=[p])
 else:
 self.expect(
 compare_string, msg=COMPLETION_MSG(
-str_input, p), exe=False, patterns=[p])
+str_input, p, match_strings), exe=False, patterns=[p])


Index: packages/Python/lldbsuite/test/lldbtest.py
===
--- packages/Python/lldbsuite/test/lldbtest.py
+++ packages/Python/lldbsuite/test/lldbtest.py
@@ -184,9 +184,10 @@
 return "Command '%s' returns successfully" % str
 
 
-def COMPLETION_MSG(str_before, str_after):
+def COMPLETION_MSG(str_before, str_after, completions):
 '''A generic message generator for the completion mechanism.'''
-return "'%s' successfully completes to '%s'" % (str_before, str_after)
+return ("'%s' successfully completes to '%s', but completions were:\n%s"
+   % (str_before, str_after, "\n".join(completions)))
 
 
 def EXP_MSG(str, actual, exe):
Index: packages/Python/lldbsuite/test/functionalities/completion/TestCompletion.py
===
--- packages/Python/lldbsuite/test/functionalities/completion/TestCompletion.py
+++ packages/Python/lldbsuite/test/functionalities/completion/TestCompletion.py
@@ -273,8 +273,8 @@
 if turn_off_re_match:
 self.expect(
 compare_string, msg=COMPLETION_MSG(
-str_input, p), exe=False, substrs=[p])
+str_input, p, match_strings), exe=False, substrs=[p])
 else:
 self.expect(
 compare_string, msg=COMPLETION_MSG(
-str_input, p), exe=False, patterns=[p])
+str_input, p, match_strings), exe=False, patterns=[p])
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D50159: Add byte counting mechanism to LLDB's Stream class.

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

- Fixing some of the merge conflicts.
- Fixed doxygen comment.

Thanks for the reviews!


https://reviews.llvm.org/D50159

Files:
  include/lldb/Core/StreamAsynchronousIO.h
  include/lldb/Core/StreamBuffer.h
  include/lldb/Core/StreamFile.h
  include/lldb/Utility/Stream.h
  include/lldb/Utility/StreamString.h
  include/lldb/Utility/StreamTee.h
  source/Core/StreamAsynchronousIO.cpp
  source/Core/StreamFile.cpp
  source/Utility/StreamString.cpp
  unittests/Utility/StreamTeeTest.cpp
  unittests/Utility/StreamTest.cpp

Index: unittests/Utility/StreamTest.cpp
===
--- unittests/Utility/StreamTest.cpp
+++ unittests/Utility/StreamTest.cpp
@@ -44,149 +44,211 @@
 
 TEST_F(StreamTest, PutChar) {
   s.PutChar('a');
+  EXPECT_EQ(1U, s.GetWrittenBytes());
   EXPECT_EQ("a", TakeValue());
 
   s.PutChar('1');
+  EXPECT_EQ(1U, s.GetWrittenBytes());
   EXPECT_EQ("1", TakeValue());
 }
 
 TEST_F(StreamTest, PutCharWhitespace) {
   s.PutChar(' ');
+  EXPECT_EQ(1U, s.GetWrittenBytes());
   EXPECT_EQ(" ", TakeValue());
 
   s.PutChar('\n');
+  EXPECT_EQ(1U, s.GetWrittenBytes());
   EXPECT_EQ("\n", TakeValue());
 
   s.PutChar('\r');
+  EXPECT_EQ(1U, s.GetWrittenBytes());
   EXPECT_EQ("\r", TakeValue());
 
   s.PutChar('\t');
+  EXPECT_EQ(1U, s.GetWrittenBytes());
   EXPECT_EQ("\t", TakeValue());
 }
 
 TEST_F(StreamTest, PutCString) {
   s.PutCString("");
+  EXPECT_EQ(0U, s.GetWrittenBytes());
   EXPECT_EQ("", TakeValue());
 
   s.PutCString("foobar");
+  EXPECT_EQ(6U, s.GetWrittenBytes());
   EXPECT_EQ("foobar", TakeValue());
 
   s.PutCString(" ");
+  EXPECT_EQ(1U, s.GetWrittenBytes());
   EXPECT_EQ(" ", TakeValue());
 }
 
 TEST_F(StreamTest, PutCStringWithStringRef) {
   s.PutCString(llvm::StringRef(""));
+  EXPECT_EQ(0U, s.GetWrittenBytes());
   EXPECT_EQ("", TakeValue());
 
   s.PutCString(llvm::StringRef("foobar"));
+  EXPECT_EQ(6U, s.GetWrittenBytes());
   EXPECT_EQ("foobar", TakeValue());
 
   s.PutCString(llvm::StringRef(" "));
+  EXPECT_EQ(1U, s.GetWrittenBytes());
   EXPECT_EQ(" ", TakeValue());
 }
 
 TEST_F(StreamTest, QuotedCString) {
   s.QuotedCString("foo");
+  EXPECT_EQ(5U, s.GetWrittenBytes());
   EXPECT_EQ(R"("foo")", TakeValue());
 
   s.QuotedCString("ba r");
+  EXPECT_EQ(6U, s.GetWrittenBytes());
   EXPECT_EQ(R"("ba r")", TakeValue());
 
   s.QuotedCString(" ");
+  EXPECT_EQ(3U, s.GetWrittenBytes());
   EXPECT_EQ(R"(" ")", TakeValue());
 }
 
 TEST_F(StreamTest, PutCharNull) {
   s.PutChar('\0');
+  EXPECT_EQ(1U, s.GetWrittenBytes());
   EXPECT_EQ(std::string("\0", 1), TakeValue());
 
   s.PutChar('a');
+  EXPECT_EQ(1U, s.GetWrittenBytes());
   EXPECT_EQ(std::string("a", 1), TakeValue());
 }
 
 TEST_F(StreamTest, PutCStringAsRawHex8) {
   s.PutCStringAsRawHex8("");
+  EXPECT_EQ(0U, s.GetWrittenBytes());
   EXPECT_EQ("", TakeValue());
 
   s.PutCStringAsRawHex8("foobar");
+  EXPECT_EQ(12U, s.GetWrittenBytes());
   EXPECT_EQ("666f6f626172", TakeValue());
 
   s.PutCStringAsRawHex8(" ");
+  EXPECT_EQ(2U, s.GetWrittenBytes());
   EXPECT_EQ("20", TakeValue());
 }
 
 TEST_F(StreamTest, PutHex8) {
   s.PutHex8((uint8_t)55);
+  EXPECT_EQ(2U, s.GetWrittenBytes());
   EXPECT_EQ("37", TakeValue());
+
   s.PutHex8(std::numeric_limits::max());
+  EXPECT_EQ(2U, s.GetWrittenBytes());
   EXPECT_EQ("ff", TakeValue());
+
   s.PutHex8((uint8_t)0);
+  EXPECT_EQ(2U, s.GetWrittenBytes());
   EXPECT_EQ("00", TakeValue());
 }
 
 TEST_F(StreamTest, PutNHex8) {
   s.PutNHex8(0, (uint8_t)55);
+  EXPECT_EQ(0U, s.GetWrittenBytes());
   EXPECT_EQ("", TakeValue());
+
   s.PutNHex8(1, (uint8_t)55);
+  EXPECT_EQ(2U, s.GetWrittenBytes());
   EXPECT_EQ("37", TakeValue());
+
   s.PutNHex8(2, (uint8_t)55);
+  EXPECT_EQ(4U, s.GetWrittenBytes());
   EXPECT_EQ("3737", TakeValue());
+
   s.PutNHex8(1, (uint8_t)56);
+  EXPECT_EQ(2U, s.GetWrittenBytes());
   EXPECT_EQ("38", TakeValue());
 }
 
 TEST_F(StreamTest, PutHex16ByteOrderLittle) {
   s.PutHex16(0x1234U, lldb::eByteOrderLittle);
+  EXPECT_EQ(4U, s.GetWrittenBytes());
   EXPECT_EQ("3412", TakeValue());
+
   s.PutHex16(std::numeric_limits::max(), lldb::eByteOrderLittle);
+  EXPECT_EQ(4U, s.GetWrittenBytes());
   EXPECT_EQ("", TakeValue());
+
   s.PutHex16(0U, lldb::eByteOrderLittle);
+  EXPECT_EQ(4U, s.GetWrittenBytes());
   EXPECT_EQ("", TakeValue());
 }
 
 TEST_F(StreamTest, PutHex16ByteOrderBig) {
   s.PutHex16(0x1234U, lldb::eByteOrderBig);
+  EXPECT_EQ(4U, s.GetWrittenBytes());
   EXPECT_EQ("1234", TakeValue());
+
   s.PutHex16(std::numeric_limits::max(), lldb::eByteOrderBig);
+  EXPECT_EQ(4U, s.GetWrittenBytes());
   EXPECT_EQ("", TakeValue());
+
   s.PutHex16(0U, lldb::eByteOrderBig);
+  EXPECT_EQ(4U, s.GetWrittenBytes());
   EXPECT_EQ("", TakeValue());
 }
 
 TEST_F(StreamTest, PutHex32ByteOrderLittle) {
   s.PutHex32(0x12345678U, lldb::eByteOrderLittle);
+  EXPECT_EQ(8U, s.GetWrittenBytes());
   EXPECT_EQ("78563412", TakeValue());
+
 

[Lldb-commits] [PATCH] D50192: Fix: ClangHighlighter.cpp should not be in CopyFiles, but in lldb-core targets

2018-08-02 Thread Raphael Isemann via Phabricator via lldb-commits
teemperor added a reviewer: t.p.northover.
teemperor added a comment.

This was changed by https://reviews.llvm.org/rLLDB338712 so I think Tim 
probably knows better what's going on here.


https://reviews.llvm.org/D50192



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


[Lldb-commits] [PATCH] D50159: Add byte counting mechanism to LLDB's Stream class.

2018-08-02 Thread Raphael Isemann via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL338733: Add byte counting mechanism to LLDBs Stream 
class. (authored by teemperor, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D50159?vs=158777=158779#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D50159

Files:
  lldb/trunk/include/lldb/Core/StreamAsynchronousIO.h
  lldb/trunk/include/lldb/Core/StreamBuffer.h
  lldb/trunk/include/lldb/Core/StreamFile.h
  lldb/trunk/include/lldb/Utility/Stream.h
  lldb/trunk/include/lldb/Utility/StreamString.h
  lldb/trunk/include/lldb/Utility/StreamTee.h
  lldb/trunk/source/Core/StreamAsynchronousIO.cpp
  lldb/trunk/source/Core/StreamFile.cpp
  lldb/trunk/source/Utility/StreamString.cpp
  lldb/trunk/unittests/Utility/StreamTeeTest.cpp
  lldb/trunk/unittests/Utility/StreamTest.cpp

Index: lldb/trunk/include/lldb/Core/StreamAsynchronousIO.h
===
--- lldb/trunk/include/lldb/Core/StreamAsynchronousIO.h
+++ lldb/trunk/include/lldb/Core/StreamAsynchronousIO.h
@@ -30,7 +30,8 @@
 
   void Flush() override;
 
-  size_t Write(const void *src, size_t src_len) override;
+protected:
+  size_t WriteImpl(const void *src, size_t src_len) override;
 
 private:
   Debugger _debugger;
Index: lldb/trunk/include/lldb/Core/StreamFile.h
===
--- lldb/trunk/include/lldb/Core/StreamFile.h
+++ lldb/trunk/include/lldb/Core/StreamFile.h
@@ -46,13 +46,13 @@
 
   void Flush() override;
 
-  size_t Write(const void *s, size_t length) override;
 
 protected:
   //--
   // Classes that inherit from StreamFile can see and modify these
   //--
   File m_file;
+  size_t WriteImpl(const void *s, size_t length) override;
 
 private:
   DISALLOW_COPY_AND_ASSIGN(StreamFile);
Index: lldb/trunk/include/lldb/Core/StreamBuffer.h
===
--- lldb/trunk/include/lldb/Core/StreamBuffer.h
+++ lldb/trunk/include/lldb/Core/StreamBuffer.h
@@ -30,12 +30,6 @@
 // Nothing to do when flushing a buffer based stream...
   }
 
-  virtual size_t Write(const void *s, size_t length) {
-if (s && length)
-  m_packet.append((const char *)s, ((const char *)s) + length);
-return length;
-  }
-
   void Clear() { m_packet.clear(); }
 
   // Beware, this might not be NULL terminated as you can expect from
@@ -48,6 +42,12 @@
 
 protected:
   llvm::SmallVector m_packet;
+
+  virtual size_t WriteImpl(const void *s, size_t length) {
+if (s && length)
+  m_packet.append((const char *)s, ((const char *)s) + length);
+return length;
+  }
 };
 
 } // namespace lldb_private
Index: lldb/trunk/include/lldb/Utility/StreamTee.h
===
--- lldb/trunk/include/lldb/Utility/StreamTee.h
+++ lldb/trunk/include/lldb/Utility/StreamTee.h
@@ -70,29 +70,6 @@
 }
   }
 
-  size_t Write(const void *s, size_t length) override {
-std::lock_guard guard(m_streams_mutex);
-if (m_streams.empty())
-  return 0;
-
-size_t min_bytes_written = SIZE_MAX;
-collection::iterator pos, end;
-for (pos = m_streams.begin(), end = m_streams.end(); pos != end; ++pos) {
-  // Allow for our collection to contain NULL streams. This allows the
-  // StreamTee to be used with hard coded indexes for clients that might
-  // want N total streams with only a few that are set to valid values.
-  Stream *strm = pos->get();
-  if (strm) {
-const size_t bytes_written = strm->Write(s, length);
-if (min_bytes_written > bytes_written)
-  min_bytes_written = bytes_written;
-  }
-}
-if (min_bytes_written == SIZE_MAX)
-  return 0;
-return min_bytes_written;
-  }
-
   size_t AppendStream(const lldb::StreamSP _sp) {
 size_t new_idx = m_streams.size();
 std::lock_guard guard(m_streams_mutex);
@@ -131,6 +108,29 @@
   typedef std::vector collection;
   mutable std::recursive_mutex m_streams_mutex;
   collection m_streams;
+
+  size_t WriteImpl(const void *s, size_t length) override {
+std::lock_guard guard(m_streams_mutex);
+if (m_streams.empty())
+  return 0;
+
+size_t min_bytes_written = SIZE_MAX;
+collection::iterator pos, end;
+for (pos = m_streams.begin(), end = m_streams.end(); pos != end; ++pos) {
+  // Allow for our collection to contain NULL streams. This allows the
+  // StreamTee to be used with hard coded indexes for clients that might
+  // want N total streams with only a few that are set to valid values.
+  Stream *strm = pos->get();
+  if (strm) {
+const size_t bytes_written = strm->Write(s, length);
+if (min_bytes_written > bytes_written)
+  min_bytes_written = 

[Lldb-commits] [PATCH] D50225: Use a DenseMap for looking up functions by UID in CompileUnit::FindFunctionByUID

2018-08-02 Thread Raphael Isemann via Phabricator via lldb-commits
teemperor created this revision.
teemperor added a reviewer: vsk.

Instead of iterating over our vector of functions, we might as well use a map 
here to
directly get the function we need.

Thanks to Vedant for pointing this out.


Repository:
  rLLDB LLDB

https://reviews.llvm.org/D50225

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


Index: source/Symbol/CompileUnit.cpp
===
--- source/Symbol/CompileUnit.cpp
+++ source/Symbol/CompileUnit.cpp
@@ -106,6 +106,7 @@
 // Add a function to this compile unit
 //--
 void CompileUnit::AddFunction(FunctionSP ) {
+  m_function_uid_to_index[funcSP->GetID()] = m_functions.size();
   // TODO: order these by address
   m_functions.push_back(funcSP);
 }
@@ -163,18 +164,10 @@
 //}
 
 FunctionSP CompileUnit::FindFunctionByUID(lldb::user_id_t func_uid) {
-  FunctionSP funcSP;
-  if (!m_functions.empty()) {
-std::vector::const_iterator pos;
-std::vector::const_iterator end = m_functions.end();
-for (pos = m_functions.begin(); pos != end; ++pos) {
-  if ((*pos)->GetID() == func_uid) {
-funcSP = *pos;
-break;
-  }
-}
-  }
-  return funcSP;
+  auto it = m_function_uid_to_index.find(func_uid);
+  if (it == m_function_uid_to_index.end())
+return FunctionSP();
+  return m_functions[it->second];
 }
 
 lldb::LanguageType CompileUnit::GetLanguage() {
Index: include/lldb/Symbol/CompileUnit.h
===
--- include/lldb/Symbol/CompileUnit.h
+++ include/lldb/Symbol/CompileUnit.h
@@ -18,6 +18,8 @@
 #include "lldb/Utility/UserID.h"
 #include "lldb/lldb-enumerations.h"
 
+#include "llvm/ADT/DenseMap.h"
+
 namespace lldb_private {
 //--
 /// @class CompileUnit CompileUnit.h "lldb/Symbol/CompileUnit.h"
@@ -418,6 +420,9 @@
   std::vector m_functions; ///< The sparsely populated list 
of
  ///shared pointers to functions
   ///< that gets populated as functions get partially parsed.
+
+  /// Maps function UIDs to indexes in m_functions.
+  llvm::DenseMap m_function_uid_to_index;
   std::vector m_imported_modules; ///< All modules, including the
///current module, imported by
///this


Index: source/Symbol/CompileUnit.cpp
===
--- source/Symbol/CompileUnit.cpp
+++ source/Symbol/CompileUnit.cpp
@@ -106,6 +106,7 @@
 // Add a function to this compile unit
 //--
 void CompileUnit::AddFunction(FunctionSP ) {
+  m_function_uid_to_index[funcSP->GetID()] = m_functions.size();
   // TODO: order these by address
   m_functions.push_back(funcSP);
 }
@@ -163,18 +164,10 @@
 //}
 
 FunctionSP CompileUnit::FindFunctionByUID(lldb::user_id_t func_uid) {
-  FunctionSP funcSP;
-  if (!m_functions.empty()) {
-std::vector::const_iterator pos;
-std::vector::const_iterator end = m_functions.end();
-for (pos = m_functions.begin(); pos != end; ++pos) {
-  if ((*pos)->GetID() == func_uid) {
-funcSP = *pos;
-break;
-  }
-}
-  }
-  return funcSP;
+  auto it = m_function_uid_to_index.find(func_uid);
+  if (it == m_function_uid_to_index.end())
+return FunctionSP();
+  return m_functions[it->second];
 }
 
 lldb::LanguageType CompileUnit::GetLanguage() {
Index: include/lldb/Symbol/CompileUnit.h
===
--- include/lldb/Symbol/CompileUnit.h
+++ include/lldb/Symbol/CompileUnit.h
@@ -18,6 +18,8 @@
 #include "lldb/Utility/UserID.h"
 #include "lldb/lldb-enumerations.h"
 
+#include "llvm/ADT/DenseMap.h"
+
 namespace lldb_private {
 //--
 /// @class CompileUnit CompileUnit.h "lldb/Symbol/CompileUnit.h"
@@ -418,6 +420,9 @@
   std::vector m_functions; ///< The sparsely populated list of
  ///shared pointers to functions
   ///< that gets populated as functions get partially parsed.
+
+  /// Maps function UIDs to indexes in m_functions.
+  llvm::DenseMap m_function_uid_to_index;
   std::vector m_imported_modules; ///< All modules, including the
///current module, imported by
///this
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D49750: Add support for ARM and ARM64 breakpad generated minidump files.

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

I don't see this mentioned here yet, so: This patch also seems to introduce a 
few hundred warnings with -Wextended-offsetof (which is enabled by default on 
the macOS builds):

  
[...]llvm/tools/lldb/source/Plugins/Process/minidump/RegisterContextMinidump_ARM64.cpp:510:5:
 warning: using extended field designator is an extension [-Wextended-offsetof] 



  DEF_S(20),

  
  ^ 

  
  
[...]llvm/tools/lldb/source/Plugins/Process/minidump/RegisterContextMinidump_ARM64.cpp:67:25:
 note: expanded from macro 'DEF_S' 
  "s" #i, nullptr, 4, OFFSET(v[i * 16]), eEncodingVector,   
 \  
  
  ^ 

  
  
[...]llvm/tools/lldb/source/Plugins/Process/minidump/RegisterContextMinidump_ARM64.cpp:29:20:
 note: expanded from macro 'OFFSET'
  #define OFFSET(r) (offsetof(RegisterContextMinidump_ARM64::Context, r))   

  
 ^~~

  
  [...]stddef.h:120:24: note: expanded from macro 'offsetof'

  #define offsetof(t, d) __builtin_offsetof(t, d)   

  
 ^ ~ 

(And the tests also fail on macOS, but they are probably fixed when the 
Linux/Windows tests are fixed).


Repository:
  rL LLVM

https://reviews.llvm.org/D49750



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


[Lldb-commits] [PATCH] D50162: Replace LLDB's LEB128 implementation with the one from LLVM

2018-08-03 Thread Raphael Isemann via Phabricator via lldb-commits
teemperor updated this revision to Diff 158930.
teemperor added a reviewer: labath.
teemperor added a comment.

- Fixed compilation errors after changes in parent revision.


https://reviews.llvm.org/D50162

Files:
  source/Utility/Stream.cpp


Index: source/Utility/Stream.cpp
===
--- source/Utility/Stream.cpp
+++ source/Utility/Stream.cpp
@@ -12,6 +12,7 @@
 #include "lldb/Utility/Endian.h"
 #include "lldb/Utility/VASPrintf.h"
 #include "llvm/ADT/SmallString.h" // for SmallString
+#include "llvm/Support/LEB128.h"
 
 #include 
 
@@ -49,47 +50,20 @@
 // Put an SLEB128 "uval" out to the stream using the printf format in "format".
 //--
 size_t Stream::PutSLEB128(int64_t sval) {
-  size_t bytes_written = 0;
-  if (m_flags.Test(eBinary)) {
-bool more = true;
-while (more) {
-  uint8_t byte = sval & 0x7fu;
-  sval >>= 7;
-  /* sign bit of byte is 2nd high order bit (0x40) */
-  if ((sval == 0 && !(byte & 0x40)) || (sval == -1 && (byte & 0x40)))
-more = false;
-  else
-// more bytes to come
-byte |= 0x80u;
-  bytes_written += Write(, 1);
-}
-  } else {
-bytes_written = Printf("0x%" PRIi64, sval);
-  }
-
-  return bytes_written;
+  if (m_flags.Test(eBinary))
+return llvm::encodeSLEB128(sval, m_forwarder);
+  else
+return Printf("0x%" PRIi64, sval);
 }
 
 //--
 // Put an ULEB128 "uval" out to the stream using the printf format in "format".
 //--
 size_t Stream::PutULEB128(uint64_t uval) {
-  size_t bytes_written = 0;
-  if (m_flags.Test(eBinary)) {
-do {
-
-  uint8_t byte = uval & 0x7fu;
-  uval >>= 7;
-  if (uval != 0) {
-// more bytes to come
-byte |= 0x80u;
-  }
-  bytes_written += Write(, 1);
-} while (uval != 0);
-  } else {
-bytes_written = Printf("0x%" PRIx64, uval);
-  }
-  return bytes_written;
+  if (m_flags.Test(eBinary))
+return llvm::encodeULEB128(uval, m_forwarder);
+  else
+return Printf("0x%" PRIx64, uval);
 }
 
 //--


Index: source/Utility/Stream.cpp
===
--- source/Utility/Stream.cpp
+++ source/Utility/Stream.cpp
@@ -12,6 +12,7 @@
 #include "lldb/Utility/Endian.h"
 #include "lldb/Utility/VASPrintf.h"
 #include "llvm/ADT/SmallString.h" // for SmallString
+#include "llvm/Support/LEB128.h"
 
 #include 
 
@@ -49,47 +50,20 @@
 // Put an SLEB128 "uval" out to the stream using the printf format in "format".
 //--
 size_t Stream::PutSLEB128(int64_t sval) {
-  size_t bytes_written = 0;
-  if (m_flags.Test(eBinary)) {
-bool more = true;
-while (more) {
-  uint8_t byte = sval & 0x7fu;
-  sval >>= 7;
-  /* sign bit of byte is 2nd high order bit (0x40) */
-  if ((sval == 0 && !(byte & 0x40)) || (sval == -1 && (byte & 0x40)))
-more = false;
-  else
-// more bytes to come
-byte |= 0x80u;
-  bytes_written += Write(, 1);
-}
-  } else {
-bytes_written = Printf("0x%" PRIi64, sval);
-  }
-
-  return bytes_written;
+  if (m_flags.Test(eBinary))
+return llvm::encodeSLEB128(sval, m_forwarder);
+  else
+return Printf("0x%" PRIi64, sval);
 }
 
 //--
 // Put an ULEB128 "uval" out to the stream using the printf format in "format".
 //--
 size_t Stream::PutULEB128(uint64_t uval) {
-  size_t bytes_written = 0;
-  if (m_flags.Test(eBinary)) {
-do {
-
-  uint8_t byte = uval & 0x7fu;
-  uval >>= 7;
-  if (uval != 0) {
-// more bytes to come
-byte |= 0x80u;
-  }
-  bytes_written += Write(, 1);
-} while (uval != 0);
-  } else {
-bytes_written = Printf("0x%" PRIx64, uval);
-  }
-  return bytes_written;
+  if (m_flags.Test(eBinary))
+return llvm::encodeULEB128(uval, m_forwarder);
+  else
+return Printf("0x%" PRIx64, uval);
 }
 
 //--
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D50161: Add raw_ostream wrapper to the Stream class

2018-08-03 Thread Raphael Isemann via Phabricator via lldb-commits
teemperor updated this revision to Diff 158926.
teemperor added a reviewer: labath.
teemperor added a comment.

- Renamed m_forward_to to m_target.
- Added a getter to allow external code to use the raw_ostream API.
- Renamed m_forward to m_forwarder.

@labath Thanks, fixed the problems you pointed out. I already made the API 
public in this patch, it's probably good for encouraging people to use LLVM's 
raw_ostream classes.


https://reviews.llvm.org/D50161

Files:
  include/lldb/Utility/Stream.h
  source/Utility/Stream.cpp


Index: source/Utility/Stream.cpp
===
--- source/Utility/Stream.cpp
+++ source/Utility/Stream.cpp
@@ -23,11 +23,11 @@
 
 Stream::Stream(uint32_t flags, uint32_t addr_size, ByteOrder byte_order)
 : m_flags(flags), m_addr_size(addr_size), m_byte_order(byte_order),
-  m_indent_level(0) {}
+  m_indent_level(0), m_forwarder(*this) {}
 
 Stream::Stream()
 : m_flags(0), m_addr_size(4), m_byte_order(endian::InlHostByteOrder()),
-  m_indent_level(0) {}
+  m_indent_level(0), m_forwarder(*this) {}
 
 //--
 // Destructor
Index: include/lldb/Utility/Stream.h
===
--- include/lldb/Utility/Stream.h
+++ include/lldb/Utility/Stream.h
@@ -15,6 +15,7 @@
 #include "lldb/lldb-enumerations.h" // for ByteOrder::eByteOrderInvalid
 #include "llvm/ADT/StringRef.h" // for StringRef
 #include "llvm/Support/FormatVariadic.h"
+#include "llvm/Support/raw_ostream.h"
 
 #include 
 #include // for size_t
@@ -52,6 +53,17 @@
   //--
   Stream();
 
+  // FIXME: Streams should not be copyable.
+  Stream(const Stream ) : m_forwarder(*this) { (*this) = other; }
+
+  Stream =(const Stream ) {
+m_flags = rhs.m_flags;
+m_addr_size = rhs.m_addr_size;
+m_byte_order = rhs.m_byte_order;
+m_indent_level = rhs.m_indent_level;
+return *this;
+  }
+
   //--
   /// Destructor
   //--
@@ -520,6 +532,13 @@
   //--
   size_t PutULEB128(uint64_t uval);
 
+  //--
+  /// Returns a raw_ostream that forwards the data to this Stream object.
+  //--
+  llvm::raw_ostream () {
+return m_forwarder;
+  }
+
 protected:
   //--
   // Member variables
@@ -548,6 +567,34 @@
   /// The number of bytes that were appended to the stream.
   //--
   virtual size_t WriteImpl(const void *src, size_t src_len) = 0;
+
+  //--
+  /// @class RawOstreamForward Stream.h "lldb/Utility/Stream.h"
+  /// This is a wrapper class that exposes a raw_ostream interface that just
+  /// forwards to an LLDB stream, allowing to reuse LLVM algorithms that take
+  /// a raw_ostream within the LLDB code base.
+  //--
+  class RawOstreamForward : public llvm::raw_ostream {
+// Note: This stream must *not* maintain its own buffer, but instead
+// directly write everything to the internal Stream class. Without this,
+// we would run into the problem that the Stream written byte count would
+// differ from the actually written bytes by the size of the internal
+// raw_ostream buffer.
+
+Stream _target;
+void write_impl(const char *Ptr, size_t Size) override {
+  m_target.Write(Ptr, Size);
+}
+
+uint64_t current_pos() const override {
+  return m_target.GetWrittenBytes();
+}
+
+  public:
+RawOstreamForward(Stream )
+: llvm::raw_ostream(/*unbuffered*/ true), m_target(target) {}
+  };
+  RawOstreamForward m_forwarder;
 };
 
 } // namespace lldb_private


Index: source/Utility/Stream.cpp
===
--- source/Utility/Stream.cpp
+++ source/Utility/Stream.cpp
@@ -23,11 +23,11 @@
 
 Stream::Stream(uint32_t flags, uint32_t addr_size, ByteOrder byte_order)
 : m_flags(flags), m_addr_size(addr_size), m_byte_order(byte_order),
-  m_indent_level(0) {}
+  m_indent_level(0), m_forwarder(*this) {}
 
 Stream::Stream()
 : m_flags(0), m_addr_size(4), m_byte_order(endian::InlHostByteOrder()),
-  m_indent_level(0) {}
+  m_indent_level(0), m_forwarder(*this) {}
 
 //--
 // Destructor
Index: include/lldb/Utility/Stream.h
===
--- include/lldb/Utility/Stream.h
+++ 

[Lldb-commits] [PATCH] D50161: Add raw_ostream wrapper to the Stream class

2018-08-03 Thread Raphael Isemann via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL338901: Add raw_ostream wrapper to the Stream class 
(authored by teemperor, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D50161?vs=158926=159032#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D50161

Files:
  lldb/trunk/include/lldb/Utility/Stream.h
  lldb/trunk/source/Utility/Stream.cpp


Index: lldb/trunk/source/Utility/Stream.cpp
===
--- lldb/trunk/source/Utility/Stream.cpp
+++ lldb/trunk/source/Utility/Stream.cpp
@@ -23,11 +23,11 @@
 
 Stream::Stream(uint32_t flags, uint32_t addr_size, ByteOrder byte_order)
 : m_flags(flags), m_addr_size(addr_size), m_byte_order(byte_order),
-  m_indent_level(0) {}
+  m_indent_level(0), m_forwarder(*this) {}
 
 Stream::Stream()
 : m_flags(0), m_addr_size(4), m_byte_order(endian::InlHostByteOrder()),
-  m_indent_level(0) {}
+  m_indent_level(0), m_forwarder(*this) {}
 
 //--
 // Destructor
Index: lldb/trunk/include/lldb/Utility/Stream.h
===
--- lldb/trunk/include/lldb/Utility/Stream.h
+++ lldb/trunk/include/lldb/Utility/Stream.h
@@ -15,6 +15,7 @@
 #include "lldb/lldb-enumerations.h" // for ByteOrder::eByteOrderInvalid
 #include "llvm/ADT/StringRef.h" // for StringRef
 #include "llvm/Support/FormatVariadic.h"
+#include "llvm/Support/raw_ostream.h"
 
 #include 
 #include // for size_t
@@ -52,6 +53,17 @@
   //--
   Stream();
 
+  // FIXME: Streams should not be copyable.
+  Stream(const Stream ) : m_forwarder(*this) { (*this) = other; }
+
+  Stream =(const Stream ) {
+m_flags = rhs.m_flags;
+m_addr_size = rhs.m_addr_size;
+m_byte_order = rhs.m_byte_order;
+m_indent_level = rhs.m_indent_level;
+return *this;
+  }
+
   //--
   /// Destructor
   //--
@@ -520,6 +532,13 @@
   //--
   size_t PutULEB128(uint64_t uval);
 
+  //--
+  /// Returns a raw_ostream that forwards the data to this Stream object.
+  //--
+  llvm::raw_ostream () {
+return m_forwarder;
+  }
+
 protected:
   //--
   // Member variables
@@ -548,6 +567,34 @@
   /// The number of bytes that were appended to the stream.
   //--
   virtual size_t WriteImpl(const void *src, size_t src_len) = 0;
+
+  //--
+  /// @class RawOstreamForward Stream.h "lldb/Utility/Stream.h"
+  /// This is a wrapper class that exposes a raw_ostream interface that just
+  /// forwards to an LLDB stream, allowing to reuse LLVM algorithms that take
+  /// a raw_ostream within the LLDB code base.
+  //--
+  class RawOstreamForward : public llvm::raw_ostream {
+// Note: This stream must *not* maintain its own buffer, but instead
+// directly write everything to the internal Stream class. Without this,
+// we would run into the problem that the Stream written byte count would
+// differ from the actually written bytes by the size of the internal
+// raw_ostream buffer.
+
+Stream _target;
+void write_impl(const char *Ptr, size_t Size) override {
+  m_target.Write(Ptr, Size);
+}
+
+uint64_t current_pos() const override {
+  return m_target.GetWrittenBytes();
+}
+
+  public:
+RawOstreamForward(Stream )
+: llvm::raw_ostream(/*unbuffered*/ true), m_target(target) {}
+  };
+  RawOstreamForward m_forwarder;
 };
 
 } // namespace lldb_private


Index: lldb/trunk/source/Utility/Stream.cpp
===
--- lldb/trunk/source/Utility/Stream.cpp
+++ lldb/trunk/source/Utility/Stream.cpp
@@ -23,11 +23,11 @@
 
 Stream::Stream(uint32_t flags, uint32_t addr_size, ByteOrder byte_order)
 : m_flags(flags), m_addr_size(addr_size), m_byte_order(byte_order),
-  m_indent_level(0) {}
+  m_indent_level(0), m_forwarder(*this) {}
 
 Stream::Stream()
 : m_flags(0), m_addr_size(4), m_byte_order(endian::InlHostByteOrder()),
-  m_indent_level(0) {}
+  m_indent_level(0), m_forwarder(*this) {}
 
 //--
 // Destructor
Index: lldb/trunk/include/lldb/Utility/Stream.h
===
--- 

[Lldb-commits] [PATCH] D50015: Remove unnecessary newlines from break command help text.

2018-07-30 Thread Raphael Isemann via Phabricator via lldb-commits
teemperor created this revision.

We usually don't have trailing newlines in the short help strings. This just 
adds
unnecessary extra lines when printing the help text of these commands.


https://reviews.llvm.org/D50015

Files:
  source/Interpreter/CommandInterpreter.cpp


Index: source/Interpreter/CommandInterpreter.cpp
===
--- source/Interpreter/CommandInterpreter.cpp
+++ source/Interpreter/CommandInterpreter.cpp
@@ -478,7 +478,7 @@
   std::unique_ptr break_regex_cmd_ap(
   new CommandObjectRegexCommand(
   *this, "_regexp-break",
-  "Set a breakpoint using one of several shorthand formats.\n",
+  "Set a breakpoint using one of several shorthand formats.",
   "\n"
   "_regexp-break :\n"
   "  main.c:12 // Break at line 12 of "
@@ -527,7 +527,7 @@
   std::unique_ptr tbreak_regex_cmd_ap(
   new CommandObjectRegexCommand(
   *this, "_regexp-tbreak",
-  "Set a one-shot breakpoint using one of several shorthand 
formats.\n",
+  "Set a one-shot breakpoint using one of several shorthand formats.",
   "\n"
   "_regexp-break :\n"
   "  main.c:12 // Break at line 12 of "


Index: source/Interpreter/CommandInterpreter.cpp
===
--- source/Interpreter/CommandInterpreter.cpp
+++ source/Interpreter/CommandInterpreter.cpp
@@ -478,7 +478,7 @@
   std::unique_ptr break_regex_cmd_ap(
   new CommandObjectRegexCommand(
   *this, "_regexp-break",
-  "Set a breakpoint using one of several shorthand formats.\n",
+  "Set a breakpoint using one of several shorthand formats.",
   "\n"
   "_regexp-break :\n"
   "  main.c:12 // Break at line 12 of "
@@ -527,7 +527,7 @@
   std::unique_ptr tbreak_regex_cmd_ap(
   new CommandObjectRegexCommand(
   *this, "_regexp-tbreak",
-  "Set a one-shot breakpoint using one of several shorthand formats.\n",
+  "Set a one-shot breakpoint using one of several shorthand formats.",
   "\n"
   "_regexp-break :\n"
   "  main.c:12 // Break at line 12 of "
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D50027: Added initial unit test for LLDB's Stream class.

2018-07-30 Thread Raphael Isemann via Phabricator via lldb-commits
teemperor created this revision.
Herald added a subscriber: mgorny.

This adds an initial small unit test for LLDB's Stream class, which should at 
least cover
most of the functions in the Stream class. StreamString is always in big endian
mode, so that's the only stream byte order path this test covers as of now. 
Also,
the binary mode still needs to be tested for all print methods.

Also adds some FIXMEs for wrong/strange result values of the Stream class that 
we hit
while testing those functions.


https://reviews.llvm.org/D50027

Files:
  unittests/Utility/CMakeLists.txt
  unittests/Utility/StreamTest.cpp

Index: unittests/Utility/StreamTest.cpp
===
--- /dev/null
+++ unittests/Utility/StreamTest.cpp
@@ -0,0 +1,504 @@
+//===-- StreamTest.cpp --*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#include "lldb/Utility/StreamString.h"
+#include "gtest/gtest.h"
+
+using namespace lldb_private;
+
+namespace {
+struct StreamTest : ::testing::Test {
+  // Note: Stream is an abstract class, so we use StreamString to test it. To
+  // make it easier to change this later, only methods in this class explicitly
+  // refer to the StringStream class.
+  StreamString s;
+  // We return here a std::string because that way gtest can print better
+  // assertion messages.
+  std::string Value() const {
+return s.GetString().str();
+  }
+};
+}
+
+namespace {
+// A StreamTest where we expect the Stream output to be binary.
+struct BinaryStreamTest : StreamTest {
+  void SetUp() override {
+s.GetFlags().Set(Stream::eBinary);
+  }
+};
+}
+
+TEST_F(StreamTest, ChangingByteOrder) {
+  s.SetByteOrder(lldb::eByteOrderPDP);
+  EXPECT_EQ(lldb::eByteOrderPDP, s.GetByteOrder());
+}
+
+TEST_F(StreamTest, PutChar) {
+  s.PutChar('a');
+  EXPECT_EQ("a", Value());
+
+  s.PutChar('1');
+  EXPECT_EQ("a1", Value());
+}
+
+TEST_F(StreamTest, PutCharWhitespace) {
+  s.PutChar(' ');
+  EXPECT_EQ(" ", Value());
+
+  s.PutChar('\n');
+  EXPECT_EQ(" \n", Value());
+
+  s.PutChar('\r');
+  EXPECT_EQ(" \n\r", Value());
+
+  s.PutChar('\t');
+  EXPECT_EQ(" \n\r\t", Value());
+}
+
+TEST_F(StreamTest, PutCString) {
+  s.PutCString("");
+  EXPECT_EQ("", Value());
+
+  s.PutCString("foobar");
+  EXPECT_EQ("foobar", Value());
+
+  s.PutCString(" ");
+  EXPECT_EQ("foobar ", Value());
+}
+
+TEST_F(StreamTest, PutCStringWithStringRef) {
+  s.PutCString(llvm::StringRef(""));
+  EXPECT_EQ("", Value());
+
+  s.PutCString(llvm::StringRef("foobar"));
+  EXPECT_EQ("foobar", Value());
+
+  s.PutCString(llvm::StringRef(" "));
+  EXPECT_EQ("foobar ", Value());
+}
+
+TEST_F(StreamTest, QuotedCString) {
+  s.QuotedCString("foo");
+  EXPECT_EQ("\"foo\"", Value());
+
+  s.QuotedCString("bar");
+  EXPECT_EQ("\"foo\"\"bar\"", Value());
+
+  s.QuotedCString(" ");
+  EXPECT_EQ("\"foo\"\"bar\"\" \"", Value());
+}
+
+TEST_F(StreamTest, PutCharNull) {
+  s.PutChar('\0');
+  EXPECT_EQ(std::string("\0", 1), Value());
+
+  s.PutChar('a');
+  EXPECT_EQ(std::string("\0a", 2), Value());
+}
+
+TEST_F(StreamTest, PutCStringAsRawHex8) {
+  s.PutCStringAsRawHex8("");
+  // FIXME: Check that printing 00 on an empty string is the intended behavior.
+  // It seems kind of unexpected  that we print the trailing 0 byte for empty
+  // strings, but not for non-empty strings.
+  EXPECT_EQ("00", Value());
+
+  s.PutCStringAsRawHex8("foobar");
+  EXPECT_EQ("00666f6f626172", Value());
+
+  s.PutCStringAsRawHex8(" ");
+  EXPECT_EQ("00666f6f62617220", Value());
+}
+
+TEST_F(StreamTest, PutHex8) {
+  s.PutHex8((uint8_t)55);
+  EXPECT_EQ("37", Value());
+  s.PutHex8(std::numeric_limits::max());
+  EXPECT_EQ("37ff", Value());
+  s.PutHex8((uint8_t)0);
+  EXPECT_EQ("37ff00", Value());
+}
+
+TEST_F(StreamTest, PutNHex8) {
+  s.PutNHex8(0, (uint8_t)55);
+  EXPECT_EQ("", Value());
+  s.PutNHex8(1, (uint8_t)55);
+  EXPECT_EQ("37", Value());
+  s.PutNHex8(2, (uint8_t)55);
+  EXPECT_EQ("373737", Value());
+  s.PutNHex8(1, (uint8_t)56);
+  EXPECT_EQ("37373738", Value());
+}
+
+TEST_F(StreamTest, PutHex16ByteOrderLittle) {
+  s.PutHex16(0x1234U, lldb::eByteOrderLittle);
+  EXPECT_EQ("3412", Value());
+  s.PutHex16(std::numeric_limits::max(), lldb::eByteOrderLittle);
+  EXPECT_EQ("3412", Value());
+  s.PutHex16(0U, lldb::eByteOrderLittle);
+  EXPECT_EQ("3412", Value());
+}
+
+TEST_F(StreamTest, PutHex16ByteOrderBig) {
+  s.PutHex16(0x1234U, lldb::eByteOrderBig);
+  EXPECT_EQ("1234", Value());
+  s.PutHex16(std::numeric_limits::max(), lldb::eByteOrderBig);
+  EXPECT_EQ("1234", Value());
+  s.PutHex16(0U, lldb::eByteOrderBig);
+  EXPECT_EQ("1234", Value());
+}
+
+TEST_F(StreamTest, PutHex32ByteOrderLittle) {
+  s.PutHex32(0x12345678U, 

[Lldb-commits] [PATCH] D50025: Don't ignore byte_order in Stream::PutMaxHex64

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

Yeah, on a second thought I should just strip out the parts of the unit test 
that found this bug and commit them alongside this.


https://reviews.llvm.org/D50025



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


[Lldb-commits] [PATCH] D50026: Remove Stream::UnitTest

2018-07-30 Thread Raphael Isemann via Phabricator via lldb-commits
teemperor created this revision.

No one is using this method, and it also doesn't really make a lot of sense to 
have it around.


https://reviews.llvm.org/D50026

Files:
  include/lldb/Utility/Stream.h
  source/Utility/Stream.cpp


Index: source/Utility/Stream.cpp
===
--- source/Utility/Stream.cpp
+++ source/Utility/Stream.cpp
@@ -526,48 +526,3 @@
 m_flags.Set(eBinary);
   return bytes_written;
 }
-
-void Stream::UnitTest(Stream *s) {
-  s->PutHex8(0x12);
-
-  s->PutChar(' ');
-  s->PutHex16(0x3456, endian::InlHostByteOrder());
-  s->PutChar(' ');
-  s->PutHex16(0x3456, eByteOrderBig);
-  s->PutChar(' ');
-  s->PutHex16(0x3456, eByteOrderLittle);
-
-  s->PutChar(' ');
-  s->PutHex32(0x789abcde, endian::InlHostByteOrder());
-  s->PutChar(' ');
-  s->PutHex32(0x789abcde, eByteOrderBig);
-  s->PutChar(' ');
-  s->PutHex32(0x789abcde, eByteOrderLittle);
-
-  s->PutChar(' ');
-  s->PutHex64(0x1122334455667788ull, endian::InlHostByteOrder());
-  s->PutChar(' ');
-  s->PutHex64(0x1122334455667788ull, eByteOrderBig);
-  s->PutChar(' ');
-  s->PutHex64(0x1122334455667788ull, eByteOrderLittle);
-
-  const char *hola = "Hello World!!!";
-  s->PutChar(' ');
-  s->PutCString(hola);
-
-  s->PutChar(' ');
-  s->Write(hola, 5);
-
-  s->PutChar(' ');
-  s->PutCStringAsRawHex8(hola);
-
-  s->PutChar(' ');
-  s->PutCStringAsRawHex8("01234");
-
-  s->PutChar(' ');
-  s->Printf("pid=%i", 12733);
-
-  s->PutChar(' ');
-  s->PrintfAsRawHex8("pid=%i", 12733);
-  s->PutChar('\n');
-}
Index: include/lldb/Utility/Stream.h
===
--- include/lldb/Utility/Stream.h
+++ include/lldb/Utility/Stream.h
@@ -524,8 +524,6 @@
   //--
   size_t PutULEB128(uint64_t uval);
 
-  static void UnitTest(Stream *s);
-
 protected:
   //--
   // Member variables


Index: source/Utility/Stream.cpp
===
--- source/Utility/Stream.cpp
+++ source/Utility/Stream.cpp
@@ -526,48 +526,3 @@
 m_flags.Set(eBinary);
   return bytes_written;
 }
-
-void Stream::UnitTest(Stream *s) {
-  s->PutHex8(0x12);
-
-  s->PutChar(' ');
-  s->PutHex16(0x3456, endian::InlHostByteOrder());
-  s->PutChar(' ');
-  s->PutHex16(0x3456, eByteOrderBig);
-  s->PutChar(' ');
-  s->PutHex16(0x3456, eByteOrderLittle);
-
-  s->PutChar(' ');
-  s->PutHex32(0x789abcde, endian::InlHostByteOrder());
-  s->PutChar(' ');
-  s->PutHex32(0x789abcde, eByteOrderBig);
-  s->PutChar(' ');
-  s->PutHex32(0x789abcde, eByteOrderLittle);
-
-  s->PutChar(' ');
-  s->PutHex64(0x1122334455667788ull, endian::InlHostByteOrder());
-  s->PutChar(' ');
-  s->PutHex64(0x1122334455667788ull, eByteOrderBig);
-  s->PutChar(' ');
-  s->PutHex64(0x1122334455667788ull, eByteOrderLittle);
-
-  const char *hola = "Hello World!!!";
-  s->PutChar(' ');
-  s->PutCString(hola);
-
-  s->PutChar(' ');
-  s->Write(hola, 5);
-
-  s->PutChar(' ');
-  s->PutCStringAsRawHex8(hola);
-
-  s->PutChar(' ');
-  s->PutCStringAsRawHex8("01234");
-
-  s->PutChar(' ');
-  s->Printf("pid=%i", 12733);
-
-  s->PutChar(' ');
-  s->PrintfAsRawHex8("pid=%i", 12733);
-  s->PutChar('\n');
-}
Index: include/lldb/Utility/Stream.h
===
--- include/lldb/Utility/Stream.h
+++ include/lldb/Utility/Stream.h
@@ -524,8 +524,6 @@
   //--
   size_t PutULEB128(uint64_t uval);
 
-  static void UnitTest(Stream *s);
-
 protected:
   //--
   // Member variables
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D50025: Don't ignore byte_order in Stream::PutMaxHex64

2018-07-30 Thread Raphael Isemann via Phabricator via lldb-commits
teemperor updated this revision to Diff 158126.
teemperor edited the summary of this revision.
teemperor added a comment.

- Reverse patch dependencies that we can add the unit test here (but also means 
this has to wait until the StreamTest is in).


https://reviews.llvm.org/D50025

Files:
  source/Utility/Stream.cpp
  unittests/Utility/StreamTest.cpp


Index: unittests/Utility/StreamTest.cpp
===
--- unittests/Utility/StreamTest.cpp
+++ unittests/Utility/StreamTest.cpp
@@ -191,6 +191,32 @@
   EXPECT_EQ("1234567890abcdef", Value());
 }
 
+TEST_F(StreamTest, PutMaxHex64ByteOrderBig) {
+  std::size_t bytes;
+  bytes = s.PutMaxHex64(0x12U, 1, lldb::eByteOrderBig);
+  EXPECT_EQ(2U, bytes);
+  bytes = s.PutMaxHex64(0x1234U, 2, lldb::eByteOrderBig);
+  EXPECT_EQ(4U, bytes);
+  bytes = s.PutMaxHex64(0x12345678U, 4, lldb::eByteOrderBig);
+  EXPECT_EQ(8U, bytes);
+  bytes = s.PutMaxHex64(0x1234567890ABCDEFU, 8, lldb::eByteOrderBig);
+  EXPECT_EQ(16U, bytes);
+  EXPECT_EQ("121234123456781234567890abcdef", Value());
+}
+
+TEST_F(StreamTest, PutMaxHex64ByteOrderLittle) {
+  std::size_t bytes;
+  bytes = s.PutMaxHex64(0x12U, 1, lldb::eByteOrderLittle);
+  EXPECT_EQ(2U, bytes);
+  bytes = s.PutMaxHex64(0x1234U, 2, lldb::eByteOrderLittle);
+  EXPECT_EQ(4U, bytes);
+  bytes = s.PutMaxHex64(0x12345678U, 4, lldb::eByteOrderLittle);
+  EXPECT_EQ(8U, bytes);
+  bytes = s.PutMaxHex64(0x1234567890ABCDEFU, 8, lldb::eByteOrderLittle);
+  EXPECT_EQ(16U, bytes);
+  EXPECT_EQ("12341278563412efcdab9078563412", Value());
+}
+
 
//--
 // Shift operator tests.
 
//--
Index: source/Utility/Stream.cpp
===
--- source/Utility/Stream.cpp
+++ source/Utility/Stream.cpp
@@ -427,11 +427,11 @@
   case 1:
 return PutHex8((uint8_t)uvalue);
   case 2:
-return PutHex16((uint16_t)uvalue);
+return PutHex16((uint16_t)uvalue, byte_order);
   case 4:
-return PutHex32((uint32_t)uvalue);
+return PutHex32((uint32_t)uvalue, byte_order);
   case 8:
-return PutHex64(uvalue);
+return PutHex64(uvalue, byte_order);
   }
   return 0;
 }


Index: unittests/Utility/StreamTest.cpp
===
--- unittests/Utility/StreamTest.cpp
+++ unittests/Utility/StreamTest.cpp
@@ -191,6 +191,32 @@
   EXPECT_EQ("1234567890abcdef", Value());
 }
 
+TEST_F(StreamTest, PutMaxHex64ByteOrderBig) {
+  std::size_t bytes;
+  bytes = s.PutMaxHex64(0x12U, 1, lldb::eByteOrderBig);
+  EXPECT_EQ(2U, bytes);
+  bytes = s.PutMaxHex64(0x1234U, 2, lldb::eByteOrderBig);
+  EXPECT_EQ(4U, bytes);
+  bytes = s.PutMaxHex64(0x12345678U, 4, lldb::eByteOrderBig);
+  EXPECT_EQ(8U, bytes);
+  bytes = s.PutMaxHex64(0x1234567890ABCDEFU, 8, lldb::eByteOrderBig);
+  EXPECT_EQ(16U, bytes);
+  EXPECT_EQ("121234123456781234567890abcdef", Value());
+}
+
+TEST_F(StreamTest, PutMaxHex64ByteOrderLittle) {
+  std::size_t bytes;
+  bytes = s.PutMaxHex64(0x12U, 1, lldb::eByteOrderLittle);
+  EXPECT_EQ(2U, bytes);
+  bytes = s.PutMaxHex64(0x1234U, 2, lldb::eByteOrderLittle);
+  EXPECT_EQ(4U, bytes);
+  bytes = s.PutMaxHex64(0x12345678U, 4, lldb::eByteOrderLittle);
+  EXPECT_EQ(8U, bytes);
+  bytes = s.PutMaxHex64(0x1234567890ABCDEFU, 8, lldb::eByteOrderLittle);
+  EXPECT_EQ(16U, bytes);
+  EXPECT_EQ("12341278563412efcdab9078563412", Value());
+}
+
 //--
 // Shift operator tests.
 //--
Index: source/Utility/Stream.cpp
===
--- source/Utility/Stream.cpp
+++ source/Utility/Stream.cpp
@@ -427,11 +427,11 @@
   case 1:
 return PutHex8((uint8_t)uvalue);
   case 2:
-return PutHex16((uint16_t)uvalue);
+return PutHex16((uint16_t)uvalue, byte_order);
   case 4:
-return PutHex32((uint32_t)uvalue);
+return PutHex32((uint32_t)uvalue, byte_order);
   case 8:
-return PutHex64(uvalue);
+return PutHex64(uvalue, byte_order);
   }
   return 0;
 }
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D50015: Remove unnecessary newlines from break command help text.

2018-07-30 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 rL338311: Remove unnecessary newlines from break command help 
text. (authored by teemperor, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D50015?vs=158076=158081#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D50015

Files:
  lldb/trunk/source/Interpreter/CommandInterpreter.cpp


Index: lldb/trunk/source/Interpreter/CommandInterpreter.cpp
===
--- lldb/trunk/source/Interpreter/CommandInterpreter.cpp
+++ lldb/trunk/source/Interpreter/CommandInterpreter.cpp
@@ -478,7 +478,7 @@
   std::unique_ptr break_regex_cmd_ap(
   new CommandObjectRegexCommand(
   *this, "_regexp-break",
-  "Set a breakpoint using one of several shorthand formats.\n",
+  "Set a breakpoint using one of several shorthand formats.",
   "\n"
   "_regexp-break :\n"
   "  main.c:12 // Break at line 12 of "
@@ -527,7 +527,7 @@
   std::unique_ptr tbreak_regex_cmd_ap(
   new CommandObjectRegexCommand(
   *this, "_regexp-tbreak",
-  "Set a one-shot breakpoint using one of several shorthand 
formats.\n",
+  "Set a one-shot breakpoint using one of several shorthand formats.",
   "\n"
   "_regexp-break :\n"
   "  main.c:12 // Break at line 12 of "


Index: lldb/trunk/source/Interpreter/CommandInterpreter.cpp
===
--- lldb/trunk/source/Interpreter/CommandInterpreter.cpp
+++ lldb/trunk/source/Interpreter/CommandInterpreter.cpp
@@ -478,7 +478,7 @@
   std::unique_ptr break_regex_cmd_ap(
   new CommandObjectRegexCommand(
   *this, "_regexp-break",
-  "Set a breakpoint using one of several shorthand formats.\n",
+  "Set a breakpoint using one of several shorthand formats.",
   "\n"
   "_regexp-break :\n"
   "  main.c:12 // Break at line 12 of "
@@ -527,7 +527,7 @@
   std::unique_ptr tbreak_regex_cmd_ap(
   new CommandObjectRegexCommand(
   *this, "_regexp-tbreak",
-  "Set a one-shot breakpoint using one of several shorthand formats.\n",
+  "Set a one-shot breakpoint using one of several shorthand formats.",
   "\n"
   "_regexp-break :\n"
   "  main.c:12 // Break at line 12 of "
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D50025: Don't ignore byte_order in Stream::PutMaxHex64

2018-07-30 Thread Raphael Isemann via Phabricator via lldb-commits
teemperor created this revision.

Note: We don't have a unittest for Stream yet, so the regression test for this 
will be added with the
upcoming Stream unit test.


https://reviews.llvm.org/D50025

Files:
  source/Utility/Stream.cpp


Index: source/Utility/Stream.cpp
===
--- source/Utility/Stream.cpp
+++ source/Utility/Stream.cpp
@@ -427,11 +427,11 @@
   case 1:
 return PutHex8((uint8_t)uvalue);
   case 2:
-return PutHex16((uint16_t)uvalue);
+return PutHex16((uint16_t)uvalue, byte_order);
   case 4:
-return PutHex32((uint32_t)uvalue);
+return PutHex32((uint32_t)uvalue, byte_order);
   case 8:
-return PutHex64(uvalue);
+return PutHex64(uvalue, byte_order);
   }
   return 0;
 }


Index: source/Utility/Stream.cpp
===
--- source/Utility/Stream.cpp
+++ source/Utility/Stream.cpp
@@ -427,11 +427,11 @@
   case 1:
 return PutHex8((uint8_t)uvalue);
   case 2:
-return PutHex16((uint16_t)uvalue);
+return PutHex16((uint16_t)uvalue, byte_order);
   case 4:
-return PutHex32((uint32_t)uvalue);
+return PutHex32((uint32_t)uvalue, byte_order);
   case 8:
-return PutHex64(uvalue);
+return PutHex64(uvalue, byte_order);
   }
   return 0;
 }
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D50027: Added initial unit test for LLDB's Stream class.

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

- Removed MaxHex64 test (which moved to the child revision to be in the same 
commit as the related bug).


https://reviews.llvm.org/D50027

Files:
  unittests/Utility/CMakeLists.txt
  unittests/Utility/StreamTest.cpp

Index: unittests/Utility/StreamTest.cpp
===
--- /dev/null
+++ unittests/Utility/StreamTest.cpp
@@ -0,0 +1,478 @@
+//===-- StreamTest.cpp --*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#include "lldb/Utility/StreamString.h"
+#include "gtest/gtest.h"
+
+using namespace lldb_private;
+
+namespace {
+struct StreamTest : ::testing::Test {
+  // Note: Stream is an abstract class, so we use StreamString to test it. To
+  // make it easier to change this later, only methods in this class explicitly
+  // refer to the StringStream class.
+  StreamString s;
+  // We return here a std::string because that way gtest can print better
+  // assertion messages.
+  std::string Value() const {
+return s.GetString().str();
+  }
+};
+}
+
+namespace {
+// A StreamTest where we expect the Stream output to be binary.
+struct BinaryStreamTest : StreamTest {
+  void SetUp() override {
+s.GetFlags().Set(Stream::eBinary);
+  }
+};
+}
+
+TEST_F(StreamTest, ChangingByteOrder) {
+  s.SetByteOrder(lldb::eByteOrderPDP);
+  EXPECT_EQ(lldb::eByteOrderPDP, s.GetByteOrder());
+}
+
+TEST_F(StreamTest, PutChar) {
+  s.PutChar('a');
+  EXPECT_EQ("a", Value());
+
+  s.PutChar('1');
+  EXPECT_EQ("a1", Value());
+}
+
+TEST_F(StreamTest, PutCharWhitespace) {
+  s.PutChar(' ');
+  EXPECT_EQ(" ", Value());
+
+  s.PutChar('\n');
+  EXPECT_EQ(" \n", Value());
+
+  s.PutChar('\r');
+  EXPECT_EQ(" \n\r", Value());
+
+  s.PutChar('\t');
+  EXPECT_EQ(" \n\r\t", Value());
+}
+
+TEST_F(StreamTest, PutCString) {
+  s.PutCString("");
+  EXPECT_EQ("", Value());
+
+  s.PutCString("foobar");
+  EXPECT_EQ("foobar", Value());
+
+  s.PutCString(" ");
+  EXPECT_EQ("foobar ", Value());
+}
+
+TEST_F(StreamTest, PutCStringWithStringRef) {
+  s.PutCString(llvm::StringRef(""));
+  EXPECT_EQ("", Value());
+
+  s.PutCString(llvm::StringRef("foobar"));
+  EXPECT_EQ("foobar", Value());
+
+  s.PutCString(llvm::StringRef(" "));
+  EXPECT_EQ("foobar ", Value());
+}
+
+TEST_F(StreamTest, QuotedCString) {
+  s.QuotedCString("foo");
+  EXPECT_EQ("\"foo\"", Value());
+
+  s.QuotedCString("bar");
+  EXPECT_EQ("\"foo\"\"bar\"", Value());
+
+  s.QuotedCString(" ");
+  EXPECT_EQ("\"foo\"\"bar\"\" \"", Value());
+}
+
+TEST_F(StreamTest, PutCharNull) {
+  s.PutChar('\0');
+  EXPECT_EQ(std::string("\0", 1), Value());
+
+  s.PutChar('a');
+  EXPECT_EQ(std::string("\0a", 2), Value());
+}
+
+TEST_F(StreamTest, PutCStringAsRawHex8) {
+  s.PutCStringAsRawHex8("");
+  // FIXME: Check that printing 00 on an empty string is the intended behavior.
+  // It seems kind of unexpected  that we print the trailing 0 byte for empty
+  // strings, but not for non-empty strings.
+  EXPECT_EQ("00", Value());
+
+  s.PutCStringAsRawHex8("foobar");
+  EXPECT_EQ("00666f6f626172", Value());
+
+  s.PutCStringAsRawHex8(" ");
+  EXPECT_EQ("00666f6f62617220", Value());
+}
+
+TEST_F(StreamTest, PutHex8) {
+  s.PutHex8((uint8_t)55);
+  EXPECT_EQ("37", Value());
+  s.PutHex8(std::numeric_limits::max());
+  EXPECT_EQ("37ff", Value());
+  s.PutHex8((uint8_t)0);
+  EXPECT_EQ("37ff00", Value());
+}
+
+TEST_F(StreamTest, PutNHex8) {
+  s.PutNHex8(0, (uint8_t)55);
+  EXPECT_EQ("", Value());
+  s.PutNHex8(1, (uint8_t)55);
+  EXPECT_EQ("37", Value());
+  s.PutNHex8(2, (uint8_t)55);
+  EXPECT_EQ("373737", Value());
+  s.PutNHex8(1, (uint8_t)56);
+  EXPECT_EQ("37373738", Value());
+}
+
+TEST_F(StreamTest, PutHex16ByteOrderLittle) {
+  s.PutHex16(0x1234U, lldb::eByteOrderLittle);
+  EXPECT_EQ("3412", Value());
+  s.PutHex16(std::numeric_limits::max(), lldb::eByteOrderLittle);
+  EXPECT_EQ("3412", Value());
+  s.PutHex16(0U, lldb::eByteOrderLittle);
+  EXPECT_EQ("3412", Value());
+}
+
+TEST_F(StreamTest, PutHex16ByteOrderBig) {
+  s.PutHex16(0x1234U, lldb::eByteOrderBig);
+  EXPECT_EQ("1234", Value());
+  s.PutHex16(std::numeric_limits::max(), lldb::eByteOrderBig);
+  EXPECT_EQ("1234", Value());
+  s.PutHex16(0U, lldb::eByteOrderBig);
+  EXPECT_EQ("1234", Value());
+}
+
+TEST_F(StreamTest, PutHex32ByteOrderLittle) {
+  s.PutHex32(0x12345678U, lldb::eByteOrderLittle);
+  EXPECT_EQ("78563412", Value());
+  s.PutHex32(std::numeric_limits::max(), lldb::eByteOrderLittle);
+  EXPECT_EQ("78563412", Value());
+  s.PutHex32(0U, lldb::eByteOrderLittle);
+  EXPECT_EQ("78563412", Value());
+}
+
+TEST_F(StreamTest, PutHex32ByteOrderBig) {
+  

[Lldb-commits] [PATCH] D50026: Remove Stream::UnitTest

2018-07-30 Thread Raphael Isemann via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL338345: Remove Stream::UnitTest (authored by teemperor, 
committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D50026?vs=158120=158151#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D50026

Files:
  lldb/trunk/include/lldb/Utility/Stream.h
  lldb/trunk/source/Utility/Stream.cpp


Index: lldb/trunk/source/Utility/Stream.cpp
===
--- lldb/trunk/source/Utility/Stream.cpp
+++ lldb/trunk/source/Utility/Stream.cpp
@@ -526,48 +526,3 @@
 m_flags.Set(eBinary);
   return bytes_written;
 }
-
-void Stream::UnitTest(Stream *s) {
-  s->PutHex8(0x12);
-
-  s->PutChar(' ');
-  s->PutHex16(0x3456, endian::InlHostByteOrder());
-  s->PutChar(' ');
-  s->PutHex16(0x3456, eByteOrderBig);
-  s->PutChar(' ');
-  s->PutHex16(0x3456, eByteOrderLittle);
-
-  s->PutChar(' ');
-  s->PutHex32(0x789abcde, endian::InlHostByteOrder());
-  s->PutChar(' ');
-  s->PutHex32(0x789abcde, eByteOrderBig);
-  s->PutChar(' ');
-  s->PutHex32(0x789abcde, eByteOrderLittle);
-
-  s->PutChar(' ');
-  s->PutHex64(0x1122334455667788ull, endian::InlHostByteOrder());
-  s->PutChar(' ');
-  s->PutHex64(0x1122334455667788ull, eByteOrderBig);
-  s->PutChar(' ');
-  s->PutHex64(0x1122334455667788ull, eByteOrderLittle);
-
-  const char *hola = "Hello World!!!";
-  s->PutChar(' ');
-  s->PutCString(hola);
-
-  s->PutChar(' ');
-  s->Write(hola, 5);
-
-  s->PutChar(' ');
-  s->PutCStringAsRawHex8(hola);
-
-  s->PutChar(' ');
-  s->PutCStringAsRawHex8("01234");
-
-  s->PutChar(' ');
-  s->Printf("pid=%i", 12733);
-
-  s->PutChar(' ');
-  s->PrintfAsRawHex8("pid=%i", 12733);
-  s->PutChar('\n');
-}
Index: lldb/trunk/include/lldb/Utility/Stream.h
===
--- lldb/trunk/include/lldb/Utility/Stream.h
+++ lldb/trunk/include/lldb/Utility/Stream.h
@@ -524,8 +524,6 @@
   //--
   size_t PutULEB128(uint64_t uval);
 
-  static void UnitTest(Stream *s);
-
 protected:
   //--
   // Member variables


Index: lldb/trunk/source/Utility/Stream.cpp
===
--- lldb/trunk/source/Utility/Stream.cpp
+++ lldb/trunk/source/Utility/Stream.cpp
@@ -526,48 +526,3 @@
 m_flags.Set(eBinary);
   return bytes_written;
 }
-
-void Stream::UnitTest(Stream *s) {
-  s->PutHex8(0x12);
-
-  s->PutChar(' ');
-  s->PutHex16(0x3456, endian::InlHostByteOrder());
-  s->PutChar(' ');
-  s->PutHex16(0x3456, eByteOrderBig);
-  s->PutChar(' ');
-  s->PutHex16(0x3456, eByteOrderLittle);
-
-  s->PutChar(' ');
-  s->PutHex32(0x789abcde, endian::InlHostByteOrder());
-  s->PutChar(' ');
-  s->PutHex32(0x789abcde, eByteOrderBig);
-  s->PutChar(' ');
-  s->PutHex32(0x789abcde, eByteOrderLittle);
-
-  s->PutChar(' ');
-  s->PutHex64(0x1122334455667788ull, endian::InlHostByteOrder());
-  s->PutChar(' ');
-  s->PutHex64(0x1122334455667788ull, eByteOrderBig);
-  s->PutChar(' ');
-  s->PutHex64(0x1122334455667788ull, eByteOrderLittle);
-
-  const char *hola = "Hello World!!!";
-  s->PutChar(' ');
-  s->PutCString(hola);
-
-  s->PutChar(' ');
-  s->Write(hola, 5);
-
-  s->PutChar(' ');
-  s->PutCStringAsRawHex8(hola);
-
-  s->PutChar(' ');
-  s->PutCStringAsRawHex8("01234");
-
-  s->PutChar(' ');
-  s->Printf("pid=%i", 12733);
-
-  s->PutChar(' ');
-  s->PrintfAsRawHex8("pid=%i", 12733);
-  s->PutChar('\n');
-}
Index: lldb/trunk/include/lldb/Utility/Stream.h
===
--- lldb/trunk/include/lldb/Utility/Stream.h
+++ lldb/trunk/include/lldb/Utility/Stream.h
@@ -524,8 +524,6 @@
   //--
   size_t PutULEB128(uint64_t uval);
 
-  static void UnitTest(Stream *s);
-
 protected:
   //--
   // Member variables
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D49831: Don't print two errors for unknown commands.

2018-07-26 Thread Raphael Isemann via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL338040: Dont print two errors for unknown commands. 
(authored by teemperor, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D49831?vs=157415=157509#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D49831

Files:
  
lldb/trunk/packages/Python/lldbsuite/test/functionalities/wrong_commands/.categories
  
lldb/trunk/packages/Python/lldbsuite/test/functionalities/wrong_commands/TestWrongCommands.py
  lldb/trunk/source/Interpreter/CommandInterpreter.cpp


Index: 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/wrong_commands/TestWrongCommands.py
===
--- 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/wrong_commands/TestWrongCommands.py
+++ 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/wrong_commands/TestWrongCommands.py
@@ -0,0 +1,39 @@
+"""
+Test how lldb reacts to wrong commands
+"""
+
+from __future__ import print_function
+
+import os
+import time
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+class UnknownCommandTestCase(TestBase):
+
+mydir = TestBase.compute_mydir(__file__)
+
+@no_debug_info_test
+def test_ambiguous_command(self):
+command_interpreter = self.dbg.GetCommandInterpreter()
+self.assertTrue(command_interpreter, VALID_COMMAND_INTERPRETER)
+result = lldb.SBCommandReturnObject()
+
+command_interpreter.HandleCommand("g", result)
+self.assertFalse(result.Succeeded())
+self.assertRegexpMatches(result.GetError(), "Ambiguous command 'g'. 
Possible matches:")
+self.assertRegexpMatches(result.GetError(), "gui")
+self.assertRegexpMatches(result.GetError(), "gdb-remote")
+# FIXME: Somehow we get 'gui' and 'gdb-remote' twice in the output.
+
+@no_debug_info_test
+def test_unknown_command(self):
+command_interpreter = self.dbg.GetCommandInterpreter()
+self.assertTrue(command_interpreter, VALID_COMMAND_INTERPRETER)
+result = lldb.SBCommandReturnObject()
+
+command_interpreter.HandleCommand("qbert", result)
+self.assertFalse(result.Succeeded())
+self.assertEquals(result.GetError(), "error: 'qbert' is not a valid 
command.\n")
Index: 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/wrong_commands/.categories
===
--- 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/wrong_commands/.categories
+++ 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/wrong_commands/.categories
@@ -0,0 +1 @@
+cmdline
Index: lldb/trunk/source/Interpreter/CommandInterpreter.cpp
===
--- lldb/trunk/source/Interpreter/CommandInterpreter.cpp
+++ lldb/trunk/source/Interpreter/CommandInterpreter.cpp
@@ -1693,33 +1693,6 @@
   remainder.c_str());
 
 cmd_obj->Execute(remainder.c_str(), result);
-  } else {
-// We didn't find the first command object, so complete the first argument.
-Args command_args(command_string);
-StringList matches;
-unsigned cursor_char_position = strlen(command_args.GetArgumentAtIndex(0));
-CompletionRequest request(command_line, cursor_char_position, 0, -1,
-  matches);
-int num_matches = HandleCompletionMatches(request);
-
-if (num_matches > 0) {
-  std::string error_msg;
-  error_msg.assign("ambiguous command '");
-  error_msg.append(command_args.GetArgumentAtIndex(0));
-  error_msg.append("'.");
-
-  error_msg.append(" Possible completions:");
-  for (int i = 0; i < num_matches; i++) {
-error_msg.append("\n\t");
-error_msg.append(matches.GetStringAtIndex(i));
-  }
-  error_msg.append("\n");
-  result.AppendRawError(error_msg.c_str());
-} else
-  result.AppendErrorWithFormat("Unrecognized command '%s'.\n",
-   command_args.GetArgumentAtIndex(0));
-
-result.SetStatus(eReturnStatusFailed);
   }
 
   if (log)


Index: lldb/trunk/packages/Python/lldbsuite/test/functionalities/wrong_commands/TestWrongCommands.py
===
--- lldb/trunk/packages/Python/lldbsuite/test/functionalities/wrong_commands/TestWrongCommands.py
+++ lldb/trunk/packages/Python/lldbsuite/test/functionalities/wrong_commands/TestWrongCommands.py
@@ -0,0 +1,39 @@
+"""
+Test how lldb reacts to wrong commands
+"""
+
+from __future__ import print_function
+
+import os
+import time
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+class UnknownCommandTestCase(TestBase):
+
+mydir = TestBase.compute_mydir(__file__)
+
+

[Lldb-commits] [PATCH] D49866: Fix duplicate suggestions after an ambiguous command

2018-07-26 Thread Raphael Isemann via Phabricator via lldb-commits
teemperor created this revision.

So far lldb is printing this when it finds an ambiguous command:

  (lldb) g
  Ambiguous command 'g'. Possible matches:
  gdb-remote
  gui
  gdb-remote
  gui

The duplicates come from the fact that we call the same query twice with the 
same parameters
and add it to the same list. This patch just removes the second query call to 
`GetCommandObject`.

As `GetCommandObject` is const and the name parameter is also not modified, 
this shouldn't break
anything else. I didn't merge the remaining if statement into the else as I 
think otherwise the
`if obj==nullptr do X else Y` pattern in there becomes hard to recognize.


https://reviews.llvm.org/D49866

Files:
  
packages/Python/lldbsuite/test/functionalities/wrong_commands/TestWrongCommands.py
  source/Interpreter/CommandInterpreter.cpp


Index: source/Interpreter/CommandInterpreter.cpp
===
--- source/Interpreter/CommandInterpreter.cpp
+++ source/Interpreter/CommandInterpreter.cpp
@@ -2932,8 +2932,6 @@
   actual_cmd_name_len = cmd_obj->GetCommandName().size();
 }
   } else {
-if (!cmd_obj)
-  cmd_obj = GetCommandObject(next_word, );
 if (cmd_obj) {
   llvm::StringRef cmd_name = cmd_obj->GetCommandName();
   actual_cmd_name_len += cmd_name.size();
Index: 
packages/Python/lldbsuite/test/functionalities/wrong_commands/TestWrongCommands.py
===
--- 
packages/Python/lldbsuite/test/functionalities/wrong_commands/TestWrongCommands.py
+++ 
packages/Python/lldbsuite/test/functionalities/wrong_commands/TestWrongCommands.py
@@ -26,7 +26,7 @@
 self.assertRegexpMatches(result.GetError(), "Ambiguous command 'g'. 
Possible matches:")
 self.assertRegexpMatches(result.GetError(), "gui")
 self.assertRegexpMatches(result.GetError(), "gdb-remote")
-# FIXME: Somehow we get 'gui' and 'gdb-remote' twice in the output.
+self.assertEquals(1, result.GetError().count("gdb-remote"))
 
 @no_debug_info_test
 def test_unknown_command(self):


Index: source/Interpreter/CommandInterpreter.cpp
===
--- source/Interpreter/CommandInterpreter.cpp
+++ source/Interpreter/CommandInterpreter.cpp
@@ -2932,8 +2932,6 @@
   actual_cmd_name_len = cmd_obj->GetCommandName().size();
 }
   } else {
-if (!cmd_obj)
-  cmd_obj = GetCommandObject(next_word, );
 if (cmd_obj) {
   llvm::StringRef cmd_name = cmd_obj->GetCommandName();
   actual_cmd_name_len += cmd_name.size();
Index: packages/Python/lldbsuite/test/functionalities/wrong_commands/TestWrongCommands.py
===
--- packages/Python/lldbsuite/test/functionalities/wrong_commands/TestWrongCommands.py
+++ packages/Python/lldbsuite/test/functionalities/wrong_commands/TestWrongCommands.py
@@ -26,7 +26,7 @@
 self.assertRegexpMatches(result.GetError(), "Ambiguous command 'g'. Possible matches:")
 self.assertRegexpMatches(result.GetError(), "gui")
 self.assertRegexpMatches(result.GetError(), "gdb-remote")
-# FIXME: Somehow we get 'gui' and 'gdb-remote' twice in the output.
+self.assertEquals(1, result.GetError().count("gdb-remote"))
 
 @no_debug_info_test
 def test_unknown_command(self):
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


  1   2   3   4   5   6   7   8   9   10   >