From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 31786 invoked by alias); 23 Nov 2010 21:53:55 -0000 Received: (qmail 31778 invoked by uid 22791); 23 Nov 2010 21:53:54 -0000 X-SWARE-Spam-Status: No, hits=-1.9 required=5.0 tests=AWL,BAYES_00,T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mail.codesourcery.com (HELO mail.codesourcery.com) (38.113.113.100) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 23 Nov 2010 21:53:23 +0000 Received: (qmail 372 invoked from network); 23 Nov 2010 21:53:21 -0000 Received: from unknown (HELO orlando.localnet) (pedro@127.0.0.2) by mail.codesourcery.com with ESMTPA; 23 Nov 2010 21:53:21 -0000 From: Pedro Alves To: gdb@sourceware.org Subject: Re: How do I patch my binary Date: Tue, 23 Nov 2010 21:53:00 -0000 User-Agent: KMail/1.13.5 (Linux/2.6.33-29-realtime; KDE/4.4.5; x86_64; ; ) Cc: Marc Khouzam References: In-Reply-To: MIME-Version: 1.0 Content-Type: Text/Plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Message-Id: <201011232153.16064.pedro@codesourcery.com> 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: 2010-11/txt/msg00091.txt.bz2 On Tuesday 23 November 2010 21:31:22, Marc Khouzam wrote: > There is doc section "Patching Programs". This got me hoping I could somehow > patch my binary while I was debugging. > > My hope was that I could modify the source code (outside of GDB), recompile > the binary and have GDB load and use the new binary, without having to restart > the program. I couldn't get this to work (using 'set write on' and reloading > the new binary). Doesn't work that way. You make it sound like you want edit&continue, which GDB doesn't do (or rather the toolchain doesn't, since it requires coordination between the compiler/linker/debugger). For some extremely lucky scenarios, against simple remote targets, you might be able to get around with "load", but forget I said that. > When the doc says "Patching" does it mean I actually have to modify the memory > where the code is written, using GDB commands? Yes. > Or can I do it high-level like I originally hoped. No. -- Pedro Alves