David Srbecky | a17c2b6 | 2020-04-14 16:59:27 +0100 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2020 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | #include <err.h> |
| 18 | #include <stdint.h> |
| 19 | |
| 20 | #include <string> |
| 21 | #include <vector> |
| 22 | |
| 23 | #include <android-base/file.h> |
| 24 | #include <android-base/strings.h> |
| 25 | #include <benchmark/benchmark.h> |
| 26 | |
| 27 | #include <unwindstack/Elf.h> |
| 28 | #include <unwindstack/Memory.h> |
| 29 | |
| 30 | std::string GetElfFile() { |
| 31 | return android::base::GetExecutableDirectory() + "/benchmarks/files/libart_arm.so"; |
| 32 | } |
| 33 | |
| 34 | std::string GetSymbolSortedElfFile() { |
| 35 | return android::base::GetExecutableDirectory() + "/benchmarks/files/boot_arm.oat"; |
| 36 | } |
| 37 | |
| 38 | std::string GetCompressedElfFile() { |
| 39 | // Both are the same right now. |
| 40 | return GetSymbolSortedElfFile(); |
| 41 | } |
| 42 | |
| 43 | #if defined(__BIONIC__) |
| 44 | |
| 45 | #include <meminfo/procmeminfo.h> |
| 46 | #include <procinfo/process_map.h> |
| 47 | |
| 48 | void GatherRss(uint64_t* rss_bytes) { |
| 49 | android::meminfo::ProcMemInfo proc_mem(getpid()); |
| 50 | const std::vector<android::meminfo::Vma>& maps = proc_mem.MapsWithoutUsageStats(); |
| 51 | for (auto& vma : maps) { |
| 52 | if (vma.name == "[anon:libc_malloc]" || android::base::StartsWith(vma.name, "[anon:scudo:") || |
| 53 | android::base::StartsWith(vma.name, "[anon:GWP-ASan")) { |
| 54 | android::meminfo::Vma update_vma(vma); |
| 55 | if (!proc_mem.FillInVmaStats(update_vma)) { |
| 56 | err(1, "FillInVmaStats failed\n"); |
| 57 | } |
| 58 | *rss_bytes += update_vma.usage.rss; |
| 59 | } |
| 60 | } |
| 61 | } |
| 62 | #endif |