Unable to debug $items variable in hook_menu_alter(&$items) I want to print out $items variable (the argument of hook_menu_alter) for debugging the menu properties in various pages. 

I tried:

/**
 * Implement hook_menu_alter()
 */
function mymodule_menu_alter(&amp;$items) {
  debug($items);
  kpr($items);
}


cache cleared.

but $items are not printed out on the page. Any ideas?
It is not working because hook_menu() and hook_menu_alter() are invoked when the menu list is rebuild. This generally happens when a module is installed, or uninstalled, but modules can force the menu to be rebuild setting a Drupal variable, as with the following code:

variable_set('menu_rebuild_needed', TRUE);


When hook_menu_alter() is invoked, Drupal could also not serving a page that is visible on the browser. The function that rebuilds the menu, menu_get_tem(), is called by menu_execute_active_handler(), which is called every time Drupal bootstrap, even when an AJAX callback is invoked. In that case, the output of the debug function is not visible (nor would JavaScript get it).

In such cases, I think it is preferable to write the output to the database using watchdog(). The output is not immediately visible, but will be logged even when an AJAX callback is invoked.