13 messages in org.perl.perl5-portersRe: Find the line number of the curre...
FromSent OnAttachments
Tim BunceMay 2, 2007 4:56 pm 
Artur BergmanMay 2, 2007 6:59 pm 
Dave MitchellMay 3, 2007 3:43 am 
Paul JohnsonMay 3, 2007 4:07 am 
Tim BunceMay 3, 2007 4:15 am 
Artur BergmanMay 3, 2007 10:34 am 
Artur BergmanMay 3, 2007 10:49 am 
Tim BunceMay 3, 2007 1:46 pm 
Tim BunceAug 8, 2007 6:13 am 
Tim BunceAug 8, 2007 6:33 am 
Dave MitchellAug 8, 2007 8:33 am 
Tim BunceJul 16, 2008 2:59 pm 
Paul JohnsonJul 17, 2008 2:48 am 
Actions with this message:
Paste this link in email or IM:
Paste this link in email or IM:
Atom feed for this thread
Paste this URL into your reader:
Subject:Re: Find the line number of the current block from XS code?Actions...
From:Tim Bunce (Tim.@pobox.com)
Date:Aug 8, 2007 6:33:55 am
List:org.perl.perl5-porters

On Wed, Aug 08, 2007 at 02:13:40PM +0100, Tim Bunce wrote:

On Thu, May 03, 2007 at 10:50:07AM -0700, Artur Bergman wrote:

Ah, I missunderstood, you want to find the start of the perl level scope that access your XS?

Yes. Specifically the first cop in the block, to get the line number.

loop is a block/scope :) but I guess you can just walk down the cxstack until you find the type you want

CxTYPE == CXt_SUB and CXt_BLOCK

The context struct is focussed on restoring state when the context is exited. So I can get the op that the context will return to (cx_u.cx_blk.blku_oldcop) but not the first op that was executed in the context. Right?

If so, does anyone have any ideas?

I may need to track the line numbers myself in the DB_sub, but that'll probaby need a stack mechanism and careful logic to note changes in cxstack_ix and PL_curstackinfo. Not very appealing.

Hypothesizing...

If I find the closest enclosing context is a sub, can I use cx->blk_sub.cv->xcv_start?

If I find the closest enclosing context is an eval, can I use PL_eval_root or cx->blk_eval.old_eval_root, or cx->blk_eval.cv->xcv_start? (which?)

If I find the closest enclosing context is a loop, can I use cx->blk_loop.redo_op?

I can't see a way to identify the first line of an ordinary block (the scope stack doesn't have enough info) but I can live without that if can get get line numbers for loops.

Tim.