Mentions légales du service

Skip to content
Snippets Groups Projects
Commit b47c7ce2 authored by Kevin Pouget's avatar Kevin Pouget
Browse files

start working on heap remapping

parent 6b68a34e
No related branches found
No related tags found
No related merge requests found
...@@ -151,9 +151,36 @@ class cmd_numa(gdb.Command): ...@@ -151,9 +151,36 @@ class cmd_numa(gdb.Command):
if args: if args:
gdb.execute("numa {}".format(args)) gdb.execute("numa {}".format(args))
def size_fmt(num, suffix='B'):
for unit in ['','Ki','Mi','Gi','Ti','Pi','Ei','Zi']:
if abs(num) < 1024.0:
return "%3.0f%s%s" % (num, unit, suffix)
num /= 1024.0
return "%.0f%s%s" % (num, 'Yi', suffix)
class cmd_numa_spread_pages(gdb.Command):
def __init__ (self):
gdb.Command.__init__ (self, "numa spread_pages", gdb.COMMAND_NONE)
def invoke (self, args, from_tty):
if gdb.selected_inferior().pid == 0:
log_user.error("No PID for this inferior. Is it running?")
return
with open("/proc/{}/maps".format(gdb.selected_inferior().pid)) as fmap:
# search for "00601000-00622000 rw-p 00000000 00:00 0 [heap]"
for line in fmap.readlines():
if "heap" in line: break
start, stop = line.split(" ")[0].split("-")
start, stop = int(start, 16), int(stop, 16)
size = size_fmt(stop - start)
log_user.info("Process heap goes from {} to {} (={})".format(hex(start), hex(stop), size))
def on_activated(): def on_activated():
cmd_numa_current_node() cmd_numa_current_node()
cmd_numa_pagemap() cmd_numa_pagemap()
cmd_numa_current_node_by_call() cmd_numa_current_node_by_call()
cmd_numa_spread_pages()
def initialize(): def initialize():
cmd_numa() cmd_numa()
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment