Perl: what does checkstack.pl in linux source do?

后端 未结 2 1800
礼貌的吻别
礼貌的吻别 2021-01-12 02:36

I am doing a project in linux kernel and I wanted to know what does this checkstack.pl do? I have never studied perl so cant understand the program. It will be great if I co

2条回答
  •  不知归路
    2021-01-12 03:08

    As already explained above that Perl script is used to find out the stack usage of kernel code, I think that Perl is used due to the fact that parsing the output of objdump -d won't be so easy if done through C code.

    You can find the stack usage at the runtime by taking the address of the first argument and the address of last local variable, then subtract them, something like:

    int stack_usage_func(char i)
    {
        int j,k,l;
    
        char buf[256];
        char m;
        unsigned long stack_use = &i - &m;
        //do all processing
        return stack_use
    }
    

    The return of the function should give you the runtime stack usage, I have not compiled the code, so please ignore if it gives compilation errors, but the logic should work.

提交回复
热议问题