[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Can DDD be used to debug cgi scripts which are written c?
From: |
Andrew Gaylard |
Subject: |
Re: Can DDD be used to debug cgi scripts which are written c? |
Date: |
Sun, 14 Nov 2004 13:59:41 +0200 |
User-agent: |
Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.4.1) Gecko/20031030 |
Julie Gong wrote:
I like DDD a lot. We have web based course management system which is
written in c.
I would like to use DDD as our debug tool. But I do not know DDD can
debug cgi scripts.
If DDD can do this job, Would you please give me some information?
Yes, DDD can easily do this job.
Step 0: put a "sleep( 60 );" into the code at the point where you'd
like to start debugging from.
Step 1: compile your code with no optimisation and full debugging.
For gcc, this means you need a "-ggdb3" and must have no "-O"
directives. Do not run "strip" at any stage either.
Step 2: call your code by pointing a web browser at it.
step 3: use the "ps" command to find the PID of your CGI process.
Step 4: start DDD as the user running the CGI process, in the
same directory where the source files are:
"ddd /path/to/your/binary"
Step 5: connect to the process which will be busy in the
"sleep( 60 )" call, by issuing this command in DDD's command
window:
attach your_PID
Step 6: debug as normal.
Step 7: When your program exits, just redo steps 1, 2, 3, and 5;
there's no need to exit DDD each time.
Once you've done steps 3 and 5 a few times, you'll find that
60 seconds can be reduced down to about 10 seconds. Once you've
done it many times, you'll figure out a way to wrap these steps
into a script...
Good luck,
Andrew.