Skip to content

Commit ff17a41

Browse files
authored
[lldb] Remove support and workarounds for Android 4 and older (llvm#124047)
1 parent 66e49e3 commit ff17a41

File tree

7 files changed

+2
-80
lines changed

7 files changed

+2
-80
lines changed

lldb/cmake/modules/LLDBConfig.cmake

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -306,9 +306,4 @@ else()
306306
set(LLDB_CAN_USE_DEBUGSERVER OFF)
307307
endif()
308308

309-
if ((CMAKE_SYSTEM_NAME MATCHES "Android") AND LLVM_BUILD_STATIC AND
310-
((ANDROID_ABI MATCHES "armeabi") OR (ANDROID_ABI MATCHES "mips")))
311-
add_definitions(-DANDROID_USE_ACCEPT_WORKAROUND)
312-
endif()
313-
314309
include(LLDBGenerateConfig)

lldb/include/lldb/Host/Time.h

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,6 @@
1111
#ifndef LLDB_HOST_TIME_H
1212
#define LLDB_HOST_TIME_H
1313

14-
#ifdef __ANDROID__
15-
#include <android/api-level.h>
16-
#endif
17-
18-
#if defined(__ANDROID_API__) && __ANDROID_API__ < 21
19-
#include <time64.h>
20-
extern time_t timegm(struct tm *t);
21-
#else
2214
#include <ctime>
23-
#endif
2415

2516
#endif // LLDB_HOST_TIME_H

lldb/source/Host/CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,6 @@ else()
113113
if (CMAKE_SYSTEM_NAME MATCHES "Android")
114114
add_host_subdirectory(android
115115
android/HostInfoAndroid.cpp
116-
android/LibcGlue.cpp
117116
)
118117
endif()
119118
elseif (CMAKE_SYSTEM_NAME MATCHES "FreeBSD")

lldb/source/Host/android/LibcGlue.cpp

Lines changed: 0 additions & 28 deletions
This file was deleted.

lldb/source/Host/common/Socket.cpp

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -472,23 +472,7 @@ Status Socket::Accept(const Timeout<std::micro> &timeout, Socket *&socket) {
472472
NativeSocket Socket::AcceptSocket(NativeSocket sockfd, struct sockaddr *addr,
473473
socklen_t *addrlen, Status &error) {
474474
error.Clear();
475-
#if defined(ANDROID_USE_ACCEPT_WORKAROUND)
476-
// Hack:
477-
// This enables static linking lldb-server to an API 21 libc, but still
478-
// having it run on older devices. It is necessary because API 21 libc's
479-
// implementation of accept() uses the accept4 syscall(), which is not
480-
// available in older kernels. Using an older libc would fix this issue, but
481-
// introduce other ones, as the old libraries were quite buggy.
482-
int fd = syscall(__NR_accept, sockfd, addr, addrlen);
483-
if (fd >= 0) {
484-
int flags = ::fcntl(fd, F_GETFD);
485-
if (flags != -1 && ::fcntl(fd, F_SETFD, flags | FD_CLOEXEC) != -1)
486-
return fd;
487-
SetLastError(error);
488-
close(fd);
489-
}
490-
return fd;
491-
#elif defined(SOCK_CLOEXEC) && defined(HAVE_ACCEPT4)
475+
#if defined(SOCK_CLOEXEC) && defined(HAVE_ACCEPT4)
492476
int flags = SOCK_CLOEXEC;
493477
NativeSocket fd = llvm::sys::RetryAfterSignal(
494478
static_cast<NativeSocket>(-1), ::accept4, sockfd, addr, addrlen, flags);

lldb/source/Host/posix/HostInfoPosix.cpp

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -86,13 +86,6 @@ std::optional<std::string> HostInfoPosix::GetOSBuildString() {
8686
return std::string(un.release);
8787
}
8888

89-
#ifdef __ANDROID__
90-
#include <android/api-level.h>
91-
#endif
92-
#if defined(__ANDROID_API__) && __ANDROID_API__ < 21
93-
#define USE_GETPWUID
94-
#endif
95-
9689
namespace {
9790
class PosixUserIDResolver : public UserIDResolver {
9891
protected:
@@ -107,14 +100,6 @@ struct PasswdEntry {
107100
};
108101

109102
static std::optional<PasswdEntry> GetPassword(id_t uid) {
110-
#ifdef USE_GETPWUID
111-
// getpwuid_r is missing from android-9
112-
// The caller should provide some thread safety by making sure no one calls
113-
// this function concurrently, because using getpwuid is ultimately not
114-
// thread-safe as we don't know who else might be calling it.
115-
if (auto *user_info_ptr = ::getpwuid(uid))
116-
return PasswdEntry{user_info_ptr->pw_name, user_info_ptr->pw_shell};
117-
#else
118103
struct passwd user_info;
119104
struct passwd *user_info_ptr = &user_info;
120105
char user_buffer[PATH_MAX];
@@ -124,7 +109,6 @@ static std::optional<PasswdEntry> GetPassword(id_t uid) {
124109
user_info_ptr) {
125110
return PasswdEntry{user_info_ptr->pw_name, user_info_ptr->pw_shell};
126111
}
127-
#endif
128112
return std::nullopt;
129113
}
130114

lldb/source/Host/posix/ProcessLauncherPosixFork.cpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,10 @@
2525
#include <sstream>
2626

2727
#ifdef __ANDROID__
28-
#include <android/api-level.h>
2928
#define PT_TRACE_ME PTRACE_TRACEME
3029
#endif
3130

32-
#if defined(__ANDROID_API__) && __ANDROID_API__ < 15
33-
#include <linux/personality.h>
34-
#elif defined(__linux__)
31+
#if defined(__linux__)
3532
#include <sys/personality.h>
3633
#endif
3734

0 commit comments

Comments
 (0)