ftmemsim-valgrind/drd/tests/pth_cleanup_handler.c
Mark Wielaard 9c9b909cbf Make the dwarf3 reader more robust and less chatty when things go wrong
Skip some stuff when seeing an unknown language, be less chatty about
parser issues.

All the issues seem to come from the multi-file, that is the shared
(supplementary or alt) file containing debuginfo shared by all the
gcc/runtime libraries.

There are a couple of issues that this patch works around:

- The multifile contains entries for the 'D' language, which has some
  constructs we don't expect.
- We don't read partial units correctly, which means we often don't know
  the language we are looking at.
- The parser is very chatty about issues it didn't expect (even if they
  are ignored, it will still output something)

It only shows up with --read-var-info=yes which some tests enable, but
which is disabled by default.

Also increate the timeout of drd/tests/pth_cleanup_handler.c because
DWARF reading is so slow.

https://bugs.kde.org/show_bug.cgi?id=433500
2021-02-26 02:34:32 +01:00

67 lines
1.1 KiB
C

/*
* Test program for verifying whether pthread cleanup handlers are invoked
* correctly.
*/
#include <stdbool.h>
#include <stdio.h>
#include <unistd.h>
#include <pthread.h>
#include <stdlib.h>
static pthread_mutex_t s_mutex;
static void cleanup_handler(void* param)
{
fprintf(stderr, "Cleanup handler has been called.\n");
pthread_mutex_unlock(&s_mutex);
}
static void* f(void *p)
{
if (pthread_mutex_lock(&s_mutex) != 0)
{
fprintf(stderr, "pthread_mutex_lock()\n");
exit(1);
}
pthread_cleanup_push(cleanup_handler, NULL);
pthread_exit(0);
pthread_cleanup_pop(true);
}
int main()
{
pthread_t pt1, pt2;
// Make sure the program exits in case a deadlock has been triggered.
alarm(60);
if (pthread_mutex_init(&s_mutex, NULL) != 0)
{
fprintf(stderr, "pthread_mutex_init()\n");
exit(1);
}
if (pthread_create(&pt1, NULL, f, NULL) != 0)
{
fprintf(stderr, "pthread_create()\n");
exit(1);
}
if (pthread_create(&pt2, NULL, f, NULL) != 0)
{
fprintf(stderr, "pthread_create()\n");
exit(1);
}
pthread_join(pt1, 0);
pthread_join(pt2, 0);
fprintf(stderr, "Test succeeded.\n");
return 0;
}