Commit Graph

111 Commits

Author SHA1 Message Date
Nicholas Nethercote
d20b2e7b5a Remove some ancient comments.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@3148
2004-11-29 17:36:48 +00:00
Nicholas Nethercote
61fcb2828d Gave VG_(do_syscall)() a more specific prototype:
Int VG_(do_syscall) ( UInt, UWord, UWord, UWord, UWord, UWord, UWord );

to replace the previous:
  
  Int VG_(do_syscall) ( UInt, ... )

Reason being that sometimes you could get incorrect args passed, when
passing 32-bit ints on 64-bit platforms.  I also added macros
VG_(do_syscall[123456]) to make life easier, and converted all the
relevant calls.




git-svn-id: svn://svn.valgrind.org/valgrind/trunk@3143
2004-11-29 16:49:18 +00:00
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
Nicholas Nethercote
5197cfe79d Last few skin-->tool changes, in various places.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@3063
2004-11-22 19:26:27 +00:00
Nicholas Nethercote
3093a1768b Renamed VG_(skin_panic) as VG_(tool_panic).
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@3057
2004-11-22 18:02:32 +00:00
Nicholas Nethercote
579966ed30 64-bit cleanness wibbles.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2924
2004-11-04 18:56:47 +00:00
Nicholas Nethercote
e59b9df749 64-bit cleanness: introduced OffT type for off_t, used it in a few important
places.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2922
2004-11-04 18:39:22 +00:00
Nicholas Nethercote
6451cc22a2 64-bit cleanness: lots more replacing of UInt with UWord as necessary.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2920
2004-11-04 18:03:06 +00:00
Nicholas Nethercote
506ef239ea 64-bit cleanness: fix some more pointer casts to UInt.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2919
2004-11-04 17:24:57 +00:00
Nicholas Nethercote
3cd28a9282 Format wibbles.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2918
2004-11-04 17:10:24 +00:00
Nicholas Nethercote
7a32118f70 64-bit cleanness: convert some (UInt) casts of pointers to (UWord) casts.
Also, remove some unnecessary (UInt) casts of integers.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2917
2004-11-04 17:02:42 +00:00
Nicholas Nethercote
65b45124ad 64-bit cleanness: replace hard-wired 0xffffffff literals with something less
32-bit-specific.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2914
2004-11-04 13:49:28 +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
c73601d666 64-bit cleanness:
- Use SizeT instead of UInt for new_mem_stack and all the related functions.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2908
2004-11-02 13:29:50 +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
e3c2b6d145 Arch-abstraction:
- use less x86-specific var names


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2842
2004-10-25 20:44:09 +00:00
Tom Hughes
d7c9575904 Use tgkill instead of tkill if it is available. This is the newer and
safer kernel interface to signalling a particular thread and it ensures
you can only send a signal to one of your own threads.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2795
2004-10-18 18:56:25 +00:00
Nicholas Nethercote
f3ef39ea53 Arch-abstraction:
- account for x86's strange argument passing (via memory) for mmap()


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2785
2004-10-18 14:47:48 +00:00
Tom Hughes
38615b9b78 It seems there are some kernels around where the getpid system call has
been changed to return the ID of the thread group leader but which do not
have a gettid system call.

This breaks VG_(gettid) which assumes that the getpid system call will
give the thread ID if the gettid system call does not exist.

The (horrible) solution is to use readlink to see where /proc/self points
when the gettid system call fails.

BUG: 82114


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2771
2004-10-16 10:46:01 +00:00
Tom Hughes
9c1dfedadc Fixed mistake in yesterday's signal trace patch.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2727
2004-09-27 18:57:08 +00:00
Tom Hughes
e340476ce0 When dieing because a fatal signal was received, print a stack trace for
the location where the signal was received rather then the signal handler.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2725
2004-09-26 18:44:06 +00:00
Nicholas Nethercote
2d90ddba44 Fix minor off-by-one error.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2701
2004-09-11 23:27:09 +00:00
Nicholas Nethercote
7615eab7a2 Arch-abstraction:
- abstract out some inline asm


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2696
2004-09-11 15:30:33 +00:00
Nicholas Nethercote
e2385fed91 minor fixes
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2673
2004-09-07 23:15:37 +00:00
Nicholas Nethercote
d897ba2bd1 To get 32-bit programs working on Opteron, VG_(valgrind_end) was recently
changed to name the last byte in Valgrind's section, rather than one past the
last byte.  This was because the last byte is 0xffffffff, and so one past gave
0x0, which screwed things up.

However, when this change was made, all the places where VG_(valgrind_end) is
used weren't adjusted appropriately.  So this commit makes those adjustments.
It also renames the variable as VG_(valgrind_last), which makes the difference
between it and the other VG_(*_end) variables much clearer.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2672
2004-09-07 23:04:49 +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
1246163aab Make VG_(last_run_tid) and VG_(sigstack) local.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2575
2004-08-07 18:16:56 +00:00
Nicholas Nethercote
7bdbf7377f Factor out differences between VG_(system) and PRE(execve). Required moving
mash_colon_env() from vg_syscalls.c to vg_mylibc.c.  Saved 20 lines of code.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2554
2004-08-03 13:08:31 +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
3dc7eebda2 Merge equivalent if statements.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2533
2004-07-28 16:03:29 +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
Nicholas Nethercote
9914c7fe6e Add some more assertion checking where it was lacking.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2477
2004-07-11 18:11:33 +00:00
Nicholas Nethercote
f6a597394d Format wibble.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2473
2004-07-10 17:36:52 +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
e7ca8c07f3 Change allocation failure message which is no longer true thanks to FV.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2465
2004-07-10 16:17:52 +00:00
Nicholas Nethercote
267ce9fcca Fixed variable name mixup, removed no-longer-used VG_STACK_SIZE_W.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2452
2004-06-30 17:34:30 +00:00
Tom Hughes
414846a941 Removed all uses of nested functions as they only work with gcc and
cause the stack to be marked as executable in order for them to work.

All assembler files have also had a declaration added so that the
object they generate will be marked as not needing an executable stack.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2446
2004-06-27 17:37:21 +00:00
Tom Hughes
f9a0e004f5 Implement an emulated soft limit for file descriptors in addition to
the current reserved area, which effectively acts as a hard limit. The
setrlimit system call now simply updates the emulated limits as best
as possible - the hard limit is not allowed to move at all and just
returns EPERM if you try and change it.

This should stop reductions in the soft limit causing assertions when
valgrind tries to allocate descriptors from the reserved area.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2440
2004-06-26 11:27:52 +00:00
Nicholas Nethercote
2fab200ad0 Renamed the following options:
--logfile-fd  -->  --log-fd
  --logfile     -->  --log-file
  --logsocket   -->  --log-socket

to be consistent with each other and other options (esp. --input-fd).  Also
renamed some related variables.  The old names still work, for backwards
compatibility, but they're not documented.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2429
2004-06-21 12:42:35 +00:00
Tom Hughes
bb942b40c8 Add a strrchr implementation.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2407
2004-06-13 09:55:22 +00:00
Jeremy Fitzhardinge
6fd5d698f2 Fix assertion failure when using VG_(system) near program termination.
The problem is that the use of VG_(system) causes a SIGCHLD to be sent
to the process, which ends up being delivered to one of the proxy LWPs
(which is a small problem in itself, but nothing too bad).

The proxy tells the scheduler LWP about this, and the scheduler LWP sends
a sigACK reply.

Then, while the proxy LWP is in the SigACK state, and the SigACK reply
is still queued in the message pipe, the scheduler LWP starts shutting
Valgrind down, and sends a SIGVGKILL to all proxy LWPs.  This causes
the proxy to drop from sigACK state to WaitReq state, and it reads
further commands - one of which is the SigACK message - this causes the
assertion failure.

The fix is to simply make the proxy LWP exit immediately when it gets
a SIGVGKILL, and not process any more requests.

This change also fixes a bug in VG_(system), in which the child process
returns back into Valgrind rather than exiting when exec fails.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2284
2004-03-02 21:38:51 +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
c75d9d3800 "VG_AR_SKIN" --> "VG_AR_TOOL"
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2235
2004-01-26 17:24:42 +00:00
Nicholas Nethercote
24f0c82b8c Patch from Tom Hughes:
Patch to provide a proper environment to the debugger

    Although this patch isn't strictly needed to allow alternative debuggers to
    be used, it is needed if you want to use an X based debugger such as ups
    (and presumably ddd) as VG_(system) has until now passed an empty
    enviroment when starting the debugger but that causes DISPLAY to be lost.

    This patch causes VG_(system) to pass a copy of the client environment
    instead, with the necessary mashing done to clean up the LD_xxx variables.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2233
2004-01-26 17:10:01 +00:00
Jeremy Fitzhardinge
8ac657b2fd Oops, make base static.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2227
2004-01-25 03:44:18 +00:00
Jeremy Fitzhardinge
9875ad6c74 Don't use TSC for internal timing purposes. This is for two reasons:
- old CPUs (and their modern embedded clones) don't implement the TSC
 - new machines with power management, the TSC changes rate, and so is
   useless as a timebase
Valgrind doesn't use read_millisecond_timer very much these days, so
the expense of doing a gettimeofday syscall shouldn't be a huge issue.
Naturally, rdtsc is still available for client purposes (if the host CPU
supports it).


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2226
2004-01-25 03:32:58 +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
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
Jeremy Fitzhardinge
f0bdc7ed7b Fix typo in VG_(munmap)() error checking, which made it never remove
any Segment mappings.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2136
2003-12-20 18:19:50 +00:00
Jeremy Fitzhardinge
5e5641d26b Fix a bug in the last VG_(max_fd) change; VG_(safe_fd) doesn't work before
VG_(max_fd) has been set up.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2128
2003-12-18 07:22:44 +00:00