Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gdbinit file and helpers #475

Merged
merged 1 commit into from
Oct 6, 2022
Merged

Conversation

QDucasse
Copy link
Contributor

@QDucasse QDucasse commented Oct 5, 2022

Hello,
This pull request adds a .gdbinit file that can be copied at ~/.gdbinit to get common debugging functions and shortcuts for the Pharo VM. The list of all user-defined functions can be accessed in gdb with help user-defined and documentation for a specific function with help function_name.

Printing:

Command Arguments Description
ptt - Print trampoline table
pf frame address Print frame info
pcog cog method address Print cog method info
pcogs - Print all cogged methods
pct cog method type Print all cog methods of a given type
pcp primitive index Print all cog methods using a given primitive
pcm compiled method address Print all cog methods of a given method
pcs selector address Print all cog methods for a given selector

Locating and Disassembling

Command Arguments Description
whereis address Locates the enclosing cog method or trampoline
dt trampoline address Disassemble the given trampoline
dc cog method address (optional length) Disassemble the cog method (splits metadata/checks/method body) up to a given length if provided (all method otherwise)
dnc cog method address (optional length) Disassemble the cog method (starting at the method body) up to a given length if provided (all method otherwise)

@guillep
Copy link
Member

guillep commented Oct 6, 2022

This is super nice! Thanks Q.

I'll integrate it and put your comment into a wiki page.
BTW, do you have an already written little tutorial on how to debug the JIT? I'm interested on that too :)

@guillep guillep merged commit 1dc399f into pharo-project:pharoX Oct 6, 2022
@guillep
Copy link
Member

guillep commented Oct 6, 2022

FYI https://github.com/pharo-project/pharo-vm/wiki/Debugging-with-GDB

GitHub
This is the VM used by Pharo. Contribute to pharo-project/pharo-vm development by creating an account on GitHub.

@QDucasse
Copy link
Contributor Author

QDucasse commented Oct 6, 2022

Happy to help! The small tutorial is here: https://qducasse.github.io/posts/jit_debug/
(or the sources at https://github.com/QDucasse/bloggy/blob/main/content/posts/jit_debug.md)! Maybe it can go along with the page above!

Investigating VM runtime crashes can be obscure, especially when dealing with code that has been recompiled to machine code by the JIT compiler. This post will show the way to track the execution path within gdb. Note that you will need gdb to be available to debug the VM, it is not possible to do this through a simple qemu image (at least by default) or user-space simulation such as qemu-debootstrap.
GitHub
Sources for my blog https://qducasse.github.io. Contribute to QDucasse/bloggy development by creating an account on GitHub.

@guillep
Copy link
Member

guillep commented Oct 7, 2022

@QDucasse would you mind if we move some of your writeups to the wiki under your name?

@guillep
Copy link
Member

guillep commented Oct 10, 2022

I thought this was safe, but this is making the build fail (not compile) due the the missing printStringOf.

I'll revert it and reopen it

@guillep
Copy link
Member

guillep commented Oct 10, 2022

Reverted in #485. I'll see how we can reopen this PR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants