仅使用程序计数器和可执行文件调查未对齐的用户空间访问
因此,我有这个使用 -g
选项编译的可执行文件,它会触发加载未对齐的用户空间访问警告。
Unaligned userspace access in "softtest" pid=1407 pc=0x0041515c ins=0x011e
Unaligned userspace access in "softtest" pid=1406 pc=0x0041515c ins=0x011e
Unaligned userspace access in "softtest" pid=1406 pc=0x004148c2 ins=0x012e
Unaligned userspace access in "softtest" pid=1407 pc=0x0041515c ins=0x011e
Unaligned userspace access in "softtest" pid=1406 pc=0x0041515c ins=0x011e
Unaligned userspace access in "softtest" pid=1407 pc=0x0041515c ins=0x011e
Unaligned userspace access in "softtest" pid=1406 pc=0x004148c2 ins=0x012e
Unaligned userspace access in "softtest" pid=1407 pc=0x0041515c ins=0x011e
Unaligned userspace access in "softtest" pid=1406 pc=0x0041515c ins=0x011e
Unaligned userspace access in "softtest" pid=1406 pc=0x004148c2 ins=0x012e
Unaligned userspace access in "softtest" pid=1407 pc=0x0041515c ins=0x011e
Unaligned userspace access in "softtest" pid=1406 pc=0x0041515c ins=0x011e
Unaligned userspace access in "softtest" pid=1407 pc=0x0041515c ins=0x011e
Unaligned userspace access in "softtest" pid=1406 pc=0x004148c2 ins=0x012e
错误消息提供了一些信息:程序计数器和指令,但我不知道如何将 PC 转换为文件和代码中的行。
我可以将其嗅探为正在执行一些内存复制或其他操作的循环中,因为地址通常是相同的。
所以问题是:如何使用 Linux 工具找出导致这种未对齐访问的文件和代码行?
有什么意见吗?
So I have this executable, compiled with the -g
options, that triggers loads of unaligned userspace access warnings.
Unaligned userspace access in "softtest" pid=1407 pc=0x0041515c ins=0x011e
Unaligned userspace access in "softtest" pid=1406 pc=0x0041515c ins=0x011e
Unaligned userspace access in "softtest" pid=1406 pc=0x004148c2 ins=0x012e
Unaligned userspace access in "softtest" pid=1407 pc=0x0041515c ins=0x011e
Unaligned userspace access in "softtest" pid=1406 pc=0x0041515c ins=0x011e
Unaligned userspace access in "softtest" pid=1407 pc=0x0041515c ins=0x011e
Unaligned userspace access in "softtest" pid=1406 pc=0x004148c2 ins=0x012e
Unaligned userspace access in "softtest" pid=1407 pc=0x0041515c ins=0x011e
Unaligned userspace access in "softtest" pid=1406 pc=0x0041515c ins=0x011e
Unaligned userspace access in "softtest" pid=1406 pc=0x004148c2 ins=0x012e
Unaligned userspace access in "softtest" pid=1407 pc=0x0041515c ins=0x011e
Unaligned userspace access in "softtest" pid=1406 pc=0x0041515c ins=0x011e
Unaligned userspace access in "softtest" pid=1407 pc=0x0041515c ins=0x011e
Unaligned userspace access in "softtest" pid=1406 pc=0x004148c2 ins=0x012e
The error message provides some information: the program counter and the instruction, but I don't know how to translate the PC into a file and line in my code.
I can sniff this as being in a loop performing some memory copying or something, since the address is very often the same.
So question: how can I find out what's the file and line of my code causing this unaligned access, using Linux tools?
Any input on that?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
看一下 addr2line 实用程序
一个简单的 c 示例:
使用 gdb 编译它
会给出以下输出:
使用该地址与 addr2line:
Have a look at the
addr2line
utilityA Simple c-example:
compile it using
gdb gives this output:
Using that address with addr2line: