From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 2686 invoked by alias); 2 Aug 2011 19:00:35 -0000 Received: (qmail 2677 invoked by uid 22791); 2 Aug 2011 19:00:34 -0000 X-SWARE-Spam-Status: No, hits=-2.3 required=5.0 tests=AWL,BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW X-Spam-Check-By: sourceware.org Received: from mail-ww0-f43.google.com (HELO mail-ww0-f43.google.com) (74.125.82.43) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 02 Aug 2011 19:00:18 +0000 Received: by wwi18 with SMTP id 18so65716wwi.12 for ; Tue, 02 Aug 2011 12:00:16 -0700 (PDT) MIME-Version: 1.0 Received: by 10.216.229.210 with SMTP id h60mr934505weq.29.1312311616563; Tue, 02 Aug 2011 12:00:16 -0700 (PDT) Received: by 10.216.184.131 with HTTP; Tue, 2 Aug 2011 12:00:16 -0700 (PDT) Reply-To: noloader@gmail.com In-Reply-To: References: Date: Tue, 02 Aug 2011 19:00:00 -0000 Message-ID: Subject: Re: Break at address on darwin From: Jeffrey Walton To: "Ben L. Titzer" Cc: 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/msg00003.txt.bz2 Hi Ben, On Tue, Aug 2, 2011 at 12:46 PM, Ben L. Titzer wrote: > 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). Are you certain you are setting a breakpoint on an address (eg, b 0x40000000)? Or is it a symbolic name (b main)? > 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. > > [SNIP] When I have issues, it typically is because I have optimizations enabled and I set a symbolic breakpoint which is never hit (despite what the result of the break command states). Taking optimizations back to -O0 usually resolves the issue for me. For what its worth, I don't find this sort of thing to be an Apple/Mac OS X issue. It can happen anywhere the optimizer works its magic. Jeff