[Lldb-commits] [PATCH] D51999: build: add libedit to include paths

2018-09-21 Thread Phabricator via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL342757: build: add libedit to include paths (authored by 
tkrasnukha, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D51999?vs=166507&id=166522#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D51999

Files:
  lldb/trunk/source/Core/CMakeLists.txt
  lldb/trunk/source/Host/CMakeLists.txt
  lldb/trunk/source/Interpreter/CMakeLists.txt


Index: lldb/trunk/source/Interpreter/CMakeLists.txt
===
--- lldb/trunk/source/Interpreter/CMakeLists.txt
+++ lldb/trunk/source/Interpreter/CMakeLists.txt
@@ -55,3 +55,7 @@
   LINK_COMPONENTS
 Support
   )
+
+if (NOT LLDB_DISABLE_LIBEDIT)
+  target_include_directories(lldbInterpreter PRIVATE ${libedit_INCLUDE_DIRS})
+endif()
\ No newline at end of file
Index: lldb/trunk/source/Host/CMakeLists.txt
===
--- lldb/trunk/source/Host/CMakeLists.txt
+++ lldb/trunk/source/Host/CMakeLists.txt
@@ -174,3 +174,7 @@
 Object
 Support
   )
+
+if (NOT LLDB_DISABLE_LIBEDIT)
+  target_include_directories(lldbHost PUBLIC ${libedit_INCLUDE_DIRS})
+endif()
Index: lldb/trunk/source/Core/CMakeLists.txt
===
--- lldb/trunk/source/Core/CMakeLists.txt
+++ lldb/trunk/source/Core/CMakeLists.txt
@@ -80,3 +80,7 @@
 # Needed to properly resolve references in a debug build.
 # TODO: Remove once we have better layering
 set_target_properties(lldbCore PROPERTIES LINK_INTERFACE_MULTIPLICITY 4)
+
+if (NOT LLDB_DISABLE_LIBEDIT)
+  target_include_directories(lldbCore PRIVATE ${libedit_INCLUDE_DIRS})
+endif()


Index: lldb/trunk/source/Interpreter/CMakeLists.txt
===
--- lldb/trunk/source/Interpreter/CMakeLists.txt
+++ lldb/trunk/source/Interpreter/CMakeLists.txt
@@ -55,3 +55,7 @@
   LINK_COMPONENTS
 Support
   )
+
+if (NOT LLDB_DISABLE_LIBEDIT)
+  target_include_directories(lldbInterpreter PRIVATE ${libedit_INCLUDE_DIRS})
+endif()
\ No newline at end of file
Index: lldb/trunk/source/Host/CMakeLists.txt
===
--- lldb/trunk/source/Host/CMakeLists.txt
+++ lldb/trunk/source/Host/CMakeLists.txt
@@ -174,3 +174,7 @@
 Object
 Support
   )
+
+if (NOT LLDB_DISABLE_LIBEDIT)
+  target_include_directories(lldbHost PUBLIC ${libedit_INCLUDE_DIRS})
+endif()
Index: lldb/trunk/source/Core/CMakeLists.txt
===
--- lldb/trunk/source/Core/CMakeLists.txt
+++ lldb/trunk/source/Core/CMakeLists.txt
@@ -80,3 +80,7 @@
 # Needed to properly resolve references in a debug build.
 # TODO: Remove once we have better layering
 set_target_properties(lldbCore PROPERTIES LINK_INTERFACE_MULTIPLICITY 4)
+
+if (NOT LLDB_DISABLE_LIBEDIT)
+  target_include_directories(lldbCore PRIVATE ${libedit_INCLUDE_DIRS})
+endif()
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D48623: Move architecture-specific address adjustment to architecture plugins.

2018-09-21 Thread Phabricator via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rLLDB342762: Move architecture-specific address adjustment to 
architecture plugins (authored by tkrasnukha, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D48623?vs=166520&id=166530#toc

Repository:
  rLLDB LLDB

https://reviews.llvm.org/D48623

Files:
  include/lldb/Core/Architecture.h
  source/Plugins/Architecture/Arm/ArchitectureArm.cpp
  source/Plugins/Architecture/Arm/ArchitectureArm.h
  source/Plugins/Architecture/CMakeLists.txt
  source/Plugins/Architecture/Mips/ArchitectureMips.cpp
  source/Plugins/Architecture/Mips/ArchitectureMips.h
  source/Plugins/Architecture/Mips/CMakeLists.txt
  source/Target/Target.cpp

Index: source/Target/Target.cpp
===
--- source/Target/Target.cpp
+++ source/Target/Target.cpp
@@ -2428,249 +2428,22 @@
 
 lldb::addr_t Target::GetCallableLoadAddress(lldb::addr_t load_addr,
 AddressClass addr_class) const {
-  addr_t code_addr = load_addr;
-  switch (m_arch.GetSpec().GetMachine()) {
-  case llvm::Triple::mips:
-  case llvm::Triple::mipsel:
-  case llvm::Triple::mips64:
-  case llvm::Triple::mips64el:
-switch (addr_class) {
-case AddressClass::eData:
-case AddressClass::eDebug:
-  return LLDB_INVALID_ADDRESS;
-
-case AddressClass::eUnknown:
-case AddressClass::eInvalid:
-case AddressClass::eCode:
-case AddressClass::eCodeAlternateISA:
-case AddressClass::eRuntime:
-  if ((code_addr & 2ull) || (addr_class == AddressClass::eCodeAlternateISA))
-code_addr |= 1ull;
-  break;
-}
-break;
-
-  case llvm::Triple::arm:
-  case llvm::Triple::thumb:
-switch (addr_class) {
-case AddressClass::eData:
-case AddressClass::eDebug:
-  return LLDB_INVALID_ADDRESS;
-
-case AddressClass::eUnknown:
-case AddressClass::eInvalid:
-case AddressClass::eCode:
-case AddressClass::eCodeAlternateISA:
-case AddressClass::eRuntime:
-  // Check if bit zero it no set?
-  if ((code_addr & 1ull) == 0) {
-// Bit zero isn't set, check if the address is a multiple of 2?
-if (code_addr & 2ull) {
-  // The address is a multiple of 2 so it must be thumb, set bit zero
-  code_addr |= 1ull;
-} else if (addr_class == AddressClass::eCodeAlternateISA) {
-  // We checked the address and the address claims to be the alternate
-  // ISA which means thumb, so set bit zero.
-  code_addr |= 1ull;
-}
-  }
-  break;
-}
-break;
-
-  default:
-break;
-  }
-  return code_addr;
+  auto arch_plugin = GetArchitecturePlugin();
+  return arch_plugin ?
+  arch_plugin->GetCallableLoadAddress(load_addr, addr_class) : load_addr;
 }
 
 lldb::addr_t Target::GetOpcodeLoadAddress(lldb::addr_t load_addr,
   AddressClass addr_class) const {
-  addr_t opcode_addr = load_addr;
-  switch (m_arch.GetSpec().GetMachine()) {
-  case llvm::Triple::mips:
-  case llvm::Triple::mipsel:
-  case llvm::Triple::mips64:
-  case llvm::Triple::mips64el:
-  case llvm::Triple::arm:
-  case llvm::Triple::thumb:
-switch (addr_class) {
-case AddressClass::eData:
-case AddressClass::eDebug:
-  return LLDB_INVALID_ADDRESS;
-
-case AddressClass::eInvalid:
-case AddressClass::eUnknown:
-case AddressClass::eCode:
-case AddressClass::eCodeAlternateISA:
-case AddressClass::eRuntime:
-  opcode_addr &= ~(1ull);
-  break;
-}
-break;
-
-  default:
-break;
-  }
-  return opcode_addr;
+  auto arch_plugin = GetArchitecturePlugin();
+  return arch_plugin ?
+  arch_plugin->GetOpcodeLoadAddress(load_addr, addr_class) : load_addr;
 }
 
 lldb::addr_t Target::GetBreakableLoadAddress(lldb::addr_t addr) {
-  addr_t breakable_addr = addr;
-  Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_BREAKPOINTS));
-
-  switch (m_arch.GetSpec().GetMachine()) {
-  default:
-break;
-  case llvm::Triple::mips:
-  case llvm::Triple::mipsel:
-  case llvm::Triple::mips64:
-  case llvm::Triple::mips64el: {
-addr_t function_start = 0;
-addr_t current_offset = 0;
-uint32_t loop_count = 0;
-Address resolved_addr;
-uint32_t arch_flags = m_arch.GetSpec().GetFlags();
-bool IsMips16 = arch_flags & ArchSpec::eMIPSAse_mips16;
-bool IsMicromips = arch_flags & ArchSpec::eMIPSAse_micromips;
-SectionLoadList §ion_load_list = GetSectionLoadList();
-
-if (section_load_list.IsEmpty())
-  // No sections are loaded, so we must assume we are not running yet and
-  // need to operate only on file address.
-  m_images.ResolveFileAddress(addr, resolved_addr);
-else
-  section_load_list.ResolveLoadAddress(addr, resolved_addr);
-
-// Get the function boundaries to make sure we don't scan back before the
-// beginning of the current function.
- 

[Lldb-commits] [PATCH] D52376: [Swig] Merge typemaps with same bodies

2018-09-25 Thread Phabricator via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL342959: [Swig] Merge typemaps with same bodies (authored by 
tkrasnukha, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D52376?vs=166719&id=166838#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D52376

Files:
  lldb/trunk/scripts/Python/python-typemaps.swig

Index: lldb/trunk/scripts/Python/python-typemaps.swig
===
--- lldb/trunk/scripts/Python/python-typemaps.swig
+++ lldb/trunk/scripts/Python/python-typemaps.swig
@@ -139,30 +139,9 @@
 
 // typemap for an outgoing buffer
 // See also SBEvent::SBEvent(uint32_t event, const char *cstr, uint32_t cstr_len).
-%typemap(in) (const char *cstr, uint32_t cstr_len) {
-   using namespace lldb_private;
-   if (PythonString::Check($input)) {
-  PythonString str(PyRefType::Borrowed, $input);
-  $1 = (char*)str.GetString().data();
-  $2 = str.GetSize();
-   }
-   else if(PythonByteArray::Check($input)) {
-  PythonByteArray bytearray(PyRefType::Borrowed, $input);
-  $1 = (char*)bytearray.GetBytes().data();
-  $2 = bytearray.GetSize();
-   }
-   else if (PythonBytes::Check($input)) {
-  PythonBytes bytes(PyRefType::Borrowed, $input);
-  $1 = (char*)bytes.GetBytes().data();
-  $2 = bytes.GetSize();
-   }
-   else {
-  PyErr_SetString(PyExc_ValueError, "Expecting a string");
-  return NULL;
-   }
-}
 // Ditto for SBProcess::PutSTDIN(const char *src, size_t src_len).
-%typemap(in) (const char *src, size_t src_len) {
+%typemap(in) (const char *cstr, uint32_t cstr_len),
+ (const char *src, size_t src_len) {
using namespace lldb_private;
if (PythonString::Check($input)) {
   PythonString str(PyRefType::Borrowed, $input);
@@ -184,32 +163,9 @@
   return NULL;
}
 }
-// And SBProcess::WriteMemory.
-%typemap(in) (const void *buf, size_t size) {
-   using namespace lldb_private;
-   if (PythonString::Check($input)) {
-  PythonString str(PyRefType::Borrowed, $input);
-  $1 = (void*)str.GetString().data();
-  $2 = str.GetSize();
-   }
-   else if(PythonByteArray::Check($input)) {
-  PythonByteArray bytearray(PyRefType::Borrowed, $input);
-  $1 = (void*)bytearray.GetBytes().data();
-  $2 = bytearray.GetSize();
-   }
-   else if (PythonBytes::Check($input)) {
-  PythonBytes bytes(PyRefType::Borrowed, $input);
-  $1 = (void*)bytes.GetBytes().data();
-  $2 = bytes.GetSize();
-   }
-   else {
-  PyErr_SetString(PyExc_ValueError, "Expecting a buffer");
-  return NULL;
-   }
-}
-
-// For SBDebugger::DispatchInput
-%typemap(in) (const void *data, size_t data_len) {
+// For SBProcess::WriteMemory, SBTarget::GetInstructions and SBDebugger::DispatchInput.
+%typemap(in) (const void *buf, size_t size),
+ (const void *data, size_t data_len) {
using namespace lldb_private;
if (PythonString::Check($input)) {
   PythonString str(PyRefType::Borrowed, $input);
@@ -264,142 +220,70 @@
free($1);
 }
 
-// these typemaps allow Python users to pass list objects
-// and have them turn into C++ arrays (this is useful, for instance
-// when creating SBData objects from lists of numbers)
-%typemap(in) (uint64_t* array, size_t array_len) {
-  /* Check if is a list  */
-  if (PyList_Check($input)) {
-int size = PyList_Size($input);
-int i = 0;
-$2 = size;
-$1 = (uint64_t*) malloc(size * sizeof(uint64_t));
-for (i = 0; i < size; i++) {
-  PyObject *o = PyList_GetItem($input,i);
-  if (PyInt_Check(o)) {
-$1[i] = PyInt_AsLong(o);
-  }
-  else if (PyLong_Check(o)) {
-$1[i] = PyLong_AsUnsignedLongLong(o);
-  }
-  else {
-PyErr_SetString(PyExc_TypeError,"list must contain numbers");
-free($1);
-return NULL;
-  }
-
-  if (PyErr_Occurred()) {
-free($1);
-return NULL;
-  }
-}
-  } else if ($input == Py_None) {
-$1 =  NULL;
-$2 = 0;
-  } else {
-PyErr_SetString(PyExc_TypeError,"not a list");
-return NULL;
-  }
+%{
+namespace {
+template 
+T PyLongAsT(PyObject *obj) {
+  static_assert(true, "unsupported type"); 
 }
 
-%typemap(freearg) (uint64_t* array, size_t array_len) {
-  free($1);
+template <> uint64_t PyLongAsT(PyObject *obj) {
+  return static_cast(PyLong_AsUnsignedLongLong(obj));
 }
 
-%typemap(in) (uint32_t* array, size_t array_len) {
-  /* Check if is a list  */
-  if (PyList_Check($input)) {
-int size = PyList_Size($input);
-int i = 0;
-$2 = size;
-$1 = (uint32_t*) malloc(size * sizeof(uint32_t));
-for (i = 0; i < size; i++) {
-  PyObject *o = PyList_GetItem($input,i);
-  if (PyInt_Check(o)) {
-$1[i] = PyInt_AsLong(o);
-  }
-  else if (PyLong_Check(o)) {
-$1[i] = PyLong_AsUnsignedLong(o);
-  }
-  else {
-PyErr_SetString(PyExc_TypeError,"list must contain

[Lldb-commits] [PATCH] D52516: [lldbinline] Set directory attribute on test-specific classes

2018-09-25 Thread Phabricator via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL343023: [lldbinline] Set directory attribute on 
test-specific classes (authored by vedantk, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D52516?vs=166980&id=166984#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D52516

Files:
  lldb/trunk/packages/Python/lldbsuite/test/lldbinline.py


Index: lldb/trunk/packages/Python/lldbsuite/test/lldbinline.py
===
--- lldb/trunk/packages/Python/lldbsuite/test/lldbinline.py
+++ lldb/trunk/packages/Python/lldbsuite/test/lldbinline.py
@@ -195,7 +195,6 @@
 
 # Derive the test name from the current file name
 file_basename = os.path.basename(__file)
-InlineTest.mydir = TestBase.compute_mydir(__file)
 
 test_name, _ = os.path.splitext(file_basename)
 
@@ -209,4 +208,5 @@
 # Keep track of the original test filename so we report it
 # correctly in test results.
 test_class.test_filename = __file
+test_class.mydir = TestBase.compute_mydir(__file)
 return test_class


Index: lldb/trunk/packages/Python/lldbsuite/test/lldbinline.py
===
--- lldb/trunk/packages/Python/lldbsuite/test/lldbinline.py
+++ lldb/trunk/packages/Python/lldbsuite/test/lldbinline.py
@@ -195,7 +195,6 @@
 
 # Derive the test name from the current file name
 file_basename = os.path.basename(__file)
-InlineTest.mydir = TestBase.compute_mydir(__file)
 
 test_name, _ = os.path.splitext(file_basename)
 
@@ -209,4 +208,5 @@
 # Keep track of the original test filename so we report it
 # correctly in test results.
 test_class.test_filename = __file
+test_class.mydir = TestBase.compute_mydir(__file)
 return test_class
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D52572: Replace pointer to C-array of PropertyDefinition with llvm::ArrayRef

2018-09-27 Thread Phabricator via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL343181: Replace pointer to C-array of PropertyDefinition 
with llvm::ArrayRef (authored by tkrasnukha, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D52572?vs=167191&id=167242#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D52572

Files:
  lldb/trunk/include/lldb/Interpreter/OptionValueProperties.h
  lldb/trunk/include/lldb/Interpreter/Property.h
  lldb/trunk/source/Core/Debugger.cpp
  lldb/trunk/source/Core/ModuleList.cpp
  lldb/trunk/source/Interpreter/CommandInterpreter.cpp
  lldb/trunk/source/Interpreter/OptionValueProperties.cpp
  
lldb/trunk/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp
  lldb/trunk/source/Plugins/JITLoader/GDB/JITLoaderGDB.cpp
  lldb/trunk/source/Plugins/OperatingSystem/Go/OperatingSystemGo.cpp
  lldb/trunk/source/Plugins/Platform/MacOSX/PlatformDarwinKernel.cpp
  lldb/trunk/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp
  lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
  lldb/trunk/source/Plugins/StructuredData/DarwinLog/StructuredDataDarwinLog.cpp
  lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
  lldb/trunk/source/Target/Platform.cpp
  lldb/trunk/source/Target/Process.cpp
  lldb/trunk/source/Target/Target.cpp
  lldb/trunk/source/Target/Thread.cpp

Index: lldb/trunk/include/lldb/Interpreter/Property.h
===
--- lldb/trunk/include/lldb/Interpreter/Property.h
+++ lldb/trunk/include/lldb/Interpreter/Property.h
@@ -32,6 +32,8 @@
   const char *description;
 };
 
+using PropertyDefinitions = llvm::ArrayRef;
+
 class Property {
 public:
   Property(const PropertyDefinition &definition);
Index: lldb/trunk/include/lldb/Interpreter/OptionValueProperties.h
===
--- lldb/trunk/include/lldb/Interpreter/OptionValueProperties.h
+++ lldb/trunk/include/lldb/Interpreter/OptionValueProperties.h
@@ -62,7 +62,7 @@
   void Apropos(llvm::StringRef keyword,
std::vector &matching_properties) const;
 
-  void Initialize(const PropertyDefinition *setting_definitions);
+  void Initialize(const PropertyDefinitions &setting_definitions);
 
   //bool
   //GetQualifiedName (Stream &strm);
Index: lldb/trunk/source/Core/ModuleList.cpp
===
--- lldb/trunk/source/Core/ModuleList.cpp
+++ lldb/trunk/source/Core/ModuleList.cpp
@@ -74,8 +74,7 @@
  "the UUID of the executable."},
 {"clang-modules-cache-path", OptionValue::eTypeFileSpec, true, 0, nullptr,
  {},
- "The path to the clang modules cache directory (-fmodules-cache-path)."},
-{nullptr, OptionValue::eTypeInvalid, false, 0, nullptr, {}, nullptr}};
+ "The path to the clang modules cache directory (-fmodules-cache-path)."}};
 
 enum { ePropertyEnableExternalLookup, ePropertyClangModulesCachePath };
 
Index: lldb/trunk/source/Core/Debugger.cpp
===
--- lldb/trunk/source/Core/Debugger.cpp
+++ lldb/trunk/source/Core/Debugger.cpp
@@ -278,8 +278,7 @@
 {"frame-format-unique", OptionValue::eTypeFormatEntity, true, 0,
  DEFAULT_FRAME_FORMAT_NO_ARGS, {},
  "The default frame format string to use when displaying stack frame"
- "information for threads from thread backtrace unique."},
-{nullptr, OptionValue::eTypeInvalid, true, 0, nullptr, {}, nullptr}};
+ "information for threads from thread backtrace unique."}};
 
 enum {
   ePropertyAutoConfirm = 0,
Index: lldb/trunk/source/Target/Platform.cpp
===
--- lldb/trunk/source/Target/Platform.cpp
+++ lldb/trunk/source/Target/Platform.cpp
@@ -71,8 +71,7 @@
 {"use-module-cache", OptionValue::eTypeBoolean, true, true, nullptr,
  {}, "Use module cache."},
 {"module-cache-directory", OptionValue::eTypeFileSpec, true, 0, nullptr,
- {}, "Root directory for cached modules."},
-{nullptr, OptionValue::eTypeInvalid, false, 0, nullptr, {}, nullptr}};
+ {}, "Root directory for cached modules."}};
 
 enum { ePropertyUseModuleCache, ePropertyModuleCacheDirectory };
 
Index: lldb/trunk/source/Target/Target.cpp
===
--- lldb/trunk/source/Target/Target.cpp
+++ lldb/trunk/source/Target/Target.cpp
@@ -3352,8 +3352,7 @@
  nullptr, {}, "If true, LLDB will show variables that are meant to "
   "support the operation of a language's runtime support."},
 {"non-stop-mode", OptionValue::eTypeBoolean, false, 0, nullptr, {},
- "Disable lock-step debugging, instead control threads independently."},
-{nullptr, OptionValue::eTypeInvalid, false, 0, nullptr, {}, nullptr}};
+ "Disable lock-step debugging, instead control threads independen

[Lldb-commits] [PATCH] D52604: Clean-up usage of OptionDefinition arrays

2018-09-28 Thread Phabricator via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rLLDB343348: Clean-up usage of OptionDefinition arrays 
(authored by tkrasnukha, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D52604?vs=167475&id=167515#toc

Repository:
  rLLDB LLDB

https://reviews.llvm.org/D52604

Files:
  include/lldb/Target/Platform.h
  source/Commands/CommandObjectDisassemble.h
  source/Commands/CommandObjectExpression.h
  tools/driver/Driver.cpp
  tools/driver/Driver.h

Index: include/lldb/Target/Platform.h
===
--- include/lldb/Target/Platform.h
+++ include/lldb/Target/Platform.h
@@ -1131,10 +1131,6 @@
 
   llvm::ArrayRef GetDefinitions() override;
 
-  // Options table: Required for subclasses of Options.
-
-  static lldb_private::OptionDefinition g_option_table[];
-
   // Instance variables to hold the values for command options.
 
   bool m_rsync;
@@ -1160,10 +1156,6 @@
 
   llvm::ArrayRef GetDefinitions() override;
 
-  // Options table: Required for subclasses of Options.
-
-  static lldb_private::OptionDefinition g_option_table[];
-
   // Instance variables to hold the values for command options.
 
   bool m_ssh;
@@ -1187,10 +1179,6 @@
 
   llvm::ArrayRef GetDefinitions() override;
 
-  // Options table: Required for subclasses of Options.
-
-  static lldb_private::OptionDefinition g_option_table[];
-
   // Instance variables to hold the values for command options.
 
   std::string m_cache_dir;
Index: tools/driver/Driver.h
===
--- tools/driver/Driver.h
+++ tools/driver/Driver.h
@@ -68,8 +68,6 @@
 void AddInitialCommand(const char *command, CommandPlacement placement,
bool is_file, lldb::SBError &error);
 
-// static OptionDefinition m_cmd_option_table[];
-
 struct InitialCmdEntry {
   InitialCmdEntry(const char *in_contents, bool in_is_file,
   bool is_cwd_lldbinit_file_read, bool in_quiet = false)
Index: tools/driver/Driver.cpp
===
--- tools/driver/Driver.cpp
+++ tools/driver/Driver.cpp
@@ -9,6 +9,7 @@
 
 #include "Driver.h"
 
+#include 
 #include 
 #include 
 #include 
@@ -46,6 +47,7 @@
 #include "llvm/Support/PrettyStackTrace.h"
 #include "llvm/Support/Signals.h"
 #include 
+#include 
 
 #if !defined(__APPLE__)
 #include "llvm/Support/DataTypes.h"
@@ -87,7 +89,7 @@
 #define LLDB_3_TO_5 LLDB_OPT_SET_3 | LLDB_OPT_SET_4 | LLDB_OPT_SET_5
 #define LLDB_4_TO_5 LLDB_OPT_SET_4 | LLDB_OPT_SET_5
 
-static OptionDefinition g_options[] = {
+static constexpr OptionDefinition g_options[] = {
 {LLDB_OPT_SET_1, true, "help", 'h', no_argument, 0, eArgTypeNone,
  "Prints out the usage information for the LLDB debugger."},
 {LLDB_OPT_SET_2, true, "version", 'v', no_argument, 0, eArgTypeNone,
@@ -159,8 +161,9 @@
 {LLDB_OPT_SET_7, true, "repl", 'r', optional_argument, 0, eArgTypeNone,
  "Runs lldb in REPL mode with a stub process."},
 {LLDB_OPT_SET_7, true, "repl-language", 'R', required_argument, 0,
- eArgTypeNone, "Chooses the language for the REPL."},
-{0, false, NULL, 0, 0, 0, eArgTypeNone, NULL}};
+ eArgTypeNone, "Chooses the language for the REPL."}};
+
+static constexpr auto g_num_options = sizeof(g_options)/sizeof(OptionDefinition);
 
 static const uint32_t last_option_set_with_args = 2;
 
@@ -229,8 +232,7 @@
   }
 }
 
-void ShowUsage(FILE *out, OptionDefinition *option_table,
-   Driver::OptionData data) {
+static void ShowUsage(FILE *out, Driver::OptionData data) {
   uint32_t screen_width = 80;
   uint32_t indent_level = 0;
   const char *name = "lldb";
@@ -245,12 +247,10 @@
   //   [options-for-level-1]
   //   etc.
 
-  uint32_t num_options;
   uint32_t num_option_sets = 0;
 
-  for (num_options = 0; option_table[num_options].long_option != NULL;
-   ++num_options) {
-uint32_t this_usage_mask = option_table[num_options].usage_mask;
+  for (const auto &opt : g_options) {
+uint32_t this_usage_mask = opt.usage_mask;
 if (this_usage_mask == LLDB_OPT_SET_ALL) {
   if (num_option_sets == 0)
 num_option_sets = 1;
@@ -274,32 +274,32 @@
 fprintf(out, "%*s%s", indent_level, "", name);
 bool is_help_line = false;
 
-for (uint32_t i = 0; i < num_options; ++i) {
-  if (option_table[i].usage_mask & opt_set_mask) {
-CommandArgumentType arg_type = option_table[i].argument_type;
+for (const auto &opt : g_options) {
+  if (opt.usage_mask & opt_set_mask) {
+CommandArgumentType arg_type = opt.argument_type;
 const char *arg_name =
 SBCommandInterpreter::GetArgumentTypeAsCString(arg_type);
 // This is a bit of a hack, but there's no way to say certain options
 // don't have arguments yet...

[Lldb-commits] [PATCH] D52678: DWARFExpression: Resolve file addresses in the linked module

2018-10-02 Thread Phabricator via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rLLDB343612: DWARFExpression: Resolve file addresses in the 
linked module (authored by adrian, committed by ).
Herald added a subscriber: teemperor.

Changed prior to commit:
  https://reviews.llvm.org/D52678?vs=167827&id=167981#toc

Repository:
  rLLDB LLDB

https://reviews.llvm.org/D52678

Files:
  include/lldb/Expression/DWARFExpression.h
  packages/Python/lldbsuite/test/functionalities/target_var/Makefile
  packages/Python/lldbsuite/test/functionalities/target_var/TestTargetVar.py
  packages/Python/lldbsuite/test/functionalities/target_var/globals.c
  packages/Python/lldbsuite/test/functionalities/target_var/globals.ll
  source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp

Index: packages/Python/lldbsuite/test/functionalities/target_var/Makefile
===
--- packages/Python/lldbsuite/test/functionalities/target_var/Makefile
+++ packages/Python/lldbsuite/test/functionalities/target_var/Makefile
@@ -0,0 +1,10 @@
+LEVEL = ../../make
+
+include $(LEVEL)/Makefile.rules
+
+a.out: globals.ll
+	$(CC) $(CFLAGS) -g -c $^ -o globals.o
+	$(LD) $(LDFLAGS) -g globals.o -o $@
+
+clean::
+	rm -rf globals.o a.out *.dSYM
Index: packages/Python/lldbsuite/test/functionalities/target_var/globals.ll
===
--- packages/Python/lldbsuite/test/functionalities/target_var/globals.ll
+++ packages/Python/lldbsuite/test/functionalities/target_var/globals.ll
@@ -0,0 +1,42 @@
+source_filename = "globals.c"
+target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
+target triple = "x86_64-apple-macosx10.14.0"
+
+@i = global i32 42, align 4
+@p = global i32* @i, align 8, !dbg !0, !dbg !6
+
+; Function Attrs: noinline nounwind optnone ssp uwtable
+define i32 @main() #0 !dbg !15 {
+entry:
+  %retval = alloca i32, align 4
+  store i32 0, i32* %retval, align 4
+  %0 = load i32*, i32** @p, align 8, !dbg !18
+  %1 = load i32, i32* %0, align 4, !dbg !18
+  ret i32 %1, !dbg !18
+}
+
+attributes #0 = { noinline nounwind optnone ssp uwtable }
+
+!llvm.dbg.cu = !{!2}
+!llvm.module.flags = !{!10, !11, !12, !13}
+!llvm.ident = !{!14}
+
+!0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression(DW_OP_deref))
+!1 = distinct !DIGlobalVariable(name: "i", scope: !2, file: !3, line: 1, type: !9, isLocal: false, isDefinition: true)
+!2 = distinct !DICompileUnit(language: DW_LANG_C99, file: !3, emissionKind: FullDebug, globals: !5, nameTableKind: None)
+!3 = !DIFile(filename: "globals.c", directory: "/")
+!4 = !{}
+!5 = !{!0, !6}
+!6 = !DIGlobalVariableExpression(var: !7, expr: !DIExpression())
+!7 = distinct !DIGlobalVariable(name: "p", scope: !2, file: !3, line: 2, type: !8, isLocal: false, isDefinition: true)
+!8 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !9, size: 64)
+!9 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
+!10 = !{i32 2, !"Dwarf Version", i32 4}
+!11 = !{i32 2, !"Debug Info Version", i32 3}
+!12 = !{i32 1, !"wchar_size", i32 4}
+!13 = !{i32 7, !"PIC Level", i32 2}
+!14 = !{!"clang version 8.0.0 (trunk 340838) (llvm/trunk 340843)"}
+!15 = distinct !DISubprogram(name: "main", scope: !3, file: !3, line: 4, type: !16, isLocal: false, isDefinition: true, scopeLine: 4, isOptimized: false, unit: !2, retainedNodes: !4)
+!16 = !DISubroutineType(types: !17)
+!17 = !{!9}
+!18 = !DILocation(line: 5, scope: !15)
Index: packages/Python/lldbsuite/test/functionalities/target_var/TestTargetVar.py
===
--- packages/Python/lldbsuite/test/functionalities/target_var/TestTargetVar.py
+++ packages/Python/lldbsuite/test/functionalities/target_var/TestTargetVar.py
@@ -0,0 +1,22 @@
+"""
+Test that target var can resolve complex DWARF expressions.
+"""
+
+import lldb
+import sys
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+
+class targetCommandTestCase(TestBase):
+
+mydir = TestBase.compute_mydir(__file__)
+
+@skipUnlessDarwin
+@skipIfDarwinEmbedded   # needs x86_64
+@skipIf(debug_info="gmodules")  # not relevant
+def testTargetVarExpr(self):
+self.build()
+lldbutil.run_to_name_breakpoint(self, 'main')
+self.expect("target variable i", substrs=['i', '42'])
Index: packages/Python/lldbsuite/test/functionalities/target_var/globals.c
===
--- packages/Python/lldbsuite/test/functionalities/target_var/globals.c
+++ packages/Python/lldbsuite/test/functionalities/target_var/globals.c
@@ -0,0 +1,6 @@
+int i = 42;
+int *p = &i;
+
+int main() {
+  return *p;
+}
Index: source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
===
--- source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
+++ source/Plugins/SymbolFile/DWARF/SymbolFileDW

[Lldb-commits] [PATCH] D52270: TestMultilineExpr: validate evaluation for expressions spread over multiple lines

2018-10-05 Thread Phabricator via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL343860: TestMultilineExpr: validate evaluation for 
expressions that span multiple lines (authored by stefan.graenitz, committed by 
).
Herald added a subscriber: llvm-commits.

Repository:
  rL LLVM

https://reviews.llvm.org/D52270

Files:
  lldb/trunk/lit/Expr/TestMultilineExpr.test
  
lldb/trunk/packages/Python/lldbsuite/test/expression_command/multiline/Makefile
  
lldb/trunk/packages/Python/lldbsuite/test/expression_command/multiline/TestMultilineExpressions.py
  lldb/trunk/packages/Python/lldbsuite/test/expression_command/multiline/main.c

Index: lldb/trunk/lit/Expr/TestMultilineExpr.test
===
--- lldb/trunk/lit/Expr/TestMultilineExpr.test
+++ lldb/trunk/lit/Expr/TestMultilineExpr.test
@@ -0,0 +1,9 @@
+# RUN: %lldb -b -s %s | FileCheck %s
+
+# In terminal sessions LLDB hides input from subsequent lines so it's not visible in the output we check below.
+expression
+2+
+3
+
+# CHECK: (lldb) expression
+# CHECK: (int) {{.*}} = 5
Index: lldb/trunk/packages/Python/lldbsuite/test/expression_command/multiline/main.c
===
--- lldb/trunk/packages/Python/lldbsuite/test/expression_command/multiline/main.c
+++ lldb/trunk/packages/Python/lldbsuite/test/expression_command/multiline/main.c
@@ -1,6 +0,0 @@
-#include 
-
-int main(int argc, char const *argv[]) {
-printf("Hello world.\n"); // break here
-return 0;
-}
Index: lldb/trunk/packages/Python/lldbsuite/test/expression_command/multiline/Makefile
===
--- lldb/trunk/packages/Python/lldbsuite/test/expression_command/multiline/Makefile
+++ lldb/trunk/packages/Python/lldbsuite/test/expression_command/multiline/Makefile
@@ -1,5 +0,0 @@
-LEVEL = ../../make
-
-C_SOURCES := main.c
-
-include $(LEVEL)/Makefile.rules
Index: lldb/trunk/packages/Python/lldbsuite/test/expression_command/multiline/TestMultilineExpressions.py
===
--- lldb/trunk/packages/Python/lldbsuite/test/expression_command/multiline/TestMultilineExpressions.py
+++ lldb/trunk/packages/Python/lldbsuite/test/expression_command/multiline/TestMultilineExpressions.py
@@ -1,90 +0,0 @@
-"""Test multiline expressions."""
-
-from __future__ import print_function
-
-import os
-import lldb
-from lldbsuite.test.decorators import *
-from lldbsuite.test.lldbtest import *
-from lldbsuite.test import lldbutil
-
-
-class MultilineExpressionsTestCase(TestBase):
-
-mydir = TestBase.compute_mydir(__file__)
-NO_DEBUG_INFO_TESTCASE = True
-
-def setUp(self):
-# Call super's setUp().
-TestBase.setUp(self)
-# Find the line number to break on inside main.cpp.
-self.line = line_number('main.c', 'break')
-
-@skipIfRemote
-@expectedFailureAll(
-oslist=["windows"],
-bugnumber="llvm.org/pr22274: need a pexpect replacement for windows")
-def test_with_run_commands(self):
-"""Test that multiline expressions work correctly"""
-self.build()
-import pexpect
-exe = self.getBuildArtifact("a.out")
-prompt = "(lldb) "
-
-# So that the child gets torn down after the test.
-self.child = pexpect.spawn(
-'%s %s %s' %
-(lldbtest_config.lldbExec, self.lldbOption, exe))
-child = self.child
-# Turn on logging for what the child sends back.
-if self.TraceOn():
-child.logfile_read = sys.stdout
-
-# Set the breakpoint, run the inferior, when it breaks, issue print on
-# the various convenience variables.
-child.expect_exact(prompt)
-child.sendline('breakpoint set -f main.c -l %d' % self.line)
-child.expect_exact(prompt)
-child.sendline('run')
-child.expect_exact("stop reason = breakpoint 1.1")
-child.expect_exact(prompt)
-child.sendline('expr')
-child.expect_exact('1:')
-
-child.sendline('2+')
-child.expect_exact('2:')
-
-child.sendline('3')
-child.expect_exact('3:')
-
-child.sendline('')
-child.expect_exact(prompt)
-self.expect(child.before, exe=False,
-patterns=['= 5'])
-
-@skipIfRemote
-@expectedFailureAll(
-oslist=["windows"],
-bugnumber="llvm.org/pr22274: need a pexpect replacement for windows")
-def test_empty_list(self):
-"""Test printing an empty list of expressions"""
-import pexpect
-prompt = "(lldb) "
-
-# So that the child gets torn down after the test
-self.child = pexpect.spawn(
-"%s %s" %
-(lldbtest_config.lldbExec, self.lldbOption))
-child = self.child
-
-# Turn on logging for what the child sends back.
-if self.TraceOn():
-  

[Lldb-commits] [PATCH] D52788: Add EchoCommentCommands to CommandInterpreterRunOptions in addition to the existing EchoCommands and expose both as interpreter settings.

2018-10-05 Thread Phabricator via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL343859: Add EchoCommentCommands to 
CommandInterpreterRunOptions in addition to the… (authored by stefan.graenitz, 
committed by ).
Herald added a subscriber: llvm-commits.

Repository:
  rL LLVM

https://reviews.llvm.org/D52788

Files:
  lldb/trunk/include/lldb/API/SBCommandInterpreter.h
  lldb/trunk/include/lldb/Interpreter/CommandInterpreter.h
  lldb/trunk/lit/Settings/Inputs/EchoCommandsAll.out
  lldb/trunk/lit/Settings/Inputs/EchoCommandsNoComments.out
  lldb/trunk/lit/Settings/Inputs/EchoCommandsNone.out
  lldb/trunk/lit/Settings/Inputs/EchoCommandsQuiet.out
  lldb/trunk/lit/Settings/Inputs/EchoCommandsTest.in
  lldb/trunk/lit/Settings/TestEchoCommands.test
  lldb/trunk/lit/lit-lldb-init
  lldb/trunk/source/API/SBCommandInterpreter.cpp
  lldb/trunk/source/Commands/CommandObjectCommands.cpp
  lldb/trunk/source/Interpreter/CommandInterpreter.cpp

Index: lldb/trunk/include/lldb/Interpreter/CommandInterpreter.h
===
--- lldb/trunk/include/lldb/Interpreter/CommandInterpreter.h
+++ lldb/trunk/include/lldb/Interpreter/CommandInterpreter.h
@@ -35,55 +35,60 @@
 class CommandInterpreterRunOptions {
 public:
   //--
-  /// Construct a CommandInterpreterRunOptions object.
-  /// This class is used to control all the instances where we run multiple
-  /// commands, e.g.
+  /// Construct a CommandInterpreterRunOptions object. This class is used to
+  /// control all the instances where we run multiple commands, e.g.
   /// HandleCommands, HandleCommandsFromFile, RunCommandInterpreter.
+  ///
   /// The meanings of the options in this object are:
   ///
   /// @param[in] stop_on_continue
-  ///If \b true execution will end on the first command that causes the
-  ///process in the
-  ///execution context to continue.  If \false, we won't check the execution
-  ///status.
+  ///If \b true, execution will end on the first command that causes the
+  ///process in the execution context to continue. If \b false, we won't
+  ///check the execution status.
   /// @param[in] stop_on_error
-  ///If \b true execution will end on the first command that causes an
+  ///If \b true, execution will end on the first command that causes an
   ///error.
   /// @param[in] stop_on_crash
-  ///If \b true when a command causes the target to run, and the end of the
-  ///run is a
-  ///signal or exception, stop executing the commands.
+  ///If \b true, when a command causes the target to run, and the end of the
+  ///run is a signal or exception, stop executing the commands.
   /// @param[in] echo_commands
-  ///If \b true echo the command before executing it.  If \false, execute
+  ///If \b true, echo the command before executing it. If \b false, execute
   ///silently.
+  /// @param[in] echo_comments
+  ///If \b true, echo command even if it is a pure comment line. If
+  ///\b false, print no ouput in this case. This setting has an effect only
+  ///if \param echo_commands is \b true.
   /// @param[in] print_results
-  ///If \b true print the results of the command after executing it.  If
-  ///\false, execute silently.
+  ///If \b true print the results of the command after executing it. If
+  ///\b false, execute silently.
   /// @param[in] add_to_history
-  ///If \b true add the commands to the command history.  If \false, don't
+  ///If \b true add the commands to the command history. If \b false, don't
   ///add them.
   //--
   CommandInterpreterRunOptions(LazyBool stop_on_continue,
LazyBool stop_on_error, LazyBool stop_on_crash,
-   LazyBool echo_commands, LazyBool print_results,
-   LazyBool add_to_history)
+   LazyBool echo_commands, LazyBool echo_comments,
+   LazyBool print_results, LazyBool add_to_history)
   : m_stop_on_continue(stop_on_continue), m_stop_on_error(stop_on_error),
 m_stop_on_crash(stop_on_crash), m_echo_commands(echo_commands),
-m_print_results(print_results), m_add_to_history(add_to_history) {}
+m_echo_comment_commands(echo_comments), m_print_results(print_results),
+m_add_to_history(add_to_history) {}
 
   CommandInterpreterRunOptions()
   : m_stop_on_continue(eLazyBoolCalculate),
 m_stop_on_error(eLazyBoolCalculate),
 m_stop_on_crash(eLazyBoolCalculate),
 m_echo_commands(eLazyBoolCalculate),
+m_echo_comment_commands(eLazyBoolCalculate),
 m_print_results(eLazyBoolCalculate),
 m_add_to_history(eLazyBoolCalculate) {}
 
   void SetSilent(bool silent) {
 LazyBool value = silent ? eLazyBoolNo

[Lldb-commits] [PATCH] D50478: Add support for artificial tail call frames

2018-10-05 Thread Phabricator via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rLLDB343900: Add support for artificial tail call frames 
(authored by vedantk, committed by ).
Herald added subscribers: teemperor, abidh.

Changed prior to commit:
  https://reviews.llvm.org/D50478?vs=168155&id=168552#toc

Repository:
  rLLDB LLDB

https://reviews.llvm.org/D50478

Files:
  include/lldb/API/SBFrame.h
  include/lldb/Core/FormatEntity.h
  include/lldb/Symbol/Block.h
  include/lldb/Symbol/Function.h
  include/lldb/Symbol/SymbolFile.h
  include/lldb/Target/StackFrame.h
  include/lldb/Target/StackFrameList.h
  include/lldb/Target/ThreadPlanStepOut.h
  packages/Python/lldbsuite/test/decorators.py
  
packages/Python/lldbsuite/test/functionalities/tail_call_frames/ambiguous_tail_call_seq1/Makefile
  
packages/Python/lldbsuite/test/functionalities/tail_call_frames/ambiguous_tail_call_seq1/TestAmbiguousTailCallSeq1.py
  
packages/Python/lldbsuite/test/functionalities/tail_call_frames/ambiguous_tail_call_seq1/main.cpp
  
packages/Python/lldbsuite/test/functionalities/tail_call_frames/ambiguous_tail_call_seq2/Makefile
  
packages/Python/lldbsuite/test/functionalities/tail_call_frames/ambiguous_tail_call_seq2/TestAmbiguousTailCallSeq2.py
  
packages/Python/lldbsuite/test/functionalities/tail_call_frames/ambiguous_tail_call_seq2/main.cpp
  
packages/Python/lldbsuite/test/functionalities/tail_call_frames/disambiguate_call_site/Makefile
  
packages/Python/lldbsuite/test/functionalities/tail_call_frames/disambiguate_call_site/TestDisambiguateCallSite.py
  
packages/Python/lldbsuite/test/functionalities/tail_call_frames/disambiguate_call_site/main.cpp
  
packages/Python/lldbsuite/test/functionalities/tail_call_frames/disambiguate_paths_to_common_sink/Makefile
  
packages/Python/lldbsuite/test/functionalities/tail_call_frames/disambiguate_paths_to_common_sink/TestDisambiguatePathsToCommonSink.py
  
packages/Python/lldbsuite/test/functionalities/tail_call_frames/disambiguate_paths_to_common_sink/main.cpp
  
packages/Python/lldbsuite/test/functionalities/tail_call_frames/disambiguate_tail_call_seq/Makefile
  
packages/Python/lldbsuite/test/functionalities/tail_call_frames/disambiguate_tail_call_seq/TestDisambiguateTailCallSeq.py
  
packages/Python/lldbsuite/test/functionalities/tail_call_frames/disambiguate_tail_call_seq/main.cpp
  
packages/Python/lldbsuite/test/functionalities/tail_call_frames/inlining_and_tail_calls/Makefile
  
packages/Python/lldbsuite/test/functionalities/tail_call_frames/inlining_and_tail_calls/TestInliningAndTailCalls.py
  
packages/Python/lldbsuite/test/functionalities/tail_call_frames/inlining_and_tail_calls/main.cpp
  
packages/Python/lldbsuite/test/functionalities/tail_call_frames/sbapi_support/Makefile
  
packages/Python/lldbsuite/test/functionalities/tail_call_frames/sbapi_support/TestTailCallFrameSBAPI.py
  
packages/Python/lldbsuite/test/functionalities/tail_call_frames/sbapi_support/main.cpp
  
packages/Python/lldbsuite/test/functionalities/tail_call_frames/thread_step_out_message/Makefile
  
packages/Python/lldbsuite/test/functionalities/tail_call_frames/thread_step_out_message/TestArtificialFrameStepOutMessage.py
  
packages/Python/lldbsuite/test/functionalities/tail_call_frames/thread_step_out_message/main.cpp
  
packages/Python/lldbsuite/test/functionalities/tail_call_frames/thread_step_out_or_return/Makefile
  
packages/Python/lldbsuite/test/functionalities/tail_call_frames/thread_step_out_or_return/TestSteppingOutWithArtificialFrames.py
  
packages/Python/lldbsuite/test/functionalities/tail_call_frames/thread_step_out_or_return/main.cpp
  
packages/Python/lldbsuite/test/functionalities/tail_call_frames/unambiguous_sequence/Makefile
  
packages/Python/lldbsuite/test/functionalities/tail_call_frames/unambiguous_sequence/TestUnambiguousTailCalls.py
  
packages/Python/lldbsuite/test/functionalities/tail_call_frames/unambiguous_sequence/main.cpp
  scripts/interface/SBFrame.i
  source/API/SBFrame.cpp
  source/Core/Debugger.cpp
  source/Core/FormatEntity.cpp
  source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
  source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
  source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp
  source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h
  source/Symbol/Block.cpp
  source/Symbol/Function.cpp
  source/Target/StackFrame.cpp
  source/Target/StackFrameList.cpp
  source/Target/ThreadPlanStepOut.cpp

Index: source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
===
--- source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
+++ source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
@@ -3742,6 +3742,60 @@
   return vars_added;
 }
 
+/// Collect call graph edges present in a function DIE.
+static std::vector
+CollectCallEdges(DWARFDIE function_die) {
+  // Check if the function has a supported call site-related attribute.
+  // TODO: In the future it may be worthwhile to support call_all_source_call

[Lldb-commits] [PATCH] D53175: [dotest] Make a missing FileCheck binary a warning, not an error

2018-10-12 Thread Phabricator via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL344401: [dotest] Make a missing FileCheck binary a warning, 
not an error (authored by vedantk, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D53175?vs=169471&id=169473#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D53175

Files:
  lldb/trunk/packages/Python/lldbsuite/test/configuration.py
  lldb/trunk/packages/Python/lldbsuite/test/dotest.py
  lldb/trunk/packages/Python/lldbsuite/test/lldbtest.py


Index: lldb/trunk/packages/Python/lldbsuite/test/configuration.py
===
--- lldb/trunk/packages/Python/lldbsuite/test/configuration.py
+++ lldb/trunk/packages/Python/lldbsuite/test/configuration.py
@@ -188,5 +188,5 @@
 """
 Get the path to the FileCheck testing tool.
 """
-assert os.path.lexists(filecheck)
-return filecheck
+if os.path.lexists(filecheck):
+return filecheck
Index: lldb/trunk/packages/Python/lldbsuite/test/dotest.py
===
--- lldb/trunk/packages/Python/lldbsuite/test/dotest.py
+++ lldb/trunk/packages/Python/lldbsuite/test/dotest.py
@@ -308,11 +308,15 @@
   'xcrun -find -toolchain default dsymutil')
 
 if args.filecheck:
-# The CMake build passes in a path to a working FileCheck binary.
+# The lldb-dotest script produced by the CMake build passes in a path
+# to a working FileCheck binary. So does one specific Xcode project
+# target. However, when invoking dotest.py directly, a valid 
--filecheck
+# option needs to be given.
 configuration.filecheck = os.path.abspath(args.filecheck)
-else:
-logging.error('No valid FileCheck executable; aborting...')
-sys.exit(-1)
+
+if not configuration.get_filecheck_path():
+logging.warning('No valid FileCheck executable; some tests may 
fail...')
+logging.warning('(Double-check the --filecheck argument to dotest.py)')
 
 if args.channels:
 lldbtest_config.channels = args.channels
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
@@ -2237,6 +2237,8 @@
 
 # Run FileCheck.
 filecheck_bin = configuration.get_filecheck_path()
+if not filecheck_bin:
+self.assertTrue(False, "No valid FileCheck executable specified")
 filecheck_args = [filecheck_bin, check_file_abs]
 if filecheck_options:
 filecheck_args.append(filecheck_options)


Index: lldb/trunk/packages/Python/lldbsuite/test/configuration.py
===
--- lldb/trunk/packages/Python/lldbsuite/test/configuration.py
+++ lldb/trunk/packages/Python/lldbsuite/test/configuration.py
@@ -188,5 +188,5 @@
 """
 Get the path to the FileCheck testing tool.
 """
-assert os.path.lexists(filecheck)
-return filecheck
+if os.path.lexists(filecheck):
+return filecheck
Index: lldb/trunk/packages/Python/lldbsuite/test/dotest.py
===
--- lldb/trunk/packages/Python/lldbsuite/test/dotest.py
+++ lldb/trunk/packages/Python/lldbsuite/test/dotest.py
@@ -308,11 +308,15 @@
   'xcrun -find -toolchain default dsymutil')
 
 if args.filecheck:
-# The CMake build passes in a path to a working FileCheck binary.
+# The lldb-dotest script produced by the CMake build passes in a path
+# to a working FileCheck binary. So does one specific Xcode project
+# target. However, when invoking dotest.py directly, a valid --filecheck
+# option needs to be given.
 configuration.filecheck = os.path.abspath(args.filecheck)
-else:
-logging.error('No valid FileCheck executable; aborting...')
-sys.exit(-1)
+
+if not configuration.get_filecheck_path():
+logging.warning('No valid FileCheck executable; some tests may fail...')
+logging.warning('(Double-check the --filecheck argument to dotest.py)')
 
 if args.channels:
 lldbtest_config.channels = args.channels
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
@@ -2237,6 +2237,8 @@
 
 # Run FileCheck.
 filecheck_bin = configuration.get_filecheck_path()
+if not filecheck_bin:
+self.assertTrue(False, "No valid FileCheck executable specified")
 filecheck_args = [filecheck_bin, check_file_abs]
 if filecheck_options:
 filecheck_args.ap

[Lldb-commits] [PATCH] D53305: Simplify LocateDSYMInVincinityOfExecutable a bit, and call Symbols::DownloadObjectAndSymbolFile for .dSYM.yaa archives

2018-10-16 Thread Phabricator 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 rLLDB344626: Simplify LocateDSYMInVincinityOfExecutable by 
moving (authored by jmolenda, committed by ).

Repository:
  rLLDB LLDB

https://reviews.llvm.org/D53305

Files:
  source/Host/common/Symbols.cpp

Index: source/Host/common/Symbols.cpp
===
--- source/Host/common/Symbols.cpp
+++ source/Host/common/Symbols.cpp
@@ -65,96 +65,134 @@
   return false;
 }
 
+// Given a binary exec_fspec, and a ModuleSpec with an architecture/uuid,
+// return true if there is a matching dSYM bundle next to the exec_fspec,
+// and return that value in dsym_fspec.  
+// If there is a .dSYM.yaa compressed archive next to the exec_fspec, 
+// call through Symbols::DownloadObjectAndSymbolFile to download the
+// expanded/uncompressed dSYM and return that filepath in dsym_fspec.
+
+static bool LookForDsymNextToExecutablePath(const ModuleSpec &mod_spec,
+const FileSpec &exec_fspec,
+FileSpec &dsym_fspec) {
+  ConstString filename = exec_fspec.GetFilename();
+  FileSpec dsym_directory = exec_fspec;
+  dsym_directory.RemoveLastPathComponent();
+
+  std::string dsym_filename = filename.AsCString();
+  dsym_filename += ".dSYM";
+  dsym_directory.AppendPathComponent(dsym_filename);
+  dsym_directory.AppendPathComponent("Contents");
+  dsym_directory.AppendPathComponent("Resources");
+  dsym_directory.AppendPathComponent("DWARF");
+  
+  if (dsym_directory.Exists()) {
+
+// See if the binary name exists in the dSYM DWARF
+// subdir.
+FileSpec dsym_fspec = dsym_directory;
+dsym_fspec.AppendPathComponent(filename.AsCString());
+if (dsym_fspec.Exists()
+&& FileAtPathContainsArchAndUUID(dsym_fspec, 
+ mod_spec.GetArchitecturePtr(),
+ mod_spec.GetUUIDPtr())) {
+  return true;
+}
+
+// See if we have "../CF.framework" - so we'll look for
+// CF.framework.dSYM/Contents/Resources/DWARF/CF
+// We need to drop the last suffix after '.' to match 
+// 'CF' in the DWARF subdir.
+std::string binary_name (filename.AsCString());
+auto last_dot = binary_name.find_last_of('.');
+if (last_dot != std::string::npos) {
+  binary_name.erase(last_dot);
+  dsym_fspec = dsym_directory;
+  dsym_fspec.AppendPathComponent(binary_name);
+  if (dsym_fspec.Exists()
+  && FileAtPathContainsArchAndUUID(dsym_fspec, 
+   mod_spec.GetArchitecturePtr(),
+   mod_spec.GetUUIDPtr())) {
+return true;
+  }
+}
+  } 
+  
+  // See if we have a .dSYM.yaa next to this executable path.
+  FileSpec dsym_yaa_fspec = exec_fspec;
+  dsym_yaa_fspec.RemoveLastPathComponent();
+  std::string dsym_yaa_filename = filename.AsCString();
+  dsym_yaa_filename += ".dSYM.yaa";
+  dsym_yaa_fspec.AppendPathComponent(dsym_yaa_filename);
+
+  if (dsym_yaa_fspec.Exists()) {
+ModuleSpec mutable_mod_spec = mod_spec;
+if (Symbols::DownloadObjectAndSymbolFile (mutable_mod_spec, true)
+&& mutable_mod_spec.GetSymbolFileSpec().Exists()) {
+  dsym_fspec = mutable_mod_spec.GetSymbolFileSpec();
+  return true;
+}
+  }
+
+  return false;
+}
+
+// Given a ModuleSpec with a FileSpec and optionally uuid/architecture
+// filled in, look for a .dSYM bundle next to that binary.  Returns true
+// if a .dSYM bundle is found, and that path is returned in the dsym_fspec
+// FileSpec.
+//
+// This routine looks a few directory layers above the given exec_path -
+// exec_path might be /System/Library/Frameworks/CF.framework/CF and the
+// dSYM might be /System/Library/Frameworks/CF.framework.dSYM.
+//
+// If there is a .dSYM.yaa compressed archive found next to the binary,
+// we'll call DownloadObjectAndSymbolFile to expand it into a plain .dSYM
+
 static bool LocateDSYMInVincinityOfExecutable(const ModuleSpec &module_spec,
   FileSpec &dsym_fspec) {
   Log *log = lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_HOST);
-  const FileSpec *exec_fspec = module_spec.GetFileSpecPtr();
+  const FileSpec &exec_fspec = module_spec.GetFileSpec();
   if (exec_fspec) {
-char path[PATH_MAX];
-if (exec_fspec->GetPath(path, sizeof(path))) {
-  // Make sure the module isn't already just a dSYM file...
-  if (strcasestr(path, ".dSYM/Contents/Resources/DWARF") == NULL) {
+if (::LookForDsymNextToExecutablePath (module_spec, exec_fspec, dsym_fspec)) {
 if (log) {
-  if (module_spec.GetUUIDPtr() && module_spec.GetUUIDPtr()->IsValid()) {
-log->Printf(
-"Searching for dSYM bundle next to executable %s, UUID %s",
-path, module_spec.GetUUIDPtr()->GetAsString().c_str());
-

[Lldb-commits] [PATCH] D53709: Get rid of C-style cast.

2018-10-25 Thread Phabricator via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL345278: Get rid of casts. (NFC) (authored by adrian, 
committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D53709?vs=171117&id=171119#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D53709

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


Index: lldb/trunk/source/Plugins/Platform/MacOSX/PlatformDarwin.h
===
--- lldb/trunk/source/Plugins/Platform/MacOSX/PlatformDarwin.h
+++ lldb/trunk/source/Plugins/Platform/MacOSX/PlatformDarwin.h
@@ -85,7 +85,7 @@
   static std::tuple
   ParseVersionBuildDir(llvm::StringRef str);
 
-  enum class SDKType {
+  enum SDKType : unsigned {
 MacOSX = 0,
 iPhoneSimulator,
 iPhoneOS,
Index: lldb/trunk/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp
===
--- lldb/trunk/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp
+++ lldb/trunk/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp
@@ -1402,10 +1402,10 @@
   if (last_path_component) {
 const llvm::StringRef sdk_name = last_path_component.GetStringRef();
 
-if (!sdk_name.startswith(sdk_strings[(int)desired_type]))
+if (!sdk_name.startswith(sdk_strings[desired_type]))
   return false;
 auto version_part =
-sdk_name.drop_front(strlen(sdk_strings[(int)desired_type]));
+sdk_name.drop_front(strlen(sdk_strings[desired_type]));
 version_part.consume_back(".sdk");
 
 llvm::VersionTuple version;


Index: lldb/trunk/source/Plugins/Platform/MacOSX/PlatformDarwin.h
===
--- lldb/trunk/source/Plugins/Platform/MacOSX/PlatformDarwin.h
+++ lldb/trunk/source/Plugins/Platform/MacOSX/PlatformDarwin.h
@@ -85,7 +85,7 @@
   static std::tuple
   ParseVersionBuildDir(llvm::StringRef str);
 
-  enum class SDKType {
+  enum SDKType : unsigned {
 MacOSX = 0,
 iPhoneSimulator,
 iPhoneOS,
Index: lldb/trunk/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp
===
--- lldb/trunk/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp
+++ lldb/trunk/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp
@@ -1402,10 +1402,10 @@
   if (last_path_component) {
 const llvm::StringRef sdk_name = last_path_component.GetStringRef();
 
-if (!sdk_name.startswith(sdk_strings[(int)desired_type]))
+if (!sdk_name.startswith(sdk_strings[desired_type]))
   return false;
 auto version_part =
-sdk_name.drop_front(strlen(sdk_strings[(int)desired_type]));
+sdk_name.drop_front(strlen(sdk_strings[desired_type]));
 version_part.consume_back(".sdk");
 
 llvm::VersionTuple version;
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D44603: [lldb] Introduce StackFrameRecognizer

2018-10-30 Thread Phabricator via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL345678: [lldb] Introduce StackFrameRecognizer (authored by 
kuba.brecka, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D44603?vs=170809&id=171844#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D44603

Files:
  lldb/trunk/include/lldb/API/SBVariablesOptions.h
  lldb/trunk/include/lldb/Interpreter/OptionGroupVariable.h
  lldb/trunk/include/lldb/Interpreter/ScriptInterpreter.h
  lldb/trunk/include/lldb/Target/StackFrame.h
  lldb/trunk/include/lldb/Target/StackFrameRecognizer.h
  lldb/trunk/include/lldb/lldb-forward.h
  lldb/trunk/lldb.xcodeproj/project.pbxproj
  
lldb/trunk/packages/Python/lldbsuite/test/functionalities/frame-recognizer/Makefile
  
lldb/trunk/packages/Python/lldbsuite/test/functionalities/frame-recognizer/TestFrameRecognizer.py
  
lldb/trunk/packages/Python/lldbsuite/test/functionalities/frame-recognizer/main.m
  
lldb/trunk/packages/Python/lldbsuite/test/functionalities/frame-recognizer/recognizer.py
  lldb/trunk/scripts/Python/python-wrapper.swig
  lldb/trunk/scripts/interface/SBVariablesOptions.i
  lldb/trunk/source/API/SBFrame.cpp
  lldb/trunk/source/API/SBVariablesOptions.cpp
  lldb/trunk/source/API/SystemInitializerFull.cpp
  lldb/trunk/source/Commands/CommandObjectFrame.cpp
  lldb/trunk/source/Interpreter/OptionGroupVariable.cpp
  lldb/trunk/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
  lldb/trunk/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.h
  lldb/trunk/source/Target/CMakeLists.txt
  lldb/trunk/source/Target/StackFrame.cpp
  lldb/trunk/source/Target/StackFrameRecognizer.cpp
  lldb/trunk/www/python-reference.html

Index: lldb/trunk/source/Target/StackFrameRecognizer.cpp
===
--- lldb/trunk/source/Target/StackFrameRecognizer.cpp
+++ lldb/trunk/source/Target/StackFrameRecognizer.cpp
@@ -0,0 +1,190 @@
+//===-- StackFrameRecognizer.cpp *- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+// C Includes
+// C++ Includes
+#include 
+// Other libraries and framework includes
+// Project includes
+#include "lldb/Core/Module.h"
+#include "lldb/Interpreter/ScriptInterpreter.h"
+#include "lldb/Symbol/Symbol.h"
+#include "lldb/Target/StackFrame.h"
+#include "lldb/Target/StackFrameRecognizer.h"
+#include "lldb/Utility/RegularExpression.h"
+
+using namespace lldb;
+using namespace lldb_private;
+
+class ScriptedRecognizedStackFrame : public RecognizedStackFrame {
+public:
+  ScriptedRecognizedStackFrame(ValueObjectListSP args) {
+m_arguments = args;
+  }
+};
+
+ScriptedStackFrameRecognizer::ScriptedStackFrameRecognizer(
+ScriptInterpreter *interpreter, const char *pclass)
+: m_interpreter(interpreter), m_python_class(pclass) {
+  m_python_object_sp =
+  m_interpreter->CreateFrameRecognizer(m_python_class.c_str());
+}
+
+RecognizedStackFrameSP
+ScriptedStackFrameRecognizer::RecognizeFrame(lldb::StackFrameSP frame) {
+  if (!m_python_object_sp || !m_interpreter)
+return RecognizedStackFrameSP();
+
+  ValueObjectListSP args =
+  m_interpreter->GetRecognizedArguments(m_python_object_sp, frame);
+
+  return RecognizedStackFrameSP(new ScriptedRecognizedStackFrame(args));
+}
+
+class StackFrameRecognizerManagerImpl {
+public:
+  void AddRecognizer(StackFrameRecognizerSP recognizer, ConstString &module,
+ ConstString &symbol, bool first_instruction_only) {
+m_recognizers.push_front({(uint32_t)m_recognizers.size(), false, recognizer, false, module, RegularExpressionSP(),
+  symbol, RegularExpressionSP(),
+  first_instruction_only});
+  }
+
+  void AddRecognizer(StackFrameRecognizerSP recognizer,
+ RegularExpressionSP module, RegularExpressionSP symbol,
+ bool first_instruction_only) {
+m_recognizers.push_front({(uint32_t)m_recognizers.size(), false, recognizer, true, ConstString(), module,
+  ConstString(), symbol, first_instruction_only});
+  }
+
+  void ForEach(
+  std::function const &callback) {
+for (auto entry : m_recognizers) {
+  if (entry.is_regexp) {
+callback(entry.recognizer_id, entry.recognizer->GetName(), entry.module_regexp->GetText(),
+ entry.symbol_regexp->GetText(), true);
+  } else {
+callback(entry.recognizer_id, entry.recognizer->GetName(), entry.module.GetCString(),
+ entry.symbol.GetCString(), false);
+  }
+}
+  }
+
+  bool RemoveRecognizerWithID(uint32_t recognizer_id) {
+if (recognizer_id >= m_recognizers.size()

[Lldb-commits] [PATCH] D44603: [lldb] Introduce StackFrameRecognizer

2018-10-30 Thread Phabricator via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rLLDB345686: [lldb] Introduce StackFrameRecognizer [take 2] 
(authored by kuba.brecka, committed by ).
Herald added subscribers: teemperor, abidh.

Changed prior to commit:
  https://reviews.llvm.org/D44603?vs=171844&id=171848#toc

Repository:
  rLLDB LLDB

https://reviews.llvm.org/D44603

Files:
  include/lldb/API/SBVariablesOptions.h
  include/lldb/Interpreter/OptionGroupVariable.h
  include/lldb/Interpreter/ScriptInterpreter.h
  include/lldb/Target/StackFrame.h
  include/lldb/Target/StackFrameRecognizer.h
  include/lldb/lldb-forward.h
  lldb.xcodeproj/project.pbxproj
  packages/Python/lldbsuite/test/functionalities/frame-recognizer/Makefile
  
packages/Python/lldbsuite/test/functionalities/frame-recognizer/TestFrameRecognizer.py
  packages/Python/lldbsuite/test/functionalities/frame-recognizer/main.m
  packages/Python/lldbsuite/test/functionalities/frame-recognizer/recognizer.py
  scripts/Python/python-wrapper.swig
  scripts/interface/SBVariablesOptions.i
  source/API/SBFrame.cpp
  source/API/SBVariablesOptions.cpp
  source/API/SystemInitializerFull.cpp
  source/Commands/CommandObjectFrame.cpp
  source/Interpreter/OptionGroupVariable.cpp
  source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
  source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.h
  source/Target/CMakeLists.txt
  source/Target/StackFrame.cpp
  source/Target/StackFrameRecognizer.cpp
  www/python-reference.html

Index: source/Target/StackFrame.cpp
===
--- source/Target/StackFrame.cpp
+++ source/Target/StackFrame.cpp
@@ -31,6 +31,7 @@
 #include "lldb/Target/ExecutionContext.h"
 #include "lldb/Target/Process.h"
 #include "lldb/Target/RegisterContext.h"
+#include "lldb/Target/StackFrameRecognizer.h"
 #include "lldb/Target/Target.h"
 #include "lldb/Target/Thread.h"
 #include "lldb/Utility/RegisterValue.h"
@@ -58,7 +59,8 @@
   m_id(pc, cfa, nullptr), m_frame_code_addr(pc), m_sc(), m_flags(),
   m_frame_base(), m_frame_base_error(), m_cfa_is_valid(cfa_is_valid),
   m_stack_frame_kind(kind), m_variable_list_sp(),
-  m_variable_list_value_objects(), m_disassembly(), m_mutex() {
+  m_variable_list_value_objects(), m_recognized_frame_sp(), m_disassembly(),
+  m_mutex() {
   // If we don't have a CFA value, use the frame index for our StackID so that
   // recursive functions properly aren't confused with one another on a history
   // stack.
@@ -82,7 +84,8 @@
   m_frame_code_addr(pc), m_sc(), m_flags(), m_frame_base(),
   m_frame_base_error(), m_cfa_is_valid(true),
   m_stack_frame_kind(StackFrame::Kind::Regular), m_variable_list_sp(),
-  m_variable_list_value_objects(), m_disassembly(), m_mutex() {
+  m_variable_list_value_objects(), m_recognized_frame_sp(), m_disassembly(),
+  m_mutex() {
   if (sc_ptr != nullptr) {
 m_sc = *sc_ptr;
 m_flags.Set(m_sc.GetResolvedMask());
@@ -107,7 +110,8 @@
   m_frame_code_addr(pc_addr), m_sc(), m_flags(), m_frame_base(),
   m_frame_base_error(), m_cfa_is_valid(true),
   m_stack_frame_kind(StackFrame::Kind::Regular), m_variable_list_sp(),
-  m_variable_list_value_objects(), m_disassembly(), m_mutex() {
+  m_variable_list_value_objects(), m_recognized_frame_sp(), m_disassembly(),
+  m_mutex() {
   if (sc_ptr != nullptr) {
 m_sc = *sc_ptr;
 m_flags.Set(m_sc.GetResolvedMask());
@@ -1952,3 +1956,11 @@
   }
   return true;
 }
+
+RecognizedStackFrameSP StackFrame::GetRecognizedFrame() {
+  if (!m_recognized_frame_sp) {
+m_recognized_frame_sp =
+StackFrameRecognizerManager::RecognizeFrame(CalculateStackFrame());
+  }
+  return m_recognized_frame_sp;
+}
Index: source/Target/StackFrameRecognizer.cpp
===
--- source/Target/StackFrameRecognizer.cpp
+++ source/Target/StackFrameRecognizer.cpp
@@ -0,0 +1,190 @@
+//===-- StackFrameRecognizer.cpp *- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+// C Includes
+// C++ Includes
+#include 
+// Other libraries and framework includes
+// Project includes
+#include "lldb/Core/Module.h"
+#include "lldb/Interpreter/ScriptInterpreter.h"
+#include "lldb/Symbol/Symbol.h"
+#include "lldb/Target/StackFrame.h"
+#include "lldb/Target/StackFrameRecognizer.h"
+#include "lldb/Utility/RegularExpression.h"
+
+using namespace lldb;
+using namespace lldb_private;
+
+class ScriptedRecognizedStackFrame : public RecognizedStackFrame {
+public:
+  ScriptedRecognizedStackFrame(ValueObjectListSP args) {
+m_arguments = args;
+  }
+};
+
+ScriptedStackFrameRecognizer::ScriptedStackFrameRecognizer(
+Scr

[Lldb-commits] [PATCH] D44603: [lldb] Introduce StackFrameRecognizer

2018-10-30 Thread Phabricator via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL345693: [lldb] Introduce StackFrameRecognizer [take 3] 
(authored by kuba.brecka, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D44603?vs=171848&id=171860#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D44603

Files:
  lldb/trunk/include/lldb/API/SBVariablesOptions.h
  lldb/trunk/include/lldb/Interpreter/OptionGroupVariable.h
  lldb/trunk/include/lldb/Interpreter/ScriptInterpreter.h
  lldb/trunk/include/lldb/Target/StackFrame.h
  lldb/trunk/include/lldb/Target/StackFrameRecognizer.h
  lldb/trunk/include/lldb/lldb-forward.h
  lldb/trunk/lldb.xcodeproj/project.pbxproj
  
lldb/trunk/packages/Python/lldbsuite/test/functionalities/frame-recognizer/Makefile
  
lldb/trunk/packages/Python/lldbsuite/test/functionalities/frame-recognizer/TestFrameRecognizer.py
  
lldb/trunk/packages/Python/lldbsuite/test/functionalities/frame-recognizer/main.m
  
lldb/trunk/packages/Python/lldbsuite/test/functionalities/frame-recognizer/recognizer.py
  lldb/trunk/scripts/Python/python-wrapper.swig
  lldb/trunk/scripts/interface/SBVariablesOptions.i
  lldb/trunk/source/API/SBFrame.cpp
  lldb/trunk/source/API/SBVariablesOptions.cpp
  lldb/trunk/source/API/SystemInitializerFull.cpp
  lldb/trunk/source/Commands/CommandObjectFrame.cpp
  lldb/trunk/source/Interpreter/OptionGroupVariable.cpp
  lldb/trunk/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
  lldb/trunk/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.h
  lldb/trunk/source/Target/CMakeLists.txt
  lldb/trunk/source/Target/StackFrame.cpp
  lldb/trunk/source/Target/StackFrameRecognizer.cpp
  lldb/trunk/www/python-reference.html

Index: lldb/trunk/packages/Python/lldbsuite/test/functionalities/frame-recognizer/recognizer.py
===
--- lldb/trunk/packages/Python/lldbsuite/test/functionalities/frame-recognizer/recognizer.py
+++ lldb/trunk/packages/Python/lldbsuite/test/functionalities/frame-recognizer/recognizer.py
@@ -0,0 +1,21 @@
+# encoding: utf-8
+
+import lldb
+
+class MyFrameRecognizer(object):
+def get_recognized_arguments(self, frame):
+if frame.name == "foo":
+arg1 = frame.EvaluateExpression("$arg1").signed
+arg2 = frame.EvaluateExpression("$arg2").signed
+val1 = lldb.target.CreateValueFromExpression("a", "%d" % arg1)
+val2 = lldb.target.CreateValueFromExpression("b", "%d" % arg2)
+return [val1, val2]
+elif frame.name == "bar":
+arg1 = frame.EvaluateExpression("$arg1").signed
+val1 = lldb.target.CreateValueFromExpression("a", "(int *)%d" % arg1)
+return [val1]
+return []
+
+class MyOtherFrameRecognizer(object):
+def get_recognized_arguments(self, frame):
+return []
Index: lldb/trunk/packages/Python/lldbsuite/test/functionalities/frame-recognizer/Makefile
===
--- lldb/trunk/packages/Python/lldbsuite/test/functionalities/frame-recognizer/Makefile
+++ lldb/trunk/packages/Python/lldbsuite/test/functionalities/frame-recognizer/Makefile
@@ -0,0 +1,10 @@
+LEVEL = ../../make
+
+OBJC_SOURCES := main.m
+
+CFLAGS_EXTRAS += -g0 # No debug info.
+MAKE_DSYM := NO
+
+include $(LEVEL)/Makefile.rules
+
+LDFLAGS += -framework Foundation
Index: lldb/trunk/packages/Python/lldbsuite/test/functionalities/frame-recognizer/TestFrameRecognizer.py
===
--- lldb/trunk/packages/Python/lldbsuite/test/functionalities/frame-recognizer/TestFrameRecognizer.py
+++ lldb/trunk/packages/Python/lldbsuite/test/functionalities/frame-recognizer/TestFrameRecognizer.py
@@ -0,0 +1,102 @@
+# encoding: utf-8
+"""
+Test lldb's frame recognizers.
+"""
+
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+import recognizer
+
+class FrameRecognizerTestCase(TestBase):
+
+mydir = TestBase.compute_mydir(__file__)
+NO_DEBUG_INFO_TESTCASE = True
+
+@skipUnlessDarwin
+def test_frame_recognizer_1(self):
+self.build()
+
+target = self.dbg.CreateTarget(self.getBuildArtifact("a.out"))
+self.assertTrue(target, VALID_TARGET)
+
+self.runCmd("command script import " + os.path.join(self.getSourceDir(), "recognizer.py"))
+
+self.expect("frame recognizer list",
+substrs=['no matching results found.'])
+
+self.runCmd("frame recognizer add -l recognizer.MyFrameRecognizer -s a.out -n foo")
+
+self.expect("frame recognizer list",
+substrs=['0: recognizer.MyFrameRecognizer, module a.out, function foo'])
+
+self.runCmd("frame recognizer add -l recognizer.MyOtherFrameRecognizer -s a.out -n bar -x")
+
+self.expect("frame recognizer list",
+substrs=['0: 

[Lldb-commits] [PATCH] D53530: Fix (and improve) the support for C99 variable length array types

2018-11-05 Thread Phabricator via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL346165: Fix (and improve) the support for C99 variable 
length array types (authored by adrian, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D53530?vs=172390&id=172639#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D53530

Files:
  lldb/trunk/include/lldb/Symbol/ClangASTContext.h
  lldb/trunk/include/lldb/Symbol/CompilerType.h
  lldb/trunk/include/lldb/Symbol/SymbolFile.h
  lldb/trunk/include/lldb/Symbol/TypeSystem.h
  lldb/trunk/packages/Python/lldbsuite/test/lang/c/vla/Makefile
  lldb/trunk/packages/Python/lldbsuite/test/lang/c/vla/TestVLA.py
  lldb/trunk/packages/Python/lldbsuite/test/lang/c/vla/main.c
  lldb/trunk/source/Core/ValueObjectCast.cpp
  lldb/trunk/source/Core/ValueObjectChild.cpp
  lldb/trunk/source/Core/ValueObjectConstResult.cpp
  lldb/trunk/source/Core/ValueObjectDynamicValue.cpp
  lldb/trunk/source/Core/ValueObjectMemory.cpp
  lldb/trunk/source/Core/ValueObjectRegister.cpp
  lldb/trunk/source/Core/ValueObjectVariable.cpp
  lldb/trunk/source/Plugins/ABI/SysV-ppc64/ABISysV_ppc64.cpp
  lldb/trunk/source/Plugins/Language/CPlusPlus/BlockPointer.cpp
  lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFASTParser.h
  lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
  lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.h
  lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
  lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
  lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp
  lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h
  lldb/trunk/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp
  lldb/trunk/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.h
  lldb/trunk/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp
  lldb/trunk/source/Plugins/SymbolFile/PDB/SymbolFilePDB.h
  lldb/trunk/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.cpp
  lldb/trunk/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.h
  lldb/trunk/source/Symbol/ClangASTContext.cpp
  lldb/trunk/source/Symbol/CompilerType.cpp
  lldb/trunk/source/Symbol/Type.cpp
  lldb/trunk/source/Symbol/Variable.cpp

Index: lldb/trunk/source/Core/ValueObjectDynamicValue.cpp
===
--- lldb/trunk/source/Core/ValueObjectDynamicValue.cpp
+++ lldb/trunk/source/Core/ValueObjectDynamicValue.cpp
@@ -92,7 +92,8 @@
 size_t ValueObjectDynamicValue::CalculateNumChildren(uint32_t max) {
   const bool success = UpdateValueIfNeeded(false);
   if (success && m_dynamic_type_info.HasType()) {
-auto children_count = GetCompilerType().GetNumChildren(true);
+ExecutionContext exe_ctx(GetExecutionContextRef());
+auto children_count = GetCompilerType().GetNumChildren(true, &exe_ctx);
 return children_count <= max ? children_count : max;
   } else
 return m_parent->GetNumChildren(max);
Index: lldb/trunk/source/Core/ValueObjectMemory.cpp
===
--- lldb/trunk/source/Core/ValueObjectMemory.cpp
+++ lldb/trunk/source/Core/ValueObjectMemory.cpp
@@ -128,8 +128,10 @@
 return child_count <= max ? child_count : max;
   }
 
+  ExecutionContext exe_ctx(GetExecutionContextRef());
   const bool omit_empty_base_classes = true;
-  auto child_count = m_compiler_type.GetNumChildren(omit_empty_base_classes);
+  auto child_count =
+  m_compiler_type.GetNumChildren(omit_empty_base_classes, &exe_ctx);
   return child_count <= max ? child_count : max;
 }
 
Index: lldb/trunk/source/Core/ValueObjectConstResult.cpp
===
--- lldb/trunk/source/Core/ValueObjectConstResult.cpp
+++ lldb/trunk/source/Core/ValueObjectConstResult.cpp
@@ -208,7 +208,8 @@
 void ValueObjectConstResult::SetByteSize(size_t size) { m_byte_size = size; }
 
 size_t ValueObjectConstResult::CalculateNumChildren(uint32_t max) {
-  auto children_count = GetCompilerType().GetNumChildren(true);
+  ExecutionContext exe_ctx(GetExecutionContextRef());
+  auto children_count = GetCompilerType().GetNumChildren(true, &exe_ctx);
   return children_count <= max ? children_count : max;
 }
 
Index: lldb/trunk/source/Core/ValueObjectRegister.cpp
===
--- lldb/trunk/source/Core/ValueObjectRegister.cpp
+++ lldb/trunk/source/Core/ValueObjectRegister.cpp
@@ -279,7 +279,8 @@
 }
 
 size_t ValueObjectRegister::CalculateNumChildren(uint32_t max) {
-  auto children_count = GetCompilerType().GetNumChildren(true);
+  ExecutionContext exe_ctx(GetExecutionContextRef());
+  auto children_count = GetCompilerType().GetNumChildren(true, &exe_ctx);
   return children_count <= max ? children_count : max;
 }
 
Index: lldb/trunk/source/Core/ValueObjectChild.cpp
===
--- l

[Lldb-commits] [PATCH] D54335: [CMake] Fix: add_host_subdirectory source/Host/macosx

2018-11-12 Thread Phabricator via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL346667: [CMake] Fix: add_host_subdirectory 
source/Host/macosx (authored by stefan.graenitz, committed by ).
Herald added a subscriber: llvm-commits.

Repository:
  rL LLVM

https://reviews.llvm.org/D54335

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


Index: lldb/trunk/source/Host/CMakeLists.txt
===
--- lldb/trunk/source/Host/CMakeLists.txt
+++ lldb/trunk/source/Host/CMakeLists.txt
@@ -91,7 +91,7 @@
 include_directories(SYSTEM ${LIBXML2_INCLUDE_DIR})
 add_subdirectory(macosx/objcxx)
 set(LLDBObjCLibs lldbHostMacOSXObjCXX)
-add_host_subdirectory(maqcosx
+add_host_subdirectory(macosx
   macosx/Symbols.cpp
   macosx/cfcpp/CFCBundle.cpp
   macosx/cfcpp/CFCData.cpp


Index: lldb/trunk/source/Host/CMakeLists.txt
===
--- lldb/trunk/source/Host/CMakeLists.txt
+++ lldb/trunk/source/Host/CMakeLists.txt
@@ -91,7 +91,7 @@
 include_directories(SYSTEM ${LIBXML2_INCLUDE_DIR})
 add_subdirectory(macosx/objcxx)
 set(LLDBObjCLibs lldbHostMacOSXObjCXX)
-add_host_subdirectory(maqcosx
+add_host_subdirectory(macosx
   macosx/Symbols.cpp
   macosx/cfcpp/CFCBundle.cpp
   macosx/cfcpp/CFCData.cpp
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D54333: [CMake] Allow version overrides with -DLLDB_VERSION_MAJOR/MINOR/PATCH/SUFFIX

2018-11-12 Thread Phabricator via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL346668: [CMake] Allow version overrides with 
-DLLDB_VERSION_MAJOR/MINOR/PATCH/SUFFIX (authored by stefan.graenitz, committed 
by ).
Herald added a subscriber: llvm-commits.

Repository:
  rL LLVM

https://reviews.llvm.org/D54333

Files:
  lldb/trunk/CMakeLists.txt
  lldb/trunk/cmake/modules/LLDBConfig.cmake


Index: lldb/trunk/CMakeLists.txt
===
--- lldb/trunk/CMakeLists.txt
+++ lldb/trunk/CMakeLists.txt
@@ -56,7 +56,7 @@
   # the framework, and must be defined before building liblldb.
   set(PRODUCT_NAME "LLDB")
   set(EXECUTABLE_NAME "LLDB")
-  set(CURRENT_PROJECT_VERSION "360.99.0")
+  set(CURRENT_PROJECT_VERSION "${LLDB_VERSION}")
   set(LLDB_SUITE_TARGET lldb-framework)
 
   set(LLDB_FRAMEWORK_DIR
Index: lldb/trunk/cmake/modules/LLDBConfig.cmake
===
--- lldb/trunk/cmake/modules/LLDBConfig.cmake
+++ lldb/trunk/cmake/modules/LLDBConfig.cmake
@@ -265,9 +265,20 @@
 "`CMakeFiles'. Please delete them.")
 endif()
 
-# Compute the LLDB version from the LLVM version.
-string(REGEX MATCH "[0-9]+\\.[0-9]+(\\.[0-9]+)?" LLDB_VERSION
-  ${PACKAGE_VERSION})
+# If LLDB_VERSION_* is specified, use it, if not use LLVM_VERSION_*.
+if(NOT DEFINED LLDB_VERSION_MAJOR)
+  set(LLDB_VERSION_MAJOR ${LLVM_VERSION_MAJOR})
+endif()
+if(NOT DEFINED LLDB_VERSION_MINOR)
+  set(LLDB_VERSION_MINOR ${LLVM_VERSION_MINOR})
+endif()
+if(NOT DEFINED LLDB_VERSION_PATCH)
+  set(LLDB_VERSION_PATCH ${LLVM_VERSION_PATCH})
+endif()
+if(NOT DEFINED LLDB_VERSION_SUFFIX)
+  set(LLDB_VERSION_SUFFIX ${LLVM_VERSION_SUFFIX})
+endif()
+set(LLDB_VERSION 
"${LLDB_VERSION_MAJOR}.${LLDB_VERSION_MINOR}.${LLDB_VERSION_PATCH}${LLDB_VERSION_SUFFIX}")
 message(STATUS "LLDB version: ${LLDB_VERSION}")
 
 include_directories(BEFORE


Index: lldb/trunk/CMakeLists.txt
===
--- lldb/trunk/CMakeLists.txt
+++ lldb/trunk/CMakeLists.txt
@@ -56,7 +56,7 @@
   # the framework, and must be defined before building liblldb.
   set(PRODUCT_NAME "LLDB")
   set(EXECUTABLE_NAME "LLDB")
-  set(CURRENT_PROJECT_VERSION "360.99.0")
+  set(CURRENT_PROJECT_VERSION "${LLDB_VERSION}")
   set(LLDB_SUITE_TARGET lldb-framework)
 
   set(LLDB_FRAMEWORK_DIR
Index: lldb/trunk/cmake/modules/LLDBConfig.cmake
===
--- lldb/trunk/cmake/modules/LLDBConfig.cmake
+++ lldb/trunk/cmake/modules/LLDBConfig.cmake
@@ -265,9 +265,20 @@
 "`CMakeFiles'. Please delete them.")
 endif()
 
-# Compute the LLDB version from the LLVM version.
-string(REGEX MATCH "[0-9]+\\.[0-9]+(\\.[0-9]+)?" LLDB_VERSION
-  ${PACKAGE_VERSION})
+# If LLDB_VERSION_* is specified, use it, if not use LLVM_VERSION_*.
+if(NOT DEFINED LLDB_VERSION_MAJOR)
+  set(LLDB_VERSION_MAJOR ${LLVM_VERSION_MAJOR})
+endif()
+if(NOT DEFINED LLDB_VERSION_MINOR)
+  set(LLDB_VERSION_MINOR ${LLVM_VERSION_MINOR})
+endif()
+if(NOT DEFINED LLDB_VERSION_PATCH)
+  set(LLDB_VERSION_PATCH ${LLVM_VERSION_PATCH})
+endif()
+if(NOT DEFINED LLDB_VERSION_SUFFIX)
+  set(LLDB_VERSION_SUFFIX ${LLVM_VERSION_SUFFIX})
+endif()
+set(LLDB_VERSION "${LLDB_VERSION_MAJOR}.${LLDB_VERSION_MINOR}.${LLDB_VERSION_PATCH}${LLDB_VERSION_SUFFIX}")
 message(STATUS "LLDB version: ${LLDB_VERSION}")
 
 include_directories(BEFORE
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D44060: [lldb] Fix "code requires global destructor" warning in g_architecture_mutex

2018-11-12 Thread Phabricator via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL346673: [lldb] Fix "code requires global 
destructor" warning in g_architecture_mutex (authored by kuba.brecka, 
committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D44060?vs=136886&id=173690#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D44060

Files:
  lldb/trunk/source/Core/PluginManager.cpp


Index: lldb/trunk/source/Core/PluginManager.cpp
===
--- lldb/trunk/source/Core/PluginManager.cpp
+++ lldb/trunk/source/Core/PluginManager.cpp
@@ -286,7 +286,10 @@
 
 typedef std::vector ArchitectureInstances;
 
-static std::mutex g_architecture_mutex;
+static std::mutex &GetArchitectureMutex() {
+static std::mutex g_architecture_mutex;
+return g_architecture_mutex;
+}
 
 static ArchitectureInstances &GetArchitectureInstances() {
   static ArchitectureInstances g_instances;
@@ -296,13 +299,13 @@
 void PluginManager::RegisterPlugin(const ConstString &name,
llvm::StringRef description,
ArchitectureCreateInstance create_callback) 
{
-  std::lock_guard guard(g_architecture_mutex);
+  std::lock_guard guard(GetArchitectureMutex());
   GetArchitectureInstances().push_back({name, description, create_callback});
 }
 
 void PluginManager::UnregisterPlugin(
 ArchitectureCreateInstance create_callback) {
-  std::lock_guard guard(g_architecture_mutex);
+  std::lock_guard guard(GetArchitectureMutex());
   auto &instances = GetArchitectureInstances();
 
   for (auto pos = instances.begin(), end = instances.end(); pos != end; ++pos) 
{
@@ -316,7 +319,7 @@
 
 std::unique_ptr
 PluginManager::CreateArchitectureInstance(const ArchSpec &arch) {
-  std::lock_guard guard(g_architecture_mutex);
+  std::lock_guard guard(GetArchitectureMutex());
   for (const auto &instances : GetArchitectureInstances()) {
 if (auto plugin_up = instances.create_callback(arch))
   return plugin_up;


Index: lldb/trunk/source/Core/PluginManager.cpp
===
--- lldb/trunk/source/Core/PluginManager.cpp
+++ lldb/trunk/source/Core/PluginManager.cpp
@@ -286,7 +286,10 @@
 
 typedef std::vector ArchitectureInstances;
 
-static std::mutex g_architecture_mutex;
+static std::mutex &GetArchitectureMutex() {
+static std::mutex g_architecture_mutex;
+return g_architecture_mutex;
+}
 
 static ArchitectureInstances &GetArchitectureInstances() {
   static ArchitectureInstances g_instances;
@@ -296,13 +299,13 @@
 void PluginManager::RegisterPlugin(const ConstString &name,
llvm::StringRef description,
ArchitectureCreateInstance create_callback) {
-  std::lock_guard guard(g_architecture_mutex);
+  std::lock_guard guard(GetArchitectureMutex());
   GetArchitectureInstances().push_back({name, description, create_callback});
 }
 
 void PluginManager::UnregisterPlugin(
 ArchitectureCreateInstance create_callback) {
-  std::lock_guard guard(g_architecture_mutex);
+  std::lock_guard guard(GetArchitectureMutex());
   auto &instances = GetArchitectureInstances();
 
   for (auto pos = instances.begin(), end = instances.end(); pos != end; ++pos) {
@@ -316,7 +319,7 @@
 
 std::unique_ptr
 PluginManager::CreateArchitectureInstance(const ArchSpec &arch) {
-  std::lock_guard guard(g_architecture_mutex);
+  std::lock_guard guard(GetArchitectureMutex());
   for (const auto &instances : GetArchitectureInstances()) {
 if (auto plugin_up = instances.create_callback(arch))
   return plugin_up;
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D44073: [lldb] Refactor ObjC/NSException.cpp (cleanup, avoid code duplication). NFC.

2018-11-12 Thread Phabricator via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rLLDB346679: [lldb] Refactor ObjC/NSException.cpp (cleanup, 
avoid code duplication). NFC. (authored by kuba.brecka, committed by ).
Herald added a subscriber: teemperor.

Changed prior to commit:
  https://reviews.llvm.org/D44073?vs=136931&id=173699#toc

Repository:
  rLLDB LLDB

https://reviews.llvm.org/D44073

Files:
  source/Plugins/Language/ObjC/NSException.cpp

Index: source/Plugins/Language/ObjC/NSException.cpp
===
--- source/Plugins/Language/ObjC/NSException.cpp
+++ source/Plugins/Language/ObjC/NSException.cpp
@@ -29,52 +29,70 @@
 using namespace lldb_private;
 using namespace lldb_private::formatters;
 
-bool lldb_private::formatters::NSException_SummaryProvider(
-ValueObject &valobj, Stream &stream, const TypeSummaryOptions &options) {
+static bool ExtractFields(ValueObject &valobj, ValueObjectSP *name_sp,
+  ValueObjectSP *reason_sp,
+  ValueObjectSP *userinfo_sp) {
   ProcessSP process_sp(valobj.GetProcessSP());
   if (!process_sp)
 return false;
 
-  lldb::addr_t ptr_value = LLDB_INVALID_ADDRESS;
+  lldb::addr_t ptr = LLDB_INVALID_ADDRESS;
 
   CompilerType valobj_type(valobj.GetCompilerType());
   Flags type_flags(valobj_type.GetTypeInfo());
   if (type_flags.AllClear(eTypeHasValue)) {
 if (valobj.IsBaseClass() && valobj.GetParent())
-  ptr_value = valobj.GetParent()->GetValueAsUnsigned(LLDB_INVALID_ADDRESS);
-  } else
-ptr_value = valobj.GetValueAsUnsigned(LLDB_INVALID_ADDRESS);
+  ptr = valobj.GetParent()->GetValueAsUnsigned(LLDB_INVALID_ADDRESS);
+  } else {
+ptr = valobj.GetValueAsUnsigned(LLDB_INVALID_ADDRESS);
+  }
 
-  if (ptr_value == LLDB_INVALID_ADDRESS)
+  if (ptr == LLDB_INVALID_ADDRESS)
 return false;
   size_t ptr_size = process_sp->GetAddressByteSize();
-  lldb::addr_t name_location = ptr_value + 1 * ptr_size;
-  lldb::addr_t reason_location = ptr_value + 2 * ptr_size;
 
   Status error;
-  lldb::addr_t name = process_sp->ReadPointerFromMemory(name_location, error);
+  auto name = process_sp->ReadPointerFromMemory(ptr + 1 * ptr_size, error);
   if (error.Fail() || name == LLDB_INVALID_ADDRESS)
 return false;
-
-  lldb::addr_t reason =
-  process_sp->ReadPointerFromMemory(reason_location, error);
+  auto reason = process_sp->ReadPointerFromMemory(ptr + 2 * ptr_size, error);
   if (error.Fail() || reason == LLDB_INVALID_ADDRESS)
 return false;
+  auto userinfo = process_sp->ReadPointerFromMemory(ptr + 3 * ptr_size, error);
+  if (error.Fail() || userinfo == LLDB_INVALID_ADDRESS)
+return false;
 
   InferiorSizedWord name_isw(name, *process_sp);
   InferiorSizedWord reason_isw(reason, *process_sp);
+  InferiorSizedWord userinfo_isw(userinfo, *process_sp);
 
   CompilerType voidstar = process_sp->GetTarget()
   .GetScratchClangASTContext()
   ->GetBasicType(lldb::eBasicTypeVoid)
   .GetPointerType();
 
-  ValueObjectSP name_sp = ValueObject::CreateValueObjectFromData(
-  "name_str", name_isw.GetAsData(process_sp->GetByteOrder()),
-  valobj.GetExecutionContextRef(), voidstar);
-  ValueObjectSP reason_sp = ValueObject::CreateValueObjectFromData(
-  "reason_str", reason_isw.GetAsData(process_sp->GetByteOrder()),
-  valobj.GetExecutionContextRef(), voidstar);
+  if (name_sp)
+*name_sp = ValueObject::CreateValueObjectFromData(
+"name", name_isw.GetAsData(process_sp->GetByteOrder()),
+valobj.GetExecutionContextRef(), voidstar);
+  if (reason_sp)
+*reason_sp = ValueObject::CreateValueObjectFromData(
+"reason", reason_isw.GetAsData(process_sp->GetByteOrder()),
+valobj.GetExecutionContextRef(), voidstar);
+  if (userinfo_sp)
+*userinfo_sp = ValueObject::CreateValueObjectFromData(
+"userInfo", userinfo_isw.GetAsData(process_sp->GetByteOrder()),
+valobj.GetExecutionContextRef(), voidstar);
+
+  return true;
+}
+
+bool lldb_private::formatters::NSException_SummaryProvider(
+ValueObject &valobj, Stream &stream, const TypeSummaryOptions &options) {
+  lldb::ValueObjectSP name_sp;
+  lldb::ValueObjectSP reason_sp;
+  if (!ExtractFields(valobj, &name_sp, &reason_sp, nullptr))
+return false;
 
   if (!name_sp || !reason_sp)
 return false;
@@ -97,63 +115,24 @@
   : SyntheticChildrenFrontEnd(*valobj_sp) {}
 
   ~NSExceptionSyntheticFrontEnd() override = default;
-  // no need to delete m_child_ptr - it's kept alive by the cluster manager on
-  // our behalf
 
   size_t CalculateNumChildren() override {
-if (m_child_ptr)
-  return 1;
-if (m_child_sp)
-  return 1;
-return 0;
+return 1;
   }
 
   lldb::ValueObjectSP GetChildAtIndex(size_t idx) override {
-if (idx != 0)
-  return lldb::ValueObjectSP();
-
-if (m_child_ptr)
-  return m_child_ptr->G

[Lldb-commits] [PATCH] D54432: [lldb] Fix the typo (replace underscore with dash) in svn:ignore on test/ and add "lldb-test-build.noindex" to ignored files

2018-11-12 Thread Phabricator via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rLLDB346692: [lldb] Fix the typo (replace underscore with 
dash) in svn:ignore on test/ and… (authored by kuba.brecka, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D54432?vs=173698&id=173719#toc

Repository:
  rLLDB LLDB

https://reviews.llvm.org/D54432

Files:
  test




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


[Lldb-commits] [PATCH] D54431: [lldb] Add "ninja" to svn:ignore

2018-11-12 Thread Phabricator via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL346693: [lldb] Add "ninja" to svn:ignore (authored 
by kuba.brecka, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D54431?vs=173697&id=173720#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D54431

Files:
  lldb/trunk




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


[Lldb-commits] [PATCH] D43884: [lldb] Extract more fields from NSException values

2018-11-12 Thread Phabricator via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rLLDB346695: [lldb] Extract more fields from NSException 
values (authored by kuba.brecka, committed by ).

Repository:
  rLLDB LLDB

https://reviews.llvm.org/D43884

Files:
  packages/Python/lldbsuite/test/lang/objc/exceptions/Makefile
  packages/Python/lldbsuite/test/lang/objc/exceptions/TestObjCExceptions.py
  packages/Python/lldbsuite/test/lang/objc/exceptions/main.m
  source/Plugins/Language/ObjC/NSException.cpp

Index: source/Plugins/Language/ObjC/NSException.cpp
===
--- source/Plugins/Language/ObjC/NSException.cpp
+++ source/Plugins/Language/ObjC/NSException.cpp
@@ -30,8 +30,8 @@
 using namespace lldb_private::formatters;
 
 static bool ExtractFields(ValueObject &valobj, ValueObjectSP *name_sp,
-  ValueObjectSP *reason_sp,
-  ValueObjectSP *userinfo_sp) {
+  ValueObjectSP *reason_sp, ValueObjectSP *userinfo_sp,
+  ValueObjectSP *reserved_sp) {
   ProcessSP process_sp(valobj.GetProcessSP());
   if (!process_sp)
 return false;
@@ -61,10 +61,14 @@
   auto userinfo = process_sp->ReadPointerFromMemory(ptr + 3 * ptr_size, error);
   if (error.Fail() || userinfo == LLDB_INVALID_ADDRESS)
 return false;
+  auto reserved = process_sp->ReadPointerFromMemory(ptr + 4 * ptr_size, error);
+  if (error.Fail() || reserved == LLDB_INVALID_ADDRESS)
+return false;
 
   InferiorSizedWord name_isw(name, *process_sp);
   InferiorSizedWord reason_isw(reason, *process_sp);
   InferiorSizedWord userinfo_isw(userinfo, *process_sp);
+  InferiorSizedWord reserved_isw(reserved, *process_sp);
 
   CompilerType voidstar = process_sp->GetTarget()
   .GetScratchClangASTContext()
@@ -83,15 +87,19 @@
 *userinfo_sp = ValueObject::CreateValueObjectFromData(
 "userInfo", userinfo_isw.GetAsData(process_sp->GetByteOrder()),
 valobj.GetExecutionContextRef(), voidstar);
+  if (reserved_sp)
+*reserved_sp = ValueObject::CreateValueObjectFromData(
+"reserved", reserved_isw.GetAsData(process_sp->GetByteOrder()),
+valobj.GetExecutionContextRef(), voidstar);
 
   return true;
 }
 
 bool lldb_private::formatters::NSException_SummaryProvider(
 ValueObject &valobj, Stream &stream, const TypeSummaryOptions &options) {
   lldb::ValueObjectSP name_sp;
   lldb::ValueObjectSP reason_sp;
-  if (!ExtractFields(valobj, &name_sp, &reason_sp, nullptr))
+  if (!ExtractFields(valobj, &name_sp, &reason_sp, nullptr, nullptr))
 return false;
 
   if (!name_sp || !reason_sp)
@@ -117,35 +125,56 @@
   ~NSExceptionSyntheticFrontEnd() override = default;
 
   size_t CalculateNumChildren() override {
-return 1;
+return 4;
   }
 
   lldb::ValueObjectSP GetChildAtIndex(size_t idx) override {
 switch (idx) {
-  case 0: return m_userinfo_sp;
+  case 0: return m_name_sp;
+  case 1: return m_reason_sp;
+  case 2: return m_userinfo_sp;
+  case 3: return m_reserved_sp;
 }
 return lldb::ValueObjectSP();
   }
 
   bool Update() override {
+m_name_sp.reset();
+m_reason_sp.reset();
 m_userinfo_sp.reset();
-if (!ExtractFields(m_backend, nullptr, nullptr, &m_userinfo_sp)) {
+m_reserved_sp.reset();
+
+if (!ExtractFields(m_backend, &m_name_sp, &m_reason_sp, &m_userinfo_sp,
+   &m_reserved_sp)) {
   return false;
 }
 return true;
   }
 
   bool MightHaveChildren() override { return true; }
 
   size_t GetIndexOfChildWithName(const ConstString &name) override {
+// NSException has 4 members:
+//   NSString *name;
+//   NSString *reason;
+//   NSDictionary *userInfo;
+//   id reserved;
+static ConstString g___name("name");
+static ConstString g___reason("reason");
 static ConstString g___userInfo("userInfo");
-if (name == g___userInfo)
-  return 0;
+static ConstString g___reserved("reserved");
+if (name == g___name) return 0;
+if (name == g___reason) return 1;
+if (name == g___userInfo) return 2;
+if (name == g___reserved) return 3;
 return UINT32_MAX;
   }
 
 private:
+  ValueObjectSP m_name_sp;
+  ValueObjectSP m_reason_sp;
   ValueObjectSP m_userinfo_sp;
+  ValueObjectSP m_reserved_sp;
 };
 
 SyntheticChildrenFrontEnd *
Index: packages/Python/lldbsuite/test/lang/objc/exceptions/main.m
===
--- packages/Python/lldbsuite/test/lang/objc/exceptions/main.m
+++ packages/Python/lldbsuite/test/lang/objc/exceptions/main.m
@@ -0,0 +1,36 @@
+//===-- main.m *- ObjC -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===---

[Lldb-commits] [PATCH] D44081: [lldb] Add synthetic frontend for _NSCallStackArray

2018-11-12 Thread Phabricator via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rLLDB346708: [lldb] Add synthetic frontend for 
_NSCallStackArray (authored by kuba.brecka, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D44081?vs=173695&id=173749#toc

Repository:
  rLLDB LLDB

https://reviews.llvm.org/D44081

Files:
  packages/Python/lldbsuite/test/lang/objc/exceptions/TestObjCExceptions.py
  source/Plugins/Language/ObjC/NSArray.cpp
  source/Plugins/Language/ObjC/ObjCLanguage.cpp

Index: source/Plugins/Language/ObjC/ObjCLanguage.cpp
===
--- source/Plugins/Language/ObjC/ObjCLanguage.cpp
+++ source/Plugins/Language/ObjC/ObjCLanguage.cpp
@@ -409,6 +409,9 @@
   "NSArray summary provider", ConstString("__NSCFArray"), appkit_flags);
   AddCXXSummary(
   objc_category_sp, lldb_private::formatters::NSArraySummaryProvider,
+  "NSArray summary provider", ConstString("_NSCallStackArray"), appkit_flags);
+  AddCXXSummary(
+  objc_category_sp, lldb_private::formatters::NSArraySummaryProvider,
   "NSArray summary provider", ConstString("CFArrayRef"), appkit_flags);
   AddCXXSummary(objc_category_sp,
 lldb_private::formatters::NSArraySummaryProvider,
@@ -528,6 +531,10 @@
   ScriptedSyntheticChildren::Flags());
   AddCXXSynthetic(objc_category_sp,
   lldb_private::formatters::NSArraySyntheticFrontEndCreator,
+  "NSArray synthetic children", ConstString("_NSCallStackArray"),
+  ScriptedSyntheticChildren::Flags());
+  AddCXXSynthetic(objc_category_sp,
+  lldb_private::formatters::NSArraySyntheticFrontEndCreator,
   "NSArray synthetic children",
   ConstString("CFMutableArrayRef"),
   ScriptedSyntheticChildren::Flags());
Index: source/Plugins/Language/ObjC/NSArray.cpp
===
--- source/Plugins/Language/ObjC/NSArray.cpp
+++ source/Plugins/Language/ObjC/NSArray.cpp
@@ -214,6 +214,25 @@
 
 }
 
+namespace CallStackArray {
+struct DataDescriptor_32 {
+  uint32_t _data;
+  uint32_t _used;
+  uint32_t _offset;
+  const uint32_t _size = 0;
+};
+
+struct DataDescriptor_64 {
+  uint64_t _data;
+  uint64_t _used;
+  uint64_t _offset;
+  const uint64_t _size = 0;
+};
+
+using NSCallStackArraySyntheticFrontEnd =
+GenericNSArrayMSyntheticFrontEnd;
+} // namespace CallStackArray
+
 template 
 class GenericNSArrayISyntheticFrontEnd : public SyntheticChildrenFrontEnd {
 public:
@@ -364,6 +383,7 @@
   static const ConstString g_NSArrayCF("__NSCFArray");
   static const ConstString g_NSArrayMLegacy("__NSArrayM_Legacy");
   static const ConstString g_NSArrayMImmutable("__NSArrayM_Immutable");
+  static const ConstString g_NSCallStackArray("_NSCallStackArray");
 
   if (class_name.IsEmpty())
 return false;
@@ -413,7 +433,9 @@
 value = 0;
   } else if (class_name == g_NSArray1) {
 value = 1;
-  } else if (class_name == g_NSArrayCF) {
+  } else if (class_name == g_NSArrayCF || class_name == g_NSCallStackArray) {
+// __NSCFArray and _NSCallStackArray store the number of elements as a
+// pointer-sized value at offset `2 * ptr_size`.
 Status error;
 value = process_sp->ReadUnsignedIntegerFromMemory(
 valobj_addr + 2 * ptr_size, ptr_size, 0, error);
@@ -813,6 +835,7 @@
   static const ConstString g_NSArray1("__NSSingleObjectArrayI");
   static const ConstString g_NSArrayMLegacy("__NSArrayM_Legacy");
   static const ConstString g_NSArrayMImmutable("__NSArrayM_Immutable");
+  static const ConstString g_NSCallStackArray("_NSCallStackArray");
 
   if (class_name.IsEmpty())
 return nullptr;
@@ -842,6 +865,8 @@
   return (new Foundation1010::NSArrayMSyntheticFrontEnd(valobj_sp));
 else
   return (new Foundation109::NSArrayMSyntheticFrontEnd(valobj_sp));
+  } else if (class_name == g_NSCallStackArray) {
+return (new CallStackArray::NSCallStackArraySyntheticFrontEnd(valobj_sp));
   } else {
 auto &map(NSArray_Additionals::GetAdditionalSynthetics());
 auto iter = map.find(class_name), end = map.end();
Index: packages/Python/lldbsuite/test/lang/objc/exceptions/TestObjCExceptions.py
===
--- packages/Python/lldbsuite/test/lang/objc/exceptions/TestObjCExceptions.py
+++ packages/Python/lldbsuite/test/lang/objc/exceptions/TestObjCExceptions.py
@@ -28,7 +28,8 @@
 self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT,
 substrs=['stopped', 'stop reason = breakpoint'])
 
-thread = self.dbg.GetSelectedTarget().GetProcess().GetSelectedThread()
+target = self.dbg.GetSelectedTarget()
+thread = target.GetProcess().GetSelectedThread()
 frame = thread.GetSelectedFrame()
 
 self.expect(
@@ -87,4 +88,13 @@
 self.assertEqual(userInfo.summary, "1 key/value pair"

[Lldb-commits] [PATCH] D54601: Makefile.rules: Use a shared clang module cache directory.

2018-11-16 Thread Phabricator via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rLLDB347056: Makefile.rules: Use a shared clang module cache 
directory. (authored by adrian, committed by ).
Herald added a subscriber: teemperor.

Repository:
  rLLDB LLDB

https://reviews.llvm.org/D54601

Files:
  lit/lit.cfg.py
  packages/Python/lldbsuite/test/make/Makefile.rules


Index: lit/lit.cfg.py
===
--- lit/lit.cfg.py
+++ lit/lit.cfg.py
@@ -4,9 +4,9 @@
 import sys
 import re
 import platform
+import shutil
 import subprocess
 
-
 import lit.util
 import lit.formats
 from lit.llvm import llvm_config
@@ -124,3 +124,12 @@
  ('--build-mode', {'DEBUG': 'debug'}),
  ('--targets-built', calculate_arch_features)
  ])
+
+# Clean the module caches in the test build directory.  This is
+# necessary in an incremental build whenever clang changes underneath,
+# so doing it once per lit.py invocation is close enough.
+for i in ['module-cache-clang']:
+cachedir = os.path.join(config.llvm_obj_root, 'lldb-test-build.noindex', i)
+if os.path.isdir(cachedir):
+print("Deleting module cache at %s."%cachedir)
+shutil.rmtree(cachedir)
Index: packages/Python/lldbsuite/test/make/Makefile.rules
===
--- packages/Python/lldbsuite/test/make/Makefile.rules
+++ packages/Python/lldbsuite/test/make/Makefile.rules
@@ -33,7 +33,6 @@
 THIS_FILE_DIR := $(shell dirname $(lastword $(MAKEFILE_LIST)))/
 LLDB_BASE_DIR := $(THIS_FILE_DIR)../../../../../
 
-
 #--
 # If OS is not defined, use 'uname -s' to determine the OS name.
 #
@@ -253,7 +252,16 @@
CFLAGS += -gsplit-dwarf
 endif
 
+# Use a shared module cache when building in the default test build directory.
+ifeq "$(findstring lldb-test-build.noindex, $(BUILDDIR))" ""
 CLANG_MODULE_CACHE_DIR := $(BUILDDIR)/module-cache
+else
+CLANG_MODULE_CACHE_DIR := $(shell echo "$(BUILDDIR)" | sed 
's/lldb-test-build.noindex.*/lldb-test-build.noindex\/module-cache-clang/')
+endif
+
+ifeq "$(CLANG_MODULE_CACHE_DIR)" ""
+$(error failed to set the shared clang module cache dir)
+endif
 
 MANDATORY_MODULE_BUILD_CFLAGS := -fmodules -gmodules 
-fmodules-cache-path=$(CLANG_MODULE_CACHE_DIR)
 


Index: lit/lit.cfg.py
===
--- lit/lit.cfg.py
+++ lit/lit.cfg.py
@@ -4,9 +4,9 @@
 import sys
 import re
 import platform
+import shutil
 import subprocess
 
-
 import lit.util
 import lit.formats
 from lit.llvm import llvm_config
@@ -124,3 +124,12 @@
  ('--build-mode', {'DEBUG': 'debug'}),
  ('--targets-built', calculate_arch_features)
  ])
+
+# Clean the module caches in the test build directory.  This is
+# necessary in an incremental build whenever clang changes underneath,
+# so doing it once per lit.py invocation is close enough.
+for i in ['module-cache-clang']:
+cachedir = os.path.join(config.llvm_obj_root, 'lldb-test-build.noindex', i)
+if os.path.isdir(cachedir):
+print("Deleting module cache at %s."%cachedir)
+shutil.rmtree(cachedir)
Index: packages/Python/lldbsuite/test/make/Makefile.rules
===
--- packages/Python/lldbsuite/test/make/Makefile.rules
+++ packages/Python/lldbsuite/test/make/Makefile.rules
@@ -33,7 +33,6 @@
 THIS_FILE_DIR := $(shell dirname $(lastword $(MAKEFILE_LIST)))/
 LLDB_BASE_DIR := $(THIS_FILE_DIR)../../../../../
 
-
 #--
 # If OS is not defined, use 'uname -s' to determine the OS name.
 #
@@ -253,7 +252,16 @@
 	CFLAGS += -gsplit-dwarf
 endif
 
+# Use a shared module cache when building in the default test build directory.
+ifeq "$(findstring lldb-test-build.noindex, $(BUILDDIR))" ""
 CLANG_MODULE_CACHE_DIR := $(BUILDDIR)/module-cache
+else
+CLANG_MODULE_CACHE_DIR := $(shell echo "$(BUILDDIR)" | sed 's/lldb-test-build.noindex.*/lldb-test-build.noindex\/module-cache-clang/')
+endif
+
+ifeq "$(CLANG_MODULE_CACHE_DIR)" ""
+$(error failed to set the shared clang module cache dir)
+endif
 
 MANDATORY_MODULE_BUILD_CFLAGS := -fmodules -gmodules -fmodules-cache-path=$(CLANG_MODULE_CACHE_DIR)
 
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D54602: Use a shared module cache directory for LLDB.

2018-11-16 Thread Phabricator via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rLLDB347057: Use a shared module cache directory for LLDB. 
(authored by adrian, committed by ).
Herald added a subscriber: teemperor.

Repository:
  rLLDB LLDB

https://reviews.llvm.org/D54602

Files:
  lit/lit.cfg.py
  packages/Python/lldbsuite/test/lldbtest.py


Index: lit/lit.cfg.py
===
--- lit/lit.cfg.py
+++ lit/lit.cfg.py
@@ -128,7 +128,7 @@
 # Clean the module caches in the test build directory.  This is
 # necessary in an incremental build whenever clang changes underneath,
 # so doing it once per lit.py invocation is close enough.
-for i in ['module-cache-clang']:
+for i in ['module-cache-clang', 'module-cache-lldb']:
 cachedir = os.path.join(config.llvm_obj_root, 'lldb-test-build.noindex', i)
 if os.path.isdir(cachedir):
 print("Deleting module cache at %s."%cachedir)
Index: packages/Python/lldbsuite/test/lldbtest.py
===
--- packages/Python/lldbsuite/test/lldbtest.py
+++ packages/Python/lldbsuite/test/lldbtest.py
@@ -1862,8 +1862,9 @@
 # decorators.
 Base.setUp(self)
 
-# Set the clang modules cache path.
-mod_cache = os.path.join(self.getBuildDir(), "module-cache-lldb")
+# Set the clang modules cache path used by LLDB.
+mod_cache = os.path.join(os.path.join(os.environ["LLDB_BUILD"],
+  "module-cache-lldb"))
 self.runCmd('settings set symbols.clang-modules-cache-path "%s"'
 % mod_cache)
 


Index: lit/lit.cfg.py
===
--- lit/lit.cfg.py
+++ lit/lit.cfg.py
@@ -128,7 +128,7 @@
 # Clean the module caches in the test build directory.  This is
 # necessary in an incremental build whenever clang changes underneath,
 # so doing it once per lit.py invocation is close enough.
-for i in ['module-cache-clang']:
+for i in ['module-cache-clang', 'module-cache-lldb']:
 cachedir = os.path.join(config.llvm_obj_root, 'lldb-test-build.noindex', i)
 if os.path.isdir(cachedir):
 print("Deleting module cache at %s."%cachedir)
Index: packages/Python/lldbsuite/test/lldbtest.py
===
--- packages/Python/lldbsuite/test/lldbtest.py
+++ packages/Python/lldbsuite/test/lldbtest.py
@@ -1862,8 +1862,9 @@
 # decorators.
 Base.setUp(self)
 
-# Set the clang modules cache path.
-mod_cache = os.path.join(self.getBuildDir(), "module-cache-lldb")
+# Set the clang modules cache path used by LLDB.
+mod_cache = os.path.join(os.path.join(os.environ["LLDB_BUILD"],
+  "module-cache-lldb"))
 self.runCmd('settings set symbols.clang-modules-cache-path "%s"'
 % mod_cache)
 
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D54443: [CMake] Accept ENTITLEMENTS in add_llvm_executable and llvm_codesign

2018-11-16 Thread Phabricator via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL347068: [CMake] Accept ENTITLEMENTS in add_llvm_executable 
and llvm_codesign (authored by stefan.graenitz, committed by ).

Repository:
  rL LLVM

https://reviews.llvm.org/D54443

Files:
  llvm/trunk/CMakeLists.txt
  llvm/trunk/cmake/modules/AddLLVM.cmake


Index: llvm/trunk/cmake/modules/AddLLVM.cmake
===
--- llvm/trunk/cmake/modules/AddLLVM.cmake
+++ llvm/trunk/cmake/modules/AddLLVM.cmake
@@ -580,7 +580,7 @@
 
   if(ARG_SHARED OR ARG_MODULE)
 llvm_externalize_debuginfo(${name})
-llvm_codesign(${name})
+llvm_codesign(TARGET ${name})
   endif()
 endfunction()
 
@@ -708,7 +708,12 @@
 
 
 macro(add_llvm_executable name)
-  cmake_parse_arguments(ARG 
"DISABLE_LLVM_LINK_LLVM_DYLIB;IGNORE_EXTERNALIZE_DEBUGINFO;NO_INSTALL_RPATH" "" 
"DEPENDS" ${ARGN})
+  cmake_parse_arguments(ARG
+
"DISABLE_LLVM_LINK_LLVM_DYLIB;IGNORE_EXTERNALIZE_DEBUGINFO;NO_INSTALL_RPATH"
+"ENTITLEMENTS"
+"DEPENDS"
+${ARGN})
+
   llvm_process_sources( ALL_FILES ${ARG_UNPARSED_ARGUMENTS} )
 
   list(APPEND LLVM_COMMON_DEPENDS ${ARG_DEPENDS})
@@ -787,7 +792,7 @@
 target_link_libraries(${name} PRIVATE ${LLVM_PTHREAD_LIB})
   endif()
 
-  llvm_codesign(${name})
+  llvm_codesign(TARGET ${name} ENTITLEMENTS ${ARG_ENTITLEMENTS})
 endmacro(add_llvm_executable name)
 
 function(export_executable_symbols target)
@@ -1626,7 +1631,14 @@
   endif()
 endfunction()
 
-function(llvm_codesign name)
+# Usage: llvm_codesign(TARGET name [ENTITLEMENTS file])
+#
+# Code-sign the given TARGET with the global LLVM_CODESIGNING_IDENTITY or skip
+# if undefined. Customize capabilities by passing a file path to ENTITLEMENTS.
+#
+function(llvm_codesign)
+  cmake_parse_arguments(ARG "" "TARGET;ENTITLEMENTS" "" ${ARGN})
+
   if(NOT LLVM_CODESIGNING_IDENTITY)
 return()
   endif()
@@ -1642,12 +1654,16 @@
 OUTPUT_VARIABLE CMAKE_CODESIGN_ALLOCATE
   )
 endif()
+if(DEFINED ARG_ENTITLEMENTS)
+  set(PASS_ENTITLEMENTS --entitlements ${ARG_ENTITLEMENTS})
+endif()
+
 add_custom_command(
-  TARGET ${name} POST_BUILD
+  TARGET ${ARG_TARGET} POST_BUILD
   COMMAND ${CMAKE_COMMAND} -E
   env CODESIGN_ALLOCATE=${CMAKE_CODESIGN_ALLOCATE}
   ${CMAKE_CODESIGN} -s ${LLVM_CODESIGNING_IDENTITY}
-  $
+  ${PASS_ENTITLEMENTS} $
 )
   endif()
 endfunction()
Index: llvm/trunk/CMakeLists.txt
===
--- llvm/trunk/CMakeLists.txt
+++ llvm/trunk/CMakeLists.txt
@@ -399,8 +399,8 @@
 option(LLVM_EXTERNALIZE_DEBUGINFO
   "Generate dSYM files and strip executables and libraries (Darwin Only)" OFF)
 
-option(LLVM_CODESIGNING_IDENTITY
-  "Sign executables and dylibs with the given identity (Darwin Only)" OFF)
+set(LLVM_CODESIGNING_IDENTITY "" CACHE STRING
+  "Sign executables and dylibs with the given identity or skip if empty 
(Darwin Only)")
 
 # If enabled, verify we are on a platform that supports oprofile.
 if( LLVM_USE_OPROFILE )


Index: llvm/trunk/cmake/modules/AddLLVM.cmake
===
--- llvm/trunk/cmake/modules/AddLLVM.cmake
+++ llvm/trunk/cmake/modules/AddLLVM.cmake
@@ -580,7 +580,7 @@
 
   if(ARG_SHARED OR ARG_MODULE)
 llvm_externalize_debuginfo(${name})
-llvm_codesign(${name})
+llvm_codesign(TARGET ${name})
   endif()
 endfunction()
 
@@ -708,7 +708,12 @@
 
 
 macro(add_llvm_executable name)
-  cmake_parse_arguments(ARG "DISABLE_LLVM_LINK_LLVM_DYLIB;IGNORE_EXTERNALIZE_DEBUGINFO;NO_INSTALL_RPATH" "" "DEPENDS" ${ARGN})
+  cmake_parse_arguments(ARG
+"DISABLE_LLVM_LINK_LLVM_DYLIB;IGNORE_EXTERNALIZE_DEBUGINFO;NO_INSTALL_RPATH"
+"ENTITLEMENTS"
+"DEPENDS"
+${ARGN})
+
   llvm_process_sources( ALL_FILES ${ARG_UNPARSED_ARGUMENTS} )
 
   list(APPEND LLVM_COMMON_DEPENDS ${ARG_DEPENDS})
@@ -787,7 +792,7 @@
 target_link_libraries(${name} PRIVATE ${LLVM_PTHREAD_LIB})
   endif()
 
-  llvm_codesign(${name})
+  llvm_codesign(TARGET ${name} ENTITLEMENTS ${ARG_ENTITLEMENTS})
 endmacro(add_llvm_executable name)
 
 function(export_executable_symbols target)
@@ -1626,7 +1631,14 @@
   endif()
 endfunction()
 
-function(llvm_codesign name)
+# Usage: llvm_codesign(TARGET name [ENTITLEMENTS file])
+#
+# Code-sign the given TARGET with the global LLVM_CODESIGNING_IDENTITY or skip
+# if undefined. Customize capabilities by passing a file path to ENTITLEMENTS.
+#
+function(llvm_codesign)
+  cmake_parse_arguments(ARG "" "TARGET;ENTITLEMENTS" "" ${ARGN})
+
   if(NOT LLVM_CODESIGNING_IDENTITY)
 return()
   endif()
@@ -1642,12 +1654,16 @@
 OUTPUT_VARIABLE CMAKE_CODESIGN_ALLOCATE
   )
 endif()
+if(DEFINED ARG_ENTITLEMENTS)
+  set(PASS_ENTITLEMENTS --entitlements ${ARG_ENTITLEMENTS})
+endif()
+
 add_custom_command(
-  TARGET ${name} POST_BUILD
+  TARGET ${AR

[Lldb-commits] [PATCH] D54476: [CMake] Streamline code signing for debugserver

2018-11-20 Thread Phabricator via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL347305: [CMake] Streamline code signing for debugserver and 
pass entitlements to… (authored by stefan.graenitz, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D54476?vs=174405&id=174761#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D54476

Files:
  lldb/trunk/CMakeLists.txt
  lldb/trunk/cmake/modules/AddLLDB.cmake
  lldb/trunk/test/CMakeLists.txt
  lldb/trunk/tools/debugserver/CMakeLists.txt
  lldb/trunk/tools/debugserver/source/CMakeLists.txt
  lldb/trunk/unittests/tools/CMakeLists.txt

Index: lldb/trunk/cmake/modules/AddLLDB.cmake
===
--- lldb/trunk/cmake/modules/AddLLDB.cmake
+++ lldb/trunk/cmake/modules/AddLLDB.cmake
@@ -100,13 +100,13 @@
 function(add_lldb_executable name)
   cmake_parse_arguments(ARG
 "INCLUDE_IN_SUITE;GENERATE_INSTALL"
-""
+"ENTITLEMENTS"
 "LINK_LIBS;LINK_COMPONENTS"
 ${ARGN}
 )
 
   list(APPEND LLVM_LINK_COMPONENTS ${ARG_LINK_COMPONENTS})
-  add_llvm_executable(${name} ${ARG_UNPARSED_ARGUMENTS})
+  add_llvm_executable(${name} ${ARG_UNPARSED_ARGUMENTS} ENTITLEMENTS ${ARG_ENTITLEMENTS})
 
   target_link_libraries(${name} PRIVATE ${ARG_LINK_LIBS})
   set_target_properties(${name} PROPERTIES
Index: lldb/trunk/test/CMakeLists.txt
===
--- lldb/trunk/test/CMakeLists.txt
+++ lldb/trunk/test/CMakeLists.txt
@@ -93,11 +93,11 @@
   endif()
 endif()
 
-if(CMAKE_HOST_APPLE)
+if(CMAKE_HOST_APPLE AND DEBUGSERVER_PATH)
   list(APPEND LLDB_TEST_COMMON_ARGS --server ${DEBUGSERVER_PATH})
 endif()
 
-if(SKIP_DEBUGSERVER)
+if(SKIP_TEST_DEBUGSERVER)
   list(APPEND LLDB_TEST_COMMON_ARGS --out-of-tree-debugserver)
 endif()
 
Index: lldb/trunk/CMakeLists.txt
===
--- lldb/trunk/CMakeLists.txt
+++ lldb/trunk/CMakeLists.txt
@@ -11,6 +11,12 @@
 include(LLDBConfig)
 include(AddLLDB)
 
+option(LLDB_USE_ENTITLEMENTS "When codesigning, use entitlements if available" ON)
+if(LLDB_CODESIGN_IDENTITY)
+  # In the future we may use LLVM_CODESIGNING_IDENTITY directly.
+  set(LLVM_CODESIGNING_IDENTITY ${LLDB_CODESIGN_IDENTITY})
+endif()
+
 # Define the LLDB_CONFIGURATION_xxx matching the build type
 if( uppercase_CMAKE_BUILD_TYPE STREQUAL "DEBUG" )
   add_definitions( -DLLDB_CONFIGURATION_DEBUG )
Index: lldb/trunk/unittests/tools/CMakeLists.txt
===
--- lldb/trunk/unittests/tools/CMakeLists.txt
+++ lldb/trunk/unittests/tools/CMakeLists.txt
@@ -1,5 +1,5 @@
 if(CMAKE_SYSTEM_NAME MATCHES "Android|Darwin|Linux|NetBSD")
-  if ((CMAKE_SYSTEM_NAME MATCHES "Darwin" AND SKIP_DEBUGSERVER) OR (NOT CMAKE_SYSTEM_NAME MATCHES "Darwin" AND SKIP_LLDB_SERVER_BUILD))
+  if ((CMAKE_SYSTEM_NAME MATCHES "Darwin" AND SKIP_TEST_DEBUGSERVER) OR (NOT CMAKE_SYSTEM_NAME MATCHES "Darwin" AND SKIP_LLDB_SERVER_BUILD))
 # These tests are meant to test lldb-server/debugserver in isolation, and
 # don't provide any value if run against a server copied from somewhere.
   else()
Index: lldb/trunk/tools/debugserver/source/CMakeLists.txt
===
--- lldb/trunk/tools/debugserver/source/CMakeLists.txt
+++ lldb/trunk/tools/debugserver/source/CMakeLists.txt
@@ -94,32 +94,102 @@
 
 add_library(lldbDebugserverCommon ${lldbDebugserverCommonSources})
 
+option(LLDB_NO_DEBUGSERVER "Disable the debugserver target" OFF)
+option(LLDB_USE_SYSTEM_DEBUGSERVER "Use the system's debugserver instead of building it from source (Darwin only)." OFF)
 
-set(LLDB_CODESIGN_IDENTITY "lldb_codesign"
-  CACHE STRING "Identity used for code signing. Set to empty string to skip the signing step.")
+# Incompatible options
+if(LLDB_NO_DEBUGSERVER AND LLDB_USE_SYSTEM_DEBUGSERVER)
+  message(FATAL_ERROR "Inconsistent options: LLDB_NO_DEBUGSERVER and LLDB_USE_SYSTEM_DEBUGSERVER")
+endif()
 
-if(NOT LLDB_CODESIGN_IDENTITY STREQUAL "")
-  set(DEBUGSERVER_PATH ${LLVM_RUNTIME_OUTPUT_INTDIR}/debugserver${CMAKE_EXECUTABLE_SUFFIX} CACHE PATH "Path to debugserver.")
-  set(SKIP_DEBUGSERVER OFF CACHE BOOL "Skip building the in-tree debug server")
-else()
+# Try to locate the system debugserver.
+# Subsequent feasibility checks depend on it.
+if(APPLE AND CMAKE_HOST_APPLE)
   execute_process(
 COMMAND xcode-select -p
-OUTPUT_VARIABLE XCODE_DEV_DIR)
-  string(STRIP ${XCODE_DEV_DIR} XCODE_DEV_DIR)
-  if(EXISTS "${XCODE_DEV_DIR}/../SharedFrameworks/LLDB.framework/")
-set(DEBUGSERVER_PATH
-  "${XCODE_DEV_DIR}/../SharedFrameworks/LLDB.framework/Resources/debugserver" CACHE PATH "Path to debugserver.")
-  elseif(EXISTS "${XCODE_DEV_DIR}/Library/PrivateFrameworks/LLDB.framework/")
-set(DEBUGSERVER_PATH
-  "${XCODE_DEV_DIR}/Library/PrivateFrameworks/LLDB.framework/Resources/debugserver" CACHE PATH "Path to debugserver.")
+  

[Lldb-commits] [PATCH] D43886: [lldb] Add GetCurrentException APIs to SBThread, add frame recognizer for objc_exception_throw for Obj-C runtimes

2018-11-28 Thread Phabricator via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rLLDB347813: [lldb] Add GetCurrentException APIs to SBThread, 
add frame recognizer for… (authored by kuba.brecka, committed by ).
Herald added a subscriber: teemperor.

Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D43886

Files:
  include/lldb/API/SBThread.h
  include/lldb/Target/StackFrameRecognizer.h
  include/lldb/Target/Thread.h
  packages/Python/lldbsuite/test/lang/objc/exceptions/TestObjCExceptions.py
  source/API/SBThread.cpp
  source/Commands/CommandObjectThread.cpp
  source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp
  source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.h
  source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV1.cpp
  source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp
  source/Target/StackFrameRecognizer.cpp
  source/Target/Thread.cpp

Index: packages/Python/lldbsuite/test/lang/objc/exceptions/TestObjCExceptions.py
===
--- packages/Python/lldbsuite/test/lang/objc/exceptions/TestObjCExceptions.py
+++ packages/Python/lldbsuite/test/lang/objc/exceptions/TestObjCExceptions.py
@@ -23,6 +23,16 @@
 target = self.dbg.CreateTarget(self.getBuildArtifact("a.out"))
 self.assertTrue(target, VALID_TARGET)
 
+lldbutil.run_to_name_breakpoint(self, "objc_exception_throw")
+
+self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT,
+substrs=['stopped', 'stop reason = breakpoint'])
+
+self.expect('thread exception', substrs=[
+'(NSException *) exception = ',
+'name: "ThrownException" - reason: "SomeReason"',
+])
+
 lldbutil.run_to_source_breakpoint(self, "// Set break point at this line.", lldb.SBFileSpec("main.m"))
 
 self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT,
Index: source/API/SBThread.cpp
===
--- source/API/SBThread.cpp
+++ source/API/SBThread.cpp
@@ -1484,6 +1484,21 @@
   return LLDB_INVALID_INDEX32;
 }
 
+SBValue SBThread::GetCurrentException() {
+  ThreadSP thread_sp(m_opaque_sp->GetThreadSP());
+  if (!thread_sp) return SBValue();
+
+  return SBValue(thread_sp->GetCurrentException());
+}
+
+/* TODO(kubamracek)
+SBThread SBThread::GetCurrentExceptionBacktrace() {
+  ThreadSP thread_sp(m_opaque_sp->GetThreadSP());
+  if (!thread_sp) return SBThread();
+
+  return SBThread(thread_sp->GetCurrentExceptionBacktrace());
+}*/
+
 bool SBThread::SafeToCallFunctions() {
   ThreadSP thread_sp(m_opaque_sp->GetThreadSP());
   if (thread_sp)
Index: source/Target/StackFrameRecognizer.cpp
===
--- source/Target/StackFrameRecognizer.cpp
+++ source/Target/StackFrameRecognizer.cpp
@@ -49,8 +49,9 @@
 
 class StackFrameRecognizerManagerImpl {
 public:
-  void AddRecognizer(StackFrameRecognizerSP recognizer, ConstString &module,
- ConstString &symbol, bool first_instruction_only) {
+  void AddRecognizer(StackFrameRecognizerSP recognizer,
+ const ConstString &module, const ConstString &symbol,
+ bool first_instruction_only) {
 m_recognizers.push_front({(uint32_t)m_recognizers.size(), false, recognizer, false, module, RegularExpressionSP(),
   symbol, RegularExpressionSP(),
   first_instruction_only});
@@ -152,8 +153,8 @@
 }
 
 void StackFrameRecognizerManager::AddRecognizer(
-StackFrameRecognizerSP recognizer, ConstString &module, ConstString &symbol,
-bool first_instruction_only) {
+StackFrameRecognizerSP recognizer, const ConstString &module,
+const ConstString &symbol, bool first_instruction_only) {
   GetStackFrameRecognizerManagerImpl().AddRecognizer(recognizer, module, symbol,
  first_instruction_only);
 }
Index: source/Target/Thread.cpp
===
--- source/Target/Thread.cpp
+++ source/Target/Thread.cpp
@@ -25,6 +25,7 @@
 #include "lldb/Target/ExecutionContext.h"
 #include "lldb/Target/Process.h"
 #include "lldb/Target/RegisterContext.h"
+#include "lldb/Target/StackFrameRecognizer.h"
 #include "lldb/Target/StopInfo.h"
 #include "lldb/Target/SystemRuntime.h"
 #include "lldb/Target/Target.h"
@@ -2199,3 +2200,18 @@
   }
   return error;
 }
+
+ValueObjectSP Thread::GetCurrentException() {
+  StackFrameSP frame_sp(GetStackFrameAtIndex(0));
+  if (!frame_sp) return ValueObjectSP();
+
+  RecognizedStackFrameSP recognized_frame(frame_sp->GetRecognizedFrame());
+  if (!recognized_frame) return ValueObjectSP();
+
+  return recognized_frame->GetExceptionObject();
+}
+
+/* TODO(kubamracek)
+ThreadSP Thread::GetCurrentExceptio

[Lldb-commits] [PATCH] D55032: [CMake] Fix standalone build for debugserver on macOS

2018-11-29 Thread Phabricator via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL347869: [CMake] Fix standalone build for debugserver on 
macOS (authored by stefan.graenitz, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D55032?vs=175775&id=175865#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D55032

Files:
  lldb/trunk/tools/debugserver/CMakeLists.txt


Index: lldb/trunk/tools/debugserver/CMakeLists.txt
===
--- lldb/trunk/tools/debugserver/CMakeLists.txt
+++ lldb/trunk/tools/debugserver/CMakeLists.txt
@@ -8,12 +8,17 @@
 "${CMAKE_SOURCE_DIR}/../../cmake"
 "${CMAKE_SOURCE_DIR}/../../cmake/modules"
 )
-  
+
   include(LLDBStandalone)
   include(AddLLDB)
 
   set(LLDB_SOURCE_DIR "${CMAKE_SOURCE_DIR}/../../")
   include_directories(${LLDB_SOURCE_DIR}/include)
+
+  # lldb-suite is a dummy target that encompasses all the necessary tools and
+  # libraries for building a fully-functioning liblldb.
+  add_custom_target(lldb-suite)
+  set(LLDB_SUITE_TARGET lldb-suite)
 endif()
 
 add_subdirectory(source)


Index: lldb/trunk/tools/debugserver/CMakeLists.txt
===
--- lldb/trunk/tools/debugserver/CMakeLists.txt
+++ lldb/trunk/tools/debugserver/CMakeLists.txt
@@ -8,12 +8,17 @@
 "${CMAKE_SOURCE_DIR}/../../cmake"
 "${CMAKE_SOURCE_DIR}/../../cmake/modules"
 )
-  
+
   include(LLDBStandalone)
   include(AddLLDB)
 
   set(LLDB_SOURCE_DIR "${CMAKE_SOURCE_DIR}/../../")
   include_directories(${LLDB_SOURCE_DIR}/include)
+
+  # lldb-suite is a dummy target that encompasses all the necessary tools and
+  # libraries for building a fully-functioning liblldb.
+  add_custom_target(lldb-suite)
+  set(LLDB_SUITE_TARGET lldb-suite)
 endif()
 
 add_subdirectory(source)
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D55128: [CMake] Store path to vendor-specific headers in clang-headers target property

2018-12-03 Thread Phabricator via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL348116: [CMake] Store path to vendor-specific headers in 
clang-headers target property (authored by stefan.graenitz, committed by ).

Repository:
  rL LLVM

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

https://reviews.llvm.org/D55128

Files:
  cfe/trunk/lib/Headers/CMakeLists.txt


Index: cfe/trunk/lib/Headers/CMakeLists.txt
===
--- cfe/trunk/lib/Headers/CMakeLists.txt
+++ cfe/trunk/lib/Headers/CMakeLists.txt
@@ -144,7 +144,7 @@
   list(APPEND out_files ${dst})
 endforeach( f )
 
-add_custom_command(OUTPUT ${output_dir}/arm_neon.h 
+add_custom_command(OUTPUT ${output_dir}/arm_neon.h
   DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/arm_neon.h
   COMMAND ${CMAKE_COMMAND} -E copy_if_different 
${CMAKE_CURRENT_BINARY_DIR}/arm_neon.h ${output_dir}/arm_neon.h
   COMMENT "Copying clang's arm_neon.h...")
@@ -156,7 +156,9 @@
 list(APPEND out_files ${output_dir}/arm_fp16.h)
 
 add_custom_target(clang-headers ALL DEPENDS ${out_files})
-set_target_properties(clang-headers PROPERTIES FOLDER "Misc")
+set_target_properties(clang-headers PROPERTIES
+  FOLDER "Misc"
+  RUNTIME_OUTPUT_DIRECTORY "${output_dir}")
 
 install(
   FILES ${files} ${CMAKE_CURRENT_BINARY_DIR}/arm_neon.h


Index: cfe/trunk/lib/Headers/CMakeLists.txt
===
--- cfe/trunk/lib/Headers/CMakeLists.txt
+++ cfe/trunk/lib/Headers/CMakeLists.txt
@@ -144,7 +144,7 @@
   list(APPEND out_files ${dst})
 endforeach( f )
 
-add_custom_command(OUTPUT ${output_dir}/arm_neon.h 
+add_custom_command(OUTPUT ${output_dir}/arm_neon.h
   DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/arm_neon.h
   COMMAND ${CMAKE_COMMAND} -E copy_if_different ${CMAKE_CURRENT_BINARY_DIR}/arm_neon.h ${output_dir}/arm_neon.h
   COMMENT "Copying clang's arm_neon.h...")
@@ -156,7 +156,9 @@
 list(APPEND out_files ${output_dir}/arm_fp16.h)
 
 add_custom_target(clang-headers ALL DEPENDS ${out_files})
-set_target_properties(clang-headers PROPERTIES FOLDER "Misc")
+set_target_properties(clang-headers PROPERTIES
+  FOLDER "Misc"
+  RUNTIME_OUTPUT_DIRECTORY "${output_dir}")
 
 install(
   FILES ${files} ${CMAKE_CURRENT_BINARY_DIR}/arm_neon.h
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D55114: [CMake] Add LLVM_EXTERNALIZE_DEBUGINFO_OUTPUT_DIR for custom dSYM target directory on Darwin

2018-12-03 Thread Phabricator via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL348118: [CMake] Add LLVM_EXTERNALIZE_DEBUGINFO_OUTPUT_DIR 
for custom dSYM target… (authored by stefan.graenitz, committed by ).

Repository:
  rL LLVM

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

https://reviews.llvm.org/D55114

Files:
  llvm/trunk/cmake/modules/AddLLVM.cmake


Index: llvm/trunk/cmake/modules/AddLLVM.cmake
===
--- llvm/trunk/cmake/modules/AddLLVM.cmake
+++ llvm/trunk/cmake/modules/AddLLVM.cmake
@@ -1597,6 +1597,13 @@
 endif()
   endif()
 
+  if(LLVM_EXTERNALIZE_DEBUGINFO_OUTPUT_DIR)
+if(APPLE)
+  set(output_name "$.dSYM")
+  set(output_path 
"-o=${LLVM_EXTERNALIZE_DEBUGINFO_OUTPUT_DIR}/${output_name}")
+endif()
+  endif()
+
   if(APPLE)
 if(CMAKE_CXX_FLAGS MATCHES "-flto"
   OR CMAKE_CXX_FLAGS_${uppercase_CMAKE_BUILD_TYPE} MATCHES "-flto")
@@ -1609,7 +1616,7 @@
   set(CMAKE_DSYMUTIL xcrun dsymutil)
 endif()
 add_custom_command(TARGET ${name} POST_BUILD
-  COMMAND ${CMAKE_DSYMUTIL} $
+  COMMAND ${CMAKE_DSYMUTIL} ${output_path} $
   ${strip_command}
   )
   else()


Index: llvm/trunk/cmake/modules/AddLLVM.cmake
===
--- llvm/trunk/cmake/modules/AddLLVM.cmake
+++ llvm/trunk/cmake/modules/AddLLVM.cmake
@@ -1597,6 +1597,13 @@
 endif()
   endif()
 
+  if(LLVM_EXTERNALIZE_DEBUGINFO_OUTPUT_DIR)
+if(APPLE)
+  set(output_name "$.dSYM")
+  set(output_path "-o=${LLVM_EXTERNALIZE_DEBUGINFO_OUTPUT_DIR}/${output_name}")
+endif()
+  endif()
+
   if(APPLE)
 if(CMAKE_CXX_FLAGS MATCHES "-flto"
   OR CMAKE_CXX_FLAGS_${uppercase_CMAKE_BUILD_TYPE} MATCHES "-flto")
@@ -1609,7 +1616,7 @@
   set(CMAKE_DSYMUTIL xcrun dsymutil)
 endif()
 add_custom_command(TARGET ${name} POST_BUILD
-  COMMAND ${CMAKE_DSYMUTIL} $
+  COMMAND ${CMAKE_DSYMUTIL} ${output_path} $
   ${strip_command}
   )
   else()
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D55316: [CMake] Add support for NO_INSTALL_RPATH argument in llvm_add_library()

2018-12-07 Thread Phabricator via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL348573: [CMake] Add support for NO_INSTALL_RPATH argument in 
llvm_add_library() (authored by stefan.graenitz, committed by ).

Repository:
  rL LLVM

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

https://reviews.llvm.org/D55316

Files:
  llvm/trunk/cmake/modules/AddLLVM.cmake


Index: llvm/trunk/cmake/modules/AddLLVM.cmake
===
--- llvm/trunk/cmake/modules/AddLLVM.cmake
+++ llvm/trunk/cmake/modules/AddLLVM.cmake
@@ -372,12 +372,14 @@
 # May specify header files for IDE generators.
 #   SONAME
 # Should set SONAME link flags and create symlinks
+#   NO_INSTALL_RPATH
+# Suppress default RPATH settings in shared libraries.
 #   PLUGIN_TOOL
 # The tool (i.e. cmake target) that this plugin will link against
 #   )
 function(llvm_add_library name)
   cmake_parse_arguments(ARG
-"MODULE;SHARED;STATIC;OBJECT;DISABLE_LLVM_LINK_LLVM_DYLIB;SONAME"
+
"MODULE;SHARED;STATIC;OBJECT;DISABLE_LLVM_LINK_LLVM_DYLIB;SONAME;NO_INSTALL_RPATH"
 "OUTPUT_NAME;PLUGIN_TOOL"
 "ADDITIONAL_HEADERS;DEPENDS;LINK_COMPONENTS;LINK_LIBS;OBJLIBS"
 ${ARGN})
@@ -448,17 +450,19 @@
 
   if(ARG_MODULE)
 add_library(${name} MODULE ${ALL_FILES})
-llvm_setup_rpath(${name})
   elseif(ARG_SHARED)
 add_windows_version_resource_file(ALL_FILES ${ALL_FILES})
 add_library(${name} SHARED ${ALL_FILES})
-
-llvm_setup_rpath(${name})
-
   else()
 add_library(${name} STATIC ${ALL_FILES})
   endif()
 
+  if(NOT ARG_NO_INSTALL_RPATH)
+if(ARG_MODULE OR ARG_SHARED)
+  llvm_setup_rpath(${name})
+endif()
+  endif()
+
   setup_dependency_debugging(${name} ${LLVM_COMMON_DEPENDS})
 
   if(DEFINED windows_resource_file)


Index: llvm/trunk/cmake/modules/AddLLVM.cmake
===
--- llvm/trunk/cmake/modules/AddLLVM.cmake
+++ llvm/trunk/cmake/modules/AddLLVM.cmake
@@ -372,12 +372,14 @@
 # May specify header files for IDE generators.
 #   SONAME
 # Should set SONAME link flags and create symlinks
+#   NO_INSTALL_RPATH
+# Suppress default RPATH settings in shared libraries.
 #   PLUGIN_TOOL
 # The tool (i.e. cmake target) that this plugin will link against
 #   )
 function(llvm_add_library name)
   cmake_parse_arguments(ARG
-"MODULE;SHARED;STATIC;OBJECT;DISABLE_LLVM_LINK_LLVM_DYLIB;SONAME"
+"MODULE;SHARED;STATIC;OBJECT;DISABLE_LLVM_LINK_LLVM_DYLIB;SONAME;NO_INSTALL_RPATH"
 "OUTPUT_NAME;PLUGIN_TOOL"
 "ADDITIONAL_HEADERS;DEPENDS;LINK_COMPONENTS;LINK_LIBS;OBJLIBS"
 ${ARGN})
@@ -448,17 +450,19 @@
 
   if(ARG_MODULE)
 add_library(${name} MODULE ${ALL_FILES})
-llvm_setup_rpath(${name})
   elseif(ARG_SHARED)
 add_windows_version_resource_file(ALL_FILES ${ALL_FILES})
 add_library(${name} SHARED ${ALL_FILES})
-
-llvm_setup_rpath(${name})
-
   else()
 add_library(${name} STATIC ${ALL_FILES})
   endif()
 
+  if(NOT ARG_NO_INSTALL_RPATH)
+if(ARG_MODULE OR ARG_SHARED)
+  llvm_setup_rpath(${name})
+endif()
+  endif()
+
   setup_dependency_debugging(${name} ${LLVM_COMMON_DEPENDS})
 
   if(DEFINED windows_resource_file)
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D55614: Fix MinidumpParser::GetFilteredModuleList() and test it

2018-12-13 Thread Phabricator via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL349062: Fix MinidumpParser::GetFilteredModuleList() and test 
it (authored by gclayton, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D55614?vs=177902&id=178086#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D55614

Files:
  lldb/trunk/source/Plugins/Process/minidump/MinidumpParser.cpp
  lldb/trunk/unittests/Process/minidump/Inputs/modules-dup-min-addr.dmp
  lldb/trunk/unittests/Process/minidump/Inputs/modules-order.dmp
  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
@@ -533,3 +533,41 @@
 }
   }
 }
+
+TEST_F(MinidumpParserTest, MinidumpDuplicateModuleMinAddress) {
+  SetUpData("modules-dup-min-addr.dmp");
+  // Test that if we have two modules in the module list:
+  ///tmp/a with range [0x2000-0x3000)
+  ///tmp/a with range [0x1000-0x2000)
+  // That we end up with one module in the filtered list with the
+  // range [0x1000-0x2000). MinidumpParser::GetFilteredModuleList() is
+  // trying to ensure that if we have the same module mentioned more than
+  // one time, we pick the one with the lowest base_of_image.
+  std::vector filtered_modules =
+  parser->GetFilteredModuleList();
+  EXPECT_EQ(1, filtered_modules.size());
+  EXPECT_EQ(0x1000, filtered_modules[0]->base_of_image);
+}
+
+TEST_F(MinidumpParserTest, MinidumpModuleOrder) {
+  SetUpData("modules-order.dmp");
+  // Test that if we have two modules in the module list:
+  ///tmp/a with range [0x2000-0x3000)
+  ///tmp/b with range [0x1000-0x2000)
+  // That we end up with two modules in the filtered list with the same ranges
+  // and in the same order. Previous versions of the
+  // MinidumpParser::GetFilteredModuleList() function would sort all images
+  // by address and modify the order of the modules.
+  std::vector filtered_modules =
+  parser->GetFilteredModuleList();
+  llvm::Optional name;
+  EXPECT_EQ(2, filtered_modules.size());
+  EXPECT_EQ(0x2000, filtered_modules[0]->base_of_image);
+  name = parser->GetMinidumpString(filtered_modules[0]->module_name_rva);
+  ASSERT_TRUE((bool)name);
+  EXPECT_EQ(std::string("/tmp/a"), *name);
+  EXPECT_EQ(0x1000, filtered_modules[1]->base_of_image);
+  name = parser->GetMinidumpString(filtered_modules[1]->module_name_rva);
+  ASSERT_TRUE((bool)name);
+  EXPECT_EQ(std::string("/tmp/b"), *name);
+}
Index: lldb/trunk/source/Plugins/Process/minidump/MinidumpParser.cpp
===
--- lldb/trunk/source/Plugins/Process/minidump/MinidumpParser.cpp
+++ lldb/trunk/source/Plugins/Process/minidump/MinidumpParser.cpp
@@ -274,36 +274,45 @@
 
 std::vector MinidumpParser::GetFilteredModuleList() {
   llvm::ArrayRef modules = GetModuleList();
-  // map module_name -> pair(load_address, pointer to module struct in memory)
-  llvm::StringMap> lowest_addr;
+  // map module_name -> filtered_modules index
+  typedef llvm::StringMap MapType;
+  MapType module_name_to_filtered_index;
 
   std::vector filtered_modules;
-
+  
   llvm::Optional name;
   std::string module_name;
 
   for (const auto &module : modules) {
 name = GetMinidumpString(module.module_name_rva);
-
+
 if (!name)
   continue;
-
+
 module_name = name.getValue();
-
-auto iter = lowest_addr.end();
-bool exists;
-std::tie(iter, exists) = lowest_addr.try_emplace(
-module_name, std::make_pair(module.base_of_image, &module));
-
-if (exists && module.base_of_image < iter->second.first)
-  iter->second = std::make_pair(module.base_of_image, &module);
-  }
-
-  filtered_modules.reserve(lowest_addr.size());
-  for (const auto &module : lowest_addr) {
-filtered_modules.push_back(module.second.second);
+
+MapType::iterator iter;
+bool inserted;
+// See if we have inserted this module aready into filtered_modules. If we
+// haven't insert an entry into module_name_to_filtered_index with the
+// index where we will insert it if it isn't in the vector already.
+std::tie(iter, inserted) = module_name_to_filtered_index.try_emplace(
+module_name, filtered_modules.size());
+
+if (inserted) {
+  // This module has not been seen yet, insert it into filtered_modules at
+  // the index that was inserted into module_name_to_filtered_index using
+  // "filtered_modules.size()" above.
+  filtered_modules.push_back(&module);
+} else {
+  // This module has been seen. Modules are sometimes mentioned multiple
+  // times when they are mapped disc

[Lldb-commits] [PATCH] D55116: [CMake] llvm_codesign workaround for Xcode double-signing errors

2018-12-13 Thread Phabricator via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL349070: [CMake] llvm_codesign workaround for Xcode 
double-signing errors (authored by stefan.graenitz, committed by ).
Herald added a subscriber: michaelplatings.

Repository:
  rL LLVM

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

https://reviews.llvm.org/D55116

Files:
  llvm/trunk/cmake/modules/AddLLVM.cmake


Index: llvm/trunk/cmake/modules/AddLLVM.cmake
===
--- llvm/trunk/cmake/modules/AddLLVM.cmake
+++ llvm/trunk/cmake/modules/AddLLVM.cmake
@@ -584,7 +584,7 @@
 
   if(ARG_SHARED OR ARG_MODULE)
 llvm_externalize_debuginfo(${name})
-llvm_codesign(TARGET ${name})
+llvm_codesign(${name})
   endif()
 endfunction()
 
@@ -796,7 +796,7 @@
 target_link_libraries(${name} PRIVATE ${LLVM_PTHREAD_LIB})
   endif()
 
-  llvm_codesign(TARGET ${name} ENTITLEMENTS ${ARG_ENTITLEMENTS})
+  llvm_codesign(${name} ENTITLEMENTS ${ARG_ENTITLEMENTS})
 endmacro(add_llvm_executable name)
 
 function(export_executable_symbols target)
@@ -1635,13 +1635,9 @@
   endif()
 endfunction()
 
-# Usage: llvm_codesign(TARGET name [ENTITLEMENTS file])
-#
-# Code-sign the given TARGET with the global LLVM_CODESIGNING_IDENTITY or skip
-# if undefined. Customize capabilities by passing a file path to ENTITLEMENTS.
-#
-function(llvm_codesign)
-  cmake_parse_arguments(ARG "" "TARGET;ENTITLEMENTS" "" ${ARGN})
+# Usage: llvm_codesign(name [ENTITLEMENTS file])
+function(llvm_codesign name)
+  cmake_parse_arguments(ARG "" "ENTITLEMENTS" "" ${ARGN})
 
   if(NOT LLVM_CODESIGNING_IDENTITY)
 return()
@@ -1659,15 +1655,20 @@
   )
 endif()
 if(DEFINED ARG_ENTITLEMENTS)
-  set(PASS_ENTITLEMENTS --entitlements ${ARG_ENTITLEMENTS})
+  set(pass_entitlements --entitlements ${ARG_ENTITLEMENTS})
+endif()
+if(CMAKE_GENERATOR STREQUAL "Xcode")
+  # Avoid double-signing error: Since output overwrites input, Xcode runs
+  # the post-build rule even if the actual build-step was skipped.
+  set(pass_force --force)
 endif()
 
 add_custom_command(
-  TARGET ${ARG_TARGET} POST_BUILD
+  TARGET ${name} POST_BUILD
   COMMAND ${CMAKE_COMMAND} -E
   env CODESIGN_ALLOCATE=${CMAKE_CODESIGN_ALLOCATE}
   ${CMAKE_CODESIGN} -s ${LLVM_CODESIGNING_IDENTITY}
-  ${PASS_ENTITLEMENTS} $
+  ${pass_entitlements} ${pass_force} $
 )
   endif()
 endfunction()


Index: llvm/trunk/cmake/modules/AddLLVM.cmake
===
--- llvm/trunk/cmake/modules/AddLLVM.cmake
+++ llvm/trunk/cmake/modules/AddLLVM.cmake
@@ -584,7 +584,7 @@
 
   if(ARG_SHARED OR ARG_MODULE)
 llvm_externalize_debuginfo(${name})
-llvm_codesign(TARGET ${name})
+llvm_codesign(${name})
   endif()
 endfunction()
 
@@ -796,7 +796,7 @@
 target_link_libraries(${name} PRIVATE ${LLVM_PTHREAD_LIB})
   endif()
 
-  llvm_codesign(TARGET ${name} ENTITLEMENTS ${ARG_ENTITLEMENTS})
+  llvm_codesign(${name} ENTITLEMENTS ${ARG_ENTITLEMENTS})
 endmacro(add_llvm_executable name)
 
 function(export_executable_symbols target)
@@ -1635,13 +1635,9 @@
   endif()
 endfunction()
 
-# Usage: llvm_codesign(TARGET name [ENTITLEMENTS file])
-#
-# Code-sign the given TARGET with the global LLVM_CODESIGNING_IDENTITY or skip
-# if undefined. Customize capabilities by passing a file path to ENTITLEMENTS.
-#
-function(llvm_codesign)
-  cmake_parse_arguments(ARG "" "TARGET;ENTITLEMENTS" "" ${ARGN})
+# Usage: llvm_codesign(name [ENTITLEMENTS file])
+function(llvm_codesign name)
+  cmake_parse_arguments(ARG "" "ENTITLEMENTS" "" ${ARGN})
 
   if(NOT LLVM_CODESIGNING_IDENTITY)
 return()
@@ -1659,15 +1655,20 @@
   )
 endif()
 if(DEFINED ARG_ENTITLEMENTS)
-  set(PASS_ENTITLEMENTS --entitlements ${ARG_ENTITLEMENTS})
+  set(pass_entitlements --entitlements ${ARG_ENTITLEMENTS})
+endif()
+if(CMAKE_GENERATOR STREQUAL "Xcode")
+  # Avoid double-signing error: Since output overwrites input, Xcode runs
+  # the post-build rule even if the actual build-step was skipped.
+  set(pass_force --force)
 endif()
 
 add_custom_command(
-  TARGET ${ARG_TARGET} POST_BUILD
+  TARGET ${name} POST_BUILD
   COMMAND ${CMAKE_COMMAND} -E
   env CODESIGN_ALLOCATE=${CMAKE_CODESIGN_ALLOCATE}
   ${CMAKE_CODESIGN} -s ${LLVM_CODESIGNING_IDENTITY}
-  ${PASS_ENTITLEMENTS} $
+  ${pass_entitlements} ${pass_force} $
 )
   endif()
 endfunction()
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D55522: Cache memory regions in ProcessMinidump and use the linux maps as the source of the information if available.

2018-12-14 Thread Phabricator via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL349182: Cache memory regions in ProcessMinidump and use the 
linux maps as the source of… (authored by gclayton, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D55522?vs=178168&id=178260#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D55522

Files:
  lldb/trunk/include/lldb/Target/MemoryRegionInfo.h
  lldb/trunk/lldb.xcodeproj/project.pbxproj
  lldb/trunk/source/Plugins/Process/Utility/CMakeLists.txt
  lldb/trunk/source/Plugins/Process/Utility/LinuxProcMaps.cpp
  lldb/trunk/source/Plugins/Process/Utility/LinuxProcMaps.h
  lldb/trunk/source/Plugins/Process/minidump/MinidumpParser.cpp
  lldb/trunk/source/Plugins/Process/minidump/MinidumpParser.h
  lldb/trunk/source/Plugins/Process/minidump/MinidumpTypes.h
  lldb/trunk/source/Plugins/Process/minidump/ProcessMinidump.cpp
  lldb/trunk/unittests/Process/minidump/Inputs/regions-linux-map.dmp
  lldb/trunk/unittests/Process/minidump/Inputs/regions-memlist.dmp
  lldb/trunk/unittests/Process/minidump/Inputs/regions-memlist64.dmp
  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
@@ -300,29 +300,120 @@
   EXPECT_FALSE(parser->FindMemoryRange(0x7ffe + 4096).hasValue());
 }
 
-void check_region_info(std::unique_ptr &parser,
-   const uint64_t addr, MemoryRegionInfo::OptionalBool read,
-   MemoryRegionInfo::OptionalBool write,
-   MemoryRegionInfo::OptionalBool exec) {
+void check_region(std::unique_ptr &parser,
+  lldb::addr_t addr, lldb::addr_t start, lldb::addr_t end,
+  MemoryRegionInfo::OptionalBool read,
+  MemoryRegionInfo::OptionalBool write,
+  MemoryRegionInfo::OptionalBool exec,
+  MemoryRegionInfo::OptionalBool mapped,
+  ConstString name = ConstString()) {
   auto range_info = parser->GetMemoryRegionInfo(addr);
-  ASSERT_TRUE(range_info.hasValue());
-  EXPECT_EQ(read, range_info->GetReadable());
-  EXPECT_EQ(write, range_info->GetWritable());
-  EXPECT_EQ(exec, range_info->GetExecutable());
+  EXPECT_EQ(start, range_info.GetRange().GetRangeBase());
+  EXPECT_EQ(end, range_info.GetRange().GetRangeEnd());
+  EXPECT_EQ(read, range_info.GetReadable());
+  EXPECT_EQ(write, range_info.GetWritable());
+  EXPECT_EQ(exec, range_info.GetExecutable());
+  EXPECT_EQ(mapped, range_info.GetMapped());
+  EXPECT_EQ(name, range_info.GetName());
+}
+
+// Same as above function where addr == start
+void check_region(std::unique_ptr &parser,
+  lldb::addr_t start, lldb::addr_t end,
+  MemoryRegionInfo::OptionalBool read,
+  MemoryRegionInfo::OptionalBool write,
+  MemoryRegionInfo::OptionalBool exec,
+  MemoryRegionInfo::OptionalBool mapped,
+  ConstString name = ConstString()) {
+  check_region(parser, start, start, end, read, write, exec, mapped, name);
 }
 
+
+constexpr auto yes = MemoryRegionInfo::eYes;
+constexpr auto no = MemoryRegionInfo::eNo;
+constexpr auto unknown = MemoryRegionInfo::eDontKnow;
+
 TEST_F(MinidumpParserTest, GetMemoryRegionInfo) {
   SetUpData("fizzbuzz_wow64.dmp");
 
-  const auto yes = MemoryRegionInfo::eYes;
-  const auto no = MemoryRegionInfo::eNo;
-
-  check_region_info(parser, 0x0, no, no, no);
-  check_region_info(parser, 0x1, yes, yes, no);
-  check_region_info(parser, 0x2, yes, yes, no);
-  check_region_info(parser, 0x3, yes, yes, no);
-  check_region_info(parser, 0x31000, no, no, no);
-  check_region_info(parser, 0x4, yes, no, no);
+  check_region(parser, 0x, 0x0001, no, no, no, no);
+  check_region(parser, 0x0001, 0x0002, yes, yes, no, yes);
+  check_region(parser, 0x0002, 0x0003, yes, yes, no, yes);
+  check_region(parser, 0x0003, 0x00031000, yes, yes, no, yes);
+  check_region(parser, 0x00031000, 0x0004, no, no, no, no);
+  check_region(parser, 0x0004, 0x00041000, yes, no, no, yes);
+
+  // Check addresses contained inside ranges
+  check_region(parser, 0x0001, 0x, 0x0001, no, no, no, no);
+  check_region(parser, 0x, 0x, 0x0001, no, no, no, no);
+  check_region(parser, 0x00010001, 0x0001, 0x0002, yes, yes, no, yes);
+  check_region(parser, 0x0001, 0x0001, 0x0002, yes, yes, no, yes);
+
+  // Test that an address after the last entry maps to rest of the memory space
+  check_region(parser, 0x7fff, 0x7fff, UINT64_MAX, no, no, no, no);
+}
+
+TEST_F(MinidumpParserTest, GetMe

[Lldb-commits] [PATCH] D55559: Remove the Disassembly benchmarks.

2018-12-14 Thread Phabricator via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rLLDB349194: Remove the Disassembly benchmarks. (authored by 
adrian, committed by ).

Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D9

Files:
  packages/Python/lldbsuite/test/benchmarks/disassembly/TestDisassembly.py
  
packages/Python/lldbsuite/test/benchmarks/disassembly/TestDoAttachThenDisassembly.py
  
packages/Python/lldbsuite/test/benchmarks/disassembly/TestXcode41Vs42GDBDisassembly.py

Index: packages/Python/lldbsuite/test/benchmarks/disassembly/TestDoAttachThenDisassembly.py
===
--- packages/Python/lldbsuite/test/benchmarks/disassembly/TestDoAttachThenDisassembly.py
+++ packages/Python/lldbsuite/test/benchmarks/disassembly/TestDoAttachThenDisassembly.py
@@ -1,70 +0,0 @@
-"""Test lldb's disassemblt speed.  This bench deliberately attaches to an lldb
-inferior and traverses the stack for thread0 to arrive at frame with function
-'MainLoop'.  It is important to specify an lldb executable as the inferior."""
-
-from __future__ import print_function
-
-
-import os
-import sys
-import lldb
-from lldbsuite.test.decorators import *
-from lldbsuite.test.lldbbench import *
-from lldbsuite.test.lldbtest import *
-
-
-class AttachThenDisassemblyBench(BenchBase):
-
-mydir = TestBase.compute_mydir(__file__)
-
-def setUp(self):
-BenchBase.setUp(self)
-self.exe = lldbtest_config.lldbExec
-self.count = 10
-
-@benchmarks_test
-@no_debug_info_test
-def test_attach_then_disassembly(self):
-"""Attach to a spawned lldb process then run disassembly benchmarks."""
-print()
-self.run_lldb_attach_then_disassembly(self.exe, self.count)
-print("lldb disassembly benchmark:", self.stopwatch)
-
-def run_lldb_attach_then_disassembly(self, exe, count):
-target = self.dbg.CreateTarget(exe)
-
-# Spawn a new process and don't display the stdout if not in TraceOn()
-# mode.
-import subprocess
-popen = subprocess.Popen([exe, self.lldbOption], stdout=open(
-os.devnull, 'w') if not self.TraceOn() else None)
-if self.TraceOn():
-print("pid of spawned process: %d" % popen.pid)
-
-# Attach to the launched lldb process.
-listener = lldb.SBListener("my.attach.listener")
-error = lldb.SBError()
-process = target.AttachToProcessWithID(listener, popen.pid, error)
-
-# Set thread0 as the selected thread, followed by the 'MainLoop' frame
-# as the selected frame.  Then do disassembly on the function.
-thread0 = process.GetThreadAtIndex(0)
-process.SetSelectedThread(thread0)
-i = 0
-found = False
-for f in thread0:
-# print("frame#%d %s" % (i, f.GetFunctionName()))
-if "MainLoop" in f.GetFunctionName():
-found = True
-thread0.SetSelectedFrame(i)
-if self.TraceOn():
-print("Found frame#%d for function 'MainLoop'" % i)
-break
-i += 1
-
-# Reset the stopwatch now.
-self.stopwatch.reset()
-for i in range(count):
-with self.stopwatch:
-# Disassemble the function.
-self.runCmd("disassemble -f")
Index: packages/Python/lldbsuite/test/benchmarks/disassembly/TestXcode41Vs42GDBDisassembly.py
===
--- packages/Python/lldbsuite/test/benchmarks/disassembly/TestXcode41Vs42GDBDisassembly.py
+++ packages/Python/lldbsuite/test/benchmarks/disassembly/TestXcode41Vs42GDBDisassembly.py
@@ -1,120 +0,0 @@
-"""Disassemble lldb's Driver::MainLoop() functions comparing Xcode 4.1 vs. 4.2's gdb."""
-
-from __future__ import print_function
-
-
-import os
-import sys
-import lldb
-from lldbsuite.test.decorators import *
-from lldbsuite.test.lldbbench import *
-from lldbsuite.test.lldbtest import *
-from lldbsuite.test import configuration
-from lldbsuite.test import lldbutil
-
-
-class XCode41Vs42GDBDisassembly(BenchBase):
-
-mydir = TestBase.compute_mydir(__file__)
-
-def setUp(self):
-BenchBase.setUp(self)
-self.gdb_41_exe = '/Xcode41/usr/bin/gdb'
-self.gdb_42_exe = '/Developer/usr/bin/gdb'
-self.exe = lldbtest_config.lldbExec
-self.function = 'Driver::MainLoop()'
-self.gdb_41_avg = None
-self.gdb_42_avg = None
-self.count = 5
-
-@benchmarks_test
-@no_debug_info_test
-@expectedFailureAll(
-oslist=["windows"],
-bugnumber="llvm.org/pr22274: need a pexpect replacement for windows")
-def test_run_41_then_42(self):
-"""Test disassembly on a large function with 4.1 vs. 4.2's gdb."""
-print()
-self.run_gdb_disassembly(
-self.gdb_41_exe,

[Lldb-commits] [PATCH] D55608: Make crashlog.py work or binaries with spaces in their names

2018-12-17 Thread Phabricator 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 rL349367: Make crashlog.py work or binaries with spaces in 
their names (authored by adrian, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D55608?vs=178476&id=178481#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D55608

Files:
  lldb/trunk/examples/python/crashlog.py
  lldb/trunk/lit/Python/crashlog.test

Index: lldb/trunk/lit/Python/crashlog.test
===
--- lldb/trunk/lit/Python/crashlog.test
+++ lldb/trunk/lit/Python/crashlog.test
@@ -0,0 +1,99 @@
+# -*- python -*-
+# RUN: cd %S/../../examples/python && %lldb -S %s | FileCheck %s
+# REQUIRES : system-darwin
+# CHECK-LABEL: {{S}}KIP BEYOND CHECKS
+script
+import crashlog
+cl = crashlog.CrashLog
+images = [
+"0x10b60b000 - 0x10f707fff com.apple.LLDB.framework (1.1000.11.38.2 - 1000.11.38.2) <96E36F5C-1A83-39A1-8713-5FDD9701C3F1> /Applications/Xcode.app/Contents/SharedFrameworks/LLDB.framework/LLDB",
+# CHECK: 0x10b60b000
+# CHECK: 0x10f707fff
+# CHECK: com.apple.LLDB.framework
+# CHECK: 96E36F5C-1A83-39A1-8713-5FDD9701C3F1
+# CHECK: /Applications/Xcode.app/Contents/SharedFrameworks/LLDB.framework/LLDB
+
+"0x104591000 - 0x1055cfff7 +llvm-dwarfdump (0)  /Users/USER 1/Documents/*/llvm-dwarfdump",
+# CHECK: 0x104591000
+# CHECK: 0x1055cfff7
+# CHECK: llvm-dwarfdump
+# CHECK: (0)
+# CHECK: B104CFA1-046A-36A6-8EB4-07DDD7CC2DF3
+# CHECK: /Users/USER 1/Documents/*/llvm-dwarfdump
+
+"0x7fff63f2 - 0x7fff63f77ff7  libc++.1.dylib (400.9.4)  /usr/lib/libc++.1.dylib",
+# CHECK: 0x7fff63f2
+# CHECK: 0x7fff63f77ff7
+# CHECK: libc++.1.dylib
+# CHECK: (400.9.4)
+# CHECK: D4AB366F-48A9-3C7D-91BD-41198F69DD57
+# CHECK: /usr/lib/libc++.1.dylib
+
+"0x111 - 0x2 +MyApp Pro arm64  <01234> /tmp/MyApp Pro.app/MyApp Pro",
+# CHECK: 0x111
+# CHECK: 0x2
+# CHECK: MyApp Pro arm64
+# CHECK: None
+# CHECK: 01234
+# CHECK: /tmp/MyApp Pro.app/MyApp Pro
+
+"0x111 - 0x2 +MyApp Pro (0) <01234> /tmp/MyApp Pro.app/MyApp Pro",
+# CHECK: 0x111
+# CHECK: 0x2
+# CHECK: MyApp Pro
+# CHECK: (0)
+# CHECK: 01234
+# CHECK: /tmp/MyApp Pro.app/MyApp Pro
+
+"0x7fff63f2 - 0x7fff63f77ff7  libc++.1.dylib (400.9.4) /usr/lib/libc++.1.dylib"
+# CHECK: 0x7fff63f2
+# CHECK: 0x7fff63f77ff7
+# CHECK: libc++.1.dylib
+# CHECK: (400.9.4)
+# CHECK: None
+# CHECK: /usr/lib/libc++.1.dylib
+]
+# CHECK-LABEL: FRAMES
+frames = [
+"0 libsystem_kernel.dylib	0x7fff684b78a6 read + 10",
+# CHECK: 0
+# CHECK: libsystem_kernel.dylib
+# CHECK: 0x7fff684b78a6
+# CHECK: read + 10
+"1   com.apple.LLDB.framework  	0x00010f7954af lldb_private::HostNativeThreadBase::ThreadCreateTrampoline(void*) + 105",
+# CHECK: 1
+# CHECK: com.apple.LLDB.framework
+# CHECK: 0x00010f7954af
+# CHECK: lldb_private{{.*}} + 105
+"2   MyApp Pro arm64	0x00019b0db3a8 foo + 72",
+# CHECK: 2
+# CHECK: MyApp Pro arm64
+# CHECK: 0x00019b0db3a8
+# CHECK: foo + 72
+"3   He 0x1	0x00019b0db3a8 foo + 72"
+# CHECK: 3
+# CHECK: He 0x1
+# CHECK: 0x00019b0db3a8
+# CHECK: foo + 72
+]
+
+
+# Avoid matching the text inside the input.
+print("SKIP BEYOND CHECKS")
+for image in images:
+print('"%s"'%image)
+print("--")
+match = cl.image_regex_uuid.search(image)
+for group in match.groups():
+print(group)
+
+print("FRAMES")
+for frame in frames:
+print('"%s"'%frame)
+print("--")
+match = cl.frame_regex.search(frame)
+for group in match.groups():
+print(group)
+
+exit()
+quit
Index: lldb/trunk/examples/python/crashlog.py
===
--- lldb/trunk/examples/python/crashlog.py
+++ lldb/trunk/examples/python/crashlog.py
@@ -94,11 +94,9 @@
 thread_regex = re.compile('^Thread ([0-9]+)([^:]*):(.*)')
 app_backtrace_regex = re.compile(
 '^Application Specific Backtrace ([0-9]+)([^:]*):(.*)')
-frame_regex = re.compile('^([0-9]+)\s+([^ ]+)\s+(0x[0-9a-fA-F]+) +(.*)')
+frame_regex = re.compile('^([0-9]+)\s+(.+?)\s+(0x[0-9a-fA-F]{7}[0-9a-fA-F]+) +(.*)')
 image_regex_uuid = re.compile(
-'(0x[0-9a-fA-F]+)[- ]+(0x[0-9a-fA-F]+) +[+]?([^ ]+) +([^<]+)<([-0-9a-fA-F]+)> (.*)')
-image_regex_no_uuid = re.compile(
-'(0x[0-9a-fA-F]+)[- ]+(0x[0-9a-fA-F]+) +[+]?([^ ]+) +([^/]+)/(.*)')
+'(0x[0-9a-fA-F]+)[-\s]+(0x[0-9a-fA-F]+)\s+[+]?(.+?)\s+(\(.+\))?\s?(<([-0-9a-fA-F]+)>)? (.*)')
 empty_line_regex = re.compile('^$')
 
 class Thread:
@@ -477,25 +475,16 @@
 elif parse_mode == PARSE_MODE_IMAGES:
 image_match = self.image_regex_uuid.search(line)
 if ima

[Lldb-commits] [PATCH] D55607: Make crashlog.py work when a .dSYM is present, but a binary is missing

2018-12-17 Thread Phabricator via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL349366: Make crashlog.py work when a .dSYM is present, but a 
binary is missing (authored by adrian, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D55607?vs=177886&id=178480#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D55607

Files:
  lldb/trunk/examples/python/crashlog.py


Index: lldb/trunk/examples/python/crashlog.py
===
--- lldb/trunk/examples/python/crashlog.py
+++ lldb/trunk/examples/python/crashlog.py
@@ -246,6 +246,25 @@
 self.identifier = identifier
 self.version = version
 
+def find_matching_slice(self):
+dwarfdump_cmd_output = commands.getoutput(
+'dwarfdump --uuid "%s"' % self.path)
+self_uuid = self.get_uuid()
+for line in dwarfdump_cmd_output.splitlines():
+match = self.dwarfdump_uuid_regex.search(line)
+if match:
+dwarf_uuid_str = match.group(1)
+dwarf_uuid = uuid.UUID(dwarf_uuid_str)
+if self_uuid == dwarf_uuid:
+self.resolved_path = self.path
+self.arch = match.group(2)
+return True
+if not self.resolved_path:
+self.unavailable = True
+print("error\nerror: unable to locate '%s' with UUID %s"
+  % (self.path, uuid_str))
+return False
+
 def locate_module_and_debug_symbols(self):
 # Don't load a module twice...
 if self.resolved:
@@ -277,22 +296,25 @@
 plist['DBGSymbolRichExecutable'])
 self.resolved_path = self.path
 if not self.resolved_path and os.path.exists(self.path):
-dwarfdump_cmd_output = commands.getoutput(
-'dwarfdump --uuid "%s"' % self.path)
-self_uuid = self.get_uuid()
-for line in dwarfdump_cmd_output.splitlines():
-match = self.dwarfdump_uuid_regex.search(line)
-if match:
-dwarf_uuid_str = match.group(1)
-dwarf_uuid = uuid.UUID(dwarf_uuid_str)
-if self_uuid == dwarf_uuid:
-self.resolved_path = self.path
-self.arch = match.group(2)
-break
-if not self.resolved_path:
-self.unavailable = True
-print "error\nerror: unable to locate '%s' with UUID 
%s" % (self.path, uuid_str)
+if not self.find_matching_slice():
 return False
+if not self.resolved_path and not os.path.exists(self.path):
+try:
+import subprocess
+dsym = subprocess.check_output(
+["/usr/bin/mdfind",
+ "com_apple_xcode_dsym_uuids == %s"%uuid_str])[:-1]
+if dsym and os.path.exists(dsym):
+print('falling back to binary inside "%s"'%dsym)
+self.symfile = dsym
+dwarf_dir = os.path.join(dsym, 
'Contents/Resources/DWARF')
+for filename in os.listdir(dwarf_dir):
+self.path = os.path.join(dwarf_dir, filename)
+if not self.find_matching_slice():
+return False
+break
+except:
+pass
 if (self.resolved_path and os.path.exists(self.resolved_path)) or (
 self.path and os.path.exists(self.path)):
 print 'ok'


Index: lldb/trunk/examples/python/crashlog.py
===
--- lldb/trunk/examples/python/crashlog.py
+++ lldb/trunk/examples/python/crashlog.py
@@ -246,6 +246,25 @@
 self.identifier = identifier
 self.version = version
 
+def find_matching_slice(self):
+dwarfdump_cmd_output = commands.getoutput(
+'dwarfdump --uuid "%s"' % self.path)
+self_uuid = self.get_uuid()
+for line in dwarfdump_cmd_output.splitlines():
+match = self.dwarfdump_uuid_regex.search(line)
+if match:
+dwarf_uuid_str = match.group(1)
+dwarf_uuid = uuid.UUID(dwarf_uuid_str)
+if self_uuid == dwarf_uuid:
+self.resolved_path = self.path
+self.arch = match.group(2)
+   

[Lldb-commits] [PATCH] D55727: Add "dump" command as a custom "process plugin" subcommand when ProcessMinidump is used.

2018-12-17 Thread Phabricator via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rLLDB349429: Add "dump" command as a custom 
"process plugin" subcommand when ProcessMinidump… (authored by 
gclayton, committed by ).
Herald added a subscriber: abidh.

Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D55727

Files:
  lit/Minidump/Inputs/dump-content.dmp
  lit/Minidump/dump-all.test
  source/Plugins/Process/minidump/MinidumpParser.cpp
  source/Plugins/Process/minidump/MinidumpParser.h
  source/Plugins/Process/minidump/MinidumpTypes.h
  source/Plugins/Process/minidump/ProcessMinidump.cpp
  source/Plugins/Process/minidump/ProcessMinidump.h
  unittests/Process/minidump/Inputs/dump-content.dmp

Index: source/Plugins/Process/minidump/MinidumpParser.h
===
--- source/Plugins/Process/minidump/MinidumpParser.h
+++ source/Plugins/Process/minidump/MinidumpParser.h
@@ -90,6 +90,13 @@
   // Perform consistency checks and initialize internal data structures
   Status Initialize();
 
+  static llvm::StringRef GetStreamTypeAsString(uint32_t stream_type);
+
+  const llvm::DenseMap &
+  GetDirectoryMap() const {
+return m_directory_map;
+  }
+
 private:
   MinidumpParser(const lldb::DataBufferSP &data_buf_sp);
 
Index: source/Plugins/Process/minidump/MinidumpParser.cpp
===
--- source/Plugins/Process/minidump/MinidumpParser.cpp
+++ source/Plugins/Process/minidump/MinidumpParser.cpp
@@ -660,3 +660,48 @@
 
   return error;
 }
+
+#define ENUM_TO_CSTR(ST) case (uint32_t)MinidumpStreamType::ST: return #ST
+
+llvm::StringRef
+MinidumpParser::GetStreamTypeAsString(uint32_t stream_type) {
+  switch (stream_type) {
+ENUM_TO_CSTR(Unused);
+ENUM_TO_CSTR(Reserved0);
+ENUM_TO_CSTR(Reserved1);
+ENUM_TO_CSTR(ThreadList);
+ENUM_TO_CSTR(ModuleList);
+ENUM_TO_CSTR(MemoryList);
+ENUM_TO_CSTR(Exception);
+ENUM_TO_CSTR(SystemInfo);
+ENUM_TO_CSTR(ThreadExList);
+ENUM_TO_CSTR(Memory64List);
+ENUM_TO_CSTR(CommentA);
+ENUM_TO_CSTR(CommentW);
+ENUM_TO_CSTR(HandleData);
+ENUM_TO_CSTR(FunctionTable);
+ENUM_TO_CSTR(UnloadedModuleList);
+ENUM_TO_CSTR(MiscInfo);
+ENUM_TO_CSTR(MemoryInfoList);
+ENUM_TO_CSTR(ThreadInfoList);
+ENUM_TO_CSTR(HandleOperationList);
+ENUM_TO_CSTR(Token);
+ENUM_TO_CSTR(JavascriptData);
+ENUM_TO_CSTR(SystemMemoryInfo);
+ENUM_TO_CSTR(ProcessVMCounters);
+ENUM_TO_CSTR(BreakpadInfo);
+ENUM_TO_CSTR(AssertionInfo);
+ENUM_TO_CSTR(LinuxCPUInfo);
+ENUM_TO_CSTR(LinuxProcStatus);
+ENUM_TO_CSTR(LinuxLSBRelease);
+ENUM_TO_CSTR(LinuxCMDLine);
+ENUM_TO_CSTR(LinuxEnviron);
+ENUM_TO_CSTR(LinuxAuxv);
+ENUM_TO_CSTR(LinuxMaps);
+ENUM_TO_CSTR(LinuxDSODebug);
+ENUM_TO_CSTR(LinuxProcStat);
+ENUM_TO_CSTR(LinuxProcUptime);
+ENUM_TO_CSTR(LinuxProcFD);
+  }
+  return "unknown stream type";
+}
Index: source/Plugins/Process/minidump/ProcessMinidump.h
===
--- source/Plugins/Process/minidump/ProcessMinidump.h
+++ source/Plugins/Process/minidump/ProcessMinidump.h
@@ -49,6 +49,8 @@
   bool CanDebug(lldb::TargetSP target_sp,
 bool plugin_specified_by_name) override;
 
+  CommandObject *GetPluginCommandObject() override;
+
   Status DoLoadCore() override;
 
   DynamicLoader *GetDynamicLoader() override { return nullptr; }
@@ -104,6 +106,7 @@
   FileSpec m_core_file;
   llvm::ArrayRef m_thread_list;
   const MinidumpExceptionStream *m_active_exception;
+  lldb::CommandObjectSP m_command_sp;
   bool m_is_wow64;
 };
 
Index: source/Plugins/Process/minidump/ProcessMinidump.cpp
===
--- source/Plugins/Process/minidump/ProcessMinidump.cpp
+++ source/Plugins/Process/minidump/ProcessMinidump.cpp
@@ -10,10 +10,17 @@
 #include "ProcessMinidump.h"
 #include "ThreadMinidump.h"
 
+#include "lldb/Core/DumpDataExtractor.h"
 #include "lldb/Core/Module.h"
 #include "lldb/Core/ModuleSpec.h"
 #include "lldb/Core/PluginManager.h"
 #include "lldb/Core/Section.h"
+#include "lldb/Interpreter/CommandInterpreter.h"
+#include "lldb/Interpreter/CommandObject.h"
+#include "lldb/Interpreter/CommandObjectMultiword.h"
+#include "lldb/Interpreter/CommandReturnObject.h"
+#include "lldb/Interpreter/OptionArgParser.h"
+#include "lldb/Interpreter/OptionGroupBoolean.h"
 #include "lldb/Target/JITLoaderList.h"
 #include "lldb/Target/MemoryRegionInfo.h"
 #include "lldb/Target/SectionLoadList.h"
@@ -398,3 +405,237 @@
   }
   return *m_jit_loaders_ap;
 }
+
+#define INIT_BOOL(VAR, LONG, SHORT, DESC) \
+VAR(LLDB_OPT_SET_1, false, LONG, SHORT, DESC, false, true)
+#define APPEND_OPT(VAR) \
+m_option_group.Append(&VAR, LLDB_OPT_SET_ALL, LLDB_OPT_SET_1)
+
+class CommandObjectProcessMinidumpDump : public CommandObjectPar

[Lldb-commits] [PATCH] D55854: Show the memory region name if there is one in the output of the "memory region" command

2018-12-19 Thread Phabricator via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rLLDB349658: Show the memory region name if there is one in 
the output of the "memory… (authored by gclayton, committed by ).
Herald added a subscriber: abidh.

Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D55854

Files:
  
packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/TestMiniDumpNew.py
  
packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/regions-linux-map.dmp
  source/Commands/CommandObjectMemory.cpp


Index: 
packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/TestMiniDumpNew.py
===
--- 
packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/TestMiniDumpNew.py
+++ 
packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/TestMiniDumpNew.py
@@ -88,6 +88,36 @@
 self.assertEqual(self.process.GetProcessID(), self._linux_x86_64_pid)
 self.check_state()
 
+def test_memory_region_name(self):
+self.dbg.CreateTarget(None)
+self.target = self.dbg.GetSelectedTarget()
+self.process = self.target.LoadCore("regions-linux-map.dmp")
+result = lldb.SBCommandReturnObject()
+addr_region_name_pairs = [
+("0x400d9000", "/system/bin/app_process"),
+("0x400db000", "/system/bin/app_process"),
+("0x400dd000", "/system/bin/linker"),
+("0x400ed000", "/system/bin/linker"),
+("0x400ee000", "/system/bin/linker"),
+("0x400fb000", "/system/lib/liblog.so"),
+("0x400fc000", "/system/lib/liblog.so"),
+("0x400fd000", "/system/lib/liblog.so"),
+("0x400ff000", "/system/lib/liblog.so"),
+("0x4010", "/system/lib/liblog.so"),
+("0x40101000", "/system/lib/libc.so"),
+("0x40122000", "/system/lib/libc.so"),
+("0x40123000", "/system/lib/libc.so"),
+("0x40167000", "/system/lib/libc.so"),
+("0x40169000", "/system/lib/libc.so"),
+]
+ci = self.dbg.GetCommandInterpreter()
+for (addr, region_name) in addr_region_name_pairs:
+command = 'memory region ' + addr
+ci.HandleCommand(command, result, False)
+message = 'Ensure memory "%s" shows up in output for "%s"' % (
+region_name, command)
+self.assertTrue(region_name in result.GetOutput(), message)
+
 def test_modules_in_mini_dump(self):
 """Test that lldb can read the list of modules from the minidump."""
 # target create -c linux-x86_64.dmp
Index: source/Commands/CommandObjectMemory.cpp
===
--- source/Commands/CommandObjectMemory.cpp
+++ source/Commands/CommandObjectMemory.cpp
@@ -1723,6 +1723,7 @@
 error = process_sp->GetMemoryRegionInfo(load_addr, range_info);
 if (error.Success()) {
   lldb_private::Address addr;
+  ConstString name = range_info.GetName();
   ConstString section_name;
   if (process_sp->GetTarget().ResolveLoadAddress(load_addr, addr)) {
 SectionSP section_sp(addr.GetSection());
@@ -1734,13 +1735,14 @@
 }
   }
   result.AppendMessageWithFormat(
-  "[0x%16.16" PRIx64 "-0x%16.16" PRIx64 ") %c%c%c%s%s\n",
+  "[0x%16.16" PRIx64 "-0x%16.16" PRIx64 ") %c%c%c%s%s%s%s\n",
   range_info.GetRange().GetRangeBase(),
   range_info.GetRange().GetRangeEnd(),
   range_info.GetReadable() ? 'r' : '-',
   range_info.GetWritable() ? 'w' : '-',
-  range_info.GetExecutable() ? 'x' : '-', section_name ? " " : "",
-  section_name ? section_name.AsCString() : "");
+  range_info.GetExecutable() ? 'x' : '-',
+  name ? " " : "", name.AsCString(""),
+  section_name ? " " : "", section_name.AsCString(""));
   m_prev_end_addr = range_info.GetRange().GetRangeEnd();
   result.SetStatus(eReturnStatusSuccessFinishResult);
 } else {


Index: packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/TestMiniDumpNew.py
===
--- packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/TestMiniDumpNew.py
+++ packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/TestMiniDumpNew.py
@@ -88,6 +88,36 @@
 self.assertEqual(self.process.GetProcessID(), self._linux_x86_64_pid)
 self.check_state()
 
+def test_memory_region_name(self):
+self.dbg.CreateTarget(None)
+self.target = self.dbg.GetSelectedTarget()
+self.process = self.target.LoadCore("regions-linux-map.dmp")
+result = lldb.SBCommandReturnObject()
+a

[Lldb-commits] [PATCH] D44072: [lldb] Retrieve currently handled Obj-C exception via __cxa_current_exception_type and add GetCurrentExceptionBacktrace SB ABI

2018-12-19 Thread Phabricator via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL349718: [lldb] Retrieve currently handled Obj-C exception 
via… (authored by kuba.brecka, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D44072?vs=178991&id=178999#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D44072

Files:
  lldb/trunk/include/lldb/API/SBThread.h
  lldb/trunk/include/lldb/Target/LanguageRuntime.h
  lldb/trunk/include/lldb/Target/Thread.h
  lldb/trunk/packages/Python/lldbsuite/test/lang/objc/exceptions/Makefile
  
lldb/trunk/packages/Python/lldbsuite/test/lang/objc/exceptions/TestObjCExceptions.py
  lldb/trunk/packages/Python/lldbsuite/test/lang/objc/exceptions/main.m
  lldb/trunk/packages/Python/lldbsuite/test/lang/objc/exceptions/main.mm
  lldb/trunk/scripts/interface/SBThread.i
  lldb/trunk/source/API/SBThread.cpp
  lldb/trunk/source/Commands/CommandObjectThread.cpp
  
lldb/trunk/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.cpp
  
lldb/trunk/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.h
  
lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp
  
lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.h
  lldb/trunk/source/Target/Thread.cpp

Index: lldb/trunk/scripts/interface/SBThread.i
===
--- lldb/trunk/scripts/interface/SBThread.i
+++ lldb/trunk/scripts/interface/SBThread.i
@@ -397,6 +397,24 @@
 ") GetExtendedBacktraceOriginatingIndexID;
 uint32_t
 GetExtendedBacktraceOriginatingIndexID();
+
+%feature("autodoc","
+Returns an SBValue object represeting the current exception for the thread,
+if there is any. Currently, this works for Obj-C code and returns an SBValue
+representing the NSException object at the throw site or that's currently
+being processes.
+") GetCurrentException;
+lldb::SBValue
+GetCurrentException();
+
+%feature("autodoc","
+Returns a historical (fake) SBThread representing the stack trace of an
+exception, if there is one for the thread. Currently, this works for Obj-C
+code, and can retrieve the throw-site backtrace of an NSException object
+even when the program is no longer at the throw site.
+") GetCurrentExceptionBacktrace;
+lldb::SBThread
+GetCurrentExceptionBacktrace();
 
 %feature("autodoc","
 Takes no arguments, returns a bool.
Index: lldb/trunk/include/lldb/Target/Thread.h
===
--- lldb/trunk/include/lldb/Target/Thread.h
+++ lldb/trunk/include/lldb/Target/Thread.h
@@ -1255,8 +1255,7 @@
 
   lldb::ValueObjectSP GetCurrentException();
 
-  // TODO(kubamracek): Extract backtrace from ValueObjectSP into ThreadSP
-  // lldb::ThreadSP GetCurrentExceptionBacktrace();
+  lldb::ThreadSP GetCurrentExceptionBacktrace();
 
 protected:
   friend class ThreadPlan;
Index: lldb/trunk/include/lldb/Target/LanguageRuntime.h
===
--- lldb/trunk/include/lldb/Target/LanguageRuntime.h
+++ lldb/trunk/include/lldb/Target/LanguageRuntime.h
@@ -119,6 +119,17 @@
   static Breakpoint::BreakpointPreconditionSP
   CreateExceptionPrecondition(lldb::LanguageType language, bool catch_bp,
   bool throw_bp);
+
+  virtual lldb::ValueObjectSP GetExceptionObjectForThread(
+  lldb::ThreadSP thread_sp) {
+return lldb::ValueObjectSP();
+  }
+
+  virtual lldb::ThreadSP GetBacktraceThreadFromException(
+  lldb::ValueObjectSP thread_sp) {
+return lldb::ThreadSP();
+  }
+
   Process *GetProcess() { return m_process; }
 
   Target &GetTargetRef() { return m_process->GetTarget(); }
Index: lldb/trunk/include/lldb/API/SBThread.h
===
--- lldb/trunk/include/lldb/API/SBThread.h
+++ lldb/trunk/include/lldb/API/SBThread.h
@@ -200,8 +200,7 @@
 
   SBValue GetCurrentException();
 
-  // TODO(kubamracek): Extract backtrace from SBValue into SBThread
-  // SBThread GetCurrentExceptionBacktrace();
+  SBThread GetCurrentExceptionBacktrace();
 
   bool SafeToCallFunctions();
 
Index: lldb/trunk/packages/Python/lldbsuite/test/lang/objc/exceptions/Makefile
===
--- lldb/trunk/packages/Python/lldbsuite/test/lang/objc/exceptions/Makefile
+++ lldb/trunk/packages/Python/lldbsuite/test/lang/objc/exceptions/Makefile
@@ -1,6 +1,6 @@
 LEVEL = ../../../make
 
-OBJC_SOURCES := main.m
+OBJCXX_SOURCES := main.mm
 
 CFLAGS_EXTRAS += -w
 
Index: lldb/trunk/packages/Python/lldbsuite/test/lang/objc/exceptions/main.mm
===
--- lldb/trunk/packages/Python/lldbsuite/test/lang/objc/excepti

[Lldb-commits] [PATCH] D55472: Speadup memory regions handling and cleanup related code

2018-12-20 Thread Phabricator via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rLLDB349766: Replace MemoryRegionInfoSP with values and 
cleanup related code (authored by tkrasnukha, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D55472?vs=178941&id=179072#toc

Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D55472

Files:
  include/lldb/API/SBMemoryRegionInfo.h
  include/lldb/API/SBMemoryRegionInfoList.h
  include/lldb/Target/MemoryRegionInfo.h
  include/lldb/Target/Process.h
  include/lldb/lldb-forward.h
  source/API/SBMemoryRegionInfoList.cpp
  source/API/SBProcess.cpp
  source/Target/Process.cpp

Index: source/API/SBMemoryRegionInfoList.cpp
===
--- source/API/SBMemoryRegionInfoList.cpp
+++ source/API/SBMemoryRegionInfoList.cpp
@@ -32,31 +32,47 @@
 return *this;
   }
 
-  uint32_t GetSize() { return m_regions.size(); }
+  size_t GetSize() const { return m_regions.size(); }
 
-  void Append(const lldb::SBMemoryRegionInfo &sb_region) {
+  void Reserve(size_t capacity) { return m_regions.reserve(capacity); }
+
+  void Append(const MemoryRegionInfo &sb_region) {
 m_regions.push_back(sb_region);
   }
 
   void Append(const MemoryRegionInfoListImpl &list) {
-for (auto val : list.m_regions)
+Reserve(GetSize() + list.GetSize());
+
+for (const auto &val : list.m_regions)
   Append(val);
   }
 
   void Clear() { m_regions.clear(); }
 
-  bool GetMemoryRegionInfoAtIndex(uint32_t index,
-  SBMemoryRegionInfo ®ion_info) {
+  bool GetMemoryRegionInfoAtIndex(size_t index,
+  MemoryRegionInfo ®ion_info) {
 if (index >= GetSize())
   return false;
 region_info = m_regions[index];
 return true;
   }
 
+  MemoryRegionInfos &Ref() { return m_regions; }
+
+  const MemoryRegionInfos &Ref() const { return m_regions; }
+
 private:
-  std::vector m_regions;
+  MemoryRegionInfos m_regions;
 };
 
+MemoryRegionInfos &SBMemoryRegionInfoList::ref() {
+  return m_opaque_ap->Ref();
+}
+
+const MemoryRegionInfos &SBMemoryRegionInfoList::ref() const {
+  return m_opaque_ap->Ref();
+}
+
 SBMemoryRegionInfoList::SBMemoryRegionInfoList()
 : m_opaque_ap(new MemoryRegionInfoListImpl()) {}
 
@@ -82,7 +98,7 @@
 uint32_t idx, SBMemoryRegionInfo ®ion_info) {
   Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
 
-  bool result = m_opaque_ap->GetMemoryRegionInfoAtIndex(idx, region_info);
+  bool result = m_opaque_ap->GetMemoryRegionInfoAtIndex(idx, region_info.ref());
 
   if (log) {
 SBStream sstr;
@@ -100,7 +116,7 @@
 void SBMemoryRegionInfoList::Clear() { m_opaque_ap->Clear(); }
 
 void SBMemoryRegionInfoList::Append(SBMemoryRegionInfo &sb_region) {
-  m_opaque_ap->Append(sb_region);
+  m_opaque_ap->Append(sb_region.ref());
 }
 
 void SBMemoryRegionInfoList::Append(SBMemoryRegionInfoList &sb_region_list) {
Index: source/API/SBProcess.cpp
===
--- source/API/SBProcess.cpp
+++ source/API/SBProcess.cpp
@@ -1358,18 +1358,14 @@
SBMemoryRegionInfo &sb_region_info) {
   lldb::SBError sb_error;
   ProcessSP process_sp(GetSP());
-  MemoryRegionInfoSP region_info_sp =
-  std::make_shared();
   if (process_sp) {
 Process::StopLocker stop_locker;
 if (stop_locker.TryLock(&process_sp->GetRunLock())) {
   std::lock_guard guard(
   process_sp->GetTarget().GetAPIMutex());
+
   sb_error.ref() =
-  process_sp->GetMemoryRegionInfo(load_addr, *region_info_sp);
-  if (sb_error.Success()) {
-sb_region_info.ref() = *region_info_sp;
-  }
+  process_sp->GetMemoryRegionInfo(load_addr, sb_region_info.ref());
 } else {
   Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
   if (log)
@@ -1385,35 +1381,23 @@
 }
 
 lldb::SBMemoryRegionInfoList SBProcess::GetMemoryRegions() {
-  lldb::SBError sb_error;
   lldb::SBMemoryRegionInfoList sb_region_list;
+
   ProcessSP process_sp(GetSP());
-  if (process_sp) {
-Process::StopLocker stop_locker;
-if (stop_locker.TryLock(&process_sp->GetRunLock())) {
-  std::lock_guard guard(
-  process_sp->GetTarget().GetAPIMutex());
-  std::vector region_list;
-  sb_error.ref() = process_sp->GetMemoryRegions(region_list);
-  if (sb_error.Success()) {
-std::vector::iterator end = region_list.end();
-for (std::vector::iterator it = region_list.begin();
- it != end; it++) {
-  SBMemoryRegionInfo sb_region_info(it->get());
-  sb_region_list.Append(sb_region_info);
-}
-  }
-} else {
-  Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
-  if (log)
-log->Printf(
-"SBProcess(%p)::GetMemoryRegionInfo() => error: process is running",
-static_cast(proc

[Lldb-commits] [PATCH] D55841: GetMemoryRegions for the ProcessMinidump

2018-12-20 Thread Phabricator via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL349767: Overload GetMemoryRegions for the ProcessMinidump 
(authored by tkrasnukha, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D55841?vs=178931&id=179073#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D55841

Files:
  
lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/TestMiniDumpNew.py
  lldb/trunk/scripts/interface/SBMemoryRegionInfo.i
  lldb/trunk/source/Plugins/Process/minidump/MinidumpParser.cpp
  lldb/trunk/source/Plugins/Process/minidump/MinidumpParser.h
  lldb/trunk/source/Plugins/Process/minidump/MinidumpTypes.cpp
  lldb/trunk/source/Plugins/Process/minidump/ProcessMinidump.cpp
  lldb/trunk/source/Plugins/Process/minidump/ProcessMinidump.h

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
@@ -242,6 +242,8 @@
 return {};
 
   std::vector result;
+  result.reserve(header->num_of_entries);
+
   for (uint64_t i = 0; i < header->num_of_entries; ++i) {
 result.push_back(reinterpret_cast(
 data.data() + i * header->size_of_entry));
Index: lldb/trunk/source/Plugins/Process/minidump/MinidumpParser.h
===
--- lldb/trunk/source/Plugins/Process/minidump/MinidumpParser.h
+++ lldb/trunk/source/Plugins/Process/minidump/MinidumpParser.h
@@ -12,6 +12,7 @@
 
 #include "MinidumpTypes.h"
 
+#include "lldb/Target/MemoryRegionInfo.h"
 #include "lldb/Utility/ArchSpec.h"
 #include "lldb/Utility/DataBuffer.h"
 #include "lldb/Utility/Status.h"
@@ -87,6 +88,8 @@
 
   MemoryRegionInfo GetMemoryRegionInfo(lldb::addr_t load_addr);
 
+  const MemoryRegionInfos &GetMemoryRegions();
+
   // Perform consistency checks and initialize internal data structures
   Status Initialize();
 
@@ -106,7 +109,7 @@
   lldb::DataBufferSP m_data_sp;
   llvm::DenseMap m_directory_map;
   ArchSpec m_arch;
-  std::vector m_regions;
+  MemoryRegionInfos m_regions;
   bool m_parsed_regions = false;
 };
 
Index: lldb/trunk/source/Plugins/Process/minidump/MinidumpParser.cpp
===
--- lldb/trunk/source/Plugins/Process/minidump/MinidumpParser.cpp
+++ lldb/trunk/source/Plugins/Process/minidump/MinidumpParser.cpp
@@ -11,7 +11,6 @@
 #include "NtStructures.h"
 #include "RegisterContextMinidump_x86_32.h"
 
-#include "lldb/Target/MemoryRegionInfo.h"
 #include "lldb/Utility/LLDBAssert.h"
 #include "Plugins/Process/Utility/LinuxProcMaps.h"
 
@@ -537,6 +536,12 @@
 
 MemoryRegionInfo
 MinidumpParser::GetMemoryRegionInfo(lldb::addr_t load_addr) {
+  if (!m_parsed_regions)
+GetMemoryRegions();
+  return FindMemoryRegion(load_addr);
+}
+
+const MemoryRegionInfos &MinidumpParser::GetMemoryRegions() {
   if (!m_parsed_regions) {
 m_parsed_regions = true;
 // We haven't cached our memory regions yet we will create the region cache
@@ -552,7 +557,7 @@
   CreateRegionsCacheFromMemory64List(*this, m_regions);
 std::sort(m_regions.begin(), m_regions.end());
   }
-  return FindMemoryRegion(load_addr);
+  return m_regions;
 }
 
 Status MinidumpParser::Initialize() {
Index: lldb/trunk/source/Plugins/Process/minidump/ProcessMinidump.h
===
--- lldb/trunk/source/Plugins/Process/minidump/ProcessMinidump.h
+++ lldb/trunk/source/Plugins/Process/minidump/ProcessMinidump.h
@@ -80,6 +80,9 @@
   Status GetMemoryRegionInfo(lldb::addr_t load_addr,
  MemoryRegionInfo &range_info) override;
 
+  Status GetMemoryRegions(
+  lldb_private::MemoryRegionInfos ®ion_list) override;
+
   bool GetProcessInfo(ProcessInstanceInfo &info) override;
 
   Status WillResume() override {
Index: lldb/trunk/source/Plugins/Process/minidump/ProcessMinidump.cpp
===
--- lldb/trunk/source/Plugins/Process/minidump/ProcessMinidump.cpp
+++ lldb/trunk/source/Plugins/Process/minidump/ProcessMinidump.cpp
@@ -295,6 +295,12 @@
   return Status();
 }
 
+Status ProcessMinidump::GetMemoryRegions(
+lldb_private::MemoryRegionInfos ®ion_list) {
+  region_list = m_minidump_parser.GetMemoryRegions();
+  return Status();
+}
+
 void ProcessMinidump::Clear() { Process::m_thread_list.Clear(); }
 
 bool ProcessMinidump::UpdateThreadList(ThreadList &old_thread_list,
Index: lldb/trunk/scripts/interface/SBMemoryRegionInfo.i
===
--- lldb/trunk/scripts/interface/SBMemoryRegionInfo.i
+++ lldb/trunk/scripts/interface/SBMemoryRegionInfo.i
@@ -44,6 +44,9 @@
 bool
 IsMapped ();
 

[Lldb-commits] [PATCH] D55954: [lldb] Add a "display-recognized-arguments" target setting to show recognized arguments by default

2018-12-20 Thread Phabricator via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rLLDB349856: [lldb] Add a 
"display-recognized-arguments" target setting to show recognized… 
(authored by kuba.brecka, committed by ).

Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D55954

Files:
  include/lldb/API/SBTarget.h
  include/lldb/API/SBVariablesOptions.h
  include/lldb/Target/Target.h
  
packages/Python/lldbsuite/test/functionalities/frame-recognizer/TestFrameRecognizer.py
  scripts/interface/SBVariablesOptions.i
  source/API/SBFrame.cpp
  source/API/SBVariablesOptions.cpp
  source/Target/Target.cpp

Index: source/API/SBFrame.cpp
===
--- source/API/SBFrame.cpp
+++ source/API/SBFrame.cpp
@@ -957,7 +957,8 @@
 
   const bool statics = options.GetIncludeStatics();
   const bool arguments = options.GetIncludeArguments();
-  const bool recognized_arguments = options.GetIncludeRecognizedArguments();
+  const bool recognized_arguments =
+options.GetIncludeRecognizedArguments(SBTarget(exe_ctx.GetTargetSP()));
   const bool locals = options.GetIncludeLocals();
   const bool in_scope_only = options.GetInScopeOnly();
   const bool include_runtime_support_values =
Index: source/API/SBVariablesOptions.cpp
===
--- source/API/SBVariablesOptions.cpp
+++ source/API/SBVariablesOptions.cpp
@@ -9,6 +9,10 @@
 //===--===//
 
 #include "lldb/API/SBVariablesOptions.h"
+#include "lldb/API/SBTarget.h"
+#include "lldb/Target/Target.h"
+
+#include "lldb/lldb-private.h"
 
 using namespace lldb;
 using namespace lldb_private;
@@ -16,9 +20,10 @@
 class VariablesOptionsImpl {
 public:
   VariablesOptionsImpl()
-  : m_include_arguments(false), m_include_recognized_arguments(false),
-m_include_locals(false), m_include_statics(false),
-m_in_scope_only(false), m_include_runtime_support_values(false),
+  : m_include_arguments(false), m_include_locals(false),
+m_include_statics(false), m_in_scope_only(false),
+m_include_runtime_support_values(false),
+m_include_recognized_arguments(eLazyBoolCalculate),
 m_use_dynamic(lldb::eNoDynamicValues) {}
 
   VariablesOptionsImpl(const VariablesOptionsImpl &) = default;
@@ -31,12 +36,14 @@
 
   void SetIncludeArguments(bool b) { m_include_arguments = b; }
 
-  bool GetIncludeRecognizedArguments() const {
-return m_include_recognized_arguments;
+  bool GetIncludeRecognizedArguments(const lldb::TargetSP &target_sp) const {
+if (m_include_recognized_arguments != eLazyBoolCalculate)
+return m_include_recognized_arguments;
+return target_sp ? target_sp->GetDisplayRecognizedArguments() : false;
   }
 
   void SetIncludeRecognizedArguments(bool b) {
-m_include_recognized_arguments = b;
+m_include_recognized_arguments = b ? eLazyBoolYes : eLazyBoolNo;
   }
 
   bool GetIncludeLocals() const { return m_include_locals; }
@@ -65,11 +72,11 @@
 
 private:
   bool m_include_arguments : 1;
-  bool m_include_recognized_arguments : 1;
   bool m_include_locals : 1;
   bool m_include_statics : 1;
   bool m_in_scope_only : 1;
   bool m_include_runtime_support_values : 1;
+  LazyBool m_include_recognized_arguments; // can be overridden with a setting
   lldb::DynamicValueType m_use_dynamic;
 };
 
@@ -97,8 +104,9 @@
   m_opaque_ap->SetIncludeArguments(arguments);
 }
 
-bool SBVariablesOptions::GetIncludeRecognizedArguments() const {
-  return m_opaque_ap->GetIncludeRecognizedArguments();
+bool SBVariablesOptions::GetIncludeRecognizedArguments(
+const lldb::SBTarget &target) const {
+  return m_opaque_ap->GetIncludeRecognizedArguments(target.GetSP());
 }
 
 void SBVariablesOptions::SetIncludeRecognizedArguments(bool arguments) {
Index: source/Target/Target.cpp
===
--- source/Target/Target.cpp
+++ source/Target/Target.cpp
@@ -3356,6 +3356,8 @@
 {"display-runtime-support-values", OptionValue::eTypeBoolean, false, false,
  nullptr, {}, "If true, LLDB will show variables that are meant to "
   "support the operation of a language's runtime support."},
+{"display-recognized-arguments", OptionValue::eTypeBoolean, false, false,
+ nullptr, {}, "Show recognized arguments in variable listings by default."},
 {"non-stop-mode", OptionValue::eTypeBoolean, false, 0, nullptr, {},
  "Disable lock-step debugging, instead control threads independently."},
 {"require-hardware-breakpoint", OptionValue::eTypeBoolean, false, 0,
@@ -3404,6 +3406,7 @@
   ePropertyDisplayExpressionsInCrashlogs,
   ePropertyTrapHandlerNames,
   ePropertyDisplayRuntimeSupportValues,
+  ePropertyDisplayRecognizedArguments,
   ePropertyNonStopModeEnabled,
   ePropertyRequireHardwareBreakpoints,
   ePropertyEx

[Lldb-commits] [PATCH] D56208: Add file-based synchronization to flaky test

2019-01-02 Thread Phabricator via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL350247: Add file-based synchronization to flaky test 
(authored by adrian, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D56208?vs=179891&id=179896#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D56208

Files:
  lldb/trunk/packages/Python/lldbsuite/test/macosx/queues/TestQueues.py
  lldb/trunk/packages/Python/lldbsuite/test/macosx/queues/main.c

Index: lldb/trunk/packages/Python/lldbsuite/test/macosx/queues/main.c
===
--- lldb/trunk/packages/Python/lldbsuite/test/macosx/queues/main.c
+++ lldb/trunk/packages/Python/lldbsuite/test/macosx/queues/main.c
@@ -1,4 +1,6 @@
 #include 
+#include 
+#include 
 #include 
 #include 
 #include 
@@ -6,6 +8,19 @@
 int finished_enqueueing_work = 0;
 
 void
+touch (const char *name, unsigned n)
+{
+char token[2048];
+snprintf (token, 2048, "%s%d", name, n);
+FILE *f = fopen (token, "wx");
+if (!f)
+exit (1);
+fputs ("\n", f);
+fflush (f);
+fclose (f);
+}
+
+void
 doing_the_work_1(void *in)
 {
 while (1)
@@ -77,7 +92,7 @@
 }
 
 
-int main ()
+int main (int argc, const char **argv)
 {
 dispatch_queue_t work_submittor_1 = dispatch_queue_create ("com.apple.work_submittor_1", DISPATCH_QUEUE_SERIAL);
 dispatch_queue_t work_submittor_2 = dispatch_queue_create ("com.apple.work_submittor_and_quit_2", DISPATCH_QUEUE_SERIAL);
@@ -100,31 +115,37 @@
 
 dispatch_async (dispatch_get_global_queue(QOS_CLASS_USER_INITIATED, 0), ^{
 pthread_setname_np ("user initiated QoS");
+touch(argv[1], 1);
 while (1)
 sleep (10);
 });
 dispatch_async (dispatch_get_global_queue(QOS_CLASS_USER_INTERACTIVE, 0), ^{
 pthread_setname_np ("user interactive QoS");
+touch(argv[1], 2);
 while (1)
 sleep (10);
 });
 dispatch_async (dispatch_get_global_queue(QOS_CLASS_DEFAULT, 0), ^{
 pthread_setname_np ("default QoS");
+touch(argv[1], 3);
 while (1)
 sleep (10);
 });
 dispatch_async (dispatch_get_global_queue(QOS_CLASS_UTILITY, 0), ^{
 pthread_setname_np ("utility QoS");
+touch(argv[1], 4);
 while (1)
 sleep (10);
 });
 dispatch_async (dispatch_get_global_queue(QOS_CLASS_BACKGROUND, 0), ^{
 pthread_setname_np ("background QoS");
+touch(argv[1], 5);
 while (1)
 sleep (10);
 });
 dispatch_async (dispatch_get_global_queue(QOS_CLASS_UNSPECIFIED, 0), ^{
 pthread_setname_np ("unspecified QoS");
+touch(argv[1], 6);
 while (1)
 sleep (10);
 });
Index: lldb/trunk/packages/Python/lldbsuite/test/macosx/queues/TestQueues.py
===
--- lldb/trunk/packages/Python/lldbsuite/test/macosx/queues/TestQueues.py
+++ lldb/trunk/packages/Python/lldbsuite/test/macosx/queues/TestQueues.py
@@ -30,6 +30,16 @@
 # Find the line numbers that we will step to in main:
 self.main_source = "main.c"
 
+def remove_token(self, name):
+for i in range(6):
+token = name+'.token.%d'%(i+1)
+if os.path.exists(token):
+os.remove(token)
+
+def await_token(self, name):
+for i in range(6):
+lldbutil.wait_for_file_on_target(self, name+'.token.%d'%(i+1))
+
 def check_queue_for_valid_queue_id(self, queue):
 self.assertTrue(
 queue.GetQueueID() != 0, "Check queue %s for valid QueueID (got 0x%x)" %
@@ -112,12 +122,14 @@
 self.main_source_spec = lldb.SBFileSpec(self.main_source)
 break1 = target.BreakpointCreateByName("stopper", 'a.out')
 self.assertTrue(break1, VALID_BREAKPOINT)
+self.remove_token(exe)
 process = target.LaunchSimple(
-None, None, self.get_process_working_directory())
+[exe+'.token.'], None, self.get_process_working_directory())
 self.assertTrue(process, PROCESS_IS_VALID)
 threads = lldbutil.get_threads_stopped_at_breakpoint(process, break1)
 if len(threads) != 1:
 self.fail("Failed to stop at breakpoint 1.")
+self.await_token(exe)
 
 queue_submittor_1 = lldb.SBQueue()
 queue_performer_1 = lldb.SBQueue()
@@ -271,8 +283,9 @@
 if self.getArchitecture() in ['arm', 'arm64', 'arm64e', 'arm64_32', 'armv7', 'armv7k']:
 libbtr_path = "/Developer/usr/lib/libBacktraceRecording.dylib"
 
+self.remove_token(exe)
 process = target.LaunchSimple(
-None,
+

[Lldb-commits] [PATCH] D56218: Rearrange bitfield to allow for more space in file_idx.

2019-01-02 Thread Phabricator via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rLLDB350274: Rearrange bitfield to allow for more space in 
file_idx. (authored by adrian, committed by ).
Herald added a subscriber: abidh.

Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D56218

Files:
  include/lldb/Symbol/LineTable.h


Index: include/lldb/Symbol/LineTable.h
===
--- include/lldb/Symbol/LineTable.h
+++ include/lldb/Symbol/LineTable.h
@@ -306,26 +306,30 @@
 //--
 // Member variables.
 //--
-lldb::addr_t file_addr; ///< The file address for this line entry
-uint32_t line;   ///< The source line number, or zero if there is no line
- ///number information.
-uint16_t column; ///< The column number of the source line, or zero if 
there
- ///is no column information.
-uint16_t file_idx : 11, ///< The file index into CompileUnit's file table,
-///or zero if there is no file information.
-is_start_of_statement : 1, ///< Indicates this entry is the beginning 
of
-   ///a statement.
-is_start_of_basic_block : 1, ///< Indicates this entry is the beginning
- ///of a basic block.
-is_prologue_end : 1, ///< Indicates this entry is one (of possibly 
many)
- ///where execution should be suspended for an 
entry
- ///breakpoint of a function.
-is_epilogue_begin : 1, ///< Indicates this entry is one (of possibly
-   ///many) where execution should be suspended for
-   ///an exit breakpoint of a function.
-is_terminal_entry : 1; ///< Indicates this entry is that of the first
-   ///byte after the end of a sequence of target
-   ///machine instructions.
+/// The file address for this line entry.
+lldb::addr_t file_addr;
+/// The source line number, or zero if there is no line number
+/// information.
+uint32_t line : 27;
+/// Indicates this entry is the beginning of a statement.
+uint32_t is_start_of_statement : 1;
+/// Indicates this entry is the beginning of a basic block.
+uint32_t is_start_of_basic_block : 1;
+/// Indicates this entry is one (of possibly many) where execution
+/// should be suspended for an entry breakpoint of a function.
+uint32_t is_prologue_end : 1;
+/// Indicates this entry is one (of possibly many) where execution
+/// should be suspended for an exit breakpoint of a function.
+uint32_t is_epilogue_begin : 1;
+/// Indicates this entry is that of the first byte after the end
+/// of a sequence of target machine instructions.
+uint32_t is_terminal_entry : 1;
+/// The column number of the source line, or zero if there is no
+/// column information.
+uint16_t column;
+/// The file index into CompileUnit's file table, or zero if there
+/// is no file information.
+uint16_t file_idx;
   };
 
   struct EntrySearchInfo {


Index: include/lldb/Symbol/LineTable.h
===
--- include/lldb/Symbol/LineTable.h
+++ include/lldb/Symbol/LineTable.h
@@ -306,26 +306,30 @@
 //--
 // Member variables.
 //--
-lldb::addr_t file_addr; ///< The file address for this line entry
-uint32_t line;   ///< The source line number, or zero if there is no line
- ///number information.
-uint16_t column; ///< The column number of the source line, or zero if there
- ///is no column information.
-uint16_t file_idx : 11, ///< The file index into CompileUnit's file table,
-///or zero if there is no file information.
-is_start_of_statement : 1, ///< Indicates this entry is the beginning of
-   ///a statement.
-is_start_of_basic_block : 1, ///< Indicates this entry is the beginning
- ///of a basic block.
-is_prologue_end : 1, ///< Indicates this entry is one (of possibly many)
- ///where execution should be suspended for an entry
- ///breakpoint of a function.
-is_epilogue_begin : 1, ///< Indicates this entry is one (of possibly
-   ///many) where execution should be suspended for
-   ///an exit breakpoint of a function.
-is_te

[Lldb-commits] [PATCH] D56115: [lldb] Check SafeToCallFunctions before calling functions in GetExceptionObjectForThread

2019-01-03 Thread Phabricator via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rLLDB350375: [lldb] Check SafeToCallFunctions before calling 
functions in… (authored by kuba.brecka, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D56115?vs=179589&id=180173#toc

Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D56115

Files:
  
source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.cpp


Index: 
source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.cpp
===
--- 
source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.cpp
+++ 
source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.cpp
@@ -554,6 +554,9 @@
 
 ValueObjectSP ItaniumABILanguageRuntime::GetExceptionObjectForThread(
 ThreadSP thread_sp) {
+  if (!thread_sp->SafeToCallFunctions())
+return {};
+
   ClangASTContext *clang_ast_context =
   m_process->GetTarget().GetScratchClangASTContext();
   CompilerType voidstar =


Index: source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.cpp
===
--- source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.cpp
+++ source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.cpp
@@ -554,6 +554,9 @@
 
 ValueObjectSP ItaniumABILanguageRuntime::GetExceptionObjectForThread(
 ThreadSP thread_sp) {
+  if (!thread_sp->SafeToCallFunctions())
+return {};
+
   ClangASTContext *clang_ast_context =
   m_process->GetTarget().GetScratchClangASTContext();
   CompilerType voidstar =
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D56027: [lldb] Fix ObjCExceptionRecognizedStackFrame to populate the list of recognized arguments

2019-01-03 Thread Phabricator via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rLLDB350376: [lldb] Fix ObjCExceptionRecognizedStackFrame to 
populate the list of recognized… (authored by kuba.brecka, committed by ).

Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D56027

Files:
  packages/Python/lldbsuite/test/lang/objc/exceptions/TestObjCExceptions.py
  source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp


Index: 
source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp
===
--- source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp
+++ source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp
@@ -2630,6 +2630,9 @@
 exception = ValueObjectConstResult::Create(frame_sp.get(), value,
ConstString("exception"));
 exception = exception->GetDynamicValue(eDynamicDontRunTarget);
+  
+m_arguments = ValueObjectListSP(new ValueObjectList());
+m_arguments->Append(exception);
   }
 
   ValueObjectSP exception;
Index: packages/Python/lldbsuite/test/lang/objc/exceptions/TestObjCExceptions.py
===
--- packages/Python/lldbsuite/test/lang/objc/exceptions/TestObjCExceptions.py
+++ packages/Python/lldbsuite/test/lang/objc/exceptions/TestObjCExceptions.py
@@ -34,6 +34,17 @@
 'name: "ThrownException" - reason: "SomeReason"',
 ])
 
+target = self.dbg.GetSelectedTarget()
+thread = target.GetProcess().GetSelectedThread()
+frame = thread.GetSelectedFrame()
+
+opts = lldb.SBVariablesOptions()
+opts.SetIncludeRecognizedArguments(True)
+variables = frame.GetVariables(opts)
+
+self.assertEqual(variables.GetSize(), 1)
+self.assertEqual(variables.GetValueAtIndex(0).name, "exception")
+
 lldbutil.run_to_source_breakpoint(self, "// Set break point at this 
line.", lldb.SBFileSpec("main.mm"), launch_info=launch_info)
 
 self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT,


Index: source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp
===
--- source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp
+++ source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp
@@ -2630,6 +2630,9 @@
 exception = ValueObjectConstResult::Create(frame_sp.get(), value,
ConstString("exception"));
 exception = exception->GetDynamicValue(eDynamicDontRunTarget);
+  
+m_arguments = ValueObjectListSP(new ValueObjectList());
+m_arguments->Append(exception);
   }
 
   ValueObjectSP exception;
Index: packages/Python/lldbsuite/test/lang/objc/exceptions/TestObjCExceptions.py
===
--- packages/Python/lldbsuite/test/lang/objc/exceptions/TestObjCExceptions.py
+++ packages/Python/lldbsuite/test/lang/objc/exceptions/TestObjCExceptions.py
@@ -34,6 +34,17 @@
 'name: "ThrownException" - reason: "SomeReason"',
 ])
 
+target = self.dbg.GetSelectedTarget()
+thread = target.GetProcess().GetSelectedThread()
+frame = thread.GetSelectedFrame()
+
+opts = lldb.SBVariablesOptions()
+opts.SetIncludeRecognizedArguments(True)
+variables = frame.GetVariables(opts)
+
+self.assertEqual(variables.GetSize(), 1)
+self.assertEqual(variables.GetValueAtIndex(0).name, "exception")
+
 lldbutil.run_to_source_breakpoint(self, "// Set break point at this line.", lldb.SBFileSpec("main.mm"), launch_info=launch_info)
 
 self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT,
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D55320: [CMake] Move debugserver options to separate debugserverConfig.cmake

2019-01-04 Thread Phabricator via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL350390: [CMake] Move debugserver options to separate 
debugserverConfig.cmake (authored by stefan.graenitz, committed by ).
Herald added a subscriber: llvm-commits.

Repository:
  rL LLVM

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

https://reviews.llvm.org/D55320

Files:
  lldb/trunk/cmake/modules/debugserverConfig.cmake
  lldb/trunk/tools/debugserver/CMakeLists.txt


Index: lldb/trunk/cmake/modules/debugserverConfig.cmake
===
--- lldb/trunk/cmake/modules/debugserverConfig.cmake
+++ lldb/trunk/cmake/modules/debugserverConfig.cmake
@@ -0,0 +1,3 @@
+# Duplicate options from LLDBConfig that are relevant for debugserver 
Standalone builds.
+
+option(LLDB_USE_ENTITLEMENTS "When code signing, use entitlements if 
available" ON)
Index: lldb/trunk/tools/debugserver/CMakeLists.txt
===
--- lldb/trunk/tools/debugserver/CMakeLists.txt
+++ lldb/trunk/tools/debugserver/CMakeLists.txt
@@ -10,13 +10,12 @@
 )
 
   include(LLDBStandalone)
+  include(debugserverConfig)
   include(AddLLDB)
 
   set(LLDB_SOURCE_DIR "${CMAKE_SOURCE_DIR}/../../")
   include_directories(${LLDB_SOURCE_DIR}/include)
 
-  option(LLDB_USE_ENTITLEMENTS "When code signing, use entitlements if 
available" ON)
-
   # lldb-suite is a dummy target that encompasses all the necessary tools and
   # libraries for building a fully-functioning liblldb.
   add_custom_target(lldb-suite)


Index: lldb/trunk/cmake/modules/debugserverConfig.cmake
===
--- lldb/trunk/cmake/modules/debugserverConfig.cmake
+++ lldb/trunk/cmake/modules/debugserverConfig.cmake
@@ -0,0 +1,3 @@
+# Duplicate options from LLDBConfig that are relevant for debugserver Standalone builds.
+
+option(LLDB_USE_ENTITLEMENTS "When code signing, use entitlements if available" ON)
Index: lldb/trunk/tools/debugserver/CMakeLists.txt
===
--- lldb/trunk/tools/debugserver/CMakeLists.txt
+++ lldb/trunk/tools/debugserver/CMakeLists.txt
@@ -10,13 +10,12 @@
 )
 
   include(LLDBStandalone)
+  include(debugserverConfig)
   include(AddLLDB)
 
   set(LLDB_SOURCE_DIR "${CMAKE_SOURCE_DIR}/../../")
   include_directories(${LLDB_SOURCE_DIR}/include)
 
-  option(LLDB_USE_ENTITLEMENTS "When code signing, use entitlements if available" ON)
-
   # lldb-suite is a dummy target that encompasses all the necessary tools and
   # libraries for building a fully-functioning liblldb.
   add_custom_target(lldb-suite)
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D55013: [CMake] Streamline code signing for debugserver #2

2019-01-04 Thread Phabricator via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL350388: [CMake] Streamline code signing for debugserver #2 
(authored by stefan.graenitz, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D55013?vs=177577&id=180227#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D55013

Files:
  lldb/trunk/CMakeLists.txt
  lldb/trunk/cmake/modules/AddLLDB.cmake
  lldb/trunk/cmake/modules/LLDBConfig.cmake
  lldb/trunk/test/CMakeLists.txt
  lldb/trunk/tools/debugserver/CMakeLists.txt
  lldb/trunk/tools/debugserver/source/CMakeLists.txt
  lldb/trunk/unittests/tools/CMakeLists.txt
  lldb/trunk/unittests/tools/lldb-server/CMakeLists.txt

Index: lldb/trunk/cmake/modules/AddLLDB.cmake
===
--- lldb/trunk/cmake/modules/AddLLDB.cmake
+++ lldb/trunk/cmake/modules/AddLLDB.cmake
@@ -100,13 +100,13 @@
 function(add_lldb_executable name)
   cmake_parse_arguments(ARG
 "INCLUDE_IN_SUITE;GENERATE_INSTALL"
-""
+"ENTITLEMENTS"
 "LINK_LIBS;LINK_COMPONENTS"
 ${ARGN}
 )
 
   list(APPEND LLVM_LINK_COMPONENTS ${ARG_LINK_COMPONENTS})
-  add_llvm_executable(${name} ${ARG_UNPARSED_ARGUMENTS})
+  add_llvm_executable(${name} ${ARG_UNPARSED_ARGUMENTS} ENTITLEMENTS ${ARG_ENTITLEMENTS})
 
   target_link_libraries(${name} PRIVATE ${ARG_LINK_LIBS})
   set_target_properties(${name} PROPERTIES
Index: lldb/trunk/cmake/modules/LLDBConfig.cmake
===
--- lldb/trunk/cmake/modules/LLDBConfig.cmake
+++ lldb/trunk/cmake/modules/LLDBConfig.cmake
@@ -50,6 +50,8 @@
   add_definitions( -DLLDB_DISABLE_CURSES )
 endif()
 
+option(LLDB_USE_ENTITLEMENTS "When code signing, use entitlements if available" ON)
+
 # On Windows, we can't use the normal FindPythonLibs module that comes with CMake,
 # for a number of reasons.
 # 1) Prior to MSVC 2015, it is only possible to embed Python if python itself was
Index: lldb/trunk/test/CMakeLists.txt
===
--- lldb/trunk/test/CMakeLists.txt
+++ lldb/trunk/test/CMakeLists.txt
@@ -74,8 +74,8 @@
   endif()
 endif()
 
-if(LLDB_CODESIGN_IDENTITY)
-  list(APPEND LLDB_TEST_COMMON_ARGS --codesign-identity "${LLDB_CODESIGN_IDENTITY}")
+if(LLDB_CODESIGN_IDENTITY_USED)
+  list(APPEND LLDB_TEST_COMMON_ARGS --codesign-identity "${LLDB_CODESIGN_IDENTITY_USED}")
 endif()
 
 if(LLDB_BUILD_FRAMEWORK)
@@ -93,11 +93,11 @@
   endif()
 endif()
 
-if(CMAKE_HOST_APPLE)
+if(CMAKE_HOST_APPLE AND DEBUGSERVER_PATH)
   list(APPEND LLDB_TEST_COMMON_ARGS --server ${DEBUGSERVER_PATH})
 endif()
 
-if(SKIP_DEBUGSERVER)
+if(SKIP_TEST_DEBUGSERVER)
   list(APPEND LLDB_TEST_COMMON_ARGS --out-of-tree-debugserver)
 endif()
 
Index: lldb/trunk/CMakeLists.txt
===
--- lldb/trunk/CMakeLists.txt
+++ lldb/trunk/CMakeLists.txt
@@ -138,9 +138,7 @@
   endif()
 
   if(TARGET debugserver)
-if(NOT CMAKE_HOST_APPLE OR LLDB_CODESIGN_IDENTITY)
-  list(APPEND LLDB_TEST_DEPS debugserver)
-endif()
+list(APPEND LLDB_TEST_DEPS debugserver)
   endif()
 
   if(TARGET lldb-mi)
Index: lldb/trunk/unittests/tools/lldb-server/CMakeLists.txt
===
--- lldb/trunk/unittests/tools/lldb-server/CMakeLists.txt
+++ lldb/trunk/unittests/tools/lldb-server/CMakeLists.txt
@@ -12,7 +12,7 @@
 add_lldb_test_executable(thread_inferior inferior/thread_inferior.cpp)
 add_lldb_test_executable(environment_check inferior/environment_check.cpp)
 
-if (CMAKE_SYSTEM_NAME MATCHES "Darwin")
+if(DEBUGSERVER_PATH)
   add_definitions(-DLLDB_SERVER="${DEBUGSERVER_PATH}" -DLLDB_SERVER_IS_DEBUGSERVER=1)
 else()
   add_definitions(-DLLDB_SERVER="$" -DLLDB_SERVER_IS_DEBUGSERVER=0)
Index: lldb/trunk/unittests/tools/CMakeLists.txt
===
--- lldb/trunk/unittests/tools/CMakeLists.txt
+++ lldb/trunk/unittests/tools/CMakeLists.txt
@@ -1,5 +1,5 @@
 if(CMAKE_SYSTEM_NAME MATCHES "Android|Darwin|Linux|NetBSD")
-  if ((CMAKE_SYSTEM_NAME MATCHES "Darwin" AND SKIP_DEBUGSERVER) OR (NOT CMAKE_SYSTEM_NAME MATCHES "Darwin" AND SKIP_LLDB_SERVER_BUILD))
+  if ((CMAKE_SYSTEM_NAME MATCHES "Darwin" AND SKIP_TEST_DEBUGSERVER) OR (NOT CMAKE_SYSTEM_NAME MATCHES "Darwin" AND SKIP_LLDB_SERVER_BUILD))
 # These tests are meant to test lldb-server/debugserver in isolation, and
 # don't provide any value if run against a server copied from somewhere.
   else()
Index: lldb/trunk/tools/debugserver/source/CMakeLists.txt
===
--- lldb/trunk/tools/debugserver/source/CMakeLists.txt
+++ lldb/trunk/tools/debugserver/source/CMakeLists.txt
@@ -94,32 +94,121 @@
 
 add_library(lldbDebugserverCommon ${lldbDebugserverCommonSourc

[Lldb-commits] [PATCH] D55317: [CMake] Aggregate options for LLDB in LLDBConfig.cmake

2019-01-04 Thread Phabricator via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL350389: [CMake] Aggregate options for LLDB in 
LLDBConfig.cmake (authored by stefan.graenitz, committed by ).
Herald added a subscriber: llvm-commits.

Repository:
  rL LLVM

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

https://reviews.llvm.org/D55317

Files:
  lldb/trunk/CMakeLists.txt
  lldb/trunk/cmake/modules/LLDBConfig.cmake

Index: lldb/trunk/cmake/modules/LLDBConfig.cmake
===
--- lldb/trunk/cmake/modules/LLDBConfig.cmake
+++ lldb/trunk/cmake/modules/LLDBConfig.cmake
@@ -10,28 +10,42 @@
   set(LLDB_LINKER_SUPPORTS_GROUPS ON)
 endif()
 
-set(LLDB_DEFAULT_DISABLE_PYTHON 0)
-set(LLDB_DEFAULT_DISABLE_CURSES 0)
+set(default_disable_python OFF)
+set(default_disable_curses OFF)
+set(default_disable_libedit OFF)
+
+if(DEFINED LLVM_ENABLE_LIBEDIT AND NOT LLVM_ENABLE_LIBEDIT)
+  set(default_disable_libedit ON)
+endif()
 
-if ( CMAKE_SYSTEM_NAME MATCHES "Windows" )
-  set(LLDB_DEFAULT_DISABLE_CURSES 1)
-elseif (CMAKE_SYSTEM_NAME MATCHES "Android" )
-  set(LLDB_DEFAULT_DISABLE_PYTHON 1)
-  set(LLDB_DEFAULT_DISABLE_CURSES 1)
+if(CMAKE_SYSTEM_NAME MATCHES "Windows")
+  set(default_disable_curses ON)
+  set(default_disable_libedit ON)
+elseif(CMAKE_SYSTEM_NAME MATCHES "Android")
+  set(default_disable_python ON)
+  set(default_disable_curses ON)
+  set(default_disable_libedit ON)
 elseif(IOS)
-  set(LLDB_DEFAULT_DISABLE_PYTHON 1)
+  set(default_disable_python ON)
 endif()
 
-set(LLDB_DISABLE_PYTHON ${LLDB_DEFAULT_DISABLE_PYTHON} CACHE BOOL
-  "Disables the Python scripting integration.")
-set(LLDB_DISABLE_CURSES ${LLDB_DEFAULT_DISABLE_CURSES} CACHE BOOL
-  "Disables the Curses integration.")
-
-set(LLDB_RELOCATABLE_PYTHON 0 CACHE BOOL
-  "Causes LLDB to use the PYTHONHOME environment variable to locate Python.")
-
-set(LLDB_USE_SYSTEM_SIX 0 CACHE BOOL
-  "Use six.py shipped with system and do not install a copy of it")
+option(LLDB_DISABLE_PYTHON "Disable Python scripting integration." ${default_disable_python})
+option(LLDB_DISABLE_CURSES "Disable Curses integration." ${default_disable_curses})
+option(LLDB_DISABLE_LIBEDIT "Disable the use of editline." ${default_disable_libedit})
+option(LLDB_RELOCATABLE_PYTHON "Use the PYTHONHOME environment variable to locate Python." OFF)
+option(LLDB_USE_SYSTEM_SIX "Use six.py shipped with system and do not install a copy of it" OFF)
+option(LLDB_USE_ENTITLEMENTS "When codesigning, use entitlements if available" ON)
+option(LLDB_BUILD_FRAMEWORK "Build LLDB.framework (Darwin only)" OFF)
+
+if(LLDB_BUILD_FRAMEWORK)
+  if(NOT APPLE)
+message(FATAL_ERROR "LLDB.framework can only be generated when targeting Apple platforms")
+  endif()
+  # CMake 3.6 did not correctly emit POST_BUILD commands for Apple Framework targets
+  if(CMAKE_VERSION VERSION_LESS 3.7)
+message(FATAL_ERROR "LLDB_BUILD_FRAMEWORK is not supported on CMake < 3.7")
+  endif()
+endif()
 
 if (NOT CMAKE_SYSTEM_NAME MATCHES "Windows")
   set(LLDB_EXPORT_ALL_SYMBOLS 0 CACHE BOOL
@@ -50,8 +64,6 @@
   add_definitions( -DLLDB_DISABLE_CURSES )
 endif()
 
-option(LLDB_USE_ENTITLEMENTS "When code signing, use entitlements if available" ON)
-
 # On Windows, we can't use the normal FindPythonLibs module that comes with CMake,
 # for a number of reasons.
 # 1) Prior to MSVC 2015, it is only possible to embed Python if python itself was
Index: lldb/trunk/CMakeLists.txt
===
--- lldb/trunk/CMakeLists.txt
+++ lldb/trunk/CMakeLists.txt
@@ -18,15 +18,6 @@
   add_definitions( -DLLDB_CONFIGURATION_RELEASE )
 endif()
 
-if (CMAKE_SYSTEM_NAME MATCHES "Windows|Android")
-  set(LLDB_DEFAULT_DISABLE_LIBEDIT 1)
-else()
-  set(LLDB_DEFAULT_DISABLE_LIBEDIT 0)
-endif ()
-
-# We need libedit support to go down both the source and
-# the scripts directories.
-set(LLDB_DISABLE_LIBEDIT ${LLDB_DEFAULT_DISABLE_LIBEDIT} CACHE BOOL "Disables the use of editline.")
 if (LLDB_DISABLE_LIBEDIT)
   add_definitions( -DLLDB_DISABLE_LIBEDIT )
 else()
@@ -42,16 +33,9 @@
 add_custom_target(lldb-suite)
 set(LLDB_SUITE_TARGET lldb-suite)
 
-option(LLDB_BUILD_FRAMEWORK "Build the Darwin LLDB.framework" Off)
 if(LLDB_BUILD_FRAMEWORK)
-  if (CMAKE_VERSION VERSION_LESS 3.7)
-message(FATAL_ERROR "LLDB_BUILD_FRAMEWORK is not supported on CMake < 3.7")
-  endif()
-  if (NOT APPLE)
-message(FATAL_ERROR "LLDB.framework can only be generated when targeting Apple platforms")
-  endif()
-
   add_custom_target(lldb-framework)
+
   # These are used to fill out LLDB-Info.plist. These are relevant when building
   # the framework, and must be defined before building liblldb.
   set(PRODUCT_NAME "LLDB")
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D55328: [CMake] Revised LLDB.framework builds

2019-01-04 Thread Phabricator via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL350391: [CMake] Revised LLDB.framework builds (authored by 
stefan.graenitz, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D55328?vs=177554&id=180230#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D55328

Files:
  lldb/trunk/CMakeLists.txt
  lldb/trunk/cmake/modules/AddLLDB.cmake
  lldb/trunk/cmake/modules/LLDBConfig.cmake
  lldb/trunk/cmake/modules/LLDBFramework.cmake
  lldb/trunk/resources/LLDB-Info.plist.in
  lldb/trunk/source/API/CMakeLists.txt
  lldb/trunk/test/CMakeLists.txt
  lldb/trunk/tools/argdumper/CMakeLists.txt
  lldb/trunk/tools/darwin-debug/CMakeLists.txt
  lldb/trunk/tools/debugserver/CMakeLists.txt
  lldb/trunk/tools/debugserver/source/CMakeLists.txt
  lldb/trunk/tools/driver/CMakeLists.txt
  lldb/trunk/tools/lldb-server/CMakeLists.txt

Index: lldb/trunk/cmake/modules/AddLLDB.cmake
===
--- lldb/trunk/cmake/modules/AddLLDB.cmake
+++ lldb/trunk/cmake/modules/AddLLDB.cmake
@@ -50,20 +50,20 @@
 
 if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY OR ${name} STREQUAL "liblldb")
   if (PARAM_SHARED)
-set(out_dir lib${LLVM_LIBDIR_SUFFIX})
 if(${name} STREQUAL "liblldb" AND LLDB_BUILD_FRAMEWORK)
-  set(out_dir ${LLDB_FRAMEWORK_INSTALL_DIR})
-  # The framework that is generated will install with install-liblldb
-  # because we enable CMake's framework support. CMake will copy all the
-  # headers and resources for us.
-  add_dependencies(install-lldb-framework install-${name})
-  add_dependencies(install-lldb-framework-stripped install-${name}-stripped)
+  if(LLDB_FRAMEWORK_INSTALL_DIR)
+set(install_dir ${LLDB_FRAMEWORK_INSTALL_DIR})
+  else()
+set(install_dir ".")
+  endif()
+else()
+  set(install_dir lib${LLVM_LIBDIR_SUFFIX})
 endif()
 install(TARGETS ${name}
   COMPONENT ${name}
   RUNTIME DESTINATION bin
-  LIBRARY DESTINATION ${out_dir}
-  ARCHIVE DESTINATION ${out_dir})
+  LIBRARY DESTINATION ${install_dir}
+  ARCHIVE DESTINATION ${install_dir})
   else()
 install(TARGETS ${name}
   COMPONENT ${name}
@@ -74,13 +74,6 @@
 add_llvm_install_targets(install-${name}
  DEPENDS $
  COMPONENT ${name})
-
-# install-liblldb{,-stripped} is the actual target that will install the
-# framework, so it must rely on the framework being fully built first.
-if (LLDB_BUILD_FRAMEWORK AND ${name} STREQUAL "liblldb")
-  add_dependencies(install-${name} lldb-framework)
-  add_dependencies(install-${name}-stripped lldb-framework)
-endif()
   endif()
 endif()
   endif()
@@ -99,7 +92,7 @@
 
 function(add_lldb_executable name)
   cmake_parse_arguments(ARG
-"INCLUDE_IN_SUITE;GENERATE_INSTALL"
+"GENERATE_INSTALL"
 "ENTITLEMENTS"
 "LINK_LIBS;LINK_COMPONENTS"
 ${ARGN}
@@ -109,53 +102,18 @@
   add_llvm_executable(${name} ${ARG_UNPARSED_ARGUMENTS} ENTITLEMENTS ${ARG_ENTITLEMENTS})
 
   target_link_libraries(${name} PRIVATE ${ARG_LINK_LIBS})
-  set_target_properties(${name} PROPERTIES
-FOLDER "lldb executables")
-
-  if(ARG_INCLUDE_IN_SUITE)
-add_dependencies(lldb-suite ${name})
-if(LLDB_BUILD_FRAMEWORK)
-  if(NOT IOS)
-set(resource_dir "/Resources")
-set(resource_dots "../")
-  endif()
-  string(REGEX REPLACE "[^/]+" ".." _dots ${LLDB_FRAMEWORK_INSTALL_DIR})
-  set_target_properties(${name} PROPERTIES
-RUNTIME_OUTPUT_DIRECTORY $${resource_dir}
-BUILD_WITH_INSTALL_RPATH On
-INSTALL_RPATH "@loader_path/../../../${resource_dots}${_dots}/${LLDB_FRAMEWORK_INSTALL_DIR}")
-endif()
-  endif()
-
-  if(LLDB_BUILD_FRAMEWORK AND NOT ARG_INCLUDE_IN_SUITE)
-set_target_properties(${name} PROPERTIES
-  BUILD_WITH_INSTALL_RPATH On
-  INSTALL_RPATH "@loader_path/../${LLDB_FRAMEWORK_INSTALL_DIR}")
-  endif()
+  set_target_properties(${name} PROPERTIES FOLDER "lldb executables")
 
   if(ARG_GENERATE_INSTALL)
-set(out_dir "bin")
-if (LLDB_BUILD_FRAMEWORK AND ARG_INCLUDE_IN_SUITE)
-  set(out_dir ${LLDB_FRAMEWORK_INSTALL_DIR}/${LLDB_FRAMEWORK_RESOURCE_DIR})
-  # While install-liblldb-stripped will handle copying the tools, it will
-  # not strip them. We depend on this target to guarantee a stripped version
-  # will get installed in the framework.
-  add_dependencies(install-lldb-framework-stripped install-${name}-stripped)
-endif()
 install(TARGETS ${name}
-  COMPONENT ${name}
-  RUNTIME DESTINATION ${out_dir})
+COMPONENT ${name}
+RUNTI

[Lldb-commits] [PATCH] D55330: [CMake] Revised RPATH handling

2019-01-04 Thread Phabricator via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL350392: [CMake] Revised RPATH handling (authored by 
stefan.graenitz, committed by ).
Herald added a subscriber: llvm-commits.

Repository:
  rL LLVM

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

https://reviews.llvm.org/D55330

Files:
  lldb/trunk/cmake/modules/AddLLDB.cmake
  lldb/trunk/cmake/modules/LLDBConfig.cmake
  lldb/trunk/tools/driver/CMakeLists.txt
  lldb/trunk/tools/lldb-mi/CMakeLists.txt
  lldb/trunk/tools/lldb-vscode/CMakeLists.txt

Index: lldb/trunk/tools/lldb-vscode/CMakeLists.txt
===
--- lldb/trunk/tools/lldb-vscode/CMakeLists.txt
+++ lldb/trunk/tools/lldb-vscode/CMakeLists.txt
@@ -28,3 +28,7 @@
   LINK_COMPONENTS
 Support
   )
+
+if(LLDB_BUILD_FRAMEWORK)
+  lldb_setup_framework_rpaths_in_tool(lldb-vscode)
+endif()
Index: lldb/trunk/tools/driver/CMakeLists.txt
===
--- lldb/trunk/tools/driver/CMakeLists.txt
+++ lldb/trunk/tools/driver/CMakeLists.txt
@@ -22,3 +22,7 @@
   LLDBOptionsTableGen
   ${tablegen_deps}
 )
+
+if(LLDB_BUILD_FRAMEWORK)
+  lldb_setup_framework_rpaths_in_tool(lldb)
+endif()
Index: lldb/trunk/tools/lldb-mi/CMakeLists.txt
===
--- lldb/trunk/tools/lldb-mi/CMakeLists.txt
+++ lldb/trunk/tools/lldb-mi/CMakeLists.txt
@@ -93,3 +93,7 @@
   LINK_COMPONENTS
 Support
   )
+
+if(LLDB_BUILD_FRAMEWORK)
+  lldb_setup_framework_rpaths_in_tool(lldb-mi)
+endif()
Index: lldb/trunk/cmake/modules/AddLLDB.cmake
===
--- lldb/trunk/cmake/modules/AddLLDB.cmake
+++ lldb/trunk/cmake/modules/AddLLDB.cmake
@@ -44,9 +44,15 @@
   if (PARAM_OBJECT)
 add_library(${name} ${libkind} ${srcs})
   else()
-llvm_add_library(${name} ${libkind} ${srcs} LINK_LIBS
-${PARAM_LINK_LIBS}
-DEPENDS ${PARAM_DEPENDS})
+if(LLDB_NO_INSTALL_DEFAULT_RPATH)
+  set(pass_NO_INSTALL_RPATH NO_INSTALL_RPATH)
+endif()
+
+llvm_add_library(${name} ${libkind} ${srcs}
+  LINK_LIBS ${PARAM_LINK_LIBS}
+  DEPENDS ${PARAM_DEPENDS}
+  ${pass_NO_INSTALL_RPATH}
+)
 
 if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY OR ${name} STREQUAL "liblldb")
   if (PARAM_SHARED)
@@ -98,8 +104,15 @@
 ${ARGN}
 )
 
+  if(LLDB_NO_INSTALL_DEFAULT_RPATH)
+set(pass_NO_INSTALL_RPATH NO_INSTALL_RPATH)
+  endif()
+
   list(APPEND LLVM_LINK_COMPONENTS ${ARG_LINK_COMPONENTS})
-  add_llvm_executable(${name} ${ARG_UNPARSED_ARGUMENTS} ENTITLEMENTS ${ARG_ENTITLEMENTS})
+  add_llvm_executable(${name} ${ARG_UNPARSED_ARGUMENTS}
+ENTITLEMENTS ${ARG_ENTITLEMENTS}
+${pass_NO_INSTALL_RPATH}
+  )
 
   target_link_libraries(${name} PRIVATE ${ARG_LINK_LIBS})
   set_target_properties(${name} PROPERTIES FOLDER "lldb executables")
@@ -135,3 +148,40 @@
   # Now set them onto the target.
   set_target_properties(${target_name} PROPERTIES LINK_FLAGS ${new_link_flags})
 endfunction()
+
+# For tools that depend on liblldb, account for varying directory structures in
+# which LLDB.framework can be used and distributed: In the build-tree we find it
+# by its absolute target path. This is only relevant for running the test suite.
+# In the install step CMake will remove this entry and insert the final RPATHs.
+# These are relative to the file path from where the tool will be loaded on the
+# enduser system.
+#
+# Note that the LLVM install-tree doesn't match the enduser system structure
+# for LLDB.framework, so by default dependent tools will not be functional in
+# their install location. The LLDB_FRAMEWORK_INSTALL_DIR variable allows to fix
+# this. If specified, it causes the install-tree location of the framework to be
+# added as an extra RPATH below.
+#
+function(lldb_setup_framework_rpaths_in_tool name)
+  # In the build-tree, we know the exact path to the binary in the framework.
+  set(rpath_build_tree "$")
+
+  # The installed framework is relocatable and can be in different locations.
+  set(rpaths_install_tree "@loader_path/../../../SharedFrameworks")
+  list(APPEND rpaths_install_tree "@loader_path/../../System/Library/PrivateFrameworks")
+  list(APPEND rpaths_install_tree "@loader_path/../../Library/PrivateFrameworks")
+
+  if(LLDB_FRAMEWORK_INSTALL_DIR)
+set(rpaths_install_tree "@loader_path/../${LLDB_FRAMEWORK_INSTALL_DIR}")
+  endif()
+
+  # If LLDB_NO_INSTALL_DEFAULT_RPATH was NOT enabled (default), this overwrites
+  # the default settings from llvm_setup_rpath().
+  set_target_properties(${name} PROPERTIES
+BUILD_WITH_INSTALL_RPATH OFF
+BUILD_RPATH "${rpath_build_tree}"
+INSTALL_RPATH "${rpaths_install_tree}"
+  )
+
+  add_dependencies(${name} lldb-framework)
+endfunction()
Index: lldb/trunk/cmake/modules/LLDBConfig.cmake
=

[Lldb-commits] [PATCH] D55332: [CMake] Python bindings generation polishing

2019-01-04 Thread Phabricator via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rLLDB350393: [CMake] Python bindings generation polishing 
(authored by stefan.graenitz, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D55332?vs=177533&id=180232#toc

Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D55332

Files:
  CMakeLists.txt
  scripts/CMakeLists.txt
  source/API/CMakeLists.txt

Index: CMakeLists.txt
===
--- CMakeLists.txt
+++ CMakeLists.txt
@@ -30,14 +30,6 @@
 
 add_subdirectory(docs)
 if (NOT LLDB_DISABLE_PYTHON)
-  set(LLDB_PYTHON_TARGET_DIR ${LLDB_BINARY_DIR}/scripts)
-  set(LLDB_WRAP_PYTHON ${LLDB_BINARY_DIR}/scripts/LLDBWrapPython.cpp)
-  if(LLDB_BUILD_FRAMEWORK)
-set(LLDB_PYTHON_TARGET_DIR ${LLDB_FRAMEWORK_BUILD_DIR})
-set(LLDB_WRAP_PYTHON ${LLDB_PYTHON_TARGET_DIR}/LLDBWrapPython.cpp)
-  endif()
-
-
   add_subdirectory(scripts)
 endif ()
 add_subdirectory(source)
@@ -133,26 +125,27 @@
 if(LLDB_USE_SYSTEM_SIX)
   set(use_six_py_from_system --useSystemSix)
 endif()
+get_target_property(lldb_scripts_dir swig_wrapper BINARY_DIR)
+get_target_property(liblldb_build_dir liblldb LIBRARY_OUTPUT_DIRECTORY)
 
 # Add a Post-Build Event to copy over Python files and create the symlink
 # to liblldb.so for the Python API(hardlink on Windows)
 add_custom_target(finish_swig ALL
 COMMAND
-   ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/scripts/finishSwigWrapperClasses.py
+   ${PYTHON_EXECUTABLE} ${LLDB_SOURCE_DIR}/scripts/finishSwigWrapperClasses.py
--srcRoot=${LLDB_SOURCE_DIR}
-   --targetDir=${LLDB_PYTHON_TARGET_DIR}
-   --cfgBldDir=${LLDB_PYTHON_TARGET_DIR}
+   --targetDir=${liblldb_build_dir}
+   --cfgBldDir=${lldb_scripts_dir}
--prefix=${CMAKE_BINARY_DIR}
--cmakeBuildConfiguration=${CMAKE_CFG_INTDIR}
--lldbLibDir=lib${LLVM_LIBDIR_SUFFIX}
${use_python_wrapper_from_src_dir}
${use_six_py_from_system}
 VERBATIM
-DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/scripts/finishSwigWrapperClasses.py
-DEPENDS ${LLDB_PYTHON_TARGET_DIR}/lldb.py
+DEPENDS ${LLDB_SOURCE_DIR}/scripts/finishSwigWrapperClasses.py
+DEPENDS ${lldb_scripts_dir}/lldb.py
 COMMENT "Python script sym-linking LLDB Python API")
 
-
 if (TARGET readline)
   set(readline_dep readline)
 endif()
Index: source/API/CMakeLists.txt
===
--- source/API/CMakeLists.txt
+++ source/API/CMakeLists.txt
@@ -4,6 +4,11 @@
 
 get_property(LLDB_ALL_PLUGINS GLOBAL PROPERTY LLDB_PLUGINS)
 
+if(NOT LLDB_DISABLE_PYTHON)
+  get_target_property(lldb_scripts_dir swig_wrapper BINARY_DIR)
+  set(lldb_python_wrapper ${lldb_scripts_dir}/LLDBWrapPython.cpp)
+endif()
+
 add_lldb_library(liblldb SHARED
   SBAddress.cpp
   SBAttachInfo.cpp
@@ -73,7 +78,7 @@
   SBWatchpoint.cpp
   SBUnixSignals.cpp
   SystemInitializerFull.cpp
-  ${LLDB_WRAP_PYTHON}
+  ${lldb_python_wrapper}
 
   LINK_LIBS
 lldbBase
@@ -92,23 +97,23 @@
 Support
   )
 
-if(LLDB_WRAP_PYTHON)
+if(lldb_python_wrapper)
   add_dependencies(liblldb swig_wrapper)
 
   if (MSVC)
-set_property(SOURCE ${LLDB_WRAP_PYTHON} APPEND_STRING PROPERTY COMPILE_FLAGS " /W0")
+set_property(SOURCE ${lldb_python_wrapper} APPEND_STRING PROPERTY COMPILE_FLAGS " /W0")
   else()
-set_property(SOURCE ${LLDB_WRAP_PYTHON} APPEND_STRING PROPERTY COMPILE_FLAGS " -w")
+set_property(SOURCE ${lldb_python_wrapper} APPEND_STRING PROPERTY COMPILE_FLAGS " -w")
   endif()
 
-  set_source_files_properties(${LLDB_WRAP_PYTHON} PROPERTIES GENERATED 1)
+  set_source_files_properties(${lldb_python_wrapper} PROPERTIES GENERATED ON)
   if (CLANG_CL)
-set_property(SOURCE ${LLDB_WRAP_PYTHON} APPEND_STRING
+set_property(SOURCE ${lldb_python_wrapper} APPEND_STRING
   PROPERTY COMPILE_FLAGS " -Wno-unused-function")
   endif()
   if (LLVM_COMPILER_IS_GCC_COMPATIBLE AND
   NOT "${CMAKE_SYSTEM_NAME}" MATCHES "Darwin")
-set_property(SOURCE ${LLDB_WRAP_PYTHON} APPEND_STRING
+set_property(SOURCE ${lldb_python_wrapper} APPEND_STRING
   PROPERTY COMPILE_FLAGS " -Wno-sequence-point -Wno-cast-qual")
   endif ()
 endif()
Index: scripts/CMakeLists.txt
===
--- scripts/CMakeLists.txt
+++ scripts/CMakeLists.txt
@@ -11,31 +11,14 @@
 
 include(FindPythonInterp)
 
-if (NOT CMAKE_SYSTEM_NAME MATCHES "Windows")
-  set(SWIG_PYTHON_DIR
-${CMAKE_BINARY_DIR}/lib${LLVM_LIBDIR_SUFFIX}/python${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR})
-else()
-  set(SWIG_PYTHON_DIR ${CMAKE_BINARY_DIR}/lib${LLVM_LIBDIR_SUFFIX}/site-packages)
-endif()
-
-set(SWIG_INSTALL_DIR lib${LLVM_LIBDIR_SUFFIX})
-
-# Generating th

[Lldb-commits] [PATCH] D56389: [CMake] Fix standalone builds: make dependency to LLVM's `count` conditional

2019-01-07 Thread Phabricator via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rLLDB350538: [CMake] Fix standalone builds: make dependency to 
LLVM's `count` conditional (authored by stefan.graenitz, committed by ).
Herald added a subscriber: abidh.

Changed prior to commit:
  https://reviews.llvm.org/D56389?vs=180493&id=180507#toc

Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D56389

Files:
  lit/CMakeLists.txt


Index: lit/CMakeLists.txt
===
--- lit/CMakeLists.txt
+++ lit/CMakeLists.txt
@@ -26,7 +26,6 @@
 string(REPLACE ${CMAKE_CFG_INTDIR} ${LLVM_BUILD_MODE} LLDB_DOTEST_ARGS 
"${LLDB_DOTEST_ARGS}")
 
 list(APPEND LLDB_TEST_DEPS
-  count
   LLDBUnitTests
   dsymutil
   llc
@@ -73,6 +72,7 @@
 if(NOT LLDB_BUILT_STANDALONE)
   list(APPEND LLDB_TEST_DEPS
 FileCheck
+count
 not
 )
 endif()


Index: lit/CMakeLists.txt
===
--- lit/CMakeLists.txt
+++ lit/CMakeLists.txt
@@ -26,7 +26,6 @@
 string(REPLACE ${CMAKE_CFG_INTDIR} ${LLVM_BUILD_MODE} LLDB_DOTEST_ARGS "${LLDB_DOTEST_ARGS}")
 
 list(APPEND LLDB_TEST_DEPS
-  count
   LLDBUnitTests
   dsymutil
   llc
@@ -73,6 +72,7 @@
 if(NOT LLDB_BUILT_STANDALONE)
   list(APPEND LLDB_TEST_DEPS
 FileCheck
+count
 not
 )
 endif()
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D46669: Retrieve the deployment target when retrieving an object file's triple

2018-05-10 Thread Phabricator via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL332067: Retrieve the deployment target when retrieving an 
object file's triple. (authored by adrian, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D46669?vs=146235&id=146264#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D46669

Files:
  lldb/trunk/lit/Modules/lc_version_min.yaml
  lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp

Index: lldb/trunk/lit/Modules/lc_version_min.yaml
===
--- lldb/trunk/lit/Modules/lc_version_min.yaml
+++ lldb/trunk/lit/Modules/lc_version_min.yaml
@@ -0,0 +1,205 @@
+# RUN: yaml2obj %s > %t.out
+# RUN: lldb-test symbols %t.out | FileCheck %s
+# REQUIRES: darwin
+# Test that the deployment target is parsed from the load commands.
+# CHECK: x86_64-apple-macosx10.9.0
+--- !mach-o
+FileHeader:  
+  magic:   0xFEEDFACF
+  cputype: 0x0107
+  cpusubtype:  0x8003
+  filetype:0x0002
+  ncmds:   14
+  sizeofcmds:  728
+  flags:   0x00200085
+  reserved:0x
+LoadCommands:
+  - cmd: LC_SEGMENT_64
+cmdsize: 72
+segname: __PAGEZERO
+vmaddr:  0
+vmsize:  4294967296
+fileoff: 0
+filesize:0
+maxprot: 0
+initprot:0
+nsects:  0
+flags:   0
+  - cmd: LC_SEGMENT_64
+cmdsize: 232
+segname: __TEXT
+vmaddr:  4294967296
+vmsize:  4096
+fileoff: 0
+filesize:4096
+maxprot: 7
+initprot:5
+nsects:  2
+flags:   0
+Sections:
+  - sectname:__text
+segname: __TEXT
+addr:0x00010FB0
+size:8
+offset:  0x0FB0
+align:   0
+reloff:  0x
+nreloc:  0
+flags:   0x8400
+reserved1:   0x
+reserved2:   0x
+reserved3:   0x
+  - sectname:__unwind_info
+segname: __TEXT
+addr:0x00010FB8
+size:72
+offset:  0x0FB8
+align:   2
+reloff:  0x
+nreloc:  0
+flags:   0x
+reserved1:   0x
+reserved2:   0x
+reserved3:   0x
+  - cmd: LC_SEGMENT_64
+cmdsize: 72
+segname: __LINKEDIT
+vmaddr:  4294971392
+vmsize:  4096
+fileoff: 4096
+filesize:152
+maxprot: 7
+initprot:1
+nsects:  0
+flags:   0
+  - cmd: LC_DYLD_INFO_ONLY
+cmdsize: 48
+rebase_off:  0
+rebase_size: 0
+bind_off:0
+bind_size:   0
+weak_bind_off:   0
+weak_bind_size:  0
+lazy_bind_off:   0
+lazy_bind_size:  0
+export_off:  4096
+export_size: 48
+  - cmd: LC_SYMTAB
+cmdsize: 24
+symoff:  4152
+nsyms:   3
+stroff:  4200
+strsize: 48
+  - cmd: LC_DYSYMTAB
+cmdsize: 80
+ilocalsym:   0
+nlocalsym:   0
+iextdefsym:  0
+nextdefsym:  2
+iundefsym:   2
+nundefsym:   1
+tocoff:  0
+ntoc:0
+modtaboff:   0
+nmodtab: 0
+extrefsymoff:0
+nextrefsyms: 0
+indirectsymoff:  0
+nindirectsyms:   0
+extreloff:   0
+nextrel: 0
+locreloff:   0
+nlocrel: 0
+  - cmd: LC_LOAD_DYLINKER
+cmdsize: 32
+name:12
+PayloadString:   /usr/lib/dyld
+ZeroPadBytes:7
+  - cmd: LC_UUID
+cmdsize: 24
+uuid:E75E737C-4FB3-312D-9B17-10987F48F957
+  - cmd: LC_VERSION_MIN_MACOSX
+cmdsize: 16
+version: 657664
+sdk: 658944
+  - cmd: LC_SOURCE_VERSION
+cmdsize: 16
+version: 0
+  - cmd: LC_MAIN
+cmdsize: 24
+entryoff:4016
+stacksize:   0
+  - cmd: LC_LOAD_DYLIB
+cmdsize: 56
+dylib:   
+  name:24
+  timestamp:   2
+  current_version: 82102276
+  compatibility_version: 65536
+PayloadString:   /usr/lib/libSystem.B.dylib
+ZeroPadBytes:6
+  - cmd: LC_FUNCTION_STARTS
+cmdsize: 16
+dataoff: 4144
+datasize:8
+  - cmd: LC_DATA_IN_CODE
+cmdsize: 16
+d

[Lldb-commits] [PATCH] D46736: HostInfoMacOSX: Share the clang resource directory with Swift.

2018-05-11 Thread Phabricator via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL332111: HostInfoMacOSX: Share the clang resource directory 
with Swift. (authored by adrian, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D46736?vs=146259&id=146363#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D46736

Files:
  lldb/trunk/include/lldb/Host/macosx/HostInfoMacOSX.h
  lldb/trunk/source/Host/macosx/HostInfoMacOSX.mm
  lldb/trunk/unittests/Host/CMakeLists.txt
  lldb/trunk/unittests/Host/HostInfoTest.cpp

Index: lldb/trunk/include/lldb/Host/macosx/HostInfoMacOSX.h
===
--- lldb/trunk/include/lldb/Host/macosx/HostInfoMacOSX.h
+++ lldb/trunk/include/lldb/Host/macosx/HostInfoMacOSX.h
@@ -38,6 +38,8 @@
   static bool ComputeHeaderDirectory(FileSpec &file_spec);
   static bool ComputePythonDirectory(FileSpec &file_spec);
   static bool ComputeClangDirectory(FileSpec &file_spec);
+  static bool ComputeClangDirectory(FileSpec &lldb_shlib_spec,
+FileSpec &file_spec, bool verify);
   static bool ComputeSystemPluginsDirectory(FileSpec &file_spec);
   static bool ComputeUserPluginsDirectory(FileSpec &file_spec);
 };
Index: lldb/trunk/unittests/Host/HostInfoTest.cpp
===
--- lldb/trunk/unittests/Host/HostInfoTest.cpp
+++ lldb/trunk/unittests/Host/HostInfoTest.cpp
@@ -8,7 +8,9 @@
 //===--===//
 
 #include "lldb/Host/HostInfo.h"
+#include "lldb/Host/macosx/HostInfoMacOSX.h"
 #include "lldb/lldb-defines.h"
+#include "TestingSupport/TestUtilities.h"
 #include "gtest/gtest.h"
 
 using namespace lldb_private;
@@ -43,3 +45,41 @@
   EXPECT_EQ(HostInfo::GetAugmentedArchSpec(LLDB_ARCH_DEFAULT).GetTriple(),
 HostInfo::GetArchitecture(HostInfo::eArchKindDefault).GetTriple());
 }
+
+
+struct HostInfoMacOSXTest : public HostInfoMacOSX {
+  static std::string ComputeClangDir(std::string lldb_shlib_path,
+ bool verify = false) {
+FileSpec clang_dir;
+FileSpec lldb_shlib_spec(lldb_shlib_path, false);
+ComputeClangDirectory(lldb_shlib_spec, clang_dir, verify);
+return clang_dir.GetPath();
+  }
+};
+
+
+TEST_F(HostInfoTest, MacOSX) {
+  // This returns whatever the POSIX fallback returns.
+  std::string posix = "/usr/lib/liblldb.dylib";
+  EXPECT_FALSE(HostInfoMacOSXTest::ComputeClangDir(posix).empty());
+
+  std::string xcode =
+"/Applications/Xcode.app/Contents/SharedFrameworks/LLDB.framework";
+  std::string xcode_clang =
+"/Applications/Xcode.app/Contents/Developer/Toolchains/"
+"XcodeDefault.xctoolchain/usr/lib/swift/clang";
+  EXPECT_EQ(HostInfoMacOSXTest::ComputeClangDir(xcode), xcode_clang);
+
+  std::string toolchain =
+  "/Applications/Xcode.app/Contents/Developer/Toolchains/"
+  "Swift-4.1-development-snapshot.xctoolchain/System/Library/"
+  "PrivateFrameworks/LLDB.framework";
+  std::string toolchain_clang =
+  "/Applications/Xcode.app/Contents/Developer/Toolchains/"
+  "Swift-4.1-development-snapshot.xctoolchain/usr/lib/swift/clang";
+  EXPECT_EQ(HostInfoMacOSXTest::ComputeClangDir(toolchain), toolchain_clang);
+
+  // Test that a bogus path is detected.
+  EXPECT_NE(HostInfoMacOSXTest::ComputeClangDir(GetInputFilePath(xcode), true),
+HostInfoMacOSXTest::ComputeClangDir(GetInputFilePath(xcode)));
+}
Index: lldb/trunk/unittests/Host/CMakeLists.txt
===
--- lldb/trunk/unittests/Host/CMakeLists.txt
+++ lldb/trunk/unittests/Host/CMakeLists.txt
@@ -22,4 +22,5 @@
   LINK_LIBS
 lldbCore
 lldbHost
+lldbUtilityHelpers
   )
Index: lldb/trunk/source/Host/macosx/HostInfoMacOSX.mm
===
--- lldb/trunk/source/Host/macosx/HostInfoMacOSX.mm
+++ lldb/trunk/source/Host/macosx/HostInfoMacOSX.mm
@@ -19,6 +19,7 @@
 
 #include "llvm/ADT/SmallString.h"
 #include "llvm/Support/FileSystem.h"
+#include "llvm/Support/Path.h"
 #include "llvm/Support/raw_ostream.h"
 
 // C++ Includes
@@ -226,21 +227,67 @@
 #endif
 }
 
+static bool VerifyClangPath(const llvm::Twine &clang_path) {
+  if (llvm::sys::fs::is_directory(clang_path))
+return true;
+  Log *log = lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_HOST);
+  if (log)
+log->Printf("HostInfoMacOSX::ComputeClangDirectory(): "
+"failed to stat clang resource directory at \"%s\"",
+clang_path.str().c_str());
+  return false;
+}
+
 bool HostInfoMacOSX::ComputeClangDirectory(FileSpec &file_spec) {
   FileSpec lldb_file_spec;
   if (!GetLLDBPath(lldb::ePathTypeLLDBShlibDir, lldb_file_spec))
 return false;
+  return ComputeClangDirectory(lldb_file_spec, file_spec, true);
+}
 
-  std::string raw_path = lldb_file_spec.GetPath(

[Lldb-commits] [PATCH] D46783: FileSpec objects that resolve to "." should have "." in m_filename and m_directory empty.

2018-05-17 Thread Phabricator via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL332618: FileSpec objects that resolve to "." 
should have "." in m_filename and… (authored by gclayton, committed 
by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D46783?vs=146434&id=147329#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D46783

Files:
  lldb/trunk/source/Utility/FileSpec.cpp
  lldb/trunk/unittests/Utility/FileSpecTest.cpp


Index: lldb/trunk/unittests/Utility/FileSpecTest.cpp
===
--- lldb/trunk/unittests/Utility/FileSpecTest.cpp
+++ lldb/trunk/unittests/Utility/FileSpecTest.cpp
@@ -199,9 +199,10 @@
   {"/..", "/"},
   {"/.", "/"},
   {"..", ".."},
-  {".", ""},
+  {".", "."},
+  {"", "."},
   {"../..", "../.."},
-  {"foo/..", ""},
+  {"foo/..", "."},
   {"foo/../bar", "bar"},
   {"../foo/..", ".."},
   {"./foo", "foo"},
@@ -230,17 +231,18 @@
   {R"(\..)", R"(\..)"},
   //  {R"(c:..)", R"(c:..)"},
   {R"(..)", R"(..)"},
-  {R"(.)", R"()"},
+  {R"(.)", R"(.)"},
   // TODO: fix llvm::sys::path::remove_dots() to return "c:\" below.
   {R"(c:..\..)", R"(c:\..\..)"},
   {R"(..\..)", R"(..\..)"},
-  {R"(foo\..)", R"()"},
+  {R"(foo\..)", R"(.)"},
   {R"(foo\..\bar)", R"(bar)"},
   {R"(..\foo\..)", R"(..)"},
   {R"(.\foo)", R"(foo)"},
   {R"(.\.\foo)", R"(foo)"},
   {R"(..\foo)", R"(..\foo)"},
   {R"(..\..\foo)", R"(..\..\foo)"},
+  {"", "."},
   };
   for (auto test : windows_tests) {
 EXPECT_EQ(test.second,
Index: lldb/trunk/source/Utility/FileSpec.cpp
===
--- lldb/trunk/source/Utility/FileSpec.cpp
+++ lldb/trunk/source/Utility/FileSpec.cpp
@@ -258,6 +258,14 @@
   if (m_style == Style::windows)
 std::replace(resolved.begin(), resolved.end(), '\\', '/');
 
+  if (resolved.empty()) {
+// If we have no path after normalization set the path to the current
+// directory. This matches what python does and also a few other path
+// utilities. 
+m_filename.SetString(".");
+return;
+  }
+
   m_filename.SetString(llvm::sys::path::filename(resolved, m_style));
   llvm::StringRef dir = llvm::sys::path::parent_path(resolved, m_style);
   if (!dir.empty())


Index: lldb/trunk/unittests/Utility/FileSpecTest.cpp
===
--- lldb/trunk/unittests/Utility/FileSpecTest.cpp
+++ lldb/trunk/unittests/Utility/FileSpecTest.cpp
@@ -199,9 +199,10 @@
   {"/..", "/"},
   {"/.", "/"},
   {"..", ".."},
-  {".", ""},
+  {".", "."},
+  {"", "."},
   {"../..", "../.."},
-  {"foo/..", ""},
+  {"foo/..", "."},
   {"foo/../bar", "bar"},
   {"../foo/..", ".."},
   {"./foo", "foo"},
@@ -230,17 +231,18 @@
   {R"(\..)", R"(\..)"},
   //  {R"(c:..)", R"(c:..)"},
   {R"(..)", R"(..)"},
-  {R"(.)", R"()"},
+  {R"(.)", R"(.)"},
   // TODO: fix llvm::sys::path::remove_dots() to return "c:\" below.
   {R"(c:..\..)", R"(c:\..\..)"},
   {R"(..\..)", R"(..\..)"},
-  {R"(foo\..)", R"()"},
+  {R"(foo\..)", R"(.)"},
   {R"(foo\..\bar)", R"(bar)"},
   {R"(..\foo\..)", R"(..)"},
   {R"(.\foo)", R"(foo)"},
   {R"(.\.\foo)", R"(foo)"},
   {R"(..\foo)", R"(..\foo)"},
   {R"(..\..\foo)", R"(..\..\foo)"},
+  {"", "."},
   };
   for (auto test : windows_tests) {
 EXPECT_EQ(test.second,
Index: lldb/trunk/source/Utility/FileSpec.cpp
===
--- lldb/trunk/source/Utility/FileSpec.cpp
+++ lldb/trunk/source/Utility/FileSpec.cpp
@@ -258,6 +258,14 @@
   if (m_style == Style::windows)
 std::replace(resolved.begin(), resolved.end(), '\\', '/');
 
+  if (resolved.empty()) {
+// If we have no path after normalization set the path to the current
+// directory. This matches what python does and also a few other path
+// utilities. 
+m_filename.SetString(".");
+return;
+  }
+
   m_filename.SetString(llvm::sys::path::filename(resolved, m_style));
   llvm::StringRef dir = llvm::sys::path::parent_path(resolved, m_style);
   if (!dir.empty())
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D47021: Fix PathMappingList for relative and empty paths after recent FileSpec normalization changes

2018-05-21 Thread Phabricator via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL332842: Fix PathMappingList for relative and empty paths 
after recent FileSpec… (authored by gclayton, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D47021?vs=147587&id=147780#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D47021

Files:
  lldb/trunk/include/lldb/Target/PathMappingList.h
  lldb/trunk/lldb.xcodeproj/project.pbxproj
  lldb/trunk/source/Target/PathMappingList.cpp
  lldb/trunk/source/Target/Target.cpp
  lldb/trunk/source/Utility/FileSpec.cpp
  lldb/trunk/unittests/Target/CMakeLists.txt
  lldb/trunk/unittests/Target/PathMappingListTest.cpp
  lldb/trunk/unittests/Utility/FileSpecTest.cpp

Index: lldb/trunk/source/Target/Target.cpp
===
--- lldb/trunk/source/Target/Target.cpp
+++ lldb/trunk/source/Target/Target.cpp
@@ -328,11 +328,7 @@
   bool hardware,
   LazyBool move_to_nearest_code) {
   FileSpec remapped_file;
-  ConstString remapped_path;
-  if (GetSourcePathMap().ReverseRemapPath(ConstString(file.GetPath().c_str()),
-  remapped_path))
-remapped_file.SetFile(remapped_path.AsCString(), false);
-  else
+  if (!GetSourcePathMap().ReverseRemapPath(file, remapped_file))
 remapped_file = file;
 
   if (check_inlines == eLazyBoolCalculate) {
Index: lldb/trunk/source/Target/PathMappingList.cpp
===
--- lldb/trunk/source/Target/PathMappingList.cpp
+++ lldb/trunk/source/Target/PathMappingList.cpp
@@ -14,6 +14,7 @@
 
 // Other libraries and framework includes
 // Project includes
+#include "lldb/lldb-private-enumerations.h"
 #include "lldb/Host/PosixApi.h"
 #include "lldb/Target/PathMappingList.h"
 #include "lldb/Utility/FileSpec.h"
@@ -23,6 +24,22 @@
 using namespace lldb;
 using namespace lldb_private;
 
+namespace {
+  // We must normalize our path pairs that we store because if we don't then
+  // things won't always work. We found a case where if we did:
+  // (lldb) settings set target.source-map . /tmp
+  // We would store a path pairs of "." and "/tmp" as raw strings. If the debug
+  // info contains "./foo/bar.c", the path will get normalized to "foo/bar.c".
+  // When PathMappingList::RemapPath() is called, it expects the path to start
+  // with the raw path pair, which doesn't work anymore because the paths have
+  // been normalized when the debug info was loaded. So we need to store
+  // nomalized path pairs to ensure things match up.
+  ConstString NormalizePath(const ConstString &path) {
+// If we use "path" to construct a FileSpec, it will normalize the path for
+// us. We then grab the string and turn it back into a ConstString.
+return ConstString(FileSpec(path.GetStringRef(), false).GetPath());
+  }
+}
 //--
 // PathMappingList constructor
 //--
@@ -52,7 +69,7 @@
 void PathMappingList::Append(const ConstString &path,
  const ConstString &replacement, bool notify) {
   ++m_mod_id;
-  m_pairs.push_back(pair(path, replacement));
+  m_pairs.emplace_back(pair(NormalizePath(path), NormalizePath(replacement)));
   if (notify && m_callback)
 m_callback(*this, m_callback_baton);
 }
@@ -77,7 +94,8 @@
 insert_iter = m_pairs.end();
   else
 insert_iter = m_pairs.begin() + index;
-  m_pairs.insert(insert_iter, pair(path, replacement));
+  m_pairs.emplace(insert_iter, pair(NormalizePath(path),
+NormalizePath(replacement)));
   if (notify && m_callback)
 m_callback(*this, m_callback_baton);
 }
@@ -88,7 +106,7 @@
   if (index >= m_pairs.size())
 return false;
   ++m_mod_id;
-  m_pairs[index] = pair(path, replacement);
+  m_pairs[index] = pair(NormalizePath(path), NormalizePath(replacement));
   if (notify && m_callback)
 m_callback(*this, m_callback_baton);
   return true;
@@ -134,58 +152,53 @@
 
 bool PathMappingList::RemapPath(const ConstString &path,
 ConstString &new_path) const {
-  const char *path_cstr = path.GetCString();
-  // CLEANUP: Convert this function to use StringRefs internally instead
-  // of raw c-strings.
-  if (!path_cstr)
-return false;
-
-  const_iterator pos, end = m_pairs.end();
-  for (pos = m_pairs.begin(); pos != end; ++pos) {
-const size_t prefixLen = pos->first.GetLength();
-
-if (::strncmp(pos->first.GetCString(), path_cstr, prefixLen) == 0) {
-  std::string new_path_str(pos->second.GetCString());
-  new_path_str.append(path.GetCString() + prefixLen);
-  new_path.SetCString(new_path_str.c_str());
-  return true;
-}
+  std::string remapped;
+  if (RemapPath(path.GetStri

[Lldb-commits] [PATCH] D47110: [LLDB, lldb-mi] Add option --synchronous.

2018-05-23 Thread Phabricator via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL333140: Add a --synchronous option to lldb-mi to facilitate 
reliable testing. (authored by adrian, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D47110?vs=147806&id=148318#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D47110

Files:
  lldb/trunk/tools/lldb-mi/MICmnResources.cpp
  lldb/trunk/tools/lldb-mi/MICmnResources.h
  lldb/trunk/tools/lldb-mi/MIDriver.cpp
  lldb/trunk/tools/lldb-mi/MIDriverMgr.cpp


Index: lldb/trunk/tools/lldb-mi/MIDriverMgr.cpp
===
--- lldb/trunk/tools/lldb-mi/MIDriverMgr.cpp
+++ lldb/trunk/tools/lldb-mi/MIDriverMgr.cpp
@@ -640,6 +640,7 @@
   MIRSRC(IDE_MI_APP_ARG_VERSION), MIRSRC(IDE_MI_APP_ARG_VERSION_LONG),
   MIRSRC(IDE_MI_APP_ARG_INTERPRETER), MIRSRC(IDE_MI_APP_ARG_SOURCE),
   MIRSRC(IDE_MI_APP_ARG_EXECUTEABLE),
+  MIRSRC(IDE_MI_APP_ARG_SYNCHRONOUS),
   CMIUtilString::Format(
   MIRSRC(IDE_MI_APP_ARG_APP_LOG),
   CMICmnLogMediumFile::Instance().GetFileName().c_str()),
Index: lldb/trunk/tools/lldb-mi/MIDriver.cpp
===
--- lldb/trunk/tools/lldb-mi/MIDriver.cpp
+++ lldb/trunk/tools/lldb-mi/MIDriver.cpp
@@ -382,6 +382,7 @@
 //  that are only handled by *this driver:
 //  --executable 
 //  --source  or -s 
+//  --synchronous
 //  The application's options --interpreter and --executable in code 
act
 //  very similar.
 //  The --executable is necessary to differentiate whether the MI 
Driver
@@ -397,6 +398,7 @@
 //  argument for a debug session. Using --interpreter on the command
 //  line does not
 //  issue additional commands to initialise a debug session.
+//  Option --synchronous disables an asynchronous mode in the lldb-mi 
driver.
 // Type:Overridden.
 // Args:argc- (R)   An integer that contains the count of arguments
 // that follow in
@@ -469,6 +471,8 @@
 // command line
   { // See fn description.
 bHaveExecutableLongOption = true;
+  } else if (strArg.compare("--synchronous") == 0) {
+CMICmnLLDBDebugSessionInfo::Instance().GetDebugger().SetAsync(false);
   }
 }
   }
Index: lldb/trunk/tools/lldb-mi/MICmnResources.cpp
===
--- lldb/trunk/tools/lldb-mi/MICmnResources.cpp
+++ lldb/trunk/tools/lldb-mi/MICmnResources.cpp
@@ -110,6 +110,8 @@
 {IDE_MI_APP_ARG_EXECUTABLE, "executable (NOT IMPLEMENTED)\n\tThe file "
 "path to the executable i.e. '\"C:\\My "
 "Dev\\foo.exe\"'."},
+{IDE_MI_APP_ARG_SYNCHRONOUS, "--synchronous\n\tBlock until each 
command "
+ "has finished executing.\n\tUsed for 
testing only."},
 {IDS_STDIN_ERR_INVALID_PROMPT,
  "Stdin. Invalid prompt description '%s'"},
 {IDS_STDIN_ERR_THREAD_CREATION_FAILED,
Index: lldb/trunk/tools/lldb-mi/MICmnResources.h
===
--- lldb/trunk/tools/lldb-mi/MICmnResources.h
+++ lldb/trunk/tools/lldb-mi/MICmnResources.h
@@ -77,6 +77,7 @@
   IDE_MI_APP_ARG_APP_LOG_DIR,
   IDE_MI_APP_ARG_EXAMPLE,
   IDE_MI_APP_ARG_EXECUTABLE,
+  IDE_MI_APP_ARG_SYNCHRONOUS,
 
   IDS_STDIN_ERR_INVALID_PROMPT,
   IDS_STDIN_ERR_THREAD_CREATION_FAILED,


Index: lldb/trunk/tools/lldb-mi/MIDriverMgr.cpp
===
--- lldb/trunk/tools/lldb-mi/MIDriverMgr.cpp
+++ lldb/trunk/tools/lldb-mi/MIDriverMgr.cpp
@@ -640,6 +640,7 @@
   MIRSRC(IDE_MI_APP_ARG_VERSION), MIRSRC(IDE_MI_APP_ARG_VERSION_LONG),
   MIRSRC(IDE_MI_APP_ARG_INTERPRETER), MIRSRC(IDE_MI_APP_ARG_SOURCE),
   MIRSRC(IDE_MI_APP_ARG_EXECUTEABLE),
+  MIRSRC(IDE_MI_APP_ARG_SYNCHRONOUS),
   CMIUtilString::Format(
   MIRSRC(IDE_MI_APP_ARG_APP_LOG),
   CMICmnLogMediumFile::Instance().GetFileName().c_str()),
Index: lldb/trunk/tools/lldb-mi/MIDriver.cpp
===
--- lldb/trunk/tools/lldb-mi/MIDriver.cpp
+++ lldb/trunk/tools/lldb-mi/MIDriver.cpp
@@ -382,6 +382,7 @@
 //  that are only handled by *this driver:
 //  --executable 
 //  --source  or -s 
+//  --synchronous
 //  The application's options --interpreter and --executable in code act
 //  very similar.
 //  The --executable is necessary to differentiate whether the MI Driver
@@ -397,6 +398,7 @@
 //  argument for a debug session. Using --interpreter on the command
 //  line does not
 //  issue additional commands to initialise a d

[Lldb-commits] [PATCH] D46588: [LLDB][lldb-mi] Add possibility to set breakpoints without selecting a target.

2018-05-24 Thread Phabricator via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL333205: [lldb-mi] Add possibility to set breakpoints without 
selecting a target. (authored by adrian, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D46588?vs=148323&id=148436#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D46588

Files:
  lldb/trunk/lit/lit.cfg
  lldb/trunk/lit/tools/lldb-mi/breakpoint/break-insert.test
  lldb/trunk/lit/tools/lldb-mi/breakpoint/inputs/break-insert.c
  lldb/trunk/lit/tools/lldb-mi/breakpoint/lit.local.cfg
  lldb/trunk/tools/lldb-mi/MICmdCmdBreak.cpp
  lldb/trunk/tools/lldb-mi/MICmnLLDBDebugSessionInfo.cpp

Index: lldb/trunk/tools/lldb-mi/MICmdCmdBreak.cpp
===
--- lldb/trunk/tools/lldb-mi/MICmdCmdBreak.cpp
+++ lldb/trunk/tools/lldb-mi/MICmdCmdBreak.cpp
@@ -148,6 +148,11 @@
   CMICMDBASE_GETOPTION(pArgRestrictBrkPtToThreadId, OptionShort,
m_constStrArgNamedRestrictBrkPtToThreadId);
 
+  // Ask LLDB for the target to check if we have valid or dummy one.
+  CMICmnLLDBDebugSessionInfo &rSessionInfo(
+  CMICmnLLDBDebugSessionInfo::Instance());
+  lldb::SBTarget sbTarget = rSessionInfo.GetTarget();
+
   m_bBrkPtEnabled = !pArgDisableBrkPt->GetFound();
   m_bBrkPtIsTemp = pArgTempBrkPt->GetFound();
   m_bHaveArgOptionThreadGrp = pArgThreadGroup->GetFound();
@@ -157,7 +162,12 @@
 nThreadGrp);
 m_strArgOptionThreadGrp = CMIUtilString::Format("i%d", nThreadGrp);
   }
-  m_bBrkPtIsPending = pArgPendingBrkPt->GetFound();
+
+  if (sbTarget == rSessionInfo.GetDebugger().GetDummyTarget())
+m_bBrkPtIsPending = true;
+  else
+m_bBrkPtIsPending = pArgPendingBrkPt->GetFound();
+
   if (pArgLocation->GetFound())
 m_brkName = pArgLocation->GetValue();
   else if (m_bBrkPtIsPending) {
@@ -225,9 +235,6 @@
 
   // Ask LLDB to create a breakpoint
   bool bOk = MIstatus::success;
-  CMICmnLLDBDebugSessionInfo &rSessionInfo(
-  CMICmnLLDBDebugSessionInfo::Instance());
-  lldb::SBTarget sbTarget = rSessionInfo.GetTarget();
   switch (eBrkPtType) {
   case eBreakPoint_ByAddress:
 m_brkPt = sbTarget.BreakpointCreateByAddress(nAddress);
Index: lldb/trunk/tools/lldb-mi/MICmnLLDBDebugSessionInfo.cpp
===
--- lldb/trunk/tools/lldb-mi/MICmnLLDBDebugSessionInfo.cpp
+++ lldb/trunk/tools/lldb-mi/MICmnLLDBDebugSessionInfo.cpp
@@ -871,7 +871,10 @@
 // Throws:  None.
 //--
 lldb::SBTarget CMICmnLLDBDebugSessionInfo::GetTarget() const {
-  return GetDebugger().GetSelectedTarget();
+  auto target = GetDebugger().GetSelectedTarget();
+  if (target.IsValid())
+return target;
+  return GetDebugger().GetDummyTarget();
 }
 
 //++
Index: lldb/trunk/lit/lit.cfg
===
--- lldb/trunk/lit/lit.cfg
+++ lldb/trunk/lit/lit.cfg
@@ -58,6 +58,8 @@
 lldb = "%s -S %s/lit-lldb-init" % (lit.util.which('lldb', lldb_tools_dir),
config.test_source_root)
 
+lldbmi = lit.util.which('lldb-mi', lldb_tools_dir)
+
 if not os.path.exists(config.cc):
 config.cc = lit.util.which(config.cc, config.environment['PATH'])
 
@@ -79,6 +81,7 @@
 config.substitutions.append(('%cc', config.cc))
 config.substitutions.append(('%cxx', config.cxx))
 
+config.substitutions.append(('%lldbmi', lldbmi + " --synchronous"))
 config.substitutions.append(('%lldb', lldb))
 
 if debugserver is not None:
Index: lldb/trunk/lit/tools/lldb-mi/breakpoint/break-insert.test
===
--- lldb/trunk/lit/tools/lldb-mi/breakpoint/break-insert.test
+++ lldb/trunk/lit/tools/lldb-mi/breakpoint/break-insert.test
@@ -0,0 +1,15 @@
+# RUN: %cc %p/inputs/break-insert.c -g
+# RUN: %lldbmi < %s | FileCheck %s
+
+# Test that a breakpoint can be inserted before creating a target.
+
+-break-insert breakpoint
+# CHECK: ^done,bkpt={number="1"
+
+-file-exec-and-symbols a.out
+# CHECK: ^done
+
+-exec-run
+# CHECK: ^running
+# CHECK: *stopped,reason="breakpoint-hit"
+
Index: lldb/trunk/lit/tools/lldb-mi/breakpoint/inputs/break-insert.c
===
--- lldb/trunk/lit/tools/lldb-mi/breakpoint/inputs/break-insert.c
+++ lldb/trunk/lit/tools/lldb-mi/breakpoint/inputs/break-insert.c
@@ -0,0 +1,7 @@
+int breakpoint() { // Breakpoint will be set here.
+  return 0;
+}
+
+int main() {
+  return breakpoint();
+}
Index: lldb/trunk/lit/tools/lldb-mi/breakpoint/lit.local.cfg
===
--- lldb/trunk/lit/tools/lldb-mi/breakpoint/lit.local.cfg
+++ lldb/trunk/lit/tools/lldb-mi/breakpoint/lit.local.cfg
@@ -0,0 +1 @@
+config.suffixes = ['.test']
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D47508: [lldb-test] Add a testing harness for the JIT's IRMemoryMap

2018-05-30 Thread Phabricator via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL333583: [lldb-test] Add a testing harness for the JIT's 
IRMemoryMap (authored by vedantk, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D47508?vs=149173&id=149183#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D47508

Files:
  lldb/trunk/lit/Expr/TestIRMemoryMap.test
  lldb/trunk/source/Target/Process.cpp
  lldb/trunk/tools/lldb-test/lldb-test.cpp

Index: lldb/trunk/tools/lldb-test/lldb-test.cpp
===
--- lldb/trunk/tools/lldb-test/lldb-test.cpp
+++ lldb/trunk/tools/lldb-test/lldb-test.cpp
@@ -15,25 +15,31 @@
 #include "lldb/Core/Debugger.h"
 #include "lldb/Core/Module.h"
 #include "lldb/Core/Section.h"
+#include "lldb/Expression/IRMemoryMap.h"
 #include "lldb/Initialization/SystemLifetimeManager.h"
 #include "lldb/Interpreter/CommandInterpreter.h"
 #include "lldb/Interpreter/CommandReturnObject.h"
 #include "lldb/Symbol/ClangASTContext.h"
 #include "lldb/Symbol/ClangASTImporter.h"
 #include "lldb/Symbol/SymbolVendor.h"
 #include "lldb/Symbol/TypeList.h"
 #include "lldb/Symbol/VariableList.h"
+#include "lldb/Target/Process.h"
+#include "lldb/Target/Target.h"
 #include "lldb/Utility/CleanUp.h"
 #include "lldb/Utility/DataExtractor.h"
 #include "lldb/Utility/StreamString.h"
 
+#include "llvm/ADT/IntervalMap.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Support/CommandLine.h"
+#include "llvm/Support/MathExtras.h"
 #include "llvm/Support/ManagedStatic.h"
 #include "llvm/Support/Path.h"
 #include "llvm/Support/PrettyStackTrace.h"
 #include "llvm/Support/Signals.h"
 #include "llvm/Support/WithColor.h"
+#include 
 #include 
 
 using namespace lldb;
@@ -46,6 +52,15 @@
 cl::SubCommand ModuleSubcommand("module-sections",
 "Display LLDB Module Information");
 cl::SubCommand SymbolsSubcommand("symbols", "Dump symbols for an object file");
+cl::SubCommand IRMemoryMapSubcommand("ir-memory-map", "Test IRMemoryMap");
+cl::opt Log("log", cl::desc("Path to a log file"), cl::init(""),
+ cl::sub(IRMemoryMapSubcommand));
+
+/// Create a target using the file pointed to by \p Filename, or abort.
+TargetSP createTarget(Debugger &Dbg, const std::string &Filename);
+
+/// Read \p Filename into a null-terminated buffer, or abort.
+std::unique_ptr openFile(const std::string &Filename);
 
 namespace breakpoint {
 static cl::opt Target(cl::Positional, cl::desc(""),
@@ -135,8 +150,49 @@
 
 static int dumpSymbols(Debugger &Dbg);
 }
+
+namespace irmemorymap {
+static cl::opt Target(cl::Positional, cl::desc(""),
+   cl::Required,
+   cl::sub(IRMemoryMapSubcommand));
+static cl::opt CommandFile(cl::Positional,
+cl::desc(""),
+cl::init("-"),
+cl::sub(IRMemoryMapSubcommand));
+using AllocationT = std::pair;
+bool areAllocationsOverlapping(const AllocationT &L, const AllocationT &R);
+using AddrIntervalMap =
+  IntervalMap>;
+bool evalMalloc(IRMemoryMap &IRMemMap, StringRef Line,
+AddrIntervalMap &AllocatedIntervals);
+int evaluateMemoryMapCommands(Debugger &Dbg);
+} // namespace irmemorymap
+
 } // namespace opts
 
+TargetSP opts::createTarget(Debugger &Dbg, const std::string &Filename) {
+  TargetSP Target;
+  Status ST =
+  Dbg.GetTargetList().CreateTarget(Dbg, Filename, /*triple*/ "",
+   /*get_dependent_modules*/ false,
+   /*platform_options*/ nullptr, Target);
+  if (ST.Fail()) {
+errs() << formatv("Failed to create target '{0}: {1}\n", Filename, ST);
+exit(1);
+  }
+  return Target;
+}
+
+std::unique_ptr opts::openFile(const std::string &Filename) {
+  auto MB = MemoryBuffer::getFileOrSTDIN(Filename);
+  if (!MB) {
+errs() << formatv("Could not open file '{0}: {1}\n", Filename,
+  MB.getError().message());
+exit(1);
+  }
+  return std::move(*MB);
+}
+
 void opts::breakpoint::dumpState(const BreakpointList &List, LinePrinter &P) {
   P.formatLine("{0} breakpoint{1}", List.GetSize(), plural(List.GetSize()));
   if (List.GetSize() > 0)
@@ -177,7 +233,7 @@
 switch (Cmd[0]) {
 case '%':
   if (Cmd.consume_front("%p") && (Cmd.empty() || !isalnum(Cmd[0]))) {
-OS << sys::path::parent_path(CommandFile);
+OS << sys::path::parent_path(breakpoint::CommandFile);
 break;
   }
   // fall through
@@ -192,26 +248,11 @@
 }
 
 int opts::breakpoint::evaluateBreakpoints(Debugger &Dbg) {
-  TargetSP Target;
-  Status ST =
-  Dbg.GetTargetList().CreateTarget(Dbg, breakpoint::Target, /*triple*/ "",
-   /*get_dependent_modules*/ false,
-   /*platfor

[Lldb-commits] [PATCH] D47481: Initialize FunctionCaller::m_struct_valid

2018-05-31 Thread Phabricator via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL333690: Set m_struct_valid to initial value in ctor.   
(authored by jmolenda, committed by ).
Herald added a subscriber: llvm-commits.

Repository:
  rL LLVM

https://reviews.llvm.org/D47481

Files:
  lldb/trunk/source/Expression/FunctionCaller.cpp


Index: lldb/trunk/source/Expression/FunctionCaller.cpp
===
--- lldb/trunk/source/Expression/FunctionCaller.cpp
+++ lldb/trunk/source/Expression/FunctionCaller.cpp
@@ -48,7 +48,8 @@
   m_function_return_type(return_type),
   m_wrapper_function_name("__lldb_caller_function"),
   m_wrapper_struct_name("__lldb_caller_struct"), m_wrapper_args_addrs(),
-  m_arg_values(arg_value_list), m_compiled(false), m_JITted(false) {
+  m_struct_valid(false), m_arg_values(arg_value_list), m_compiled(false),
+  m_JITted(false) {
   m_jit_process_wp = lldb::ProcessWP(exe_scope.CalculateProcess());
   // Can't make a FunctionCaller without a process.
   assert(m_jit_process_wp.lock());


Index: lldb/trunk/source/Expression/FunctionCaller.cpp
===
--- lldb/trunk/source/Expression/FunctionCaller.cpp
+++ lldb/trunk/source/Expression/FunctionCaller.cpp
@@ -48,7 +48,8 @@
   m_function_return_type(return_type),
   m_wrapper_function_name("__lldb_caller_function"),
   m_wrapper_struct_name("__lldb_caller_struct"), m_wrapper_args_addrs(),
-  m_arg_values(arg_value_list), m_compiled(false), m_JITted(false) {
+  m_struct_valid(false), m_arg_values(arg_value_list), m_compiled(false),
+  m_JITted(false) {
   m_jit_process_wp = lldb::ProcessWP(exe_scope.CalculateProcess());
   // Can't make a FunctionCaller without a process.
   assert(m_jit_process_wp.lock());
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D47551: [IRMemoryMap] Fix the alignment adjustment in Malloc

2018-05-31 Thread Phabricator 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 rL333697: [IRMemoryMap] Fix the alignment adjustment in Malloc 
(authored by vedantk, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D47551?vs=149355&id=149366#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D47551

Files:
  lldb/trunk/lit/Expr/Inputs/ir-memory-map-basic.test
  lldb/trunk/lit/Expr/Inputs/ir-memory-map-overlap1.test
  lldb/trunk/lit/Expr/TestIRMemoryMap.test
  lldb/trunk/source/Expression/IRMemoryMap.cpp

Index: lldb/trunk/source/Expression/IRMemoryMap.cpp
===
--- lldb/trunk/source/Expression/IRMemoryMap.cpp
+++ lldb/trunk/source/Expression/IRMemoryMap.cpp
@@ -301,15 +301,21 @@
   lldb::addr_t allocation_address = LLDB_INVALID_ADDRESS;
   lldb::addr_t aligned_address = LLDB_INVALID_ADDRESS;
 
-  size_t alignment_mask = alignment - 1;
   size_t allocation_size;
 
-  if (size == 0)
+  if (size == 0) {
+// FIXME: Malloc(0) should either return an invalid address or assert, in
+// order to cut down on unnecessary allocations.
 allocation_size = alignment;
-  else
-allocation_size = (size & alignment_mask)
-  ? ((size + alignment) & (~alignment_mask))
-  : size;
+  } else {
+// Round up the requested size to an aligned value.
+allocation_size = llvm::alignTo(size, alignment);
+
+// The process page cache does not see the requested alignment. We can't
+// assume its result will be any more than 1-byte aligned. To work around
+// this, request `alignment - 1` additional bytes.
+allocation_size += alignment - 1;
+  }
 
   switch (policy) {
   default:
Index: lldb/trunk/lit/Expr/Inputs/ir-memory-map-overlap1.test
===
--- lldb/trunk/lit/Expr/Inputs/ir-memory-map-overlap1.test
+++ lldb/trunk/lit/Expr/Inputs/ir-memory-map-overlap1.test
@@ -0,0 +1,10 @@
+malloc 8 16
+malloc 16 8
+malloc 64 32
+malloc 1 8
+malloc 64 32
+malloc 64 8
+malloc 1024 32
+malloc 1 16
+malloc 8 16
+malloc 1024 16
\ No newline at end of file
Index: lldb/trunk/lit/Expr/Inputs/ir-memory-map-basic.test
===
--- lldb/trunk/lit/Expr/Inputs/ir-memory-map-basic.test
+++ lldb/trunk/lit/Expr/Inputs/ir-memory-map-basic.test
@@ -0,0 +1,25 @@
+malloc 0 1
+malloc 1 1
+
+malloc 2 1
+malloc 2 2
+malloc 2 4
+
+malloc 3 1
+malloc 3 2
+malloc 3 4
+
+malloc 128 1
+malloc 128 2
+malloc 128 4
+malloc 128 128
+
+malloc 2048 1
+malloc 2048 2
+malloc 2048 4
+
+malloc 3968 1
+malloc 3968 2
+malloc 3968 4
+
+malloc 0 1
Index: lldb/trunk/lit/Expr/TestIRMemoryMap.test
===
--- lldb/trunk/lit/Expr/TestIRMemoryMap.test
+++ lldb/trunk/lit/Expr/TestIRMemoryMap.test
@@ -1,28 +1,3 @@
 # RUN: %cxx %p/Inputs/call-function.cpp -g -o %t
-# RUN: lldb-test ir-memory-map %t %s
-
-malloc 0 1
-malloc 1 1
-
-malloc 2 1
-malloc 2 2
-malloc 2 4
-
-malloc 3 1
-malloc 3 2
-malloc 3 4
-
-malloc 128 1
-malloc 128 2
-malloc 128 4
-malloc 128 128
-
-malloc 2048 1
-malloc 2048 2
-malloc 2048 4
-
-malloc 3968 1
-malloc 3968 2
-malloc 3968 4
-
-malloc 0 1
+# RUN: lldb-test ir-memory-map %t %S/Inputs/ir-memory-map-basic.test
+# RUN: lldb-test ir-memory-map %t %S/Inputs/ir-memory-map-overlap1.test
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D47678: [lldb, lldm-mi] Fix hanging of -exec-run command.

2018-06-03 Thread Phabricator via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL333844: [lldb, lldm-mi] Fix hanging of -exec-run command. 
(authored by apolyakov, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D47678?vs=149626&id=149641#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D47678

Files:
  lldb/trunk/lit/tools/lldb-mi/exec/exec-run-wrong-binary.test
  lldb/trunk/lit/tools/lldb-mi/exec/lit.local.cfg
  lldb/trunk/tools/lldb-mi/MICmdCmdExec.cpp


Index: lldb/trunk/tools/lldb-mi/MICmdCmdExec.cpp
===
--- lldb/trunk/tools/lldb-mi/MICmdCmdExec.cpp
+++ lldb/trunk/tools/lldb-mi/MICmdCmdExec.cpp
@@ -99,6 +99,19 @@
 bool CMICmdCmdExecRun::Execute() {
   CMICmnLLDBDebugSessionInfo &rSessionInfo(
   CMICmnLLDBDebugSessionInfo::Instance());
+
+  {
+// Check we have a valid target.
+// Note: target created via 'file-exec-and-symbols' command.
+lldb::SBTarget sbTarget = rSessionInfo.GetTarget();
+if (!sbTarget.IsValid() ||
+sbTarget == rSessionInfo.GetDebugger().GetDummyTarget()) {
+  
SetError(CMIUtilString::Format(MIRSRC(IDS_CMD_ERR_INVALID_TARGET_CURRENT),
+ m_cmdData.strMiCmd.c_str()));
+  return MIstatus::failure;
+}
+  }
+
   lldb::SBError error;
   lldb::SBStream errMsg;
   lldb::SBLaunchInfo launchInfo = rSessionInfo.GetTarget().GetLaunchInfo();
Index: lldb/trunk/lit/tools/lldb-mi/exec/exec-run-wrong-binary.test
===
--- lldb/trunk/lit/tools/lldb-mi/exec/exec-run-wrong-binary.test
+++ lldb/trunk/lit/tools/lldb-mi/exec/exec-run-wrong-binary.test
@@ -0,0 +1,6 @@
+# RUN: %lldbmi < %s | FileCheck %s
+
+# Test that -exec-run command won't hang in case of wrong name of binary file.
+
+-file-exec-and-symbols name.exe
+# CHECK: ^error,msg="Command 'file-exec-and-symbols'. Target binary 'name.exe' 
is invalid.
Index: lldb/trunk/lit/tools/lldb-mi/exec/lit.local.cfg
===
--- lldb/trunk/lit/tools/lldb-mi/exec/lit.local.cfg
+++ lldb/trunk/lit/tools/lldb-mi/exec/lit.local.cfg
@@ -0,0 +1 @@
+config.suffixes = ['.test']


Index: lldb/trunk/tools/lldb-mi/MICmdCmdExec.cpp
===
--- lldb/trunk/tools/lldb-mi/MICmdCmdExec.cpp
+++ lldb/trunk/tools/lldb-mi/MICmdCmdExec.cpp
@@ -99,6 +99,19 @@
 bool CMICmdCmdExecRun::Execute() {
   CMICmnLLDBDebugSessionInfo &rSessionInfo(
   CMICmnLLDBDebugSessionInfo::Instance());
+
+  {
+// Check we have a valid target.
+// Note: target created via 'file-exec-and-symbols' command.
+lldb::SBTarget sbTarget = rSessionInfo.GetTarget();
+if (!sbTarget.IsValid() ||
+sbTarget == rSessionInfo.GetDebugger().GetDummyTarget()) {
+  SetError(CMIUtilString::Format(MIRSRC(IDS_CMD_ERR_INVALID_TARGET_CURRENT),
+ m_cmdData.strMiCmd.c_str()));
+  return MIstatus::failure;
+}
+  }
+
   lldb::SBError error;
   lldb::SBStream errMsg;
   lldb::SBLaunchInfo launchInfo = rSessionInfo.GetTarget().GetLaunchInfo();
Index: lldb/trunk/lit/tools/lldb-mi/exec/exec-run-wrong-binary.test
===
--- lldb/trunk/lit/tools/lldb-mi/exec/exec-run-wrong-binary.test
+++ lldb/trunk/lit/tools/lldb-mi/exec/exec-run-wrong-binary.test
@@ -0,0 +1,6 @@
+# RUN: %lldbmi < %s | FileCheck %s
+
+# Test that -exec-run command won't hang in case of wrong name of binary file.
+
+-file-exec-and-symbols name.exe
+# CHECK: ^error,msg="Command 'file-exec-and-symbols'. Target binary 'name.exe' is invalid.
Index: lldb/trunk/lit/tools/lldb-mi/exec/lit.local.cfg
===
--- lldb/trunk/lit/tools/lldb-mi/exec/lit.local.cfg
+++ lldb/trunk/lit/tools/lldb-mi/exec/lit.local.cfg
@@ -0,0 +1 @@
+config.suffixes = ['.test']
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D47646: [IRMemoryMap] Use labels in the "malloc" and "free" lldb-test commands

2018-06-04 Thread Phabricator via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL333930: [IRMemoryMap] Use labels in the "malloc" 
and "free" lldb-test commands (authored by vedantk, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D47646?vs=149517&id=149800#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D47646

Files:
  lldb/trunk/lit/Expr/Inputs/ir-memory-map-basic
  lldb/trunk/lit/Expr/Inputs/ir-memory-map-mix-malloc-free
  lldb/trunk/lit/Expr/Inputs/ir-memory-map-overlap1
  lldb/trunk/tools/lldb-test/lldb-test.cpp

Index: lldb/trunk/tools/lldb-test/lldb-test.cpp
===
--- lldb/trunk/tools/lldb-test/lldb-test.cpp
+++ lldb/trunk/tools/lldb-test/lldb-test.cpp
@@ -167,13 +167,25 @@
 cl::init(false), cl::sub(IRMemoryMapSubcommand));
 
 using AllocationT = std::pair;
-bool areAllocationsOverlapping(const AllocationT &L, const AllocationT &R);
 using AddrIntervalMap =
   IntervalMap>;
-bool evalMalloc(IRMemoryMap &IRMemMap, StringRef Line,
-AddrIntervalMap &AllocatedIntervals);
-bool evalFree(IRMemoryMap &IRMemMap, StringRef Line,
-  AddrIntervalMap &AllocatedIntervals);
+
+struct IRMemoryMapTestState {
+  TargetSP Target;
+  IRMemoryMap Map;
+
+  AddrIntervalMap::Allocator IntervalMapAllocator;
+  AddrIntervalMap Allocations;
+
+  StringMap Label2AddrMap;
+
+  IRMemoryMapTestState(TargetSP Target)
+  : Target(Target), Map(Target), Allocations(IntervalMapAllocator) {}
+};
+
+bool areAllocationsOverlapping(const AllocationT &L, const AllocationT &R);
+bool evalMalloc(StringRef Line, IRMemoryMapTestState &State);
+bool evalFree(StringRef Line, IRMemoryMapTestState &State);
 int evaluateMemoryMapCommands(Debugger &Dbg);
 } // namespace irmemorymap
 
@@ -514,17 +526,23 @@
   return R.first < L.second && L.first < R.second;
 }
 
-bool opts::irmemorymap::evalMalloc(IRMemoryMap &IRMemMap, StringRef Line,
-   AddrIntervalMap &AllocatedIntervals) {
-  // ::= malloc  
+bool opts::irmemorymap::evalMalloc(StringRef Line,
+   IRMemoryMapTestState &State) {
+  // ::=  = malloc  
+  StringRef Label;
+  std::tie(Label, Line) = Line.split('=');
+  if (Line.empty())
+return false;
+  Label = Label.trim();
+  Line = Line.trim();
   size_t Size;
   uint8_t Alignment;
   int Matches = sscanf(Line.data(), "malloc %zu %hhu", &Size, &Alignment);
   if (Matches != 2)
 return false;
 
-  outs() << formatv("Command: malloc(size={0}, alignment={1})\n", Size,
-Alignment);
+  outs() << formatv("Command: {0} = malloc(size={1}, alignment={2})\n", Label,
+Size, Alignment);
   if (!isPowerOf2_32(Alignment)) {
 outs() << "Malloc error: alignment is not a power of 2\n";
 exit(1);
@@ -539,7 +557,7 @@
   const bool ZeroMemory = false;
   Status ST;
   addr_t Addr =
-  IRMemMap.Malloc(Size, Alignment, Permissions, AP, ZeroMemory, ST);
+  State.Map.Malloc(Size, Alignment, Permissions, AP, ZeroMemory, ST);
   if (ST.Fail()) {
 outs() << formatv("Malloc error: {0}\n", ST);
 return true;
@@ -557,10 +575,10 @@
   // Check that the allocation does not overlap another allocation. Do so by
   // testing each allocation which may cover the interval [Addr, EndOfRegion).
   addr_t EndOfRegion = Addr + Size;
-  auto Probe = AllocatedIntervals.begin();
+  auto Probe = State.Allocations.begin();
   Probe.advanceTo(Addr); //< First interval s.t stop >= Addr.
   AllocationT NewAllocation = {Addr, EndOfRegion};
-  while (Probe != AllocatedIntervals.end() && Probe.start() < EndOfRegion) {
+  while (Probe != State.Allocations.end() && Probe.start() < EndOfRegion) {
 AllocationT ProbeAllocation = {Probe.start(), Probe.stop()};
 if (areAllocationsOverlapping(ProbeAllocation, NewAllocation)) {
   outs() << "Malloc error: overlapping allocation detected"
@@ -575,41 +593,42 @@
   // to inhibit interval coalescing.
   static unsigned AllocationID = 0;
   if (Size)
-AllocatedIntervals.insert(Addr, EndOfRegion, AllocationID++);
+State.Allocations.insert(Addr, EndOfRegion, AllocationID++);
+
+  // Store the label -> address mapping.
+  State.Label2AddrMap[Label] = Addr;
 
   return true;
 }
 
-bool opts::irmemorymap::evalFree(IRMemoryMap &IRMemMap, StringRef Line,
- AddrIntervalMap &AllocatedIntervals) {
-  // ::= free 
-  size_t AllocIndex;
-  int Matches = sscanf(Line.data(), "free %zu", &AllocIndex);
-  if (Matches != 1)
+bool opts::irmemorymap::evalFree(StringRef Line, IRMemoryMapTestState &State) {
+  // ::= free 
+  if (!Line.consume_front("free"))
 return false;
+  StringRef Label = Line.trim();
 
-  outs() << formatv("Command: free(allocation-index={0})\n", AllocIndex);
-
-  // Find and free the AllocIndex-th allocation.
-  auto Probe = AllocatedIntervals.begin();
-  for (size_t I = 0; I < AllocIndex 

[Lldb-commits] [PATCH] D47679: [lldb, lldb-mi] Enable lldb-mi -break-insert test on Windows.

2018-06-04 Thread Phabricator via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL333963: [lldb, lldb-mi] Enable lldb-mi -break-insert test on 
Windows. (authored by apolyakov, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D47679?vs=149629&id=149863#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D47679

Files:
  lldb/trunk/lit/tools/lldb-mi/breakpoint/break-insert.test


Index: lldb/trunk/lit/tools/lldb-mi/breakpoint/break-insert.test
===
--- lldb/trunk/lit/tools/lldb-mi/breakpoint/break-insert.test
+++ lldb/trunk/lit/tools/lldb-mi/breakpoint/break-insert.test
@@ -1,16 +1,15 @@
-# REQUIRES: nowindows
+# XFAIL: windows
 # -> llvm.org/pr24452
-# Rather than XFAILing the test, skip it on Windows because it hangs
-
-# RUN: %cc %p/inputs/break-insert.c -g
+#
+# RUN: %cc -o a.exe %p/inputs/break-insert.c -g
 # RUN: %lldbmi < %s | FileCheck %s
 
 # Test that a breakpoint can be inserted before creating a target.
 
 -break-insert breakpoint
 # CHECK: ^done,bkpt={number="1"
 
--file-exec-and-symbols a.out
+-file-exec-and-symbols a.exe
 # CHECK: ^done
 
 -exec-run


Index: lldb/trunk/lit/tools/lldb-mi/breakpoint/break-insert.test
===
--- lldb/trunk/lit/tools/lldb-mi/breakpoint/break-insert.test
+++ lldb/trunk/lit/tools/lldb-mi/breakpoint/break-insert.test
@@ -1,16 +1,15 @@
-# REQUIRES: nowindows
+# XFAIL: windows
 # -> llvm.org/pr24452
-# Rather than XFAILing the test, skip it on Windows because it hangs
-
-# RUN: %cc %p/inputs/break-insert.c -g
+#
+# RUN: %cc -o a.exe %p/inputs/break-insert.c -g
 # RUN: %lldbmi < %s | FileCheck %s
 
 # Test that a breakpoint can be inserted before creating a target.
 
 -break-insert breakpoint
 # CHECK: ^done,bkpt={number="1"
 
--file-exec-and-symbols a.out
+-file-exec-and-symbols a.exe
 # CHECK: ^done
 
 -exec-run
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D48302: Search for kext variants is searching from parent directory when it should not be

2018-06-19 Thread Phabricator via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL335079: Correct the pathname that 
PlatformDarwinKernel::ExamineKextForMatchingUUID (authored by jmolenda, 
committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D48302?vs=151809&id=151981#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D48302

Files:
  lldb/trunk/source/Plugins/Platform/MacOSX/PlatformDarwinKernel.cpp
  lldb/trunk/source/Plugins/Platform/MacOSX/PlatformDarwinKernel.h


Index: lldb/trunk/source/Plugins/Platform/MacOSX/PlatformDarwinKernel.cpp
===
--- lldb/trunk/source/Plugins/Platform/MacOSX/PlatformDarwinKernel.cpp
+++ lldb/trunk/source/Plugins/Platform/MacOSX/PlatformDarwinKernel.cpp
@@ -780,10 +780,10 @@
 }
 
 std::vector
-PlatformDarwinKernel::SearchForExecutablesRecursively(const ConstString &dir) {
+PlatformDarwinKernel::SearchForExecutablesRecursively(const std::string &dir) {
   std::vector executables;
   std::error_code EC;
-  for (llvm::sys::fs::recursive_directory_iterator it(dir.GetStringRef(), EC),
+  for (llvm::sys::fs::recursive_directory_iterator it(dir.c_str(), EC),
end;
it != end && !EC; it.increment(EC)) {
 auto status = it->status();
@@ -800,7 +800,7 @@
 const FileSpec &kext_bundle_path, const lldb_private::UUID &uuid,
 const ArchSpec &arch, ModuleSP &exe_module_sp) {
   for (const auto &exe_file :
-   SearchForExecutablesRecursively(kext_bundle_path.GetDirectory())) {
+   SearchForExecutablesRecursively(kext_bundle_path.GetPath())) {
 if (exe_file.Exists()) {
   ModuleSpec exe_spec(exe_file);
   exe_spec.GetUUID() = uuid;
Index: lldb/trunk/source/Plugins/Platform/MacOSX/PlatformDarwinKernel.h
===
--- lldb/trunk/source/Plugins/Platform/MacOSX/PlatformDarwinKernel.h
+++ lldb/trunk/source/Plugins/Platform/MacOSX/PlatformDarwinKernel.h
@@ -128,7 +128,7 @@
   bool recurse);
 
   static std::vector
-  SearchForExecutablesRecursively(const lldb_private::ConstString &dir);
+  SearchForExecutablesRecursively(const std::string &dir);
 
   static void AddKextToMap(PlatformDarwinKernel *thisp,
const lldb_private::FileSpec &file_spec);


Index: lldb/trunk/source/Plugins/Platform/MacOSX/PlatformDarwinKernel.cpp
===
--- lldb/trunk/source/Plugins/Platform/MacOSX/PlatformDarwinKernel.cpp
+++ lldb/trunk/source/Plugins/Platform/MacOSX/PlatformDarwinKernel.cpp
@@ -780,10 +780,10 @@
 }
 
 std::vector
-PlatformDarwinKernel::SearchForExecutablesRecursively(const ConstString &dir) {
+PlatformDarwinKernel::SearchForExecutablesRecursively(const std::string &dir) {
   std::vector executables;
   std::error_code EC;
-  for (llvm::sys::fs::recursive_directory_iterator it(dir.GetStringRef(), EC),
+  for (llvm::sys::fs::recursive_directory_iterator it(dir.c_str(), EC),
end;
it != end && !EC; it.increment(EC)) {
 auto status = it->status();
@@ -800,7 +800,7 @@
 const FileSpec &kext_bundle_path, const lldb_private::UUID &uuid,
 const ArchSpec &arch, ModuleSP &exe_module_sp) {
   for (const auto &exe_file :
-   SearchForExecutablesRecursively(kext_bundle_path.GetDirectory())) {
+   SearchForExecutablesRecursively(kext_bundle_path.GetPath())) {
 if (exe_file.Exists()) {
   ModuleSpec exe_spec(exe_file);
   exe_spec.GetUUID() = uuid;
Index: lldb/trunk/source/Plugins/Platform/MacOSX/PlatformDarwinKernel.h
===
--- lldb/trunk/source/Plugins/Platform/MacOSX/PlatformDarwinKernel.h
+++ lldb/trunk/source/Plugins/Platform/MacOSX/PlatformDarwinKernel.h
@@ -128,7 +128,7 @@
   bool recurse);
 
   static std::vector
-  SearchForExecutablesRecursively(const lldb_private::ConstString &dir);
+  SearchForExecutablesRecursively(const std::string &dir);
 
   static void AddKextToMap(PlatformDarwinKernel *thisp,
const lldb_private::FileSpec &file_spec);
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D48868: [LLDB] In ProcessGDBRemote::UpdateThreadIDList(), the thread PCs should not be cleared after they are updated from the stop reply packet

2018-07-12 Thread Phabricator via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL336956: Remove incorrect thread-pc-values clearing (authored 
by jmolenda, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D48868?vs=154947&id=155291#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D48868

Files:
  lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp


Index: lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
===
--- lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
+++ lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
@@ -1523,7 +1523,6 @@
 size_t
 ProcessGDBRemote::UpdateThreadIDsFromStopReplyThreadsValue(std::string &value) 
{
   m_thread_ids.clear();
-  m_thread_pcs.clear();
   size_t comma_pos;
   lldb::tid_t tid;
   while ((comma_pos = value.find(',')) != std::string::npos) {


Index: lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
===
--- lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
+++ lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
@@ -1523,7 +1523,6 @@
 size_t
 ProcessGDBRemote::UpdateThreadIDsFromStopReplyThreadsValue(std::string &value) {
   m_thread_ids.clear();
-  m_thread_pcs.clear();
   size_t comma_pos;
   lldb::tid_t tid;
   while ((comma_pos = value.find(',')) != std::string::npos) {
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D49579: Support parsing minidump files that are created by Breakpad.

2018-07-23 Thread Phabricator via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL337694: Add support for parsing Breakpad minidump files that 
can have extra padding in… (authored by gclayton, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D49579?vs=156545&id=156779#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D49579

Files:
  lldb/trunk/source/Plugins/Process/minidump/MinidumpTypes.cpp
  lldb/trunk/unittests/Process/minidump/CMakeLists.txt
  lldb/trunk/unittests/Process/minidump/Inputs/memory-list-not-padded.dmp
  lldb/trunk/unittests/Process/minidump/Inputs/memory-list-padded.dmp
  lldb/trunk/unittests/Process/minidump/Inputs/module-list-not-padded.dmp
  lldb/trunk/unittests/Process/minidump/Inputs/module-list-padded.dmp
  lldb/trunk/unittests/Process/minidump/Inputs/thread-list-not-padded.dmp
  lldb/trunk/unittests/Process/minidump/Inputs/thread-list-padded.dmp
  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
@@ -84,6 +84,76 @@
   EXPECT_EQ(1232UL, context.size());
 }
 
+TEST_F(MinidumpParserTest, GetThreadListNotPadded) {
+  // Verify that we can load a thread list that doesn't have 4 bytes of padding
+  // after the thread count.
+  SetUpData("thread-list-not-padded.dmp");
+  llvm::ArrayRef thread_list;
+  
+  thread_list = parser->GetThreads();
+  ASSERT_EQ(2UL, thread_list.size());
+  EXPECT_EQ(0x11223344UL, thread_list[0].thread_id);
+  EXPECT_EQ(0x55667788UL, thread_list[1].thread_id);
+}
+
+TEST_F(MinidumpParserTest, GetThreadListPadded) {
+  // Verify that we can load a thread list that has 4 bytes of padding
+  // after the thread count as found in breakpad minidump files.
+  SetUpData("thread-list-padded.dmp");
+  auto thread_list = parser->GetThreads();
+  ASSERT_EQ(2UL, thread_list.size());
+  EXPECT_EQ(0x11223344UL, thread_list[0].thread_id);
+  EXPECT_EQ(0x55667788UL, thread_list[1].thread_id);
+}
+
+TEST_F(MinidumpParserTest, GetModuleListNotPadded) {
+  // Verify that we can load a module list that doesn't have 4 bytes of padding
+  // after the module count.
+  SetUpData("module-list-not-padded.dmp");
+  auto module_list = parser->GetModuleList();
+  ASSERT_EQ(2UL, module_list.size());
+  EXPECT_EQ(0x1000UL, module_list[0].base_of_image);
+  EXPECT_EQ(0x2000UL, module_list[0].size_of_image);
+  EXPECT_EQ(0x5000UL, module_list[1].base_of_image);
+  EXPECT_EQ(0x3000UL, module_list[1].size_of_image);
+}
+
+TEST_F(MinidumpParserTest, GetModuleListPadded) {
+  // Verify that we can load a module list that has 4 bytes of padding
+  // after the module count as found in breakpad minidump files.
+  SetUpData("module-list-padded.dmp");
+  auto module_list = parser->GetModuleList();
+  ASSERT_EQ(2UL, module_list.size());
+  EXPECT_EQ(0x1000UL, module_list[0].base_of_image);
+  EXPECT_EQ(0x2000UL, module_list[0].size_of_image);
+  EXPECT_EQ(0x5000UL, module_list[1].base_of_image);
+  EXPECT_EQ(0x3000UL, module_list[1].size_of_image);
+}
+
+TEST_F(MinidumpParserTest, GetMemoryListNotPadded) {
+  // Verify that we can load a memory list that doesn't have 4 bytes of padding
+  // after the memory range count.
+  SetUpData("memory-list-not-padded.dmp");
+  auto mem = parser->FindMemoryRange(0x8000);
+  ASSERT_TRUE(mem.hasValue());
+  EXPECT_EQ((lldb::addr_t)0x8000, mem->start);
+  mem = parser->FindMemoryRange(0x8010);
+  ASSERT_TRUE(mem.hasValue());
+  EXPECT_EQ((lldb::addr_t)0x8010, mem->start);
+}
+
+TEST_F(MinidumpParserTest, GetMemoryListPadded) {
+  // Verify that we can load a memory list that has 4 bytes of padding
+  // after the memory range count as found in breakpad minidump files.
+  SetUpData("memory-list-padded.dmp");
+  auto mem = parser->FindMemoryRange(0x8000);
+  ASSERT_TRUE(mem.hasValue());
+  EXPECT_EQ((lldb::addr_t)0x8000, mem->start);
+  mem = parser->FindMemoryRange(0x8010);
+  ASSERT_TRUE(mem.hasValue());
+  EXPECT_EQ((lldb::addr_t)0x8010, mem->start);
+}
+
 TEST_F(MinidumpParserTest, TruncatedMinidumps) {
   InvalidMinidump("linux-x86_64.dmp", 32);
   InvalidMinidump("linux-x86_64.dmp", 100);
Index: lldb/trunk/unittests/Process/minidump/CMakeLists.txt
===
--- lldb/trunk/unittests/Process/minidump/CMakeLists.txt
+++ lldb/trunk/unittests/Process/minidump/CMakeLists.txt
@@ -19,6 +19,12 @@
fizzbuzz_no_heap.dmp
fizzbuzz_wow64.dmp
bad_duplicate_streams.dmp
-   bad_overlapping_streams.dmp)
+   bad_overlapping_streams.dmp
+   thread-list-padded.dmp
+   thread-list-not-padded.dmp
+   module-list-padded.dmp
+   module-list-not-padded.dmp
+   memory-list-padded.dmp
+   memory-list-not-padded.dmp)
 
 add_unittest_inputs(LLDBMinidumpTests "${test_inputs}")

[Lldb-commits] [PATCH] D49612: Use LLVM's new ItaniumPartialDemangler in LLDB

2018-07-25 Thread Phabricator via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL337931: Use LLVM's new ItaniumPartialDemangler in LLDB 
(authored by stefan.graenitz, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D49612?vs=157062&id=157280#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D49612

Files:
  lldb/trunk/cmake/modules/LLDBConfig.cmake
  lldb/trunk/lldb.xcodeproj/project.pbxproj
  lldb/trunk/source/Core/Mangled.cpp
  lldb/trunk/unittests/Core/CMakeLists.txt
  lldb/trunk/unittests/Core/MangledTest.cpp

Index: lldb/trunk/lldb.xcodeproj/project.pbxproj
===
--- lldb/trunk/lldb.xcodeproj/project.pbxproj
+++ lldb/trunk/lldb.xcodeproj/project.pbxproj
@@ -483,6 +483,7 @@
 		9A20573A1F3B8E7E00F6C293 /* MainLoopTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9A2057301F3B8E7600F6C293 /* MainLoopTest.cpp */; };
 		8C3BD9961EF45DA50016C343 /* MainThreadCheckerRuntime.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 8C3BD9951EF45D9B0016C343 /* MainThreadCheckerRuntime.cpp */; };
 		2689004313353E0400698AC0 /* Mangled.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26BC7E8010F1B85900F91463 /* Mangled.cpp */; };
+		4F29D3CF21010FA3003B549A /* MangledTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4F29D3CD21010F84003B549A /* MangledTest.cpp */; };
 		4CD44CFC20B37C440003557C /* ManualDWARFIndex.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4CD44CF920B37C440003557C /* ManualDWARFIndex.cpp */; };
 		49DCF702170E70120092F75E /* Materializer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 49DCF700170E70120092F75E /* Materializer.cpp */; };
 		2690B3711381D5C300ECFBAE /* Memory.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2690B3701381D5C300ECFBAE /* Memory.cpp */; };
@@ -2185,6 +2186,7 @@
 		2669415F1A6DC2AB0063BE93 /* Makefile */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.make; name = Makefile; path = "tools/lldb-mi/Makefile"; sourceTree = SOURCE_ROOT; };
 		26BC7E8010F1B85900F91463 /* Mangled.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = Mangled.cpp; path = source/Core/Mangled.cpp; sourceTree = ""; };
 		26BC7D6910F1B77400F91463 /* Mangled.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Mangled.h; path = include/lldb/Core/Mangled.h; sourceTree = ""; };
+		4F29D3CD21010F84003B549A /* MangledTest.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MangledTest.cpp; sourceTree = ""; };
 		4CD44CF920B37C440003557C /* ManualDWARFIndex.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ManualDWARFIndex.cpp; sourceTree = ""; };
 		4CD44D0020B37C580003557C /* ManualDWARFIndex.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ManualDWARFIndex.h; sourceTree = ""; };
 		2682100C143A59AE004BCF2D /* MappedHash.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = MappedHash.h; path = include/lldb/Core/MappedHash.h; sourceTree = ""; };
@@ -3657,6 +3659,7 @@
 		23CB14E51D66CBEB00EDDDE1 /* Core */ = {
 			isa = PBXGroup;
 			children = (
+4F29D3CD21010F84003B549A /* MangledTest.cpp */,
 9A3D43E31F3237D500EB767C /* ListenerTest.cpp */,
 9A3D43E21F3237D500EB767C /* StateTest.cpp */,
 9A3D43E11F3237D500EB767C /* StreamCallbackTest.cpp */,
@@ -7443,6 +7446,7 @@
 9A3D43D71F3151C400EB767C /* LogTest.cpp in Sources */,
 9A2057181F3B861400F6C293 /* TestType.cpp in Sources */,
 9A2057171F3B861400F6C293 /* TestDWARFCallFrameInfo.cpp in Sources */,
+4F29D3CF21010FA3003B549A /* MangledTest.cpp in Sources */,
 9A3D43EC1F3237F900EB767C /* ListenerTest.cpp in Sources */,
 9A3D43DC1F3151C400EB767C /* TimeoutTest.cpp in Sources */,
 9A3D43D61F3151C400EB767C /* ConstStringTest.cpp in Sources */,
@@ -9326,14 +9330,12 @@
 	"-fno-rtti",
 	"-Wglobal-constructors",
 	"$(OTHER_CFLAGS)",
-	"-DLLDB_USE_BUILTIN_DEMANGLER",
 	"-DLIBXML2_DEFINED",
 );
 "OTHER_CPLUSPLUSFLAGS[sdk=iphoneos*]" = (
 	"-fno-rtti",
 	"-Wglobal-constructors",
 	"$(OTHER_CFLAGS)",
-	"-DLLDB_USE_BUILTIN_DEMANGLER",
 	"-DLIBXML2_DEFINED",
 );
 OTHER_LDFLAGS = "";
@@ -9385,14 +9387,12 @@
 	"-fno-rtti",
 	"-Wglobal-constructors",
 	"$(OTHER_CFLAGS)",
-	"-DLLDB_USE_BUILTIN_DEMANGLER",
 	"-DLIBXML2_DEFINED",
 );
 "OTHER_CPLUSPLUSFLAGS[sdk=iphoneos*]" = (
 	"-fno-rtti",
 	"-Wglobal-constructors",
 	"$(OTHER_CFLAGS)",
-	"-DLLDB_USE_BUILTIN_DEMANGLER",
 	"-DLIBXML2_DEFINED",
 );
 OTHER_LDFLAGS = "";
@@ -9444,14 +9444,12 @@
 	"-fno-rtti",
 	"-Wglobal-constructors",
 	"$(OTHER_CFLAGS)",
-	"-DLLDB_USE_BUILTIN_DEMANGLER",
 	"-DLIBXML2_DEFINED",
 );
 "OTHER_CP

[Lldb-commits] [PATCH] D50087: Add doxygen comments to the StackFrameList API (NFC)

2018-08-01 Thread Phabricator via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL338590: [StackFrame] Add doxygen comments to the 
StackFrameList API (NFC) (authored by vedantk, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D50087?vs=158327&id=158562#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D50087

Files:
  lldb/trunk/include/lldb/Target/StackFrameList.h
  lldb/trunk/source/Target/StackFrameList.cpp

Index: lldb/trunk/source/Target/StackFrameList.cpp
===
--- lldb/trunk/source/Target/StackFrameList.cpp
+++ lldb/trunk/source/Target/StackFrameList.cpp
@@ -436,11 +436,7 @@
   if (can_create)
 GetFramesUpTo(UINT32_MAX);
 
-  uint32_t inlined_depth = GetCurrentInlinedDepth();
-  if (inlined_depth == UINT32_MAX)
-return m_frames.size();
-  else
-return m_frames.size() - inlined_depth;
+  return GetVisibleStackFrameIndex(m_frames.size());
 }
 
 void StackFrameList::Dump(Stream *s) {
@@ -620,7 +616,6 @@
   return m_selected_frame_idx;
 }
 
-// Mark a stack frame as the current frame using the frame index
 bool StackFrameList::SetSelectedFrameByIndex(uint32_t idx) {
   std::lock_guard guard(m_mutex);
   StackFrameSP frame_sp(GetFrameAtIndex(idx));
@@ -652,19 +647,6 @@
   m_concrete_frames_fetched = 0;
 }
 
-void StackFrameList::InvalidateFrames(uint32_t start_idx) {
-  std::lock_guard guard(m_mutex);
-  if (m_show_inlined_frames) {
-Clear();
-  } else {
-const size_t num_frames = m_frames.size();
-while (start_idx < num_frames) {
-  m_frames[start_idx].reset();
-  ++start_idx;
-}
-  }
-}
-
 void StackFrameList::Merge(std::unique_ptr &curr_ap,
lldb::StackFrameListSP &prev_sp) {
   std::unique_lock current_lock, previous_lock;
Index: lldb/trunk/include/lldb/Target/StackFrameList.h
===
--- lldb/trunk/include/lldb/Target/StackFrameList.h
+++ lldb/trunk/include/lldb/Target/StackFrameList.h
@@ -10,14 +10,10 @@
 #ifndef liblldb_StackFrameList_h_
 #define liblldb_StackFrameList_h_
 
-// C Includes
-// C++ Includes
 #include 
 #include 
 #include 
 
-// Other libraries and framework includes
-// Project includes
 #include "lldb/Target/StackFrame.h"
 
 namespace lldb_private {
@@ -32,39 +28,57 @@
 
   ~StackFrameList();
 
+  /// Get the number of visible frames. Frames may be created if \p can_create
+  /// is true. Synthetic (inline) frames expanded from the concrete frame #0
+  /// (aka invisible frames) are not included in this count.
   uint32_t GetNumFrames(bool can_create = true);
 
+  /// Get the frame at index \p idx. Invisible frames cannot be indexed.
   lldb::StackFrameSP GetFrameAtIndex(uint32_t idx);
 
+  /// Get the first concrete frame with index greater than or equal to \p idx.
+  /// Unlike \ref GetFrameAtIndex, this cannot return a synthetic frame.
   lldb::StackFrameSP GetFrameWithConcreteFrameIndex(uint32_t unwind_idx);
 
+  /// Retrieve the stack frame with the given ID \p stack_id.
   lldb::StackFrameSP GetFrameWithStackID(const StackID &stack_id);
 
-  // Mark a stack frame as the current frame
+  /// Mark a stack frame as the currently selected frame and return its index.
   uint32_t SetSelectedFrame(lldb_private::StackFrame *frame);
 
+  /// Get the currently selected frame index.
   uint32_t GetSelectedFrameIndex() const;
 
-  // Mark a stack frame as the current frame using the frame index
+  /// Mark a stack frame as the currently selected frame using the frame index
+  /// \p idx. Like \ref GetFrameAtIndex, invisible frames cannot be selected.
   bool SetSelectedFrameByIndex(uint32_t idx);
 
+  /// If the current inline depth (i.e the number of invisible frames) is valid,
+  /// subtract it from \p idx. Otherwise simply return \p idx.
   uint32_t GetVisibleStackFrameIndex(uint32_t idx) {
 if (m_current_inlined_depth < UINT32_MAX)
   return idx - m_current_inlined_depth;
 else
   return idx;
   }
 
+  /// Calculate and set the current inline depth. This may be used to update
+  /// the StackFrameList's set of inline frames when execution stops, e.g when
+  /// a breakpoint is hit.
   void CalculateCurrentInlinedDepth();
 
+  /// If the currently selected frame comes from the currently selected thread,
+  /// point the default file and line of the thread's target to the location
+  /// specified by the frame.
   void SetDefaultFileAndLineToSelectedFrame();
 
+  /// Clear the cache of frames.
   void Clear();
 
-  void InvalidateFrames(uint32_t start_idx);
-
   void Dump(Stream *s);
 
+  /// If \p stack_frame_ptr is contained in this StackFrameList, return its
+  /// wrapping shared pointer.
   lldb::StackFrameSP
   GetStackFrameSPForStackFramePtr(StackFrame *stack_frame_ptr);
 
@@ -101,14 +115,44 @@
   typedef collection::iterator iterator;
   typedef collection::const_iterator const_iterator;
 
+  /// The th

[Lldb-commits] [PATCH] D49909: Unit test for Symtab::InitNameIndexes

2018-08-02 Thread Phabricator via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL338695: Unit test for Symtab::InitNameIndexes (authored by 
stefan.graenitz, committed by ).
Herald added a subscriber: llvm-commits.

Repository:
  rL LLVM

https://reviews.llvm.org/D49909

Files:
  lldb/trunk/unittests/Core/CMakeLists.txt
  lldb/trunk/unittests/Core/Inputs/mangled-function-names.yaml
  lldb/trunk/unittests/Core/MangledTest.cpp

Index: lldb/trunk/unittests/Core/Inputs/mangled-function-names.yaml
===
--- lldb/trunk/unittests/Core/Inputs/mangled-function-names.yaml
+++ lldb/trunk/unittests/Core/Inputs/mangled-function-names.yaml
@@ -0,0 +1,116 @@
+--- !ELF
+FileHeader:  
+  Class:   ELFCLASS64
+  Data:ELFDATA2LSB
+  Type:ET_EXEC
+  Machine: EM_X86_64
+Sections:
+  - Name:.text
+Type:SHT_PROGBITS
+Flags:   [ SHF_ALLOC, SHF_EXECINSTR ]
+AddressAlign:0x0010
+Content: 554889E58B0425A8005DC30F1F00
+  - Name:.anothertext
+Type:SHT_PROGBITS
+Flags:   [ SHF_ALLOC, SHF_EXECINSTR ]
+Address: 0x0010
+AddressAlign:0x0010
+Content: 554889E54883EC20488D0425A800C745FC488945F0488B45F08B08894DECE8C7FF8B4DEC01C189C84883C4205D746573742073747200C3
+  - Name:.eh_frame
+Type:SHT_PROGBITS
+Flags:   [ SHF_ALLOC ]
+Address: 0x0050
+AddressAlign:0x0008
+Content: 1400017A5200017810011B0C070890011C001C0090FF0D410E108602430D06001C003C0080FF3F410E108602430D0600
+  - Name:.data
+Type:SHT_PROGBITS
+Flags:   [ SHF_WRITE, SHF_ALLOC ]
+Address: 0x00A8
+AddressAlign:0x0004
+Content: '0100'
+  - Name:.comment
+Type:SHT_PROGBITS
+Flags:   [ SHF_MERGE, SHF_STRINGS ]
+AddressAlign:0x0001
+Content: 5562756E747520636C616E672076657273696F6E20332E352D317562756E74753120287472756E6B2920286261736564206F6E204C4C564D20332E352900
+Symbols: 
+  Local:   
+- Type:STT_SECTION
+  Section: .text
+- Type:STT_SECTION
+  Section: .anothertext
+  Value:   0x0010
+- Type:STT_SECTION
+  Section: .eh_frame
+  Value:   0x0050
+- Type:STT_SECTION
+  Section: .data
+  Value:   0x00A8
+- Type:STT_SECTION
+  Section: .comment
+- Name:/tmp/a.c
+  Type:STT_FILE
+- Type:STT_FILE
+  Global:  
+- Name:somedata
+  Type:STT_OBJECT
+  Section: .anothertext
+  Value:   0x0045
+- Name:main
+  Type:STT_FUNC
+  Section: .anothertext
+  Value:   0x0010
+  Size:0x003F
+- Name:_Z3foov
+  Type:STT_FUNC
+  Section: .text
+  Size:0x000D
+- Name:puts@GLIBC_2.5
+  Type:STT_FUNC
+  Section: .text
+  Size:0x000D
+- Name:puts@GLIBC_2.6
+  Type:STT_FUNC
+  Section: .text
+  Size:0x000D
+- Name:_Z5annotv@VERSION3
+  Type:STT_FUNC
+  Section: .text
+  Size:0x000D
+- Name:_ZN1AC2Ev
+  Type:STT_FUNC
+  Section: .text
+  Size:0x000D
+- Name:_ZN1AD2Ev
+  Type:STT_FUNC
+  Section: .text
+  Size:0x000D
+- Name:_ZN1A3barEv
+  Type:STT_FUNC
+  Section: .text
+  Size:0x000D
+- Name:_ZGVZN4llvm4dbgsEvE7thestrm
+  Type:STT_FUNC
+  Section: .text
+  Size:0x000D
+- Name:_ZZN4llvm4dbgsEvE7thestrm
+  Type:STT_FUNC
+  Section: .text
+  Size:0x000D
+- Name:_ZTVN5clang4DeclE
+  Type:STT_FUNC
+  Section: .text
+  Size:0x000D
+- Name:-[ObjCfoo]
+  Type:STT_FUNC
+  Section: .text
+  Size:0x000D
+- Name:+[B ObjCbar(WithCategory)]
+  Type

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

2018-08-02 Thread Phabricator via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL338734: Add support for ARM and ARM64 breakpad generated 
minidump files (authored by gclayton, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D49750?vs=158631&id=158784#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D49750

Files:
  lldb/trunk/include/lldb/Target/Target.h
  lldb/trunk/lldb.xcodeproj/project.pbxproj
  lldb/trunk/lldb.xcodeproj/xcshareddata/xcschemes/desktop.xcscheme
  
lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/TestMiniDumpNew.py
  
lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/arm-linux.dmp
  
lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/arm-macos.dmp
  
lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/arm64-macos.dmp
  lldb/trunk/source/Plugins/Process/minidump/MinidumpParser.cpp
  lldb/trunk/source/Plugins/Process/minidump/MinidumpParser.h
  lldb/trunk/source/Plugins/Process/minidump/ProcessMinidump.cpp
  lldb/trunk/source/Plugins/Process/minidump/RegisterContextMinidump_ARM.cpp
  lldb/trunk/source/Plugins/Process/minidump/RegisterContextMinidump_ARM.h
  lldb/trunk/source/Plugins/Process/minidump/RegisterContextMinidump_ARM64.cpp
  lldb/trunk/source/Plugins/Process/minidump/RegisterContextMinidump_ARM64.h
  lldb/trunk/source/Plugins/Process/minidump/ThreadMinidump.cpp
  lldb/trunk/source/Target/Target.cpp

Index: lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/TestMiniDumpNew.py
===
--- lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/TestMiniDumpNew.py
+++ lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/TestMiniDumpNew.py
@@ -189,6 +189,161 @@
 stop_description = thread.GetStopDescription(256)
 self.assertEqual(stop_description, "")
 
+def check_register_unsigned(self, set, name, expected):
+reg_value = set.GetChildMemberWithName(name)
+self.assertTrue(reg_value.IsValid(),
+'Verify we have a register named "%s"' % (name))
+self.assertEqual(reg_value.GetValueAsUnsigned(), expected,
+ 'Verify "%s" == %i' % (name, expected))
+
+def check_register_string_value(self, set, name, expected, format):
+reg_value = set.GetChildMemberWithName(name)
+self.assertTrue(reg_value.IsValid(),
+'Verify we have a register named "%s"' % (name))
+if format is not None:
+reg_value.SetFormat(format)
+self.assertEqual(reg_value.GetValue(), expected,
+ 'Verify "%s" has string value "%s"' % (name,
+expected))
+
+def test_arm64_registers(self):
+"""Test ARM64 registers from a breakpad created minidump."""
+# target create -c arm64-macos.dmp
+self.dbg.CreateTarget(None)
+self.target = self.dbg.GetSelectedTarget()
+self.process = self.target.LoadCore("arm64-macos.dmp")
+self.check_state()
+self.assertEqual(self.process.GetNumThreads(), 1)
+thread = self.process.GetThreadAtIndex(0)
+self.assertEqual(thread.GetStopReason(), lldb.eStopReasonNone)
+stop_description = thread.GetStopDescription(256)
+self.assertEqual(stop_description, "")
+registers = thread.GetFrameAtIndex(0).GetRegisters()
+# Verify the GPR registers are all correct
+# Verify x0 - x31 register values
+gpr = registers.GetValueAtIndex(0)
+for i in range(32):
+v = i+1 | i+2 << 32 | i+3 << 48
+w = i+1
+self.check_register_unsigned(gpr, 'x%i' % (i), v)
+self.check_register_unsigned(gpr, 'w%i' % (i), w)
+# Verify arg1 - arg8 register values
+for i in range(1, 9):
+v = i | i+1 << 32 | i+2 << 48
+self.check_register_unsigned(gpr, 'arg%i' % (i), v)
+i = 29
+v = i+1 | i+2 << 32 | i+3 << 48
+self.check_register_unsigned(gpr, 'fp', v)
+i = 30
+v = i+1 | i+2 << 32 | i+3 << 48
+self.check_register_unsigned(gpr, 'lr', v)
+i = 31
+v = i+1 | i+2 << 32 | i+3 << 48
+self.check_register_unsigned(gpr, 'sp', v)
+self.check_register_unsigned(gpr, 'pc', 0x1000)
+self.check_register_unsigned(gpr, 'cpsr', 0x11223344)
+self.check_register_unsigned(gpr, 'psr', 0x11223344)
+
+# Verify the FPR registers are all correct
+fpr = registers.GetValueAtIndex(1)
+for i in range(32):
+v = "0x"
+d = "0x"
+s = "0x"
+h = "0x"
+for j in range(i+15, i-1, -1):
+v += "%2.2x" % (j)

[Lldb-commits] [PATCH] D50327: Add ConstString::IsNull() to tell between null vs. empty strings and fix usage in Mangled::GetDemangledName()

2018-08-06 Thread Phabricator via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL339014: Add ConstString::IsNull() to tell between null vs. 
empty strings and fix usage… (authored by stefan.graenitz, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D50327?vs=159278&id=159297#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D50327

Files:
  lldb/trunk/include/lldb/Utility/ConstString.h
  lldb/trunk/source/Core/Mangled.cpp
  lldb/trunk/unittests/Utility/ConstStringTest.cpp


Index: lldb/trunk/include/lldb/Utility/ConstString.h
===
--- lldb/trunk/include/lldb/Utility/ConstString.h
+++ lldb/trunk/include/lldb/Utility/ConstString.h
@@ -346,6 +346,15 @@
   bool IsEmpty() const { return m_string == nullptr || m_string[0] == '\0'; }
 
   //--
+  /// Test for null string.
+  ///
+  /// @return
+  /// @li \b true if there is no string associated with this instance.
+  /// @li \b false if there is a string associated with this instance.
+  //--
+  bool IsNull() const { return m_string == nullptr; }
+
+  //--
   /// Set the C string value.
   ///
   /// Set the string value in the object by uniquing the \a cstr string value
Index: lldb/trunk/unittests/Utility/ConstStringTest.cpp
===
--- lldb/trunk/unittests/Utility/ConstStringTest.cpp
+++ lldb/trunk/unittests/Utility/ConstStringTest.cpp
@@ -33,3 +33,20 @@
   EXPECT_TRUE(foo.GetMangledCounterpart(counterpart));
   EXPECT_EQ("bar", counterpart.GetStringRef());
 }
+
+TEST(ConstStringTest, NullAndEmptyStates) {
+  ConstString foo("foo");
+  EXPECT_FALSE(!foo);
+  EXPECT_FALSE(foo.IsEmpty());
+  EXPECT_FALSE(foo.IsNull());
+
+  ConstString empty("");
+  EXPECT_TRUE(!empty);
+  EXPECT_TRUE(empty.IsEmpty());
+  EXPECT_FALSE(empty.IsNull());
+
+  ConstString null;
+  EXPECT_TRUE(!null);
+  EXPECT_TRUE(null.IsEmpty());
+  EXPECT_TRUE(null.IsNull());
+}
Index: lldb/trunk/source/Core/Mangled.cpp
===
--- lldb/trunk/source/Core/Mangled.cpp
+++ lldb/trunk/source/Core/Mangled.cpp
@@ -242,7 +242,7 @@
 Mangled::GetDemangledName(lldb::LanguageType language) const {
   // Check to make sure we have a valid mangled name and that we haven't
   // already decoded our mangled name.
-  if (m_mangled && !m_demangled) {
+  if (m_mangled && m_demangled.IsNull()) {
 // We need to generate and cache the demangled name.
 static Timer::Category func_cat(LLVM_PRETTY_FUNCTION);
 Timer scoped_timer(func_cat, "Mangled::GetDemangledName (m_mangled = %s)",
@@ -312,7 +312,7 @@
 free(demangled_name);
   }
 }
-if (!m_demangled) {
+if (m_demangled.IsNull()) {
   // Set the demangled string to the empty string to indicate we tried to
   // parse it once and failed.
   m_demangled.SetCString("");


Index: lldb/trunk/include/lldb/Utility/ConstString.h
===
--- lldb/trunk/include/lldb/Utility/ConstString.h
+++ lldb/trunk/include/lldb/Utility/ConstString.h
@@ -346,6 +346,15 @@
   bool IsEmpty() const { return m_string == nullptr || m_string[0] == '\0'; }
 
   //--
+  /// Test for null string.
+  ///
+  /// @return
+  /// @li \b true if there is no string associated with this instance.
+  /// @li \b false if there is a string associated with this instance.
+  //--
+  bool IsNull() const { return m_string == nullptr; }
+
+  //--
   /// Set the C string value.
   ///
   /// Set the string value in the object by uniquing the \a cstr string value
Index: lldb/trunk/unittests/Utility/ConstStringTest.cpp
===
--- lldb/trunk/unittests/Utility/ConstStringTest.cpp
+++ lldb/trunk/unittests/Utility/ConstStringTest.cpp
@@ -33,3 +33,20 @@
   EXPECT_TRUE(foo.GetMangledCounterpart(counterpart));
   EXPECT_EQ("bar", counterpart.GetStringRef());
 }
+
+TEST(ConstStringTest, NullAndEmptyStates) {
+  ConstString foo("foo");
+  EXPECT_FALSE(!foo);
+  EXPECT_FALSE(foo.IsEmpty());
+  EXPECT_FALSE(foo.IsNull());
+
+  ConstString empty("");
+  EXPECT_TRUE(!empty);
+  EXPECT_TRUE(empty.IsEmpty());
+  EXPECT_FALSE(empty.IsNull());
+
+  ConstString null;
+  EXPECT_TRUE(!null);
+  EXPECT_TRUE(null.IsEmpty());
+  EXPECT_TRUE(null.IsNull());
+}
Index: lldb/trunk/source/Core/Mangled.cpp
===
--- lldb/trunk/source/Core/Mangled.cpp
+++ lldb/trunk/source/Core/M

[Lldb-commits] [PATCH] D50336: Add support for ARM and ARM64 breakpad generated minidump files (version 2).

2018-08-06 Thread Phabricator via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL339032: Add support for ARM and ARM64 breakpad generated 
minidump files (version 2). (authored by gclayton, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D50336?vs=159324&id=159326#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D50336

Files:
  lldb/trunk/include/lldb/Target/Target.h
  lldb/trunk/lldb.xcodeproj/project.pbxproj
  
lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/TestMiniDumpNew.py
  
lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/arm-linux.dmp
  
lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/arm-macos.dmp
  
lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/arm64-macos.dmp
  lldb/trunk/source/Plugins/Process/minidump/CMakeLists.txt
  lldb/trunk/source/Plugins/Process/minidump/MinidumpParser.cpp
  lldb/trunk/source/Plugins/Process/minidump/MinidumpParser.h
  lldb/trunk/source/Plugins/Process/minidump/ProcessMinidump.cpp
  lldb/trunk/source/Plugins/Process/minidump/RegisterContextMinidump_ARM.cpp
  lldb/trunk/source/Plugins/Process/minidump/RegisterContextMinidump_ARM.h
  lldb/trunk/source/Plugins/Process/minidump/RegisterContextMinidump_ARM64.cpp
  lldb/trunk/source/Plugins/Process/minidump/RegisterContextMinidump_ARM64.h
  lldb/trunk/source/Plugins/Process/minidump/ThreadMinidump.cpp
  lldb/trunk/source/Target/Target.cpp

Index: lldb/trunk/include/lldb/Target/Target.h
===
--- lldb/trunk/include/lldb/Target/Target.h
+++ lldb/trunk/include/lldb/Target/Target.h
@@ -913,28 +913,30 @@
   /// Set the architecture for this target.
   ///
   /// If the current target has no Images read in, then this just sets the
-  /// architecture, which will
-  /// be used to select the architecture of the ExecutableModule when that is
-  /// set.
-  /// If the current target has an ExecutableModule, then calling
-  /// SetArchitecture with a different
+  /// architecture, which will be used to select the architecture of the
+  /// ExecutableModule when that is set. If the current target has an
+  /// ExecutableModule, then calling SetArchitecture with a different
   /// architecture from the currently selected one will reset the
-  /// ExecutableModule to that slice
-  /// of the file backing the ExecutableModule.  If the file backing the
-  /// ExecutableModule does not
-  /// contain a fork of this architecture, then this code will return false, and
-  /// the architecture
-  /// won't be changed.
-  /// If the input arch_spec is the same as the already set architecture, this
-  /// is a no-op.
+  /// ExecutableModule to that slice of the file backing the ExecutableModule.
+  /// If the file backing the ExecutableModule does not contain a fork of this
+  /// architecture, then this code will return false, and the architecture
+  /// won't be changed. If the input arch_spec is the same as the already set
+  /// architecture, this is a no-op.
   ///
   /// @param[in] arch_spec
   /// The new architecture.
   ///
+  /// @param[in] set_platform
+  /// If \b true, then the platform will be adjusted if the currently
+  /// selected platform is not compatible with the archicture being set.
+  /// If \b false, then just the architecture will be set even if the
+  /// currently selected platform isn't compatible (in case it might be
+  /// manually set following this function call).
+  ///
   /// @return
   /// \b true if the architecture was successfully set, \bfalse otherwise.
   //--
-  bool SetArchitecture(const ArchSpec &arch_spec);
+  bool SetArchitecture(const ArchSpec &arch_spec, bool set_platform = false);
 
   bool MergeArchitecture(const ArchSpec &arch_spec);
 
Index: lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/TestMiniDumpNew.py
===
--- lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/TestMiniDumpNew.py
+++ lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/TestMiniDumpNew.py
@@ -189,6 +189,161 @@
 stop_description = thread.GetStopDescription(256)
 self.assertEqual(stop_description, "")
 
+def check_register_unsigned(self, set, name, expected):
+reg_value = set.GetChildMemberWithName(name)
+self.assertTrue(reg_value.IsValid(),
+'Verify we have a register named "%s"' % (name))
+self.assertEqual(reg_value.GetValueAsUnsigned(), expected,
+ 'Verify "%s" == %i' % (name, expected))
+
+def check_register_string_value(self, set, name, expected, format):
+reg_value = set.GetChildMemberWithName(name)
+  

[Lldb-commits] [PATCH] D50336: Add support for ARM and ARM64 breakpad generated minidump files (version 2).

2018-08-06 Thread Phabricator via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rLLDB339032: Add support for ARM and ARM64 breakpad generated 
minidump files (version 2). (authored by gclayton, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D50336?vs=159324&id=159325#toc

Repository:
  rLLDB LLDB

https://reviews.llvm.org/D50336

Files:
  include/lldb/Target/Target.h
  lldb.xcodeproj/project.pbxproj
  
packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/TestMiniDumpNew.py
  
packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/arm-linux.dmp
  
packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/arm-macos.dmp
  
packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/arm64-macos.dmp
  source/Plugins/Process/minidump/CMakeLists.txt
  source/Plugins/Process/minidump/MinidumpParser.cpp
  source/Plugins/Process/minidump/MinidumpParser.h
  source/Plugins/Process/minidump/ProcessMinidump.cpp
  source/Plugins/Process/minidump/RegisterContextMinidump_ARM.cpp
  source/Plugins/Process/minidump/RegisterContextMinidump_ARM.h
  source/Plugins/Process/minidump/RegisterContextMinidump_ARM64.cpp
  source/Plugins/Process/minidump/RegisterContextMinidump_ARM64.h
  source/Plugins/Process/minidump/ThreadMinidump.cpp
  source/Target/Target.cpp

Index: include/lldb/Target/Target.h
===
--- include/lldb/Target/Target.h
+++ include/lldb/Target/Target.h
@@ -913,28 +913,30 @@
   /// Set the architecture for this target.
   ///
   /// If the current target has no Images read in, then this just sets the
-  /// architecture, which will
-  /// be used to select the architecture of the ExecutableModule when that is
-  /// set.
-  /// If the current target has an ExecutableModule, then calling
-  /// SetArchitecture with a different
+  /// architecture, which will be used to select the architecture of the
+  /// ExecutableModule when that is set. If the current target has an
+  /// ExecutableModule, then calling SetArchitecture with a different
   /// architecture from the currently selected one will reset the
-  /// ExecutableModule to that slice
-  /// of the file backing the ExecutableModule.  If the file backing the
-  /// ExecutableModule does not
-  /// contain a fork of this architecture, then this code will return false, and
-  /// the architecture
-  /// won't be changed.
-  /// If the input arch_spec is the same as the already set architecture, this
-  /// is a no-op.
+  /// ExecutableModule to that slice of the file backing the ExecutableModule.
+  /// If the file backing the ExecutableModule does not contain a fork of this
+  /// architecture, then this code will return false, and the architecture
+  /// won't be changed. If the input arch_spec is the same as the already set
+  /// architecture, this is a no-op.
   ///
   /// @param[in] arch_spec
   /// The new architecture.
   ///
+  /// @param[in] set_platform
+  /// If \b true, then the platform will be adjusted if the currently
+  /// selected platform is not compatible with the archicture being set.
+  /// If \b false, then just the architecture will be set even if the
+  /// currently selected platform isn't compatible (in case it might be
+  /// manually set following this function call).
+  ///
   /// @return
   /// \b true if the architecture was successfully set, \bfalse otherwise.
   //--
-  bool SetArchitecture(const ArchSpec &arch_spec);
+  bool SetArchitecture(const ArchSpec &arch_spec, bool set_platform = false);
 
   bool MergeArchitecture(const ArchSpec &arch_spec);
 
Index: packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/TestMiniDumpNew.py
===
--- packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/TestMiniDumpNew.py
+++ packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/TestMiniDumpNew.py
@@ -189,6 +189,161 @@
 stop_description = thread.GetStopDescription(256)
 self.assertEqual(stop_description, "")
 
+def check_register_unsigned(self, set, name, expected):
+reg_value = set.GetChildMemberWithName(name)
+self.assertTrue(reg_value.IsValid(),
+'Verify we have a register named "%s"' % (name))
+self.assertEqual(reg_value.GetValueAsUnsigned(), expected,
+ 'Verify "%s" == %i' % (name, expected))
+
+def check_register_string_value(self, set, name, expected, format):
+reg_value = set.GetChildMemberWithName(name)
+self.assertTrue(reg_value.IsValid(),
+'Verify we have a register named "%s"' % (name))
+if format is not None:
+reg_value.SetFormat(format)
+self.assertEqual(reg_value.GetValue(), expected,
+ 'Ve

[Lldb-commits] [PATCH] D50271: [IRMemoryMap] Shrink Allocation make it move-only (NFC)

2018-08-08 Thread Phabricator via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL339290: [IRMemoryMap] Shrink Allocation and make it 
move-only (NFC) (authored by vedantk, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D50271?vs=159339&id=159797#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D50271

Files:
  lldb/trunk/include/lldb/Expression/IRMemoryMap.h
  lldb/trunk/source/Expression/IRMemoryMap.cpp


Index: lldb/trunk/include/lldb/Expression/IRMemoryMap.h
===
--- lldb/trunk/include/lldb/Expression/IRMemoryMap.h
+++ lldb/trunk/include/lldb/Expression/IRMemoryMap.h
@@ -39,7 +39,7 @@
   IRMemoryMap(lldb::TargetSP target_sp);
   ~IRMemoryMap();
 
-  enum AllocationPolicy {
+  enum AllocationPolicy : uint8_t {
 eAllocationPolicyInvalid =
 0, ///< It is an error for an allocation to have this policy.
 eAllocationPolicyHostOnly, ///< This allocation was created in the host and
@@ -91,32 +91,32 @@
 private:
   struct Allocation {
 lldb::addr_t
-m_process_alloc; ///< The (unaligned) base for the remote allocation
+m_process_alloc; ///< The (unaligned) base for the remote allocation.
 lldb::addr_t
-m_process_start; ///< The base address of the allocation in the process
-size_t m_size;   ///< The size of the requested allocation
-uint32_t m_permissions; ///< The access permissions on the memory in the
-///process.  In the host, the memory is always
-///read/write.
-uint8_t m_alignment;///< The alignment of the requested allocation
+m_process_start; ///< The base address of the allocation in the 
process.
+size_t m_size;   ///< The size of the requested allocation.
 DataBufferHeap m_data;
 
-///< Flags
+/// Flags. Keep these grouped together to avoid structure padding.
 AllocationPolicy m_policy;
 bool m_leak;
+uint8_t m_permissions; ///< The access permissions on the memory in the
+   /// process. In the host, the memory is always
+   /// read/write.
+uint8_t m_alignment;   ///< The alignment of the requested allocation.
 
   public:
 Allocation(lldb::addr_t process_alloc, lldb::addr_t process_start,
size_t size, uint32_t permissions, uint8_t alignment,
AllocationPolicy m_policy);
 
-Allocation()
-: m_process_alloc(LLDB_INVALID_ADDRESS),
-  m_process_start(LLDB_INVALID_ADDRESS), m_size(0), m_permissions(0),
-  m_alignment(0), m_data(), m_policy(eAllocationPolicyInvalid),
-  m_leak(false) {}
+DISALLOW_COPY_AND_ASSIGN(Allocation);
   };
 
+  static_assert(sizeof(Allocation) <=
+(4 * sizeof(lldb::addr_t)) + sizeof(DataBufferHeap),
+"IRMemoryMap::Allocation is larger than expected");
+
   lldb::ProcessWP m_process_wp;
   lldb::TargetWP m_target_wp;
   typedef std::map AllocationMap;
Index: lldb/trunk/source/Expression/IRMemoryMap.cpp
===
--- lldb/trunk/source/Expression/IRMemoryMap.cpp
+++ lldb/trunk/source/Expression/IRMemoryMap.cpp
@@ -272,8 +272,8 @@
 uint32_t permissions, uint8_t alignment,
 AllocationPolicy policy)
 : m_process_alloc(process_alloc), m_process_start(process_start),
-  m_size(size), m_permissions(permissions), m_alignment(alignment),
-  m_policy(policy), m_leak(false) {
+  m_size(size), m_policy(policy), m_leak(false), 
m_permissions(permissions),
+  m_alignment(alignment) {
   switch (policy) {
   default:
 assert(0 && "We cannot reach this!");
@@ -389,9 +389,10 @@
   lldb::addr_t mask = alignment - 1;
   aligned_address = (allocation_address + mask) & (~mask);
 
-  m_allocations[aligned_address] =
-  Allocation(allocation_address, aligned_address, allocation_size,
- permissions, alignment, policy);
+  m_allocations.emplace(
+  std::piecewise_construct, std::forward_as_tuple(aligned_address),
+  std::forward_as_tuple(allocation_address, aligned_address,
+allocation_size, permissions, alignment, policy));
 
   if (zero_memory) {
 Status write_error;


Index: lldb/trunk/include/lldb/Expression/IRMemoryMap.h
===
--- lldb/trunk/include/lldb/Expression/IRMemoryMap.h
+++ lldb/trunk/include/lldb/Expression/IRMemoryMap.h
@@ -39,7 +39,7 @@
   IRMemoryMap(lldb::TargetSP target_sp);
   ~IRMemoryMap();
 
-  enum AllocationPolicy {
+  enum AllocationPolicy : uint8_t {
 eAllocationPolicyInvalid =
 0, ///< It is an error for an allocation to have this policy.
 eAllocationPolicyHostOnly, ///< This allocation was created in the host and
@@ -91,32 +91,32 @

[Lldb-commits] [PATCH] D50071: Use rich mangling information in Symtab::InitNameIndexes()

2018-08-08 Thread Phabricator via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL339291: Use rich mangling information in 
Symtab::InitNameIndexes() (authored by stefan.graenitz, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D50071?vs=159767&id=159804#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D50071

Files:
  lldb/trunk/include/lldb/Core/Mangled.h
  lldb/trunk/include/lldb/Core/RichManglingContext.h
  lldb/trunk/include/lldb/Symbol/Symtab.h
  lldb/trunk/include/lldb/lldb-forward.h
  lldb/trunk/lldb.xcodeproj/project.pbxproj
  lldb/trunk/source/Core/CMakeLists.txt
  lldb/trunk/source/Core/Mangled.cpp
  lldb/trunk/source/Core/RichManglingContext.cpp
  lldb/trunk/source/Symbol/Symtab.cpp
  lldb/trunk/unittests/Core/CMakeLists.txt
  lldb/trunk/unittests/Core/RichManglingContextTest.cpp

Index: lldb/trunk/include/lldb/Symbol/Symtab.h
===
--- lldb/trunk/include/lldb/Symbol/Symtab.h
+++ lldb/trunk/include/lldb/Symbol/Symtab.h
@@ -197,6 +197,15 @@
   void SymbolIndicesToSymbolContextList(std::vector &symbol_indexes,
 SymbolContextList &sc_list);
 
+  void RegisterMangledNameEntry(
+  NameToIndexMap::Entry &entry, std::set &class_contexts,
+  std::vector> &backlog,
+  RichManglingContext &rmc);
+
+  void RegisterBacklogEntry(const NameToIndexMap::Entry &entry,
+const char *decl_context,
+const std::set &class_contexts);
+
   DISALLOW_COPY_AND_ASSIGN(Symtab);
 };
 
Index: lldb/trunk/include/lldb/lldb-forward.h
===
--- lldb/trunk/include/lldb/lldb-forward.h
+++ lldb/trunk/include/lldb/lldb-forward.h
@@ -191,6 +191,7 @@
 class RegisterValue;
 class RegularExpression;
 class REPL;
+class RichManglingContext;
 class Scalar;
 class ScriptInterpreter;
 class ScriptInterpreterLocker;
@@ -492,5 +493,15 @@
 
 } // namespace lldb
 
+//--
+// llvm forward declarations
+//--
+namespace llvm {
+
+struct ItaniumPartialDemangler;
+class StringRef;
+
+} // namespace llvm
+
 #endif // #if defined(__cplusplus)
 #endif // LLDB_lldb_forward_h_
Index: lldb/trunk/include/lldb/Core/RichManglingContext.h
===
--- lldb/trunk/include/lldb/Core/RichManglingContext.h
+++ lldb/trunk/include/lldb/Core/RichManglingContext.h
@@ -0,0 +1,110 @@
+//===-- RichManglingContext.h ---*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#ifndef liblldb_RichManglingContext_h_
+#define liblldb_RichManglingContext_h_
+
+#include "lldb/lldb-forward.h"
+#include "lldb/lldb-private.h"
+
+#include "lldb/Utility/ConstString.h"
+
+#include "llvm/ADT/Any.h"
+#include "llvm/ADT/SmallString.h"
+#include "llvm/Demangle/Demangle.h"
+
+namespace lldb_private {
+
+/// Uniform wrapper for access to rich mangling information from different
+/// providers. See Mangled::DemangleWithRichManglingInfo()
+class RichManglingContext {
+public:
+  RichManglingContext()
+  : m_provider(None), m_ipd_buf_size(2048), m_ipd_str_len(0) {
+m_ipd_buf = static_cast(std::malloc(m_ipd_buf_size));
+m_ipd_buf[m_ipd_str_len] = '\0';
+  }
+
+  ~RichManglingContext() { std::free(m_ipd_buf); }
+
+  /// Use the ItaniumPartialDemangler to obtain rich mangling information from
+  /// the given mangled name.
+  bool FromItaniumName(const ConstString &mangled);
+
+  /// Use the legacy language parser implementation to obtain rich mangling
+  /// information from the given demangled name.
+  bool FromCxxMethodName(const ConstString &demangled);
+
+  /// If this symbol describes a constructor or destructor.
+  bool IsCtorOrDtor() const;
+
+  /// If this symbol describes a function.
+  bool IsFunction() const;
+
+  /// Get the base name of a function. This doesn't include trailing template
+  /// arguments, ie "a::b" gives "b". The result will overwrite the
+  /// internal buffer. It can be obtained via GetBufferRef().
+  void ParseFunctionBaseName();
+
+  /// Get the context name for a function. For "a::b::c", this function returns
+  /// "a::b". The result will overwrite the internal buffer. It can be obtained
+  /// via GetBufferRef().
+  void ParseFunctionDeclContextName();
+
+  /// Get the entire demangled name. The result will overwrite the internal
+  /// buffer. It can be obtained via GetBufferRef().
+  void ParseFullName();
+
+  /// Obtain a StringRef to the internal buffer that holds the result of the
+  /// most 

[Lldb-commits] [PATCH] D50334: Add ConstString test FromMidOfBufferStringRef

2018-08-08 Thread Phabricator via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rLLDB339292: Add ConstString test FromMidOfBufferStringRef 
(authored by stefan.graenitz, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D50334?vs=159298&id=159806#toc

Repository:
  rLLDB LLDB

https://reviews.llvm.org/D50334

Files:
  unittests/Utility/ConstStringTest.cpp


Index: unittests/Utility/ConstStringTest.cpp
===
--- unittests/Utility/ConstStringTest.cpp
+++ unittests/Utility/ConstStringTest.cpp
@@ -34,6 +34,26 @@
   EXPECT_EQ("bar", counterpart.GetStringRef());
 }
 
+TEST(ConstStringTest, FromMidOfBufferStringRef) {
+  // StringRef's into bigger buffer: no null termination
+  const char *buffer = "foobarbaz";
+  llvm::StringRef foo_ref(buffer, 3);
+  llvm::StringRef bar_ref(buffer + 3, 3);
+
+  ConstString foo(foo_ref);
+
+  ConstString bar;
+  bar.SetStringWithMangledCounterpart(bar_ref, foo);
+  EXPECT_EQ("bar", bar.GetStringRef());
+
+  ConstString counterpart;
+  EXPECT_TRUE(bar.GetMangledCounterpart(counterpart));
+  EXPECT_EQ("foo", counterpart.GetStringRef());
+
+  EXPECT_TRUE(foo.GetMangledCounterpart(counterpart));
+  EXPECT_EQ("bar", counterpart.GetStringRef());
+}
+
 TEST(ConstStringTest, NullAndEmptyStates) {
   ConstString foo("foo");
   EXPECT_FALSE(!foo);


Index: unittests/Utility/ConstStringTest.cpp
===
--- unittests/Utility/ConstStringTest.cpp
+++ unittests/Utility/ConstStringTest.cpp
@@ -34,6 +34,26 @@
   EXPECT_EQ("bar", counterpart.GetStringRef());
 }
 
+TEST(ConstStringTest, FromMidOfBufferStringRef) {
+  // StringRef's into bigger buffer: no null termination
+  const char *buffer = "foobarbaz";
+  llvm::StringRef foo_ref(buffer, 3);
+  llvm::StringRef bar_ref(buffer + 3, 3);
+
+  ConstString foo(foo_ref);
+
+  ConstString bar;
+  bar.SetStringWithMangledCounterpart(bar_ref, foo);
+  EXPECT_EQ("bar", bar.GetStringRef());
+
+  ConstString counterpart;
+  EXPECT_TRUE(bar.GetMangledCounterpart(counterpart));
+  EXPECT_EQ("foo", counterpart.GetStringRef());
+
+  EXPECT_TRUE(foo.GetMangledCounterpart(counterpart));
+  EXPECT_EQ("bar", counterpart.GetStringRef());
+}
+
 TEST(ConstStringTest, NullAndEmptyStates) {
   ConstString foo("foo");
   EXPECT_FALSE(!foo);
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D50473: [Demangle] Add another test for ItaniumPartialDemangler

2018-08-08 Thread Phabricator via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL339297: [Demangle] Add another test for 
ItaniumPartialDemangler (authored by stefan.graenitz, committed by ).

Repository:
  rL LLVM

https://reviews.llvm.org/D50473

Files:
  llvm/trunk/unittests/Demangle/PartialDemangleTest.cpp


Index: llvm/trunk/unittests/Demangle/PartialDemangleTest.cpp
===
--- llvm/trunk/unittests/Demangle/PartialDemangleTest.cpp
+++ llvm/trunk/unittests/Demangle/PartialDemangleTest.cpp
@@ -145,5 +145,50 @@
   EXPECT_TRUE(D2.isFunction());
 
   EXPECT_TRUE(D1.partialDemangle("Not a mangled name!"));
+}
+
+TEST(PartialDemanglerTest, TestPrintCases) {
+  llvm::ItaniumPartialDemangler D;
+
+  const size_t OriginalSize = 4;
+  char *Buf = static_cast(std::malloc(OriginalSize));
+  const char *OriginalBuf = Buf;
+
+  // Default success case: Result fits into the given buffer.
+  // Res points to Buf. N returns string size including null termination.
+  {
+EXPECT_FALSE(D.partialDemangle("_ZN1a1bEv"));
+
+size_t N = OriginalSize;
+char *Res = D.getFunctionDeclContextName(Buf, &N);
+EXPECT_STREQ("a", Res);
+EXPECT_EQ(OriginalBuf, Res);
+EXPECT_EQ(strlen(Res) + 1, N);
+  }
 
+  // Realloc success case: Result does not fit into the given buffer.
+  // Res points to the new or extended buffer. N returns string size
+  // including null termination. Buf was extended or freed.
+  {
+EXPECT_FALSE(D.partialDemangle("_ZN1a1b1cIiiiEEvm"));
+
+size_t N = OriginalSize;
+char *Res = D.finishDemangle(Buf, &N);
+EXPECT_STREQ("void a::b::c(unsigned long)", Res);
+EXPECT_EQ(strlen(Res) + 1, N);
+Buf = Res;
+  }
+
+  // Failure case: a::c is not a function.
+  // Res is nullptr. N remains unchanged.
+  {
+EXPECT_FALSE(D.partialDemangle("_ZN1a1cE"));
+
+size_t N = OriginalSize;
+char *Res = D.getFunctionName(Buf, &N);
+EXPECT_EQ(nullptr, Res);
+EXPECT_EQ(OriginalSize, N);
+  }
+
+  std::free(Buf);
 }


Index: llvm/trunk/unittests/Demangle/PartialDemangleTest.cpp
===
--- llvm/trunk/unittests/Demangle/PartialDemangleTest.cpp
+++ llvm/trunk/unittests/Demangle/PartialDemangleTest.cpp
@@ -145,5 +145,50 @@
   EXPECT_TRUE(D2.isFunction());
 
   EXPECT_TRUE(D1.partialDemangle("Not a mangled name!"));
+}
+
+TEST(PartialDemanglerTest, TestPrintCases) {
+  llvm::ItaniumPartialDemangler D;
+
+  const size_t OriginalSize = 4;
+  char *Buf = static_cast(std::malloc(OriginalSize));
+  const char *OriginalBuf = Buf;
+
+  // Default success case: Result fits into the given buffer.
+  // Res points to Buf. N returns string size including null termination.
+  {
+EXPECT_FALSE(D.partialDemangle("_ZN1a1bEv"));
+
+size_t N = OriginalSize;
+char *Res = D.getFunctionDeclContextName(Buf, &N);
+EXPECT_STREQ("a", Res);
+EXPECT_EQ(OriginalBuf, Res);
+EXPECT_EQ(strlen(Res) + 1, N);
+  }
 
+  // Realloc success case: Result does not fit into the given buffer.
+  // Res points to the new or extended buffer. N returns string size
+  // including null termination. Buf was extended or freed.
+  {
+EXPECT_FALSE(D.partialDemangle("_ZN1a1b1cIiiiEEvm"));
+
+size_t N = OriginalSize;
+char *Res = D.finishDemangle(Buf, &N);
+EXPECT_STREQ("void a::b::c(unsigned long)", Res);
+EXPECT_EQ(strlen(Res) + 1, N);
+Buf = Res;
+  }
+
+  // Failure case: a::c is not a function.
+  // Res is nullptr. N remains unchanged.
+  {
+EXPECT_FALSE(D.partialDemangle("_ZN1a1cE"));
+
+size_t N = OriginalSize;
+char *Res = D.getFunctionName(Buf, &N);
+EXPECT_EQ(nullptr, Res);
+EXPECT_EQ(OriginalSize, N);
+  }
+
+  std::free(Buf);
 }
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D50587: Straight forward FastDemangle replacement in SubsPrimitiveParmItanium

2018-08-13 Thread Phabricator via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL339583: Straight forward FastDemangle replacement in 
SubsPrimitiveParmItanium (authored by stefan.graenitz, committed by ).
Herald added a subscriber: llvm-commits.

Repository:
  rL LLVM

https://reviews.llvm.org/D50587

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

Index: lldb/trunk/unittests/Language/CPlusPlus/CPlusPlusLanguageTest.cpp
===
--- lldb/trunk/unittests/Language/CPlusPlus/CPlusPlusLanguageTest.cpp
+++ lldb/trunk/unittests/Language/CPlusPlus/CPlusPlusLanguageTest.cpp
@@ -183,4 +183,5 @@
   EXPECT_THAT(FindAlternate("_ZN1A1fEa"), Contains("_ZN1A1fEc"));
   EXPECT_THAT(FindAlternate("_ZN1A1fEx"), Contains("_ZN1A1fEl"));
   EXPECT_THAT(FindAlternate("_ZN1A1fEy"), Contains("_ZN1A1fEm"));
+  EXPECT_THAT(FindAlternate("_ZN1A1fEai"), Contains("_ZN1A1fEci"));
 }
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
@@ -21,6 +21,7 @@
 
 // Other libraries and framework includes
 #include "llvm/ADT/StringRef.h"
+#include "llvm/Demangle/Demangle.h"
 
 // Project includes
 #include "lldb/Core/PluginManager.h"
@@ -30,7 +31,6 @@
 #include "lldb/DataFormatters/FormattersHelpers.h"
 #include "lldb/DataFormatters/VectorType.h"
 #include "lldb/Utility/ConstString.h"
-#include "lldb/Utility/FastDemangle.h"
 #include "lldb/Utility/Log.h"
 #include "lldb/Utility/RegularExpression.h"
 
@@ -278,48 +278,67 @@
 static ConstString SubsPrimitiveParmItanium(llvm::StringRef mangled,
 llvm::StringRef search,
 llvm::StringRef replace) {
-  Log *log = GetLogIfAllCategoriesSet(LIBLLDB_LOG_LANGUAGE);
+  class PrimitiveParmSubs {
+llvm::StringRef mangled;
+llvm::StringRef search;
+llvm::StringRef replace;
+ptrdiff_t read_pos;
+std::string output;
+std::back_insert_iterator writer;
 
-  const size_t max_len =
-  mangled.size() + mangled.count(search) * replace.size() + 1;
+  public:
+PrimitiveParmSubs(llvm::StringRef m, llvm::StringRef s, llvm::StringRef r)
+: mangled(m), search(s), replace(r), read_pos(0),
+  writer(std::back_inserter(output)) {}
+
+void Substitute(llvm::StringRef tail) {
+  assert(tail.data() >= mangled.data() &&
+ tail.data() < mangled.data() + mangled.size() &&
+ "tail must point into range of mangled");
+
+  if (tail.startswith(search)) {
+auto reader = mangled.begin() + read_pos;
+ptrdiff_t read_len = tail.data() - (mangled.data() + read_pos);
+
+// First write the unmatched part of the original. Then write the
+// replacement string. Finally skip the search string in the original.
+writer = std::copy(reader, reader + read_len, writer);
+writer = std::copy(replace.begin(), replace.end(), writer);
+read_pos += read_len + search.size();
+  }
+}
+
+ConstString Finalize() {
+  // If we did a substitution, write the remaining part of the original.
+  if (read_pos > 0) {
+writer = std::copy(mangled.begin() + read_pos, mangled.end(), writer);
+read_pos = mangled.size();
+  }
 
-  // Make a temporary buffer to fix up the mangled parameter types and copy the
-  // original there
-  std::string output_buf;
-  output_buf.reserve(max_len);
-  output_buf.insert(0, mangled.str());
-  ptrdiff_t replaced_offset = 0;
-
-  auto swap_parms_hook = [&](const char *parsee) {
-if (!parsee || !*parsee)
-  return;
-
-// Check whether we've found a substitutee
-llvm::StringRef s(parsee);
-if (s.startswith(search)) {
-  // account for the case where a replacement is of a different length to
-  // the original
-  replaced_offset += replace.size() - search.size();
-
-  ptrdiff_t replace_idx = (mangled.size() - s.size()) + replaced_offset;
-  output_buf.erase(replace_idx, search.size());
-  output_buf.insert(replace_idx, replace.str());
+  return ConstString(output);
+}
+
+static void Callback(void *context, const char *match) {
+  ((PrimitiveParmSubs *)context)->Substitute(llvm::StringRef(match));
 }
   };
 
-  // FastDemangle will call our hook for each instance of a primitive type,
+  // FastDemangle will call back for each instance of a primitive type,
   // allowing us to perform substitution
-  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_

[Lldb-commits] [PATCH] D50536: Fix: ConstString::GetConstCStringAndSetMangledCounterPart() should update the value if the key exists already

2018-08-14 Thread Phabricator via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rLLDB339669: Fix: 
ConstString::GetConstCStringAndSetMangledCounterPart() should update the… 
(authored by stefan.graenitz, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D50536?vs=160143&id=160549#toc

Repository:
  rLLDB LLDB

https://reviews.llvm.org/D50536

Files:
  source/Utility/ConstString.cpp
  unittests/Utility/ConstStringTest.cpp

Index: unittests/Utility/ConstStringTest.cpp
===
--- unittests/Utility/ConstStringTest.cpp
+++ unittests/Utility/ConstStringTest.cpp
@@ -18,40 +18,60 @@
 }
 
 TEST(ConstStringTest, MangledCounterpart) {
-  ConstString foo("foo");
+  ConstString uvw("uvw");
   ConstString counterpart;
-  EXPECT_FALSE(foo.GetMangledCounterpart(counterpart));
+  EXPECT_FALSE(uvw.GetMangledCounterpart(counterpart));
   EXPECT_EQ("", counterpart.GetStringRef());
 
-  ConstString bar;
-  bar.SetStringWithMangledCounterpart("bar", foo);
-  EXPECT_EQ("bar", bar.GetStringRef());
+  ConstString xyz;
+  xyz.SetStringWithMangledCounterpart("xyz", uvw);
+  EXPECT_EQ("xyz", xyz.GetStringRef());
 
-  EXPECT_TRUE(bar.GetMangledCounterpart(counterpart));
-  EXPECT_EQ("foo", counterpart.GetStringRef());
+  EXPECT_TRUE(xyz.GetMangledCounterpart(counterpart));
+  EXPECT_EQ("uvw", counterpart.GetStringRef());
 
-  EXPECT_TRUE(foo.GetMangledCounterpart(counterpart));
-  EXPECT_EQ("bar", counterpart.GetStringRef());
+  EXPECT_TRUE(uvw.GetMangledCounterpart(counterpart));
+  EXPECT_EQ("xyz", counterpart.GetStringRef());
+}
+
+TEST(ConstStringTest, UpdateMangledCounterpart) {
+  { // Add counterpart
+ConstString some1;
+some1.SetStringWithMangledCounterpart("some", ConstString(""));
+  }
+  { // Overwrite empty string
+ConstString some2;
+some2.SetStringWithMangledCounterpart("some", ConstString("one"));
+  }
+  { // Overwrite with identical value
+ConstString some2;
+some2.SetStringWithMangledCounterpart("some", ConstString("one"));
+  }
+  { // Check counterpart is set
+ConstString counterpart;
+EXPECT_TRUE(ConstString("some").GetMangledCounterpart(counterpart));
+EXPECT_EQ("one", counterpart.GetStringRef());
+  }
 }
 
 TEST(ConstStringTest, FromMidOfBufferStringRef) {
   // StringRef's into bigger buffer: no null termination
-  const char *buffer = "foobarbaz";
+  const char *buffer = "abcdefghi";
   llvm::StringRef foo_ref(buffer, 3);
   llvm::StringRef bar_ref(buffer + 3, 3);
 
   ConstString foo(foo_ref);
 
   ConstString bar;
   bar.SetStringWithMangledCounterpart(bar_ref, foo);
-  EXPECT_EQ("bar", bar.GetStringRef());
+  EXPECT_EQ("def", bar.GetStringRef());
 
   ConstString counterpart;
   EXPECT_TRUE(bar.GetMangledCounterpart(counterpart));
-  EXPECT_EQ("foo", counterpart.GetStringRef());
+  EXPECT_EQ("abc", counterpart.GetStringRef());
 
   EXPECT_TRUE(foo.GetMangledCounterpart(counterpart));
-  EXPECT_EQ("bar", counterpart.GetStringRef());
+  EXPECT_EQ("def", counterpart.GetStringRef());
 }
 
 TEST(ConstStringTest, NullAndEmptyStates) {
Index: source/Utility/ConstString.cpp
===
--- source/Utility/ConstString.cpp
+++ source/Utility/ConstString.cpp
@@ -119,11 +119,16 @@
   const uint8_t h = hash(demangled);
   llvm::sys::SmartScopedWriter wlock(m_string_pools[h].m_mutex);
 
-  // Make string pool entry with the mangled counterpart already set
-  StringPoolEntryType &entry =
-  *m_string_pools[h]
-   .m_string_map.insert(std::make_pair(demangled, mangled_ccstr))
-   .first;
+  // Make or update string pool entry with the mangled counterpart
+  StringPool &map = m_string_pools[h].m_string_map;
+  StringPoolEntryType &entry = *map.try_emplace(demangled).first;
+
+  assert((entry.second == nullptr || entry.second == mangled_ccstr ||
+  strlen(entry.second) == 0) &&
+ "The demangled string must have a unique counterpart or otherwise "
+ "it must be empty");
+
+  entry.second = mangled_ccstr;
 
   // Extract the const version of the demangled_cstr
   demangled_ccstr = entry.getKeyData();
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D50997: Automatically set path to sanitizer runtime when running tests on macOS.

2018-08-20 Thread Phabricator via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rLLDB340218: Set path to sanitizer runtime when running tests 
through LIT on macOS. (authored by adrian, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D50997?vs=161566&id=161575#toc

Repository:
  rLLDB LLDB

https://reviews.llvm.org/D50997

Files:
  lit/Suite/lit.cfg
  lit/Suite/lit.site.cfg.in


Index: lit/Suite/lit.site.cfg.in
===
--- lit/Suite/lit.site.cfg.in
+++ lit/Suite/lit.site.cfg.in
@@ -9,6 +9,10 @@
 config.lit_tools_dir = "@LLVM_LIT_TOOLS_DIR@"
 config.lldb_obj_root = "@LLDB_BINARY_DIR@"
 config.lldb_src_root = "@LLDB_SOURCE_DIR@"
+config.cmake_cxx_compiler = "@CMAKE_CXX_COMPILER@"
+config.host_os = "@HOST_OS@"
+config.host_triple = "@LLVM_HOST_TRIPLE@"
+config.llvm_use_sanitizer = "@LLVM_USE_SANITIZER@"
 config.target_triple = "@TARGET_TRIPLE@"
 config.python_executable = "@PYTHON_EXECUTABLE@"
 config.dotest_path = "@LLDB_SOURCE_DIR@/test/dotest.py"
Index: lit/Suite/lit.cfg
===
--- lit/Suite/lit.cfg
+++ lit/Suite/lit.cfg
@@ -19,6 +19,19 @@
'Python', 'lldbsuite', 'test')
 config.test_exec_root = config.test_source_root
 
+# macOS flags needed for LLDB built with address sanitizer.
+if 'Address' in config.llvm_use_sanitizer and \
+   'Darwin' in config.host_os and \
+   'x86' in config.host_triple:
+  import subprocess
+  resource_dir = subprocess.check_output(
+config.cmake_cxx_compiler +' -print-resource-dir', shell=True).strip()
+  runtime = os.path.join(resource_dir, 'lib', 'darwin',
+ 'libclang_rt.asan_osx_dynamic.dylib')
+  config.environment['ASAN_OPTIONS'] = \
+'detect_stack_use_after_return=1:container_overflow=0'
+  config.environment['DYLD_INSERT_LIBRARIES'] = runtime
+
 # Build dotest command.
 dotest_cmd = [config.dotest_path, '-q']
 dotest_cmd.extend(config.dotest_args_str.split(';'))


Index: lit/Suite/lit.site.cfg.in
===
--- lit/Suite/lit.site.cfg.in
+++ lit/Suite/lit.site.cfg.in
@@ -9,6 +9,10 @@
 config.lit_tools_dir = "@LLVM_LIT_TOOLS_DIR@"
 config.lldb_obj_root = "@LLDB_BINARY_DIR@"
 config.lldb_src_root = "@LLDB_SOURCE_DIR@"
+config.cmake_cxx_compiler = "@CMAKE_CXX_COMPILER@"
+config.host_os = "@HOST_OS@"
+config.host_triple = "@LLVM_HOST_TRIPLE@"
+config.llvm_use_sanitizer = "@LLVM_USE_SANITIZER@"
 config.target_triple = "@TARGET_TRIPLE@"
 config.python_executable = "@PYTHON_EXECUTABLE@"
 config.dotest_path = "@LLDB_SOURCE_DIR@/test/dotest.py"
Index: lit/Suite/lit.cfg
===
--- lit/Suite/lit.cfg
+++ lit/Suite/lit.cfg
@@ -19,6 +19,19 @@
'Python', 'lldbsuite', 'test')
 config.test_exec_root = config.test_source_root
 
+# macOS flags needed for LLDB built with address sanitizer.
+if 'Address' in config.llvm_use_sanitizer and \
+   'Darwin' in config.host_os and \
+   'x86' in config.host_triple:
+  import subprocess
+  resource_dir = subprocess.check_output(
+config.cmake_cxx_compiler +' -print-resource-dir', shell=True).strip()
+  runtime = os.path.join(resource_dir, 'lib', 'darwin',
+ 'libclang_rt.asan_osx_dynamic.dylib')
+  config.environment['ASAN_OPTIONS'] = \
+'detect_stack_use_after_return=1:container_overflow=0'
+  config.environment['DYLD_INSERT_LIBRARIES'] = runtime
+
 # Build dotest command.
 dotest_cmd = [config.dotest_path, '-q']
 dotest_cmd.extend(config.dotest_args_str.split(';'))
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D50864: Add libc++ data formatter for std::function

2018-08-23 Thread Phabricator via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL340543: Add libc++ data formatter for std::function 
(authored by adrian, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D50864?vs=161997&id=162214#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D50864

Files:
  
lldb/trunk/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/function/TestLibCxxFunction.py
  
lldb/trunk/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/function/main.cpp
  lldb/trunk/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
  lldb/trunk/source/Plugins/Language/CPlusPlus/LibCxx.cpp
  lldb/trunk/source/Plugins/Language/CPlusPlus/LibCxx.h

Index: lldb/trunk/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/function/TestLibCxxFunction.py
===
--- lldb/trunk/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/function/TestLibCxxFunction.py
+++ lldb/trunk/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/function/TestLibCxxFunction.py
@@ -40,13 +40,17 @@
 substrs=['stopped',
  'stop reason = breakpoint'])
 
-f1 = self.get_variable('f1')
-f2 = self.get_variable('f2')
+self.expect("frame variable f1",
+substrs=['f1 =  Function = foo(int, int)'])
 
-if self.TraceOn():
-print(f1)
-if self.TraceOn():
-print(f2)
+self.expect("frame variable f2",
+substrs=['f2 =  Lambda in File main.cpp at Line 27'])
 
-self.assertTrue(f1.GetValueAsUnsigned(0) != 0, 'f1 has a valid value')
-self.assertTrue(f2.GetValueAsUnsigned(0) != 0, 'f2 has a valid value')
+self.expect("frame variable f3",
+substrs=['f3 =  Lambda in File main.cpp at Line 31'])
+
+self.expect("frame variable f4",
+substrs=['f4 =  Function in File main.cpp at Line 17'])
+
+self.expect("frame variable f5",
+substrs=['f5 =  Function = Bar::add_num(int) const'])
Index: lldb/trunk/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/function/main.cpp
===
--- lldb/trunk/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/function/main.cpp
+++ lldb/trunk/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/function/main.cpp
@@ -13,13 +13,28 @@
   return x + y - 1;
 }
 
-int main ()
+struct Bar {
+   int operator()() {
+   return 66 ;
+   }
+   int add_num(int i) const { return i + 3 ; }
+} ;
+
+int main (int argc, char *argv[])
 {
   int acc = 42;
   std::function f1 = foo;
   std::function f2 = [acc,f1] (int x) -> int {
 return x+f1(acc,x);
   };
-return f1(acc,acc) + f2(acc); // Set break point at this line.
-}
 
+  auto f = [](int x, int y) { return x + y; };
+  auto g = [](int x, int y) { return x * y; } ;
+  std::function f3 =  argc %2 ? f : g ;
+
+  Bar bar1 ;
+  std::function f4( bar1 ) ;
+  std::function f5 = &Bar::add_num;
+
+  return f1(acc,acc) + f2(acc) + f3(acc+1,acc+2) + f4() + f5(bar1, 10); // Set break point at this line.
+}
Index: lldb/trunk/source/Plugins/Language/CPlusPlus/LibCxx.h
===
--- lldb/trunk/source/Plugins/Language/CPlusPlus/LibCxx.h
+++ lldb/trunk/source/Plugins/Language/CPlusPlus/LibCxx.h
@@ -36,6 +36,10 @@
 const TypeSummaryOptions
 &options); // libc++ std::shared_ptr<> and std::weak_ptr<>
 
+bool LibcxxFunctionSummaryProvider(
+ValueObject &valobj, Stream &stream,
+const TypeSummaryOptions &options); // libc++ std::function<>
+
 SyntheticChildrenFrontEnd *
 LibcxxVectorBoolSyntheticFrontEndCreator(CXXSyntheticChildren *,
  lldb::ValueObjectSP);
@@ -128,9 +132,6 @@
 LibcxxInitializerListSyntheticFrontEndCreator(CXXSyntheticChildren *,
   lldb::ValueObjectSP);
 
-SyntheticChildrenFrontEnd *LibcxxFunctionFrontEndCreator(CXXSyntheticChildren *,
- lldb::ValueObjectSP);
-
 SyntheticChildrenFrontEnd *LibcxxQueueFrontEndCreator(CXXSyntheticChildren *,
   lldb::ValueObjectSP);
 
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
@@ -542,6 +542,11 @@
   ConstString("^(std::__(ndk)?

[Lldb-commits] [PATCH] D51442: Don't include the Age in the UUID for CvRecordPdb70 UUID records in minidump files

2018-08-29 Thread Phabricator via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rLLDB340966: Don't include the Age in the UUID for 
CvRecordPdb70 UUID records in minidump… (authored by gclayton, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D51442?vs=163143&id=163182#toc

Repository:
  rLLDB LLDB

https://reviews.llvm.org/D51442

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


Index: source/Plugins/Process/minidump/MinidumpParser.cpp
===
--- source/Plugins/Process/minidump/MinidumpParser.cpp
+++ source/Plugins/Process/minidump/MinidumpParser.cpp
@@ -80,8 +80,18 @@
 // PDB70 record
 const CvRecordPdb70 *pdb70_uuid = nullptr;
 Status error = consumeObject(cv_record, pdb70_uuid);
-if (!error.Fail())
-  return UUID::fromData(pdb70_uuid, sizeof(*pdb70_uuid));
+if (!error.Fail()) {
+  auto arch = GetArchitecture();
+  // For Apple targets we only need a 16 byte UUID so that we can match
+  // the UUID in the Module to actual UUIDs from the built binaries. The
+  // "Age" field is zero in breakpad minidump files for Apple targets, so
+  // we restrict the UUID to the "Uuid" field so we have a UUID we can use
+  // to match.
+  if (arch.GetTriple().getVendor() == llvm::Triple::Apple)
+return UUID::fromData(pdb70_uuid->Uuid, sizeof(pdb70_uuid->Uuid));
+  else
+return UUID::fromData(pdb70_uuid, sizeof(*pdb70_uuid));
+}
   } else if (cv_signature == CvSignature::ElfBuildId)
 return UUID::fromData(cv_record);
 


Index: source/Plugins/Process/minidump/MinidumpParser.cpp
===
--- source/Plugins/Process/minidump/MinidumpParser.cpp
+++ source/Plugins/Process/minidump/MinidumpParser.cpp
@@ -80,8 +80,18 @@
 // PDB70 record
 const CvRecordPdb70 *pdb70_uuid = nullptr;
 Status error = consumeObject(cv_record, pdb70_uuid);
-if (!error.Fail())
-  return UUID::fromData(pdb70_uuid, sizeof(*pdb70_uuid));
+if (!error.Fail()) {
+  auto arch = GetArchitecture();
+  // For Apple targets we only need a 16 byte UUID so that we can match
+  // the UUID in the Module to actual UUIDs from the built binaries. The
+  // "Age" field is zero in breakpad minidump files for Apple targets, so
+  // we restrict the UUID to the "Uuid" field so we have a UUID we can use
+  // to match.
+  if (arch.GetTriple().getVendor() == llvm::Triple::Apple)
+return UUID::fromData(pdb70_uuid->Uuid, sizeof(pdb70_uuid->Uuid));
+  else
+return UUID::fromData(pdb70_uuid, sizeof(*pdb70_uuid));
+}
   } else if (cv_signature == CvSignature::ElfBuildId)
 return UUID::fromData(cv_record);
 
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D51453: Refactor BreakpointResolver::SetSCMatchesByLine()

2018-08-29 Thread Phabricator via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL340994: Refactor BreakpointResolver::SetSCMatchesByLine() to 
make it easier to (authored by adrian, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D51453?vs=163198&id=163227#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D51453

Files:
  lldb/trunk/include/lldb/Breakpoint/BreakpointResolver.h
  lldb/trunk/source/Breakpoint/BreakpointResolver.cpp

Index: lldb/trunk/include/lldb/Breakpoint/BreakpointResolver.h
===
--- lldb/trunk/include/lldb/Breakpoint/BreakpointResolver.h
+++ lldb/trunk/include/lldb/Breakpoint/BreakpointResolver.h
@@ -237,6 +237,10 @@
 // breakpoints we set.
 
 private:
+  /// Helper for \p SetSCMatchesByLine.
+  void AddLocation(SearchFilter &filter, const SymbolContext &sc,
+   bool skip_prologue, llvm::StringRef log_ident);
+
   // Subclass identifier (for llvm isa/dyn_cast)
   const unsigned char SubclassID;
   DISALLOW_COPY_AND_ASSIGN(BreakpointResolver);
Index: lldb/trunk/source/Breakpoint/BreakpointResolver.cpp
===
--- lldb/trunk/source/Breakpoint/BreakpointResolver.cpp
+++ lldb/trunk/source/Breakpoint/BreakpointResolver.cpp
@@ -180,128 +180,109 @@
 SymbolContextList &sc_list,
 bool skip_prologue,
 llvm::StringRef log_ident) {
-  Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_BREAKPOINTS));
-
-  while (sc_list.GetSize() > 0) {
-SymbolContextList tmp_sc_list;
-unsigned current_idx = 0;
-SymbolContext sc;
-bool first_entry = true;
-
-FileSpec match_file_spec;
-FileSpec match_original_file_spec;
-uint32_t closest_line_number = UINT32_MAX;
-
-// Pull out the first entry, and all the others that match its file spec,
-// and stuff them in the tmp list.
-while (current_idx < sc_list.GetSize()) {
-  bool matches;
-
-  sc_list.GetContextAtIndex(current_idx, sc);
-  if (first_entry) {
-match_file_spec = sc.line_entry.file;
-match_original_file_spec = sc.line_entry.original_file;
-matches = true;
-first_entry = false;
-  } else
-matches = ((sc.line_entry.file == match_file_spec) ||
-   (sc.line_entry.original_file == match_original_file_spec));
-
-  if (matches) {
-tmp_sc_list.Append(sc);
-sc_list.RemoveContextAtIndex(current_idx);
-
-// ResolveSymbolContext will always return a number that is >= the line
-// number you pass in. So the smaller line number is always better.
-if (sc.line_entry.line < closest_line_number)
-  closest_line_number = sc.line_entry.line;
-  } else
-current_idx++;
+  llvm::SmallVector all_scs;
+  for (uint32_t i = 0; i < sc_list.GetSize(); ++i)
+all_scs.push_back(sc_list[i]);
+
+  while (all_scs.size()) {
+// ResolveSymbolContext will always return a number that is >= the
+// line number you pass in. So the smaller line number is always
+// better.
+uint32_t closest_line = UINT32_MAX;
+
+// Move all the elements with a matching file spec to the end.
+auto &match = all_scs[0];
+auto worklist_begin = std::partition(
+all_scs.begin(), all_scs.end(), [&](const SymbolContext &sc) {
+  if (sc.line_entry.file == match.line_entry.file ||
+  sc.line_entry.original_file == match.line_entry.original_file) {
+// When a match is found, keep track of the smallest line number.
+closest_line = std::min(closest_line, sc.line_entry.line);
+return false;
+  }
+  return true;
+});
+
+// Within, remove all entries with a larger line number.
+auto worklist_end = std::remove_if(
+worklist_begin, all_scs.end(), [&](const SymbolContext &sc) {
+  return closest_line != sc.line_entry.line;
+});
+
+// Sort by file address.
+std::sort(worklist_begin, worklist_end,
+  [](const SymbolContext &a, const SymbolContext &b) {
+return a.line_entry.range.GetBaseAddress().GetFileAddress() <
+   b.line_entry.range.GetBaseAddress().GetFileAddress();
+  });
+
+// Go through and see if there are line table entries that are
+// contiguous, and if so keep only the first of the contiguous range.
+// We do this by picking the first location in each lexical block.
+llvm::SmallDenseSet blocks_with_breakpoints;
+for (auto first = worklist_begin; first != worklist_end; ++first) {
+  assert(!blocks_with_breakpoints.count(first->block));
+  blocks_with_breakpoints.insert(first->block);
+  worklist_end =
+  std::remove_i

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

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

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

Repository:
  rL LLVM

https://reviews.llvm.org/D51461

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

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

[Lldb-commits] [PATCH] D51569: Hold GIL while allocating memory for PythonString.

2018-09-05 Thread Phabricator via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rLLDB341482: Hold GIL while allocating memory for 
PythonString. (authored by tkrasnukha, committed by ).

Repository:
  rLLDB LLDB

https://reviews.llvm.org/D51569

Files:
  scripts/Python/python-extensions.swig

Index: scripts/Python/python-extensions.swig
===
--- scripts/Python/python-extensions.swig
+++ scripts/Python/python-extensions.swig
@@ -1,5 +1,6 @@
 
 %extend lldb::SBAddress {
+%nothreadallow;
 PyObject *lldb::SBAddress::__str__ (){
 lldb::SBStream description;
 $self->GetDescription (description);
@@ -12,8 +13,10 @@
 else
 return lldb_private::PythonString("").release();
 }
+%clearnothreadallow;
 }
 %extend lldb::SBBlock {
+%nothreadallow;
 PyObject *lldb::SBBlock::__str__ (){
 lldb::SBStream description;
 $self->GetDescription (description);
@@ -26,8 +29,10 @@
 else
 return lldb_private::PythonString("").release();
 }
+%clearnothreadallow;
 }
 %extend lldb::SBBreakpoint {
+%nothreadallow;
 PyObject *lldb::SBBreakpoint::__str__ (){
 lldb::SBStream description;
 $self->GetDescription (description);
@@ -40,6 +45,7 @@
 else
 return lldb_private::PythonString("").release();
 }
+%clearnothreadallow;
 
 %pythoncode %{ 
 def __eq__(self, rhs):
@@ -57,6 +63,7 @@
 
 }
 %extend lldb::SBBreakpointLocation {
+%nothreadallow;
 PyObject *lldb::SBBreakpointLocation::__str__ (){
 lldb::SBStream description;
 $self->GetDescription (description, lldb::eDescriptionLevelFull);
@@ -69,9 +76,11 @@
 else
 return lldb_private::PythonString("").release();
 }
+%clearnothreadallow;
 }
 
 %extend lldb::SBBreakpointName {
+%nothreadallow;
 PyObject *lldb::SBBreakpointName::__str__ (){
 lldb::SBStream description;
 $self->GetDescription (description);
@@ -84,6 +93,7 @@
 else
 return lldb_private::PythonString("").release();
 }
+%clearnothreadallow;
 }
 
 %extend lldb::SBBroadcaster {
@@ -103,6 +113,7 @@
 }
 
 %extend lldb::SBCommandReturnObject {
+%nothreadallow;
 PyObject *lldb::SBCommandReturnObject::__str__ (){
 lldb::SBStream description;
 $self->GetDescription (description);
@@ -115,6 +126,7 @@
 else
 return lldb_private::PythonString("").release();
 }
+%clearnothreadallow;
 
 /* the write() and flush() calls are not part of the SB API proper, and are solely for Python usage
 they are meant to make an SBCommandReturnObject into a file-like object so that instructions of the sort
@@ -130,6 +142,7 @@
 {}
 }
 %extend lldb::SBCompileUnit {
+%nothreadallow;
 PyObject *lldb::SBCompileUnit::__str__ (){
 lldb::SBStream description;
 $self->GetDescription (description);
@@ -142,6 +155,7 @@
 else
 return lldb_private::PythonString("").release();
 }
+%clearnothreadallow;
 %pythoncode %{ 
 def __eq__(self, rhs):
 if not isinstance(rhs, type(self)): 
@@ -157,6 +171,7 @@
 %}
 }
 %extend lldb::SBData {
+%nothreadallow;
 PyObject *lldb::SBData::__str__ (){
 lldb::SBStream description;
 $self->GetDescription (description);
@@ -169,8 +184,10 @@
 else
 return lldb_private::PythonString("").release();
 }
+%clearnothreadallow;
 }
 %extend lldb::SBDebugger {
+%nothreadallow;
 PyObject *lldb::SBDebugger::__str__ (){
 lldb::SBStream description;
 $self->GetDescription (description);
@@ -183,8 +200,10 @@
 else
 return lldb_private::PythonString("").release();
 }
+%clearnothreadallow;
 }
 %extend lldb::SBDeclaration {
+%nothreadallow;
 PyObject *lldb::SBDeclaration::__str__ (){
 lldb::SBStream description;
 $self->GetDescription (description);
@@ -197,6 +216,7 @@
 else
 return lldb_private::PythonString("").release();
 }
+%clearnothreadallow;
 
 %pythoncode %{ 
 def __eq__(self, rhs):
@@ -214,6 +234,7 @@
 
 }
 %extend lldb::SBError {
+%nothreadallow;
 PyObject *lldb::SBError::__str__ (){
 lldb::SBStream description;
 $self->GetDescription (description);
@@ -226,8 +2

[Lldb-commits] [PATCH] D51661: Print column info in backtraces et al. if available

2018-09-05 Thread Phabricator via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL341506: Print column info in backtraces et al. if available 
(authored by adrian, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D51661?vs=164104&id=164128#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D51661

Files:
  lldb/trunk/include/lldb/Core/FormatEntity.h
  lldb/trunk/packages/Python/lldbsuite/test/functionalities/asan/Makefile
  
lldb/trunk/packages/Python/lldbsuite/test/functionalities/asan/TestReportData.py
  lldb/trunk/source/Core/Debugger.cpp
  lldb/trunk/source/Core/FormatEntity.cpp


Index: lldb/trunk/source/Core/FormatEntity.cpp
===
--- lldb/trunk/source/Core/FormatEntity.cpp
+++ lldb/trunk/source/Core/FormatEntity.cpp
@@ -146,6 +146,7 @@
 static FormatEntity::Entry::Definition g_line_child_entries[] = {
 ENTRY_CHILDREN("file", LineEntryFile, None, g_file_child_entries),
 ENTRY("number", LineEntryLineNumber, UInt32),
+ENTRY("column", LineEntryColumn, UInt32),
 ENTRY("start-addr", LineEntryStartAddress, UInt64),
 ENTRY("end-addr", LineEntryEndAddress, UInt64),
 };
@@ -372,6 +373,7 @@
 ENUM_TO_CSTR(FunctionIsOptimized);
 ENUM_TO_CSTR(LineEntryFile);
 ENUM_TO_CSTR(LineEntryLineNumber);
+ENUM_TO_CSTR(LineEntryColumn);
 ENUM_TO_CSTR(LineEntryStartAddress);
 ENUM_TO_CSTR(LineEntryEndAddress);
 ENUM_TO_CSTR(CurrentPCArrow);
@@ -1814,6 +1816,16 @@
 }
 return false;
 
+  case Entry::Type::LineEntryColumn:
+if (sc && sc->line_entry.IsValid() && sc->line_entry.column) {
+  const char *format = "%" PRIu32;
+  if (!entry.printf_format.empty())
+format = entry.printf_format.c_str();
+  s.Printf(format, sc->line_entry.column);
+  return true;
+}
+return false;
+
   case Entry::Type::LineEntryStartAddress:
   case Entry::Type::LineEntryEndAddress:
 if (sc && sc->line_entry.range.GetBaseAddress().IsValid()) {
Index: lldb/trunk/source/Core/Debugger.cpp
===
--- lldb/trunk/source/Core/Debugger.cpp
+++ lldb/trunk/source/Core/Debugger.cpp
@@ -121,7 +121,8 @@
   "${module.file.basename}{`${function.name-without-args}" 
\
   "{${frame.no-debug}${function.pc-offset"
 
-#define FILE_AND_LINE "{ at ${line.file.basename}:${line.number}}"
+#define FILE_AND_LINE  
\
+  "{ at ${line.file.basename}:${line.number}{:${line.column}}}"
 #define IS_OPTIMIZED "{${function.is-optimized} [opt]}"
 
 #define DEFAULT_THREAD_FORMAT  
\
Index: lldb/trunk/include/lldb/Core/FormatEntity.h
===
--- lldb/trunk/include/lldb/Core/FormatEntity.h
+++ lldb/trunk/include/lldb/Core/FormatEntity.h
@@ -104,6 +104,7 @@
   FunctionIsOptimized,
   LineEntryFile,
   LineEntryLineNumber,
+  LineEntryColumn,
   LineEntryStartAddress,
   LineEntryEndAddress,
   CurrentPCArrow
Index: lldb/trunk/packages/Python/lldbsuite/test/functionalities/asan/Makefile
===
--- lldb/trunk/packages/Python/lldbsuite/test/functionalities/asan/Makefile
+++ lldb/trunk/packages/Python/lldbsuite/test/functionalities/asan/Makefile
@@ -1,6 +1,6 @@
 LEVEL = ../../make
 
 C_SOURCES := main.c
-CFLAGS_EXTRAS := -fsanitize=address -g
+CFLAGS_EXTRAS := -fsanitize=address -g -gcolumn-info
 
 include $(LEVEL)/Makefile.rules
Index: 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/asan/TestReportData.py
===
--- 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/asan/TestReportData.py
+++ 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/asan/TestReportData.py
@@ -37,6 +37,7 @@
 self.line_free = line_number('main.c', '// free line')
 self.line_breakpoint = line_number('main.c', '// break line')
 self.line_crash = line_number('main.c', '// BOOM line')
+self.col_crash = 16
 
 def asan_tests(self):
 exe = self.getBuildArtifact("a.out")
@@ -63,7 +64,7 @@
 lldb.eStopReasonInstrumentation)
 
 self.expect("bt", "The backtrace should show the crashing line",
-substrs=['main.c:%d' % self.line_crash])
+substrs=['main.c:%d:%d' % (self.line_crash, 
self.col_crash)])
 
 self.expect(
 "thread info -s",


Index: lldb/trunk/source/Core/FormatEntity.cpp
===
--- lldb/trunk/source/Core/FormatEntity.cpp
+++ lldb/trunk/source/Core/FormatEntity.cpp
@@ -146,6 +146,7 @@
 static FormatEntity::Entry::Definition g_line_child_entries[] = {
 ENTRY_CHILDREN("file", LineEntryFile, None, 

[Lldb-commits] [PATCH] D50751: Allow use of self.filecheck in LLDB tests (c.f self.expect)

2018-09-18 Thread Phabricator via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL342508: Allow use of self.filecheck in LLDB tests (c.f 
self.expect) (authored by vedantk, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D50751?vs=165613&id=166018#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D50751

Files:
  lldb/trunk/CMakeLists.txt
  lldb/trunk/lldb.xcodeproj/project.pbxproj
  lldb/trunk/packages/Python/lldbsuite/test/configuration.py
  lldb/trunk/packages/Python/lldbsuite/test/dotest.py
  lldb/trunk/packages/Python/lldbsuite/test/dotest_args.py
  
lldb/trunk/packages/Python/lldbsuite/test/expression_command/formatters/TestFormatters.py
  
lldb/trunk/packages/Python/lldbsuite/test/functionalities/data-formatter/typedef_array/main.cpp
  lldb/trunk/packages/Python/lldbsuite/test/lldbtest.py
  lldb/trunk/test/CMakeLists.txt

Index: lldb/trunk/test/CMakeLists.txt
===
--- lldb/trunk/test/CMakeLists.txt
+++ lldb/trunk/test/CMakeLists.txt
@@ -49,6 +49,7 @@
 list(APPEND LLDB_TEST_COMMON_ARGS
   --executable ${LLDB_TEST_EXECUTABLE}
   --dsymutil ${LLDB_TEST_DSYMUTIL}
+  --filecheck ${LLDB_TEST_FILECHECK}
   -C ${LLDB_TEST_C_COMPILER}
   )
 
Index: lldb/trunk/packages/Python/lldbsuite/test/configuration.py
===
--- lldb/trunk/packages/Python/lldbsuite/test/configuration.py
+++ lldb/trunk/packages/Python/lldbsuite/test/configuration.py
@@ -46,6 +46,9 @@
 arch = None# Must be initialized after option parsing
 compiler = None# Must be initialized after option parsing
 
+# Path to the FileCheck testing tool. Not optional.
+filecheck = None
+
 # The arch might dictate some specific CFLAGS to be passed to the toolchain to build
 # the inferior programs.  The global variable cflags_extras provides a hook to do
 # just that.
@@ -179,3 +182,11 @@
 return test_subdir
 
 return os.path.dirname(os.path.realpath(__file__))
+
+
+def get_filecheck_path():
+"""
+Get the path to the FileCheck testing tool.
+"""
+assert os.path.lexists(filecheck)
+return filecheck
Index: lldb/trunk/packages/Python/lldbsuite/test/expression_command/formatters/TestFormatters.py
===
--- lldb/trunk/packages/Python/lldbsuite/test/expression_command/formatters/TestFormatters.py
+++ lldb/trunk/packages/Python/lldbsuite/test/expression_command/formatters/TestFormatters.py
@@ -57,14 +57,21 @@
 self.runCmd("frame variable foo1.b --show-types")
 self.runCmd("frame variable foo1.b.b_ref --show-types")
 
-self.expect(
-"expression --show-types -- *(new foo(47))",
-substrs=[
-'(int) a = 47',
-'(bar) b = {',
-'(int) i = 94',
-'(baz) b = {',
-'(int) k = 99'])
+self.filecheck("expression --show-types -- *(new foo(47))", __file__,
+'-check-prefix=EXPR-TYPES-NEW-FOO')
+# EXPR-TYPES-NEW-FOO: (foo) ${{.*}} = {
+# EXPR-TYPES-NEW-FOO-NEXT:   (int) a = 47
+# EXPR-TYPES-NEW-FOO-NEXT:   (int *) a_ptr = 0x
+# EXPR-TYPES-NEW-FOO-NEXT:   (bar) b = {
+# EXPR-TYPES-NEW-FOO-NEXT: (int) i = 94
+# EXPR-TYPES-NEW-FOO-NEXT: (int *) i_ptr = 0x
+# EXPR-TYPES-NEW-FOO-NEXT: (baz) b = {
+# EXPR-TYPES-NEW-FOO-NEXT:   (int) h = 97
+# EXPR-TYPES-NEW-FOO-NEXT:   (int) k = 99
+# EXPR-TYPES-NEW-FOO-NEXT: }
+# EXPR-TYPES-NEW-FOO-NEXT: (baz &) b_ref = 0x
+# EXPR-TYPES-NEW-FOO-NEXT:   }
+# EXPR-TYPES-NEW-FOO-NEXT: }
 
 self.runCmd("type summary add -F formatters.foo_SummaryProvider foo")
 
@@ -80,68 +87,49 @@
 self.expect("expression foo1.a_ptr",
 substrs=['(int *) $', '= 0x', ' -> 13'])
 
-self.expect(
-"expression foo1",
-substrs=[
-'(foo) $',
-' a = 12',
-'a_ptr = ',
-' -> 13',
-'i = 24',
-'i_ptr = ',
-' -> 25'])
-
-self.expect(
-"expression --ptr-depth=1 -- new foo(47)",
-substrs=[
-'(foo *) $',
-'a = 47',
-'a_ptr = ',
-' -> 48',
-'i = 94',
-'i_ptr = ',
-' -> 95'])
-
-self.expect(
-"expression foo2",
-substrs=[
-'(foo) $',
-'a = 121',
-'a_ptr = ',
-' -> 122',
-'i = 242',
-'i_ptr = ',
-' -> 243'])
+self.filecheck("expression foo1", __file__, '-check-prefix=EXPR-FOO1')
+# EXPR-FOO1: (foo) $
+# EXPR-FOO1-SAME: a = 12

[Lldb-commits] [PATCH] D50751: Allow use of self.filecheck in LLDB tests (c.f self.expect)

2018-09-18 Thread Phabricator via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rLLDB342508: Allow use of self.filecheck in LLDB tests (c.f 
self.expect) (authored by vedantk, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D50751?vs=165613&id=166017#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D50751

Files:
  CMakeLists.txt
  lldb.xcodeproj/project.pbxproj
  packages/Python/lldbsuite/test/configuration.py
  packages/Python/lldbsuite/test/dotest.py
  packages/Python/lldbsuite/test/dotest_args.py
  packages/Python/lldbsuite/test/expression_command/formatters/TestFormatters.py
  
packages/Python/lldbsuite/test/functionalities/data-formatter/typedef_array/main.cpp
  packages/Python/lldbsuite/test/lldbtest.py
  test/CMakeLists.txt

Index: test/CMakeLists.txt
===
--- test/CMakeLists.txt
+++ test/CMakeLists.txt
@@ -49,6 +49,7 @@
 list(APPEND LLDB_TEST_COMMON_ARGS
   --executable ${LLDB_TEST_EXECUTABLE}
   --dsymutil ${LLDB_TEST_DSYMUTIL}
+  --filecheck ${LLDB_TEST_FILECHECK}
   -C ${LLDB_TEST_C_COMPILER}
   )
 
Index: packages/Python/lldbsuite/test/configuration.py
===
--- packages/Python/lldbsuite/test/configuration.py
+++ packages/Python/lldbsuite/test/configuration.py
@@ -46,6 +46,9 @@
 arch = None# Must be initialized after option parsing
 compiler = None# Must be initialized after option parsing
 
+# Path to the FileCheck testing tool. Not optional.
+filecheck = None
+
 # The arch might dictate some specific CFLAGS to be passed to the toolchain to build
 # the inferior programs.  The global variable cflags_extras provides a hook to do
 # just that.
@@ -179,3 +182,11 @@
 return test_subdir
 
 return os.path.dirname(os.path.realpath(__file__))
+
+
+def get_filecheck_path():
+"""
+Get the path to the FileCheck testing tool.
+"""
+assert os.path.lexists(filecheck)
+return filecheck
Index: packages/Python/lldbsuite/test/expression_command/formatters/TestFormatters.py
===
--- packages/Python/lldbsuite/test/expression_command/formatters/TestFormatters.py
+++ packages/Python/lldbsuite/test/expression_command/formatters/TestFormatters.py
@@ -57,14 +57,21 @@
 self.runCmd("frame variable foo1.b --show-types")
 self.runCmd("frame variable foo1.b.b_ref --show-types")
 
-self.expect(
-"expression --show-types -- *(new foo(47))",
-substrs=[
-'(int) a = 47',
-'(bar) b = {',
-'(int) i = 94',
-'(baz) b = {',
-'(int) k = 99'])
+self.filecheck("expression --show-types -- *(new foo(47))", __file__,
+'-check-prefix=EXPR-TYPES-NEW-FOO')
+# EXPR-TYPES-NEW-FOO: (foo) ${{.*}} = {
+# EXPR-TYPES-NEW-FOO-NEXT:   (int) a = 47
+# EXPR-TYPES-NEW-FOO-NEXT:   (int *) a_ptr = 0x
+# EXPR-TYPES-NEW-FOO-NEXT:   (bar) b = {
+# EXPR-TYPES-NEW-FOO-NEXT: (int) i = 94
+# EXPR-TYPES-NEW-FOO-NEXT: (int *) i_ptr = 0x
+# EXPR-TYPES-NEW-FOO-NEXT: (baz) b = {
+# EXPR-TYPES-NEW-FOO-NEXT:   (int) h = 97
+# EXPR-TYPES-NEW-FOO-NEXT:   (int) k = 99
+# EXPR-TYPES-NEW-FOO-NEXT: }
+# EXPR-TYPES-NEW-FOO-NEXT: (baz &) b_ref = 0x
+# EXPR-TYPES-NEW-FOO-NEXT:   }
+# EXPR-TYPES-NEW-FOO-NEXT: }
 
 self.runCmd("type summary add -F formatters.foo_SummaryProvider foo")
 
@@ -80,68 +87,49 @@
 self.expect("expression foo1.a_ptr",
 substrs=['(int *) $', '= 0x', ' -> 13'])
 
-self.expect(
-"expression foo1",
-substrs=[
-'(foo) $',
-' a = 12',
-'a_ptr = ',
-' -> 13',
-'i = 24',
-'i_ptr = ',
-' -> 25'])
-
-self.expect(
-"expression --ptr-depth=1 -- new foo(47)",
-substrs=[
-'(foo *) $',
-'a = 47',
-'a_ptr = ',
-' -> 48',
-'i = 94',
-'i_ptr = ',
-' -> 95'])
-
-self.expect(
-"expression foo2",
-substrs=[
-'(foo) $',
-'a = 121',
-'a_ptr = ',
-' -> 122',
-'i = 242',
-'i_ptr = ',
-' -> 243'])
+self.filecheck("expression foo1", __file__, '-check-prefix=EXPR-FOO1')
+# EXPR-FOO1: (foo) $
+# EXPR-FOO1-SAME: a = 12
+# EXPR-FOO1-SAME: a_ptr = {{[0-9]+}} -> 13
+# EXPR-FOO1-SAME: i = 24
+# EXPR-FOO1-SAME: i_ptr = {{[0-9]+}} -> 25
+# EXPR-FOO1-SAME: b_ref = {{[0-9]+}}
+# EXPR-FOO1-SAME: h = 27
+# EXPR-FOO

[Lldb-commits] [PATCH] D39574: Add type to FileSpec::PathSyntax enum.

2017-11-03 Thread Phabricator via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL317327: Add type to FileSpec::PathSyntax enum. (authored by 
dhinton).

Repository:
  rL LLVM

https://reviews.llvm.org/D39574

Files:
  lldb/trunk/include/lldb/Utility/FileSpec.h


Index: lldb/trunk/include/lldb/Utility/FileSpec.h
===
--- lldb/trunk/include/lldb/Utility/FileSpec.h
+++ lldb/trunk/include/lldb/Utility/FileSpec.h
@@ -61,7 +61,7 @@
 //--
 class FileSpec {
 public:
-  enum PathSyntax {
+  enum PathSyntax : unsigned char {
 ePathSyntaxPosix,
 ePathSyntaxWindows,
 ePathSyntaxHostNative


Index: lldb/trunk/include/lldb/Utility/FileSpec.h
===
--- lldb/trunk/include/lldb/Utility/FileSpec.h
+++ lldb/trunk/include/lldb/Utility/FileSpec.h
@@ -61,7 +61,7 @@
 //--
 class FileSpec {
 public:
-  enum PathSyntax {
+  enum PathSyntax : unsigned char {
 ePathSyntaxPosix,
 ePathSyntaxWindows,
 ePathSyntaxHostNative
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D39578: Fix a couple of self-assignments using memcpy.

2017-11-14 Thread Phabricator via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL318164: Add check for self-assignment.  NFC (authored by 
dhinton).

Repository:
  rL LLVM

https://reviews.llvm.org/D39578

Files:
  lldb/trunk/source/Core/RegisterValue.cpp
  lldb/trunk/source/Core/Value.cpp


Index: lldb/trunk/source/Core/Value.cpp
===
--- lldb/trunk/source/Core/Value.cpp
+++ lldb/trunk/source/Core/Value.cpp
@@ -142,6 +142,9 @@
 }
 
 size_t Value::AppendDataToHostBuffer(const Value &rhs) {
+  if (this == &rhs)
+return 0;
+
   size_t curr_size = m_data_buffer.GetByteSize();
   Status error;
   switch (rhs.GetValueType()) {
Index: lldb/trunk/source/Core/RegisterValue.cpp
===
--- lldb/trunk/source/Core/RegisterValue.cpp
+++ lldb/trunk/source/Core/RegisterValue.cpp
@@ -539,6 +539,9 @@
 }
 
 bool RegisterValue::CopyValue(const RegisterValue &rhs) {
+  if (this == &rhs)
+return rhs.m_type == eTypeInvalid ? false : true;
+
   m_type = rhs.m_type;
   switch (m_type) {
   case eTypeInvalid:


Index: lldb/trunk/source/Core/Value.cpp
===
--- lldb/trunk/source/Core/Value.cpp
+++ lldb/trunk/source/Core/Value.cpp
@@ -142,6 +142,9 @@
 }
 
 size_t Value::AppendDataToHostBuffer(const Value &rhs) {
+  if (this == &rhs)
+return 0;
+
   size_t curr_size = m_data_buffer.GetByteSize();
   Status error;
   switch (rhs.GetValueType()) {
Index: lldb/trunk/source/Core/RegisterValue.cpp
===
--- lldb/trunk/source/Core/RegisterValue.cpp
+++ lldb/trunk/source/Core/RegisterValue.cpp
@@ -539,6 +539,9 @@
 }
 
 bool RegisterValue::CopyValue(const RegisterValue &rhs) {
+  if (this == &rhs)
+return rhs.m_type == eTypeInvalid ? false : true;
+
   m_type = rhs.m_type;
   switch (m_type) {
   case eTypeInvalid:
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D40821: Fix const-correctness in RegisterContext methods, NFC

2017-12-06 Thread Phabricator via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL319939: Fix const-correctness in RegisterContext methods, 
NFC (authored by vedantk).

Changed prior to commit:
  https://reviews.llvm.org/D40821?vs=125639&id=125774#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D40821

Files:
  lldb/trunk/source/Plugins/Process/Utility/RegisterContextMach_arm.cpp
  lldb/trunk/source/Plugins/Process/Utility/RegisterContextMach_i386.cpp
  lldb/trunk/source/Plugins/Process/Utility/RegisterContextMach_x86_64.cpp

Index: lldb/trunk/source/Plugins/Process/Utility/RegisterContextMach_i386.cpp
===
--- lldb/trunk/source/Plugins/Process/Utility/RegisterContextMach_i386.cpp
+++ lldb/trunk/source/Plugins/Process/Utility/RegisterContextMach_i386.cpp
@@ -43,17 +43,23 @@
 
 int RegisterContextMach_i386::DoWriteGPR(lldb::tid_t tid, int flavor,
  const GPR &gpr) {
-  return ::thread_set_state(tid, flavor, (thread_state_t)&gpr, GPRWordCount);
+  return ::thread_set_state(
+  tid, flavor, reinterpret_cast(const_cast(&gpr)),
+  GPRWordCount);
 }
 
 int RegisterContextMach_i386::DoWriteFPU(lldb::tid_t tid, int flavor,
  const FPU &fpu) {
-  return ::thread_set_state(tid, flavor, (thread_state_t)&fpu, FPUWordCount);
+  return ::thread_set_state(
+  tid, flavor, reinterpret_cast(const_cast(&fpu)),
+  FPUWordCount);
 }
 
 int RegisterContextMach_i386::DoWriteEXC(lldb::tid_t tid, int flavor,
  const EXC &exc) {
-  return ::thread_set_state(tid, flavor, (thread_state_t)&exc, EXCWordCount);
+  return ::thread_set_state(
+  tid, flavor, reinterpret_cast(const_cast(&exc)),
+  EXCWordCount);
 }
 
 #endif
Index: lldb/trunk/source/Plugins/Process/Utility/RegisterContextMach_arm.cpp
===
--- lldb/trunk/source/Plugins/Process/Utility/RegisterContextMach_arm.cpp
+++ lldb/trunk/source/Plugins/Process/Utility/RegisterContextMach_arm.cpp
@@ -50,22 +50,30 @@
 
 int RegisterContextMach_arm::DoWriteGPR(lldb::tid_t tid, int flavor,
 const GPR &gpr) {
-  return ::thread_set_state(tid, flavor, (thread_state_t)&gpr, GPRWordCount);
+  return ::thread_set_state(
+  tid, flavor, reinterpret_cast(const_cast(&gpr)),
+  GPRWordCount);
 }
 
 int RegisterContextMach_arm::DoWriteFPU(lldb::tid_t tid, int flavor,
 const FPU &fpu) {
-  return ::thread_set_state(tid, flavor, (thread_state_t)&fpu, FPUWordCount);
+  return ::thread_set_state(
+  tid, flavor, reinterpret_cast(const_cast(&fpu)),
+  FPUWordCount);
 }
 
 int RegisterContextMach_arm::DoWriteEXC(lldb::tid_t tid, int flavor,
 const EXC &exc) {
-  return ::thread_set_state(tid, flavor, (thread_state_t)&exc, EXCWordCount);
+  return ::thread_set_state(
+  tid, flavor, reinterpret_cast(const_cast(&exc)),
+  EXCWordCount);
 }
 
 int RegisterContextMach_arm::DoWriteDBG(lldb::tid_t tid, int flavor,
 const DBG &dbg) {
-  return ::thread_set_state(tid, flavor, (thread_state_t)&dbg, DBGWordCount);
+  return ::thread_set_state(
+  tid, flavor, reinterpret_cast(const_cast(&dbg)),
+  DBGWordCount);
 }
 
 #endif
Index: lldb/trunk/source/Plugins/Process/Utility/RegisterContextMach_x86_64.cpp
===
--- lldb/trunk/source/Plugins/Process/Utility/RegisterContextMach_x86_64.cpp
+++ lldb/trunk/source/Plugins/Process/Utility/RegisterContextMach_x86_64.cpp
@@ -46,17 +46,23 @@
 
 int RegisterContextMach_x86_64::DoWriteGPR(lldb::tid_t tid, int flavor,
const GPR &gpr) {
-  return ::thread_set_state(tid, flavor, (thread_state_t)&gpr, GPRWordCount);
+  return ::thread_set_state(
+  tid, flavor, reinterpret_cast(const_cast(&gpr)),
+  GPRWordCount);
 }
 
 int RegisterContextMach_x86_64::DoWriteFPU(lldb::tid_t tid, int flavor,
const FPU &fpu) {
-  return ::thread_set_state(tid, flavor, (thread_state_t)&fpu, FPUWordCount);
+  return ::thread_set_state(
+  tid, flavor, reinterpret_cast(const_cast(&fpu)),
+  FPUWordCount);
 }
 
 int RegisterContextMach_x86_64::DoWriteEXC(lldb::tid_t tid, int flavor,
const EXC &exc) {
-  return ::thread_set_state(tid, flavor, (thread_state_t)&exc, EXCWordCount);
+  return ::thread_set_state(
+  tid, flavor, reinterpret_cast(const_cast(&exc)),
+  EXCWordCount);
 }
 
 #endif
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D40812: Remove no-op null checks, NFC

2017-12-06 Thread Phabricator via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL319936: Remove no-op function pointer null checks, NFC 
(authored by vedantk).

Changed prior to commit:
  https://reviews.llvm.org/D40812?vs=125437&id=125773#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D40812

Files:
  lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp
  lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
  lldb/trunk/tools/debugserver/source/MacOSX/OsLogger.cpp
  lldb/trunk/tools/debugserver/source/RNBRemote.cpp

Index: lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp
===
--- lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp
+++ lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp
@@ -600,10 +600,9 @@
 #if defined(HAVE_LIBCOMPRESSION)
   // libcompression is weak linked so check that compression_decode_buffer() is
   // available
-  if (compression_decode_buffer != NULL &&
-  (m_compression_type == CompressionType::ZlibDeflate ||
-   m_compression_type == CompressionType::LZFSE ||
-   m_compression_type == CompressionType::LZ4)) {
+  if (m_compression_type == CompressionType::ZlibDeflate ||
+  m_compression_type == CompressionType::LZFSE ||
+  m_compression_type == CompressionType::LZ4) {
 compression_algorithm compression_type;
 if (m_compression_type == CompressionType::LZFSE)
   compression_type = COMPRESSION_LZFSE;
Index: lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
===
--- lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
+++ lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
@@ -1022,10 +1022,7 @@
   std::string avail_name;
 
 #if defined(HAVE_LIBCOMPRESSION)
-  // libcompression is weak linked so test if compression_decode_buffer() is
-  // available
-  if (compression_decode_buffer != NULL &&
-  avail_type == CompressionType::None) {
+  if (avail_type == CompressionType::None) {
 for (auto compression : supported_compressions) {
   if (compression == "lzfse") {
 avail_type = CompressionType::LZFSE;
@@ -1037,10 +1034,7 @@
 #endif
 
 #if defined(HAVE_LIBCOMPRESSION)
-  // libcompression is weak linked so test if compression_decode_buffer() is
-  // available
-  if (compression_decode_buffer != NULL &&
-  avail_type == CompressionType::None) {
+  if (avail_type == CompressionType::None) {
 for (auto compression : supported_compressions) {
   if (compression == "zlib-deflate") {
 avail_type = CompressionType::ZlibDeflate;
@@ -1064,10 +1058,7 @@
 #endif
 
 #if defined(HAVE_LIBCOMPRESSION)
-  // libcompression is weak linked so test if compression_decode_buffer() is
-  // available
-  if (compression_decode_buffer != NULL &&
-  avail_type == CompressionType::None) {
+  if (avail_type == CompressionType::None) {
 for (auto compression : supported_compressions) {
   if (compression == "lz4") {
 avail_type = CompressionType::LZ4;
@@ -1079,10 +1070,7 @@
 #endif
 
 #if defined(HAVE_LIBCOMPRESSION)
-  // libcompression is weak linked so test if compression_decode_buffer() is
-  // available
-  if (compression_decode_buffer != NULL &&
-  avail_type == CompressionType::None) {
+  if (avail_type == CompressionType::None) {
 for (auto compression : supported_compressions) {
   if (compression == "lzma") {
 avail_type = CompressionType::LZMA;
Index: lldb/trunk/tools/debugserver/source/MacOSX/OsLogger.cpp
===
--- lldb/trunk/tools/debugserver/source/MacOSX/OsLogger.cpp
+++ lldb/trunk/tools/debugserver/source/MacOSX/OsLogger.cpp
@@ -56,9 +56,7 @@
 }
 }
 
-DNBCallbackLog OsLogger::GetLogFunction() {
-  return _os_log_impl ? DarwinLogCallback : nullptr;
-}
+DNBCallbackLog OsLogger::GetLogFunction() { return DarwinLogCallback; }
 
 #else
 
Index: lldb/trunk/tools/debugserver/source/RNBRemote.cpp
===
--- lldb/trunk/tools/debugserver/source/RNBRemote.cpp
+++ lldb/trunk/tools/debugserver/source/RNBRemote.cpp
@@ -710,26 +710,22 @@
   size_t compressed_size = 0;
 
 #if defined(HAVE_LIBCOMPRESSION)
-  if (compression_decode_buffer &&
-  compression_type == compression_types::lz4) {
+  if (compression_type == compression_types::lz4) {
 compressed_size = compression_encode_buffer(
 encoded_data.data(), encoded_data_buf_size, (uint8_t *)orig.c_str(),
 orig.size(), nullptr, COMPRESSION_LZ4_RAW);
   }
-  if (compression_decode_buffer &&
-  compression_type == compression_types::zlib_deflate) {
+  if (compression_type == compression_types::zlib_deflate) {
 compressed_size = compr

[Lldb-commits] [PATCH] D40757: Disable warnings related to anonymous types in the ObjC plugin

2017-12-07 Thread Phabricator via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL320071: Disable warnings related to anonymous types in the 
ObjC plugin (authored by vedantk).

Changed prior to commit:
  https://reviews.llvm.org/D40757?vs=125816&id=125999#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D40757

Files:
  lldb/trunk/cmake/modules/AddLLDB.cmake
  lldb/trunk/cmake/modules/LLDBConfig.cmake
  lldb/trunk/source/Plugins/Language/ObjC/CMakeLists.txt


Index: lldb/trunk/source/Plugins/Language/ObjC/CMakeLists.txt
===
--- lldb/trunk/source/Plugins/Language/ObjC/CMakeLists.txt
+++ lldb/trunk/source/Plugins/Language/ObjC/CMakeLists.txt
@@ -1,3 +1,13 @@
+set(EXTRA_CXXFLAGS "")
+
+if (CXX_SUPPORTS_NO_GNU_ANONYMOUS_STRUCT)
+  set(EXTRA_CXXFLAGS ${EXTRA_CXXFLAGS} -Wno-gnu-anonymous-struct)
+endif ()
+
+if (CXX_SUPPORTS_NO_NESTED_ANON_TYPES)
+  set(EXTRA_CXXFLAGS ${EXTRA_CXXFLAGS} -Wno-nested-anon-types)
+endif ()
+
 add_lldb_library(lldbPluginObjCLanguage PLUGIN
   ObjCLanguage.cpp
   CF.cpp
@@ -21,4 +31,6 @@
 lldbTarget
 lldbUtility
 lldbPluginAppleObjCRuntime
+
+  EXTRA_CXXFLAGS ${EXTRA_CXXFLAGS}
 )
Index: lldb/trunk/cmake/modules/AddLLDB.cmake
===
--- lldb/trunk/cmake/modules/AddLLDB.cmake
+++ lldb/trunk/cmake/modules/AddLLDB.cmake
@@ -4,7 +4,7 @@
   cmake_parse_arguments(PARAM
 "MODULE;SHARED;STATIC;OBJECT;PLUGIN"
 ""
-"DEPENDS;LINK_LIBS;LINK_COMPONENTS"
+"EXTRA_CXXFLAGS;DEPENDS;LINK_LIBS;LINK_COMPONENTS"
 ${ARGN})
   llvm_process_sources(srcs ${PARAM_UNPARSED_ARGUMENTS})
   list(APPEND LLVM_LINK_COMPONENTS ${PARAM_LINK_COMPONENTS})
@@ -35,6 +35,8 @@
   endif()
 
   #PIC not needed on Win
+  # FIXME: Setting CMAKE_CXX_FLAGS here is a no-op, use target_compile_options
+  # or omit this logic instead.
   if (NOT WIN32)
 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC")
   endif()
@@ -78,6 +80,9 @@
   # headers without negatively impacting much of anything.
   add_dependencies(${name} clang-tablegen-targets)
 
+  # Add in any extra C++ compilation flags for this library.
+  target_compile_options(${name} PRIVATE ${PARAM_EXTRA_CXXFLAGS})
+
   set_target_properties(${name} PROPERTIES FOLDER "lldb libraries")
 endfunction(add_lldb_library)
 
Index: lldb/trunk/cmake/modules/LLDBConfig.cmake
===
--- lldb/trunk/cmake/modules/LLDBConfig.cmake
+++ lldb/trunk/cmake/modules/LLDBConfig.cmake
@@ -231,6 +231,12 @@
   set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-vla-extension")
 endif ()
 
+check_cxx_compiler_flag("-Wno-gnu-anonymous-struct"
+CXX_SUPPORTS_NO_GNU_ANONYMOUS_STRUCT)
+
+check_cxx_compiler_flag("-Wno-nested-anon-types"
+CXX_SUPPORTS_NO_NESTED_ANON_TYPES)
+
 # Disable MSVC warnings
 if( MSVC )
   add_definitions(


Index: lldb/trunk/source/Plugins/Language/ObjC/CMakeLists.txt
===
--- lldb/trunk/source/Plugins/Language/ObjC/CMakeLists.txt
+++ lldb/trunk/source/Plugins/Language/ObjC/CMakeLists.txt
@@ -1,3 +1,13 @@
+set(EXTRA_CXXFLAGS "")
+
+if (CXX_SUPPORTS_NO_GNU_ANONYMOUS_STRUCT)
+  set(EXTRA_CXXFLAGS ${EXTRA_CXXFLAGS} -Wno-gnu-anonymous-struct)
+endif ()
+
+if (CXX_SUPPORTS_NO_NESTED_ANON_TYPES)
+  set(EXTRA_CXXFLAGS ${EXTRA_CXXFLAGS} -Wno-nested-anon-types)
+endif ()
+
 add_lldb_library(lldbPluginObjCLanguage PLUGIN
   ObjCLanguage.cpp
   CF.cpp
@@ -21,4 +31,6 @@
 lldbTarget
 lldbUtility
 lldbPluginAppleObjCRuntime
+
+  EXTRA_CXXFLAGS ${EXTRA_CXXFLAGS}
 )
Index: lldb/trunk/cmake/modules/AddLLDB.cmake
===
--- lldb/trunk/cmake/modules/AddLLDB.cmake
+++ lldb/trunk/cmake/modules/AddLLDB.cmake
@@ -4,7 +4,7 @@
   cmake_parse_arguments(PARAM
 "MODULE;SHARED;STATIC;OBJECT;PLUGIN"
 ""
-"DEPENDS;LINK_LIBS;LINK_COMPONENTS"
+"EXTRA_CXXFLAGS;DEPENDS;LINK_LIBS;LINK_COMPONENTS"
 ${ARGN})
   llvm_process_sources(srcs ${PARAM_UNPARSED_ARGUMENTS})
   list(APPEND LLVM_LINK_COMPONENTS ${PARAM_LINK_COMPONENTS})
@@ -35,6 +35,8 @@
   endif()
 
   #PIC not needed on Win
+  # FIXME: Setting CMAKE_CXX_FLAGS here is a no-op, use target_compile_options
+  # or omit this logic instead.
   if (NOT WIN32)
 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC")
   endif()
@@ -78,6 +80,9 @@
   # headers without negatively impacting much of anything.
   add_dependencies(${name} clang-tablegen-targets)
 
+  # Add in any extra C++ compilation flags for this library.
+  target_compile_options(${name} PRIVATE ${PARAM_EXTRA_CXXFLAGS})
+
   set_target_properties(${name} PROPERTIES FOLDER "lldb libraries")
 endfunction(add_lldb_library)
 
Index: lldb/trunk/cmake/modules/LLDBConfig.cmake
===
--- lldb/trunk/cmake/modules/LLDBConfig.cmake
+++ lldb/

[Lldb-commits] [PATCH] D42215: [CMake] Make check-lldb work with LLDB_CODESIGN_IDENTITY=''

2018-01-17 Thread Phabricator via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL322803: [CMake] Make check-lldb work with 
LLDB_CODESIGN_IDENTITY='' (authored by vedantk, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D42215?vs=130325&id=130332#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D42215

Files:
  lldb/trunk/docs/code-signing.txt
  lldb/trunk/test/CMakeLists.txt


Index: lldb/trunk/docs/code-signing.txt
===
--- lldb/trunk/docs/code-signing.txt
+++ lldb/trunk/docs/code-signing.txt
@@ -1,6 +1,11 @@
-On MacOSX lldb needs to be code signed. The Debug, DebugClang and Release 
-builds  are set to code sign using a code signing certificate named 
-"lldb_codesign". 
+To use the in-tree debug server on macOS, lldb needs to be code signed. The
+Debug, DebugClang and Release builds are set to code sign using a code signing
+certificate named "lldb_codesign". This document explains how to set up the
+signing certificate.
+
+Note that it's possible to build and use lldb on macOS without setting up code
+signing by using the system's debug server. To configure lldb in this way with
+cmake, specify -DLLDB_CODESIGN_IDENTITY=''.
 
 If you have re-installed a new OS, please delete all old lldb_codesign items
 from your keychain. There will be a code signing certification and a public
Index: lldb/trunk/test/CMakeLists.txt
===
--- lldb/trunk/test/CMakeLists.txt
+++ lldb/trunk/test/CMakeLists.txt
@@ -25,7 +25,9 @@
 endif()
   
 if(TARGET debugserver)
-  list(APPEND LLDB_TEST_DEPS debugserver)
+  if(NOT CMAKE_HOST_APPLE OR LLDB_CODESIGN_IDENTITY)
+list(APPEND LLDB_TEST_DEPS debugserver)
+  endif()
 endif()
 
 if(TARGET lldb-mi)
@@ -95,7 +97,18 @@
 endif()
 
 if(CMAKE_HOST_APPLE)
-  list(APPEND LLDB_TEST_COMMON_ARGS --server $)
+  if(LLDB_CODESIGN_IDENTITY)
+set(DEBUGSERVER_PATH $)
+  else()
+execute_process(
+  COMMAND xcode-select -p
+  OUTPUT_VARIABLE XCODE_DEV_DIR)
+string(STRIP ${XCODE_DEV_DIR} XCODE_DEV_DIR)
+set(DEBUGSERVER_PATH
+  
"${XCODE_DEV_DIR}/../SharedFrameworks/LLDB.framework/Resources/debugserver")
+  endif()
+  message(STATUS "Path to the lldb debugserver: ${DEBUGSERVER_PATH}")
+  list(APPEND LLDB_TEST_COMMON_ARGS --server ${DEBUGSERVER_PATH})
 endif()
 
 set(LLDB_DOTEST_ARGS ${LLDB_TEST_COMMON_ARGS};${LLDB_TEST_USER_ARGS})


Index: lldb/trunk/docs/code-signing.txt
===
--- lldb/trunk/docs/code-signing.txt
+++ lldb/trunk/docs/code-signing.txt
@@ -1,6 +1,11 @@
-On MacOSX lldb needs to be code signed. The Debug, DebugClang and Release 
-builds  are set to code sign using a code signing certificate named 
-"lldb_codesign". 
+To use the in-tree debug server on macOS, lldb needs to be code signed. The
+Debug, DebugClang and Release builds are set to code sign using a code signing
+certificate named "lldb_codesign". This document explains how to set up the
+signing certificate.
+
+Note that it's possible to build and use lldb on macOS without setting up code
+signing by using the system's debug server. To configure lldb in this way with
+cmake, specify -DLLDB_CODESIGN_IDENTITY=''.
 
 If you have re-installed a new OS, please delete all old lldb_codesign items
 from your keychain. There will be a code signing certification and a public
Index: lldb/trunk/test/CMakeLists.txt
===
--- lldb/trunk/test/CMakeLists.txt
+++ lldb/trunk/test/CMakeLists.txt
@@ -25,7 +25,9 @@
 endif()
   
 if(TARGET debugserver)
-  list(APPEND LLDB_TEST_DEPS debugserver)
+  if(NOT CMAKE_HOST_APPLE OR LLDB_CODESIGN_IDENTITY)
+list(APPEND LLDB_TEST_DEPS debugserver)
+  endif()
 endif()
 
 if(TARGET lldb-mi)
@@ -95,7 +97,18 @@
 endif()
 
 if(CMAKE_HOST_APPLE)
-  list(APPEND LLDB_TEST_COMMON_ARGS --server $)
+  if(LLDB_CODESIGN_IDENTITY)
+set(DEBUGSERVER_PATH $)
+  else()
+execute_process(
+  COMMAND xcode-select -p
+  OUTPUT_VARIABLE XCODE_DEV_DIR)
+string(STRIP ${XCODE_DEV_DIR} XCODE_DEV_DIR)
+set(DEBUGSERVER_PATH
+  "${XCODE_DEV_DIR}/../SharedFrameworks/LLDB.framework/Resources/debugserver")
+  endif()
+  message(STATUS "Path to the lldb debugserver: ${DEBUGSERVER_PATH}")
+  list(APPEND LLDB_TEST_COMMON_ARGS --server ${DEBUGSERVER_PATH})
 endif()
 
 set(LLDB_DOTEST_ARGS ${LLDB_TEST_COMMON_ARGS};${LLDB_TEST_USER_ARGS})
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


  1   2   3   >