chiark / gitweb /
tree-wide: drop copyright headers from frequent contributors
[elogind.git] / tools / gdb-sd_dump_hashmaps.py
old mode 100644 (file)
new mode 100755 (executable)
index 9ee81fb..27572be
@@ -1,26 +1,11 @@
+#!/usr/bin/env python3
 #  -*- Mode: python; coding: utf-8; indent-tabs-mode: nil -*- */
-#
-#  This file is part of systemd.
-#
-#  Copyright 2014 Michal Schmidt
-#
-#  systemd is free software; you can redistribute it and/or modify it
-#  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/>.
+# SPDX-License-Identifier: LGPL-2.1+
 
 import gdb
 
 class sd_dump_hashmaps(gdb.Command):
-        "dump systemd's hashmaps"
+        "dump elogind's hashmaps"
 
         def __init__(self):
                 super(sd_dump_hashmaps, self).__init__("sd_dump_hashmaps", gdb.COMMAND_DATA, gdb.COMPLETE_NONE)
@@ -49,7 +34,7 @@ class sd_dump_hashmaps(gdb.Command):
 
                         t = ["plain", "ordered", "set"][int(h["type"])]
 
-                        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"])
+                        print "{}, {}, {}, {}, {}, {}, {} ({}:{})".format(t, h["hash_ops"], bool(h["has_indirect"]), n_entries, d["max_entries"], n_buckets, d["func"], d["file"], d["line"])
 
                         if arg != "" and n_entries > 0:
                                 dib_raw_addr = storage_ptr + (all_entry_sizes[h["type"]] * n_buckets)
@@ -61,10 +46,10 @@ class sd_dump_hashmaps(gdb.Command):
 
                                 for dib in sorted(iter(histogram)):
                                         if dib != 255:
-                                                print "%3d %8d %f%% of entries" % (dib, histogram[dib], 100.0*histogram[dib]/n_entries)
+                                                print "{:>3} {:>8} {} of entries".format(dib, histogram[dib], 100.0*histogram[dib]/n_entries)
                                         else:
-                                                print "%3d %8d %f%% of slots" % (dib, histogram[dib], 100.0*histogram[dib]/n_buckets)
-                                print "mean DIB of entries: %f" % (sum([dib*histogram[dib] for dib in iter(histogram) if dib != 255])*1.0/n_entries)
+                                                print "{:>3} {:>8} {} of slots".format(dib, histogram[dib], 100.0*histogram[dib]/n_buckets)
+                                print "mean DIB of entries: {}".format(sum([dib*histogram[dib] for dib in iter(histogram) if dib != 255])*1.0/n_entries)
 
                                 blocks = []
                                 current_len = 1
@@ -85,9 +70,9 @@ class sd_dump_hashmaps(gdb.Command):
                                 if len(blocks) > 1 and blocks[0][0] == blocks[0][1] and blocks[-1][0] == n_buckets - 1:
                                         blocks[0][1] += blocks[-1][1]
                                         blocks = blocks[0:-1]
-                                print "max block: %s" % max(blocks, key=lambda a: a[1])
-                                print "sum block lens: %d" % sum(b[1] for b in blocks)
-                                print "mean block len: %f" % (1.0 * sum(b[1] for b in blocks) / len(blocks))
+                                print "max block: {}".format(max(blocks, key=lambda a: a[1]))
+                                print "sum block lens: {}".format(sum(b[1] for b in blocks))
+                                print "mean block len: {}".format((1.0 * sum(b[1] for b in blocks) / len(blocks)))
 
                         d = d["debug_list_next"]