From patchwork Mon Jan 20 21:22:02 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jean Pihet X-Patchwork-Id: 23420 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-pa0-f71.google.com (mail-pa0-f71.google.com [209.85.220.71]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 74B75203C6 for ; Mon, 20 Jan 2014 21:22:24 +0000 (UTC) Received: by mail-pa0-f71.google.com with SMTP id kp14sf18874442pab.6 for ; Mon, 20 Jan 2014 13:22:23 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:in-reply-to:references:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :list-post:list-help:list-archive:list-unsubscribe; bh=tDFSrjak801DWICo8DLtrlqQRLwNAjaLJMhuT78pwPE=; b=C24LiQ0zfSZ//RVjVcAASA1tnIcXYsSvIvp7wOfx88/10Ho570dOn34zIQK8XAKCxc vwYAmq/7yBxqy1ykkl3xBmHg9o8UJu0SODKR0wP3aN5eCDrkoww9L5AoQDNv/spWucBy mspa7GWv1WyYUsiLpD/Su39mMx/PNP9oQe03ZAT5FC81c4i4bNepqSi+GFa7KEQDDtjA NLtTz/KBYeGMxWrld9dizNpXQ3EKjVvFb1AnJdmGR/aazLseSIT4tjMJq96hTrd+cW8r zqYqvCm7N7iyc+Mhh+gC70K0j/WyzfGcgI0h8xo5Y/Cq2alkKN/TLuFxmcNHpimVhwlw d/dA== X-Gm-Message-State: ALoCoQk6NJ6ZwizETrWhOIadVnu/OI6f7BnKOJf24NOHJuKWOiP6EtTiA8UbuoIYvHnpqtj/5cZq X-Received: by 10.66.246.194 with SMTP id xy2mr7437203pac.36.1390252943668; Mon, 20 Jan 2014 13:22:23 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.23.80 with SMTP id 74ls1143030qgo.61.gmail; Mon, 20 Jan 2014 13:22:23 -0800 (PST) X-Received: by 10.52.106.107 with SMTP id gt11mr10011989vdb.7.1390252943510; Mon, 20 Jan 2014 13:22:23 -0800 (PST) Received: from mail-vc0-f180.google.com (mail-vc0-f180.google.com [209.85.220.180]) by mx.google.com with ESMTPS id vq3si796782veb.65.2014.01.20.13.22.23 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 20 Jan 2014 13:22:23 -0800 (PST) Received-SPF: neutral (google.com: 209.85.220.180 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.220.180; Received: by mail-vc0-f180.google.com with SMTP id ks9so3009410vcb.25 for ; Mon, 20 Jan 2014 13:22:23 -0800 (PST) X-Received: by 10.220.133.80 with SMTP id e16mr11844266vct.13.1390252943428; Mon, 20 Jan 2014 13:22:23 -0800 (PST) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patches@linaro.org Received: by 10.220.174.196 with SMTP id u4csp77097vcz; Mon, 20 Jan 2014 13:22:23 -0800 (PST) X-Received: by 10.14.214.65 with SMTP id b41mr716853eep.105.1390252942549; Mon, 20 Jan 2014 13:22:22 -0800 (PST) Received: from mail-ee0-f44.google.com (mail-ee0-f44.google.com [74.125.83.44]) by mx.google.com with ESMTPS id p9si4602375eew.223.2014.01.20.13.22.22 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 20 Jan 2014 13:22:22 -0800 (PST) Received-SPF: neutral (google.com: 74.125.83.44 is neither permitted nor denied by best guess record for domain of jean.pihet@linaro.org) client-ip=74.125.83.44; Received: by mail-ee0-f44.google.com with SMTP id c13so3678684eek.17 for ; Mon, 20 Jan 2014 13:22:22 -0800 (PST) X-Received: by 10.14.122.5 with SMTP id s5mr19777073eeh.28.1390252942141; Mon, 20 Jan 2014 13:22:22 -0800 (PST) Received: from localhost.localdomain (222.28-245-81.adsl-dyn.isp.belgacom.be. [81.245.28.222]) by mx.google.com with ESMTPSA id w4sm7306209eef.20.2014.01.20.13.22.20 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Mon, 20 Jan 2014 13:22:21 -0800 (PST) From: Jean Pihet To: libunwind-devel Cc: Will Deacon , Jiri Olsa , patches@linaro.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Jean Pihet Subject: [PATCH 3/3] Dwarf: unwind the recorded stack frame of different target address sizes Date: Mon, 20 Jan 2014 22:22:02 +0100 Message-Id: <1390252922-25889-4-git-send-email-jean.pihet@linaro.org> X-Mailer: git-send-email 1.7.11.7 In-Reply-To: <1390252922-25889-1-git-send-email-jean.pihet@linaro.org> References: <1390252922-25889-1-git-send-email-jean.pihet@linaro.org> X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: jean.pihet@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.220.180 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Precedence: list Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org List-ID: X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , When in compat mode, correctly unwind the recorded stack frame. The returned pointers are cast to the desired target address size. Signed-off-by: Jean Pihet --- src/dwarf/Gparser.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/src/dwarf/Gparser.c b/src/dwarf/Gparser.c index b251e31..d676861 100644 --- a/src/dwarf/Gparser.c +++ b/src/dwarf/Gparser.c @@ -706,6 +706,29 @@ eval_location_expr (struct dwarf_cursor *c, unw_addr_space_t as, return 0; } +/* Cast pointer content to the type of target address size */ +static inline int cast_value_to_addr_size(unw_word_t *val, int addr_size) +{ + switch (addr_size) { + /* + * Return the value of the type found at binary load time (e.g. from the + * ELF format)... + */ + case TARGET_ADDR_SIZE_32: + *val = (uint32_t) *val; + break; + case TARGET_ADDR_SIZE_64: + *val = (uint64_t) *val; + break; + /* ... otherwise leave it as is */ + case TARGET_ADDR_SIZE_DEFAULT: + default: + break; + } + + return 0; +} + static int apply_reg_state (struct dwarf_cursor *c, struct dwarf_reg_state *rs) { @@ -743,6 +766,8 @@ apply_reg_state (struct dwarf_cursor *c, struct dwarf_reg_state *rs) regnum = dwarf_to_unw_regnum (rs->reg[DWARF_CFA_REG_COLUMN].val); if ((ret = unw_get_reg ((unw_cursor_t *) c, regnum, &cfa)) < 0) return ret; + /* Cast value to the type as found in the ELF binary format */ + cast_value_to_addr_size(&cfa, as->target_addr_size); } cfa += rs->reg[DWARF_CFA_OFF_COLUMN].val; } @@ -797,6 +822,8 @@ apply_reg_state (struct dwarf_cursor *c, struct dwarf_reg_state *rs) ret = dwarf_get (c, c->loc[c->ret_addr_column], &ip); if (ret < 0) return ret; + /* Cast value to the type as found in the ELF binary format */ + cast_value_to_addr_size(&ip, as->target_addr_size); c->ip = ip; }