and needs further cleaning up, but it's a start.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@3821
*/
#include "tool.h"
+#include "pub_tool_debuginfo.h"
#include "pub_tool_hashtable.h"
#include "pub_tool_mallocfree.h"
#include "pub_tool_options.h"
auxprogs/Makefile
coregrind/Makefile
coregrind/m_aspacemgr/Makefile
+ coregrind/m_debuginfo/Makefile
coregrind/m_demangle/Makefile
coregrind/m_dispatch/Makefile
coregrind/m_replacemalloc/Makefile
MODULES = \
m_aspacemgr \
+ m_debuginfo \
m_demangle \
m_dispatch \
m_replacemalloc \
core.h \
core_asm.h \
pub_core_aspacemgr.h \
+ pub_core_debuginfo.h \
pub_core_debuglog.h \
pub_core_demangle.h \
pub_core_dispatch.h \
pub_core_transtab.h \
pub_core_transtab_asm.h \
ume.h \
- vg_symtab2.h \
- vg_symtypes.h \
vki_unistd.h \
vki_unistd-amd64-linux.h\
vki_unistd-arm-linux.h \
vg_messages.c \
vg_mylibc.c \
vg_dummy_profile.c \
- vg_symtab2.c \
vg_threadmodel.c \
- vg_pthreadmodel.c \
- vg_dwarf.c \
- vg_stabs.c \
- vg_symtypes.c
+ vg_pthreadmodel.c
## Nb: libscheduler.a must precede libdispatch.a in this list.
stage2_extra= \
+ m_debuginfo/libdebuginfo.a \
+ m_demangle/libdemangle.a \
m_scheduler/libscheduler.a \
m_dispatch/libdispatch.a \
- m_demangle/libdemangle.a \
m_aspacemgr/libaspacemgr.a \
m_sigframe/libsigframe.a \
m_syscalls/libsyscalls.a \
extern void VG_(nanosleep)(struct vki_timespec *);
-/* ---------------------------------------------------------------------
- Exports of vg_symtab2.c
- ------------------------------------------------------------------ */
-
-typedef struct _Segment Segment;
-typedef struct _CodeRedirect CodeRedirect;
-
-extern Bool VG_(is_object_file) ( const void *hdr );
-extern SegInfo * VG_(read_seg_symbols) ( Segment *seg );
-extern void VG_(seginfo_incref) ( SegInfo * );
-extern void VG_(seginfo_decref) ( SegInfo *, Addr a );
-
-extern Bool VG_(get_fnname_nodemangle)( Addr a, Char* fnname, Int n_fnname );
-
-extern Addr VG_(reverse_search_one_symtab) ( const SegInfo* si, const Char* name );
-
-extern Bool VG_(use_CFI_info) ( /*MOD*/Addr* ipP,
- /*MOD*/Addr* spP,
- /*MOD*/Addr* fpP,
- Addr min_accessible,
- Addr max_accessible );
-
-
/* ---------------------------------------------------------------------
Exports of vg_syscall.S
------------------------------------------------------------------ */
--- /dev/null
+include $(top_srcdir)/Makefile.all.am
+include $(top_srcdir)/Makefile.core-AM_CPPFLAGS.am
+
+noinst_HEADERS = \
+ priv_symtab.h \
+ priv_symtypes.h
+
+noinst_LIBRARIES = libdebuginfo.a
+
+libdebuginfo_a_SOURCES = \
+ dwarf.c \
+ stabs.c \
+ symtab.c \
+ symtypes.c
+
/*--------------------------------------------------------------------*/
-/*--- Read DWARF2 debug info. vg_dwarf.c ---*/
+/*--- Read DWARF2 debug info. dwarf.c ---*/
/*--------------------------------------------------------------------*/
/*
*/
#include "core.h"
-#include "vg_symtab2.h"
-
#include "pub_core_options.h"
+#include "priv_symtab.h"
/* Structure found in the .debug_line section. */
typedef struct
/*--------------------------------------------------------------------*/
-/*--- end vg_dwarf.c ---*/
+/*--- end ---*/
/*--------------------------------------------------------------------*/
+
/*--------------------------------------------------------------------*/
-/*--- Header for symbol table stuff. vg_symtab2.h ---*/
+/*--- Header for symbol table stuff. priv_symtab.h ---*/
/*--------------------------------------------------------------------*/
/*
The GNU General Public License is contained in the file COPYING.
*/
-#ifndef _VG_SYMTYPE_H
-#define _VG_SYMTYPE_H
+#ifndef __PRIV_SYMTAB_H
+#define __PRIV_SYMTAB_H
-#include "vg_symtypes.h"
+#include "pub_core_debuginfo.h"
+#include "priv_symtypes.h"
/* A structure to hold an ELF symbol (very crudely). */
typedef
( /*OUT*/SegInfo* si, UChar* ehframe, Int ehframe_sz, Addr ehframe_addr );
-#endif /* _VG_SYMTYPE_H */
+#endif // __PRIV_SYMTAB_H
/*--------------------------------------------------------------------*/
-/*--- end vg_symtab2.h ---*/
+/*--- end ---*/
/*--------------------------------------------------------------------*/
+
/*--------------------------------------------------------------------*/
-/*--- Intra-Valgrind interfaces for vg_symtypes.c. vg_symtypes.h ---*/
+/*--- Intra-Valgrind interfaces for symtypes.c. priv_symtypes.h ---*/
/*--------------------------------------------------------------------*/
/*
The GNU General Public License is contained in the file COPYING.
*/
-#ifndef __VG_SYMTYPES_H
-#define __VG_SYMTYPES_H
+#ifndef __PRIV_SYMTYPES_H
+#define __PRIV_SYMTYPES_H
/* Lets try to make these opaque */
typedef struct _SymType SymType;
Bool VG_(st_isenum)(SymType *);
/* ------------------------------------------------------------
- Interface with vg_symtab2.c
+ Interface with symtab.c
------------------------------------------------------------ */
/* Typed value */
Variable *VG_(get_scope_variables)(ThreadId tid);
-#endif /* VG_SYMTYPES_H */
+#endif // __PRIV_SYMTYPES_H
/*--------------------------------------------------------------------*/
-/*--- end vg_symtypes.h ---*/
+/*--- end ---*/
/*--------------------------------------------------------------------*/
+
/*--------------------------------------------------------------------*/
-/*--- Read stabs debug info. vg_stabs.c ---*/
+/*--- Read stabs debug info. stabs.c ---*/
/*--------------------------------------------------------------------*/
/*
*/
#include "core.h"
-#include "vg_symtab2.h"
+#include "priv_symtab.h"
#include <a.out.h> /* stabs defns */
/*--------------------------------------------------------------------*/
/*--- Management of symbols and debugging information. ---*/
-/*--- vg_symtab2.c ---*/
+/*--- symtab.c ---*/
/*--------------------------------------------------------------------*/
/*
*/
#include "core.h"
-#include "vg_symtypes.h"
-#include "vg_symtab2.h"
-
#include "pub_core_aspacemgr.h"
#include "pub_core_demangle.h"
#include "pub_core_options.h"
#include "pub_core_redir.h"
#include "pub_core_tooliface.h"
+#include "priv_symtab.h"
#include <elf.h> /* ELF defns */
}
/*--------------------------------------------------------------------*/
-/*--- end vg_symtab2.c ---*/
+/*--- end ---*/
/*--------------------------------------------------------------------*/
+
/*--------------------------------------------------------------------*/
-/*--- Extract type info from debug info. vg_symtypes.h ---*/
+/*--- Extract type info from debug info. symtypes.h ---*/
/*--------------------------------------------------------------------*/
/*
*/
#include "core.h"
-#include "vg_symtypes.h"
+#include "pub_core_debuginfo.h"
#include "pub_core_debuglog.h" /* VG_(debugLog_vprintf) */
#include "pub_core_tooliface.h"
+#include "priv_symtypes.h"
typedef enum {
TyUnknown, /* unknown type */
#endif /* TEST */
/*--------------------------------------------------------------------*/
-/*--- end vg_symtypes.c ---*/
+/*--- end ---*/
/*--------------------------------------------------------------------*/
*/
#include "core.h"
+#include "pub_core_debuginfo.h"
#include "pub_core_errormgr.h"
#include "pub_core_execontext.h"
#include "pub_core_main.h" // for VG_(start_debugger)()
The GNU General Public License is contained in the file COPYING.
*/
#include "core.h"
-#include "vg_symtab2.h"
#include "pub_core_aspacemgr.h"
#include "pub_core_skiplist.h"
#include "pub_core_options.h"
#include "pub_core_redir.h"
#include "pub_core_transtab.h"
+#include "m_debuginfo/priv_symtab.h" // XXX: bad!
/*------------------------------------------------------------*/
/*--- General purpose redirection. ---*/
*/
#include "core.h"
+#include "pub_core_debuginfo.h"
#include "pub_core_options.h"
#include "pub_core_tooliface.h"
// XXX: this module should not depend on m_translate!
// memory management. Hence this module is almost completely
// standalone; the only module it uses is m_debuglog. DO NOT CHANGE
// THIS.
+// [XXX: actually, this is far from true...]
//--------------------------------------------------------------------
/* #include "pub_tool_aspacemgr.h" */
+#include "pub_core_debuginfo.h"
// Address space globals
extern Addr VG_(client_base); // client address space limits
--- /dev/null
+
+/*--------------------------------------------------------------------*/
+/*--- Debug info. pub_core_debuginfo.h ---*/
+/*--------------------------------------------------------------------*/
+
+/*
+ This file is part of Valgrind, a dynamic binary instrumentation
+ framework.
+
+ Copyright (C) 2000-2005 Julian Seward
+ jseward@acm.org
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307, USA.
+
+ The GNU General Public License is contained in the file COPYING.
+*/
+
+#ifndef __PUB_CORE_DEBUGINFO_H
+#define __PUB_CORE_DEBUGINFO_H
+
+//--------------------------------------------------------------------
+// PURPOSE: This module deals with reading debug info and symbol tables
+// to get file and function names, line numbers, variable types, and
+// to help stack unwinding.
+//
+// And it's internals are currently a mess. It's interface is ugly, too.
+//--------------------------------------------------------------------
+
+#include "pub_tool_debuginfo.h"
+
+typedef struct _Segment Segment;
+typedef struct _CodeRedirect CodeRedirect;
+
+extern Bool VG_(is_object_file) ( const void *hdr );
+extern SegInfo * VG_(read_seg_symbols) ( Segment *seg );
+extern void VG_(seginfo_incref) ( SegInfo * );
+extern void VG_(seginfo_decref) ( SegInfo *, Addr a );
+
+extern Bool VG_(get_fnname_nodemangle)( Addr a, Char* fnname, Int n_fnname );
+
+extern Addr VG_(reverse_search_one_symtab) ( const SegInfo* si, const Char* name );
+
+extern Bool VG_(use_CFI_info) ( /*MOD*/Addr* ipP,
+ /*MOD*/Addr* spP,
+ /*MOD*/Addr* fpP,
+ Addr min_accessible,
+ Addr max_accessible );
+
+
+#endif // __PUB_CORE_DEBUGINFO_H
+
+/*--------------------------------------------------------------------*/
+/*--- end ---*/
+/*--------------------------------------------------------------------*/
*/
#include "tool.h"
+#include "pub_tool_debuginfo.h"
#include "pub_tool_hashtable.h"
#include "pub_tool_mallocfree.h"
#include "pub_tool_options.h"
--- /dev/null
+
+/*--------------------------------------------------------------------*/
+/*--- DebugInfo. pub_tool_debuginfo.h ---*/
+/*--------------------------------------------------------------------*/
+
+/*
+ This file is part of Valgrind, a dynamic binary instrumentation
+ framework.
+
+ Copyright (C) 2000-2005 Julian Seward
+ jseward@acm.org
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307, USA.
+
+ The GNU General Public License is contained in the file COPYING.
+*/
+
+#ifndef __PUB_TOOL_DEBUGINFO_H
+#define __PUB_TOOL_DEBUGINFO_H
+
+/*====================================================================*/
+/*=== Obtaining debug information ===*/
+/*====================================================================*/
+
+/* Get the file/function/line number of the instruction at address
+ 'a'. For these four, if debug info for the address is found, it
+ copies the info into the buffer/UInt and returns True. If not, it
+ returns False and nothing is copied. VG_(get_fnname) always
+ demangles C++ function names. VG_(get_fnname_w_offset) is the
+ same, except it appends "+N" to symbol names to indicate offsets. */
+extern Bool VG_(get_filename) ( Addr a, Char* filename, Int n_filename );
+extern Bool VG_(get_fnname) ( Addr a, Char* fnname, Int n_fnname );
+extern Bool VG_(get_linenum) ( Addr a, UInt* linenum );
+extern Bool VG_(get_fnname_w_offset)
+ ( Addr a, Char* fnname, Int n_fnname );
+
+/* This one is more efficient if getting both filename and line number,
+ because the two lookups are done together. */
+extern Bool VG_(get_filename_linenum)
+ ( Addr a, Char* filename, Int n_filename,
+ UInt* linenum );
+
+/* Succeeds only if we find from debug info that 'a' is the address of the
+ first instruction in a function -- as opposed to VG_(get_fnname) which
+ succeeds if we find from debug info that 'a' is the address of any
+ instruction in a function. Use this to instrument the start of
+ a particular function. Nb: if an executable/shared object is stripped
+ of its symbols, this function will not be able to recognise function
+ entry points within it. */
+extern Bool VG_(get_fnname_if_entry) ( Addr a, Char* fnname, Int n_fnname );
+
+/* Succeeds if the address is within a shared object or the main executable.
+ It doesn't matter if debug info is present or not. */
+extern Bool VG_(get_objname) ( Addr a, Char* objname, Int n_objname );
+
+/* Puts into 'buf' info about the code address %eip: the address, function
+ name (if known) and filename/line number (if known), like this:
+
+ 0x4001BF05: realloc (vg_replace_malloc.c:339)
+
+ 'n_buf' gives length of 'buf'. Returns 'buf'.
+*/
+extern Char* VG_(describe_IP)(Addr eip, Char* buf, Int n_buf);
+
+/* Returns a string containing an expression for the given
+ address. String is malloced with VG_(malloc)() */
+Char *VG_(describe_addr)(ThreadId, Addr);
+
+/*====================================================================*/
+/*=== Obtaining segment information ===*/
+/*====================================================================*/
+
+/* A way to get information about what segments are mapped */
+typedef struct _SegInfo SegInfo;
+
+/* Returns NULL if the SegInfo isn't found. It doesn't matter if debug info
+ is present or not. */
+extern SegInfo* VG_(get_obj) ( Addr a );
+
+extern const SegInfo* VG_(next_seginfo) ( const SegInfo *si );
+extern Addr VG_(seg_start) ( const SegInfo *si );
+extern SizeT VG_(seg_size) ( const SegInfo *si );
+extern const UChar* VG_(seg_filename) ( const SegInfo *si );
+extern ULong VG_(seg_sym_offset)( const SegInfo *si );
+
+typedef
+ enum {
+ Vg_SectUnknown,
+ Vg_SectText,
+ Vg_SectData,
+ Vg_SectBSS,
+ Vg_SectGOT,
+ Vg_SectPLT
+ }
+ VgSectKind;
+
+extern VgSectKind VG_(seg_sect_kind)(Addr);
+
+#endif // __PUB_TOOL_DEBUGINFO_H
+
+/*--------------------------------------------------------------------*/
+/*--- end ---*/
+/*--------------------------------------------------------------------*/
UInt *eax_ret, UInt *ebx_ret,
UInt *ecx_ret, UInt *edx_ret );
-/*====================================================================*/
-/*=== Obtaining debug information ===*/
-/*====================================================================*/
-
-/* Get the file/function/line number of the instruction at address
- 'a'. For these four, if debug info for the address is found, it
- copies the info into the buffer/UInt and returns True. If not, it
- returns False and nothing is copied. VG_(get_fnname) always
- demangles C++ function names. VG_(get_fnname_w_offset) is the
- same, except it appends "+N" to symbol names to indicate offsets. */
-extern Bool VG_(get_filename) ( Addr a, Char* filename, Int n_filename );
-extern Bool VG_(get_fnname) ( Addr a, Char* fnname, Int n_fnname );
-extern Bool VG_(get_linenum) ( Addr a, UInt* linenum );
-extern Bool VG_(get_fnname_w_offset)
- ( Addr a, Char* fnname, Int n_fnname );
-
-/* This one is more efficient if getting both filename and line number,
- because the two lookups are done together. */
-extern Bool VG_(get_filename_linenum)
- ( Addr a, Char* filename, Int n_filename,
- UInt* linenum );
-
-/* Succeeds only if we find from debug info that 'a' is the address of the
- first instruction in a function -- as opposed to VG_(get_fnname) which
- succeeds if we find from debug info that 'a' is the address of any
- instruction in a function. Use this to instrument the start of
- a particular function. Nb: if an executable/shared object is stripped
- of its symbols, this function will not be able to recognise function
- entry points within it. */
-extern Bool VG_(get_fnname_if_entry) ( Addr a, Char* fnname, Int n_fnname );
-
-/* Succeeds if the address is within a shared object or the main executable.
- It doesn't matter if debug info is present or not. */
-extern Bool VG_(get_objname) ( Addr a, Char* objname, Int n_objname );
-
-/* Puts into 'buf' info about the code address %eip: the address, function
- name (if known) and filename/line number (if known), like this:
-
- 0x4001BF05: realloc (vg_replace_malloc.c:339)
-
- 'n_buf' gives length of 'buf'. Returns 'buf'.
-*/
-extern Char* VG_(describe_IP)(Addr eip, Char* buf, Int n_buf);
-
-/* Returns a string containing an expression for the given
- address. String is malloced with VG_(malloc)() */
-Char *VG_(describe_addr)(ThreadId, Addr);
-
-/* A way to get information about what segments are mapped */
-typedef struct _SegInfo SegInfo;
-
-/* Returns NULL if the SegInfo isn't found. It doesn't matter if debug info
- is present or not. */
-extern SegInfo* VG_(get_obj) ( Addr a );
-
-extern const SegInfo* VG_(next_seginfo) ( const SegInfo *si );
-extern Addr VG_(seg_start) ( const SegInfo *si );
-extern SizeT VG_(seg_size) ( const SegInfo *si );
-extern const UChar* VG_(seg_filename) ( const SegInfo *si );
-extern ULong VG_(seg_sym_offset)( const SegInfo *si );
-
-typedef
- enum {
- Vg_SectUnknown,
- Vg_SectText,
- Vg_SectData,
- Vg_SectBSS,
- Vg_SectGOT,
- Vg_SectPLT
- }
- VgSectKind;
-
-extern VgSectKind VG_(seg_sect_kind)(Addr);
-
/*====================================================================*/
/*=== Functions for shadow registers ===*/
/*====================================================================*/
// structures below for more info on how things work.
#include "tool.h"
+#include "pub_tool_debuginfo.h"
#include "pub_tool_hashtable.h"
#include "pub_tool_mallocfree.h"
#include "pub_tool_options.h"