CSC231 Lab 2
This lab will introduce you to the ddd debugger, and simple steps you can take to debug assembly programs.
The Target Program
Create a simple program that adds the contents of two variables and stores the result in a third one.
The data section should be something like this:
a dd 3 b dd 5 result dd 0
The code section, something like this:
nop nop mov eax, dword[a] add eax, dword[b] mov dword[result], eax
Save your program as simpleAdd.asm, and generate the executable as follows:
nasm -f elf -F stabs simpleAdd.asm ld -o simpleAdd simpleAdd.o
Test
Run your program. What happens?
The Debugger
Start the Debugger
Start the debugger and instruct it to open the program simpleAdd
ddd simpleAdd &
Configuration
You need to do this step only once, the very first time you use the debugger.
Before we can start using DDD, we need to change some of its default settings.
Select "Edit->Preferences" from the main menu. On the window that will appear, open the "Source" tab (top of the window). Then, check the "Display Source Line Numbers" option. Click OK to close the window.