112 Commits

Author SHA1 Message Date
Nicholas Nethercote
f474d2e51a A modularisation + refactoring commit. vg_execontext.c has been split into
two halves: stacktrace.c, which deals with getting, traversing and printing
stack traces;  and execontext.c, which deals with storing stack traces
permanently in a way that avoids duplicates, and comparing them.

One nice outcome:  previously we were often creating ExeContexts, which live
forever, even when they were only needed temporarily.  Ie. this was a memory
leak, which has been removed.

As part of this, new headers have been created, carved off core.h and
tool.h.  Lots of function names have changed, too.

In Massif, I also changed a lot of "eip" names to "ip" to make them less
x86-specific.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@3429
2005-03-25 23:35:48 +00:00
Julian Seward
0356d27ca6 Merge in changes from the 2.4.0 line. This basically brings in the
overhaul of the thread support.  Many things are now probably broken,
but at least with --tool=none, simple and not-so-simple threaded and
non-thread programs work.



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@3265
2005-03-10 23:59:00 +00:00
Nicholas Nethercote
7a75a9f583 Overhauled the docs. Removed all the HTML files, put in XML files as
converted by Donna.  Hooked it into the build system so they are only
built when specifically asked for, and when doing "make dist".

They're not perfect;  in particular, there are the following problems:
- The plain-text FAQ should be built from FAQ.xml, but this is not
  currently done.  (The text FAQ has been left in for now.)

- The PS/PDF building doesn't work -- it fails with an incomprehensible
  error message which I haven't yet deciphered.

Nonetheless, I'm putting it in so others can see it.



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@3153
2004-11-30 10:43:45 +00:00
Nicholas Nethercote
7a04aed730 Introduced build variables VG_ARCH_ALL, VG_OS_ALL, and VG_PLATFORM_ALL,
which list all the arches/OSes/platforms supported.  These are used by
several newly added DIST_SUBDIRS automake commands, which specify that
although when you are building you only want to build for the current
arch/OS/platform, when you do 'make dist' you want every
arch/OS/platform to get included.



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@3127
2004-11-27 16:47:42 +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
Nicholas Nethercote
196e8dfd25 Removed the now-defunct files vg_from_ucode.c and vg_to_ucode.c.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@3073
2004-11-22 21:23:08 +00:00
Julian Seward
b3498dd85c Merge in enough changes from the old Vex tree to make stage2 link, at
least.



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@3061
2004-11-22 19:01:47 +00:00
Nicholas Nethercote
2f787498e8 Arch-abstraction:
- Moved some more syscall wrappers into linux/syscalls.c and
  x86-linux/syscalls.c.  There are still heaps of wrappers that probably aren't
  generic, but I'm not sure, so they're staying in vg_syscalls.c for now.
  Let's worry about that when we do an OS port.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@3036
2004-11-17 18:22:38 +00:00
Nicholas Nethercote
d0ef8153b4 Arch-abstraction:
- Moved the system call table into x86-linux, since it's platform specific.

- Started moving the non-generic syscall wrappers into linux/syscalls.c and
  x86-linux/syscalls.c as appropriate.

- Added new coregrind/linux/ directory and some files in it.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@3034
2004-11-17 17:11:45 +00:00
Nicholas Nethercote
1524d5ac06 Converted the last syscalls. Phew. Still some cleaning up to do, esp. with
socketcall() and ipc() which are done too simplistically.

Also, VG_([gs]et_thread_area)() both now return -VKI_EFAULT if they are given a
NULL pointer.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@3024
2004-11-16 17:13:24 +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
Tom Hughes
77c5cb0085 Add -fno-omit-frame-pointer when building libpthread.so as that gets
loaded into the user's program and we want to be able to trace the
stack properly. Also add -fpic given that the code is going into a
shared library.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2869
2004-10-28 13:47:14 +00:00
Tom Hughes
1475455567 Leave frame pointers in for the code in lib_replace_malloc.a as
valgrind likes to be able to trace the stack out of malloc etc.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2854
2004-10-26 15:55:46 +00:00
Nicholas Nethercote
90c4861e79 Revert last commit because stupid older versions (eg. 1.6.3) of automake can't
handle it.  Pah.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2836
2004-10-25 19:13:41 +00:00
Nicholas Nethercote
8afd755e7d Fix up stage2's dependencies.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2835
2004-10-25 17:59:43 +00:00
Nicholas Nethercote
ea8dfa8f34 If PIE (position-independent executables) are supported, build valgrind's
stage2 as one.  This means that we're not hard-wiring stage2 in at 0xb0000000,
which means our memory layout is a bit more flexible, yay.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2833
2004-10-25 17:18:24 +00:00
Nicholas Nethercote
8d5541b229 Arch-abstraction:
- factor out different CFLAGS in Makefiles


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2829
2004-10-25 15:21:00 +00:00
Nicholas Nethercote
d611af0e22 Arch-abstraction:
- factor out KICKSTART_BASE


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2828
2004-10-25 14:05:56 +00:00
Nicholas Nethercote
d343add11a Build vg_replace_malloc.c into a library, because it makes the Makefiles a bit
neater.  Also remove some dodgy CFLAGS+= lines.

I had to change the expected output of pth_once.c, because the change has
altered the order of the (non-deterministic) output.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2825
2004-10-20 18:40:40 +00:00
Nicholas Nethercote
3e21a5a1fd Whoops, syscall.S is platform-specific, and so must go in x86-linux/ rather
than x86/.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2800
2004-10-19 14:23:46 +00:00
Nicholas Nethercote
4b44d1df7d Arch-abstraction:
- Moved all assembly files in coregrind/ into coregrind/x86/.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2799
2004-10-19 13:48:06 +00:00
Nicholas Nethercote
266836ab69 Arch-abstraction:
- Factored out the remaining arch-specific code from vg_libpthread.c.
- Also fixed up the build process for x86/libpthread.c, which was done
  wrongly in the previous commit.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2798
2004-10-19 13:18:00 +00:00
Nicholas Nethercote
493933b1c6 Arch-abstraction: a nice change that removes the need for ume_entry.S. Instead
of using an assembly hack to find the stack pointer at startup, we find it from
argv.  It's much simpler, avoids linking games, is platform independent, and
works on PPC.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2782
2004-10-18 11:52:17 +00:00
Nicholas Nethercote
11c046a9b9 Arch-abstraction: replace direct mentions of x86/ directory with ${VG_ARCH}.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2763
2004-10-14 09:48:34 +00:00
Nicholas Nethercote
7942c92bd6 Some combined cleaning up and arch-abstraction, involving UME and start-up:
- removed some assumptions that arch==x86 in Makefile.am files

- removed ume_arch.h;  moved its contents into ume.h.  There was no need for
  these to be separate.

- moved ume_go.c into an x86/ subdir;  gave it the more meaningful name
  jmp_with_stack.c in the process (the corresponding function also got the name
  change)


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2757
2004-10-13 17:55:31 +00:00
Nicholas Nethercote
15b8a2af00 Stage2 doesn't need ume_go.c.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2754
2004-10-13 16:36:03 +00:00
Nicholas Nethercote
fcae323a88 Arch-abstraction:
- move LDT stuff out of core, into x86-linux specific stuff.  Some of it
  (VG_(do_useseg)()?) may be really x86-specific, rather than
  x86/linux-specific, but that can be fixed later if it's really shared with
  another OS.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2748
2004-10-13 13:05:20 +00:00
Nicholas Nethercote
5e8f6e1293 vg_replace_malloc.c doesn't need to be included in "make dist", because it's
generated from vg_replace_malloc.c.base.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2700
2004-09-11 23:07:22 +00:00
Nicholas Nethercote
a8d85f7180 Arch-abstraction:
- create coregrind/x86-linux/ directory.
- move vg_unistd.h into x86-linux/, because it's platform-dependent.  Also
  rename it as vki_unistd.h to make clear it's a kernel interface thing.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2681
2004-09-10 14:23:59 +00:00
Nicholas Nethercote
2a1a81befa Arch-abstraction: arch-neutralise the startup message.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2667
2004-09-06 15:34: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
90369deb78 Arch-abstraction:
- renamed "vg_constants.h" as "core_asm.h".
- renamed "vg_constants_skin.h" as "tool_asm.h".
- renamed "mc_constants.h" as "mc_asm.h".


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2650
2004-09-02 15:37:39 +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
acd57ac595 Use Makefile.am includes. This gets rid of 110 lines of repetitive Makefile.am
cruft, yay!


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2641
2004-09-01 23:20:49 +00:00
Nicholas Nethercote
a03b974a90 'valgrind' (ie. stage1) does not need to be installed in $PREFIX/lib/valgrind/;
$PREFIX/bin/ is enough.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2640
2004-09-01 11:33:35 +00:00
Nicholas Nethercote
3df220384a Change things so that stage2's location is controlled by a single variable.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2620
2004-08-25 16:16:56 +00:00
Nicholas Nethercote
cfebbd9108 Fix symlinking -- the old code worked, but worked for the wrong reason; the
bit before "$(subdir)" has to specify the path from .in_place/ to the root.
It just so happened that $(top_builddir) was the same for all directories at
the same level in the hierarchy as .in_place/ (ie. one deep).

(I haven't bothered changing it in all the tool Makefile.am files, because I'll
do that when I factor out all their common bits into a single file, be it
before or after 2.2.0 is released.)


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2616
2004-08-25 11:57:21 +00:00
Nicholas Nethercote
472d50b40a Merged Valgrind's heap and stack. This has two main advantages:
1. It simplifies various things a bit.

2. Valgrind/tools will run out of memory later than currently in many
circumstances.  This is good news esp. for Calltree.

Some things were going in V's 128MB heap, and some were going in V's 128MB map
segment.  Now all these things are going into a single 256MB map segment.
stage2 has been moved down to 0xb0000000, the start of the 256MB map segment.
The .so files needed by it are placed at 0xb1000000 (that's the map_base).

This required some bootstrapping at startup for memory -- we need to allocate
memory to create the segments skip-list which lets us allocate memory...
solution was to make the first superblock allocated a special static one.
That's pretty simple and enough to get things going.

Removed vg_glibc.c which wasn't doing anything anyway.

Removed VG_(brk) and associated stuff, made all the things that were calling it
call VG_(mmap)() instead.

Removed VG_(valgrind_mmap_end) which was no longer needed.

Rejigged the startup order a bit as necessary.

Moved an important comment from ume.c to vg_main.c where it should be.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2482
2004-07-15 12:59:41 +00:00
Tom Hughes
a2a0946b8a Make VPATH builds work so that valgrind can be built in a different
directory from the source tree. This resolves bug 83040.

Based on patch from Ralf Wildenhues <Ralf.Wildenhues@gmx.de>.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2450
2004-06-29 09:45:37 +00:00
Oswald Buddenhagen
efb2984d2e make "make dist" work.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2423
2004-06-17 13:25:47 +00:00
Tom Hughes
3561ea08ca Added VG_(cpuid) to replace the various bits of inline assembler used
to query the CPU characteristics as the use of four implicit registers
causes havoc when GCC tries to inline and optimise the assembler.

Fix to bug #79696.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2421
2004-06-16 20:51:45 +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
82aaa16ef9 Fix "make distcheck", and also make sure that the generated archive
contains everything needed to "make regtest".  Bump the version.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2308
2004-03-12 10:51:39 +00:00
Julian Seward
9171770931 Partially unbreak 'make distcheck'.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2307
2004-03-12 01:22:30 +00:00
Dirk Mueller
11fbbb3c91 remove arch subdir for 2.1.1 release
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2282
2004-03-01 03:25:09 +00:00
Jeremy Fitzhardinge
d03690c430 Fix the use of brk. This change removes the requirement for the "real" brk
segment to be moved up to stage2's brk segment.  Instead, Valgrind's
use of brk is simulated with mmap.  In order to prevent any unwanted use
of the process brk segment, it also sets the RLIMIT_DATA to 0, which will
make brk always fail.  glibc's malloc will use mmap to allocate if brk
fails.  We try to intercept glibc's brk, but malloc seems to always use the
library-internal version.  (The client's use of brk has always been simulated,
and is unaffected by this change.)


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2266
2004-02-24 23:42:55 +00:00
Nicholas Nethercote
41dd3b13ee Fix broken "make dist".
Doesn't fix "make distcheck", however, because this happens:

  /usr/bin/ld: cannot open linker script file ../../coregrind/x86/stage2.lds:
  No such file or directory

For some reason I can't work out, that file is built when you make in a CVS
tree, or manually from a "make dist" tarball, but not when you "make
distcheck".


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2239
2004-02-05 14:27:36 +00:00
Nicholas Nethercote
5ec5ade4c2 Killed the terminally wounded --stop-after option.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2238
2004-02-01 17:29:59 +00:00
Nicholas Nethercote
aa5c98c53b Moved stage2.c into vg_main.c. Merged main() and VG_(main)(); VG_(main)()
no longer exists.  One advantage of this is that global
variables/structures needed for communicating between the two can be made
local.  Also, the order in which things happen has been simplified.

This is mostly just a big refactoring.  Startup is now a fair bit easier to
understand.  Dependencies between the various startup stages are fairly well
documented in comments.  Also, --help and --version now work properly --
eg. --help gives tool-specific help if --tool was specified.  There is still
some parts where things could be reordered and/or simplified, and where the
dependencies aren't clear.  These are marked with 'XXX'.

One new feature was added: ability to read options from ~/.valgrindrc and
./.valgrindrc.  Part of this is support for specifying tool-specific options
in the form --toolname:tool-specific-option.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2222
2004-01-24 18:18:54 +00:00
Jeremy Fitzhardinge
75d6dc8434 This change implements the TLS extension to the x86 ABI. This allows
threads to have thread-private data which is quickly accessible via a
segment in the GDT, stored in %gs.  The patch implements the relevent
syscalls (setthreadarea), and also manages switching the VCPU's segment
information at thread context-switch time.  Mostly Tom Hughes' work.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2215
2004-01-21 01:27:27 +00:00