如何在系统调用内打印到控制台(终端)
我如何在 Linux 系统调用中打印一些内容(用于调试目的)到控制台?
或者有没有什么不太困难的调试内核代码的方法?
谢谢
how can i print something (for debugging purpose) to console inside a linux system call?
Or is there any not very diffucult way of debugging kernel code?
thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
在内核中进行打印的可接受的方式是通过 printk() 。
The accepted way of printing inside the kernel is via
printk()
.您还应该检查 printk 的不同修饰符(例如 KERNEL_DEBUG),它将控制消息的打印位置/方式,包括它们是打印到所有活动终端还是仅打印到系统缓冲区
You should also check the different modifiers to printk (such as KERNEL_DEBUG) which will control where/how the messages are printed, including whether they are printed to all active terminals or just the system buffer