Bug 689178 - Remove crash-reporter hooks to externally provide library mappings. r=gsvelto

This is a rebase of a 7-year-old patch that was r=ted. The hooks are not
used as of bug 725231.

Differential Revision: https://phabricator.services.mozilla.com/D81026
This commit is contained in:
Mike Hommey 2020-06-25 08:43:23 +00:00
parent 200194bccd
commit 6b2fc90663
5 changed files with 0 additions and 105 deletions

View File

@ -67,13 +67,6 @@ enum StartupEvent {
using namespace mozilla;
static const int MAX_MAPPING_INFO = 32;
static mapping_info lib_mapping[MAX_MAPPING_INFO];
APKOPEN_EXPORT const struct mapping_info* getLibraryMapping() {
return lib_mapping;
}
void JNI_Throw(JNIEnv* jenv, const char* classname, const char* msg) {
__android_log_print(ANDROID_LOG_ERROR, "GeckoLibLoad", "Throw\n");
jclass cls = jenv->FindClass(classname);
@ -148,32 +141,6 @@ static void* plc_handle = nullptr;
#endif
static void* nss_handle = nullptr;
static int mapping_count = 0;
extern "C" void report_mapping(char* name, void* base, uint32_t len,
uint32_t offset) {
if (mapping_count >= MAX_MAPPING_INFO) return;
struct mapping_info* info = &lib_mapping[mapping_count++];
info->name = strdup(name);
info->base = (uintptr_t)base;
info->len = len;
info->offset = offset;
}
extern "C" void delete_mapping(const char* name) {
for (int pos = 0; pos < mapping_count; ++pos) {
struct mapping_info* info = &lib_mapping[pos];
if (!strcmp(info->name, name)) {
struct mapping_info* last = &lib_mapping[mapping_count - 1];
free(info->name);
*info = *last;
--mapping_count;
break;
}
}
}
static UniquePtr<char[]> getUnpackedLibraryName(const char* libraryName) {
static const char* libdir = getenv("MOZ_ANDROID_LIBDIR");

View File

@ -11,14 +11,6 @@
# define APKOPEN_EXPORT __attribute__((visibility("default")))
#endif
struct mapping_info {
char* name;
uintptr_t base;
size_t len;
size_t offset;
};
APKOPEN_EXPORT const struct mapping_info* getLibraryMapping();
APKOPEN_EXPORT void abortThroughJava(const char* msg);
static const int SUCCESS = 0;

View File

@ -382,35 +382,6 @@ static const SIZE_T kReserveSize = 0x5000000; // 80 MB
static void* gBreakpadReservedVM;
#endif
#if defined(MOZ_WIDGET_ANDROID)
// Android builds use a custom library loader,
// so the embedding will provide a list of shared
// libraries that are mapped into anonymous mappings.
typedef struct {
std::string name;
uintptr_t start_address;
size_t length;
size_t file_offset;
} mapping_info;
static std::vector<mapping_info> gLibraryMappings;
static void AddMappingInfoToExceptionHandler(const mapping_info& aInfo) {
PageAllocator allocator;
auto_wasteful_vector<uint8_t, kDefaultBuildIdSize> guid(&allocator);
FileID::ElfFileIdentifierFromMappedFile(
reinterpret_cast<void const*>(aInfo.start_address), guid);
gExceptionHandler->AddMappingInfo(aInfo.name, guid, aInfo.start_address,
aInfo.length, aInfo.file_offset);
}
static void AddAndroidMappingInfo() {
for (auto info : gLibraryMappings) {
AddMappingInfoToExceptionHandler(info);
}
}
#endif // defined(MOZ_WIDGET_ANDROID)
#ifdef XP_LINUX
static inline void my_inttostring(intmax_t t, char* buffer,
size_t buffer_length) {
@ -2116,10 +2087,6 @@ nsresult SetExceptionHandler(nsIFile* aXREDirectory, bool force /*=false*/) {
if (keyExistsAndHasValidFormat) showOSCrashReporter = prefValue;
#endif
#if defined(MOZ_WIDGET_ANDROID)
AddAndroidMappingInfo();
#endif // defined(MOZ_WIDGET_ANDROID)
mozalloc_set_oom_abort_handler(AnnotateOOMAllocationSize);
oldTerminateHandler = std::set_terminate(&TerminateHandler);
@ -3904,20 +3871,6 @@ void SetNotificationPipeForChild(int childCrashFd) {
void SetCrashAnnotationPipeForChild(int childCrashAnnotationFd) {
gChildCrashAnnotationReportFd = childCrashAnnotationFd;
}
void AddLibraryMapping(const char* library_name, uintptr_t start_address,
size_t mapping_length, size_t file_offset) {
mapping_info info;
if (!gExceptionHandler) {
info.name = library_name;
info.start_address = start_address;
info.length = mapping_length;
info.file_offset = file_offset;
gLibraryMappings.push_back(info);
} else {
AddMappingInfoToExceptionHandler(info);
}
}
#endif
} // namespace CrashReporter

View File

@ -323,15 +323,6 @@ bool UnsetRemoteExceptionHandler();
// the handle for the pipe since it can't get remapped to a default value.
void SetNotificationPipeForChild(int childCrashFd);
void SetCrashAnnotationPipeForChild(int childCrashAnnotationFd);
// Android builds use a custom library loader, so /proc/<pid>/maps
// will just show anonymous mappings for all the non-system
// shared libraries. This API is to work around that by providing
// info about the shared libraries that are mapped into these anonymous
// mappings.
void AddLibraryMapping(const char* library_name, uintptr_t start_address,
size_t mapping_length, size_t file_offset);
#endif
// Annotates the crash report with the name of the calling thread.

View File

@ -15,7 +15,6 @@
#include "nsTArray.h"
#include "nsString.h"
#include "nsAppRunner.h"
#include "APKOpen.h"
#include "nsExceptionHandler.h"
#include "mozilla/Bootstrap.h"
@ -27,13 +26,6 @@ extern "C" NS_EXPORT void GeckoStart(JNIEnv* env, char** argv, int argc,
const StaticXREAppData& aAppData) {
mozilla::jni::SetGeckoThreadEnv(env);
const struct mapping_info* info = getLibraryMapping();
while (info->name) {
CrashReporter::AddLibraryMapping(info->name, info->base, info->len,
info->offset);
info++;
}
if (!argv) {
LOG("Failed to get arguments for GeckoStart\n");
return;