From patchwork Wed Jun 27 19:04:55 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Marchi X-Patchwork-Id: 28083 Received: (qmail 42943 invoked by alias); 27 Jun 2018 19:05:58 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 42930 invoked by uid 89); 27 Jun 2018 19:05:58 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-26.1 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, SPF_PASS autolearn=ham version=3.3.2 spammy= X-HELO: sessmg23.ericsson.net Received: from sessmg23.ericsson.net (HELO sessmg23.ericsson.net) (193.180.251.45) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 27 Jun 2018 19:05:56 +0000 DKIM-Signature: v=1; a=rsa-sha256; d=ericsson.com; s=mailgw201801; c=relaxed/simple; q=dns/txt; i=@ericsson.com; t=1530126354; h=From:Sender:Reply-To:Subject:Date:Message-Id:To:CC:MIME-Version:Content-Type: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=Y9hUvbPA7EaYQ10F2dnY2lt8zazfz6cQ5p9gYoNK70U=; b=hNrzdXIW7MuZs7lt4zQNTFImJz1FOckFPm3w0JU+pqqHk3DkI8GdBJ9dh+xCQXmk lVKeVW7TSDVFd6ewzfGifOPlbLtTYJmydYJxzZbDqJ5lvbzoFky8pojwRySf9LVq 2l0a3i4zWtBHVg+gam1Q7jHrKKn8lutseBu7W7Aqz2I=; Received: from ESESBMB501.ericsson.se (Unknown_Domain [153.88.183.114]) by sessmg23.ericsson.net (Symantec Mail Security) with SMTP id 0B.49.22015.210E33B5; Wed, 27 Jun 2018 21:05:54 +0200 (CEST) Received: from ESESBMB501.ericsson.se (153.88.183.168) by ESESBMB501.ericsson.se (153.88.183.168) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1466.3; Wed, 27 Jun 2018 21:05:10 +0200 Received: from NAM03-CO1-obe.outbound.protection.outlook.com (153.88.183.157) by ESESBMB501.ericsson.se (153.88.183.168) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1466.3 via Frontend Transport; Wed, 27 Jun 2018 21:05:10 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ericsson.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=6XdqZk2tiXDGSTpYKZfdk+rtUuOqjd1wdZJeOX4QlFE=; b=YccThXzV8kyJOPySegBQ1iNRRYmA/xlVi4pLjlii2QfUkzdMdVeHISoDkRPSywi6TgsVox7uhcq5HYZ0glqmC4leIoFHbm/c8sgsn7ZMKtkz+5SvoGM8AabSeWqkVFe+6AgPuvKUW1fLxRIIcPhV2I3T8piCrXXACZ3y8lSy4QE= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=simon.marchi@ericsson.com; Received: from elxacz23q12.ericsson.se (129.192.64.65) by BYAPR15MB2389.namprd15.prod.outlook.com (2603:10b6:a02:8c::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.884.24; Wed, 27 Jun 2018 19:05:06 +0000 From: Simon Marchi To: CC: Simon Marchi Subject: [PATCH] Add pretty-printer for CORE_ADDR Date: Wed, 27 Jun 2018 15:04:55 -0400 Message-Id: <1530126295-3218-1-git-send-email-simon.marchi@ericsson.com> MIME-Version: 1.0 Return-Path: simon.marchi@ericsson.com Received-SPF: None (protection.outlook.com: ericsson.com does not designate permitted sender hosts) X-IsSubscribed: yes Add a pretty-printer that prints CORE_ADDR values in hex. gdb/ChangeLog: * gdb-gdb.py.in (CoreAddrPrettyPrinter): New class. (type_lookup_function): Recognize CORE_ADDR values. --- gdb/gdb-gdb.py.in | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/gdb/gdb-gdb.py.in b/gdb/gdb-gdb.py.in index cde6068..aeaf69d 100644 --- a/gdb/gdb-gdb.py.in +++ b/gdb/gdb-gdb.py.in @@ -222,6 +222,16 @@ class StructMainTypePrettyPrinter: return "\n{" + ",\n ".join(fields) + "}" + +class CoreAddrPrettyPrinter: + + def __init__(self, val): + self._val = val + + def to_string(self): + return hex(int(self._val)) + + def type_lookup_function(val): """A routine that returns the correct pretty printer for VAL if appropriate. Returns None otherwise. @@ -230,6 +240,8 @@ def type_lookup_function(val): return StructTypePrettyPrinter(val) elif val.type.tag == "main_type": return StructMainTypePrettyPrinter(val) + elif val.type.name == 'CORE_ADDR': + return CoreAddrPrettyPrinter(val) return None def register_pretty_printer(objfile):