From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 30039 invoked by alias); 27 Oct 2014 23:22:20 -0000 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 Received: (qmail 30026 invoked by uid 89); 27 Oct 2014 23:22:19 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.1 required=5.0 tests=AWL,BAYES_00,FREEMAIL_ENVFROM_END_DIGIT,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,SPF_PASS autolearn=ham version=3.3.2 X-HELO: mail-yh0-f48.google.com Received: from mail-yh0-f48.google.com (HELO mail-yh0-f48.google.com) (209.85.213.48) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-SHA encrypted) ESMTPS; Mon, 27 Oct 2014 23:22:17 +0000 Received: by mail-yh0-f48.google.com with SMTP id v1so5124223yhn.21 for ; Mon, 27 Oct 2014 16:22:15 -0700 (PDT) MIME-Version: 1.0 X-Received: by 10.236.191.230 with SMTP id g66mr25705348yhn.27.1414452135705; Mon, 27 Oct 2014 16:22:15 -0700 (PDT) Received: by 10.170.140.214 with HTTP; Mon, 27 Oct 2014 16:22:15 -0700 (PDT) In-Reply-To: References: Date: Mon, 27 Oct 2014 23:22:00 -0000 Message-ID: Subject: Re: Define python hooks From: Doug Evans To: nojhan Cc: gdb Content-Type: text/plain; charset=UTF-8 X-IsSubscribed: yes X-SW-Source: 2014-10/txt/msg00099.txt.bz2 gdb.execute (command, to_string=True) will return the output as a python string. As for what's the best way to go, I'm not sure. On Mon, Oct 27, 2014 at 2:17 AM, nojhan wrote: > Thanks. > I would want to manipulate the output of several existing commands with python. > > Is there a way to get the output of the command in python (something > like a gdb.execute that would return the output)? > Or should I use a redirection to a named pipe to communicate with gdb? > Or maybe it would be a better option to overload existing commands > with a python class that would execute them? > > -- > nojhan > > On Sun, Oct 26, 2014 at 12:57 AM, Doug Evans wrote: >> On Sat, Oct 25, 2014 at 2:08 AM, nojhan wrote: >>> Hello, >>> >>> I'm currently using several of hook-* and hookpost-* functions with >>> shell commands. >>> I was wondering if there was a way to define such hooks in pure python. >>> >>> For instance, I would like to import a module at startup and use it >>> across all the hooks to manipulate the output of the hooked commands. >> >> Hi. >> >> While one can't directly define hooks in python, one can still invoke >> python from hooks. >> >> E.g. >> >> define hookpost-step >> python >> ... python code ... >> end >> end