To start gdb type "gdb program". For example, to debug your shell type:
csh> gdb shellThen type
(gdb) break mainThis will make the debugger stop your program before main is called. In general, to set a breakpoint in a given function type "break <function-name>"
To start running your program type:
(gdb)runYour program will start running and then will stop at main.
Use "step"or "next" to execute the following line in your program. "step" will execute the following line and if it is a function, it will step into it. "next" will execute the following line and if it a function it will execute the function.
(gdb) next - Executes following line. If it is a function it will execute the function and return.An empty line in gdb will rerun the previous gdb command.
or
(gdb) step - Executes following line. If it is a function it will step into it.
Other useful commands are:
print var - Prints a variableFor more complete tutorials on gdb see:
where - Prints the stack trace
quit - Exits gdb
GDB Tutorial
1
GDB
Tutorial 2
GDB
Tutorial 3
GDB Tutorial
4
makeTo run it type:
shellThen type commands like
ls -al ls -al aaa bbb > outCheck the output printed
cmd [arg]* [> filename]You will have to modify shell.y to implement a more complex grammar
cmd [arg]* [ | cmd [arg]* ]* [< filename] [ [> filename] [ >& filename] [>> filename] [>>& filename] ] [&]
ls ls -al ls -al aaa bbb cc ls -al aaa bbb cc > outfile ls | cat | grep ls | cat | grep > out < inp ls aaaa | grep cccc | grep jjjj ssss dfdffdf ls aaaa | grep cccc | grep jjjj ssss dfdffdf >& out < in httpd & ls aaaa | grep cccc | grep jjjj ssss dfdffdf >>& out < in
The deadline of this part of the project is March 18, 2003, before class. Follow these instructions to turnin your part one.1. Login to CSSUN.
2. cd to lab3-src and type "make clean"
3. Type "make" to make sure that your shell is build correctly.
4. Type "make clean" again.
5. cd one directory above lab3-src by typing "cd .."
6. Create a tar file named <user_name>.tar, where <user_name> is your CSSUN login, by typing
tar -cf <user_name>.tar lab3-src
7. Gzip the tar file by typing
gzip <user_name>.tar
8. Since this timestamp will be used to verify whether the work was completed on time or not, you should set the permissions on the file you submitted to make sure that the file timestamp is not changed. So this by typing:
chmod a-w <user_name>.tar.gz
9. Mail the gzipped tar file to clay at cs dot georgetown dot edu as an attachment.
Additional links to information about lex and yacc can be found here.