0

By default, when I profile a page request with xDebug, I get output that looks something like this

19.2468   51097384    -> is_string() /path/to/app/code/core/Mage/Eav/Model/Entity/Abstract.php:363
19.2469   51097336  -> Mage_Eav_Model_Entity_Abstract->getAttribute() /path/to/app/code/core/Mage/Eav/Model/Entity/Abstract.php:513
19.2469   51097384    -> is_numeric() /path/to/app/code/core/Mage/Eav/Model/Entity/Abstract.php:352
19.2469   51097384    -> is_string() /path/to/app/code/core/Mage/Eav/Model/Entity/Abstract.php:363
19.2470   51097336  -> Mage_Eav_Model_Entity_Abstract->getAttribute() /path/to/app/code/core/Mage/Eav/Model/Entity/Abstract.php:513
19.2470   51097384    -> is_numeric() /path/to/app/code/core/Mage/Eav/Model/Entity/Abstract.php:352
19.2471   51097384    -> is_string() /path/to/app/code/core/Mage/Eav/Model/Entity/Abstract.php:363
19.2949   50464472    -> Zend_Log->__destruct() /path/to/lib/Zend/Log.php:513
19.2950   50464472      -> Zend_Log_Writer_Stream->shutdown() /path/to/lib/Zend/Log.php:285

Are there any xdebug flags, or other features, for reporting on the object type for a particular call? That is, when the report contains this line

Mage_Eav_Model_Entity_Abstract->getAttribute()

it's telling me the getAttribute method, defined in the Mage_Eav_Model_Entity_Abstract, is being called. In addition to the above information, I'd like to know what type of object is having its getAttribute method called.

My end goal is to know a bit more, at glance, about which objects are consuming large amounts of memory in a system. Right now, once I've identified a large jump in memory consumption, I'll add some debugging code to the root methods using memory_get_usage which will let me identify the object with a get_class($this); call. This works, but adds time and mental overhead to the process. I want to know immediately after profiling which specific objects are responsible.

Update: Per the comments, if I run the following script via a web browser

<?php
xdebug_start_trace();
abstract class A
{
    abstract function foo();        

    public function bar()
    {
        echo "A Test","\n";
    }
}

class B extends A
{
    public function foo()
    {
    }
}

$test = new B;
$test->bar();

xDebug reports the following in its trace file.

TRACE START [2012-03-18 22:15:30]
    0.0248     643288     -> A->bar() /Users/alanstorm/Sites2011/magento1point6point1.dev/xdebug.php:21
    0.0258       8512
TRACE END   [2012-03-18 22:15:30]

What I want (and should, per the comments, expect?), is instead of

A->bar();

which lets me know the bar method, defined in the A class, was called, is

B->bar();

which would let me know the bar method was called on an object which was instantiated with the class B.

Running on OS X 10.6.8 with the stock PHP, installed and upgraded via the stock pecl.

11
  • did you look up xdebug_call_function() and xdebug_call_class? Mar 15, 2012 at 22:28
  • Unless I'm missing something neither of those functions solves the problem I described above. Mar 15, 2012 at 23:02
  • I suppose Varien_Profiler just isn't giving you what you need? What about a cachegrind?
    – benmarks
    Mar 16, 2012 at 0:36
  • I was looking for something finer grained than Varien_Profiler, plus something that's applicable to other frameworks. This led me to believe the cachegrind files aren't to be trusted w/r/t memory usage: derickrethans.nl/xdebug-and-tracing-memory-usage.html Mar 16, 2012 at 5:17
  • 1
    Uh, I don't think it's a normal Xdebug behaviour, and I wrote it.
    – Derick
    Mar 18, 2012 at 21:22

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.