Re: [PHP-DEV] Doing something with an each opcode as zend_execute() handles it

2003-03-05 Thread Sterling Hughes
 Just before zend_execute()/execute() handles each opcode in its big switch()
 statement, I'd like to be able to call a function and pass it the opcode (or
 other information from the opline.
 
 Is the best approach to reset zend_execute to a new function in the
 PHP_MINIT_FUNCTION() (and restore the saved value in
 PHP_MSHUTDOWN_FUNCTION)? This new function would mostly be a copy of
 execute() in zend_execute.c with my addtional function call tossed in.
 
 What's the difference between zend_execute() and zend_execute_internal()?
 

Well, I have a feeling what you are talking about is sub-optimal, what
do you want to do?

-Sterling

 Thanks,
 David
 
 
 -- 
 PHP Development Mailing List http://www.php.net/
 To unsubscribe, visit: http://www.php.net/unsub.php

-- 
Reductionists like to take things apart.  The rest of us are
 just trying to get it together.
- Larry Wall, Programming Perl, 3rd Edition

-- 
PHP Development Mailing List http://www.php.net/
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP-DEV] Doing something with an each opcode as zend_execute() handles it

2003-03-05 Thread David Sklar
On Wednesday, March 05, 2003 5:35 PM, Sterling Hughes wrote:

 Just before zend_execute()/execute() handles each opcode in its big
 switch() statement, I'd like to be able to call a function and pass
 it the opcode (or other information from the opline.

 Is the best approach to reset zend_execute to a new function in the
 PHP_MINIT_FUNCTION() (and restore the saved value in
 PHP_MSHUTDOWN_FUNCTION)? This new function would mostly be a copy of
 execute() in zend_execute.c with my addtional function call tossed
 in.

 What's the difference between zend_execute() and
 zend_execute_internal()?


 Well, I have a feeling what you are talking about is sub-optimal,
 what do you want to do?

Essentially, I want to be able to produce a sort of serialized
representation of the opcodes, but as they are executed, not all in one big
chunk after they are compiled.

This isn't for any actually useful production code, just some
debugging/messing around/exploring engine internals.

David


-- 
PHP Development Mailing List http://www.php.net/
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DEV] Doing something with an each opcode as zend_execute() handles it

2003-03-05 Thread Sterling Hughes
 On Wednesday, March 05, 2003 5:35 PM, Sterling Hughes wrote:
 
  Just before zend_execute()/execute() handles each opcode in its big
  switch() statement, I'd like to be able to call a function and pass
  it the opcode (or other information from the opline.
 
  Is the best approach to reset zend_execute to a new function in the
  PHP_MINIT_FUNCTION() (and restore the saved value in
  PHP_MSHUTDOWN_FUNCTION)? This new function would mostly be a copy of
  execute() in zend_execute.c with my addtional function call tossed
  in.
 
  What's the difference between zend_execute() and
  zend_execute_internal()?
 
 
  Well, I have a feeling what you are talking about is sub-optimal,
  what do you want to do?
 
 Essentially, I want to be able to produce a sort of serialized
 representation of the opcodes, but as they are executed, not all in one big
 chunk after they are compiled.
 
 This isn't for any actually useful production code, just some
 debugging/messing around/exploring engine internals.

I would suggest you take a look at Ze2's execution architecture, it
should allow you to do this.

-Sterling

 David

-- 
Reductionists like to take things apart.  The rest of us are
 just trying to get it together.
- Larry Wall, Programming Perl, 3rd Edition

-- 
PHP Development Mailing List http://www.php.net/
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DEV] Doing something with an each opcode as zend_execute() handles it

2003-03-05 Thread George Schlossnagle
Essentially, I want to be able to produce a sort of serialized
representation of the opcodes, but as they are executed, not all in 
one big
chunk after they are compiled.

This isn't for any actually useful production code, just some
debugging/messing around/exploring engine internals.
There's no good way to do this as a zend_extension in ZE1 (that I know 
of).  You need to patch the engine (which is trivial).

--
PHP Development Mailing List http://www.php.net/
To unsubscribe, visit: http://www.php.net/unsub.php


RE: [PHP-DEV] Doing something with an each opcode as zend_execute() handles it

2003-03-05 Thread John Coggeshall

Look at zend_init_opcodes_handlers() and the zend_opcode_handler array..


John


-Original Message-
From: George Schlossnagle [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, March 05, 2003 6:10 PM
To: David Sklar
Cc: Sterling Hughes; [EMAIL PROTECTED]
Subject: Re: [PHP-DEV] Doing something with an each opcode as 
zend_execute() handles it


 Essentially, I want to be able to produce a sort of serialized 
 representation of the opcodes, but as they are executed, not all in 
 one big chunk after they are compiled.

 This isn't for any actually useful production code, just some 
 debugging/messing around/exploring engine internals.


There's no good way to do this as a zend_extension in ZE1 (that I know 
of).  You need to patch the engine (which is trivial).


-- 
PHP Development Mailing List http://www.php.net/
To unsubscribe, visit: http://www.php.net/unsub.php




-- 
PHP Development Mailing List http://www.php.net/
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP-DEV] Doing something with an each opcode as zend_execute() handles it

2003-03-05 Thread David Sklar
On Wednesday, March 05, 2003 5:46 PM, Sterling Hughes wrote:

 Essentially, I want to be able to produce a sort of serialized
 representation of the opcodes, but as they are executed, not all in
 one big chunk after they are compiled.

 This isn't for any actually useful production code, just some
 debugging/messing around/exploring engine internals.

 I would suggest you take a look at Ze2's execution architecture, it
 should allow you to do this.

Such as overriding the opcode handlers for each opcode? I suppose I could
change what the handlers are initialized to in zend_init_opcodes_handler()
so that my new handler does the serialization and then calls the regular
handler. Does that make sense?


On Wednesday, March 05, 2003 6:10 PM, George Schlossnagle wrote:

 There's no good way to do this as a zend_extension in ZE1 (that I know
 of).  You need to patch the engine (which is trivial).

Yeah, so far I'm just using a different zend_execute.c with my added code, I
was just wondering if there's a better/more formal/etc way to do it...

Thanks,
David


-- 
PHP Development Mailing List http://www.php.net/
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP-DEV] Doing something with an each opcode as zend_execute() handles it

2003-03-05 Thread John Coggeshall
Such as overriding the opcode handlers for each opcode? I 
suppose I could change what the handlers are initialized to in 
zend_init_opcodes_handler() so that my new handler does the 
serialization and then calls the regular handler. Does that make sense?


Yep

Int my_do_fetch_r_handler(ZEND_OPCODE_HANDLER_ARGS) {
fprintf(stderr, we hooked fetch_r\n);
return
zend_do_fetch_r_handler(ZEND_OPCODE_HANDLER_ARGS_PASSTHRU);

}

Is all you'd need.

John


-- 
PHP Development Mailing List http://www.php.net/
To unsubscribe, visit: http://www.php.net/unsub.php