• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2019 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 #ifndef SRC_TRACE_PROCESSOR_FUCHSIA_TRACE_UTILS_H_
18 #define SRC_TRACE_PROCESSOR_FUCHSIA_TRACE_UTILS_H_
19 
20 #include <stddef.h>
21 #include <stdint.h>
22 #include <functional>
23 
24 #include "perfetto/base/string_view.h"
25 
26 namespace perfetto {
27 namespace trace_processor {
28 namespace fuchsia_trace_utils {
29 
30 struct ThreadInfo {
31   uint64_t pid;
32   uint64_t tid;
33 };
34 
35 template <class T>
ReadField(uint64_t word,size_t begin,size_t end)36 T ReadField(uint64_t word, size_t begin, size_t end) {
37   return static_cast<T>((word >> begin) &
38                         ((uint64_t(1) << (end - begin + 1)) - 1));
39 }
40 
41 bool IsInlineString(uint32_t);
42 base::StringView ReadInlineString(const uint64_t**, uint32_t);
43 
44 bool IsInlineThread(uint32_t);
45 ThreadInfo ReadInlineThread(const uint64_t**);
46 
47 int64_t ReadTimestamp(const uint64_t**, uint64_t);
48 int64_t TicksToNs(uint64_t ticks, uint64_t ticks_per_second);
49 
50 }  // namespace fuchsia_trace_utils
51 }  // namespace trace_processor
52 }  // namespace perfetto
53 
54 #endif  // SRC_TRACE_PROCESSOR_FUCHSIA_TRACE_UTILS_H_
55