stacktrace_impl_setup-inl.h 3.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. // -*- Mode: C++; c-basic-offset: 2; indent-tabs-mode: nil -*-
  2. // NOTE: this is NOT to be #include-d normally. It's internal
  3. // implementation detail of stacktrace.cc
  4. //
  5. // Copyright (c) 2014, gperftools Contributors.
  6. // All rights reserved.
  7. //
  8. // Redistribution and use in source and binary forms, with or without
  9. // modification, are permitted provided that the following conditions are
  10. // met:
  11. //
  12. // * Redistributions of source code must retain the above copyright
  13. // notice, this list of conditions and the following disclaimer.
  14. // * Redistributions in binary form must reproduce the above
  15. // copyright notice, this list of conditions and the following disclaimer
  16. // in the documentation and/or other materials provided with the
  17. // distribution.
  18. // * Neither the name of Google Inc. nor the names of its
  19. // contributors may be used to endorse or promote products derived from
  20. // this software without specific prior written permission.
  21. //
  22. // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  23. // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  24. // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  25. // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  26. // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  27. // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  28. // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  29. // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  30. // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  31. // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  32. // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  33. // ---
  34. // Author: Aliaksey Kandratsenka <alk@tut.by>
  35. //
  36. // based on stacktrace.cc and stacktrace_config.h by Sanjay Ghemawat
  37. // and Paul Pluzhnikov from Google Inc
  38. #define SIS_CONCAT2(a, b) a##b
  39. #define SIS_CONCAT(a, b) SIS_CONCAT2(a,b)
  40. #define SIS_STRINGIFY(a) SIS_STRINGIFY2(a)
  41. #define SIS_STRINGIFY2(a) #a
  42. #define IS_STACK_FRAMES 0
  43. #define IS_WITH_CONTEXT 0
  44. #define GET_STACK_TRACE_OR_FRAMES \
  45. SIS_CONCAT(GetStackTrace_, GST_SUFFIX)(void **result, int max_depth, int skip_count)
  46. #include STACKTRACE_INL_HEADER
  47. #undef IS_STACK_FRAMES
  48. #undef IS_WITH_CONTEXT
  49. #undef GET_STACK_TRACE_OR_FRAMES
  50. #define IS_STACK_FRAMES 1
  51. #define IS_WITH_CONTEXT 0
  52. #define GET_STACK_TRACE_OR_FRAMES \
  53. SIS_CONCAT(GetStackFrames_, GST_SUFFIX)(void **result, int *sizes, int max_depth, int skip_count)
  54. #include STACKTRACE_INL_HEADER
  55. #undef IS_STACK_FRAMES
  56. #undef IS_WITH_CONTEXT
  57. #undef GET_STACK_TRACE_OR_FRAMES
  58. #define IS_STACK_FRAMES 0
  59. #define IS_WITH_CONTEXT 1
  60. #define GET_STACK_TRACE_OR_FRAMES \
  61. SIS_CONCAT(GetStackTraceWithContext_, GST_SUFFIX)(void **result, int max_depth, \
  62. int skip_count, const void *ucp)
  63. #include STACKTRACE_INL_HEADER
  64. #undef IS_STACK_FRAMES
  65. #undef IS_WITH_CONTEXT
  66. #undef GET_STACK_TRACE_OR_FRAMES
  67. #define IS_STACK_FRAMES 1
  68. #define IS_WITH_CONTEXT 1
  69. #define GET_STACK_TRACE_OR_FRAMES \
  70. SIS_CONCAT(GetStackFramesWithContext_, GST_SUFFIX)(void **result, int *sizes, int max_depth, \
  71. int skip_count, const void *ucp)
  72. #include STACKTRACE_INL_HEADER
  73. #undef IS_STACK_FRAMES
  74. #undef IS_WITH_CONTEXT
  75. #undef GET_STACK_TRACE_OR_FRAMES
  76. static GetStackImplementation SIS_CONCAT(impl__,GST_SUFFIX) = {
  77. SIS_CONCAT(GetStackFrames_, GST_SUFFIX),
  78. SIS_CONCAT(GetStackFramesWithContext_, GST_SUFFIX),
  79. SIS_CONCAT(GetStackTrace_, GST_SUFFIX),
  80. SIS_CONCAT(GetStackTraceWithContext_, GST_SUFFIX),
  81. SIS_STRINGIFY(GST_SUFFIX)
  82. };
  83. #undef SIS_CONCAT2
  84. #undef SIS_CONCAT