2015-02-17 21:46:36 +00:00
|
|
|
#
|
|
|
|
# gdb helper commands and functions for Linux kernel debugging
|
|
|
|
#
|
|
|
|
# loader module
|
|
|
|
#
|
|
|
|
# Copyright (c) Siemens AG, 2012, 2013
|
|
|
|
#
|
|
|
|
# Authors:
|
|
|
|
# Jan Kiszka <jan.kiszka@siemens.com>
|
|
|
|
#
|
|
|
|
# This work is licensed under the terms of the GNU GPL version 2.
|
|
|
|
#
|
|
|
|
|
|
|
|
import os
|
|
|
|
|
2022-07-12 11:02:48 +00:00
|
|
|
sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)) + "/scripts/gdb")
|
2015-02-17 21:46:36 +00:00
|
|
|
|
|
|
|
try:
|
|
|
|
gdb.parse_and_eval("0")
|
|
|
|
gdb.execute("", to_string=True)
|
|
|
|
except:
|
|
|
|
gdb.write("NOTE: gdb 7.2 or later required for Linux helper scripts to "
|
|
|
|
"work.\n")
|
2015-02-17 21:46:41 +00:00
|
|
|
else:
|
2023-04-06 21:52:51 +00:00
|
|
|
import linux.constants
|
|
|
|
if linux.constants.LX_CONFIG_DEBUG_INFO_REDUCED:
|
|
|
|
raise gdb.GdbError("Reduced debug information will prevent GDB "
|
|
|
|
"from having complete types.\n")
|
2015-02-17 21:46:41 +00:00
|
|
|
import linux.utils
|
2015-02-17 21:46:47 +00:00
|
|
|
import linux.symbols
|
2015-02-17 21:46:55 +00:00
|
|
|
import linux.modules
|
2015-02-17 21:47:04 +00:00
|
|
|
import linux.dmesg
|
2015-02-17 21:47:10 +00:00
|
|
|
import linux.tasks
|
2019-05-14 22:45:53 +00:00
|
|
|
import linux.config
|
2015-02-17 21:47:21 +00:00
|
|
|
import linux.cpus
|
2015-06-30 21:58:07 +00:00
|
|
|
import linux.lists
|
2019-05-14 22:45:56 +00:00
|
|
|
import linux.rbtree
|
2016-03-22 21:27:33 +00:00
|
|
|
import linux.proc
|
2019-05-14 22:45:59 +00:00
|
|
|
import linux.timerlist
|
2019-05-14 22:46:08 +00:00
|
|
|
import linux.clk
|
2019-07-16 23:30:12 +00:00
|
|
|
import linux.genpd
|
2019-07-16 23:30:15 +00:00
|
|
|
import linux.device
|
2023-03-01 00:53:34 +00:00
|
|
|
import linux.vfs
|
2023-08-08 08:30:14 +00:00
|
|
|
import linux.pgtable
|
2023-04-04 21:40:49 +00:00
|
|
|
import linux.radixtree
|
2023-04-06 22:04:51 +00:00
|
|
|
import linux.interrupts
|
2023-08-08 08:30:14 +00:00
|
|
|
import linux.mm
|
2023-08-08 08:30:15 +00:00
|
|
|
import linux.stackdepot
|
scripts/gdb/page_owner: add page owner support
This GDB script prints page owner information for user to analyze the
memory usage or memory corruption issue.
Example output from an aarch64 system:
(gdb) lx-dump-page-owner --pfn 655360
page_owner tracks the page as allocated
Page last allocated via order 0, gfp_mask: 0x8, pid: 1, tgid: 1 ("swapper/0\000\000\000\000\000\000"), ts 1295948880 ns, free_ts 1011852016 ns
PFN: 655360, Flags: 0x3fffc0000000000
0xffff8000086ab964 <post_alloc_hook+452>: ldp x19, x20, [sp, #16]
0xffff80000862e4e0 <split_map_pages+344>: cbnz w22, 0xffff80000862e57c <split_map_pages+500>
0xffff8000086370c4 <isolate_freepages_range+556>: mov x0, x27
0xffff8000086bc1cc <alloc_contig_range+808>: mov x24, x0
0xffff80000877d6d8 <cma_alloc+772>: mov w1, w0
0xffff8000082c8d18 <dma_alloc_from_contiguous+104>: ldr x19, [sp, #16]
0xffff8000082ce0e8 <atomic_pool_expand+208>: mov x19, x0
0xffff80000c1e41b4 <__dma_atomic_pool_init+172>: Cannot access memory at address 0xffff80000c1e41b4
0xffff80000c1e4298 <dma_atomic_pool_init+92>: Cannot access memory at address 0xffff80000c1e4298
0xffff8000080161d4 <do_one_initcall+176>: mov w21, w0
0xffff80000c1c1b50 <kernel_init_freeable+952>: Cannot access memory at address 0xffff80000c1c1b50
0xffff80000acf87dc <kernel_init+36>: bl 0xffff8000081ab100 <async_synchronize_full>
0xffff800008018d00 <ret_from_fork+16>: mrs x28, sp_el0
page last free stack trace:
0xffff8000086a6e8c <free_unref_page_prepare+796>: mov w2, w23
0xffff8000086aee1c <free_unref_page+96>: tst w0, #0xff
0xffff8000086af3f8 <__free_pages+292>: ldp x19, x20, [sp, #16]
0xffff80000c1f3214 <init_cma_reserved_pageblock+220>: Cannot access memory at address 0xffff80000c1f3214
0xffff80000c20363c <cma_init_reserved_areas+1284>: Cannot access memory at address 0xffff80000c20363c
0xffff8000080161d4 <do_one_initcall+176>: mov w21, w0
0xffff80000c1c1b50 <kernel_init_freeable+952>: Cannot access memory at address 0xffff80000c1c1b50
0xffff80000acf87dc <kernel_init+36>: bl 0xffff8000081ab100 <async_synchronize_full>
0xffff800008018d00 <ret_from_fork+16>: mrs x28, sp_el0
Link: https://lkml.kernel.org/r/20230808083020.22254-7-Kuan-Ying.Lee@mediatek.com
Signed-off-by: Kuan-Ying Lee <Kuan-Ying.Lee@mediatek.com>
Cc: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
Cc: Chinwen Chang <chinwen.chang@mediatek.com>
Cc: Matthias Brugger <matthias.bgg@gmail.com>
Cc: Qun-Wei Lin <qun-wei.lin@mediatek.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
2023-08-08 08:30:16 +00:00
|
|
|
import linux.page_owner
|
2023-08-08 08:30:17 +00:00
|
|
|
import linux.slab
|
2023-08-08 08:30:18 +00:00
|
|
|
import linux.vmalloc
|