Shawn Best wrote:
Hi Matthew,
I think the other stops are perfectly normal. There are cases where
the inferior program will temporarily stop (for example waiting to
load dependent libraries, or maybe stepping over multiple instructions
in a section of code). In these 'private stop' cases, it is
determined the stop is temporary and it will quietly restart the program.
For a "program launch" where the user does not want to stop at the
inferior's entry point, then only 1 stop should occur. Compile the
program I've attached, in linux, it launches a program (/bin/ls - which
has shared library dependencies on my system) with a tracer and wait for
stops. Perhaps there's good reason for the other 2 stops when lldb is
the debugger, I'm just unaware of them right now.
Jim Ingham, I think may be alluding to other reasons why we see 3 stops
on "program launch" in his mail on this thread, but I've not digested
that mail thoroughly yet.
In the case where the program is meant to stop (i.e. hitting a
breakpoint) the event is broadcast so the state machine in
HandleProcessEvents picks it up and changes the public state to stop,
dumps some information and pops the IOHandler so the user can interact
with the command line.
Yeah, agreed.
I went through the same steps as you chasing this problem. I also
stepped through the equivalent code on OSX, which does it completely
different and bypasses this issue.
Ok, fair enough. I don't know the differences between OSX and linux, or
why as you say, a completely different flow happens which avoids our
current problem.
Matt
Member of the CSR plc group of companies. CSR plc registered in England and
Wales, registered number 4187346, registered office Churchill House, Cambridge
Business Park, Cowley Road, Cambridge, CB4 0WZ, United Kingdom
More information can be found at www.csr.com. Keep up to date with CSR on our
technical blog, www.csr.com/blog, CSR people blog, www.csr.com/people, YouTube,
www.youtube.com/user/CSRplc, Facebook,
www.facebook.com/pages/CSR/191038434253534, or follow us on Twitter at
www.twitter.com/CSR_plc.
New for 2014, you can now access the wide range of products powered by aptX at
www.aptx.com.
#include <stdio.h>
#include <stdlib.h>
#include <sys/ptrace.h>
#include <sys/wait.h>
//-------------------------------------------------------------------------------
int main()
{
int pid = fork();
if(0 == pid)
{
// debuggee will stop on SIGTRAP
if(ptrace(PTRACE_TRACEME, 0, NULL, NULL))
{
perror("ptrace");
}
char* args[] = {"/bin/ls", ".", 0};
execv("/bin/ls", args);
exit(0);
}
// the parent (i.e. debugger)
else
{
int status = 0;
while((pid = waitpid(-1, &status, __WALL)) > 0)
{
if(WIFEXITED(status))
{
fprintf(stderr, "Program has exit\n");
break;
}
else
{
if(WIFSTOPPED(status))
{
int rc = 0;
fprintf(stderr, "Program stopped signal=%d\n", WSTOPSIG(status));
ptrace(PTRACE_CONT, pid, NULL, NULL);
fprintf(stderr, "Restarting %d\n", rc);
}
}
}
}
return 0;
}
_______________________________________________
lldb-dev mailing list
lldb-dev@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/lldb-dev