xref: /aosp_15_r20/external/abseil-cpp/absl/debugging/internal/demangle_rust.h (revision 9356374a3709195abf420251b3e825997ff56c0f)
1 // Copyright 2024 The Abseil Authors
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 //     https://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 
15 #ifndef ABSL_DEBUGGING_INTERNAL_DEMANGLE_RUST_H_
16 #define ABSL_DEBUGGING_INTERNAL_DEMANGLE_RUST_H_
17 
18 #include <cstddef>
19 
20 #include "absl/base/config.h"
21 
22 namespace absl {
23 ABSL_NAMESPACE_BEGIN
24 namespace debugging_internal {
25 
26 // Demangle the Rust encoding `mangled`.  On success, return true and write the
27 // demangled symbol name to `out`.  Otherwise, return false, leaving unspecified
28 // contents in `out`.  For example, calling DemangleRustSymbolEncoding with
29 // `mangled = "_RNvC8my_crate7my_func"` will yield `my_crate::my_func` in `out`,
30 // provided `out_size` is large enough for that value and its trailing NUL.
31 //
32 // DemangleRustSymbolEncoding is async-signal-safe and runs in bounded C++
33 // call-stack space.  It is suitable for symbolizing stack traces in a signal
34 // handler.
35 bool DemangleRustSymbolEncoding(const char* mangled, char* out,
36                                 size_t out_size);
37 
38 }  // namespace debugging_internal
39 ABSL_NAMESPACE_END
40 }  // namespace absl
41 
42 #endif  // ABSL_DEBUGGING_INTERNAL_DEMANGLE_RUST_H_
43