fprintf (stderr, "%*s", current_indentation_level * DB_INDENT_UNIT, " ");
}
+/* If ATTRIBUTE_PRINTF_2 is not available, assume a printf format
+ attribute a-la gcc such as: */
+#ifndef ATTRIBUTE_PRINTF_2
+#define ATTRIBUTE_PRINTF_2 __attribute((format(printf, 2, 3)))
+#endif
+
static void ATTRIBUTE_PRINTF_2
db (int db_code, const char * msg_format, ...)
{
#undef TCR
#define TCR(S) TAB(CR(S))
-/* REGNO constants, dwarf column numbers for registers of interest. */
+/* REGNO constants, dwarf column numbers for registers of interest.
+
+ In the REGNO definitions that follow, when there is a register
+ number argument N, the use of parens around N in the result
+ is to be avoided. These eventually expand as a register column
+ number in a .cfi_offset directive within an "asm" statement,
+ through stringification. Parens in the macro expansion would
+ end up in the result and yield code such as
+
+ asm(".cfi_offset (0), <offset-expr>")
+
+ The parens impair readability here, and could even cause
+ processing errors from llvm compilers that interpret the
+ directives. */
#if defined (__PPC__)
#define REGNO_CTR 66
#define REGNO_CR 70
#define REGNO_XER 76
-#define REGNO_GR(N) (N)
+#define REGNO_GR(N) N
#define REGNO_PC 67 /* ARG_POINTER_REGNUM */
#elif defined (ARMEL)
-#define REGNO_G_REG_OFFSET(N) (N)
+#define REGNO_G_REG_OFFSET(N) N
#define FUNCTION "%function"
#ifdef __aarch64__
-#define REGNO_PC_OFFSET 96 /* DWARF_ALT_FRAME_RETURN_COLUMN */
+
+/* For the return column, GCC has DWARF_ALT_FRAME_RETURN_COLUMN (96)
+ while libunwind, used with llvm toolchains, implements the PC (!= LR)
+ ABI column 32. */
+#ifdef __llvm__
+#define REGNO_PC_OFFSET 32
+#else
+#define REGNO_PC_OFFSET 96 /* DWARF_ALT_FRAME_RETURN_COLUMN */
+#endif
#else
#define REGNO_PC_OFFSET 15 /* PC_REGNUM */
#endif
}
#endif
+/* When one is known for the compiler processing this runtime file,
+ a function attribute requesting optimization for the said function.
+ Assume __has_attribute is available for such queries, valid for at
+ least gcc and clang. */
+#if __has_attribute(optimize)
+#define OPTIMIZE_O2 __attribute__((optimize(2)));
+#else
+#define OPTIMIZE_O2
+#endif
void __gnat_sigtramp (int signo, void *si, void *sc,
- __sigtramphandler_t * handler)
- __attribute__((optimize(2)));
+ __sigtramphandler_t * handler) OPTIMIZE_O2;
void __gnat_sigtramp (int signo, void *si, void *sc,
__sigtramphandler_t * handler)