demangle_rust.h 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  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. #ifndef ABSL_DEBUGGING_INTERNAL_DEMANGLE_RUST_H_
  15. #define ABSL_DEBUGGING_INTERNAL_DEMANGLE_RUST_H_
  16. #include <cstddef>
  17. #include "absl/base/config.h"
  18. namespace absl {
  19. ABSL_NAMESPACE_BEGIN
  20. namespace debugging_internal {
  21. // Demangle the Rust encoding `mangled`. On success, return true and write the
  22. // demangled symbol name to `out`. Otherwise, return false, leaving unspecified
  23. // contents in `out`. For example, calling DemangleRustSymbolEncoding with
  24. // `mangled = "_RNvC8my_crate7my_func"` will yield `my_crate::my_func` in `out`,
  25. // provided `out_size` is large enough for that value and its trailing NUL.
  26. //
  27. // DemangleRustSymbolEncoding is async-signal-safe and runs in bounded C++
  28. // call-stack space. It is suitable for symbolizing stack traces in a signal
  29. // handler.
  30. bool DemangleRustSymbolEncoding(const char* mangled, char* out,
  31. size_t out_size);
  32. } // namespace debugging_internal
  33. ABSL_NAMESPACE_END
  34. } // namespace absl
  35. #endif // ABSL_DEBUGGING_INTERNAL_DEMANGLE_RUST_H_