gdb/memdump: add option to exclude nodes from specific PID

This is useful to exclude memory nodes for mempool.

E.g.

(gdb) mm dump --nob --top 5 --sort size --nop --no-pid -1
  Pool          CNT          PID         Size  Overhead          Seqno            Address Backtrace
     H            1            0     16777264        44             13         0x41a79010
     H            2          160      1536048        44     1129827490         0x41d6aad0
     H            1        45374      1536176        44     1129829080         0x45ef1010
     H            3          141       408440        44         145817         0x43905bf0
     H            7          158       131120        44          32955         0x4308d090
Total 14 blks, 23528696 bytes
(gdb) mm dump --nob --top 5 --sort size --nop
  Pool          CNT          PID         Size  Overhead          Seqno            Address Backtrace
     H            1            0     16777264        44             13         0x41a79010
*    H            6           -1      1048640        44         116954         0x436a0fd0
*    H            5           -1      1048640        44         146821         0x43b24fd0
*    H            3           -1      1048640        44          66161         0x4335bfd0
*    H            3           -1      1048640        44         156337         0x43d3ffd0
Total 18 blks, 16777264 bytes

Signed-off-by: xuxingliang <xuxingliang@xiaomi.com>
This commit is contained in:
xuxingliang 2024-11-21 20:49:21 +08:00 • committed by Xiang Xiao
parent f849092ede
commit ee9673f62e

View file

@ -286,6 +286,9 @@ class MMDump(gdb.Command):
action="store_true",
help="Do not reverse the sort result",
)
parser.add_argument(
"--no-pid", type=int, default=None, help="Exclude nodes from this PID"
)
# add option to sort the node by size or count
parser.add_argument(
@ -368,6 +371,7 @@ class MMDump(gdb.Command):
"orphan": args.orphan,
"no_heap": args.no_heap,
"no_pool": args.no_pool,
"no_pid": args.no_pid,
}
nodes = self.collect_nodes(args.heap, log=args.log, filters=filters)