/* memory.c - core analysis suite
*
* Copyright (C) 1999, 2000, 2001, 2002 Mission Critical Linux, Inc.
* Copyright (C) 2002-2019 David Anderson
* Copyright (C) 2002-2019 Red Hat, Inc. All rights reserved.
* Copyright (C) 2002 Silicon Graphics, Inc.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/
#include "defs.h"
#include <sys/mman.h>
#include <ctype.h>
#include <netinet/in.h>
#include <byteswap.h>
#include "maple_tree.h"
struct meminfo { /* general purpose memory information structure */
ulong cache; /* used by the various memory searching/dumping */
ulong slab; /* routines. Only one of these is used per cmd */
ulong c_flags; /* so stuff whatever's helpful in here... */
ulong c_offset;
ulong c_num;
ulong s_mem;
void *s_freep;
ulong *s_index;
ulong s_inuse;
ulong cpucached_cache;
ulong cpucached_slab;
ulong inuse;
ulong order;
ulong slabsize;
ulong num_slabs;
ulong objects;
ulonglong spec_addr;
ulong flags;
ulong size;
ulong objsize;
int memtype;
int free;
int slab_offset;
char *reqname;
char *curname;
ulong *spec_cpumask;
ulong *addrlist;
int *kmem_bufctl;
ulong *cpudata[NR_CPUS];
ulong *shared_array_cache;
int current_cache_index;
ulong found;
ulong retval;
struct struct_member_data *page_member_cache;
ulong nr_members;
char *ignore;
int errors;
int calls;
int cpu;
int cache_count;
ulong get_shared;
ulong get_totalram;
ulong get_buffers;
ulong get_slabs;
char *slab_buf;
char *cache_buf;
ulong *cache_list;
struct vmlist {
ulong addr;
ulong size;
} *vmlist;
ulong container;
int *freelist;
int freelist_index_size;
ulong random;
ulong list_offset;
};
/*
* Search modes
*/
#define SEARCH_ULONG (0)
#define SEARCH_UINT (1)
#define SEARCH_USHORT (2)
#define SEARCH_CHARS (3)
#define SEARCH_DEFAULT (SEARCH_ULONG)
/* search mode information */
struct searchinfo {
int mode;
int vcnt;
int val;
int context;
int memtype;
int do_task_header;
int tasks_found;
struct task_context *task_context;
ulong vaddr_start;
ulong vaddr_end;
ulonglong paddr_start;
ulonglong paddr_end;
union {
/* default ulong search */
struct {
ulong value[MAXARGS];
char *opt_string[MAXARGS];
ulong mask;
} s_ulong;
/* uint search */
struct {
uint value[MAXARGS];
char *opt_string[MAXARGS];
uint mask;
} s_uint;
/* ushort search */
struct {
ushort value[MAXARGS];
char *opt_string[MAXARGS];
ushort mask;
} s_ushort;
/* string (chars) search */
struct {
char *value[MAXARGS];
int len[MAXARGS];
int started_flag; /* string search needs history */
} s_chars;
} s_parms;
char buf[BUFSIZE];
};
struct handle_each_vm_area_args {
ulong task;
ulong flag;
ulong vaddr;
struct reference *ref;
char *vma_header;
char *buf1;
char *buf2;
char *buf3;
char *buf4;
char *buf5;
ulong vma;
char **vma_buf;
struct task_mem_usage *tm;
int *found;
int *single_vma_found;
unsigned int radix;
struct task_context *tc;
ulong *single_vma;
};
static char *memtype_string(int, int);
static char *error_handle_string(ulong);
static void collect_page_member_data(char *, struct meminfo *);
struct integer_data {
ulong value;
ulong bitfield_value;
struct struct_member_data *pmd;
};
static int get_bitfield_data(struct integer_data *);
static int show_page_member_data(char *, ulong, struct meminfo *, char *);
static void dump_mem_map(struct meminfo *);
static void dump_mem_map_SPARSEMEM(struct meminfo *);
static void fill_mem_map_cache(ulong, ulong, char *);
static void page_flags_init(void);
static int page_flags_init_from_pageflag_names(void);
static int page_flags_init_from_pageflags_enum(void);
static int translate_page_flags(char *, ulong);
static void dump_free_pages(struct meminfo *);
static int dump_zone_page_usage(void);
static void dump_multidimensional_free_pages(struct meminfo *);
static void dump_free_pages_zones_v1(struct meminfo *);
static void dump_free_pages_zones_v2(struct meminfo *);
struct free_page_callback_data;
static int dump_zone_free_area(ulong, int, ulong, struct free_page_callback_data *);
static void dump_page_hash_table(struct meminfo *);
static void kmem_search(struct meminfo *);
static void kmem_cache_init(void);
static void kmem_cache_init_slub(void);
static ulong max_cpudata_limit(ulong, ulong *);
static int kmem_cache_downsize(void);
static int ignore_cache(struct meminfo *, char *);
static char *is_kmem_cache_addr(ulong, char *);
static char *is_kmem_cache_addr_common(ulong, char *);
static void kmem_cache_list(struct meminfo *);
static void dump_kmem_cache(struct meminfo *);
static void dump_kmem_cache_percpu_v1(struct meminfo *);
static void dump_kmem_cache_percpu_v2(struct meminfo *);
static void dump_kmem_cache_slub(struct meminfo *);
static void kmem_cache_list_common(struct meminfo *);
static ulong get_cpu_slab_ptr(struct meminfo *, int, ulong *);
static unsigned int oo_order(ulong);
static unsigned int oo_objects(ulong);
static char *vaddr_to_kmem_cache(ulong, char *, int);
static char *is_slab_overload_page(ulong, ulong *, char *);
static ulong vaddr_to_slab(ulong);
static void do_slab_chain(int, struct meminfo *);
static void do_slab_chain_percpu_v1(long, struct meminfo *);
static void do_slab_chain_percpu_v2(long, struct meminfo *);
static void do_slab_chain_percpu_v2_nodes(long, struct meminfo *);
static void do_slab_chain_slab_overload_page(long, struct meminfo *);
static int slab_freelist_index_size(void);
static int do_slab_slub(struct meminfo *, int);
static void do_kmem_cache_slub(struct meminfo *);
static void save_slab_data(struct meminfo *);
static int slab_data_saved(struct meminfo *);
static void dump_saved_slab_data(void);
static void dump_slab(struct meminfo *);
static void dump_slab_percpu_v1(struct meminfo *);
static void dump_slab_percpu_v2(struct meminfo *);
static void dump_slab_overload_page(struct meminfo *);
static int verify_slab_v1(struct meminfo *, ulong, int);
static int verify_slab_v2(struct meminfo *, ulong, int);
static int verify_slab_overload_page(struct meminfo *, ulong, int);
static void gather_slab_free_list(struct meminfo *);
static void gather_slab_free_list_percpu(struct meminfo *);
static void gather_slab_free_list_slab_overload_page(struct meminfo *);
static void gather_cpudata_list_v1(struct meminfo *);
static void gather_cpudata_list_v2(struct meminfo *);
static void gather_cpudata_list_v2_nodes(struct meminfo *, int);
static int check_cpudata_list(struct meminfo *, ulong);
static int check_shared_list(struct meminfo *, ulong);
static void gather_slab_cached_count(struct meminfo *);
static void dump_slab_objects(struct meminfo *);
static void dump_slab_objects_percpu(struct meminfo *);
static void dump_vmlist(struct meminfo *);
static void dump_vmap_area(struct meminfo *);
static int dump_page_lists(struct meminfo *);
static void dump_kmeminfo(void);
static int page_to_phys(ulong, physaddr_t *);
static void display_memory(ulonglong, long, ulong, int, void *);
static char *show_opt_string(struct searchinfo *);
static void display_with_pre_and_post(void *, ulonglong, struct searchinfo *);
static ulong search_ulong(ulong *, ulong, int, struct searchinfo *);
static ulong search_uint(ulong *, ulong, int, struct searchinfo *);
static ulong search_ushort(ulong *, ulong, int, struct searchinfo *);
static ulong search_chars(ulong *, ulong, int, struct searchinfo *);
static ulonglong search_ulong_p(ulong *, ulonglong, int, struct searchinfo *);
stat
没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
收起资源包目录
crash源码github可以下载 (116个子文件)
crash.8 23KB
memory.c 552KB
help.c 427KB
symbols.c 421KB
kernel.c 328KB
task.c 291KB
x86_64.c 277KB
tools.c 173KB
x86.c 161KB
dev.c 152KB
netdump.c 148KB
arm64.c 142KB
lkcd_x86_trace.c 138KB
ia64.c 125KB
filesys.c 115KB
ppc64.c 108KB
remote.c 104KB
diskdump.c 90KB
unwind.c 82KB
xendump.c 76KB
alpha.c 75KB
xen_hyper.c 63KB
cmdline.c 62KB
main.c 61KB
s390x.c 60KB
ppc.c 56KB
riscv64.c 52KB
configure.c 52KB
net.c 50KB
arm.c 47KB
xen_hyper_command.c 46KB
sadump.c 44KB
dminfo.c 42KB
bpf.c 39KB
xen_hyper_dump_tables.c 38KB
loongarch64.c 37KB
mips64.c 37KB
lkcd_common.c 36KB
s390dbf.c 35KB
unwind_x86_32_64.c 33KB
s390.c 32KB
mips.c 32KB
ipcs.c 32KB
sparc64.c 31KB
kvmdump.c 31KB
gdb_interface.c 29KB
vmware_vmss.c 26KB
qemu-load.c 26KB
snap.c 20KB
lkcd_v8.c 19KB
unwind_arm.c 19KB
kaslr_helper.c 19KB
sbitmap.c 19KB
maple_tree.c 17KB
lkcd_v2_v3.c 15KB
lkcd_v7.c 15KB
extensions.c 14KB
xen_hyper_global_data.c 14KB
unwind_decoder.c 13KB
lkcd_v5.c 13KB
va_server.c 10KB
va_server_v1.c 9KB
makedumpfile.c 9KB
printk.c 9KB
ramdump.c 9KB
lkcd_v1.c 9KB
vmware_guestdump.c 9KB
qemu.c 8KB
crash.c 8KB
xen_dom0.c 7KB
global_data.c 6KB
crash_target.c 4KB
echo.c 3KB
test.c 2KB
lkcd_fix_mem.c 2KB
s390_dump.c 2KB
eppic.c 139B
COPYING3 34KB
.gitignore 304B
defs.h 242KB
xen_hyper_defs.h 30KB
unwind.h 22KB
lkcd_x86_trace.h 20KB
lkcd_dump_v8.h 16KB
lkcd_dump_v7.h 14KB
lkcd_fix_mem.h 11KB
lkcd_dump_v5.h 9KB
lkcd_vmdump_v2_v3.h 7KB
unwind_i.h 6KB
sadump.h 6KB
lkcd_vmdump_v1.h 5KB
qemu-load.h 5KB
xendump.h 5KB
vmware_vmss.h 5KB
vas_crash.h 4KB
diskdump.h 4KB
netdump.h 4KB
ibm_common.h 4KB
unwind_x86_64.h 3KB
kvmdump.h 2KB
共 116 条
- 1
- 2
资源评论
鑫鑫缺点金
- 粉丝: 1441
- 资源: 41
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- Java项目-基于SSM+Vue的汽车售票网站的设计与实现(源码+数据库脚本+部署视频+代码讲解视频+全套软件)
- Java项目-基于SSM+Jsp的大型商场会员管理系统的设计与实现(源码+数据库脚本+部署视频+代码讲解视频+全套软件)
- 小米长条音响app,支持手机控制长条音响和低音炮
- Java项目-基于SSM+Vue的高校实验室管理系统的设计与实现(源码+数据库脚本+部署视频+代码讲解视频+全套软件)
- IMG_20240917_194445.jpg
- Java项目-基于SSM+Jsp的校园快递一站式服务系统的设计与实现(源码+数据库脚本+部署视频+代码讲解视频+全套软件)
- docker基础概念的简化理解
- Java项目-基于SSM+Jsp的学生信息管理系统的设计与实现(源码+数据库脚本+部署视频+代码讲解视频+全套软件)
- mamba相关torch环境
- Java项目-基于SSM+Jsp的彩妆小样售卖商城的设计与实现(源码+数据库脚本+部署视频+代码讲解视频+全套软件)
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功