From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 31991 invoked by alias); 2 Aug 2011 16:47:07 -0000 Received: (qmail 31979 invoked by uid 22791); 2 Aug 2011 16:47:06 -0000 X-SWARE-Spam-Status: No, hits=-0.1 required=5.0 tests=AWL,BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,TW_EB,T_TO_NO_BRKTS_FREEMAIL 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; Tue, 02 Aug 2011 16:46:50 +0000 Received: by wyg36 with SMTP id 36so2922262wyg.0 for ; Tue, 02 Aug 2011 09:46:49 -0700 (PDT) MIME-Version: 1.0 Received: by 10.216.139.37 with SMTP id b37mr827635wej.41.1312303609034; Tue, 02 Aug 2011 09:46:49 -0700 (PDT) Received: by 10.216.36.131 with HTTP; Tue, 2 Aug 2011 09:46:49 -0700 (PDT) Date: Tue, 02 Aug 2011 16:47:00 -0000 Message-ID: Subject: Break at address on darwin From: "Ben L. Titzer" To: gdb@sourceware.org Content-Type: text/plain; charset=ISO-8859-1 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/msg00002.txt.bz2 I am generating very simple Mach-O binaries by hand without symbol information and trying to debug them with gdb by setting breakpoints at various addresses. However, the breakpoints I set do not fire, though I am certain those addresses are being executed (program runs to completion, I can put in illegal instructions and they trap in gdb, my program makes system calls that output to stdout, etc). When I debug other binaries (e.g. generated by gcc), I am able to set breakpoints at various addresses and they fire in gdb no problem. Even though my binaries load and run correctly, producing the correct output, gdb breakpoints don't work. If I explicitly insert an int3 instruction, a gdb breakpoint does occur. I have a feeling that I am missing some step that is required by gdb, such as setting an attribute or adding an extra section to my binary, but I don't know what. uname -a Darwin goro 10.7.0 Darwin Kernel Version 10.7.0: Sat Jan 29 15:17:16 PST 2011; root:xnu-1504.9.37~1/RELEASE_I386 i386 output from otool -l for one of my binaries: /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