0% found this document useful (0 votes)
158 views25 pages

Rtos For Embedded Applications

This document provides instructions for debugging sample programs using the Data Display Debugger (DDD). It discusses setting breakpoints, examining program state by viewing registers and memory, stepping through code, and setting up remote debugging using gdbserver. Configuring DDD preferences like source line numbers and assembly flavor is also covered. The goal of debugging is to analyze a program's state at specific points by suspending execution at breakpoints.
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
158 views25 pages

Rtos For Embedded Applications

This document provides instructions for debugging sample programs using the Data Display Debugger (DDD). It discusses setting breakpoints, examining program state by viewing registers and memory, stepping through code, and setting up remote debugging using gdbserver. Configuring DDD preferences like source line numbers and assembly flavor is also covered. The goal of debugging is to analyze a program's state at specific points by suspending execution at breakpoints.
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 25

RTOS FOR EMBEDDED APPLICATIONS

Example Program: shellsort gcc g o shellsort shellsort.c -g requests that the compiler and linker generate and retain symbol information in the executable itself. Place output in file shellsort.c. This applies to whatever sort of output is being produced, whether it be an executable file, an object file, an assembler file or preprocessed C code. If -o is not specified, the default is to put an executable file in a.out, the object file for source.suffix in source.o, its assembler file in source.s, a precompiled header file in source.suffix.gch, and all preprocessed C source on standard output.

Debugging a Sample Program


./shellsort 4 6 3 1 7 8 ./shellsort 4000 6000 3000 1000 7000 8000 Debugging using DDD (Data Display Debugger) ddd shellsort Sourse Window: Display the source code around the current execution point Command Tool: Buttons for commonly used commands

Debugging a Sample Program


Tool Bar: Contains buttons for commands that require and argument along with a window for entering the argument Debugger Console: Lets you enter commands directly to the inferior debugger's command line. There are some operations that just work better at the command line Status Line: Shows the current state of DDD and GDB

Debugging a Sample Program


select "View->Machine Code Window" to see the assembly instructions (If required). Configuring the debugger 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 umbers"option. Click OK to close the window.

Debugging a Sample Program


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 and click on CLOSE. Finally, click on the "Edit->Save Options" menu to save these changes.

Debugging a Sample Program


Setting up breakpoints The job of a debugger is to let us analyze a program's state at a certain point during its execution. The state of a program is given by the program's registers (EAX, EBX, etc), its stack and memory images. A breakpoint identifies an instruction at which execution of the program will be suspended.

Debugging a Sample Program


Notice that the debugger will top before executing the breakpoint instruction. To set a breakpoint in DDD, right-click on the instruction where you want to set the breakpoint, in the source window. Then, select "Set Breakpoint" from the popup menu. This is called sticky break point because it stays there until specifically we remove it. The breakpoint will appear as a "stop" sign on the left of the instruction

Debugging a Sample Program


Debugging First, open an execution window by selecting the "View->Execution Window" menu or by pressing ALT+F9. This window will show any message that your program writes to standard output. Then click on the "Run" button in the command toolbox on the right of the screen. As expected, execution stops at line 40, where we set the breakpoint. This is indicated by the green arrow next to the stop signal

Debugging a Sample Program

Debugging a Sample Program


To see the current value of a variable, place cursor over green arrow. Yellow box appears with current value. To execute the current line, click on the 'NEXT' button on the command tool. The arrow advances to the following line. We can also set temporary break point, and it goes away when the first time it is hit.

Debugging a Sample Program


At this point we can examine the state of the program by first looking into its registers. This is done by selecting the StatusRegisters menu. A window will pop up showing the value of all of the program's registers. Notice that you can keep this window open as you continue your debug process later on.

Debugging a Sample Program


If instead of a register we are interested in examining a particular memory location (such as msg), we can use the "Data->Memory" menu. A window will pop up asking for the number of bytes to examine, and the start memory address. In the example below we choose to examine 5 bytes starting from the address of msg. Because msg contains a string of characters, we choose char as the format to print these 5 bytes. When you click on "Display", a new frame inside the DDD window will appear, showing the contents of memory. Notice that in below Figure we used &msg to indicate the address of msg.

Debugging a Sample Program


It is often helpful, once reached a breakpoint, to continue execution of your program one instruction at the time to observe how the status of the program changes. The Next and Step commands in the toolbox serve at this purpose. Open the registers window as explained earlier, and observe how the values of the registers change as we step through the instructions of the program using Step. The difference between Next and Step is that Next treats function calls (such as "call myFunction") as a whole instruction, while Step jumps into the code of the function.

Debugging a Sample Program


To view the values of array say a, we can enter following into argument window a[0]@(argc-1) and click the print button. The values appear in the debugger console. Display option will display the variable with name. Rotate option can rotate the results to required direction.

Debugging a Sample Program


Stack frame display: Clicking on step to step in a function, the execution pointer in function will move to the first line of function and debugger console shows the argument passed to it.

Debugging a Sample Program


Setting up for remote debugging Gdb server: gdbserver is a computer program that makes it possible to remotely debug other programs. Running on the same system as the program to be debugged, it allows the GNU Debugger to connect from another system; that is, only the executable to be debugged needs to be resident on the target system, while the source code and a copy of the binary file to be debugged reside on the developers local computer. The connection can be either TCP or a serial line.

Debugging a Sample Program


Connecting to gdb server: change to ddd folder; cd /usr/ddd Starting gdb server: gdbserver :1234 shellsort 4000 7000 2000 900 Gdb server responds with: process shellsort created; pid = 23 This indicates gdbserver has loaded the programe and is waiting for debugging session to begin on the specified port.

Debugging a Sample Program


Debugging:

Start up DDD and to connect gdb server type the following in debugger console window target remote 192.168.0.200:1234
Output from gdb server indicates that target programe has started and the coressponding message in gdb window. Use cont button insted of run in DDD.

You might also like