简体   繁体   English

如何使用pid和不使用pid在linux中打印内核堆栈的低位和高位地址以进行处理

[英]How to print kernel stack's lower and upper address in linux for process using pid and without using pid

How to print kernel stack's lower and upper address in linux for each process process 如何在Linux中为每个进程打印内核堆栈的上下地址

  1. using pid and 使用pid和
  2. without using pid 不使用pid

You may want to understand into the current_stack_pointer() code. 您可能想了解current_stack_pointer()代码。 (for the slightly older kernels, now the stack size has been increased to 16K) (对于稍旧的内核,现在堆栈大小已增加到16K)

The kernel stack starts on top of the page and increases downwards, %esp on x86 points (or %rsp on x86_64) to the bottom of stack. 内核堆栈从页面顶部开始,然后向下增加,在x86点上为%esp (在x86_64上为%rsp)到堆栈底部。 You can also derive the current macro as follows 您还可以按以下方式派生当前宏

current macro == current_thread_info(%esp)->task
current->pid == (current_thread_info(%esp)->task)->pid

As you know the bottom of the stack, you need to add/subtract the number of pages to get the top of the kernel stack (using %esp or %rsp depends on your arch). 如您所知栈的底部,您需要添加/减去页数才能获得内核栈的顶部(使用%esp或%rsp取决于您的体系结构)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM