From patchwork Mon Feb 22 15:24:08 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kieran Bingham X-Patchwork-Id: 62592 Delivered-To: patch@linaro.org Received: by 10.112.43.199 with SMTP id y7csp1303585lbl; Mon, 22 Feb 2016 07:26:04 -0800 (PST) X-Received: by 10.66.228.231 with SMTP id sl7mr4798306pac.30.1456154764745; Mon, 22 Feb 2016 07:26:04 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id fi15si40298791pac.191.2016.02.22.07.26.04; Mon, 22 Feb 2016 07:26:04 -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 S1754162AbcBVP0A (ORCPT + 30 others); Mon, 22 Feb 2016 10:26:00 -0500 Received: from mail-wm0-f52.google.com ([74.125.82.52]:35250 "EHLO mail-wm0-f52.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753279AbcBVPY1 (ORCPT ); Mon, 22 Feb 2016 10:24:27 -0500 Received: by mail-wm0-f52.google.com with SMTP id c200so176822824wme.0 for ; Mon, 22 Feb 2016 07:24: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=3DkLTREn1NY5k5B7tX9WKFpZyjVutcG7Lcke5Ym1Psk=; b=VfX+XlaYJzOiKQqdrupFVU/f0uFQKsKUs/ktvosMeS/UTvg7z8/jkojZTKaSm0GD70 PS2UlZkMiOtEYzWw3NH9SDVfWq59C4th7a4bq9Dq78MF9T+Zg7wBEfjJWUacHB3NI542 PyBVE9p5/GE+h68cAzHfYNYx55DzmeH2OrFQM= 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=3DkLTREn1NY5k5B7tX9WKFpZyjVutcG7Lcke5Ym1Psk=; b=YVlmpF+Zm8lhf+3BN11FJ3keujtY7poWUdr45kqojWWNEavOBiml41X7+RysuoxiOb jSAI4CAs9ASnT6ul8KFeKrbRxRkMqG4f6Kza5QuqWyZqg7vvLMUmzFHYNk5G5AyrMDhS q+lAqlWhSIg+llKO+zXfRmiwkGllwrgYVHm1SknJewJOgU5owkJ2gG9+9lB2n6RVBTA7 1ejpXiLR+3nDJluj6OIQtAde8OMRjw5q6ecGW+gt0jyWWg3s8qFkSJ+2xJHj7gL8ewyF cSymkdIB+w5Hyt/o/ZchmtHVYWJhThyV2QRt3x55SQNJeAl4hh4DYA2rTc++ujy87UX4 nzBA== X-Gm-Message-State: AG10YORQGUXG7DHafmTeW+FpXPirvi9zEicZttv2mmzMvEQhG4JsDKPWulGufzNX9c6/QUnL X-Received: by 10.194.187.175 with SMTP id ft15mr28419163wjc.141.1456154665920; Mon, 22 Feb 2016 07:24: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 w66sm21557528wmd.2.2016.02.22.07.24.25 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 22 Feb 2016 07:24:25 -0800 (PST) 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: [PATCH 4/8] scripts/gdb: Provide exception catching parser Date: Mon, 22 Feb 2016 15:24:08 +0000 Message-Id: <1456154652-29023-5-git-send-email-kieran.bingham@linaro.org> X-Mailer: git-send-email 2.5.0 In-Reply-To: <1456154652-29023-1-git-send-email-kieran.bingham@linaro.org> References: <1456154652-29023-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 If we attempt to read a value that is not available to GDB, an exception is raised. Most of the time, this is a good thing; however on occasion we will want to be able to determine if a symbol is available. By catching the exception to simply return None, we can determine if we tried to read an invalid value, without the exception taking our execution context away from us Signed-off-by: Kieran Bingham --- scripts/gdb/linux/utils.py | 7 +++++++ 1 file changed, 7 insertions(+) -- 2.5.0 diff --git a/scripts/gdb/linux/utils.py b/scripts/gdb/linux/utils.py index 0893b326a28b..dbe2ad78048c 100644 --- a/scripts/gdb/linux/utils.py +++ b/scripts/gdb/linux/utils.py @@ -154,3 +154,10 @@ def get_gdbserver_type(): if gdbserver_type is not None and hasattr(gdb, 'events'): gdb.events.exited.connect(exit_handler) return gdbserver_type + + +def gdb_eval_or_none(expresssion): + try: + return gdb.parse_and_eval(expresssion) + except: + return None