声明
本文版权属于笔者朋友 YangHui
,所有资料内容均由 YangHui
提供,笔者只是一个转述者。
文章目录
- 声明
- 1. 前言
- 2. 问题的发生、跟踪、解决
- 3. 小结
1. 前言
限于作者能力水平,本文可能存在谬误,因此而给读者带来的损失,作者不做任何承诺。
2. 问题的发生、跟踪、解决
YangHui
童鞋在某嵌入式平台移植了 retroarch
模拟器,运行效果如下图:
上图中,可以发现,有几个黑框部分,这就是问题所在。对 retroarch
模拟器不熟悉的朋友,第一反应可能是去研究源代码。可对于 YangHui
童鞋来说,工程紧急,时间有限,老板催的屁股冒烟,这时候来从头研究 retroarch
的源码,有点不太现实。所以,YangHui
童鞋想到了使用 strace
来追踪程序的系统调用,看有没有报出一些错误,死马当活马医,你还别说,当 YangHui
童鞋追踪 open()
系统调用的时候,还真的发现了一些端倪:
# strace -f -e openat retroarch 2>&1 | grep assets
strace -f -e openat retroarch 2>&1 | grep assets
[pid 720] openat(AT_FDCWD, "assets://pkg/osd-font.ttf", O_RDONLY|O_LARGEFILE) = -1 ENOENT (No such file or directory)
[pid 720] openat(AT_FDCWD, "//.config/retroarch/assets/xmb/monochrome/font.ttf", O_RDONLY|O_LARGEFILE) = -1 ENOENT (No such file or directory)
[pid 720] openat(AT_FDCWD, "//.config/retroarch/assets/xmb/monochrome/font.ttf", O_RDONLY|O_LARGEFILE) = -1 ENOENT (No such file or directory)
Failed to open //.config/retroarch/assets/xmb/monochrome/font.ttf: No such file or directory
[pid 720] openat(AT_FDCWD, "//.config/retroarch/assets/xmb/monochrome/font.ttf", O_RDONLY|O_LARGEFILE) = -1 ENOENT (No such file or directory)
[pid 720] openat(AT_FDCWD, "//.config/retroarch/assets/xmb/monochrome/font.ttf", O_RDONLY|O_LARGEFILE) = -1 ENOENT (No such file or directory)
Failed to open //.config/retroarch/assets/xmb/monochrome/font.ttf: No such file or directory
[pid 720] openat(AT_FDCWD, "//.config/retroarch/assets/xmb/monochrome/png/retroarch.png", O_RDONLY|O_LARGEFILE) = -1 ENOENT (No such file or directory)
[pid 720] openat(AT_FDCWD, "//.config/retroarch/assets/xmb/monochrome/png/settings.png", O_RDONLY|O_LARGEFILE) = -1 ENOENT (No such file or directory)
[pid 720] openat(AT_FDCWD, "//.config/retroarch/assets/xmb/monochrome/png/history.png", O_RDONLY|O_LARGEFILE) = -1 ENOENT (No such file or directory)
[pid 720] openat(AT_FDCWD, "//.config/retroarch/assets/xmb/monochrome/png/favorites.png", O_RDONLY|O_LARGEFILE) = -1 ENOENT (No such file or directory)
[pid 720] openat(AT_FDCWD, "//.config/retroarch/assets/xmb/monochrome/png/musics.png", O_RDONLY|O_LARGEFILE) = -1 ENOENT (No such file or directory)
[pid 720] openat(AT_FDCWD, "//.config/retroarch/assets/xmb/monochrome/png/movies.png", O_RDONLY|O_LARGEFILE) = -1 ENOENT (No such file or directory)
[pid 720] openat(AT_FDCWD, "//.config/retroarch/assets/xmb/monochrome/png/netplay.png", O_RDONLY|O_LARGEFILE) = -1 ENOENT (No
从上面的追踪记录看,缺少了 TTF
字体 和 很多 PNG
图片。按照 strace
输出提示,逐一补齐图片后,重新运行模拟器,已经可以正常显示了:
3. 小结
本文完全是一次工程经验的完美体现,就技术本身而言,并没有太多的东西,重点是想到通过 strace
去进行追踪。很多时候,我们限于自身的积累,不可能对遇到的问题做到全知全能,这时候工程经验往往会起到很重要的作用。