mirror of
https://github.com/Zenithsiz/ftmemsim-valgrind.git
synced 2026-02-04 18:56:10 +00:00
(1) Detect availability of pthread_setname_np. Ignore testcases
memcheck/tests/threadname[_xml] if not available.
(2) Enable _GNU_SOURCE to avold compiler warnings.
(3) In threadname_xml filter out stackframes referring to system
libraries. Added tests/filter_xml_frames to do that.
(4) Adjust .exp files as needed
(5) Do not ship stdout.exp for memcheck/tests/threadname[_xml].
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@13557
81 lines
1.2 KiB
C
81 lines
1.2 KiB
C
#define _GNU_SOURCE
|
|
#include <stdio.h>
|
|
#include <pthread.h>
|
|
#include <string.h>
|
|
#include <stdlib.h>
|
|
#include <sys/prctl.h>
|
|
#include <sys/types.h>
|
|
#include <unistd.h>
|
|
#include <assert.h>
|
|
|
|
static pthread_t children[3];
|
|
|
|
void bad_things(int offset)
|
|
{
|
|
char* m = malloc(sizeof(char)*offset);
|
|
m[offset] = 0;
|
|
free(m);
|
|
}
|
|
|
|
void* child_fn_2 ( void* arg )
|
|
{
|
|
const char* threadname = "012345678901234";
|
|
|
|
pthread_setname_np(pthread_self(), threadname);
|
|
|
|
bad_things(4);
|
|
|
|
return NULL;
|
|
}
|
|
|
|
void* child_fn_1 ( void* arg )
|
|
{
|
|
const char* threadname = "try1";
|
|
int r;
|
|
|
|
pthread_setname_np(pthread_self(), threadname);
|
|
|
|
bad_things(3);
|
|
|
|
r = pthread_create(&children[2], NULL, child_fn_2, NULL);
|
|
assert(!r);
|
|
|
|
r = pthread_join(children[2], NULL);
|
|
assert(!r);
|
|
|
|
return NULL;
|
|
}
|
|
|
|
void* child_fn_0 ( void* arg )
|
|
{
|
|
int r;
|
|
|
|
bad_things(2);
|
|
|
|
r = pthread_create(&children[1], NULL, child_fn_1, NULL);
|
|
assert(!r);
|
|
|
|
r = pthread_join(children[1], NULL);
|
|
assert(!r);
|
|
|
|
return NULL;
|
|
}
|
|
|
|
int main(int argc, const char** argv)
|
|
{
|
|
int r;
|
|
|
|
bad_things(1);
|
|
|
|
r = pthread_create(&children[0], NULL, child_fn_0, NULL);
|
|
assert(!r);
|
|
|
|
r = pthread_join(children[0], NULL);
|
|
assert(!r);
|
|
|
|
bad_things(5);
|
|
|
|
return 0;
|
|
}
|
|
|