Re: Attaching to newly-exec'd process
Re: Attaching to newly-exec'd process
- Subject: Re: Attaching to newly-exec'd process
- From: Steve Checkoway <email@hidden>
- Date: Fri, 18 Jan 2008 17:01:16 -0800
Jim Ingham wrote:
The time honored trick is to put a spin loop like:
int wait = 1;
while (wait) {;}
Would you want wait to be volatile? I'm not at a mac at the moment, but
if I don't use volatile, the code gets optimized (when I turn on
optimization, of course) to:
Dump of assembler code for function main:
0x08048360 <main+0>: lea 0x4(%esp),ìx
0x08048364 <main+4>: and $0xfffffff0,%esp
0x08048367 <main+7>: pushl 0xfffffffc(ìx)
0x0804836a <main+10>: push ëp
0x0804836b <main+11>: mov %esp,ëp
0x0804836d <main+13>: push ìx
0x0804836e <main+14>: mov 0x8049570,êx
0x08048373 <main+19>: test êx,êx
0x08048375 <main+21>: jne 0x804837f <main+31>
0x08048377 <main+23>: pop ìx
0x08048378 <main+24>: xor êx,êx
0x0804837a <main+26>: pop ëp
0x0804837b <main+27>: lea 0xfffffffc(ìx),%esp
0x0804837e <main+30>: ret
0x0804837f <main+31>: jmp 0x804837f <main+31>
and it stays at that last jump instruction forwever.
Scott Ribe wrote:
Given a process-per-connection server, process A gets the socket,
vforks,
dups the socket, and execs a different executable image B--how to
attach to
B and debug??? Specifically, I want to step main from the start, not
attach
to the process after it's been running a while. Is there a way to do
that,
besides sleeping main in the first line?
Are you sure you can dup a socket on the child side of a vfork? The
Apple man page doesn't mention anything, but I've always thought (and
the linux man page I'm looking at now) claims that doing anything other
than _exit(2)ing or calling one of the exec family of functions (or,
oddly enough modifying data of type pid_t) from the client side of
vfork() results in undefined behavior.
I also recall someone mentioning something about this on some apple
list, but unfortunately, my searches aren't supporting my memory.
--
Steve Checkoway
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden