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]

Break at address on darwin


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


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