首页 > 其他分享 >crash —— 查看数据结构内部成员的偏移量和地址

crash —— 查看数据结构内部成员的偏移量和地址

时间:2023-09-24 10:55:05浏览次数:31  
标签:head crash struct union list unsigned long 偏移量 数据结构

whatis

如果提前知道数据类型的定义,可以直接用struct、union等,否则可以直接用whatis。

crash> whatis -o page
struct page {
   [0] unsigned long flags;
       union {
           struct {
               union {
   [8]             struct list_head lru;
                   struct {
   [8]                 void *__filler;
  [16]                 unsigned int mlock_count;
                   };
   [8]             struct list_head buddy_list;
   [8]             struct list_head pcp_list;
               };
  [24]         struct address_space *mapping;
               union {
  [32]             unsigned long index;
  [32]             unsigned long share;
               };
  [40]         unsigned long private;
           };
           struct {
   [8]         unsigned long pp_magic;
  [16]         struct page_pool *pp;
  [24]         unsigned long _pp_mapping_pad;
  [32]         unsigned long dma_addr;
               union {
  [40]             unsigned long dma_addr_upper;
  [40]             atomic_long_t pp_frag_count;
               };
           };
...
  [52] atomic_t _refcount;
  [56] unsigned long memcg_data;
}
SIZE: 64

struct

上面显示page是struct类型,那么也可以直接用struct,struct的输出格式更丰富,这里struct也可以用*代替。

crash> *page -xo
struct page {
   [0x0] unsigned long flags;
         union {
             struct {
                 union {
   [0x8]             struct list_head lru;
                     struct {
   [0x8]                 void *__filler;
  [0x10]                 unsigned int mlock_count;
                     };
   [0x8]             struct list_head buddy_list;
   [0x8]             struct list_head pcp_list;
                 };
  [0x18]         struct address_space *mapping;
                 union {
  [0x20]             unsigned long index;
  [0x20]             unsigned long share;
                 };
  [0x28]         unsigned long private;
             };
...
  [0x34] atomic_t _refcount;
  [0x38] unsigned long memcg_data;
}
SIZE: 0x40

上面显示的是结构体成员的的偏移,如果我们已经知道某个结构体变量的地址,那么可以可以用下面的方法获取其中每个成员的地址:

crash> *page -ox ffffea0000000440
struct page {
  [ffffea0000000440] unsigned long flags;
         union {
             struct {
                 union {
  [ffffea0000000448]             struct list_head lru;
                     struct {
  [ffffea0000000448]                 void *__filler;
  [ffffea0000000450]                 unsigned int mlock_count;
                     };
  [ffffea0000000448]             struct list_head buddy_list;
  [ffffea0000000448]             struct list_head pcp_list;
                 };
  [ffffea0000000458]         struct address_space *mapping;
                 union {
  [ffffea0000000460]             unsigned long index;
  [ffffea0000000460]             unsigned long share;
                 };
  [ffffea0000000468]         unsigned long private;
             };
...
  [ffffea0000000474] atomic_t _refcount;
  [ffffea0000000478] unsigned long memcg_data;
}
SIZE: 0x40

完。

标签:head,crash,struct,union,list,unsigned,long,偏移量,数据结构
From: https://www.cnblogs.com/pengdonglin137/p/17725710.html

相关文章

  • crash —— 如何查看数据是什么类型以及函数原型
    在crash中可以用whatis命令查看数据类型信息以及函数的原型。如果想知道某个数据是什么类型那么可以用下面的方法:查看结构体的定义crash>whatismm_structstructmm_struct{struct{structmaple_treemm_mt;unsignedlong(*get_unmapped_area)(str......
  • crash —— 获取系统的磁盘IO统计数据
    crash的dev命令可以获取系统磁盘IO的统计数据。获取所有磁盘的IO统计数据crash>dev-dMAJORGENDISKNAMEREQUEST_QUEUETOTALASYNCSYNC8ffff88de95d51000sdmffff88de94a90000653791776636038ffff88deb2396800sd......
  • crash —— 如何获取IO port和IO memory使用情况
    在linux中通过/proc/ioport和/proc/iomem可以获取系统的IO端口和内存的布局信息,在crash中需要使用dev命令来获取。crash>dev-iRESOURCERANGENAMEffffffff822668c00000-ffffPCIIOffff88deafffd5a00000-0cf7PCIBus0000:00ffffffff822407000000-......
  • crash —— 如何查看PCI设备拓扑?
    在linux系统上用lspci可以查看PCI设备信息,crash的dev命令也提供了这个功能。crash>dev-pROOTBUSBUSNAMEffff893eaeb430000000:00PCIDEVDO:BU:SL.FNCLASSPCI_IDTYPEffff88deaf8130000000:00:00.006008086:2020ROOT_PORTffff......
  • crash —— 如何获取某个系统调用入口代码?
    通过sys命令可以获取当前系统的系统调用的信息:crash>sys-cNUMSYSTEMCALLFILEANDLINENUMBER0__x64_sys_read../fs/read_write.c:6211__x64_sys_write../fs/read_write.c:6462__x64_sys_open../f......
  • crash —— 查看内核配置
    在编译内核时如果配置了CONFIG_IKCONFIG,那么内核配置文件会被内嵌到内核中,那么可以通过crash工具将其输出出来。crash>sysconfig##Automaticallygeneratedfile;DONOTEDIT.#Linux/x864.18.0KernelConfiguration###Compiler:gcc(Ubuntu5.4.0-6ubuntu1~16.04.......
  • crash工具使用 —— 查看DMI信息
    在linux上一般通过dmidecode来获取DMI信息,crash也提供了获取DMI信息的命令,不过内容不会像dmidecode那么详细。crash>sys-iDMI_BIOS_VENDOR:SeaBIOSDMI_BIOS_VERSION:rel-1.14.0-0-g155821a1990b-prebuilt.qemu.orgDMI_BIOS_DATE:04/01/20......
  • crash工具使用 —— 省去输入struct或者union关键字
    使用crash工具根据地址查看结构体的内容时,有时需要输入struct或者union,多少有些繁琐,crash提供了*命令,直接跟在结构体或者联合体的名字的前面即可。示例:带structcrash>structkmem_cache-xffff893751f60800structkmem_cache{cpu_slab=0x5fc135c77b40,flags=......
  • crash工具学习 —— percpu相关的一些用法
    作者[email protected]查看percpu变量在每个cpu上的基地址crash>kmem-oPER-CPUOFFSETVALUES:CPU0:ffff88807f600000CPU1:ffff88807fa00000CPU2:ffff88813d600000CPU3:ffff88813da00000CPU4:ffff8881bd600000CPU5:ffff8881bda00000C......
  • 【Java 基础篇】Java LinkedList 详解:数据结构的灵活伙伴
    在Java编程中,数据结构起着至关重要的作用。这些数据结构可以帮助我们组织和管理数据,使我们的代码更加高效和可维护。其中之一是LinkedList,它是一个灵活的数据结构,允许我们高效地进行插入和删除操作。本篇博客将深入探讨Java中的LinkedList,从基础概念到高级用法,为您呈现全面的......