Coverage Report

Created: 2025-07-23 06:46

/src/perfetto/buildtools/android-unwinding/libunwindstack/LogStdout.cpp
Line
Count
Source (jump to first uncovered line)
1
/*
2
 * Copyright (C) 2021 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
#include <stdarg.h>
18
#include <stdint.h>
19
#include <stdio.h>
20
21
#include <string>
22
23
#include <android-base/stringprintf.h>
24
25
#include <unwindstack/Log.h>
26
27
namespace unwindstack {
28
29
namespace Log {
30
31
6
static void PrintToStdout(uint8_t indent, const char* format, va_list args) {
32
6
  std::string real_format;
33
6
  if (indent > 0) {
34
0
    real_format = android::base::StringPrintf("%*s%s", 2 * indent, " ", format);
35
6
  } else {
36
6
    real_format = format;
37
6
  }
38
6
  real_format += '\n';
39
40
6
  vprintf(real_format.c_str(), args);
41
6
}
42
43
6
void Info(const char* format, ...) {
44
6
  va_list args;
45
6
  va_start(args, format);
46
6
  PrintToStdout(0, format, args);
47
6
  va_end(args);
48
6
}
49
50
0
void Info(uint8_t indent, const char* format, ...) {
51
0
  va_list args;
52
0
  va_start(args, format);
53
0
  PrintToStdout(indent, format, args);
54
0
  va_end(args);
55
0
}
56
57
0
void Error(const char* format, ...) {
58
0
  va_list args;
59
0
  va_start(args, format);
60
0
  PrintToStdout(0, format, args);
61
0
  va_end(args);
62
0
}
63
64
0
void AsyncSafe(const char* format, ...) {
65
0
  va_list args;
66
0
  va_start(args, format);
67
  // Only call vprintf to avoid allocating as much as possible, PrintToStdout uses a std::string.
68
0
  vprintf(format, args);
69
0
  printf("\n");
70
0
  va_end(args);
71
0
}
72
73
}  // namespace Log
74
75
}  // namespace unwindstack