Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:56786 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 15166 invoked from network); 6 Dec 2011 00:07:15 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 6 Dec 2011 00:07:15 -0000 Authentication-Results: pb1.pair.com smtp.mail=releaze3@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=releaze3@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.214.42 as permitted sender) X-PHP-List-Original-Sender: releaze3@gmail.com X-Host-Fingerprint: 209.85.214.42 mail-bw0-f42.google.com Received: from [209.85.214.42] ([209.85.214.42:42814] helo=mail-bw0-f42.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id F7/B0-09469-2BC5DDE4 for ; Mon, 05 Dec 2011 19:07:14 -0500 Received: by bkcjf3 with SMTP id jf3so1944001bkc.29 for ; Mon, 05 Dec 2011 16:07:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=message-id:date:from:user-agent:mime-version:to:subject :content-type:content-transfer-encoding; bh=7QMip+nhWSiEc1f54dR4ZQ59myc0cor3OgK3cYvRDG4=; b=X5z6PU0bFEM4c47i4m5AVKyU7XlHlFisKbuOblV5stmeJLn4+f/fodkV3527M07733 0Qk5uPKJeulH2zwH3JoHm4/R7qOVIw8dE/3YKQU6ONMrMvr94Sp2U6mAOP6K9mIp/ikI qTpe2qsgs7qu8USOY4wn1wAL92yio2rwEnNzU= Received: by 10.180.84.33 with SMTP id v1mr15325320wiy.4.1323130031504; Mon, 05 Dec 2011 16:07:11 -0800 (PST) Received: from [192.168.1.42] (41-133-121-112.dsl.mweb.co.za. [41.133.121.112]) by mx.google.com with ESMTPS id fy13sm30568624wbb.18.2011.12.05.16.07.09 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 05 Dec 2011 16:07:10 -0800 (PST) Message-ID: <4EDD5CAB.2000605@gmail.com> Date: Tue, 06 Dec 2011 02:07:07 +0200 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:8.0) Gecko/20111105 Thunderbird/8.0 MIME-Version: 1.0 To: internals@lists.php.net Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Subject: Issue with op_array moving From: releaze3@gmail.com (James Edmunds) Hi all, I am writing an extension that does performance monitoring. I guess somewhat like xdebug but a bit different. The user can specify the functions / methods they care about and I will time the execution of those things. I do this by hooking zend_execute. My hook is: void rrdmon_execute (zend_op_array *op_array TSRMLS_DC) { ... } After a php file has loaded ((op_array->function_name == NULL) && op_array->filename)) I check through the list of functions the user wants to monitor. I check to see if the thing they want to hook is a class or a normal function and then do something like this: HashTable *ftbl = EG(function_table); zend_function *func; if (is_a_class_method) { zend_class_entry **ce; if (zend_hash_find (CG(class_table), classnm, classnmlen, (void **)&ce) == FAILURE) { return; } ftbl = &((*ce)->function_table); } if (zend_hash_find (ftbl, funcnm, funcnmlen, (void **)&func) == FAILURE) { return; } func->op_array.reserved[0] = pointer_to_my_stuff; I dont actually use reserved[0] I do it properly getting the next offset but this was for illustrative purposes only. Then in my rrdmon_execute I do something like: if (op_array->reserved[0]) { ... do stuff ...; } This all works well, until I tried this with a class that had a namespace. The method is Symfony\Component\HttpKernel\Controller\ControllerResolver::getController. It finds the class name (everything pre the ::) in CG(class_table) and it finds the function (getController) in that class's function table, but unlike every other class and function I have tested this with, the op_array that I put my stuff into isn't the one being executed. That is, func->op_array isn't the op_array that ends up getting passed to rrdmon_execute(). This seems to only be an issue with namespaces. Symfony does a bunch of weird caching stuff so the class gets loaded out of a cache file but at this level, that shouldn't matter. So please, can someone who knows Zend's guts a bit better tell me if I am doing something wrong (this has worked just fine for several months up until I decided to time that stuff in Symfony which is the first time I have encountered namespaces) or if the op_array somehow gets moved around or how I should deal with namespaces for these purposes? Any help greatly appreciated. --Jim Edmunds.