]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Fix offload dwarf info
authorAndrew Stubbs <ams@codesourcery.com>
Sun, 6 Dec 2020 19:23:55 +0000 (19:23 +0000)
committerKwok Cheung Yeung <kcy@codesourcery.com>
Tue, 21 Jun 2022 13:11:30 +0000 (14:11 +0100)
Add a notional code range to the notional parent function of offload kernel
functions.  This is enough to prevent GDB discarding them.

gcc/ChangeLog:

* dwarf2out.cc (gen_subprogram_die): Add high/low_pc attributes for
parents of offload kernels.

gcc/ChangeLog.omp
gcc/dwarf2out.cc

index 444d008139ddfeaf893a03f650591f7206b35ccc..4346ea0411c210bd2decdbc54d5dfed7e52341fa 100644 (file)
@@ -1,3 +1,8 @@
+2020-12-06  Andrew Stubbs  <ams@codesourcery.com>
+
+       * dwarf2out.cc (gen_subprogram_die): Add high/low_pc attributes for
+       parents of offload kernels.
+
 2021-01-13  Julian Brown  <julian@codesourcery.com>
 
        * doc/tm.texi.in (TARGET_VECTORIZE_PREFER_GATHER_SCATTER): Add
index d7a39944424b9f4eed7e042d6835acea1394b95f..dfdc0426cf1f03c80f7027fa7f0305ac3c4efe53 100644 (file)
@@ -23755,6 +23755,20 @@ gen_subprogram_die (tree decl, dw_die_ref context_die)
              /* We have already generated the labels.  */
              add_AT_low_high_pc (subr_die, fde->dw_fde_begin,
                                  fde->dw_fde_end, false);
+
+            /* Offload kernel functions are nested within a parent function
+               that doesn't actually exist within the offload object.  GDB
+               will ignore the function and everything nested within unless
+               we give it a notional code range (the values aren't
+               important, as long as they are valid).  */
+            if (flag_generate_offload
+                && lookup_attribute ("omp target entrypoint",
+                                     DECL_ATTRIBUTES (decl))
+                && subr_die->die_parent
+                && subr_die->die_parent->die_tag == DW_TAG_subprogram
+                && !get_AT_low_pc (subr_die->die_parent))
+              add_AT_low_high_pc (subr_die->die_parent, fde->dw_fde_begin,
+                                  fde->dw_fde_end, false);
            }
          else
            {