Rtos for Embedded Applications Ppt

Embed Size (px)

Citation preview

  • 7/29/2019 Rtos for Embedded Applications Ppt

    1/25

    RTOS FOR EMBEDDED

    APPLICATIONS

  • 7/29/2019 Rtos for Embedded Applications Ppt

    2/25

    Example Program: shellsort

    gccgo shellsort shellsort.c

    -g requests that the compiler and linker generate and retainsymbol 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, anassembler file or preprocessed C code.

    If -o is not specified, the default is to put an executable filein a.out, the object file for source.suffix in source.o, itsassembler file in source.s, a precompiled header filein source.suffix.gch, and all preprocessed C source onstandard output.

  • 7/29/2019 Rtos for Embedded Applications Ppt

    3/25

    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

  • 7/29/2019 Rtos for Embedded Applications Ppt

    4/25

  • 7/29/2019 Rtos for Embedded Applications Ppt

    5/25

    Debugging a Sample Program

    Tool Bar: Contains buttons for commands thatrequire and argument along with a windowfor entering the argument

    Debugger Console: Lets you enter commandsdirectly to the inferior debugger's commandline. There are some operations that just workbetter at the command line

    Status Line: Shows the current state of DDDand GDB

  • 7/29/2019 Rtos for Embedded Applications Ppt

    6/25

    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.

  • 7/29/2019 Rtos for Embedded Applications Ppt

    7/25

  • 7/29/2019 Rtos for Embedded Applications Ppt

    8/25

    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" menuto save these changes.

  • 7/29/2019 Rtos for Embedded Applications Ppt

    9/25

  • 7/29/2019 Rtos for Embedded Applications Ppt

    10/25

    Debugging a Sample Program

    Setting up breakpoints

    The job of a debugger is to let us analyze aprogram'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.

  • 7/29/2019 Rtos for Embedded Applications Ppt

    11/25

    Debugging a Sample Program

    Notice that the debugger will top beforeexecuting 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 "SetBreakpoint" from the popup menu. This is calledsticky 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

  • 7/29/2019 Rtos for Embedded Applications Ppt

    12/25

  • 7/29/2019 Rtos for Embedded Applications Ppt

    13/25

    Debugging a Sample Program

    Debugging

    First, open an execution window by selectingthe "View->Execution Window" menu or bypressing ALT+F9. This window will show anymessage that your program writes to standardoutput.

    Then click on the "Run" button in the commandtoolbox on the right of the screen. As expected,

    execution stops at line 40, where we set thebreakpoint. This is indicated by the green arrownext to the stop signal

  • 7/29/2019 Rtos for Embedded Applications Ppt

    14/25

    Debugging a Sample Program

  • 7/29/2019 Rtos for Embedded Applications Ppt

    15/25

    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.

  • 7/29/2019 Rtos for Embedded Applications Ppt

    16/25

    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 Status-

    Registers menu. A window will pop upshowing the value of all of the program's

    registers. Notice that you can keep this

    window open as you continue your debugprocess later on.

  • 7/29/2019 Rtos for Embedded Applications Ppt

    17/25

  • 7/29/2019 Rtos for Embedded Applications Ppt

    18/25

    Debugging a Sample Program

    If instead of a register we are interested in examining aparticular memory location (such as msg), we can usethe "Data->Memory" menu. A window will pop upasking for the number of bytes to examine, and the

    start memory address. In the example below wechoose to examine 5 bytes starting from the addressof msg. Because msg contains a string of characters, wechoose char as the format to print these 5 bytes. Whenyou 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 indicatethe address of msg.

  • 7/29/2019 Rtos for Embedded Applications Ppt

    19/25

  • 7/29/2019 Rtos for Embedded Applications Ppt

    20/25

    Debugging a Sample Program

    It is often helpful, once reached a breakpoint, tocontinue execution of your program one instruction atthe time to observe how the status of the programchanges. The Next and Step commands in the toolbox

    serve at this purpose. Open the registers window asexplained earlier, and observe how the values of theregisters change as we step through the instructions ofthe program using Step.

    The difference between Next and Step is

    that Next treats function calls (such as "callmyFunction") as a whole instruction, while Step jumpsinto the code of the function.

  • 7/29/2019 Rtos for Embedded Applications Ppt

    21/25

    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.

  • 7/29/2019 Rtos for Embedded Applications Ppt

    22/25

    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 passedto it.

  • 7/29/2019 Rtos for Embedded Applications Ppt

    23/25

    Debugging a Sample Program

    Setting up for remote debugging

    Gdb server: gdbserver is a computer program thatmakes it possible to remotely debug otherprograms. Running on the same system as the programto be debugged, it allows the GNU Debugger toconnect from another system; that is, only theexecutable to be debugged needs to be resident on thetarget system, while the source code and a copy of the

    binary file to be debugged reside on the developerslocal computer. The connection can be either TCP or aserial line.

  • 7/29/2019 Rtos for Embedded Applications Ppt

    24/25

    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 theprograme and is waiting for debugging sessionto begin on the specified port.

  • 7/29/2019 Rtos for Embedded Applications Ppt

    25/25

    Debugging a Sample Program

    Debugging:

    Start up DDD and to connect gdb server typethe following in debugger console window

    target remote 192.168.0.200:1234 Output from gdb server indicates that target

    programe has started and the coresspondingmessage in gdb window.

    Use cont button insted ofrun in DDD.