b.liu | bb59049 | 2024-06-13 16:42:08 +0800 | [diff] [blame] | 1 | #include <stdio.h> |
| 2 | |
| 3 | #include "mbtk_log.h" |
| 4 | #include "mbtk_utils.h" |
| 5 | |
| 6 | |
| 7 | void test3() |
| 8 | { |
| 9 | printf("%s start\n", __FUNCTION__); |
| 10 | char *ptr = 10; |
| 11 | *ptr = 'a'; |
| 12 | printf("%s end\n", __FUNCTION__); |
| 13 | } |
| 14 | |
| 15 | void test2() |
| 16 | { |
| 17 | printf("%s start\n", __FUNCTION__); |
| 18 | mbtk_get_kernel_cmdline(NULL, 1024); |
| 19 | // test3(); |
| 20 | printf("%s end\n", __FUNCTION__); |
| 21 | } |
| 22 | |
| 23 | void test1() |
| 24 | { |
| 25 | printf("%s start\n", __FUNCTION__); |
| 26 | test2(); |
| 27 | printf("%s end\n", __FUNCTION__); |
| 28 | } |
| 29 | |
| 30 | void* thread_function(void* arg) { |
| 31 | // 模拟一个导致SIGSEGV的操作 |
| 32 | int* invalid_pointer = NULL; |
| 33 | *invalid_pointer = 0; // 尝试写入一个无效的指针,将触发SIGSEGV |
| 34 | return NULL; |
| 35 | } |
| 36 | |
| 37 | int main(int argc, char *argv[]) |
| 38 | { |
| 39 | |
| 40 | #ifdef MBTK_DUMP_SUPPORT |
| 41 | mbtk_debug_open(NULL, TRUE); |
| 42 | #endif |
| 43 | |
| 44 | test1(); |
| 45 | |
| 46 | pthread_t thread; |
| 47 | pthread_create(&thread, NULL, &thread_function, NULL); |
| 48 | pthread_join(thread, NULL); |
| 49 | |
| 50 | printf("Exit.\n"); |
| 51 | |
| 52 | return 0; |
| 53 | } |
| 54 | |