Debugging layout XML loading

You can log the compiled layout XML directives which are used to generate blocks. Create an observer on controller_action_layout_generate_blocks_before, and in the observer method log the update XML from the transported layout object:

public function logCompiledLayout($o)
{
    $req  = Mage::app()->getRequest();
    $info = sprintf(
        "\nRequest: %s\nFull Action Name: %s_%s_%s\nHandles:\n\t%s\nUpdate XML:\n%s",
        $req->getRouteName(),
        $req->getRequestedRouteName(),      //full action name 1/3
        $req->getRequestedControllerName(), //full action name 2/3
        $req->getRequestedActionName(),     //full action name 3/3
        implode("\n\t",$o->getLayout()->getUpdate()->getHandles()),
        $o->getLayout()->getUpdate()->asString()
    );

    // Force logging to var/log/layout.log
    Mage::log($info, Zend_Log::INFO, 'layout.log', true);
}

Output will be similar to:

2013-01-23T16:24:26+00:00 INFO (6): 
Request: cms
Full Action Name: cms_index_index
Handles:
    default
    cms_page
    STORE_default
    THEME_frontend_default_default
    cms_index_index
    page_two_columns_right
    customer_logged_out
Update XML:
<block name="formkey" type="core/template" template="core/formkey.phtml"/>
<label>All Pages</label>
<!-- ... ->

You can retrieve all the layout handles in your controller by doing this:

var_dump($this->getLayout()->getUpdate()->getHandles());

Or anywhere (as long as the layout has been initialized) using this:

var_dump(Mage::app()->getLayout()->getUpdate()->getHandles());

Perhaps that will help you debug.

EDIT

Have you set your config.xml to specify the block class?

    <blocks>
        <banners>
            <class>My_Banners_Block</class>
        </banners>
    </blocks>

I'm using PhpStorm with Magicento and so I thought I would adapt @benmarks great answer to my usage.

In PhpStorm, open up app/code/core/Mage/Core/Controller/Varien/Action.php and put a break point in method generateLayoutBlocks(). I think the point is to insert it anywhere before $this->getLayout()->generateBlocks();. I put it on the previous line.

After you insert the breakpoint, indicated by the red dot on the left by the line number, you can right click it to customize behavior. Click "More" at the bottom to open up all options. enter image description here

Once you open that up, you check the box for "Log message to console" (optional) and "Log evaluated expression" (where the magic happens). Then copy paste this adaptation of benmark's code into the text box. The only thing I've changed is spelling out the $request variable as Mage::app()->getRequest() every time, and changed the $o variable to $this (b/c we're not in the observer context here).

sprintf("\nRequest: %s\nFull Action Name: %s_%s_%s\nHandles:\n\t%s\nUpdate XML:\n%s",Mage::app()->getRequest()->getRouteName(),Mage::app()->getRequest()->getRequestedRouteName(),Mage::app()->getRequest()->getRequestedControllerName(),Mage::app()->getRequest()->getRequestedActionName(),implode("\n\t",$this->getLayout()->getUpdate()->getHandles()),$this->getLayout()->getUpdate()->asString())

So now it looks like this: Image shows advanced breakpoint settings

After you run the program (using xdebug or zend debugger) you'll stop at the breakpoint and see this in the log:

Update XML:
<block name="formkey" type="core/template" template="core/formkey.phtml"/>
<label>All Pages</label>
<block type="page/html" name="root" output="toHtml" template="page/2columns-left.phtml">
   <block type="page/html_head" name="head" as="head">
      <action method="addJs">
         <script>jquery/jquery-migrate-1.2.1.min.js</script>
      </action>
      <action method="addJs">
         <script>jquery/jquery-ui/jquery-ui.min.js</script>
      </action>
      <action method="addJs">
         <script>prototype/prototype.js</script>
      </action>
      <action method="addJs" ifconfig="dev/js/deprecation">
         <script>prototype/deprecation.js</script>
      </action>
      <action method="addJs">
         <script>lib/ccard.js</scrip

There seems to be a size limit for the log entries that might be determined by the idea.cycle.buffer.size property in the idea.properties file for PhpStorm, according to this. You could change that, or just right click on the code window and select "Evaluate Expression" from the dropdown menu, and copy and paste the code to execute in there and you will get the full output.

In the "Evaluate Expression" pop-up, you can right-click (Windows) on the result and select "Copy Value" to get the entire output and paste it somewhere else for analysis.

PhpStorm - copy from Evaluate Expression popup