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

Provide a way, from Perl, to efficiently store the call stack. #19

Open
schwern opened this issue Oct 16, 2015 · 3 comments
Open

Provide a way, from Perl, to efficiently store the call stack. #19

schwern opened this issue Oct 16, 2015 · 3 comments

Comments

@schwern
Copy link
Contributor

schwern commented Oct 16, 2015

Provide a way to store the call stack at the Perl level without having to copy it with a loop through caller. Ideally it's a ref counted pointer to the internal Perl call stack structure.

The interface should be a CallStack object (which doesn't exist) that provides a lazy interface to the underlying C structure. It should do minimal work on initialization.

Rationale: It could be nice if exceptions could provide the whole call stack for the exception, but since that will be used rarely it would be inefficient to copy the whole thing using caller.

@Leont
Copy link
Contributor

Leont commented Nov 8, 2015

@nothingmuch's Devel::Stacktrace::XS provides some ideas on how to get there, but the addition of caller_cx in 5.14 means you can do this in significantly less code.

@schwern
Copy link
Contributor Author

schwern commented Nov 11, 2015

@Leont Interesting. So, potentially, the exception object would call caller_cx(level) in a loop to get the whole stack and store it in an array of PERL_CONTEXT. Or is that already what cxstack is? Could the Exception potentially store cxstack (would it need to be copied?) and interrogate it later if it's requested?

The goal here is to store the stack, but avoid having to do a lot of work if it's never used.

@Leont
Copy link
Contributor

Leont commented Nov 11, 2015

Interesting. So, potentially, the exception object would call caller_cx(level) in a loop to get the whole stack and store it in an array of PERL_CONTEXT.

Basically, yes. The point is to store a bunch of frames (relatively cheap) that can be later expanded into the full caller information if necessary.

Could the Exception potentially store cxstack (would it need to be copied?) and interrogate it later if it's requested?

AFAIK copying will be necessary, as it will be unwound during the exception handling (just like the other stacks), it's been 5 years since I've used that part of perl though.

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

No branches or pull requests

2 participants