mirror of
https://github.com/Zenithsiz/ftmemsim-valgrind.git
synced 2026-02-03 18:13:01 +00:00
of memcheck and helgrind in a common module: pub_tool_addrinfo.h pub_core_addrinfo.h m_addrinfo.c At the same time, the factorised code is made usable by other tools also (and is used by the gdbserver command 'v.info location' which replaces the helgrind 'describe addr' introduced 1 week ago and which is now callable by all tools). The new address description code can describe more addresses (e.g. for memcheck, if the block is not on the free list anymore, but is in an arena free list, this will also be described). Similarly, helgrind address description can now describe more addresses when --read-var-info=no is given (e.g. global symbols are described, or addresses on the stack are described as being on the stack, freed blocks in the arena free list are described, ...). See e.g. the change in helgrind/tests/annotate_rwlock.stderr.exp or locked_vs_unlocked2.stderr.exp The patch touches many files, but is basically a lot of improvements in helgrind output files. The code changes are mostly refactorisation of existing code. git-svn-id: svn://svn.valgrind.org/valgrind/trunk@13965
58 lines
1.4 KiB
C
58 lines
1.4 KiB
C
#include <stdlib.h>
|
|
/* To be run with --freelist-vol=1000000 --freelist-big-blocks=50000 */
|
|
static void jumped(void)
|
|
{
|
|
;
|
|
}
|
|
int main(int argc, char *argv[])
|
|
{
|
|
char *semi_big = NULL;
|
|
char *big = NULL;
|
|
char *small = NULL;
|
|
char *other_small = NULL;
|
|
int i;
|
|
int j;
|
|
|
|
/* Verify that access via a dangling pointer to a big block bigger than
|
|
the free list is found by memcheck (still on the free list). */
|
|
semi_big = malloc (900000);
|
|
big = malloc (1000015);
|
|
free(semi_big);
|
|
free(big);
|
|
if (big[1000] > 0x0) jumped();
|
|
if (semi_big[1000] > 0x0) jumped();
|
|
|
|
/* Then verify that dangling pointers for small blocks is not hampered
|
|
by doing big alloc/free. */
|
|
small = malloc (10000);
|
|
free(small);
|
|
|
|
/* We should still have a nice error msg for the semi_big
|
|
but not for the big block, which has been removed from the free list
|
|
with the malloc of small above. */
|
|
if (big[2000] > 0x0) jumped();
|
|
if (semi_big[2000] > 0x0) jumped();
|
|
|
|
big = NULL;
|
|
|
|
{
|
|
big = malloc (1000015);
|
|
free(big);
|
|
if (small[10] > 0x0) jumped();
|
|
|
|
/* Do not common up the below in a loop. We
|
|
want a different error/stack trace for each of
|
|
these. */
|
|
if (big[10] > 0x0) jumped();
|
|
}
|
|
|
|
|
|
for (i = 0; i < 100; i++) {
|
|
other_small = malloc(10000);
|
|
for (j = 0; j < 10000; j++)
|
|
other_small[j] = 0x1;
|
|
}
|
|
if (small[10] > 0x0) jumped();
|
|
return 0;
|
|
}
|