From owner-freebsd-hackers Tue Feb 16 19: 0:43 1999 Delivered-To: freebsd-hackers@freebsd.org Received: from allegro.lemis.com (allegro.lemis.com [192.109.197.134]) by hub.freebsd.org (Postfix) with ESMTP id 8CE3510FB6; Tue, 16 Feb 1999 19:00:05 -0800 (PST) (envelope-from grog@freebie.lemis.com) Received: from freebie.lemis.com (freebie.lemis.com [192.109.197.137]) by allegro.lemis.com (8.9.1/8.9.0) with ESMTP id NAA12685; Wed, 17 Feb 1999 13:29:57 +1030 (CST) Received: (from grog@localhost) by freebie.lemis.com (8.9.3/8.9.0) id NAA10346; Wed, 17 Feb 1999 13:29:52 +1030 (CST) Message-ID: <19990217132952.Z515@lemis.com> Date: Wed, 17 Feb 1999 13:29:52 +1030 From: Greg Lehey To: Chuck Robey , Eivind Eklund Cc: hackers@FreeBSD.ORG Subject: Re: gdb sucks - and I need to get around it. help? References: <19990216170310.C60651@bitbox.follo.net> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Mailer: Mutt 0.93.2i In-Reply-To: ; from Chuck Robey on Tue, Feb 16, 1999 at 12:41:34PM -0500 WWW-Home-Page: http://www.lemis.com/~grog Organization: LEMIS, PO Box 460, Echunga SA 5153, Australia Phone: +61-8-8388-8286 Fax: +61-8-8388-8725 Mobile: +61-41-739-7062 Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG On Tuesday, 16 February 1999 at 12:41:34 -0500, Chuck Robey wrote: > On Tue, 16 Feb 1999, Eivind Eklund wrote: > >> Anybody know of any way of getting gdb to step from the start of the >> program? >> >> I have an executable with absolutely no symbol data (symbol data is >> absolutely non-available) which I *have* to get to step through, if >> necessary by re-implementing gdb. > > You can tell the absolute address of main(), right? Can't you just set > a breakpoint of the program to the address of main() directly (not > symbolically) then start the program. It should stop immediately, then > you can single step until you fall asleep, right? > > That's all if this is a C program. If it's C++, where there is stuff > active even before main(), then I'm not sure the address you'd want, but > it'd NOT be main(). I think I'd get it via objdump. It could read the > elf headers and get it. There's stuff before main in C programs as well. The entry point of all C and C++ programs is start, which is in crt0.o or crt1.o. In a.out files, it used to be directly after the header at 0x1020. I'm not sure where the start address is in an ELF file. The clue should be here somewhere, but I can't see it: $ objdump --section-headers /bin/sh /bin/sh: file format elf32-i386 Sections: Idx Name Size VMA LMA File off Algn 0 .init 00000006 08048074 08048074 00000074 2**2 CONTENTS, ALLOC, LOAD, READONLY, CODE 1 .text 00042c50 0804807c 0804807c 0000007c 2**2 CONTENTS, ALLOC, LOAD, READONLY, CODE 2 .fini 00000006 0808accc 0808accc 00042ccc 2**2 CONTENTS, ALLOC, LOAD, READONLY, CODE 3 .rodata 0000706d 0808acd4 0808acd4 00042cd4 2**2 CONTENTS, ALLOC, LOAD, READONLY, DATA 4 .data 00002758 08092d44 08092d44 00049d44 2**2 CONTENTS, ALLOC, LOAD, DATA 5 .ctors 00000008 0809549c 0809549c 0004c49c 2**2 CONTENTS, ALLOC, LOAD, DATA 6 .dtors 00000008 080954a4 080954a4 0004c4a4 2**2 CONTENTS, ALLOC, LOAD, DATA 7 .bss 00008eec 080954b0 080954b0 0004c4b0 2**4 ALLOC 8 .comment 00000fdc 00000000 00000000 0004c4b0 2**0 CONTENTS, READONLY 9 .note 00000fdc 00000fdc 00000fdc 0004d48c 2**0 CONTENTS, READONLY 10 .gnu.warning.f_prealloc 0000003a 00001fb8 00001fb8 0004e468 2**0 CONTENTS, READONLY I set a breakpoint on the base address of the text segment, but it didn't hit: $ gdb /bin/sh GDB is free software and you are welcome to distribute copies of it under certain conditions; type "show copying" to see the conditions. There is absolutely no warranty for GDB; type "show warranty" for details. GDB 4.16 (i386-unknown-freebsd), Copyright 1996 Free Software Foundation, Inc...(no debugging symbols found)... (gdb) b *0x0804807c Breakpoint 1 at 0x804807c (gdb) r Starting program: /bin/sh warning: shared library handler failed to enable breakpoint # ^C Program received signal SIGINT, Interrupt. 0x806b234 in ?? () (gdb) bt #0 0x806b234 in ?? () #1 0x804f34a in ?? () #2 0x8054399 in ?? () #3 0x80541f5 in ?? () #4 0x80535e9 in ?? () #5 0x80511fb in ?? () #6 0x805118b in ?? () #7 0x80480e9 in ?? () (gdb) The backtrace looks like it's coming from that address, so I'd guess that the address is correct, and the "failed to enable breakpoint" warning is the problem. Is this a bug or a feature? Greg -- See complete headers for address, home page and phone numbers finger grog@lemis.com for PGP public key To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message