-
Notifications
You must be signed in to change notification settings - Fork 1
/
segfault_handler.c
56 lines (48 loc) · 1.12 KB
/
segfault_handler.c
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
43
44
45
46
47
48
49
50
51
52
53
54
55
/**
* @file segfault_handler.c
* @author Merve Gulmez
* @brief Simple Example
* @version 0.1
* @date 2023-05-17
*
* @copyright © Ericsson AB 2022-2023
*
* SPDX-License-Identifier: BSD 3-Clause
*/
#define _GNU_SOURCE
#include <unistd.h>
#include <sys/syscall.h>
#include <sys/mman.h>
#include <setjmp.h>
#include <stddef.h>
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <stdbool.h>
#include <pthread.h>
#include <signal.h>
#include "../src/sdrad_api.h"
void empty()
{
raise(SIGSEGV);
}
int main()
{
int32_t err;
int32_t udi, j;
/*Declare udi*/
udi = 1;
for(j = 0; j < 5; j++)
{
/*Domain Init */
err = sdrad_init(udi, SDRAD_EXECUTION_DOMAIN | SDRAD_NONISOLATED_DOMAIN);
if(err == SDRAD_SUCCESSFUL_RETURNED || err == SDRAD_WARNING_SAVE_EC){ /*Normal Domain Exit*/
sdrad_enter(udi);
empty();
sdrad_exit();
sdrad_deinit(udi);
} else {
printf("Success: Domain Violation Detected\n"); /*Abnormal Domain Exit*/
}
}
}