From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 11881 invoked by alias); 31 Jul 2014 20:22:32 -0000 Mailing-List: contact systemtap-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Post: List-Help: , Sender: systemtap-owner@sourceware.org Received: (qmail 11800 invoked by uid 89); 31 Jul 2014 20:22:31 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-2.1 required=5.0 tests=AWL,BAYES_00,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,SPF_PASS autolearn=ham version=3.3.2 X-HELO: mail-we0-f173.google.com Received: from mail-we0-f173.google.com (HELO mail-we0-f173.google.com) (74.125.82.173) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-SHA encrypted) ESMTPS; Thu, 31 Jul 2014 20:22:29 +0000 Received: by mail-we0-f173.google.com with SMTP id q58so3338998wes.4 for ; Thu, 31 Jul 2014 13:22:26 -0700 (PDT) X-Received: by 10.194.91.228 with SMTP id ch4mr866214wjb.59.1406838146524; Thu, 31 Jul 2014 13:22:26 -0700 (PDT) Received: from ixro-lcrestez-lin.ixiacom.com ([109.100.41.154]) by mx.google.com with ESMTPSA id lk7sm15678895wjb.24.2014.07.31.13.22.09 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 31 Jul 2014 13:22:09 -0700 (PDT) From: Crestez Dan Leonard To: systemtap@sourceware.org Subject: [RFC 06/13] Force sign-extend statement addresses on mips64 -msym32 Date: Thu, 31 Jul 2014 20:22:00 -0000 Message-Id: In-Reply-To: References: In-Reply-To: References: MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="------------true" X-IsSubscribed: yes X-SW-Source: 2014-q3/txt/msg00104.txt.bz2 From: Crestez Dan Leonard This is a multi-part message in MIME format. --------------true Content-Type: text/plain; charset=UTF-8; format=fixed Content-Transfer-Encoding: 8bit Content-length: 203 Signed-off-by: Crestez Dan Leonard --- dwflpp.cxx | 34 ++++++++++++++++++++++++++++++++++ dwflpp.h | 1 + tapsets.cxx | 14 ++++++++++++++ 3 files changed, 49 insertions(+) --------------true Content-Type: text/x-patch; name="0006-Force-sign-extend-statement-addresses-on-mips64-msym.patch" Content-Transfer-Encoding: 8bit Content-Disposition: attachment; filename="0006-Force-sign-extend-statement-addresses-on-mips64-msym.patch" Content-length: 2586 diff --git a/dwflpp.cxx b/dwflpp.cxx index e53d5f2..dea81b9 100644 --- a/dwflpp.cxx +++ b/dwflpp.cxx @@ -3054,6 +3054,31 @@ dwflpp::die_location_as_function_string(Dwarf_Addr pc, Dwarf_Die *die) return locstr; } +static bool +is_elf_mips64(Elf *elf) +{ + GElf_Ehdr ehdr_mem; + GElf_Ehdr* ehdr = gelf_getehdr (elf, &ehdr_mem); + return ehdr->e_machine == EM_MIPS && + ehdr->e_ident[EI_CLASS] == ELFCLASS64; +} + +bool +dwflpp::is_mips64_msym32(Dwarf_Die *die) +{ + Dwarf_Addr bias; + Elf* elf = (dwarf_getelf (module_dwarf) + ?: dwfl_module_getelf (this->module, &bias)); + if (!::is_elf_mips64(elf)) { + return false; + } + + Dwarf_Die cu_mem; + uint8_t address_size; + dwarf_diecu (die, &cu_mem, &address_size, NULL); + return (address_size == 4); +} + struct location * dwflpp::translate_location(struct obstack *pool, Dwarf_Attribute *attr, Dwarf_Die *die, @@ -3084,6 +3109,15 @@ dwflpp::translate_location(struct obstack *pool, to be passed in, but instead should now be zero for the same reason. */ retry: + if (is_mips64_msym32(die)) + { + /* Force sign extension */ + if (sess.verbose > 2) + clog << "query_statement truncate pc=" << hex << pc + << " to " << hex << (uint32_t)pc + << " for lookup on mips64 with 32bit symbols" << endl; + pc = (uint32_t)pc; + } switch (dwarf_getlocation_addr (attr, pc /*+ module_bias*/, &expr, &len, 1)) { case 1: /* Should always happen. */ diff --git a/dwflpp.h b/dwflpp.h index 2546acf..a411ed4 100644 --- a/dwflpp.h +++ b/dwflpp.h @@ -649,6 +649,7 @@ private: public: Dwarf_Addr pr15123_retry_addr (Dwarf_Addr pc, Dwarf_Die* var); + bool is_mips64_msym32(Dwarf_Die *die); }; // Template specializations for iterate_over_* functions diff --git a/tapsets.cxx b/tapsets.cxx index 3724a96..97d4b7e 100644 --- a/tapsets.cxx +++ b/tapsets.cxx @@ -1610,6 +1610,20 @@ query_statement (string const & func, Dwarf_Addr stmt_addr, dwarf_query * q) { + if (1) + { + if (q->dw.is_mips64_msym32(scope_die)) + { + /* Force sign extension */ + if (q->sess.verbose > 2) + clog << "query_statement " << func << "@" << file << ":" << line + << " sign-extend stmt_addr " << hex << stmt_addr + << " to " << hex << ((int64_t)((int32_t)stmt_addr)) + << " because were on mips64 with 32bit symbols" << endl; + stmt_addr = (int32_t)stmt_addr; + } + } + try { q->add_probe_point(func, file ? file : "", --------------true--