Tutorial #3: Debugging
First of all, make sure that the GNU tools has been installed on your machine, including gcc, gdb, and objdump. If them have not been installed, you could use apt-get command with the install option and package name build-essential and gdb to install them.
$ apt-get install build-essential
...
$ apt-get install gdb
To learn more about them, you can read the manual by typing man command, like man objdump.
We provide the tut1 to help you to be familiar with the operations, which you need to use in the following labs.
Now you need to exit the root user and change to your top-level svn directory which should include your lab0 and lab1 (If you have not checkout your svn directory, please do it according to the SVN introduction in Tutorial-2). You could use the svn command with the update option under the svn top-level directory to get tut1 folder.
$ svn update
A tut1
A tut1/bomb
A tut1/test.c
A tut1/test.h
Updated to revision 317.
Change your current directory to tut1 directory, and use the ls to show the content within it. The output should include three files, test.c, test.h and bomb.
$ cd tut1
$ ls
bomb test.c test.h
The first task is to build test executable file from test.c and test.h. You could use the gcc command with the -Wall and -o option to compiling. (There are lots of bugs in test.h and test.c)
$ gcc -Wall -o test test.c
In file included from test.c:1:
test.h:5: error: expected ':', ',', ';', '}' or '__attribute__' before 'int'
...
After you fix all compiling problems, you should further try to make the output of test look like the following.
$ ./test
main: 1 10 0
main: 2 11 1
test: 12 (nil)
test: 0
After you finish the task, you need to submit your updated files to svn server using the svn command with the commit(ci) option and the file name. You also could add some comments to this commit operation using --message="blablabla". Note: you don't need to subimit the executable file test
$ svn ci test.c test.h --message="finish test program."
Sending test.c
Sending test.h
Transmitting file data .
Committed revision 318.
The second task is to defuse the binary bomb. The bomb is very similiar to the example in tutorial today. You need to find the rigth password using objdump, gdb and anything else.
$ ./bomb
input password: (enter your password)
survive!
$
After you find the right password, you need to create a new file named "password.txt" to save your password. The password file should be submitted to svn server. You should add the new file to svn server using the svn command with the add option and the file name, and commit it like previous operations.
$ vim password.txt
...
(add your password)
$ svn add password.txt
A password.txt
$ svn ci password.txt --message="find the password here."
Adding password.txt
Transmitting file data ...
Committed revision 319.
Congratulations!
|
Go to Top // ICS Home Page Questions or comments regarding ICS course? Send e-mail to the course Staffs or TAs. Last updated: Wed Mar. 10 2012 Acknowledges the MIT 6.033 course (Computer System Engineering) |