From patchwork Wed Mar 30 12:00:51 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kieran Bingham X-Patchwork-Id: 64690 Delivered-To: patch@linaro.org Received: by 10.112.199.169 with SMTP id jl9csp2550183lbc; Wed, 30 Mar 2016 05:01:46 -0700 (PDT) X-Received: by 10.98.71.70 with SMTP id u67mr12401827pfa.85.1459339298224; Wed, 30 Mar 2016 05:01:38 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id kd12si6145685pad.15.2016.03.30.05.01.37; Wed, 30 Mar 2016 05:01:38 -0700 (PDT) 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; dkim=pass header.i=@linaro.org; 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; dmarc=pass (p=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753229AbcC3MBX (ORCPT + 29 others); Wed, 30 Mar 2016 08:01:23 -0400 Received: from mail-wm0-f46.google.com ([74.125.82.46]:38367 "EHLO mail-wm0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753084AbcC3MBT (ORCPT ); Wed, 30 Mar 2016 08:01:19 -0400 Received: by mail-wm0-f46.google.com with SMTP id 20so67579928wmh.1 for ; Wed, 30 Mar 2016 05:01:18 -0700 (PDT) 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=aRExnjtXrAwZYnJfb9E0C6ac63AgPQ4VNooWTy0Yjws=; b=Dz03KQNijoEzFAaMJKTQqHEQSKZTViyvV+XfexVz1ySIZyZk46MxuoGVzUHKbo9pZo afBgGZVx1wqTa/mX+/ucA5nzsUD4WJFV9LtFEB9jEazWtXlBeA8ZUv7ENHWiTN1ABB4q Gj1uppX732YrCUMURNNm3bRy6qHT1d/JqOLp8= 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=aRExnjtXrAwZYnJfb9E0C6ac63AgPQ4VNooWTy0Yjws=; b=WKQo9oCr0xaXNb2gxcax+NstFsrBFLyTjkioyKT5FteQyMTStcI4LgTAk+1nK/psGS n0UsUsf3rzyiQ/xZTFdBCahE1tmCDRLsG6vPw1Vuad7bbvP5kmrTgwOL4fd8QtMsS69E M2eOhT+jiH3nfwil47/w+CT9laY+zlymLhQyc/NM73gGUnsi6Su9XK6FA1pzkkaVuW2m oJJfq7XRQE5do8Z2wDhhvRJFoJye95x0fdHlPNYU9rSA7g4oWb4suQop1nc1ohOZEP4L DqMIxJmI1VzhroN7NNv2/BpsSFnR6i5watcDMJsHxDjM1s4jvuYQMV96+kzf1gvX0C3I aD9w== X-Gm-Message-State: AD7BkJKup40h0+DGS4SNGhs2pZ2ApzGhGDxXPe/ZwjOUgiXad9qDkQaw5N6UfABpKWknIbiK X-Received: by 10.194.144.10 with SMTP id si10mr8882841wjb.180.1459339277739; Wed, 30 Mar 2016 05:01:17 -0700 (PDT) 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 e190sm1175530wma.15.2016.03.30.05.01.16 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 30 Mar 2016 05:01:17 -0700 (PDT) From: Kieran Bingham To: jan.kiszka@siemens.com, linux-kernel@vger.kernel.org Cc: lee.jones@linaro.org, peter.griffin@linaro.org, maxime.coquelin@st.com, Kieran Bingham Subject: [PATCHv4 12/12] scripts/gdb: Add lx_thread_info_by_pid helper Date: Wed, 30 Mar 2016 13:00:51 +0100 Message-Id: <1459339251-29611-13-git-send-email-kieran.bingham@linaro.org> X-Mailer: git-send-email 2.5.0 In-Reply-To: <1459339251-29611-1-git-send-email-kieran.bingham@linaro.org> References: <1459339251-29611-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 The tasks module already provides helpers to find the task struct by pid, and the thread_info by task struct; however this is cumbersome to utilise on the gdb commandline. Wrap these two functionalities together in an extra single helper to allow exploring the thread info, from a PID value Signed-off-by: Kieran Bingham --- scripts/gdb/linux/tasks.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) -- 2.5.0 diff --git a/scripts/gdb/linux/tasks.py b/scripts/gdb/linux/tasks.py index 862a4ae24d49..1bf949c43b76 100644 --- a/scripts/gdb/linux/tasks.py +++ b/scripts/gdb/linux/tasks.py @@ -114,3 +114,22 @@ variable.""" LxThreadInfoFunc() + + +class LxThreadInfoByPidFunc (gdb.Function): + """Calculate Linux thread_info from task variable found by pid + +$lx_thread_info_by_pid(PID): Given PID, return the corresponding thread_info +variable.""" + + def __init__(self): + super(LxThreadInfoByPidFunc, self).__init__("lx_thread_info_by_pid") + + def invoke(self, pid): + task = get_task_by_pid(pid) + if task: + return get_thread_info(task.dereference()) + else: + raise gdb.GdbError("No task of PID " + str(pid)) + +LxThreadInfoByPidFunc()