diff options
Diffstat (limited to 'lldb')
| -rw-r--r-- | lldb/cmake/platforms/Android.cmake | 8 | ||||
| -rw-r--r-- | lldb/test/lldbtest.py | 50 | ||||
| -rw-r--r-- | lldb/test/make/Makefile.rules | 4 | 
3 files changed, 38 insertions, 24 deletions
diff --git a/lldb/cmake/platforms/Android.cmake b/lldb/cmake/platforms/Android.cmake index d2a5d5cb9db..df735612d8b 100644 --- a/lldb/cmake/platforms/Android.cmake +++ b/lldb/cmake/platforms/Android.cmake @@ -39,8 +39,8 @@ set( ANDROID True )  set( __ANDROID_NDK__ True )  # linking lldb-server statically for Android avoids the need to ship two -# binaries (pie for API 21+ and non-pie for API 14-). It's possible to use -# a non-pie shim on API 14-, but that requires lldb-server to dynamically export +# binaries (pie for API 21+ and non-pie for API 16-). It's possible to use +# a non-pie shim on API 16-, but that requires lldb-server to dynamically export  # its symbols, which significantly increases the binary size. Static linking, on  # the other hand, has little to no effect on the binary size.  if ( NOT DEFINED LLVM_BUILD_STATIC ) @@ -110,8 +110,8 @@ endif()  if ( NOT LLVM_BUILD_STATIC )   # PIE is required for API 21+ so we enable it if we're not statically linking - # unfortunately, it is not supported before API 14 so we need to do something else there - # see http://llvm.org/pr23457 + # unfortunately, it is not supported before API 16 so we need to do something + # else there see http://llvm.org/pr23457   set( ANDROID_CXX_FLAGS "${ANDROID_CXX_FLAGS} -pie -fPIE" )  endif() diff --git a/lldb/test/lldbtest.py b/lldb/test/lldbtest.py index c3deee9cb36..288dd11953e 100644 --- a/lldb/test/lldbtest.py +++ b/lldb/test/lldbtest.py @@ -431,21 +431,30 @@ def run_adb_command(cmd, device_id):      stdout, stderr = p.communicate()      return p.returncode, stdout, stderr +def target_is_android(): +    if not hasattr(target_is_android, 'result'): +        triple = lldb.DBG.GetSelectedPlatform().GetTriple() +        match = re.match(".*-.*-.*-android", triple) +        target_is_android.result = match is not None +    return target_is_android.result +  def android_device_api(): -    assert lldb.platform_url is not None -    device_id = None -    parsed_url = urlparse.urlparse(lldb.platform_url) -    if parsed_url.scheme == "adb": -        device_id = parsed_url.netloc.split(":")[0] -    retcode, stdout, stderr = run_adb_command( -        ["shell", "getprop", "ro.build.version.sdk"], device_id) -    if retcode == 0: -        return int(stdout) -    else: -        raise LookupError( -            ">>> Unable to determine the API level of the Android device.\n" -            ">>> stdout:\n%s\n" -            ">>> stderr:\n%s\n" % (stdout, stderr)) +    if not hasattr(android_device_api, 'result'): +        assert lldb.platform_url is not None +        device_id = None +        parsed_url = urlparse.urlparse(lldb.platform_url) +        if parsed_url.scheme == "adb": +            device_id = parsed_url.netloc.split(":")[0] +        retcode, stdout, stderr = run_adb_command( +            ["shell", "getprop", "ro.build.version.sdk"], device_id) +        if retcode == 0: +            android_device_api.result = int(stdout) +        else: +            raise LookupError( +                ">>> Unable to determine the API level of the Android device.\n" +                ">>> stdout:\n%s\n" +                ">>> stderr:\n%s\n" % (stdout, stderr)) +    return android_device_api.result  #  # Decorators for categorizing test cases. @@ -690,9 +699,7 @@ def expectedFailureAndroid(bugnumber=None, api_levels=None):              for which a test is expected to fail.      """      def fn(self): -        triple = self.dbg.GetSelectedPlatform().GetTriple() -        match = re.match(".*-.*-.*-android", triple) -        if match: +        if target_is_android():              if not api_levels:                  return True              device_api = android_device_api() @@ -1036,8 +1043,7 @@ def skipIfTargetAndroid(api_levels=None):          def wrapper(*args, **kwargs):              from unittest2 import case              self = args[0] -            triple = self.dbg.GetSelectedPlatform().GetTriple() -            if re.match(".*-.*-.*-android", triple): +            if target_is_android():                  if api_levels:                      device_api = android_device_api()                      if device_api and (device_api in api_levels): @@ -1984,6 +1990,12 @@ class Base(unittest2.TestCase):          if lldb.skip_build_and_cleanup:              return          module = builder_module() +        if target_is_android(): +            if dictionary is None: +                dictionary = {} +            dictionary["OS"] = "Android" +            if android_device_api() >= 16: +                dictionary["PIE"] = 1          if not module.buildDwarf(self, architecture, compiler, dictionary, clean):              raise Exception("Don't know how to build binary with dwarf") diff --git a/lldb/test/make/Makefile.rules b/lldb/test/make/Makefile.rules index f612703a088..69d5de147fc 100644 --- a/lldb/test/make/Makefile.rules +++ b/lldb/test/make/Makefile.rules @@ -251,7 +251,9 @@ endif  # Android specific options  #----------------------------------------------------------------------  ifeq "$(OS)" "Android" -    LDFLAGS += -pie +    ifdef PIE +        LDFLAGS += -pie +    endif      replace_with = $(if $(findstring clang,$(1)), \                          $(subst clang,$(2),$(1)), \                          $(if $(findstring gcc,$(1)), \  | 

