Commit Graph

91 Commits

Author SHA1 Message Date
Nicholas Nethercote
e0e17fab32 Increase the size of M_VG_ERRTXT from 512B to 4KB, increasing the size of C++
names that can be demangled.

MERGE TO STABLE


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2787
2004-10-18 15:47:18 +00:00
Nicholas Nethercote
b24f257005 Arch-abstraction:
- abstract out three ELF constants


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2741
2004-10-09 19:08:08 +00:00
Nicholas Nethercote
68da16321d Arch-abstraction:
- in vg_symtab2.c, abstract out mentions of specific registers.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2703
2004-09-11 23:48:22 +00:00
Nicholas Nethercote
49eea042c1 Arch-abstraction: introduce constants for min and max instruction sizes.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2660
2004-09-04 15:28:37 +00:00
Nicholas Nethercote
18355ff96b Arch-abstraction:
- Added include/x86/:  contains tool_arch.h, Makefile.am, .cvsignore.

- Added coregrind/x86/state.c.  Contains some arch-specific code for dealing
  with x86 registers -- eg. setting up the baseBlock, loading/saving the whole
  register state.  It is compiled into coregrind/x86/libarch.a and linked via
  ${VG_ARCH} with the core.

  Relatedly, also added coregrind/x86/{core_arch.h,core_arch_asm.h}.

- Correspondingly abstracted the register state out of ThreadState.  This
  affected every place that touches registers, and there are a lot of them.
  (Eventually all the register touching should be abstracted out in an
  arch-neutral way, but not yet;  one step at a time.)

- Added some declarations about register loading/saving functions to core.h;
  all architectures will have to provide these functions.

- Rejigged the build system so that the arch-specific stuff is all done via
  ${VG_ARCH}, rather than naming e.g. x86/ directly.  Appropriate -I arguments
  are used so that all the headers are found, etc.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2656
2004-09-03 13:45:29 +00:00
Nicholas Nethercote
ba210a6364 Arch-abstraction step: renamed "vg_include.h" as "core.h".
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2643
2004-09-01 23:58:16 +00:00
Nicholas Nethercote
982a0ff98e Remove VG_() from name of local function.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2563
2004-08-03 23:44:12 +00:00
Nicholas Nethercote
9a31e70a79 Cleaned up vg_include.h:
- removed various things that are no longer used
- made (module-)local some things that were global
- improved the formatting in places

Removed about 160 lines of code, and non-trivially reduced the number
of global entities.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2541
2004-08-01 22:36:40 +00:00
Nicholas Nethercote
877d4dd0bd Fix bug #86254 -- symtab sorting was going array in very obscure circumstances
due to a signed/unsigned int problem.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2540
2004-08-01 20:24:46 +00:00
Nicholas Nethercote
977f595b53 Added assertion checking to a whole bunch of mmap() and munmap() calls. I used
assertions because if these calls fail, it's a bug in Valgrind.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2474
2004-07-10 17:49:17 +00:00
Nicholas Nethercote
be21773f17 Removed the 'place-holder' behaviour of VG_(mmap). Previously, VG_(mmap) would
add a segment mapping to the segment skip-list, and then often the caller of
VG_(mmap) would do another one for the same segment, just to change the SF_*
flags.  Now VG_(mmap) gets passed the appropriate SF_* flags so it can do it
directly.   This results in shorter, simpler code, and less work at runtime.

Also, strengthened checking in VG_(mmap), POST(mmap), POST(mmap2) -- now if the
result is not in the right place, it aborts rather than unmapping and
continuing.  This is because if it's not in the right place, something has
gone badly wrong.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2466
2004-07-10 16:50:09 +00:00
Nicholas Nethercote
4978146393 Printing slightly more informative message when mmap fails.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2442
2004-06-27 12:30:15 +00:00
Tom Hughes
dc049b7c82 Add support for separate debug files, which are just separate ELF files
containing the relevant debug sections and located using the information
in the .gnu_debuglink section of the main file along with some search
rules and checksum logic borrowed from binutils/gdb.

CCMAIL: 82872-done@bugs.kde.org


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2408
2004-06-13 09:59:02 +00:00
Robert Walsh
f7e7e4ba37 Fix bug 73655.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2371
2004-04-16 23:02:29 +00:00
Jeremy Fitzhardinge
54b904f8bd Quiet an overly noisy message.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2363
2004-04-14 07:22:00 +00:00
Tom Hughes
9f1434ff0c Redirect _dl_sysinfo_int80, which is glibc's default system call
routine, to the routine in our trampoline page so that the
special sysinfo unwind hack in vg_execontext.c will kick in.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2334
2004-03-22 19:46:29 +00:00
Jeremy Fitzhardinge
863515c9a4 Fix for bug 73326. It seems that gcc 3.2.2 is generating negatively-sized
scopes and out of order line number information in the stabs debug info.
I wonder if this is the stabs writer rotting now that dwarf is the
default...


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2240
2004-02-05 22:58:37 +00:00
Nicholas Nethercote
c756c590cf Convert "skin" to "tool" in various places; almost entirely within comments,
nothing that will affect code.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2217
2004-01-21 15:08:04 +00:00
Dirk Mueller
1df018a591 remove anonymous unions - not supported by older versions of gcc.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2188
2004-01-06 16:02:29 +00:00
Nicholas Nethercote
07b8e3438b Updated copyright dates for 2004. Also added a couple of missing headers and
footers to some new files.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2177
2004-01-04 16:43:23 +00:00
Julian Seward
a3188f40fd Add an implementation of strnlen for memcheck, from Tom Hughes.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2146
2003-12-22 22:39:15 +00:00
Jeremy Fitzhardinge
a77797ee87 Fix nasty use after free bug revealed by last munmap fix.
Unexport split_segment; it isn't needed elsewhere.
(Something still wrong with munmap.)


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2143
2003-12-22 10:42:59 +00:00
Julian Seward
5425200499 resolve_redir(): when a redirect is resolved, if the source has
already been translated, discard that translation.  Otherwise the
redirect will never take effect.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2141
2003-12-22 00:50:52 +00:00
Julian Seward
22fd0f99dc For whatever reason, ld-2.3.2.so (ld-linux.so.2) seems to have its own
PLT-bypassed versions of stpcpy and strchr.  Subvert them.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2140
2003-12-22 00:14:50 +00:00
Julian Seward
79c85b65bf Use the redir machinery to forcibly remap stpcpy in libc.so.6 to our
own version in mac_replace_strmem.c.  We have to do this the hard way
because overenthusiastic PLT bypassing in glibc means the usual
symbol-override stuff doesn't work.  IOW, for the usual reason that we
have to use the redir machinery at all.

This makes many programs run much more quietly on SuSE 9.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2139
2003-12-21 23:54:59 +00:00
Julian Seward
b1580b78eb Make the debug printing in the symbol redirect machinery, easier to
understand.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2138
2003-12-21 23:32:43 +00:00
Jeremy Fitzhardinge
918c3a7b7e This jumbo-checkin is the Full Virtualization checkin. This eliminates
Valgrind's dependency on the dynamic linker for getting started, and
instead takes things into its own hands.

This checkin doesn't add much in the way of new functionality, but it
is the basis for all future work on Valgrind.  It allows us much more
flexibility in implementation, and well as increasing the reliability
of Valgrind by protecting it more from its clients.

This patch requires some changes to tools to update them to the changes
in the tool API, but they are straightforward.  See the posting "Heads
up: Full Virtualization" on valgrind-developers for a more complete
description of this change and its effects on you.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2118
2003-12-16 02:05:15 +00:00
Jeremy Fitzhardinge
7a664bc301 Make symbol prefix matching table driver, and be a bit more careful
about overrunning the ends of names.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2116
2003-12-15 23:31:52 +00:00
Jeremy Fitzhardinge
e77d4b8d7e When merging multiple symbols with the same address, rather than always
choosing the longest symbol, choose the longest ignoring any of the libc
junk prefixes like __libc_, __, __GI_*, etc.  This makes the symbol
presented to the user in messages and used in *.supp files more consistent
and comprehensible.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2114
2003-12-15 09:00:21 +00:00
Julian Seward
4d11934a22 Patch in a DWARF1 (obsolete) line number reader, from the stable (2.0)
branch.  Apparently the Lahey Fortran compiler emits DWARF1 line
number info.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2105
2003-12-13 23:16:26 +00:00
Julian Seward
74d799e2d9 Print "object doesn't have a %s" all on one line.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2101
2003-12-12 06:22:06 +00:00
Nicholas Nethercote
5f1bf8818f Fixed test in section finding code that was broken for .plt and .got sections.
Thanks to Tom Hughes for the patch.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2075
2003-12-01 11:54:09 +00:00
Dirk Mueller
c1f0959dfe make it compile on non-C90 compilers. Thanks for the patch.
CCMAIL: 68525-done@bugs.kde.org


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2051
2003-11-19 22:05:35 +00:00
Dirk Mueller
abbe971b7c be less verbose by default
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2036
2003-11-19 00:47:00 +00:00
Nicholas Nethercote
d1642f0ed8 Greatly improved the symbol table reading code. It was a kludgy, accreted
mess.  Pulled the symbol table reading bit out of vg_read_lib_symbols() into
read_symtab(), in the process removing the awful twice-only loop used to read
the symbol table and the dynamic symbol table.  Factored out the code used to
find sections of interest (eg. .strtab, .symtab, .stabs, .plt, etc), replacing
nine (yes, nine) individual and slightly differing searches.

It's now much easier to understand, 132 lines shorter, and provides a better
base for easily doing more complicated debug stuff, eg. when we start reading
in all the debugging info (such as .debug_info for dwarf2).


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2024
2003-11-13 22:34:00 +00:00
Nicholas Nethercote
4126f4b26e Remove local shellshort function, use the standard VG_(ssort).
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2023
2003-11-13 21:50:45 +00:00
Nicholas Nethercote
d7bfd760a8 Changed error messages: now don't print anything below main() unless the new
option --show-below-main is on.  It's on by default.  It also affects
suppressions generated with --gen-suppressions=yes.  Updated reg tests
accordingly.

Also updated docs for this.  And added some missing command-line args to docs.
Also compartmentalised the options a little in the docs, and rearranged the
order of options in the usage message, in anticipation of a bigger
rearrangement that will be necessary soon -- to distinguish options used by all
skins from those used by error-checking skins, to skin-specific ones.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2020
2003-11-13 17:35:04 +00:00
Jeremy Fitzhardinge
8f0884bbb6 When creating a logfile name, add a sequence number to the name in case
a logfile for that pid already exists.  This may happen for programs
started during system boot which will tend to get the same pid each boot.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@1928
2003-10-14 22:13:28 +00:00
Jeremy Fitzhardinge
65bdafc30c Fix a bug in the duplicate string squasher, which was a bit over-eager
to decide two strings are duplicates.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@1927
2003-10-14 22:07:31 +00:00
Jeremy Fitzhardinge
c55d99c0cc Adds VG_(describe_addr)() for generating symbolic descriptions of a
memory address, based on which variables are in scope at the time and
their types.

As part of this change, I restructured the symbol table parsing code,
by splitting the stabs and dwarf-specific parts into their own files.
I also added a new set of vg_symtypes.[ch] files which contains the
type system code and the core of the VG_(describe_addr)().

I've only implemented the stabs type parser.  I have not yet implemented
the DWARF2 parser.  It looks well-defined but complex.

The only skin which uses this is Helgrind at the moment.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@1926
2003-10-14 21:55:10 +00:00
Julian Seward
b820f69079 Delete some "inline" directives on functions that gcc-3.3.1 declined
to inline.  This is needed to get a warning-free compilation on 3.3.1.
It seems we had "inline" on some pretty huge functions in places.
Also it appears gcc-3.3.1 won't inline a function call in a tail call
position, reasonably enough.  I assume in that case it prefers to
create a tailcall to the callee, rather than inlining it.

MERGE TO STABLE


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@1907
2003-10-12 10:27:06 +00:00
Nicholas Nethercote
ce82c07580 Cleaned up reading of debug info a bit.
Renamed:
  VG_(read_procselfmaps_contents)() --> VG_(read_procselfmaps)()
  VG_(read_procselfmaps)()          --> VG_(parse_procselfmaps)()
  VG_(read_symbols)()               --> VG_(read_all_symbols)()
  VG_(read_symtab_callback)()       --> VG_(read_seg_symbols)()

Removed the Bool 'read_from_file' arg from (what is now)
VG_(parse_procselfmaps)().  If /proc/self/maps needs to be read beforehand, the
code calls (what is now) VG_(read_procselfmaps)() before.  Still using the
static buffer which is not nice but good enough.

More importantly, I split up VG_(new_exe_segment)() into
VG_(new_exeseg_startup)() and VG_(new_exeseg_mmap)().  This is because at
startup, we were stupidly calling VG_(read_symbols)() for every exe seg, which
parses /proc/self/maps completely in order to load the debug info/symbols for
the exe seg (and any others we haven't already got the symbols for).  Despite
the fact that the startup code reads /proc/self/maps to know which segments are
there at startup.  In other words, we were reading /proc/self/maps several
times more often than necessary, and there were nested reads, which Stephan
Kulow's recent depth patch fixed (but in a pretty hacky way;  this commit fixes
it properly).  So VG_(new_exeseg_startup)() now doesn't cause /proc/self/maps
to be re-read.  Unfortunately we do have to re-read /proc/self/maps for mmap(),
because we don't know the filename from the mmap() call (only the file
descriptor, which isn't enough).


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@1830
2003-09-25 17:54:11 +00:00
Nicholas Nethercote
c0f0059bf7 Added some skin-visible functions that give skins a bit more control over
how stack snapshots are taken and printed;  they can be used in preference
to VG_(get_ExeContext)() and VG_(pp_ExeContext)().  These are used by
Massif, my heap profiling skin.

Changed --num-callers to allow a backtrace size of 1.

Added code so that when Valgrind fails to disassemble an instruction, the
instructions line/file and address are printed out, which makes it easier to
work out where and what it is.  Required the stack snapshot changes above.

MERGE TO STABLE?


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@1819
2003-09-16 07:41:43 +00:00
Julian Seward
b3ff4b514a Do the symbol substitution game for glibc-2.2.93 too (Red Hat 8).
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@1762
2003-07-16 19:59:59 +00:00
Julian Seward
2b50eb4a3b VG_(setup_code_redirect_table): do errno etc entry-point redirection
for glibc-2.3.1 too.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@1758
2003-07-14 20:50:36 +00:00
Julian Seward
79eff13d46 Refine the PLT-bypassing-bypassing machinery so it works on Red Hat 9.
This means we are now are zero regression test failures on RH9 too.  Yay.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@1752
2003-07-13 00:53:22 +00:00
Julian Seward
e4397da1ca A bit of cleaning up now that symbol table reading is no longer optional.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@1745
2003-07-10 23:31:27 +00:00
Julian Seward
1f01517ca3 Add a new mechanism for intercepting calls, which doesn't depend on
the vagaries of the dynamic linker.  In particular this has been
devised so as to work around errno/h_errno/resolver-state misbehaviour
caused by excessive PLT bypassing in glibc-2.3.2: we need to intercept
calls to __errno_location(), __h_errno_location() and __res_state(),
in threaded programs, but we can't always do that because some calls
made internally within glibc-2.3.2 bypass the PLT.

New mechanism is:

- In vg_symtab2.c, VG_(setup_code_redirect_table), search the
  symbol tables to find the entry points of the above functions,
  and find the corresponding entry points replacements in our
  vg_libpthread.c.  Put these pairs into a table,
  VG_(code_redirect_table).

- In vg_translate.c, VG_(translate), consult the table each time
  a translation is made, and if a hit is found, translate from
  the substitute address instead.

This seems to make corecheck/tests/res_search work properly,
although for some as-yet unknown reason breaks the corecheck
skin.  All other skins appear unaffected.

One unfortunate effect is that the lazy debug info scheme is now
nullified, since we always need to read debug info in order to
generate the redirection table.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@1743
2003-07-10 00:17:58 +00:00
Dirk Mueller
faf02201e5 spelling fixes
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@1715
2003-07-04 16:18:15 +00:00
Julian Seward
07258f73de gcc-3.3 as supplied with SuSE 8.2 ("gcc version 3.3 20030226
(prerelease) (SuSE Linux)") seems to complain about signed-vs-unsigned
comparisons, when -Wall is on.  This commit fixes (most of) those
complaints.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@1638
2003-05-18 10:05:38 +00:00