base: replace dump utilities in Allocator_avl

Replace 'dump()' debug utilities within Allocator_avl with Output::print
equivalents, and use the new Avl_tree::for_each utility to simplify
the implementation.

Ref #2159
This commit is contained in:
Stefan Kalkowski 2016-11-02 10:39:13 +01:00 committed by Christian Helmuth
parent 1542d92165
commit e1ec39e476
10 changed files with 64 additions and 119 deletions

View File

@ -440,13 +440,13 @@ Platform::Platform() :
_setup_irq_alloc(); _setup_irq_alloc();
_setup_rom(); _setup_rom();
log(":ram_alloc: "); _ram_alloc()->dump_addr_tree(); log(":ram_alloc: ", _ram_alloc);
log(":region_alloc: "); _region_alloc()->dump_addr_tree(); log(":region_alloc: ", _region_alloc);
log(":io_mem: "); _io_mem_alloc()->dump_addr_tree(); log(":io_mem: ", _io_mem_alloc);
log(":io_port: "); _io_port_alloc()->dump_addr_tree(); log(":io_port: ", _io_port_alloc);
log(":irq: "); _irq_alloc()->dump_addr_tree(); log(":irq: ", _irq_alloc);
log(":rom_fs: "); _rom_fs.print_fs(); log(":rom_fs: "); _rom_fs.print_fs();
log(":core ranges: "); _core_address_ranges()()->dump_addr_tree(); log(":core ranges: ", _core_address_ranges);
Fiasco::l4_threadid_t myself = Fiasco::l4_myself(); Fiasco::l4_threadid_t myself = Fiasco::l4_myself();

View File

@ -446,13 +446,13 @@ Platform::Platform() :
_setup_irq_alloc(); _setup_irq_alloc();
_setup_rom(); _setup_rom();
log(":ram_alloc: "); _ram_alloc()->dump_addr_tree(); log(":ram_alloc: ", _ram_alloc);
log(":region_alloc: "); _region_alloc()->dump_addr_tree(); log(":region_alloc: ", _region_alloc);
log(":io_mem: "); _io_mem_alloc()->dump_addr_tree(); log(":io_mem: ", _io_mem_alloc);
log(":io_port: "); _io_port_alloc()->dump_addr_tree(); log(":io_port: ", _io_port_alloc);
log(":irq: "); _irq_alloc()->dump_addr_tree(); log(":irq: ", _irq_alloc);
log(":rom_fs: "); _rom_fs.print_fs(); log(":rom_fs: "); _rom_fs.print_fs();
log(":core ranges: "); _core_address_ranges()()->dump_addr_tree(); log(":core ranges: ", _core_address_ranges());
Core_cap_index* pdi = Core_cap_index* pdi =
reinterpret_cast<Core_cap_index*>(cap_map()->insert(_cap_id_alloc.alloc(), Fiasco::L4_BASE_TASK_CAP)); reinterpret_cast<Core_cap_index*>(cap_map()->insert(_cap_id_alloc.alloc(), Fiasco::L4_BASE_TASK_CAP));

View File

@ -147,30 +147,12 @@ Platform::Platform()
_init_additional(); _init_additional();
/* print ressource summary */ /* print ressource summary */
log("Core virtual memory allocator"); log(":virt_alloc: ", *_core_mem_alloc.virt_alloc());
log("---------------------"); log(":phys_alloc: ", *_core_mem_alloc.phys_alloc());
(*_core_mem_alloc.virt_alloc())()->dump_addr_tree(); log(":io_mem_alloc: ", _io_mem_alloc);
log("\n"); log(":io_port_alloc: ", _io_port_alloc);
log("RAM memory allocator"); log(":irq_alloc: ", _irq_alloc);
log("---------------------"); log(":rom_fs: "); _rom_fs.print_fs();
(*_core_mem_alloc.phys_alloc())()->dump_addr_tree();
log("");
log("IO memory allocator");
log("-------------------");
_io_mem_alloc()->dump_addr_tree();
log("");
log("IO port allocator");
log("-------------------");
_io_port_alloc()->dump_addr_tree();
log("");
log("IRQ allocator");
log("-------------------");
_irq_alloc()->dump_addr_tree();
log("");
log("ROM filesystem");
log("--------------");
_rom_fs.print_fs();
log("");
} }

View File

@ -628,10 +628,10 @@ Platform::Platform() :
_gsi_base_sel = (hip->mem_desc_offset - hip->cpu_desc_offset) / hip->cpu_desc_size; _gsi_base_sel = (hip->mem_desc_offset - hip->cpu_desc_offset) / hip->cpu_desc_size;
if (verbose_boot_info) { if (verbose_boot_info) {
log(":virt_alloc: "); (*_core_mem_alloc.virt_alloc())()->dump_addr_tree(); log(":virt_alloc: ", *_core_mem_alloc.virt_alloc());
log(":phys_alloc: "); (*_core_mem_alloc.phys_alloc())()->dump_addr_tree(); log(":phys_alloc: ", *_core_mem_alloc.phys_alloc());
log(":io_mem_alloc: "); _io_mem_alloc()->dump_addr_tree(); log(":io_mem_alloc: ", _io_mem_alloc);
log(":rom_fs: "); _rom_fs.print_fs(); log(":rom_fs: "); _rom_fs.print_fs();
} }
/* add capability selector ranges to map */ /* add capability selector ranges to map */

View File

@ -185,11 +185,11 @@ Platform::Platform() :
init_log(); init_log();
log(":phys_alloc: "); (*_core_mem_alloc.phys_alloc())()->dump_addr_tree(); log(":phys_alloc: ", *_core_mem_alloc.phys_alloc());
log(":virt_alloc: "); (*_core_mem_alloc.virt_alloc())()->dump_addr_tree(); log(":virt_alloc: ", *_core_mem_alloc.virt_alloc());
log(":io_mem: "); _io_mem_alloc()->dump_addr_tree(); log(":io_mem: ", _io_mem_alloc);
log(":io_port: "); _io_port_alloc()->dump_addr_tree(); log(":io_port: ", _io_port_alloc);
log(":irq: "); _irq_alloc()->dump_addr_tree(); log(":irq: ", _irq_alloc);
log(":rom_fs: "); _rom_fs.print_fs(); log(":rom_fs: "); _rom_fs.print_fs();
/* setup task object for core task */ /* setup task object for core task */

View File

@ -630,13 +630,13 @@ Platform::Platform() :
* hold the meta data for the ROM modules as initialized by '_setup_rom'. * hold the meta data for the ROM modules as initialized by '_setup_rom'.
*/ */
if (verbose) { if (verbose) {
log(":ram_alloc: "); _ram_alloc()->dump_addr_tree(); log(":ram_alloc: ", _ram_alloc);
log(":region_alloc: "); _region_alloc()->dump_addr_tree(); log(":region_alloc: ", _region_alloc);
log(":io_mem: "); _io_mem_alloc()->dump_addr_tree(); log(":io_mem: ", _io_mem_alloc);
log(":io_port: "); _io_port_alloc()->dump_addr_tree(); log(":io_port: ", _io_port_alloc);
log(":irq: "); _irq_alloc()->dump_addr_tree(); log(":irq: ", _irq_alloc);
log(":rom_fs: "); _rom_fs.print_fs(); log(":rom_fs: "); _rom_fs.print_fs();
log(":core ranges: "); _core_address_ranges()()->dump_addr_tree(); log(":core ranges: ", _core_address_ranges);
} }
/* /*

View File

@ -438,10 +438,10 @@ Platform::Platform()
log("VM area at ", Hex_range<addr_t>(_vm_base, _vm_size)); log("VM area at ", Hex_range<addr_t>(_vm_base, _vm_size));
if (verbose_boot_info) { if (verbose_boot_info) {
log(":phys_alloc: "); (*_core_mem_alloc.phys_alloc())()->dump_addr_tree(); log(":phys_alloc: ", *_core_mem_alloc.phys_alloc());
log(":unused_phys_alloc:"); _unused_phys_alloc()->dump_addr_tree(); log(":unused_phys_alloc:", _unused_phys_alloc);
log(":virt_alloc: "); (*_core_mem_alloc.virt_alloc())()->dump_addr_tree(); log(":virt_alloc: ", *_core_mem_alloc.virt_alloc());
log(":io_mem_alloc: "); _io_mem_alloc()->dump_addr_tree(); log(":io_mem_alloc: ", _io_mem_alloc);
} }
_init_rom_modules(); _init_rom_modules();

View File

@ -16,6 +16,7 @@
#include <base/allocator.h> #include <base/allocator.h>
#include <base/tslab.h> #include <base/tslab.h>
#include <base/output.h>
#include <util/avl_tree.h> #include <util/avl_tree.h>
#include <util/misc_math.h> #include <util/misc_math.h>
@ -150,20 +151,6 @@ class Genode::Allocator_avl_base : public Range_allocator
* Return sum of available memory in subtree * Return sum of available memory in subtree
*/ */
size_t avail_in_subtree(void); size_t avail_in_subtree(void);
/**
* Debug hook
*
* \noapi
*/
void dump();
/**
* Debug hook
*
* \noapi
*/
void dump_dot(int indent = 0);
}; };
private: private:
@ -252,12 +239,7 @@ class Genode::Allocator_avl_base : public Range_allocator
*/ */
bool any_block_addr(addr_t *out_addr); bool any_block_addr(addr_t *out_addr);
/** void print(Output &out) const;
* Debug hook
*
* \noapi
*/
void dump_addr_tree(Block *addr_node = 0);
/******************************* /*******************************

View File

@ -1,58 +1,37 @@
/* /*
* \brief Allocator dump helpers * \brief Allocator AVL dump
* \author Norman Feske * \author Norman Feske
* \author Stefan Kalkowski
* \date 2009-10-15 * \date 2009-10-15
*/ */
/* /*
* Copyright (C) 2009-2013 Genode Labs GmbH * Copyright (C) 2009-2016 Genode Labs GmbH
* *
* This file is part of the Genode OS framework, which is distributed * This file is part of the Genode OS framework, which is distributed
* under the terms of the GNU General Public License version 2. * under the terms of the GNU General Public License version 2.
*/ */
#include <base/log.h>
#include <base/allocator_avl.h> #include <base/allocator_avl.h>
using namespace Genode; void Genode::Allocator_avl_base::print(Genode::Output & out) const
void Allocator_avl_base::Block::dump()
{ {
log(" Block: [", Hex(addr()), ",", Hex(addr() + size()), "] ", using Genode::print;
"size=", Hex(size()), " avail=", Hex(avail()), " ", unsigned long mem_size = 0;
"max_avail=", Hex(max_avail())); unsigned long mem_avail = 0;
}
print(out, "Allocator ", this, " dump:\n");
void Allocator_avl_base::dump_addr_tree(Block *addr_node) _addr_tree.for_each([&] (Block const & b)
{ {
bool top = false; print(out, " Block: [", Hex(b.addr()), ",", Hex(b.addr() + b.size()),
static unsigned long mem_size; "] ", "size=", Hex(b.size()), " avail=", Hex(b.avail()), " ",
static unsigned long mem_avail; "max_avail=", Hex(b.max_avail()), "\n");
mem_size += b.size();
if (addr_node == 0) { mem_avail += b.avail();
addr_node = _addr_tree.first(); });
log("Allocator ", this, " dump:"); print(out, " => mem_size=", mem_size, " (", mem_size / 1024 / 1024 ,
mem_size = mem_avail = 0; " MB) / mem_avail=" , mem_avail , " (" , mem_avail / 1024 / 1024 ,
top = true; " MB)\n");
}
if (!addr_node) return;
if (addr_node->child(0))
dump_addr_tree(addr_node->child(0));
Block *b = (Block *)addr_node;
b->dump();
mem_size += b->size();
mem_avail += b->avail();
if (addr_node->child(1))
dump_addr_tree(addr_node->child(1));
if (top)
log(" => mem_size=", mem_size, " (", mem_size / 1024 / 1024, " MB) ",
"/ mem_avail=", mem_avail, " (", mem_avail / 1024 / 1024, " MB)");
} }

View File

@ -60,6 +60,8 @@ class Genode::Synced_range_allocator : public Range_allocator
Guard operator () () { return _synced_object(); } Guard operator () () { return _synced_object(); }
Guard operator () () const { return _synced_object(); } Guard operator () () const { return _synced_object(); }
void print(Output &out) const { _synced_object()->print(out); }
/************************* /*************************
** Allocator interface ** ** Allocator interface **