1 /* 1 /* 2 * gdb helper commands and functions for Linux 2 * gdb helper commands and functions for Linux kernel debugging 3 * 3 * 4 * Kernel constants derived from include file 4 * Kernel constants derived from include files. 5 * 5 * 6 * Copyright (c) 2016 Linaro Ltd 6 * Copyright (c) 2016 Linaro Ltd 7 * 7 * 8 * Authors: 8 * Authors: 9 * Kieran Bingham <kieran.bingham@linaro.org> 9 * Kieran Bingham <kieran.bingham@linaro.org> 10 * 10 * 11 * This work is licensed under the terms of th 11 * This work is licensed under the terms of the GNU GPL version 2. 12 * 12 * 13 */ 13 */ 14 14 15 #include <linux/clk-provider.h> 15 #include <linux/clk-provider.h> 16 #include <linux/fs.h> 16 #include <linux/fs.h> 17 #include <linux/hrtimer.h> 17 #include <linux/hrtimer.h> 18 #include <linux/irq.h> 18 #include <linux/irq.h> 19 #include <linux/mount.h> 19 #include <linux/mount.h> 20 #include <linux/of_fdt.h> 20 #include <linux/of_fdt.h> 21 #include <linux/page_ext.h> << 22 #include <linux/radix-tree.h> 21 #include <linux/radix-tree.h> 23 #include <linux/slab.h> << 24 #include <linux/threads.h> 22 #include <linux/threads.h> 25 #include <linux/vmalloc.h> << 26 23 27 /* We need to stringify expanded macros so tha 24 /* We need to stringify expanded macros so that they can be parsed */ 28 25 29 #define STRING(x) #x 26 #define STRING(x) #x 30 #define XSTRING(x) STRING(x) 27 #define XSTRING(x) STRING(x) 31 28 32 #define LX_VALUE(x) LX_##x = x 29 #define LX_VALUE(x) LX_##x = x 33 #define LX_GDBPARSED(x) LX_##x = gdb.parse_and 30 #define LX_GDBPARSED(x) LX_##x = gdb.parse_and_eval(XSTRING(x)) 34 31 35 /* 32 /* 36 * IS_ENABLED generates (a || b) which is not 33 * IS_ENABLED generates (a || b) which is not compatible with python 37 * We can only switch on configuration items w 34 * We can only switch on configuration items we know are available 38 * Therefore - IS_BUILTIN() is more appropriat 35 * Therefore - IS_BUILTIN() is more appropriate 39 */ 36 */ 40 #define LX_CONFIG(x) LX_##x = IS_BUILTIN(x) 37 #define LX_CONFIG(x) LX_##x = IS_BUILTIN(x) 41 38 42 /* The build system will take care of deleting 39 /* The build system will take care of deleting everything above this marker */ 43 <!-- end-c-headers --> 40 <!-- end-c-headers --> 44 41 45 import gdb 42 import gdb 46 43 47 LX_CONFIG(CONFIG_DEBUG_INFO_REDUCED) 44 LX_CONFIG(CONFIG_DEBUG_INFO_REDUCED) 48 45 49 /* linux/clk-provider.h */ 46 /* linux/clk-provider.h */ 50 if IS_BUILTIN(CONFIG_COMMON_CLK): 47 if IS_BUILTIN(CONFIG_COMMON_CLK): 51 LX_GDBPARSED(CLK_GET_RATE_NOCACHE) 48 LX_GDBPARSED(CLK_GET_RATE_NOCACHE) 52 49 53 /* linux/fs.h */ 50 /* linux/fs.h */ 54 LX_GDBPARSED(SB_RDONLY) 51 LX_GDBPARSED(SB_RDONLY) 55 LX_GDBPARSED(SB_SYNCHRONOUS) 52 LX_GDBPARSED(SB_SYNCHRONOUS) 56 LX_GDBPARSED(SB_MANDLOCK) 53 LX_GDBPARSED(SB_MANDLOCK) 57 LX_GDBPARSED(SB_DIRSYNC) 54 LX_GDBPARSED(SB_DIRSYNC) 58 LX_GDBPARSED(SB_NOATIME) 55 LX_GDBPARSED(SB_NOATIME) 59 LX_GDBPARSED(SB_NODIRATIME) 56 LX_GDBPARSED(SB_NODIRATIME) 60 57 61 /* linux/htimer.h */ 58 /* linux/htimer.h */ 62 LX_GDBPARSED(hrtimer_resolution) 59 LX_GDBPARSED(hrtimer_resolution) 63 60 64 /* linux/irq.h */ 61 /* linux/irq.h */ 65 LX_GDBPARSED(IRQD_LEVEL) 62 LX_GDBPARSED(IRQD_LEVEL) 66 LX_GDBPARSED(IRQ_HIDDEN) 63 LX_GDBPARSED(IRQ_HIDDEN) 67 64 68 /* linux/module.h */ 65 /* linux/module.h */ 69 if IS_BUILTIN(CONFIG_MODULES): 66 if IS_BUILTIN(CONFIG_MODULES): 70 LX_GDBPARSED(MOD_TEXT) 67 LX_GDBPARSED(MOD_TEXT) 71 LX_GDBPARSED(MOD_DATA) 68 LX_GDBPARSED(MOD_DATA) 72 LX_GDBPARSED(MOD_RODATA) 69 LX_GDBPARSED(MOD_RODATA) 73 LX_GDBPARSED(MOD_RO_AFTER_INIT) 70 LX_GDBPARSED(MOD_RO_AFTER_INIT) 74 71 75 /* linux/mount.h */ 72 /* linux/mount.h */ 76 LX_VALUE(MNT_NOSUID) 73 LX_VALUE(MNT_NOSUID) 77 LX_VALUE(MNT_NODEV) 74 LX_VALUE(MNT_NODEV) 78 LX_VALUE(MNT_NOEXEC) 75 LX_VALUE(MNT_NOEXEC) 79 LX_VALUE(MNT_NOATIME) 76 LX_VALUE(MNT_NOATIME) 80 LX_VALUE(MNT_NODIRATIME) 77 LX_VALUE(MNT_NODIRATIME) 81 LX_VALUE(MNT_RELATIME) 78 LX_VALUE(MNT_RELATIME) 82 79 83 /* linux/threads.h */ 80 /* linux/threads.h */ 84 LX_VALUE(NR_CPUS) 81 LX_VALUE(NR_CPUS) 85 82 86 /* linux/of_fdt.h> */ 83 /* linux/of_fdt.h> */ 87 LX_VALUE(OF_DT_HEADER) 84 LX_VALUE(OF_DT_HEADER) 88 85 89 /* linux/radix-tree.h */ 86 /* linux/radix-tree.h */ 90 LX_GDBPARSED(RADIX_TREE_ENTRY_MASK) 87 LX_GDBPARSED(RADIX_TREE_ENTRY_MASK) 91 LX_GDBPARSED(RADIX_TREE_INTERNAL_NODE) 88 LX_GDBPARSED(RADIX_TREE_INTERNAL_NODE) 92 LX_GDBPARSED(RADIX_TREE_MAP_SIZE) 89 LX_GDBPARSED(RADIX_TREE_MAP_SIZE) 93 LX_GDBPARSED(RADIX_TREE_MAP_SHIFT) 90 LX_GDBPARSED(RADIX_TREE_MAP_SHIFT) 94 LX_GDBPARSED(RADIX_TREE_MAP_MASK) 91 LX_GDBPARSED(RADIX_TREE_MAP_MASK) 95 92 96 /* linux/vmalloc.h */ << 97 LX_VALUE(VM_IOREMAP) << 98 LX_VALUE(VM_ALLOC) << 99 LX_VALUE(VM_MAP) << 100 LX_VALUE(VM_USERMAP) << 101 LX_VALUE(VM_DMA_COHERENT) << 102 << 103 /* linux/page_ext.h */ << 104 if IS_BUILTIN(CONFIG_PAGE_OWNER): << 105 LX_GDBPARSED(PAGE_EXT_OWNER) << 106 LX_GDBPARSED(PAGE_EXT_OWNER_ALLOCATED) << 107 << 108 /* linux/slab.h */ << 109 LX_GDBPARSED(SLAB_RED_ZONE) << 110 LX_GDBPARSED(SLAB_POISON) << 111 LX_GDBPARSED(SLAB_KMALLOC) << 112 LX_GDBPARSED(SLAB_HWCACHE_ALIGN) << 113 LX_GDBPARSED(SLAB_CACHE_DMA) << 114 LX_GDBPARSED(SLAB_CACHE_DMA32) << 115 LX_GDBPARSED(SLAB_STORE_USER) << 116 LX_GDBPARSED(SLAB_PANIC) << 117 << 118 /* Kernel Configs */ 93 /* Kernel Configs */ 119 LX_CONFIG(CONFIG_GENERIC_CLOCKEVENTS) 94 LX_CONFIG(CONFIG_GENERIC_CLOCKEVENTS) 120 LX_CONFIG(CONFIG_GENERIC_CLOCKEVENTS_BROADCAST 95 LX_CONFIG(CONFIG_GENERIC_CLOCKEVENTS_BROADCAST) 121 LX_CONFIG(CONFIG_HIGH_RES_TIMERS) 96 LX_CONFIG(CONFIG_HIGH_RES_TIMERS) 122 LX_CONFIG(CONFIG_NR_CPUS) 97 LX_CONFIG(CONFIG_NR_CPUS) 123 LX_CONFIG(CONFIG_OF) 98 LX_CONFIG(CONFIG_OF) 124 LX_CONFIG(CONFIG_TICK_ONESHOT) 99 LX_CONFIG(CONFIG_TICK_ONESHOT) 125 LX_CONFIG(CONFIG_GENERIC_IRQ_SHOW_LEVEL) 100 LX_CONFIG(CONFIG_GENERIC_IRQ_SHOW_LEVEL) 126 LX_CONFIG(CONFIG_X86_LOCAL_APIC) 101 LX_CONFIG(CONFIG_X86_LOCAL_APIC) 127 LX_CONFIG(CONFIG_SMP) 102 LX_CONFIG(CONFIG_SMP) 128 LX_CONFIG(CONFIG_X86_THERMAL_VECTOR) 103 LX_CONFIG(CONFIG_X86_THERMAL_VECTOR) 129 LX_CONFIG(CONFIG_X86_MCE_THRESHOLD) 104 LX_CONFIG(CONFIG_X86_MCE_THRESHOLD) 130 LX_CONFIG(CONFIG_X86_MCE_AMD) 105 LX_CONFIG(CONFIG_X86_MCE_AMD) 131 LX_CONFIG(CONFIG_X86_MCE) 106 LX_CONFIG(CONFIG_X86_MCE) 132 LX_CONFIG(CONFIG_X86_IO_APIC) 107 LX_CONFIG(CONFIG_X86_IO_APIC) 133 /* !! 108 LX_CONFIG(CONFIG_HAVE_KVM) 134 * CONFIG_KVM can be "m" but it affects common << 135 * as a proxy for IS_ENABLED(CONFIG_KVM). << 136 */ << 137 LX_CONFIG_KVM = IS_BUILTIN(CONFIG_KVM_COMMON) << 138 LX_CONFIG(CONFIG_NUMA) << 139 LX_CONFIG(CONFIG_ARM64) << 140 LX_CONFIG(CONFIG_ARM64_4K_PAGES) << 141 LX_CONFIG(CONFIG_ARM64_16K_PAGES) << 142 LX_CONFIG(CONFIG_ARM64_64K_PAGES) << 143 if IS_BUILTIN(CONFIG_ARM64): << 144 LX_VALUE(CONFIG_ARM64_PA_BITS) << 145 LX_VALUE(CONFIG_ARM64_VA_BITS) << 146 LX_VALUE(CONFIG_PAGE_SHIFT) << 147 LX_VALUE(CONFIG_ARCH_FORCE_MAX_ORDER) << 148 LX_CONFIG(CONFIG_SPARSEMEM) << 149 LX_CONFIG(CONFIG_SPARSEMEM_EXTREME) << 150 LX_CONFIG(CONFIG_SPARSEMEM_VMEMMAP) << 151 LX_CONFIG(CONFIG_KASAN) << 152 LX_CONFIG(CONFIG_KASAN_GENERIC) << 153 LX_CONFIG(CONFIG_KASAN_SW_TAGS) << 154 LX_CONFIG(CONFIG_KASAN_HW_TAGS) << 155 if IS_BUILTIN(CONFIG_KASAN_GENERIC) or IS_BUIL << 156 LX_VALUE(CONFIG_KASAN_SHADOW_OFFSET) << 157 LX_CONFIG(CONFIG_VMAP_STACK) << 158 if IS_BUILTIN(CONFIG_NUMA): << 159 LX_VALUE(CONFIG_NODES_SHIFT) << 160 LX_CONFIG(CONFIG_DEBUG_VIRTUAL) << 161 LX_CONFIG(CONFIG_STACKDEPOT) << 162 LX_CONFIG(CONFIG_PAGE_OWNER) << 163 LX_CONFIG(CONFIG_SLUB_DEBUG) << 164 LX_CONFIG(CONFIG_SLAB_FREELIST_HARDENED) << 165 LX_CONFIG(CONFIG_MMU) <<
Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.