Date: Sun, 6 Jul 1997 17:46:31 +0300 (IDT) From: Eli Zaretskii To: Thomas Demmer cc: djgpp AT delorie DOT com Subject: Re: Debugging version of C library In-Reply-To: <33B7C686.2781@LSTM.Ruhr-UNI-Bochum.De> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Precedence: bulk On Mon, 30 Jun 1997, Thomas Demmer wrote: > > since rebuilding the library is not easy, I suggest to extract from > > djlsr201.zip only the functions that you need to debug, compile them > > with -g, put them into the library and relink your program: > > > > unzip djlsr201.zip src/libc/foo/bar.c > > gcc -O3 -g src/libc/foo/bar.c > > ar rvs lib/libc.a src/libc/foo/bar.o > > make yourprog > > gdb yourprog > > I think it will suffice to copy bar.c to the working directory and link > it into the executable: > gcc -o foo.exe -g foo.c bar.c > bar.o will be seen by the linker _before_ bar.o inside libc and > used (just because ld is a one pass linker. Beware of such shortcuts! I have been burned by subtle bugs and crashes in programs when I tried to use this technique. In some cases, I even inserted `printf' statement into the modified library function and saw for sure that the linker still links in the old version from the library (the `printf' didn't work)! Don't ask me how can this be, but the facts are indisputable. So I still recommend to use the longer but safer way as outlined in my message. > So there is no need to fiddle > around with libc, and probably forgetting to switch back... Even if you don't switch back, when you strip the binary, all the debugging symbols are gone, so you don't lose anything.