[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Starting DDD programmatically
From: |
Michael Eager |
Subject: |
Re: Starting DDD programmatically |
Date: |
Fri, 26 Aug 2011 11:46:17 -0700 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:6.0) Gecko/20110816 Thunderbird/6.0 |
On 08/26/2011 09:14 AM, address@hidden wrote:
I'm writing CGI scripts using the C language. I'd like to know if DDD can help
me debug these
programs (scripts).
CGI scripts are programs that get executed by a web server (ex: Apache).
Scripts don't run
continuously. They are executed by the web server when the user of a web browser
"submits" a web
page that contains an HTML form. The script (C program) runs long enough to
process the information
on the form. The script then terminates. Consequently, there is no continously
running program for
DDD to attach to. Is there a way that the script (or the web server) can start
or attach to DDD when
the script executes?
You might add code to your script to save the PID for the
CGI process and then sleep for a while to allow you to attach
with gdb/ddd. Something like the following:
void wait_for_gdb (void)
{
pid_t pid = getpid();
FILE pidfd = fopen ("/tmp/cgipid", "w")
fprintf (pidfd, "%d", pid);
fclose (pidfd);
sleep (15);
}
or perhaps wait for you to set a flag before continuing:
while (fopen ("/tmp/goddd", "r") != 0) sleep (1);
--
Michael Eager address@hidden
1960 Park Blvd., Palo Alto, CA 94306 650-325-8077