From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 25998 invoked by alias); 1 Feb 2013 17:48:50 -0000 Received: (qmail 25989 invoked by uid 22791); 1 Feb 2013 17:48:48 -0000 X-SWARE-Spam-Status: No, hits=-5.8 required=5.0 tests=AWL,BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,KHOP_RCVD_TRUST,KHOP_THREADED,RCVD_IN_DNSWL_LOW,RCVD_IN_HOSTKARMA_YE,RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mail-oa0-f49.google.com (HELO mail-oa0-f49.google.com) (209.85.219.49) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 01 Feb 2013 17:48:43 +0000 Received: by mail-oa0-f49.google.com with SMTP id j6so4573597oag.36 for ; Fri, 01 Feb 2013 09:48:42 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=mime-version:x-received:in-reply-to:references:date:message-id :subject:from:to:cc:content-type:x-gm-message-state; bh=Y1kVAUkRGqIEJg9rPkhqRDhylkWNL954v03/8T73Y7U=; b=O8BgPxg9TClQ8UAn3J3j/P5qm6e2d7eTE2GGnIE/SImJmjC6VWamIgaphkB0/2WOgm R7splCnK0l7cdbXqJWtumdUazxtXw+zCsYzeS8XntDLfYSw+M92Pd3VtIeIao0d7Ln5t hMSbGIxQnjPamKFkKwN5DKTKHfuDq8gWTfziftXijnUi2xxoCwdGGQ+0VHUEylvWF351 XK+qsGe4QO3QtzXL53FBR2izGuPztT7njpJb4Opnrq1rMOhvSM2rfx7RIoNmCoz+mpS0 +IXyQkS2xLL6Zq8Bi5SbnSHBy1udoXgDdmsFGbMn/b0NXYQt9UELqunQ746nsijnlmxb VSUA== MIME-Version: 1.0 X-Received: by 10.182.154.4 with SMTP id vk4mr9156395obb.70.1359740922214; Fri, 01 Feb 2013 09:48:42 -0800 (PST) Received: by 10.76.73.72 with HTTP; Fri, 1 Feb 2013 09:48:42 -0800 (PST) In-Reply-To: References: Date: Fri, 01 Feb 2013 17:48:00 -0000 Message-ID: Subject: Re: Pretty Printing From: Doug Evans To: Graham Labdon Cc: "gdb@sourceware.org" Content-Type: text/plain; charset=ISO-8859-1 X-Gm-Message-State: ALoCoQlpKmsiNPVURqC9/jlnVcU3WF9ymIBnWHPCEHMtvg6v+PAE7UvmSh4ie4S3jH9EORu0P/OXmavlfjHGq6He/14m0DfQGYmTsZDVOMh3+LQUyWF+pNCImvWiqQ/6UP46Cinf3wo3qDVtB5qKAlZB7u/1NhI35oUmf3jveV/okWmSrNqwYWG+YZUVi1bziqiutnCy/egj 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: 2013-02/txt/msg00005.txt.bz2 On Fri, Feb 1, 2013 at 1:22 AM, Graham Labdon wrote: > Hi > I don't know if there is anyone on this forum who can help > > I am developing a set of gdb pretty printers for Qt > A dictionary is built of the functions to call when a variable of a given type is detected > Code: > def build_dictionary (): > pretty_printers_dict[re.compile ('^QFile$')] = lambda val:QFilePrinter(val,"false") > pretty_printers_dict[re.compile ('^QFile \*$')] = lambda val: QFilePointerPrinter(val) > > > Here I have declared handlers for the QFile and QFile * types > > In the QFile handler I have this code > Code: > exp = "((class QFile *)%s)->%s()" % (value.address, "exists") > > > The problem is that this causes the handler for QFile * to be called which causes great problems > > If any Python guru knows how to overcome this I would appreciate it Have you tried beginning with an existing pretty-printer that works? Here are the pretty-printers for libstdc++: http://gcc.gnu.org/viewcvs/trunk/libstdc%2B%2B-v3/python/libstdcxx/v6/printers.py?revision=193573&view=markup It's not clear what you're trying to do with "exp". Secondly, it's bad practice for pretty-printers to run code on the inferior (which appears to be what exp is for). - won't work with core files - the inferior (gdb parlance for the program you're debugging) may not be in a good enough state to run the code - if you're debugging a problem, that last thing you want is to perturb inferior state