You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

examine_stack.h 2.5 kB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. //
  2. // Copyright 2018 The Abseil Authors.
  3. //
  4. // Licensed under the Apache License, Version 2.0 (the "License");
  5. // you may not use this file except in compliance with the License.
  6. // You may obtain a copy of the License at
  7. //
  8. // https://www.apache.org/licenses/LICENSE-2.0
  9. //
  10. // Unless required by applicable law or agreed to in writing, software
  11. // distributed under the License is distributed on an "AS IS" BASIS,
  12. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. // See the License for the specific language governing permissions and
  14. // limitations under the License.
  15. //
  16. #ifndef ABSL_DEBUGGING_INTERNAL_EXAMINE_STACK_H_
  17. #define ABSL_DEBUGGING_INTERNAL_EXAMINE_STACK_H_
  18. #include "absl/base/config.h"
  19. namespace absl
  20. {
  21. ABSL_NAMESPACE_BEGIN
  22. namespace debugging_internal
  23. {
  24. // Type of function used for printing in stack trace dumping, etc.
  25. // We avoid closures to keep things simple.
  26. typedef void OutputWriter(const char*, void*);
  27. // RegisterDebugStackTraceHook() allows to register a single routine
  28. // `hook` that is called each time DumpStackTrace() is called.
  29. // `hook` may be called from a signal handler.
  30. typedef void (*SymbolizeUrlEmitter)(void* const stack[], int depth, OutputWriter* writer, void* writer_arg);
  31. // Registration of SymbolizeUrlEmitter for use inside of a signal handler.
  32. // This is inherently unsafe and must be signal safe code.
  33. void RegisterDebugStackTraceHook(SymbolizeUrlEmitter hook);
  34. SymbolizeUrlEmitter GetDebugStackTraceHook();
  35. // Returns the program counter from signal context, or nullptr if
  36. // unknown. `vuc` is a ucontext_t*. We use void* to avoid the use of
  37. // ucontext_t on non-POSIX systems.
  38. void* GetProgramCounter(void* const vuc);
  39. // Uses `writer` to dump the program counter, stack trace, and stack
  40. // frame sizes.
  41. void DumpPCAndFrameSizesAndStackTrace(void* const pc, void* const stack[], int frame_sizes[], int depth, int min_dropped_frames, bool symbolize_stacktrace, OutputWriter* writer, void* writer_arg);
  42. // Dump current stack trace omitting the topmost `min_dropped_frames` stack
  43. // frames.
  44. void DumpStackTrace(int min_dropped_frames, int max_num_frames, bool symbolize_stacktrace, OutputWriter* writer, void* writer_arg);
  45. } // namespace debugging_internal
  46. ABSL_NAMESPACE_END
  47. } // namespace absl
  48. #endif // ABSL_DEBUGGING_INTERNAL_EXAMINE_STACK_H_