]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Implement DW_OP_{bregx,consts,const8s,const8u,constu} in dwarfexpr_to_dag
authorMark Wielaard <mark@klomp.org>
Sun, 1 Oct 2023 22:37:24 +0000 (00:37 +0200)
committerMark Wielaard <mark@klomp.org>
Sun, 1 Oct 2023 22:52:46 +0000 (00:52 +0200)
readdwarf.c (dwarfexpr_to_dag) didn't hanle various DW_OP expressions
causing Warning: DWARF2 CFI reader: unhandled DW_OP_ opcode and errors
m_debuginfo/readdwarf.c:2822 (copy_convert_CfiExpr_tree): Assertion
'srcix >= 0 && srcix < VG_(sizeXA)(srcxa)' failed.

Implement DW_OP_bregx and DW_OP_consts as reported in bug #461074.
Also add implementations for DW_OP_const8s, DW_OP_const8u and
DW_OP constu.

https://bugs.kde.org/show_bug.cgi?id=461074

NEWS
coregrind/m_debuginfo/readdwarf.c

diff --git a/NEWS b/NEWS
index cf37711fba7c775ea0d12a5245f1df1209a72561..9a05f5486d3c84e7e00ae33358d02c47f73f209e 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -60,6 +60,7 @@ are not entered into bugzilla tend to get forgotten about or ignored.
 433857  Add validation to C++17 aligned new/delete alignment size
 433859  Add mismatched detection to C++ 17 aligned new/delete
 460192  Add epoll_pwait2
+461074  DWARF2 CFI reader: unhandled DW_OP_ 0x11 (consts) DW_OP_ 0x92 (bregx)
 466105  aligned_alloc problems, part 2
 467441  Add mismatched detection to C++ 14 sized delete
 469049  link failure on ppc64 (big endian) valgrind 3.20
index 79d6764eafeeab65c2a3702196485ff12ce0d536..7b8187ee6fbb5a3015fde336ad62fed6a5026658 100644 (file)
@@ -3165,6 +3165,20 @@ static Int dwarfexpr_to_dag ( const UnwindContext* ctx,
                VG_(printf)("DW_OP_breg%d: %ld", reg, sw);
             break;
 
+         case DW_OP_bregx:
+            /* push: reg + sleb128 */
+            reg = (Int)step_leb128U( &expr );
+            sw = step_leb128S( &expr );
+            ix = ML_(CfiExpr_Binop)( dst,
+                    Cbinop_Add,
+                    ML_(CfiExpr_DwReg)( dst, reg ),
+                    ML_(CfiExpr_Const)( dst, (UWord)sw )
+                 );
+            PUSH(ix);
+            if (ddump_frames)
+               VG_(printf)("DW_OP_bregx: %d %ld", reg, sw);
+            break;
+
          case DW_OP_reg0 ... DW_OP_reg31:
             /* push: reg */
             reg = (Int)opcode - (Int)DW_OP_reg0;
@@ -3185,6 +3199,21 @@ static Int dwarfexpr_to_dag ( const UnwindContext* ctx,
                VG_(printf)("DW_OP_plus_uconst: %lu", uw);
             break;
 
+         case DW_OP_consts:
+            sw = step_leb128S( &expr );
+            PUSH( ML_(CfiExpr_Const)( dst, (UWord)sw ) );
+            if (ddump_frames)
+               VG_(printf)("DW_OP_consts: %ld", sw);
+            break;
+
+         case DW_OP_const8s:
+            /* push: 64-bit signed immediate */
+            sw = step_le_s_encoded_literal( &expr, 8 );
+            PUSH( ML_(CfiExpr_Const)( dst, (UWord)sw ) );
+            if (ddump_frames)
+               VG_(printf)("DW_OP_const8s: %ld", sw);
+            break;
+
          case DW_OP_const4s:
             /* push: 32-bit signed immediate */
             sw = step_le_s_encoded_literal( &expr, 4 );
@@ -3233,6 +3262,21 @@ static Int dwarfexpr_to_dag ( const UnwindContext* ctx,
                VG_(printf)("DW_OP_const4: %lu", uw);
             break;
 
+         case DW_OP_const8u:
+            /* push: 64-bit unsigned immediate */
+            uw = step_le_u_encoded_literal( &expr, 8 );
+            PUSH( ML_(CfiExpr_Const)( dst, uw ) );
+            if (ddump_frames)
+               VG_(printf)("DW_OP_const8: %lu", uw);
+            break;
+
+         case DW_OP_constu:
+            uw = step_leb128S ( &expr );
+            PUSH( ML_(CfiExpr_Const)( dst, uw ) );
+            if (ddump_frames)
+               VG_(printf)("DW_OP_constu: %lu", uw);
+            break;
+
          case DW_OP_abs:
             uop = Cunop_Abs; opname = "abs"; goto unop;
          case DW_OP_neg: