-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathHiPerf.xs
30 lines (27 loc) · 809 Bytes
/
HiPerf.xs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#include "EXTERN.h"
#include "perl.h"
#include "XSUB.h"
#include "ppport.h"
MODULE = StackTrace::HiPerf PACKAGE = StackTrace::HiPerf
PROTOTYPES: DISABLE
SV* trace( int start_depth = 0 )
CODE:
SV * trace = newSVpv( "", 0 );
int caller_depth = -1;
I32 i;
for ( i = cxstack_ix; i >= 0; --i ) {
switch( CxTYPE( &cxstack[ i ] ) & CXTYPEMASK ) {
case CXt_SUB:
case CXt_EVAL:
if ( ++caller_depth >= start_depth ) {
sv_catpvf(
trace,
"%li|%s||",
( I32 ) CopLINE( cxstack[ i ].blk_oldcop ),
OutCopFILE( cxstack[ i ].blk_oldcop )
);
}
}
}
RETVAL = trace;
OUTPUT: RETVAL