|
||||
File indexing completed on 2025-01-18 10:13:31
0001 /*--------------------------------------------------------------------*/ 0002 /*--- ExeContexts: long-lived stack traces. pub_tool_execontext.h ---*/ 0003 /*--------------------------------------------------------------------*/ 0004 0005 /* 0006 This file is part of Valgrind, a dynamic binary instrumentation 0007 framework. 0008 0009 Copyright (C) 2000-2017 Julian Seward 0010 jseward@acm.org 0011 0012 This program is free software; you can redistribute it and/or 0013 modify it under the terms of the GNU General Public License as 0014 published by the Free Software Foundation; either version 2 of the 0015 License, or (at your option) any later version. 0016 0017 This program is distributed in the hope that it will be useful, but 0018 WITHOUT ANY WARRANTY; without even the implied warranty of 0019 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 0020 General Public License for more details. 0021 0022 You should have received a copy of the GNU General Public License 0023 along with this program; if not, see <http://www.gnu.org/licenses/>. 0024 0025 The GNU General Public License is contained in the file COPYING. 0026 */ 0027 0028 #ifndef __PUB_TOOL_EXECONTEXT_H 0029 #define __PUB_TOOL_EXECONTEXT_H 0030 0031 #include "pub_tool_basics.h" // ThreadID 0032 #include "pub_tool_debuginfo.h" // DiEpoch 0033 0034 0035 /*====================================================================*/ 0036 /*=== ExeContext ===*/ 0037 /*====================================================================*/ 0038 0039 // It's an abstract type. 0040 typedef 0041 struct _ExeContext 0042 ExeContext; 0043 0044 // Resolution type used to decide how closely to compare two errors for 0045 // equality. 0046 typedef 0047 enum { Vg_LowRes, Vg_MedRes, Vg_HighRes } 0048 VgRes; 0049 0050 // Take a snapshot of the client's stack. Search our collection of 0051 // ExeContexts to see if we already have it, and if not, allocate a 0052 // new one. Either way, return a pointer to the context. Context size 0053 // controlled by --num-callers option. 0054 // 0055 // This should only be used for long-lived stack traces. If you want a 0056 // short-lived stack trace, use VG_(get_StackTrace)(). 0057 // 0058 // If called from generated code, use VG_(get_running_tid)() to get the 0059 // current ThreadId. If called from non-generated code, the current 0060 // ThreadId should be passed in by the core. The initial IP value to 0061 // use is adjusted by first_ip_delta before the stack is unwound. 0062 // A safe value to pass is zero. 0063 // 0064 // See comments in pub_tool_stacktrace.h for precise definition of 0065 // the meaning of the code addresses in the returned ExeContext. 0066 extern 0067 ExeContext* VG_(record_ExeContext) ( ThreadId tid, Word first_ip_delta ); 0068 0069 // Trivial version of VG_(record_ExeContext), which just records the 0070 // thread's current program counter but does not do any stack 0071 // unwinding. This is useful in some rare cases when we suspect the 0072 // stack might be outside mapped storage, and so unwinding 0073 // might cause a segfault. In this case we can at least safely 0074 // produce a one-element stack trace, which is better than nothing. 0075 extern 0076 ExeContext* VG_(record_depth_1_ExeContext)(ThreadId tid, Word first_ip_delta); 0077 0078 // Apply a function to every element in the ExeContext. The parameter 'n' 0079 // gives the index of the passed ip. Doesn't go below main() unless 0080 // --show-below-main=yes is set. 0081 extern void VG_(apply_ExeContext)( 0082 void(*action)(UInt n, DiEpoch ep, Addr ip, void* opaque), 0083 void* opaque, ExeContext* ec); 0084 0085 // Compare two ExeContexts. Number of callers considered depends on `res': 0086 // Vg_LowRes: 2 0087 // Vg_MedRes: 4 0088 // Vg_HighRes: all 0089 extern Bool VG_(eq_ExeContext) ( VgRes res, const ExeContext* e1, 0090 const ExeContext* e2 ); 0091 0092 // Print an ExeContext. 0093 extern void VG_(pp_ExeContext) ( ExeContext* ec ); 0094 0095 // Get the 32-bit unique reference number for this ExeContext 0096 // (the "ExeContext Unique"). Guaranteed to be nonzero and to be a 0097 // multiple of four (iow, the lowest two bits are guaranteed to 0098 // be zero, so that callers can store other information there. 0099 extern UInt VG_(get_ECU_from_ExeContext)( const ExeContext* e ); 0100 0101 // Returns the epoch in which the ips of e can be symbolised. 0102 extern DiEpoch VG_(get_ExeContext_epoch)( const ExeContext* e ); 0103 0104 // How many entries (frames) in this ExeContext? 0105 extern Int VG_(get_ExeContext_n_ips)( const ExeContext* e ); 0106 0107 // Find the ExeContext that has the given ECU, if any. 0108 // NOTE: very slow. Do not call often. 0109 extern ExeContext* VG_(get_ExeContext_from_ECU)( UInt uniq ); 0110 0111 // Make an ExeContext containing just 'a', and nothing else 0112 ExeContext* VG_(make_depth_1_ExeContext_from_Addr)( Addr a ); 0113 0114 // Is this a plausible-looking ECU ? Catches some obvious stupid 0115 // cases, but does not guarantee that the ECU is really valid, that 0116 // is, has an associated ExeContext. 0117 static inline Bool VG_(is_plausible_ECU)( UInt ecu ) { 0118 return (ecu > 0) && ((ecu & 3) == 0); 0119 } 0120 0121 // Make an ExeContext containing exactly the specified stack frames. 0122 ExeContext* VG_(make_ExeContext_from_StackTrace)( const Addr* ips, UInt n_ips ); 0123 0124 // Returns the "null" exe context. The null execontext is an artificial 0125 // exe context, with a stack trace made of one Addr (the NULL address). 0126 extern 0127 ExeContext* VG_(null_ExeContext) (void); 0128 0129 #endif // __PUB_TOOL_EXECONTEXT_H 0130 0131 /*--------------------------------------------------------------------*/ 0132 /*--- end ---*/ 0133 /*--------------------------------------------------------------------*/
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |