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

pry-doc show-source (or equivalent) for deeper C definitions #12

Open
kyrylo opened this issue May 11, 2013 · 1 comment
Open

pry-doc show-source (or equivalent) for deeper C definitions #12

kyrylo opened this issue May 11, 2013 · 1 comment

Comments

@kyrylo
Copy link
Member

kyrylo commented May 11, 2013

Moved from: pry/pry#593

The original description:

# when i run the command:
pry(main)> show-source String#length`
# it gives the C code for rb_str_length:
...
VALUE
rb_str_length(VALUE str)
{
    long len;

    len = str_strlen(str, STR_ENC_GET(str));
    return LONG2NUM(len);
}
# but there seems to be no way to look at the code for the definitions of str_strlen, VALUE, STR_ENC_GET, LONG2NUM without something like grep, vim & ctags to research the ruby C sources
# it would be very useful, when tracing ruby code to determine the source of performance issues, to be able to follow logic down to the lowest levels of the C code
# it would be very fast & easy on the brain to be able to do this from within the pry window
# perhaps another command show-c-source could be added:
pry(main)> show-c-source str_strlen
# would give something like:
static long
str_strlen(VALUE str, rb_encoding *enc)
{
    const char *p, *e;
    long n;
    int cr;
...
    return n;
}
# i am starting to look at ruby performance seriously, and studying the ruby & c code is just as effective as using a tool like gperftools
@kyrylo
Copy link
Member Author

kyrylo commented Feb 13, 2014

I think it should belong to a different gem. pry-cdoc, perhaps.

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

No branches or pull requests

1 participant