This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH] Fix DW_CFA_expression handling in dwarf2out (PR debug/43540)
- From: Jakub Jelinek <jakub at redhat dot com>
- To: Richard Henderson <rth at redhat dot com>, Jason Merrill <jason at redhat dot com>, Richard Guenther <rguenther at suse dot de>
- Cc: gcc-patches at gcc dot gnu dot org
- Date: Fri, 26 Mar 2010 19:41:47 +0100
- Subject: [PATCH] Fix DW_CFA_expression handling in dwarf2out (PR debug/43540)
- Reply-to: Jakub Jelinek <jakub at redhat dot com>
Hi!
When writing output_cfis routine, I've missed that DW_CFA_expression
was using reverse order of arguments (operand 1 for location, operand 2 for
regnum) compared to what DWARF says. I think it is better to use the
order of arguments that the standard has, everything else will lead to
similar errors like I've made (output_cfis would use first operand of
DW_CFA_expression like for many other opcodes as regnum when pushing into a
vector).
Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?
2010-03-26 Jakub Jelinek <jakub@redhat.com>
PR debug/43540
* dwarf2out.c (reg_save): For DW_CFA_expression put regnum
into first operand and location into second.
(dw_cfi_oprnd1_desc): Return dw_cfi_oprnd_reg_num instead of
dw_cfi_oprnd_loc for DW_CFA_expression.
(dw_cfi_oprnd2_desc): Return dw_cfi_oprnd_loc for DW_CFA_expression.
(output_cfa_loc, output_cfa_loc_raw): For DW_CFA_expression
assume first argument is regnum and second argument is location.
--- gcc/dwarf2out.c.jj 2010-03-26 14:54:05.000000000 +0100
+++ gcc/dwarf2out.c 2010-03-26 16:40:16.000000000 +0100
@@ -1115,8 +1115,8 @@ reg_save (const char *label, unsigned in
&& sreg == INVALID_REGNUM)
{
cfi->dw_cfi_opc = DW_CFA_expression;
- cfi->dw_cfi_oprnd2.dw_cfi_reg_num = reg;
- cfi->dw_cfi_oprnd1.dw_cfi_loc
+ cfi->dw_cfi_oprnd1.dw_cfi_reg_num = reg;
+ cfi->dw_cfi_oprnd2.dw_cfi_loc
= build_cfa_aligned_loc (offset, fde->stack_realignment);
}
else if (sreg == INVALID_REGNUM)
@@ -2911,6 +2911,7 @@ dw_cfi_oprnd1_desc (enum dwarf_call_fram
case DW_CFA_same_value:
case DW_CFA_def_cfa_register:
case DW_CFA_register:
+ case DW_CFA_expression:
return dw_cfi_oprnd_reg_num;
case DW_CFA_def_cfa_offset:
@@ -2919,7 +2920,6 @@ dw_cfi_oprnd1_desc (enum dwarf_call_fram
return dw_cfi_oprnd_offset;
case DW_CFA_def_cfa_expression:
- case DW_CFA_expression:
return dw_cfi_oprnd_loc;
default:
@@ -2946,6 +2946,9 @@ dw_cfi_oprnd2_desc (enum dwarf_call_fram
case DW_CFA_register:
return dw_cfi_oprnd_reg_num;
+ case DW_CFA_expression:
+ return dw_cfi_oprnd_loc;
+
default:
return dw_cfi_oprnd_unused;
}
@@ -5193,10 +5196,14 @@ output_cfa_loc (dw_cfi_ref cfi)
unsigned long size;
if (cfi->dw_cfi_opc == DW_CFA_expression)
- dw2_asm_output_data (1, cfi->dw_cfi_oprnd2.dw_cfi_reg_num, NULL);
+ {
+ dw2_asm_output_data (1, cfi->dw_cfi_oprnd1.dw_cfi_reg_num, NULL);
+ loc = cfi->dw_cfi_oprnd2.dw_cfi_loc;
+ }
+ else
+ loc = cfi->dw_cfi_oprnd1.dw_cfi_loc;
/* Output the size of the block. */
- loc = cfi->dw_cfi_oprnd1.dw_cfi_loc;
size = size_of_locs (loc);
dw2_asm_output_data_uleb128 (size, NULL);
@@ -5213,10 +5220,14 @@ output_cfa_loc_raw (dw_cfi_ref cfi)
unsigned long size;
if (cfi->dw_cfi_opc == DW_CFA_expression)
- fprintf (asm_out_file, "0x%x,", cfi->dw_cfi_oprnd2.dw_cfi_reg_num);
+ {
+ fprintf (asm_out_file, "0x%x,", cfi->dw_cfi_oprnd1.dw_cfi_reg_num);
+ loc = cfi->dw_cfi_oprnd2.dw_cfi_loc;
+ }
+ else
+ loc = cfi->dw_cfi_oprnd1.dw_cfi_loc;
/* Output the size of the block. */
- loc = cfi->dw_cfi_oprnd1.dw_cfi_loc;
size = size_of_locs (loc);
dw2_asm_output_data_uleb128_raw (size);
fputc (',', asm_out_file);
Jakub