00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #ifndef __ZStackCrawl__
00026 #define __ZStackCrawl__ 1
00027 #include "zconfig.h"
00028
00029 #include "ZCONFIG_API.h"
00030 #include "ZCONFIG_SPI.h"
00031
00032 #ifndef ZCONFIG_API_Avail__StackCrawl
00033 # if defined(linux) && ZCONFIG(Processor, x86)
00034 # define ZCONFIG_API_Avail__StackCrawl 1
00035 # endif
00036 # if ZCONFIG(OS, Win32)
00037 # define ZCONFIG_API_Avail__StackCrawl ZCONFIG_SPI_Enabled(imagehlp)
00038 # endif
00039 #endif
00040
00041 #ifndef ZCONFIG_API_Avail__StackCrawl
00042 # define ZCONFIG_API_Avail__StackCrawl 0
00043 #endif
00044
00045 #ifndef ZCONFIG_API_Desired__StackCrawl
00046 # define ZCONFIG_API_Desired__StackCrawl 1
00047 #endif
00048
00049 #if ZCONFIG_API_Enabled(StackCrawl)
00050 #include "ZTypes.h"
00051
00052 #include <string>
00053 #include <vector>
00054
00055
00056 #pragma mark -
00057 #pragma mark * ZStackCrawl
00058
00059 class ZStackCrawl
00060 {
00061 public:
00062 enum { kMaxCountParams = 8 };
00063
00064 class Frame
00065 {
00066 public:
00067 const void* fPC;
00068 size_t fOffset;
00069 size_t fCountParams;
00070 uint32 fParams[kMaxCountParams];
00071 std::string fName;
00072 };
00073
00074 private:
00075 class pFrame_t
00076 {
00077 public:
00078 const void* fPC;
00079 size_t fOffset;
00080 size_t fCountParams;
00081 uint32 fParams[kMaxCountParams];
00082 };
00083
00084 public:
00085
00086 ZStackCrawl();
00087 ~ZStackCrawl();
00088
00089 size_t Count() const;
00090 Frame At(size_t iIndex) const;
00091
00092 #if defined(linux) && ZCONFIG(Processor, x86)
00093 static void sPopulateStackFrames(std::vector<ZStackCrawl::pFrame_t>& oFrames);
00094 #endif
00095
00096 #if ZCONFIG(OS, Win32)
00097 static void sPopulateStackFrames(std::vector<ZStackCrawl::pFrame_t>& oFrames);
00098 #endif
00099
00100 private:
00101 std::vector<pFrame_t> fFrames;
00102
00103 #if defined(linux) && ZCONFIG(Processor, x86)
00104 class AllSymbols;
00105 mutable AllSymbols* fAllSymbols;
00106 #endif
00107 };
00108
00109 #endif // ZCONFIG_API_Enabled(StackCrawl)
00110
00111 #endif // __ZStackCrawl__