• Keine Ergebnisse gefunden

Debugging multithreaded programs

Im Dokument . Turbo Debugger " (Seite 157-160)

Figure 10.4 The Threads window

The Threads Information pane

The Threads window (opened with the View I Threads command) supports the multithreaded environment of Windows NT.

Threads Detail pane Threads List pane

Threads Information pane

The Threads Information pane, which lists general thread information, consists of these fields:

The Last field lists the last thread that was executing before Turbo Debugger regained control.

The Current field shows the thread whose values are displayed in Turbo.

Debugger's windows. You can change the thread you're debugging via the Make Current SpeedMenu command.

The Total field indicates the total number of active program threads.

The Notify field displays either Yes or No, the Notify on Termination status of all threads. Although you can set the Notify on Termination status for

The Threads List pane

Threads List panes SpeedMenu

Options

Figure 10.5 The Thread Options dialog box

individual threads, the overall status is set through the All Threads

SpeedMenu command. Newly created threads are also assigned this status.

The Threads List pane lists all your program's active threads. Threads are identified by a thread number (assigned by Windows NT) and a thread name. Turbo Debugger generates a thread name when your program creates a thread. The first thread created is named Thread 1, followed by Thread 2, and so on. You can modify a thread's name using the Option command on the List pane's SpeedMenu.

The Threads window contains a single SpeedMenu (which you activate through the Threads List pane) which contains the Options, Make Current, and All Threads commands.

The Options SpeedMenu command opens the Thread Options dialog box.

This dialog box lets you set options for individual program threads.

The Freeze check box lets you freeze and thaw individual threads. When you freeze a thread by checking this box, the thread will not run. To thaw the thread (which enables it to run), clear the check box. For your program to run, there must be at least one thread that isn't frozen.

- . If you freeze the only thread in your program that processes window messages, your program and the debugger will hang when you run the program.

The Notify on Termination check box lets you specify whether Turbo . Debugger should notify you when the currently highlighted thread

terminates. When this box is checked, Turbo Debugger generates a message when the thread terminates, and activates a Module or CPU window that displays the current program location. If you clear the Notify on

Termination check box, Turbo Debugger doesn't pause when the thread terminates. To set the Notify on Termination status for all threads, use the All Threads SpeedMenu command.

Chapter 10, Windows debugging features 149

Make current

Inspect

AI/threads

Step

The Thread Name input box lets you modify the thread name that's generated by Turbo Debugger. If your program generates many threads, it can be easier to keep track of them if you specify your own thread names.

The Make Current command lets you change the thread currently being processed by Turbo Debugger. To change the current thread, highlight the thread that you want to examine in the Threads List pane, and press Ctrl+M (or choose the Make Current command). When you do so, the Thread Information pane displays the thread number whose data values are displayed in ,Turbo Debugger's windows, and all references tothe CPU registers and stack data will now relate to this thread.

The Inspect command opens a Module or CPU window that shows the current point of execution for the highlighted thread. Pressing Enterhas the same effect as choosing Inspect from the SpeedMenu:

The All Threads command opens a menu whose commands relate to all program threads. '

The Thaw command unfreezes any currently frozen threads. When you issue this command, all threads in your program are able to run.

The Freeze command disables all thread execution. When you issue this command, all threads in your program will be frozen and unable to run.

For your program to run, you must thaw at least one thread using the Options SpeedMenu command (or use the Thaw command on the All Threads menu to unfreeze all the threads).

The Enable Exit Notification command sets the notify-on-exit status for all program threads, including threads that have yet to be created. Choosing this command causes Turbo Debugger to issue a message when any thread terminates. The status of notify-on-exit is displayed in the Notify 'field of the Threads Information pane.

The Disable Exit Notification command turns off the notify-on-exit status. This is Turbo Debugger's default setting.

The Step command toggles between All and Single:

When set to All (the default), all the threads in your program can run as , you step through your program using F7 or FB. If you're debugging a '

thread with a low priority, other threads might execute several statements before the thread you're debugging executes a single statement. (This can sometimes make it difficult to watch the behavior of a single thread in your

The Threads Detail pane

When the Step command is set to Single, only the thread located at the current instruction pointer will run as you step. This is different from freezing threads because different threads can be created and destroyed, and you can step into these threads as your program's execution dictates.

The Thread Detail pane, shown in Figure 10.4, displays the details of the thread that's highlighted in the Threads List pane.

The first line of the Thread Detail pane displays the status of the

highlighted thread (either suspended or runnable) and the thread's priority.

The priority, which is set by the operating system, can be one of five different states:

...:..2 (lowest) -1 (below normal)

o

(normal)

1 (above normal) 2 (highest)

. The second line of the Thread Detail pane displays the current execution point of the thread that's highlighted in the Threads List pane.

The third line, if present, indicates how Turbo Debugger gained control from the running thread. A complete list of the messages that Turbo Debugger can generate for this line is given in the "Status messages"

section on page ~98.

The fourth line of the Thread Detail pane, if present, lists the thread's settings. Possible settings are Frozen and Notify on Termination.

Im Dokument . Turbo Debugger " (Seite 157-160)