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.
- In terminal 1, start
gdb ./server
- (gdb)
break parse
- (gdb)
run public
- 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.
- Back in terminal 1, time to
n
ext through parse and let the troubleshooting begin!