Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:79580 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 82662 invoked from network); 11 Dec 2014 19:54:51 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 11 Dec 2014 19:54:51 -0000 Authentication-Results: pb1.pair.com smtp.mail=argyros.george@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=argyros.george@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.218.41 as permitted sender) X-PHP-List-Original-Sender: argyros.george@gmail.com X-Host-Fingerprint: 209.85.218.41 mail-oi0-f41.google.com Received: from [209.85.218.41] ([209.85.218.41:48723] helo=mail-oi0-f41.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 2D/43-58820-A86F9845 for ; Thu, 11 Dec 2014 14:54:51 -0500 Received: by mail-oi0-f41.google.com with SMTP id a3so4274166oib.14 for ; Thu, 11 Dec 2014 11:54:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:date:message-id:subject:from:to:content-type; bh=+r+v3jSiRqX92W7gNpxe4d3Si1fnxvenLjfHj52xbls=; b=BUl5laQ7rOmNOn9G0yJu+9YMh3Zr7bb7oB41JowzUtzwOAoX4ON24MCYUpIFdq9Ux9 Tvx+orFJCjtPM5k0Ni+Na48WOUxKYRQOiOSYgqtx0cFXf6QVaGvD6lX3as43jsbCoCKN 6XW7WWltlLFeUBYSg1lb3IwNUaP5QGBWftplyx3WSuH5Nk718fan4XXb6xccUIF3n1zl xrLlC0uM/bw+s7nCc6PDqcvKVofXgA6+SfWzhfKfo3Jmj24voTn6BEuNCmd81JpuCgSh S3/g2T/1r87y3ehaLSSubFxVUjCYPTAtP97YuyY3XmTRxpL15dgLZJxiaXFFqIRcMoUZ i2mA== MIME-Version: 1.0 X-Received: by 10.202.174.198 with SMTP id x189mr7143774oie.78.1418327688349; Thu, 11 Dec 2014 11:54:48 -0800 (PST) Received: by 10.202.80.142 with HTTP; Thu, 11 Dec 2014 11:54:48 -0800 (PST) Date: Thu, 11 Dec 2014 14:54:48 -0500 Message-ID: To: internals@lists.php.net Content-Type: multipart/alternative; boundary=001a113ce8e40a0db00509f62650 Subject: Post hooking opcode execution and accessing userland names of variables From: argyros.george@gmail.com (George Argyros) --001a113ce8e40a0db00509f62650 Content-Type: text/plain; charset=UTF-8 Hi all, I am developing a program analysis tool as a PHP extension. The extension makes use of the zend_set_user_opcode_handler API in order to propagate information about the variables along the execution. I have two questions: 1. From my undestanding we can only pre-hook the execution of an opcode. In other words, we define a user_opcode_handler and after the execution of our opcode handler finish, then we can dispatch the execution to the original handler, but there is no way of taking control of the execution after the original handler is executed. Is that correct? If so, would the following way of implementing a post-hook work? - Save (by copying to another memory area) the opcode arguments. - On the next instruction executed utilize a user opcode handler for the next instruction to do the post-hook analysis by using the saved arguments. One reason I would like to use this is to propagate information after, for example, assignment operations where the result variable is not yet defined, and therefore no respective zval structure exists. Would it be possible in this case to access the newly created zval structure with the post-hook method I described above? 2. Again by what I understand from the code, userland variable names are stored in the compiled variable structure. Is there a way to access this structure given the zval pointer of the variable efficiently? Also, in a similar question, is there a way to access the userland name of a variable which is passed as an argument to a function of the extension? All I have found is how to grub the value of the variable or the respective zval structure using the argument parsing functions. Thanks, George --001a113ce8e40a0db00509f62650--