Re: [Lldb-commits] [lldb] r366433 - [CMake] Always build debugserver on Darwin and allow tests to use the system's one

2019-07-19 Thread Hans Wennborg via lldb-commits
Okay, merged in r366553.


On Thu, Jul 18, 2019 at 3:38 PM Stefan Gränitz
 wrote:
>
> Hello Hans
>
> This commit would be very good to have on release/9.x. It simplifies a lot of 
> code in the code-sign and testing logic for LLDB on Darwin. This would be 
> useful for people who build their own LLDB's from upstream.
> I was testing more comprehensively then usual and, thus, just missed the 
> branch point.
>
> Best
> Stefan
>
>  Forwarded Message 
> Subject: [Lldb-commits] [lldb] r366433 - [CMake] Always build debugserver on 
> Darwin and allow tests to use the system's one
> Date: Thu, 18 Jul 2019 13:30:37 -
> From: Stefan Granitz via lldb-commits 
> Reply-To: Stefan Granitz 
> To: lldb-commits@lists.llvm.org
>
>
> Author: stefan.graenitz
> Date: Thu Jul 18 06:30:37 2019
> New Revision: 366433
>
> URL: http://llvm.org/viewvc/llvm-project?rev=366433&view=rev
> Log:
> [CMake] Always build debugserver on Darwin and allow tests to use the 
> system's one
>
> Summary:
> We can always build debugserver, but we can't always sign it to be useable 
> for testing. `LLDB_USE_SYSTEM_DEBUGSERVER` should only tell whether or not 
> the system debugserver should be used for testing.
> The old behavior complicated the logic around debugserver a lot. The new 
> logic sorts out most of it.
>
> Please note that this patch is in early stage and needs some more testing. It 
> should not affect platfroms other than Darwin. It builds on Davide's approach 
> to validate the code-signing identity at configuration time.
>
> What do you think?
>
> Reviewers: xiaobai, JDevlieghere, davide, compnerd, friss, labath, mgorny, 
> jasonmolenda
>
> Reviewed By: JDevlieghere
>
> Subscribers: lldb-commits, #lldb
>
> Tags: #lldb
>
> Differential Revision: https://reviews.llvm.org/D64806
>
> Modified:
> lldb/trunk/CMakeLists.txt
> lldb/trunk/cmake/modules/AddLLDB.cmake
> lldb/trunk/cmake/modules/LLDBConfig.cmake
> lldb/trunk/test/CMakeLists.txt
> lldb/trunk/tools/debugserver/source/CMakeLists.txt
> lldb/trunk/unittests/CMakeLists.txt
> lldb/trunk/unittests/tools/lldb-server/CMakeLists.txt
>
> Modified: lldb/trunk/CMakeLists.txt
> URL: 
> http://llvm.org/viewvc/llvm-project/lldb/trunk/CMakeLists.txt?rev=366433&r1=366432&r2=366433&view=diff
> ==
> --- lldb/trunk/CMakeLists.txt (original)
> +++ lldb/trunk/CMakeLists.txt Thu Jul 18 06:30:37 2019
> @@ -107,10 +107,6 @@ if(LLDB_INCLUDE_TESTS)
> list(APPEND LLDB_TEST_DEPS lldb-server)
> endif()
> - if(TARGET debugserver)
> - list(APPEND LLDB_TEST_DEPS debugserver)
> - endif()
> -
> if(TARGET lldb-mi)
> list(APPEND LLDB_TEST_DEPS lldb-mi)
> endif()
>
> Modified: lldb/trunk/cmake/modules/AddLLDB.cmake
> URL: 
> http://llvm.org/viewvc/llvm-project/lldb/trunk/cmake/modules/AddLLDB.cmake?rev=366433&r1=366432&r2=366433&view=diff
> ==
> --- lldb/trunk/cmake/modules/AddLLDB.cmake (original)
> +++ lldb/trunk/cmake/modules/AddLLDB.cmake Thu Jul 18 06:30:37 2019
> @@ -276,3 +276,27 @@ function(lldb_setup_rpaths name)
> INSTALL_RPATH "${LIST_INSTALL_RPATH}"
> )
> endfunction()
> +
> +function(lldb_find_system_debugserver path)
> + execute_process(COMMAND xcode-select -p
> + RESULT_VARIABLE exit_code
> + OUTPUT_VARIABLE xcode_dev_dir
> + ERROR_VARIABLE error_msg
> + OUTPUT_STRIP_TRAILING_WHITESPACE)
> + if(exit_code)
> + message(WARNING "`xcode-select -p` failed:\n${error_msg}")
> + else()
> + set(subpath "LLDB.framework/Resources/debugserver")
> + set(path_shared "${xcode_dev_dir}/../SharedFrameworks/${subpath}")
> + set(path_private "${xcode_dev_dir}/Library/PrivateFrameworks/${subpath}")
> +
> + if(EXISTS ${path_shared})
> + set(${path} ${path_shared} PARENT_SCOPE)
> + elseif(EXISTS ${path_private})
> + set(${path} ${path_private} PARENT_SCOPE)
> + else()
> + message(WARNING "System debugserver requested, but not found. "
> + "Candidates don't exist: ${path_shared}\n${path_private}")
> + endif()
> + endif()
> +endfunction()
>
> Modified: lldb/trunk/cmake/modules/LLDBConfig.cmake
> URL: 
> http://llvm.org/viewvc/llvm-project/lldb/trunk/cmake/modules/LLDBConfig.cmake?rev=366433&r1=366432&r2=366433&view=diff
> ==
> --- lldb/trunk/cmake/modules/LLDBConfig.cmake (original)
> +++ lldb/trunk/cmake/modules/LLDBConfig.cmake Thu Jul 18 06:30:37 2019
> @@ -50,6 +50,7 @@ option(LLDB_USE_SYSTEM_SIX "Use six.py s
> option(LLDB_USE_ENTITLEMENTS "When codesigning, use entitlements if 
> available" ON)
> option(LLDB_BUILD_FRAMEWORK "Build LLDB.framework (Darwin only)" OFF)
> option(LLDB_NO_INSTALL_DEFAULT_RPATH "Disable default RPATH settings in 
> binaries" OFF)
> +option(LLDB_USE_SYSTEM_DEBUGSERVER "Use the system's debugserver for testing 
> (Darwin only)." OFF)
> if(LLDB_BUILD_FRAMEWORK)
> if(NOT APPLE)
>
> Modified: lldb/trunk/test/CMakeLists.txt
> URL: 
> http://llvm.org/viewv

[Lldb-commits] [PATCH] D63165: Initial support for native debugging of x86/x64 Windows processes

2019-07-19 Thread Pavel Labath via Phabricator via lldb-commits
labath added inline comments.



Comment at: 
lldb/source/Plugins/Process/Utility/RegisterContextWindows_x86_64.cpp:141
+GetRegisterInfo_WoW64(const lldb_private::ArchSpec &arch) {
+  // A WoW64 register info is the same as the i386's.
+  std::vector &g_register_infos =

Hui wrote:
> labath wrote:
> > Why is all of this complexity necessary? Couldn't you just switch on the 
> > target architecture in `CreateRegisterInfoInterface` in 
> > NativeRegisterContextWindows_x86_64.cpp and create either 
> > `RegisterContextWindows_WoW64` or `RegisterContextWindows_x86_64` ?
> > 
> > In fact, if RegisterContextWindows_WoW64 is identical to 
> > RegisterContextWindows_i386, then why do you even need the _WoW64 version 
> > of the class in the first place? FWIW, linux also does not have a 
> > RegisterContextLinux_32_bit_process_on_64_bit_kernel class...
> I think WoW64 is i686 that shall deserve a separate arch specific 
> implementation?
I am sorry, but I don't follow. Can you repeat the question?

(FWIW, I don't believe that the fact that two things are different from a 
certain point of view justifies copy-pasting (at least) 150 LOC. If you think 
it's confusing to use something called "i386" in things dealing with WoW64, you 
can always typedef the WOW64 context to it, or rename the i386 context to 
something more generic.)



Comment at: 
lldb/source/Plugins/Process/Windows/Common/NativeProcessWindows.h:45-49
+  NativeProcessWindows(ProcessLaunchInfo &launch_info, NativeDelegate 
&delegate,
+   llvm::Error &E);
+
+  NativeProcessWindows(lldb::pid_t pid, int terminal_fd,
+   NativeDelegate &delegate, llvm::Error &E);

Hui wrote:
> labath wrote:
> > labath wrote:
> > > I guess these shouldn't be public as these object should be constructed 
> > > through the factory, right?
> > This doesn't seem to be addressed.
> These constructors contain a call to function template make_unique that is 
> not allowed to access private members of NativeProcessWindows.
> Simply do the following could address this concern.
> 
> ```
> 
> -  auto process_up =
> -  std::make_unique(launch_info, native_delegate, 
> E);
> 
> +  auto process_up = std::unique_ptr(
> +  new NativeProcessWindows(launch_info, native_delegate, E));
> ```
> 
The make_unique thing is unfortunate, but that is the nature of c++. Since 
you're concerned about consistency, I'll mention that other classes (e.g. 
NativeProcessLinux) also prioritize clarifying what is the public interface of 
a class over the niceness of being able to call make_unique.



Comment at: 
lldb/source/Plugins/Process/Windows/Common/NativeRegisterContextWindows_x86_64.cpp:104-109
+  if (::SuspendThread(thread_handle) == -1) {
+error.SetError(GetLastError(), eErrorTypeWin32);
+LLDB_LOG(log, "{0} ResumeThread failed with error {1}", __FUNCTION__,
+ error);
+return error;
+  }

Hui wrote:
> labath wrote:
> > Are these suspend/resume calls necessary? You should be able to assume that 
> > the process is stopped (due to breakpoint, exception or whatever). Nobody 
> > will be calling functions that get/set registers on a running process. 
> > (linux does not support that either, but we don't bother explicitly 
> > stopping the process before we attempt to do this).
> Yes, agreed. But such codes are added to be consistent with what is now in 
> upstream from https://reviews.llvm.org/rL364216. (CacheAllRegisterValues).
> 
Interesting. I don't think it's worth being consistent with that, as that code 
is hopefully going to go away soon, and lldb-server can offer much stronger 
guarantees about when these things can be called (due to everything being 
funneled through the gdb-remote protocol, which doesn't even support sending 
any packets while the process is running).

However, I am not familiar with windows APIs, so I'll leave this decision up to 
you...


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

https://reviews.llvm.org/D63165



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


[Lldb-commits] [lldb] r366560 - [NFC] Remove indent after r366433

2019-07-19 Thread Stefan Granitz via lldb-commits
Author: stefan.graenitz
Date: Fri Jul 19 03:20:35 2019
New Revision: 366560

URL: http://llvm.org/viewvc/llvm-project?rev=366560&view=rev
Log:
[NFC] Remove indent after r366433

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

Modified: lldb/trunk/tools/debugserver/source/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/debugserver/source/CMakeLists.txt?rev=366560&r1=366559&r2=366560&view=diff
==
--- lldb/trunk/tools/debugserver/source/CMakeLists.txt (original)
+++ lldb/trunk/tools/debugserver/source/CMakeLists.txt Fri Jul 19 03:20:35 2019
@@ -127,132 +127,130 @@ if(LLDB_USE_ENTITLEMENTS)
   endif()
 endif()
 
-#if(build_and_sign_debugserver)
-  set(generated_mach_interfaces
-${CMAKE_CURRENT_BINARY_DIR}/mach_exc.h
-${CMAKE_CURRENT_BINARY_DIR}/mach_excServer.c
-${CMAKE_CURRENT_BINARY_DIR}/mach_excUser.c
-)
-  add_custom_command(OUTPUT ${generated_mach_interfaces}
-COMMAND mig ${CMAKE_CURRENT_SOURCE_DIR}/MacOSX/dbgnub-mig.defs
-DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/MacOSX/dbgnub-mig.defs
-)
+set(generated_mach_interfaces
+  ${CMAKE_CURRENT_BINARY_DIR}/mach_exc.h
+  ${CMAKE_CURRENT_BINARY_DIR}/mach_excServer.c
+  ${CMAKE_CURRENT_BINARY_DIR}/mach_excUser.c
+  )
+add_custom_command(OUTPUT ${generated_mach_interfaces}
+  COMMAND mig ${CMAKE_CURRENT_SOURCE_DIR}/MacOSX/dbgnub-mig.defs
+  DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/MacOSX/dbgnub-mig.defs
+  )
 
-  set(DEBUGSERVER_VERS_GENERATED_FILE 
${CMAKE_CURRENT_BINARY_DIR}/debugserver_vers.c)
-  set_source_files_properties(${DEBUGSERVER_VERS_GENERATED_FILE} PROPERTIES 
GENERATED 1)
+set(DEBUGSERVER_VERS_GENERATED_FILE 
${CMAKE_CURRENT_BINARY_DIR}/debugserver_vers.c)
+set_source_files_properties(${DEBUGSERVER_VERS_GENERATED_FILE} PROPERTIES 
GENERATED 1)
 
-  add_custom_command(OUTPUT ${DEBUGSERVER_VERS_GENERATED_FILE}
-COMMAND ${LLDB_SOURCE_DIR}/scripts/generate-vers.pl
-${LLDB_SOURCE_DIR}/lldb.xcodeproj/project.pbxproj debugserver
-> ${DEBUGSERVER_VERS_GENERATED_FILE}
-DEPENDS ${LLDB_SOURCE_DIR}/scripts/generate-vers.pl
-${LLDB_SOURCE_DIR}/lldb.xcodeproj/project.pbxproj
+add_custom_command(OUTPUT ${DEBUGSERVER_VERS_GENERATED_FILE}
+  COMMAND ${LLDB_SOURCE_DIR}/scripts/generate-vers.pl
+  ${LLDB_SOURCE_DIR}/lldb.xcodeproj/project.pbxproj debugserver
+  > ${DEBUGSERVER_VERS_GENERATED_FILE}
+  DEPENDS ${LLDB_SOURCE_DIR}/scripts/generate-vers.pl
+  ${LLDB_SOURCE_DIR}/lldb.xcodeproj/project.pbxproj
+  )
+
+set(lldbDebugserverCommonSources
+  DNBArch.cpp
+  DNBBreakpoint.cpp
+  DNB.cpp
+  DNBDataRef.cpp
+  DNBError.cpp
+  DNBLog.cpp
+  DNBRegisterInfo.cpp
+  DNBThreadResumeActions.cpp
+  JSON.cpp
+  StdStringExtractor.cpp
+  # JSON reader depends on the following LLDB-common files
+  ${LLDB_SOURCE_DIR}/source/Host/common/StringConvert.cpp
+  ${LLDB_SOURCE_DIR}/source/Host/common/SocketAddress.cpp
+  # end JSON reader dependencies
+  libdebugserver.cpp
+  PseudoTerminal.cpp
+  PThreadEvent.cpp
+  PThreadMutex.cpp
+  RNBContext.cpp
+  RNBRemote.cpp
+  RNBServices.cpp
+  RNBSocket.cpp
+  SysSignal.cpp
+  TTYState.cpp
+
+  MacOSX/CFBundle.cpp
+  MacOSX/CFString.cpp
+  MacOSX/Genealogy.cpp
+  MacOSX/MachException.cpp
+  MacOSX/MachProcess.mm
+  MacOSX/MachTask.mm
+  MacOSX/MachThread.cpp
+  MacOSX/MachThreadList.cpp
+  MacOSX/MachVMMemory.cpp
+  MacOSX/MachVMRegion.cpp
+  MacOSX/OsLogger.cpp
+  ${generated_mach_interfaces}
+  ${DEBUGSERVER_VERS_GENERATED_FILE})
+
+add_library(lldbDebugserverCommon ${lldbDebugserverCommonSources})
+set_target_properties(lldbDebugserverCommon PROPERTIES FOLDER "lldb 
libraries/debugserver")
+
+target_link_libraries(lldbDebugserverCommon
+  INTERFACE ${COCOA_LIBRARY}
+  ${CORE_FOUNDATION_LIBRARY}
+  ${FOUNDATION_LIBRARY}
+  ${BACKBOARD_LIBRARY}
+  ${FRONTBOARD_LIBRARY}
+  ${SPRINGBOARD_LIBRARY}
+  ${MOBILESERVICES_LIBRARY}
+  ${LOCKDOWN_LIBRARY}
+  lldbDebugserverArchSupport
+  lldbDebugserverDarwin_DarwinLog
+  ${LIBCOMPRESSION})
+if(HAVE_LIBCOMPRESSION)
+  set_property(TARGET lldbDebugserverCommon APPEND PROPERTY
+COMPILE_DEFINITIONS HAVE_LIBCOMPRESSION)
+endif()
+set(LLVM_OPTIONAL_SOURCES ${lldbDebugserverCommonSources})
+add_lldb_tool(debugserver ADD_TO_FRAMEWORK
+  debugserver.cpp
+  LINK_LIBS lldbDebugserverCommon
+  ENTITLEMENTS ${entitlements}
+)
+
+set_target_properties(debugserver PROPERTIES FOLDER "lldb 
libraries/debugserver")
+
+if(IOS)
+  set_property(TARGET lldbDebugserverCommon APPEND PROPERTY COMPILE_DEFINITIONS
+WITH_LOCKDOWN
+WITH_FBS
+WITH_BKS
+)
+  set_property(TARGET debugserver APPEND PROPERTY COMPILE_DEFINITIONS
+WITH_LOCKDOWN
+WITH_FBS
+WITH_BKS
+)
+  

[Lldb-commits] [lldb] r366561 - [lldb][NFC] Tablegenify target

2019-07-19 Thread Raphael Isemann via lldb-commits
Author: teemperor
Date: Fri Jul 19 03:23:22 2019
New Revision: 366561

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

Modified:
lldb/trunk/source/Commands/CommandObjectTarget.cpp
lldb/trunk/source/Commands/Options.td
lldb/trunk/source/Commands/OptionsBase.td

Modified: lldb/trunk/source/Commands/CommandObjectTarget.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectTarget.cpp?rev=366561&r1=366560&r2=366561&view=diff
==
--- lldb/trunk/source/Commands/CommandObjectTarget.cpp (original)
+++ lldb/trunk/source/Commands/CommandObjectTarget.cpp Fri Jul 19 03:23:22 2019
@@ -145,12 +145,9 @@ static constexpr OptionEnumValueElement
  "Load dependents, even if the target is not an executable."}};
 
 static constexpr OptionDefinition g_dependents_options[] = {
-{LLDB_OPT_SET_1, false, "no-dependents", 'd',
- OptionParser::eOptionalArgument, nullptr,
- OptionEnumValues(g_dependents_enumaration), 0, eArgTypeValue,
- "Whether or not to load dependents when creating a target. If the option "
- "is not specified, the value is implicitly 'default'. If the option is "
- "specified but without a value, the value is implicitly 'true'."}};
+#define LLDB_OPTIONS_target_dependents
+#include "CommandOptions.inc"
+};
 
 class OptionGroupDependents : public OptionGroup {
 public:
@@ -2455,16 +2452,8 @@ protected:
 
 llvm::ArrayRef GetDefinitions() override {
   static constexpr OptionDefinition g_options[] = {
-  {LLDB_OPT_SET_ALL,
-   false,
-   "verbose",
-   'v',
-   OptionParser::eNoArgument,
-   nullptr,
-   {},
-   0,
-   eArgTypeNone,
-   "Enable verbose dump."},
+#define LLDB_OPTIONS_target_modules_dump
+#include "CommandOptions.inc"
   };
   return llvm::makeArrayRef(g_options);
 }
@@ -2970,23 +2959,8 @@ protected:
 // List images with associated information
 
 static constexpr OptionDefinition g_target_modules_list_options[] = {
-// clang-format off
-  { LLDB_OPT_SET_1, false, "address",'a', 
OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypeAddressOrExpression, 
"Display the image at this address." },
-  { LLDB_OPT_SET_1, false, "arch",   'A', 
OptionParser::eOptionalArgument, nullptr, {}, 0, eArgTypeWidth,   
"Display the architecture when listing images." },
-  { LLDB_OPT_SET_1, false, "triple", 't', 
OptionParser::eOptionalArgument, nullptr, {}, 0, eArgTypeWidth,   
"Display the triple when listing images." },
-  { LLDB_OPT_SET_1, false, "header", 'h', OptionParser::eNoArgument,   
nullptr, {}, 0, eArgTypeNone,"Display the image base 
address as a load address if debugging, a file address otherwise." },
-  { LLDB_OPT_SET_1, false, "offset", 'o', OptionParser::eNoArgument,   
nullptr, {}, 0, eArgTypeNone,"Display the image load 
address offset from the base file address (the slide amount)." },
-  { LLDB_OPT_SET_1, false, "uuid",   'u', OptionParser::eNoArgument,   
nullptr, {}, 0, eArgTypeNone,"Display the UUID when listing 
images." },
-  { LLDB_OPT_SET_1, false, "fullpath",   'f', 
OptionParser::eOptionalArgument, nullptr, {}, 0, eArgTypeWidth,   
"Display the fullpath to the image object file." },
-  { LLDB_OPT_SET_1, false, "directory",  'd', 
OptionParser::eOptionalArgument, nullptr, {}, 0, eArgTypeWidth,   
"Display the directory with optional width for the image object file." },
-  { LLDB_OPT_SET_1, false, "basename",   'b', 
OptionParser::eOptionalArgument, nullptr, {}, 0, eArgTypeWidth,   
"Display the basename with optional width for the image object file." },
-  { LLDB_OPT_SET_1, false, "symfile",'s', 
OptionParser::eOptionalArgument, nullptr, {}, 0, eArgTypeWidth,   
"Display the fullpath to the image symbol file with optional width." },
-  { LLDB_OPT_SET_1, false, "symfile-unique", 'S', 
OptionParser::eOptionalArgument, nullptr, {}, 0, eArgTypeWidth,   
"Display the symbol file with optional width only if it is different from the 
executable object file." },
-  { LLDB_OPT_SET_1, false, "mod-time",   'm', 
OptionParser::eOptionalArgument, nullptr, {}, 0, eArgTypeWidth,   
"Display the modification time with optional width of the module." },
-  { LLDB_OPT_SET_1, false, "ref-count",  'r', 
OptionParser::eOptionalArgument, nullptr, {}, 0, eArgTypeWidth,   
"Display the reference count if the module is still in the shared module 
cache." },
-  { LLDB_OPT_SET_1, false, "pointer",'p', 
OptionParser::eOptionalArgument, nullptr, {}, 0, eArgTypeNone,
"Display the module pointer." },
-  { LLDB_OPT_SET_1, false, "global", 'g', OptionParser::

[Lldb-commits] [PATCH] D64806: [CMake] Always build debugserver on Darwin and allow tests to use the system's one

2019-07-19 Thread Stefan Gränitz via Phabricator via lldb-commits
sgraenitz marked 2 inline comments as done.
sgraenitz added inline comments.



Comment at: lldb/trunk/tools/debugserver/source/CMakeLists.txt:50
-
-option(LLDB_NO_DEBUGSERVER "Disable the debugserver target" OFF)
-option(LLDB_USE_SYSTEM_DEBUGSERVER "Use the system's debugserver instead of 
building it from source (Darwin only)." OFF)

xiaobai wrote:
> Could we actually preserve `LLDB_NO_DEBUGSERVER`? After pulling this patch 
> down into my tree and modifying my caches, I realize that I never really 
> change or test debugserver and would like to avoid building it at all.
This should be equivalent to `-DLLDB_TOOL_DEBUGSERVER_BUILD=OFF`


Repository:
  rL LLVM

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

https://reviews.llvm.org/D64806



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


[Lldb-commits] [PATCH] D64806: [CMake] Always build debugserver on Darwin and allow tests to use the system's one

2019-07-19 Thread Stefan Gränitz via Phabricator via lldb-commits
sgraenitz marked an inline comment as done.
sgraenitz added inline comments.



Comment at: lldb/trunk/tools/debugserver/source/CMakeLists.txt:50
-
-option(LLDB_NO_DEBUGSERVER "Disable the debugserver target" OFF)
-option(LLDB_USE_SYSTEM_DEBUGSERVER "Use the system's debugserver instead of 
building it from source (Darwin only)." OFF)

sgraenitz wrote:
> xiaobai wrote:
> > Could we actually preserve `LLDB_NO_DEBUGSERVER`? After pulling this patch 
> > down into my tree and modifying my caches, I realize that I never really 
> > change or test debugserver and would like to avoid building it at all.
> This should be equivalent to `-DLLDB_TOOL_DEBUGSERVER_BUILD=OFF`
Ok this is a different issue. I guess we should align these:
```
if (CMAKE_SYSTEM_NAME MATCHES "Darwin")
  add_subdirectory(darwin-debug)
  add_subdirectory(debugserver)
endif()

if (LLDB_CAN_USE_LLDB_SERVER)
  add_lldb_tool_subdirectory(lldb-server)
endif()
```


Repository:
  rL LLVM

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

https://reviews.llvm.org/D64806



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


[Lldb-commits] [PATCH] D64989: [lldb] Fix crash when looking up type coming from the ClangModuleDeclVendor

2019-07-19 Thread Raphael Isemann via Phabricator via lldb-commits
teemperor created this revision.
teemperor added reviewers: davide, shafik.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

We assume in LLDB that every type comes from an ASTContext with an associated 
ClangASTContext.
However the types inside the ClangModuleDeclVendor don't have a ClangASTContext 
so we end up
crashing whenever we create a CompilerType for one of these types.

Simplest way to trigger this bug is to just look up NSObject from a module:

  (lldb) expr @import Foundation
  (lldb) type lookup NSObject   


 
  Assertion failed: (m_type_system != nullptr), function CompilerType, file 
/Users/teemperor/llvm1/llvm-project/lldb/source/Symbol/CompilerType.cpp, line 
39. 

This patch just creates a ClangASTContext for the ASTContext used by 
ClangModuleDeclVendor.


Repository:
  rLLDB LLDB

https://reviews.llvm.org/D64989

Files:
  lldb/packages/Python/lldbsuite/test/lang/objc/modules/TestObjCModules.py
  lldb/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.cpp


Index: lldb/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.cpp
===
--- lldb/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.cpp
+++ lldb/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.cpp
@@ -27,6 +27,7 @@
 #include "lldb/Core/ModuleList.h"
 #include "lldb/Host/Host.h"
 #include "lldb/Host/HostInfo.h"
+#include "lldb/Symbol/ClangASTContext.h"
 #include "lldb/Symbol/CompileUnit.h"
 #include "lldb/Symbol/SourceModule.h"
 #include "lldb/Target/Target.h"
@@ -110,6 +111,9 @@
   ImportedModuleMap m_imported_modules;
   ImportedModuleSet m_user_imported_modules;
   const clang::ExternalASTMerger::OriginMap m_origin_map;
+  // We assume that every ASTContext has an ClangASTContext, so we also store
+  // a custom ClangASTContext for our internal ASTContext.
+  std::unique_ptr m_ast_context;
 };
 } // anonymous namespace
 
@@ -155,7 +159,13 @@
 : m_diagnostics_engine(std::move(diagnostics_engine)),
   m_compiler_invocation(std::move(compiler_invocation)),
   m_compiler_instance(std::move(compiler_instance)),
-  m_parser(std::move(parser)), m_origin_map() {}
+  m_parser(std::move(parser)), m_origin_map() {
+
+  // Initialize our ClangASTContext.
+  auto target_opts = m_compiler_invocation->getTargetOpts();
+  m_ast_context.reset(new ClangASTContext(target_opts.Triple.c_str()));
+  m_ast_context->setASTContext(&m_compiler_instance->getASTContext());
+}
 
 void ClangModulesDeclVendorImpl::ReportModuleExportsHelper(
 std::set &exports,
Index: lldb/packages/Python/lldbsuite/test/lang/objc/modules/TestObjCModules.py
===
--- lldb/packages/Python/lldbsuite/test/lang/objc/modules/TestObjCModules.py
+++ lldb/packages/Python/lldbsuite/test/lang/objc/modules/TestObjCModules.py
@@ -60,6 +60,10 @@
 "int",
 "4"])
 
+# Type lookup should still work and print something reasonable
+# for types from the module.
+self.expect("type lookup NSObject", substrs=["instanceMethod"])
+
 self.expect("expr string.length", VARIABLES_DISPLAYED_CORRECTLY,
 substrs=["NSUInteger", "5"])
 


Index: lldb/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.cpp
===
--- lldb/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.cpp
+++ lldb/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.cpp
@@ -27,6 +27,7 @@
 #include "lldb/Core/ModuleList.h"
 #include "lldb/Host/Host.h"
 #include "lldb/Host/HostInfo.h"
+#include "lldb/Symbol/ClangASTContext.h"
 #include "lldb/Symbol/CompileUnit.h"
 #include "lldb/Symbol/SourceModule.h"
 #include "lldb/Target/Target.h"
@@ -110,6 +111,9 @@
   ImportedModuleMap m_imported_modules;
   ImportedModuleSet m_user_imported_modules;
   const clang::ExternalASTMerger::OriginMap m_origin_map;
+  // We assume that every ASTContext has an ClangASTContext, so we also store
+  // a custom ClangASTContext for our internal ASTContext.
+  std::unique_ptr m_ast_context;
 };
 } // anonymous namespace
 
@@ -155,7 +159,13 @@
 : m_diagnostics_engine(std::move(diagnostics_engine)),
   m_compiler_invocation(std::move(compiler_invocation)),
   m_compiler_instance(std::move(compiler_instance)),
-  m_parser(std::move(parser)), m_origin_map() {}
+  m_parser(std::move(parser)), m_origin_map() {
+
+  // Initialize our ClangASTContext.
+  auto target_opts = m_compiler_invocation->getTargetOpts();
+  m_ast_context.reset(new ClangASTContext(target_opts.Triple.c_str()));
+  m_ast_context->setASTContext(&m_compiler_insta

[Lldb-commits] [PATCH] D63667: Support __kernel_rt_sigreturn in frame initialization

2019-07-19 Thread Phabricator via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL366580: Support Linux signal return trampolines in frame 
initialization (authored by josepht, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D63667?vs=206931&id=210830#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D63667

Files:
  lldb/trunk/include/lldb/Symbol/UnwindPlan.h
  
lldb/trunk/packages/Python/lldbsuite/test/functionalities/signal/handle-abrt/Makefile
  
lldb/trunk/packages/Python/lldbsuite/test/functionalities/signal/handle-abrt/TestHandleAbort.py
  
lldb/trunk/packages/Python/lldbsuite/test/functionalities/signal/handle-abrt/main.c
  lldb/trunk/source/Plugins/ABI/MacOSX-arm/ABIMacOSX_arm.cpp
  lldb/trunk/source/Plugins/ABI/MacOSX-arm64/ABIMacOSX_arm64.cpp
  lldb/trunk/source/Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.cpp
  lldb/trunk/source/Plugins/ABI/SysV-arm/ABISysV_arm.cpp
  lldb/trunk/source/Plugins/ABI/SysV-arm64/ABISysV_arm64.cpp
  lldb/trunk/source/Plugins/ABI/SysV-hexagon/ABISysV_hexagon.cpp
  lldb/trunk/source/Plugins/ABI/SysV-i386/ABISysV_i386.cpp
  lldb/trunk/source/Plugins/ABI/SysV-mips/ABISysV_mips.cpp
  lldb/trunk/source/Plugins/ABI/SysV-mips64/ABISysV_mips64.cpp
  lldb/trunk/source/Plugins/ABI/SysV-ppc/ABISysV_ppc.cpp
  lldb/trunk/source/Plugins/ABI/SysV-ppc64/ABISysV_ppc64.cpp
  lldb/trunk/source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.cpp
  lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp
  lldb/trunk/source/Plugins/Instruction/ARM64/EmulateInstructionARM64.cpp
  lldb/trunk/source/Plugins/Instruction/MIPS/EmulateInstructionMIPS.cpp
  lldb/trunk/source/Plugins/Instruction/MIPS64/EmulateInstructionMIPS64.cpp
  lldb/trunk/source/Plugins/Instruction/PPC64/EmulateInstructionPPC64.cpp
  lldb/trunk/source/Plugins/Platform/Linux/PlatformLinux.cpp
  lldb/trunk/source/Plugins/Process/Utility/RegisterContextLLDB.cpp
  lldb/trunk/source/Plugins/SymbolFile/Breakpad/SymbolFileBreakpad.cpp
  lldb/trunk/source/Plugins/UnwindAssembly/x86/x86AssemblyInspectionEngine.cpp
  lldb/trunk/source/Symbol/ArmUnwindInfo.cpp
  lldb/trunk/source/Symbol/CompactUnwindInfo.cpp
  lldb/trunk/source/Symbol/DWARFCallFrameInfo.cpp

Index: lldb/trunk/include/lldb/Symbol/UnwindPlan.h
===
--- lldb/trunk/include/lldb/Symbol/UnwindPlan.h
+++ lldb/trunk/include/lldb/Symbol/UnwindPlan.h
@@ -370,6 +370,7 @@
 m_return_addr_register(LLDB_INVALID_REGNUM), m_source_name(),
 m_plan_is_sourced_from_compiler(eLazyBoolCalculate),
 m_plan_is_valid_at_all_instruction_locations(eLazyBoolCalculate),
+m_plan_is_for_signal_trap(eLazyBoolCalculate),
 m_lsda_address(), m_personality_func_addr() {}
 
   // Performs a deep copy of the plan, including all the rows (expensive).
@@ -463,6 +464,17 @@
 m_plan_is_valid_at_all_instruction_locations = valid_at_all_insn;
   }
 
+  // Is this UnwindPlan for a signal trap frame?  If so, then its saved pc
+  // may have been set manually by the signal dispatch code and therefore
+  // not follow a call to the child frame.
+  lldb_private::LazyBool GetUnwindPlanForSignalTrap() const {
+return m_plan_is_for_signal_trap;
+  }
+
+  void SetUnwindPlanForSignalTrap(lldb_private::LazyBool is_for_signal_trap) {
+m_plan_is_for_signal_trap = is_for_signal_trap;
+  }
+
   int GetRowCount() const;
 
   void Clear() {
@@ -472,6 +484,7 @@
 m_source_name.Clear();
 m_plan_is_sourced_from_compiler = eLazyBoolCalculate;
 m_plan_is_valid_at_all_instruction_locations = eLazyBoolCalculate;
+m_plan_is_for_signal_trap = eLazyBoolCalculate;
 m_lsda_address.Clear();
 m_personality_func_addr.Clear();
   }
@@ -502,6 +515,7 @@
   m_source_name; // for logging, where this UnwindPlan originated from
   lldb_private::LazyBool m_plan_is_sourced_from_compiler;
   lldb_private::LazyBool m_plan_is_valid_at_all_instruction_locations;
+  lldb_private::LazyBool m_plan_is_for_signal_trap;
 
   Address m_lsda_address; // Where the language specific data area exists in the
   // module - used
Index: lldb/trunk/packages/Python/lldbsuite/test/functionalities/signal/handle-abrt/TestHandleAbort.py
===
--- lldb/trunk/packages/Python/lldbsuite/test/functionalities/signal/handle-abrt/TestHandleAbort.py
+++ lldb/trunk/packages/Python/lldbsuite/test/functionalities/signal/handle-abrt/TestHandleAbort.py
@@ -0,0 +1,72 @@
+"""Test that we can unwind out of a SIGABRT handler"""
+
+from __future__ import print_function
+
+
+import os
+import re
+
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+
+class HandleAbortTestCase(TestBase):
+
+mydir = TestBase.compute_mydir(__file

[Lldb-commits] [PATCH] D64993: Fix PC adjustment in StackFrame::GetSymbolContext

2019-07-19 Thread Joseph Tremoulet via Phabricator via lldb-commits
JosephTremoulet created this revision.
JosephTremoulet added reviewers: jasonmolenda, clayborg.
Herald added a reviewer: jfb.
Herald added a project: LLDB.

Update StackFrame::GetSymbolContext to mirror the logic in
RegisterContextLLDB::InitializeNonZerothFrame that knows not to do the
pc decrement when the given frame is a signal trap handler frame or the
parent of one, because the pc may not follow a call in these frames.
Accomplish this by adding a behaves_like_zeroth_frame field to
lldb_private::StackFrame, set to true for the zeroth frame, for
signal handler frames, and for parents of signal handler frames.

Also add logic to propagate the signal handler flag from UnwindPlan to
the FrameType on the RegisterContextLLDB it generates, and factor out a
helper to resolve symbol and address range for a RegisterContextLLDB now
that we have it in four places.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D64993

Files:
  lldb/include/lldb/Target/StackFrame.h
  lldb/include/lldb/Target/Unwind.h
  lldb/source/Plugins/Process/Utility/HistoryUnwind.cpp
  lldb/source/Plugins/Process/Utility/HistoryUnwind.h
  lldb/source/Plugins/Process/Utility/RegisterContextLLDB.cpp
  lldb/source/Plugins/Process/Utility/RegisterContextLLDB.h
  lldb/source/Plugins/Process/Utility/UnwindLLDB.cpp
  lldb/source/Plugins/Process/Utility/UnwindLLDB.h
  lldb/source/Plugins/Process/Utility/UnwindMacOSXFrameBackchain.cpp
  lldb/source/Plugins/Process/Utility/UnwindMacOSXFrameBackchain.h
  lldb/source/Target/StackFrame.cpp
  lldb/source/Target/StackFrameList.cpp

Index: lldb/source/Target/StackFrameList.cpp
===
--- lldb/source/Target/StackFrameList.cpp
+++ lldb/source/Target/StackFrameList.cpp
@@ -394,11 +394,13 @@
 bool cfa_is_valid = false;
 addr_t pc =
 callee->GetAddressRange().GetBaseAddress().GetLoadAddress(&target);
+constexpr bool behaves_like_zeroth_frame = false;
 SymbolContext sc;
 callee->CalculateSymbolContext(&sc);
 auto synth_frame = std::make_shared(
 m_thread.shared_from_this(), frame_idx, concrete_frame_idx, cfa,
-cfa_is_valid, pc, StackFrame::Kind::Artificial, &sc);
+cfa_is_valid, pc, StackFrame::Kind::Artificial,
+behaves_like_zeroth_frame, &sc);
 m_frames.push_back(synth_frame);
 LLDB_LOG(log, "Pushed frame {0}", callee->GetDisplayName());
   }
@@ -448,6 +450,7 @@
 uint32_t idx = m_concrete_frames_fetched++;
 lldb::addr_t pc = LLDB_INVALID_ADDRESS;
 lldb::addr_t cfa = LLDB_INVALID_ADDRESS;
+bool behaves_like_zeroth_frame;
 if (idx == 0) {
   // We might have already created frame zero, only create it if we need
   // to.
@@ -455,8 +458,9 @@
 RegisterContextSP reg_ctx_sp(m_thread.GetRegisterContext());
 
 if (reg_ctx_sp) {
-  const bool success =
-  unwinder && unwinder->GetFrameInfoAtIndex(idx, cfa, pc);
+  const bool success = unwinder &&
+   unwinder->GetFrameInfoAtIndex(
+   idx, cfa, pc, behaves_like_zeroth_frame);
   // There shouldn't be any way not to get the frame info for frame
   // 0. But if the unwinder can't make one, lets make one by hand
   // with the SP as the CFA and see if that gets any further.
@@ -467,7 +471,7 @@
 
   unwind_frame_sp = std::make_shared(
   m_thread.shared_from_this(), m_frames.size(), idx, reg_ctx_sp,
-  cfa, pc, nullptr);
+  cfa, pc, behaves_like_zeroth_frame, nullptr);
   m_frames.push_back(unwind_frame_sp);
 }
   } else {
@@ -475,8 +479,9 @@
 cfa = unwind_frame_sp->m_id.GetCallFrameAddress();
   }
 } else {
-  const bool success =
-  unwinder && unwinder->GetFrameInfoAtIndex(idx, cfa, pc);
+  const bool success = unwinder &&
+   unwinder->GetFrameInfoAtIndex(
+   idx, cfa, pc, behaves_like_zeroth_frame);
   if (!success) {
 // We've gotten to the end of the stack.
 SetAllFramesFetched();
@@ -485,7 +490,7 @@
   const bool cfa_is_valid = true;
   unwind_frame_sp = std::make_shared(
   m_thread.shared_from_this(), m_frames.size(), idx, cfa, cfa_is_valid,
-  pc, StackFrame::Kind::Regular, nullptr);
+  pc, StackFrame::Kind::Regular, behaves_like_zeroth_frame, nullptr);
 
   // Create synthetic tail call frames between the previous frame and the
   // newly-found frame. The new frame's index may change after this call,
@@ -527,10 +532,11 @@
   while (unwind_sc.GetParentOfInlinedScope(
   curr_frame_address, next_frame_sc, next_frame_address)) {
 next_frame_sc.line_entry.ApplyFileMappings(target_sp);
-StackFrameSP frame_sp(
-new StackFrame(m_thread.shared_from_this(), m_frames.size(), idx,
-   unwind_frame_sp->Get

[Lldb-commits] [PATCH] D64994: [CMake] Align debugserver with lldb-server on Darwin

2019-07-19 Thread Stefan Gränitz via Phabricator via lldb-commits
sgraenitz created this revision.
sgraenitz added reviewers: xiaobai, JDevlieghere, davide.
Herald added a subscriber: mgorny.
Herald added a project: LLDB.

Make debugserver a tool like lldb-server, so it can be included/excluded via 
`LLDB_TOOL_DEBUGSERVER_BUILD`. This replaces the old `LLDB_NO_DEBUGSERVER` 
flag. Doing the same for darwin-debug while I am here.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D64994

Files:
  lldb/cmake/modules/LLDBConfig.cmake
  lldb/test/CMakeLists.txt
  lldb/tools/CMakeLists.txt
  lldb/unittests/CMakeLists.txt
  lldb/unittests/tools/lldb-server/CMakeLists.txt


Index: lldb/unittests/tools/lldb-server/CMakeLists.txt
===
--- lldb/unittests/tools/lldb-server/CMakeLists.txt
+++ lldb/unittests/tools/lldb-server/CMakeLists.txt
@@ -13,7 +13,7 @@
 add_lldb_test_executable(thread_inferior inferior/thread_inferior.cpp)
 add_lldb_test_executable(environment_check inferior/environment_check.cpp)
 
-if(LLDB_CAN_USE_DEBUGSERVER)
+if(LLDB_CAN_USE_DEBUGSERVER AND LLDB_TOOL_DEBUGSERVER_BUILD)
   if(LLDB_USE_SYSTEM_DEBUGSERVER)
 lldb_find_system_debugserver(debugserver_path)
   else()
Index: lldb/unittests/CMakeLists.txt
===
--- lldb/unittests/CMakeLists.txt
+++ lldb/unittests/CMakeLists.txt
@@ -78,6 +78,6 @@
 add_subdirectory(UnwindAssembly)
 add_subdirectory(Utility)
 
-if(LLDB_CAN_USE_DEBUGSERVER AND NOT LLDB_USE_SYSTEM_DEBUGSERVER)
+if(LLDB_CAN_USE_DEBUGSERVER AND LLDB_TOOL_DEBUGSERVER_BUILD AND NOT 
LLDB_USE_SYSTEM_DEBUGSERVER)
   add_subdirectory(debugserver)
 endif()
Index: lldb/tools/CMakeLists.txt
===
--- lldb/tools/CMakeLists.txt
+++ lldb/tools/CMakeLists.txt
@@ -11,8 +11,8 @@
 add_lldb_tool_subdirectory(lldb-vscode)
 
 if (CMAKE_SYSTEM_NAME MATCHES "Darwin")
-  add_subdirectory(darwin-debug)
-  add_subdirectory(debugserver)
+  add_lldb_tool_subdirectory(darwin-debug)
+  add_lldb_tool_subdirectory(debugserver)
 endif()
 
 if (LLDB_CAN_USE_LLDB_SERVER)
Index: lldb/test/CMakeLists.txt
===
--- lldb/test/CMakeLists.txt
+++ lldb/test/CMakeLists.txt
@@ -101,11 +101,18 @@
 lldb_find_system_debugserver(system_debugserver_path)
 message(STATUS "LLDB tests use out-of-tree debugserver: 
${system_debugserver_path}")
 list(APPEND LLDB_TEST_COMMON_ARGS --out-of-tree-debugserver)
-  else()
+  elseif(TARGET debugserver)
 set(debugserver_path ${LLVM_RUNTIME_OUTPUT_INTDIR}/debugserver)
 message(STATUS "LLDB Tests use just-built debugserver: 
${debugserver_path}")
 list(APPEND LLDB_TEST_COMMON_ARGS --server ${debugserver_path})
 add_dependencies(lldb-test-deps debugserver)
+  elseif(TARGET lldb-server)
+set(lldb_server_path ${LLVM_RUNTIME_OUTPUT_INTDIR}/lldb-server)
+message(STATUS "LLDB Tests use just-built lldb-server: 
${lldb_server_path}")
+list(APPEND LLDB_TEST_COMMON_ARGS --server ${lldb_server_path})
+add_dependencies(lldb-test-deps lldb-server)
+  else()
+message(WARNING "LLDB Tests enabled, but no server available")
   endif()
 endif()
 
Index: lldb/cmake/modules/LLDBConfig.cmake
===
--- lldb/cmake/modules/LLDBConfig.cmake
+++ lldb/cmake/modules/LLDBConfig.cmake
@@ -373,17 +373,17 @@
 # Figure out if lldb could use lldb-server.  If so, then we'll
 # ensure we build lldb-server when an lldb target is being built.
 if (CMAKE_SYSTEM_NAME MATCHES "Android|Darwin|FreeBSD|Linux|NetBSD")
-  set(LLDB_CAN_USE_LLDB_SERVER 1)
+  set(LLDB_CAN_USE_LLDB_SERVER ON)
 else()
-  set(LLDB_CAN_USE_LLDB_SERVER 0)
+  set(LLDB_CAN_USE_LLDB_SERVER OFF)
 endif()
 
 # Figure out if lldb could use debugserver.  If so, then we'll
 # ensure we build debugserver when we build lldb.
-if ( CMAKE_SYSTEM_NAME MATCHES "Darwin" )
-set(LLDB_CAN_USE_DEBUGSERVER 1)
+if (CMAKE_SYSTEM_NAME MATCHES "Darwin")
+set(LLDB_CAN_USE_DEBUGSERVER ON)
 else()
-set(LLDB_CAN_USE_DEBUGSERVER 0)
+set(LLDB_CAN_USE_DEBUGSERVER OFF)
 endif()
 
 if (NOT LLDB_DISABLE_CURSES)


Index: lldb/unittests/tools/lldb-server/CMakeLists.txt
===
--- lldb/unittests/tools/lldb-server/CMakeLists.txt
+++ lldb/unittests/tools/lldb-server/CMakeLists.txt
@@ -13,7 +13,7 @@
 add_lldb_test_executable(thread_inferior inferior/thread_inferior.cpp)
 add_lldb_test_executable(environment_check inferior/environment_check.cpp)
 
-if(LLDB_CAN_USE_DEBUGSERVER)
+if(LLDB_CAN_USE_DEBUGSERVER AND LLDB_TOOL_DEBUGSERVER_BUILD)
   if(LLDB_USE_SYSTEM_DEBUGSERVER)
 lldb_find_system_debugserver(debugserver_path)
   else()
Index: lldb/unittests/CMakeLists.txt
===
--- lldb/unittests/CMakeLists.txt
+++ lldb/unittests/CMakeLists.txt
@@ -78,6 +78,6 @@
 add_subdir

[Lldb-commits] [PATCH] D64995: [lldb] Fix crash when tab-completing in multi-line expr

2019-07-19 Thread Raphael Isemann via Phabricator via lldb-commits
teemperor created this revision.
teemperor added a reviewer: shafik.
Herald added subscribers: lldb-commits, abidh.
Herald added a project: LLDB.
teemperor added a comment.

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

Correct me if I'm wrong with this. I know we never test this functionality (as 
the whole IOHandler business is tricky to test), but I'm not sure if we maybe 
have some funky way around it.

Otherwise I would say we merge this as-is, as I don't want to have an obvious 
bug around until we find a method to test the interactive IO code.


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

  (lldb) expr
  1. a[tab]

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

Fixes rdar://51754005

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


Repository:
  rLLDB LLDB

https://reviews.llvm.org/D64995

Files:
  lldb/source/Core/IOHandler.cpp


Index: lldb/source/Core/IOHandler.cpp
===
--- lldb/source/Core/IOHandler.cpp
+++ lldb/source/Core/IOHandler.cpp
@@ -233,7 +233,7 @@
 matches, descriptions);
   case Completion::Expression: {
 CompletionResult result;
-CompletionRequest request(current_line, current_line - cursor,
+CompletionRequest request(current_line, cursor - current_line,
   skip_first_n_matches, max_matches, result);
 CommandCompletions::InvokeCommonCompletionCallbacks(
 io_handler.GetDebugger().GetCommandInterpreter(),


Index: lldb/source/Core/IOHandler.cpp
===
--- lldb/source/Core/IOHandler.cpp
+++ lldb/source/Core/IOHandler.cpp
@@ -233,7 +233,7 @@
 matches, descriptions);
   case Completion::Expression: {
 CompletionResult result;
-CompletionRequest request(current_line, current_line - cursor,
+CompletionRequest request(current_line, cursor - current_line,
   skip_first_n_matches, max_matches, result);
 CommandCompletions::InvokeCommonCompletionCallbacks(
 io_handler.GetDebugger().GetCommandInterpreter(),
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D64995: [lldb] Fix crash when tab-completing in multi-line expr

2019-07-19 Thread Raphael Isemann via Phabricator via lldb-commits
teemperor added a comment.

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

Correct me if I'm wrong with this. I know we never test this functionality (as 
the whole IOHandler business is tricky to test), but I'm not sure if we maybe 
have some funky way around it.

Otherwise I would say we merge this as-is, as I don't want to have an obvious 
bug around until we find a method to test the interactive IO code.


Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D64995



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


[Lldb-commits] [PATCH] D64993: Fix PC adjustment in StackFrame::GetSymbolContext

2019-07-19 Thread Joseph Tremoulet via Phabricator via lldb-commits
JosephTremoulet marked 2 inline comments as done.
JosephTremoulet added inline comments.



Comment at: lldb/source/Plugins/Process/Utility/RegisterContextLLDB.cpp:1760
+void RegisterContextLLDB::PropagateTrapHandlerFlag(
+lldb::UnwindPlanSP unwind_plan) {
+  if (unwind_plan->GetUnwindPlanForSignalTrap() != eLazyBoolYes) {

I'm a bit ambivalent about adding this part -- the downside is that it's not 
concretely helping today, because if an eh_frame record has the 'S' flag in its 
augmentation (which is what `unwind_Plan->GetUnwindPlanForSignalTrap()` 
reports), we'll have already decremented pc and generated unwind plans based on 
the prior function when initializing the register context.  But the upside is 
that this connects the dots between the otherwise-unused bit on the unwind plan 
and the frame type, and will be in place should we subsequently add code to try 
the second function's unwind plan as a fallback.



Comment at: lldb/source/Target/StackFrame.cpp:297
 Address lookup_addr(GetFrameCodeAddress());
-if (m_frame_index > 0 && lookup_addr.IsValid()) {
+if (!m_behaves_like_zeroth_frame && lookup_addr.IsValid()) {
   addr_t offset = lookup_addr.GetOffset();

I've verified that this fixes the issue with the function name in the stack 
trace mentioned in D63667, but I haven't figured a way to add a test to that 
effect without putting a brittle assumption about particular trap handler names 
in the test.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D64993



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


[Lldb-commits] [PATCH] D64995: [lldb] Fix crash when tab-completing in multi-line expr

2019-07-19 Thread Pavel Labath via Phabricator via lldb-commits
labath added a comment.

This looks like a good opportunity to unleash pexpect.


Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D64995



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


[Lldb-commits] [PATCH] D64806: [CMake] Always build debugserver on Darwin and allow tests to use the system's one

2019-07-19 Thread Stefan Gränitz via Phabricator via lldb-commits
sgraenitz marked 2 inline comments as done.
sgraenitz added inline comments.



Comment at: lldb/trunk/tools/debugserver/source/CMakeLists.txt:50
-
-option(LLDB_NO_DEBUGSERVER "Disable the debugserver target" OFF)
-option(LLDB_USE_SYSTEM_DEBUGSERVER "Use the system's debugserver instead of 
building it from source (Darwin only)." OFF)

sgraenitz wrote:
> sgraenitz wrote:
> > xiaobai wrote:
> > > Could we actually preserve `LLDB_NO_DEBUGSERVER`? After pulling this 
> > > patch down into my tree and modifying my caches, I realize that I never 
> > > really change or test debugserver and would like to avoid building it at 
> > > all.
> > This should be equivalent to `-DLLDB_TOOL_DEBUGSERVER_BUILD=OFF`
> Ok this is a different issue. I guess we should align these:
> ```
> if (CMAKE_SYSTEM_NAME MATCHES "Darwin")
>   add_subdirectory(darwin-debug)
>   add_subdirectory(debugserver)
> endif()
> 
> if (LLDB_CAN_USE_LLDB_SERVER)
>   add_lldb_tool_subdirectory(lldb-server)
> endif()
> ```
https://reviews.llvm.org/D64994


Repository:
  rL LLVM

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

https://reviews.llvm.org/D64806



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


[Lldb-commits] [PATCH] D64994: [CMake] Align debugserver with lldb-server on Darwin

2019-07-19 Thread Stefan Gränitz via Phabricator via lldb-commits
sgraenitz marked an inline comment as done.
sgraenitz added inline comments.



Comment at: lldb/test/CMakeLists.txt:113
+list(APPEND LLDB_TEST_COMMON_ARGS --server ${lldb_server_path})
+add_dependencies(lldb-test-deps lldb-server)
+  else()

Not sure if this needs test suite support.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D64994



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


[Lldb-commits] [PATCH] D64992: [lldb][NFC] Cleanup mentions and code related to lldb-mi

2019-07-19 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere accepted this revision.
JDevlieghere added a comment.
This revision is now accepted and ready to land.
Herald added a subscriber: dexonsmith.

Thanks Raphael! I think I landed an older patch or something, I'm sure I 
grep'ed for references when I was preparing the removal.


Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D64992



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


[Lldb-commits] [lldb] r366590 - [lldb][NFC] Cleanup mentions and code related to lldb-mi

2019-07-19 Thread Raphael Isemann via lldb-commits
Author: teemperor
Date: Fri Jul 19 08:55:23 2019
New Revision: 366590

URL: http://llvm.org/viewvc/llvm-project?rev=366590&view=rev
Log:
[lldb][NFC] Cleanup mentions and code related to lldb-mi

Summary: lldb-mi has been removed, but there are still a bunch of references in 
the code base. This patch removes all of them.

Reviewers: JDevlieghere, jfb

Reviewed By: JDevlieghere

Subscribers: dexonsmith, ki.stfu, mgorny, abidh, jfb, lldb-commits

Tags: #lldb

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

Removed:
lldb/trunk/packages/Python/lldbsuite/test/tools/
Modified:
lldb/trunk/CMakeLists.txt
lldb/trunk/CODE_OWNERS.txt
lldb/trunk/lit/helper/toolchain.py
lldb/trunk/packages/Python/lldbsuite/test/dotest.py
lldb/trunk/packages/Python/lldbsuite/test/lldbtest.py
lldb/trunk/packages/Python/lldbsuite/test/test_categories.py

Modified: lldb/trunk/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/CMakeLists.txt?rev=366590&r1=366589&r2=366590&view=diff
==
--- lldb/trunk/CMakeLists.txt (original)
+++ lldb/trunk/CMakeLists.txt Fri Jul 19 08:55:23 2019
@@ -106,10 +106,6 @@ if(LLDB_INCLUDE_TESTS)
 list(APPEND LLDB_TEST_DEPS lldb-server)
   endif()
 
-  if(TARGET lldb-mi)
-list(APPEND LLDB_TEST_DEPS lldb-mi)
-  endif()
-
   if(TARGET lldb-vscode)
 list(APPEND LLDB_TEST_DEPS lldb-vscode)
   endif()

Modified: lldb/trunk/CODE_OWNERS.txt
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/CODE_OWNERS.txt?rev=366590&r1=366589&r2=366590&view=diff
==
--- lldb/trunk/CODE_OWNERS.txt (original)
+++ lldb/trunk/CODE_OWNERS.txt Fri Jul 19 08:55:23 2019
@@ -21,10 +21,6 @@ D: Watchpoints, Trampolines, Target, Com
 D: Expression evaluator, IR interpreter, Clang integration
 D: Data Formatters
 
-N: Ilia K
-E: ki.s...@gmail.com
-D: lldb-mi
-
 N: Ed Maste
 E: ema...@freebsd.org
 D: FreeBSD
@@ -34,10 +30,6 @@ E: jmole...@apple.com
 D: ABI, Disassembler, Unwinding, iOS, debugserver, Platform, ObjectFile, 
SymbolFile, 
 D: SymbolVendor, DWARF, gdb-remote
 
-N: Hafiz Abid Qadeer
-E: abidh@gmail.com
-D: lldb-mi
-
 N: Kamil Rytarowski
 E: ka...@netbsd.org
 D: NetBSD

Modified: lldb/trunk/lit/helper/toolchain.py
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/lit/helper/toolchain.py?rev=366590&r1=366589&r2=366590&view=diff
==
--- lldb/trunk/lit/helper/toolchain.py (original)
+++ lldb/trunk/lit/helper/toolchain.py Fri Jul 19 08:55:23 2019
@@ -16,11 +16,6 @@ def use_lldb_substitutions(config):
 
 dsname = 'debugserver' if platform.system() in ['Darwin'] else 
'lldb-server'
 dsargs = [] if platform.system() in ['Darwin'] else ['gdbserver']
-lldbmi = ToolSubst('%lldbmi',
-   command=FindTool('lldb-mi'),
-   extra_args=['--synchronous'],
-   unresolved='ignore')
-
 
 build_script = os.path.dirname(__file__)
 build_script = os.path.join(build_script, 'build.py')
@@ -43,7 +38,6 @@ def use_lldb_substitutions(config):
 ToolSubst('%lldb-init',
   command=FindTool('lldb'),
   extra_args=['-S', lldb_init]),
-lldbmi,
 ToolSubst('%debugserver',
   command=FindTool(dsname),
   extra_args=dsargs,
@@ -61,9 +55,6 @@ def use_lldb_substitutions(config):
 
 llvm_config.add_tool_substitutions(primary_tools,
[config.lldb_tools_dir])
-# lldb-mi always fails without Python support
-if lldbmi.was_resolved and not config.lldb_disable_python:
-config.available_features.add('lldb-mi')
 
 def _use_msvc_substitutions(config):
 # If running from a Visual Studio Command prompt (e.g. vcvars), this will

Modified: lldb/trunk/packages/Python/lldbsuite/test/dotest.py
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/dotest.py?rev=366590&r1=366589&r2=366590&view=diff
==
--- lldb/trunk/packages/Python/lldbsuite/test/dotest.py (original)
+++ lldb/trunk/packages/Python/lldbsuite/test/dotest.py Fri Jul 19 08:55:23 2019
@@ -693,16 +693,11 @@ def setupSysPath():
 os.environ["LLDB_SRC"] = lldbsuite.lldb_root
 
 pluginPath = os.path.join(scriptPath, 'plugins')
-toolsLLDBMIPath = os.path.join(scriptPath, 'tools', 'lldb-mi')
 toolsLLDBVSCode = os.path.join(scriptPath, 'tools', 'lldb-vscode')
 toolsLLDBServerPath = os.path.join(scriptPath, 'tools', 'lldb-server')
 
-# Insert script dir, plugin dir, lldb-mi dir and lldb-server dir to the
-# sys.path.
+# Insert script dir, plugin dir and lldb-server dir to the sys.path.
 sys.path.insert(0, pluginPath)
-# Adding test/tools/lldb-mi to the path makes it easy
-sys.pat

[Lldb-commits] [PATCH] D64992: [lldb][NFC] Cleanup mentions and code related to lldb-mi

2019-07-19 Thread Raphael Isemann via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGb45853f17313: [lldb][NFC] Cleanup mentions and code related 
to lldb-mi (authored by teemperor).
Herald added subscribers: krytarowski, srhines.

Changed prior to commit:
  https://reviews.llvm.org/D64992?vs=210828&id=210846#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D64992

Files:
  lldb/CMakeLists.txt
  lldb/CODE_OWNERS.txt
  lldb/lit/helper/toolchain.py
  lldb/packages/Python/lldbsuite/test/dotest.py
  lldb/packages/Python/lldbsuite/test/lldbtest.py
  lldb/packages/Python/lldbsuite/test/test_categories.py
  lldb/packages/Python/lldbsuite/test/tools/lldb-mi/.categories
  lldb/packages/Python/lldbsuite/test/tools/lldb-mi/Makefile
  lldb/packages/Python/lldbsuite/test/tools/lldb-mi/TestMiEnvironmentCd.py
  lldb/packages/Python/lldbsuite/test/tools/lldb-mi/TestMiLibraryLoaded.py
  lldb/packages/Python/lldbsuite/test/tools/lldb-mi/TestMiPrompt.py
  lldb/packages/Python/lldbsuite/test/tools/lldb-mi/breakpoint/Makefile
  lldb/packages/Python/lldbsuite/test/tools/lldb-mi/breakpoint/TestMiBreak.py
  lldb/packages/Python/lldbsuite/test/tools/lldb-mi/breakpoint/main.cpp
  lldb/packages/Python/lldbsuite/test/tools/lldb-mi/control/Makefile
  lldb/packages/Python/lldbsuite/test/tools/lldb-mi/control/TestMiExec.py
  lldb/packages/Python/lldbsuite/test/tools/lldb-mi/control/main.cpp
  lldb/packages/Python/lldbsuite/test/tools/lldb-mi/data/Makefile
  lldb/packages/Python/lldbsuite/test/tools/lldb-mi/data/TestMiData.py
  lldb/packages/Python/lldbsuite/test/tools/lldb-mi/data/main.cpp
  lldb/packages/Python/lldbsuite/test/tools/lldb-mi/interpreter/Makefile
  
lldb/packages/Python/lldbsuite/test/tools/lldb-mi/interpreter/TestMiCliSupport.py
  
lldb/packages/Python/lldbsuite/test/tools/lldb-mi/interpreter/TestMiInterpreterExec.py
  lldb/packages/Python/lldbsuite/test/tools/lldb-mi/interpreter/main.cpp
  lldb/packages/Python/lldbsuite/test/tools/lldb-mi/lexical_scope/Makefile
  
lldb/packages/Python/lldbsuite/test/tools/lldb-mi/lexical_scope/TestMiLexicalScope.py
  lldb/packages/Python/lldbsuite/test/tools/lldb-mi/lexical_scope/main.cpp
  lldb/packages/Python/lldbsuite/test/tools/lldb-mi/lldbmi_testcase.py
  lldb/packages/Python/lldbsuite/test/tools/lldb-mi/main.cpp
  lldb/packages/Python/lldbsuite/test/tools/lldb-mi/signal/Makefile
  lldb/packages/Python/lldbsuite/test/tools/lldb-mi/signal/TestMiSignal.py
  lldb/packages/Python/lldbsuite/test/tools/lldb-mi/signal/main.cpp
  lldb/packages/Python/lldbsuite/test/tools/lldb-mi/stack/Makefile
  lldb/packages/Python/lldbsuite/test/tools/lldb-mi/stack/TestMiStack.py
  lldb/packages/Python/lldbsuite/test/tools/lldb-mi/stack/main.cpp
  lldb/packages/Python/lldbsuite/test/tools/lldb-mi/startup_options/Makefile
  
lldb/packages/Python/lldbsuite/test/tools/lldb-mi/startup_options/TestMiStartupOptions.py
  lldb/packages/Python/lldbsuite/test/tools/lldb-mi/startup_options/main.cpp
  lldb/packages/Python/lldbsuite/test/tools/lldb-mi/startup_options/start_script
  
lldb/packages/Python/lldbsuite/test/tools/lldb-mi/startup_options/start_script_error
  
lldb/packages/Python/lldbsuite/test/tools/lldb-mi/startup_options/start_script_exit
  lldb/packages/Python/lldbsuite/test/tools/lldb-mi/syntax/Makefile
  lldb/packages/Python/lldbsuite/test/tools/lldb-mi/syntax/TestMiSyntax.py
  lldb/packages/Python/lldbsuite/test/tools/lldb-mi/syntax/main.cpp
  lldb/packages/Python/lldbsuite/test/tools/lldb-mi/target/Makefile
  lldb/packages/Python/lldbsuite/test/tools/lldb-mi/target/TestMiTarget.py
  lldb/packages/Python/lldbsuite/test/tools/lldb-mi/target/test_attach.cpp
  lldb/packages/Python/lldbsuite/test/tools/lldb-mi/threadinfo/Makefile
  
lldb/packages/Python/lldbsuite/test/tools/lldb-mi/threadinfo/TestMiThreadInfo.py
  
lldb/packages/Python/lldbsuite/test/tools/lldb-mi/threadinfo/test_threadinfo.cpp
  lldb/packages/Python/lldbsuite/test/tools/lldb-mi/variable/Makefile
  
lldb/packages/Python/lldbsuite/test/tools/lldb-mi/variable/TestMiGdbSetShowPrint.py
  lldb/packages/Python/lldbsuite/test/tools/lldb-mi/variable/TestMiVar.py
  lldb/packages/Python/lldbsuite/test/tools/lldb-mi/variable/main.cpp
  lldb/packages/Python/lldbsuite/test/tools/lldb-server/.clang-format
  lldb/packages/Python/lldbsuite/test/tools/lldb-server/Makefile
  
lldb/packages/Python/lldbsuite/test/tools/lldb-server/TestAppleSimulatorOSType.py
  lldb/packages/Python/lldbsuite/test/tools/lldb-server/TestGdbRemoteAttach.py
  
lldb/packages/Python/lldbsuite/test/tools/lldb-server/TestGdbRemoteAuxvSupport.py
  lldb/packages/Python/lldbsuite/test/tools/lldb-server/TestGdbRemoteExitCode.py
  
lldb/packages/Python/lldbsuite/test/tools/lldb-server/TestGdbRemoteExpeditedRegisters.py
  lldb/packages/Python/lldbsuite/test/tools/lldb-server/TestGdbRemoteHostInfo.py
  lldb/packages/Python/lldbsuite/test/tools/lldb-server/TestGdbRemoteKill.py
  
lldb/packages/Pytho

[Lldb-commits] [PATCH] D64994: [CMake] Align debugserver with lldb-server on Darwin

2019-07-19 Thread Alex Langford via Phabricator via lldb-commits
xiaobai accepted this revision.
xiaobai added a comment.

Excellent, thanks for taking care of this! :)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D64994



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


[Lldb-commits] [PATCH] D65025: [Symbol] Improve TypeSystemMap mutex safety

2019-07-19 Thread Alex Langford via Phabricator via lldb-commits
xiaobai created this revision.
xiaobai added reviewers: JDevlieghere, clayborg, davide, labath, jingham.

Relying on m_clear_in_progress is dangerous for modifying m_map. It's
entirely possible for one thread to invoke TypeSystemMap::Clear(), lock
the mutex, and copy the map for finalization while another thread tries
to add a new type system. This could end up in a situation where a type
system isn't finalized because of unsynchronized access.

I propose we remove the `m_clear_in_progress` variable entirely and rely
on the mutex.


https://reviews.llvm.org/D65025

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

Index: source/Symbol/TypeSystem.cpp
===
--- source/Symbol/TypeSystem.cpp
+++ source/Symbol/TypeSystem.cpp
@@ -155,32 +155,21 @@
 
 #pragma mark TypeSystemMap
 
-TypeSystemMap::TypeSystemMap()
-: m_mutex(), m_map(), m_clear_in_progress(false) {}
+TypeSystemMap::TypeSystemMap() : m_mutex(), m_map() {}
 
 TypeSystemMap::~TypeSystemMap() {}
 
 void TypeSystemMap::Clear() {
-  collection map;
-  {
-std::lock_guard guard(m_mutex);
-map = m_map;
-m_clear_in_progress = true;
-  }
+  std::lock_guard guard(m_mutex);
   std::set visited;
-  for (auto pair : map) {
+  for (auto pair : m_map) {
 TypeSystem *type_system = pair.second.get();
 if (type_system && !visited.count(type_system)) {
   visited.insert(type_system);
   type_system->Finalize();
 }
   }
-  map.clear();
-  {
-std::lock_guard guard(m_mutex);
-m_map.clear();
-m_clear_in_progress = false;
-  }
+  m_map.clear();
 }
 
 void TypeSystemMap::ForEach(std::function const &callback) {
@@ -210,7 +199,7 @@
 if (pair.second && pair.second->SupportsLanguage(language)) {
   // Add a new mapping for "language" to point to an already existing
   // TypeSystem that supports this language
-  AddToMap(language, pair.second);
+  m_map[language] = pair.second;
   return pair.second.get();
 }
   }
@@ -221,7 +210,7 @@
   // Cache even if we get a shared pointer that contains null type system back
   lldb::TypeSystemSP type_system_sp =
   TypeSystem::CreateInstance(language, module);
-  AddToMap(language, type_system_sp);
+  m_map[language] = type_system_sp;
   return type_system_sp.get();
 }
 
@@ -238,7 +227,7 @@
   // Add a new mapping for "language" to point to an already existing
   // TypeSystem that supports this language
 
-  AddToMap(language, pair.second);
+  m_map[language] = pair.second;
   return pair.second.get();
 }
   }
@@ -247,16 +236,8 @@
 return nullptr;
 
   // Cache even if we get a shared pointer that contains null type system back
-  lldb::TypeSystemSP type_system_sp;
-  if (!m_clear_in_progress)
-type_system_sp = TypeSystem::CreateInstance(language, target);
-
-  AddToMap(language, type_system_sp);
+  lldb::TypeSystemSP type_system_sp =
+  TypeSystem::CreateInstance(language, target);
+  m_map[language] = type_system_sp;
   return type_system_sp.get();
 }
-
-void TypeSystemMap::AddToMap(lldb::LanguageType language,
- lldb::TypeSystemSP const &type_system_sp) {
-  if (!m_clear_in_progress)
-m_map[language] = type_system_sp;
-}
Index: include/lldb/Symbol/TypeSystem.h
===
--- include/lldb/Symbol/TypeSystem.h
+++ include/lldb/Symbol/TypeSystem.h
@@ -498,16 +498,11 @@
Target *target, bool can_create);
 
 protected:
-  // This function does not take the map mutex, and should only be called from
-  // functions that do take the mutex.
-  void AddToMap(lldb::LanguageType language,
-lldb::TypeSystemSP const &type_system_sp);
 
   typedef std::map collection;
   mutable std::mutex m_mutex; ///< A mutex to keep this object happy in
   ///multi-threaded environments.
   collection m_map;
-  bool m_clear_in_progress;
 };
 
 } // namespace lldb_private
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D64042: [Symbol] Improve Variable::GetLanguage

2019-07-19 Thread Alex Langford via Phabricator via lldb-commits
xiaobai added a comment.

ping


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

https://reviews.llvm.org/D64042



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


[Lldb-commits] [PATCH] D64989: [lldb] Fix crash when looking up type coming from the ClangModuleDeclVendor

2019-07-19 Thread Davide Italiano via Phabricator via lldb-commits
davide accepted this revision.
davide added a comment.
This revision is now accepted and ready to land.

No brainer.


Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D64989



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


[Lldb-commits] [PATCH] D64995: [lldb] Fix crash when tab-completing in multi-line expr

2019-07-19 Thread Davide Italiano via Phabricator via lldb-commits
davide requested changes to this revision.
davide added a comment.
This revision now requires changes to proceed.

See if you can write a pexpect test, as Pavel suggested.


Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D64995



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


[Lldb-commits] [PATCH] D65025: [Symbol] Improve TypeSystemMap mutex safety

2019-07-19 Thread Alex Langford via Phabricator via lldb-commits
xiaobai abandoned this revision.
xiaobai added a comment.

Actually from the looks of it, I completely misunderstood what's going on here. 
It looks like `AddToMap` should only be called by things that hold the mutex, 
meaning that this change isn't actually necessary. I do think that makes this 
code kind of frustrating to understand though. Closing.


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

https://reviews.llvm.org/D65025



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