Skip to content

Commit

Permalink
Add printing vm_map to kdump
Browse files Browse the repository at this point in the history
  • Loading branch information
franciscozdo committed May 22, 2021
1 parent 4adc5b6 commit f0787c5
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 9 deletions.
4 changes: 2 additions & 2 deletions sys/debug/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ you can use following custom commands:

* `free_pages` - list of free pages per segment with virtual and physical
addresses,
* `segments` - list all memory segments, incl. start, end addresses and
number of pages (currently just one),
* `vm_map` - list memory map of process of given pid (when number is given as argument)
or of current process (when no argument is given)
* `klog` - all log messages currently saved in the kernel,
* `threads` - all existing threads,
* `tlb` - Translation Lookaside Buffer with addresses and flags marking if page
Expand Down
3 changes: 3 additions & 0 deletions sys/debug/proc.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ def __repr__(self):
def address(self):
return self._obj.address

def vm_map(self):
return self._obj['p_uspace']


class Kprocess(SimpleCommand):
"""List all processes."""
Expand Down
21 changes: 14 additions & 7 deletions sys/debug/virtmem.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from .cmd import UserCommand
from .cpu import TLBLo
from .utils import TextTable, global_var, cast
from .proc import Process


PM_NQUEUES = 16
Expand Down Expand Up @@ -81,13 +82,19 @@ def __init__(self):

def __call__(self, args):
args = args.strip()
if args not in ['user', 'kernel']:
print('Choose either "user" or "kernel" vm_map!')
return
vm_map = gdb.parse_and_eval('vm_map_%s()' % args)
if vm_map == 0:
print('No active %s vm_map!' % args)
return
if len(args) == 0:
vm_map = gdb.parse_and_eval('vm_map_user()')
if vm_map == 0:
print('No active user vm_map!')
return
else:
pid = int(args)
proc = Process.from_pid(pid)
if proc is None:
print(f'No process of pid {pid}!')
return
vm_map = proc.vm_map()

entries = vm_map['entries']
table = TextTable(types='itttttt', align='rrrrrrr')
table.header(['segment', 'start', 'end', 'prot', 'flags', 'object',
Expand Down

0 comments on commit f0787c5

Please sign in to comment.