From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 602 invoked by alias); 28 Jun 2003 22:23:04 -0000 Mailing-List: contact gdb-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-owner@sources.redhat.com Received: (qmail 591 invoked from network); 28 Jun 2003 22:23:03 -0000 Received: from unknown (HELO molenda.com) (192.220.74.81) by sources.redhat.com with SMTP; 28 Jun 2003 22:23:03 -0000 Received: (qmail 60351 invoked by uid 19025); 28 Jun 2003 22:23:03 -0000 Date: Sat, 28 Jun 2003 22:35:00 -0000 From: Jason Molenda To: Kris Warkentin Cc: gdb@sources.redhat.com Subject: Re: Howdy from Apple; Fix and Continue implemented Yet Again Message-ID: <20030628152303.A56582@molenda.com> References: <20030627004003.A6119@molenda.com> <20030627202956.A42704@molenda.com> <007f01c33d7c$c7a5d980$2a00a8c0@dash> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5.1i In-Reply-To: <007f01c33d7c$c7a5d980$2a00a8c0@dash>; from kewarken@qnx.com on Sat, Jun 28, 2003 at 09:54:22AM -0400 X-SW-Source: 2003-06/txt/msg00532.txt.bz2 On Sat, Jun 28, 2003 at 09:54:22AM -0400, Kris Warkentin wrote: > That's pretty interesting. Does it require any special os support in the > debug interface or is it all done with dlopen/dlclose, etc.? Other than > compiling your app PIC, does it require any other special compiler features? There aren't a lot of additional requirements. The main app doesn't have to be PIC, but the Fixed file does. Mike Stump added two gcc options to support Fix and Continue: the first pads the prologues of every function with a few NOP instructions, the second creates indirect references for all file-static data. We also had to modify the Objective C runtime to not register the duplicate classes in the Fixed file, and a new option to our dlopen equivalent, NSLinkModule. The NOPs are added so that we're guaranteed to have room for the 5-instruction long trampoline sequence (four insns plus an illegal op code so I can reliably detect the sequence). F&C is only used on unoptimized code[1] but it's possible for a function to be too small on a PowerPC if it has no body or arguemnts. [1] F&C could be used on optimized code as long as you never try to update the PC from the middle of an old function to the middle of a new function. If you keep running the old version of a function, or you don't ever fix while a function is on the stack, optimized code should work correctly. The file-static indirection is a bit trickier. Normally references to global data are made indirectly, with the static link editor or dynamic linker updating the references at link/runtime. But when you refer to static data in your file, or global data that is allocated in that file, the indirection is not necessary. So a simplistic approach to F&C (the one H-P took) will have a separate copy of each file static/global variable for each time you Fix a file. (H-P does copy the values from the globals at Fix time) Instead, we changed our compiler and assembler to force all of these file-static references though a table of indirections. The table is an array of addresses, one for each static, containing the offset of the variable in the DATA section. gdb tries to match these up to identify which (struct symbol) each entry is referring to, finds the original structure, and changes the indirection table to point to the original one. In the dynamic linker, we added a feature to suppress static initializers in Fixed solibs. We don't export the function names in the Fixed solib (aka don't add RTLD_GLOBAL to the dlopen() call in Linux-speek :), and we added a NSLINKMODULE_OPTION_DONT_CALL_MOD_INIT_ROUTINES option to NSLinkModule() for this. The file static data will be redirected to the already-initialized data so there's no need to run the initializers, and doing so could have side effects to the program, so we just avoid the whole issue by not running those. The important thing for our customers is that F&C is ready to be used at all times when they're doing "development style" builds. We build -g -O0 and add in the compiler flag to pad prologues automatically. Then, half-way through debugging, they realize they want to use F&C and it's ready to go. The H-P implementation does use one other feature from the compiler. They rebuild the source file from within gdb, so they require the compiler to put the entire compiler command line option in the .o file. J