summaryrefslogtreecommitdiff
path: root/src/stdlib/abort_handler_s.c
blob: 49141c7b8024849f9b9b9361793c83f59f124945 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <errno.h>
#include "errno/errno_t.h"
#include "_stdlib.h"

void abort_handler_s(const char * restrict msg, void * restrict ptr, errno_t error)
{
	SIGNAL_SAFE(0);

	struct __constraint_info *ci = ptr;

	puts(msg);
	if (ci) {
		if (ci->func) {
			printf("In call to %s() ", ci->func);
		}

		if (ci->signal != 0) {
			/* TODO: map numbers to names as well */
			printf("While handling signal %d: ", ci->signal);
		}

		if (__checked_call.file) {
			printf(" (");
			if (__checked_call.func) {
				printf("in %s(), ", __checked_call.func);
			}
			printf("at %s:%llu)", __checked_call.file, __checked_call.line);
		}
		printf(", value %x\n", ci->value);
	}
	if (error != 0) {
		printf("Provided error: %s (%d)\n", strerror(error), error);
	}
	abort();
}

/*
CEXT1(201112)
*/