__ __ __ __ _____ _ _ _____ _ _ _ | \/ | \ \ / / | __ \ (_) | | / ____| | | | | | \ / |_ __\ V / | |__) | __ ___ ____ _| |_ ___ | (___ | |__ ___| | | | |\/| | '__|> < | ___/ '__| \ \ / / _` | __/ _ \ \___ \| '_ \ / _ \ | | | | | | |_ / . \ | | | | | |\ V / (_| | || __/ ____) | | | | __/ | | |_| |_|_(_)_/ \_\ |_| |_| |_| \_/ \__,_|\__\___| |_____/|_| |_|\___V 2.1 if you need WebShell for Seo everyday contact me on Telegram Telegram Address : @jackleetFor_More_Tools:
# SPDX-License-Identifier: GPL-2.0
#
# Copyright 2019 Google LLC.
import gdb
from linux import utils
rb_root_type = utils.CachedType("struct rb_root")
rb_node_type = utils.CachedType("struct rb_node")
def rb_inorder_for_each(root):
def inorder(node):
if node:
yield from inorder(node['rb_left'])
yield node
yield from inorder(node['rb_right'])
yield from inorder(root['rb_node'])
def rb_inorder_for_each_entry(root, gdbtype, member):
for node in rb_inorder_for_each(root):
yield utils.container_of(node, gdbtype, member)
def rb_first(root):
if root.type == rb_root_type.get_type():
node = root.address.cast(rb_root_type.get_type().pointer())
elif root.type != rb_root_type.get_type().pointer():
raise gdb.GdbError("Must be struct rb_root not {}".format(root.type))
node = root['rb_node']
if node == 0:
return None
while node['rb_left']:
node = node['rb_left']
return node
def rb_last(root):
if root.type == rb_root_type.get_type():
node = root.address.cast(rb_root_type.get_type().pointer())
elif root.type != rb_root_type.get_type().pointer():
raise gdb.GdbError("Must be struct rb_root not {}".format(root.type))
node = root['rb_node']
if node == 0:
return None
while node['rb_right']:
node = node['rb_right']
return node
def rb_parent(node):
parent = gdb.Value(node['__rb_parent_color'] & ~3)
return parent.cast(rb_node_type.get_type().pointer())
def rb_empty_node(node):
return node['__rb_parent_color'] == node.address
def rb_next(node):
if node.type == rb_node_type.get_type():
node = node.address.cast(rb_node_type.get_type().pointer())
elif node.type != rb_node_type.get_type().pointer():
raise gdb.GdbError("Must be struct rb_node not {}".format(node.type))
if rb_empty_node(node):
return None
if node['rb_right']:
node = node['rb_right']
while node['rb_left']:
node = node['rb_left']
return node
parent = rb_parent(node)
while parent and node == parent['rb_right']:
node = parent
parent = rb_parent(node)
return parent
def rb_prev(node):
if node.type == rb_node_type.get_type():
node = node.address.cast(rb_node_type.get_type().pointer())
elif node.type != rb_node_type.get_type().pointer():
raise gdb.GdbError("Must be struct rb_node not {}".format(node.type))
if rb_empty_node(node):
return None
if node['rb_left']:
node = node['rb_left']
while node['rb_right']:
node = node['rb_right']
return node.dereference()
parent = rb_parent(node)
while parent and node == parent['rb_left'].dereference():
node = parent
parent = rb_parent(node)
return parent
class LxRbFirst(gdb.Function):
"""Lookup and return a node from an RBTree
$lx_rb_first(root): Return the node at the given index.
If index is omitted, the root node is dereferenced and returned."""
def __init__(self):
super(LxRbFirst, self).__init__("lx_rb_first")
def invoke(self, root):
result = rb_first(root)
if result is None:
raise gdb.GdbError("No entry in tree")
return result
LxRbFirst()
class LxRbLast(gdb.Function):
"""Lookup and return a node from an RBTree.
$lx_rb_last(root): Return the node at the given index.
If index is omitted, the root node is dereferenced and returned."""
def __init__(self):
super(LxRbLast, self).__init__("lx_rb_last")
def invoke(self, root):
result = rb_last(root)
if result is None:
raise gdb.GdbError("No entry in tree")
return result
LxRbLast()
class LxRbNext(gdb.Function):
"""Lookup and return a node from an RBTree.
$lx_rb_next(node): Return the node at the given index.
If index is omitted, the root node is dereferenced and returned."""
def __init__(self):
super(LxRbNext, self).__init__("lx_rb_next")
def invoke(self, node):
result = rb_next(node)
if result is None:
raise gdb.GdbError("No entry in tree")
return result
LxRbNext()
class LxRbPrev(gdb.Function):
"""Lookup and return a node from an RBTree.
$lx_rb_prev(node): Return the node at the given index.
If index is omitted, the root node is dereferenced and returned."""
def __init__(self):
super(LxRbPrev, self).__init__("lx_rb_prev")
def invoke(self, node):
result = rb_prev(node)
if result is None:
raise gdb.GdbError("No entry in tree")
return result
LxRbPrev()
| Name | Type | Size | Permission | Actions |
|---|---|---|---|---|
| .gitignore | File | 65 B | 0644 |
|
| Makefile | File | 634 B | 0644 |
|
| __init__.py | File | 55 B | 0644 |
|
| clk.py | File | 2.57 KB | 0644 |
|
| config.py | File | 1.3 KB | 0644 |
|
| constants.py.in | File | 4.39 KB | 0644 |
|
| cpus.py | File | 6.05 KB | 0644 |
|
| device.py | File | 5.66 KB | 0644 |
|
| dmesg.py | File | 5.69 KB | 0644 |
|
| genpd.py | File | 2.65 KB | 0644 |
|
| interrupts.py | File | 7.67 KB | 0644 |
|
| kasan.py | File | 1.38 KB | 0644 |
|
| lists.py | File | 4.16 KB | 0644 |
|
| mapletree.py | File | 7.17 KB | 0644 |
|
| mm.py | File | 13.98 KB | 0644 |
|
| modules.py | File | 3.92 KB | 0644 |
|
| page_owner.py | File | 6.83 KB | 0644 |
|
| pgtable.py | File | 10.08 KB | 0644 |
|
| proc.py | File | 8.58 KB | 0644 |
|
| radixtree.py | File | 2.46 KB | 0644 |
|
| rbtree.py | File | 4.62 KB | 0644 |
|
| slab.py | File | 11.27 KB | 0644 |
|
| stackdepot.py | File | 2.62 KB | 0644 |
|
| symbols.py | File | 7.32 KB | 0644 |
|
| tasks.py | File | 3.17 KB | 0644 |
|
| timerlist.py | File | 7.86 KB | 0644 |
|
| utils.py | File | 5.87 KB | 0644 |
|
| vfs.py | File | 1.42 KB | 0644 |
|
| vmalloc.py | File | 2.33 KB | 0644 |
|
| xarray.py | File | 636 B | 0644 |
|