/* * Copyright (C) 2022 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 SRC_TRACE_PROCESSOR_IMPORTERS_ANDROID_BUGREPORT_ANDROID_LOG_READER_H_ #define SRC_TRACE_PROCESSOR_IMPORTERS_ANDROID_BUGREPORT_ANDROID_LOG_READER_H_ #include <chrono> #include <cstdint> #include <optional> #include "perfetto/base/status.h" #include "perfetto/ext/base/string_view.h" #include "src/trace_processor/importers/android_bugreport/android_log_event.h" #include "src/trace_processor/importers/android_bugreport/chunked_line_reader.h" namespace perfetto ::trace_processor { class TraceProcessorContext; // Parses log lines coming from persistent logcat (FS/data/misc/logd), interns // string in the TP string pools and populates a vector of AndroidLogEvent // structs. Does NOT insert log events into any table (for testing isolation), // the caller is in charge to do that. // It supports the following formats (auto-detected): // 1) 12-31 23:59:00.123456 <pid> <tid> I tag: message // This is typically found in persistent logcat (FS/data/misc/logd/) // 2) 06-24 15:57:11.346 <uid> <pid> <tid> D Tag: Message // This is typically found in the recent logcat dump in bugreport-xxx.txt class AndroidLogReader : public ChunkedLineReader { … }; // Helper struct to deduplicate events. // When reading bug reports log data will be present in a dumpstate file and in // the log cat files. struct TimestampedAndroidLogEvent { … }; // Same as AndroidLogReader (sends events to sorter), but also stores them in a // vector that can later be feed to a `DedupingAndroidLogReader` instance. class BufferingAndroidLogReader : public AndroidLogReader { … }; // Similar to `AndroidLogReader` but this class will not forward duplicate // events. These are events already present in a given vector of events. class DedupingAndroidLogReader : public AndroidLogReader { … }; } // namespace perfetto::trace_processor #endif // SRC_TRACE_PROCESSOR_IMPORTERS_ANDROID_BUGREPORT_ANDROID_LOG_READER_H_