/root/doris/be/src/util/debug_util.cpp
Line | Count | Source (jump to first uncovered line) |
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 <gen_cpp/HeartbeatService_types.h> |
21 | | #include <gen_cpp/PlanNodes_types.h> |
22 | | #include <stdint.h> |
23 | | |
24 | | #include <iomanip> |
25 | | #include <map> |
26 | | #include <sstream> // IWYU pragma: keep |
27 | | #include <utility> |
28 | | |
29 | | #include "common/version_internal.h" |
30 | | #include "fmt/core.h" |
31 | | #include "util/uid_util.h" |
32 | | |
33 | | namespace doris { |
34 | | |
35 | 2 | std::string print_plan_node_type(const TPlanNodeType::type& type) { |
36 | 2 | std::map<int, const char*>::const_iterator i; |
37 | 2 | i = _TPlanNodeType_VALUES_TO_NAMES.find(type); |
38 | | |
39 | 2 | if (i != _TPlanNodeType_VALUES_TO_NAMES.end()) { |
40 | 2 | return i->second; |
41 | 2 | } |
42 | | |
43 | 0 | return "Invalid plan node type"; |
44 | 2 | } |
45 | | |
46 | 0 | std::string get_build_version(bool compact) { |
47 | 0 | std::stringstream ss; |
48 | 0 | ss << version::doris_build_version() |
49 | 0 | #if defined(__x86_64__) || defined(_M_X64) |
50 | | #ifdef __AVX2__ |
51 | | << "(AVX2)" |
52 | | #else |
53 | 0 | << "(SSE4.2)" |
54 | 0 | #endif |
55 | | #elif defined(__aarch64__) |
56 | | << "(AArch64)" |
57 | | #endif |
58 | | #ifdef NDEBUG |
59 | | << " RELEASE" |
60 | | #else |
61 | 0 | << " DEBUG" |
62 | 0 | #if defined(ADDRESS_SANITIZER) |
63 | 0 | << " with ASAN" |
64 | | #elif defined(LEAK_SANITIZER) |
65 | | << " with LSAN" |
66 | | #elif defined(THREAD_SANITIZER) |
67 | | << " with TSAN" |
68 | | #elif defined(UNDEFINED_BEHAVIOR_SANITIZER) |
69 | | << " with UBSAN" |
70 | | #elif defined(MEMORY_SANITIZER) |
71 | | << " with MSAN" |
72 | | #elif defined(BLACKLIST_SANITIZER) |
73 | | << " with BLSAN" |
74 | | #endif |
75 | 0 | #endif |
76 | 0 | << " (build " << version::doris_build_hash() << ")"; |
77 | |
|
78 | 0 | if (!compact) { |
79 | 0 | ss << std::endl |
80 | 0 | << "Built on " << version::doris_build_time() << " by " << version::doris_build_info(); |
81 | 0 | } |
82 | |
|
83 | 0 | return ss.str(); |
84 | 0 | } |
85 | | |
86 | 0 | std::string get_short_version() { |
87 | 0 | static std::string short_version(std::string(version::doris_build_version()) + "-" + |
88 | 0 | version::doris_build_short_hash()); |
89 | 0 | return short_version; |
90 | 0 | } |
91 | | |
92 | 0 | std::string get_version_string(bool compact) { |
93 | 0 | std::stringstream ss; |
94 | 0 | ss << " version " << get_build_version(compact); |
95 | 0 | return ss.str(); |
96 | 0 | } |
97 | | |
98 | 22 | std::string hexdump(const char* buf, int len) { |
99 | 22 | std::stringstream ss; |
100 | 22 | ss << std::hex << std::uppercase; |
101 | 166 | for (int i = 0; i < len; ++i) { |
102 | 144 | ss << std::setfill('0') << std::setw(2) << ((uint16_t)buf[i] & 0xff); |
103 | 144 | } |
104 | 22 | return ss.str(); |
105 | 22 | } |
106 | | |
107 | 0 | std::string PrintThriftNetworkAddress(const TNetworkAddress& add) { |
108 | 0 | std::stringstream ss; |
109 | 0 | add.printTo(ss); |
110 | 0 | return ss.str(); |
111 | 0 | } |
112 | | |
113 | 0 | std::string PrintFrontendInfos(const std::vector<TFrontendInfo>& fe_infos) { |
114 | 0 | std::stringstream ss; |
115 | 0 | const size_t count = fe_infos.size(); |
116 | |
|
117 | 0 | for (int i = 0; i < count; ++i) { |
118 | 0 | fe_infos[i].printTo(ss); |
119 | 0 | ss << ' '; |
120 | 0 | } |
121 | |
|
122 | 0 | return ss.str(); |
123 | 0 | } |
124 | | |
125 | 0 | std::string PrintFrontendInfo(const TFrontendInfo& fe_info) { |
126 | 0 | std::stringstream ss; |
127 | 0 | fe_info.printTo(ss); |
128 | 0 | return ss.str(); |
129 | 0 | } |
130 | | |
131 | 0 | std::string PrintInstanceStandardInfo(const TUniqueId& qid, const TUniqueId& iid) { |
132 | 0 | return fmt::format("{}|{}", print_id(qid), print_id(iid)); |
133 | 0 | } |
134 | | |
135 | | } // namespace doris |