summaryrefslogtreecommitdiff
path: root/simpleperf/read_symbol_map.h
diff options
context:
space:
mode:
authorEvgeny Eltsin <eaeltsin@google.com>2020-08-26 11:08:00 +0200
committerEvgeny Eltsin <eaeltsin@google.com>2020-08-27 06:40:43 +0000
commitc2dc7e584a0596842ff6e67950f10e71741c8a63 (patch)
tree887afb84f278fa5d513b1a81a9ad351875860ba5 /simpleperf/read_symbol_map.h
parent7fd0b7a1148e31bfad6671863c487f0d1931248e (diff)
downloadextras-c2dc7e584a0596842ff6e67950f10e71741c8a63.tar.gz
simpleperf: add perf symbol map reader + test
Bug: 164091700 Test: simpleperf_unit_test Change-Id: I89cafbad694851121ca74734a16b802172d408cb
Diffstat (limited to 'simpleperf/read_symbol_map.h')
-rw-r--r--simpleperf/read_symbol_map.h38
1 files changed, 38 insertions, 0 deletions
diff --git a/simpleperf/read_symbol_map.h b/simpleperf/read_symbol_map.h
new file mode 100644
index 00000000..733df4ad
--- /dev/null
+++ b/simpleperf/read_symbol_map.h
@@ -0,0 +1,38 @@
+/*
+ * Copyright (C) 2020 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.
+ */
+
+#pragma once
+
+#include "dso.h"
+
+#include <string>
+#include <vector>
+
+#include <android-base/file.h>
+
+namespace simpleperf {
+
+std::vector<Symbol> ReadSymbolMapFromString(const std::string& content);
+
+inline std::vector<Symbol> ReadSymbolMapFromFile(const std::string& path) {
+ std::string content;
+ if (android::base::ReadFileToString(path, &content, /* follow_symlinks = */ true)) {
+ return ReadSymbolMapFromString(content);
+ }
+ return {};
+}
+
+} // namespace simpleperf