From patchwork Wed Mar 30 12:00:43 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kieran Bingham X-Patchwork-Id: 64687 Delivered-To: patch@linaro.org Received: by 10.112.199.169 with SMTP id jl9csp2550095lbc; Wed, 30 Mar 2016 05:01:38 -0700 (PDT) X-Received: by 10.66.176.193 with SMTP id ck1mr12341304pac.138.1459339296772; Wed, 30 Mar 2016 05:01:36 -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.36; Wed, 30 Mar 2016 05:01:36 -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 S1753012AbcC3MBR (ORCPT + 29 others); Wed, 30 Mar 2016 08:01:17 -0400 Received: from mail-wm0-f49.google.com ([74.125.82.49]:36329 "EHLO mail-wm0-f49.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751172AbcC3MBL (ORCPT ); Wed, 30 Mar 2016 08:01:11 -0400 Received: by mail-wm0-f49.google.com with SMTP id 127so94428380wmu.1 for ; Wed, 30 Mar 2016 05:01:10 -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=3DkLTREn1NY5k5B7tX9WKFpZyjVutcG7Lcke5Ym1Psk=; b=NuyB+Eqvf2ksO3OpuKG5M9mu7DO/191QL04dUCjqnPyH+YyGNVwl+EB8TD0t6ATjUt 0EDTAvEEGKgS4TouXqmIdiwnbmwUpxOrvI/EdzLOwTqq+Kufzg++auqJPoEGOWsozYrZ 8hZ+uNWXsLXynXM9jloMBr2aN90kGqWEAlY1E= 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=IWf9oScVynuNtuwfi59B2vkMGPe2ePzh4G8Q+VkN4yPmTdcDMSEL5csk4hyxAJQdu1 bxSWKZR2Q0vUF1V5qrykFInxW0DUo2E+Gpwaffi0UxT18xny/Bfb0aqn8fFMP39PJQeI 0b8UWcF3wJLqBxnNkdztqCgAcVhdSJ+HmkgSX0BUUN5Z1tKg0QlcNu+B3HYxtWLllaWj O75pqG4liGXuCUdrEXD90Fyi+AVbOv9tnDNKL+dJg/LklqaCqTBC0yEp2rQl/Z/0uCxQ cXQosSCUtkta6YeNSdeonp7TVPDGUBIKs+oacJO7XPr9ZfZ3fMR1xxu1gzuXd91QPAn7 ekEg== X-Gm-Message-State: AD7BkJIFnmM7HOFnjerR1Iktzk9146xE2i89pj7KaV2xEeIAFAQfPicH71rs2hVuB7nBsi/U X-Received: by 10.194.174.197 with SMTP id bu5mr9714308wjc.23.1459339270010; Wed, 30 Mar 2016 05:01:10 -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.09 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 30 Mar 2016 05:01:09 -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 04/12] scripts/gdb: Provide exception catching parser Date: Wed, 30 Mar 2016 13:00:43 +0100 Message-Id: <1459339251-29611-5-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 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