From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 3923 invoked by alias); 3 May 2011 04:51:29 -0000 Received: (qmail 3787 invoked by uid 22791); 3 May 2011 04:51:28 -0000 X-SWARE-Spam-Status: No, hits=-1.5 required=5.0 tests=AWL,BAYES_00,FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,T_TO_NO_BRKTS_FREEMAIL X-Spam-Check-By: sourceware.org Received: from mailout-de.gmx.net (HELO mailout-de.gmx.net) (213.165.64.23) by sourceware.org (qpsmtpd/0.43rc1) with SMTP; Tue, 03 May 2011 04:51:13 +0000 Received: (qmail 8116 invoked by uid 0); 3 May 2011 04:51:11 -0000 Received: from 199.64.72.252 by www144.gmx.net with HTTP; Tue, 03 May 2011 06:51:08 +0200 (CEST) Content-Type: text/plain; charset="utf-8" Date: Tue, 03 May 2011 04:51:00 -0000 From: "Klaus Rudolph" Message-ID: <20110503045109.28010@gmx.net> MIME-Version: 1.0 Subject: pretty print beginner question To: gdb@sourceware.org Content-Transfer-Encoding: 8bit X-IsSubscribed: yes Mailing-List: contact gdb-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-owner@sourceware.org X-SW-Source: 2011-05/txt/msg00012.txt.bz2 Hi again, after I heared that gdb.printing is comming with gdb 7.3 and we using the last release 7.2 I tried other examples from the older manual, but without any result? I have a file printer.py: class StdStringPrinter(object): "Print a std::string" def __init__(self, val): self.val = val def to_string(self): return self.val['_M_dataplus']['_M_p'] def display_hint(self): return 'string' def str_lookup_function(val): lookup_tag = val.type.tag if lookup_tag == None: return None regex = re.compile("^std::basic_string$") if regex.match(lookup_tag): return StdStringPrinter(val) return None def register_printers(objfile): objfile.pretty_printers.add(str_lookup_function) source it from the gdb prompt: source printer.py have a little c++ prog with a std::string s if i do a "print s" the output is as without printer.py Can anyone give a short complete and running example how to write and load and setup a first pretty printer for any kind of data... It is hard to fill the gaps in the manual :-( Thanks Klaus -- Empfehlen Sie GMX DSL Ihren Freunden und Bekannten und wir belohnen Sie mit bis zu 50,- Euro! https://freundschaftswerbung.gmx.de