Red Hat Docs  >  Manuals  >  EDK Manuals  > 

Contents

Previous

Next


Working with Insight, the Debugger Interface

To work with Embedded DevKit's visual debugger, Insight, see the following documentation and Insight's Help menu for discussion of general functionality and use of menus, buttons or other features.

  1. From Source-Navigator, select Tools -> Debugger. The Program to debug window displays.

    Program to debug window

  2. Click OK. Insight launches, displaying the Source Window (Source Window). For a native project, click the Run button. For an embedded project, click Run and then click the Continue button. For more information on Insight, see its Help menu.

WARNING!

Having an inactive debugging session open when starting another debugging session with EDK will close all projects. All work will be unrecoverable.

Using the Source Window

When Insight first launches, it displays an empty Source Window (Source Window).

Source Window

The menu selections in the Source Window are File, Run, View, Control, Preferences and Help. See Source Window Menus and Display Features for more descriptions of the Source Window. To work with the other windows for debugging purposes specific to your project, use the View menu or the buttons in the toolbar and see the following documentation.

To open a specific file as a project for debugging, select File -> Open in the Source Window. The file's contents will then be passed to the GDB interpreter for execution. To start debugging, click the Run button (Run button) from the Source Window.

Run button

 

When the debugger runs, the button turns into the Stop button (Stop button). The Stop button interrupts the debugging process for a project, provided that the underlying hardware and protocols support such interruptions. Generally, machines that are connected to boards cannot interrupt programs on those boards, so the Stop button has no functionality (it will appear unavailable, or "grayed out"). For more information on the toolbar buttons, see Default style toolbar.

Stop button

 

WARNING!

When debugging a target, do not click on the Run button during an active debugging process, or it will de-activate the process. The Run button will become the Stop button and Insight will lose connection with the target.

To specify preferences of how source code appears and to change debugging settings, select Preferences -> Source from the Source Window. The Source Preferences dialog opens (Source Preferences dialog).

Source Preferences dialog

Left-click any of the colored squares to open the Choose color dialog, with which you modify the display colors of the Source Window.

Mouse Button-1 Behavior sets and clears either breakpoints or tracepoints (points in the source code, with an associated text string); the default is for setting breakpoints.

Variable Balloons lets you display a balloon of text whenever the cursor is over a variable in the Source Window; the balloon displays the value of the variable (see Breakpoint information balloon for an example). On is the default selection.

Selecting Tab Size sets the number of spaces for a tab character in the Source Window.

The Source Window has the following functionality and display features when using the Source Preferences dialog settings.

To set other preferences for a debugging session, select Preferences -> Global from the Source Window. The Global Preferences dialog opens (Global Preferences dialog) where you select a specific font and type size for the text in the windows for Insight.

Global Preferences dialog

 

Icons allows you to select the appearance of the toolbar buttons as the Windows-style Icon Set (the default; see Default style toolbar) or the Basic Icon Set (see Insight's Help menu for more information).

Fonts is for selecting font family and size.

Use builtin image as icon to change your host default settings for the Insight session icon on your desktop.

Use Netscape to View Help Files provides Netscape as your default browser for Insight's Help documentation.

Tracing features disabled disables setting tracepoints.

Default style toolbar

The following descriptions discuss the use of the default debugger toolbar buttons.

 

The Run button starts the debugging process for an executable file. I fthere is no executable open, the Load New Executable dialog displays to open an executable


 

During the debugging process, the Run button turns into the Stop button to interrupt the debugging. You cannot interrupt some targets; you will instead have to disconnect from the target.

 

The Step button steps to next executable line of source code. Also, the Step button steps into called functions.

 

The Next button steps to the next executable line of source code in the current file. Unlike the Step button, the Next button steps over called functions.

 

The Finish button finishes execution of a current frame. If clicked while in a function, it finishes the function and returns to the line that called the function.

 

The Continue button continues execution until a breakpoint, watchpoint or exception is encountered, or until execution completes.

 

The Registers button invokes the Registers window for viewing or changing register properties for a program's content.

 

The Memory button invokes the Memory window for displaying and editing the state of memory and addresses.

 

The Stack button invokes the Stack window for displaying and navigating the current call stack, where each line represents a stack frame.

 

The Watch Expressions button invokes the Watch Expressions window for entering expressions which will be updated every time that the executable stops.

 

The Local Variable button invokes the Local Variables window for displaying all local variables and their structure.

 

The Breakpoints button invokes the Breakpoints window for examining breakpoints and changing their settings.

 

The Console button invokes the Console window as a command line interface for debugging. The prompt is (gdb).

 

The left-hand read-only frame displays the program counter (pc) of the current frame.
The right-hand read-only frame displays the line number, which contains the program counter.

 

The Step assembler button steps through one assembler machine instruction. Also, the Step assembler button steps into subroutines.

 

The Next assembler button steps to the next assembler instruction. The Next assembler button then executes subroutines and steps to the next instruction.

 

The Down Stack Frame button moves down the stack frame one level.

 

The Up Stack Frame button moves up the stack frame one level.

 

The Go to Bottom of Stack Frame button moves to the bottom of the stack frame.

 

Using the Mouse in the Source Window

The mouse has many uses within the main display pane of the Source Window. Divided into two columns (Using the mouse in the Source Window), the window's left column extends from the left edge of the display pane to the last character of the line number, while the right column extends from the last character of the line number to the right edge of the display pane. Within each column, the mouse has different effects (see the following descriptions for Left column functionality for the Source Window and Right column functionality for the Source Window).

Using the mouse in the Source Window

Left column functionality for the Source Window

When the cursor is in the left column over an executable line, it appears as a minus sign. When a breakpoint is set at this point, the cursor changes into a circle. A left click sets a breakpoint at the current line; the breakpoint appears as a colored square in place of the minus sign. A left click on any existing or temporary breakpoint removes that breakpoint. A right click on any existing or temporary breakpoint brings up a pop-up menu (Pop-up menu for setting breakpoints).

Pop-up menu for setting breakpoints

 

Continue to Here causes the program to run up to a location, ignoring any breakpoints; like the temporary breakpoint, this menu selection displays as a differently shaded square than a regular breakpoint. When a breakpoint has been disabled, it turns, for instance, from red or orange to black (color settings vary depending on the preferences you set; see also Source Preferences dialog and its accompanying descriptions). Set Breakpoint sets a breakpoint on the current executable line; this has the same action as left clicking on the minus sign. Set Temporary Breakpoint sets a temporary breakpoint on a current executable line; a temporary breakpoint displays as a differently shaded square than a regular breakpoint, and is automatically removed when hit. Set Breakpoint on Thread(s) sets a thread-specific breakpoint at the current location.

Right-click on a line with a breakpoint to invoke a pop-up menu to delete breakpoints (Pop-up menu for deleting breakpoints).

Pop-up menu for deleting breakpoints

 

Delete Breakpoint deletes the breakpoint on the current executable line. This has the same action as left clicking on the colored square; see the description for Continue to Here for Pop-up menu for setting breakpoints. With the cursor over a line, a breakpoint opens a breakpoint information balloon; see Breakpoint information balloon for an example of such a tool tip.

Breakpoint information balloon

 

Right column functionality for the Source Window

The following documentation discusses the functionality of how the mouse works in the right column of the Source Window. With the cursor over a global or local variable, the value of that variable displays. With the cursor over a pointer to a structure or class, view the type of structure or class and the address of the structure or class. Double clicking an expression selects it. Right clicking an expression invokes a pop-up menu (Pop-up window for expressions).

Pop-up window for expressions

 

Add <selected expression>   to Watch opens the Watch Expressions window (<selected expression>   in the example was get_run_time) and adds a variable expression to the list of expressions in the window. Dump Memory at <selected expression>   opens the Memory window, which displays a memory dump at an expression. Open Another Source Window opens another Source Window for displaying a program in an alternate format (see Code display drop-down list box and its accompanying descriptions). Open Source in external editor opens the program in an alternate editor, such as the Source-Navigator Editor (see Using the Editor).

Source Window Menus and Display Features

The Source Window has the following menu items, many of which correspond to the toolbar buttons (see Default style toolbar).

Below the horizontal scroll bar of the Source Window

There are four display and selection fields below the horizontal scroll bar: the status text box (Status text box), the file drop-down combo box (File drop-down list box), the function drop-down combo box (Function drop-down combo box) and the code display drop-down list box (Code display drop-down list box). At the top of the horizontal scroll bar, text details the current status of the debugger; the status text box in Status text box shows "Program stopped at line 19" as the message.

The Function Browser window provides even more powerful tools for locating files and functions within your source code; for more information, see Using the Function Browser Window.

Status text box

The function drop-down list box (Function drop-down combo box) displays all the functions of a selected source (.c) or header (.h) file that an executable uses. Select a function by clicking in the list, or by typing directly into the text field for the function drop-down list box.

Function drop-down combo box

 

The file drop-down list box (File drop-down list box) displays the source (.c) and header (.h) files associated with an executable. Select files by clicking the arrow to the right of the drop-down list and then selecting one of the files in the list, or by typing the file's name directly into the list's text field.

File drop-down list box

Select how the code in the Source Window displays by using the code display drop-down list box (Code display drop-down list box).

Code display drop-down list box

The selections in the code display drop-down list box provide the following different ways to display code in the Source Window.

Type a character string into the search text box (Search text box).

Search text box

 

Press Enter to perform a forward search on the source file for the first instance of a specific character string. After having specified "main" in the search text box, the example program in Searching for a word in source code shows the jump to a main function.

Searching for a word in source code

 

Use the Shift and Enter keys simultaneously to search for the string. Use the Enter key or the Shift and Enter keys to repeat the search. Type "@" with a number in the search text box and press Enter to jump to a specific line number in the source code. The example program in Searching for a specific line in source code shows a jump to the line 86.

Searching for a specific line in source code

 

Using the Stack Window

Each time your program performs a function call, information about the call generates. That information includes the location of the call in your program, the arguments of the call, and the local variables of the function being called. The information is saved in a block of data called a stack frame. The stack frames are allocated in a region of memory called the call stack. When your program stops, you can examine the stack you to see this information.

A stack refers to the layers (TCP, IP, and sometimes others) through which all data passes at both client and server ends of a data exchange. The call stack is the data area or buffer used for storing requests that need to be handled, as in a list of tasks or, specifically, the contiguous parts of the data associated with one call to a specified function in a frame. The frame contains the arguments given to the function, the function's local variables, and the address at which the program is executing.

The Stack window displays the current state of the call stack (Stack window), where each line represents a stack frame; the line with the main.c executable had been selected for the example.

Stack window

Click a frame to select or highlight that frame. The Source Window automatically shows the source code that corresponds to the selected frame. If the frame points to an assembly instruction, the Source Window changes to assembly code; the corresponding source line's background in the Source Window also changes to the stack color.

Using the Registers Window

The Registers window (Registers window) dynamically displays registers and their contents.

Registers window

To change the properties of registers, use the following methods.

Using the Memory Window

The Memory window (Memory window) dynamically displays the state of memory. Double-click a memory location with the cursor in the window and edit its contents.

Memory window

Use Addresses -> Auto Update to update the contents of the Memory window automatically whenever the target's state changes; this is the default setting. Use Addresses -> Update Now to update the Memory window's view of the target's memory.

Memory Preferences dialog for the Memory window

Use Addresses -> Preferences to invoke the Memory Preferences dialog to set memory options.

Using the Watch Expressions Window

The Watch Expressions window displays the name and current value of user-specified expressions (Watch Expressions window).

Watch Expressions window

The Watch Expressions window has the following functionality.

Watch menu in the Watch Expressions window

Use Watch -> Edit to edit the value in an expression (an example of an expression capable of being edited is shown in Editing the value in an expression). Use the Esc key to abort editing.

Editing the value in an expression

Use Watch -> Format to invoke another pop-up menu for displaying a selected expression's value in Hex (Hexadecimal), Decimal, Binary, or Octal formats; by default, pointers display in hexadecimal with all other expressions as decimal. Use Watch -> Remove to remove a selected expression from the watch list.

Use the text edit field and the Add Watch button at the bottom of the window to add registers to the Watch Expression window or, by typing register convenience variables into the text edit field, add an expression to the watch list (see corearg added in Using the Add Watch button for the Watch Expressions window with its results in Results of using Add Watch button for the Watch Expressions window).

Using the Add Watch button for the Watch Expressions window

 

Every register has a corresponding convenience variable. The register convenience variables consist of a dollar sign followed by the register name; $pc is the program counter's convenience variable, for example, while $fp is the frame pointer's convenience variable.

Re-cast other types to which a pointer was cast by typing it in the text edit field. For example, typing (struct _foo *) bar in the text edit field, the bar pointer is cast as a struct _foo pointer.

Invalid expressions are ignored.

Results of using Add Watch button for the Watch Expressions window

Using the Local Variables Window

The Local Variables window displays the current value of all local variables.

Local Variables window

Use Variable -> Edit to change the value of a selected variable that you want edit. Using the Escape key (Esc) aborts editing. Use Variable -> Format to invoke another pop-up menu to display a selected variable's value in Hex (Hexadecimal), Decimal, Binary or Octal formats. By default, pointers display in hexadecimal and all other expressions as decimal. Single click the mouse with the cursor over a variable in the Local Variables window to select the variable (Selecting a variable).

Selecting a variable

Double click the mouse with the cursor in the Local Variables window to edit the variable (Editing local variables).

Editing local variables

Single click the mouse with the cursor on the plus sign to the left of a structure variable to see the elements of that structure (compare the variable structure for homebuf in Selecting a variable with the results in Displaying the elements of a variable structure). To close the structure elements, click the minus sign to the left of an open structure (compare the variable structure in Displaying the elements of a variable structure with what the window had displayed in Selecting a variable).

Displaying the elements of a variable structure

See also Setting Breakpoints and Viewing Local Variables and File after changing local variables values..

Using the Breakpoints Window

The Breakpoints window displays the currently set breakpoints. See Breakpoints window for the main.c example program breakpoints running in the Source Window, and see Results of setting breakpoints at line 105 for the results in the Source Window.

WARNING!

Breakpoints and exceptions may not work, especially if debugging C++ code, and the Breakpoints window may be inoperative.

Breakpoints window

Single click the mouse with the cursor over a check-box for a breakpoint to select that breakpoint (see the breakpoint results for line 105 in Selecting a breakpoint).

Selecting a breakpoint

Single click with the mouse with the cursor over a check-box of a breakpoint to disable the breakpoint. The color of the square in the Breakpoint window changes (Line 101 in Setting temporary breakpoints in the Breakpoints window) and the line's breakpoint status changes in the Source Window.

Setting temporary breakpoints in the Breakpoints window

Using the Breakpoint menu for the Breakpoints window, toggle the enabled or disabled state of a selected breakpoint. The single check mark between them shows the state of the selected breakpoint. Remove removes the selected breakpoint.

Using the Global menu for the Breakpoints window, Disable All disables all breakpoints, Enable All enables all breakpoints, and Remove All removes all breakpoints.

Single click an empty check box of a disabled breakpoint to re-enable a breakpoint (Results in Source Window having enabled a breakpoint). A check reappears and the color of the square in the Source Window changes (see line 105 in Results of setting breakpoints at line 105.).

Results in Source Window having enabled a breakpoint

Using the Breakpoint menu, toggle between the normal and temporary setting of a selected breakpoint. A normal breakpoint remains valid no matter how many times it is hit. A temporary breakpoint is removed automatically the first time it is hit. A single check mark for either setting shows the state of the selected breakpoint. When a breakpoint is set to temporary, the line in the Source Window no longer has a colored quare, as shown by comparing Results in Source Window having enabled a breakpoint with Results in Source Window having set a breakpoint as temporary, where the breakpoint for line 105 in the main.c example program changed.

Results in Source Window having set a breakpoint as temporary

See also Local Variables window after setting breakpoints.

Using the Console Window

To send commands directly to the GDB interpreter, use the Console window (Console window).

Console window

The Console window opens with a (gdb) prompt for invoking debugging commands. Console window shows the help command's available topics when using the Console window. For more specific commands, see Debugging with GDB in GNUPro Debugger Tools.

Using the Function Browser Window

To invoke the Function Browser window, select View -> Function Browser from the Source Window. The Function Browser window has several fields that provide search and browsing capability for source code debugging (Function Browser window). Descriptions follow of the Filter, Files, Functions and View Source fields.

Function Browser window

 

The Filter group at the top of the Function Browser window contains the Show if function drop-down list box and a text edit field. Show if function allows you to match the character string in the text edit field to its right by any of the four alternatives. Using the Show if function drop-down list box (Show if function drop-down list box), starts with shows functions that start with the character string in the text edit field entry, contains shows functions that contain the character string in the text edit field entry, ends with shows functions that end with the character string in the text edit field entry, matches regexp makes the search routines use regular expression matching (for example, searching for "^[ab].*" matches all functions starting with either a or b letters).

Show if function drop-down list box

 

The Files group limits the search to highlighted files. Clicking individual file names selects or deselects that file. The list of matching files refreshes when any search parameter changes. Hide .h files, if checked, disallows .h header files to display. Select All selects all listed files.

The Functions group matches all functions in the selected file(s). Breakpoints has two available buttons, Delete or Set; Delete removes a breakpoint previously set at the first executable line of the selected function, while Set sets a breakpoint at the first executable line of the selected function. Both of these will work on any and all selected functions in the listing. If all functions are selected, they all get or lose a breakpoint.

View Source/Hide Source allows you to toggle between displaying or hiding a file in a source browser (Function Browser window with source browser); the source browser has the same functionality as when using the Source Window.

Function Browser window with source browser

There are four display and selection fields below the horizontal scroll bar (the same functionality as using the Source Window): the status text box (Status text box), the function drop-down combo box (Function drop-down combo box) and the code display drop-down list box (Code display drop-down list box); see the figures and their accompanying explanations for specific information.

Using the Processes Window for Threads

The Processes window (Process window for displaying state of threads) dynamically displays the state of currently running threads.

WARNING!

Threads support is not available for all targets.

Processes window for displaying state of threads

The Processes window will display a list of threads and/or processes of an executable that you are debugging. The exact contents are specific to each operating system. The first column is the thread number, used internally by the debugger to track the thread. This number is also used by the command line interface (in the Console window) when referring to threads. The rest of the columns are dependent on information coming from the operating system.

The Source Window displays the current location and source for a current thread (or process). To change the current thread, click on the desired thread in the Threads window and the debugger will switch contexts, updating all windows. The current thread will highlight.

Having set a breakpoint on a line or function, stop execution and return control to the debugger for every thread that hits a set location. To set a breakpoint on a specific thread or threads, use the Source Window. See also Setting Breakpoints and Viewing Local Variables and Setting Breakpoints on Multiple Threads.

Using the Help Window

Invoke the window (Help window showing the help topic's index) using the Help menu from the Source Window to get HTML-based navigable help by topic.

Help window showing the help topic's index

The Help window has two menus: File and Topics.

Examples for Debugging with Insight

The following documentation contains an example debugging session procedures for using Insight. See also Debug an Executable Application on a Target Board.

Selecting and Examining a Source File

To select a source file, or to specify what to display when examining a source file when debugging, use the following process.

  1. Select a source file (main.c in the example in Source file selection) from the file drop-down list, at the bottom left of the Source Window.

    Source file selection

  2. Select a function from the function drop-down list to the right of the file drop-down list, or type its name in the text field above the list to locate a function (in Searching for a word in source code, see the executable line 86, where the main function displays).

  3. Type a character string into the search text box (Search text box).

    Search text box

  4. Press Enter to perform a forward search on the source file for the first instance of a specific character string. After having specified main in the search text box, the example program in Searching for a word in source code shows the jump to a main function.

    Searching for a word in source code

  5. Use the Shift and Enter keys simultaneously to search for the string. Use the Enter key or the Shift and Enter keys to repeat the search. Type "@" with a number in the search text box and press Enter to jump to a specific line number in the source code. The example program in Searching for a specific line in source code shows a jump to the line 86.

    Searching for a specific line in source code

Setting Breakpoints and Viewing Local Variables

A breakpoint can be set at any executable line in a source file. Executable lines are marked by a minus sign in the left margin of the Source Window. When the cursor is in the left column and it is over an executable line, it changes into a circle. When the cursor is in this state, a breakpoint can be set.

The following exercise steps you through setting four breakpoints in a function, as well as running the program and viewing the changing values in the local variables.

  1. With the Source Window active and the main.c source file open, the cursor was placed over the minus sign on line 6.
  2. When the minus sign changes into a circle, click the left mouse button; this sets the breakpoint, indicated by a colored square.
  3. Click on a breakpoint to remove the breakpoint.
  4. Repeat the process to set breakpoints at specific lines.
  5. Open the Breakpoints window (Breakpoints window).

    Breakpoints window

  6. Click the check box for a line to set a breakpoint in an executable. The box's color changes and the square's color of the line in the Source Window changes (Disabling a breakpoint in Breakpoints window). This color change indicates a disabling of the breakpoint.

    Disabling a breakpoint in Breakpoints window

    Re-enable the breakpoint at the line by clicking the check box in the Breakpoints window.

  7. Click the Run button on the tool bar to start the executable (see Run button). The program runs until it hits the first breakpoint. The color bar on the line changes color, indicating that the program is running (see settings in Breakpoints window changed in Disabling a breakpoint in Breakpoints window, and the Source Window in Results of setting breakpoints at line 105, after debugging stopped).

    Results of setting breakpoints at line 105

  8. Open the Local Variables window (Local Variables window), by clicking the Local Variables button in the tool bar. The window displays the initial values of the variables.

    Local Variables window

  9. Click the Continue button in the tool bar to move to the next breakpoint. The variables that have changed value turn color in the Local Variables window (see results in Local Variables window after setting breakpoints for line 105 in the main.c example).

    Local Variables window after setting breakpoints

  10. Click the Continue button two more times to step through the next two breakpoints and notice that the values of the local variables change (compare results from the main.c example program in Results of setting breakpoints at line 105 and results in File after changing local variables values). Repeat with the Continue button to step through breakpoints and notice their values change.

    File after changing local variables values

Setting Breakpoints on Multiple Threads

With Insight processing in a multi-thread environment, select threads and set breakpoints on one or more threads when debugging.

WARNING!

Multiple thread functionality does not work similarly on all embedded targets. When debugging C++ code, for instance, breakpoints and exceptions may not work on multiple threads.

A process can have multiple threads running concurrently, each performing a different task, such as waiting for events or something time-consuming that a program doesn't need to complete before resuming. When a thread finishes its job, the debugger suspends or destroys the thread running in the debugging process.

The thread debugging facility allows you to observe all threads while your program runs. However, whenever the debugging process is active, one thread in particular is always the focus of debugging. This thread is called the current thread.

The precise semantics of threads and the use of threads differs depending on operating systems.

In general, the threads of a single program are like multiple processes--except that they share one address space (that is, they can all examine and modify the same variables). Additionally, each thread has its own registers and execution stack, and perhaps private memory.

  1. In the Source Window, right click on an executable line without a breakpoint to open the breakpoint pop-up menu (see Breakpoint pop-up menu in the Source Window).
  2. Breakpoint pop-up menu in the Source Window

     

  3. Select the Set Breakpoint on Thread(s) menu item. The Processes window displays (Process window for threads).
  4. Processes window for threads

  5. By clicking on specific breakpoints, select one or more threads. A breakpoint sets in the Source Window at the executable line only for the selected threads. Having selected threads, the results display in the Processes window. With the cursor over a breakpoint at line 105 in the sample program in the Source Window, a breakpoint information balloon displayed to show where the selected thread begins (Breakpoint balloon with thread information in Source Window).
  6. Breakpoint balloon with thread information in Source Window


Contents

Previous

Next