From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 16642 invoked by alias); 17 Oct 2014 16:57:37 -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 16630 invoked by uid 89); 17 Oct 2014 16:57:36 -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-f43.google.com Received: from mail-yh0-f43.google.com (HELO mail-yh0-f43.google.com) (209.85.213.43) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-SHA encrypted) ESMTPS; Fri, 17 Oct 2014 16:57:35 +0000 Received: by mail-yh0-f43.google.com with SMTP id f73so535990yha.2 for ; Fri, 17 Oct 2014 09:57:33 -0700 (PDT) MIME-Version: 1.0 X-Received: by 10.236.43.208 with SMTP id l56mr13616765yhb.9.1413565053278; Fri, 17 Oct 2014 09:57:33 -0700 (PDT) Received: by 10.170.140.214 with HTTP; Fri, 17 Oct 2014 09:57:33 -0700 (PDT) In-Reply-To: References: Date: Fri, 17 Oct 2014 16:57:00 -0000 Message-ID: Subject: Re: Breakpoint commands compiler From: Doug Evans To: Daniel Gutson Cc: gdb Content-Type: text/plain; charset=UTF-8 X-IsSubscribed: yes X-SW-Source: 2014-10/txt/msg00077.txt.bz2 On Fri, Oct 17, 2014 at 8:42 AM, Daniel Gutson wrote: > Hi, > > gdb is sometimes used for changing the runtime behavior of a program. > That is, suppose there is a program that has a bug, > it is spotted with gdb, then I create a set of non-stopping breakpoints that > "fix" the runtime behavior by altering memory and registers. > It does work, but it's slow. > > I was thinking to start a project to add a "breakpoint commands compiler" > to gdb, which basically generates C code from the breakpoint commands > (one function per breakpoint), > which in turns calls a C API (similar to the python api), invokes the compiler > (user-specified), loads it as a shared object, and finally replaces the commands > of the breakpoints by calls to the compiled breakpoint-functions. > > Any comment/suggestion? Would this be accepted within gdb? Hi. For reference sake a patch has been submitted by Red Hat to add a "compile" command. [The patch is still being reviewed, it hasn't been committed yet.] It doesn't compile gdb commands, but allows one to add compiled code to the inferior in the debugging session. The problem with attaching this code to breakpoints is that breakpoints are handled exterior to the program (the inferior gets, e.g., a SIGTRAP and gdb processes the signal - the inferior never sees it). If you wanted to add compiled code that ran when the breakpoint was "hit" you'd need to solve this problem. There are "agent expressions" which support a limited number of gdb-like things and are compiled as bytecode. They can even be run without communication with gdb when used with gdbserver. There is even a jitter to support limited things like fast conditional breakpoints. Part of the gdb/gdbserver unification project is to add support for agent expressions to gdb. https://sourceware.org/gdb/wiki/LocalRemoteFeatureParity But until then agent expressions are only supported by gdbserver. Hope that helps. I think a feature to compile gdb commands to C would not be accepted, at least not in that form. But limited extensions of the above features (and certainly assistence with LocalRemoteFeatureParity) would be welcome.