1

I'm reading the Linux kernel code. Some functions are called by function pointer. I want to know the call sequence of all these functions, so I've tried to print the function. But I haven't figured out how to make it.

Here is my code:

for (fn = initcall_levels[level]; fn < initcall_levels[level+1]; fn++) {
    //printk("xhl -- %pF \n", fn);
    do_one_initcall(*fn);
}

1 Answer 1

3

Kernel's printk() supports special %p format specifiers:

Symbols/Function Pointers

    %pF     versatile_init+0x0/0x110
    %pf     versatile_init
    %pS     versatile_init+0x0/0x110
    %pSR    versatile_init+0x9/0x110
            (with __builtin_extract_return_addr() translation)
    %ps     versatile_init
    %pB     prev_fn_of_versatile_init+0x88/0x88

See https://www.kernel.org/doc/Documentation/printk-formats.txt for full list.

For your example, setting the initcall_debug=1 kernel cmdline option might be a better way, than adding printk() manually.

Sign up to request clarification or add additional context in comments.

1 Comment

@teddyxiong53: If the answer works for you, consider to accept it.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.