core only functions (vg_assert and VG_(core_panic)), which screwed things up.
Replaced them with the skin versions. I don't know how this ever worked.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@1450
Fixed demangler bug -- it was relying on glibc for some functions. This
triggered an incredibly obscure bug in my experimental skin -- memcpy() was
called within the demangler at (about?) the same time as the dynamic linker was
fiddling with the memcpy() entry, which caused one word of memory (probably
some counter in the dynamic linker) to be incremented, which my skin didn't
like.
So I removed all (AFAICT) of the demangler's dependencies on glibc. This
required adding macros for memset, memcpy, strlen, strcmp..., to replace them
with their VG_(...) version. The only #includes now are to .h files that are
part of Valgrind.
Also required #defining "size_t" as "Int".
Also required adding VG_(memcmp)() to vg_mylibc.c.
Also removed the "-1 == EOF" part of the compile-time test in safe-ctype.h
that checks the character set is ASCII. This was to remove the dependency
on stdio.h. Slightly dodgy, but should be ok I think/hope.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@1436
VG_(handle_esp_assignment)() was needed by a skin (and thus whether to register
it in the baseBlock) was different to that used when determining whether to
call it in code generation... so it could be (attempted to be) called having
not been registered.
Fixed this by consistifying the conditions, using a function
VG_(need_to_handle_esp_assignment)() that is used in both places. The bug
hadn't been found previously because no existing skin exercised the mismatched
conditions in conflicting ways.
Also took VG_(track).post_mem_write out of consideration because it's no longer
important (due to a change in how stack switching is detected).
----
Improved the error message for when a helper can't be found in the baseBlock --
now looks up the debug info to tell you the name of the not-found function.
----
Increased the number of noncompact helpers allowed from 8 to 24
----
Removed a magic number that was hardcoded all over the place, introducing
VG_MAX_REGS_USED for the size of the arrays needed by VG_(get_reg_usage)()
----
Also added these functions
VG_(get_archreg)()
VG_(get_thread_archreg)()
VG_(get_thread_shadow_archreg)()
VG_(set_thread_shadow_archreg)()
which can be useful for skins.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@1419
100 bytes (added VG_DEFAULT_TRANS_SIZEB). Took the now-unnecessary settings
out of Nulgrind and CoreCheck. Also made .avg_translation_sizeB a UInt (from
an Int), to avoid possibility of negatives.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@1413
VG_(get_shadow_archreg), VG_(set_shadow_archreg), VG_(shadow_archreg_address).
Curiously, the only way skins could previously access them was with
VG_(shadow_reg_offset), which wasn't very flexible.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@1412
with similar functions, and made it visible to skins (useful).
Also bumped up the skin interface minor version number due to this change; this
bumping will cover any other binary-compatible changes between now and the next
release (after 1.9.3).
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@1410
Also added declaration for VG_(get_error_where)() to vg_skin.h (which should
have been included with the last commit).
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@1407
asked-for feature.
A leak-check suppression looks like any other, and has the name 'Leak':
{
example-leak-suppression
Memcheck,Addrcheck:Leak
fun:malloc
fun:foo
fun:main
}
Fitting this into the core/skin split proved very tricky. Problem is
we want to scan the suppressions list to find Leak suppressions, but
- The core code can't do it because LeakSupp is a skin-specific
suppression kind.
- The skin code can't do it because most (all) of the types and
structures for the suppressions are private to the core.
Eventual "solution" (least-worst thing I could think of) is for the
skins using the leak checker to pass it the value of LeakSupp.
Even that isn't really clean because the skins consider it a value
of type MemCheckSuppKind but the core thinks it must be a
CoreSuppKind, and the two are not to be reconciled. So I kludged
around this by casting it to a UInt.
Nick, perhaps you know some way to smooth this out?
Apart from that all changes are straightforward.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@1390
adding offsets ("+N") to the end of function names. Make a new
function VG_(get_fnname_w_offset) with that behaviour and use it for
%y in VG_(printf) et al.
This is needed so that all addresses within a function generate the
same function name. The offset'd behaviour was breaking the cache
profiler and dependent program kcachegrind.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@1381
72-jump
Add some codegen infrastructure to make it easier to generate local
jumps. If you want to generate a local backwards jump, use
VG_(init_target)(&tgt) to initialize the target descriptor, then
VG_(emit_target_back)(&tgt) just before emitting the target
instruction. Then, when emitting the delta for the jump, call
VG_(emit_delta)(&tgt).
Forward jumps are analogous, except that you call VG_(emit_delta)()
then VG_(emit_target_forward)().
The new emit function, VG_(emit_jcondshort_target)() takes a target
pointer rather than a delta.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@1364
- D flag is seperated from the rest (OSZCAP)
- Minimise transfers between real and simulated %eflags since these
are very expensive.
61-special-d
Make the D flag special. Store it separately in the baseblock rather
than in EFLAGs. This is because it is used almost completely unlike
the other flags, and mashing them together just makes maintaining
eflags hard.
62-lazy-eflags
Implements lazy eflags save and restore. Helps a lot.
Hopefully more documentation to follow.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@1346
50-fast-cond
Implement Julian's idea for fast conditional jumps. Rather than fully
restoring the eflags register with an expensive push-popf pair, just
test the flag bits directly out of the base block. Faster, and smaller
code too!
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@1339
This commit adds stats gathering / printing (use -v -v), and selection
of sector size decided by asking skins, via
VG_(details).avg_translation_sizeB, the average size of their
translations.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@1334
27-nvalgrind
Make valgrind.h pay attention to the preprocessor symbol NVALGRIND. If
defined, it compiles out the Valgrind magic sequence and just assigns
the result with the default return. This is analogous to NDEBUG's
effect on assert().
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@1320
that changes will cause binary incompatibilities. Mostly done by hiding naked
structs with function calls.
Structs hidden in this way were: UCodeBlock, SkinSupp and SkinError (which were
merged back with CoreSupp and CoreError into single types Supp and Error),
ShadowChunk, VgDetails, VgNeeds and VgTrackEvents. The last three are the most
important ones, as they are (I think) the most likely to change.
Suitable get()/set() methods were defined for each one. The way UCodeBlocks
are copied for instrumentation by skins is a little different now, using
setup_UCodeBlock. Had to add a few other functions here n there. Changed
how SK_(complete_shadow_chunk) works a bit.
Added a file coregrind/vg_needs.c which contains all the get/set functions.
It's pretty simple.
The changes are not totally ideal -- eg. ShadowChunks has get()/set() methods
for its `next' field which arguably shouldn't be exposed (betraying the fact
that it's a linked list), and the get()/set() methods are a bit cumbersome at
times, esp. for `Error' because the fields are accessed quite a few times, and
the treatment of Supps and Errors is a bit inconsistent (but they are used in
different ways), and sizeof_shadow_blocks is still a hack. But still better
than naked structs. And one advantage is that a bit of sanity checking can be
performed by the get()/set() methods, as is done for VG_({get,set}_sc_extra)()
to make sure no reading/writing occurs outside the allowed area.
I didn't do it for UInstr, because its fields are accessed directly in lots and
lots of spots, which would have been a great big pain and I was a little
worried about overhead of calling lots of extra functions, although in practice
translation times are small enough that it probably doesn't matter.
Updated the example skin and the docs, too, hurrah.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@1314
39-lock-prefix
Add a new UInstr LOCK to represent a "lock" prefix in the instruction
stream. This has the same semantics as NOP, but allows a skin to tell
whether a group of UInstrs associated with an x86 instruction are
meant to be locked.
HELGRIND: uses the LOCK UInstr to automatically take and release a
special __BUS_HARDWARE_LOCK__ around locked instructions. This only
works properly if all instructions touching a given address are locked
(even reads).
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@1310
33-pre_mutex_lock
HELGRIND: two updates: add a pre_mutex_lock tracking function, so the
skin can do something before the thread blocks. This allows us to do
lock ordering tests before the thread blocks in the deadlock we'd like
to report...
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@1306
32-hg-lifetime-segments
HELGRIND: implement the algorithm described in "Runtime Checking of
Multithreaded Applications with Visual Threads". Rather than working
with thread IDs, this algorithm breaks the lifetime of a thread up
into thread lifetime segments, and arranges them in an interference
graph.
If a memory location is in exclusive state and it is touched by
another thread, it compares the TLSs of the old owner and the new
thread. If the two TLSs can't possibly overlap in time (for example,
one TLS is the parent before a child thread is created, and the other
TLS is the child thread) the memory location's ownership is
transferred rather than moving it into a shared state. This allows a
parent thread to set up some memory and then create a new child,
handing ownership of that memory to the child, without generating
spurious errors.
At present the only synchonization events used to create new TLSs are
thread create and thread join, though in principle any synchronization
event would work.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@1305
31-hg-shadow-execontext
HELGRIND: Add option to record ExeContext for every word access. This
is probably very slow and memory hungry, but it helps make the error
reports more useful. Defaults to off.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@1304
macro VG_DETERMINE_INTERFACE_VERSION exactly once. If the X.Y core and skin
versions don't have a matching X (indicating binary incompatibility), Valgrind
will abort execution immediately at startup.
I even documented it in the skins guide!
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@1279
14-hg-mmap-magic-virgin
This does two things:
1. change the signatures of the new_mem_mmap and change_mem_mprotect
functions to remove the pointless 'nn' argument. This makes them match
the signature of new_mem_startup...
2. change helgrind to mark memory created by mmap as if it were the
same as other magically pre-inited memory. Implement this by pointing
helgrind's new_mem_mmap function at new_mem_startup.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@1263
13-kill-1ifroot
Kill VG_(get_current_tid_1_if_root)() and replace it with the slightly
more appetising (though still hackish)
VG_(get_current_or_recent_tid)(). This is intended for use when
there's no thread actually loaded into the baseblock, but we're doing
work on behalf of the the thread that was last running (such as during
a syscall).
This probably fixes a bug with helgrind misattributing memory created
with mmap to thread 1 rather than the thread which called mmap (though
the behaviour is still probably wrong: mmapped memory should be
magically_inited).
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@1262
14-sprintf
Update to core VG_(printf)/sprintf/vprintf. They've been modified to
return the number of characters they generated (either printed, put
into the buffer, or sent). Also adds a new %y format, which takes an
Addr argument and looks up a symbol. It takes a '(' flag (ie: "%(y")
which surrounds the symbol in parens if it could be found.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@1253
08-skin-clientreq
Introduce a systematic way for skins to distinguish each other's
client requests. Uses the de-facto standard two-letter identifiers in
the top two bytes of the client request code. Also changes the
interface to SK_(handle_client_request) so that a skin can say whether
or not it handled the request, which allows correct setting of the
default return value if the request was not handled.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@1251
and Addrcheck. In coregrind/vg_memory.c, create
void VG_(generic_detect_memory_leaks
and remove several hundred lines of code from both ac_main.c and mc_main.c.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@1250
14-hg-tid
HELGRIND: This fixes a bug in Helgrind in which all memory access by
syscalls was being treated as if it were happening in thread 1. This
is because the eraser_mem_read/write functions were using
get_current_tid_1_if_root() to get the current tid. Unfortunately,
during syscalls there is no current thread, so it was getting
1_if_root. This patch fixes this by using what thread ID information
we're given, and only using get_current_tid() if we're recording a
memory access performed by code (rather than by a syscall).
... which relies on ...
06-memops
Implement VG_(memcpy/memset).
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@1247
Fix to the ELF file reader to make sure that each SegInfo includes not
only the text mapped from an ELF file, but also the data and bss. This
allows the data symbols to be extracted. Also adds a new needs boolean
to allow a skin to specify if it needs data symbols. As a nice
side-effect, it removes the "offset" hack: the offset is the mapped
address in the ELF Phdr: it is (mapped_address - phdr_vaddr).
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@1246
files, into vg_skin.h:
uInstr0, uInstr1, uInstr2, uInstr3, nameIReg, nameISize, nameSReg,
newTemp, newShadow, uLiteral, uCCall
As macros they avoid namespace problems (they expand to VG_(whatever)) so
this should work fine.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@1182
Added "version" and "copyright_author" fields for skins to supply.
Now startup message looks something like this:
==12698== cachegrind, an I1/D1/L2 cache profiler for x86-linux.
==12698== Copyright (C) 2002, and GNU GPL'd, by Nicholas Nethercote.
==12698== Built with valgrind-HEAD, a program execution monitor.
==12698== Copyright (C) 2000-2002, and GNU GPL'd, by Julian Seward.
==12698== Estimated CPU clock rate is 1422 MHz
==12698== For more details, rerun with: -v
The skin can specify a version number, but the skins that will be distributed
with Valgrind don't.
Also changed "x86 GNU/Linux" to the wicked "x86-linux" at Julian's request.
Updated default regression test filter to handle this new startup message.
----
Also moved the skin's name, description, etc., fields out of VG_(needs) into a
new struct VG_(details), since they are logically quite different to the needs.
Did a little code formatting, etc., for this. Updated skin docs
correspondingly, too.
Also renamed the need `run_libc_freeres' --> `libc_freeres' so it's a noun
phrase rather than a verb phrase.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@1172
from core error ones:
- Split up VG_(panic) into VG_(core_panic) and VG_(skin_panic)
- Likewise, split vg_assert into vg_assert and sk_assert
- Added a new need string: `bug_reports_to'
- Removed VG_(skin_error) which was a previous wussy attempt at this change.
This removed the need for the hacky redeclaration of VG_(skin_error) in
vg_profile.c, which is good.
At the moment, Julian and Nick's email addresses are hard-coded into each skin
individually, rather than using a #define in vg_skin.h, because that didn't
feel quite right to me... jseward@acm.org is still done with a #define for
core errors, though.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@1164
- New core uinstrs, GETSEG, PUTSEG (save and restore segment regs)
- New core uinstr USESEG, which takes a segment selector and a
virtual address, and returns a linear address -- and also does
a limit check. This calls through to VG_(use_ldt) in vg_ldt.c.
- Insn parser (disAMode) made aware of segment override prefixes
- Obvious fixes to insn emitter and translators
None of the skins understand these new uinstrs, so only --skin=none
works with them at the mo. This and some other rough edges still
need to be fixed.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@1139
use_under_scores instead, to be consistent.
Also added some missing 'extern's on function declarations in vg_skin.h.
Also added a quick note in vg_regtest.in on the simplest way to run regression
tests.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@1135
- changed lots of Makefile.am files
- changed configure.in
- changed lots of #include lines for changed file names
- changed lots of file headers n footers for changed file names
- changed vg_regtest to handle new directory structure -- recursively
traverses subdirectories for .vgtest test files
- changed lots of paths in memcheck/ regression test expected outputs
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@1090