/root/doris/be/src/vec/common/demangle.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 | | // This file is copied from |
18 | | // https://github.com/ClickHouse/ClickHouse/blob/master/base/base/demangle.cpp |
19 | | // and modified by Doris |
20 | | |
21 | | #include "vec/common/demangle.h" |
22 | | |
23 | | #if defined(__has_feature) |
24 | | #if __has_feature(memory_sanitizer) |
25 | | #define MEMORY_SANITIZER 1 |
26 | | #endif |
27 | | #elif defined(__MEMORY_SANITIZER__) |
28 | | #define MEMORY_SANITIZER 1 |
29 | | #endif |
30 | | |
31 | | #if _MSC_VER || MEMORY_SANITIZER |
32 | | |
33 | | std::string demangle(const char* name, int& status) { |
34 | | status = 0; |
35 | | return name; |
36 | | } |
37 | | |
38 | | #else |
39 | | |
40 | | #include <cxxabi.h> |
41 | | #include <stdlib.h> |
42 | | |
43 | 338 | std::string demangle(const char* name, int& status) { |
44 | 338 | std::string res; |
45 | | |
46 | 338 | char* demangled_str = abi::__cxa_demangle(name, nullptr, nullptr, &status); |
47 | 338 | if (demangled_str) { |
48 | 281 | try { |
49 | 281 | res = demangled_str; |
50 | 281 | } catch (...) { |
51 | 0 | free(demangled_str); |
52 | 0 | throw; |
53 | 0 | } |
54 | 281 | free(demangled_str); |
55 | 281 | } else { |
56 | 57 | res = name; |
57 | 57 | } |
58 | | |
59 | 338 | return res; |
60 | 338 | } |
61 | | |
62 | | #endif |