0

I'm trying to debug server.c with gdb, but I can't figure out how to run server.c. The program compiles correctly, but when I use gdb ./server and then run public, server.c runs into an infinite loop. This also happens when I enter ./server public.

How do I run server.c using run public?

Thanks in advance!

0

Remember, when you start server it doesn't do anything until it gets a request, so maybe it's not in an infinite loop. Also, remember to set your breakpoint(s) before run public. Here is a quick guide for using gdb with server:

You will need two terminal sessions. It is also helpful to have the source code open in a third tab, I find it easier to follow than using l in gdb. It is infinitely easier (especially in the beginning) to test server with a curl request instead of a browser request. Key point: if gdb is not doing anything, it's waiting for a request; if curl is not doing anything it's waiting for gdb.

  1. In terminal 1, start gdb ./server
  2. (gdb) break parse
  3. (gdb) run public
  4. In terminal 2, issue a curl request to hello.html curl -i http://localhost:8080/hello.html. It won't do anything, assume gdb is at the parse breakpoint.
  5. Back in terminal 1, time to next through parse and let the troubleshooting begin!

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .