Linux kernel-state debug function bug_on () [Go]

Source: Internet
Author: User

Some kernel calls can be used to easily mark Bugs, provide assertions, and output information. The two most common are bug () and bug_on ().

When called, they trigger oops, which causes the stack's backtracking and error messages to be printed. Why these claims lead to oops and hardware architectures

is relevant. Most architectures define bugs () and bug_on () as some kind of illegal operation, which naturally generates the Oops needed. You can use these calls as assertions, and you want to assert that a situation should not occur:

if (bad_thing)
BUG (); requires Linux kernel to open general Setup->configure standard kernel features->bug () support

Or use a better form:

BUG_ON (bad_thing);

A more serious error can be raised with panic (). calling Panic () will not only print error messages (Oops) but will also suspend the entire system . Obviously, you should only use it in extremely bad situations:

if (terrible_thing)
Panic ("Foo is%ld\n", foo);

Sometimes you just need to print a stack of backtracking information on the terminal to help you test. You can use Dump_stack () at this time. It only prints trace clues for the register context and function on the terminal:

if (!debug_check) {
PRINTK (kern_debug "provide some information...\n");
Dump_stack ();
}

Linux kernel-state debug function bug_on () [Go]

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.