42 Commits

Author SHA1 Message Date
Julian Seward
7e1fd774cc Minor tidyings:
search_all_symtabs: look for data symbols also in .sbss and .rodata
sections.

VG_(seginfo_sect_kind): identify addresses in .sbss sections.

VG_(pp_SectKind): handle missing case Vg_SectGOTPLT

search_all_loctabs, VG_(get_objname), VG_(find_seginfo): augment tests
"di->text_present" with "&& di->text_size > 0" (probably not
necessary, but is clearer, and more consistent in that most places
that look at DebugInfo.text_{size,avma} first perform both of those
tests).



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@9029
2009-01-22 21:18:15 +00:00
Tom Hughes
4ca0c5f735 Don't assume that all global variables are in the data section - we
now cope with variables in the text, data, sdata and bss sections.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@9021
2009-01-22 13:40:12 +00:00
Nicholas Nethercote
5ad1dd61f9 Introduce a new type, PtrdiffT. Replace lots of uses of OffT (all those
that are memory offsets) with PtrdiffT;  OffT should only be used for file
sizes and offsets.

Change Off64T from a ULong to a Long, as it should be.  Replace some uses
of ULong in the address space manager with Off64T to match.

Also add a comment explaining the meanings of the basic types like Addr,
OffT, SizeT, etc.

Also fix the prototype for VG_(pread) -- the last arg is an OffT, not an
Int.



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@8959
2009-01-15 21:29:24 +00:00
Julian Seward
ba2ece03b8 This commit subtly changes the meaning of the values obtained via the
stack unwind mechanism (the function VG_(record_ExeContext) et al),
clears up some associated kludges, and makes suppression matching work
more reliably.

Prior to this commit, a stack snapshot contained, at [0], the IP of
the relevant thread, and at all positions [1] and above, the return
addresses for the open calls.

When showing a snapshot to the user (in VG_(apply_StackTrace)), and
searching the stack for stack blocks (in VG_(get_data_description)), 1
is subtracted from positions [1] and above, so as to move these return
addresses back to the last byte of the calling instruction.  This
subtraction is also done even in VG_(get_StackTrace_wrk) itself, in
order to make the stack unwinding work at all.

It turns out that suppression-vs-function-name matching requires the
same hack, and sometimes failed to match suppressions that should
match, because of this self-same problem.

So the commit changes the stack unwinder itself, so that entries [1]
and above point to the last byte of the call instruction, rather than
the return address.  The associated kludges in VG_(apply_StackTrace)
and VG_(get_StackTrace_wrk) are removed, and suppression matching is
observed to work in a case where it failed before.



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@8818
2008-12-12 13:23:03 +00:00
Julian Seward
09dac86eca Add a new module, m_seqmatch, which does very simple sequence (regexp)
matching, in the function VG_(generic_match).  Patterns to be matched
against may contain only '*'-style wildcards (matches any number of
elements, we don't care what they are), '?' wildcards (matches exactly
one element, we don't care what it is) and literal elements.

It is totally abstractified, in the sense that the pattern and input
arrays may be arrays of anything.  The caller provides enough
information so that VG_(generic_match) can step along both arrays, and
can ask the questions "is this pattern element a '*' ?", "is this
pattern element a '?' ?", and "does this pattern element match an
input element ?".

The existing function VG_(string_match) is reimplemented using
VG_(generic_match), although the ability to escape metacharacters in
the pattern string is removed -- I don't think it was ever used.

In m_errormgr, matching of suppression stacks (including wildcard
"..." lines) against error stacks is re-implemented using
VG_(generic_match).

Further detailed comments are in m_seqmatch.h and pub_tool_seqmatch.h.

A negative side effect is that VG_(string_match) will be much slower
than before, due to the abstractification.  It may be necessary to
reimplement a specialised version later.



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@8816
2008-12-12 08:07:49 +00:00
Julian Seward
cf588ba40d When trying to establish whether or not debuginfo should be read from
a file, first the mapping permissions _before_ peering at the file's
header, rather than afterwards.  This changes the logic to behave more
like it does in 3.3.x.  Fixes #164669, although really it is all still
rather fragile.  The bug report,
http://bugs.kde.org/show_bug.cgi?id=164669, contains a detailed
explanation.



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@8747
2008-11-08 15:22:19 +00:00
Julian Seward
35c28b721f Merge Helgrind from branches/YARD into the trunk. Also includes some
minor changes to make stack unwinding on amd64-linux approximately
twice as fast as it was before.



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@8707
2008-10-25 16:22:41 +00:00
Julian Seward
1eceb4282b Dwarf3 variable & type reader: use 64-bit numbers throughout to
represent the sizes of types, even on 32-bit hosts, where a type with
a size >= 2^32 is, well, if not meaningless, then at least impossible
to instantiate.  This is of course motivated by reality .. on ppc32
SUSE11.0, the debuginfo for glibc-2.8 appears to contain a declaration
amounting to

  char __EH_FRAME_BEGIN__ [4294967296]

Really.



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@8683
2008-10-20 16:08:55 +00:00
Julian Seward
335992d8fc Merge all remaining changes from branches/PTRCHECK. These are some
relatively minor extensions to m_debuginfo, a major overhaul of
m_debuginfo/readdwarf3.c to get its space usage under control, and
changes throughout the system to enable heap-use profiling.

The majority of the merged changes were committed into
branches/PTRCHECK as the following revs: 8591 8595 8598 8599 8601 and
8161.



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@8621
2008-09-18 18:12:50 +00:00
Julian Seward
244a20c3ed Fix regression on none/tests/faultstatus caused by r8522.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@8547
2008-08-25 12:10:14 +00:00
Julian Seward
207c05fd20 Rework storage management in the Dwarf3 type and variable reader, to
try and reduce its space consumption.  This change changes some long
linked lists into XArrays instead.



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@8540
2008-08-22 23:18:02 +00:00
Julian Seward
e5150447d7 Presently, Valgrind (non-client) code that wants to use the stat
family of syscalls is impossible to write in a way that's portable and
correct.  On some targets (eg x86-linux) you need to do sys_stat64 and
receive the results in a 'struct vki_stat64'.  But on other targets
(eg amd64-linux) neither sys_stat64 nor 'struct vki_stat64' exist.

This commit adds a new type, 'struct vg_stat', which contains 64 bit
fields in all the right places, and makes VG_(stat) and VG_(fstat) use
it.  This means callers to the two functions no longer need to worry
about the is-it-64-bit-clean-or-not question, since these routines
reformat the received data into a'struct vg_stat'.  Kind of like what
glibc must have been doing for decades.

This (indirectly) fixes a bug on x86-linux, in which m_debuginfo would
sometimes fail to read debug info, due to VG_(di_notify_mmap) using
VG_(stat) (hence sys_stat) on the file, which failed, and when in fact
it should have used sys_stat64.  Bug reported and tracked down by
Marc-Oliver Straub.



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@8522
2008-08-19 07:03:04 +00:00
Bart Van Assche
8e96150945 Merged FORMATCHECK branch (r8368) to trunk.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@8369
2008-07-07 06:49:24 +00:00
Bart Van Assche
46cb6b91d7 - Added support for querying information about .plt sections.
- Added support for .got.plt sections.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@8127
2008-05-25 16:37:22 +00:00
Bart Van Assche
109d597941 Bug fixes (not in bugzilla):
- Make sure that Valgrind does not complain when it tries to read the
  debug information of a file of size zero when such a file is mmap()'ed
  into memory.
- Make sure the filename is included in the error message that is
  printed when reading the debug information fails for a file that is mmap()'ed
  into memory.
- Fixed assertion failure that was triggered by supplying an output
  buffer to VG_(seginfo_sect_kind)() that is smaller than the filename
  to be copied into that buffer.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@8126
2008-05-25 16:25:51 +00:00
Julian Seward
4cae5c3ed5 Merge branches/OTRACK_BY_INSTRUMENTATION into the trunk. This adds
support to Memcheck for tracking the origin of uninitialised values,
if you use the --track-origins=yes flag.

This currently causes some Memcheck regression tests to fail, because
they now print an extra line of advisory text in their output.  This
will be fixed.

The core-tool interface is slightly changed.  The version number for
the interface needs to be incremented.



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@7982
2008-05-01 20:24:26 +00:00
Bart Van Assche
cf45f897a6 Only read debug information from regular files, and not from device nodes. Do not complain on files for which we do not have read access.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@7862
2008-04-09 16:21:34 +00:00
Julian Seward
81663bc4b7 Kludgily fix a regression caused by the recent DATASYMS merge, which
caused V to hang when running Amarok in KDE 3.5.X.



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@7723
2008-03-17 16:23:54 +00:00
Julian Seward
8c1638a9ed Don't tell m_redir (and the user) that debuginfo is about to be
discarded if in fact we never got as far as reading anything into
DebugInfo.  This unbreaks self-hosting.



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@7579
2008-03-06 18:31:42 +00:00
Julian Seward
14af4957fc Merge in the DATASYMS branch.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@7540
2008-03-03 01:35:41 +00:00
Julian Seward
5679a22410 Update copyright dates ("200X-2007" --> "200X-2008").
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@7398
2008-02-11 11:34:59 +00:00
Tom Hughes
b67822d578 If we don't find the address in the segInfo list that ask the address
space manager for the name of the file it was mapped from as a fallback
solution.

This allows us to print the names of exe/dll files in the stack trace
when running programs under wine.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@7327
2008-01-08 17:44:04 +00:00
Julian Seward
06214b0c46 Back out r7210 ("Fix completely bogus implementation of
VG_(seginfo_sect_kind).") as it breaks DRD and possible Callgrind.

The segment kind identification code is basically broken for non-text
segments, but requires fixing at a higher level than this.  See
discussion on valgrind-developers, 20 March 07, "Bug in
VG_(seginfo_sect_kind) ?"



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@7267
2007-12-02 22:03:43 +00:00
Julian Seward
54e5bf2856 Misc changes needed to support exp-drd (Bart Van Assche).
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@7213
2007-11-25 14:08:53 +00:00
Julian Seward
e78a73e925 Fix completely bogus implementation of VG_(seginfo_sect_kind). This
was reported a very long time ago (2 years?) but was not fixed until
now.



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@7210
2007-11-25 12:30:36 +00:00
Nicholas Nethercote
bb2eae844c augment previous commit
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@6708
2007-04-20 02:15:28 +00:00
Nicholas Nethercote
2005fbaa40 It's generally a good idea to set call-by-reference arguments, especially
when the function comments says that they always are set.



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@6707
2007-04-19 23:35:42 +00:00
Julian Seward
1907f8c209 Handle DW_CFA_def_cfa_expression; also DW_OP_mul.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@6627
2007-02-28 13:03:27 +00:00
Julian Seward
142e2aedb7 Fill in a few more DWARF3 'expression' related cases.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@6626
2007-02-28 01:46:30 +00:00
Julian Seward
9377cf0ea5 Add limited support for DWARF3 'expressions' in stack-unwind (CFI)
info (DW_CFA_def_cfa_expression, DW_CFA_expression,
DW_CFA_val_expression).  Mechanism to support all of these is in place
although only DW_CFA_val_expression is currently connected up.

This is really nasty.  The basic idea is to partially evaluate each
expression at the debuginfo-reading time by running it on a stack
machine in which each stack element is an expression tree.  If the
expression can be 'run' successfully, the tree (dag, really) remaining
at the top of the stack is massaged and put into the DiCfSI record for
that address range.  At unwind time the tree is evaluated if needed.
Such cases are in fact extremely rare and so the vast majority of
unwindings use the same mechanism as before.

As a result of all this:

* some obscure cases in glibc-2.5's libpthread.so unwind when they
  didn't before

* --debug-dump=frames produces identical output to that of readelf
  for libc-2.5.so and associated libpthread.so

* All the action centers around the new type CfiExpr, which is a
  union expression-tree type in the same style as IRExpr et al

* Many dark corners of the CFI reader have been looked at and
  (re-)validated



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@6620
2007-02-27 16:52:23 +00:00
Julian Seward
6b895f8c7d Non-functional (debug printing only) change:
Implement GNU binutils 'readelf' style output for --debug-dump=lines
(fully) and --debug-dump=frames (partially).

Initial testing with --debug-dump=lines shows our DWARF2 line number
reader behaves identically to readelf for all examples I tried so far.



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@6597
2007-02-16 14:17:10 +00:00
Julian Seward
be97b31c6c Make VG_(printf) et al conform to ANSI w.r.t. capitalisation of
hex numbers: %x produces lowercase hex, and %X produces uppercase.
Unfortunately this probably changes the output in dozens of places.



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@6596
2007-02-16 14:10:24 +00:00
Julian Seward
0dfa208588 Essentially non-functional tidyings and improvements to debuginfo
reading.  Two sets of changes:

* New flags for debugging the readers.  
  --debug-dump=syms
  --debug-dump=line
  --debug-dump=frames

  These (currently accepted but nonfunctional) are intended to
  create output in the style of (that is, identical to)
    /usr/bin/readelf --syms
    /usr/bin/readelf --debug-dump=line
    /usr/bin/readelf --debug-dump=frames
  respectively.  The plan is that flaws in these readers can then
  be easily found by diff-ing the output against that from readelf.

  Also, a new flag --trace-symtab-patt=<object filename pattern>
  which is used to limit all debuginfo-related debug info to the
  set of shared object names matching the given pattern.  This
  facilitates extracting the debuginfo details of one specific
  shared object, which is usually what is required, rather than
  having to wade through megabytes of junk from every object in
  the process.

* Propagate the avma/svma/image address-naming scheme
  (as described at the top of debuginfo.c) through large parts of
  readelf.c and readdwarf.c.



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@6588
2007-02-12 17:47:14 +00:00
Julian Seward
9943647c57 Unbreak aix build.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@6578
2007-02-09 02:11:06 +00:00
Julian Seward
471585d496 In struct _SegInfo, rename field 'size' to 'text_size' so as to be
consistent with all the other 'foo_start_avma'/'foo_size' pairings.



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@6508
2007-01-11 21:56:20 +00:00
Julian Seward
1b7dd32e8f In struct _SegInfo, rename field 'offset' to 'text_bias'.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@6507
2007-01-11 20:11:51 +00:00
Julian Seward
00c15317cc Non-functional change: rename a bunch of variables and field names
that hold various kinds of addresses during debuginfo reading, so as
to make it easier to understand.  See comment at top of debuginfo.c.



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@6506
2007-01-11 19:42:11 +00:00
Julian Seward
afb082acc7 Generate valid XML even for very long fn names - always ensure tags
have matching closing tags.



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@6502
2007-01-10 15:42:15 +00:00
Julian Seward
172505c978 Update copyright dates.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@6488
2007-01-08 06:01:59 +00:00
Julian Seward
565fe34ff0 Merge r6129:
Changes to support XCOFF:

- allow modules to have 'member names' as well as file names.  A member
  name is a "foo.o" name inside a "bar.a"; necessary as AIX
  keeps all its dynamic libraries in .a files.

- rename the type RiLoc to DiLoc (this holds a line number indication).
  No idea why it was called RiLoc in the first place.

- trace changes in type SysRes

- implement VG_(di_aix5_notify_segchange)



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@6266
2006-10-17 01:37:10 +00:00
Julian Seward
ae8215b3ac Create a new module, m_vki, and move all knowledge about the kernel
interface, except for the syscall numbers, into that.  Mostly this
means moving include/vki-*.h to include/vki/vki-*.h.

include/pub_tool_basics.h previously dragged in the entire kernel
interface.  I've done away with that, so that modules which need to
see the kernel interface now have to include pub_{core,tool}_vki.h
explicitly.  This is why there are many modified .c files -- they have
all acquired an extra #include line.

This certainly breaks all platforms except x86.  Will fix shortly.



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@6225
2006-10-14 19:26:10 +00:00
Julian Seward
27b95f28a5 Cleanup/restructure m_debuginfo, as described in
coregrind/m_debuginfo/README.txt.



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@5823
2006-04-04 15:12:44 +00:00