Search the FAQ Archives

3 - A - B - C - D - E - F - G - H - I - J - K - L - M
N - O - P - Q - R - S - T - U - V - W - X - Y - Z
faqs.org - Internet FAQ Archives

FAQ: Frequently Asked Questions about CGI Programming
Section - 4.5 How can I run my CGI program 'live' in a debugger?

( Single Page )
[ Usenet FAQs | Web FAQs | Documents | RFC Index | Restaurant inspections ]


Top Document: FAQ: Frequently Asked Questions about CGI Programming
Previous Document: 4.4 I tried to use (Content-Type|Location|whatever), but it appears in my Browser?
Next Document: 4.6 I'm using CGI with QUERY_STRING embedded in my HTML, but it gets corrupted?
See reader questions & answers on this topic! - Help others by sharing your knowledge

David S. Jackson offers the following tip:

> I have a very good trick for debugging CGIs written in C/C++ running on
> UNIX. You might want to add it to the debugging section of your CGI faq.
> 
> First, in your CGI code, at it's start, add "sleep(30);". This will cause
> the CGI to do nothing for thiry seconds (you may need to adjust this
> time). Compile the CGI with debuging info ("-g" in gcc) and install the
> CGI as normal. Next, using your web browser, activate the CGI. It will of
> course just sit there doing nothing. While it is 'sleeping', find it's PID
> (ps -a | grep <cgi name>). Load your debugger and attach to that PID
> ("attach <pid>" in gdb). You will also need to tell it where to find the
> symbol definitions ("symbol-file <cgi>" in gdb). Then set a break point
> after the invocation of the sleep function and you are ready to debug. Do
> be aware that your browser will eventually timeout if it doesn't recieve
> anything.

(Anyone know similar tricks for scripting languages)?


User Contributions:

Comment about this article, ask questions, or add new information about this topic: