MCPcopy Create free account
hub / github.com/apache/fory / get_call_trace

Function get_call_trace

cpp/fory/util/logging.cc:44–69  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

42const ForyLogLevel fory_severity_threshold = ForyLog::get_log_level();
43
44std::string get_call_trace() {
45#if !defined(_WIN32)
46 std::array<void *, 100> local_stack{};
47 int frames =
48 backtrace(local_stack.data(), static_cast<int>(local_stack.size()));
49 std::string output;
50 char **symbols = backtrace_symbols(local_stack.data(), frames);
51 if (symbols != nullptr) {
52 for (int i = 0; i < frames; ++i) {
53 output.append(" ").append(symbols[i]).append("\n");
54 }
55 std::free(symbols);
56 return output;
57 }
58 for (int i = 0; i < frames; ++i) {
59 std::ostringstream stream;
60 stream << " frame[" << i << "] " << local_stack[static_cast<size_t>(i)]
61 << "\n";
62 output.append(stream.str());
63 }
64 return output;
65#else
66 std::string output = " Stack trace is not supported on this platform.\n";
67 return output;
68#endif
69}
70
71std::unordered_map<ForyLogLevel, std::string> log_level_to_str = {
72 {ForyLogLevel::FORY_DEBUG, "DEBUG"},

Callers 2

test_function_level0Function · 0.85
~ForyLogMethod · 0.85

Calls 3

dataMethod · 0.45
sizeMethod · 0.45
appendMethod · 0.45

Tested by 1

test_function_level0Function · 0.68