From patchwork Sun Jan 8 17:56:17 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 712411 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3txR870mh0z9sCN for ; Mon, 9 Jan 2017 05:07:19 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="JMSDw15n"; dkim-atps=neutral Received: from localhost ([::1]:34328 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cQHsC-0003vk-Jl for incoming@patchwork.ozlabs.org; Sun, 08 Jan 2017 13:07:16 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38425) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cQHhm-00034Y-6n for qemu-devel@nongnu.org; Sun, 08 Jan 2017 12:56:31 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cQHhk-0003v5-TG for qemu-devel@nongnu.org; Sun, 08 Jan 2017 12:56:30 -0500 Received: from mail-pf0-x242.google.com ([2607:f8b0:400e:c00::242]:33375) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1cQHhk-0003ud-Nl for qemu-devel@nongnu.org; Sun, 08 Jan 2017 12:56:28 -0500 Received: by mail-pf0-x242.google.com with SMTP id 127so23021174pfg.0 for ; Sun, 08 Jan 2017 09:56:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=CdC7CqUM0WQfeQF6OPWZEeOASOjF0FDD4BhFZuBxgCM=; b=JMSDw15noF1641ThAQLrBSDMIISTOjWrYiTlBbq89Afub5ilSIZ9vBtiRetevpXTdG 9y3vQNP8vtzLgaY8+cNbmjvtOPpAB/Hj4CbW7TTd6NDy73+dLE6Luzod52IuRulLdYLU lPZ/z0MaBAMDY7z2CpSTHLNm4o2TBrcs0/4fubGTTrCIfr9A27exHVM2IrDqzAw+b3Tx 8Iwn9Q5CbKLhECxbPRZ3kfhNpkuknNcAsp66JZta1/jmwnf27kd8iLuWS8aSOvl09Hb+ y8/9b/zmH/QDbUkxUF4tOwXSE6QF6QyFPwBWHsRust4rWXkXMRbAbUakLejbafwh3Agz mNvQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=CdC7CqUM0WQfeQF6OPWZEeOASOjF0FDD4BhFZuBxgCM=; b=m+GRjbg3ECbj6QoLYAHOBrwt3zkKy1eRsBivWoXHK14wOjQ3xtC9N/BJe9UgoN4UOM rnDGCakQ1SpyHO0YBI51/jNANxkyaCgFJxIpVxBwLZiwKWONW0FL83+PGdS1CLSB7nSF zIfA0XxVSc7kJHU6RUpwaqElS9qSqA+Jm41UTuChr3rbBdR5S+f6F8ODdgCKDQWi1jG8 JfoF385O6XMEOx49hghOnmngEsd271uMynYE7HbojyKfxnMY0qdVLvJQUSTRvVCXxOfT Lq+tRIvS9Yg4cI5BMTsXqp54KumWEg9aCFfiU+akgPlXvM+MOrEXVBDe0LD0ZI8/oQkd 2KNw== X-Gm-Message-State: AIkVDXLjVJsaIA0B8fPgOZVDsvh7gbFloH/GttkoEX4/EU9XOLTtP4VBePW5/LUxOTZLTA== X-Received: by 10.84.212.144 with SMTP id e16mr187113087pli.140.1483898187760; Sun, 08 Jan 2017 09:56:27 -0800 (PST) Received: from anchor.domain ([2602:47:d954:1500:221:9bff:feff:8add]) by smtp.gmail.com with ESMTPSA id e127sm15388273pfh.89.2017.01.08.09.56.27 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 08 Jan 2017 09:56:27 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sun, 8 Jan 2017 09:56:17 -0800 Message-Id: <20170108175620.6605-9-rth@twiddle.net> X-Mailer: git-send-email 2.9.3 In-Reply-To: <20170108175620.6605-1-rth@twiddle.net> References: <20170108175620.6605-1-rth@twiddle.net> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2607:f8b0:400e:c00::242 Subject: [Qemu-devel] [PULL 08/11] tcg-mips: Add tcg unwind info X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org, Jin Guojie Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Jin Guojie Tested-by: Aurelien Jarno Tested-by: James Hogan Tested-by: YunQiang Su Signed-off-by: Richard Henderson Signed-off-by: Jin Guojie Message-Id: <1483592275-4496-9-git-send-email-jinguojie@loongson.cn> --- tcg/mips/tcg-target.inc.c | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/tcg/mips/tcg-target.inc.c b/tcg/mips/tcg-target.inc.c index 9e24662..b7e2586 100644 --- a/tcg/mips/tcg-target.inc.c +++ b/tcg/mips/tcg-target.inc.c @@ -2465,3 +2465,47 @@ void tb_set_jmp_target1(uintptr_t jmp_addr, uintptr_t addr) atomic_set((uint32_t *)jmp_addr, deposit32(OPC_J, 0, 26, addr >> 2)); flush_icache_range(jmp_addr, jmp_addr + 4); } + +typedef struct { + DebugFrameHeader h; + uint8_t fde_def_cfa[4]; + uint8_t fde_reg_ofs[ARRAY_SIZE(tcg_target_callee_save_regs) * 2]; +} DebugFrame; + +#define ELF_HOST_MACHINE EM_MIPS +/* GDB doesn't appear to require proper setting of ELF_HOST_FLAGS, + which is good because they're really quite complicated for MIPS. */ + +static const DebugFrame debug_frame = { + .h.cie.len = sizeof(DebugFrameCIE) - 4, /* length after .len member */ + .h.cie.id = -1, + .h.cie.version = 1, + .h.cie.code_align = 1, + .h.cie.data_align = -(TCG_TARGET_REG_BITS / 8) & 0x7f, /* sleb128 */ + .h.cie.return_column = TCG_REG_RA, + + /* Total FDE size does not include the "len" member. */ + .h.fde.len = sizeof(DebugFrame) - offsetof(DebugFrame, h.fde.cie_offset), + + .fde_def_cfa = { + 12, TCG_REG_SP, /* DW_CFA_def_cfa sp, ... */ + (FRAME_SIZE & 0x7f) | 0x80, /* ... uleb128 FRAME_SIZE */ + (FRAME_SIZE >> 7) + }, + .fde_reg_ofs = { + 0x80 + 16, 9, /* DW_CFA_offset, s0, -72 */ + 0x80 + 17, 8, /* DW_CFA_offset, s2, -64 */ + 0x80 + 18, 7, /* DW_CFA_offset, s3, -56 */ + 0x80 + 19, 6, /* DW_CFA_offset, s4, -48 */ + 0x80 + 20, 5, /* DW_CFA_offset, s5, -40 */ + 0x80 + 21, 4, /* DW_CFA_offset, s6, -32 */ + 0x80 + 22, 3, /* DW_CFA_offset, s7, -24 */ + 0x80 + 30, 2, /* DW_CFA_offset, s8, -16 */ + 0x80 + 31, 1, /* DW_CFA_offset, ra, -8 */ + } +}; + +void tcg_register_jit(void *buf, size_t buf_size) +{ + tcg_register_jit_int(buf, buf_size, &debug_frame, sizeof(debug_frame)); +}