# -*- Mode: python; coding: utf-8; indent-tabs-mode: nil -*- */
#
# This file is part of systemd.
#
# Copyright 2014 Michal Schmidt
#
# under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation; either version 2.1 of the License, or
# (at your option) any later version.
#
# systemd is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with systemd; If not, see <http://www.gnu.org/licenses/>.
import gdb
"dump systemd's hashmaps"
print "type, hash, indirect, entries, max_entries, buckets, creator"
while d:
if h["has_indirect"]:
else:
n_entries = h["n_direct_entries"]
print "%s, %s, %s, %d, %d, %d, %s (%s:%d)" % (t, h["hash_ops"], bool(h["has_indirect"]), n_entries, d["max_entries"], n_buckets, d["func"], d["file"], d["line"])
histogram = {}
if dib != 255:
else:
print "mean DIB of entries: %f" % (sum([dib*histogram[dib] for dib in iter(histogram) if dib != 255])*1.0/n_entries)
blocks = []
current_len = 1
if prev != 255:
blocks += [[i, current_len]]
current_len = 1
else:
current_len += 1
if prev != 255:
blocks += [[i, current_len]]
# a block may be wrapped around
d = d["debug_list_next"]