Commit Graph

101 Commits

Author SHA1 Message Date
Nicholas Nethercote
10b4595add Added beginnings of an AMD64 port, so lots of new files and directories.
It compiles, but aborts immediately if you try to run it.

I didn't include ldt.c;  I'm not sure how the LDT is used on AMD64.  It can be
added later if necessary.

While doing this, did some 64-bit cleanness fixes:
- Added necessary intermediate casts to ULong to avoid warnings when converting
  ThreadId to void* and vice versa, in vg_scheduler.c.
- Fixed VALGRIND_NON_SIMD_CALL[0123] to use 'long' as the return type.
- Fixed VALGRIND_PRINTF{,BACKTRACE} to use unsigned longs instead of unsigned
  ints, as needed.
- Converted some offsets in vg_symtab2.h from "Int" to "OffT".
- Made strlen, strncat, etc, use SizeT instead of 'unsigned int' for the length
  parameter.
- Couple of other minor things.

I had to insert some "#ifdef __amd64__" and "#ifndef __amd64__" guards in
places.  In particular, in vg_mylibc.c, some of our syscall wrappers aren't
appropriate for AMD64 because the syscall numbering is a bit different in
places.  This difference will have to be abstracted out somehow.

Also rewrote the sys_fcntl and sys_fcntl64 wrappers, as required for AMD64.

Also moved the ipc wrapper into x86, since it's not applicable for
AMD64.  However, it is applicable (I think) for ARM, so it would be nice
to work out a way to share syscall wrappers between some, but not all,
archs.  Hmm.  Also now using the real IPC constants rather than magic
numbers in the wrapper.

Other non-AMD64-related fixes:
- ARM: fixed syscall table by accounting for the fact that syscall
  numbers don't start at 0, but rather at 0x900000.
- Converted a few places to use ThreadId instead of 'int' or 'Int' for
  thread IDs.
- Added both AMD64 and ARM (which I'd forgotten) entries to valgrind.spec.in.
- Tweaked comments in various places.




git-svn-id: svn://svn.valgrind.org/valgrind/trunk@3136
2004-11-29 13:54:10 +00:00
Julian Seward
86ef8a5a44 Get rid of all vestiges of translation-chaining, and generally clean
up and paranoidise the translation cache management.



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@3134
2004-11-28 16:58:05 +00:00
Nicholas Nethercote
4399d9700f Added beginnings of an ARM port, to the point where it compiles. It does not
run, though.  There are lots of stubs to be filled in.  (The asm ones currently
just have "swi" in them, which seems to cause seg faults.) 

Also, some of the macros are decided dubious, especially:

  ARCH_* are bogus
  SYSCALL_RET is bogus
  PLATFORM_SET_SYSCALL_RESULT is bogus
  not sure about SET_SYSCALL_RETVAL
  FIRST_STACK_FRAME et al -- bogus?
  VG_MAX_JUMPS ?

And in stage2.lds, the 0x8048000 is almost certainly wrong


This required some tweakings of the core:
- some of the vki_*.h kernel types were fixed up

- had to disable the AM_PROG_CC_C_O macro in configure.in, because automake
  (autoconf?) didn't like it...

- some "#ifdef __x86__" guards were introduced, for nasty x86 things I don't
  yet know how to factor out (trampoline page muck, sysinfo page muck).

- fixed a minor stupidity in vg_proxylwp.c.

- moved the ptrace wrapper into the x86-linux part

- had to change the intercept mangling scheme, to use 'J' instead of '$' as the
  escape char because GCC didn't like '$'.  This is all very dubious, and only
  works because none of our intercepted symbols contains a 'J'.  To be fixed up
  ASAP.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@3120
2004-11-26 19:34:36 +00:00
Julian Seward
4c21141359 More debug printing for redirections (disabled).
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@3117
2004-11-26 15:06:13 +00:00
Julian Seward
3558db91b1 Get rid of baseBlock. Now, when generated code is running, the guest
state pointer points directly at the ThreadState.arch.vex field, thus
updating it in place and avoiding a lot of code (and time-wasting)
which copies stuff back and forth to baseBlock.

Fix zillions of other places in the system where the current thread id
is needed.  It is now passed to all needed places.



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@3090
2004-11-24 10:44:19 +00:00
Julian Seward
166033939c Do our own implementations of strchrnul() and rawmemchr().
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@3075
2004-11-23 00:20:17 +00:00
Nicholas Nethercote
d8fc746ba4 64-bit cleanness: Yet more UInt-->SizeT changes.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2910
2004-11-03 18:10:37 +00:00
Nicholas Nethercote
3af1e3e24b 64-bit cleanness: More UInt-->SizeT changes.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2909
2004-11-03 17:07:46 +00:00
Tom Hughes
6318f7c944 Make sure source-location mapping entries of size zero are converted
to size one even if verbose more is off.

BUG: 92528


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2894
2004-11-01 17:36:15 +00:00
Nicholas Nethercote
c4cf15dc21 Arch-abstraction:
- Added include/x86-linux/ and include/linux/ subdirectories, with Makefile.am
  files.

- Overhauled the definitions of kernel types.  include/vg_kerneliface.h is now
  three files, include/linux/vki.h, include/x86-linux/vki_arch.h, and
  include/x86-linux/vki_arch_posixtypes.h.  These files separate the
  common/Linux and x86/Linux parts cleanly.  All code is copied verbatim from
  the relevant kernel headers, except that VKI_/vki_ prefixes are added as
  necessary to distinguish them from glibc types.  (This is done consistently,
  unlike previously when some types did not have the prefixes.)

  All code is clearly marked to show which particular header file it came from,
  and the Linux version used.  (I used 2.6.8.1, the most recent stable release,
  for all of them.)

  A few of the types changed;  this is because they changed between the older
  versions of Linux and the current 2.6.8.1.  I checked that all these changes
  were ok with respect to backwards compatibility for our purposes.

- vg_unsafe.h has been removed;  we are no longer including any kernel headers,
  as we have our own copies for everything.  This is because installed kernel
  headers are not reliable, and often cause compilation problems. (bug
  #92420 is a recent example)

- Removed some no-longer-needed header-presence tests from configure.in.

- Some code in the rest of Valgrind was changed to account for some slight
  changes in the names of our VKI_/vki_ kernel constants and types.

- Updated README_MISSING_SYSCALL_OR_IOCTL accordingly.

- Fixed off-by-one error with VKI_GDT_ENTRY_TLS_MAX (merged from stable branch)

The end result is that the kernel types situation should be much clearer, and
similar files can be created relatively easily for other architectures as
necessary.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2884
2004-10-31 18:48:21 +00:00
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