Hi,

This is the GCC part of my fix for PR15559, the GDB part of which was
posted here:

https://sourceware.org/ml/gdb-patches/2014-03/msg00610.html

Cross-tested (gcc/g++/libstdc++) from Linux to Mingw32: results are the
same, apart from (what I presume to be) noise in guality.exp/pr55665.C.

According to PR15559, this is technically a regression from pre-4.7.0,
so OK either for now, or for stage 1? For other branches?

Thanks,

Julian

ChangeLog

    include/
    * dwarf2.h (enum dwarf_calling_convention): Add
    DW_CC_GNU_thiscall_i386.

    gcc/
    * config/i386/i386.c (ix86_dwarf_calling_convention): New.
    (TARGET_DWARF_CALLING_CONVENTION): Define, using above.
Index: include/dwarf2.h
===================================================================
--- include/dwarf2.h	(revision 208642)
+++ include/dwarf2.h	(working copy)
@@ -182,6 +182,7 @@ enum dwarf_calling_convention
 
     DW_CC_GNU_renesas_sh = 0x40,
     DW_CC_GNU_borland_fastcall_i386 = 0x41,
+    DW_CC_GNU_thiscall_i386 = 0x42,
 
     /* This DW_CC_ value is not currently generated by any toolchain.  It is
        used internally to GDB to indicate OpenCL C functions that have been
Index: gcc/config/i386/i386.c
===================================================================
--- gcc/config/i386/i386.c	(revision 208642)
+++ gcc/config/i386/i386.c	(working copy)
@@ -14155,6 +14155,21 @@ output_pic_addr_const (FILE *file, rtx x
     }
 }
 
+/* Return Dwarf2 tag for calling convention to use for FUNCTION.  */
+
+static int
+ix86_dwarf_calling_convention (const_tree function)
+{
+  unsigned int ccvt = ix86_get_callcvt (function);
+
+  /* This is needed so that the debugger can reliably detect when to use the
+     "thiscall" calling convention to invoke inferior functions/methods.  */
+  if ((ccvt & IX86_CALLCVT_THISCALL) != 0)
+    return DW_CC_GNU_thiscall_i386;
+
+  return DW_CC_normal;
+}
+
 /* This is called from dwarf2out.c via TARGET_ASM_OUTPUT_DWARF_DTPREL.
    We need to emit DTP-relative relocations.  */
 
@@ -46984,6 +46999,9 @@ ix86_atomic_assign_expand_fenv (tree *ho
 #undef TARGET_C_MODE_FOR_SUFFIX
 #define TARGET_C_MODE_FOR_SUFFIX ix86_c_mode_for_suffix
 
+#undef TARGET_DWARF_CALLING_CONVENTION
+#define TARGET_DWARF_CALLING_CONVENTION ix86_dwarf_calling_convention
+
 #ifdef HAVE_AS_TLS
 #undef TARGET_ASM_OUTPUT_DWARF_DTPREL
 #define TARGET_ASM_OUTPUT_DWARF_DTPREL i386_output_dwarf_dtprel

Reply via email to