Mercurial > hg > CbC > CbC_gcc
comparison gcc/ada/tracebak.c @ 131:84e7813d76e9
gcc-8.2
author | mir3636 |
---|---|
date | Thu, 25 Oct 2018 07:37:49 +0900 |
parents | 04ced10e8804 |
children | 1830386684a0 |
comparison
equal
deleted
inserted
replaced
111:04ced10e8804 | 131:84e7813d76e9 |
---|---|
4 * * | 4 * * |
5 * T R A C E B A C K * | 5 * T R A C E B A C K * |
6 * * | 6 * * |
7 * C Implementation File * | 7 * C Implementation File * |
8 * * | 8 * * |
9 * Copyright (C) 2000-2016, Free Software Foundation, Inc. * | 9 * Copyright (C) 2000-2018, Free Software Foundation, Inc. * |
10 * * | 10 * * |
11 * GNAT is free software; you can redistribute it and/or modify it under * | 11 * GNAT is free software; you can redistribute it and/or modify it under * |
12 * terms of the GNU General Public License as published by the Free Soft- * | 12 * terms of the GNU General Public License as published by the Free Soft- * |
13 * ware Foundation; either version 3, or (at your option) any later ver- * | 13 * ware Foundation; either version 3, or (at your option) any later ver- * |
14 * sion. GNAT is distributed in the hope that it will be useful, but WITH- * | 14 * sion. GNAT is distributed in the hope that it will be useful, but WITH- * |
307 #include "version.h" | 307 #include "version.h" |
308 | 308 |
309 #define USE_GCC_UNWINDER | 309 #define USE_GCC_UNWINDER |
310 #define PC_ADJUST -2 | 310 #define PC_ADJUST -2 |
311 | 311 |
312 #if (_WRS_VXWORKS_MAJOR >= 7) | 312 #if ((_WRS_VXWORKS_MAJOR >= 7) && (_VX_CPU != ARMARCH8A)) |
313 #define USING_ARM_UNWINDING 1 | 313 #define USING_ARM_UNWINDING 1 |
314 #endif | 314 #endif |
315 | 315 |
316 /*---------------------- PPC AIX/PPC Lynx 178/Older Darwin --------------*/ | 316 /*---------------------- PPC AIX/PPC Lynx 178/Older Darwin --------------*/ |
317 #elif ((defined (_POWER) && defined (_AIX)) || \ | 317 #elif ((defined (_POWER) && defined (_AIX)) || \ |
371 | 371 |
372 #elif (defined (_ARCH_PPC) && defined (__vxworks)) || \ | 372 #elif (defined (_ARCH_PPC) && defined (__vxworks)) || \ |
373 (defined (__powerpc__) && defined (__Lynx__) && defined(__ELF__)) || \ | 373 (defined (__powerpc__) && defined (__Lynx__) && defined(__ELF__)) || \ |
374 (defined (__linux__) && defined (__powerpc__)) | 374 (defined (__linux__) && defined (__powerpc__)) |
375 | 375 |
376 #if defined (_ARCH_PPC64) && !defined (__USING_SJLJ_EXCEPTIONS__) | |
377 #define USE_GCC_UNWINDER | |
378 #else | |
376 #define USE_GENERIC_UNWINDER | 379 #define USE_GENERIC_UNWINDER |
380 #endif | |
377 | 381 |
378 struct layout | 382 struct layout |
379 { | 383 { |
380 struct layout *next; | 384 struct layout *next; |
381 void *return_address; | 385 void *return_address; |
472 | 476 |
473 #define FRAME_OFFSET(FP) 0 | 477 #define FRAME_OFFSET(FP) 0 |
474 #define PC_ADJUST -2 | 478 #define PC_ADJUST -2 |
475 #define STOP_FRAME(CURRENT, TOP_STACK) \ | 479 #define STOP_FRAME(CURRENT, TOP_STACK) \ |
476 (IS_BAD_PTR((long)(CURRENT)) \ | 480 (IS_BAD_PTR((long)(CURRENT)) \ |
481 || (void *) (CURRENT) < (TOP_STACK) \ | |
477 || IS_BAD_PTR((long)(CURRENT)->return_address) \ | 482 || IS_BAD_PTR((long)(CURRENT)->return_address) \ |
478 || (CURRENT)->return_address == 0 \ | 483 || (CURRENT)->return_address == 0 \ |
479 || (void *) ((CURRENT)->next) < (TOP_STACK) \ | 484 || (void *) ((CURRENT)->next) < (TOP_STACK) \ |
480 || (void *) (CURRENT) < (TOP_STACK)) | 485 || EXTRA_STOP_CONDITION(CURRENT)) |
481 | 486 |
482 #define BASE_SKIP (1+FRAME_LEVEL) | 487 #define BASE_SKIP (1+FRAME_LEVEL) |
483 | 488 |
484 /* On i386 architecture we check that at the call point we really have a call | 489 /* On i386 architecture we check that at the call point we really have a call |
485 insn. Possible call instructions are: | 490 insn. Possible call instructions are: |
498 && (((*((ptr) - 3) & 0xff) == 0xe8) \ | 503 && (((*((ptr) - 3) & 0xff) == 0xe8) \ |
499 || ((*((ptr) - 5) & 0xff) == 0x9a) \ | 504 || ((*((ptr) - 5) & 0xff) == 0x9a) \ |
500 || ((*((ptr) - 1) & 0xff) == 0xff) \ | 505 || ((*((ptr) - 1) & 0xff) == 0xff) \ |
501 || (((*(ptr) & 0xd0ff) == 0xd0ff)))) | 506 || (((*(ptr) & 0xd0ff) == 0xd0ff)))) |
502 | 507 |
508 #if defined (__vxworks) && defined (__RTP__) | |
509 | |
510 /* For VxWorks following backchains past the "main" frame gets us into the | |
511 kernel space, where it can't be dereferenced. So lets stop at the main | |
512 symbol. */ | |
513 extern void main(); | |
514 | |
515 static int | |
516 is_return_from(void *symbol_addr, void *ret_addr) | |
517 { | |
518 int ret = 0; | |
519 char *ptr = (char *)ret_addr; | |
520 | |
521 if ((*(ptr - 5) & 0xff) == 0xe8) | |
522 { | |
523 /* call addr16 E8 xx xx xx xx */ | |
524 int32_t offset = *(int32_t *)(ptr - 4); | |
525 ret = (ptr + offset) == symbol_addr; | |
526 } | |
527 | |
528 /* Others not implemented yet... But it is very likely that call addr16 | |
529 is used here. */ | |
530 return ret; | |
531 } | |
532 | |
533 #define EXTRA_STOP_CONDITION(CURRENT) \ | |
534 (is_return_from(&main, (CURRENT)->return_address)) | |
535 #else /* not (defined (__vxworks) && defined (__RTP__)) */ | |
536 #define EXTRA_STOP_CONDITION(CURRENT) (0) | |
537 #endif /* not (defined (__vxworks) && defined (__RTP__)) */ | |
538 | |
539 /*----------------------------- qnx ----------------------------------*/ | |
540 | |
541 #elif defined (__QNX__) | |
542 | |
543 #define USE_GCC_UNWINDER | |
544 | |
545 #if defined (__aarch64__) | |
546 #define PC_ADJUST -4 | |
547 #else | |
548 #error Unhandled QNX architecture. | |
549 #endif | |
550 | |
551 /*------------------- aarch64-linux ----------------------------------*/ | |
552 | |
553 #elif (defined (__aarch64__) && defined (__linux__)) | |
554 | |
555 #define USE_GCC_UNWINDER | |
556 #define PC_ADJUST -4 | |
557 | |
503 /*----------------------------- ia64 ---------------------------------*/ | 558 /*----------------------------- ia64 ---------------------------------*/ |
504 | 559 |
505 #elif defined (__ia64__) && (defined (__linux__) || defined (__hpux__)) | 560 #elif defined (__ia64__) && (defined (__linux__) || defined (__hpux__)) |
506 | 561 |
507 #define USE_GCC_UNWINDER | 562 #define USE_GCC_UNWINDER |