From: "Ben L. Titzer" <ben.titzer@gmail.com>
To: Jonas Maebe <jonas.maebe@elis.ugent.be>
Cc: Pedro Alves <pedro@codesourcery.com>, GDB Users <gdb@sourceware.org>
Subject: Re: Break at address on darwin
Date: Wed, 03 Aug 2011 13:45:00 -0000 [thread overview]
Message-ID: <CAL9pw=_JphLiru9-b7HJsWC-U_MvLeU34r_Pn-qAddR+2quXbg@mail.gmail.com> (raw)
In-Reply-To: <3A370EF2-7FE5-4266-99A9-E58537D4A4B2@elis.ugent.be>
On Wed, Aug 3, 2011 at 2:05 AM, Jonas Maebe <jonas.maebe@elis.ugent.be> wrote:
>
> On 03 Aug 2011, at 10:59, Pedro Alves wrote:
>
>> On Tuesday 02 August 2011 22:51:22, Ben L. Titzer wrote:
>>>
>>> Num Type Disp Enb Address What
>>> 1 breakpoint keep y 0x00001114
>>> 2 breakpoint keep y 0x00001148
>>
>> Does the program really load at those addresses?
Yes I am 100% sure this program actually runs to completion and
produces what it should. As I mentioned, if I insert an int3 or
illegal instruction manually somewhere in its code, the program will
trap appropriately. However, I need to debug other programs with gdb,
e.g. by single-stepping through their execution.
>> They look suspiciously low.
>
> They're probably correct. Darwin/i386 generally does load programs starting
> at 0x1000.
Yes, 0x1000 is where the program loads its first text page, which is
mapped to file offset 0. 0x01114 happens to be the entrypoint
instruction. 0x01148 is the address of the first function it calls,
which you can see from the assembly listing.
Output from the otool -l command for this binary:
/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
-B
next prev parent reply other threads:[~2011-08-03 13:45 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-08-02 16:47 Ben L. Titzer
2011-08-02 19:00 ` Jeffrey Walton
2011-08-02 19:19 ` Ben L. Titzer
2011-08-02 20:31 ` Jonas Maebe
2011-08-02 21:51 ` Ben L. Titzer
2011-08-03 8:09 ` Tristan Gingold
2011-08-03 9:00 ` Pedro Alves
2011-08-03 9:05 ` Jonas Maebe
2011-08-03 13:45 ` Ben L. Titzer [this message]
2011-08-03 14:06 ` Pedro Alves
2011-08-03 21:00 ` Ben L. Titzer
2011-08-04 7:19 ` Tristan Gingold
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CAL9pw=_JphLiru9-b7HJsWC-U_MvLeU34r_Pn-qAddR+2quXbg@mail.gmail.com' \
--to=ben.titzer@gmail.com \
--cc=gdb@sourceware.org \
--cc=jonas.maebe@elis.ugent.be \
--cc=pedro@codesourcery.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox