From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 30319 invoked by alias); 3 Aug 2011 13:45:28 -0000 Received: (qmail 30303 invoked by uid 22791); 3 Aug 2011 13:45:27 -0000 X-SWARE-Spam-Status: No, hits=-0.4 required=5.0 tests=AWL,BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,TW_EB X-Spam-Check-By: sourceware.org Received: from mail-wy0-f169.google.com (HELO mail-wy0-f169.google.com) (74.125.82.169) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Wed, 03 Aug 2011 13:45:12 +0000 Received: by wyg36 with SMTP id 36so690255wyg.0 for ; Wed, 03 Aug 2011 06:45:11 -0700 (PDT) MIME-Version: 1.0 Received: by 10.216.69.77 with SMTP id m55mr2910350wed.11.1312379111266; Wed, 03 Aug 2011 06:45:11 -0700 (PDT) Received: by 10.216.36.131 with HTTP; Wed, 3 Aug 2011 06:45:11 -0700 (PDT) In-Reply-To: <3A370EF2-7FE5-4266-99A9-E58537D4A4B2@elis.ugent.be> References: <5456BE39-F808-4255-B327-334CBC46B068@elis.ugent.be> <201108030959.38208.pedro@codesourcery.com> <3A370EF2-7FE5-4266-99A9-E58537D4A4B2@elis.ugent.be> Date: Wed, 03 Aug 2011 13:45:00 -0000 Message-ID: Subject: Re: Break at address on darwin From: "Ben L. Titzer" To: Jonas Maebe Cc: Pedro Alves , GDB Users Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable 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: 2011-08/txt/msg00013.txt.bz2 On Wed, Aug 3, 2011 at 2:05 AM, Jonas Maebe wro= te: > > On 03 Aug 2011, at 10:59, Pedro Alves wrote: > >> On Tuesday 02 August 2011 22:51:22, Ben L. Titzer wrote: >>> >>> Num Type =A0 =A0 =A0 =A0 =A0 Disp Enb Address =A0 =A0What >>> 1 =A0 breakpoint =A0 =A0 keep y =A0 0x00001114 >>> 2 =A0 breakpoint =A0 =A0 keep y =A0 0x00001148 >> >> Does the program really load at those addresses? Yes I am 100% sure this program actually runs to completion and produces what it should. As I mentioned, if I insert an int3 or illegal instruction manually somewhere in its code, the program will trap appropriately. However, I need to debug other programs with gdb, e.g. by single-stepping through their execution. >> They look suspiciously low. > > They're probably correct. Darwin/i386 generally does load programs starti= ng > at 0x1000. Yes, 0x1000 is where the program loads its first text page, which is mapped to file offset 0. 0x01114 happens to be the entrypoint instruction. 0x01148 is the address of the first function it calls, which you can see from the assembly listing. Output from the otool -l command for this binary: /tmp/add01: Load command 0 cmd LC_SEGMENT cmdsize 56 segname __PAGEZERO vmaddr 0x00000000 vmsize 0x00001000 fileoff 0 filesize 0 maxprot 0x00000000 initprot 0x00000000 nsects 0 flags 0x0 Load command 1 cmd LC_SEGMENT cmdsize 56 segname __TEXT vmaddr 0x00001000 vmsize 0x00001000 fileoff 0 filesize 4096 maxprot 0x00000007 initprot 0x00000005 nsects 0 flags 0x0 Load command 2 cmd LC_SEGMENT cmdsize 56 segname __DATA vmaddr 0x00002000 vmsize 0x00000000 fileoff 4096 filesize 0 maxprot 0x00000003 initprot 0x00000003 nsects 0 flags 0x0 Load command 3 cmd LC_UNIXTHREAD cmdsize 80 flavor i386_THREAD_STATE count i386_THREAD_STATE_COUNT eax 0x00000000 ebx 0x00000000 ecx 0x00000000 edx 0x00000000 edi 0x00000000 esi 0x00000000 ebp 0x00000000 esp 0x00000000 ss 0x00000000 eflags 0x00000000 eip 0x00001114 cs 0x00000000 ds 0x00000000 es 0x00000000 fs 0x00000000 gs 0x00000000 -B