From: Crestez Dan Leonard <cdleonard@gmail.com>
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 [thread overview]
Message-ID: <f39d847ebcb8870c4254d323d44c18fc35924d9c.1406837921.git.cdleonard@gmail.com> (raw)
In-Reply-To: <cover.1406837921.git.cdleonard@gmail.com>
In-Reply-To: <cover.1406837921.git.cdleonard@gmail.com>
[-- Attachment #1: Type: text/plain, Size: 44 bytes --]
This is a multi-part message in MIME format.
[-- Attachment #2: Type: text/plain, Size: 203 bytes --]
Signed-off-by: Crestez Dan Leonard <cdleonard@gmail.com>
---
dwflpp.cxx | 34 ++++++++++++++++++++++++++++++++++
dwflpp.h | 1 +
tapsets.cxx | 14 ++++++++++++++
3 files changed, 49 insertions(+)
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #3: 0006-Force-sign-extend-statement-addresses-on-mips64-msym.patch --]
[-- Type: text/x-patch; name="0006-Force-sign-extend-statement-addresses-on-mips64-msym.patch", Size: 2586 bytes --]
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 <void> 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 : "",
next prev parent reply other threads:[~2014-07-31 20:22 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-07-31 20:21 [RFC 00/13] MIPS64 support Crestez Dan Leonard
2014-07-31 20:21 ` [RFC 02/13] mips: Define TIF_32BIT if missing Crestez Dan Leonard
2014-07-31 20:21 ` [RFC 01/13] mips: Minimal build support Crestez Dan Leonard
2014-07-31 20:21 ` [RFC 03/13] mips: Read _stp_deref and _stp_store_deref support Crestez Dan Leonard
2014-07-31 20:22 ` [RFC 05/13] mips: Special get_cycles for cavium octeon Crestez Dan Leonard
2014-07-31 20:22 ` [RFC 08/13] mips: Fix fetching params of type long on mips kernel Crestez Dan Leonard
2014-07-31 20:22 ` [RFC 10/13] Create debug_frame_hdr in target byte order Crestez Dan Leonard
2014-07-31 20:22 ` [RFC 11/13] mips64: Initial unwind support Crestez Dan Leonard
2014-07-31 20:22 ` Crestez Dan Leonard [this message]
2014-07-31 20:22 ` [RFC 09/13] mips: dwflpp hack for struct fields being DW_OP_constu instead of DW_OP_plus_uconst Crestez Dan Leonard
2014-07-31 20:22 ` [RFC 04/13] mips: runtime and tapset code from cisco Crestez Dan Leonard
2014-07-31 20:22 ` [RFC 07/13] loc2c: Add Dwarf pointer to location_context Crestez Dan Leonard
2014-07-31 20:23 ` [RFC 12/13] translator: Hack to interpret mips64 FDEs as 32bit for unwind Crestez Dan Leonard
2014-07-31 20:23 ` [RFC 13/13] runtime: " Crestez Dan Leonard
2014-08-01 11:16 ` [RFC 00/13] MIPS64 support Mark Wielaard
2014-08-01 12:02 ` Crestez Dan Leonard
2014-08-14 20:58 ` Josh Stone
2014-08-15 1:27 ` Victor Kamensky
2014-09-01 13:47 ` Crestez Dan Leonard
2014-09-02 18:05 ` Josh Stone
2014-09-02 19:10 ` Crestez Dan Leonard
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=f39d847ebcb8870c4254d323d44c18fc35924d9c.1406837921.git.cdleonard@gmail.com \
--to=cdleonard@gmail.com \
--cc=systemtap@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).