Книга: Embedded Linux development using Eclipse

5.3.1 The Signals View

5.3.1 The Signals View

The suspend functionality raises the interesting question of how gdb handles signals in general. Normally, the SIGINT signal is generated by typing Ctrl-C, which causes the receiving process to be terminated if it doesn’t handle the signal itself.

The thermostat program registers a signal handler for SIGINT to terminate the program gracefully. Among other things, in a multi-threaded environment, it’s important that threads terminate in the correct order. That’s what the function terminateThread() does.

But by default gdb intercepts the signal and uses it to suspend the program. Click Window?Show View?Signals. This displays the Signals view in the upper right tabbed window (Figure 5.7). This shows you the signals defined on the selected target and how the debugger handles each one.


Figure 5.7: Signals view.

SIGINT is currently configured to suspend the program, which is the behavior we just saw, and not to pass the signal on to the program. Right-click the SIGINT entry and select Signal Properties. This brings up a dialog with two check boxes:

• Pass this signal to the program.

• Suspend the program when this signal happens.

If both boxes are checked, the program is suspended before the signal is passed to the program. Resuming the program then allows the signal handler to be executed. With the Pass box checked and the Suspend box unchecked, the signal handler is executed first, and then oddly enough, the debugger catches the signal later. Try it with thermostat and you’ll see that Thread [1] is suspended in the pthread_cancel() call inside terminateThread().

Оглавление книги

Оглавление статьи/книги

Генерация: 1.216. Запросов К БД/Cache: 3 / 1
поделиться
Вверх Вниз