From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 14699 invoked by alias); 27 Oct 2014 09:17:39 -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 14685 invoked by uid 89); 27 Oct 2014 09:17:38 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-0.9 required=5.0 tests=AWL,BAYES_00,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,SPF_PASS autolearn=ham version=3.3.2 X-HELO: mail-wi0-f178.google.com Received: from mail-wi0-f178.google.com (HELO mail-wi0-f178.google.com) (209.85.212.178) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-SHA encrypted) ESMTPS; Mon, 27 Oct 2014 09:17:37 +0000 Received: by mail-wi0-f178.google.com with SMTP id q5so5761370wiv.11 for ; Mon, 27 Oct 2014 02:17:34 -0700 (PDT) X-Received: by 10.194.90.15 with SMTP id bs15mr20638800wjb.47.1414401454129; Mon, 27 Oct 2014 02:17:34 -0700 (PDT) MIME-Version: 1.0 Received: by 10.194.163.34 with HTTP; Mon, 27 Oct 2014 02:17:13 -0700 (PDT) In-Reply-To: References: From: nojhan Date: Mon, 27 Oct 2014 09:17:00 -0000 Message-ID: Subject: Re: Define python hooks To: gdb Content-Type: text/plain; charset=UTF-8 X-IsSubscribed: yes X-SW-Source: 2014-10/txt/msg00098.txt.bz2 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