1 /*
2  * Copyright (c) 2024 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 "dump_ffrt_helper.h"
17 
18 #include <cstdint>
19 #include <cstring>
20 #include "ffrt_inner.h"
21 
22 namespace OHOS {
23 namespace AppExecFwk {
24 constexpr const uint32_t MAX_BUF_SIZE = (1U << 19);
DumpFfrt(std::string & result)25 int DumpFfrtHelper::DumpFfrt(std::string& result)
26 {
27     result.resize(MAX_BUF_SIZE);
28 
29     int printNum = ffrt_dump(ffrt_dump_cmd_t::DUMP_INFO_ALL, &result[0], MAX_BUF_SIZE);
30     if (printNum > 0) {
31         result.resize(printNum);
32         return 0;
33     }
34     result.resize(0);
35     return -1;
36 }
37 }  // namespace AppExecFwk
38 }  // namespace OHOS
39