04. Crosswind

advertisement

CrossWind

4.1 Overview

Starting A Debugging Session

Basic Debugging

System-Level Debugging

®

4-2

Overview

 Allows debugging at source and assembly levels.

 CrossWind executes on host; code executes on target.

Based on GNU debugger GDB:

– Debug engine customized for VxWorks multitasking and Tornado target server communication strategy.

– Graphical user interface added. Windows and Unix GUIs differ.

CrossWind uses the WTX protocol to communicate with the target server.

®

4-3

Customization

The Debugger is easy to customize:

– Extend or modify user interface

– Add new debugger commands

To customize the user interface: Use Tcl language.

– Put Tcl commands in crosswind.tcl

– Interpreted by GUI Tcl interpreter

To customize the debug engine:

– Put Tcl commands in gdb.tcl

– Interpreted by debug engine Tcl interpreter

– Put GDB commands in .gdbinit

WRS extensions provide access to the WTX protocol via

Tcl functions.

®

4-4

Task vs. System Level Debugging

Task level debugging:

– Can debug tasks only, not ISRs.

– By default, breakpoints affect only the attached task. Global task breakpoints may also be set.

– When the attached task is stopped, other tasks and ISRs in the system continue executing.

– Communication with WDB agent is interrupt driven.

System level debugging:

– Can debug tasks, ISRs, and pre-kernel execution.

– Default breakpoints stop the whole system. Task-specific breakpoints may be set.

– When system stopped, external WDB agent runs with interrupts locked out. During this time, communication with WDB agent is in polled mode.

®

4-5

CrossWind

Overview

4.2 Starting A Debugging Session

Basic Debugging

System-Level Debugging

®

4-6

Executing CrossWind

 Compile code with the -g option to generate debug symbols. Specifying -O0 is also recommended.

 Select a target server.

 To invoke the debugger:

– Use the launcher CrossWind button (UNIX)

– Use Tools => Debugger or button.

(Windows)

 To exit the debugger:

– Select File => Quit from the debugger menu.

(UNIX)

– Select Debug => Stop Debugging from the Tornado menu bar, or use button. (Windows)

®

4-7

Locating Code

 CrossWind needs to access both object and source code for modules to be debugged symbolically. Usually it can locate such modules automatically.

Modules may be downloaded to the target via

– Project Facility Download button or menu item.

– WindSh ld() command, CrossWind load command, or any other

Tornado tool which can load modules.

When GDB starts, it querries the target server for the file path to each object module loaded on the target.

– The object module contains symbolic debug information if compiled with -g.

– If debug information is found, CrossWind searches its source path for the corresponding source code.

®

4-8

Listing Source

 Displays the C or/and assembly source code centered at location.

Without argument, displays source:

(gdb) list

Used to get source into source display window. This happens automatically when GDB attaches to a task.

Examples, using argument:

(gdb) list foo.c:1 First few lines of foo.c

(gdb) list 25 Line 25 in foo.c

(gdb) list mySub Location can be a function.

®

4-9

Debugging a Task

Use CrossWind to create a new task tDbgTask that runs the function to debug:

– (gdb) run function arg1 arg2 ...

– Windows users may use Debug->Run or the button.

– You may set breakpoints before running the task.

To debug a task already running on the target, GDB must attach to the task.

– Targets->Attach Task... in CrossWind (UNIX)

– Debug->Attach... in Tornado (Windows)

– (gdb) attach taskId

– The task is suspended wherever it is executing. (Windows users may override this default.)

®

4-10

Debugging Multiple Tasks

 At task level, a CrossWind instance may be attached to a single task at a time. To debug multiple tasks, either detach from one and attach to another, use system level debugging, or start multiple debugger instances.

 To detach from a task, resuming it, use

– Targets->Detach Task/System (UNIX)

– Detach and Resume (Windows)

– detach from the GDB command line.

To detach from a task, leaving it in its current state, use

– Debug->Detach (Windows)

– detach auto from the GDB command line.

(GDB) sdetach detaches, leaving the task suspended.

®

4-11

Automatic Attachment (Windows)

 In Windows, CrossWind may be configured to automatically attach to a task which generates an exception or hits a breakpoint.

 Use Tools => Options => Debugger dialog.

Three choices:

– Never auto-attach.

– Auto-attach only if not already attached.

– Auto-attach even if already attached.

The last choice, always auto-attach, can lead to flurries of reattachments when several tasks hit a global breakpoint.

®

4-12

CrossWind

Overview

Starting A Debugging Session

4.3 Basic Debugging

System-Level Debugging

®

4-13

Debugging Tools

Examples of debugger functionality:

– Set/delete breakpoints.

– Step to next line of code.

– Step over a function call.

– Continue program execution.

– Finish current subroutine.

– Move up or down stack frames.

– Monitor variables or other expressions.

– De-reference pointers.

– Call up editor (UNIX).

For a complete list of debugger tools and GUI access methods, see the Tornado User’s Guide.

®

4-14

Make it Go! Make it Stop!

Windows Unix step next continue finish interrupt

®

4-15

A View of the Stack

Click on the desired frame to select it.

The selected frame is used in informational commands such

as info locals.

It also also affect the stopping

address of finish.

®

4-16

Breakpoints

Default breakpoints:

– Stop attached task, or whole system in system mode.

Global breakpoints:

– Stop any breakable task. Good for stopping tasks spawned by the task being debugged.

Hardware breakpoints on some architectures.

– Halts on instruction access or various sorts of data access to specified address. Limited in number.

– PPC 603, 603e, 604, 860, 403; Mips R4650; x86; i960 CA, JX, HX

Temporary breakpoints:

– Effective once, then deleted (default) or disabled.

®

4-17

Breakpoints, Continued.

Conditional breakpoints:

– Effective if specified expression is true, otherwise task hitting breakpoint is automatically resumed.

– (gdb) break snafu.c:228 if fbCount > 4

– Debug => Breakpoints => Advanced (Windows)

Listing breakpoints:

– GDB info breakpoints (i b) command.

– Debug->Breakpoints dialog.

(Windows)

®

4-18

Information

Displaying variables and expressions:

Watch windows - extendable, editable, dockable, hierarchical display.

(Windows)

Inspect windows - hierarchical display. Following pointers opens additional inspect windows.

(UNIX)

– (GDB) display /W expr

– (GDB) print expr

Other display windows:

– Backtrace, Registers

– Locals, Memory dump

(UNIX, Windows)

(Windows)

®

4-19

UNIX: The Graphical Interface

Menu Bar

Toolbar

Program

Display

Panel

Command

Panel

®

4-20

PC: The Graphical Interface

®

4-21

CrossWind

Overview

Starting A Debugging Session

Basic Debugging

4.4 System-Level Debugging

®

4-22

Overview

System-level debugging supports:

– Debugging ISRs.

– Debugging before the kernel is started.

– Multitask debugging.

In system mode, VxWorks and all application tasks and

ISRs stop when a breakpoint is hit.

 The external WDB agent runs with interrupts locked out when VxWorks is stopped.

 VxWorks configuration must include the WDB system debugging component.

®

4-23

Debugging In System Mode

 To enter system mode:

(gdb) attach system

Attaching to system.

0x407ae in wdbSuspendSystemHere ()

 To exit system mode:

(gdb) detach

 While in system mode, one can use normal debugger features:

– Step/continue

– Set breakpoints

– Display expressions

®

4-24

Selecting a Thread To Debug

 To display all threads (the GDB term for VxWorks contexts), use the info threads command:

(gdb) i th

5 task 0x3e8984 tExcTask 0x72e50 in qJobGet()

4 task 0x3e605c tLogTask 0x72e50 in qJobGet()

3 task 0x3b349c + tNetTask 0x38e44 in wdbSuspendSystemHere()

2 task 0x389de4 tPortmapd 0x3c36a in noSemQPutEvt()

1 task 0x3881c0 tWdbTask 0x3c36a in noSemQPutEvt()

 To select the current thread, for information display:

(gdb) thread 4

[Switching to task 0x3e605c tLogTask ]

#0 0x72e50 in qJobGet ()

®

4-25

Examining a Thread

 Use normal debugger tools to examine a thread.

To set a thread-specific breakpoint:

(gdb) break location thread threadNumber

– If the breakpoint is hit by a different thread, the system is resumed automatically.

Resume execution of the system with Step, Next, Finish, or Continue from the debugger menu.

– When you continue the system, VxWorks controls scheduling.

– You may not be in the same task after a step, next, or finish command completes. Such commands may involve setting a breakpoint and resuming the system.

®

4-26

Caveats

 Cannot create a new task with run.

 Can only step or continue from where system is stopped.

 Cannot use multiple debuggers per target.

®

4-27

Summary

Tornado supports a source-code debugger which:

– Executes on host while code executes on target

– Provides source-level debugging

Code must be compiled with -g option. For easiest debugging, also specify -O0 (or no -O flags).

 System-level debugging:

– Is useful for debugging ISRs and BSPs.

– Is useful for multitask debugging.

– VxWorks and application freeze when breakpoint is hit.

– WDB agent uses polled-mode communication when system suspended, as interrupts are locked out.

®

4-28

Download