]> sourceware.org Git - systemtap.git/commitdiff
loc2stap.cxx: Add partial support for DW_OP_bra in DWARF location lists
authorAaron Merey <amerey@redhat.com>
Thu, 18 Apr 2024 01:41:57 +0000 (21:41 -0400)
committerAaron Merey <amerey@redhat.com>
Tue, 23 Apr 2024 18:11:18 +0000 (14:11 -0400)
Add support for DW_OP_bra when operand is non-negative.  Previously
systemtap would quit probe translation if DW_OP_bra was seen in a
DWARF location list.

Tested manually on RHEL 8.9 with kernel 4.18.0-513.24.1.el8_9.x86_64.
Scripts containing a vfs.read probe require DW_OP_bra support when
run with this kernel.

Support for DW_OP_bra negative operands continues to be deferred due
to lack of use as well as being more complex to implement.

https://sourceware.org/bugzilla/show_bug.cgi?id=31496

loc2stap.cxx

index 53316a48051a2cbe24220a234aa0c85c778a55f6..883993040744a3bd12649d05116be8f0acee2b92 100644 (file)
@@ -435,9 +435,26 @@ location_context::translate (const Dwarf_Op *expr, const size_t len,
            }
            break;
 
-           /* Control flow operations.  */
+         /* Control flow operations.  */
+         case DW_OP_bra:
+           {
+             POP(taken)
+             if (taken == 0)
+               break;
+           }
+           /* FALLTHROUGH */
+
          case DW_OP_skip:
            {
+             /* A backward branch could lead to an infinite loop.  So
+                punt it until we find we actually need it.
+
+                To support backward branches, we could copy the stack,
+                recurse, and place both traces in arms of a
+                ternary_expression.  */
+             if ((Dwarf_Sword) expr[i].number < 0)
+               DIE("backward branch in DW_OP operation not supported");
+
              Dwarf_Off target = expr[i].offset + 3 + expr[i].number;
              while (i + 1 < len && expr[i + 1].offset < target)
                ++i;
@@ -446,13 +463,6 @@ location_context::translate (const Dwarf_Op *expr, const size_t len,
              break;
            }
 
-         case DW_OP_bra:
-           // ??? Could copy the stack, recurse, and place both
-           // traces in arms of a ternary_expression.  No point
-           // in doing that if this is never used, however.
-           DIE ("conditional branches not supported");
-           break;
-
            /* Memory access.  */
          case DW_OP_deref:
            // ??? Target sizeof, not host sizeof.
This page took 0.030376 seconds and 5 git commands to generate.