dart-sdk/runtime/vm/native_symbol_android.cc
Zach Anderson f407419d0a [vm] Reland: Prefix HOST_OS_* and TARGET_OS_* with DART_
This relands https://dart-review.googlesource.com/c/sdk/+/205633
but without renaming TARGET_OS_IPHONE to DART_TARGET_OS_IPHONE.
It also changes uses of TARGET_OS_IOS to
DART_TARGET_OS_MACOS_IOS to be consistent with the rest of the
VM.

TargetConditionals.h for XCode 13 defines several
TARGET_OS_* preprocessor symbols that confuse the
Dart build. There is probably a more targeted fix
for this, but renaming the symbols that Dart uses
will also prevent this problem if more symbols
are added to the platform headers in the future.

See: https://github.com/dart-lang/sdk/issues/46499

TEST=It builds.

Change-Id: Ie775c19dd23cfdf5f65e5ebc6ee4ec3a561676fa
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/205860
Commit-Queue: Zach Anderson <zra@google.com>
Reviewed-by: Alexander Aprelev <aam@google.com>
2021-07-02 19:06:45 +00:00

71 lines
1.8 KiB
C++

// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
#include "platform/globals.h"
#if defined(DART_HOST_OS_ANDROID)
#include "vm/native_symbol.h"
#include "vm/os.h"
#include <cxxabi.h> // NOLINT
#include <dlfcn.h> // NOLINT
namespace dart {
void NativeSymbolResolver::Init() {}
void NativeSymbolResolver::Cleanup() {}
char* NativeSymbolResolver::LookupSymbolName(uword pc, uword* start) {
Dl_info info;
int r = dladdr(reinterpret_cast<void*>(pc), &info);
if (r == 0) {
return NULL;
}
if (info.dli_sname == NULL) {
return NULL;
}
if (start != NULL) {
*start = reinterpret_cast<uword>(info.dli_saddr);
}
int status = 0;
size_t len = 0;
char* demangled = abi::__cxa_demangle(info.dli_sname, NULL, &len, &status);
MSAN_UNPOISON(demangled, len);
if (status == 0) {
return demangled;
}
return strdup(info.dli_sname);
}
void NativeSymbolResolver::FreeSymbolName(char* name) {
free(name);
}
bool NativeSymbolResolver::LookupSharedObject(uword pc,
uword* dso_base,
char** dso_name) {
Dl_info info;
int r = dladdr(reinterpret_cast<void*>(pc), &info);
if (r == 0) {
return false;
}
if (dso_base != nullptr) {
*dso_base = reinterpret_cast<uword>(info.dli_fbase);
}
if (dso_name != nullptr) {
*dso_name = strdup(info.dli_fname);
}
return true;
}
void NativeSymbolResolver::AddSymbols(const char* dso_name,
void* buffer,
size_t size) {
OS::PrintErr("warning: Dart_AddSymbols has no effect on Android\n");
}
} // namespace dart
#endif // defined(DART_HOST_OS_ANDROID)