270 likes | 408 Views
CrossWind. 4.1 Overview Starting A Debugging Session Basic Debugging System-Level Debugging. Overview. Allows debugging at source and assembly levels. CrossWind executes on host; code executes on target. Based on GNU debugger GDB:
E N D
CrossWind 4.1 Overview Starting A Debugging Session Basic Debugging System-Level Debugging
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.
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.
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.
CrossWind Overview 4.2 Starting A Debugging Session Basic Debugging System-Level Debugging
Executing CrossWind • Compile code with the-goption to generate debug symbols. Specifying-O0is 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)
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.
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.
Debugging a Task • Use CrossWind to create a new task tDbgTask that runs the function to debug: • (gdb) runfunction 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)attachtaskId • The task is suspended wherever it is executing. (Windows users may override this default.)
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) • detachfrom 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.
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.
CrossWind Overview Starting A Debugging Session 4.3 Basic Debugging System-Level Debugging
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.
Make it Go! Make it Stop! Windows Unix step next continue finish interrupt
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.
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.
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)
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 /Wexpr • (GDB) printexpr • Other display windows: • Backtrace, Registers (UNIX, Windows) • Locals, Memory dump (Windows)
UNIX: The Graphical Interface Menu Bar Toolbar Program Display Panel Command Panel
CrossWind Overview Starting A Debugging Session Basic Debugging 4.4 System-Level Debugging
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.
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
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 ()
Examining a Thread • Use normal debugger tools to examine a thread. • To set a thread-specific breakpoint: (gdb) breaklocationthreadthreadNumber • 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.
Caveats • Cannot create a new task with run. • Can only step or continue from where system is stopped. • Cannot use multiple debuggers per target.
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.