From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 31672 invoked by alias); 9 Feb 2008 19:20:07 -0000 Received: (qmail 31652 invoked by uid 22791); 9 Feb 2008 19:20:05 -0000 X-Spam-Check-By: sourceware.org Received: from smtp-out.google.com (HELO smtp-out.google.com) (216.239.33.17) by sourceware.org (qpsmtpd/0.31) with ESMTP; Sat, 09 Feb 2008 19:19:46 +0000 Received: from zps19.corp.google.com (zps19.corp.google.com [172.25.146.19]) by smtp-out.google.com with ESMTP id m19JJbad012036 for ; Sat, 9 Feb 2008 19:19:38 GMT Received: from wa-out-1112.google.com (wafj37.prod.google.com [10.114.186.37]) by zps19.corp.google.com with ESMTP id m19JJamE030526 for ; Sat, 9 Feb 2008 11:19:37 -0800 Received: by wa-out-1112.google.com with SMTP id j37so1127300waf.7 for ; Sat, 09 Feb 2008 11:19:36 -0800 (PST) Received: by 10.114.94.1 with SMTP id r1mr216805wab.32.1202584776021; Sat, 09 Feb 2008 11:19:36 -0800 (PST) Received: by 10.114.13.5 with HTTP; Sat, 9 Feb 2008 11:19:35 -0800 (PST) Message-ID: Date: Sat, 09 Feb 2008 19:20:00 -0000 From: "Doug Evans" To: gdb-patches@sourceware.org Subject: Re: RFC: Allow a wrapper when starting programs In-Reply-To: <20080209165328.GA3161@caradoc.them.org> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <20080208185727.GA30185@caradoc.them.org> <20080209154834.GA32141@caradoc.them.org> <20080209165328.GA3161@caradoc.them.org> X-IsSubscribed: yes Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2008-02/txt/msg00167.txt.bz2 On Feb 9, 2008 8:53 AM, Daniel Jacobowitz wrote: > Sure. We're waiting for an extra trap for the same reason we > currently wait for two (on most systems; sometimes varies). We > normally fork and then execute a command like this one: > > sh -c 'exec your-program' > > The first trap is generated when gdb execs sh. At this point we know > where the child is, but it's at the wrong place. The loaded binary is > sh, not your-program, so we can't set breakpoints in your-program. > > With a wrapper, we run: > > sh -c 'exec wrapper your-program' > > So after two traps, the loaded program is wrapper. If we gave > control to the user or tried to insert breakpoints at your-program's > symbols, things would go wrong. We have to wait until the loaded > program is finally your-program. > > There's no portable way to check what the loaded program is, and > even if there were it wouldn't help enough; wrapper and your-program > might be the same binary (a corner case, I admit). When explained this way one might think there are two wrappers: sh and wrapper. Has anyone ever wanted a way to remove, replace, or otherwise alter the use of the sh "wrapper"? I realize sh brings certain functionality to the party, but it seems like one popular use of the second wrapper is to work around the presence of the first wrapper. It leaves me wondering if there's a better way. OTOH, pragmatics may require the proposed implementation.