mirror of
https://github.com/genodelabs/genode.git
synced 2025-06-21 00:23:16 +00:00
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:
committed by
Christian Helmuth
parent
1542d92165
commit
e1ec39e476
@ -1,58 +1,37 @@
|
||||
/*
|
||||
* \brief Allocator dump helpers
|
||||
* \brief Allocator AVL dump
|
||||
* \author Norman Feske
|
||||
* \author Stefan Kalkowski
|
||||
* \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
|
||||
* under the terms of the GNU General Public License version 2.
|
||||
*/
|
||||
|
||||
#include <base/log.h>
|
||||
#include <base/allocator_avl.h>
|
||||
|
||||
using namespace Genode;
|
||||
|
||||
|
||||
void Allocator_avl_base::Block::dump()
|
||||
void Genode::Allocator_avl_base::print(Genode::Output & out) const
|
||||
{
|
||||
log(" Block: [", Hex(addr()), ",", Hex(addr() + size()), "] ",
|
||||
"size=", Hex(size()), " avail=", Hex(avail()), " ",
|
||||
"max_avail=", Hex(max_avail()));
|
||||
}
|
||||
|
||||
|
||||
void Allocator_avl_base::dump_addr_tree(Block *addr_node)
|
||||
{
|
||||
bool top = false;
|
||||
static unsigned long mem_size;
|
||||
static unsigned long mem_avail;
|
||||
|
||||
if (addr_node == 0) {
|
||||
addr_node = _addr_tree.first();
|
||||
|
||||
log("Allocator ", this, " dump:");
|
||||
mem_size = mem_avail = 0;
|
||||
top = true;
|
||||
}
|
||||
|
||||
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)");
|
||||
using Genode::print;
|
||||
unsigned long mem_size = 0;
|
||||
unsigned long mem_avail = 0;
|
||||
|
||||
print(out, "Allocator ", this, " dump:\n");
|
||||
|
||||
_addr_tree.for_each([&] (Block const & b)
|
||||
{
|
||||
print(out, " Block: [", Hex(b.addr()), ",", Hex(b.addr() + b.size()),
|
||||
"] ", "size=", Hex(b.size()), " avail=", Hex(b.avail()), " ",
|
||||
"max_avail=", Hex(b.max_avail()), "\n");
|
||||
mem_size += b.size();
|
||||
mem_avail += b.avail();
|
||||
});
|
||||
|
||||
print(out, " => mem_size=", mem_size, " (", mem_size / 1024 / 1024 ,
|
||||
" MB) / mem_avail=" , mem_avail , " (" , mem_avail / 1024 / 1024 ,
|
||||
" MB)\n");
|
||||
}
|
||||
|
@ -60,6 +60,8 @@ class Genode::Synced_range_allocator : public Range_allocator
|
||||
Guard operator () () { return _synced_object(); }
|
||||
Guard operator () () const { return _synced_object(); }
|
||||
|
||||
void print(Output &out) const { _synced_object()->print(out); }
|
||||
|
||||
|
||||
/*************************
|
||||
** Allocator interface **
|
||||
|
Reference in New Issue
Block a user