summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYabin Cui <yabinc@google.com>2024-04-16 16:46:15 -0700
committerYabin Cui <yabinc@google.com>2024-04-16 16:46:15 -0700
commit19ce98eeba0c80746dfd58acc90cb074bf9501f1 (patch)
treed184c26753d871c3c363554278c2092368805d95
parent7d8db10758230140905163e451ac4af348cd1883 (diff)
downloadextras-19ce98eeba0c80746dfd58acc90cb074bf9501f1.tar.gz
simpleperf: Handle empty string in TracepointStringFinder
Avoid crash when the kernel doesn't expose any tracepoint events. Bug: 328598190 Test: run simpleperf_unit_test Change-Id: I194a387c3ff94e4b669b41432530c5452a10d3a5
-rw-r--r--simpleperf/event_type.cpp6
1 files changed, 5 insertions, 1 deletions
diff --git a/simpleperf/event_type.cpp b/simpleperf/event_type.cpp
index 0d10d12d..d8379141 100644
--- a/simpleperf/event_type.cpp
+++ b/simpleperf/event_type.cpp
@@ -104,7 +104,11 @@ class TracepointStringFinder : public EventTypeFinder {
protected:
void LoadTypes() override {
for (const auto& line : android::base::Split(s_, "\n")) {
- std::vector<std::string> items = android::base::Split(line, " ");
+ std::string str = android::base::Trim(line);
+ if (str.empty()) {
+ continue;
+ }
+ std::vector<std::string> items = android::base::Split(str, " ");
CHECK_EQ(items.size(), 2u);
std::string event_name = items[0];
uint64_t id;