1 // Copyright 2000 - 2007 Google Inc.
2 // All rights reserved.
4 // Routines to extract the current stack trace. These functions are
7 #ifndef BASE_STACKTRACE_H_
8 #define BASE_STACKTRACE_H_
12 _START_GOOGLE_NAMESPACE_
14 // Skips the most recent "skip_count" stack frames (also skips the
15 // frame generated for the "GetStackFrames" routine itself), and then
16 // records the pc values for up to the next "max_depth" frames in
17 // "pcs", and the corresponding stack frame sizes in "sizes". Returns
18 // the number of values recorded in "pcs"/"sizes".
26 // int depth = GetStackFrames(pcs, sizes, 10, 1);
29 // The GetStackFrames call will skip the frame for "bar". It will
30 // return 2 and will produce pc values that map to the following
34 // (Actually, there may be a few more entries after "main" to account for
35 // startup procedures.)
36 // And corresponding stack frame sizes will also be recorded:
39 // (Stack frame sizes of 16 above are just for illustration purposes.)
40 // Stack frame sizes of 0 or less indicate that those frame sizes couldn't
43 // This routine may return fewer stack frame entries than are
44 // available. Also note that "pcs" and "sizes" must both be non-NULL.
45 extern int GetStackFrames(void** pcs, int* sizes, int max_depth,
48 // This is similar to the GetStackFrames routine, except that it returns
49 // the stack trace only, and not the stack frame sizes as well.
55 // int depth = GetStackFrames(result, 10, 1);
63 // "result" must not be NULL.
64 extern int GetStackTrace(void** result, int max_depth, int skip_count);
66 _END_GOOGLE_NAMESPACE_
68 #endif // BASE_STACKTRACE_H_