Improve LLDB probing and fix a small bug in umthunkstub.S.
authorPat Gavlin <pagavlin@microsoft.com>
Fri, 27 Feb 2015 21:30:03 +0000 (13:30 -0800)
committerPat Gavlin <pagavlin@microsoft.com>
Sat, 28 Feb 2015 02:08:58 +0000 (18:08 -0800)
- Replace the LLDB_{INCLUDE,LIB}_DIR environment variables with
  WITH_LLDB_{INCLUDES,LIBS} variables in lldbplugin/CMakeLists.txt. These
  variables are instead picked up in gen-buildsys-clang.sh.
- Look for a typical lldb installation as well as the Ubuntu-specific
  lldb-3.5 installationin the usual location as well as the Ubuntu-specific
  location for lldb-3.5.
- Unify the probing logic for Linux and OS X.
- In addition to ensuring the presence of LLDB.h, ensure that liblldb is
  present.
- Fix an ambiguously-sized comparison in umthunkstub.S.

src/ToolBox/SOS/lldbplugin/CMakeLists.txt
src/pal/tools/gen-buildsys-clang.sh
src/vm/amd64/umthunkstub.S

index 489de95..325ad3b 100644 (file)
@@ -1,35 +1,36 @@
 project(sosplugin)
 
 set(CMAKE_INCLUDE_CURRENT_DIR ON)
+set(ENABLE_SOSPLUGIN OFF)
 
-if((NOT $ENV{LLDB_INCLUDE_DIR} STREQUAL "") AND (NOT $ENV{LLDB_LIB_DIR} STREQUAL ""))
-    # The OSx build depends on the environment variables LLDB_INCLUDE_DIR and LLDB_LIB_DIR being set
-    set(LLDB_INCLUDE_DIR "$ENV{LLDB_INCLUDE_DIR}")
-    set(LLDB_LIB_DIR "$ENV{LLDB_LIB_DIR}")
-elseif(CLR_CMAKE_PLATFORM_LINUX)
-    # The Linux build depends on the lldb-3.5-dev package
-    set(LLVM_DIR "/usr/lib/llvm-3.5")
-    set(LLDB_INCLUDE_DIR "${LLVM_DIR}/include")
-    set(LLDB_LIB_DIR "${LLVM_DIR}/lib")
-
-    if (NOT HAVE_LLDB_H)
-        message(STATUS "Looking for include file LLDB.h")
-        if(NOT EXISTS ${LLDB_INCLUDE_DIR}/lldb/API/LLDB.h)
-            unset(HAVE_LLDB_H CACHE)
-            message(FATAL_ERROR "Cannot find LLDB.h. Try installing lldb-3.5-dev (or the appropriate packages for your platform)")
-        else()
-            set(HAVE_LLDB_H 1 CACHE INTERNAL "Have LLDB.h")
+if(CLR_CMAKE_PLATFORM_UNIX)
+    # Check for LLDB library
+    find_library(LLDB NAMES lldb lldb-3.5 PATHS WITH_LLDB_LIBS)
+    if(LLDB STREQUAL LLDB-NOTFOUND)
+        message(FATAL_ERROR "Cannot find liblldb or liblldb-3.5. Try installing lldb-3.5-dev (or the appropriate package for your platform)")
+    endif()
+
+    # Check for LLDB headers
+    find_path(LLDB_H "lldb/API/LLDB.h" PATHS WITH_LLDB_INCLUDES)
+    if(LLDB_H STREQUAL LLDB_H-NOTFOUND)
+        find_path(LLDB_H "lldb/API/LLDB.h" PATHS "/usr/lib/llvm-3.5/include")
+        if(LLDB_H STREQUAL LLDB_H-NOTFOUND)
+            message(FATAL_ERROR "Cannot find LLDB.h. Try installing lldb-3.5-dev (or the appropriate package for your platform)")
         endif()
-        message(STATUS "Looking for include file LLDB.h - found")
     endif()
+
+    # Add the parent's parent's directory to the include path
+    get_filename_component(LLDB_H LLDB_H DIRECTORY)
+    get_filename_component(LLDB_H LLDB_H DIRECTORY)
+    include_directories(LLDB_H)
+
+    set(ENABLE_SOSPLUGIN ON)
 endif()
 
-if((NOT ${LLDB_INCLUDE_DIR} STREQUAL "") AND (NOT ${LLDB_LIB_DIR} STREQUAL ""))
+if(ENABLE_SOSPLUGIN)
     add_compile_options(-Wno-delete-non-virtual-dtor)
 
     include_directories(inc)
-    include_directories("${LLDB_INCLUDE_DIR}")
-
     set(SOURCES
         sosplugin.cpp
         soscommand.cpp
@@ -39,14 +40,9 @@ if((NOT ${LLDB_INCLUDE_DIR} STREQUAL "") AND (NOT ${LLDB_LIB_DIR} STREQUAL ""))
     add_library(sosplugin SHARED ${SOURCES})
     add_dependencies(sosplugin sos)
 
-    if(CLR_CMAKE_PLATFORM_LINUX)
-        link_directories("${LLDB_LIB_DIR}")
-    endif(CLR_CMAKE_PLATFORM_LINUX)
-
-    if(CLR_CMAKE_PLATFORM_DARWIN)
-        find_library(LLDB LLDB PATHS ${LLDB_LIB_DIR})
+    if (CLR_CMAKE_PLATFORM_UNIX)
         target_link_libraries(sosplugin ${LLDB})
-    endif(CLR_CMAKE_PLATFORM_DARWIN)
+    endif()
 
     # add the install targets
     install (TARGETS sosplugin DESTINATION .)
index 760d89e..24e75da 100755 (executable)
@@ -65,6 +65,14 @@ if [ $OS = "Linux" ]; then
   [[ $? -eq 0 ]] || { echo "Unable to locate llvm-objdump"; exit 1; }
 fi
 
+cmake_extra_defines=
+if [[ -n "$LLDB_LIB_DIR" ]]; then
+    cmake_extra_defines="$cmake_extra_defines -DWITH_LLDB_LIBS=$LLDB_LIB_DIR"
+fi
+if [[ -n "$LLDB_INCLUDE_DIR" ]]; then
+    cmake_extra_defines="$cmake_extra_defines -DWITH_LLDB_INCLUDES=$LLDB_INCLUDE_DIR"
+fi
+
 cmake "-DCMAKE_USER_MAKE_RULES_OVERRIDE=$1/src/pal/tools/clang-compiler-override.txt" \
   "-DCMAKE_AR=$llvm_ar" \
   "-DCMAKE_LINKER=$llvm_link" \
@@ -72,5 +80,6 @@ cmake "-DCMAKE_USER_MAKE_RULES_OVERRIDE=$1/src/pal/tools/clang-compiler-override
   "-DCMAKE_OBJDUMP=$llvm_objdump" \
   "-DCMAKE_RANLIB=$llvm_ranlib" \
   "-DCMAKE_BUILD_TYPE=$buildtype" \
+  "$cmake_extra_defines" \
   "$1"
 
index 260fd21..e4a4ce8 100644 (file)
@@ -92,7 +92,7 @@ LOCAL_LABEL(HaveThread):
         // catch returning thread here if a GC is in progress
         //
         PREPARE_EXTERNAL_VAR g_TrapReturningThreads, rax
-        cmp                  [rax], 0
+        cmp                  dword ptr [rax], 0
         jnz                  LOCAL_LABEL(DoTrapReturningThreadsTHROW)
 
 LOCAL_LABEL(InCooperativeMode):