/**** Debugging Info ****/
+/* Use BTF debug info by default. */
+
+#undef PREFERRED_DEBUGGING_TYPE
+#define PREFERRED_DEBUGGING_TYPE BTF_DEBUG
+
/* In eBPF it is not possible to unwind frames. Disable CFA. */
#define DWARF2_FRAME_INFO 0
--- /dev/null
+/* Default to BTF debug info. */
+/* { dg-do compile } */
+/* { dg-options "-g -dA" }*/
+
+struct A {
+ int x;
+ int y;
+};
+
+int
+foo (struct A *a)
+{
+ return a->x;
+}
+
+/* { dg-final { scan-assembler-not "DWARF version" } } */
+/* { dg-final { scan-assembler "btf_version" } } */
--- /dev/null
+/* -g defaults to BTF, which in turn implies -mco-re. */
+/* { dg-do compile } */
+/* { dg-options "-g -dA" }*/
+
+struct A {
+ int x;
+ int y;
+};
+
+int
+foo (struct A *a)
+{
+ return __builtin_preserve_access_index (a->x);
+}
+
+/* { dg-final { scan-assembler-not "DWARF version" } } */
+/* { dg-final { scan-assembler "btf_version" } } */
+/* { dg-final { scan-assembler "btfext_version" } } */
--- /dev/null
+/* Using -g does not incorrectly force CO-RE enabled. */
+/* { dg-do compile } */
+/* { dg-options "-g -dA -mno-co-re" }*/
+
+struct A {
+ int x;
+ int y;
+};
+
+int
+foo (struct A *a)
+{
+ return __builtin_preserve_access_index (a->x); /* { dg-error "BPF CO-RE is required" } */
+}
--- /dev/null
+/* -g implies BTF, -gtoggle turns it off. CO-RE should not work. */
+/* { dg-do compile } */
+/* { dg-options "-g -mco-re -gtoggle" } */
+/* { dg-excess-errors "BPF CO-RE requires BTF debugging information" } */