Difference between revisions of "CSC231 Lab 2"
(New page: This lab will introduce you to the ddd debugger, and simple steps you can take to debug assembly programs. __TOC__ =The Target Program= Create a simple program that adds the contents of...) |
(→Configuration) |
||
Line 40: | Line 40: | ||
==Configuration== | ==Configuration== | ||
− | You need to do this step only once, the very first time you use the debugger. | + | '''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. | 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. | 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. | ||
+ | |||
[[Image:231_ddd_preferences.png]] | [[Image:231_ddd_preferences.png]] | ||
+ | |||
+ | Next, select "Edit->GDB Settings" from the main menu. In the window that pops up, scroll approximately half way down through the list of options, until you find the option "Disassembly flavor". Change its value to "Intel" (Figure 3.2) and click on CLOSE. | ||
+ | |||
+ | [[Image:231_ddd_preferences2.png]] |
Revision as of 10:19, 12 September 2008
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.
Next, select "Edit->GDB Settings" from the main menu. In the window that pops up, scroll approximately half way down through the list of options, until you find the option "Disassembly flavor". Change its value to "Intel" (Figure 3.2) and click on CLOSE.