Coverage Report

Created: 2025-10-30 14:39

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/root/doris/be/src/util/debug_util.cpp
Line
Count
Source
1
// Licensed to the Apache Software Foundation (ASF) under one
2
// or more contributor license agreements.  See the NOTICE file
3
// distributed with this work for additional information
4
// regarding copyright ownership.  The ASF licenses this file
5
// to you under the Apache License, Version 2.0 (the
6
// "License"); you may not use this file except in compliance
7
// with the License.  You may obtain a copy of the License at
8
//
9
//   http://www.apache.org/licenses/LICENSE-2.0
10
//
11
// Unless required by applicable law or agreed to in writing,
12
// software distributed under the License is distributed on an
13
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14
// KIND, either express or implied.  See the License for the
15
// specific language governing permissions and limitations
16
// under the License.
17
18
#include "util/debug_util.h"
19
20
#include <bvar/bvar.h>
21
#include <gen_cpp/HeartbeatService_types.h>
22
#include <gen_cpp/PlanNodes_types.h>
23
#include <stdint.h>
24
25
#include <cstring>
26
#include <iomanip>
27
#include <map>
28
#include <sstream> // IWYU pragma: keep
29
#include <utility>
30
31
#include "common/version_internal.h"
32
#include "fmt/core.h"
33
#include "util/uid_util.h"
34
35
namespace doris {
36
37
96.2k
std::string print_plan_node_type(const TPlanNodeType::type& type) {
38
96.2k
    std::map<int, const char*>::const_iterator i;
39
96.2k
    i = _TPlanNodeType_VALUES_TO_NAMES.find(type);
40
41
96.2k
    if (i != _TPlanNodeType_VALUES_TO_NAMES.end()) {
42
96.2k
        return i->second;
43
96.2k
    }
44
45
0
    return "Invalid plan node type";
46
96.2k
}
47
48
0
std::string get_build_version(bool compact) {
49
0
    std::stringstream ss;
50
    // clang-format off
51
0
    ss << version::doris_build_version()
52
0
#if defined(__x86_64__) || defined(_M_X64)
53
0
#ifdef __AVX2__
54
0
       << "(AVX2)"
55
#else
56
       << "(SSE4.2)"
57
#endif
58
#elif defined(__aarch64__)
59
       << "(AArch64)"
60
#endif
61
#ifdef NDEBUG
62
       << " RELEASE"
63
#else
64
0
       << " DEBUG"
65
0
#if defined(ADDRESS_SANITIZER)
66
0
       << " with ASAN"
67
#elif defined(LEAK_SANITIZER)
68
       << " with LSAN"
69
#elif defined(THREAD_SANITIZER)
70
       << " with TSAN"
71
#elif defined(UNDEFINED_BEHAVIOR_SANITIZER)
72
       << " with UBSAN"
73
#elif defined(MEMORY_SANITIZER)
74
       << " with MSAN"
75
#elif defined(BLACKLIST_SANITIZER)
76
       << " with BLSAN"
77
#endif
78
0
#endif
79
0
       << (version::doris_feature_list().empty() ? "" : " features: " + version::doris_feature_list())
80
0
       << " (build " << version::doris_build_hash() << ")";
81
    // clang-format on
82
83
0
    if (!compact) {
84
0
        ss << std::endl
85
0
           << "Built on " << version::doris_build_time() << " by " << version::doris_build_info();
86
0
    }
87
88
0
    return ss.str();
89
0
}
90
91
0
std::string get_short_version() {
92
0
    static std::string short_version(std::string(version::doris_build_version()) + "-" +
93
0
                                     version::doris_build_short_hash());
94
0
    return short_version;
95
0
}
96
97
0
std::string get_version_string(bool compact) {
98
0
    std::stringstream ss;
99
0
    ss << " version " << get_build_version(compact);
100
0
    return ss.str();
101
0
}
102
103
52
std::string hexdump(const char* buf, int len) {
104
52
    std::stringstream ss;
105
52
    ss << std::hex << std::uppercase;
106
435
    for (int i = 0; i < len; ++i) {
107
383
        ss << std::setfill('0') << std::setw(2) << ((uint16_t)buf[i] & 0xff);
108
383
    }
109
52
    return ss.str();
110
52
}
111
112
1
bvar::Status<uint64_t> be_version_metrics("doris_be_version", [] {
113
1
    std::stringstream ss;
114
1
    ss << version::doris_build_version_major() << 0 << version::doris_build_version_minor() << 0
115
1
       << version::doris_build_version_patch();
116
1
    if (version::doris_build_version_hotfix() > 0) {
117
0
        ss << 0 << version::doris_build_version_hotfix();
118
0
    }
119
1
    return std::strtoul(ss.str().c_str(), nullptr, 10);
120
1
}());
121
122
0
std::string PrintThriftNetworkAddress(const TNetworkAddress& add) {
123
0
    std::stringstream ss;
124
0
    add.printTo(ss);
125
0
    return ss.str();
126
0
}
127
128
0
std::string PrintFrontendInfos(const std::vector<TFrontendInfo>& fe_infos) {
129
0
    std::stringstream ss;
130
0
    const size_t count = fe_infos.size();
131
132
0
    for (int i = 0; i < count; ++i) {
133
0
        fe_infos[i].printTo(ss);
134
0
        ss << ' ';
135
0
    }
136
137
0
    return ss.str();
138
0
}
139
140
0
std::string PrintFrontendInfo(const TFrontendInfo& fe_info) {
141
0
    std::stringstream ss;
142
0
    fe_info.printTo(ss);
143
0
    return ss.str();
144
0
}
145
146
0
std::string PrintInstanceStandardInfo(const TUniqueId& qid, const TUniqueId& iid) {
147
0
    return fmt::format("{}|{}", print_id(qid), print_id(iid));
148
0
}
149
150
} // namespace doris