njn | ea27e46 | 2005-05-31 02:38:09 +0000 | [diff] [blame^] | 1 | |
| 2 | /*--------------------------------------------------------------------*/ |
| 3 | /*--- DebugInfo. pub_tool_debuginfo.h ---*/ |
| 4 | /*--------------------------------------------------------------------*/ |
| 5 | |
| 6 | /* |
| 7 | This file is part of Valgrind, a dynamic binary instrumentation |
| 8 | framework. |
| 9 | |
| 10 | Copyright (C) 2000-2005 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_TOOL_DEBUGINFO_H |
| 32 | #define __PUB_TOOL_DEBUGINFO_H |
| 33 | |
| 34 | /*====================================================================*/ |
| 35 | /*=== Obtaining debug information ===*/ |
| 36 | /*====================================================================*/ |
| 37 | |
| 38 | /* Get the file/function/line number of the instruction at address |
| 39 | 'a'. For these four, if debug info for the address is found, it |
| 40 | copies the info into the buffer/UInt and returns True. If not, it |
| 41 | returns False and nothing is copied. VG_(get_fnname) always |
| 42 | demangles C++ function names. VG_(get_fnname_w_offset) is the |
| 43 | same, except it appends "+N" to symbol names to indicate offsets. */ |
| 44 | extern Bool VG_(get_filename) ( Addr a, Char* filename, Int n_filename ); |
| 45 | extern Bool VG_(get_fnname) ( Addr a, Char* fnname, Int n_fnname ); |
| 46 | extern Bool VG_(get_linenum) ( Addr a, UInt* linenum ); |
| 47 | extern Bool VG_(get_fnname_w_offset) |
| 48 | ( Addr a, Char* fnname, Int n_fnname ); |
| 49 | |
| 50 | /* This one is more efficient if getting both filename and line number, |
| 51 | because the two lookups are done together. */ |
| 52 | extern Bool VG_(get_filename_linenum) |
| 53 | ( Addr a, Char* filename, Int n_filename, |
| 54 | UInt* linenum ); |
| 55 | |
| 56 | /* Succeeds only if we find from debug info that 'a' is the address of the |
| 57 | first instruction in a function -- as opposed to VG_(get_fnname) which |
| 58 | succeeds if we find from debug info that 'a' is the address of any |
| 59 | instruction in a function. Use this to instrument the start of |
| 60 | a particular function. Nb: if an executable/shared object is stripped |
| 61 | of its symbols, this function will not be able to recognise function |
| 62 | entry points within it. */ |
| 63 | extern Bool VG_(get_fnname_if_entry) ( Addr a, Char* fnname, Int n_fnname ); |
| 64 | |
| 65 | /* Succeeds if the address is within a shared object or the main executable. |
| 66 | It doesn't matter if debug info is present or not. */ |
| 67 | extern Bool VG_(get_objname) ( Addr a, Char* objname, Int n_objname ); |
| 68 | |
| 69 | /* Puts into 'buf' info about the code address %eip: the address, function |
| 70 | name (if known) and filename/line number (if known), like this: |
| 71 | |
| 72 | 0x4001BF05: realloc (vg_replace_malloc.c:339) |
| 73 | |
| 74 | 'n_buf' gives length of 'buf'. Returns 'buf'. |
| 75 | */ |
| 76 | extern Char* VG_(describe_IP)(Addr eip, Char* buf, Int n_buf); |
| 77 | |
| 78 | /* Returns a string containing an expression for the given |
| 79 | address. String is malloced with VG_(malloc)() */ |
| 80 | Char *VG_(describe_addr)(ThreadId, Addr); |
| 81 | |
| 82 | /*====================================================================*/ |
| 83 | /*=== Obtaining segment information ===*/ |
| 84 | /*====================================================================*/ |
| 85 | |
| 86 | /* A way to get information about what segments are mapped */ |
| 87 | typedef struct _SegInfo SegInfo; |
| 88 | |
| 89 | /* Returns NULL if the SegInfo isn't found. It doesn't matter if debug info |
| 90 | is present or not. */ |
| 91 | extern SegInfo* VG_(get_obj) ( Addr a ); |
| 92 | |
| 93 | extern const SegInfo* VG_(next_seginfo) ( const SegInfo *si ); |
| 94 | extern Addr VG_(seg_start) ( const SegInfo *si ); |
| 95 | extern SizeT VG_(seg_size) ( const SegInfo *si ); |
| 96 | extern const UChar* VG_(seg_filename) ( const SegInfo *si ); |
| 97 | extern ULong VG_(seg_sym_offset)( const SegInfo *si ); |
| 98 | |
| 99 | typedef |
| 100 | enum { |
| 101 | Vg_SectUnknown, |
| 102 | Vg_SectText, |
| 103 | Vg_SectData, |
| 104 | Vg_SectBSS, |
| 105 | Vg_SectGOT, |
| 106 | Vg_SectPLT |
| 107 | } |
| 108 | VgSectKind; |
| 109 | |
| 110 | extern VgSectKind VG_(seg_sect_kind)(Addr); |
| 111 | |
| 112 | #endif // __PUB_TOOL_DEBUGINFO_H |
| 113 | |
| 114 | /*--------------------------------------------------------------------*/ |
| 115 | /*--- end ---*/ |
| 116 | /*--------------------------------------------------------------------*/ |