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 Wednesday, April 3rd, at 11:59 P.M. Follow these instructions to turnin your part one.Here are the man pages for Lex and Yacc .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
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.
ls -al ls -al /etc &
ls -al > out cat out ls /tttt >& err cat err cat < out cat < out > out2 cat out2
ls /tt >>& out2
">& file" redirects both stdout and stderr to file. ">>& file" append both stdout and stderr to file.
">> file" appends stdout to file.
ls -al | grep command ls -al | grep command | grep command.o ls -al | grep command ls -al | grep command | grep command.o > out cat outThe deadline of this part of the project is Thursday April 18, 2002 at 11:59pm.
Follow these instructions to turnin your part two.
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
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.
Your grade for this project will depend on the number of tests that pass. The tests given are for part 2 and 3 of the project. Tests used for grading: test-shell-grading/ and test-shell-grading.tar.Z
See the file lab3-src/README for an explanation on how to run the tests. The tests will also give you an estimated grade. This grade is just an approximation. Other tests not given to you will be used as well during grading.
myshell> exit Good bye!! csh>
char **environ;Check the man pages of environ.
echo * // Prints all the files in the current directory echo *.cc // Prints all the files in the current // director that end with cc echo c*.cc echo M*f* echo /tmp/* // Prints all the files in the tmp directory echo /*t*/* echo /dev/*You can try this wildcards in csh to see the results. The way you will implement wild carding is the following. First do the wild carding only in the current directory. Before you insert a new argument in the current simple command, check if the argument has wild card (* or ?). If it does, then insert the file names that match the wildcard including their absolute paths. Use opendir and readdir to get all the entries of the current directory (check the man pages). Use the functions compile and advance to find the entries that match the wildcard. Check the example file provided in regular.cc to see how to do this. Notice that the wildcards and the regular expressions used in the library are different and you will have to convert from the wildcard to the regular expression. The "*" wildcard matches 0 or more non-blank characters, except "." if it is the first character in the file name. The "?" wildcar matches one non-blank character, except "." if it is the first character in the file name. Once that wildcarding works for the current directory, make it work for absolute paths.
ls & ls & ls & ls & /bin/ps -u <your-login> | grep defunctThe zombie processes appear as "defunct" in the output of the "ps -u <your-login>" command.
To cleanup these processes you will have to setup a signal handler,
like the one you used for ctrl-c, to catch the SIGCHLD signals that are
sent to the parent when a child process exits. The signal handler will
then call wait3() to cleanup the zombie child. Check the man pages
for
wait3 and sigset. The shell should print the process
ID of the child when a process in the background exits in the form "[PID]
exited."
ls "command.cc Makefile" command.cc Makefile not found "command.cc Makefile" is only one argument.Remove the quotes before inserting argument. No wild-card expansion is expected inside quotes.
setenv A hello
setenv B world
echo ${A} {$B}
Hello World
setenv C ap
setenv D le
echo I like ${C}p${D}
I like apple
Add a README file to the lab3-src/ directory with the following:
Follow these instructions to turnin your project1. 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
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.