1 /*
2 * Copyright (c) 2021 Huawei Device Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16 #include "trace_data_cache.h"
17 #include <sqlite3.h>
18 #include "args_table.h"
19 #include "callstack_table.h"
20 #include "clk_event_filter_table.h"
21 #include "clock_event_filter_table.h"
22 #include "cpu_measure_filter_table.h"
23 #include "data_dict_table.h"
24 #include "data_type_table.h"
25 #include "filter_table.h"
26 #include "heap_frame_table.h"
27 #include "heap_table.h"
28 #include "hidump_table.h"
29 #include "instants_table.h"
30 #include "irq_table.h"
31 #include "log_table.h"
32 #include "measure_filter_table.h"
33 #include "measure_table.h"
34 #include "meta_table.h"
35 #include "process_filter_table.h"
36 #include "process_measure_filter_table.h"
37 #include "process_table.h"
38 #include "range_table.h"
39 #include "raw_table.h"
40 #include "sched_slice_table.h"
41 #include "stat_table.h"
42 #include "symbols_table.h"
43 #include "system_call_table.h"
44 #include "system_event_filter_table.h"
45 #include "table_base.h"
46 #include "thread_filter_table.h"
47 #include "thread_state_table.h"
48 #include "thread_table.h"
49
50
51 namespace SysTuning {
52 namespace TraceStreamer {
TraceDataCache()53 TraceDataCache::TraceDataCache()
54 {
55 InitDB();
56 }
57
~TraceDataCache()58 TraceDataCache::~TraceDataCache() {}
59
InitDB()60 void TraceDataCache::InitDB()
61 {
62 if (dbInited) {
63 return;
64 }
65 TableBase::TableDeclare<ProcessTable>(*db_, this, "_process");
66 TableBase::TableDeclare<SchedSliceTable>(*db_, this, "_sched_slice");
67 TableBase::TableDeclare<CallStackTable>(*db_, this, "_callstack");
68 TableBase::TableDeclare<IrqTable>(*db_, this, "_irq");
69 TableBase::TableDeclare<DataDictTable>(*db_, this, "_data_dict");
70 TableBase::TableDeclare<ThreadStateTable>(*db_, this, "_thread_state");
71 TableBase::TableDeclare<InstantsTable>(*db_, this, "_instant");
72 TableBase::TableDeclare<MeasureTable>(*db_, this, "_measure");
73 TableBase::TableDeclare<RangeTable>(*db_, this, "_trace_range");
74 TableBase::TableDeclare<ThreadTable>(*db_, this, "_thread");
75 TableBase::TableDeclare<RawTable>(*db_, this, "_raw");
76 TableBase::TableDeclare<CpuMeasureFilterTable>(*db_, this, "_cpu_measure_filter");
77 TableBase::TableDeclare<FilterTable>(*db_, this, "_measure_filter");
78 TableBase::TableDeclare<ProcessMeasureFilterTable>(*db_, this, "_process_measure_filter");
79 TableBase::TableDeclare<StatTable>(*db_, this, "_stat");
80 TableBase::TableDeclare<ClockEventFilterTable>(*db_, this, "_clock_event_filter");
81 TableBase::TableDeclare<ClkEventFilterTable>(*db_, this, "_clk_event_filter");
82 TableBase::TableDeclare<SymbolsTable>(*db_, this, "_symbols");
83 TableBase::TableDeclare<SystemCallTable>(*db_, this, "_syscall");
84 TableBase::TableDeclare<ArgsTable>(*db_, this, "_args");
85 TableBase::TableDeclare<DataTypeTable>(*db_, this, "_data_type");
86 TableBase::TableDeclare<MetaTable>(*db_, this, "_meta");
87 TableBase::TableDeclare<LogTable>(*db_, this, "_log");
88 TableBase::TableDeclare<HeapTable>(*db_, this, "_heap");
89 TableBase::TableDeclare<HeapFrameTable>(*db_, this, "_heap_frame");
90 TableBase::TableDeclare<HidumpTable>(*db_, this, "_hidump");
91 TableBase::TableDeclare<SystemEventFilterTable>(*db_, this, "_sys_event_filter");
92 dbInited = true;
93 }
94 } // namespace TraceStreamer
95 } // namespace SysTuning
96