summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKieran Bingham <kieran.bingham@linaro.org>2016-05-23 19:24:40 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2016-05-23 20:04:14 -0400
commitf197d75fcad125f41cc6e2fdf1b3ea733db995f1 (patch)
treed3d667d60a24dc5e9caeeb036bfb2781f53f9b56
parent0c22fde8b0e674a201f277688f1b3a38f6e09ada (diff)
scripts/gdb: provide linux constants
Some macro's and defines are needed when parsing memory, and without compiling the kernel as -g3 they are not available in the debug-symbols. We use the pre-processor here to extract constants to a dedicated module for the linux debugger extensions Top level Kbuild is used to call in and generate the constants file, while maintaining dependencies on autogenerated files in include/generated Link: http://lkml.kernel.org/r/bc3df9c25f57ea72177c066a51a446fc19e2c27f.1462865983.git.jan.kiszka@siemens.com Signed-off-by: Kieran Bingham <kieran.bingham@linaro.org> Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com> Cc: Michal Marek <mmarek@suse.cz> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r--Kbuild10
-rw-r--r--scripts/gdb/linux/Makefile12
-rw-r--r--scripts/gdb/linux/constants.py.in32
-rw-r--r--scripts/gdb/vmlinux-gdb.py1
4 files changed, 54 insertions, 1 deletions
diff --git a/Kbuild b/Kbuild
index f55cefd9bf29..3d0ae152af7c 100644
--- a/Kbuild
+++ b/Kbuild
@@ -5,6 +5,7 @@
5# 2) Generate timeconst.h 5# 2) Generate timeconst.h
6# 3) Generate asm-offsets.h (may need bounds.h and timeconst.h) 6# 3) Generate asm-offsets.h (may need bounds.h and timeconst.h)
7# 4) Check for missing system calls 7# 4) Check for missing system calls
8# 5) Generate constants.py (may need bounds.h)
8 9
9# Default sed regexp - multiline due to syntax constraints 10# Default sed regexp - multiline due to syntax constraints
10define sed-y 11define sed-y
@@ -96,5 +97,14 @@ quiet_cmd_syscalls = CALL $<
96missing-syscalls: scripts/checksyscalls.sh $(offsets-file) FORCE 97missing-syscalls: scripts/checksyscalls.sh $(offsets-file) FORCE
97 $(call cmd,syscalls) 98 $(call cmd,syscalls)
98 99
100#####
101# 5) Generate constants for Python GDB integration
102#
103
104extra-$(CONFIG_GDB_SCRIPTS) += build_constants_py
105
106build_constants_py: $(obj)/$(timeconst-file) $(obj)/$(bounds-file)
107 @$(MAKE) $(build)=scripts/gdb/linux $@
108
99# Keep these three files during make clean 109# Keep these three files during make clean
100no-clean-files := $(bounds-file) $(offsets-file) $(timeconst-file) 110no-clean-files := $(bounds-file) $(offsets-file) $(timeconst-file)
diff --git a/scripts/gdb/linux/Makefile b/scripts/gdb/linux/Makefile
index 6cf1ecf61057..cd129e65d1ff 100644
--- a/scripts/gdb/linux/Makefile
+++ b/scripts/gdb/linux/Makefile
@@ -8,4 +8,14 @@ ifneq ($(KBUILD_SRC),)
8endif 8endif
9 @: 9 @:
10 10
11clean-files := *.pyc *.pyo $(if $(KBUILD_SRC),*.py) 11quiet_cmd_gen_constants_py = GEN $@
12 cmd_gen_constants_py = \
13 $(CPP) -E -x c -P $(c_flags) $< > $@ ;\
14 sed -i '1,/<!-- end-c-headers -->/d;' $@
15
16$(obj)/constants.py: $(SRCTREE)/$(obj)/constants.py.in
17 $(call if_changed,gen_constants_py)
18
19build_constants_py: $(obj)/constants.py
20
21clean-files := *.pyc *.pyo $(if $(KBUILD_SRC),*.py) $(obj)/constants.py
diff --git a/scripts/gdb/linux/constants.py.in b/scripts/gdb/linux/constants.py.in
new file mode 100644
index 000000000000..79d9d0092452
--- /dev/null
+++ b/scripts/gdb/linux/constants.py.in
@@ -0,0 +1,32 @@
1/*
2 * gdb helper commands and functions for Linux kernel debugging
3 *
4 * Kernel constants derived from include files.
5 *
6 * Copyright (c) 2016 Linaro Ltd
7 *
8 * Authors:
9 * Kieran Bingham <kieran.bingham@linaro.org>
10 *
11 * This work is licensed under the terms of the GNU GPL version 2.
12 *
13 */
14
15/* We need to stringify expanded macros so that they can be parsed */
16#define STRING(x) #x
17#define XSTRING(x) STRING(x)
18
19#define LX_VALUE(x) LX_##x = x
20#define LX_GDBPARSED(x) LX_##x = gdb.parse_and_eval(XSTRING(x))
21
22/*
23 * IS_ENABLED generates (a || b) which is not compatible with python
24 * We can only switch on configuration items we know are available
25 * Therefore - IS_BUILTIN() is more appropriate
26 */
27#define LX_CONFIG(x) LX_##x = IS_BUILTIN(x)
28
29/* The build system will take care of deleting everything above this marker */
30<!-- end-c-headers -->
31
32import gdb
diff --git a/scripts/gdb/vmlinux-gdb.py b/scripts/gdb/vmlinux-gdb.py
index d5943eca19cd..6e0b0afd888a 100644
--- a/scripts/gdb/vmlinux-gdb.py
+++ b/scripts/gdb/vmlinux-gdb.py
@@ -30,3 +30,4 @@ else:
30 import linux.cpus 30 import linux.cpus
31 import linux.lists 31 import linux.lists
32 import linux.proc 32 import linux.proc
33 import linux.constants