mirror of
https://github.com/apache/nuttx.git
synced 2026-05-22 13:52:22 +08:00
gdb: optimize memory commands
Tested on a complex project, results are promising.
Command Time cost(s) Time saving(s) Peformance Boost
Before After
memleak 39.494172 22.366415 17.127757 1.8
memdump 41.872441 26.458386 15.414055 1.6
memdump -a 0x1234 28.116294 1.114119 27.002175 25.2
memdump --no-backtrace N/A 1.114119
memmap 7.973809 6.836468 1.137341 1.2
Signed-off-by: Xu Xingliang <xuxingliang@xiaomi.com>
This commit is contained in:
+432
-894
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -28,3 +28,10 @@ class ForeachPrefix(gdb.Command):
|
||||
|
||||
def __init__(self):
|
||||
super(ForeachPrefix, self).__init__("foreach", gdb.COMMAND_USER, prefix=True)
|
||||
|
||||
|
||||
class MMPrefixCommand(gdb.Command):
|
||||
"""Memory manager related commands prefix."""
|
||||
|
||||
def __init__(self):
|
||||
super().__init__("mm", gdb.COMMAND_USER, prefix=True)
|
||||
|
||||
@@ -0,0 +1,120 @@
|
||||
############################################################################
|
||||
# tools/gdb/nuttxgdb/protocols/mm.py
|
||||
#
|
||||
# Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
# contributor license agreements. See the NOTICE file distributed with
|
||||
# this work for additional information regarding copyright ownership. The
|
||||
# ASF licenses this file to you under the Apache License, Version 2.0 (the
|
||||
# "License"); you may not use this file except in compliance with the
|
||||
# License. You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
#
|
||||
############################################################################
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import List
|
||||
|
||||
from .value import Value
|
||||
|
||||
|
||||
class ProcfsMeminfoEntry(Value):
|
||||
"""struct procfs_meminfo_entry_s"""
|
||||
|
||||
name: Value
|
||||
heap: Value
|
||||
next: ProcfsMeminfoEntry
|
||||
|
||||
|
||||
class MMAllocNode(Value):
|
||||
"""struct mm_allocnode_s"""
|
||||
|
||||
preceding: Value
|
||||
size: Value
|
||||
pid: Value
|
||||
seqno: Value
|
||||
backtrace: Value
|
||||
|
||||
|
||||
class MMFreeNode(Value):
|
||||
"""struct mm_freenode_s"""
|
||||
|
||||
preceding: Value
|
||||
size: Value
|
||||
pid: Value
|
||||
seqno: Value
|
||||
backtrace: Value
|
||||
flink: MMFreeNode
|
||||
blink: MMFreeNode
|
||||
|
||||
|
||||
class MMHeap(Value):
|
||||
"""struct mm_heap_s"""
|
||||
|
||||
mm_lock: Value
|
||||
mm_heapsize: Value
|
||||
mm_maxused: Value
|
||||
mm_curused: Value
|
||||
mm_heapstart: List[MMAllocNode]
|
||||
mm_heapend: List[MMAllocNode]
|
||||
mm_nregions: Value
|
||||
mm_nodelist: Value
|
||||
|
||||
|
||||
class MemPool(Value):
|
||||
"""struct mempool_s"""
|
||||
|
||||
initialsize: Value
|
||||
interruptsize: Value
|
||||
expandsize: Value
|
||||
wait: Value
|
||||
priv: Value
|
||||
alloc: Value
|
||||
free: Value
|
||||
check: Value
|
||||
ibase: Value
|
||||
queue: Value
|
||||
iqueue: Value
|
||||
equeue: Value
|
||||
nalloc: Value
|
||||
lock: Value
|
||||
waitsem: Value
|
||||
procfs: Value
|
||||
|
||||
|
||||
class MemPoolMultiple(Value):
|
||||
"""struct mempool_multiple_s"""
|
||||
|
||||
pools: List[MemPool]
|
||||
npools: Value
|
||||
expandsize: Value
|
||||
minpoolsize: Value
|
||||
arg: Value
|
||||
alloc: Value
|
||||
alloc_size: Value
|
||||
free: Value
|
||||
alloced: Value
|
||||
delta: Value
|
||||
lock: Value
|
||||
chunk_queue: Value
|
||||
chunk_size: Value
|
||||
dict_used: Value
|
||||
dict_col_num_log2: Value
|
||||
dict_row_num: Value
|
||||
dict: Value
|
||||
|
||||
|
||||
class MemPoolBlock(Value):
|
||||
"""struct mempool_backtrace_s"""
|
||||
|
||||
magic: Value
|
||||
pid: Value
|
||||
seqno: Value
|
||||
backtrace: Value
|
||||
@@ -500,6 +500,13 @@ def parse_arg(arg: str) -> Union[gdb.Value, int]:
|
||||
return None
|
||||
|
||||
|
||||
def alias(name, command):
|
||||
try:
|
||||
gdb.execute(f"alias {name} = {command}")
|
||||
except gdb.error:
|
||||
pass
|
||||
|
||||
|
||||
def nitems(array):
|
||||
array_type = array.type
|
||||
element_type = array_type.target()
|
||||
|
||||
Reference in New Issue
Block a user