02.03.2014 Views

Tornado

Tornado

Tornado

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

7<br />

Debugger<br />

Internally, the debugger still gets control every time any thread encounters the<br />

breakpoint; but if the thread ID is not the one you specified with the break<br />

command, the debugger silently continues program execution without prompting<br />

you.<br />

! CAUTION: Because the thread ID for the system context is not constant, it is not<br />

possible to set a breakpoint specific to system context. The only way to stop when<br />

a breakpoint is encountered in system context is to use a non-task-specific<br />

breakpoint.<br />

7<br />

Switching Threads Implicitly<br />

Your program may not always suspend in the thread you expect. If any breakpoint<br />

or other event (such as an exception) occurs while in system mode, in any thread,<br />

the debugger gets control. Whenever the target system is stopped, the debugger<br />

switches to the thread that was executing. If the new current thread is different<br />

from the previous value, a message beginning “Switching to” shows what thread<br />

suspended:<br />

(gdb) thread 2<br />

(gdb) cont<br />

Continuing.<br />

Interrupt...<br />

Program received signal SIGINT, Interrupt.<br />

[Switching to system +]<br />

0x5b58 in wdbSuspendSystemHere ()<br />

Whenever the debugger does not have control, you can interrupt the target system<br />

by clicking on the interrupt button or by keying the interrupt character (usually<br />

CTRL+C). This usually suspends the target in the system thread rather than in any<br />

task.<br />

When you step program execution (with any of the commands step, stepi, next,or<br />

nexti, or the equivalent buttons or ), the target resumes execution where it<br />

left off, in the thread marked with + in the info threads display. However, in the<br />

course of stepping that thread, other threads may begin executing. Hence, the<br />

debugger may stop in another thread before the stepping command completes,<br />

due to an event in that other thread.<br />

265

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!