Created
June 30, 2016 16:14
-
-
Save kivikakk/d472d0ec2670d2bc80076bcb3ade0f07 to your computer and use it in GitHub Desktop.
find the file:line of the current ruby thread that crashed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| m_pos = int(gdb.parse_and_eval("ruby_current_thread->cfp->pc - ruby_current_thread->cfp->iseq->iseq_encoded")) | |
| if m_pos > 0: | |
| m_pos -= 1 | |
| size = int(gdb.parse_and_eval("ruby_current_thread->cfp->iseq->line_info_size")) | |
| if size == 0: | |
| res = 0 | |
| elif size == 1: | |
| res = int(gdb.parse_and_eval("ruby_current_thread->cfp->iseq->line_info_table[0].line_no")) | |
| else: | |
| ix = 1 | |
| while ix < size: | |
| pos = int(gdb.parse_and_eval("ruby_current_thread->cfp->iseq->line_info_table[{}].position".format(ix))) | |
| if pos == m_pos: | |
| break | |
| elif pos > m_pos: | |
| ix -= 1 | |
| break | |
| ix += 1 | |
| if ix == size: | |
| ix -= 1 | |
| res = int(gdb.parse_and_eval("ruby_current_thread->cfp->iseq->line_info_table[{}].line_no".format(ix))) | |
| path = gdb.parse_and_eval("RSTRING_PTR(ruby_current_thread->cfp->iseq->location.path)").string() | |
| gdb.write("{}:{}\n".format(path, res)) |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Usage: