1 2 /*--------------------------------------------------------------------*/ 3 /*--- Debug info. pub_core_debuginfo.h ---*/ 4 /*--------------------------------------------------------------------*/ 5 6 /* 7 This file is part of Valgrind, a dynamic binary instrumentation 8 framework. 9 10 Copyright (C) 2000-2010 Julian Seward 11 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_CORE_DEBUGINFO_H 32 #define __PUB_CORE_DEBUGINFO_H 33 34 //-------------------------------------------------------------------- 35 // PURPOSE: This module deals with reading debug info and symbol tables 36 // to get file and function names, line numbers, variable types, and 37 // to help stack unwinding. 38 //-------------------------------------------------------------------- 39 40 #include "pub_tool_debuginfo.h" 41 42 /* Initialise the entire module. Must be called first of all. */ 43 extern void VG_(di_initialise) ( void ); 44 45 /* LINUX: Notify the debuginfo system about a new mapping, or the 46 disappearance of such, or a permissions change on an existing 47 mapping. This is the way new debug information gets loaded. If 48 allow_SkFileV is True, it will try load debug info if the mapping 49 at 'a' belongs to Valgrind; whereas normally (False) it will not do 50 that. This allows us to carefully control when the thing will read 51 symbols from the Valgrind executable itself. 52 53 If a call to VG_(di_notify_mmap) causes debug info to be read, then 54 the returned ULong is an abstract handle which can later be used to 55 refer to the debuginfo read as a result of this specific mapping, 56 in later queries to m_debuginfo. In this case the handle value 57 will be one or above. If the returned value is zero, no debug info 58 was read. */ 59 #if defined(VGO_linux) || defined(VGO_darwin) 60 extern ULong VG_(di_notify_mmap)( Addr a, Bool allow_SkFileV ); 61 62 extern void VG_(di_notify_munmap)( Addr a, SizeT len ); 63 64 extern void VG_(di_notify_mprotect)( Addr a, SizeT len, UInt prot ); 65 66 /* this should really return ULong, as per VG_(di_notify_mmap). */ 67 extern void VG_(di_notify_pdb_debuginfo)( Int fd, Addr avma, 68 SizeT total_size, 69 PtrdiffT unknown_purpose__reloc ); 70 #endif 71 72 #if defined(VGO_aix5) 73 // GrP fixme use this instead for darwin? 74 /* AIX5: Very similar, except packaged more neatly. The supplied 75 parameters describe a code segment and its associated data segment, 76 that have recently been mapped in -- so we need to read debug info 77 for it -- or conversely, have recently been dumped, in which case 78 the relevant debug info has to be unloaded. 79 80 The returned ULong has the same meaning as documented for 81 VG_(di_notify_mmap) just above. */ 82 extern ULong VG_(di_aix5_notify_segchange)( 83 Addr code_start, 84 Word code_len, 85 Addr data_start, 86 Word data_len, 87 UChar* file_name, 88 UChar* mem_name, 89 Bool is_mainexe, 90 Bool acquire 91 ); 92 #endif 93 94 extern void VG_(di_discard_ALL_debuginfo)( void ); 95 96 /* Like VG_(get_fnname), but it does not do C++ demangling nor Z-demangling 97 * nor below-main renaming. 98 * It should not be used for any names that will be shown to users. 99 * It should only be used in cases where the names of interest will have 100 * particular (ie. non-mangled) forms, or the mangled form is acceptable. */ 101 extern 102 Bool VG_(get_fnname_raw) ( Addr a, Char* buf, Int nbuf ); 103 104 /* Like VG_(get_fnname), but without C++ demangling. (But it does 105 * Z-demangling and below-main renaming.) */ 106 extern 107 Bool VG_(get_fnname_no_cxx_demangle) ( Addr a, Char* buf, Int nbuf ); 108 109 110 /* Use DWARF2/3 CFA information to do one step of stack unwinding. 111 D3UnwindRegs holds the current register values, and is 112 arch-specific. Note that the x86 and amd64 definitions are shared 113 and so the regs are named 'xip' etc rather than 'eip' and 'rip'. */ 114 #if defined(VGA_amd64) || defined(VGA_x86) 115 typedef 116 struct { Addr xip; Addr xsp; Addr xbp; } 117 D3UnwindRegs; 118 #elif defined(VGA_arm) 119 typedef 120 struct { Addr r15; Addr r14; Addr r13; Addr r12; Addr r11; Addr r7; } 121 D3UnwindRegs; 122 #elif defined(VGA_ppc32) || defined(VGA_ppc64) 123 typedef 124 UChar /* should be void, but gcc complains at use points */ 125 D3UnwindRegs; 126 #else 127 # error "Unsupported arch" 128 #endif 129 130 extern Bool VG_(use_CF_info) ( /*MOD*/D3UnwindRegs* uregs, 131 Addr min_accessible, 132 Addr max_accessible ); 133 134 135 /* Use MSVC FPO data to do one step of stack unwinding. */ 136 extern Bool VG_(use_FPO_info) ( /*MOD*/Addr* ipP, 137 /*MOD*/Addr* spP, 138 /*MOD*/Addr* fpP, 139 Addr min_accessible, 140 Addr max_accessible ); 141 142 /* ppc64-linux only: find the TOC pointer (R2 value) that should be in 143 force at the entry point address of the function containing 144 guest_code_addr. Returns 0 if not known. */ 145 extern Addr VG_(get_tocptr) ( Addr guest_code_addr ); 146 147 /* Map a function name to its entry point and toc pointer. Is done by 148 sequential search of all symbol tables, so is very slow. To 149 mitigate the worst performance effects, you may specify a soname 150 pattern, and only objects matching that pattern are searched. 151 Therefore specify "*" to search all the objects. On TOC-afflicted 152 platforms, a symbol is deemed to be found only if it has a nonzero 153 TOC pointer. */ 154 extern 155 Bool VG_(lookup_symbol_SLOW)(UChar* sopatt, UChar* name, Addr* pEnt, Addr* pToc); 156 157 #endif // __PUB_CORE_DEBUGINFO_H 158 159 /*--------------------------------------------------------------------*/ 160 /*--- end ---*/ 161 /*--------------------------------------------------------------------*/ 162