From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 10448 invoked by alias); 9 Apr 2013 16:19:24 -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 10437 invoked by uid 89); 9 Apr 2013 16:19:23 -0000 X-Spam-SWARE-Status: No, score=-6.8 required=5.0 tests=AWL,BAYES_00,KHOP_RCVD_TRUST,KHOP_THREADED,RCVD_IN_DNSWL_LOW,RCVD_IN_HOSTKARMA_YE,RP_MATCHES_RCVD autolearn=ham version=3.3.1 Received: from mail-vc0-f170.google.com (HELO mail-vc0-f170.google.com) (209.85.220.170) by sourceware.org (qpsmtpd/0.84/v0.84-167-ge50287c) with ESMTP; Tue, 09 Apr 2013 16:19:22 +0000 Received: by mail-vc0-f170.google.com with SMTP id lf10so2525654vcb.15 for ; Tue, 09 Apr 2013 09:19:20 -0700 (PDT) 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=xeHk/VLvbax167dyLtlbOajGU09VjSq3fnu6AsyQUHs=; b=bPtd+N7+eOM1MEKvRsP48/+vXoOL068dBOmcIcOUhpturqUItseGHsRKogsOmcV9RV lm+6AHOgtRMm0WAQKQP8H4+z5d0udKaQz9aFgl0mnjq4oV5/2AHYnGioZkld/5ehEUEL 3HKq82ltT+rp3bgMMhs739su+pCZMk5xkJqnr7CjtnI4Pn2OryuQ5HfXhSQxaoTcdKME IQo+TyGfIChEqMbq0ChCmlWN+fAJ2ql+sAVzWBjWGdQVgS/orphH0gsWRx0i7cFNdnon i0ZkiVs/OJiSJI6hqEW3M8aIV5+kVKB5wqWG3yTLvTskbnzS/Yyc/jYDPrUTuHFZninr PyqA== MIME-Version: 1.0 X-Received: by 10.58.223.134 with SMTP id qu6mr19812599vec.35.1365524360812; Tue, 09 Apr 2013 09:19:20 -0700 (PDT) Received: by 10.220.123.70 with HTTP; Tue, 9 Apr 2013 09:19:20 -0700 (PDT) In-Reply-To: References: Date: Tue, 09 Apr 2013 16:19:00 -0000 Message-ID: Subject: Re: Spotting inferior function calls from Python From: Doug Evans To: Nick Bull Cc: gdb Content-Type: text/plain; charset=ISO-8859-1 X-Gm-Message-State: ALoCoQmtNGQfe/FnngGP4nhK9Ud6tzyMUWiMccpO0ihJdG7IGCHcBMRngVmLw5IN9VEqCIfiDpkLa0Eb5jcN1qcK0CF0ag8dvTPDVpIvJn+GCBu/C6JGKrgHbwYkRp4VvTF5kG7oNzhqz8gxqB4zA1CYm8Kkn2b/bOdY36g+yywZR+HCUIgWQg4hEDJB9NLp6rhtkerxr2vb X-SW-Source: 2013-04/txt/msg00024.txt.bz2 On Fri, Apr 5, 2013 at 4:48 AM, Nick Bull wrote: > Hi, > > I would like my Python code to be notified when gdb causes a function to be > run on the inferior outside of the normal program flow. For example, this > could be used to warn the user that any side-effects might change future > program execution. > > I can't simply hook the 'call' command because there are many other > commands which could in principle invoke inferior functions, and too many > false positives would be inconvenient. > > It looks as though all such function calls happen via > call_function_by_hand. So the simplest approach would be for me to create a > new observer type which is notified in call_function_by_hand, and a > corresponding Python event type. Does that sound sensible? > > And is such a patch likely to be accepted for inclusion, assuming all > formatting and copyright assignment requirements are met? Is such a warning sufficiently useful? And if it is useful, it might make more sense to just add it to gdb proper. Are there other uses for such an observer? I'm not sure. [I'm not objecting, just requesting more data.] Plus for full coverage you need to intercept not just hand-called functions but target memory and register writes (and reads if they're to device registers and such, but one could punt on that in the first pass, I think). fwiw, One feature I would like to see added is the ability to intercept hand-called functions and run some Python code instead. [I mightn't implement the warning using this. Just fyi.]