From patchwork Wed Mar 26 13:24:45 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julian Brown X-Patchwork-Id: 333895 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4F1D614008D for ; Thu, 27 Mar 2014 00:25:09 +1100 (EST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:subject:message-id:mime-version:content-type; q=dns; s= default; b=xU8JwVT4uOpcA3aH30CGaaQE32hDcmkgHa5a7ddWG0f/MMWNA1aA3 Ym377S8F/J8ug057M34PQucqeR3vPjZ3QjKugWgdy6YjxLJ7IQVv8tuceD3HJwnM cNWOQMzwkOMyglbwHeX0gkmpljC+ep/XUxcF1/Fmsjspx3jp8wWenE= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:subject:message-id:mime-version:content-type; s= default; bh=mHYBhE5L0M3VIeLOzyu9jcwYuK4=; b=Rmrj04K4TVxQZiN3ju+F UuvNMCAtRbYIjC7tbTm9BUMSrJ0zj+WUJ1Kz1eJrJWyC9n5hlcMu2bTwiXMobJXP wV4ofI1eGWMUGxAejXjX+iTwUOQS4iDjcsuyPEO0emp+btqAdMbFjw4H7VMxzsOJ no2CXf1UbNe7/HR91RIRb6A= Received: (qmail 21641 invoked by alias); 26 Mar 2014 13:25:02 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 21253 invoked by uid 89); 26 Mar 2014 13:25:01 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.0 required=5.0 tests=AWL, BAYES_00, FROM_12LTRDOM autolearn=ham version=3.3.2 X-HELO: relay1.mentorg.com Received: from relay1.mentorg.com (HELO relay1.mentorg.com) (192.94.38.131) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 26 Mar 2014 13:24:59 +0000 Received: from svr-orw-exc-10.mgc.mentorg.com ([147.34.98.58]) by relay1.mentorg.com with esmtp id 1WSnp9-0002C3-QD from Julian_Brown@mentor.com for gcc-patches@gcc.gnu.org; Wed, 26 Mar 2014 06:24:55 -0700 Received: from SVR-IES-FEM-01.mgc.mentorg.com ([137.202.0.104]) by SVR-ORW-EXC-10.mgc.mentorg.com with Microsoft SMTPSVC(6.0.3790.4675); Wed, 26 Mar 2014 06:24:55 -0700 Received: from octopus (137.202.0.76) by SVR-IES-FEM-01.mgc.mentorg.com (137.202.0.104) with Microsoft SMTP Server id 14.2.247.3; Wed, 26 Mar 2014 13:24:53 +0000 Date: Wed, 26 Mar 2014 13:24:45 +0000 From: Julian Brown To: Subject: [PATCH] Fix GDB PR15559 (inferior calls using "thiscall" calling convention) Message-ID: <20140326132445.7568d2a2@octopus> MIME-Version: 1.0 X-IsSubscribed: yes 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