在 Solaris 中查找从虚拟页到物理页的映射
我想访问虚拟页面到某个进程的物理页面的映射。操作系统是Solaris,确切的版本可以从https://stackoverflow.com/users/760807/metalicpriest
询问想要获得如下列表:
virt_addrs phys_addrs
0x000000-0x001000 0x537000-0x538000
0x001000-0x002000 0x832000-0x833000
...
CPU 是 x86 或 x86_64。页面大小为4K;交换已关闭。我对由 FS(可执行映像)支持且进程未使用的页面不感兴趣。
I want to access a mapping of virtual pages to physical one of some process. The OS is Solaris, the exact version can be asked from https://stackoverflow.com/users/760807/metallicpriest
I want to get list like:
virt_addrs phys_addrs
0x000000-0x001000 0x537000-0x538000
0x001000-0x002000 0x832000-0x833000
...
The cpu is x86 or x86_64. Page size is 4K; swap is turned off. I'm not interested in pages, that are backed by FS (executable image) and unused by process.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以使用 pmap 和内核调试器 (mdb -k) 来实现这一点。
pmap首先会显示进程使用了哪些(虚拟)内存区域,然后,在mdb下,您将获取进程结构(pid2proc)并显示其p_as字段(进程地址空间)。当将该值作为参数传递时,vtop 命令可以显示进程虚拟地址到物理地址的映射。
例如:
You can use pmap and the kernel debugger (mdb -k) to achieve that.
Pmap will first displays what (virtual) memory areas are used by the process, then, under mdb, you get the process structure (pid2proc) and display its p_as field (process address space). When passed that value as parameter, the vtop command can display the process virtual to physical address mapping.
eg:
虽然有点晚了,但在 Solaris 上做到这一点并不难。只需使用
libkvm
。这是针对 Solaris 11 的:
您需要 root 权限才能运行它,而且根本没有错误检查。如果给它一个错误的 PID,它可能会出现 SEGV。
A bit late, but it's not hard to do at all on Solaris. Just use
libkvm
.This is for Solaris 11:
You'll need to be root to run that, and there's no error checking - at all. Give it a bad PID and it'll probably SEGV.