Generating a Non-Maskable Interrupt (NMI)

Q: I need to do remote debugging on a Mac computer which is hung in the kernel. How do I interrupt this system so I can attach to it from a remote GDB kernel debugging session?

A: If Mac OS X is started with the DB_NMI bit set in the debug boot argument, momentarily pressing the system's power button will generate a non-maskable interrupt instead of sleeping or waking the system.

Note: On PowerPC-based portable computers such as the iBook or PowerBook, if the DB_NMI bit is set, hold down the command key while pressing the power button to generate an NMI. On these systems, pressing the power button alone brings up the "Are you sure you want to shut down your computer now?" dialog.

IMPORTANT: On Intel-based Macs, the interrupt that is generated by the power button technically is not an NMI but an ACPI System Control Interrupt (SCI). Practically speaking, this means that the power button will not interrupt an Intel-based system while interrupts are disabled.

Should you find yourself in this situation, you can still potentially read useful information from the hung system using FireWire GDB as documented in the FireWire SDK.

The system reads the debug flags at boot time from the boot-args firmware variable.

To set the DB_NMI bit, start by entering this command in Terminal:

$ nvram boot-args

This will display the current setting of the boot arguments. Now, add debug=0x4 to the current settings with this command:

$ sudo nvram boot-args="<current settings> debug=0x4"

You must restart the computer for the new settings to take effect.

For other useful debug flags, please see Table 19-1 'Debugging flags' of Kernel Programming Guide: When Things Go Wrong: Debugging the Kernel.

IMPORTANT: If the power button is pressed for more than five seconds, the system will immediately power off.

The power button will retain this functionality until Mac OS X is restarted without the DB_NMI bit set. You can clear this bit by issuing the nvram command with the -d option:

$ sudo nvram -d boot-args

Note: Prior to Mac OS X 10.5, the DB_NMI bit will be cleared if you use System Preferences to change the startup disk. It may also be cleared if you perform an installation that requires a restart.

Document Revision History

Date Notes
2008-10-13 Modernized and made editorial revisions. Added details related to Intel-based Macs.
2004-04-26 Unspecified content revisions.
2003-04-23 Explains how to generate a non-maskable interrupt (NMI) on modern Macintosh systems.

Posted: 2008-10-13


Did this document help you?
Yes: Tell us what works for you.
It’s good, but: Report typos, inaccuracies, and so forth.
It wasn’t helpful: Tell us what would have helped.