Commit Graph

131 Commits

Author SHA1 Message Date
Julian Seward
9d7f1c6a52 Don't be confused by archive (.a) files which contain both a 32-bit
and a 64-bit version of the same object (with the same name).  Prior
to this, it would sometimes attempt to read debug info from the wrong
version of the object, complain that the magic number wasn't right,
and so end up reading nothing at all for that object.



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@7248
2007-11-29 03:06:25 +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
Tom Hughes
70a1666570 Don't load debug sections from the linked debug file if we have
already loaded them from the main ELF file. Fixes #145609.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@7196
2007-11-21 16:09:18 +00:00
Julian Seward
6520d8f476 Be more robust against malformed DWARF2 line number information: don't
assert when a reference is made to a filename not in the filename
table.  Fixes #150380 and #129937.



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@7191
2007-11-20 08:46:05 +00:00
Nicholas Nethercote
0974a299f5 Split the OSet interface into two parts: "OSetGen_", which is the existing
interface and provides full power;  and "OSetWord_", which is an
easier-to-use interface for if you just want to store words.



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@6841
2007-09-17 05:30:48 +00:00
Julian Seward
8629b74b36 Handle DW_OP_deref in DWARF3 expressions. Fixes #147285.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@6793
2007-08-31 23:08:39 +00:00
Julian Seward
d18e63eb42 Avoid compilation warnings with gcc-4.2.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@6722
2007-05-01 14:18:48 +00:00
Julian Seward
984e45e88f Add disclaimers.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@6709
2007-04-29 09:06:40 +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
Nicholas Nethercote
742ae56613 Remove duplicate code -- make XArray use VG_(ssort).
Had to change XArray's comparison function to return an Int rather than a
Word so it's consistent with the rest of the world.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@6680
2007-03-28 01:27:05 +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
7efbc7213b Track recent XArray changes.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@6625
2007-02-27 22:36:14 +00:00
Julian Seward
046ec22beb Barf more elegantly.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@6623
2007-02-27 18:38:33 +00:00
Julian Seward
0cbff69f1c Make the leb readers 64-bit clean. That should guard against another
couple of decades of Moore's law.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@6621
2007-02-27 17:43:43 +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
9a4164c5f3 Comment-only change.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@6617
2007-02-25 17:13:19 +00:00
Julian Seward
804c7868a1 Expandable arrays of arbitrary element type T are a simple, useful
abstraction implemented independently in several places in the code
base (bad!).  This commit moves into public view a generic
implementation of it which has been lurking in readxcoff.c for some
time.  Currently nothing uses it.



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@6614
2007-02-25 11:51:13 +00:00
Julian Seward
b095682a89 CFI reader: make reading of 'encoded addresses' be much more in
line with the DWARF3 spec and also with binutils/readelf.c:

- Update some comments

- Get rid of kludge_then_addDiCfSI; apparently no longer needed

- Pass the SegInfo's text_bias around in the AddressDecodingInfo,
  so that ...

- read_encoded_Addr can set 'base' to the text_bias when handling
  DW_EH_PE_absptr.  This is the central change of this commit and
  appears (to me) to be what DWARF3 requires.  (The spec is less
  than clear ..)

- don't use read_encoded_Addr to read the FDE arange field since
  read_encoded_Addr's adding-on of a 'base' value is meaningless
  here - the arange is not an address, but a value saying how many
  bytes the FDE covers.  Instead just read a little-endian value of
  the right size.  This is in accordance with DWARF3 and with 
  readelf.c.  Add new function read_le_encoded_literal to make 
  this possible.

I believe this is all correct, and it's certainly much better than it
was.  But given that the DWARF3 spec isn't as formal as it should be,
it's hard to be sure.



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@6611
2007-02-24 23:29:31 +00:00
Julian Seward
80835689c0 Make the frame unwinder able to handle 64-bit DWARF (untested :-(
mostly by a lot of comparison of this code vs that of
binutils-2.17/binutils/dwarf.c vs the relevant specs.



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@6610
2007-02-23 10:10:02 +00:00
Julian Seward
f8d99e1ee3 Improve --debug-dump=frames output.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@6600
2007-02-16 20:11:27 +00:00
Julian Seward
c555fa5434 Correctly handle DW_CFA_def_cfa_sf (existing code fails to scale
offset by data_a_f).



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@6599
2007-02-16 19:20:28 +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
20ce1d0a81 Handle DW_CFA_undefined (produced by PathScale 2.4 on amd64-linux)
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@6510
2007-01-12 19:21:22 +00:00
Julian Seward
c8bb92ec69 ML_(read_callframe_info_dwarf2): deal better with CIEs with no
augmentation (has to do with read_encoded_Addr).  This "fix" is a
kludge and may be replaced in future by something cleaner.  See
extensive comment addition for the whole sorry tale.



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@6509
2007-01-12 19:03:19 +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
cf7e9dbc05 CFI reader: when decoding the single (address) argument to
DW_CFA_set_loc, take into account any encoding info conveyed by the
augmentation string.  See big comment in the code.



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@6356
2006-11-16 12:21:52 +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
5db73d123f Merge r6100:
Code for reading XCOFF32 and XCOFF64 symbol tables and line numbers.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@6249
2006-10-17 01:07:21 +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
0401e8938b Slacken assertion slightly, and add comments. Fixes #133051
('cfsi->len > 0 && cfsi->len < 2000000' failed)



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@6040
2006-08-28 22:56:59 +00:00
Tom Hughes
ab63c4397b Use fstat64 to work out the size of a file if it is available as it
copes with a wider range of filesystems than the old fstat call.

Fixes bug #130020.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@5979
2006-07-05 17:47:46 +00:00
Julian Seward
ad67fd79fe Update copyright dates.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@5954
2006-06-05 23:21:15 +00:00
Julian Seward
ddf1056a0e Properly handle external debuginfo (.gnu_debuglink) for stripped and
prelinked libraries (patch from L. David Baron).



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@5841
2006-04-12 10:08:05 +00:00
Julian Seward
1cebaa9c21 Fold in a patch which appeared in FC5's default valgrind build, which
causes V to ignore more DWARF3 CFA expressions on amd64 and so gets
rid of complaints from the CFA reader.  Why didn't Red Hat push this
patch upstream?  I don't know.



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@5838
2006-04-08 16:22:53 +00:00
Julian Seward
7636cac62a Avoid compiler warnings on ppc64-linux.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@5829
2006-04-06 13:31:17 +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
Robert Walsh
7b68d73711 Denestification.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@5626
2006-02-10 03:33:10 +00:00
Julian Seward
b529b21907 Teach the Dwarf2 line-info reader how to handle so-called 64-bit
Dwarf, which is a (fully documented) Dwarf3 variant in which some
32-bit fields are expanded to 64 bits.  Presumably this is useful for
those vast hordes of folks who regularly build executables or shared
objects more than 4GB long.  For whatever reason, IBM's xlc/xlC/xlf
insist on generating 64-bit Dwarf when compiling even hello-world size
programs for ppc64-linux.



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@5625
2006-02-09 23:35:11 +00:00
Julian Seward
296920f25b Rationalise demangling a bit more, so that suppression matching works
properly again.



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@5553
2006-01-19 03:38:19 +00:00
Julian Seward
a9bbc3690b Fix an all-platforms bug introduced by the recent overhaul of function
interception and wrapping.  This was causing failures matching
function names in suppressions to function names in backtraces when
the latter names were Z-encoded (eg malloc), which typically caused
all leak suppressions to fail because they contain names such as
malloc, which are Z-encoded.



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@5548
2006-01-18 04:23:10 +00:00