~ubuntu-branches/ubuntu/jaunty/google-perftools/jaunty

« back to all changes in this revision

Viewing changes to src/google/stacktrace.h

  • Committer: Bazaar Package Importer
  • Author(s): Daigo Moriwaki
  • Date: 2008-06-15 23:41:36 UTC
  • mfrom: (3.1.1 sid)
  • Revision ID: james.westby@ubuntu.com-20080615234136-al5gawvdvt5vhdtz
Tags: 0.98-1
* New upstream release. (Closes: #425147)
* Compiled with GCC 4.3. (Closes: #454841)
* debian/watch: can now report upstream's version (Closes: #450294)
* Because of a file conflict between tau and libgoogle-perftools the
  binary pprof is renamed as google-pprof. (Closes: #404001)
  Great thanks to Michael Mende.
* debian/rules: autoconf files are now generated at the build time.
* Bumped up Standards-Version to 3.7.3, no changes are required.
* Split a new package, libtcmallc_minimal0. The upstream supports
  this module for wider platforms. So I leave its architecture to be
  `any'.
* libgoogle-perftools0's architecture is now i386. The upstream
  supports this module for x86 and x86_64. However, x86_64 requires
  libunwind's development head, which Debian does not have yet.
* Removed an unnecessary patch, debian/patches/02_profiler.cc_alpha.diff.

Show diffs side-by-side

added added

removed removed

Lines of Context:
30
30
// ---
31
31
// Author: Sanjay Ghemawat
32
32
//
33
 
// Routine to extract the current stack trace.
34
 
 
35
 
#ifndef _GOOGLE_STACKTRACE_H
36
 
#define _GOOGLE_STACKTRACE_H
37
 
 
38
 
// Skip the most recent "skip_count" stack frames (also skips the
39
 
// frame generated for the "GetStackTrace" routine itself), and then
40
 
// record the pc values for upto the next "max_depth" frames in
41
 
// "result".  Returns the number of values recorded in "result".
 
33
// Routines to extract the current stack trace.  These functions are
 
34
// thread-safe.
 
35
 
 
36
#ifndef GOOGLE_STACKTRACE_H_
 
37
#define GOOGLE_STACKTRACE_H_
 
38
 
 
39
// Annoying stuff for windows -- makes sure clients can import these functions
 
40
#ifndef PERFTOOLS_DLL_DECL
 
41
# ifdef WIN32
 
42
#   define PERFTOOLS_DLL_DECL  __declspec(dllimport)
 
43
# else
 
44
#   define PERFTOOLS_DLL_DECL
 
45
# endif
 
46
#endif
 
47
 
 
48
 
 
49
// Skips the most recent "skip_count" stack frames (also skips the
 
50
// frame generated for the "GetStackFrames" routine itself), and then
 
51
// records the pc values for up to the next "max_depth" frames in
 
52
// "pcs", and the corresponding stack frame sizes in "sizes".  Returns
 
53
// the number of values recorded in "pcs"/"sizes".
42
54
//
43
55
// Example:
44
56
//      main() { foo(); }
45
57
//      foo() { bar(); }
46
58
//      bar() {
47
 
//        void* result[10];
48
 
//        int depth = GetStackTrace(result, 10, 1);
 
59
//        void* pcs[10];
 
60
//        int sizes[10];
 
61
//        int depth = GetStackFrames(pcs, sizes, 10, 1);
49
62
//      }
50
63
//
51
 
// The GetStackTrace call will skip the frame for "bar".  It will
 
64
// The GetStackFrames call will skip the frame for "bar".  It will
52
65
// return 2 and will produce pc values that map to the following
53
66
// procedures:
 
67
//      pcs[0]       foo
 
68
//      pcs[1]       main
 
69
// (Actually, there may be a few more entries after "main" to account for
 
70
// startup procedures.)
 
71
// And corresponding stack frame sizes will also be recorded:
 
72
//    sizes[0]       16
 
73
//    sizes[1]       16
 
74
// (Stack frame sizes of 16 above are just for illustration purposes.)
 
75
// Stack frame sizes of 0 or less indicate that those frame sizes couldn't
 
76
// be identified.
 
77
//
 
78
// This routine may return fewer stack frame entries than are
 
79
// available. Also note that "pcs" and "sizes" must both be non-NULL.
 
80
extern PERFTOOLS_DLL_DECL int GetStackFrames(void** pcs, int* sizes, int max_depth,
 
81
                          int skip_count);
 
82
 
 
83
// This is similar to the GetStackFrames routine, except that it returns
 
84
// the stack trace only, and not the stack frame sizes as well.
 
85
// Example:
 
86
//      main() { foo(); }
 
87
//      foo() { bar(); }
 
88
//      bar() {
 
89
//        void* result[10];
 
90
//        int depth = GetStackFrames(result, 10, 1);
 
91
//      }
 
92
//
 
93
// This produces:
54
94
//      result[0]       foo
55
95
//      result[1]       main
56
 
// (Actually, there may be a few more entries after "main" to account for
57
 
// startup procedures.)
58
 
//
59
 
// This routine currently produces non-empty stack traces only for
60
 
// Linux/x86 machines.
61
 
extern int GetStackTrace(void** result, int max_depth, int skip_count);
62
 
 
63
 
// Compute the extent of the function call stack by traversing it up.
64
 
// Input: "sp" is either NULL, or is a stack pointer
65
 
// (e.g., a value of the ebp register for x86).
66
 
// If "sp == NULL", the stack pointer for the current thread is implied.
67
 
//
68
 
// Stores the range of addresses covered by the specified stack
69
 
// in *stack_top and *stack_bottom.  Returns true if successful,
70
 
// false on failure (e.g., an inability to walk the stack).
71
 
//
72
 
// If it returns true, *stack_top and *stack_bottom respectively correspond
73
 
// to the most-recetly pushed frame of the call stack
74
 
// and the intial frame that started the call stack.
75
 
// Their relative ordering as integers though
76
 
// depends on the underlying machine's architecture.
77
 
extern bool GetStackExtent(void* sp,
78
 
                           void** stack_top,
79
 
                           void** stack_bottom);
80
 
 
81
 
#endif /* _GOOGLE_STACKTRACE_H */
 
96
//           ....       ...
 
97
//
 
98
// "result" must not be NULL.
 
99
extern PERFTOOLS_DLL_DECL int GetStackTrace(void** result, int max_depth,
 
100
                                            int skip_count);
 
101
 
 
102
#endif /* GOOGLE_STACKTRACE_H_ */