lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1453288550-4706-2-git-send-email-kieran.bingham@linaro.org>
Date:	Wed, 20 Jan 2016 11:15:46 +0000
From:	Kieran Bingham <kieran.bingham@...aro.org>
To:	jan.kiszka@...mens.com
Cc:	Kieran Bingham <kieran.bingham@...aro.org>,
	linux-kernel@...r.kernel.org, maxime.coquelin@...com,
	peter.griffin@...aro.org, lee.jones@...aro.org
Subject: [PATCH 1/5] 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

Signed-off-by: Kieran Bingham <kieran.bingham@...aro.org>
---

I've added a 'constants.py' which is automatically generated. This allows
values not available to the debugger, through #defines to be provided to
our scripts.

The alternative method for this is to create a c-object file to obtain values
through symbols instead, and compile segments with -g3 to include macro
definitions in the debug-info.

I'd appreciate your thoughts on these options.

 scripts/gdb/linux/Makefile        |  9 +++++++--
 scripts/gdb/linux/constants.py.in | 22 ++++++++++++++++++++++
 scripts/gdb/vmlinux-gdb.py        |  1 +
 3 files changed, 30 insertions(+), 2 deletions(-)
 create mode 100644 scripts/gdb/linux/constants.py.in

diff --git a/scripts/gdb/linux/Makefile b/scripts/gdb/linux/Makefile
index 6cf1ecf61057..50864f408ca8 100644
--- a/scripts/gdb/linux/Makefile
+++ b/scripts/gdb/linux/Makefile
@@ -2,10 +2,15 @@ always := gdb-scripts
 
 SRCTREE := $(shell cd $(srctree) && /bin/pwd)
 
-$(obj)/gdb-scripts:
+$(obj)/gdb-scripts: $(obj)/constants.py
 ifneq ($(KBUILD_SRC),)
 	$(Q)ln -fsn $(SRCTREE)/$(obj)/*.py $(objtree)/$(obj)
 endif
 	@:
 
-clean-files := *.pyc *.pyo $(if $(KBUILD_SRC),*.py)
+$(obj)/constants.py: $(SRCTREE)/$(obj)/constants.py.in
+	@echo "  GDB PP  $@"
+	@$(CPP) -E -x c -P $(c_flags) $< > $@
+	@sed -i '1,/<!-- end-c-headers -->/d;' $@
+
+clean-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..d84084ac945b
--- /dev/null
+++ b/scripts/gdb/linux/constants.py.in
@@ -0,0 +1,22 @@
+/*
+ * gdb helper commands and functions for Linux kernel debugging
+ *
+ *  Kernel constants derived from include files.
+ *
+ * Copyright (c) 2016 Linaro Ltd
+ *
+ * Authors:
+ *  Kieran Bingham <kieran.bingham@...aro.org>
+ *
+ * This work is licensed under the terms of the GNU GPL version 2.
+ *
+ */
+
+/* We need to stringify expanded macros so that they can be parsed */
+#define STRING(x) #x
+#define XSTRING(x) STRING(x)
+
+/* The build system will take care of deleting everything above this marker */
+<!-- end-c-headers -->
+
+import 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:
     import linux.cpus
     import linux.lists
     import linux.proc
+    import linux.constants
-- 
2.5.0

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ