bionic supplies PR_SET_VMA now.

Bug: N/A
Test: builds
Change-Id: I8254711543cbf11bdf905ea441655ca1c1e82aac
This commit is contained in:
Elliott Hughes 2018-08-22 12:06:20 -07:00
parent 56d079b40a
commit 95c34a72af
4 changed files with 7 additions and 35 deletions

View file

@ -35,10 +35,6 @@
#include <backtrace/BacktraceMap.h>
#include <unwindstack/Memory.h>
// Definitions of prctl arguments to set a vma name in Android kernels.
#define ANDROID_PR_SET_VMA 0x53564d41
#define ANDROID_PR_SET_VMA_ANON_NAME 0
constexpr size_t kNumMaps = 2000;
static bool CountMaps(pid_t pid, size_t* num_maps) {
@ -93,10 +89,11 @@ static void CreateMap(benchmark::State& state, BacktraceMap* (*map_func)(pid_t,
exit(1);
}
memset(memory, 0x1, PAGE_SIZE);
if (prctl(ANDROID_PR_SET_VMA, ANDROID_PR_SET_VMA_ANON_NAME, memory, PAGE_SIZE, "test_map") ==
-1) {
#if defined(PR_SET_VMA)
if (prctl(PR_SET_VMA, PR_SET_VMA_ANON_NAME, memory, PAGE_SIZE, "test_map") == -1) {
fprintf(stderr, "Failed: %s\n", strerror(errno));
}
#endif
maps.push_back(memory);
}

View file

@ -24,6 +24,7 @@
#include <sys/cdefs.h>
#include <sys/mman.h>
#include <sys/prctl.h>
#include <cmath>
#include <cstddef>
@ -35,7 +36,6 @@
#include "Allocator.h"
#include "LinkedList.h"
#include "anon_vma_naming.h"
namespace android {
@ -153,10 +153,10 @@ static void* MapAligned(size_t size, size_t align) {
munmap(reinterpret_cast<void*>(reinterpret_cast<uintptr_t>(ptr) + size), map_size - size);
}
#define PR_SET_VMA 0x53564d41
#define PR_SET_VMA_ANON_NAME 0
#if defined(PR_SET_VMA)
prctl(PR_SET_VMA, PR_SET_VMA_ANON_NAME, reinterpret_cast<uintptr_t>(ptr), size,
"leak_detector_malloc");
#endif
return ptr;
}

View file

@ -24,6 +24,7 @@
#include <stdlib.h>
#include <string.h>
#include <sys/mman.h>
#include <sys/prctl.h>
#include <sys/syscall.h>
#include <sys/types.h>
#include <sys/wait.h>
@ -32,7 +33,6 @@
#include "android-base/macros.h"
#include "PtracerThread.h"
#include "anon_vma_naming.h"
#include "log.h"
namespace android {

View file

@ -1,25 +0,0 @@
/*
* Copyright (C) 2016 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef LIBMEMUNREACHABLE_ANON_VMA_NAMING_H_
#define LIBMEMUNREACHABLE_ANON_VMA_NAMING_H_
#include <sys/prctl.h>
#define PR_SET_VMA 0x53564d41
#define PR_SET_VMA_ANON_NAME 0
#endif // LIBMEMUNREACHABLE_ANON_VMA_NAMING_H_