From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 117926 invoked by alias); 23 Nov 2016 22:11:14 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 117109 invoked by uid 89); 23 Nov 2016 22:11:13 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.2 required=5.0 tests=AWL,BAYES_00,FREEMAIL_FROM,KAM_ASCII_DIVIDERS,RCVD_IN_DNSWL_NONE,SPF_PASS autolearn=no version=3.3.2 spammy=*regcache, gdbarch_info, sk:set_gdb, Resume X-HELO: mail-pf0-f194.google.com Received: from mail-pf0-f194.google.com (HELO mail-pf0-f194.google.com) (209.85.192.194) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 23 Nov 2016 22:11:11 +0000 Received: by mail-pf0-f194.google.com with SMTP id i88so1038902pfk.2 for ; Wed, 23 Nov 2016 14:11:11 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=HfN73nTGE9dKD3SJ15XJb1SK48R1bLNusC3ZCUHx8Uk=; b=PIhvV34IGdynNOMApPVO9m7Wux3bd2zC8lH/GOIXxiArmzqAAJxs4eaNlYb2RUfPci l7d6EB9NyCOmWub4Rls3af/R9YGbVT2qA7RQubxeKPj++RMShaowKF+2EQI/EpnErSZc OCUqWpPeBBAPQ4lEWd2SajPKaVdFI/r8usIL6jsQgAT3ycCXLwA0GRgWUZOK6ABFqAE/ vpggLp2O8fOubE9wK5g/jRKCWww6VPEW7Re/f53Bm8DFD9UNs8JeXQlMh0JZN/HhmN4G AJJBMTJJM3TskL82MAVQ4IZNWLn982tpfIXrYTHd2FlPD4f/uuysSDRDp6uKKaeBtD4u yXwg== X-Gm-Message-State: AKaTC02Fb3hXPSYq5qYJKsgnRTBpw8KaaoU1/yDVNmCFih6g/hwVQpe+5o4hkD6B6Qyipg== X-Received: by 10.84.213.137 with SMTP id g9mr11323047pli.146.1479939069960; Wed, 23 Nov 2016 14:11:09 -0800 (PST) Received: from lianli.shorne-pla.net (z14.124-44-185.ppp.wakwak.ne.jp. [124.44.185.14]) by smtp.gmail.com with ESMTPSA id q145sm54970146pfq.22.2016.11.23.14.11.08 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 23 Nov 2016 14:11:09 -0800 (PST) Received: from lianli.shorne-pla.net (localhost [127.0.0.1]) by lianli.shorne-pla.net (8.15.2/8.15.2) with ESMTPS id uANMB7hv001431 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Thu, 24 Nov 2016 07:11:07 +0900 Received: (from shorne@localhost) by lianli.shorne-pla.net (8.15.2/8.15.2/Submit) id uANMB7XF001429; Thu, 24 Nov 2016 07:11:07 +0900 From: Stafford Horne To: gdb-patches@sourceware.org Cc: openrisc@lists.librecores.org, Franck Jullien Subject: [PATCH 03/18] gdb: or1k: Add or1k_push_dummy_code and use it. Date: Wed, 23 Nov 2016 22:11:00 -0000 Message-Id: <1479939044-1341-4-git-send-email-shorne@gmail.com> In-Reply-To: <1479939044-1341-1-git-send-email-shorne@gmail.com> References: <1479939044-1341-1-git-send-email-shorne@gmail.com> X-IsSubscribed: yes X-SW-Source: 2016-11/txt/msg00694.txt.bz2 From: Franck Jullien gdb/ChangeLog: * or1k-tdep.c (or1k_push_dummy_code): New function. (or1k_gdbarch_init): Override default behavior and call dummy from the stack. Set the push_dummy_code handler to or1k_push_dummy_code. Signed-off-by: Franck Jullien --- gdb/or1k-tdep.c | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/gdb/or1k-tdep.c b/gdb/or1k-tdep.c index 55b9522..d660a39 100644 --- a/gdb/or1k-tdep.c +++ b/gdb/or1k-tdep.c @@ -1112,6 +1112,47 @@ or1k_unwind_sp (struct gdbarch *gdbarch, } /* or1k_unwind_sp() */ +/*----------------------------------------------------------------------------*/ +/*!Provides return address for dummy call + + Provides an address on the stack where to put a breakpoint as return + address for function. bp_addr is the address to which the function should + return (which is breakpointed, so gdb can regain control, hence the name). + + @param[in] gdbarch The architecture to use + @param[in] sp The stack pointer + @param[in] function Pointer to the function that will be called + @param[in] args The arguments + @param[in] nargs Number of ags to push + @param[in] value_type Type of the function result + @param[in] real_pc Resume address + @param[in] bp_addr Breakpoint address + @param[in] regcache The register cache to use + + @return The breakpoint address */ +/*---------------------------------------------------------------------------*/ + +static CORE_ADDR +or1k_push_dummy_code (struct gdbarch *gdbarch, + CORE_ADDR sp, + CORE_ADDR function, + struct value **args, + int nargs, + struct type *value_type, + CORE_ADDR *real_pc, + CORE_ADDR *bp_addr, + struct regcache *regcache) +{ + /* Allocate space sufficient for a breakpoint, keeping the stack aligned. */ + sp = (sp - 4) & ~15; + /* Store the address of that breakpoint */ + *bp_addr = sp; + /* The call starts at the callee's entry point. */ + *real_pc = function; + + return sp; + +} /* or1k_push_dummy_code() */ /*----------------------------------------------------------------------------*/ /*!Create a dummy stack frame @@ -1888,6 +1929,8 @@ or1k_gdbarch_init (struct gdbarch_info info, set_gdbarch_unwind_sp (gdbarch, or1k_unwind_sp); /* Functions handling dummy frames */ + set_gdbarch_call_dummy_location (gdbarch, ON_STACK); + set_gdbarch_push_dummy_code (gdbarch, or1k_push_dummy_code); set_gdbarch_push_dummy_call (gdbarch, or1k_push_dummy_call); set_gdbarch_dummy_id (gdbarch, or1k_dummy_id); -- 2.7.4