Handle gcc __builtin_strcmp using 128/256 bit vectors with sse4.1, avx/avx2
[valgrind.git] / include / pub_tool_stacktrace.h
blobcad840e1df567f0a6dffa96ff1c567e571a81628
1 /*--------------------------------------------------------------------*/
2 /*--- Stack traces: getting, traversing, printing. ---*/
3 /*--- tool_stacktrace.h ---*/
4 /*--------------------------------------------------------------------*/
6 /*
7 This file is part of Valgrind, a dynamic binary instrumentation
8 framework.
10 Copyright (C) 2000-2017 Julian Seward
11 jseward@acm.org
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.
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.
23 You should have received a copy of the GNU General Public License
24 along with this program; if not, see <http://www.gnu.org/licenses/>.
26 The GNU General Public License is contained in the file COPYING.
29 #ifndef __PUB_TOOL_STACKTRACE_H
30 #define __PUB_TOOL_STACKTRACE_H
32 #include "pub_tool_basics.h" // Addr, DiEpoch
34 // The basic stack trace type: just an array of code addresses.
35 typedef Addr* StackTrace;
37 // Walks the stack to get instruction pointers from the top stack frames
38 // for thread 'tid'. Maximum of 'n_ips' addresses put into 'ips';
39 // 0 is the top of the stack, 1 is its caller, etc. Everything from
40 // ips[return_value] onwards is undefined and should not be read.
41 // The initial IP value to use is adjusted by first_ip_delta before
42 // the stack is unwound. A safe value to pass is zero.
44 // The specific meaning of the returned addresses is:
46 // [0] is the IP of thread 'tid'
47 // [1] points to the last byte of the call instruction that called [0].
48 // [2] points to the last byte of the call instruction that called [1].
49 // etc etc
51 // Hence ips[0 .. return_value-1] should all point to currently
52 // 'active' (in the sense of a stack of unfinished function calls)
53 // instructions. [0] points to the start of an arbitrary instruction.#
54 // [1 ..] point to the last byte of a chain of call instructions.
56 // If sps and fps are non-NULL, the corresponding frame-pointer and
57 // stack-pointer values for each frame are stored there.
59 extern UInt VG_(get_StackTrace) ( ThreadId tid,
60 /*OUT*/StackTrace ips, UInt n_ips,
61 /*OUT*/StackTrace sps,
62 /*OUT*/StackTrace fps,
63 Word first_ip_delta );
65 // Same as VG_(get_StackTrace), but applies a delta to the first SP used for
66 // unwinding the first frame.
67 extern UInt VG_(get_StackTrace_with_deltas)(
68 ThreadId tid,
69 /*OUT*/StackTrace ips, UInt n_ips,
70 /*OUT*/StackTrace sps,
71 /*OUT*/StackTrace fps,
72 Word first_ip_delta,
73 Word first_sp_delta
76 // Apply a function to every element in the StackTrace. The parameter 'n'
77 // gives the index of the passed ip. 'opaque' is an arbitrary pointer
78 // provided to each invocation of 'action' (a poor man's closure). 'ep' is
79 // the debuginfo epoch assumed to apply to all code addresses in the stack
80 // trace. Doesn't go below main() unless --show-below-main=yes is set.
81 extern void VG_(apply_StackTrace)(
82 void(*action)(UInt n, DiEpoch ep, Addr ip, void* opaque),
83 void* opaque,
84 DiEpoch ep, StackTrace ips, UInt n_ips
87 // Print a StackTrace.
88 extern void VG_(pp_StackTrace) ( DiEpoch ep, StackTrace ips, UInt n_ips );
90 // Gets and immediately prints a StackTrace. Just a bit simpler than
91 // calling VG_(get_StackTrace)() then VG_(pp_StackTrace)().
92 extern void VG_(get_and_pp_StackTrace) ( ThreadId tid, UInt n_ips );
94 #endif // __PUB_TOOL_STACKTRACE_H
96 /*--------------------------------------------------------------------*/
97 /*--- end ---*/
98 /*--------------------------------------------------------------------*/