From patchwork Wed Nov 20 03:59:44 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Malcolm X-Patchwork-Id: 292646 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id BF8C42C00B3 for ; Wed, 20 Nov 2013 15:08:26 +1100 (EST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :message-id:subject:from:to:date:content-type:mime-version; q= dns; s=default; b=P1qnS3hN95NnpSchnEusD33WBR3A29B2EvUfOYGIzteZr2 JEeYqRiQc3eychwywTKdSd2fnoca1HswwRC1tr1ficURbz4F8rAC6QGPn8g97+YC UW0D7BjBmhpUF8qsYkscvFI7qVJrQ/EnpcvAqQjTyab1KqMWt7yKykysSYUKQ= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :message-id:subject:from:to:date:content-type:mime-version; s= default; bh=wTIT6gO49cwZc5AALSlBNIUPOFE=; b=l/tj8j7OysRlZbuwlyE6 nUpdFMX/x1yhbGjmQ+phQKRuDcIaEP5dm0kjGMyiF9GiBHR3YDDoy9Iie1CwbIFc 1PrdE9JwgCkfyJoZ8Cip5DjhuBz8OuDb31namGmsp4cSqJpdG6dhxZvy5/N3clYP oTse0tHuQg59xitLwN0JdGQ= Received: (qmail 31078 invoked by alias); 20 Nov 2013 04:07:59 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 31066 invoked by uid 89); 20 Nov 2013 04:07:58 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-0.8 required=5.0 tests=AWL, BAYES_50, RDNS_NONE, SPF_HELO_PASS, SPF_PASS, URIBL_BLOCKED autolearn=no version=3.3.2 X-HELO: mx1.redhat.com Received: from Unknown (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 20 Nov 2013 04:07:10 +0000 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id rAK472LB021576 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Tue, 19 Nov 2013 23:07:02 -0500 Received: from [10.3.227.208] (vpn-227-208.phx2.redhat.com [10.3.227.208]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id rAK40GoY012017 for ; Tue, 19 Nov 2013 23:00:16 -0500 Message-ID: <1384919984.11568.140.camel@surprise> Subject: Committed: gdbhooks.py: Implement a prettyprinter for vec<>* From: David Malcolm To: gcc-patches Date: Tue, 19 Nov 2013 22:59:44 -0500 Mime-Version: 1.0 X-IsSubscribed: yes I've committed the attached to trunk as r205086, implementing support in gdb for prettyprinting gcc's vec<>* types. commit 0c55e3277d41a47e23178d05c6779a683145febd Author: David Malcolm Date: Tue Nov 19 22:18:54 2013 -0500 gdbhooks.py: Implement a prettyprinter for vec<>* gcc/ * gdbhooks.py (VecPrinter): New class, for prettyprinting pointers to "vec<>" instances. (build_pretty_printer): Register the vec<>* prettyprinter. diff --git a/gcc/gdbhooks.py b/gcc/gdbhooks.py index 3afa796..baccd6b 100644 --- a/gcc/gdbhooks.py +++ b/gcc/gdbhooks.py @@ -109,6 +109,26 @@ available: 1594 execute_pass_list (g->get_passes ()->all_passes); (gdb) p node $1 = + +vec<> pointers are printed as the address followed by the elements in +braces. Here's a length 2 vec: + (gdb) p bb->preds + $18 = 0x7ffff0428b68 = { 5)>, 5)>} + +and here's a length 1 vec: + (gdb) p bb->succs + $19 = 0x7ffff0428bb8 = { EXIT)>} + +You cannot yet use array notation [] to access the elements within the +vector: attempting to do so instead gives you the vec itself (for vec[0]), +or a (probably) invalid cast to vec<> for the memory after the vec (for +vec[1] onwards). + +Instead (for now) you must access m_vecdata: + (gdb) p bb->preds->m_vecdata[0] + $20 = 5)> + (gdb) p bb->preds->m_vecdata[1] + $21 = 5)> """ import re @@ -349,8 +369,29 @@ class PassPrinter: ###################################################################### +class VecPrinter: + # -ex "up" -ex "p bb->preds" + def __init__(self, gdbval): + self.gdbval = gdbval + + def display_hint (self): + return 'array' + + def to_string (self): + # A trivial implementation; prettyprinting the contents is done + # by gdb calling the "children" method below. + return '0x%x' % long(self.gdbval) + + def children (self): + m_vecpfx = self.gdbval['m_vecpfx'] + m_num = m_vecpfx['m_num'] + m_vecdata = self.gdbval['m_vecdata'] + for i in range(m_num): + yield ('[%d]' % i, m_vecdata[i]) + +###################################################################### + # TODO: -# * vec # * hashtab # * location_t @@ -423,6 +464,10 @@ def build_pretty_printer(): pp.add_printer_for_types(['rtx_def *'], 'rtx_def', RtxPrinter) pp.add_printer_for_types(['opt_pass *'], 'opt_pass', PassPrinter) + pp.add_printer_for_regex(r'vec<(\S+), (\S+), (\S+)> \*', + 'vec', + VecPrinter) + return pp gdb.printing.register_pretty_printer(