mirror of
https://github.com/Zenithsiz/ftmemsim-valgrind.git
synced 2026-02-03 10:05:29 +00:00
This patch implements the support needed for stacktraces
showing inlined function calls. See 278972 valgrind stacktraces and suppression do not handle inlined function call debuginfo Reading the inlined dwarf call info is activated using the new clo --read-inline-info=yes Default is currently no but an objective is to optimise the performance and memory in order to possibly set it on by default. (see below discussion about performances). Basically, the patch provides the following pieces: 1. Implement a new dwarf3 reader that reads the inlined call info 2. Some performance improvements done for this new parser, and on some common code between the new parser and the var info parser. 3. Use the parsed inlined info to produce stacktrace showing inlined calls 4. Use the parsed inlined info in the suppression matching and suppression generation 5. and of course, some reg tests 1. new dwarf3 reader: --------------------- Two options were possible: add the reading of the inlined info in the current var info dwarf reader, or add a 2nd reader. The 2nd approach was preferred, for the following reasons: The var info reader is slow, memory hungry and quite complex. Having a separate parsing phase for the inlined information is simpler/faster when just reading the inlined info. Possibly, a single parser would be faster when using both --read-var-info=yes and --read-inline-info=yes. However, var-info being extremely memory/cpu hungry, it is unlikely to be used often, and having a separate parsing for inlined info does in any case make not much difference. (--read-var-info=yes is also now less interesting thanks to commit r13991, which provides a fast and low memory "reasonable" location for an address). The inlined info parser reads the dwarf info to make calls to priv_storage.h ML_(addInlInfo). 2. performance optimisations ---------------------------- * the abbrev cache has been improved in revision r14035. * The new parser skips the non interesting DIEs (the var-info parser has no logic to skip uninteresting DIEs). * Some other minor perf optimisation here and there. In total now, on a big executable, 15 seconds CPU are needed to create the inlined info (on my slow x86 pentium). With regards to memory, the dinfo arena: with inlined info: 172281856/121085952 max/curr mmap'd without : 157892608/106721280 max/curr mmap'd, So, basically, inlined information costs about 15Mb of memory for my big executable (compared to first version of the patch, this is already using less memory, thanks to the strpool deduppoolalloc. The needed memory can probably be decreased somewhat more. 3. produce better stack traces ------------------------------ VG_(describe_IP) has a new argument InlIPCursor *iipc which allows to describe inlined function calls by doing repetitive calls to describe_IP. See pub_tool_debuginfo.h for a description. 4. suppression generation and matching -------------------------------------- * suppression generation now also uses an InlIPCursor *iipc to generate a line for each inlined fn call. * suppression matching: to allow suppression matching to match one IP to several function calls in a suppression entry, the 'inputCompleter' object (that allows to lazily generate function or object names for a stacktrace when matching an error with a suppression) has been generalised a little bit more to also lazily generate the input sequence. VG_(generic_match) has been updated so as to be more generic with respect to the input completer : when providing an input completer, VG_(generic_match) does not need anymore to produce/compute any input itself : this is all delegated to the input completer. 5. various regtests ------------------- to test stack traces with inlined calls, and suppressions of (some of) these errors using inlined fn calls matching. Work still to do: ----------------- * improve parsing performance * improve the memory overhead. * handling the directory name for files of the inlined function calls is not yet done. (probably implies to refactor some code) * see if m_errormgr.c *offsets arrays cannot be managed via xarray git-svn-id: svn://svn.valgrind.org/valgrind/trunk@14036
This commit is contained in:
parent
19a3689518
commit
ceaa5b2efe
@ -212,6 +212,7 @@ static void free_DebugInfo ( DebugInfo* di )
|
||||
if (di->fsm.filename) ML_(dinfo_free)(di->fsm.filename);
|
||||
if (di->soname) ML_(dinfo_free)(di->soname);
|
||||
if (di->loctab) ML_(dinfo_free)(di->loctab);
|
||||
if (di->inltab) ML_(dinfo_free)(di->inltab);
|
||||
if (di->cfsi) ML_(dinfo_free)(di->cfsi);
|
||||
if (di->cfsi_exprs) VG_(deleteXA)(di->cfsi_exprs);
|
||||
if (di->fpo) ML_(dinfo_free)(di->fpo);
|
||||
@ -1258,8 +1259,10 @@ void VG_(di_notify_pdb_debuginfo)( Int fd_obj, Addr avma_obj,
|
||||
|
||||
if (VG_(clo_verbosity) > 0) {
|
||||
VG_(message)(Vg_UserMsg, "LOAD_PDB_DEBUGINFO: done: "
|
||||
"%lu syms, %lu src locs, %lu fpo recs\n",
|
||||
di->symtab_used, di->loctab_used, di->fpo_size);
|
||||
"%lu syms, %lu src locs, "
|
||||
"%lu src locs, %lu fpo recs\n",
|
||||
di->symtab_used, di->loctab_used,
|
||||
di->inltab_used, di->fpo_size);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1313,6 +1316,167 @@ struct _DebugInfoMapping* ML_(find_rx_mapping) ( struct _DebugInfo* di,
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/*------------------------------------------------------------*/
|
||||
/*--- Types and functions for inlined IP cursor ---*/
|
||||
/*------------------------------------------------------------*/
|
||||
struct _InlIPCursor {
|
||||
Addr eip; // Cursor used to describe calls at eip.
|
||||
DebugInfo* di; // DebugInfo describing inlined calls at eip
|
||||
|
||||
Word inltab_lopos; // The inlined fn calls covering eip are in
|
||||
Word inltab_hipos; // di->inltab[inltab_lopos..inltab_hipos].
|
||||
// Note that not all inlined fn calls in this range
|
||||
// are necessarily covering eip.
|
||||
|
||||
Int curlevel; // Current level to describe.
|
||||
// 0 means to describe eip itself.
|
||||
Word cur_inltab; // inltab pos for call inlined at current level.
|
||||
Word next_inltab; // inltab pos for call inlined at next (towards main)
|
||||
// level.
|
||||
};
|
||||
|
||||
static Bool is_top(InlIPCursor *iipc)
|
||||
{
|
||||
return !iipc || iipc->cur_inltab == -1;
|
||||
}
|
||||
|
||||
static Bool is_bottom(InlIPCursor *iipc)
|
||||
{
|
||||
return !iipc || iipc->next_inltab == -1;
|
||||
}
|
||||
|
||||
Bool VG_(next_IIPC)(InlIPCursor *iipc)
|
||||
{
|
||||
Word i;
|
||||
DiInlLoc *hinl = NULL;
|
||||
Word hinl_pos = -1;
|
||||
DebugInfo *di;
|
||||
|
||||
if (iipc == NULL)
|
||||
return False;
|
||||
|
||||
if (iipc->curlevel <= 0) {
|
||||
iipc->curlevel--;
|
||||
return False;
|
||||
}
|
||||
|
||||
di = iipc->di;
|
||||
for (i = iipc->inltab_lopos; i <= iipc->inltab_hipos; i++) {
|
||||
if (di->inltab[i].addr_lo <= iipc->eip
|
||||
&& iipc->eip < di->inltab[i].addr_hi
|
||||
&& di->inltab[i].level < iipc->curlevel
|
||||
&& (!hinl || hinl->level < di->inltab[i].level)) {
|
||||
hinl = &di->inltab[i];
|
||||
hinl_pos = i;
|
||||
}
|
||||
}
|
||||
|
||||
iipc->cur_inltab = iipc->next_inltab;
|
||||
iipc->next_inltab = hinl_pos;
|
||||
if (iipc->next_inltab < 0)
|
||||
iipc->curlevel = 0; // no inlined call anymore, describe eip itself
|
||||
else
|
||||
iipc->curlevel = di->inltab[iipc->next_inltab].level;
|
||||
|
||||
return True;
|
||||
}
|
||||
|
||||
/* Forward */
|
||||
static void search_all_loctabs ( Addr ptr, /*OUT*/DebugInfo** pdi,
|
||||
/*OUT*/Word* locno );
|
||||
|
||||
/* Returns the position after which eip would be inserted in inltab.
|
||||
(-1 if eip should be inserted before position 0).
|
||||
This is the highest position with an addr_lo <= eip.
|
||||
As inltab is sorted on addr_lo, dichotomic search can be done
|
||||
(note that inltab might have duplicates addr_lo). */
|
||||
static Word inltab_insert_pos (DebugInfo *di, Addr eip)
|
||||
{
|
||||
Word mid,
|
||||
lo = 0,
|
||||
hi = di->inltab_used-1;
|
||||
while (lo <= hi) {
|
||||
mid = (lo + hi) / 2;
|
||||
if (eip < di->inltab[mid].addr_lo) { hi = mid-1; continue; }
|
||||
if (eip > di->inltab[mid].addr_lo) { lo = mid+1; continue; }
|
||||
lo = mid; break;
|
||||
}
|
||||
|
||||
while (lo <= di->inltab_used-1 && di->inltab[lo].addr_lo <= eip)
|
||||
lo++;
|
||||
#if 0
|
||||
for (mid = 0; mid <= di->inltab_used-1; mid++)
|
||||
if (eip < di->inltab[mid].addr_lo)
|
||||
break;
|
||||
vg_assert (lo - 1 == mid - 1);
|
||||
#endif
|
||||
return lo - 1;
|
||||
}
|
||||
|
||||
InlIPCursor* VG_(new_IIPC)(Addr eip)
|
||||
{
|
||||
DebugInfo* di;
|
||||
Word locno;
|
||||
Word i;
|
||||
InlIPCursor *ret;
|
||||
Bool avail;
|
||||
|
||||
if (!VG_(clo_read_inline_info))
|
||||
return NULL; // No way we can find inlined calls.
|
||||
|
||||
/* Search the DebugInfo for eip */
|
||||
search_all_loctabs ( eip, &di, &locno );
|
||||
if (di == NULL || di->inltab_used == 0)
|
||||
return NULL; // No di (with inltab) containing eip.
|
||||
|
||||
/* Search the entry in di->inltab with the highest addr_lo that
|
||||
contains eip. */
|
||||
/* We start from the highest pos in inltab after which eip would
|
||||
be inserted. */
|
||||
for (i = inltab_insert_pos (di, eip); i >= 0; i--) {
|
||||
if (di->inltab[i].addr_lo <= eip && eip < di->inltab[i].addr_hi) {
|
||||
break;
|
||||
}
|
||||
/* Stop the backward scan when reaching an addr_lo which
|
||||
cannot anymore contain eip : we know that all ranges before
|
||||
i also cannot contain eip. */
|
||||
if (di->inltab[i].addr_lo < eip - di->maxinl_codesz)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (i < 0)
|
||||
return NULL; // No entry containing eip.
|
||||
|
||||
/* We have found the highest entry containing eip.
|
||||
Build a cursor. */
|
||||
ret = ML_(dinfo_zalloc) ("dinfo.new_IIPC", sizeof(*ret));
|
||||
ret->eip = eip;
|
||||
ret->di = di;
|
||||
ret->inltab_hipos = i;
|
||||
for (i = ret->inltab_hipos - 1; i >= 0; i--) {
|
||||
|
||||
if (di->inltab[i].addr_lo < eip - di->maxinl_codesz)
|
||||
break; /* Similar stop backward scan logic as above. */
|
||||
}
|
||||
ret->inltab_lopos = i + 1;
|
||||
ret->curlevel = MAX_LEVEL;
|
||||
ret->cur_inltab = -1;
|
||||
ret->next_inltab = -1;
|
||||
|
||||
/* MAX_LEVEL is higher than any stored level. We can use
|
||||
VG_(next_IIPC) to get to the 'real' first highest call level. */
|
||||
avail = VG_(next_IIPC) (ret);
|
||||
vg_assert (avail);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
void VG_(delete_IIPC)(InlIPCursor *iipc)
|
||||
{
|
||||
if (iipc)
|
||||
ML_(dinfo_free)( iipc );
|
||||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------*/
|
||||
/*--- Use of symbol table & location info to create ---*/
|
||||
@ -1544,15 +1708,27 @@ Bool VG_(get_fnname_raw) ( Addr a, HChar* buf, Int nbuf )
|
||||
/* This is only available to core... don't demangle C++ names, but do
|
||||
do Z-demangling and below-main-renaming, match anywhere in function, and
|
||||
don't show offsets. */
|
||||
Bool VG_(get_fnname_no_cxx_demangle) ( Addr a, HChar* buf, Int nbuf )
|
||||
Bool VG_(get_fnname_no_cxx_demangle) ( Addr a, HChar* buf, Int nbuf,
|
||||
InlIPCursor* iipc )
|
||||
{
|
||||
return get_sym_name ( /*C++-demangle*/False, /*Z-demangle*/True,
|
||||
/*below-main-renaming*/True,
|
||||
a, buf, nbuf,
|
||||
/*match_anywhere_in_fun*/True,
|
||||
/*show offset?*/False,
|
||||
/*text syms only*/True,
|
||||
/*offsetP*/NULL );
|
||||
if (is_bottom(iipc)) {
|
||||
// At the bottom (towards main), we describe the fn at eip.
|
||||
return get_sym_name ( /*C++-demangle*/False, /*Z-demangle*/True,
|
||||
/*below-main-renaming*/True,
|
||||
a, buf, nbuf,
|
||||
/*match_anywhere_in_fun*/True,
|
||||
/*show offset?*/False,
|
||||
/*text syms only*/True,
|
||||
/*offsetP*/NULL );
|
||||
} else {
|
||||
const DiInlLoc *next_inl = iipc && iipc->next_inltab >= 0
|
||||
? & iipc->di->inltab[iipc->next_inltab]
|
||||
: NULL;
|
||||
vg_assert (next_inl);
|
||||
// The function we are in is called by next_inl.
|
||||
VG_(snprintf)(buf, nbuf, "%s", next_inl->inlinedfn);
|
||||
return True;
|
||||
}
|
||||
}
|
||||
|
||||
/* mips-linux only: find the offset of current address. This is needed for
|
||||
@ -1873,7 +2049,7 @@ static Int putStrEsc ( Int n, Int n_buf, Int count, HChar* buf, HChar* str )
|
||||
return n;
|
||||
}
|
||||
|
||||
HChar* VG_(describe_IP)(Addr eip, HChar* buf, Int n_buf)
|
||||
HChar* VG_(describe_IP)(Addr eip, HChar* buf, Int n_buf, InlIPCursor *iipc)
|
||||
{
|
||||
# define APPEND(_str) \
|
||||
n = putStr(n, n_buf, buf, _str)
|
||||
@ -1885,6 +2061,8 @@ HChar* VG_(describe_IP)(Addr eip, HChar* buf, Int n_buf)
|
||||
HChar ibuf[50];
|
||||
Int n = 0;
|
||||
|
||||
vg_assert (!iipc || iipc->eip == eip);
|
||||
|
||||
static HChar buf_fn[BUF_LEN];
|
||||
static HChar buf_obj[BUF_LEN];
|
||||
static HChar buf_srcloc[BUF_LEN];
|
||||
@ -1892,16 +2070,57 @@ HChar* VG_(describe_IP)(Addr eip, HChar* buf, Int n_buf)
|
||||
buf_fn[0] = buf_obj[0] = buf_srcloc[0] = buf_dirname[0] = 0;
|
||||
|
||||
Bool know_dirinfo = False;
|
||||
Bool know_fnname = VG_(clo_sym_offsets)
|
||||
? VG_(get_fnname_w_offset) (eip, buf_fn, BUF_LEN)
|
||||
: VG_(get_fnname) (eip, buf_fn, BUF_LEN);
|
||||
Bool know_objname = VG_(get_objname)(eip, buf_obj, BUF_LEN);
|
||||
Bool know_srcloc = VG_(get_filename_linenum)(
|
||||
eip,
|
||||
buf_srcloc, BUF_LEN,
|
||||
buf_dirname, BUF_LEN, &know_dirinfo,
|
||||
&lineno
|
||||
);
|
||||
Bool know_fnname;
|
||||
Bool know_objname;
|
||||
Bool know_srcloc;
|
||||
|
||||
if (is_bottom(iipc)) {
|
||||
// At the bottom (towards main), we describe the fn at eip.
|
||||
know_fnname = VG_(clo_sym_offsets)
|
||||
? VG_(get_fnname_w_offset) (eip, buf_fn, BUF_LEN)
|
||||
: VG_(get_fnname) (eip, buf_fn, BUF_LEN);
|
||||
} else {
|
||||
const DiInlLoc *next_inl = iipc && iipc->next_inltab >= 0
|
||||
? & iipc->di->inltab[iipc->next_inltab]
|
||||
: NULL;
|
||||
vg_assert (next_inl);
|
||||
// The function we are in is called by next_inl.
|
||||
VG_(snprintf)(buf_fn, BUF_LEN, "%s", next_inl->inlinedfn);
|
||||
know_fnname = True;
|
||||
|
||||
// INLINED????
|
||||
// ??? Can we compute an offset for an inlined fn call ?
|
||||
// ??? Offset from what ? The beginning of the inl info ?
|
||||
// ??? But that is not necessarily the beginning of the fn
|
||||
// ??? as e.g. an inlined fn call can be in several ranges.
|
||||
// ??? Currently never showing an offset.
|
||||
}
|
||||
|
||||
know_objname = VG_(get_objname)(eip, buf_obj, BUF_LEN);
|
||||
|
||||
if (is_top(iipc)) {
|
||||
// The source for the highest level is in the loctab entry.
|
||||
know_srcloc = VG_(get_filename_linenum)(
|
||||
eip,
|
||||
buf_srcloc, BUF_LEN,
|
||||
buf_dirname, BUF_LEN, &know_dirinfo,
|
||||
&lineno
|
||||
);
|
||||
} else {
|
||||
const DiInlLoc *cur_inl = iipc && iipc->cur_inltab >= 0
|
||||
? & iipc->di->inltab[iipc->cur_inltab]
|
||||
: NULL;
|
||||
vg_assert (cur_inl);
|
||||
// The filename and lineno for the inlined fn caller is in cur_inl.
|
||||
VG_(snprintf) (buf_srcloc, BUF_LEN, cur_inl->filename);
|
||||
lineno = cur_inl->lineno;
|
||||
|
||||
know_dirinfo = False; //INLINED TBD
|
||||
|
||||
know_srcloc = True;
|
||||
}
|
||||
|
||||
|
||||
buf_fn [ sizeof(buf_fn)-1 ] = 0;
|
||||
buf_obj [ sizeof(buf_obj)-1 ] = 0;
|
||||
buf_srcloc [ sizeof(buf_srcloc)-1 ] = 0;
|
||||
|
||||
@ -119,6 +119,29 @@ typedef
|
||||
}
|
||||
DiLoc;
|
||||
|
||||
#define LEVEL_BITS (32 - LINENO_BITS)
|
||||
#define MAX_LEVEL ((1 << LEVEL_BITS) - 1)
|
||||
|
||||
/* A structure to hold addr-to-inlined fn info. There
|
||||
can be a lot of these, hence the dense packing. */
|
||||
typedef
|
||||
struct {
|
||||
/* Word 1 */
|
||||
Addr addr_lo; /* lowest address for inlined fn */
|
||||
/* Word 2 */
|
||||
Addr addr_hi; /* highest address following the inlined fn */
|
||||
/* Word 3 */
|
||||
const HChar* inlinedfn; /* inlined function name */
|
||||
/* Word 4 */
|
||||
const HChar* filename; /* caller source filename */
|
||||
/* Word 5 */
|
||||
const HChar* dirname; /* caller source directory name */
|
||||
/* Word 6 */
|
||||
UInt lineno:LINENO_BITS; /* caller line number */
|
||||
UShort level:LEVEL_BITS; /* level of inlining */
|
||||
}
|
||||
DiInlLoc;
|
||||
|
||||
/* --------------------- CF INFO --------------------- */
|
||||
|
||||
/* DiCfSI: a structure to summarise DWARF2/3 CFA info for the code
|
||||
@ -790,6 +813,13 @@ struct _DebugInfo {
|
||||
DiLoc* loctab;
|
||||
UWord loctab_used;
|
||||
UWord loctab_size;
|
||||
/* An expandable array of inlined fn info.
|
||||
maxinl_codesz is the biggest inlined piece of code
|
||||
in inltab (i.e. the max of 'addr_hi - addr_lo'. */
|
||||
DiInlLoc* inltab;
|
||||
UWord inltab_used;
|
||||
UWord inltab_size;
|
||||
SizeT maxinl_codesz;
|
||||
/* An expandable array of CFI summary info records. Also includes
|
||||
summary address bounds, showing the min and max address covered
|
||||
by any of the records, as an aid to fast searching. And, if the
|
||||
@ -874,6 +904,21 @@ void ML_(addLineInfo) ( struct _DebugInfo* di,
|
||||
const HChar* dirname, /* NULL is allowable */
|
||||
Addr this, Addr next, Int lineno, Int entry);
|
||||
|
||||
/* Add a call inlined record to a DebugInfo.
|
||||
A call to the below means that inlinedfn code has been
|
||||
inlined, resulting in code from [addr_lo, addr_hi[.
|
||||
Note that addr_hi is excluded, i.e. is not part of the inlined code.
|
||||
The call that caused this inlining is in filename/dirname/lineno
|
||||
In case of nested inlining, a small level indicates the call
|
||||
is closer to main that a call with a higher level. */
|
||||
extern
|
||||
void ML_(addInlInfo) ( struct _DebugInfo* di,
|
||||
Addr addr_lo, Addr addr_hi,
|
||||
const HChar* inlinedfn,
|
||||
const HChar* filename,
|
||||
const HChar* dirname, /* NULL is allowable */
|
||||
Int lineno, UShort level);
|
||||
|
||||
/* Add a CFI summary record. The supplied DiCfSI is copied. */
|
||||
extern void ML_(addDiCfSI) ( struct _DebugInfo* di, DiCfSI* cfsi );
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -1447,6 +1447,7 @@ Bool ML_(read_elf_debug_info) ( struct _DebugInfo* di )
|
||||
vg_assert(di->fsm.filename);
|
||||
vg_assert(!di->symtab);
|
||||
vg_assert(!di->loctab);
|
||||
vg_assert(!di->inltab);
|
||||
vg_assert(!di->cfsi);
|
||||
vg_assert(!di->cfsi_exprs);
|
||||
vg_assert(!di->strpool);
|
||||
@ -2801,11 +2802,11 @@ Bool ML_(read_elf_debug_info) ( struct _DebugInfo* di )
|
||||
debug_str_escn,
|
||||
debug_str_alt_escn );
|
||||
/* The new reader: read the DIEs in .debug_info to acquire
|
||||
information on variable types and locations. But only if
|
||||
the tool asks for it, or the user requests it on the
|
||||
command line. */
|
||||
if (VG_(needs).var_info /* the tool requires it */
|
||||
|| VG_(clo_read_var_info) /* the user asked for it */) {
|
||||
information on variable types and locations or inline info.
|
||||
But only if the tool asks for it, or the user requests it on
|
||||
the command line. */
|
||||
if (VG_(clo_read_var_info) /* the user or tool asked for it */
|
||||
|| VG_(clo_read_inline_info)) {
|
||||
ML_(new_dwarf3_reader)(
|
||||
di, debug_info_escn, debug_types_escn,
|
||||
debug_abbv_escn, debug_line_escn,
|
||||
@ -2834,7 +2835,7 @@ Bool ML_(read_elf_debug_info) ( struct _DebugInfo* di )
|
||||
showing the number of variables read for each object.
|
||||
(Currently disabled -- is a sanity-check mechanism for
|
||||
exp-sgcheck.) */
|
||||
if (0 && (VG_(needs).var_info || VG_(clo_read_var_info))) {
|
||||
if (0 && VG_(clo_read_var_info)) {
|
||||
UWord nVars = 0;
|
||||
if (di->varinfo) {
|
||||
for (j = 0; j < VG_(sizeXA)(di->varinfo); j++) {
|
||||
|
||||
@ -1128,11 +1128,11 @@ Bool ML_(read_macho_debug_info)( struct _DebugInfo* di )
|
||||
DiSlice_INVALID /* ALT .debug_str */ );
|
||||
|
||||
/* The new reader: read the DIEs in .debug_info to acquire
|
||||
information on variable types and locations. But only if
|
||||
the tool asks for it, or the user requests it on the
|
||||
command line. */
|
||||
if (VG_(needs).var_info /* the tool requires it */
|
||||
|| VG_(clo_read_var_info) /* the user asked for it */) {
|
||||
information on variable types and locations or inline info.
|
||||
But only if the tool asks for it, or the user requests it on
|
||||
the command line. */
|
||||
if (VG_(clo_read_var_info) /* the user or tool asked for it */
|
||||
|| VG_(clo_read_inline_info)) {
|
||||
ML_(new_dwarf3_reader)(
|
||||
di, debug_info_mscn,
|
||||
DiSlice_INVALID, /* .debug_types */
|
||||
|
||||
@ -450,6 +450,115 @@ void ML_(addLineInfo) ( struct _DebugInfo* di,
|
||||
addLoc ( di, &loc );
|
||||
}
|
||||
|
||||
/* Add an inlined call info to the inlined call table.
|
||||
*/
|
||||
static void addInl ( struct _DebugInfo* di, DiInlLoc* inl )
|
||||
{
|
||||
UInt new_sz, i;
|
||||
DiInlLoc* new_tab;
|
||||
|
||||
/* empty inl should have been ignored earlier */
|
||||
vg_assert(inl->addr_lo < inl->addr_hi);
|
||||
|
||||
if (di->inltab_used == di->inltab_size) {
|
||||
new_sz = 2 * di->inltab_size;
|
||||
if (new_sz == 0) new_sz = 500;
|
||||
new_tab = ML_(dinfo_zalloc)( "di.storage.addInl.1",
|
||||
new_sz * sizeof(DiInlLoc) );
|
||||
if (di->inltab != NULL) {
|
||||
for (i = 0; i < di->inltab_used; i++)
|
||||
new_tab[i] = di->inltab[i];
|
||||
ML_(dinfo_free)(di->inltab);
|
||||
}
|
||||
di->inltab = new_tab;
|
||||
di->inltab_size = new_sz;
|
||||
}
|
||||
|
||||
di->inltab[di->inltab_used] = *inl;
|
||||
if (inl->addr_hi - inl->addr_lo > di->maxinl_codesz)
|
||||
di->maxinl_codesz = inl->addr_hi - inl->addr_lo;
|
||||
di->inltab_used++;
|
||||
vg_assert(di->inltab_used <= di->inltab_size);
|
||||
}
|
||||
|
||||
|
||||
/* Resize the InlTab (inlined call table) to save memory, by removing
|
||||
(and, potentially, allowing m_mallocfree to unmap) any unused space
|
||||
at the end of the table.
|
||||
*/
|
||||
static void shrinkInlTab ( struct _DebugInfo* di )
|
||||
{
|
||||
DiInlLoc* new_tab;
|
||||
UWord new_sz = di->inltab_used;
|
||||
if (new_sz == di->inltab_size) return;
|
||||
vg_assert(new_sz < di->inltab_size);
|
||||
|
||||
new_tab = ML_(dinfo_zalloc)( "di.storage.shrinkInlTab",
|
||||
new_sz * sizeof(DiInlLoc) );
|
||||
VG_(memcpy)(new_tab, di->inltab, new_sz * sizeof(DiInlLoc));
|
||||
|
||||
ML_(dinfo_free)(di->inltab);
|
||||
di->inltab = new_tab;
|
||||
di->inltab_size = new_sz;
|
||||
}
|
||||
|
||||
/* Top-level place to call to add a addr-to-inlined fn info. */
|
||||
void ML_(addInlInfo) ( struct _DebugInfo* di,
|
||||
Addr addr_lo, Addr addr_hi,
|
||||
const HChar* inlinedfn,
|
||||
const HChar* filename,
|
||||
const HChar* dirname, /* NULL is allowable */
|
||||
Int lineno, UShort level)
|
||||
{
|
||||
DiInlLoc inl;
|
||||
|
||||
/* Similar paranoia as in ML_(addLineInfo). Unclear if needed. */
|
||||
if (addr_lo >= addr_hi) {
|
||||
if (VG_(clo_verbosity) > 2) {
|
||||
VG_(message)(Vg_DebugMsg,
|
||||
"warning: inlined info addresses out of order "
|
||||
"at: 0x%lx 0x%lx\n", addr_lo, addr_hi);
|
||||
}
|
||||
addr_hi = addr_lo + 1;
|
||||
}
|
||||
|
||||
vg_assert(lineno >= 0);
|
||||
if (lineno > MAX_LINENO) {
|
||||
static Bool complained = False;
|
||||
if (!complained) {
|
||||
complained = True;
|
||||
VG_(message)(Vg_UserMsg,
|
||||
"warning: ignoring inlined call info entry with "
|
||||
"huge line number (%d)\n", lineno);
|
||||
VG_(message)(Vg_UserMsg,
|
||||
" Can't handle line numbers "
|
||||
"greater than %d, sorry\n", MAX_LINENO);
|
||||
VG_(message)(Vg_UserMsg,
|
||||
"(Nb: this message is only shown once)\n");
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
// code resulting from inlining of inlinedfn:
|
||||
inl.addr_lo = addr_lo;
|
||||
inl.addr_hi = addr_hi;
|
||||
inl.inlinedfn = inlinedfn;
|
||||
// caller:
|
||||
inl.filename = filename;
|
||||
inl.dirname = dirname;
|
||||
inl.lineno = lineno;
|
||||
inl.level = level;
|
||||
|
||||
if (0) VG_(message)
|
||||
(Vg_DebugMsg,
|
||||
"addInlInfo: fn %s inlined as addr_lo %#lx,addr_hi %#lx,"
|
||||
"caller %s:%d (dir %s)\n",
|
||||
inlinedfn, addr_lo, addr_hi, filename, lineno,
|
||||
dirname ? dirname : "???");
|
||||
|
||||
addInl ( di, &inl );
|
||||
}
|
||||
|
||||
|
||||
/* Top-level place to call to add a CFI summary record. The supplied
|
||||
DiCfSI is copied. */
|
||||
@ -1701,6 +1810,45 @@ static void canonicaliseLoctab ( struct _DebugInfo* di )
|
||||
shrinkLocTab(di);
|
||||
}
|
||||
|
||||
/* Sort the inlined call table by starting address. Mash the table around
|
||||
so as to establish the property that addresses are in order.
|
||||
This facilitates using binary search to map addresses to locations when
|
||||
we come to query the table.
|
||||
Note : ranges can overlap, multiple ranges can start at an address,
|
||||
multiple ranges can end at an address.
|
||||
*/
|
||||
static Int compare_DiInlLoc ( const void* va, const void* vb )
|
||||
{
|
||||
const DiInlLoc* a = va;
|
||||
const DiInlLoc* b = vb;
|
||||
if (a->addr_lo < b->addr_lo) return -1;
|
||||
if (a->addr_lo > b->addr_lo) return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void canonicaliseInltab ( struct _DebugInfo* di )
|
||||
{
|
||||
Word i;
|
||||
|
||||
if (di->inltab_used == 0)
|
||||
return;
|
||||
|
||||
/* Sort by start address. */
|
||||
VG_(ssort)(di->inltab, di->inltab_used,
|
||||
sizeof(*di->inltab), compare_DiInlLoc);
|
||||
|
||||
/* Ensure relevant postconditions hold. */
|
||||
for (i = 0; i < ((Word)di->inltab_used)-1; i++) {
|
||||
/* No zero-sized inlined call. */
|
||||
vg_assert(di->inltab[i].addr_lo < di->inltab[i].addr_hi);
|
||||
/* In order, but we can have duplicates and overlapping ranges. */
|
||||
vg_assert(di->inltab[i].addr_lo <= di->inltab[i+1].addr_lo);
|
||||
}
|
||||
|
||||
/* Free up unused space at the end of the table. */
|
||||
shrinkInlTab(di);
|
||||
}
|
||||
|
||||
|
||||
/* Sort the call-frame-info table by starting address. Mash the table
|
||||
around so as to establish the property that addresses are in order
|
||||
@ -1815,6 +1963,7 @@ void ML_(canonicaliseTables) ( struct _DebugInfo* di )
|
||||
{
|
||||
canonicaliseSymtab ( di );
|
||||
canonicaliseLoctab ( di );
|
||||
canonicaliseInltab ( di );
|
||||
ML_(canonicaliseCFI) ( di );
|
||||
canonicaliseVarInfo ( di );
|
||||
if (di->strpool)
|
||||
|
||||
@ -323,28 +323,36 @@ static Bool eq_Error ( VgRes res, Error* e1, Error* e2 )
|
||||
static void printSuppForIp_XML(UInt n, Addr ip, void* uu_opaque)
|
||||
{
|
||||
static HChar buf[ERRTXT_LEN];
|
||||
if ( VG_(get_fnname_no_cxx_demangle) (ip, buf, ERRTXT_LEN) ) {
|
||||
VG_(printf_xml)(" <sframe> <fun>%pS</fun> </sframe>\n", buf);
|
||||
} else
|
||||
if ( VG_(get_objname)(ip, buf, ERRTXT_LEN) ) {
|
||||
VG_(printf_xml)(" <sframe> <obj>%pS</obj> </sframe>\n", buf);
|
||||
} else {
|
||||
VG_(printf_xml)(" <sframe> <obj>*</obj> </sframe>\n");
|
||||
}
|
||||
InlIPCursor* iipc = VG_(new_IIPC)(ip);
|
||||
do {
|
||||
if ( VG_(get_fnname_no_cxx_demangle) (ip, buf, ERRTXT_LEN, iipc) ) {
|
||||
VG_(printf_xml)(" <sframe> <fun>%pS</fun> </sframe>\n", buf);
|
||||
} else
|
||||
if ( VG_(get_objname)(ip, buf, ERRTXT_LEN) ) {
|
||||
VG_(printf_xml)(" <sframe> <obj>%pS</obj> </sframe>\n", buf);
|
||||
} else {
|
||||
VG_(printf_xml)(" <sframe> <obj>*</obj> </sframe>\n");
|
||||
}
|
||||
} while (VG_(next_IIPC)(iipc));
|
||||
VG_(delete_IIPC)(iipc);
|
||||
}
|
||||
|
||||
static void printSuppForIp_nonXML(UInt n, Addr ip, void* textV)
|
||||
{
|
||||
static HChar buf[ERRTXT_LEN];
|
||||
XArray* /* of HChar */ text = (XArray*)textV;
|
||||
if ( VG_(get_fnname_no_cxx_demangle) (ip, buf, ERRTXT_LEN) ) {
|
||||
VG_(xaprintf)(text, " fun:%s\n", buf);
|
||||
} else
|
||||
if ( VG_(get_objname)(ip, buf, ERRTXT_LEN) ) {
|
||||
VG_(xaprintf)(text, " obj:%s\n", buf);
|
||||
} else {
|
||||
VG_(xaprintf)(text, " obj:*\n");
|
||||
}
|
||||
InlIPCursor* iipc = VG_(new_IIPC)(ip);
|
||||
do {
|
||||
if ( VG_(get_fnname_no_cxx_demangle) (ip, buf, ERRTXT_LEN, iipc) ) {
|
||||
VG_(xaprintf)(text, " fun:%s\n", buf);
|
||||
} else
|
||||
if ( VG_(get_objname)(ip, buf, ERRTXT_LEN) ) {
|
||||
VG_(xaprintf)(text, " obj:%s\n", buf);
|
||||
} else {
|
||||
VG_(xaprintf)(text, " obj:*\n");
|
||||
}
|
||||
} while (VG_(next_IIPC)(iipc));
|
||||
VG_(delete_IIPC)(iipc);
|
||||
}
|
||||
|
||||
/* Generate a suppression for an error, either in text or XML mode.
|
||||
@ -1472,6 +1480,8 @@ static Bool supploc_IsQuery ( const void* supplocV )
|
||||
with the IP function name or with the IP object name.
|
||||
First time the fun or obj name is needed for an IP member
|
||||
of a stack trace, it will be computed and stored in names.
|
||||
Also, if the IP corresponds to one or more inlined function calls,
|
||||
the inlined function names are expanded.
|
||||
The IPtoFunOrObjCompleter type is designed to minimise the nr of
|
||||
allocations and the nr of debuginfo search. */
|
||||
typedef
|
||||
@ -1479,13 +1489,49 @@ typedef
|
||||
StackTrace ips; // stack trace we are lazily completing.
|
||||
UWord n_ips; // nr of elements in ips.
|
||||
|
||||
// VG_(generic_match) calls haveInputInpC to check
|
||||
// for the presence of an input element identified by ixInput
|
||||
// (i.e. a number that identifies the ixInput element of the
|
||||
// input sequence). It calls supp_pattEQinp to match this input
|
||||
// element with a pattern.
|
||||
// When inlining info is used to provide inlined function calls
|
||||
// in stacktraces, one IP in ips can be expanded in several
|
||||
// function names. So, each time input (or presence of input)
|
||||
// is requested by VG_(generic_match), we will expand
|
||||
// more IP of ips till we have expanded enough to reach the
|
||||
// input element requested (or we cannot expand anymore).
|
||||
|
||||
UWord n_ips_expanded;
|
||||
// n_ips_expanded maintains the nr of elements in ips that we have
|
||||
// already expanded.
|
||||
UWord n_expanded;
|
||||
// n_expanded maintains the nr of elements resulting from the expansion
|
||||
// of the n_ips_expanded IPs. Without inlined function calls,
|
||||
// n_expanded == n_ips_expanded. With inlining info,
|
||||
// n_expanded >= n_ips_expanded.
|
||||
|
||||
Int* n_offsets_per_ip;
|
||||
// n_offsets_per_ip[i] gives the nr of offsets in fun_offsets and obj_offsets
|
||||
// resulting of the expansion of ips[i].
|
||||
// The sum of all n_expanded_per_ip must be equal to n_expanded.
|
||||
// This array allows to retrieve the position in ips corresponding to an ixInput.
|
||||
|
||||
// size (in elements) of fun_offsets and obj_offsets.
|
||||
// (fun|obj)_offsets are reallocated if more space is needed
|
||||
// to expand an IP.
|
||||
UWord sz_offsets;
|
||||
|
||||
Int* fun_offsets;
|
||||
// fun_offsets[i] is the offset in names where the
|
||||
// function name for ips[i] is located.
|
||||
// An offset -1 means the function name is not yet completed.
|
||||
// fun_offsets[ixInput] is the offset in names where the
|
||||
// function name for the ixInput element of the input sequence
|
||||
// can be found. As one IP of ips can be expanded in several
|
||||
// function calls due to inlined function calls, we can have more
|
||||
// elements in fun_offsets than in ips.
|
||||
// An offset -1 means the function name has not yet been computed.
|
||||
Int* obj_offsets;
|
||||
// Similarly, obj_offsets[i] gives the offset for the
|
||||
// object name for ips[i] (-1 meaning object name not yet completed).
|
||||
// Similarly, obj_offsets[ixInput] gives the offset for the
|
||||
// object name for ips[ixInput]
|
||||
// (-1 meaning object name not yet been computed).
|
||||
|
||||
// All function names and object names will be concatenated
|
||||
// in names. names is reallocated on demand.
|
||||
@ -1499,22 +1545,37 @@ typedef
|
||||
static void clearIPtoFunOrObjCompleter
|
||||
(IPtoFunOrObjCompleter* ip2fo)
|
||||
{
|
||||
if (ip2fo->fun_offsets) VG_(free)(ip2fo->fun_offsets);
|
||||
if (ip2fo->obj_offsets) VG_(free)(ip2fo->obj_offsets);
|
||||
if (ip2fo->names) VG_(free)(ip2fo->names);
|
||||
if (ip2fo->n_offsets_per_ip) VG_(free)(ip2fo->n_offsets_per_ip);
|
||||
if (ip2fo->fun_offsets) VG_(free)(ip2fo->fun_offsets);
|
||||
if (ip2fo->obj_offsets) VG_(free)(ip2fo->obj_offsets);
|
||||
if (ip2fo->names) VG_(free)(ip2fo->names);
|
||||
}
|
||||
|
||||
/* foComplete returns the function name or object name for IP.
|
||||
If needFun, returns the function name for IP
|
||||
else returns the object name for IP.
|
||||
The function name or object name will be computed and added in
|
||||
names if not yet done.
|
||||
IP must be equal to focompl->ipc[ixIP]. */
|
||||
static HChar* foComplete(IPtoFunOrObjCompleter* ip2fo,
|
||||
Addr IP, Int ixIP, Bool needFun)
|
||||
/* Grow ip2fo->names to ensure we have ERRTXT_LEN characters available
|
||||
in ip2fo->names and returns a pointer to the first free char. */
|
||||
static HChar* grow_names(IPtoFunOrObjCompleter* ip2fo)
|
||||
{
|
||||
vg_assert (ixIP < ip2fo->n_ips);
|
||||
vg_assert (IP == ip2fo->ips[ixIP]);
|
||||
if (ip2fo->names_szB
|
||||
< ip2fo->names_free + ERRTXT_LEN) {
|
||||
ip2fo->names
|
||||
= VG_(realloc)("foc_names",
|
||||
ip2fo->names,
|
||||
ip2fo->names_szB + ERRTXT_LEN);
|
||||
ip2fo->names_szB += ERRTXT_LEN;
|
||||
}
|
||||
return ip2fo->names + ip2fo->names_free;
|
||||
}
|
||||
|
||||
/* foComplete returns the function name or object name for ixInput.
|
||||
If needFun, returns the function name for this input
|
||||
else returns the object name for this input.
|
||||
The function name or object name will be computed and added in
|
||||
names if not yet done. */
|
||||
static HChar* foComplete(IPtoFunOrObjCompleter* ip2fo,
|
||||
Int ixInput, Bool needFun)
|
||||
{
|
||||
vg_assert (ixInput < ip2fo->n_expanded);
|
||||
vg_assert (VG_(clo_read_inline_info) || ixInput < ip2fo->n_ips);
|
||||
|
||||
// ptr to the offset array for function offsets (if needFun)
|
||||
// or object offsets (if !needFun).
|
||||
@ -1524,30 +1585,13 @@ static HChar* foComplete(IPtoFunOrObjCompleter* ip2fo,
|
||||
else
|
||||
offsets = &ip2fo->obj_offsets;
|
||||
|
||||
// Allocate offsets if not yet done.
|
||||
if (!*offsets) {
|
||||
Int i;
|
||||
*offsets =
|
||||
VG_(malloc)("foComplete",
|
||||
ip2fo->n_ips * sizeof(Int));
|
||||
for (i = 0; i < ip2fo->n_ips; i++)
|
||||
(*offsets)[i] = -1;
|
||||
}
|
||||
|
||||
// Complete Fun name or Obj name for IP if not yet done.
|
||||
if ((*offsets)[ixIP] == -1) {
|
||||
/* Ensure we have ERRTXT_LEN characters available in names */
|
||||
if (ip2fo->names_szB
|
||||
< ip2fo->names_free + ERRTXT_LEN) {
|
||||
ip2fo->names
|
||||
= VG_(realloc)("foc_names",
|
||||
ip2fo->names,
|
||||
ip2fo->names_szB + ERRTXT_LEN);
|
||||
ip2fo->names_szB += ERRTXT_LEN;
|
||||
}
|
||||
HChar* caller_name = ip2fo->names + ip2fo->names_free;
|
||||
(*offsets)[ixIP] = ip2fo->names_free;
|
||||
if ((*offsets)[ixInput] == -1) {
|
||||
HChar* caller_name = grow_names(ip2fo);
|
||||
(*offsets)[ixInput] = ip2fo->names_free;
|
||||
if (needFun) {
|
||||
// With inline info, fn names must have been completed already.
|
||||
vg_assert (!VG_(clo_read_inline_info));
|
||||
/* Get the function name into 'caller_name', or "???"
|
||||
if unknown. */
|
||||
// Nb: C++-mangled names are used in suppressions. Do, though,
|
||||
@ -1555,28 +1599,140 @@ static HChar* foComplete(IPtoFunOrObjCompleter* ip2fo,
|
||||
// up comparing "malloc" in the suppression against
|
||||
// "_vgrZU_libcZdsoZa_malloc" in the backtrace, and the
|
||||
// two of them need to be made to match.
|
||||
if (!VG_(get_fnname_no_cxx_demangle)(IP, caller_name, ERRTXT_LEN))
|
||||
if (!VG_(get_fnname_no_cxx_demangle)(ip2fo->ips[ixInput],
|
||||
caller_name, ERRTXT_LEN,
|
||||
NULL))
|
||||
VG_(strcpy)(caller_name, "???");
|
||||
} else {
|
||||
/* Get the object name into 'caller_name', or "???"
|
||||
if unknown. */
|
||||
if (!VG_(get_objname)(IP, caller_name, ERRTXT_LEN))
|
||||
UWord i;
|
||||
UWord last_expand_pos_ips = 0;
|
||||
UWord pos_ips;
|
||||
|
||||
/* First get the pos in ips corresponding to ixInput */
|
||||
for (pos_ips = 0; pos_ips < ip2fo->n_expanded; pos_ips++) {
|
||||
last_expand_pos_ips += ip2fo->n_offsets_per_ip[pos_ips];
|
||||
if (ixInput <= last_expand_pos_ips)
|
||||
break;
|
||||
}
|
||||
/* pos_ips is the position in ips corresponding to ixInput.
|
||||
last_expand_pos_ips is the last offset in fun/obj where
|
||||
ips[pos_ips] has been expanded. */
|
||||
|
||||
if (!VG_(get_objname)(ip2fo->ips[pos_ips], caller_name, ERRTXT_LEN))
|
||||
VG_(strcpy)(caller_name, "???");
|
||||
|
||||
// Have all inlined calls pointing at this object name
|
||||
for (i = last_expand_pos_ips - ip2fo->n_offsets_per_ip[pos_ips] - 1;
|
||||
i <= last_expand_pos_ips;
|
||||
i++)
|
||||
ip2fo->obj_offsets[i] = ip2fo->names_free;
|
||||
}
|
||||
ip2fo->names_free += VG_(strlen)(caller_name) + 1;
|
||||
}
|
||||
|
||||
return ip2fo->names + (*offsets)[ixIP];
|
||||
return ip2fo->names + (*offsets)[ixInput];
|
||||
}
|
||||
|
||||
// Grow fun and obj _offsets arrays to have at least n_req elements.
|
||||
// Ensure n_offsets_per_ip is allocated.
|
||||
static void grow_offsets(IPtoFunOrObjCompleter* ip2fo, Int n_req)
|
||||
{
|
||||
Int i;
|
||||
|
||||
// n_offsets_per_ip must always have the size of the ips array
|
||||
if (ip2fo->n_offsets_per_ip == NULL) {
|
||||
ip2fo->n_offsets_per_ip = VG_(malloc)("grow_offsets",
|
||||
ip2fo->n_ips * sizeof(Int));
|
||||
for (i = 0; i < ip2fo->n_ips; i++)
|
||||
ip2fo->n_offsets_per_ip[i] = 0;
|
||||
}
|
||||
|
||||
if (ip2fo->sz_offsets >= n_req)
|
||||
return;
|
||||
|
||||
// Avoid too much re-allocation by allocating at least ip2fo->n_ips
|
||||
// elements and at least a few more elements than the current size.
|
||||
if (n_req < ip2fo->n_ips)
|
||||
n_req = ip2fo->n_ips;
|
||||
if (n_req < ip2fo->sz_offsets + 5)
|
||||
n_req = ip2fo->sz_offsets + 5;
|
||||
|
||||
ip2fo->fun_offsets = VG_(realloc)("grow_offsets", ip2fo->fun_offsets,
|
||||
n_req * sizeof(Int));
|
||||
for (i = ip2fo->sz_offsets; i < n_req; i++)
|
||||
ip2fo->fun_offsets[i] = -1;
|
||||
|
||||
ip2fo->obj_offsets = VG_(realloc)("grow_offsets", ip2fo->obj_offsets,
|
||||
n_req * sizeof(Int));
|
||||
for (i = ip2fo->sz_offsets; i < n_req; i++)
|
||||
ip2fo->obj_offsets[i] = -1;
|
||||
|
||||
ip2fo->sz_offsets = n_req;
|
||||
}
|
||||
|
||||
// Expands more IPs from ip2fo->ips.
|
||||
static void expandInput (IPtoFunOrObjCompleter* ip2fo, UWord ixInput )
|
||||
{
|
||||
while (ip2fo->n_ips_expanded < ip2fo->n_ips
|
||||
&& ip2fo->n_expanded <= ixInput) {
|
||||
if (VG_(clo_read_inline_info)) {
|
||||
// Expand one more IP in one or more calls.
|
||||
const Addr IP = ip2fo->ips[ip2fo->n_ips_expanded];
|
||||
InlIPCursor *iipc;
|
||||
|
||||
iipc = VG_(new_IIPC)(IP);
|
||||
// The only thing we really need is the nr of inlined fn calls
|
||||
// corresponding to the IP we will expand.
|
||||
// However, computing this is mostly the same as finding
|
||||
// the function name. So, let's directly complete the function name.
|
||||
do {
|
||||
HChar* caller_name = grow_names(ip2fo);
|
||||
grow_offsets(ip2fo, ip2fo->n_expanded+1);
|
||||
ip2fo->fun_offsets[ip2fo->n_expanded] = ip2fo->names_free;
|
||||
if (!VG_(get_fnname_no_cxx_demangle)(IP,
|
||||
caller_name, ERRTXT_LEN,
|
||||
iipc))
|
||||
VG_(strcpy)(caller_name, "???");
|
||||
ip2fo->names_free += VG_(strlen)(caller_name) + 1;
|
||||
ip2fo->n_expanded++;
|
||||
ip2fo->n_offsets_per_ip[ip2fo->n_ips_expanded]++;
|
||||
} while (VG_(next_IIPC)(iipc));
|
||||
ip2fo->n_ips_expanded++;
|
||||
VG_(delete_IIPC) (iipc);
|
||||
} else {
|
||||
// Without inlined fn call info, expansion simply
|
||||
// consists in allocating enough elements in (fun|obj)_offsets.
|
||||
// The function or object names themselves will be completed
|
||||
// when requested.
|
||||
Int i;
|
||||
grow_offsets(ip2fo, ip2fo->n_ips);
|
||||
ip2fo->n_ips_expanded = ip2fo->n_ips;
|
||||
ip2fo->n_expanded = ip2fo->n_ips;
|
||||
for (i = 0; i < ip2fo->n_ips; i++)
|
||||
ip2fo->n_offsets_per_ip[i] = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static Bool haveInputInpC (void* inputCompleter, UWord ixInput )
|
||||
{
|
||||
IPtoFunOrObjCompleter* ip2fo = inputCompleter;
|
||||
expandInput(ip2fo, ixInput);
|
||||
return ixInput < ip2fo->n_expanded;
|
||||
}
|
||||
|
||||
static Bool supp_pattEQinp ( const void* supplocV, const void* addrV,
|
||||
void* inputCompleter, UWord ixAddrV )
|
||||
void* inputCompleter, UWord ixInput )
|
||||
{
|
||||
const SuppLoc* supploc = supplocV; /* PATTERN */
|
||||
Addr ip = *(const Addr*)addrV; /* INPUT */
|
||||
IPtoFunOrObjCompleter* ip2fo = inputCompleter;
|
||||
HChar* funobj_name; // Fun or Obj name.
|
||||
|
||||
expandInput(ip2fo, ixInput);
|
||||
vg_assert(ixInput < ip2fo->n_expanded);
|
||||
|
||||
/* So, does this IP address match this suppression-line? */
|
||||
switch (supploc->ty) {
|
||||
case DotDotDot:
|
||||
@ -1587,10 +1743,10 @@ static Bool supp_pattEQinp ( const void* supplocV, const void* addrV,
|
||||
this can't happen. */
|
||||
vg_assert(0);
|
||||
case ObjName:
|
||||
funobj_name = foComplete(ip2fo, ip, ixAddrV, False /*needFun*/);
|
||||
funobj_name = foComplete(ip2fo, ixInput, False /*needFun*/);
|
||||
break;
|
||||
case FunName:
|
||||
funobj_name = foComplete(ip2fo, ip, ixAddrV, True /*needFun*/);
|
||||
funobj_name = foComplete(ip2fo, ixInput, True /*needFun*/);
|
||||
break;
|
||||
default:
|
||||
vg_assert(0);
|
||||
@ -1617,15 +1773,16 @@ static Bool supp_matches_callers(IPtoFunOrObjCompleter* ip2fo, Supp* su)
|
||||
SuppLoc* supps = su->callers;
|
||||
UWord n_supps = su->n_callers;
|
||||
UWord szbPatt = sizeof(SuppLoc);
|
||||
UWord szbInput = sizeof(Addr);
|
||||
Bool matchAll = False; /* we just want to match a prefix */
|
||||
return
|
||||
VG_(generic_match)(
|
||||
matchAll,
|
||||
/*PATT*/supps, szbPatt, n_supps, 0/*initial Ix*/,
|
||||
/*INPUT*/ip2fo->ips, szbInput, ip2fo->n_ips, 0/*initial Ix*/,
|
||||
/*PATT*/supps, szbPatt, n_supps, 0/*initial ixPatt*/,
|
||||
/*INPUT*/
|
||||
NULL, 0, 0, /* input/szbInput/nInput 0, as using an inputCompleter */
|
||||
0/*initial ixInput*/,
|
||||
supploc_IsStar, supploc_IsQuery, supp_pattEQinp,
|
||||
ip2fo
|
||||
ip2fo, haveInputInpC
|
||||
);
|
||||
}
|
||||
|
||||
@ -1683,6 +1840,10 @@ static Supp* is_suppressible_error ( Error* err )
|
||||
/* Prepare the lazy input completer. */
|
||||
ip2fo.ips = VG_(get_ExeContext_StackTrace)(err->where);
|
||||
ip2fo.n_ips = VG_(get_ExeContext_n_ips)(err->where);
|
||||
ip2fo.n_ips_expanded = 0;
|
||||
ip2fo.n_expanded = 0;
|
||||
ip2fo.sz_offsets = 0;
|
||||
ip2fo.n_offsets_per_ip = NULL;
|
||||
ip2fo.fun_offsets = NULL;
|
||||
ip2fo.obj_offsets = NULL;
|
||||
ip2fo.names = NULL;
|
||||
|
||||
@ -146,7 +146,7 @@ static HChar* sym (Addr addr, Bool is_code)
|
||||
if (w == 2) w = 0;
|
||||
buf[w][0] = '\0';
|
||||
if (is_code) {
|
||||
VG_(describe_IP) (addr, buf[w], 200);
|
||||
VG_(describe_IP) (addr, buf[w], 200, NULL);
|
||||
} else {
|
||||
VG_(get_datasym_and_offset) (addr, buf[w], 200, &offset);
|
||||
}
|
||||
|
||||
@ -179,7 +179,7 @@ static
|
||||
char* sym (Addr addr)
|
||||
{
|
||||
static char buf[200];
|
||||
VG_(describe_IP) (addr, buf, 200);
|
||||
VG_(describe_IP) (addr, buf, 200, NULL);
|
||||
return buf;
|
||||
}
|
||||
|
||||
|
||||
@ -162,6 +162,8 @@ static void usage_NORETURN ( Bool debug_help )
|
||||
" checks for self-modifying code: none, only for\n"
|
||||
" code found in stacks, for all code, or for all\n"
|
||||
" code except that from file-backed mappings\n"
|
||||
" --read-inline-info=yes|no read debug info about inlined function calls\n"
|
||||
" and use it to do better stack traces [no]\n"
|
||||
" --read-var-info=yes|no read debug info on stack and global variables\n"
|
||||
" and use it to print better error messages in\n"
|
||||
" tools that make use of it (Memcheck, Helgrind,\n"
|
||||
@ -593,6 +595,7 @@ void main_process_cmd_line_options ( /*OUT*/Bool* logging_to_fd,
|
||||
else if VG_BOOL_CLO(arg, "--wait-for-gdb", VG_(clo_wait_for_gdb)) {}
|
||||
else if VG_STR_CLO (arg, "--db-command", VG_(clo_db_command)) {}
|
||||
else if VG_BOOL_CLO(arg, "--sym-offsets", VG_(clo_sym_offsets)) {}
|
||||
else if VG_BOOL_CLO(arg, "--read-inline-info", VG_(clo_read_inline_info)) {}
|
||||
else if VG_BOOL_CLO(arg, "--read-var-info", VG_(clo_read_var_info)) {}
|
||||
|
||||
else if VG_INT_CLO (arg, "--dump-error", VG_(clo_dump_error)) {}
|
||||
@ -1930,6 +1933,9 @@ Int valgrind_main ( Int argc, HChar **argv, HChar **envp )
|
||||
//--------------------------------------------------------------
|
||||
VG_(debugLog)(1, "main", "Initialise the tool part 1 (pre_clo_init)\n");
|
||||
VG_(tl_pre_clo_init)();
|
||||
// Activate var info readers, if the tool asked for it:
|
||||
if (VG_(needs).var_info)
|
||||
VG_(clo_read_var_info) = True;
|
||||
|
||||
//--------------------------------------------------------------
|
||||
// If --tool and --help/--help-debug was given, now give the core+tool
|
||||
|
||||
@ -113,6 +113,7 @@ Int VG_(clo_backtrace_size) = 12;
|
||||
Int VG_(clo_merge_recursive_frames) = 0; // default value: no merge
|
||||
const HChar* VG_(clo_sim_hints) = NULL;
|
||||
Bool VG_(clo_sym_offsets) = False;
|
||||
Bool VG_(clo_read_inline_info) = False; // Or should be put it to True by default ???
|
||||
Bool VG_(clo_read_var_info) = False;
|
||||
Int VG_(clo_n_req_tsyms) = 0;
|
||||
const HChar* VG_(clo_req_tsyms)[VG_CLO_MAX_REQ_TSYMS];
|
||||
|
||||
@ -46,7 +46,7 @@ Bool VG_(generic_match) (
|
||||
Bool (*pIsStar)(const void*),
|
||||
Bool (*pIsQuery)(const void*),
|
||||
Bool (*pattEQinp)(const void*,const void*,void*,UWord),
|
||||
void* inputCompleter
|
||||
void* inputCompleter, Bool (*haveInputInpC)(void*,UWord)
|
||||
)
|
||||
{
|
||||
/* This is the spec, written in my favourite formal specification
|
||||
@ -67,19 +67,23 @@ Bool VG_(generic_match) (
|
||||
Bool havePatt, haveInput;
|
||||
const HChar *currPatt, *currInput;
|
||||
tailcall:
|
||||
vg_assert(nPatt >= 0 && nPatt < 1000000); /* arbitrary */
|
||||
vg_assert(nInput >= 0 && nInput < 1000000); /* arbitrary */
|
||||
vg_assert(nPatt >= 0 && nPatt < 1000000); /* arbitrary */
|
||||
vg_assert(inputCompleter
|
||||
|| (nInput >= 0 && nInput < 1000000)); /* arbitrary */
|
||||
vg_assert(ixPatt >= 0 && ixPatt <= nPatt);
|
||||
vg_assert(ixInput >= 0 && ixInput <= nInput);
|
||||
vg_assert(ixInput >= 0 && (inputCompleter || ixInput <= nInput));
|
||||
|
||||
havePatt = ixPatt < nPatt;
|
||||
haveInput = ixInput < nInput;
|
||||
haveInput = inputCompleter ?
|
||||
(*haveInputInpC)(inputCompleter, ixInput)
|
||||
: ixInput < nInput;
|
||||
|
||||
/* No specific need to set NULL when !have{Patt,Input}, but guards
|
||||
against inadvertantly dereferencing an out of range pointer to
|
||||
the pattern or input arrays. */
|
||||
currPatt = havePatt ? ((const HChar*)patt) + szbPatt * ixPatt : NULL;
|
||||
currInput = haveInput ? ((const HChar*)input) + szbInput * ixInput : NULL;
|
||||
currInput = haveInput && !inputCompleter ?
|
||||
((const HChar*)input) + szbInput * ixInput : NULL;
|
||||
|
||||
// Deal with the complex case first: wildcards. Do frugal
|
||||
// matching. When encountering a '*', first skip no characters
|
||||
@ -104,7 +108,7 @@ Bool VG_(generic_match) (
|
||||
patt, szbPatt, nPatt, ixPatt+1,
|
||||
input,szbInput,nInput, ixInput+0,
|
||||
pIsStar,pIsQuery,pattEQinp,
|
||||
inputCompleter) ) {
|
||||
inputCompleter,haveInputInpC) ) {
|
||||
return True;
|
||||
}
|
||||
// but we can tail-recurse for the second call
|
||||
@ -179,7 +183,7 @@ Bool VG_(string_match) ( const HChar* patt, const HChar* input )
|
||||
patt, sizeof(HChar), VG_(strlen)(patt), 0,
|
||||
input, sizeof(HChar), VG_(strlen)(input), 0,
|
||||
charIsStar, charIsQuery, char_p_EQ_i,
|
||||
NULL
|
||||
NULL, NULL
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@ -1450,13 +1450,20 @@ static void printIpDesc(UInt n, Addr ip, void* uu_opaque)
|
||||
|
||||
static HChar buf[BUF_LEN];
|
||||
|
||||
VG_(describe_IP)(ip, buf, BUF_LEN);
|
||||
InlIPCursor *iipc = VG_(new_IIPC)(ip);
|
||||
|
||||
if (VG_(clo_xml)) {
|
||||
VG_(printf_xml)(" %s\n", buf);
|
||||
} else {
|
||||
VG_(message)(Vg_UserMsg, " %s %s\n", ( n == 0 ? "at" : "by" ), buf);
|
||||
}
|
||||
do {
|
||||
VG_(describe_IP)(ip, buf, BUF_LEN, iipc);
|
||||
if (VG_(clo_xml)) {
|
||||
VG_(printf_xml)(" %s\n", buf);
|
||||
} else {
|
||||
VG_(message)(Vg_UserMsg, " %s %s\n",
|
||||
( n == 0 ? "at" : "by" ), buf);
|
||||
}
|
||||
n++;
|
||||
// Increase n to show "at" for only one level.
|
||||
} while (VG_(next_IIPC)(iipc));
|
||||
VG_(delete_IIPC)(iipc);
|
||||
}
|
||||
|
||||
/* Print a StackTrace. */
|
||||
|
||||
@ -89,9 +89,11 @@ extern
|
||||
Bool VG_(get_fnname_raw) ( Addr a, HChar* buf, Int nbuf );
|
||||
|
||||
/* Like VG_(get_fnname), but without C++ demangling. (But it does
|
||||
* Z-demangling and below-main renaming.) */
|
||||
Z-demangling and below-main renaming.)
|
||||
iipc argument: same usage as in VG_(describe_IP) in pub_tool_debuginfo.h. */
|
||||
extern
|
||||
Bool VG_(get_fnname_no_cxx_demangle) ( Addr a, HChar* buf, Int nbuf );
|
||||
Bool VG_(get_fnname_no_cxx_demangle) ( Addr a, HChar* buf, Int nbuf,
|
||||
InlIPCursor* iipc );
|
||||
|
||||
/* mips-linux only: find the offset of current address. This is needed for
|
||||
stack unwinding for MIPS.
|
||||
|
||||
@ -227,6 +227,8 @@ extern Int VG_(clo_dump_error);
|
||||
extern const HChar* VG_(clo_sim_hints);
|
||||
/* Show symbols in the form 'name+offset' ? Default: NO */
|
||||
extern Bool VG_(clo_sym_offsets);
|
||||
/* Read DWARF3 inline info ? */
|
||||
extern Bool VG_(clo_read_inline_info);
|
||||
/* Read DWARF3 variable info even if tool doesn't ask for it? */
|
||||
extern Bool VG_(clo_read_var_info);
|
||||
/* Which prefix to strip from full source file paths, if any. */
|
||||
|
||||
@ -1780,6 +1780,50 @@ need to use them.</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry id="opt.read-inline-info" xreflabel="--read-inline-info">
|
||||
<term>
|
||||
<option><![CDATA[--read-inline-info=<yes|no> [default: no] ]]></option>
|
||||
</term>
|
||||
<listitem>
|
||||
<para>When enabled, Valgrind will read information about
|
||||
inlined function calls from DWARF3 debug info.
|
||||
This slows Valgrind startup and makes it use more memory (typically
|
||||
for each inlined piece of code, 6 words + the function name), but
|
||||
it results in more descriptive stacktraces:</para>
|
||||
<programlisting><![CDATA[
|
||||
==15380== Conditional jump or move depends on uninitialised value(s)
|
||||
==15380== at 0x80484EA: main (inlinfo.c:6)
|
||||
==15380==
|
||||
==15380== Conditional jump or move depends on uninitialised value(s)
|
||||
==15380== at 0x8048550: fun_noninline (inlinfo.c:6)
|
||||
==15380== by 0x804850E: main (inlinfo.c:34)
|
||||
==15380==
|
||||
==15380== Conditional jump or move depends on uninitialised value(s)
|
||||
==15380== at 0x8048520: main (inlinfo.c:6)]]></programlisting>
|
||||
|
||||
<para>And here are the same errors with
|
||||
<option>--read-inline-info=yes</option>:</para>
|
||||
|
||||
<programlisting><![CDATA[
|
||||
==15377== Conditional jump or move depends on uninitialised value(s)
|
||||
==15377== at 0x80484EA: fun_d (inlinfo.c:6)
|
||||
==15377== by 0x80484EA: fun_c (inlinfo.c:14)
|
||||
==15377== by 0x80484EA: fun_b (inlinfo.c:20)
|
||||
==15377== by 0x80484EA: fun_a (inlinfo.c:26)
|
||||
==15377== by 0x80484EA: main (inlinfo.c:33)
|
||||
==15377==
|
||||
==15377== Conditional jump or move depends on uninitialised value(s)
|
||||
==15377== at 0x8048550: fun_d (inlinfo.c:6)
|
||||
==15377== by 0x8048550: fun_noninline (inlinfo.c:41)
|
||||
==15377== by 0x804850E: main (inlinfo.c:34)
|
||||
==15377==
|
||||
==15377== Conditional jump or move depends on uninitialised value(s)
|
||||
==15377== at 0x8048520: fun_d (inlinfo.c:6)
|
||||
==15377== by 0x8048520: main (inlinfo.c:35)
|
||||
]]></programlisting>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry id="opt.read-var-info" xreflabel="--read-var-info">
|
||||
<term>
|
||||
<option><![CDATA[--read-var-info=<yes|no> [default: no] ]]></option>
|
||||
@ -1787,36 +1831,39 @@ need to use them.</para>
|
||||
<listitem>
|
||||
<para>When enabled, Valgrind will read information about
|
||||
variable types and locations from DWARF3 debug info.
|
||||
This slows Valgrind down and makes it use more memory, but for
|
||||
the tools that can take advantage of it (Memcheck, Helgrind,
|
||||
DRD) it can result in more precise error messages. For example,
|
||||
This slows Valgrind startup significantly and makes it use significantly
|
||||
more memory, but for the tools that can take advantage of it (Memcheck,
|
||||
Helgrind, DRD) it can result in more precise error messages. For example,
|
||||
here are some standard errors issued by Memcheck:</para>
|
||||
<programlisting><![CDATA[
|
||||
==15516== Uninitialised byte(s) found during client check request
|
||||
==15516== at 0x400633: croak (varinfo1.c:28)
|
||||
==15516== by 0x4006B2: main (varinfo1.c:55)
|
||||
==15516== Address 0x60103b is 7 bytes inside data symbol "global_i2"
|
||||
==15516==
|
||||
==15516== Uninitialised byte(s) found during client check request
|
||||
==15516== at 0x400633: croak (varinfo1.c:28)
|
||||
==15516== by 0x4006BC: main (varinfo1.c:56)
|
||||
==15516== Address 0x7fefffefc is on thread 1's stack]]></programlisting>
|
||||
==15363== Uninitialised byte(s) found during client check request
|
||||
==15363== at 0x80484A9: croak (varinfo1.c:28)
|
||||
==15363== by 0x8048544: main (varinfo1.c:55)
|
||||
==15363== Address 0x80497f7 is 7 bytes inside data symbol "global_i2"
|
||||
==15363==
|
||||
==15363== Uninitialised byte(s) found during client check request
|
||||
==15363== at 0x80484A9: croak (varinfo1.c:28)
|
||||
==15363== by 0x8048550: main (varinfo1.c:56)
|
||||
==15363== Address 0xbea0d0cc is on thread 1's stack
|
||||
==15363== in frame #1, created by main (varinfo1.c:45)
|
||||
></programlisting>
|
||||
|
||||
<para>And here are the same errors with
|
||||
<option>--read-var-info=yes</option>:</para>
|
||||
|
||||
<programlisting><![CDATA[
|
||||
==15522== Uninitialised byte(s) found during client check request
|
||||
==15522== at 0x400633: croak (varinfo1.c:28)
|
||||
==15522== by 0x4006B2: main (varinfo1.c:55)
|
||||
==15522== Location 0x60103b is 0 bytes inside global_i2[7],
|
||||
==15522== a global variable declared at varinfo1.c:41
|
||||
==15522==
|
||||
==15522== Uninitialised byte(s) found during client check request
|
||||
==15522== at 0x400633: croak (varinfo1.c:28)
|
||||
==15522== by 0x4006BC: main (varinfo1.c:56)
|
||||
==15522== Location 0x7fefffefc is 0 bytes inside local var "local"
|
||||
==15522== declared at varinfo1.c:46, in frame #1 of thread 1]]></programlisting>
|
||||
==15370== Uninitialised byte(s) found during client check request
|
||||
==15370== at 0x80484A9: croak (varinfo1.c:28)
|
||||
==15370== by 0x8048544: main (varinfo1.c:55)
|
||||
==15370== Location 0x80497f7 is 0 bytes inside global_i2[7],
|
||||
==15370== a global variable declared at varinfo1.c:41
|
||||
==15370==
|
||||
==15370== Uninitialised byte(s) found during client check request
|
||||
==15370== at 0x80484A9: croak (varinfo1.c:28)
|
||||
==15370== by 0x8048550: main (varinfo1.c:56)
|
||||
==15370== Location 0xbeb4a0cc is 0 bytes inside local var "local"
|
||||
==15370== declared at varinfo1.c:46, in frame #1 of thread 1
|
||||
]]></programlisting>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
|
||||
@ -120,14 +120,44 @@ Bool VG_(get_data_description)(
|
||||
It doesn't matter if debug info is present or not. */
|
||||
extern Bool VG_(get_objname) ( Addr a, HChar* objname, Int n_objname );
|
||||
|
||||
|
||||
/* Cursor allowing to describe inlined function calls at an IP,
|
||||
by doing successive calls to VG_(describe_IP). */
|
||||
typedef struct _InlIPCursor InlIPCursor;
|
||||
|
||||
/* 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'.
|
||||
|
||||
eip can possibly corresponds to inlined function call(s).
|
||||
To describe eip and the inlined function calls, the following must
|
||||
be done:
|
||||
InlIPCursor *iipc = VG_(new_IIPC)(eip);
|
||||
do {
|
||||
VG_(describe_IP)(eip, buf, n_buf, iipc);
|
||||
... use buf ...
|
||||
} while (VG_(next_IIPC)(iipc));
|
||||
VG_(delete_IIPC)(iipc);
|
||||
|
||||
To only describe eip, without the inlined calls at eip, give a NULL iipc:
|
||||
VG_(describe_IP)(eip, buf, n_buf, NULL);
|
||||
*/
|
||||
extern HChar* VG_(describe_IP)(Addr eip, HChar* buf, Int n_buf);
|
||||
extern HChar* VG_(describe_IP)(Addr eip, HChar* buf, Int n_buf,
|
||||
InlIPCursor* iipc);
|
||||
|
||||
/* Builds a IIPC (Inlined IP Cursor) to describe eip and all the inlined calls
|
||||
at eip. Such a cursor must be deleted after use using VG_(delete_IIPC). */
|
||||
extern InlIPCursor* VG_(new_IIPC)(Addr eip);
|
||||
/* Move the cursor to the next call to describe.
|
||||
Returns True if there are still calls to describe.
|
||||
False if nothing to describe anymore. */
|
||||
extern Bool VG_(next_IIPC)(InlIPCursor *iipc);
|
||||
/* Free all memory associated with iipc. */
|
||||
extern void VG_(delete_IIPC)(InlIPCursor *iipc);
|
||||
|
||||
|
||||
|
||||
/* Get an XArray of StackBlock which describe the stack (auto) blocks
|
||||
|
||||
@ -58,7 +58,11 @@
|
||||
elements each of size 'szbPatt'. For the initial call, pass a
|
||||
value of zero to 'ixPatt'.
|
||||
|
||||
Ditto for input/nInput/szbInput/ixInput.
|
||||
The input sequence can be similarly described using
|
||||
input/nInput/szbInput/ixInput.
|
||||
Alternatively, the input can be lazily constructed using an
|
||||
inputCompleter. When using an inputCompleter, input/nInput/szbInput
|
||||
are unused.
|
||||
|
||||
pIsStar should return True iff the pointed-to pattern element is
|
||||
conceptually a '*'.
|
||||
@ -72,11 +76,13 @@
|
||||
(conceptually) '*' nor '?', so it must be a literal (in the sense
|
||||
that all the input sequence elements are literal).
|
||||
|
||||
input might be lazily constructed when pattEQinp is called.
|
||||
If inputCompleter is not NULL, the input will be lazily constructed
|
||||
when pattEQinp is called.
|
||||
For lazily constructing the input element, the two last arguments
|
||||
of pattEQinp are the inputCompleter and the index of the input
|
||||
element to complete.
|
||||
inputCompleter can be NULL.
|
||||
VG_(generic_match) calls (*haveInputInpC)(inputCompleter,ixInput) to
|
||||
check if there is an element ixInput in the input sequence.
|
||||
*/
|
||||
Bool VG_(generic_match) (
|
||||
Bool matchAll,
|
||||
@ -85,7 +91,8 @@ Bool VG_(generic_match) (
|
||||
Bool (*pIsStar)(const void*),
|
||||
Bool (*pIsQuery)(const void*),
|
||||
Bool (*pattEQinp)(const void*,const void*,void*,UWord),
|
||||
void* inputCompleter
|
||||
void* inputCompleter,
|
||||
Bool (*haveInputInpC)(void*,UWord)
|
||||
);
|
||||
|
||||
/* Mini-regexp function. Searches for 'pat' in 'str'. Supports
|
||||
|
||||
@ -2174,7 +2174,7 @@ static void pp_snapshot_SXPt(Int fd, SXPt* sxpt, Int depth, HChar* depth_str,
|
||||
}
|
||||
|
||||
// We need the -1 to get the line number right, But I'm not sure why.
|
||||
ip_desc = VG_(describe_IP)(sxpt->Sig.ip-1, ip_desc_array, BUF_LEN);
|
||||
ip_desc = VG_(describe_IP)(sxpt->Sig.ip-1, ip_desc_array, BUF_LEN, NULL);
|
||||
}
|
||||
|
||||
// Do the non-ip_desc part first...
|
||||
|
||||
@ -117,6 +117,9 @@ EXTRA_DIST = \
|
||||
holey_buffer_too_small.stderr.exp \
|
||||
inits.stderr.exp inits.vgtest \
|
||||
inline.stderr.exp inline.stdout.exp inline.vgtest \
|
||||
inlinfo.stderr.exp inlinfo.stdout.exp inlinfo.vgtest \
|
||||
inlinfosupp.stderr.exp inlinfosupp.stdout.exp inlinfosupp.supp inlinfosupp.vgtest \
|
||||
inlinfosuppobj.stderr.exp inlinfosuppobj.stdout.exp inlinfosuppobj.supp inlinfosuppobj.vgtest \
|
||||
leak-0.vgtest leak-0.stderr.exp \
|
||||
leak-cases-full.vgtest leak-cases-full.stderr.exp \
|
||||
leak-cases-possible.vgtest leak-cases-possible.stderr.exp \
|
||||
@ -299,7 +302,7 @@ check_PROGRAMS = \
|
||||
err_disable1 err_disable2 err_disable3 err_disable4 \
|
||||
err_disable_arange1 \
|
||||
file_locking \
|
||||
fprw fwrite inits inline \
|
||||
fprw fwrite inits inline inlinfo \
|
||||
holey_buffer_too_small \
|
||||
leak-0 \
|
||||
leak-cases \
|
||||
@ -406,6 +409,8 @@ fprw_CFLAGS = $(AM_CFLAGS) @FLAG_W_NO_UNINITIALIZED@
|
||||
|
||||
inits_CFLAGS = $(AM_CFLAGS) @FLAG_W_NO_UNINITIALIZED@
|
||||
|
||||
inlinfo_CFLAGS = $(AM_CFLAGS) @FLAG_W_NO_UNINITIALIZED@
|
||||
|
||||
long_namespace_xml_SOURCES = long_namespace_xml.cpp
|
||||
|
||||
manuel1_CFLAGS = $(AM_CFLAGS) @FLAG_W_NO_UNINITIALIZED@
|
||||
|
||||
75
memcheck/tests/inlinfo.c
Normal file
75
memcheck/tests/inlinfo.c
Normal file
@ -0,0 +1,75 @@
|
||||
#include <stdio.h>
|
||||
#include <../memcheck.h>
|
||||
#define INLINE inline __attribute__((always_inline))
|
||||
|
||||
INLINE int fun_d(int argd) {
|
||||
static int locd = 0;
|
||||
if (argd > 0)
|
||||
locd += argd;
|
||||
return locd;
|
||||
}
|
||||
|
||||
INLINE int fun_c(int argc) {
|
||||
static int locc = 0;
|
||||
locc += argc;
|
||||
return fun_d(locc);
|
||||
}
|
||||
|
||||
INLINE int fun_b(int argb) {
|
||||
static int locb = 0;
|
||||
locb += argb;
|
||||
return fun_c(locb);
|
||||
}
|
||||
|
||||
INLINE int fun_a(int arga) {
|
||||
static int loca = 0;
|
||||
loca += arga;
|
||||
return fun_b(loca);
|
||||
}
|
||||
|
||||
__attribute__((noinline))
|
||||
static int fun_noninline_m(int argm)
|
||||
{
|
||||
return fun_d(argm);
|
||||
}
|
||||
|
||||
__attribute__((noinline))
|
||||
static int fun_noninline_o(int argo)
|
||||
{
|
||||
static int loco = 0;
|
||||
if (argo > 0)
|
||||
loco += argo;
|
||||
return loco;
|
||||
}
|
||||
|
||||
INLINE int fun_f(int argf) {
|
||||
static int locf = 0;
|
||||
locf += argf;
|
||||
return fun_noninline_o(locf);
|
||||
}
|
||||
|
||||
INLINE int fun_e(int arge) {
|
||||
static int loce = 0;
|
||||
loce += arge;
|
||||
return fun_f(loce);
|
||||
}
|
||||
|
||||
__attribute__((noinline))
|
||||
static int fun_noninline_n(int argn)
|
||||
{
|
||||
return fun_e(argn);
|
||||
}
|
||||
|
||||
|
||||
int main() {
|
||||
int result;
|
||||
result = fun_a(result);
|
||||
VALGRIND_MAKE_MEM_UNDEFINED(&result, sizeof(result));
|
||||
result += fun_noninline_m(result);
|
||||
VALGRIND_MAKE_MEM_UNDEFINED(&result, sizeof(result));
|
||||
result += fun_d(result);
|
||||
VALGRIND_MAKE_MEM_UNDEFINED(&result, sizeof(result));
|
||||
result += fun_noninline_n(result);
|
||||
return 0;
|
||||
}
|
||||
|
||||
54
memcheck/tests/inlinfo.stderr.exp
Normal file
54
memcheck/tests/inlinfo.stderr.exp
Normal file
@ -0,0 +1,54 @@
|
||||
Conditional jump or move depends on uninitialised value(s)
|
||||
at 0x........: fun_d (inlinfo.c:7)
|
||||
by 0x........: fun_c (inlinfo.c:15)
|
||||
by 0x........: fun_b (inlinfo.c:21)
|
||||
by 0x........: fun_a (inlinfo.c:27)
|
||||
by 0x........: main (inlinfo.c:66)
|
||||
|
||||
{
|
||||
<insert_a_suppression_name_here>
|
||||
Memcheck:Cond
|
||||
fun:fun_d
|
||||
fun:fun_c
|
||||
fun:fun_b
|
||||
fun:fun_a
|
||||
fun:main
|
||||
}
|
||||
Conditional jump or move depends on uninitialised value(s)
|
||||
at 0x........: fun_d (inlinfo.c:7)
|
||||
by 0x........: fun_noninline_m (inlinfo.c:33)
|
||||
by 0x........: main (inlinfo.c:68)
|
||||
|
||||
{
|
||||
<insert_a_suppression_name_here>
|
||||
Memcheck:Cond
|
||||
fun:fun_d
|
||||
fun:fun_noninline_m
|
||||
fun:main
|
||||
}
|
||||
Conditional jump or move depends on uninitialised value(s)
|
||||
at 0x........: fun_d (inlinfo.c:7)
|
||||
by 0x........: main (inlinfo.c:70)
|
||||
|
||||
{
|
||||
<insert_a_suppression_name_here>
|
||||
Memcheck:Cond
|
||||
fun:fun_d
|
||||
fun:main
|
||||
}
|
||||
Conditional jump or move depends on uninitialised value(s)
|
||||
at 0x........: fun_noninline_o (inlinfo.c:40)
|
||||
by 0x........: fun_f (inlinfo.c:48)
|
||||
by 0x........: fun_e (inlinfo.c:54)
|
||||
by 0x........: fun_noninline_n (inlinfo.c:60)
|
||||
by 0x........: main (inlinfo.c:72)
|
||||
|
||||
{
|
||||
<insert_a_suppression_name_here>
|
||||
Memcheck:Cond
|
||||
fun:fun_noninline_o
|
||||
fun:fun_f
|
||||
fun:fun_e
|
||||
fun:fun_noninline_n
|
||||
fun:main
|
||||
}
|
||||
0
memcheck/tests/inlinfo.stdout.exp
Normal file
0
memcheck/tests/inlinfo.stdout.exp
Normal file
4
memcheck/tests/inlinfo.vgtest
Normal file
4
memcheck/tests/inlinfo.vgtest
Normal file
@ -0,0 +1,4 @@
|
||||
# test that the inlined function calls are properly shown in errors.
|
||||
# Also test the generation of suppression entries with inlined calls.
|
||||
prog: inlinfo
|
||||
vgopts: -q --read-inline-info=yes --gen-suppressions=all
|
||||
0
memcheck/tests/inlinfosupp.stderr.exp
Normal file
0
memcheck/tests/inlinfosupp.stderr.exp
Normal file
0
memcheck/tests/inlinfosupp.stdout.exp
Normal file
0
memcheck/tests/inlinfosupp.stdout.exp
Normal file
31
memcheck/tests/inlinfosupp.supp
Normal file
31
memcheck/tests/inlinfosupp.supp
Normal file
@ -0,0 +1,31 @@
|
||||
{
|
||||
main_a_b_c_d
|
||||
Memcheck:Cond
|
||||
fun:fun_d
|
||||
fun:fun_c
|
||||
fun:fun_b
|
||||
fun:fun_a
|
||||
fun:main
|
||||
}
|
||||
{
|
||||
main_m_d
|
||||
Memcheck:Cond
|
||||
fun:fun_d
|
||||
fun:fun_noninline_m
|
||||
fun:main
|
||||
}
|
||||
{
|
||||
main_d
|
||||
Memcheck:Cond
|
||||
fun:fun_d
|
||||
fun:main
|
||||
}
|
||||
{
|
||||
main_n_e_f_o
|
||||
Memcheck:Cond
|
||||
fun:fun_noninline_o
|
||||
fun:fun_f
|
||||
fun:fun_e
|
||||
fun:fun_noninline_n
|
||||
fun:main
|
||||
}
|
||||
3
memcheck/tests/inlinfosupp.vgtest
Normal file
3
memcheck/tests/inlinfosupp.vgtest
Normal file
@ -0,0 +1,3 @@
|
||||
# test suppressions with inlined fn calls.
|
||||
prog: inlinfo
|
||||
vgopts: -q --read-inline-info=yes --suppressions=inlinfosupp.supp
|
||||
7
memcheck/tests/inlinfosuppobj.stderr.exp
Normal file
7
memcheck/tests/inlinfosuppobj.stderr.exp
Normal file
@ -0,0 +1,7 @@
|
||||
Conditional jump or move depends on uninitialised value(s)
|
||||
at 0x........: fun_d (inlinfo.c:7)
|
||||
by 0x........: fun_c (inlinfo.c:15)
|
||||
by 0x........: fun_b (inlinfo.c:21)
|
||||
by 0x........: fun_a (inlinfo.c:27)
|
||||
by 0x........: main (inlinfo.c:66)
|
||||
|
||||
0
memcheck/tests/inlinfosuppobj.stdout.exp
Normal file
0
memcheck/tests/inlinfosuppobj.stdout.exp
Normal file
31
memcheck/tests/inlinfosuppobj.supp
Normal file
31
memcheck/tests/inlinfosuppobj.supp
Normal file
@ -0,0 +1,31 @@
|
||||
{
|
||||
main_a_b_c_d_non_matching_obj_is_not_trucmuch
|
||||
Memcheck:Cond
|
||||
fun:fun_d
|
||||
fun:fun_c
|
||||
obj:trucmuch
|
||||
fun:fun_a
|
||||
fun:main
|
||||
}
|
||||
{
|
||||
main_m_d
|
||||
Memcheck:Cond
|
||||
obj:*inlinfo
|
||||
obj:*inlinfo
|
||||
fun:main
|
||||
}
|
||||
{
|
||||
main_d
|
||||
Memcheck:Cond
|
||||
obj:*inlinfo
|
||||
fun:main
|
||||
}
|
||||
{
|
||||
main_n_e_f_o
|
||||
Memcheck:Cond
|
||||
fun:fun_noninline_o
|
||||
fun:fun_f
|
||||
obj:*inlinfo
|
||||
obj:*inlinfo
|
||||
fun:main
|
||||
}
|
||||
4
memcheck/tests/inlinfosuppobj.vgtest
Normal file
4
memcheck/tests/inlinfosuppobj.vgtest
Normal file
@ -0,0 +1,4 @@
|
||||
# test suppressions with inlined fn calls, with some obj patterns
|
||||
prog: inlinfo
|
||||
vgopts: -q --read-inline-info=yes --suppressions=inlinfosuppobj.supp
|
||||
stderr_filter_args: inlinfo.c
|
||||
@ -75,6 +75,8 @@ usage: valgrind [options] prog-and-args
|
||||
checks for self-modifying code: none, only for
|
||||
code found in stacks, for all code, or for all
|
||||
code except that from file-backed mappings
|
||||
--read-inline-info=yes|no read debug info about inlined function calls
|
||||
and use it to do better stack traces [no]
|
||||
--read-var-info=yes|no read debug info on stack and global variables
|
||||
and use it to print better error messages in
|
||||
tools that make use of it (Memcheck, Helgrind,
|
||||
|
||||
@ -75,6 +75,8 @@ usage: valgrind [options] prog-and-args
|
||||
checks for self-modifying code: none, only for
|
||||
code found in stacks, for all code, or for all
|
||||
code except that from file-backed mappings
|
||||
--read-inline-info=yes|no read debug info about inlined function calls
|
||||
and use it to do better stack traces [no]
|
||||
--read-var-info=yes|no read debug info on stack and global variables
|
||||
and use it to print better error messages in
|
||||
tools that make use of it (Memcheck, Helgrind,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user