blob: 5387676aa10362aaadeb1c4ef3a9211bbbfb0365 [file] [log] [blame]
njnd01fef72005-03-25 23:35:48 +00001/*--------------------------------------------------------------------*/
2/*--- Stack traces: getting, traversing, printing. ---*/
3/*--- tool_stacktrace.h ---*/
4/*--------------------------------------------------------------------*/
5
6/*
7 This file is part of Valgrind, a dynamic binary instrumentation
8 framework.
9
sewardj4d474d02008-02-11 11:34:59 +000010 Copyright (C) 2000-2008 Julian Seward
njnd01fef72005-03-25 23:35:48 +000011 jseward@acm.org
12
13 This program is free software; you can redistribute it and/or
14 modify it under the terms of the GNU General Public License as
15 published by the Free Software Foundation; either version 2 of the
16 License, or (at your option) any later version.
17
18 This program is distributed in the hope that it will be useful, but
19 WITHOUT ANY WARRANTY; without even the implied warranty of
20 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
21 General Public License for more details.
22
23 You should have received a copy of the GNU General Public License
24 along with this program; if not, write to the Free Software
25 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
26 02111-1307, USA.
27
28 The GNU General Public License is contained in the file COPYING.
29*/
30
31#ifndef __PUB_TOOL_STACKTRACE_H
32#define __PUB_TOOL_STACKTRACE_H
33
njnd01fef72005-03-25 23:35:48 +000034// The basic stack trace type: just an array of code addresses.
35typedef Addr* StackTrace;
36
37// Walks the stack to get instruction pointers from the top stack frames for
38// thread 'tid'. Maximum of 'n_ips' addresses put into 'ips'; 0 is the top
njnc0ec8e92005-12-25 06:34:04 +000039// of the stack, 1 is its caller, etc. Everything from ips[n_ips] onwards
sewardjea226c42007-11-09 23:16:11 +000040// is undefined and should not be read. The initial IP value to
41// use is adjusted by first_ip_delta before the stack is unwound.
42// A safe value to pass is zero.
43extern UInt VG_(get_StackTrace) ( ThreadId tid, StackTrace ips, UInt n_ips,
44 Word first_ip_delta );
njnd01fef72005-03-25 23:35:48 +000045
46// Apply a function to every element in the StackTrace. The parameter 'n'
47// gives the index of the passed ip. Doesn't go below main() unless
48// --show-below-main=yes is set.
49extern void VG_(apply_StackTrace)( void(*action)(UInt n, Addr ip),
50 StackTrace ips, UInt n_ips );
51
52// Print a StackTrace.
53extern void VG_(pp_StackTrace) ( StackTrace ips, UInt n_ips );
54
55// Gets and immediately prints a StackTrace. Just a bit simpler than
56// calling VG_(get_StackTrace)() then VG_(pp_StackTrace)().
57extern void VG_(get_and_pp_StackTrace) ( ThreadId tid, UInt n_ips );
58
59#endif // __PUB_TOOL_STACKTRACE_H
60
61/*--------------------------------------------------------------------*/
62/*--- end ---*/
63/*--------------------------------------------------------------------*/