From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 9715 invoked by alias); 2 Aug 2011 19:19:29 -0000 Received: (qmail 9705 invoked by uid 22791); 2 Aug 2011 19:19:27 -0000 X-SWARE-Spam-Status: No, hits=-0.2 required=5.0 tests=AWL,BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,T_TO_NO_BRKTS_FREEMAIL 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:19:13 +0000 Received: by wwi18 with SMTP id 18so82584wwi.12 for ; Tue, 02 Aug 2011 12:19:12 -0700 (PDT) MIME-Version: 1.0 Received: by 10.216.27.135 with SMTP id e7mr2145404wea.41.1312312752268; Tue, 02 Aug 2011 12:19:12 -0700 (PDT) Received: by 10.216.36.131 with HTTP; Tue, 2 Aug 2011 12:19:12 -0700 (PDT) In-Reply-To: References: Date: Tue, 02 Aug 2011 19:19:00 -0000 Message-ID: Subject: Re: Break at address on darwin From: "Ben L. Titzer" To: noloader@gmail.com 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/msg00004.txt.bz2 On Tue, Aug 2, 2011 at 12:00 PM, Jeffrey Walton wrote: > 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)? It's an address. I know for sure it's being executed because it's the first instruction in the binary. No gdb breakpoints work on my binaries. However if I insert an int3 or illegal instruction in the code, then it will break or trap in gdb. > >> 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. > I am not trying to debug binaries generated by gcc. I am generating binaries from my own compiler, and I think I missed some attribute or section necessary for gdb breakpoints to work properly with my binaries. -B