Blame src/stacktrace.h

Packit 18d29c
// Copyright (c) 2000 - 2007, Google Inc.
Packit 18d29c
// All rights reserved.
Packit 18d29c
//
Packit 18d29c
// Redistribution and use in source and binary forms, with or without
Packit 18d29c
// modification, are permitted provided that the following conditions are
Packit 18d29c
// met:
Packit 18d29c
//
Packit 18d29c
//     * Redistributions of source code must retain the above copyright
Packit 18d29c
// notice, this list of conditions and the following disclaimer.
Packit 18d29c
//     * Redistributions in binary form must reproduce the above
Packit 18d29c
// copyright notice, this list of conditions and the following disclaimer
Packit 18d29c
// in the documentation and/or other materials provided with the
Packit 18d29c
// distribution.
Packit 18d29c
//     * Neither the name of Google Inc. nor the names of its
Packit 18d29c
// contributors may be used to endorse or promote products derived from
Packit 18d29c
// this software without specific prior written permission.
Packit 18d29c
//
Packit 18d29c
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
Packit 18d29c
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
Packit 18d29c
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
Packit 18d29c
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
Packit 18d29c
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
Packit 18d29c
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
Packit 18d29c
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
Packit 18d29c
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
Packit 18d29c
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
Packit 18d29c
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
Packit 18d29c
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Packit 18d29c
//
Packit 18d29c
// Routines to extract the current stack trace.  These functions are
Packit 18d29c
// thread-safe.
Packit 18d29c
Packit 18d29c
#ifndef BASE_STACKTRACE_H_
Packit 18d29c
#define BASE_STACKTRACE_H_
Packit 18d29c
Packit 18d29c
#include "config.h"
Packit 18d29c
Packit 18d29c
_START_GOOGLE_NAMESPACE_
Packit 18d29c
Packit 18d29c
// This is similar to the GetStackFrames routine, except that it returns
Packit 18d29c
// the stack trace only, and not the stack frame sizes as well.
Packit 18d29c
// Example:
Packit 18d29c
//      main() { foo(); }
Packit 18d29c
//      foo() { bar(); }
Packit 18d29c
//      bar() {
Packit 18d29c
//        void* result[10];
Packit 18d29c
//        int depth = GetStackFrames(result, 10, 1);
Packit 18d29c
//      }
Packit 18d29c
//
Packit 18d29c
// This produces:
Packit 18d29c
//      result[0]       foo
Packit 18d29c
//      result[1]       main
Packit 18d29c
//           ....       ...
Packit 18d29c
//
Packit 18d29c
// "result" must not be NULL.
Packit 18d29c
extern int GetStackTrace(void** result, int max_depth, int skip_count);
Packit 18d29c
Packit 18d29c
_END_GOOGLE_NAMESPACE_
Packit 18d29c
Packit 18d29c
#endif  // BASE_STACKTRACE_H_