Modularised all the debug info stuff as m_debuginfo/. It's a mess

and needs further cleaning up, but it's a start.



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@3821
This commit is contained in:
Nicholas Nethercote 2005-05-31 02:38:09 +00:00
parent 02df24345a
commit d01259a1d0
20 changed files with 241 additions and 132 deletions

View File

@ -30,6 +30,7 @@
*/
#include "tool.h"
#include "pub_tool_debuginfo.h"
#include "pub_tool_hashtable.h"
#include "pub_tool_mallocfree.h"
#include "pub_tool_options.h"

View File

@ -388,6 +388,7 @@ AC_OUTPUT(
auxprogs/Makefile
coregrind/Makefile
coregrind/m_aspacemgr/Makefile
coregrind/m_debuginfo/Makefile
coregrind/m_demangle/Makefile
coregrind/m_dispatch/Makefile
coregrind/m_replacemalloc/Makefile

View File

@ -3,6 +3,7 @@ include $(top_srcdir)/Makefile.core-AM_CPPFLAGS.am
MODULES = \
m_aspacemgr \
m_debuginfo \
m_demangle \
m_dispatch \
m_replacemalloc \
@ -37,6 +38,7 @@ noinst_HEADERS = \
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 \
@ -60,8 +62,6 @@ noinst_HEADERS = \
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 \
@ -101,18 +101,15 @@ stage2_SOURCES = \
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 \

View File

@ -209,29 +209,6 @@ extern void VG_(env_remove_valgrind_env_stuff) ( Char** env );
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
------------------------------------------------------------------ */

View File

@ -0,0 +1,14 @@
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

View File

@ -1,5 +1,6 @@
/*--------------------------------------------------------------------*/
/*--- Read DWARF2 debug info. vg_dwarf.c ---*/
/*--- Read DWARF2 debug info. dwarf.c ---*/
/*--------------------------------------------------------------------*/
/*
@ -28,9 +29,8 @@
*/
#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
@ -1968,5 +1968,5 @@ void VG_(read_callframe_info_dwarf2)
/*--------------------------------------------------------------------*/
/*--- end vg_dwarf.c ---*/
/*--- end ---*/
/*--------------------------------------------------------------------*/

View File

@ -1,5 +1,6 @@
/*--------------------------------------------------------------------*/
/*--- Header for symbol table stuff. vg_symtab2.h ---*/
/*--- Header for symbol table stuff. priv_symtab.h ---*/
/*--------------------------------------------------------------------*/
/*
@ -27,10 +28,11 @@
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
@ -262,8 +264,8 @@ void VG_(read_callframe_info_dwarf2)
( /*OUT*/SegInfo* si, UChar* ehframe, Int ehframe_sz, Addr ehframe_addr );
#endif /* _VG_SYMTYPE_H */
#endif // __PRIV_SYMTAB_H
/*--------------------------------------------------------------------*/
/*--- end vg_symtab2.h ---*/
/*--- end ---*/
/*--------------------------------------------------------------------*/

View File

@ -1,5 +1,6 @@
/*--------------------------------------------------------------------*/
/*--- Intra-Valgrind interfaces for vg_symtypes.c. vg_symtypes.h ---*/
/*--- Intra-Valgrind interfaces for symtypes.c. priv_symtypes.h ---*/
/*--------------------------------------------------------------------*/
/*
@ -27,8 +28,8 @@
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;
@ -87,7 +88,7 @@ Bool VG_(st_isunion)(SymType *);
Bool VG_(st_isenum)(SymType *);
/* ------------------------------------------------------------
Interface with vg_symtab2.c
Interface with symtab.c
------------------------------------------------------------ */
/* Typed value */
@ -105,8 +106,8 @@ struct _Variable {
Variable *VG_(get_scope_variables)(ThreadId tid);
#endif /* VG_SYMTYPES_H */
#endif // __PRIV_SYMTYPES_H
/*--------------------------------------------------------------------*/
/*--- end vg_symtypes.h ---*/
/*--- end ---*/
/*--------------------------------------------------------------------*/

View File

@ -1,5 +1,6 @@
/*--------------------------------------------------------------------*/
/*--- Read stabs debug info. vg_stabs.c ---*/
/*--- Read stabs debug info. stabs.c ---*/
/*--------------------------------------------------------------------*/
/*
@ -28,7 +29,7 @@
*/
#include "core.h"
#include "vg_symtab2.h"
#include "priv_symtab.h"
#include <a.out.h> /* stabs defns */

View File

@ -1,7 +1,7 @@
/*--------------------------------------------------------------------*/
/*--- Management of symbols and debugging information. ---*/
/*--- vg_symtab2.c ---*/
/*--- symtab.c ---*/
/*--------------------------------------------------------------------*/
/*
@ -30,14 +30,12 @@
*/
#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 */
@ -2652,5 +2650,5 @@ VgSectKind VG_(seg_sect_kind)(Addr a)
}
/*--------------------------------------------------------------------*/
/*--- end vg_symtab2.c ---*/
/*--- end ---*/
/*--------------------------------------------------------------------*/

View File

@ -1,5 +1,6 @@
/*--------------------------------------------------------------------*/
/*--- Extract type info from debug info. vg_symtypes.h ---*/
/*--- Extract type info from debug info. symtypes.h ---*/
/*--------------------------------------------------------------------*/
/*
@ -28,9 +29,10 @@
*/
#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 */
@ -1058,5 +1060,5 @@ Char *VG_(describe_addr)(ThreadId tid, Addr addr)
#endif /* TEST */
/*--------------------------------------------------------------------*/
/*--- end vg_symtypes.c ---*/
/*--- end ---*/
/*--------------------------------------------------------------------*/

View File

@ -29,6 +29,7 @@
*/
#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)()

View File

@ -30,13 +30,13 @@
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. ---*/

View File

@ -30,6 +30,7 @@
*/
#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!

View File

@ -37,9 +37,11 @@
// 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

View File

@ -0,0 +1,67 @@
/*--------------------------------------------------------------------*/
/*--- 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 ---*/
/*--------------------------------------------------------------------*/

View File

@ -30,6 +30,7 @@
*/
#include "tool.h"
#include "pub_tool_debuginfo.h"
#include "pub_tool_hashtable.h"
#include "pub_tool_mallocfree.h"
#include "pub_tool_options.h"

View File

@ -0,0 +1,116 @@
/*--------------------------------------------------------------------*/
/*--- 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 ---*/
/*--------------------------------------------------------------------*/

View File

@ -457,80 +457,6 @@ extern void VG_(cpuid) ( UInt eax,
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 ===*/
/*====================================================================*/

View File

@ -35,6 +35,7 @@
// 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"