[lldb] Remove support and workarounds for Android 4 and older (#124047)

This commit is contained in:
Brad Smith
2025-01-23 12:54:35 -05:00
committed by GitHub
parent 66e49e38ae
commit ff17a4136d
7 changed files with 2 additions and 80 deletions

View File

@@ -306,9 +306,4 @@ else()
set(LLDB_CAN_USE_DEBUGSERVER OFF)
endif()
if ((CMAKE_SYSTEM_NAME MATCHES "Android") AND LLVM_BUILD_STATIC AND
((ANDROID_ABI MATCHES "armeabi") OR (ANDROID_ABI MATCHES "mips")))
add_definitions(-DANDROID_USE_ACCEPT_WORKAROUND)
endif()
include(LLDBGenerateConfig)

View File

@@ -11,15 +11,6 @@
#ifndef LLDB_HOST_TIME_H
#define LLDB_HOST_TIME_H
#ifdef __ANDROID__
#include <android/api-level.h>
#endif
#if defined(__ANDROID_API__) && __ANDROID_API__ < 21
#include <time64.h>
extern time_t timegm(struct tm *t);
#else
#include <ctime>
#endif
#endif // LLDB_HOST_TIME_H

View File

@@ -113,7 +113,6 @@ else()
if (CMAKE_SYSTEM_NAME MATCHES "Android")
add_host_subdirectory(android
android/HostInfoAndroid.cpp
android/LibcGlue.cpp
)
endif()
elseif (CMAKE_SYSTEM_NAME MATCHES "FreeBSD")

View File

@@ -1,28 +0,0 @@
//===-- LibcGlue.cpp ------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
// This files adds functions missing from libc on earlier versions of Android
#include <android/api-level.h>
#include <sys/syscall.h>
#if __ANDROID_API__ < 21
#include <csignal>
#include <fcntl.h>
#include <sys/stat.h>
#include <sys/types.h>
#include "lldb/Host/Time.h"
time_t timegm(struct tm *t) { return (time_t)timegm64(t); }
int posix_openpt(int flags) { return open("/dev/ptmx", flags); }
#endif

View File

@@ -472,23 +472,7 @@ Status Socket::Accept(const Timeout<std::micro> &timeout, Socket *&socket) {
NativeSocket Socket::AcceptSocket(NativeSocket sockfd, struct sockaddr *addr,
socklen_t *addrlen, Status &error) {
error.Clear();
#if defined(ANDROID_USE_ACCEPT_WORKAROUND)
// Hack:
// This enables static linking lldb-server to an API 21 libc, but still
// having it run on older devices. It is necessary because API 21 libc's
// implementation of accept() uses the accept4 syscall(), which is not
// available in older kernels. Using an older libc would fix this issue, but
// introduce other ones, as the old libraries were quite buggy.
int fd = syscall(__NR_accept, sockfd, addr, addrlen);
if (fd >= 0) {
int flags = ::fcntl(fd, F_GETFD);
if (flags != -1 && ::fcntl(fd, F_SETFD, flags | FD_CLOEXEC) != -1)
return fd;
SetLastError(error);
close(fd);
}
return fd;
#elif defined(SOCK_CLOEXEC) && defined(HAVE_ACCEPT4)
#if defined(SOCK_CLOEXEC) && defined(HAVE_ACCEPT4)
int flags = SOCK_CLOEXEC;
NativeSocket fd = llvm::sys::RetryAfterSignal(
static_cast<NativeSocket>(-1), ::accept4, sockfd, addr, addrlen, flags);

View File

@@ -86,13 +86,6 @@ std::optional<std::string> HostInfoPosix::GetOSBuildString() {
return std::string(un.release);
}
#ifdef __ANDROID__
#include <android/api-level.h>
#endif
#if defined(__ANDROID_API__) && __ANDROID_API__ < 21
#define USE_GETPWUID
#endif
namespace {
class PosixUserIDResolver : public UserIDResolver {
protected:
@@ -107,14 +100,6 @@ struct PasswdEntry {
};
static std::optional<PasswdEntry> GetPassword(id_t uid) {
#ifdef USE_GETPWUID
// getpwuid_r is missing from android-9
// The caller should provide some thread safety by making sure no one calls
// this function concurrently, because using getpwuid is ultimately not
// thread-safe as we don't know who else might be calling it.
if (auto *user_info_ptr = ::getpwuid(uid))
return PasswdEntry{user_info_ptr->pw_name, user_info_ptr->pw_shell};
#else
struct passwd user_info;
struct passwd *user_info_ptr = &user_info;
char user_buffer[PATH_MAX];
@@ -124,7 +109,6 @@ static std::optional<PasswdEntry> GetPassword(id_t uid) {
user_info_ptr) {
return PasswdEntry{user_info_ptr->pw_name, user_info_ptr->pw_shell};
}
#endif
return std::nullopt;
}

View File

@@ -25,13 +25,10 @@
#include <sstream>
#ifdef __ANDROID__
#include <android/api-level.h>
#define PT_TRACE_ME PTRACE_TRACEME
#endif
#if defined(__ANDROID_API__) && __ANDROID_API__ < 15
#include <linux/personality.h>
#elif defined(__linux__)
#if defined(__linux__)
#include <sys/personality.h>
#endif