diff options
author | Yabin Cui <yabinc@google.com> | 2020-09-01 10:52:28 -0700 |
---|---|---|
committer | Yabin Cui <yabinc@google.com> | 2020-09-01 13:26:08 -0700 |
commit | a22f3b948a42628d2c89b66c8a3400856ef9cec0 (patch) | |
tree | becc2503a4bcfb300e712b02fad42c5c705c86b5 | |
parent | d62949cffb5cddf7465811ec610e586285099ff9 (diff) | |
download | extras-a22f3b948a42628d2c89b66c8a3400856ef9cec0.tar.gz |
simpleperf: Move event_type.h and related headers into simpleperf namespace.
Bug: 166335356
Test: run simpleperf_unit_test.
Change-Id: Ib75c72d600a132cfacc7e9f3717327c58632e760
-rw-r--r-- | simpleperf/cmd_dumprecord.cpp | 2 | ||||
-rw-r--r-- | simpleperf/cmd_record_impl.h | 4 | ||||
-rw-r--r-- | simpleperf/cpu_hotplug_test.cpp | 2 | ||||
-rw-r--r-- | simpleperf/event_attr.cpp | 4 | ||||
-rw-r--r-- | simpleperf/event_attr.h | 4 | ||||
-rw-r--r-- | simpleperf/event_selection_set.cpp | 5 | ||||
-rw-r--r-- | simpleperf/event_selection_set.h | 4 | ||||
-rw-r--r-- | simpleperf/event_type.cpp | 4 | ||||
-rw-r--r-- | simpleperf/event_type.h | 4 | ||||
-rw-r--r-- | simpleperf/record_file.h | 8 | ||||
-rw-r--r-- | simpleperf/record_file_format.h | 2 | ||||
-rw-r--r-- | simpleperf/record_file_reader.cpp | 4 | ||||
-rw-r--r-- | simpleperf/record_file_test.cpp | 3 | ||||
-rw-r--r-- | simpleperf/record_file_writer.cpp | 4 | ||||
-rw-r--r-- | simpleperf/record_test.cpp | 2 |
15 files changed, 45 insertions, 11 deletions
diff --git a/simpleperf/cmd_dumprecord.cpp b/simpleperf/cmd_dumprecord.cpp index 554d4ea6..148be69c 100644 --- a/simpleperf/cmd_dumprecord.cpp +++ b/simpleperf/cmd_dumprecord.cpp @@ -36,8 +36,8 @@ #include "tracing.h" #include "utils.h" -using namespace PerfFileFormat; using namespace simpleperf; +using namespace simpleperf::PerfFileFormat; namespace { diff --git a/simpleperf/cmd_record_impl.h b/simpleperf/cmd_record_impl.h index bcdf1b92..623f6e34 100644 --- a/simpleperf/cmd_record_impl.h +++ b/simpleperf/cmd_record_impl.h @@ -21,10 +21,10 @@ #include "command.h" -struct AddrFilter; - namespace simpleperf { +struct AddrFilter; + std::vector<AddrFilter> ParseAddrFilterOption(const std::string& s); inline const OptionFormatMap& GetRecordCmdOptionFormats() { diff --git a/simpleperf/cpu_hotplug_test.cpp b/simpleperf/cpu_hotplug_test.cpp index a698d2f9..c882d8f4 100644 --- a/simpleperf/cpu_hotplug_test.cpp +++ b/simpleperf/cpu_hotplug_test.cpp @@ -37,6 +37,8 @@ #include "event_type.h" #include "utils.h" +using namespace simpleperf; + static auto test_duration_for_long_tests = std::chrono::seconds(120); static auto cpu_hotplug_interval = std::chrono::microseconds(1000); static bool verbose_mode = false; diff --git a/simpleperf/event_attr.cpp b/simpleperf/event_attr.cpp index ecc08439..c923375c 100644 --- a/simpleperf/event_attr.cpp +++ b/simpleperf/event_attr.cpp @@ -27,6 +27,8 @@ #include "event_type.h" #include "utils.h" +namespace simpleperf { + static std::string BitsToString(const std::string& name, uint64_t bits, const std::vector<std::pair<int, std::string>>& bit_names) { std::string result; @@ -245,3 +247,5 @@ std::string GetEventNameByAttr(const perf_event_attr& attr) { } return "unknown"; } + +} // namespace simpleperf diff --git a/simpleperf/event_attr.h b/simpleperf/event_attr.h index 969f9f99..9957bf7c 100644 --- a/simpleperf/event_attr.h +++ b/simpleperf/event_attr.h @@ -24,6 +24,8 @@ #include "perf_event.h" +namespace simpleperf { + struct EventType; struct EventAttrWithId { @@ -42,4 +44,6 @@ bool IsCpuSupported(const perf_event_attr& attr); // This function is slow for using linear search, so only used when reporting. std::string GetEventNameByAttr(const perf_event_attr& attr); +} // namespace simpleperf + #endif // SIMPLE_PERF_EVENT_ATTR_H_ diff --git a/simpleperf/event_selection_set.cpp b/simpleperf/event_selection_set.cpp index 644fa9b3..790db43d 100644 --- a/simpleperf/event_selection_set.cpp +++ b/simpleperf/event_selection_set.cpp @@ -35,7 +35,8 @@ #include "RecordReadThread.h" using android::base::StringPrintf; -using namespace simpleperf; + +namespace simpleperf { bool IsBranchSamplingSupported() { const EventType* type = FindEventTypeByName("cpu-cycles"); @@ -832,3 +833,5 @@ bool EventSelectionSet::SetEnableEvents(bool enable) { } return true; } + +} // namespace simpleperf diff --git a/simpleperf/event_selection_set.h b/simpleperf/event_selection_set.h index 6a6a063f..ad24d1a9 100644 --- a/simpleperf/event_selection_set.h +++ b/simpleperf/event_selection_set.h @@ -33,6 +33,8 @@ #include "record.h" #include "RecordReadThread.h" +namespace simpleperf { + constexpr double DEFAULT_PERIOD_TO_CHECK_MONITORED_TARGETS_IN_SEC = 1; constexpr uint64_t DEFAULT_SAMPLE_FREQ_FOR_NONTRACEPOINT_EVENT = 4000; constexpr uint64_t DEFAULT_SAMPLE_PERIOD_FOR_TRACEPOINT_EVENT = 1; @@ -226,4 +228,6 @@ bool IsDumpingRegsForTracepointEventsSupported(); bool IsSettingClockIdSupported(); bool IsMmap2Supported(); +} // namespace simpleperf + #endif // SIMPLE_PERF_EVENT_SELECTION_SET_H_ diff --git a/simpleperf/event_type.cpp b/simpleperf/event_type.cpp index 71c3d9f1..a553d231 100644 --- a/simpleperf/event_type.cpp +++ b/simpleperf/event_type.cpp @@ -33,7 +33,7 @@ #include "event_attr.h" #include "utils.h" -using namespace simpleperf; +namespace simpleperf { struct EventFormat { EventFormat(const std::string& name, const std::string& attr, int shift) @@ -389,3 +389,5 @@ std::unique_ptr<EventTypeAndModifier> ParseEventType(const std::string& event_ty bool IsEtmEventType(uint32_t type) { return g_etm_event_type != 0 && type == g_etm_event_type; } + +} // namespace simpleperf diff --git a/simpleperf/event_type.h b/simpleperf/event_type.h index 359438ec..71797975 100644 --- a/simpleperf/event_type.h +++ b/simpleperf/event_type.h @@ -24,6 +24,8 @@ #include <string> #include <vector> +namespace simpleperf { + // EventType represents one type of event, like cpu_cycle_event, cache_misses_event. // The user knows one event type by its name, and the kernel knows one event type by its // (type, config) pair. EventType connects the two representations, and tells the user if @@ -99,4 +101,6 @@ struct EventTypeAndModifier { std::unique_ptr<EventTypeAndModifier> ParseEventType(const std::string& event_type_str); bool IsEtmEventType(uint32_t type); +} // namespace simpleperf + #endif // SIMPLE_PERF_EVENT_H_ diff --git a/simpleperf/record_file.h b/simpleperf/record_file.h index 0030b085..1182b08c 100644 --- a/simpleperf/record_file.h +++ b/simpleperf/record_file.h @@ -36,6 +36,8 @@ #include "record_file_format.h" #include "thread_tree.h" +namespace simpleperf { + // RecordFileWriter writes to a perf record file, like perf.data. // User should call RecordFileWriter::Close() to finish writing the file, otherwise the file will // be removed in RecordFileWriter::~RecordFileWriter(). @@ -214,8 +216,8 @@ class RecordFileReader { DISALLOW_COPY_AND_ASSIGN(RecordFileReader); }; -namespace simpleperf { - bool IsPerfDataFile(const std::string& filename); -} +bool IsPerfDataFile(const std::string& filename); + +} // namespace simpleperf #endif // SIMPLE_PERF_RECORD_FILE_H_ diff --git a/simpleperf/record_file_format.h b/simpleperf/record_file_format.h index 4606abcc..0394d97f 100644 --- a/simpleperf/record_file_format.h +++ b/simpleperf/record_file_format.h @@ -67,6 +67,7 @@ meta_info feature section: */ +namespace simpleperf { namespace PerfFileFormat { enum { @@ -124,5 +125,6 @@ struct FileAttr { }; } // namespace PerfFileFormat +} // namespace simpleperf #endif // SIMPLE_PERF_RECORD_FILE_FORMAT_H_ diff --git a/simpleperf/record_file_reader.cpp b/simpleperf/record_file_reader.cpp index d4d59e74..87923cb6 100644 --- a/simpleperf/record_file_reader.cpp +++ b/simpleperf/record_file_reader.cpp @@ -27,6 +27,8 @@ #include "record.h" #include "utils.h" +namespace simpleperf { + using namespace PerfFileFormat; namespace PerfFileFormat { @@ -625,8 +627,6 @@ std::vector<std::unique_ptr<Record>> RecordFileReader::DataSection() { return records; } -namespace simpleperf { - bool IsPerfDataFile(const std::string& filename) { auto fd = FileHelper::OpenReadOnly(filename); if (fd.ok()) { diff --git a/simpleperf/record_file_test.cpp b/simpleperf/record_file_test.cpp index 76d15ec7..114adbbe 100644 --- a/simpleperf/record_file_test.cpp +++ b/simpleperf/record_file_test.cpp @@ -30,7 +30,8 @@ #include "record_equal_test.h" -using namespace PerfFileFormat; +using namespace simpleperf; +using namespace simpleperf::PerfFileFormat; class RecordFileTest : public ::testing::Test { protected: diff --git a/simpleperf/record_file_writer.cpp b/simpleperf/record_file_writer.cpp index f718df49..2d337ffe 100644 --- a/simpleperf/record_file_writer.cpp +++ b/simpleperf/record_file_writer.cpp @@ -35,6 +35,8 @@ #include "record.h" #include "utils.h" +namespace simpleperf { + using namespace PerfFileFormat; std::unique_ptr<RecordFileWriter> RecordFileWriter::CreateInstance(const std::string& filename) { @@ -498,3 +500,5 @@ bool RecordFileWriter::Close() { record_fp_ = nullptr; return result; } + +} // namespace simpleperf diff --git a/simpleperf/record_test.cpp b/simpleperf/record_test.cpp index 954acfaa..7644ec9e 100644 --- a/simpleperf/record_test.cpp +++ b/simpleperf/record_test.cpp @@ -21,6 +21,8 @@ #include "record.h" #include "record_equal_test.h" +using namespace simpleperf; + class RecordTest : public ::testing::Test { protected: virtual void SetUp() { |