I am having trouble with this pset and I am using gdb to step through the function. Should I worry about the following observations or should I ignore them and assume my problems are from something further down the line

I set a break point to the end of the parse function and then print out the values of the pointers the parse function is supposed to be manipulating. I get the following EXPECTED output:

(gdb) print line
$1 = 0x7fffffff9b80 "GET / HTTP/1.1\r\n"
(gdb) print abs_path
$2 = 0x7fffffffbce0 "/"
(gdb) print query
$3 = 0x7fffffff9ce0 ""

I then step out of the parse function and get the following UNEXPECTED output:

(gdb) s
765     }
main (argc=2, argv=0x7fffffffdeb8) at server.c:193
193                         char* p = urldecode(abs_path);
(gdb) print line
$4 = 0x7fffffff9b80 "GET / HTTP/1.1\r\n"
(gdb) print query
$5 = '\000' <repeats 8190 times>
(gdb) print abs_path
$6 = "/", '\000' <repeats 5527 times>...

What does '\000' <repeats XXXX times>... mean? Does this indicate I have done something wrong and is this causing problems in the rest of the program?


Notice the difference between the declaration of abs_path/query in main

char abs_path[LimitRequestLine + 1];
char query[LimitRequestLine + 1];

vs. the declaration in parse.

bool parse(const char* line, char* abs_path, char* query)

In main they are char arrays. In parse they are char*. Both your sample outputs should be expected. Both variables appear to be properly null terminated in main, so look in other parts of your code for problems. The "repeats" message indicates the the next XXXX bytes have the same value.

| improve this answer | |
  • So, I am finally working on the php portion of the pset. I have the same issue but this time, *query should have data in it. I do the same procedure in gdb and when I print query inside parse I get something like "$1 = 0x607a5a "?name=d" " and when I step back into main and print query I get "$2 = '\000' <repeats 8190 times>" This really seems wrong. If you would like, I can post this as another question. – Brendan Rafferty May 31 '16 at 18:00

You must log in to answer this question.

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