From patchwork Wed Jan 20 11:15:46 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kieran Bingham X-Patchwork-Id: 60034 Delivered-To: patch@linaro.org Received: by 10.112.130.2 with SMTP id oa2csp3109793lbb; Wed, 20 Jan 2016 03:17:43 -0800 (PST) X-Received: by 10.66.234.200 with SMTP id ug8mr51900400pac.129.1453288663823; Wed, 20 Jan 2016 03:17:43 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v63si54651520pfa.245.2016.01.20.03.17.43; Wed, 20 Jan 2016 03:17:43 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dkim=pass header.i=@linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S964894AbcATLRl (ORCPT + 29 others); Wed, 20 Jan 2016 06:17:41 -0500 Received: from mail-wm0-f51.google.com ([74.125.82.51]:35598 "EHLO mail-wm0-f51.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S935031AbcATLQ0 (ORCPT ); Wed, 20 Jan 2016 06:16:26 -0500 Received: by mail-wm0-f51.google.com with SMTP id r129so126591737wmr.0 for ; Wed, 20 Jan 2016 03:16:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=tcOSeYBUv50EGb40FjWVJrCkE4iPN3YWTzTGiCFT3tw=; b=VaQwrzqrf5y67gR0efjhc0fbdInHLLjC6mG7SUaV58e3nIvFs1BuMU9R59Hf0ACOyU IkqKJbxIMHii0Fa+QwSYB9ibOTjagzv0QYt32BQdRd/cKT9CeGDaU887IVjbsVtgX1rZ ptWwo/yR7icyNOCbSOhHF49fbpHpMp1AdOc/E= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=tcOSeYBUv50EGb40FjWVJrCkE4iPN3YWTzTGiCFT3tw=; b=QFN0oXwF+JR7SIOKR97bzxphV1kC6J4U0+97uH2zVGt/kHViYFe2z42+xOhlLZ994t CxLKPKz1uV5JCZgJTz/w+oZ+TP6OZuwMrW1o86QskvAZgvYeJv2DR56qa343ev7GM/Xy NtoU2mDyugadATvatfNtDaS4XRlmRzTwVe9B3GVWtS4eWRYj32spS0jM+IqE21vjBi1t iJxwH1QUJzGa2huxvGOj49Sw5UU30vnoF5avmzJXYwO+SB84HDhfpGqaBvJRKUjUCnJ1 KrbACx/eBEsSDeih5it+5yPZj194pVSa24h9g0NeZj7Jbhv9VmDl8bknV2h7fcoVeOsI 2jMw== X-Gm-Message-State: AG10YOT/I+4e8306gWBRcPr1NWx8of4s28/w3n06tMHVO0HuwfCrHA/Myy6gYL1Vhd0EnUqV X-Received: by 10.28.178.206 with SMTP id b197mr3229357wmf.72.1453288585634; Wed, 20 Jan 2016 03:16:25 -0800 (PST) Received: from localhost.localdomain (cpc87017-aztw30-2-0-cust65.18-1.cable.virginm.net. [92.232.232.66]) by smtp.gmail.com with ESMTPSA id bg1sm28398065wjc.27.2016.01.20.03.16.24 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 20 Jan 2016 03:16:25 -0800 (PST) From: Kieran Bingham To: jan.kiszka@siemens.com Cc: Kieran Bingham , linux-kernel@vger.kernel.org, maxime.coquelin@st.com, peter.griffin@linaro.org, lee.jones@linaro.org Subject: [PATCH 1/5] scripts/gdb: Provide linux constants Date: Wed, 20 Jan 2016 11:15:46 +0000 Message-Id: <1453288550-4706-2-git-send-email-kieran.bingham@linaro.org> X-Mailer: git-send-email 2.5.0 In-Reply-To: <1453288550-4706-1-git-send-email-kieran.bingham@linaro.org> References: <1453288550-4706-1-git-send-email-kieran.bingham@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- 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 -- 2.5.0 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,//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 + * + * 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 */ + + +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