Debugging user-code on xv6 with gdb

ぐ巨炮叔叔 提交于 2019-12-13 11:43:27

问题


I'm doing an OS class that's based on xv6 and I wrote a program that needs to run on it.

I know that I can debug kernel code with make qemu-gdb but I'm not sure how to debug my own user program.

Lets say I want to debug cat, how would I go about doing that?

Thanks

P.S. isn't there an xv6 tag? should this question even go here?


回答1:


file cat, break main, continue

semi reference running and debugging xv6




回答2:


From the xv6 top-level dir:

  1. Run the emulator in debug mode (assuming no X11): make qemu-nox-gdb

  2. In other terminal just run the debugger loading the kernel symbols with: gdb kernel This is important, otherwise the debugger will be confused between kernel and and user program symbols, for example main()

  3. From the gdb interface run: (gdb) target remote localhost:26000 where 26000 is the TCP port that the step #1 report at the end (this might change).

  4. Load the user exec with (gdb)file user_program

  5. Place a breakpoint (gdb) break main and continue with (gdb) continue

  6. etc...



来源:https://stackoverflow.com/questions/10534798/debugging-user-code-on-xv6-with-gdb

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!