From 9dd5db3cb1c46c50d29bf11a495a77e2669b847a Mon Sep 17 00:00:00 2001 From: Mark Wielaard Date: Mon, 2 Oct 2023 00:37:24 +0200 Subject: [PATCH] Implement DW_OP_{bregx,consts,const8s,const8u,constu} in dwarfexpr_to_dag 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 | 1 + coregrind/m_debuginfo/readdwarf.c | 44 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 45 insertions(+) diff --git a/NEWS b/NEWS index cf37711fb..9a05f5486 100644 --- 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 diff --git a/coregrind/m_debuginfo/readdwarf.c b/coregrind/m_debuginfo/readdwarf.c index 79d6764ea..7b8187ee6 100644 --- a/coregrind/m_debuginfo/readdwarf.c +++ b/coregrind/m_debuginfo/readdwarf.c @@ -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: -- 2.11.4.GIT