public inbox for systemtap@sourceware.org
 help / color / mirror / Atom feed
* [RFC 00/13] MIPS64 support
@ 2014-07-31 20:21 Crestez Dan Leonard
  2014-07-31 20:21 ` [RFC 01/13] mips: Minimal build support Crestez Dan Leonard
                   ` (14 more replies)
  0 siblings, 15 replies; 21+ messages in thread
From: Crestez Dan Leonard @ 2014-07-31 20:21 UTC (permalink / raw)
  To: systemtap

[-- Attachment #1: Type: text/plain, Size: 4960 bytes --]


I've been playing with systemtap on mips64 and finally got most of what I need
from it to work:
- kprobe insertion
- examining structs via dwarf data
- stack unwinding

I did not test userspace support at all.

I know about the earlier patches by cisco from the systemtap-1.6-cisco-patches
branch. Only commit 487cb1bffaf4b5661f42798d2e4047ec986b7438 was actually
interesting to me, but it's a big one and I split off some small chunks. I
think only patches 1, 2, 3 are strictly required. I don't particularly care
about syscall probing or implementing print_regs. Patch 5 could probably be
dropped off entirely. If it helps I could split this patch further. 

I was able to handle cross-compiling by writing a python wrapper which passes
correct -g and -B CROSS_COMPILE=* arguments to stap itself. Cisco posted some
"cross-compilation helpers" but I did not use them.

One obvious cross-compiling issue I found is that unwind data is written in the
translator's byte order. I believe patch 10 applies to all scenarios where the
host and target have different byte orders.

Some hacks are required because of some unusual behavior of gcc on mips64. I
believe these hacks are not specific to my local setup but affect a wide range
of released gcc versions. It's not clear to me why cisco didn't hit these
issues. Maybe they used mips32 or were not interested in dwarf support?

The first issue is that a 64bit mips kernel is compiled with -msym32 which
results in 32bit dwarf symbols. These need to be detected and handled
specially. I think that checking for address_size == 4 from dwarf_diecu on a
target which is otherwise 64bit is correct. The way I'm checking this (patch 6)
might slow down translation.

Inside loc2c the CU address_size is used to determine the max_fetch_size, this
becomes incorrect with -msym32. Handling this (patch 8) requires access to the
elf header which requires a lot of code churn (patch 7). This could be avoided
if elfutils exported a dwarf_die_getdwarf but this would be a new elfutils API.

Apparently -msym32 also affects the FDE data for unwind support. It's not clear
how to detect it cleanly in there. Apparently an "address_size" field can be
included in the CIE, but I don't have it. Both eu-readelf and binutils readelf
show corrupt FDEs. Patches 12 and 13 are evil hacks. Presumably I could try to
interpret initial_address both ways and attempt to lookup the CU?

Another issue is that struct fields are generated with a single DW_OP_constu
instead of DW_OP_plus_uconst. Handling this is isolated in patch 9.

The patches are against systemtap's current HEAD. It would be great if you
could include this mips support in systemtap upstream. I realize that some
of the hacks would require some reworking. Suggestions are welcome.

Crestez Dan Leonard (12):
  mips: Minimal build support
  mips: Define TIF_32BIT if missing
  mips: Read _stp_deref and _stp_store_deref support
  mips: Special get_cycles for cavium octeon
  Force sign-extend statement addresses on mips64 -msym32
  loc2c: Add Dwarf pointer to location_context
  mips: Fix fetching params of type long on mips kernel
  mips: dwflpp hack for struct fields being DW_OP_constu instead of
    DW_OP_plus_uconst
  Create debug_frame_hdr in target byte order
  mips64: Initial unwind support
  translator: Hack to interpret mips64 FDEs as 32bit for unwind
  runtime: Hack to interpret mips64 FDEs as 32bit for unwind

Victor Kamensky (1):
  mips: runtime and tapset code from cisco

 dwflpp.cxx                    |  62 +++++++++-
 dwflpp.h                      |   1 +
 loc2c-test.c                  |  27 +++--
 loc2c.c                       |  36 ++++--
 loc2c.h                       |   9 +-
 runtime/compatdefs.h          |   8 ++
 runtime/linux/arith.c         |  25 +++-
 runtime/linux/copy.c          |   2 +-
 runtime/linux/loc2c-runtime.h |  83 +++++++++++++
 runtime/linux/runtime.h       |   2 +-
 runtime/loc2c-runtime.h       |   9 ++
 runtime/regs.c                | 117 ++++++++++++++++++
 runtime/regs.h                |   4 +
 runtime/stack-mips.c          |   7 ++
 runtime/stack.c               |   2 +
 runtime/syscall.h             |  49 ++++++++
 runtime/time.c                |  16 +++
 runtime/unwind.c              |  13 ++
 runtime/unwind/mips64.h       |  80 ++++++++++++
 runtime/unwind/unwind.h       |   2 +
 tapset/errno.stp              |   2 +
 tapset/linux/aux_syscalls.stp |   5 +-
 tapset/linux/scheduler.stp    |   2 +-
 tapset/linux/syscalls2.stp    |   8 ++
 tapset/mips/aux_syscalls.stp  |  44 +++++++
 tapset/mips/registers.stp     | 276 ++++++++++++++++++++++++++++++++++++++++++
 tapsets.cxx                   |  15 +++
 translate.cxx                 |  53 ++++++--
 28 files changed, 917 insertions(+), 42 deletions(-)
 create mode 100644 runtime/stack-mips.c
 create mode 100644 runtime/unwind/mips64.h
 create mode 100644 tapset/mips/aux_syscalls.stp
 create mode 100644 tapset/mips/registers.stp

-- 
2.0.1


^ permalink raw reply	[flat|nested] 21+ messages in thread

end of thread, other threads:[~2014-09-02 19:10 UTC | newest]

Thread overview: 21+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-07-31 20:21 [RFC 00/13] MIPS64 support 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:21 ` [RFC 02/13] mips: Define TIF_32BIT if missing 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:22 ` [RFC 05/13] mips: Special get_cycles for cavium octeon 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 08/13] mips: Fix fetching params of type long on mips kernel Crestez Dan Leonard
2014-07-31 20:22 ` [RFC 11/13] mips64: Initial unwind support Crestez Dan Leonard
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 06/13] Force sign-extend statement addresses on mips64 -msym32 Crestez Dan Leonard
2014-07-31 20:23 ` [RFC 13/13] runtime: Hack to interpret mips64 FDEs as 32bit for unwind Crestez Dan Leonard
2014-07-31 20:23 ` [RFC 12/13] translator: " 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

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).