perf tools: Add MIPS userspace DWARF callchains.
Subsystems (2)
cover perf tools: Add MIPS userspace DWARF callchains.
From: David Daney <[email protected]>
These patches to the perf tool depend on the kernel patch here:
http://www.linux-mips.org/archives/linux-mips/2013-05/msg00124.html
With these two applied, I get the same nice call graphs on MIPS that are obtained on my x86_64 workstation.
The patches are against Jiri Olsa'sgit://git.kernel.org/pub/scm/linux/kernel/git/jolsa/perf.git perf/core branch. I hope that is the proper thing to base these things off of.
David Daney (2):
perf tools: Add support for MIPS userspace DWARF callchains. perf tools: Hook up MIPS unwind and dwarf-regs in the Makefile
tools/perf/Makefile | 3 ++ tools/perf/arch/mips/Makefile | 7 +++ tools/perf/arch/mips/include/perf_regs.h | 84 ++++++++++++++++++++++++++++++++ tools/perf/arch/mips/util/dwarf-regs.c | 37 ++++++++++++++ tools/perf/arch/mips/util/unwind.c | 20 ++++++++ tools/perf/config/Makefile | 12 ++++- 6 files changed, 161 insertions(+), 2 deletions(-) create mode 100644 tools/perf/arch/mips/Makefile create mode 100644 tools/perf/arch/mips/include/perf_regs.h create mode 100644 tools/perf/arch/mips/util/dwarf-regs.c create mode 100644 tools/perf/arch/mips/util/unwind.c
Signature · 1 line
1.7.11.7
PATCH 2/2 perf tools: Hook up MIPS unwind and dwarf-regs in the Makefile
From: David Daney <[email protected]>
Define a new symbol (ARCH_SUPPORTS_LIBUNWIND) in config/Makefile. Use this from x86 and MIPS to gate testing of libunwind.
--- tools/perf/config/Makefile | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-)
tools/perf/config/Makefile +10 -2
@@ -11,6 +11,7 @@ CFLAGS := $(EXTRA_CFLAGS) $(EXTRA_WARNINGS) # Additional ARCH settings for x86 ifeq ($(ARCH),i386) override ARCH := x86 + ARCH_SUPPORTS_LIBUNWIND := 1 NO_PERF_REGS := 0 LIBUNWIND_LIBS = -lunwind -lunwind-x86 endif
@@ -26,10 +27,18 @@ ifeq ($(ARCH),x86_64) CFLAGS += -DARCH_X86_64 ARCH_INCLUDE = ../../arch/x86/lib/memcpy_64.S ../../arch/x86/lib/memset_64.S endif + ARCH_SUPPORTS_LIBUNWIND := 1 NO_PERF_REGS := 0 LIBUNWIND_LIBS = -lunwind -lunwind-x86_64 endif +# Additional ARCH settings for MIPS +ifeq ($(ARCH),mips) + ARCH_SUPPORTS_LIBUNWIND := 1 + NO_PERF_REGS := 0 + LIBUNWIND_LIBS = -lunwind -lunwind-mips +endif + ifeq ($(NO_PERF_REGS),0) CFLAGS += -DHAVE_PERF_REGS endif
@@ -204,8 +213,7 @@ ifeq ($(call try-cc,$(SOURCE_ELF_MMAP),$(FLAGS_LIBELF),-DLIBELF_MMAP),y) endif # try-cc endif # NO_LIBELF -# There's only x86 (both 32 and 64) support for CFI unwind so far -ifneq ($(ARCH),x86) +ifndef ARCH_SUPPORTS_LIBUNWIND NO_LIBUNWIND := 1 endif
Signature · 1 line
1.7.11.7
PATCH 1/2 perf tools: Add support for MIPS userspace DWARF callchains.
In reply to David DaneyFrom: David Daney <[email protected]>
Hack up the Makefile and add support code for mips unwinding and dwarf-regs.
--- tools/perf/Makefile | 3 ++ tools/perf/arch/mips/Makefile | 7 +++ tools/perf/arch/mips/include/perf_regs.h | 84 ++++++++++++++++++++++++++++++++ tools/perf/arch/mips/util/dwarf-regs.c | 37 ++++++++++++++ tools/perf/arch/mips/util/unwind.c | 20 ++++++++ 5 files changed, 151 insertions(+) create mode 100644 tools/perf/arch/mips/Makefile create mode 100644 tools/perf/arch/mips/include/perf_regs.h create mode 100644 tools/perf/arch/mips/util/dwarf-regs.c create mode 100644 tools/perf/arch/mips/util/unwind.c
tools/perf/Makefile +3 -0
@@ -505,6 +505,9 @@ ifeq ($(NO_PERF_REGS),0) ifeq ($(ARCH),x86) LIB_H += arch/x86/include/perf_regs.h endif + ifeq ($(ARCH),mips) + LIB_H += arch/mips/include/perf_regs.h + endif endif ifndef NO_LIBNUMA
tools/perf/arch/mips/Makefile new file +7 -0
@@ -0,0 +1,7 @@ +ifndef NO_DWARF +PERF_HAVE_DWARF_REGS := 1 +LIB_OBJS += $(OUTPUT)arch/$(ARCH)/util/dwarf-regs.o +endif +ifndef NO_LIBUNWIND +LIB_OBJS += $(OUTPUT)arch/$(ARCH)/util/unwind.o +endif
tools/perf/arch/mips/include/perf_regs.h new file +84 -0
84 lines not on this page · raw message
tools/perf/arch/mips/util/dwarf-regs.c new file +37 -0
@@ -0,0 +1,37 @@ +/* +* dwarf-regs.c : Mapping of DWARF debug register numbers into register names. +* +* Copyright (C) 2013 Cavium, Inc. +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation; either version 2 of the License, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +*/ + +#include <libio.h> +#include <dwarf-regs.h> + +static const char *mips_gpr_names[32 ] = { +"$0" ,"$1" ,"$2" ,"$3" ,"$4" ,"$5" ,"$6" ,"$7" ,"$8" ,"$9" , +"$10" ,"$11" ,"$12" ,"$13" ,"$14" ,"$15" ,"$16" ,"$17" ,"$18" ,"$19" , +"$20" ,"$21" ,"$22" ,"$23" ,"$24" ,"$25" ,"$26" ,"$27" ,"$28" ,"$29" , +"$30" ,"$31" +}; + +const char *get_arch_regstr (unsigned int n) +{ +if (n <32 ) +return mips_gpr_names[n]; +if (n ==64 ) +return "hi" ; +if (n ==65 ) +return "lo" ; +return NULL ; +}
tools/perf/arch/mips/util/unwind.c new file +20 -0
@@ -0,0 +1,20 @@ + +#include <errno.h> +#include <libunwind.h> +#include "perf_regs.h" +#include "../../util/unwind.h" + +int unwind__arch_reg_id (int regnum) +{ +switch (regnum) { + case UNW_MIPS_R1 ... UNW_MIPS_R25: +return regnum -UNW_MIPS_R1 +PERF_REG_MIPS_R1 ; + case UNW_MIPS_R28 ... UNW_MIPS_R31: +return regnum -UNW_MIPS_R28 +PERF_REG_MIPS_R28 ; +case UNW_MIPS_PC : +return PERF_REG_MIPS_PC ; +default : +pr_err ("unwind: invalid reg id %d\n" , regnum); +return -EINVAL ; + } +}
Signature · 1 line
1.7.11.7