[Lldb-commits] [PATCH] D29352: [CMake] Final dependency cleanup patch!

2017-02-08 Thread Phabricator via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL294515: [CMake] Final dependency cleanup patch! (authored by 
cbieneman).

Changed prior to commit:
  https://reviews.llvm.org/D29352?vs=87265=87701#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D29352

Files:
  lldb/trunk/cmake/LLDBDependencies.cmake
  lldb/trunk/cmake/modules/AddLLDB.cmake
  lldb/trunk/source/API/CMakeLists.txt
  lldb/trunk/source/Initialization/CMakeLists.txt
  lldb/trunk/source/Plugins/Process/CMakeLists.txt
  lldb/trunk/source/Plugins/Process/Windows/Common/CMakeLists.txt
  lldb/trunk/tools/intel-mpx/CMakeLists.txt
  lldb/trunk/tools/lldb-server/CMakeLists.txt
  lldb/trunk/unittests/CMakeLists.txt

Index: lldb/trunk/unittests/CMakeLists.txt
===
--- lldb/trunk/unittests/CMakeLists.txt
+++ lldb/trunk/unittests/CMakeLists.txt
@@ -39,7 +39,6 @@
 POST_BUILD
 COMMAND "${CMAKE_COMMAND}" -E make_directory ${CMAKE_CURRENT_BINARY_DIR}/Inputs)
 
-  lldb_link_common_libs(${test_name} EXE)
   target_link_libraries(${test_name} ${ARG_LINK_LIBS} ${CLANG_USED_LIBS} ${LLDB_SYSTEM_LIBS})
 endfunction()
 
Index: lldb/trunk/source/API/CMakeLists.txt
===
--- lldb/trunk/source/API/CMakeLists.txt
+++ lldb/trunk/source/API/CMakeLists.txt
@@ -16,6 +16,8 @@
   message(FATAL_ERROR "LLDB.framework cannot be generated unless targeting Apple platforms.")
 endif()
 
+get_property(LLDB_ALL_PLUGINS GLOBAL PROPERTY LLDB_PLUGINS)
+
 add_lldb_library(liblldb SHARED
   SBAddress.cpp
   SBAttachInfo.cpp
@@ -80,6 +82,21 @@
   SBUnixSignals.cpp
   SystemInitializerFull.cpp
   ${LLDB_WRAP_PYTHON}
+
+  LINK_LIBS
+lldbBase
+lldbBreakpoint
+lldbCore
+lldbDataFormatters
+lldbExpression
+lldbHost
+lldbInitialization
+lldbInterpreter
+lldbSymbol
+lldbTarget
+${LLDB_ALL_PLUGINS}
+  LINK_COMPONENTS
+Support
   )
 
 if (LLVM_ENABLE_WERROR)
Index: lldb/trunk/source/Initialization/CMakeLists.txt
===
--- lldb/trunk/source/Initialization/CMakeLists.txt
+++ lldb/trunk/source/Initialization/CMakeLists.txt
@@ -7,11 +7,7 @@
 endif()
 
 if ( CMAKE_SYSTEM_NAME MATCHES "Windows" )
-  list(APPEND LLDB_USED_LIBS
-lldbPluginProcessWindowsCommon
-ws2_32
-rpcrt4
-)
+  list(APPEND EXTRA_PLUGINS lldbPluginProcessWindowsCommon)
 endif ()
 
 add_lldb_library(lldbInitialization
@@ -31,6 +27,7 @@
 lldbPluginObjectFilePECOFF
 lldbPluginProcessGDBRemote
 ${EXTRA_PLUGINS}
+${LLDB_SYSTEM_LIBS}
   LINK_COMPONENTS
 Support
   )
Index: lldb/trunk/source/Plugins/Process/Windows/Common/CMakeLists.txt
===
--- lldb/trunk/source/Plugins/Process/Windows/Common/CMakeLists.txt
+++ lldb/trunk/source/Plugins/Process/Windows/Common/CMakeLists.txt
@@ -28,6 +28,8 @@
 lldbHost
 lldbInterpreter
 lldbTarget
+ws2_32
+rpcrt4
   LINK_COMPONENTS
 Support
   )
Index: lldb/trunk/source/Plugins/Process/CMakeLists.txt
===
--- lldb/trunk/source/Plugins/Process/CMakeLists.txt
+++ lldb/trunk/source/Plugins/Process/CMakeLists.txt
@@ -10,9 +10,9 @@
   add_subdirectory(Windows/Common)
 elseif (CMAKE_SYSTEM_NAME MATCHES "Darwin")
   add_subdirectory(MacOSX-Kernel)
+  add_subdirectory(mach-core)
 endif()
 add_subdirectory(gdb-remote)
 add_subdirectory(Utility)
-add_subdirectory(mach-core)
 add_subdirectory(elf-core)
 add_subdirectory(minidump)
Index: lldb/trunk/tools/intel-mpx/CMakeLists.txt
===
--- lldb/trunk/tools/intel-mpx/CMakeLists.txt
+++ lldb/trunk/tools/intel-mpx/CMakeLists.txt
@@ -8,16 +8,8 @@
   IntelMPXTablePlugin.cpp
   )
 
-target_link_libraries(lldb-intel-mpxtable PUBLIC liblldb)
-
-if (LLDB_LINKER_SUPPORTS_GROUPS)
-  target_link_libraries(lldb-intel-mpxtable PUBLIC
--Wl,--start-group ${LLDB_USED_LIBS} -Wl,--end-group)
-else()
-  target_link_libraries(lldb-intel-mpxtable PUBLIC ${LLDB_USED_LIBS})
-endif()
-llvm_config(lldb-intel-mpxtable ${LLVM_LINK_COMPONENTS})
-
+target_link_libraries(lldb-intel-mpxtable
+  PUBLIC liblldb LLVMSupport)
 
 install(TARGETS lldb-intel-mpxtable
   LIBRARY DESTINATION bin)
Index: lldb/trunk/tools/lldb-server/CMakeLists.txt
===
--- lldb/trunk/tools/lldb-server/CMakeLists.txt
+++ lldb/trunk/tools/lldb-server/CMakeLists.txt
@@ -23,90 +23,6 @@
 
 include_directories(../../source)
 
-
-set( LLDB_USED_LIBS
-  lldbBase
-  lldbBreakpoint
-  lldbCommands
-  lldbDataFormatters
-  lldbHost
-  lldbCore
-  lldbExpression
-  lldbInitialization
-  lldbInterpreter
-  lldbSymbol
-  lldbTarget
-  lldbUtility
-
-  # Plugins
-  lldbPluginDisassemblerLLVM
-  

[Lldb-commits] [PATCH] D29403: Fix multi-process-driver.cpp build on NetBSD

2017-02-02 Thread Phabricator via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL293895: Fix multi-process-driver.cpp build on NetBSD 
(authored by kamil).

Changed prior to commit:
  https://reviews.llvm.org/D29403?vs=8=86807#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D29403

Files:
  
lldb/trunk/packages/Python/lldbsuite/test/api/multiple-debuggers/multi-process-driver.cpp


Index: 
lldb/trunk/packages/Python/lldbsuite/test/api/multiple-debuggers/multi-process-driver.cpp
===
--- 
lldb/trunk/packages/Python/lldbsuite/test/api/multiple-debuggers/multi-process-driver.cpp
+++ 
lldb/trunk/packages/Python/lldbsuite/test/api/multiple-debuggers/multi-process-driver.cpp
@@ -15,7 +15,7 @@
 
 #include 
 #include 
-
+#include 
 
 #include "lldb/API/LLDB.h"
 #include "lldb/API/SBCommandInterpreter.h"


Index: lldb/trunk/packages/Python/lldbsuite/test/api/multiple-debuggers/multi-process-driver.cpp
===
--- lldb/trunk/packages/Python/lldbsuite/test/api/multiple-debuggers/multi-process-driver.cpp
+++ lldb/trunk/packages/Python/lldbsuite/test/api/multiple-debuggers/multi-process-driver.cpp
@@ -15,7 +15,7 @@
 
 #include 
 #include 
-
+#include 
 
 #include "lldb/API/LLDB.h"
 #include "lldb/API/SBCommandInterpreter.h"
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D29288: Switch std::call_once to llvm::call_once

2017-02-06 Thread Phabricator via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL294202: Switch std::call_once to llvm::call_once (authored 
by kamil).

Changed prior to commit:
  https://reviews.llvm.org/D29288?vs=87153=87252#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D29288

Files:
  lldb/trunk/include/lldb/Core/Debugger.h
  lldb/trunk/source/Commands/CommandObjectPlatform.cpp
  lldb/trunk/source/Core/Debugger.cpp
  lldb/trunk/source/Core/ModuleList.cpp
  lldb/trunk/source/Host/common/Editline.cpp
  lldb/trunk/source/Host/common/HostInfoBase.cpp
  lldb/trunk/source/Host/linux/HostInfoLinux.cpp
  lldb/trunk/source/Host/windows/HostInfoWindows.cpp
  lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.cpp
  lldb/trunk/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
  lldb/trunk/source/Plugins/Language/Go/GoLanguage.cpp
  lldb/trunk/source/Plugins/Language/Java/JavaLanguage.cpp
  lldb/trunk/source/Plugins/Language/ObjC/ObjCLanguage.cpp
  lldb/trunk/source/Plugins/Platform/MacOSX/PlatformAppleSimulator.cpp
  lldb/trunk/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp
  lldb/trunk/source/Plugins/Process/FreeBSD/ProcessFreeBSD.cpp
  lldb/trunk/source/Plugins/Process/Linux/NativeProcessLinux.cpp
  lldb/trunk/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp
  lldb/trunk/source/Plugins/Process/POSIX/ProcessPOSIXLog.cpp
  lldb/trunk/source/Plugins/Process/Windows/Common/ProcessWindows.cpp
  lldb/trunk/source/Plugins/Process/Windows/Common/ProcessWindowsLog.cpp
  lldb/trunk/source/Plugins/Process/elf-core/ProcessElfCore.cpp
  
lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerPlatform.cpp
  lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
  lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemoteLog.cpp
  lldb/trunk/source/Plugins/Process/mach-core/ProcessMachCore.cpp
  lldb/trunk/source/Plugins/Process/minidump/ProcessMinidump.cpp
  lldb/trunk/source/Plugins/ScriptInterpreter/None/ScriptInterpreterNone.cpp
  lldb/trunk/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
  lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
  lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
  lldb/trunk/source/Symbol/ClangASTContext.cpp
  lldb/trunk/source/Symbol/GoASTContext.cpp
  lldb/trunk/source/Target/Language.cpp
  lldb/trunk/source/Utility/ConstString.cpp
  lldb/trunk/tools/debugserver/source/MacOSX/DarwinLog/DarwinLogCollector.cpp

Index: lldb/trunk/tools/debugserver/source/MacOSX/DarwinLog/DarwinLogCollector.cpp
===
--- lldb/trunk/tools/debugserver/source/MacOSX/DarwinLog/DarwinLogCollector.cpp
+++ lldb/trunk/tools/debugserver/source/MacOSX/DarwinLog/DarwinLogCollector.cpp
@@ -46,10 +46,10 @@
 s_os_activity_stream_set_event_handler;
 
 bool LookupSPICalls() {
-  static std::once_flag s_once_flag;
+  static llvm::once_flag s_once_flag;
   static bool s_has_spi;
 
-  std::call_once(s_once_flag, [] {
+  llvm::call_once(s_once_flag, [] {
 dlopen ("/System/Library/PrivateFrameworks/LoggingSupport.framework/LoggingSupport", RTLD_NOW);
 s_os_activity_stream_for_pid = (os_activity_stream_for_pid_t)dlsym(
 RTLD_DEFAULT, "os_activity_stream_for_pid");
Index: lldb/trunk/source/Host/common/HostInfoBase.cpp
===
--- lldb/trunk/source/Host/common/HostInfoBase.cpp
+++ lldb/trunk/source/Host/common/HostInfoBase.cpp
@@ -22,9 +22,10 @@
 #include "llvm/Support/Host.h"
 #include "llvm/Support/Path.h"
 #include "llvm/Support/ScopedPrinter.h"
+#include "llvm/Support/Threading.h"
 #include "llvm/Support/raw_ostream.h"
 
-#include  // std::once
+#include 
 #include 
 
 using namespace lldb;
@@ -79,45 +80,45 @@
 }
 
 uint32_t HostInfoBase::GetNumberCPUS() {
-  static std::once_flag g_once_flag;
-  std::call_once(g_once_flag, []() {
+  static llvm::once_flag g_once_flag;
+  llvm::call_once(g_once_flag, []() {
 g_fields->m_number_cpus = std::thread::hardware_concurrency();
   });
   return g_fields->m_number_cpus;
 }
 
 uint32_t HostInfoBase::GetMaxThreadNameLength() { return 0; }
 
 llvm::StringRef HostInfoBase::GetVendorString() {
-  static std::once_flag g_once_flag;
-  std::call_once(g_once_flag, []() {
+  static llvm::once_flag g_once_flag;
+  llvm::call_once(g_once_flag, []() {
 g_fields->m_vendor_string =
 HostInfo::GetArchitecture().GetTriple().getVendorName().str();
   });
   return g_fields->m_vendor_string;
 }
 
 llvm::StringRef HostInfoBase::GetOSString() {
-  static std::once_flag g_once_flag;
-  std::call_once(g_once_flag, []() {
+  static llvm::once_flag g_once_flag;
+  llvm::call_once(g_once_flag, []() {
 g_fields->m_os_string =
 std::move(HostInfo::GetArchitecture().GetTriple().getOSName());
   });
   return g_fields->m_os_string;
 }
 
 llvm::StringRef HostInfoBase::GetTargetTriple() {
-  static std::once_flag g_once_flag;
-  

[Lldb-commits] [PATCH] D29333: [CMake] Add accurate dependency specifications

2017-01-31 Thread Phabricator via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL293686: [CMake] Add accurate dependency specifications 
(authored by cbieneman).

Changed prior to commit:
  https://reviews.llvm.org/D29333?vs=86461=86481#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D29333

Files:
  lldb/trunk/source/Breakpoint/CMakeLists.txt
  lldb/trunk/source/Commands/CMakeLists.txt
  lldb/trunk/source/Core/CMakeLists.txt
  lldb/trunk/source/DataFormatters/CMakeLists.txt
  lldb/trunk/source/Expression/CMakeLists.txt
  lldb/trunk/source/Host/CMakeLists.txt
  lldb/trunk/source/Initialization/CMakeLists.txt
  lldb/trunk/source/Interpreter/CMakeLists.txt
  lldb/trunk/source/Symbol/CMakeLists.txt
  lldb/trunk/source/Target/CMakeLists.txt
  lldb/trunk/source/Utility/CMakeLists.txt
  lldb/trunk/tools/argdumper/CMakeLists.txt
  lldb/trunk/tools/debugserver/source/CMakeLists.txt
  lldb/trunk/tools/debugserver/source/MacOSX/CMakeLists.txt
  lldb/trunk/tools/driver/CMakeLists.txt
  lldb/trunk/tools/lldb-mi/CMakeLists.txt
  lldb/trunk/tools/lldb-server/CMakeLists.txt

Index: lldb/trunk/source/Core/CMakeLists.txt
===
--- lldb/trunk/source/Core/CMakeLists.txt
+++ lldb/trunk/source/Core/CMakeLists.txt
@@ -69,5 +69,24 @@
   ValueObjectSyntheticFilter.cpp
   ValueObjectVariable.cpp
   VMRange.cpp
+
+  LINK_LIBS
+lldbBreakpoint
+lldbDataFormatters
+lldbExpression
+lldbHost
+lldbInterpreter
+lldbSymbol
+lldbTarget
+lldbUtility
+lldbPluginProcessUtility
+lldbPluginCPlusPlusLanguage
+lldbPluginObjCLanguage
+lldbPluginObjectFileJIT
+lldbPluginExpressionParserClang
+
+  LINK_COMPONENTS
+Support
+Demangle
   )
 
Index: lldb/trunk/source/Initialization/CMakeLists.txt
===
--- lldb/trunk/source/Initialization/CMakeLists.txt
+++ lldb/trunk/source/Initialization/CMakeLists.txt
@@ -1,5 +1,36 @@
+if ( CMAKE_SYSTEM_NAME MATCHES "Darwin" )
+  list(APPEND EXTRA_PLUGINS lldbPluginObjectFileMachO)
+endif()
+
+if ( CMAKE_SYSTEM_NAME MATCHES "Linux|Android|FreeBSD|NetBSD" )
+  list(APPEND EXTRA_PLUGINS lldbPluginProcessPOSIX)
+endif()
+
+if ( CMAKE_SYSTEM_NAME MATCHES "Windows" )
+  list(APPEND LLDB_USED_LIBS
+lldbPluginProcessWindowsCommon
+ws2_32
+rpcrt4
+)
+endif ()
+
 add_lldb_library(lldbInitialization
   SystemInitializerCommon.cpp
   SystemInitializer.cpp
   SystemLifetimeManager.cpp
+
+  LINK_LIBS
+lldbCore
+lldbHost
+lldbPluginInstructionARM
+lldbPluginInstructionMIPS
+lldbPluginInstructionMIPS64
+lldbPluginObjectContainerBSDArchive
+lldbPluginObjectContainerMachOArchive
+lldbPluginObjectFileELF
+lldbPluginObjectFilePECOFF
+lldbPluginProcessGDBRemote
+${EXTRA_PLUGINS}
+  LINK_COMPONENTS
+Support
   )
Index: lldb/trunk/source/Target/CMakeLists.txt
===
--- lldb/trunk/source/Target/CMakeLists.txt
+++ lldb/trunk/source/Target/CMakeLists.txt
@@ -58,4 +58,20 @@
   ThreadSpec.cpp
   UnixSignals.cpp
   UnwindAssembly.cpp
+
+  LINK_LIBS
+lldbBreakpoint
+lldbCore
+lldbExpression
+lldbHost
+lldbInterpreter
+lldbSymbol
+lldbUtility
+lldbPluginExpressionParserClang
+lldbPluginCPlusPlusLanguage
+lldbPluginObjCLanguage
+lldbPluginProcessUtility
+
+  LINK_COMPONENTS
+Support
   )
Index: lldb/trunk/source/Symbol/CMakeLists.txt
===
--- lldb/trunk/source/Symbol/CMakeLists.txt
+++ lldb/trunk/source/Symbol/CMakeLists.txt
@@ -36,4 +36,25 @@
   Variable.cpp
   VariableList.cpp
   VerifyDecl.cpp
+
+  LINK_LIBS
+clangAST
+clangBasic
+clangFrontend
+lldbCore
+lldbDataFormatters
+lldbExpression
+lldbHost
+lldbTarget
+lldbUtility
+lldbPluginExpressionParserClang
+lldbPluginExpressionParserGo
+lldbPluginSymbolFileDWARF
+lldbPluginSymbolFilePDB
+lldbPluginObjectContainerBSDArchive
+lldbPluginCPlusPlusLanguage
+lldbPluginObjCLanguage
+
+  LINK_COMPONENTS
+Support
   )
Index: lldb/trunk/source/Utility/CMakeLists.txt
===
--- lldb/trunk/source/Utility/CMakeLists.txt
+++ lldb/trunk/source/Utility/CMakeLists.txt
@@ -16,4 +16,12 @@
   StringLexer.cpp
   TaskPool.cpp
   UriParser.cpp
+
+  LINK_LIBS
+lldbCore
+lldbHost
+lldbTarget
+
+  LINK_COMPONENTS
+Support
   )
Index: lldb/trunk/source/Interpreter/CMakeLists.txt
===
--- lldb/trunk/source/Interpreter/CMakeLists.txt
+++ lldb/trunk/source/Interpreter/CMakeLists.txt
@@ -43,4 +43,15 @@
   Options.cpp
   Property.cpp
   ScriptInterpreter.cpp
+
+  LINK_LIBS
+lldbCommands
+lldbCore
+lldbDataFormatters
+lldbHost
+lldbTarget
+lldbUtility
+
+  

[Lldb-commits] [PATCH] D29091: Recognize Real-Time Signals on NetBSD

2017-01-28 Thread Phabricator via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL293391: Recognize Real-Time Signals on NetBSD (authored by 
kamil).

Changed prior to commit:
  https://reviews.llvm.org/D29091?vs=85611=86183#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D29091

Files:
  lldb/trunk/source/Plugins/Process/Utility/NetBSDSignals.cpp


Index: lldb/trunk/source/Plugins/Process/Utility/NetBSDSignals.cpp
===
--- lldb/trunk/source/Plugins/Process/Utility/NetBSDSignals.cpp
+++ lldb/trunk/source/Plugins/Process/Utility/NetBSDSignals.cpp
@@ -24,7 +24,35 @@
   //===
   AddSignal(32, "SIGPWR", false, true, true,
 "power fail/restart (not reset when caught)");
-#ifdef SIGRTMIN /* SIGRTMAX */
-/* Kernel only; not exposed to userland yet */
-#endif
+  AddSignal(33, "SIGRTMIN", false, false, false, "real time signal 0");
+  AddSignal(34, "SIGRTMIN+1", false, false, false, "real time signal 1");
+  AddSignal(35, "SIGRTMIN+2", false, false, false, "real time signal 2");
+  AddSignal(36, "SIGRTMIN+3", false, false, false, "real time signal 3");
+  AddSignal(37, "SIGRTMIN+4", false, false, false, "real time signal 4");
+  AddSignal(38, "SIGRTMIN+5", false, false, false, "real time signal 5");
+  AddSignal(39, "SIGRTMIN+6", false, false, false, "real time signal 6");
+  AddSignal(40, "SIGRTMIN+7", false, false, false, "real time signal 7");
+  AddSignal(41, "SIGRTMIN+8", false, false, false, "real time signal 8");
+  AddSignal(42, "SIGRTMIN+9", false, false, false, "real time signal 9");
+  AddSignal(43, "SIGRTMIN+10", false, false, false, "real time signal 10");
+  AddSignal(44, "SIGRTMIN+11", false, false, false, "real time signal 11");
+  AddSignal(45, "SIGRTMIN+12", false, false, false, "real time signal 12");
+  AddSignal(46, "SIGRTMIN+13", false, false, false, "real time signal 13");
+  AddSignal(47, "SIGRTMIN+14", false, false, false, "real time signal 14");
+  AddSignal(48, "SIGRTMIN+15", false, false, false, "real time signal 15");
+  AddSignal(49, "SIGRTMIN-14", false, false, false, "real time signal 16");
+  AddSignal(50, "SIGRTMAX-13", false, false, false, "real time signal 17");
+  AddSignal(51, "SIGRTMAX-12", false, false, false, "real time signal 18");
+  AddSignal(52, "SIGRTMAX-11", false, false, false, "real time signal 19");
+  AddSignal(53, "SIGRTMAX-10", false, false, false, "real time signal 20");
+  AddSignal(54, "SIGRTMAX-9", false, false, false, "real time signal 21");
+  AddSignal(55, "SIGRTMAX-8", false, false, false, "real time signal 22");
+  AddSignal(56, "SIGRTMAX-7", false, false, false, "real time signal 23");
+  AddSignal(57, "SIGRTMAX-6", false, false, false, "real time signal 24");
+  AddSignal(58, "SIGRTMAX-5", false, false, false, "real time signal 25");
+  AddSignal(59, "SIGRTMAX-4", false, false, false, "real time signal 26");
+  AddSignal(60, "SIGRTMAX-3", false, false, false, "real time signal 27");
+  AddSignal(61, "SIGRTMAX-2", false, false, false, "real time signal 28");
+  AddSignal(62, "SIGRTMAX-1", false, false, false, "real time signal 29");
+  AddSignal(63, "SIGRTMAX", false, false, false, "real time signal 30");
 }


Index: lldb/trunk/source/Plugins/Process/Utility/NetBSDSignals.cpp
===
--- lldb/trunk/source/Plugins/Process/Utility/NetBSDSignals.cpp
+++ lldb/trunk/source/Plugins/Process/Utility/NetBSDSignals.cpp
@@ -24,7 +24,35 @@
   //===
   AddSignal(32, "SIGPWR", false, true, true,
 "power fail/restart (not reset when caught)");
-#ifdef SIGRTMIN /* SIGRTMAX */
-/* Kernel only; not exposed to userland yet */
-#endif
+  AddSignal(33, "SIGRTMIN", false, false, false, "real time signal 0");
+  AddSignal(34, "SIGRTMIN+1", false, false, false, "real time signal 1");
+  AddSignal(35, "SIGRTMIN+2", false, false, false, "real time signal 2");
+  AddSignal(36, "SIGRTMIN+3", false, false, false, "real time signal 3");
+  AddSignal(37, "SIGRTMIN+4", false, false, false, "real time signal 4");
+  AddSignal(38, "SIGRTMIN+5", false, false, false, "real time signal 5");
+  AddSignal(39, "SIGRTMIN+6", false, false, false, "real time signal 6");
+  AddSignal(40, "SIGRTMIN+7", false, false, false, "real time signal 7");
+  AddSignal(41, "SIGRTMIN+8", false, false, false, "real time signal 8");
+  AddSignal(42, "SIGRTMIN+9", false, false, false, "real time signal 9");
+  AddSignal(43, "SIGRTMIN+10", false, false, false, "real time signal 10");
+  AddSignal(44, "SIGRTMIN+11", false, false, false, "real time signal 11");
+  AddSignal(45, "SIGRTMIN+12", false, false, false, "real time signal 12");
+  AddSignal(46, "SIGRTMIN+13", false, false, false, "real time signal 13");
+  AddSignal(47, "SIGRTMIN+14", false, false, false, "real time signal 14");
+  AddSignal(48, 

[Lldb-commits] [PATCH] D23977: Support of lldb on Kfreebsd

2016-12-17 Thread Phabricator via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL290044: Support of lldb on Kfreebsd  (authored by sylvestre).

Changed prior to commit:
  https://reviews.llvm.org/D23977?vs=77714=81842#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D23977

Files:
  lldb/trunk/cmake/LLDBDependencies.cmake
  lldb/trunk/cmake/modules/LLDBConfig.cmake
  lldb/trunk/scripts/Python/modules/CMakeLists.txt
  lldb/trunk/scripts/utilsOsType.py


Index: lldb/trunk/cmake/modules/LLDBConfig.cmake
===
--- lldb/trunk/cmake/modules/LLDBConfig.cmake
+++ lldb/trunk/cmake/modules/LLDBConfig.cmake
@@ -416,3 +416,5 @@
 if(LLDB_USE_BUILTIN_DEMANGLER)
 add_definitions(-DLLDB_USE_BUILTIN_DEMANGLER)
 endif()
+
+find_package(Backtrace)
Index: lldb/trunk/cmake/LLDBDependencies.cmake
===
--- lldb/trunk/cmake/LLDBDependencies.cmake
+++ lldb/trunk/cmake/LLDBDependencies.cmake
@@ -161,10 +161,7 @@
 list(APPEND LLDB_SYSTEM_LIBS atomic)
 endif()
 
-# On FreeBSD/NetBSD backtrace() is provided by libexecinfo, not libc.
-if (CMAKE_SYSTEM_NAME MATCHES "FreeBSD" OR CMAKE_SYSTEM_NAME MATCHES "NetBSD")
-  list(APPEND LLDB_SYSTEM_LIBS execinfo)
-endif()
+list(APPEND LLDB_SYSTEM_LIBS ${Backtrace_LIBRARY})
 
 if (NOT LLDB_DISABLE_PYTHON AND NOT LLVM_BUILD_STATIC)
   list(APPEND LLDB_SYSTEM_LIBS ${PYTHON_LIBRARIES})
Index: lldb/trunk/scripts/utilsOsType.py
===
--- lldb/trunk/scripts/utilsOsType.py
+++ lldb/trunk/scripts/utilsOsType.py
@@ -36,14 +36,16 @@
 Linux = 3
 NetBSD = 4
 Windows = 5
+kFreeBSD = 6
 else:
 class EnumOsType(object):
 values = ["Unknown",
   "Darwin",
   "FreeBSD",
   "Linux",
   "NetBSD",
-  "Windows"]
+  "Windows",
+  "kFreeBSD"]
 
 class __metaclass__(type):
 #++
@@ -91,5 +93,7 @@
 eOSType = EnumOsType.NetBSD
 elif strOS == "win32":
 eOSType = EnumOsType.Windows
+elif strOS.startswith("gnukfreebsd"):
+eOSType = EnumOsType.kFreeBSD
 
 return eOSType
Index: lldb/trunk/scripts/Python/modules/CMakeLists.txt
===
--- lldb/trunk/scripts/Python/modules/CMakeLists.txt
+++ lldb/trunk/scripts/Python/modules/CMakeLists.txt
@@ -6,6 +6,6 @@
 endif ()
 
 # build the Python readline suppression module only on Linux
-if (CMAKE_SYSTEM_NAME MATCHES "Linux")
+​if (CMAKE_SYSTEM_NAME MATCHES "Linux" OR CMAKE_SYSTEM_NAME STREQUAL "GNU" OR 
CMAKE_SYSTEM_NAME STREQUAL "kFreeBSD")
add_subdirectory(readline)
 endif()


Index: lldb/trunk/cmake/modules/LLDBConfig.cmake
===
--- lldb/trunk/cmake/modules/LLDBConfig.cmake
+++ lldb/trunk/cmake/modules/LLDBConfig.cmake
@@ -416,3 +416,5 @@
 if(LLDB_USE_BUILTIN_DEMANGLER)
 add_definitions(-DLLDB_USE_BUILTIN_DEMANGLER)
 endif()
+
+find_package(Backtrace)
Index: lldb/trunk/cmake/LLDBDependencies.cmake
===
--- lldb/trunk/cmake/LLDBDependencies.cmake
+++ lldb/trunk/cmake/LLDBDependencies.cmake
@@ -161,10 +161,7 @@
 list(APPEND LLDB_SYSTEM_LIBS atomic)
 endif()
 
-# On FreeBSD/NetBSD backtrace() is provided by libexecinfo, not libc.
-if (CMAKE_SYSTEM_NAME MATCHES "FreeBSD" OR CMAKE_SYSTEM_NAME MATCHES "NetBSD")
-  list(APPEND LLDB_SYSTEM_LIBS execinfo)
-endif()
+list(APPEND LLDB_SYSTEM_LIBS ${Backtrace_LIBRARY})
 
 if (NOT LLDB_DISABLE_PYTHON AND NOT LLVM_BUILD_STATIC)
   list(APPEND LLDB_SYSTEM_LIBS ${PYTHON_LIBRARIES})
Index: lldb/trunk/scripts/utilsOsType.py
===
--- lldb/trunk/scripts/utilsOsType.py
+++ lldb/trunk/scripts/utilsOsType.py
@@ -36,14 +36,16 @@
 Linux = 3
 NetBSD = 4
 Windows = 5
+kFreeBSD = 6
 else:
 class EnumOsType(object):
 values = ["Unknown",
   "Darwin",
   "FreeBSD",
   "Linux",
   "NetBSD",
-  "Windows"]
+  "Windows",
+  "kFreeBSD"]
 
 class __metaclass__(type):
 #++
@@ -91,5 +93,7 @@
 eOSType = EnumOsType.NetBSD
 elif strOS == "win32":
 eOSType = EnumOsType.Windows
+elif strOS.startswith("gnukfreebsd"):
+eOSType = EnumOsType.kFreeBSD
 
 return eOSType
Index: lldb/trunk/scripts/Python/modules/CMakeLists.txt
===
--- lldb/trunk/scripts/Python/modules/CMakeLists.txt
+++ 

[Lldb-commits] [PATCH] D28035: Stop limiting the number of TSan backtrace size to 8

2017-01-09 Thread Phabricator via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL291522: Stop limiting the number of TSan backtrace size to 8 
(authored by kuba.brecka).

Changed prior to commit:
  https://reviews.llvm.org/D28035?vs=82280=83753#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D28035

Files:
  
lldb/trunk/source/Plugins/InstrumentationRuntime/ThreadSanitizer/ThreadSanitizerRuntime.cpp


Index: 
lldb/trunk/source/Plugins/InstrumentationRuntime/ThreadSanitizer/ThreadSanitizerRuntime.cpp
===
--- 
lldb/trunk/source/Plugins/InstrumentationRuntime/ThreadSanitizer/ThreadSanitizerRuntime.cpp
+++ 
lldb/trunk/source/Plugins/InstrumentationRuntime/ThreadSanitizer/ThreadSanitizerRuntime.cpp
@@ -206,7 +206,8 @@
   StructuredData::Array *trace = new StructuredData::Array();
   ValueObjectSP trace_value_object =
   o->GetValueForExpressionPath(trace_item_name.c_str());
-  for (int j = 0; j < 8; j++) {
+  size_t count = trace_value_object->GetNumChildren();
+  for (size_t j = 0; j < count; j++) {
 addr_t trace_addr =
 trace_value_object->GetChildAtIndex(j, true)->GetValueAsUnsigned(0);
 if (trace_addr == 0)


Index: lldb/trunk/source/Plugins/InstrumentationRuntime/ThreadSanitizer/ThreadSanitizerRuntime.cpp
===
--- lldb/trunk/source/Plugins/InstrumentationRuntime/ThreadSanitizer/ThreadSanitizerRuntime.cpp
+++ lldb/trunk/source/Plugins/InstrumentationRuntime/ThreadSanitizer/ThreadSanitizerRuntime.cpp
@@ -206,7 +206,8 @@
   StructuredData::Array *trace = new StructuredData::Array();
   ValueObjectSP trace_value_object =
   o->GetValueForExpressionPath(trace_item_name.c_str());
-  for (int j = 0; j < 8; j++) {
+  size_t count = trace_value_object->GetNumChildren();
+  for (size_t j = 0; j < count; j++) {
 addr_t trace_addr =
 trace_value_object->GetChildAtIndex(j, true)->GetValueAsUnsigned(0);
 if (trace_addr == 0)
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D27017: Support more report types in AddressSanitizerRuntime.cpp

2016-12-02 Thread Phabricator via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL288535: Support more report types in 
AddressSanitizerRuntime.cpp, re-word existing ones. (authored by kuba.brecka).

Changed prior to commit:
  https://reviews.llvm.org/D27017?vs=79611=80123#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D27017

Files:
  
lldb/trunk/source/Plugins/InstrumentationRuntime/AddressSanitizer/AddressSanitizerRuntime.cpp


Index: 
lldb/trunk/source/Plugins/InstrumentationRuntime/AddressSanitizer/AddressSanitizerRuntime.cpp
===
--- 
lldb/trunk/source/Plugins/InstrumentationRuntime/AddressSanitizer/AddressSanitizerRuntime.cpp
+++ 
lldb/trunk/source/Plugins/InstrumentationRuntime/AddressSanitizer/AddressSanitizerRuntime.cpp
@@ -26,6 +26,8 @@
 #include "lldb/Target/Target.h"
 #include "lldb/Target/Thread.h"
 
+#include "llvm/ADT/StringSwitch.h"
+
 using namespace lldb;
 using namespace lldb_private;
 
@@ -194,32 +196,45 @@
 ->GetValueForKey("description")
 ->GetAsString()
 ->GetValue();
-  if (description == "heap-use-after-free") {
-return "Use of deallocated memory detected";
-  } else if (description == "heap-buffer-overflow") {
-return "Heap buffer overflow detected";
-  } else if (description == "stack-buffer-underflow") {
-return "Stack buffer underflow detected";
-  } else if (description == "initialization-order-fiasco") {
-return "Initialization order problem detected";
-  } else if (description == "stack-buffer-overflow") {
-return "Stack buffer overflow detected";
-  } else if (description == "stack-use-after-return") {
-return "Use of returned stack memory detected";
-  } else if (description == "use-after-poison") {
-return "Use of poisoned memory detected";
-  } else if (description == "container-overflow") {
-return "Container overflow detected";
-  } else if (description == "stack-use-after-scope") {
-return "Use of out-of-scope stack memory detected";
-  } else if (description == "global-buffer-overflow") {
-return "Global buffer overflow detected";
-  } else if (description == "unknown-crash") {
-return "Invalid memory access detected";
-  }
-
-  // for unknown report codes just show the code
-  return description;
+  return llvm::StringSwitch(description)
+  .Case("heap-use-after-free", "Use of deallocated memory")
+  .Case("heap-buffer-overflow", "Heap buffer overflow")
+  .Case("stack-buffer-underflow", "Stack buffer underflow")
+  .Case("initialization-order-fiasco", "Initialization order problem")
+  .Case("stack-buffer-overflow", "Stack buffer overflow")
+  .Case("stack-use-after-return", "Use of stack memory after return")
+  .Case("use-after-poison", "Use of poisoned memory")
+  .Case("container-overflow", "Container overflow")
+  .Case("stack-use-after-scope", "Use of out-of-scope stack memory")
+  .Case("global-buffer-overflow", "Global buffer overflow")
+  .Case("unknown-crash", "Invalid memory access")
+  .Case("stack-overflow", "Stack space exhausted")
+  .Case("null-deref", "Dereference of null pointer")
+  .Case("wild-jump", "Jump to non-executable address")
+  .Case("wild-addr-write", "Write through wild pointer")
+  .Case("wild-addr-read", "Read from wild pointer")
+  .Case("wild-addr", "Access through wild pointer")
+  .Case("signal", "Deadly signal")
+  .Case("double-free", "Deallocation of freed memory")
+  .Case("new-delete-type-mismatch",
+"Deallocation size different from allocation size")
+  .Case("bad-free", "Deallocation of non-allocated memory")
+  .Case("alloc-dealloc-mismatch",
+"Mismatch between allocation and deallocation APIs")
+  .Case("bad-malloc_usable_size", "Invalid argument to malloc_usable_size")
+  .Case("bad-__sanitizer_get_allocated_size",
+"Invalid argument to __sanitizer_get_allocated_size")
+  .Case("param-overlap",
+"Call to function disallowing overlapping memory ranges")
+  .Case("negative-size-param", "Negative size used when accessing memory")
+  .Case("bad-__sanitizer_annotate_contiguous_container",
+"Invalid argument to __sanitizer_annotate_contiguous_container")
+  .Case("odr-violation", "Symbol defined in multiple translation units")
+  .Case(
+  "invalid-pointer-pair",
+  "Comparison or arithmetic on pointers from different memory regions")
+  // for unknown report codes just show the code
+  .Default("AddressSanitizer detected: " + description);
 }
 
 bool AddressSanitizerRuntime::NotifyBreakpointHit(


Index: lldb/trunk/source/Plugins/InstrumentationRuntime/AddressSanitizer/AddressSanitizerRuntime.cpp
===
--- 

[Lldb-commits] [PATCH] D31374: Add support for tracing hello-world application on NetBSD

2017-03-28 Thread Phabricator via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL298953: Add support for tracing hello-world application on 
NetBSD (authored by kamil).

Changed prior to commit:
  https://reviews.llvm.org/D31374?vs=93312=93315#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D31374

Files:
  lldb/trunk/source/Plugins/Process/NetBSD/CMakeLists.txt
  lldb/trunk/source/Plugins/Process/NetBSD/NativeProcessNetBSD.cpp
  lldb/trunk/source/Plugins/Process/NetBSD/NativeProcessNetBSD.h
  lldb/trunk/source/Plugins/Process/NetBSD/NativeRegisterContextNetBSD.cpp
  lldb/trunk/source/Plugins/Process/NetBSD/NativeRegisterContextNetBSD.h
  
lldb/trunk/source/Plugins/Process/NetBSD/NativeRegisterContextNetBSD_x86_64.cpp
  lldb/trunk/source/Plugins/Process/NetBSD/NativeRegisterContextNetBSD_x86_64.h
  lldb/trunk/source/Plugins/Process/NetBSD/NativeThreadNetBSD.cpp
  lldb/trunk/source/Plugins/Process/NetBSD/NativeThreadNetBSD.h

Index: lldb/trunk/source/Plugins/Process/NetBSD/NativeRegisterContextNetBSD.h
===
--- lldb/trunk/source/Plugins/Process/NetBSD/NativeRegisterContextNetBSD.h
+++ lldb/trunk/source/Plugins/Process/NetBSD/NativeRegisterContextNetBSD.h
@@ -33,6 +33,19 @@
   CreateHostNativeRegisterContextNetBSD(const ArchSpec _arch,
 NativeThreadProtocol _thread,
 uint32_t concrete_frame_idx);
+
+protected:
+  virtual Error ReadGPR();
+  virtual Error WriteGPR();
+  virtual void *GetGPRBuffer() { return nullptr; }
+  virtual size_t GetGPRSize() {
+return GetRegisterInfoInterface().GetGPRSize();
+  }
+  virtual Error DoReadGPR(void *buf);
+  virtual Error DoWriteGPR(void *buf);
+
+  virtual NativeProcessNetBSD ();
+  virtual ::pid_t GetProcessPid();
 };
 
 } // namespace process_netbsd
Index: lldb/trunk/source/Plugins/Process/NetBSD/NativeProcessNetBSD.cpp
===
--- lldb/trunk/source/Plugins/Process/NetBSD/NativeProcessNetBSD.cpp
+++ lldb/trunk/source/Plugins/Process/NetBSD/NativeProcessNetBSD.cpp
@@ -14,38 +14,978 @@
 // C++ Includes
 
 // Other libraries and framework includes
-
 #include "Plugins/Process/POSIX/ProcessPOSIXLog.h"
+#include "lldb/Core/State.h"
+#include "lldb/Host/HostProcess.h"
+#include "lldb/Host/common/NativeBreakpoint.h"
+#include "lldb/Host/common/NativeRegisterContext.h"
+#include "lldb/Host/posix/ProcessLauncherPosixFork.h"
+#include "lldb/Target/Process.h"
 
 // System includes - They have to be included after framework includes because
 // they define some
 // macros which collide with variable names in other modules
+// clang-format off
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+// clang-format on
 
 using namespace lldb;
 using namespace lldb_private;
 using namespace lldb_private::process_netbsd;
 using namespace llvm;
 
+static ExitType convert_pid_status_to_exit_type(int status) {
+  if (WIFEXITED(status))
+return ExitType::eExitTypeExit;
+  else if (WIFSIGNALED(status))
+return ExitType::eExitTypeSignal;
+  else if (WIFSTOPPED(status))
+return ExitType::eExitTypeStop;
+  else {
+// We don't know what this is.
+return ExitType::eExitTypeInvalid;
+  }
+}
+
+static int convert_pid_status_to_return_code(int status) {
+  if (WIFEXITED(status))
+return WEXITSTATUS(status);
+  else if (WIFSIGNALED(status))
+return WTERMSIG(status);
+  else if (WIFSTOPPED(status))
+return WSTOPSIG(status);
+  else {
+// We don't know what this is.
+return ExitType::eExitTypeInvalid;
+  }
+}
+
+// Simple helper function to ensure flags are enabled on the given file
+// descriptor.
+static Error EnsureFDFlags(int fd, int flags) {
+  Error error;
+
+  int status = fcntl(fd, F_GETFL);
+  if (status == -1) {
+error.SetErrorToErrno();
+return error;
+  }
+
+  if (fcntl(fd, F_SETFL, status | flags) == -1) {
+error.SetErrorToErrno();
+return error;
+  }
+
+  return error;
+}
+
 // -
 // Public Static Methods
 // -
 
 Error NativeProcessProtocol::Launch(
 ProcessLaunchInfo _info,
 NativeProcessProtocol::NativeDelegate _delegate, MainLoop ,
 NativeProcessProtocolSP _process_sp) {
-  return Error();
+  Log *log(ProcessPOSIXLog::GetLogIfAllCategoriesSet(POSIX_LOG_PROCESS));
+
+  Error error;
+
+  // Verify the working directory is valid if one was specified.
+  FileSpec working_dir{launch_info.GetWorkingDirectory()};
+  if (working_dir && (!working_dir.ResolvePath() ||
+  !llvm::sys::fs::is_directory(working_dir.GetPath( {
+error.SetErrorStringWithFormat("No such file or directory: %s",
+   working_dir.GetCString());
+return error;
+  }
+
+  // Create the 

[Lldb-commits] [PATCH] D31357: Support Unit Testing debugserver

2017-04-12 Thread Phabricator via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL300111: Support Unit Testing debugserver (authored by 
cbieneman).

Changed prior to commit:
  https://reviews.llvm.org/D31357?vs=94526=95036#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D31357

Files:
  lldb/trunk/tools/debugserver/source/CMakeLists.txt
  lldb/trunk/tools/debugserver/source/MacOSX/CMakeLists.txt
  lldb/trunk/unittests/CMakeLists.txt
  lldb/trunk/unittests/debugserver/CMakeLists.txt
  lldb/trunk/unittests/debugserver/RNBSocketTest.cpp
  lldb/trunk/unittests/debugserver/debugserver_LogCallback.cpp

Index: lldb/trunk/unittests/CMakeLists.txt
===
--- lldb/trunk/unittests/CMakeLists.txt
+++ lldb/trunk/unittests/CMakeLists.txt
@@ -70,3 +70,7 @@
 add_subdirectory(Target)
 add_subdirectory(UnwindAssembly)
 add_subdirectory(Utility)
+
+if(LLDB_CAN_USE_DEBUGSERVER)
+  add_subdirectory(debugserver)
+endif()
\ No newline at end of file
Index: lldb/trunk/unittests/debugserver/CMakeLists.txt
===
--- lldb/trunk/unittests/debugserver/CMakeLists.txt
+++ lldb/trunk/unittests/debugserver/CMakeLists.txt
@@ -0,0 +1,19 @@
+# Note: debugserver is a Darwin-only implementation of a remote debugging
+# server. It is not intended to be used on other platforms. The tests are here
+# because using the LLDB Host API is convienent and allows testing of both parts
+# of the debugserver communication path. If you are looking for a non-darwin
+# remote debugging server, please use lldb-server.
+
+include_directories(${LLDB_SOURCE_DIR}/tools/debugserver/source
+${LLDB_SOURCE_DIR}/tools/debugserver/source/MacOSX)
+
+add_lldb_unittest(debugserverTests
+  RNBSocketTest.cpp
+  debugserver_LogCallback.cpp
+
+  LINK_LIBS
+lldbDebugserverCommon
+lldbHost
+  LINK_COMPONENTS
+Support
+  )
Index: lldb/trunk/unittests/debugserver/debugserver_LogCallback.cpp
===
--- lldb/trunk/unittests/debugserver/debugserver_LogCallback.cpp
+++ lldb/trunk/unittests/debugserver/debugserver_LogCallback.cpp
@@ -0,0 +1,20 @@
+//===-- debugserver_LogCallback.cpp -*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+//--
+// this function is defined in debugserver.cpp, but is needed to link the
+// debugserver Common library. It is for logging only, so it is left
+// unimplemented here.
+//--
+
+#include 
+#include 
+
+void FileLogCallback(void *baton, uint32_t flags, const char *format,
+ va_list args) {}
Index: lldb/trunk/unittests/debugserver/RNBSocketTest.cpp
===
--- lldb/trunk/unittests/debugserver/RNBSocketTest.cpp
+++ lldb/trunk/unittests/debugserver/RNBSocketTest.cpp
@@ -0,0 +1,133 @@
+//===-- RNBSocketTest.cpp ---*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#include "gtest/gtest.h"
+
+#include 
+#include 
+#include 
+
+#include "RNBDefs.h"
+#include "RNBSocket.h"
+#include "lldb/Host/Socket.h"
+#include "lldb/Host/StringConvert.h"
+#include "lldb/Host/common/TCPSocket.h"
+
+using namespace lldb_private;
+
+std::string hello = "Hello, world!";
+std::string goodbye = "Goodbye!";
+
+static void ServerCallbackv4(const void *baton, in_port_t port) {
+  auto child_pid = fork();
+  if (child_pid == 0) {
+Socket *client_socket;
+char addr_buffer[256];
+sprintf(addr_buffer, "%s:%d", baton, port);
+Error err = Socket::TcpConnect(addr_buffer, false, client_socket);
+if (err.Fail())
+  abort();
+char buffer[32];
+size_t read_size = 32;
+err = client_socket->Read((void *)[0], read_size);
+if (err.Fail())
+  abort();
+std::string Recv([0], read_size);
+if (Recv != hello)
+  abort();
+size_t write_size = goodbye.length();
+err = client_socket->Write(goodbye.c_str(), write_size);
+if (err.Fail())
+  abort();
+if (write_size != goodbye.length())
+  abort();
+delete client_socket;
+exit(0);
+  }
+}
+
+void TestSocketListen(const char *addr) {
+  RNBSocket server_socket;
+  auto result =
+  server_socket.Listen(addr, 0, ServerCallbackv4, (const void *)addr);
+  ASSERT_TRUE(result == rnb_success);

[Lldb-commits] [PATCH] D31969: [CMake] Support generating Config.h

2017-04-14 Thread Phabricator via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL300372: [CMake] Support generating Config.h (authored by 
cbieneman).

Changed prior to commit:
  https://reviews.llvm.org/D31969?vs=95024=95354#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D31969

Files:
  lldb/trunk/cmake/modules/LLDBConfig.cmake
  lldb/trunk/include/lldb/Host/Config.h
  lldb/trunk/include/lldb/Host/Config.h.cmake
  lldb/trunk/include/lldb/Host/android/Config.h
  lldb/trunk/include/lldb/Host/freebsd/Config.h
  lldb/trunk/include/lldb/Host/linux/Config.h
  lldb/trunk/include/lldb/Host/macosx/Config.h
  lldb/trunk/include/lldb/Host/mingw/Config.h
  lldb/trunk/include/lldb/Host/msvc/Config.h
  lldb/trunk/include/lldb/Host/netbsd/Config.h
  lldb/trunk/include/lldb/Host/openbsd/Config.h
  lldb/trunk/source/Host/common/File.cpp

Index: lldb/trunk/source/Host/common/File.cpp
===
--- lldb/trunk/source/Host/common/File.cpp
+++ lldb/trunk/source/Host/common/File.cpp
@@ -307,7 +307,7 @@
 
 Error File::GetFileSpec(FileSpec _spec) const {
   Error error;
-#ifdef LLDB_CONFIG_FCNTL_GETPATH_SUPPORTED
+#ifdef F_GETPATH
   if (IsValid()) {
 char path[PATH_MAX];
 if (::fcntl(GetDescriptor(), F_GETPATH, path) == -1)
Index: lldb/trunk/include/lldb/Host/freebsd/Config.h
===
--- lldb/trunk/include/lldb/Host/freebsd/Config.h
+++ lldb/trunk/include/lldb/Host/freebsd/Config.h
@@ -1,28 +0,0 @@
-//===-- Config.h ---*- C++ -*-===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===--===//
-
-//--
-// LLDB currently doesn't have a dynamic configuration mechanism, so we
-// are going to hardcode things for now. Eventually these files will
-// be auto generated by some configuration script that can detect
-// platform functionality availability.
-//--
-
-#ifndef liblldb_Platform_Config_h_
-#define liblldb_Platform_Config_h_
-
-#define LLDB_CONFIG_TERMIOS_SUPPORTED 1
-
-#define LLDB_CONFIG_TILDE_RESOLVES_TO_USER 1
-
-//#define LLDB_CONFIG_DLOPEN_RTLD_FIRST_SUPPORTED 1
-
-//#define LLDB_CONFIG_FCNTL_GETPATH_SUPPORTED 1
-
-#endif // #ifndef liblldb_Platform_Config_h_
Index: lldb/trunk/include/lldb/Host/Config.h
===
--- lldb/trunk/include/lldb/Host/Config.h
+++ lldb/trunk/include/lldb/Host/Config.h
@@ -7,45 +7,21 @@
 //
 //===--===//
 
-#ifndef liblldb_Config_h_
-#define liblldb_Config_h_
-
+#ifndef LLDB_HOST_CONFIG_H
+#define LLDB_HOST_CONFIG_H
+ 
 #if defined(__APPLE__)
 
-#include "lldb/Host/macosx/Config.h"
-
-#elif defined(__ANDROID__)
-
-#include "lldb/Host/android/Config.h"
-
-#elif defined(__linux__) || defined(__GNU__)
-
-#include "lldb/Host/linux/Config.h"
-
-#elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
-
-#include "lldb/Host/freebsd/Config.h"
-
-#elif defined(__NetBSD__)
-
-#include "lldb/Host/netbsd/Config.h"
-
-#elif defined(__OpenBSD__)
-
-#include "lldb/Host/openbsd/Config.h"
-
-#elif defined(__MINGW__) || defined(__MINGW32__)
-
-#include "lldb/Host/mingw/Config.h"
-
-#elif defined(_MSC_VER)
+// This block of code only exists to keep the Xcode project working in the
+// absence of a configuration step.
+#define LLDB_CONFIG_TERMIOS_SUPPORTED 1
 
-#include "lldb/Host/msvc/Config.h"
+#define HAVE_SYS_EVENT_H 1
 
 #else
 
-#error undefined platform
+#error This file is only used by the Xcode build.
 
 #endif
 
-#endif // #ifndef liblldb_Config_h_
+#endif // #ifndef LLDB_HOST_CONFIG_H
Index: lldb/trunk/include/lldb/Host/openbsd/Config.h
===
--- lldb/trunk/include/lldb/Host/openbsd/Config.h
+++ lldb/trunk/include/lldb/Host/openbsd/Config.h
@@ -1,28 +0,0 @@
-//===-- Config.h ---*- C++ -*-===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===--===//
-
-//--
-// LLDB currently doesn't have a dynamic configuration mechanism, so we
-// are going to hardcode things for now. Eventually these files will
-// be auto generated by some configuration script that can detect
-// platform functionality availability.
-//--
-

[Lldb-commits] [PATCH] D32087: Modify GDBRemoteCommunication::ScopedTimeout to not ever decrease a timeout

2017-04-17 Thread Phabricator via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL300455: Don't ever reduce the timeout of a packet, only 
increase it. (authored by gclayton).

Changed prior to commit:
  https://reviews.llvm.org/D32087?vs=95314=95442#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D32087

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


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
@@ -1310,12 +1310,20 @@
 
 GDBRemoteCommunication::ScopedTimeout::ScopedTimeout(
 GDBRemoteCommunication _comm, std::chrono::seconds timeout)
-: m_gdb_comm(gdb_comm) {
-  m_saved_timeout = m_gdb_comm.SetPacketTimeout(timeout);
+  : m_gdb_comm(gdb_comm), m_timeout_modified(false) {
+auto curr_timeout = gdb_comm.GetPacketTimeout();
+// Only update the timeout if the timeout is greater than the current
+// timeout. If the current timeout is larger, then just use that.
+if (curr_timeout < timeout) {
+  m_timeout_modified = true;
+  m_saved_timeout = m_gdb_comm.SetPacketTimeout(timeout);
+}
 }
 
 GDBRemoteCommunication::ScopedTimeout::~ScopedTimeout() {
-  m_gdb_comm.SetPacketTimeout(m_saved_timeout);
+  // Only restore the timeout if we set it in the constructor.
+  if (m_timeout_modified)
+m_gdb_comm.SetPacketTimeout(m_saved_timeout);
 }
 
 // This function is called via the Communications class read thread when bytes
Index: lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.h
===
--- lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.h
+++ lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.h
@@ -89,6 +89,10 @@
   private:
 GDBRemoteCommunication _gdb_comm;
 std::chrono::seconds m_saved_timeout;
+// Don't ever reduce the timeout for a packet, only increase it. If the
+// requested timeout if less than the current timeout, we don't set it
+// and won't need to restore it.
+bool m_timeout_modified;
   };
 
   GDBRemoteCommunication(const char *comm_name, const char *listener_name);


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
@@ -1310,12 +1310,20 @@
 
 GDBRemoteCommunication::ScopedTimeout::ScopedTimeout(
 GDBRemoteCommunication _comm, std::chrono::seconds timeout)
-: m_gdb_comm(gdb_comm) {
-  m_saved_timeout = m_gdb_comm.SetPacketTimeout(timeout);
+  : m_gdb_comm(gdb_comm), m_timeout_modified(false) {
+auto curr_timeout = gdb_comm.GetPacketTimeout();
+// Only update the timeout if the timeout is greater than the current
+// timeout. If the current timeout is larger, then just use that.
+if (curr_timeout < timeout) {
+  m_timeout_modified = true;
+  m_saved_timeout = m_gdb_comm.SetPacketTimeout(timeout);
+}
 }
 
 GDBRemoteCommunication::ScopedTimeout::~ScopedTimeout() {
-  m_gdb_comm.SetPacketTimeout(m_saved_timeout);
+  // Only restore the timeout if we set it in the constructor.
+  if (m_timeout_modified)
+m_gdb_comm.SetPacketTimeout(m_saved_timeout);
 }
 
 // This function is called via the Communications class read thread when bytes
Index: lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.h
===
--- lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.h
+++ lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.h
@@ -89,6 +89,10 @@
   private:
 GDBRemoteCommunication _gdb_comm;
 std::chrono::seconds m_saved_timeout;
+// Don't ever reduce the timeout for a packet, only increase it. If the
+// requested timeout if less than the current timeout, we don't set it
+// and won't need to restore it.
+bool m_timeout_modified;
   };
 
   GDBRemoteCommunication(const char *comm_name, const char *listener_name);
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D30918: [debugserver] This is a small cleanup patch to AVX support detection

2017-03-13 Thread Phabricator via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL297685: [debugserver] This is a small cleanup patch to AVX 
support detection (authored by cbieneman).

Changed prior to commit:
  https://reviews.llvm.org/D30918?vs=91644=91645#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D30918

Files:
  lldb/trunk/tools/debugserver/debugserver.xcodeproj/project.pbxproj
  lldb/trunk/tools/debugserver/source/MacOSX/CMakeLists.txt
  lldb/trunk/tools/debugserver/source/MacOSX/HasAVX.h
  lldb/trunk/tools/debugserver/source/MacOSX/HasAVX.s
  lldb/trunk/tools/debugserver/source/MacOSX/i386/DNBArchImplI386.h
  lldb/trunk/tools/debugserver/source/MacOSX/x86_64/DNBArchImplX86_64.cpp

Index: lldb/trunk/tools/debugserver/source/MacOSX/CMakeLists.txt
===
--- lldb/trunk/tools/debugserver/source/MacOSX/CMakeLists.txt
+++ lldb/trunk/tools/debugserver/source/MacOSX/CMakeLists.txt
@@ -29,7 +29,6 @@
   )
 
 add_lldb_tool(debugserver INCLUDE_IN_FRAMEWORK
-  HasAVX.s
   CFBundle.cpp
   CFString.cpp
   Genealogy.cpp
Index: lldb/trunk/tools/debugserver/source/MacOSX/x86_64/DNBArchImplX86_64.cpp
===
--- lldb/trunk/tools/debugserver/source/MacOSX/x86_64/DNBArchImplX86_64.cpp
+++ lldb/trunk/tools/debugserver/source/MacOSX/x86_64/DNBArchImplX86_64.cpp
@@ -17,7 +17,6 @@
 #include 
 #include 
 
-#include "../HasAVX.h"
 #include "DNBLog.h"
 #include "MacOSX/x86_64/DNBArchImplX86_64.h"
 #include "MachProcess.h"
@@ -60,42 +59,64 @@
 #define FORCE_AVX_REGS (0)
 #endif
 
-extern "C" bool CPUHasAVX() {
-  enum AVXPresence { eAVXUnknown = -1, eAVXNotPresent = 0, eAVXPresent = 1 };
+bool DetectHardwareFeature(const char *feature) {
+  int answer = 0;
+  size_t answer_size = sizeof(answer);
+  int error = ::sysctlbyname(feature, , _size, NULL, 0);
+  return error != 0 && answer != 0;
+}
+
+enum AVXPresence { eAVXUnknown = -1, eAVXNotPresent = 0, eAVXPresent = 1 };
+
+bool LogAVXAndReturn(AVXPresence has_avx, int err, const char * os_ver) {
+  DNBLogThreadedIf(LOG_THREAD,
+   "CPUHasAVX(): g_has_avx = %i (err = %i, os_ver = %s)",
+   has_avx, err, os_ver);
+  return (has_avx == eAVXPresent);
+}
 
+extern "C" bool CPUHasAVX() {
   static AVXPresence g_has_avx = eAVXUnknown;
-  if (g_has_avx == eAVXUnknown) {
-g_has_avx = eAVXNotPresent;
+  if (g_has_avx != eAVXUnknown)
+return LogAVXAndReturn(g_has_avx, 0, "");
 
-// Only xnu-2020 or later has AVX support, any versions before
-// this have a busted thread_get_state RPC where it would truncate
-// the thread state buffer (). So we need to
-// verify the kernel version number manually or disable AVX support.
-int mib[2];
-char buffer[1024];
-size_t length = sizeof(buffer);
-uint64_t xnu_version = 0;
-mib[0] = CTL_KERN;
-mib[1] = KERN_VERSION;
-int err = ::sysctl(mib, 2, , , NULL, 0);
-if (err == 0) {
-  const char *xnu = strstr(buffer, "xnu-");
-  if (xnu) {
-const char *xnu_version_cstr = xnu + 4;
-xnu_version = strtoull(xnu_version_cstr, NULL, 0);
-if (xnu_version >= 2020 && xnu_version != ULLONG_MAX) {
-  if (::HasAVX()) {
-g_has_avx = eAVXPresent;
-  }
-}
-  }
-}
-DNBLogThreadedIf(LOG_THREAD, "CPUHasAVX(): g_has_avx = %i (err = %i, errno "
- "= %i, xnu_version = %llu)",
- g_has_avx, err, errno, xnu_version);
+  g_has_avx = eAVXNotPresent;
+
+  // OS X 10.7.3 and earlier have a bug in thread_get_state that truncated the
+  // size of the return. To work around this we have to disable AVX debugging
+  // on hosts prior to 10.7.3 ().
+  int mib[2];
+  char buffer[1024];
+  size_t length = sizeof(buffer);
+  mib[0] = CTL_KERN;
+  mib[1] = KERN_OSVERSION;
+
+  // KERN_OSVERSION returns the build number which is a number signifying the
+  // major version, a capitol letter signifying the minor version, and numbers
+  // signifying the build (ex: on 10.12.3, the returned value is 16D32).
+  int err = ::sysctl(mib, 2, , , NULL, 0);
+  if (err != 0)
+return LogAVXAndReturn(g_has_avx, err, "");
+
+  size_t first_letter = 0;
+  for (; first_letter < length; ++first_letter) {
+// This is looking for the first uppercase letter
+if (isupper(buffer[first_letter]))
+  break;
   }
+  char letter = buffer[first_letter];
+  buffer[first_letter] = '\0';
+  auto major_ver = strtoull(buffer, NULL, 0);
+  buffer[first_letter] = letter;
+
+  // In this check we're looking to see that our major and minor version numer
+  // was >= 11E, which is the 10.7.4 release.
+  if (major_ver < 11 || (major_ver == 11 && letter < 'E'))
+return LogAVXAndReturn(g_has_avx, err, buffer);
+  if (DetectHardwareFeature("hw.optional.avx1_0"))
+g_has_avx = eAVXPresent;
 
-  return (g_has_avx == eAVXPresent);
+  return 

[Lldb-commits] [PATCH] D31823: Update LLDB Host to support IPv6 over TCP

2017-04-18 Thread Phabricator via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL300579: Update LLDB Host to support IPv6 over TCP (authored 
by cbieneman).

Changed prior to commit:
  https://reviews.llvm.org/D31823?vs=95453=95616#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D31823

Files:
  lldb/trunk/cmake/modules/LLDBConfig.cmake
  lldb/trunk/include/lldb/Host/Config.h
  lldb/trunk/include/lldb/Host/Config.h.cmake
  lldb/trunk/include/lldb/Host/MainLoop.h
  lldb/trunk/include/lldb/Host/Socket.h
  lldb/trunk/include/lldb/Host/common/TCPSocket.h
  lldb/trunk/include/lldb/Host/common/UDPSocket.h
  lldb/trunk/include/lldb/Host/linux/AbstractSocket.h
  lldb/trunk/include/lldb/Host/posix/DomainSocket.h
  lldb/trunk/include/lldb/Host/posix/MainLoopPosix.h
  lldb/trunk/lldb.xcodeproj/project.pbxproj
  lldb/trunk/source/Host/CMakeLists.txt
  lldb/trunk/source/Host/common/MainLoop.cpp
  lldb/trunk/source/Host/common/Socket.cpp
  lldb/trunk/source/Host/common/TCPSocket.cpp
  lldb/trunk/source/Host/common/UDPSocket.cpp
  lldb/trunk/source/Host/linux/AbstractSocket.cpp
  lldb/trunk/source/Host/posix/ConnectionFileDescriptorPosix.cpp
  lldb/trunk/source/Host/posix/DomainSocket.cpp
  lldb/trunk/source/Host/posix/MainLoopPosix.cpp
  lldb/trunk/source/Plugins/Platform/Android/PlatformAndroidRemoteGDBServer.cpp
  lldb/trunk/tools/lldb-server/Acceptor.cpp
  lldb/trunk/unittests/Host/SocketTest.cpp
  lldb/trunk/unittests/Process/gdb-remote/GDBRemoteTestUtils.cpp
  lldb/trunk/unittests/debugserver/RNBSocketTest.cpp

Index: lldb/trunk/include/lldb/Host/Socket.h
===
--- lldb/trunk/include/lldb/Host/Socket.h
+++ lldb/trunk/include/lldb/Host/Socket.h
@@ -57,8 +57,7 @@
 
   virtual Error Connect(llvm::StringRef name) = 0;
   virtual Error Listen(llvm::StringRef name, int backlog) = 0;
-  virtual Error Accept(llvm::StringRef name, bool child_processes_inherit,
-   Socket *) = 0;
+  virtual Error Accept(Socket *) = 0;
 
   // Initialize a Tcp Socket object in listening mode.  listen and accept are
   // implemented
@@ -103,7 +102,8 @@
 int32_t , Error *error_ptr);
 
 protected:
-  Socket(NativeSocket socket, SocketProtocol protocol, bool should_close);
+  Socket(SocketProtocol protocol, bool should_close,
+ bool m_child_process_inherit);
 
   virtual size_t Send(const void *buf, const size_t num_bytes);
 
@@ -117,6 +117,7 @@
 
   SocketProtocol m_protocol;
   NativeSocket m_socket;
+  bool m_child_processes_inherit;
 };
 
 } // namespace lldb_private
Index: lldb/trunk/include/lldb/Host/Config.h.cmake
===
--- lldb/trunk/include/lldb/Host/Config.h.cmake
+++ lldb/trunk/include/lldb/Host/Config.h.cmake
@@ -16,4 +16,6 @@
 
 #cmakedefine01 HAVE_SYS_EVENT_H
 
+#cmakedefine01 HAVE_PPOLL
+
 #endif // #ifndef LLDB_HOST_CONFIG_H
Index: lldb/trunk/include/lldb/Host/MainLoop.h
===
--- lldb/trunk/include/lldb/Host/MainLoop.h
+++ lldb/trunk/include/lldb/Host/MainLoop.h
@@ -10,16 +10,88 @@
 #ifndef lldb_Host_MainLoop_h_
 #define lldb_Host_MainLoop_h_
 
-#ifdef _WIN32
 #include "lldb/Host/MainLoopBase.h"
+
+#include "llvm/ADT/DenseMap.h"
+
 namespace lldb_private {
-typedef MainLoopBase MainLoop;
-}
-#else
-#include "lldb/Host/posix/MainLoopPosix.h"
-namespace lldb_private {
-typedef MainLoopPosix MainLoop;
-}
-#endif
+
+// Implementation of the MainLoopBase class. It can monitor file descriptors for
+// readability using ppoll, kqueue, poll or WSAPoll. On Windows it only supports
+// polling sockets, and will not work on generic file handles or pipes. On
+// systems without kqueue or ppoll handling singnals is not supported. In
+// addition to the common base, this class provides the ability to invoke a
+// given handler when a signal is received.
+//
+// Since this class is primarily intended to be used for single-threaded
+// processing, it does not attempt to perform any internal synchronisation and
+// any concurrent accesses must be protected  externally. However, it is
+// perfectly legitimate to have more than one instance of this class running on
+// separate threads, or even a single thread (with some limitations on signal
+// monitoring).
+// TODO: Add locking if this class is to be used in a multi-threaded context.
+class MainLoop : public MainLoopBase {
+private:
+  class SignalHandle;
+
+public:
+  typedef std::unique_ptr SignalHandleUP;
+
+  ~MainLoop() override;
+
+  ReadHandleUP RegisterReadObject(const lldb::IOObjectSP _sp,
+  const Callback ,
+  Error ) override;
+
+  // Listening for signals from multiple MainLoop instances is perfectly safe as
+  // long as they don't try to listen for the same signal. The callback function
+  // is invoked when the control returns to the Run() function, not 

[Lldb-commits] [PATCH] D35298: [MainLoop] Fix possible use of an invalid iterator

2017-07-12 Thread Phabricator via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL307782: [MainLoop] Fix possible use of an invalid iterator 
(authored by petr.pavlu).

Changed prior to commit:
  https://reviews.llvm.org/D35298?vs=106164=106187#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D35298

Files:
  lldb/trunk/source/Host/common/MainLoop.cpp


Index: lldb/trunk/source/Host/common/MainLoop.cpp
===
--- lldb/trunk/source/Host/common/MainLoop.cpp
+++ lldb/trunk/source/Host/common/MainLoop.cpp
@@ -193,10 +193,16 @@
 
 void MainLoop::RunImpl::ProcessEvents() {
 #ifdef FORCE_PSELECT
-  for (const auto  : loop.m_read_fds) {
-if (!FD_ISSET(fd.first, _fd_set))
-  continue;
-IOObject::WaitableHandle handle = fd.first;
+  // Collect first all readable file descriptors into a separate vector and 
then
+  // iterate over it to invoke callbacks. Iterating directly over
+  // loop.m_read_fds is not possible because the callbacks can modify the
+  // container which could invalidate the iterator.
+  std::vector fds;
+  for (const auto  : loop.m_read_fds)
+if (FD_ISSET(fd.first, _fd_set))
+  fds.push_back(fd.first);
+
+  for (const auto  : fds) {
 #else
   for (const auto  : read_fds) {
 if ((fd.revents & POLLIN) == 0)
@@ -209,13 +215,16 @@
 loop.ProcessReadObject(handle);
   }
 
-  for (const auto  : loop.m_signals) {
+  std::vector signals;
+  for (const auto  : loop.m_signals)
+if (g_signal_flags[entry.first] != 0)
+  signals.push_back(entry.first);
+
+  for (const auto  : signals) {
 if (loop.m_terminate_request)
   return;
-if (g_signal_flags[entry.first] == 0)
-  continue; // No signal
-g_signal_flags[entry.first] = 0;
-loop.ProcessSignal(entry.first);
+g_signal_flags[signal] = 0;
+loop.ProcessSignal(signal);
   }
 }
 #endif


Index: lldb/trunk/source/Host/common/MainLoop.cpp
===
--- lldb/trunk/source/Host/common/MainLoop.cpp
+++ lldb/trunk/source/Host/common/MainLoop.cpp
@@ -193,10 +193,16 @@
 
 void MainLoop::RunImpl::ProcessEvents() {
 #ifdef FORCE_PSELECT
-  for (const auto  : loop.m_read_fds) {
-if (!FD_ISSET(fd.first, _fd_set))
-  continue;
-IOObject::WaitableHandle handle = fd.first;
+  // Collect first all readable file descriptors into a separate vector and then
+  // iterate over it to invoke callbacks. Iterating directly over
+  // loop.m_read_fds is not possible because the callbacks can modify the
+  // container which could invalidate the iterator.
+  std::vector fds;
+  for (const auto  : loop.m_read_fds)
+if (FD_ISSET(fd.first, _fd_set))
+  fds.push_back(fd.first);
+
+  for (const auto  : fds) {
 #else
   for (const auto  : read_fds) {
 if ((fd.revents & POLLIN) == 0)
@@ -209,13 +215,16 @@
 loop.ProcessReadObject(handle);
   }
 
-  for (const auto  : loop.m_signals) {
+  std::vector signals;
+  for (const auto  : loop.m_signals)
+if (g_signal_flags[entry.first] != 0)
+  signals.push_back(entry.first);
+
+  for (const auto  : signals) {
 if (loop.m_terminate_request)
   return;
-if (g_signal_flags[entry.first] == 0)
-  continue; // No signal
-g_signal_flags[entry.first] = 0;
-loop.ProcessSignal(entry.first);
+g_signal_flags[signal] = 0;
+loop.ProcessSignal(signal);
   }
 }
 #endif
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D35740: Fix PR33875 by distinguishing between DWO and clang modules

2017-07-23 Thread Phabricator via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL308850: Fix PR33875 by distinguishing between DWO and clang 
modules (authored by adrian).

Changed prior to commit:
  https://reviews.llvm.org/D35740?vs=107734=107836#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D35740

Files:
  
lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/gmodules/TestWithModuleDebugging.py
  lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.cpp


Index: lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.cpp
===
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.cpp
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.cpp
@@ -61,6 +61,12 @@
 }
 
 DWARFCompileUnit *SymbolFileDWARFDwo::GetCompileUnit() {
+  // A clang module is found via a skeleton CU, but is not a proper DWO.
+  // Clang modules have a .debug_info section instead of the *_dwo variant.
+  if (auto *section_list = m_obj_file->GetSectionList(false))
+if (section_list->FindSectionByType(eSectionTypeDWARFDebugInfo, true))
+  return nullptr;
+
   // Only dwo files with 1 compile unit is supported
   if (GetNumCompileUnits() == 1)
 return DebugInfo()->GetCompileUnitAtIndex(0);
Index: 
lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/gmodules/TestWithModuleDebugging.py
===
--- 
lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/gmodules/TestWithModuleDebugging.py
+++ 
lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/gmodules/TestWithModuleDebugging.py
@@ -9,8 +9,6 @@
 
 mydir = TestBase.compute_mydir(__file__)
 
-@expectedFailureAll(bugnumber="llvm.org/pr33875", oslist=["linux"],
-compiler="clang", compiler_version=[">", "6.0"])
 @add_test_categories(["gmodules"])
 def test_specialized_typedef_from_pch(self):
 self.build()


Index: lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.cpp
===
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.cpp
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.cpp
@@ -61,6 +61,12 @@
 }
 
 DWARFCompileUnit *SymbolFileDWARFDwo::GetCompileUnit() {
+  // A clang module is found via a skeleton CU, but is not a proper DWO.
+  // Clang modules have a .debug_info section instead of the *_dwo variant.
+  if (auto *section_list = m_obj_file->GetSectionList(false))
+if (section_list->FindSectionByType(eSectionTypeDWARFDebugInfo, true))
+  return nullptr;
+
   // Only dwo files with 1 compile unit is supported
   if (GetNumCompileUnits() == 1)
 return DebugInfo()->GetCompileUnitAtIndex(0);
Index: lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/gmodules/TestWithModuleDebugging.py
===
--- lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/gmodules/TestWithModuleDebugging.py
+++ lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/gmodules/TestWithModuleDebugging.py
@@ -9,8 +9,6 @@
 
 mydir = TestBase.compute_mydir(__file__)
 
-@expectedFailureAll(bugnumber="llvm.org/pr33875", oslist=["linux"],
-compiler="clang", compiler_version=[">", "6.0"])
 @add_test_categories(["gmodules"])
 def test_specialized_typedef_from_pch(self):
 self.build()
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D35734: Don't allow LLDB to try and parse .debug_types

2017-07-24 Thread Phabricator via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL308911: Don't allow .debug_types to be parsed as LLDB can 
crash when enums are not able… (authored by gclayton).

Changed prior to commit:
  https://reviews.llvm.org/D35734?vs=107710=107936#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D35734

Files:
  lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp


Index: lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
===
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
@@ -497,6 +497,21 @@
 if (section_list == NULL)
   return 0;
 
+// On non Apple platforms we might have .debug_types debug info that
+// is created by using "-fdebug-types-section". LLDB currently will try
+// to load this debug info, but it causes crashes during debugging when
+// types are missing since it doesn't know how to parse the info in
+// the .debug_types type units. This causes all complex debug info
+// types to be unresolved. Because this causes LLDB to crash and since
+// it really doesn't provide a solid debuggiung experience, we should
+// disable trying to debug this kind of DWARF until support gets
+// added or deprecated.
+if (section_list->FindSectionByName(ConstString(".debug_types"))) {
+  m_obj_file->GetModule()->ReportWarning(
+"lldb doesn’t support .debug_types debug info");
+  return 0;
+}
+
 uint64_t debug_abbrev_file_size = 0;
 uint64_t debug_info_file_size = 0;
 uint64_t debug_line_file_size = 0;


Index: lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
===
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
@@ -497,6 +497,21 @@
 if (section_list == NULL)
   return 0;
 
+// On non Apple platforms we might have .debug_types debug info that
+// is created by using "-fdebug-types-section". LLDB currently will try
+// to load this debug info, but it causes crashes during debugging when
+// types are missing since it doesn't know how to parse the info in
+// the .debug_types type units. This causes all complex debug info
+// types to be unresolved. Because this causes LLDB to crash and since
+// it really doesn't provide a solid debuggiung experience, we should
+// disable trying to debug this kind of DWARF until support gets
+// added or deprecated.
+if (section_list->FindSectionByName(ConstString(".debug_types"))) {
+  m_obj_file->GetModule()->ReportWarning(
+"lldb doesn’t support .debug_types debug info");
+  return 0;
+}
+
 uint64_t debug_abbrev_file_size = 0;
 uint64_t debug_info_file_size = 0;
 uint64_t debug_line_file_size = 0;
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D34322: [lldb] Correctly escape newlines and backslashes in the JSON serializer

2017-08-22 Thread Phabricator via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL311483: [lldb] Correctly escape newlines and backslashes in 
the JSON serializer (authored by kuba.brecka).

Changed prior to commit:
  https://reviews.llvm.org/D34322?vs=102950=112206#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D34322

Files:
  lldb/trunk/lldb.xcodeproj/project.pbxproj
  lldb/trunk/source/Utility/JSON.cpp
  lldb/trunk/unittests/Utility/CMakeLists.txt
  lldb/trunk/unittests/Utility/JSONTest.cpp

Index: lldb/trunk/lldb.xcodeproj/project.pbxproj
===
--- lldb/trunk/lldb.xcodeproj/project.pbxproj
+++ lldb/trunk/lldb.xcodeproj/project.pbxproj
@@ -768,6 +768,7 @@
 		8C26C4261C3EA5F90031DF7C /* TSanRuntime.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 8C26C4241C3EA4340031DF7C /* TSanRuntime.cpp */; };
 		8C2D6A53197A1EAF006989C9 /* MemoryHistory.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 8C2D6A52197A1EAF006989C9 /* MemoryHistory.cpp */; };
 		8C2D6A5E197A250F006989C9 /* MemoryHistoryASan.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 8C2D6A5A197A1FDC006989C9 /* MemoryHistoryASan.cpp */; };
+		8C3BD9A01EF5D1FF0016C343 /* JSONTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 8C3BD99F1EF5D1B50016C343 /* JSONTest.cpp */; };
 		8C3BD9961EF45DA50016C343 /* MainThreadCheckerRuntime.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 8C3BD9951EF45D9B0016C343 /* MainThreadCheckerRuntime.cpp */; };
 		8CCB017E19BA28A80009FD44 /* ThreadCollection.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 8CCB017A19BA283D0009FD44 /* ThreadCollection.cpp */; };
 		8CCB018219BA4E270009FD44 /* SBThreadCollection.h in Headers */ = {isa = PBXBuildFile; fileRef = 8CCB018119BA4E210009FD44 /* SBThreadCollection.h */; settings = {ATTRIBUTES = (Public, ); }; };
@@ -2653,6 +2654,7 @@
 		8C2D6A54197A1EBE006989C9 /* MemoryHistory.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = MemoryHistory.h; path = include/lldb/Target/MemoryHistory.h; sourceTree = ""; };
 		8C2D6A5A197A1FDC006989C9 /* MemoryHistoryASan.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MemoryHistoryASan.cpp; sourceTree = ""; };
 		8C2D6A5B197A1FDC006989C9 /* MemoryHistoryASan.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MemoryHistoryASan.h; sourceTree = ""; };
+		8C3BD99F1EF5D1B50016C343 /* JSONTest.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = JSONTest.cpp; sourceTree = ""; };
 		8C3BD9931EF45D9B0016C343 /* MainThreadCheckerRuntime.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MainThreadCheckerRuntime.h; sourceTree = ""; };
 		8C3BD9951EF45D9B0016C343 /* MainThreadCheckerRuntime.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = MainThreadCheckerRuntime.cpp; sourceTree = ""; };
 		8CCB017A19BA283D0009FD44 /* ThreadCollection.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ThreadCollection.cpp; path = source/Target/ThreadCollection.cpp; sourceTree = ""; };
@@ -3392,6 +3394,7 @@
 23CB15041D66CD9200EDDDE1 /* Inputs */,
 2321F9441BDD346100BA9A93 /* StringExtractorTest.cpp */,
 2321F9451BDD346100BA9A93 /* TaskPoolTest.cpp */,
+8C3BD99F1EF5D1B50016C343 /* JSONTest.cpp */,
 2321F9461BDD346100BA9A93 /* UriParserTest.cpp */,
 			);
 			path = Utility;
@@ -7177,6 +7180,7 @@
 9A2057121F3B824B00F6C293 /* SymbolFileDWARFTests.cpp in Sources */,
 9A20573A1F3B8E7E00F6C293 /* MainLoopTest.cpp in Sources */,
 23CB15351D66DA9300EDDDE1 /* UriParserTest.cpp in Sources */,
+8C3BD9A01EF5D1FF0016C343 /* JSONTest.cpp in Sources */,
 23CB15361D66DA9300EDDDE1 /* FileSpecTest.cpp in Sources */,
 23E2E5251D90373D006F38BB /* ArchSpecTest.cpp in Sources */,
 9A2057081F3B819100F6C293 /* MemoryRegionInfoTest.cpp in Sources */,
Index: lldb/trunk/unittests/Utility/JSONTest.cpp
===
--- lldb/trunk/unittests/Utility/JSONTest.cpp
+++ lldb/trunk/unittests/Utility/JSONTest.cpp
@@ -0,0 +1,26 @@
+#include "gtest/gtest.h"
+
+#include "lldb/Core/StreamString.h"
+#include "lldb/Utility/JSON.h"
+
+using namespace lldb_private;
+
+TEST(JSONTest, Dictionary) {
+  JSONObject o;
+  o.SetObject("key", std::make_shared("value"));
+
+  StreamString stream;
+  o.Write(stream);
+
+  ASSERT_EQ(stream.GetString(), R"({"key":"value"})");
+}
+
+TEST(JSONTest, Newlines) {
+  JSONObject o;
+  o.SetObject("key", std::make_shared("hello\nworld"));
+
+  StreamString stream;
+  o.Write(stream);
+
+  ASSERT_EQ(stream.GetString(), R"({"key":"hello\nworld"})");
+}
Index: lldb/trunk/unittests/Utility/CMakeLists.txt
===
--- lldb/trunk/unittests/Utility/CMakeLists.txt
+++ 

[Lldb-commits] [PATCH] D38328: Assume git-generated patch files in build scripts

2017-09-27 Thread Phabricator via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL314366: Change build-llvm.py and build-lldb-llvm-clang's 
patching mechanisms to (authored by jmolenda).

Repository:
  rL LLVM

https://reviews.llvm.org/D38328

Files:
  lldb/trunk/scripts/Xcode/build-llvm.py
  lldb/trunk/scripts/build-lldb-llvm-clang


Index: lldb/trunk/scripts/build-lldb-llvm-clang
===
--- lldb/trunk/scripts/build-lldb-llvm-clang
+++ lldb/trunk/scripts/build-lldb-llvm-clang
@@ -33,15 +33,15 @@
 for patch_file in ../scripts/llvm.*.diff
 do
echo "Applying patch from '$patch_file'"
-patch -p0 < "$patch_file"
+patch -p1 < "$patch_file"
 done
 
 # change directory to "./llvm/tools/clang"
 cd tools/clang
 for patch_file in ../../../scripts/clang.*.diff
 do
echo "Applying patch from '$patch_file'"
-patch -p0 < "$patch_file"
+patch -p1 < "$patch_file"
 done
 
 # change directory to "./"
Index: lldb/trunk/scripts/Xcode/build-llvm.py
===
--- lldb/trunk/scripts/Xcode/build-llvm.py
+++ lldb/trunk/scripts/Xcode/build-llvm.py
@@ -224,7 +224,7 @@
 f, spec['name'] + '.*.diff')]
 for p in patches:
 run_in_directory(["patch",
-  "-p0",
+  "-p1",
   "-i",
   os.path.join(lldb_source_path(),
'scripts',


Index: lldb/trunk/scripts/build-lldb-llvm-clang
===
--- lldb/trunk/scripts/build-lldb-llvm-clang
+++ lldb/trunk/scripts/build-lldb-llvm-clang
@@ -33,15 +33,15 @@
 for patch_file in ../scripts/llvm.*.diff
 do
 	echo "Applying patch from '$patch_file'"
-patch -p0 < "$patch_file"
+patch -p1 < "$patch_file"
 done
 
 # change directory to "./llvm/tools/clang"
 cd tools/clang
 for patch_file in ../../../scripts/clang.*.diff
 do
 	echo "Applying patch from '$patch_file'"
-patch -p0 < "$patch_file"
+patch -p1 < "$patch_file"
 done
 
 # change directory to "./"
Index: lldb/trunk/scripts/Xcode/build-llvm.py
===
--- lldb/trunk/scripts/Xcode/build-llvm.py
+++ lldb/trunk/scripts/Xcode/build-llvm.py
@@ -224,7 +224,7 @@
 f, spec['name'] + '.*.diff')]
 for p in patches:
 run_in_directory(["patch",
-  "-p0",
+  "-p1",
   "-i",
   os.path.join(lldb_source_path(),
'scripts',
___
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 ) {
+  if (this == )
+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 ) {
+  if (this == )
+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 ) {
+  if (this == )
+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 ) {
+  if (this == )
+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] 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] 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=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-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=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 = 

[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=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 ) {
-  return ::thread_set_state(tid, flavor, (thread_state_t), GPRWordCount);
+  return ::thread_set_state(
+  tid, flavor, reinterpret_cast(const_cast()),
+  GPRWordCount);
 }
 
 int RegisterContextMach_i386::DoWriteFPU(lldb::tid_t tid, int flavor,
  const FPU ) {
-  return ::thread_set_state(tid, flavor, (thread_state_t), FPUWordCount);
+  return ::thread_set_state(
+  tid, flavor, reinterpret_cast(const_cast()),
+  FPUWordCount);
 }
 
 int RegisterContextMach_i386::DoWriteEXC(lldb::tid_t tid, int flavor,
  const EXC ) {
-  return ::thread_set_state(tid, flavor, (thread_state_t), EXCWordCount);
+  return ::thread_set_state(
+  tid, flavor, reinterpret_cast(const_cast()),
+  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 ) {
-  return ::thread_set_state(tid, flavor, (thread_state_t), GPRWordCount);
+  return ::thread_set_state(
+  tid, flavor, reinterpret_cast(const_cast()),
+  GPRWordCount);
 }
 
 int RegisterContextMach_arm::DoWriteFPU(lldb::tid_t tid, int flavor,
 const FPU ) {
-  return ::thread_set_state(tid, flavor, (thread_state_t), FPUWordCount);
+  return ::thread_set_state(
+  tid, flavor, reinterpret_cast(const_cast()),
+  FPUWordCount);
 }
 
 int RegisterContextMach_arm::DoWriteEXC(lldb::tid_t tid, int flavor,
 const EXC ) {
-  return ::thread_set_state(tid, flavor, (thread_state_t), EXCWordCount);
+  return ::thread_set_state(
+  tid, flavor, reinterpret_cast(const_cast()),
+  EXCWordCount);
 }
 
 int RegisterContextMach_arm::DoWriteDBG(lldb::tid_t tid, int flavor,
 const DBG ) {
-  return ::thread_set_state(tid, flavor, (thread_state_t), DBGWordCount);
+  return ::thread_set_state(
+  tid, flavor, reinterpret_cast(const_cast()),
+  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 ) {
-  return ::thread_set_state(tid, flavor, (thread_state_t), GPRWordCount);
+  return ::thread_set_state(
+  tid, flavor, reinterpret_cast(const_cast()),
+  GPRWordCount);
 }
 
 int RegisterContextMach_x86_64::DoWriteFPU(lldb::tid_t tid, int flavor,
const FPU ) {
-  return ::thread_set_state(tid, flavor, (thread_state_t), FPUWordCount);
+  return ::thread_set_state(
+  tid, flavor, reinterpret_cast(const_cast()),
+  FPUWordCount);
 }
 
 int RegisterContextMach_x86_64::DoWriteEXC(lldb::tid_t tid, int flavor,
const EXC ) {
-  return ::thread_set_state(tid, flavor, (thread_state_t), EXCWordCount);
+  return ::thread_set_state(
+  tid, flavor, reinterpret_cast(const_cast()),
+  EXCWordCount);
 }
 
 #endif
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D46606: General cleanup to minimize the .debug_types patch

2018-05-09 Thread Phabricator via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL331892: General cleanup to minimize the .debug_types patch 
(authored by gclayton, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D46606?vs=145926=145946#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D46606

Files:
  lldb/trunk/include/lldb/lldb-forward.h
  lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
  lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFASTParserGo.cpp
  lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFAttribute.cpp
  lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp
  lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.h
  lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDIE.cpp
  lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDIE.h
  lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDataExtractor.cpp
  lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDataExtractor.h
  lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp
  lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.h
  lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp
  lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
  lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFUnit.h
  lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp

Index: lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
===
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
@@ -3758,7 +3758,7 @@
   location_is_const_value_data = true;
   // The constant value will be either a block, a data value or a
   // string.
-  const DWARFDataExtractor _info_data = get_debug_info_data();
+  auto debug_info_data = die.GetData();
   if (DWARFFormValue::IsBlockForm(form_value.Form())) {
 // Retrieve the value as a block expression.
 uint32_t block_offset =
@@ -3815,13 +3815,12 @@
 location_is_const_value_data = false;
 has_explicit_location = true;
 if (DWARFFormValue::IsBlockForm(form_value.Form())) {
-  const DWARFDataExtractor _info_data = get_debug_info_data();
+  auto data = die.GetData();
 
   uint32_t block_offset =
-  form_value.BlockData() - debug_info_data.GetDataStart();
+  form_value.BlockData() - data.GetDataStart();
   uint32_t block_length = form_value.Unsigned();
-  location.CopyOpcodeData(module, get_debug_info_data(),
-  block_offset, block_length);
+  location.CopyOpcodeData(module, data, block_offset, block_length);
 } else {
   const DWARFDataExtractor _loc_data = get_debug_loc_data();
   const dw_offset_t debug_loc_offset = form_value.Unsigned();
Index: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp
===
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp
@@ -20,14 +20,10 @@
 : DWARFUnit(dwarf2Data) {}
 
 DWARFUnitSP DWARFCompileUnit::Extract(SymbolFileDWARF *dwarf2Data,
-lldb::offset_t *offset_ptr) {
+  const DWARFDataExtractor _info,
+  lldb::offset_t *offset_ptr) {
   // std::make_shared would require the ctor to be public.
   std::shared_ptr cu_sp(new DWARFCompileUnit(dwarf2Data));
-  // Out of memory?
-  if (cu_sp.get() == NULL)
-return nullptr;
-
-  const DWARFDataExtractor _info = dwarf2Data->get_debug_info_data();
 
   cu_sp->m_offset = *offset_ptr;
 
@@ -67,3 +63,8 @@
 m_offset, m_length, m_version, GetAbbrevOffset(), m_addr_size,
 GetNextCompileUnitOffset());
 }
+
+
+const lldb_private::DWARFDataExtractor ::GetData() const {
+  return m_dwarf->get_debug_info_data();
+}
Index: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.h
===
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.h
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.h
@@ -44,13 +44,6 @@
   DWARFDIE GetDIEForDIEOffset(dw_offset_t die_offset);
   DWARFDIE GetDIE(const DIERef _ref);
 
-  void Dump(lldb_private::Stream *s, const uint32_t die_offset,
-const uint32_t recurse_depth);
-  static void Parse(SymbolFileDWARF *parser, Callback callback, void *userData);
-  static void Verify(lldb_private::Stream *s, SymbolFileDWARF *dwarf2Data);
-  static void Dump(lldb_private::Stream *s, SymbolFileDWARF *dwarf2Data,
-   const uint32_t die_offset, const uint32_t recurse_depth);
-
   enum {

[Lldb-commits] [PATCH] D45977: Always normalize FileSpec paths.

2018-04-27 Thread Phabricator via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL331049: Always normalize FileSpec paths. (authored by 
gclayton, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D45977?vs=144021=144353#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D45977

Files:
  lldb/trunk/include/lldb/Core/FileSpecList.h
  lldb/trunk/include/lldb/Utility/FileSpec.h
  lldb/trunk/source/Breakpoint/BreakpointResolverFileLine.cpp
  lldb/trunk/source/Core/FileSpecList.cpp
  lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
  lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugLine.cpp
  lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugLine.h
  lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
  lldb/trunk/source/Symbol/CompileUnit.cpp
  lldb/trunk/source/Symbol/Declaration.cpp
  lldb/trunk/source/Utility/FileSpec.cpp
  lldb/trunk/unittests/Utility/FileSpecTest.cpp

Index: lldb/trunk/include/lldb/Utility/FileSpec.h
===
--- lldb/trunk/include/lldb/Utility/FileSpec.h
+++ lldb/trunk/include/lldb/Utility/FileSpec.h
@@ -256,8 +256,7 @@
   //--
   static int Compare(const FileSpec , const FileSpec , bool full);
 
-  static bool Equal(const FileSpec , const FileSpec , bool full,
-bool remove_backups = false);
+  static bool Equal(const FileSpec , const FileSpec , bool full);
 
   //--
   /// Case sensitivity of path.
@@ -488,12 +487,6 @@
   size_t MemorySize() const;
 
   //--
-  /// Normalize a pathname by collapsing redundant separators and
-  /// up-level references.
-  //--
-  FileSpec GetNormalizedPath() const;
-
-  //--
   /// Change the file specified with a new path.
   ///
   /// Update the contents of this object with a new path. The path will
Index: lldb/trunk/include/lldb/Core/FileSpecList.h
===
--- lldb/trunk/include/lldb/Core/FileSpecList.h
+++ lldb/trunk/include/lldb/Core/FileSpecList.h
@@ -119,16 +119,11 @@
   /// @param[in] full
   /// Should FileSpec::Equal be called with "full" true or false.
   ///
-  /// @param[in] remove_backup_dots
-  /// Should FileSpec::Equal be called with "remove_backup_dots" true or
-  /// false.
-  ///
   /// @return
   /// The index of the file that matches \a file if it is found,
   /// else UINT32_MAX is returned.
   //--
-  size_t FindFileIndex(size_t idx, const FileSpec , bool full,
-   bool remove_backup_dots = false) const;
+  size_t FindFileIndex(size_t idx, const FileSpec , bool full) const;
 
   //--
   /// Get file at index.
Index: lldb/trunk/unittests/Utility/FileSpecTest.cpp
===
--- lldb/trunk/unittests/Utility/FileSpecTest.cpp
+++ lldb/trunk/unittests/Utility/FileSpecTest.cpp
@@ -54,17 +54,14 @@
 
   FileSpec fs_posix_trailing_slash("/foo/bar/", false,
FileSpec::ePathSyntaxPosix);
-  EXPECT_STREQ("/foo/bar/.", fs_posix_trailing_slash.GetCString());
-  EXPECT_STREQ("/foo/bar", fs_posix_trailing_slash.GetDirectory().GetCString());
-  EXPECT_STREQ(".", fs_posix_trailing_slash.GetFilename().GetCString());
+  EXPECT_STREQ("/foo/bar", fs_posix_trailing_slash.GetCString());
+  EXPECT_STREQ("/foo", fs_posix_trailing_slash.GetDirectory().GetCString());
+  EXPECT_STREQ("bar", fs_posix_trailing_slash.GetFilename().GetCString());
 
   FileSpec fs_windows_trailing_slash("F:\\bar\\", false,
  FileSpec::ePathSyntaxWindows);
-  EXPECT_STREQ("F:\\bar\\.", fs_windows_trailing_slash.GetCString());
-  // EXPECT_STREQ("F:\\bar",
-  // fs_windows_trailing_slash.GetDirectory().GetCString()); // It returns
-  // "F:/bar"
-  EXPECT_STREQ(".", fs_windows_trailing_slash.GetFilename().GetCString());
+  EXPECT_STREQ("F:\\bar", fs_windows_trailing_slash.GetCString());
+  EXPECT_STREQ("bar", fs_windows_trailing_slash.GetFilename().GetCString());
 }
 
 TEST(FileSpecTest, AppendPathComponent) {
@@ -131,32 +128,13 @@
   EXPECT_STREQ("F:\\bar", fs_windows_root.GetCString());
 }
 
-static void Compare(const FileSpec , const FileSpec , bool full_match,
-bool remove_backup_dots, bool result) {
-  EXPECT_EQ(result, FileSpec::Equal(one, two, full_match, remove_backup_dots))
-  << "File one: " << one.GetCString() << "\nFile two: " << two.GetCString()
-  << "\nFull match: " << full_match
-  << 

[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=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 _spec);
   static bool ComputePythonDirectory(FileSpec _spec);
   static bool ComputeClangDirectory(FileSpec _spec);
+  static bool ComputeClangDirectory(FileSpec _shlib_spec,
+FileSpec _spec, bool verify);
   static bool ComputeSystemPluginsDirectory(FileSpec _spec);
   static bool ComputeUserPluginsDirectory(FileSpec _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 _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 _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();
+bool 

[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 files triple. (authored by adrian, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D46669?vs=146235=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
+

[Lldb-commits] [PATCH] D46529: Add support to object files for accessing the .debug_types section

2018-05-08 Thread Phabricator via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL331777: Add support to object files for accessing the 
.debug_types section (authored by gclayton, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D46529?vs=145715=145723#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D46529

Files:
  lldb/trunk/include/lldb/lldb-enumerations.h
  lldb/trunk/lit/Modules/elf-section-types.yaml
  lldb/trunk/source/Core/Section.cpp
  lldb/trunk/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
  lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
  lldb/trunk/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
  lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
  lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
  lldb/trunk/source/Symbol/ObjectFile.cpp

Index: lldb/trunk/source/Core/Section.cpp
===
--- lldb/trunk/source/Core/Section.cpp
+++ lldb/trunk/source/Core/Section.cpp
@@ -89,6 +89,8 @@
 return "dwarf-str";
   case eSectionTypeDWARFDebugStrOffsets:
 return "dwarf-str-offsets";
+  case eSectionTypeDWARFDebugTypes:
+return "dwarf-types";
   case eSectionTypeELFSymbolTable:
 return "elf-symbol-table";
   case eSectionTypeELFDynamicSymbols:
Index: lldb/trunk/source/Symbol/ObjectFile.cpp
===
--- lldb/trunk/source/Symbol/ObjectFile.cpp
+++ lldb/trunk/source/Symbol/ObjectFile.cpp
@@ -359,6 +359,7 @@
   case eSectionTypeDWARFDebugRanges:
   case eSectionTypeDWARFDebugStr:
   case eSectionTypeDWARFDebugStrOffsets:
+  case eSectionTypeDWARFDebugTypes:
   case eSectionTypeDWARFAppleNames:
   case eSectionTypeDWARFAppleTypes:
   case eSectionTypeDWARFAppleNamespaces:
Index: lldb/trunk/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
===
--- lldb/trunk/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
+++ lldb/trunk/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
@@ -1806,6 +1806,7 @@
   static ConstString g_sect_name_dwarf_debug_str_dwo(".debug_str.dwo");
   static ConstString g_sect_name_dwarf_debug_str_offsets_dwo(
   ".debug_str_offsets.dwo");
+  static ConstString g_sect_name_dwarf_debug_types(".debug_types");
   static ConstString g_sect_name_eh_frame(".eh_frame");
   static ConstString g_sect_name_arm_exidx(".ARM.exidx");
   static ConstString g_sect_name_arm_extab(".ARM.extab");
@@ -1873,6 +1874,8 @@
 sect_type = eSectionTypeDWARFDebugRanges;
   else if (name == g_sect_name_dwarf_debug_str)
 sect_type = eSectionTypeDWARFDebugStr;
+  else if (name == g_sect_name_dwarf_debug_types)
+sect_type = eSectionTypeDWARFDebugTypes;
   else if (name == g_sect_name_dwarf_debug_str_offsets)
 sect_type = eSectionTypeDWARFDebugStrOffsets;
   else if (name == g_sect_name_dwarf_debug_abbrev_dwo)
Index: lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
===
--- lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
+++ lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
@@ -1205,6 +1205,7 @@
   case eSectionTypeDWARFDebugRanges:
   case eSectionTypeDWARFDebugStr:
   case eSectionTypeDWARFDebugStrOffsets:
+  case eSectionTypeDWARFDebugTypes:
   case eSectionTypeDWARFAppleNames:
   case eSectionTypeDWARFAppleTypes:
   case eSectionTypeDWARFAppleNamespaces:
@@ -1458,6 +1459,7 @@
   static ConstString g_sect_name_dwarf_debug_pubtypes("__debug_pubtypes");
   static ConstString g_sect_name_dwarf_debug_ranges("__debug_ranges");
   static ConstString g_sect_name_dwarf_debug_str("__debug_str");
+  static ConstString g_sect_name_dwarf_debug_types("__debug_types");
   static ConstString g_sect_name_dwarf_apple_names("__apple_names");
   static ConstString g_sect_name_dwarf_apple_types("__apple_types");
   static ConstString g_sect_name_dwarf_apple_namespaces("__apple_namespac");
@@ -1490,6 +1492,8 @@
 return eSectionTypeDWARFDebugRanges;
   if (section_name == g_sect_name_dwarf_debug_str)
 return eSectionTypeDWARFDebugStr;
+  if (section_name == g_sect_name_dwarf_debug_types)
+return eSectionTypeDWARFDebugTypes;
   if (section_name == g_sect_name_dwarf_apple_names)
 return eSectionTypeDWARFAppleNames;
   if (section_name == g_sect_name_dwarf_apple_types)
Index: lldb/trunk/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
===
--- lldb/trunk/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
+++ lldb/trunk/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
@@ -696,6 +696,7 @@
 static ConstString 

[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=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 ) {
+// 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 ,
  const ConstString , 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 ,
 ConstString _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.GetStringRef(), remapped)) {
+

[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=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 

[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=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 ) {
+PlatformDarwinKernel::SearchForExecutablesRecursively(const std::string ) {
   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 _bundle_path, const lldb_private::UUID ,
 const ArchSpec , ModuleSP _module_sp) {
   for (const auto _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 );
+  SearchForExecutablesRecursively(const std::string );
 
   static void AddKextToMap(PlatformDarwinKernel *thisp,
const lldb_private::FileSpec _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 ) {
+PlatformDarwinKernel::SearchForExecutablesRecursively(const std::string ) {
   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 _bundle_path, const lldb_private::UUID ,
 const ArchSpec , ModuleSP _module_sp) {
   for (const auto _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 );
+  SearchForExecutablesRecursively(const std::string );
 
   static void AddKextToMap(PlatformDarwinKernel *thisp,
const lldb_private::FileSpec _spec);
___
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 JITs 
IRMemoryMap (authored by vedantk, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D47508?vs=149173=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 , const std::string );
+
+/// Read \p Filename into a null-terminated buffer, or abort.
+std::unique_ptr openFile(const std::string );
 
 namespace breakpoint {
 static cl::opt Target(cl::Positional, cl::desc(""),
@@ -135,8 +150,49 @@
 
 static int dumpSymbols(Debugger );
 }
+
+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 , const AllocationT );
+using AddrIntervalMap =
+  IntervalMap>;
+bool evalMalloc(IRMemoryMap , StringRef Line,
+AddrIntervalMap );
+int evaluateMemoryMapCommands(Debugger );
+} // namespace irmemorymap
+
 } // namespace opts
 
+TargetSP opts::createTarget(Debugger , const std::string ) {
+  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 ) {
+  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 , LinePrinter ) {
   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 ) {
-  TargetSP Target;
-  Status ST =
-  Dbg.GetTargetList().CreateTarget(Dbg, breakpoint::Target, /*triple*/ "",
-   /*get_dependent_modules*/ false,
-   /*platform_options*/ nullptr, Target);
-  if (ST.Fail()) {
-errs() << formatv("Failed to create target 

[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] 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=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 (
   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 (
   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] 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=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] 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=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] 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=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 , const AllocationT );
 using AddrIntervalMap =
   IntervalMap>;
-bool evalMalloc(IRMemoryMap , StringRef Line,
-AddrIntervalMap );
-bool evalFree(IRMemoryMap , StringRef Line,
-  AddrIntervalMap );
+
+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 , const AllocationT );
+bool evalMalloc(StringRef Line, IRMemoryMapTestState );
+bool evalFree(StringRef Line, IRMemoryMapTestState );
 int evaluateMemoryMapCommands(Debugger );
 } // namespace irmemorymap
 
@@ -514,17 +526,23 @@
   return R.first < L.second && L.first < R.second;
 }
 
-bool opts::irmemorymap::evalMalloc(IRMemoryMap , StringRef Line,
-   AddrIntervalMap ) {
-  // ::= malloc  
+bool opts::irmemorymap::evalMalloc(StringRef Line,
+   IRMemoryMapTestState ) {
+  // ::=  = 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", , );
   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 , StringRef Line,
- AddrIntervalMap ) {
-  // ::= free 
-  size_t AllocIndex;
-  int Matches = sscanf(Line.data(), "free %zu", );
-  if (Matches != 1)
+bool opts::irmemorymap::evalFree(StringRef Line, IRMemoryMapTestState ) {
+  // ::= 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 && Probe != AllocatedIntervals.end(); ++I)
-++Probe;
-
-  if (Probe == AllocatedIntervals.end()) {
-outs() << "Free error: Invalid allocation index\n";
+  outs() << 

[Lldb-commits] [PATCH] D46220: Remove premature caching of the global variables list in CompileUnit.

2018-04-30 Thread Phabricator via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL331230: Remove premature caching of the global variables 
list in CompileUnit. (authored by adrian, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D46220?vs=144418=144642#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D46220

Files:
  
lldb/trunk/packages/Python/lldbsuite/test/lang/c/global_variables/TestGlobalVariables.py
  lldb/trunk/packages/Python/lldbsuite/test/lang/c/global_variables/main.c
  lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp


Index: lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
===
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
@@ -4194,7 +4194,6 @@
   variable_list_sp = sc.comp_unit->GetVariableList(false);
   if (variable_list_sp.get() == NULL) {
 variable_list_sp.reset(new VariableList());
-sc.comp_unit->SetVariableList(variable_list_sp);
   }
 } else {
   GetObjectFile()->GetModule()->ReportError(
Index: 
lldb/trunk/packages/Python/lldbsuite/test/lang/c/global_variables/TestGlobalVariables.py
===
--- 
lldb/trunk/packages/Python/lldbsuite/test/lang/c/global_variables/TestGlobalVariables.py
+++ 
lldb/trunk/packages/Python/lldbsuite/test/lang/c/global_variables/TestGlobalVariables.py
@@ -39,6 +39,12 @@
 environment = self.registerSharedLibrariesWithTarget(
 target, self.shlib_names)
 
+# Test that static initialized variables can be inspected without 
process.
+self.expect("target variable g_ptr", VARIABLES_DISPLAYED_CORRECTLY,
+substrs=['(int *)'])
+self.expect("target variable *g_ptr", VARIABLES_DISPLAYED_CORRECTLY,
+substrs=['42'])
+
 # Now launch the process, and do not stop at entry point.
 process = target.LaunchSimple(
 None, environment, self.get_process_working_directory())
@@ -54,17 +60,21 @@
 substrs=[' resolved, hit count = 1'])
 
 # Check that GLOBAL scopes are indicated for the variables.
+self.runCmd("frame variable --show-types --scope --show-globals 
--no-args")
 self.expect(
 "frame variable --show-types --scope --show-globals --no-args",
 VARIABLES_DISPLAYED_CORRECTLY,
 substrs=[
-'GLOBAL: (int) g_file_global_int = 42',
 'STATIC: (const int) g_file_static_int = 2',
+'STATIC: (const char *) g_func_static_cstr',
 'GLOBAL: (const char *) g_file_global_cstr',
 '"g_file_global_cstr"',
+'GLOBAL: (int) g_file_global_int = 42',
+'GLOBAL: (int) g_common_1 = 21',
+'GLOBAL: (int *) g_ptr',
 'STATIC: (const char *) g_file_static_cstr',
-'"g_file_static_cstr"',
-'GLOBAL: (int) g_common_1 = 21'])
+'"g_file_static_cstr"'
+])
 
 # 'frame variable' should support address-of operator.
 self.runCmd("frame variable _file_global_int")
@@ -95,3 +105,8 @@
 VARIABLES_DISPLAYED_CORRECTLY,
 matching=False,
 substrs=["can't be resolved"])
+
+# Test that the statically initialized variable can also be
+# inspected *with* a process.
+self.expect("target variable *g_ptr", VARIABLES_DISPLAYED_CORRECTLY,
+substrs=['42'])
Index: lldb/trunk/packages/Python/lldbsuite/test/lang/c/global_variables/main.c
===
--- lldb/trunk/packages/Python/lldbsuite/test/lang/c/global_variables/main.c
+++ lldb/trunk/packages/Python/lldbsuite/test/lang/c/global_variables/main.c
@@ -13,12 +13,13 @@
 static const int g_file_static_int = 2;
 const char *g_file_global_cstr = "g_file_global_cstr";
 static const char *g_file_static_cstr = "g_file_static_cstr";
+int *g_ptr = _file_global_int;
 
 extern int g_a;
 int main (int argc, char const *argv[])
 {
 g_common_1 = g_file_global_int / g_file_static_int;
 static const char *g_func_static_cstr = "g_func_static_cstr";
 printf ("%s %s\n", g_file_global_cstr, g_file_static_cstr);
-return g_file_global_int + g_a + g_common_1; // Set break point at this 
line.   break $source:$line; continue; var -global g_a -global g_global_int
+return g_file_global_int + g_a + g_common_1 + *g_ptr; // Set break point 
at this line.   break $source:$line; continue; var -global g_a -global 
g_global_int
 }


Index: lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp

[Lldb-commits] [PATCH] D46128: Fix expression parser to not accept any type whose basename matches for a type that must exist at root level

2018-04-30 Thread Phabricator via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL331227: Fix expression parser to not accept any type whose 
basename matches for a type… (authored by gclayton, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D46128?vs=144133=144636#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D46128

Files:
  lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/type_lookup/Makefile
  
lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/type_lookup/TestTypeLookup.py
  lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/type_lookup/main.cpp
  lldb/trunk/source/Core/Module.cpp
  lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp

Index: lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/type_lookup/Makefile
===
--- lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/type_lookup/Makefile
+++ lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/type_lookup/Makefile
@@ -0,0 +1,3 @@
+LEVEL = ../../../make
+C_SOURCES := main.c
+include $(LEVEL)/Makefile.rules
Index: lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/type_lookup/main.cpp
===
--- lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/type_lookup/main.cpp
+++ lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/type_lookup/main.cpp
@@ -0,0 +1,67 @@
+//===-- main.c --*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+// In this test, we define struct that exist might exist at the different
+// levels in the code and test that we can properly locate these types with
+// a varienty of different expressions.
+
+namespace a {
+  struct namespace_only {
+int a;
+  };
+  struct namespace_and_file {
+int aa;
+  };
+  struct contains_type {
+struct in_contains_type {
+  int aaa;
+};
+  };
+};
+namespace b {
+  struct namespace_only {
+int b;
+  };
+  struct namespace_and_file {
+int bb;
+  };
+  struct contains_type {
+struct in_contains_type {
+  int bbb;
+};
+  };
+};
+
+struct namespace_and_file {
+  int ff;
+};
+
+struct contains_type {
+  struct in_contains_type {
+int fff;
+  };
+};
+
+
+int main (int argc, char const *argv[]) {
+  a::namespace_only a_namespace_only = { 1 };
+  a::namespace_and_file a_namespace_and_file = { 2 };
+  a::contains_type::in_contains_type a_in_contains_type = { 3 };
+  b::namespace_only b_namespace_only = { 11 };
+  b::namespace_and_file b_namespace_and_file = { 22 };
+  b::contains_type::in_contains_type b_in_contains_type = { 33 };
+  namespace_and_file file_namespace_and_file = { 44 };
+  contains_type::in_contains_type file_in_contains_type = { 55 };
+  int i = 123; // Provide an integer that can be used for casting
+  // Take address of "i" to ensure it is in memory
+  if ( == ) {
+i = -1;
+  }
+  return i == -1; // Set a breakpoint here
+}
Index: lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/type_lookup/TestTypeLookup.py
===
--- lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/type_lookup/TestTypeLookup.py
+++ lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/type_lookup/TestTypeLookup.py
@@ -0,0 +1,89 @@
+"""
+Test that we can lookup types correctly in the expression parser
+"""
+
+from __future__ import print_function
+
+
+import lldb
+import lldbsuite.test.lldbutil as lldbutil
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import decorators
+
+class TestTypeLookup(TestBase):
+
+mydir = TestBase.compute_mydir(__file__)
+
+def check_value(self, value, ivar_name, ivar_value):
+self.assertTrue(value.GetError().Success(),
+"Invalid valobj: %s" % (
+value.GetError().GetCString()))
+ivar = value.GetChildMemberWithName(ivar_name)
+self.assertTrue(ivar.GetError().Success(),
+"Failed to fetch ivar named '%s'" % (ivar_name))
+self.assertEqual(ivar_value,
+ ivar.GetValueAsSigned(),
+ "Got the right value for ivar")
+
+def test_namespace_only(self):
+"""
+Test that we fail to lookup a struct type that exists only in a
+namespace.
+"""
+self.build()
+self.main_source_file = lldb.SBFileSpec("main.cpp")
+(target, process, thread, bkpt) = lldbutil.run_to_source_breakpoint(
+self, "Set a breakpoint here", self.main_source_file)
+
+# Get frame for current thread
+frame = thread.GetSelectedFrame()
+
+# Make sure we don't accidentally 

[Lldb-commits] [PATCH] D45348: Don't return error for settings set .experimental. settings that are absent

2018-05-01 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 rL331315: Fix the .experimental. settings feature so that we 
dont return an error (authored by jmolenda, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D45348?vs=141473=144807#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D45348

Files:
  lldb/trunk/packages/Python/lldbsuite/test/settings/TestSettings.py
  lldb/trunk/source/Interpreter/OptionValueProperties.cpp


Index: lldb/trunk/packages/Python/lldbsuite/test/settings/TestSettings.py
===
--- lldb/trunk/packages/Python/lldbsuite/test/settings/TestSettings.py
+++ lldb/trunk/packages/Python/lldbsuite/test/settings/TestSettings.py
@@ -524,3 +524,41 @@
  "target.process.extra-startup-command",
  "target.process.thread.step-avoid-regexp",
  "target.process.thread.trace-thread"])
+
+# settings under an ".experimental" domain should have two properties:
+#   1. If the name does not exist with "experimental" in the name path,
+#  the name lookup should try to find it without "experimental".  So
+#  a previously-experimental setting that has been promoted to a 
+#  "real" setting will still be set by the original name.
+#   2. Changing a setting with .experimental., name, where the setting
+#  does not exist either with ".experimental." or without, should
+#  not generate an error.  So if an experimental setting is removed,
+#  people who may have that in their ~/.lldbinit files should not see
+#  any errors.
+def test_experimental_settings(self):
+cmdinterp = self.dbg.GetCommandInterpreter()
+result = lldb.SBCommandReturnObject()
+
+# Set target.arg0 to a known value, check that we can retrieve it via
+# the actual name and via .experimental.
+self.expect('settings set target.arg0 first-value')
+self.expect('settings show target.arg0', substrs=['first-value'])
+self.expect('settings show target.experimental.arg0', 
substrs=['first-value'], error=False)
+
+# Set target.arg0 to a new value via a target.experimental.arg0 name,
+# verify that we can read it back via both .experimental., and not.
+self.expect('settings set target.experimental.arg0 second-value', 
error=False)
+self.expect('settings show target.arg0', substrs=['second-value'])
+self.expect('settings show target.experimental.arg0', 
substrs=['second-value'], error=False)
+
+# showing & setting an undefined .experimental. setting should 
generate no errors.
+self.expect('settings show 
target.experimental.setting-which-does-not-exist', patterns=['^\s$'], 
error=False)
+self.expect('settings set 
target.experimental.setting-which-does-not-exist true', error=False)
+
+# A domain component before .experimental. which does not exist should 
give an error
+# But the code does not yet do that.
+# self.expect('settings set 
target.setting-which-does-not-exist.experimental.arg0 true', error=True)
+
+# finally, confirm that trying to set a setting that does not exist 
still fails.
+# (SHOWING a setting that does not exist does not currently yield an 
error.)
+self.expect('settings set target.setting-which-does-not-exist true', 
error=True)
Index: lldb/trunk/source/Interpreter/OptionValueProperties.cpp
===
--- lldb/trunk/source/Interpreter/OptionValueProperties.cpp
+++ lldb/trunk/source/Interpreter/OptionValueProperties.cpp
@@ -202,12 +202,23 @@
   llvm::StringRef value) {
   Status error;
   const bool will_modify = true;
+  llvm::SmallVector components;
+  name.split(components, '.');
+  bool name_contains_experimental = false;
+  for (const auto  : components)
+if (Properties::IsSettingExperimental(part))
+  name_contains_experimental = true;
+
+  
   lldb::OptionValueSP value_sp(GetSubValue(exe_ctx, name, will_modify, error));
   if (value_sp)
 error = value_sp->SetValueFromString(value, op);
   else {
-if (error.AsCString() == nullptr)
+// Don't set an error if the path contained .experimental. - those are
+// allowed to be missing and should silently fail.
+if (name_contains_experimental == false && error.AsCString() == nullptr) {
   error.SetErrorStringWithFormat("invalid value path '%s'", 
name.str().c_str());
+}
   }
   return error;
 }


Index: lldb/trunk/packages/Python/lldbsuite/test/settings/TestSettings.py
===
--- lldb/trunk/packages/Python/lldbsuite/test/settings/TestSettings.py
+++ 

[Lldb-commits] [PATCH] D46321: Enable AUTOBRIEF in doxygen configuration.

2018-05-02 Thread Phabricator via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL331373: Enable AUTOBRIEF in doxygen configuration. (authored 
by adrian, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D46321?vs=144739=144897#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D46321

Files:
  lldb/trunk/docs/doxygen.cfg.in
  lldb/trunk/include/lldb/Breakpoint/Breakpoint.h
  lldb/trunk/include/lldb/Breakpoint/BreakpointList.h
  lldb/trunk/include/lldb/Breakpoint/BreakpointLocation.h
  lldb/trunk/include/lldb/Breakpoint/BreakpointLocationList.h
  lldb/trunk/include/lldb/Breakpoint/BreakpointOptions.h
  lldb/trunk/include/lldb/Breakpoint/BreakpointResolver.h
  lldb/trunk/include/lldb/Breakpoint/BreakpointResolverAddress.h
  lldb/trunk/include/lldb/Breakpoint/BreakpointResolverFileLine.h
  lldb/trunk/include/lldb/Breakpoint/BreakpointResolverFileRegex.h
  lldb/trunk/include/lldb/Breakpoint/BreakpointResolverName.h
  lldb/trunk/include/lldb/Breakpoint/BreakpointSite.h
  lldb/trunk/include/lldb/Breakpoint/BreakpointSiteList.h
  lldb/trunk/include/lldb/Breakpoint/StoppointCallbackContext.h
  lldb/trunk/include/lldb/Breakpoint/WatchpointList.h
  lldb/trunk/include/lldb/Breakpoint/WatchpointOptions.h
  lldb/trunk/include/lldb/Core/Address.h
  lldb/trunk/include/lldb/Core/AddressRange.h
  lldb/trunk/include/lldb/Core/AddressResolver.h
  lldb/trunk/include/lldb/Core/AddressResolverFileLine.h
  lldb/trunk/include/lldb/Core/AddressResolverName.h
  lldb/trunk/include/lldb/Core/Broadcaster.h
  lldb/trunk/include/lldb/Core/Communication.h
  lldb/trunk/include/lldb/Core/Debugger.h
  lldb/trunk/include/lldb/Core/EmulateInstruction.h
  lldb/trunk/include/lldb/Core/FileLineResolver.h
  lldb/trunk/include/lldb/Core/FileSpecList.h
  lldb/trunk/include/lldb/Core/Mangled.h
  lldb/trunk/include/lldb/Core/Module.h
  lldb/trunk/include/lldb/Core/ModuleChild.h
  lldb/trunk/include/lldb/Core/ModuleList.h
  lldb/trunk/include/lldb/Core/SearchFilter.h
  lldb/trunk/include/lldb/Expression/DWARFExpression.h
  lldb/trunk/include/lldb/Expression/Expression.h
  lldb/trunk/include/lldb/Expression/ExpressionParser.h
  lldb/trunk/include/lldb/Expression/ExpressionTypeSystemHelper.h
  lldb/trunk/include/lldb/Expression/ExpressionVariable.h
  lldb/trunk/include/lldb/Expression/FunctionCaller.h
  lldb/trunk/include/lldb/Expression/IRDynamicChecks.h
  lldb/trunk/include/lldb/Expression/IRExecutionUnit.h
  lldb/trunk/include/lldb/Expression/IRInterpreter.h
  lldb/trunk/include/lldb/Expression/IRMemoryMap.h
  lldb/trunk/include/lldb/Expression/LLVMUserExpression.h
  lldb/trunk/include/lldb/Expression/UserExpression.h
  lldb/trunk/include/lldb/Expression/UtilityFunction.h
  lldb/trunk/include/lldb/Host/File.h
  lldb/trunk/include/lldb/Host/Host.h
  lldb/trunk/include/lldb/Host/HostInfo.h
  lldb/trunk/include/lldb/Host/HostProcess.h
  lldb/trunk/include/lldb/Host/HostThread.h
  lldb/trunk/include/lldb/Host/Predicate.h
  lldb/trunk/include/lldb/Host/ProcessRunLock.h
  lldb/trunk/include/lldb/Host/PseudoTerminal.h
  lldb/trunk/include/lldb/Host/StringConvert.h
  lldb/trunk/include/lldb/Host/Terminal.h
  lldb/trunk/include/lldb/Host/posix/PipePosix.h
  lldb/trunk/include/lldb/Host/windows/PipeWindows.h
  lldb/trunk/include/lldb/Interpreter/Options.h
  lldb/trunk/include/lldb/Symbol/Block.h
  lldb/trunk/include/lldb/Symbol/CompileUnit.h
  lldb/trunk/include/lldb/Symbol/Declaration.h
  lldb/trunk/include/lldb/Symbol/Function.h
  lldb/trunk/include/lldb/Symbol/LineEntry.h
  lldb/trunk/include/lldb/Symbol/LineTable.h
  lldb/trunk/include/lldb/Symbol/ObjectContainer.h
  lldb/trunk/include/lldb/Symbol/ObjectFile.h
  lldb/trunk/include/lldb/Symbol/SymbolContext.h
  lldb/trunk/include/lldb/Symbol/SymbolContextScope.h
  lldb/trunk/include/lldb/Target/DynamicLoader.h
  lldb/trunk/include/lldb/Target/ExecutionContext.h
  lldb/trunk/include/lldb/Target/ExecutionContextScope.h
  lldb/trunk/include/lldb/Target/JITLoader.h
  lldb/trunk/include/lldb/Target/ModuleCache.h
  lldb/trunk/include/lldb/Target/OperatingSystem.h
  lldb/trunk/include/lldb/Target/Platform.h
  lldb/trunk/include/lldb/Target/Process.h
  lldb/trunk/include/lldb/Target/StackFrame.h
  lldb/trunk/include/lldb/Target/SystemRuntime.h
  lldb/trunk/include/lldb/Utility/ArchSpec.h
  lldb/trunk/include/lldb/Utility/Args.h
  lldb/trunk/include/lldb/Utility/Baton.h
  lldb/trunk/include/lldb/Utility/Connection.h
  lldb/trunk/include/lldb/Utility/ConstString.h
  lldb/trunk/include/lldb/Utility/DataBuffer.h
  lldb/trunk/include/lldb/Utility/DataBufferHeap.h
  lldb/trunk/include/lldb/Utility/DataBufferLLVM.h
  lldb/trunk/include/lldb/Utility/DataEncoder.h
  lldb/trunk/include/lldb/Utility/DataExtractor.h
  lldb/trunk/include/lldb/Utility/FileSpec.h
  lldb/trunk/include/lldb/Utility/Flags.h
  lldb/trunk/include/lldb/Utility/History.h
  lldb/trunk/include/lldb/Utility/RegularExpression.h
  lldb/trunk/include/lldb/Utility/Status.h
  

[Lldb-commits] [PATCH] D46088: Refactor GetNextPersistentVariableName into a non-virtual method

2018-04-30 Thread Phabricator via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL331235: Refactor GetNextPersistentVariableName into a 
non-virtual method (authored by adrian, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D46088?vs=144649=144651#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D46088

Files:
  lldb/trunk/include/lldb/Expression/ExpressionVariable.h
  lldb/trunk/source/Core/ValueObject.cpp
  lldb/trunk/source/Expression/ExpressionVariable.cpp
  lldb/trunk/source/Expression/Materializer.cpp
  lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangPersistentVariables.cpp
  lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangPersistentVariables.h
  lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp
  lldb/trunk/source/Plugins/ExpressionParser/Go/GoUserExpression.cpp
  lldb/trunk/source/Plugins/ExpressionParser/Go/GoUserExpression.h
  lldb/trunk/source/Target/ABI.cpp

Index: lldb/trunk/include/lldb/Expression/ExpressionVariable.h
===
--- lldb/trunk/include/lldb/Expression/ExpressionVariable.h
+++ lldb/trunk/include/lldb/Expression/ExpressionVariable.h
@@ -239,7 +239,12 @@
lldb::ByteOrder byte_order,
uint32_t addr_byte_size) = 0;
 
-  virtual ConstString GetNextPersistentVariableName(Target ) = 0;
+  /// Return a new persistent variable name with the specified prefix.
+  ConstString GetNextPersistentVariableName(Target ,
+llvm::StringRef prefix);
+
+  virtual llvm::StringRef
+  GetPersistentVariablePrefix(bool is_error = false) const = 0;
 
   virtual void
   RemovePersistentVariable(lldb::ExpressionVariableSP variable) = 0;
Index: lldb/trunk/source/Plugins/ExpressionParser/Go/GoUserExpression.h
===
--- lldb/trunk/source/Plugins/ExpressionParser/Go/GoUserExpression.h
+++ lldb/trunk/source/Plugins/ExpressionParser/Go/GoUserExpression.h
@@ -29,8 +29,10 @@
 public:
   GoPersistentExpressionState();
 
-  ConstString GetNextPersistentVariableName(Target ) override;
-
+  llvm::StringRef
+  GetPersistentVariablePrefix(bool is_error) const override {
+return "$go";
+  }
   void RemovePersistentVariable(lldb::ExpressionVariableSP variable) override;
 
   lldb::addr_t LookupSymbol(const ConstString ) override {
Index: lldb/trunk/source/Plugins/ExpressionParser/Go/GoUserExpression.cpp
===
--- lldb/trunk/source/Plugins/ExpressionParser/Go/GoUserExpression.cpp
+++ lldb/trunk/source/Plugins/ExpressionParser/Go/GoUserExpression.cpp
@@ -272,7 +272,8 @@
   PersistentExpressionState *pv =
   target->GetPersistentExpressionStateForLanguage(eLanguageTypeGo);
   if (pv != nullptr) {
-result->SetName(pv->GetNextPersistentVariableName(*target));
+result->SetName(pv->GetNextPersistentVariableName(
+*target, pv->GetPersistentVariablePrefix()));
 pv->AddVariable(result);
   }
   return lldb::eExpressionCompleted;
@@ -650,16 +651,6 @@
 GoPersistentExpressionState::GoPersistentExpressionState()
 : PersistentExpressionState(eKindGo) {}
 
-ConstString
-GoPersistentExpressionState::GetNextPersistentVariableName(Target ) {
-  char name_cstr[256];
-  // We can't use the same variable format as clang.
-  ::snprintf(name_cstr, sizeof(name_cstr), "$go%u",
- target.GetNextPersistentVariableIndex());
-  ConstString name(name_cstr);
-  return name;
-}
-
 void GoPersistentExpressionState::RemovePersistentVariable(
 lldb::ExpressionVariableSP variable) {
   RemoveVariable(variable);
Index: lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangPersistentVariables.h
===
--- lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangPersistentVariables.h
+++ lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangPersistentVariables.h
@@ -54,16 +54,11 @@
   const CompilerType _type, lldb::ByteOrder byte_order,
   uint32_t addr_byte_size) override;
 
-  //--
-  /// Return the next entry in the sequence of strings "$0", "$1", ... for
-  /// use naming persistent expression convenience variables.
-  ///
-  /// @return
-  /// A string that contains the next persistent variable name.
-  //--
-  ConstString GetNextPersistentVariableName(Target ) override;
-
   void RemovePersistentVariable(lldb::ExpressionVariableSP variable) override;
+  llvm::StringRef
+  GetPersistentVariablePrefix(bool is_error) const override {
+return "$";
+  }
 
   void RegisterPersistentDecl(const ConstString , clang::NamedDecl *decl);
 
Index: lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp

[Lldb-commits] [PATCH] D46083: Move the persistent variable counter into Target

2018-04-30 Thread Phabricator via Phabricator via lldb-commits
This revision was not accepted when it landed; it landed in state "Needs 
Revision".
This revision was automatically updated to reflect the committed changes.
Closed by commit rL331234: Move the persistent variable counter into Target 
(authored by adrian, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D46083?vs=144628=144650#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D46083

Files:
  lldb/trunk/include/lldb/Expression/ExpressionVariable.h
  lldb/trunk/include/lldb/Target/Target.h
  lldb/trunk/source/Core/ValueObject.cpp
  lldb/trunk/source/Expression/Materializer.cpp
  lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangPersistentVariables.cpp
  lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangPersistentVariables.h
  lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp
  lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangUserExpression.h
  lldb/trunk/source/Plugins/ExpressionParser/Go/GoUserExpression.cpp
  lldb/trunk/source/Plugins/ExpressionParser/Go/GoUserExpression.h
  lldb/trunk/source/Target/ABI.cpp

Index: lldb/trunk/include/lldb/Target/Target.h
===
--- lldb/trunk/include/lldb/Target/Target.h
+++ lldb/trunk/include/lldb/Target/Target.h
@@ -1082,6 +1082,11 @@
 
   lldb::ExpressionVariableSP GetPersistentVariable(const ConstString );
 
+  /// Return the next available number for numbered persistent variables.
+  unsigned GetNextPersistentVariableIndex() {
+return m_next_persistent_variable_index++;
+  }
+
   lldb::addr_t GetPersistentSymbol(const ConstString );
 
   //--
@@ -1271,6 +1276,7 @@
   bool m_valid;
   bool m_suppress_stop_hooks;
   bool m_is_dummy_target;
+  unsigned m_next_persistent_variable_index = 0;
 
   static void ImageSearchPathsChanged(const PathMappingList _list,
   void *baton);
Index: lldb/trunk/include/lldb/Expression/ExpressionVariable.h
===
--- lldb/trunk/include/lldb/Expression/ExpressionVariable.h
+++ lldb/trunk/include/lldb/Expression/ExpressionVariable.h
@@ -239,7 +239,7 @@
lldb::ByteOrder byte_order,
uint32_t addr_byte_size) = 0;
 
-  virtual ConstString GetNextPersistentVariableName() = 0;
+  virtual ConstString GetNextPersistentVariableName(Target ) = 0;
 
   virtual void
   RemovePersistentVariable(lldb::ExpressionVariableSP variable) = 0;
Index: lldb/trunk/source/Plugins/ExpressionParser/Go/GoUserExpression.h
===
--- lldb/trunk/source/Plugins/ExpressionParser/Go/GoUserExpression.h
+++ lldb/trunk/source/Plugins/ExpressionParser/Go/GoUserExpression.h
@@ -29,7 +29,7 @@
 public:
   GoPersistentExpressionState();
 
-  ConstString GetNextPersistentVariableName() override;
+  ConstString GetNextPersistentVariableName(Target ) override;
 
   void RemovePersistentVariable(lldb::ExpressionVariableSP variable) override;
 
Index: lldb/trunk/source/Plugins/ExpressionParser/Go/GoUserExpression.cpp
===
--- lldb/trunk/source/Plugins/ExpressionParser/Go/GoUserExpression.cpp
+++ lldb/trunk/source/Plugins/ExpressionParser/Go/GoUserExpression.cpp
@@ -272,7 +272,7 @@
   PersistentExpressionState *pv =
   target->GetPersistentExpressionStateForLanguage(eLanguageTypeGo);
   if (pv != nullptr) {
-result->SetName(pv->GetNextPersistentVariableName());
+result->SetName(pv->GetNextPersistentVariableName(*target));
 pv->AddVariable(result);
   }
   return lldb::eExpressionCompleted;
@@ -650,11 +650,12 @@
 GoPersistentExpressionState::GoPersistentExpressionState()
 : PersistentExpressionState(eKindGo) {}
 
-ConstString GoPersistentExpressionState::GetNextPersistentVariableName() {
+ConstString
+GoPersistentExpressionState::GetNextPersistentVariableName(Target ) {
   char name_cstr[256];
   // We can't use the same variable format as clang.
   ::snprintf(name_cstr, sizeof(name_cstr), "$go%u",
- m_next_persistent_variable_id++);
+ target.GetNextPersistentVariableIndex());
   ConstString name(name_cstr);
   return name;
 }
Index: lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangPersistentVariables.cpp
===
--- lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangPersistentVariables.cpp
+++ lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangPersistentVariables.cpp
@@ -10,6 +10,7 @@
 #include "ClangPersistentVariables.h"
 
 #include "lldb/Core/Value.h"
+#include "lldb/Target/Target.h"
 #include "lldb/Utility/DataExtractor.h"
 #include "lldb/Utility/Log.h"
 #include "lldb/Utility/StreamString.h"
@@ -52,10 +53,11 @@
 m_next_persistent_variable_id--;
 }
 
-ConstString 

[Lldb-commits] [PATCH] D46144: Reflow paragraphs in comments.

2018-04-30 Thread Phabricator via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL331197: Reflow paragraphs in comments. (authored by adrian, 
committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D46144?vs=144420=144575#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D46144

Files:
  lldb/trunk/include/lldb/API/SBAddress.h
  lldb/trunk/include/lldb/API/SBBroadcaster.h
  lldb/trunk/include/lldb/API/SBCommandInterpreter.h
  lldb/trunk/include/lldb/API/SBCommandReturnObject.h
  lldb/trunk/include/lldb/API/SBData.h
  lldb/trunk/include/lldb/API/SBExpressionOptions.h
  lldb/trunk/include/lldb/API/SBFrame.h
  lldb/trunk/include/lldb/API/SBInstruction.h
  lldb/trunk/include/lldb/API/SBInstructionList.h
  lldb/trunk/include/lldb/API/SBProcess.h
  lldb/trunk/include/lldb/API/SBStream.h
  lldb/trunk/include/lldb/API/SBSymbol.h
  lldb/trunk/include/lldb/API/SBTarget.h
  lldb/trunk/include/lldb/API/SBValue.h
  lldb/trunk/include/lldb/API/SBValueList.h
  lldb/trunk/include/lldb/Breakpoint/Breakpoint.h
  lldb/trunk/include/lldb/Breakpoint/BreakpointLocation.h
  lldb/trunk/include/lldb/Breakpoint/BreakpointLocationCollection.h
  lldb/trunk/include/lldb/Breakpoint/BreakpointLocationList.h
  lldb/trunk/include/lldb/Breakpoint/BreakpointName.h
  lldb/trunk/include/lldb/Breakpoint/BreakpointOptions.h
  lldb/trunk/include/lldb/Breakpoint/BreakpointResolver.h
  lldb/trunk/include/lldb/Breakpoint/BreakpointResolverAddress.h
  lldb/trunk/include/lldb/Breakpoint/BreakpointResolverName.h
  lldb/trunk/include/lldb/Breakpoint/BreakpointSite.h
  lldb/trunk/include/lldb/Breakpoint/StoppointLocation.h
  lldb/trunk/include/lldb/Breakpoint/Watchpoint.h
  lldb/trunk/include/lldb/Breakpoint/WatchpointList.h
  lldb/trunk/include/lldb/Breakpoint/WatchpointOptions.h
  lldb/trunk/include/lldb/Core/Address.h
  lldb/trunk/include/lldb/Core/AddressRange.h
  lldb/trunk/include/lldb/Core/AddressResolverName.h
  lldb/trunk/include/lldb/Core/Broadcaster.h
  lldb/trunk/include/lldb/Core/Debugger.h
  lldb/trunk/include/lldb/Core/Disassembler.h
  lldb/trunk/include/lldb/Core/EmulateInstruction.h
  lldb/trunk/include/lldb/Core/FormatEntity.h
  lldb/trunk/include/lldb/Core/IOHandler.h
  lldb/trunk/include/lldb/Core/MappedHash.h
  lldb/trunk/include/lldb/Core/Module.h
  lldb/trunk/include/lldb/Core/ModuleList.h
  lldb/trunk/include/lldb/Core/ModuleSpec.h
  lldb/trunk/include/lldb/Core/PluginManager.h
  lldb/trunk/include/lldb/Core/RangeMap.h
  lldb/trunk/include/lldb/Core/RegisterValue.h
  lldb/trunk/include/lldb/Core/STLUtils.h
  lldb/trunk/include/lldb/Core/Scalar.h
  lldb/trunk/include/lldb/Core/SearchFilter.h
  lldb/trunk/include/lldb/Core/Section.h
  lldb/trunk/include/lldb/Core/SourceManager.h
  lldb/trunk/include/lldb/Core/StreamBuffer.h
  lldb/trunk/include/lldb/Core/UniqueCStringMap.h
  lldb/trunk/include/lldb/Core/UserSettingsController.h
  lldb/trunk/include/lldb/Core/Value.h
  lldb/trunk/include/lldb/Core/ValueObject.h
  lldb/trunk/include/lldb/Core/ValueObjectSyntheticFilter.h
  lldb/trunk/include/lldb/DataFormatters/DataVisualization.h
  lldb/trunk/include/lldb/DataFormatters/FormatClasses.h
  lldb/trunk/include/lldb/DataFormatters/FormatManager.h
  lldb/trunk/include/lldb/DataFormatters/FormattersContainer.h
  lldb/trunk/include/lldb/DataFormatters/StringPrinter.h
  lldb/trunk/include/lldb/DataFormatters/TypeFormat.h
  lldb/trunk/include/lldb/DataFormatters/TypeSummary.h
  lldb/trunk/include/lldb/DataFormatters/TypeSynthetic.h
  lldb/trunk/include/lldb/DataFormatters/TypeValidator.h
  lldb/trunk/include/lldb/DataFormatters/ValueObjectPrinter.h
  lldb/trunk/include/lldb/Expression/ExpressionSourceCode.h
  lldb/trunk/include/lldb/Expression/ExpressionVariable.h
  lldb/trunk/include/lldb/Expression/IRMemoryMap.h
  lldb/trunk/include/lldb/Expression/LLVMUserExpression.h
  lldb/trunk/include/lldb/Expression/UtilityFunction.h
  lldb/trunk/include/lldb/Host/Debug.h
  lldb/trunk/include/lldb/Host/Editline.h
  lldb/trunk/include/lldb/Host/MainLoop.h
  lldb/trunk/include/lldb/Host/MainLoopBase.h
  lldb/trunk/include/lldb/Host/PosixApi.h
  lldb/trunk/include/lldb/Host/Predicate.h
  lldb/trunk/include/lldb/Host/Socket.h
  lldb/trunk/include/lldb/Host/SocketAddress.h
  lldb/trunk/include/lldb/Host/Symbols.h
  lldb/trunk/include/lldb/Host/TaskPool.h
  lldb/trunk/include/lldb/Host/XML.h
  lldb/trunk/include/lldb/Host/common/GetOptInc.h
  lldb/trunk/include/lldb/Host/common/NativeBreakpoint.h
  lldb/trunk/include/lldb/Host/common/NativeProcessProtocol.h
  lldb/trunk/include/lldb/Host/common/NativeRegisterContext.h
  lldb/trunk/include/lldb/Host/posix/ConnectionFileDescriptorPosix.h
  lldb/trunk/include/lldb/Interpreter/CommandAlias.h
  lldb/trunk/include/lldb/Interpreter/CommandCompletions.h
  lldb/trunk/include/lldb/Interpreter/CommandInterpreter.h
  lldb/trunk/include/lldb/Interpreter/CommandObject.h
  lldb/trunk/include/lldb/Interpreter/CommandObjectMultiword.h
  

[Lldb-commits] [PATCH] D46362: DWARFExpression: Convert file addresses to load addresses early on

2018-05-03 Thread Phabricator via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL331462: DWARFExpression: Convert file addresses to load 
addresses early on. (authored by adrian, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D46362?vs=145032=145034#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D46362

Files:
  lldb/trunk/include/lldb/Core/Value.h
  lldb/trunk/source/Core/Value.cpp
  lldb/trunk/source/Core/ValueObjectVariable.cpp
  lldb/trunk/source/Expression/DWARFExpression.cpp


Index: lldb/trunk/include/lldb/Core/Value.h
===
--- lldb/trunk/include/lldb/Core/Value.h
+++ lldb/trunk/include/lldb/Core/Value.h
@@ -228,6 +228,9 @@
 
   static const char *GetContextTypeAsCString(ContextType context_type);
 
+  /// Convert this value's file address to a load address, if possible.
+  void ConvertToLoadAddress(SymbolContext sc);
+
   bool GetData(DataExtractor );
 
   void Clear();
Index: lldb/trunk/source/Expression/DWARFExpression.cpp
===
--- lldb/trunk/source/Expression/DWARFExpression.cpp
+++ lldb/trunk/source/Expression/DWARFExpression.cpp
@@ -1379,10 +1379,13 @@
 // The DW_OP_addr operation has a single operand that encodes a machine
 // address and whose size is the size of an address on the target machine.
 //--
-case DW_OP_addr:
+case DW_OP_addr: {
   stack.push_back(Scalar(opcodes.GetAddress()));
   stack.back().SetValueType(Value::eValueTypeFileAddress);
+  auto sc = frame->GetSymbolContext(eSymbolContextFunction);
+  stack.back().ConvertToLoadAddress(sc);
   break;
+}
 
 //--
 // The DW_OP_addr_sect_offset4 is used for any location expressions in
Index: lldb/trunk/source/Core/Value.cpp
===
--- lldb/trunk/source/Core/Value.cpp
+++ lldb/trunk/source/Core/Value.cpp
@@ -669,6 +669,28 @@
   return "???";
 }
 
+void Value::ConvertToLoadAddress(SymbolContext sc) {
+  if (GetValueType() != eValueTypeFileAddress)
+return;
+
+  if (!sc.module_sp)
+return;
+
+  lldb::addr_t file_addr = GetScalar().ULongLong(LLDB_INVALID_ADDRESS);
+  if (file_addr == LLDB_INVALID_ADDRESS)
+return;
+
+  Address so_addr;
+  if (!sc.module_sp->ResolveFileAddress(file_addr, so_addr))
+return;
+  lldb::addr_t load_addr = so_addr.GetLoadAddress(sc.target_sp.get());
+  if (load_addr == LLDB_INVALID_ADDRESS)
+return;
+
+  SetValueType(Value::eValueTypeLoadAddress);
+  GetScalar() = load_addr;
+}
+
 ValueList::ValueList(const ValueList ) { m_values = rhs.m_values; }
 
 const ValueList ::operator=(const ValueList ) {
Index: lldb/trunk/source/Core/ValueObjectVariable.cpp
===
--- lldb/trunk/source/Core/ValueObjectVariable.cpp
+++ lldb/trunk/source/Core/ValueObjectVariable.cpp
@@ -234,26 +234,10 @@
 // If this variable is a simple type, we read all data for it into
 // m_data. Make sure this type has a value before we try and read it
 
+SymbolContext var_sc;
+variable->CalculateSymbolContext(_sc);
 // If we have a file address, convert it to a load address if we can.
-if (value_type == Value::eValueTypeFileAddress && process_is_alive) {
-  lldb::addr_t file_addr =
-  m_value.GetScalar().ULongLong(LLDB_INVALID_ADDRESS);
-  if (file_addr != LLDB_INVALID_ADDRESS) {
-SymbolContext var_sc;
-variable->CalculateSymbolContext(_sc);
-if (var_sc.module_sp) {
-  ObjectFile *objfile = var_sc.module_sp->GetObjectFile();
-  if (objfile) {
-Address so_addr(file_addr, objfile->GetSectionList());
-lldb::addr_t load_addr = so_addr.GetLoadAddress(target);
-if (load_addr != LLDB_INVALID_ADDRESS) {
-  m_value.SetValueType(Value::eValueTypeLoadAddress);
-  m_value.GetScalar() = load_addr;
-}
-  }
-}
-  }
-}
+m_value.ConvertToLoadAddress(var_sc);
 
 if (!CanProvideValue()) {
   // this value object represents an aggregate type whose children have


Index: lldb/trunk/include/lldb/Core/Value.h
===
--- lldb/trunk/include/lldb/Core/Value.h
+++ lldb/trunk/include/lldb/Core/Value.h
@@ -228,6 +228,9 @@
 
   static const char *GetContextTypeAsCString(ContextType context_type);
 
+  /// Convert this value's file address to a load address, if possible.
+  void ConvertToLoadAddress(SymbolContext sc);
+
   bool GetData(DataExtractor );
 
   void Clear();
Index: 

[Lldb-commits] [PATCH] D36347: New lldb python module for adding diagnostic breakpoints

2017-10-27 Thread Phabricator via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL316773: New lldb python module for managing diagnostic 
breakpoints (authored by dhinton).

Repository:
  rL LLVM

https://reviews.llvm.org/D36347

Files:
  cfe/trunk/utils/clangdiag.py

Index: cfe/trunk/utils/clangdiag.py
===
--- cfe/trunk/utils/clangdiag.py
+++ cfe/trunk/utils/clangdiag.py
@@ -0,0 +1,192 @@
+#!/usr/bin/python
+
+#--
+# Be sure to add the python path that points to the LLDB shared library.
+#
+# # To use this in the embedded python interpreter using "lldb" just
+# import it with the full path using the "command script import"
+# command
+#   (lldb) command script import /path/to/clandiag.py
+#--
+
+import lldb
+import argparse
+import commands
+import shlex
+import os
+import re
+import subprocess
+
+class MyParser(argparse.ArgumentParser):
+def format_help(self):
+return ''' Commands for managing clang diagnostic breakpoints
+
+Syntax: clangdiag enable [|]
+clangdiag disable
+clangdiag diagtool [|reset]
+
+The following subcommands are supported:
+
+  enable   -- Enable clang diagnostic breakpoints.
+  disable  -- Disable all clang diagnostic breakpoints.
+  diagtool -- Return, set, or reset diagtool path.
+
+This command sets breakpoints in clang, and clang based tools, that
+emit diagnostics.  When a diagnostic is emitted, and clangdiag is
+enabled, it will use the appropriate diagtool application to determine
+the name of the DiagID, and set breakpoints in all locations that
+'diag::name' appears in the source.  Since the new breakpoints are set
+after they are encountered, users will need to launch the executable a
+second time in order to hit the new breakpoints.
+
+For in-tree builds, the diagtool application, used to map DiagID's to
+names, is found automatically in the same directory as the target
+executable.  However, out-or-tree builds must use the 'diagtool'
+subcommand to set the appropriate path for diagtool in the clang debug
+bin directory.  Since this mapping is created at build-time, it's
+important for users to use the same version that was generated when
+clang was compiled, or else the id's won't match.
+
+Notes:
+- Substrings can be passed for both  and .
+- If  is passed, only enable the DiagID(s) for that warning.
+- If  is passed, only enable that DiagID.
+- Rerunning enable clears existing breakpoints.
+- diagtool is used in breakpoint callbacks, so it can be changed
+  without the need to rerun enable.
+- Adding this to your ~.lldbinit file makes clangdiag available at startup:
+  "command script import /path/to/clangdiag.py"
+
+'''
+
+def create_diag_options():
+parser = MyParser(prog='clangdiag')
+subparsers = parser.add_subparsers(
+title='subcommands',
+dest='subcommands',
+metavar='')
+disable_parser = subparsers.add_parser('disable')
+enable_parser = subparsers.add_parser('enable')
+enable_parser.add_argument('id', nargs='?')
+diagtool_parser = subparsers.add_parser('diagtool')
+diagtool_parser.add_argument('path', nargs='?')
+return parser
+
+def getDiagtool(target, diagtool = None):
+id = target.GetProcess().GetProcessID()
+if 'diagtool' not in getDiagtool.__dict__:
+getDiagtool.diagtool = {}
+if diagtool:
+if diagtool == 'reset':
+getDiagtool.diagtool[id] = None
+elif os.path.exists(diagtool):
+getDiagtool.diagtool[id] = diagtool
+else:
+print('clangdiag: %s not found.' % diagtool)
+if not id in getDiagtool.diagtool or not getDiagtool.diagtool[id]:
+getDiagtool.diagtool[id] = None
+exe = target.GetExecutable()
+if not exe.Exists():
+print('clangdiag: Target (%s) not set.' % exe.GetFilename())
+else:
+diagtool = os.path.join(exe.GetDirectory(), 'diagtool')
+if os.path.exists(diagtool):
+getDiagtool.diagtool[id] = diagtool
+else:
+print('clangdiag: diagtool not found along side %s' % exe)
+
+return getDiagtool.diagtool[id]
+
+def setDiagBreakpoint(frame, bp_loc, dict):
+id = frame.FindVariable("DiagID").GetValue()
+if id is None:
+print('clangdiag: id is None')
+return False
+
+# Don't need to test this time, since we did that in enable.
+target = frame.GetThread().GetProcess().GetTarget()
+diagtool = getDiagtool(target)
+name = subprocess.check_output([diagtool, "find-diagnostic-id", id]).rstrip();
+# Make sure we only consider errors, warnings, and extentions.
+# FIXME: Make this configurable?
+prefixes = ['err_', 'warn_', 'exp_']
+if len([prefix for prefix in prefixes+[''] if name.startswith(prefix)][0]):
+

[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=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


[Lldb-commits] [PATCH] D42277: Use test-specific module caches to avoid stale header conflicts

2018-01-25 Thread Phabricator via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL323450: Use test-specific module caches to avoid stale 
header conflicts (authored by vedantk, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D42277?vs=131000=131475#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D42277

Files:
  
lldb/trunk/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-cpp/TestDataFormatterCpp.py
  
lldb/trunk/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-globals/TestDataFormatterGlobals.py
  
lldb/trunk/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/list/TestDataFormatterLibcxxList.py
  
lldb/trunk/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/vector/TestDataFormatterLibcxxVector.py
  
lldb/trunk/packages/Python/lldbsuite/test/lang/objc/modules-auto-import/Makefile
  
lldb/trunk/packages/Python/lldbsuite/test/lang/objc/modules-auto-import/TestModulesAutoImport.py
  
lldb/trunk/packages/Python/lldbsuite/test/lang/objc/modules-incomplete/Makefile
  
lldb/trunk/packages/Python/lldbsuite/test/lang/objc/modules-incomplete/TestIncompleteModules.py
  
lldb/trunk/packages/Python/lldbsuite/test/lang/objc/modules-inline-functions/Makefile
  
lldb/trunk/packages/Python/lldbsuite/test/lang/objc/modules-inline-functions/TestModulesInlineFunctions.py
  lldb/trunk/packages/Python/lldbsuite/test/make/Makefile.rules

Index: lldb/trunk/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/list/TestDataFormatterLibcxxList.py
===
--- lldb/trunk/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/list/TestDataFormatterLibcxxList.py
+++ lldb/trunk/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/list/TestDataFormatterLibcxxList.py
@@ -31,6 +31,8 @@
  '// Set fourth break point at this line.')
 
 @add_test_categories(["libc++"])
+@skipIf(debug_info="gmodules",
+bugnumber="https://bugs.llvm.org/show_bug.cgi?id=36048;)
 def test_with_run_command(self):
 """Test that that file and class static variables display correctly."""
 self.build()
Index: lldb/trunk/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/vector/TestDataFormatterLibcxxVector.py
===
--- lldb/trunk/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/vector/TestDataFormatterLibcxxVector.py
+++ lldb/trunk/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/vector/TestDataFormatterLibcxxVector.py
@@ -18,6 +18,8 @@
 mydir = TestBase.compute_mydir(__file__)
 
 @add_test_categories(["libc++"])
+@skipIf(debug_info="gmodules",
+bugnumber="https://bugs.llvm.org/show_bug.cgi?id=36048;)
 def test_with_run_command(self):
 """Test that that file and class static variables display correctly."""
 self.build()
Index: lldb/trunk/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-cpp/TestDataFormatterCpp.py
===
--- lldb/trunk/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-cpp/TestDataFormatterCpp.py
+++ lldb/trunk/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-cpp/TestDataFormatterCpp.py
@@ -26,6 +26,8 @@
 @expectedFailureAll(
 oslist=["windows"],
 bugnumber="llvm.org/pr24462: Data formatters have problems on Windows")
+@skipIf(debug_info="gmodules",
+bugnumber="https://bugs.llvm.org/show_bug.cgi?id=36048;)
 def test_with_run_command(self):
 """Test that that file and class static variables display correctly."""
 self.build()
Index: lldb/trunk/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-globals/TestDataFormatterGlobals.py
===
--- lldb/trunk/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-globals/TestDataFormatterGlobals.py
+++ lldb/trunk/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-globals/TestDataFormatterGlobals.py
@@ -9,6 +9,7 @@
 import time
 import lldb
 from lldbsuite.test.lldbtest import *
+from lldbsuite.test.decorators import *
 import lldbsuite.test.lldbutil as lldbutil
 
 
@@ -22,6 +23,8 @@
 # Find the line number to break at.
 self.line = line_number('main.cpp', '// Set break point at this line.')
 
+@skipIf(debug_info="gmodules",
+bugnumber="https://bugs.llvm.org/show_bug.cgi?id=36048;)
 def 

[Lldb-commits] [PATCH] D42828: Fix for read-past-end-of-array buglet in ProcessElfCore.cpp while reading linux notes

2018-02-02 Thread Phabricator via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL324156: Fix a copy of a fixed length, possibly non-nul 
terminated, string (authored by jmolenda, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D42828?vs=132500=132688#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D42828

Files:
  lldb/trunk/source/Plugins/Process/elf-core/ProcessElfCore.cpp


Index: lldb/trunk/source/Plugins/Process/elf-core/ProcessElfCore.cpp
===
--- lldb/trunk/source/Plugins/Process/elf-core/ProcessElfCore.cpp
+++ lldb/trunk/source/Plugins/Process/elf-core/ProcessElfCore.cpp
@@ -665,7 +665,7 @@
   Status status = prpsinfo.Parse(note.data, arch);
   if (status.Fail())
 return status.ToError();
-  thread_data.name = prpsinfo.pr_fname;
+  thread_data.name.assign (prpsinfo.pr_fname, strnlen (prpsinfo.pr_fname, 
sizeof (prpsinfo.pr_fname)));
   SetID(prpsinfo.pr_pid);
   break;
 }


Index: lldb/trunk/source/Plugins/Process/elf-core/ProcessElfCore.cpp
===
--- lldb/trunk/source/Plugins/Process/elf-core/ProcessElfCore.cpp
+++ lldb/trunk/source/Plugins/Process/elf-core/ProcessElfCore.cpp
@@ -665,7 +665,7 @@
   Status status = prpsinfo.Parse(note.data, arch);
   if (status.Fail())
 return status.ToError();
-  thread_data.name = prpsinfo.pr_fname;
+  thread_data.name.assign (prpsinfo.pr_fname, strnlen (prpsinfo.pr_fname, sizeof (prpsinfo.pr_fname)));
   SetID(prpsinfo.pr_pid);
   break;
 }
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D42763: Build each testcase variant in its own subdirectory and remove the srcdir lock file

2018-02-06 Thread Phabricator via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL324368: Build each testcase variant in its own subdirectory 
and remove the srcdir lock… (authored by adrian, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D42763?vs=132888=133039#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D42763

Files:
  lldb/trunk/packages/Python/lldbsuite/test/api/listeners/TestListener.py
  
lldb/trunk/packages/Python/lldbsuite/test/functionalities/breakpoint/comp_dir_symlink/TestCompDirSymLink.py
  
lldb/trunk/packages/Python/lldbsuite/test/functionalities/load_unload/TestLoadUnload.py
  
lldb/trunk/packages/Python/lldbsuite/test/functionalities/watchpoint/watchpoint_on_vectors/TestValueOfVectorVariable.py
  lldb/trunk/packages/Python/lldbsuite/test/lldbinline.py
  lldb/trunk/packages/Python/lldbsuite/test/lldbtest.py
  lldb/trunk/packages/Python/lldbsuite/test/plugins/builder_base.py
  lldb/trunk/packages/Python/lldbsuite/test/plugins/builder_darwin.py
  
lldb/trunk/packages/Python/lldbsuite/test/python_api/hello_world/TestHelloWorld.py
  
lldb/trunk/packages/Python/lldbsuite/test/python_api/process/io/TestProcessIO.py
  
lldb/trunk/packages/Python/lldbsuite/test/python_api/symbol-context/TestSymbolContext.py
  
lldb/trunk/packages/Python/lldbsuite/test/python_api/symbol-context/two-files/TestSymbolContextTwoFiles.py
  
lldb/trunk/packages/Python/lldbsuite/test/python_api/value_var_update/TestValueVarUpdate.py

Index: lldb/trunk/packages/Python/lldbsuite/test/api/listeners/TestListener.py
===
--- lldb/trunk/packages/Python/lldbsuite/test/api/listeners/TestListener.py
+++ lldb/trunk/packages/Python/lldbsuite/test/api/listeners/TestListener.py
@@ -23,10 +23,10 @@
 def setUp(self):
 # Call super's setUp().
 TestBase.setUp(self)
-self.build()
 
 def test_receiving_breakpoint_added(self):
 """Test that we get breakpoint added events, waiting on event classes on the debugger"""
+self.build()
 
 my_listener = lldb.SBListener("test_listener")
 
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
@@ -92,9 +92,9 @@
 # The test was skipped altogether.
 return ""
 elif self.using_dsym:
-return "-N dwarf %s" % (self.mydir)
+return "-N dwarf " + self.mydir
 else:
-return "-N dsym %s" % (self.mydir)
+return "-N dsym " + self.mydir
 
 def BuildMakefile(self):
 self.makeBuildDir()
Index: lldb/trunk/packages/Python/lldbsuite/test/plugins/builder_darwin.py
===
--- lldb/trunk/packages/Python/lldbsuite/test/plugins/builder_darwin.py
+++ lldb/trunk/packages/Python/lldbsuite/test/plugins/builder_darwin.py
@@ -11,13 +11,14 @@
 compiler=None,
 dictionary=None,
 clean=True,
-testdir=None):
+testdir=None,
+testname=None):
 """Build the binaries with dsym debug info."""
 commands = []
-
 if clean:
-commands.append(getMake(testdir) + ["clean", getCmdLine(dictionary)])
-commands.append(getMake(testdir) +
+commands.append(getMake(testdir, testname) +
+["clean", getCmdLine(dictionary)])
+commands.append(getMake(testdir, testname) +
 ["MAKE_DSYM=YES",
  getArchSpec(architecture),
  getCCSpec(compiler),
Index: lldb/trunk/packages/Python/lldbsuite/test/plugins/builder_base.py
===
--- lldb/trunk/packages/Python/lldbsuite/test/plugins/builder_base.py
+++ lldb/trunk/packages/Python/lldbsuite/test/plugins/builder_base.py
@@ -50,30 +50,31 @@
 
 return ("ARCHFLAG=" + archflag) if archflag else ""
 
-def getMake(test_subdir):
+def getMake(test_subdir, test_name):
 """Returns the invocation for GNU make.
-   The argument test_subdir is the relative path to the testcase."""
+   The first argument is a tuple of the relative path to the testcase
+   and its filename stem."""
 if platform.system() == "FreeBSD" or platform.system() == "NetBSD":
 make = "gmake"
 else:
 make = "make"
 
 # Construct the base make invocation.
 lldb_test = os.environ["LLDB_TEST"]
 lldb_build = os.environ["LLDB_BUILD"]
-if not (lldb_test and lldb_build and test_subdir and
+if not (lldb_test and lldb_build and test_subdir and test_name and
 (not os.path.isabs(test_subdir))):
 raise Exception("Could not derive test directories")
-build_dir = os.path.join(lldb_build, test_subdir)
-test_dir = 

[Lldb-commits] [PATCH] D43099: Make LLDB's clang module cache path customizable

2018-02-09 Thread Phabricator via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL324775: Make LLDBs clang module cache path 
customizable (authored by adrian, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D43099?vs=133636=133684#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D43099

Files:
  lldb/trunk/include/lldb/Target/Target.h
  lldb/trunk/packages/Python/lldbsuite/test/lldbtest.py
  
lldb/trunk/packages/Python/lldbsuite/test/macosx/nslog/TestDarwinNSLogOutput.py
  lldb/trunk/source/Plugins/ExpressionParser/Clang/CMakeLists.txt
  lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.cpp
  lldb/trunk/source/Target/Target.cpp

Index: lldb/trunk/source/Plugins/ExpressionParser/Clang/CMakeLists.txt
===
--- lldb/trunk/source/Plugins/ExpressionParser/Clang/CMakeLists.txt
+++ lldb/trunk/source/Plugins/ExpressionParser/Clang/CMakeLists.txt
@@ -23,6 +23,7 @@
   LINK_LIBS
 clangAST
 clangCodeGen
+clangDriver
 clangEdit
 clangFrontend
 clangLex
Index: lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.cpp
===
--- lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.cpp
+++ lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.cpp
@@ -13,6 +13,7 @@
 
 // Other libraries and framework includes
 #include "clang/Basic/TargetInfo.h"
+#include "clang/Driver/Driver.h"
 #include "clang/Frontend/CompilerInstance.h"
 #include "clang/Frontend/FrontendActions.h"
 #include "clang/Lex/Preprocessor.h"
@@ -590,14 +591,12 @@
   // Add additional search paths with { "-I", path } or { "-F", path } here.
 
   {
-llvm::SmallString<128> DefaultModuleCache;
-const bool erased_on_reboot = false;
-llvm::sys::path::system_temp_directory(erased_on_reboot,
-   DefaultModuleCache);
-llvm::sys::path::append(DefaultModuleCache, "org.llvm.clang");
-llvm::sys::path::append(DefaultModuleCache, "ModuleCache");
+llvm::SmallString<128> Path;
+target.GetClangModulesCachePath().GetPath(Path);
+if (Path.empty())
+  clang::driver::Driver::getDefaultModuleCachePath(Path);
 std::string module_cache_argument("-fmodules-cache-path=");
-module_cache_argument.append(DefaultModuleCache.str().str());
+module_cache_argument.append(Path.str());
 compiler_invocation_arguments.push_back(module_cache_argument);
   }
 
Index: lldb/trunk/source/Target/Target.cpp
===
--- lldb/trunk/source/Target/Target.cpp
+++ lldb/trunk/source/Target/Target.cpp
@@ -3509,6 +3509,9 @@
  OptionValue::eTypeString, nullptr, nullptr,
  "A list of trap handler function names, e.g. a common Unix user process "
  "one is _sigtramp."},
+{"clang-modules-cache-path",
+ OptionValue::eTypeFileSpec, false, 0, nullptr, nullptr,
+ "The path to the clang modules cache directory (-fmodules-cache-path)."},
 {"display-runtime-support-values", OptionValue::eTypeBoolean, false, false,
  nullptr, nullptr, "If true, LLDB will show variables that are meant to "
"support the operation of a language's runtime "
@@ -3558,6 +3561,7 @@
   ePropertyMemoryModuleLoadLevel,
   ePropertyDisplayExpressionsInCrashlogs,
   ePropertyTrapHandlerNames,
+  ePropertyClangModulesCachePath,
   ePropertyDisplayRuntimeSupportValues,
   ePropertyNonStopModeEnabled,
   ePropertyExperimental
@@ -3937,6 +3941,15 @@
   return option_value->GetCurrentValue();
 }
 
+FileSpec ::GetClangModulesCachePath() {
+  const uint32_t idx = ePropertyClangModulesCachePath;
+  OptionValueFileSpec *option_value =
+  m_collection_sp->GetPropertyAtIndexAsOptionValueFileSpec(nullptr, false,
+   idx);
+  assert(option_value);
+  return option_value->GetCurrentValue();
+}
+
 FileSpecList ::GetClangModuleSearchPaths() {
   const uint32_t idx = ePropertyClangModuleSearchPaths;
   OptionValueFileSpecList *option_value =
Index: lldb/trunk/include/lldb/Target/Target.h
===
--- lldb/trunk/include/lldb/Target/Target.h
+++ lldb/trunk/include/lldb/Target/Target.h
@@ -126,6 +126,8 @@
 
   FileSpecList ();
 
+  FileSpec ();
+
   FileSpecList ();
 
   bool GetEnableAutoImportClangModules() const;
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
@@ -1914,6 +1914,14 @@
 # decorators.
 Base.setUp(self)
 
+# Set the clang modules cache path.
+if self.child:
+assert(self.getDebugInfo() == 'default')
+  

[Lldb-commits] [PATCH] D43432: [cmake] Fix LLDB_CODESIGN_IDENTITY logic.

2018-02-17 Thread Phabricator via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL325442: [cmake] Fix LLDB_CODESIGN_IDENTITY logic. (authored 
by dhinton, committed by ).
Herald added a subscriber: llvm-commits.

Repository:
  rL LLVM

https://reviews.llvm.org/D43432

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


Index: lldb/trunk/CMakeLists.txt
===
--- lldb/trunk/CMakeLists.txt
+++ lldb/trunk/CMakeLists.txt
@@ -57,21 +57,6 @@
   add_subdirectory(scripts)
 endif ()
 
-if(CMAKE_HOST_APPLE)
-  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")
-set(SKIP_DEBUGSERVER True)
-  endif()
-  message(STATUS "Path to the lldb debugserver: ${DEBUGSERVER_PATH}")
-endif()
-
 add_subdirectory(source)
 add_subdirectory(tools)
 
Index: lldb/trunk/tools/debugserver/source/CMakeLists.txt
===
--- lldb/trunk/tools/debugserver/source/CMakeLists.txt
+++ lldb/trunk/tools/debugserver/source/CMakeLists.txt
@@ -95,6 +95,22 @@
 add_library(lldbDebugserverCommon ${lldbDebugserverCommonSources})
 
 
+set(LLDB_CODESIGN_IDENTITY "lldb_codesign"
+  CACHE STRING "Identity used for code signing. Set to empty string to skip 
the signing step.")
+
+if(NOT LLDB_CODESIGN_IDENTITY STREQUAL "")
+  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")
+  set(SKIP_DEBUGSERVER True)
+endif()
+message(STATUS "Path to the lldb debugserver: ${DEBUGSERVER_PATH}")
+
 if (APPLE)
   if(IOS)
 find_library(BACKBOARD_LIBRARY BackBoardServices
@@ -187,15 +203,13 @@
   set(entitlements_xml 
${CMAKE_CURRENT_SOURCE_DIR}/debugserver-entitlements.plist)
 endif()
 
-set(LLDB_CODESIGN_IDENTITY "lldb_codesign"
-  CACHE STRING "Identity used for code signing. Set to empty string to skip 
the signing step.")
 set(LLDB_USE_ENTITLEMENTS_Default On)
 if("${LLDB_CODESIGN_IDENTITY}" STREQUAL "lldb_codesign")
   set(LLDB_USE_ENTITLEMENTS_Default Off)
 endif()
 option(LLDB_USE_ENTITLEMENTS "Use entitlements when codesigning (Defaults Off 
when using lldb_codesign identity, otherwise On)" 
${LLDB_USE_ENTITLEMENTS_Default})
 
-if ("${LLDB_CODESIGN_IDENTITY}" STREQUAL "")
+if (SKIP_DEBUGSERVER)
   if (CMAKE_HOST_APPLE)
 # If we haven't built a signed debugserver, copy the one from the system.
 add_custom_target(debugserver


Index: lldb/trunk/CMakeLists.txt
===
--- lldb/trunk/CMakeLists.txt
+++ lldb/trunk/CMakeLists.txt
@@ -57,21 +57,6 @@
   add_subdirectory(scripts)
 endif ()
 
-if(CMAKE_HOST_APPLE)
-  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")
-set(SKIP_DEBUGSERVER True)
-  endif()
-  message(STATUS "Path to the lldb debugserver: ${DEBUGSERVER_PATH}")
-endif()
-
 add_subdirectory(source)
 add_subdirectory(tools)
 
Index: lldb/trunk/tools/debugserver/source/CMakeLists.txt
===
--- lldb/trunk/tools/debugserver/source/CMakeLists.txt
+++ lldb/trunk/tools/debugserver/source/CMakeLists.txt
@@ -95,6 +95,22 @@
 add_library(lldbDebugserverCommon ${lldbDebugserverCommonSources})
 
 
+set(LLDB_CODESIGN_IDENTITY "lldb_codesign"
+  CACHE STRING "Identity used for code signing. Set to empty string to skip the signing step.")
+
+if(NOT LLDB_CODESIGN_IDENTITY STREQUAL "")
+  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")
+  set(SKIP_DEBUGSERVER True)
+endif()
+message(STATUS "Path to the lldb debugserver: ${DEBUGSERVER_PATH}")
+
 if (APPLE)
   if(IOS)
 find_library(BACKBOARD_LIBRARY BackBoardServices
@@ -187,15 +203,13 @@
   set(entitlements_xml ${CMAKE_CURRENT_SOURCE_DIR}/debugserver-entitlements.plist)
 endif()
 
-set(LLDB_CODESIGN_IDENTITY "lldb_codesign"
-  CACHE STRING "Identity used for code signing. Set to empty string to skip the signing step.")
 set(LLDB_USE_ENTITLEMENTS_Default On)
 if("${LLDB_CODESIGN_IDENTITY}" STREQUAL "lldb_codesign")
   set(LLDB_USE_ENTITLEMENTS_Default Off)
 endif()
 

[Lldb-commits] [PATCH] D43662: [Utility] Simplify and generalize the CleanUp helper, NFC

2018-02-23 Thread Phabricator via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL325964: [Utility] Simplify and generalize the CleanUp 
helper, NFC (authored by vedantk, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D43662?vs=135671=135698#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D43662

Files:
  lldb/trunk/include/lldb/Utility/CleanUp.h
  lldb/trunk/lldb.xcodeproj/project.pbxproj
  lldb/trunk/source/Host/macosx/Host.mm
  lldb/trunk/source/Host/macosx/Symbols.cpp
  lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
  lldb/trunk/unittests/Utility/CMakeLists.txt
  lldb/trunk/unittests/Utility/CleanUpTest.cpp

Index: lldb/trunk/lldb.xcodeproj/project.pbxproj
===
--- lldb/trunk/lldb.xcodeproj/project.pbxproj
+++ lldb/trunk/lldb.xcodeproj/project.pbxproj
@@ -770,6 +770,7 @@
 		6D99A3631BBC2F3200979793 /* ArmUnwindInfo.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 6D99A3621BBC2F3200979793 /* ArmUnwindInfo.cpp */; };
 		6D9AB3DD1BB2B74E003F2289 /* TypeMap.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 6D9AB3DC1BB2B74E003F2289 /* TypeMap.cpp */; };
 		6DEC6F391BD66D750091ABA6 /* TaskPool.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 6DEC6F381BD66D750091ABA6 /* TaskPool.cpp */; };
+		7F94D7182040A13A006EE3EA /* CleanUpTest.cpp in CopyFiles */ = {isa = PBXBuildFile; fileRef = 7F94D7172040A13A006EE3EA /* CleanUpTest.cpp */; };
 		8C26C4261C3EA5F90031DF7C /* TSanRuntime.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 8C26C4241C3EA4340031DF7C /* TSanRuntime.cpp */; };
 		8C2D6A53197A1EAF006989C9 /* MemoryHistory.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 8C2D6A52197A1EAF006989C9 /* MemoryHistory.cpp */; };
 		8C2D6A5E197A250F006989C9 /* MemoryHistoryASan.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 8C2D6A5A197A1FDC006989C9 /* MemoryHistoryASan.cpp */; };
@@ -1242,6 +1243,7 @@
 			dstPath = "$(DEVELOPER_INSTALL_DIR)/usr/share/man/man1";
 			dstSubfolderSpec = 0;
 			files = (
+7F94D7182040A13A006EE3EA /* CleanUpTest.cpp in CopyFiles */,
 AF90106515AB7D3600FF120D /* lldb.1 in CopyFiles */,
 			);
 			runOnlyForDeploymentPostprocessing = 1;
@@ -2672,6 +2674,7 @@
 		6D9AB3DE1BB2B76B003F2289 /* TypeMap.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = TypeMap.h; path = include/lldb/Symbol/TypeMap.h; sourceTree = ""; };
 		6DEC6F381BD66D750091ABA6 /* TaskPool.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = TaskPool.cpp; path = source/Host/common/TaskPool.cpp; sourceTree = ""; };
 		6DEC6F3A1BD66D950091ABA6 /* TaskPool.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = TaskPool.h; path = include/lldb/Host/TaskPool.h; sourceTree = ""; };
+		7F94D7172040A13A006EE3EA /* CleanUpTest.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CleanUpTest.cpp; sourceTree = ""; };
 		8C26C4241C3EA4340031DF7C /* TSanRuntime.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = TSanRuntime.cpp; path = TSan/TSanRuntime.cpp; sourceTree = ""; };
 		8C26C4251C3EA4340031DF7C /* TSanRuntime.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = TSanRuntime.h; path = TSan/TSanRuntime.h; sourceTree = ""; };
 		8C2D6A52197A1EAF006989C9 /* MemoryHistory.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = MemoryHistory.cpp; path = source/Target/MemoryHistory.cpp; sourceTree = ""; };
@@ -3419,6 +3422,7 @@
 		2321F9421BDD343A00BA9A93 /* Utility */ = {
 			isa = PBXGroup;
 			children = (
+7F94D7172040A13A006EE3EA /* CleanUpTest.cpp */,
 23E2E5161D903689006F38BB /* ArchSpecTest.cpp */,
 9A3D43C81F3150D200EB767C /* ConstStringTest.cpp */,
 9A3D43C71F3150D200EB767C /* LogTest.cpp */,
Index: lldb/trunk/unittests/Utility/CMakeLists.txt
===
--- lldb/trunk/unittests/Utility/CMakeLists.txt
+++ lldb/trunk/unittests/Utility/CMakeLists.txt
@@ -1,5 +1,6 @@
 add_lldb_unittest(UtilityTests
   ArchSpecTest.cpp
+  CleanUpTest.cpp
   ConstStringTest.cpp
   EnvironmentTest.cpp
   JSONTest.cpp
Index: lldb/trunk/unittests/Utility/CleanUpTest.cpp
===
--- lldb/trunk/unittests/Utility/CleanUpTest.cpp
+++ lldb/trunk/unittests/Utility/CleanUpTest.cpp
@@ -0,0 +1,47 @@
+//===-- CleanUpTest.cpp -*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#include "lldb/Utility/CleanUp.h"
+#include "gtest/gtest.h"
+
+using 

[Lldb-commits] [PATCH] D43694: Add a sanity check for inline tests

2018-02-26 Thread Phabricator via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL326140: Add a sanity check for inline testcases. (authored 
by adrian, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D43694?vs=135693=135990#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D43694

Files:
  lldb/trunk/packages/Python/lldbsuite/test/lang/c/inlines/main.c
  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
@@ -182,14 +182,23 @@
 parser.set_breakpoints(target)
 
 process = target.LaunchSimple(None, None, self.getBuildDir())
+hit_breakpoints = 0
 
 while lldbutil.get_stopped_thread(process, lldb.eStopReasonBreakpoint):
+hit_breakpoints += 1
 thread = lldbutil.get_stopped_thread(
 process, lldb.eStopReasonBreakpoint)
 breakpoint_id = thread.GetStopReasonDataAtIndex(0)
 parser.handle_breakpoint(self, breakpoint_id)
 process.Continue()
 
+self.assertTrue(hit_breakpoints > 0,
+"inline test did not hit a single breakpoint")
+# Either the process exited or the stepping plan is complete.
+self.assertTrue(process.GetState() in [lldb.eStateStopped,
+   lldb.eStateExited],
+PROCESS_EXITED)
+
 # Utilities for testcases
 
 def check_expression(self, expression, expected_result, use_summary=True):
Index: lldb/trunk/packages/Python/lldbsuite/test/lang/c/inlines/main.c
===
--- lldb/trunk/packages/Python/lldbsuite/test/lang/c/inlines/main.c
+++ lldb/trunk/packages/Python/lldbsuite/test/lang/c/inlines/main.c
@@ -21,4 +21,5 @@
 int main() {
 test2(42);
 test1(23);
+return 0;
 }


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
@@ -182,14 +182,23 @@
 parser.set_breakpoints(target)
 
 process = target.LaunchSimple(None, None, self.getBuildDir())
+hit_breakpoints = 0
 
 while lldbutil.get_stopped_thread(process, lldb.eStopReasonBreakpoint):
+hit_breakpoints += 1
 thread = lldbutil.get_stopped_thread(
 process, lldb.eStopReasonBreakpoint)
 breakpoint_id = thread.GetStopReasonDataAtIndex(0)
 parser.handle_breakpoint(self, breakpoint_id)
 process.Continue()
 
+self.assertTrue(hit_breakpoints > 0,
+"inline test did not hit a single breakpoint")
+# Either the process exited or the stepping plan is complete.
+self.assertTrue(process.GetState() in [lldb.eStateStopped,
+   lldb.eStateExited],
+PROCESS_EXITED)
+
 # Utilities for testcases
 
 def check_expression(self, expression, expected_result, use_summary=True):
Index: lldb/trunk/packages/Python/lldbsuite/test/lang/c/inlines/main.c
===
--- lldb/trunk/packages/Python/lldbsuite/test/lang/c/inlines/main.c
+++ lldb/trunk/packages/Python/lldbsuite/test/lang/c/inlines/main.c
@@ -21,4 +21,5 @@
 int main() {
 test2(42);
 test1(23);
+return 0;
 }
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


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

2018-08-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=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] 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=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 _ap,
lldb::StackFrameListSP _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 _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 thread this frame 

[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)]
+  

[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 LLVMs 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=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",
 );
 

[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, );
+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, );
+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, );
+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, );
+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, );
+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, );
+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] 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=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=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 _indexes,
 SymbolContextList _list);
 
+  void RegisterMangledNameEntry(
+  NameToIndexMap::Entry , std::set _contexts,
+  std::vector> ,
+  RichManglingContext );
+
+  void RegisterBacklogEntry(const NameToIndexMap::Entry ,
+const char *decl_context,
+const std::set _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 );
+
+  /// Use the legacy language parser implementation to obtain rich mangling
+  /// information from the given demangled name.
+  bool FromCxxMethodName(const ConstString );
+
+  /// 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 recent ParseXy() operation. The next ParseXy() call invalidates 

[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=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] 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=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  =
-  *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  = m_string_pools[h].m_string_map;
+  StringPoolEntryType  = *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] 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=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-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=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 _spec);
+  bool SetArchitecture(const ArchSpec _spec, bool set_platform = false);
 
   bool MergeArchitecture(const ArchSpec _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=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 _spec);
+  bool SetArchitecture(const ArchSpec _spec, bool set_platform = false);
 
   bool MergeArchitecture(const ArchSpec _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,
+ 'Verify "%s" has 

[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, 

[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=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=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 = ::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
 ); // libc++ std::shared_ptr<> and std::weak_ptr<>
 
+bool LibcxxFunctionSummaryProvider(
+ValueObject , Stream ,
+const TypeSummaryOptions ); // 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)?1::)weak_ptr<.+>(( )?&)?$"), 

[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=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] 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=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 _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 _dict,
 Status ) {
   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_inlines);
   

[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 

[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=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] 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: Dont 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=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=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 , const SymbolContext ,
+   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 _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  = all_scs[0];
+auto worklist_begin = std::partition(
+all_scs.begin(), all_scs.end(), [&](const SymbolContext ) {
+  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 ) {
+  return closest_line != sc.line_entry.line;
+});
+
+// Sort by file address.
+std::sort(worklist_begin, worklist_end,
+  [](const SymbolContext , const SymbolContext ) {
+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_if(std::next(first), 

[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=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 ) 
{
   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 ) {
   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] D44507: [cmake] Copy system debugserver from the right place when only CommandLineTools are installed

2018-03-15 Thread Phabricator via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL327691: [cmake] Copy system debugserver from the right place 
when only CommandLineTools (authored by vedantk, committed by ).
Herald added a subscriber: llvm-commits.

Repository:
  rL LLVM

https://reviews.llvm.org/D44507

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


Index: lldb/trunk/tools/debugserver/source/CMakeLists.txt
===
--- lldb/trunk/tools/debugserver/source/CMakeLists.txt
+++ lldb/trunk/tools/debugserver/source/CMakeLists.txt
@@ -106,8 +106,15 @@
 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" 
CACHE PATH "Path to debugserver.")
+  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.")
+  else()
+message(SEND_ERROR "Cannot find debugserver on system.")
+  endif()
   set(SKIP_DEBUGSERVER ON CACHE BOOL "Skip building the in-tree debug server")
 endif()
 message(STATUS "Path to the lldb debugserver: ${DEBUGSERVER_PATH}")


Index: lldb/trunk/tools/debugserver/source/CMakeLists.txt
===
--- lldb/trunk/tools/debugserver/source/CMakeLists.txt
+++ lldb/trunk/tools/debugserver/source/CMakeLists.txt
@@ -106,8 +106,15 @@
 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" CACHE PATH "Path to debugserver.")
+  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.")
+  else()
+message(SEND_ERROR "Cannot find debugserver on system.")
+  endif()
   set(SKIP_DEBUGSERVER ON CACHE BOOL "Skip building the in-tree debug server")
 endif()
 message(STATUS "Path to the lldb debugserver: ${DEBUGSERVER_PATH}")
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D44502: Fix a bug in "target.source-map" where we would resolve unmapped paths incorrectly

2018-03-14 Thread Phabricator via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL327600: Fix a bug in target.source-map where we 
would resolve unmapped paths… (authored by gclayton, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D44502?vs=138472=138491#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D44502

Files:
  
lldb/trunk/packages/Python/lldbsuite/test/functionalities/source-map/TestTargetSourceMap.py
  lldb/trunk/packages/Python/lldbsuite/test/functionalities/source-map/a.yaml
  lldb/trunk/source/Target/Target.cpp

Index: lldb/trunk/packages/Python/lldbsuite/test/functionalities/source-map/a.yaml
===
--- lldb/trunk/packages/Python/lldbsuite/test/functionalities/source-map/a.yaml
+++ lldb/trunk/packages/Python/lldbsuite/test/functionalities/source-map/a.yaml
@@ -0,0 +1,396 @@
+--- !mach-o
+FileHeader:
+  magic:   0xFEEDFACF
+  cputype: 0x0107
+  cpusubtype:  0x0003
+  filetype:0x000A
+  ncmds:   6
+  sizeofcmds:  1376
+  flags:   0x
+  reserved:0x
+LoadCommands:
+  - cmd: LC_UUID
+cmdsize: 24
+uuid:D37CC773-C218-3F97-99C9-CE4E77DDF2CE
+  - cmd: LC_SYMTAB
+cmdsize: 24
+symoff:  4096
+nsyms:   2
+stroff:  4128
+strsize: 28
+  - 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:0
+maxprot: 7
+initprot:5
+nsects:  2
+flags:   0
+Sections:
+  - sectname:__text
+segname: __TEXT
+addr:0x00010FA0
+size:15
+offset:  0x
+align:   4
+reloff:  0x
+nreloc:  0
+flags:   0x8400
+reserved1:   0x
+reserved2:   0x
+reserved3:   0x
+  - sectname:__unwind_info
+segname: __TEXT
+addr:0x00010FB0
+size:72
+offset:  0x
+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:60
+maxprot: 7
+initprot:1
+nsects:  0
+flags:   0
+  - cmd: LC_SEGMENT_64
+cmdsize: 952
+segname: __DWARF
+vmaddr:  4294975488
+vmsize:  4096
+fileoff: 8192
+filesize:563
+maxprot: 7
+initprot:3
+nsects:  11
+flags:   0
+Sections:
+  - sectname:__debug_line
+segname: __DWARF
+addr:0x00012000
+size:60
+offset:  0x2000
+align:   0
+reloff:  0x
+nreloc:  0
+flags:   0x
+reserved1:   0x
+reserved2:   0x
+reserved3:   0x
+  - sectname:__debug_pubnames
+segname: __DWARF
+addr:0x0001203C
+size:27
+offset:  0x203C
+align:   0
+reloff:  0x
+nreloc:  0
+flags:   0x
+reserved1:   0x
+reserved2:   0x
+reserved3:   0x
+  - sectname:__debug_pubtypes
+segname: __DWARF
+addr:0x00012057
+size:26
+offset:  0x2057
+align:   0
+reloff:  0x
+nreloc:  0
+flags:   0x
+reserved1:   0x
+reserved2:   0x
+reserved3:   0x
+  - sectname:__debug_aranges
+segname: __DWARF
+addr:0x00012071
+size:48
+

[Lldb-commits] [PATCH] D44342: Introduce a setting to disable Spotlight while running the test suite

2018-03-12 Thread Phabricator via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL327330: Introduce a setting to disable Spotlight while 
running the test suite (authored by adrian, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D44342?vs=138086=138093#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D44342

Files:
  lldb/trunk/include/lldb/Core/ModuleList.h
  lldb/trunk/lit/lit-lldb-init
  lldb/trunk/lit/lit.cfg
  lldb/trunk/packages/Python/lldbsuite/test/lldbtest.py
  lldb/trunk/source/Core/ModuleList.cpp
  lldb/trunk/source/Host/macosx/Symbols.cpp

Index: lldb/trunk/source/Host/macosx/Symbols.cpp
===
--- lldb/trunk/source/Host/macosx/Symbols.cpp
+++ lldb/trunk/source/Host/macosx/Symbols.cpp
@@ -23,6 +23,7 @@
 #include "Host/macosx/cfcpp/CFCData.h"
 #include "Host/macosx/cfcpp/CFCReleaser.h"
 #include "Host/macosx/cfcpp/CFCString.h"
+#include "lldb/Core/ModuleList.h"
 #include "lldb/Core/ModuleSpec.h"
 #include "lldb/Host/Host.h"
 #include "lldb/Symbol/ObjectFile.h"
@@ -54,6 +55,13 @@
 
 int LocateMacOSXFilesUsingDebugSymbols(const ModuleSpec _spec,
ModuleSpec _module_spec) {
+  Log *log = lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_HOST);
+  if (!ModuleList::GetGlobalModuleListProperties().GetEnableExternalLookup()) {
+if (log)
+  log->Printf("Spotlight lookup for .dSYM bundles is disabled.");
+return 0;
+  }
+  
   return_module_spec = module_spec;
   return_module_spec.GetFileSpec().Clear();
   return_module_spec.GetSymbolFileSpec().Clear();
@@ -79,7 +87,6 @@
   if (module_uuid_ref.get()) {
 CFCReleaser exec_url;
 const FileSpec *exec_fspec = module_spec.GetFileSpecPtr();
-Log *log = lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_HOST);
 if (exec_fspec) {
   char exec_cf_path[PATH_MAX];
   if (exec_fspec->GetPath(exec_cf_path, sizeof(exec_cf_path)))
Index: lldb/trunk/source/Core/ModuleList.cpp
===
--- lldb/trunk/source/Core/ModuleList.cpp
+++ lldb/trunk/source/Core/ModuleList.cpp
@@ -67,12 +67,17 @@
 namespace {
 
 PropertyDefinition g_properties[] = {
+{"enable-external-lookup", OptionValue::eTypeBoolean, true, true, nullptr,
+ nullptr,
+ "Control the use of external tools or libraries to locate symbol files. "
+ "On macOS, Spotlight is used to locate a matching .dSYM bundle based on "
+ "the UUID of the executable."},
 {"clang-modules-cache-path", OptionValue::eTypeFileSpec, true, 0, nullptr,
  nullptr,
  "The path to the clang modules cache directory (-fmodules-cache-path)."},
 {nullptr, OptionValue::eTypeInvalid, false, 0, nullptr, nullptr, nullptr}};
 
-enum { ePropertyClangModulesCachePath };
+enum { ePropertyEnableExternalLookup, ePropertyClangModulesCachePath };
 
 } // namespace
 
@@ -85,6 +90,12 @@
   SetClangModulesCachePath(path);
 }
 
+bool ModuleListProperties::GetEnableExternalLookup() const {
+  const uint32_t idx = ePropertyEnableExternalLookup;
+  return m_collection_sp->GetPropertyAtIndexAsBoolean(
+  nullptr, idx, g_properties[idx].default_uint_value != 0);
+}
+
 FileSpec ModuleListProperties::GetClangModulesCachePath() const {
   return m_collection_sp
   ->GetPropertyAtIndexAsOptionValueFileSpec(nullptr, false,
Index: lldb/trunk/lit/lit.cfg
===
--- lldb/trunk/lit/lit.cfg
+++ lldb/trunk/lit/lit.cfg
@@ -55,7 +55,8 @@
 config.substitutions.append(('%python', config.python_executable))
 
 debugserver = lit.util.which('debugserver', lldb_tools_dir)
-lldb = lit.util.which('lldb', lldb_tools_dir)
+lldb = "%s -S %s/lit-lldb-init" % (lit.util.which('lldb', lldb_tools_dir),
+   config.test_source_root)
 
 if not os.path.exists(config.cc):
 config.cc = lit.util.which(config.cc, config.environment['PATH'])
Index: lldb/trunk/lit/lit-lldb-init
===
--- lldb/trunk/lit/lit-lldb-init
+++ lldb/trunk/lit/lit-lldb-init
@@ -0,0 +1,2 @@
+# LLDB init file for the LIT tests.
+settings set symbols.enable-external-lookup false
Index: lldb/trunk/include/lldb/Core/ModuleList.h
===
--- lldb/trunk/include/lldb/Core/ModuleList.h
+++ lldb/trunk/include/lldb/Core/ModuleList.h
@@ -81,6 +81,7 @@
 
   FileSpec GetClangModulesCachePath() const;
   bool SetClangModulesCachePath(llvm::StringRef path);
+  bool GetEnableExternalLookup() const;
 }; 
 
 //--
Index: lldb/trunk/packages/Python/lldbsuite/test/lldbtest.py
===
--- lldb/trunk/packages/Python/lldbsuite/test/lldbtest.py
+++ 

[Lldb-commits] [PATCH] D45592: Allow relative file paths when settings source breakpoints

2018-04-13 Thread Phabricator via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL330028: Allow relative file paths when settings source 
breakpoints (authored by gclayton, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D45592?vs=142289=142413#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D45592

Files:
  lldb/trunk/include/lldb/Breakpoint/BreakpointResolverFileLine.h
  
lldb/trunk/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_command/TestBreakpointCommand.py
  lldb/trunk/packages/Python/lldbsuite/test/lldbutil.py
  lldb/trunk/source/Breakpoint/BreakpointResolverFileLine.cpp

Index: lldb/trunk/packages/Python/lldbsuite/test/lldbutil.py
===
--- lldb/trunk/packages/Python/lldbsuite/test/lldbutil.py
+++ lldb/trunk/packages/Python/lldbsuite/test/lldbutil.py
@@ -576,7 +576,7 @@
 if 'file' in break_results:
 out_file_name = break_results['file']
 test.assertTrue(
-file_name == out_file_name,
+file_name.endswith(out_file_name),
 "Breakpoint file name '%s' doesn't match resultant name '%s'." %
 (file_name,
  out_file_name))
Index: lldb/trunk/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_command/TestBreakpointCommand.py
===
--- lldb/trunk/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_command/TestBreakpointCommand.py
+++ lldb/trunk/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_command/TestBreakpointCommand.py
@@ -62,7 +62,31 @@
 # setting breakpoint commands on two breakpoints at a time
 lldbutil.run_break_set_by_file_and_line(
 self, None, self.line, num_expected_locations=1, loc_exact=True)
-
+# Make sure relative path source breakpoints work as expected. We test
+# with partial paths with and without "./" prefixes.
+lldbutil.run_break_set_by_file_and_line(
+self, "./main.c", self.line,
+num_expected_locations=1, loc_exact=True)
+lldbutil.run_break_set_by_file_and_line(
+self, "breakpoint_command/main.c", self.line,
+num_expected_locations=1, loc_exact=True)
+lldbutil.run_break_set_by_file_and_line(
+self, "./breakpoint_command/main.c", self.line,
+num_expected_locations=1, loc_exact=True)
+lldbutil.run_break_set_by_file_and_line(
+self, "breakpoint/breakpoint_command/main.c", self.line,
+num_expected_locations=1, loc_exact=True)
+lldbutil.run_break_set_by_file_and_line(
+self, "./breakpoint/breakpoint_command/main.c", self.line,
+num_expected_locations=1, loc_exact=True)
+# Test relative breakpoints with incorrect paths and make sure we get
+# no breakpoint locations
+lldbutil.run_break_set_by_file_and_line(
+self, "invalid/main.c", self.line,
+num_expected_locations=0, loc_exact=True)
+lldbutil.run_break_set_by_file_and_line(
+self, "./invalid/main.c", self.line,
+num_expected_locations=0, loc_exact=True)
 # Now add callbacks for the breakpoints just created.
 self.runCmd(
 "breakpoint command add -s command -o 'frame variable --show-types --scope' 1 4")
Index: lldb/trunk/source/Breakpoint/BreakpointResolverFileLine.cpp
===
--- lldb/trunk/source/Breakpoint/BreakpointResolverFileLine.cpp
+++ lldb/trunk/source/Breakpoint/BreakpointResolverFileLine.cpp
@@ -115,15 +115,35 @@
 // here is handling inlined functions -- in this case we need to make sure we
 // look at the declaration line of the inlined function, NOT the function it was
 // inlined into.
-void BreakpointResolverFileLine::FilterContexts(SymbolContextList _list) {
+void BreakpointResolverFileLine::FilterContexts(SymbolContextList _list,
+bool is_relative) {
   if (m_exact_match)
 return; // Nothing to do. Contexts are precise.
 
+  llvm::StringRef relative_path;
+  if (is_relative)
+relative_path = m_file_spec.GetNormalizedPath().GetDirectory().GetStringRef();
+
   Log * log = GetLogIfAllCategoriesSet(LIBLLDB_LOG_BREAKPOINTS);
   for(uint32_t i = 0; i < sc_list.GetSize(); ++i) {
 SymbolContext sc;
 sc_list.GetContextAtIndex(i, sc);
-if (! sc.block)
+if (is_relative) {
+  // If the path was relative, make sure any matches match as long as the
+  // relative parts of the path match the path from support files
+  auto sc_dir = sc.line_entry.file.GetDirectory().GetStringRef();
+  if (!sc_dir.endswith(relative_path)) {
+// We had a relative path specified and the relative directory
+// doesn't match so 

[Lldb-commits] [PATCH] D43984: Make the clang module cache setting available without a target

2018-03-02 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 rL326628: Make the clang module cache setting available 
without a target (authored by adrian, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D43984?vs=136803=136858#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D43984

Files:
  lldb/trunk/include/lldb/Core/ModuleList.h
  lldb/trunk/include/lldb/Target/Target.h
  lldb/trunk/packages/Python/lldbsuite/test/lang/objc/modules-cache/Makefile
  
lldb/trunk/packages/Python/lldbsuite/test/lang/objc/modules-cache/TestClangModulesCache.py
  lldb/trunk/packages/Python/lldbsuite/test/lang/objc/modules-cache/f.h
  lldb/trunk/packages/Python/lldbsuite/test/lang/objc/modules-cache/main.m
  
lldb/trunk/packages/Python/lldbsuite/test/lang/objc/modules-cache/module.modulemap
  lldb/trunk/packages/Python/lldbsuite/test/lldbtest.py
  lldb/trunk/source/Core/Debugger.cpp
  lldb/trunk/source/Core/ModuleList.cpp
  lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.cpp
  lldb/trunk/source/Target/Target.cpp

Index: lldb/trunk/include/lldb/Core/ModuleList.h
===
--- lldb/trunk/include/lldb/Core/ModuleList.h
+++ lldb/trunk/include/lldb/Core/ModuleList.h
@@ -12,6 +12,7 @@
 
 #include "lldb/Core/Address.h" // for Address
 #include "lldb/Core/ModuleSpec.h"  // for ModuleSpec
+#include "lldb/Core/UserSettingsController.h"
 #include "lldb/Utility/FileSpec.h" // for FileSpec
 #include "lldb/Utility/Iterable.h"
 #include "lldb/Utility/Status.h" // for Status
@@ -74,6 +75,14 @@
 
 namespace lldb_private {
 
+class ModuleListProperties : public Properties {
+public:
+  ModuleListProperties();
+
+  FileSpec GetClangModulesCachePath() const;
+  bool SetClangModulesCachePath(llvm::StringRef path);
+}; 
+
 //--
 /// @class ModuleList ModuleList.h "lldb/Core/ModuleList.h"
 /// @brief A collection class for Module objects.
@@ -534,6 +543,8 @@
   Stream *feedback_stream = nullptr,
   bool continue_on_error = true);
 
+  static ModuleListProperties ();
+
   static bool ModuleIsInCache(const Module *module_ptr);
 
   static Status GetSharedModule(const ModuleSpec _spec,
@@ -551,7 +562,7 @@
   static size_t RemoveOrphanSharedModules(bool mandatory);
 
   static bool RemoveSharedModuleIfOrphaned(const Module *module_ptr);
-
+  
   void ForEach(std::function const
) const;
 
Index: lldb/trunk/include/lldb/Target/Target.h
===
--- lldb/trunk/include/lldb/Target/Target.h
+++ lldb/trunk/include/lldb/Target/Target.h
@@ -126,8 +126,6 @@
 
   FileSpecList ();
 
-  FileSpec ();
-
   FileSpecList ();
 
   bool GetEnableAutoImportClangModules() const;
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
@@ -1921,8 +1921,8 @@
 if self.child:
 assert(self.getDebugInfo() == 'default')
 mod_cache = os.path.join(self.getBuildDir(), "module-cache")
-self.runCmd("settings set target.clang-modules-cache-path "
-+ mod_cache)
+self.runCmd('settings set clang.modules-cache-path "%s"'
+% mod_cache)
 
 
 if "LLDB_MAX_LAUNCH_COUNT" in os.environ:
Index: lldb/trunk/packages/Python/lldbsuite/test/lang/objc/modules-cache/main.m
===
--- lldb/trunk/packages/Python/lldbsuite/test/lang/objc/modules-cache/main.m
+++ lldb/trunk/packages/Python/lldbsuite/test/lang/objc/modules-cache/main.m
@@ -0,0 +1,5 @@
+@import Foo;
+int main() {
+  f(); // Set breakpoint here.
+  return 0;
+}
Index: lldb/trunk/packages/Python/lldbsuite/test/lang/objc/modules-cache/Makefile
===
--- lldb/trunk/packages/Python/lldbsuite/test/lang/objc/modules-cache/Makefile
+++ lldb/trunk/packages/Python/lldbsuite/test/lang/objc/modules-cache/Makefile
@@ -0,0 +1,4 @@
+LEVEL = ../../../make
+OBJC_SOURCES := main.m
+include $(LEVEL)/Makefile.rules
+CFLAGS += $(MANDATORY_MODULE_BUILD_CFLAGS) -I$(SRCDIR)
Index: lldb/trunk/packages/Python/lldbsuite/test/lang/objc/modules-cache/f.h
===
--- lldb/trunk/packages/Python/lldbsuite/test/lang/objc/modules-cache/f.h
+++ lldb/trunk/packages/Python/lldbsuite/test/lang/objc/modules-cache/f.h
@@ -0,0 +1 @@
+void f() {}
Index: 

[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 ? 

[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=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:
 

[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 _spec,
+const FileSpec _fspec,
+FileSpec _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 _spec,
   FileSpec _fspec) {
   Log *log = lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_HOST);
-  const FileSpec *exec_fspec = module_spec.GetFileSpecPtr();
+  const FileSpec _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());
-  } else {
-

[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=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 ,
+ ConstString , 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 ) {
+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()) return false;
+if 

[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=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(
+

[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=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] 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=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] 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=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, _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, _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, _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, _ctx);
   return children_count <= max ? children_count : max;
 }
 
Index: lldb/trunk/source/Core/ValueObjectChild.cpp
===
--- 

[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=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 , 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 , Stream , const TypeSummaryOptions ) {
   lldb::ValueObjectSP name_sp;
   lldb::ValueObjectSP reason_sp;
-  if (!ExtractFields(valobj, _sp, _sp, nullptr))
+  if (!ExtractFields(valobj, _sp, _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, _userinfo_sp)) {
+m_reserved_sp.reset();
+
+if (!ExtractFields(m_backend, _name_sp, _reason_sp, _userinfo_sp,
+   _reserved_sp)) {
   return false;
 }
 return true;
   }
 
   bool MightHaveChildren() override { return true; }
 
   size_t GetIndexOfChildWithName(const ConstString ) 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.
+//
+//===--===//
+
+#import 
+
+void foo()
+{
+ 

[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=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] 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=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 () {
+static std::mutex g_architecture_mutex;
+return g_architecture_mutex;
+}
 
 static ArchitectureInstances () {
   static ArchitectureInstances g_instances;
@@ -296,13 +299,13 @@
 void PluginManager::RegisterPlugin(const ConstString ,
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  = GetArchitectureInstances();
 
   for (auto pos = instances.begin(), end = instances.end(); pos != end; ++pos) 
{
@@ -316,7 +319,7 @@
 
 std::unique_ptr
 PluginManager::CreateArchitectureInstance(const ArchSpec ) {
-  std::lock_guard guard(g_architecture_mutex);
+  std::lock_guard guard(GetArchitectureMutex());
   for (const auto  : 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 () {
+static std::mutex g_architecture_mutex;
+return g_architecture_mutex;
+}
 
 static ArchitectureInstances () {
   static ArchitectureInstances g_instances;
@@ -296,13 +299,13 @@
 void PluginManager::RegisterPlugin(const ConstString ,
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  = GetArchitectureInstances();
 
   for (auto pos = instances.begin(), end = instances.end(); pos != end; ++pos) {
@@ -316,7 +319,7 @@
 
 std::unique_ptr
 PluginManager::CreateArchitectureInstance(const ArchSpec ) {
-  std::lock_guard guard(g_architecture_mutex);
+  std::lock_guard guard(GetArchitectureMutex());
   for (const auto  : 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] 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] 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=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 , Stream , const TypeSummaryOptions ) {
+static bool ExtractFields(ValueObject , 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 , Stream , const TypeSummaryOptions ) {
+  lldb::ValueObjectSP name_sp;
+  lldb::ValueObjectSP reason_sp;
+  if (!ExtractFields(valobj, _sp, _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->GetSP();
-return m_child_sp;
+switch (idx) {
+  case 

[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=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 (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] 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] 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=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 = 
+
+int main() {
+  return *p;
+}
Index: source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
===
--- source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
+++ 

  1   2   3   >