提交 1e043e92 创建 作者: Austin Clements's avatar Austin Clements

Subtract one from PCs recorded by getcallerpcs

This gets the call PCs instead of the return PCs, since this turns out to be what we really want everywhere we use this. This was particularly annoying for panics: since the compiler knows that panic doesn't return, when it's the last thing in the function, the compiler doesn't emit any further code after the call, which means the "return" PC either doesn't map to anything or maps to another function entirely.
上级 341c60bf
...@@ -291,7 +291,8 @@ getcallerpcs(void *v, uptr pcs[], int n) ...@@ -291,7 +291,8 @@ getcallerpcs(void *v, uptr pcs[], int n)
if(rbp == 0 || rbp < (uptr*)KBASE || rbp == (uptr*)(~0UL) || if(rbp == 0 || rbp < (uptr*)KBASE || rbp == (uptr*)(~0UL) ||
(rbp >= (uptr*)KBASEEND && rbp < (uptr*)KCODE)) (rbp >= (uptr*)KBASEEND && rbp < (uptr*)KCODE))
break; break;
pcs[i] = rbp[1]; // saved %rip pcs[i] = rbp[1] - 1; // saved %rip; - 1 so it points to the call
// instruction
rbp = (uptr*)rbp[0]; // saved %rbp rbp = (uptr*)rbp[0]; // saved %rbp
} }
for(; i < n; i++) for(; i < n; i++)
......
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论