Patchwork Fix GDB PR15559 (inferior calls using "thiscall" calling convention)

login
register
mail settings
Submitter Julian Brown
Date March 26, 2014, 1:24 p.m.
Message ID <20140326132445.7568d2a2@octopus>
Download mbox | patch
Permalink /patch/333895/
State New
Headers show

Comments

Julian Brown - March 26, 2014, 1:24 p.m.
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.
Tom Tromey - March 26, 2014, 4:25 p.m.
>>>>> "Julian" == Julian Brown <julian@codesourcery.com> writes:

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

We've been trying to ensure that all GNU DWARF extensions are
documented.  In the past we had problems where an extension was added
and then, years later, its use was unclear.

The usual approach is some appropriate text somewhere on the GCC wiki
(though I suppose a note in the mail archives would do in a pinch) along
with a URL in a comment in the appropriate file (dwarf2.h or
dwarf2.def).

Could you please do that?

thanks,
Tom
Julian Brown - March 27, 2014, 12:47 p.m.
On Wed, 26 Mar 2014 10:25:19 -0600
Tom Tromey <tromey@redhat.com> wrote:

> >>>>> "Julian" == Julian Brown <julian@codesourcery.com> writes:
> 
> Julian>     include/
> Julian>     * dwarf2.h (enum dwarf_calling_convention): Add
> Julian>     DW_CC_GNU_thiscall_i386.
> 
> We've been trying to ensure that all GNU DWARF extensions are
> documented.  In the past we had problems where an extension was added
> and then, years later, its use was unclear.
> 
> The usual approach is some appropriate text somewhere on the GCC wiki
> (though I suppose a note in the mail archives would do in a pinch)
> along with a URL in a comment in the appropriate file (dwarf2.h or
> dwarf2.def).
> 
> Could you please do that?

How's this, as a first attempt?

http://gcc.gnu.org/wiki/GNUDwarfExtensions

Thanks,

Julian
Julian Brown - May 1, 2014, 4:37 p.m.
On Thu, 27 Mar 2014 12:47:23 +0000
Julian Brown <julian@codesourcery.com> wrote:

> On Wed, 26 Mar 2014 10:25:19 -0600
> Tom Tromey <tromey@redhat.com> wrote:
> 
> > >>>>> "Julian" == Julian Brown <julian@codesourcery.com> writes:
> > 
> > Julian>     include/
> > Julian>     * dwarf2.h (enum dwarf_calling_convention): Add
> > Julian>     DW_CC_GNU_thiscall_i386.
> > 
> > We've been trying to ensure that all GNU DWARF extensions are
> > documented.  In the past we had problems where an extension was
> > added and then, years later, its use was unclear.
> > 
> > The usual approach is some appropriate text somewhere on the GCC
> > wiki (though I suppose a note in the mail archives would do in a
> > pinch) along with a URL in a comment in the appropriate file
> > (dwarf2.h or dwarf2.def).
> > 
> > Could you please do that?
> 
> How's this, as a first attempt?
> 
> http://gcc.gnu.org/wiki/GNUDwarfExtensions

Ping?

Julian
Tom Tromey - May 7, 2014, 3:41 p.m.
Tom> The usual approach is some appropriate text somewhere on the GCC wiki
Tom> (though I suppose a note in the mail archives would do in a pinch)
Tom> along with a URL in a comment in the appropriate file (dwarf2.h or
Tom> dwarf2.def).

Tom> Could you please do that?

Julian> How's this, as a first attempt?
Julian> http://gcc.gnu.org/wiki/GNUDwarfExtensions

Sorry I didn't reply to this sooner.
That page looks great.  Thanks for doing this.

Tom
Julian Brown - May 9, 2014, 4:33 p.m.
On Wed, 7 May 2014 09:41:27 -0600
Tom Tromey <tromey@redhat.com> wrote:

> Tom> The usual approach is some appropriate text somewhere on the GCC
> Tom> wiki (though I suppose a note in the mail archives would do in a
> Tom> pinch) along with a URL in a comment in the appropriate file
> Tom> (dwarf2.h or dwarf2.def).
> 
> Tom> Could you please do that?
> 
> Julian> How's this, as a first attempt?
> Julian> http://gcc.gnu.org/wiki/GNUDwarfExtensions
> 
> Sorry I didn't reply to this sooner.
> That page looks great.  Thanks for doing this.

Thanks! Now, does anyone want to review the patch itself? :-)

Cheers,

Julian
Julian Brown - June 24, 2014, 11:23 a.m.
On Fri, 9 May 2014 17:33:41 +0100
Julian Brown <julian@codesourcery.com> wrote:

> On Wed, 7 May 2014 09:41:27 -0600
> Tom Tromey <tromey@redhat.com> wrote:
> 
> > Tom> The usual approach is some appropriate text somewhere on the
> > Tom> GCC wiki (though I suppose a note in the mail archives would
> > Tom> do in a pinch) along with a URL in a comment in the
> > Tom> appropriate file (dwarf2.h or dwarf2.def).
> > 
> > Tom> Could you please do that?
> > 
> > Julian> How's this, as a first attempt?
> > Julian> http://gcc.gnu.org/wiki/GNUDwarfExtensions
> > 
> > Sorry I didn't reply to this sooner.
> > That page looks great.  Thanks for doing this.
> 
> Thanks! Now, does anyone want to review the patch itself? :-)

Ping?

Julian

Patch

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