This is the mail archive of the gdb@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Break at address on darwin


On Tue, Aug 2, 2011 at 12:00 PM, Jeffrey Walton <noloader@gmail.com> wrote:
> Hi Ben,
>
> On Tue, Aug 2, 2011 at 12:46 PM, Ben L. Titzer <ben.titzer@gmail.com> 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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]