1baa3858d3f5d128a5c8466b700098109edcad5f2repo sync// Copyright (c) 2009, Google Inc. 2baa3858d3f5d128a5c8466b700098109edcad5f2repo sync// All rights reserved. 3baa3858d3f5d128a5c8466b700098109edcad5f2repo sync// 4baa3858d3f5d128a5c8466b700098109edcad5f2repo sync// Redistribution and use in source and binary forms, with or without 5baa3858d3f5d128a5c8466b700098109edcad5f2repo sync// modification, are permitted provided that the following conditions are 6baa3858d3f5d128a5c8466b700098109edcad5f2repo sync// met: 7baa3858d3f5d128a5c8466b700098109edcad5f2repo sync// 8baa3858d3f5d128a5c8466b700098109edcad5f2repo sync// * Redistributions of source code must retain the above copyright 9baa3858d3f5d128a5c8466b700098109edcad5f2repo sync// notice, this list of conditions and the following disclaimer. 10baa3858d3f5d128a5c8466b700098109edcad5f2repo sync// * Redistributions in binary form must reproduce the above 11baa3858d3f5d128a5c8466b700098109edcad5f2repo sync// copyright notice, this list of conditions and the following disclaimer 12baa3858d3f5d128a5c8466b700098109edcad5f2repo sync// in the documentation and/or other materials provided with the 13baa3858d3f5d128a5c8466b700098109edcad5f2repo sync// distribution. 14baa3858d3f5d128a5c8466b700098109edcad5f2repo sync// * Neither the name of Google Inc. nor the names of its 15baa3858d3f5d128a5c8466b700098109edcad5f2repo sync// contributors may be used to endorse or promote products derived from 16baa3858d3f5d128a5c8466b700098109edcad5f2repo sync// this software without specific prior written permission. 17baa3858d3f5d128a5c8466b700098109edcad5f2repo sync// 18baa3858d3f5d128a5c8466b700098109edcad5f2repo sync// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19baa3858d3f5d128a5c8466b700098109edcad5f2repo sync// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20baa3858d3f5d128a5c8466b700098109edcad5f2repo sync// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21baa3858d3f5d128a5c8466b700098109edcad5f2repo sync// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22baa3858d3f5d128a5c8466b700098109edcad5f2repo sync// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23baa3858d3f5d128a5c8466b700098109edcad5f2repo sync// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24baa3858d3f5d128a5c8466b700098109edcad5f2repo sync// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25baa3858d3f5d128a5c8466b700098109edcad5f2repo sync// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26baa3858d3f5d128a5c8466b700098109edcad5f2repo sync// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27baa3858d3f5d128a5c8466b700098109edcad5f2repo sync// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28baa3858d3f5d128a5c8466b700098109edcad5f2repo sync// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29baa3858d3f5d128a5c8466b700098109edcad5f2repo sync 30baa3858d3f5d128a5c8466b700098109edcad5f2repo sync// --- 31baa3858d3f5d128a5c8466b700098109edcad5f2repo sync// Author: Paul Pluzhnikov 32baa3858d3f5d128a5c8466b700098109edcad5f2repo sync// 33baa3858d3f5d128a5c8466b700098109edcad5f2repo sync// This code logically belongs in stacktrace.cc, but 34baa3858d3f5d128a5c8466b700098109edcad5f2repo sync// it is moved into (this) separate file in order to 35baa3858d3f5d128a5c8466b700098109edcad5f2repo sync// prevent inlining of routines defined here. 36baa3858d3f5d128a5c8466b700098109edcad5f2repo sync// 37// Inlining causes skip_count to be incorrect, and there 38// is no portable way to prevent it. 39// 40// Eventually LTO (link-time optimization) and/or LLVM 41// may inline this code anyway. Let's hope they respect 42// ATTRIBUTE_NOINLINE. 43 44#include <config.h> 45#include <gperftools/stacktrace.h> 46#include "stacktrace_config.h" 47#include "base/basictypes.h" 48 49#if !defined(STACKTRACE_SKIP_CONTEXT_ROUTINES) 50ATTRIBUTE_NOINLINE PERFTOOLS_DLL_DECL 51int GetStackFramesWithContext(void** pcs, int* sizes, int max_depth, 52 int skip_count, const void * /* uc */) { 53 return GetStackFrames(pcs, sizes, max_depth, skip_count + 1); 54} 55 56ATTRIBUTE_NOINLINE PERFTOOLS_DLL_DECL 57int GetStackTraceWithContext(void** result, int max_depth, 58 int skip_count, const void * /* uc */) { 59 return GetStackTrace(result, max_depth, skip_count + 1); 60} 61#endif 62