Re: [PATCH 1/2] perf: Move arch specific code into separate arch directory

Previous thread: [PATCH] ummunotify: Userspace support for MMU notifications by Eric B Munson on Sunday, April 11, 2010 - 11:22 pm. (16 messages)

Next thread: [PATCH] max732x: Correct nr_port checking off by one error by Axel Lin on Monday, April 12, 2010 - 12:29 am. (2 messages)
From: Ian Munsie
Subject:
Date: Sunday, April 11, 2010 - 11:43 pm

These patches add the required mappings to use perf probe on PowerPC.

Functionality wise it requires patch 359e4284a3f37aba7fd06d993863de2509d86f54
from the powerpc-next tree to provide the HAVE_REGS_AND_STACK_ACCESS_API
required for CONFIG_KPROBE_EVENT. The code will still compile cleanly without
it and will fail gracefully at runtime on the missing CONFIG_KPROBE_EVENT
support as before.

Part 1 of the patch series moves the arch dependent x86 32 and 64 bit DWARF
register number mappings out into a separate arch directory and adds the
necessary Makefile foo to use it.

Part 2 of the patch series adds the PowerPC mappings.

Thanks,
-Ian

--

From: Ian Munsie
Date: Sunday, April 11, 2010 - 11:43 pm

From: Ian Munsie <imunsie@au.ibm.com>

The perf userspace tool included some architecture specific code to map
registers from the DWARF register number into the names used by the regs
and stack access API.

This patch moves the architecture specific code out into a seperate
arch/x86 directory along with the infrastructure required to use it.

Signed-off-by: Ian Munsie <imunsie@au.ibm.com>
---
 tools/perf/Makefile                           |   18 ++++++-
 tools/perf/arch/x86/Makefile                  |    1 +
 tools/perf/arch/x86/include/arch_dwarf-regs.h |    6 ++
 tools/perf/arch/x86/util/dwarf-regs.c         |   75 +++++++++++++++++++++++++
 tools/perf/util/include/dwarf-regs.h          |    8 +++
 tools/perf/util/probe-finder.c                |   55 ++----------------
 6 files changed, 113 insertions(+), 50 deletions(-)
 create mode 100644 tools/perf/arch/x86/Makefile
 create mode 100644 tools/perf/arch/x86/include/arch_dwarf-regs.h
 create mode 100644 tools/perf/arch/x86/util/dwarf-regs.c
 create mode 100644 tools/perf/util/include/dwarf-regs.h

diff --git a/tools/perf/Makefile b/tools/perf/Makefile
index f578b05..07a6ee2 100644
--- a/tools/perf/Makefile
+++ b/tools/perf/Makefile
@@ -172,6 +172,20 @@ uname_R := $(shell sh -c 'uname -r 2>/dev/null || echo not')
 uname_P := $(shell sh -c 'uname -p 2>/dev/null || echo not')
 uname_V := $(shell sh -c 'uname -v 2>/dev/null || echo not')
 
+ARCH ?= $(shell echo $(uname_M) | sed -e s/i.86/i386/ -e s/sun4u/sparc64/ \
+				  -e s/arm.*/arm/ -e s/sa110/arm/ \
+				  -e s/s390x/s390/ -e s/parisc64/parisc/ \
+				  -e s/ppc.*/powerpc/ -e s/mips.*/mips/ \
+				  -e s/sh[234].*/sh/ )
+
+# Additional ARCH settings for x86
+ifeq ($(ARCH),i386)
+        ARCH := x86
+endif
+ifeq ($(ARCH),x86_64)
+        ARCH := x86
+endif
+
 # CFLAGS and LDFLAGS are for the users to override from the command line.
 
 #
@@ -284,7 +298,7 @@ endif
 # Those must not be GNU-specific; they are shared with perl/ which may
 # be built by a ...
From: Ian Munsie
Date: Sunday, April 11, 2010 - 11:43 pm

From: Ian Munsie <imunsie@au.ibm.com>

This patch adds mappings from the register numbers from DWARF to the
register names used in the PowerPC Regs and Stack Access API. This
allows perf probe to be used to record variable contents on PowerPC.

This patch depends on functionality in the powerpc/next tree, though it
will compile fine without it. Specifically this patch depends on
359e4284a3f37aba7fd06d993863de2509d86f54

Signed-off-by: Ian Munsie <imunsie@au.ibm.com>
---
 tools/perf/arch/powerpc/Makefile                  |    1 +
 tools/perf/arch/powerpc/include/arch_dwarf-regs.h |    6 ++
 tools/perf/arch/powerpc/util/dwarf-regs.c         |   88 +++++++++++++++++++++
 3 files changed, 95 insertions(+), 0 deletions(-)
 create mode 100644 tools/perf/arch/powerpc/Makefile
 create mode 100644 tools/perf/arch/powerpc/include/arch_dwarf-regs.h
 create mode 100644 tools/perf/arch/powerpc/util/dwarf-regs.c

diff --git a/tools/perf/arch/powerpc/Makefile b/tools/perf/arch/powerpc/Makefile
new file mode 100644
index 0000000..1191403
--- /dev/null
+++ b/tools/perf/arch/powerpc/Makefile
@@ -0,0 +1 @@
+LIB_OBJS += $(OUTPUT)arch/$(ARCH)/util/dwarf-regs.o
diff --git a/tools/perf/arch/powerpc/include/arch_dwarf-regs.h b/tools/perf/arch/powerpc/include/arch_dwarf-regs.h
new file mode 100644
index 0000000..a7fc588
--- /dev/null
+++ b/tools/perf/arch/powerpc/include/arch_dwarf-regs.h
@@ -0,0 +1,6 @@
+#ifndef _PREF_ARCH_X86_DWARF_REGS_H
+#define _PREF_ARCH_X86_DWARF_REGS_H
+
+#define get_arch_regstr(n) get_arch_regstr(n)
+
+#endif
diff --git a/tools/perf/arch/powerpc/util/dwarf-regs.c b/tools/perf/arch/powerpc/util/dwarf-regs.c
new file mode 100644
index 0000000..48ae0c5
--- /dev/null
+++ b/tools/perf/arch/powerpc/util/dwarf-regs.c
@@ -0,0 +1,88 @@
+/*
+ * Mapping of DWARF debug register numbers into register names.
+ *
+ * Copyright (C) 2010 Ian Munsie, IBM Corporation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU ...
From: Masami Hiramatsu
Date: Monday, April 12, 2010 - 5:40 am

Hi Ian,



Thank you,

-- 
Masami Hiramatsu
e-mail: mhiramat@redhat.com
--

From: Masami Hiramatsu
Date: Monday, April 12, 2010 - 5:37 am

Hi Ian,


Nice! :)

Could you add a check whether the get_arch_regstr() is defined
(or dwarf-regs.h is exist) in Makefile?
If it is not defined, we'd better drop dwarf support(so set NO_DWARF),




Thank you,

-- 
Masami Hiramatsu
e-mail: mhiramat@redhat.com
--

From: Ian Munsie
Date: Tuesday, April 13, 2010 - 1:44 am

Hi Masami,

Thanks for the feedback


I was a little reluctant to do that when I first read your message
because it felt like adding autoconf stuff into the Makefile and the
code should already fail gracefully on architectures without the
register mappings. But, since the Makefile already has some autoconf
like magic and it would make the code cleaner, I'll play with the idea a

Nice catch (oops)


Cheers,
-Ian
--

Previous thread: [PATCH] ummunotify: Userspace support for MMU notifications by Eric B Munson on Sunday, April 11, 2010 - 11:22 pm. (16 messages)

Next thread: [PATCH] max732x: Correct nr_port checking off by one error by Axel Lin on Monday, April 12, 2010 - 12:29 am. (2 messages)