• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021-2023 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 #include <memory>
16 
17 #include "hiview_platform.h"
18 #include "hiview_service.h"
19 
20 #include "defines.h"
21 #include "logger.h"
22 #include "memory_util.h"
23 #include "dump_manager_cpu_service.h"
24 
25 DEFINE_LOG_TAG("HiView-Main");
26 using namespace OHOS::HiviewDFX;
27 
main(int argc __UNUSED,char * argv[]__UNUSED)28 int main(int argc __UNUSED, char* argv[] __UNUSED)
29 {
30     if (MemoryUtil::DisableThreadCache() != 0 || MemoryUtil::DisableDelayFree() != 0) {
31         HIVIEW_LOGW("Failed to optimize memory for current thread");
32     }
33 
34     auto& hiview = HiviewPlatform::GetInstance();
35     // process cmdline
36     hiview.ProcessArgsRequest(argc, argv);
37 
38     // parse configs and load plugin
39     if (!hiview.InitEnvironment()) {
40         HIVIEW_LOGW("Fail to init plugin environment. exit");
41         return -1;
42     }
43 
44     auto hidumperCpuService = std::make_unique<DumpManagerCpuService>();
45     hidumperCpuService->StartService();
46 
47     // start service
48     auto hiviewService = std::make_unique<HiviewService>();
49     hiviewService->StartService();
50 
51     return 0;
52 }
53