[Lldb-commits] [lldb] lldb: android: fix missing Python import of urlparse from lldb test utilities (PR #99934)

2024-07-22 Thread Andrew Rogers via lldb-commits

https://github.com/andrurogerz created 
https://github.com/llvm/llvm-project/pull/99934

## Issue
Attempting to run the lldb API tests against a remote-android target fails with 
the error `NameError: name 'urlparse' is not defined`.

## Root Cause
It looks the Python import of `urlparse` was removed by mistake in 
22ea97d7bfd65abf68a68b13bf96ad69be23df54. This import is only used when running 
the lldb API tests against a remote-android target so it went unnoticed.

## Fix
This change simply puts back the missing import. It is a one line change.

fixes 99931

## Validation
Tested on Fedora 39 with an attached Android device:

`cd llvm-project`
`cmake -S llvm -B build -G Ninja -DLLVM_ENABLE_PROJECTS='clang;lldb' 
-DCMAKE_BUILD_TYPE=Release -DLLDB_ENABLE_PYTHON=On`
`ninja -C build`
`./build/bin/lldb-dotest --arch aarch64 --out-of-tree-debugserver 
--platform-name=remote-android --platform-working-dir=/data/local/tmp/ds2 
--platform-url=connect://localhost:5432 --compiler 
~/Android/Sdk/ndk/21.4.7075529/toolchains/llvm/prebuilt/linux-x86_64/bin/clang`

>From 0dc32f964a0f8d03d9c1aaebd453167738d461d8 Mon Sep 17 00:00:00 2001
From: Andrew Rogers 
Date: Mon, 22 Jul 2024 08:48:13 -0700
Subject: [PATCH] android: fix missing import for urlparse

This import is only used on the Android path. It looks like it was
removed by mistake in 22ea97d7bfd65abf68a68b13bf96ad69be23df54.
---
 lldb/packages/Python/lldbsuite/test/lldbplatformutil.py | 1 +
 1 file changed, 1 insertion(+)

diff --git a/lldb/packages/Python/lldbsuite/test/lldbplatformutil.py 
b/lldb/packages/Python/lldbsuite/test/lldbplatformutil.py
index b7e6f240f59f6..e3c6fd1a99568 100644
--- a/lldb/packages/Python/lldbsuite/test/lldbplatformutil.py
+++ b/lldb/packages/Python/lldbsuite/test/lldbplatformutil.py
@@ -9,6 +9,7 @@
 import sys
 import os
 from packaging import version
+from urllib.parse import urlparse
 
 # LLDB modules
 import lldb

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


[Lldb-commits] [lldb] lldb: android: fix missing Python import of urlparse from lldb test utilities (PR #99934)

2024-07-22 Thread Andrew Rogers via lldb-commits

andrurogerz wrote:

cc @compnerd

https://github.com/llvm/llvm-project/pull/99934
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] lldb: android: fix missing Python import of urlparse in lldb test utilities (PR #99934)

2024-07-22 Thread Andrew Rogers via lldb-commits

https://github.com/andrurogerz edited 
https://github.com/llvm/llvm-project/pull/99934
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] lldb: android: fix missing Python import of urlparse in lldb test utilities (PR #99934)

2024-07-22 Thread Andrew Rogers via lldb-commits

https://github.com/andrurogerz edited 
https://github.com/llvm/llvm-project/pull/99934
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] lldb: get lldb API tests working with newer Android NDKs (PR #106443)

2024-08-28 Thread Andrew Rogers via lldb-commits

https://github.com/andrurogerz created 
https://github.com/llvm/llvm-project/pull/106443

Running the LLDB API tests against a remote Android target with NDK version r22 
or later fails when compiling the test inferiors.

## Problem Details
Android introduced a unified tools layout in NDK r19 (2019) and
 removed the old layout in r22 (2021). Releases r19, r20, and r21 support both 
the old and new layout side-by-side. More details are 
[here](https://github.com/android/ndk/issues/780). NDK r21 is the most recent 
NDK that is still compatible with the LLDB API tests.

## Solution

This change updates `Android.rules` to match the newer unified tools
 structure in NDK r19, which is described in more detail at . It significantly 
simplifies `Android.rules` in the process.

**With this change, the pre-2019 NDK structure is no longer supported. Only NDK 
r19 (from 2019) and later can be used when running the LLDB API tests. ** We 
can support both the old and new NDK toolchain layouts side-by-side if the 
maintainers object to only supporting NDKs released since 2019 (at the cost of 
readability and maintainability).

## Test Plan
Run a sub-set of the LLDB API tests against remote Android targets for the four 
primary architectures i386, x86_64, arm, and aarch64. Run with both r19 (the 
oldest supported) and r26 (more recent, unified layout only) NDK versions.

For each case, run the copy of `lldb-server` from the Android NDK on the device.

Example test command for aarch64:
```
./build/bin/lldb-dotest --out-of-tree-debugserver --arch aarch64 
--platform-name remote-android --platform-url connect://localhost:5432 
--platform-working-dir /data/local/tmp 
--compiler=$ANDROID_NDK_ROOT/toolchains/llvm/prebuilt/linux-x86_64/bin/clang 
--exclude 
/home/user/src/ds2/Support/Testing/Excluded/upstream/android-x86_64.excluded 
--env OBJCOPY=/home/user/src/llvm/llvm-project/build/bin/llvm-objcopy --env 
ARCHIVER=/home/user/src/llvm/llvm-project/build/bin/llvm-ar 
lldb/test/API/android/
```

NOTE: there are a lot of failures when running the full suite. These failures 
occur independent of this change.

>From 476a0109d5889a80d90ae484a553cce058a6e5ce Mon Sep 17 00:00:00 2001
From: Andrew Rogers 
Date: Mon, 26 Aug 2024 17:42:35 -0700
Subject: [PATCH 1/2] [android] get lldb tests working against newer Android
 NDKs

Android introduced a unified tools layout in NDK r19 (2019) and
removed the old layout in r22 (2021). Running lldb tests with NDK r22
or newer fails when compiling the test inferiors.

This change updates `Android.rules` to match the newer unified tools
structure introduced in NDK r19, which is described in more detail at
https://github.com/android/ndk/issues/780.

NOTE: After this change, ONLY NDK r19c and later can be used when
running the lldb tests. The pre-2019 NDK structure is no longer
supported.
---
 .../Python/lldbsuite/test/make/Android.rules  | 78 ++-
 1 file changed, 23 insertions(+), 55 deletions(-)

diff --git a/lldb/packages/Python/lldbsuite/test/make/Android.rules 
b/lldb/packages/Python/lldbsuite/test/make/Android.rules
index cd7d8ae74d6bf3..518a90a5ba84d7 100644
--- a/lldb/packages/Python/lldbsuite/test/make/Android.rules
+++ b/lldb/packages/Python/lldbsuite/test/make/Android.rules
@@ -1,81 +1,49 @@
 NDK_ROOT := $(shell dirname $(CC))/../../../../..
 
-ifeq "$(findstring 64, $(ARCH))" "64"
-   # lowest 64-bit API level
-   API_LEVEL := 21
-else ifeq "$(ARCH)" "i386"
-   # clone(2) declaration is present only since this api level
-   API_LEVEL := 17
+ifeq "$(HOST_OS)" "Linux"
+   HOST_TAG := linux-x86_64
+else ifeq "$(HOST_OS)" "Darwin"
+   HOST_TAG := darwin-x86_64
 else
-   # lowest supported 32-bit API level
-   API_LEVEL := 16
+   HOST_TAG := windows-x86_64
 endif
 
 ifeq "$(ARCH)" "arm"
-   SYSROOT_ARCH := arm
-   STL_ARCH := armeabi-v7a
TRIPLE := armv7-none-linux-androideabi
ARCH_CFLAGS += -march=armv7-a -mfloat-abi=softfp -mfpu=vfpv3-d16 -marm
 else ifeq "$(ARCH)" "aarch64"
-   SYSROOT_ARCH := arm64
-   STL_ARCH := arm64-v8a
TRIPLE := aarch64-none-linux-android
 else ifeq "$(ARCH)" "i386"
-   SYSROOT_ARCH := x86
-   STL_ARCH := x86
TRIPLE := i686-none-linux-android
 else
-   SYSROOT_ARCH := $(ARCH)
-   STL_ARCH := $(ARCH)
TRIPLE := $(ARCH)-none-linux-android
 endif
 
-ifeq "$(findstring 86,$(ARCH))" "86"
-   TOOLCHAIN_DIR := $(STL_ARCH)-4.9
-else ifeq "$(ARCH)" "arm"
-   TOOLCHAIN_DIR := arm-linux-androideabi-4.9
-else
-   TOOLCHAIN_DIR := $(subst -none,,$(TRIPLE))-4.9
-endif
+TOOLCHAIN_SYSROOT := $(NDK_ROOT)/toolchains/llvm/prebuilt/$(HOST_TAG)/sysroot
 
-ifeq "$(ARCH)" "arm"
-   TOOL_PREFIX := arm-linux-androideabi
-else
-   TOOL_PREFIX := $(subst -none,,$(TRIPLE))
-endif
+# lowest 64-bit API level
+API_LEVEL := 21
 
-ifeq "$(HOST_OS)" "Linux"
-   HOST_TAG := linux-x86_64
-else ifeq "$(HOST_OS)" "Darwin"
-   HOST_TAG := darwin-x86_64
+ifeq

[Lldb-commits] [lldb] lldb: get lldb API tests working with newer Android NDKs (PR #106443)

2024-08-28 Thread Andrew Rogers via lldb-commits

https://github.com/andrurogerz edited 
https://github.com/llvm/llvm-project/pull/106443
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] lldb: get lldb API tests working with newer Android NDKs (PR #106443)

2024-08-28 Thread Andrew Rogers via lldb-commits

https://github.com/andrurogerz edited 
https://github.com/llvm/llvm-project/pull/106443
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] lldb: get lldb API tests working with newer Android NDKs (PR #106443)

2024-08-28 Thread Andrew Rogers via lldb-commits

https://github.com/andrurogerz edited 
https://github.com/llvm/llvm-project/pull/106443
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] lldb: get lldb API tests working with newer Android NDKs (PR #106443)

2024-08-28 Thread Andrew Rogers via lldb-commits

https://github.com/andrurogerz edited 
https://github.com/llvm/llvm-project/pull/106443
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] lldb: get lldb API tests working with newer Android NDKs (PR #106443)

2024-08-28 Thread Andrew Rogers via lldb-commits

https://github.com/andrurogerz ready_for_review 
https://github.com/llvm/llvm-project/pull/106443
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] lldb: get lldb API tests working with newer Android NDKs (PR #106443)

2024-08-29 Thread Andrew Rogers via lldb-commits

https://github.com/andrurogerz edited 
https://github.com/llvm/llvm-project/pull/106443
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] lldb: get lldb API tests working with newer Android NDKs (PR #106443)

2024-08-29 Thread Andrew Rogers via lldb-commits

https://github.com/andrurogerz updated 
https://github.com/llvm/llvm-project/pull/106443

>From 476a0109d5889a80d90ae484a553cce058a6e5ce Mon Sep 17 00:00:00 2001
From: Andrew Rogers 
Date: Mon, 26 Aug 2024 17:42:35 -0700
Subject: [PATCH 1/4] [android] get lldb tests working against newer Android
 NDKs

Android introduced a unified tools layout in NDK r19 (2019) and
removed the old layout in r22 (2021). Running lldb tests with NDK r22
or newer fails when compiling the test inferiors.

This change updates `Android.rules` to match the newer unified tools
structure introduced in NDK r19, which is described in more detail at
https://github.com/android/ndk/issues/780.

NOTE: After this change, ONLY NDK r19c and later can be used when
running the lldb tests. The pre-2019 NDK structure is no longer
supported.
---
 .../Python/lldbsuite/test/make/Android.rules  | 78 ++-
 1 file changed, 23 insertions(+), 55 deletions(-)

diff --git a/lldb/packages/Python/lldbsuite/test/make/Android.rules 
b/lldb/packages/Python/lldbsuite/test/make/Android.rules
index cd7d8ae74d6bf3..518a90a5ba84d7 100644
--- a/lldb/packages/Python/lldbsuite/test/make/Android.rules
+++ b/lldb/packages/Python/lldbsuite/test/make/Android.rules
@@ -1,81 +1,49 @@
 NDK_ROOT := $(shell dirname $(CC))/../../../../..
 
-ifeq "$(findstring 64, $(ARCH))" "64"
-   # lowest 64-bit API level
-   API_LEVEL := 21
-else ifeq "$(ARCH)" "i386"
-   # clone(2) declaration is present only since this api level
-   API_LEVEL := 17
+ifeq "$(HOST_OS)" "Linux"
+   HOST_TAG := linux-x86_64
+else ifeq "$(HOST_OS)" "Darwin"
+   HOST_TAG := darwin-x86_64
 else
-   # lowest supported 32-bit API level
-   API_LEVEL := 16
+   HOST_TAG := windows-x86_64
 endif
 
 ifeq "$(ARCH)" "arm"
-   SYSROOT_ARCH := arm
-   STL_ARCH := armeabi-v7a
TRIPLE := armv7-none-linux-androideabi
ARCH_CFLAGS += -march=armv7-a -mfloat-abi=softfp -mfpu=vfpv3-d16 -marm
 else ifeq "$(ARCH)" "aarch64"
-   SYSROOT_ARCH := arm64
-   STL_ARCH := arm64-v8a
TRIPLE := aarch64-none-linux-android
 else ifeq "$(ARCH)" "i386"
-   SYSROOT_ARCH := x86
-   STL_ARCH := x86
TRIPLE := i686-none-linux-android
 else
-   SYSROOT_ARCH := $(ARCH)
-   STL_ARCH := $(ARCH)
TRIPLE := $(ARCH)-none-linux-android
 endif
 
-ifeq "$(findstring 86,$(ARCH))" "86"
-   TOOLCHAIN_DIR := $(STL_ARCH)-4.9
-else ifeq "$(ARCH)" "arm"
-   TOOLCHAIN_DIR := arm-linux-androideabi-4.9
-else
-   TOOLCHAIN_DIR := $(subst -none,,$(TRIPLE))-4.9
-endif
+TOOLCHAIN_SYSROOT := $(NDK_ROOT)/toolchains/llvm/prebuilt/$(HOST_TAG)/sysroot
 
-ifeq "$(ARCH)" "arm"
-   TOOL_PREFIX := arm-linux-androideabi
-else
-   TOOL_PREFIX := $(subst -none,,$(TRIPLE))
-endif
+# lowest 64-bit API level
+API_LEVEL := 21
 
-ifeq "$(HOST_OS)" "Linux"
-   HOST_TAG := linux-x86_64
-else ifeq "$(HOST_OS)" "Darwin"
-   HOST_TAG := darwin-x86_64
+ifeq "$(ARCH)" "arm"
+   ARCH_DIR := arm-linux-androideabi
 else
-   HOST_TAG := windows-x86_64
+   ARCH_DIR := $(subst -none,,$(TRIPLE))
 endif
 
-GCC_TOOLCHAIN = $(NDK_ROOT)/toolchains/$(TOOLCHAIN_DIR)/prebuilt/$(HOST_TAG)
-
-OBJCOPY ?= $(GCC_TOOLCHAIN)/bin/$(TOOL_PREFIX)-objcopy
-ARCHIVER ?= $(GCC_TOOLCHAIN)/bin/$(TOOL_PREFIX)-ar
-
-ifeq "$(findstring clang,$(CC))" "clang"
-   ARCH_CFLAGS += -target $(TRIPLE) --gcc-toolchain=$(GCC_TOOLCHAIN)
-   ARCH_LDFLAGS += -target $(TRIPLE) --gcc-toolchain=$(GCC_TOOLCHAIN)
-endif
-
-ARCH_CFLAGS += --sysroot=$(NDK_ROOT)/sysroot \
-   -isystem $(NDK_ROOT)/sysroot/usr/include/$(TOOL_PREFIX) \
-   -D__ANDROID_API__=$(API_LEVEL) \
-   -isystem 
$(NDK_ROOT)/platforms/android-$(API_LEVEL)/arch-$(SYSROOT_ARCH)/usr/include
-
-ARCH_LDFLAGS += 
--sysroot=$(NDK_ROOT)/platforms/android-$(API_LEVEL)/arch-$(SYSROOT_ARCH) -lm
+ARCH_CFLAGS += \
+   --target=$(TRIPLE) \
+   --sysroot=$(TOOLCHAIN_SYSROOT) \
+   -D __ANDROID_API__=$(API_LEVEL) \
 
 ARCH_CXXFLAGS += \
-   -isystem $(NDK_ROOT)/sources/cxx-stl/llvm-libc++/include \
-   -isystem $(NDK_ROOT)/sources/android/support/include \
-   -isystem $(NDK_ROOT)/sources/cxx-stl/llvm-libc++abi/include
+   -isystem $(TOOLCHAIN_SYSROOT)/usr/include/c++/v1 \
 
 ARCH_LDFLAGS += \
-   -L$(NDK_ROOT)/sources/cxx-stl/llvm-libc++/libs/$(STL_ARCH) \
-   
$(NDK_ROOT)/sources/cxx-stl/llvm-libc++/libs/$(STL_ARCH)/libc++_static.a \
+   --target=$(TRIPLE) \
+   --sysroot=$(TOOLCHAIN_SYSROOT) \
+   --prefix=$(TOOLCHAIN_SYSROOT)/usr/lib/$(ARCH_DIR)/$(API_LEVEL) \
+   
--library-directory=$(TOOLCHAIN_SYSROOT)/usr/lib/$(ARCH_DIR)/$(API_LEVEL) \
+   $(TOOLCHAIN_SYSROOT)/usr/lib/$(ARCH_DIR)/libc++_static.a \
+   -lm \
-lc++abi \
-   -nostdlib++
+   -nostdlib++ \

>From 14064c39f8c53bcdcf3f7ace7455aa3a4b9bca28 Mon Sep 17 00:00:00 2001
From: Andrew Rogers 
Date: Wed, 28 Aug 2024 12:08:10 -0700
Subject: [PATCH 2/4] [android] explicitly fail inferior 

[Lldb-commits] [lldb] lldb: get lldb API tests working with newer Android NDKs (PR #106443)

2024-08-29 Thread Andrew Rogers via lldb-commits

https://github.com/andrurogerz edited 
https://github.com/llvm/llvm-project/pull/106443
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] lldb: get lldb API tests working with newer Android NDKs (PR #106443)

2024-09-16 Thread Andrew Rogers via lldb-commits

andrurogerz wrote:

@labath there have been no additional comments; is there anyone specifically 
you'd like me to seek feedback from?

@JDevlieghere would you have a moment to take a look at this PR soon? I really 
appreciate it.

@compnerd FYI

https://github.com/llvm/llvm-project/pull/106443
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits