scripts/gdb/linux/mapletree.py
Source file repositories/reference/linux-study-clean/scripts/gdb/linux/mapletree.py
File Facts
- System
- Linux kernel
- Corpus path
scripts/gdb/linux/mapletree.py- Extension
.py- Size
- 7337 bytes
- Lines
- 253
- Domain
- Support Tooling And Documentation
- Bucket
- scripts
- Inferred role
- Support Tooling And Documentation: scripts
- Status
- atlas-only
Why This File Exists
Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.
- Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
- No C-style include directives detected by the generator.
Detected Declarations
- No top-level syscall, struct, function, initcall, or export declaration detected by the generator.
Annotated Snippet
# SPDX-License-Identifier: GPL-2.0
#
# Maple tree helpers
#
# Copyright (c) 2025 Broadcom
#
# Authors:
# Florian Fainelli <florian.fainelli@broadcom.com>
import gdb
from linux import utils
from linux import constants
from linux import xarray
maple_tree_root_type = utils.CachedType("struct maple_tree")
maple_node_type = utils.CachedType("struct maple_node")
maple_enode_type = utils.CachedType("void")
maple_dense = 0
maple_leaf_64 = 1
maple_range_64 = 2
maple_arange_64 = 3
class Mas(object):
ma_active = 0
ma_start = 1
ma_root = 2
ma_none = 3
ma_pause = 4
ma_overflow = 5
ma_underflow = 6
ma_error = 7
def __init__(self, mt, first, end):
if mt.type == maple_tree_root_type.get_type().pointer():
self.tree = mt.dereference()
elif mt.type != maple_tree_root_type.get_type():
raise gdb.GdbError("must be {} not {}"
.format(maple_tree_root_type.get_type().pointer(), mt.type))
self.tree = mt
self.index = first
self.last = end
self.node = None
self.status = self.ma_start
self.min = 0
self.max = -1
def is_start(self):
# mas_is_start()
return self.status == self.ma_start
def is_ptr(self):
# mas_is_ptr()
return self.status == self.ma_root
def is_none(self):
# mas_is_none()
return self.status == self.ma_none
def root(self):
# mas_root()
return self.tree['ma_root'].cast(maple_enode_type.get_type().pointer())
def start(self):
# mas_start()
if self.is_start() is False:
return None
self.min = 0
Annotation
- Atlas domain: Support Tooling And Documentation / scripts.
- Implementation status: atlas-only.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.