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 "instants_table.h"
27 #include "log_table.h"
28 #include "measure_filter_table.h"
29 #include "measure_table.h"
30 #include "meta_table.h"
31 #include "process_filter_table.h"
32 #include "process_measure_filter_table.h"
33 #include "process_table.h"
34 #include "range_table.h"
35 #include "raw_table.h"
36 #include "sched_slice_table.h"
37 #include "stat_table.h"
38 #include "symbols_table.h"
39 #include "system_call_table.h"
40 #include "system_event_filter_table.h"
41 #include "table_base.h"
42 #include "thread_filter_table.h"
43 #include "thread_state_table.h"
44 #include "thread_table.h"
45
46
47 namespace SysTuning {
48 namespace TraceStreamer {
TraceDataCache()49 TraceDataCache::TraceDataCache()
50 {
51 InitDB();
52 }
53
~TraceDataCache()54 TraceDataCache::~TraceDataCache() {}
55
InitDB()56 void TraceDataCache::InitDB()
57 {
58 if (dbInited) {
59 return;
60 }
61 TableBase::TableDeclare<ProcessTable>(*db_, this, "process");
62 TableBase::TableDeclare<SchedSliceTable>(*db_, this, "sched_slice");
63 TableBase::TableDeclare<CallStackTable>(*db_, this, "callstack");
64 TableBase::TableDeclare<DataDictTable>(*db_, this, "data_dict");
65 TableBase::TableDeclare<ThreadStateTable>(*db_, this, "thread_state");
66 TableBase::TableDeclare<InstantsTable>(*db_, this, "instant");
67 TableBase::TableDeclare<MeasureTable>(*db_, this, "measure");
68 TableBase::TableDeclare<RangeTable>(*db_, this, "trace_range");
69 TableBase::TableDeclare<ThreadTable>(*db_, this, "thread");
70 TableBase::TableDeclare<RawTable>(*db_, this, "raw");
71 TableBase::TableDeclare<CpuMeasureFilterTable>(*db_, this, "cpu_measure_filter");
72 TableBase::TableDeclare<FilterTable>(*db_, this, "measure_filter");
73 TableBase::TableDeclare<ProcessMeasureFilterTable>(*db_, this, "process_measure_filter");
74 TableBase::TableDeclare<StatTable>(*db_, this, "stat");
75 TableBase::TableDeclare<ClockEventFilterTable>(*db_, this, "clock_event_filter");
76 TableBase::TableDeclare<ClkEventFilterTable>(*db_, this, "clk_event_filter");
77 TableBase::TableDeclare<SymbolsTable>(*db_, this, "symbols");
78 TableBase::TableDeclare<SystemCallTable>(*db_, this, "syscall");
79 TableBase::TableDeclare<ArgsTable>(*db_, this, "args");
80 TableBase::TableDeclare<DataTypeTable>(*db_, this, "data_type");
81 TableBase::TableDeclare<MetaTable>(*db_, this, "meta");
82 TableBase::TableDeclare<LogTable>(*db_, this, "log");
83 TableBase::TableDeclare<SystemEventFilterTable>(*db_, this, "sys_event_filter");
84 dbInited = true;
85 }
86 } // namespace TraceStreamer
87 } // namespace SysTuning
88