From patchwork Thu Mar 3 11:40:58 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kieran Bingham X-Patchwork-Id: 63472 Delivered-To: patch@linaro.org Received: by 10.112.199.169 with SMTP id jl9csp2896551lbc; Thu, 3 Mar 2016 03:47:31 -0800 (PST) X-Received: by 10.98.87.216 with SMTP id i85mr1298409pfj.72.1457005651690; Thu, 03 Mar 2016 03:47:31 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s8si11640905pfi.10.2016.03.03.03.47.31; Thu, 03 Mar 2016 03:47:31 -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 S1757289AbcCCLr3 (ORCPT + 30 others); Thu, 3 Mar 2016 06:47:29 -0500 Received: from mail-wm0-f54.google.com ([74.125.82.54]:36559 "EHLO mail-wm0-f54.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756785AbcCCLlV (ORCPT ); Thu, 3 Mar 2016 06:41:21 -0500 Received: by mail-wm0-f54.google.com with SMTP id n186so127594593wmn.1 for ; Thu, 03 Mar 2016 03:41:21 -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=HLiXoXDX03hY1Oz/pOGP/r3HYsi7PUdFGbgKrkDlPIRVBSthel1V2V2C0qmnQMY/Nz aZn5wL/GPYKvBRcQ6ArFCxqEr3fHj3NGiMlodyVysYYfG/six0dXIlay1+an6n5YNNdh MVtVsN5Zh8vP8JwA2W+H4TIZBK+y4U1PS7vSE= 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=hIA8VfdqX2o65nfNJT98BKEco7nuto5o6OZVEY2VpFrddqhGAMkpJ71tZgLuMuDs0r hzvu5jhnxLDFbOVzaGts185CXhmYKoHHVS1Fy6s4PRbsM1UPamf9E2ff8cJ3npERiVNa Nzr4PLD7lfCfXIvJAgUSMlcp30LcQJGgTqW3Tr62Mo7403J8aG4T9Eys4jSqlPjZsthi AZip2OEb81ffud5LNTwmdf1VLcemrs5Ltt9xsdprGC0X6fuLVhms0TQHiEg5+/Apxf3H QisQo3qoA6jWWVOK7xf1OpKuXEUAGWr3BkaTkzTymclQcTjtLBSzugCokl5G4JStheLl ilxA== X-Gm-Message-State: AD7BkJJ9P6PpDsbeJMhgDEnFIM4LIF10/2Vi8gNXvbQiwGlyngMb7Oh1LHfya9PhNSdb5ZLy X-Received: by 10.28.53.4 with SMTP id c4mr3068604wma.34.1457005280546; Thu, 03 Mar 2016 03:41:20 -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 e19sm8570696wmd.1.2016.03.03.03.41.19 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 03 Mar 2016 03:41:20 -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: [PATCHv3 04/13] scripts/gdb: Provide exception catching parser Date: Thu, 3 Mar 2016 11:40:58 +0000 Message-Id: <1457005267-843-5-git-send-email-kieran.bingham@linaro.org> X-Mailer: git-send-email 2.5.0 In-Reply-To: <1457005267-843-1-git-send-email-kieran.bingham@linaro.org> References: <1457005267-843-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