Skip to content

Commit

Permalink
Use pppport.h and its suggested changes.
Browse files Browse the repository at this point in the history
  • Loading branch information
ashb committed May 12, 2009
1 parent 91e5541 commit 06e2315
Show file tree
Hide file tree
Showing 2 changed files with 6,993 additions and 7 deletions.
16 changes: 9 additions & 7 deletions TryCatch.xs
@@ -1,6 +1,8 @@
#include "EXTERN.h" #include "EXTERN.h"
#include "perl.h" #include "perl.h"
#include "XSUB.h" #include "XSUB.h"
#define NEED_sv_2pv_flags
#include "ppport.h"


#include "hook_op_check.h" #include "hook_op_check.h"
#include "hook_op_ppaddr.h" #include "hook_op_ppaddr.h"
Expand All @@ -10,7 +12,6 @@ static int trycatch_debug = 0;
STATIC I32 STATIC I32
dump_cxstack() dump_cxstack()
{ {
//dVAR;
I32 i; I32 i;
for (i = cxstack_ix; i >= 0; i--) { for (i = cxstack_ix; i >= 0; i--) {
register const PERL_CONTEXT * const cx = cxstack+i; register const PERL_CONTEXT * const cx = cxstack+i;
Expand Down Expand Up @@ -59,17 +60,17 @@ STATIC OP* unwind_return (pTHX_ OP *op, void *user_data) {
} }




// call_pv("Scope::Upper::unwind", G_VOID); /* Can't use call_sv et al. since it resets PL_op. */
// Can't use call_sv et al. since it resets PL_op. /* call_pv("Scope::Upper::unwind", G_VOID); */


unwind = get_cv("Scope::Upper::unwind", 0); unwind = get_cv("Scope::Upper::unwind", 0);
XPUSHs( (SV*)unwind); XPUSHs( (SV*)unwind);
PUTBACK; PUTBACK;


return CALL_FPTR(PL_ppaddr[OP_ENTERSUB])(aTHX); return CALL_FPTR(PL_ppaddr[OP_ENTERSUB])(aTHXR);
} }


// Hook the OP_RETURN iff we are in hte same file as originally compiling. /* Hook the OP_RETURN iff we are in hte same file as originally compiling. */
STATIC OP* check_return (pTHX_ OP *op, void *user_data) { STATIC OP* check_return (pTHX_ OP *op, void *user_data) {


const char* file = SvPV_nolen( (SV*)user_data ); const char* file = SvPV_nolen( (SV*)user_data );
Expand All @@ -87,7 +88,7 @@ PROTOTYPES: DISABLE
void void
install_return_op_check() install_return_op_check()
CODE: CODE:
// Code stole from Scalar::Util::dualvar /* Code stole from Scalar::Util::dualvar */
UV id; UV id;
char* file = CopFILE(&PL_compiling); char* file = CopFILE(&PL_compiling);
STRLEN len = strlen(file); STRLEN len = strlen(file);
Expand Down Expand Up @@ -119,7 +120,6 @@ SV* id
UV uiv = SvIV(id); UV uiv = SvIV(id);
#endif #endif
hook_op_check_remove(OP_RETURN, uiv); hook_op_check_remove(OP_RETURN, uiv);
//SvREFCNT_dec( id );
OUTPUT: OUTPUT:


void dump_stack() void dump_stack()
Expand All @@ -128,7 +128,9 @@ void dump_stack()
OUTPUT: OUTPUT:


BOOT: BOOT:
{
char *debug = getenv ("TRYCATCH_DEBUG"); char *debug = getenv ("TRYCATCH_DEBUG");
if (debug && atoi(debug) >= 2) { if (debug && atoi(debug) >= 2) {
trycatch_debug = 1; trycatch_debug = 1;
} }
}

0 comments on commit 06e2315

Please sign in to comment.