|
DistroBaker |
7d0122 |
From c617ec63339222f3a44d73e36677a9acc8954ccd Mon Sep 17 00:00:00 2001
|
|
DistroBaker |
7d0122 |
From: John Ogness <john.ogness@linutronix.de>
|
|
DistroBaker |
7d0122 |
Date: Thu, 19 Nov 2020 02:41:21 +0000
|
|
DistroBaker |
7d0122 |
Subject: [PATCH 1/2] [PATCH 1/2] printk: add support for lockless ringbuffer
|
|
DistroBaker |
7d0122 |
|
|
DistroBaker |
7d0122 |
* Required for kernel 5.10
|
|
DistroBaker |
7d0122 |
|
|
DistroBaker |
7d0122 |
Linux 5.10 introduces a new lockless ringbuffer. The new ringbuffer
|
|
DistroBaker |
7d0122 |
is structured completely different to the previous iterations.
|
|
DistroBaker |
7d0122 |
Add support for retrieving the ringbuffer from debug information
|
|
DistroBaker |
7d0122 |
and/or using vmcoreinfo. The new ringbuffer is detected based on
|
|
DistroBaker |
7d0122 |
the availability of the "prb" symbol.
|
|
DistroBaker |
7d0122 |
|
|
DistroBaker |
7d0122 |
Signed-off-by: John Ogness <john.ogness@linutronix.de>
|
|
DistroBaker |
7d0122 |
Signed-off-by: Kazuhito Hagio <k-hagio-ab@nec.com>
|
|
DistroBaker |
7d0122 |
---
|
|
DistroBaker |
7d0122 |
Makefile | 2 +-
|
|
DistroBaker |
7d0122 |
dwarf_info.c | 36 ++++++++-
|
|
DistroBaker |
7d0122 |
makedumpfile.c | 103 +++++++++++++++++++++++-
|
|
DistroBaker |
7d0122 |
makedumpfile.h | 58 ++++++++++++++
|
|
DistroBaker |
7d0122 |
printk.c | 207 +++++++++++++++++++++++++++++++++++++++++++++++++
|
|
DistroBaker |
7d0122 |
5 files changed, 399 insertions(+), 7 deletions(-)
|
|
DistroBaker |
7d0122 |
create mode 100644 printk.c
|
|
DistroBaker |
7d0122 |
|
|
DistroBaker |
7d0122 |
diff --git a/makedumpfile-1.6.8/Makefile b/makedumpfile-1.6.8/Makefile
|
|
DistroBaker |
7d0122 |
index e5ac71a..cb6bd42 100644
|
|
DistroBaker |
7d0122 |
--- a/makedumpfile-1.6.8/Makefile
|
|
DistroBaker |
7d0122 |
+++ b/makedumpfile-1.6.8/Makefile
|
|
DistroBaker |
7d0122 |
@@ -45,7 +45,7 @@ CFLAGS_ARCH += -m32
|
|
DistroBaker |
7d0122 |
endif
|
|
DistroBaker |
7d0122 |
|
|
DistroBaker |
7d0122 |
SRC_BASE = makedumpfile.c makedumpfile.h diskdump_mod.h sadump_mod.h sadump_info.h
|
|
DistroBaker |
7d0122 |
-SRC_PART = print_info.c dwarf_info.c elf_info.c erase_info.c sadump_info.c cache.c tools.c
|
|
DistroBaker |
7d0122 |
+SRC_PART = print_info.c dwarf_info.c elf_info.c erase_info.c sadump_info.c cache.c tools.c printk.c
|
|
DistroBaker |
7d0122 |
OBJ_PART=$(patsubst %.c,%.o,$(SRC_PART))
|
|
DistroBaker |
7d0122 |
SRC_ARCH = arch/arm.c arch/arm64.c arch/x86.c arch/x86_64.c arch/ia64.c arch/ppc64.c arch/s390x.c arch/ppc.c arch/sparc64.c
|
|
DistroBaker |
7d0122 |
OBJ_ARCH=$(patsubst %.c,%.o,$(SRC_ARCH))
|
|
DistroBaker |
7d0122 |
diff --git a/makedumpfile-1.6.8/dwarf_info.c b/makedumpfile-1.6.8/dwarf_info.c
|
|
DistroBaker |
7d0122 |
index e42a9f5..543588b 100644
|
|
DistroBaker |
7d0122 |
--- a/makedumpfile-1.6.8/dwarf_info.c
|
|
DistroBaker |
7d0122 |
+++ b/makedumpfile-1.6.8/dwarf_info.c
|
|
DistroBaker |
7d0122 |
@@ -614,6 +614,7 @@ search_structure(Dwarf_Die *die, int *found)
|
|
DistroBaker |
7d0122 |
{
|
|
DistroBaker |
7d0122 |
int tag;
|
|
DistroBaker |
7d0122 |
const char *name;
|
|
DistroBaker |
7d0122 |
+ Dwarf_Die die_type;
|
|
DistroBaker |
7d0122 |
|
|
DistroBaker |
7d0122 |
/*
|
|
DistroBaker |
7d0122 |
* If we get to here then we don't have any more
|
|
DistroBaker |
7d0122 |
@@ -622,9 +623,31 @@ search_structure(Dwarf_Die *die, int *found)
|
|
DistroBaker |
7d0122 |
do {
|
|
DistroBaker |
7d0122 |
tag = dwarf_tag(die);
|
|
DistroBaker |
7d0122 |
name = dwarf_diename(die);
|
|
DistroBaker |
7d0122 |
- if ((tag != DW_TAG_structure_type) || (!name)
|
|
DistroBaker |
7d0122 |
- || strcmp(name, dwarf_info.struct_name))
|
|
DistroBaker |
7d0122 |
+ if ((!name) || strcmp(name, dwarf_info.struct_name))
|
|
DistroBaker |
7d0122 |
+ continue;
|
|
DistroBaker |
7d0122 |
+
|
|
DistroBaker |
7d0122 |
+ if (tag == DW_TAG_typedef) {
|
|
DistroBaker |
7d0122 |
+ if (!get_die_type(die, &die_type)) {
|
|
DistroBaker |
7d0122 |
+ ERRMSG("Can't get CU die of DW_AT_type.\n");
|
|
DistroBaker |
7d0122 |
+ break;
|
|
DistroBaker |
7d0122 |
+ }
|
|
DistroBaker |
7d0122 |
+
|
|
DistroBaker |
7d0122 |
+ /* Resolve typedefs of typedefs. */
|
|
DistroBaker |
7d0122 |
+ while ((tag = dwarf_tag(&die_type)) == DW_TAG_typedef) {
|
|
DistroBaker |
7d0122 |
+ if (!get_die_type(&die_type, &die_type)) {
|
|
DistroBaker |
7d0122 |
+ ERRMSG("Can't get CU die of DW_AT_type.\n");
|
|
DistroBaker |
7d0122 |
+ return;
|
|
DistroBaker |
7d0122 |
+ }
|
|
DistroBaker |
7d0122 |
+ }
|
|
DistroBaker |
7d0122 |
+
|
|
DistroBaker |
7d0122 |
+ if (tag != DW_TAG_structure_type)
|
|
DistroBaker |
7d0122 |
+ continue;
|
|
DistroBaker |
7d0122 |
+ die = &die_type;
|
|
DistroBaker |
7d0122 |
+
|
|
DistroBaker |
7d0122 |
+ } else if (tag != DW_TAG_structure_type) {
|
|
DistroBaker |
7d0122 |
continue;
|
|
DistroBaker |
7d0122 |
+ }
|
|
DistroBaker |
7d0122 |
+
|
|
DistroBaker |
7d0122 |
/*
|
|
DistroBaker |
7d0122 |
* Skip if DW_AT_byte_size is not included.
|
|
DistroBaker |
7d0122 |
*/
|
|
DistroBaker |
7d0122 |
@@ -740,6 +763,15 @@ search_typedef(Dwarf_Die *die, int *found)
|
|
DistroBaker |
7d0122 |
ERRMSG("Can't get CU die of DW_AT_type.\n");
|
|
DistroBaker |
7d0122 |
break;
|
|
DistroBaker |
7d0122 |
}
|
|
DistroBaker |
7d0122 |
+
|
|
DistroBaker |
7d0122 |
+ /* Resolve typedefs of typedefs. */
|
|
DistroBaker |
7d0122 |
+ while ((tag = dwarf_tag(&die_type)) == DW_TAG_typedef) {
|
|
DistroBaker |
7d0122 |
+ if (!get_die_type(&die_type, &die_type)) {
|
|
DistroBaker |
7d0122 |
+ ERRMSG("Can't get CU die of DW_AT_type.\n");
|
|
DistroBaker |
7d0122 |
+ return;
|
|
DistroBaker |
7d0122 |
+ }
|
|
DistroBaker |
7d0122 |
+ }
|
|
DistroBaker |
7d0122 |
+
|
|
DistroBaker |
7d0122 |
dwarf_info.struct_size = dwarf_bytesize(&die_type);
|
|
DistroBaker |
7d0122 |
if (dwarf_info.struct_size <= 0)
|
|
DistroBaker |
7d0122 |
continue;
|
|
DistroBaker |
7d0122 |
diff --git a/makedumpfile-1.6.8/makedumpfile.c b/makedumpfile-1.6.8/makedumpfile.c
|
|
DistroBaker |
7d0122 |
index cdde040..061741f 100644
|
|
DistroBaker |
7d0122 |
--- a/makedumpfile-1.6.8/makedumpfile.c
|
|
DistroBaker |
7d0122 |
+++ b/makedumpfile-1.6.8/makedumpfile.c
|
|
DistroBaker |
7d0122 |
@@ -1555,6 +1555,7 @@ get_symbol_info(void)
|
|
DistroBaker |
7d0122 |
SYMBOL_INIT(node_data, "node_data");
|
|
DistroBaker |
7d0122 |
SYMBOL_INIT(pgdat_list, "pgdat_list");
|
|
DistroBaker |
7d0122 |
SYMBOL_INIT(contig_page_data, "contig_page_data");
|
|
DistroBaker |
7d0122 |
+ SYMBOL_INIT(prb, "prb");
|
|
DistroBaker |
7d0122 |
SYMBOL_INIT(log_buf, "log_buf");
|
|
DistroBaker |
7d0122 |
SYMBOL_INIT(log_buf_len, "log_buf_len");
|
|
DistroBaker |
7d0122 |
SYMBOL_INIT(log_end, "log_end");
|
|
DistroBaker |
7d0122 |
@@ -1971,16 +1972,47 @@ get_structure_info(void)
|
|
DistroBaker |
7d0122 |
OFFSET_INIT(elf64_phdr.p_memsz, "elf64_phdr", "p_memsz");
|
|
DistroBaker |
7d0122 |
|
|
DistroBaker |
7d0122 |
SIZE_INIT(printk_log, "printk_log");
|
|
DistroBaker |
7d0122 |
- if (SIZE(printk_log) != NOT_FOUND_STRUCTURE) {
|
|
DistroBaker |
7d0122 |
+ SIZE_INIT(printk_ringbuffer, "printk_ringbuffer");
|
|
DistroBaker |
7d0122 |
+ if ((SIZE(printk_ringbuffer) != NOT_FOUND_STRUCTURE)) {
|
|
DistroBaker |
7d0122 |
+ info->flag_use_printk_ringbuffer = TRUE;
|
|
DistroBaker |
7d0122 |
+ info->flag_use_printk_log = FALSE;
|
|
DistroBaker |
7d0122 |
+
|
|
DistroBaker |
7d0122 |
+ OFFSET_INIT(printk_ringbuffer.desc_ring, "printk_ringbuffer", "desc_ring");
|
|
DistroBaker |
7d0122 |
+ OFFSET_INIT(printk_ringbuffer.text_data_ring, "printk_ringbuffer", "text_data_ring");
|
|
DistroBaker |
7d0122 |
+
|
|
DistroBaker |
7d0122 |
+ OFFSET_INIT(prb_desc_ring.count_bits, "prb_desc_ring", "count_bits");
|
|
DistroBaker |
7d0122 |
+ OFFSET_INIT(prb_desc_ring.descs, "prb_desc_ring", "descs");
|
|
DistroBaker |
7d0122 |
+ OFFSET_INIT(prb_desc_ring.infos, "prb_desc_ring", "infos");
|
|
DistroBaker |
7d0122 |
+ OFFSET_INIT(prb_desc_ring.head_id, "prb_desc_ring", "head_id");
|
|
DistroBaker |
7d0122 |
+ OFFSET_INIT(prb_desc_ring.tail_id, "prb_desc_ring", "tail_id");
|
|
DistroBaker |
7d0122 |
+
|
|
DistroBaker |
7d0122 |
+ SIZE_INIT(prb_desc, "prb_desc");
|
|
DistroBaker |
7d0122 |
+ OFFSET_INIT(prb_desc.state_var, "prb_desc", "state_var");
|
|
DistroBaker |
7d0122 |
+ OFFSET_INIT(prb_desc.text_blk_lpos, "prb_desc", "text_blk_lpos");
|
|
DistroBaker |
7d0122 |
+
|
|
DistroBaker |
7d0122 |
+ OFFSET_INIT(prb_data_blk_lpos.begin, "prb_data_blk_lpos", "begin");
|
|
DistroBaker |
7d0122 |
+ OFFSET_INIT(prb_data_blk_lpos.next, "prb_data_blk_lpos", "next");
|
|
DistroBaker |
7d0122 |
+
|
|
DistroBaker |
7d0122 |
+ OFFSET_INIT(prb_data_ring.size_bits, "prb_data_ring", "size_bits");
|
|
DistroBaker |
7d0122 |
+ OFFSET_INIT(prb_data_ring.data, "prb_data_ring", "data");
|
|
DistroBaker |
7d0122 |
+
|
|
DistroBaker |
7d0122 |
+ SIZE_INIT(printk_info, "printk_info");
|
|
DistroBaker |
7d0122 |
+ OFFSET_INIT(printk_info.ts_nsec, "printk_info", "ts_nsec");
|
|
DistroBaker |
7d0122 |
+ OFFSET_INIT(printk_info.text_len, "printk_info", "text_len");
|
|
DistroBaker |
7d0122 |
+
|
|
DistroBaker |
7d0122 |
+ OFFSET_INIT(atomic_long_t.counter, "atomic_long_t", "counter");
|
|
DistroBaker |
7d0122 |
+ } else if (SIZE(printk_log) != NOT_FOUND_STRUCTURE) {
|
|
DistroBaker |
7d0122 |
/*
|
|
DistroBaker |
7d0122 |
* In kernel 3.11-rc4 the log structure name was renamed
|
|
DistroBaker |
7d0122 |
* to "printk_log".
|
|
DistroBaker |
7d0122 |
*/
|
|
DistroBaker |
7d0122 |
+ info->flag_use_printk_ringbuffer = FALSE;
|
|
DistroBaker |
7d0122 |
info->flag_use_printk_log = TRUE;
|
|
DistroBaker |
7d0122 |
OFFSET_INIT(printk_log.ts_nsec, "printk_log", "ts_nsec");
|
|
DistroBaker |
7d0122 |
OFFSET_INIT(printk_log.len, "printk_log", "len");
|
|
DistroBaker |
7d0122 |
OFFSET_INIT(printk_log.text_len, "printk_log", "text_len");
|
|
DistroBaker |
7d0122 |
} else {
|
|
DistroBaker |
7d0122 |
+ info->flag_use_printk_ringbuffer = FALSE;
|
|
DistroBaker |
7d0122 |
info->flag_use_printk_log = FALSE;
|
|
DistroBaker |
7d0122 |
SIZE_INIT(printk_log, "log");
|
|
DistroBaker |
7d0122 |
OFFSET_INIT(printk_log.ts_nsec, "log", "ts_nsec");
|
|
DistroBaker |
7d0122 |
@@ -2191,6 +2223,7 @@ write_vmcoreinfo_data(void)
|
|
DistroBaker |
7d0122 |
WRITE_SYMBOL("node_data", node_data);
|
|
DistroBaker |
7d0122 |
WRITE_SYMBOL("pgdat_list", pgdat_list);
|
|
DistroBaker |
7d0122 |
WRITE_SYMBOL("contig_page_data", contig_page_data);
|
|
DistroBaker |
7d0122 |
+ WRITE_SYMBOL("prb", prb);
|
|
DistroBaker |
7d0122 |
WRITE_SYMBOL("log_buf", log_buf);
|
|
DistroBaker |
7d0122 |
WRITE_SYMBOL("log_buf_len", log_buf_len);
|
|
DistroBaker |
7d0122 |
WRITE_SYMBOL("log_end", log_end);
|
|
DistroBaker |
7d0122 |
@@ -2222,7 +2255,11 @@ write_vmcoreinfo_data(void)
|
|
DistroBaker |
7d0122 |
WRITE_STRUCTURE_SIZE("node_memblk_s", node_memblk_s);
|
|
DistroBaker |
7d0122 |
WRITE_STRUCTURE_SIZE("nodemask_t", nodemask_t);
|
|
DistroBaker |
7d0122 |
WRITE_STRUCTURE_SIZE("pageflags", pageflags);
|
|
DistroBaker |
7d0122 |
- if (info->flag_use_printk_log)
|
|
DistroBaker |
7d0122 |
+ if (info->flag_use_printk_ringbuffer) {
|
|
DistroBaker |
7d0122 |
+ WRITE_STRUCTURE_SIZE("printk_ringbuffer", printk_ringbuffer);
|
|
DistroBaker |
7d0122 |
+ WRITE_STRUCTURE_SIZE("prb_desc", prb_desc);
|
|
DistroBaker |
7d0122 |
+ WRITE_STRUCTURE_SIZE("printk_info", printk_info);
|
|
DistroBaker |
7d0122 |
+ } else if (info->flag_use_printk_log)
|
|
DistroBaker |
7d0122 |
WRITE_STRUCTURE_SIZE("printk_log", printk_log);
|
|
DistroBaker |
7d0122 |
else
|
|
DistroBaker |
7d0122 |
WRITE_STRUCTURE_SIZE("log", printk_log);
|
|
DistroBaker |
7d0122 |
@@ -2268,7 +2305,30 @@ write_vmcoreinfo_data(void)
|
|
DistroBaker |
7d0122 |
WRITE_MEMBER_OFFSET("vm_struct.addr", vm_struct.addr);
|
|
DistroBaker |
7d0122 |
WRITE_MEMBER_OFFSET("vmap_area.va_start", vmap_area.va_start);
|
|
DistroBaker |
7d0122 |
WRITE_MEMBER_OFFSET("vmap_area.list", vmap_area.list);
|
|
DistroBaker |
7d0122 |
- if (info->flag_use_printk_log) {
|
|
DistroBaker |
7d0122 |
+ if (info->flag_use_printk_ringbuffer) {
|
|
DistroBaker |
7d0122 |
+ WRITE_MEMBER_OFFSET("printk_ringbuffer.desc_ring", printk_ringbuffer.desc_ring);
|
|
DistroBaker |
7d0122 |
+ WRITE_MEMBER_OFFSET("printk_ringbuffer.text_data_ring", printk_ringbuffer.text_data_ring);
|
|
DistroBaker |
7d0122 |
+
|
|
DistroBaker |
7d0122 |
+ WRITE_MEMBER_OFFSET("prb_desc_ring.count_bits", prb_desc_ring.count_bits);
|
|
DistroBaker |
7d0122 |
+ WRITE_MEMBER_OFFSET("prb_desc_ring.descs", prb_desc_ring.descs);
|
|
DistroBaker |
7d0122 |
+ WRITE_MEMBER_OFFSET("prb_desc_ring.infos", prb_desc_ring.infos);
|
|
DistroBaker |
7d0122 |
+ WRITE_MEMBER_OFFSET("prb_desc_ring.head_id", prb_desc_ring.head_id);
|
|
DistroBaker |
7d0122 |
+ WRITE_MEMBER_OFFSET("prb_desc_ring.tail_id", prb_desc_ring.tail_id);
|
|
DistroBaker |
7d0122 |
+
|
|
DistroBaker |
7d0122 |
+ WRITE_MEMBER_OFFSET("prb_desc.state_var", prb_desc.state_var);
|
|
DistroBaker |
7d0122 |
+ WRITE_MEMBER_OFFSET("prb_desc.text_blk_lpos", prb_desc.text_blk_lpos);
|
|
DistroBaker |
7d0122 |
+
|
|
DistroBaker |
7d0122 |
+ WRITE_MEMBER_OFFSET("prb_data_blk_lpos.begin", prb_data_blk_lpos.begin);
|
|
DistroBaker |
7d0122 |
+ WRITE_MEMBER_OFFSET("prb_data_blk_lpos.next", prb_data_blk_lpos.next);
|
|
DistroBaker |
7d0122 |
+
|
|
DistroBaker |
7d0122 |
+ WRITE_MEMBER_OFFSET("prb_data_ring.size_bits", prb_data_ring.size_bits);
|
|
DistroBaker |
7d0122 |
+ WRITE_MEMBER_OFFSET("prb_data_ring.data", prb_data_ring.data);
|
|
DistroBaker |
7d0122 |
+
|
|
DistroBaker |
7d0122 |
+ WRITE_MEMBER_OFFSET("printk_info.ts_nsec", printk_info.ts_nsec);
|
|
DistroBaker |
7d0122 |
+ WRITE_MEMBER_OFFSET("printk_info.text_len", printk_info.text_len);
|
|
DistroBaker |
7d0122 |
+
|
|
DistroBaker |
7d0122 |
+ WRITE_MEMBER_OFFSET("atomic_long_t.counter", atomic_long_t.counter);
|
|
DistroBaker |
7d0122 |
+ } else if (info->flag_use_printk_log) {
|
|
DistroBaker |
7d0122 |
WRITE_MEMBER_OFFSET("printk_log.ts_nsec", printk_log.ts_nsec);
|
|
DistroBaker |
7d0122 |
WRITE_MEMBER_OFFSET("printk_log.len", printk_log.len);
|
|
DistroBaker |
7d0122 |
WRITE_MEMBER_OFFSET("printk_log.text_len", printk_log.text_len);
|
|
DistroBaker |
7d0122 |
@@ -2606,6 +2666,7 @@ read_vmcoreinfo(void)
|
|
DistroBaker |
7d0122 |
READ_SYMBOL("node_data", node_data);
|
|
DistroBaker |
7d0122 |
READ_SYMBOL("pgdat_list", pgdat_list);
|
|
DistroBaker |
7d0122 |
READ_SYMBOL("contig_page_data", contig_page_data);
|
|
DistroBaker |
7d0122 |
+ READ_SYMBOL("prb", prb);
|
|
DistroBaker |
7d0122 |
READ_SYMBOL("log_buf", log_buf);
|
|
DistroBaker |
7d0122 |
READ_SYMBOL("log_buf_len", log_buf_len);
|
|
DistroBaker |
7d0122 |
READ_SYMBOL("log_end", log_end);
|
|
DistroBaker |
7d0122 |
@@ -2684,12 +2745,43 @@ read_vmcoreinfo(void)
|
|
DistroBaker |
7d0122 |
READ_MEMBER_OFFSET("cpu_spec.mmu_features", cpu_spec.mmu_features);
|
|
DistroBaker |
7d0122 |
|
|
DistroBaker |
7d0122 |
READ_STRUCTURE_SIZE("printk_log", printk_log);
|
|
DistroBaker |
7d0122 |
- if (SIZE(printk_log) != NOT_FOUND_STRUCTURE) {
|
|
DistroBaker |
7d0122 |
+ READ_STRUCTURE_SIZE("printk_ringbuffer", printk_ringbuffer);
|
|
DistroBaker |
7d0122 |
+ if (SIZE(printk_ringbuffer) != NOT_FOUND_STRUCTURE) {
|
|
DistroBaker |
7d0122 |
+ info->flag_use_printk_ringbuffer = TRUE;
|
|
DistroBaker |
7d0122 |
+ info->flag_use_printk_log = FALSE;
|
|
DistroBaker |
7d0122 |
+
|
|
DistroBaker |
7d0122 |
+ READ_MEMBER_OFFSET("printk_ringbuffer.desc_ring", printk_ringbuffer.desc_ring);
|
|
DistroBaker |
7d0122 |
+ READ_MEMBER_OFFSET("printk_ringbuffer.text_data_ring", printk_ringbuffer.text_data_ring);
|
|
DistroBaker |
7d0122 |
+
|
|
DistroBaker |
7d0122 |
+ READ_MEMBER_OFFSET("prb_desc_ring.count_bits", prb_desc_ring.count_bits);
|
|
DistroBaker |
7d0122 |
+ READ_MEMBER_OFFSET("prb_desc_ring.descs", prb_desc_ring.descs);
|
|
DistroBaker |
7d0122 |
+ READ_MEMBER_OFFSET("prb_desc_ring.infos", prb_desc_ring.infos);
|
|
DistroBaker |
7d0122 |
+ READ_MEMBER_OFFSET("prb_desc_ring.head_id", prb_desc_ring.head_id);
|
|
DistroBaker |
7d0122 |
+ READ_MEMBER_OFFSET("prb_desc_ring.tail_id", prb_desc_ring.tail_id);
|
|
DistroBaker |
7d0122 |
+
|
|
DistroBaker |
7d0122 |
+ READ_STRUCTURE_SIZE("prb_desc", prb_desc);
|
|
DistroBaker |
7d0122 |
+ READ_MEMBER_OFFSET("prb_desc.state_var", prb_desc.state_var);
|
|
DistroBaker |
7d0122 |
+ READ_MEMBER_OFFSET("prb_desc.text_blk_lpos", prb_desc.text_blk_lpos);
|
|
DistroBaker |
7d0122 |
+
|
|
DistroBaker |
7d0122 |
+ READ_MEMBER_OFFSET("prb_data_blk_lpos.begin", prb_data_blk_lpos.begin);
|
|
DistroBaker |
7d0122 |
+ READ_MEMBER_OFFSET("prb_data_blk_lpos.next", prb_data_blk_lpos.next);
|
|
DistroBaker |
7d0122 |
+
|
|
DistroBaker |
7d0122 |
+ READ_MEMBER_OFFSET("prb_data_ring.size_bits", prb_data_ring.size_bits);
|
|
DistroBaker |
7d0122 |
+ READ_MEMBER_OFFSET("prb_data_ring.data", prb_data_ring.data);
|
|
DistroBaker |
7d0122 |
+
|
|
DistroBaker |
7d0122 |
+ READ_STRUCTURE_SIZE("printk_info", printk_info);
|
|
DistroBaker |
7d0122 |
+ READ_MEMBER_OFFSET("printk_info.ts_nsec", printk_info.ts_nsec);
|
|
DistroBaker |
7d0122 |
+ READ_MEMBER_OFFSET("printk_info.text_len", printk_info.text_len);
|
|
DistroBaker |
7d0122 |
+
|
|
DistroBaker |
7d0122 |
+ READ_MEMBER_OFFSET("atomic_long_t.counter", atomic_long_t.counter);
|
|
DistroBaker |
7d0122 |
+ } else if (SIZE(printk_log) != NOT_FOUND_STRUCTURE) {
|
|
DistroBaker |
7d0122 |
+ info->flag_use_printk_ringbuffer = FALSE;
|
|
DistroBaker |
7d0122 |
info->flag_use_printk_log = TRUE;
|
|
DistroBaker |
7d0122 |
READ_MEMBER_OFFSET("printk_log.ts_nsec", printk_log.ts_nsec);
|
|
DistroBaker |
7d0122 |
READ_MEMBER_OFFSET("printk_log.len", printk_log.len);
|
|
DistroBaker |
7d0122 |
READ_MEMBER_OFFSET("printk_log.text_len", printk_log.text_len);
|
|
DistroBaker |
7d0122 |
} else {
|
|
DistroBaker |
7d0122 |
+ info->flag_use_printk_ringbuffer = FALSE;
|
|
DistroBaker |
7d0122 |
info->flag_use_printk_log = FALSE;
|
|
DistroBaker |
7d0122 |
READ_STRUCTURE_SIZE("log", printk_log);
|
|
DistroBaker |
7d0122 |
READ_MEMBER_OFFSET("log.ts_nsec", printk_log.ts_nsec);
|
|
DistroBaker |
7d0122 |
@@ -5286,6 +5378,9 @@ dump_dmesg()
|
|
DistroBaker |
7d0122 |
if (!initial())
|
|
DistroBaker |
7d0122 |
return FALSE;
|
|
DistroBaker |
7d0122 |
|
|
DistroBaker |
7d0122 |
+ if ((SYMBOL(prb) != NOT_FOUND_SYMBOL))
|
|
DistroBaker |
7d0122 |
+ return dump_lockless_dmesg();
|
|
DistroBaker |
7d0122 |
+
|
|
DistroBaker |
7d0122 |
if ((SYMBOL(log_buf) == NOT_FOUND_SYMBOL)
|
|
DistroBaker |
7d0122 |
|| (SYMBOL(log_buf_len) == NOT_FOUND_SYMBOL)) {
|
|
DistroBaker |
7d0122 |
ERRMSG("Can't find some symbols for log_buf.\n");
|
|
DistroBaker |
7d0122 |
diff --git a/makedumpfile-1.6.8/makedumpfile.h b/makedumpfile-1.6.8/makedumpfile.h
|
|
DistroBaker |
7d0122 |
index 698c054..47f7e79 100644
|
|
DistroBaker |
7d0122 |
--- a/makedumpfile-1.6.8/makedumpfile.h
|
|
DistroBaker |
7d0122 |
+++ b/makedumpfile-1.6.8/makedumpfile.h
|
|
DistroBaker |
7d0122 |
@@ -1317,6 +1317,7 @@ struct DumpInfo {
|
|
DistroBaker |
7d0122 |
int flag_partial_dmesg; /* dmesg dump only from the last cleared index*/
|
|
DistroBaker |
7d0122 |
int flag_mem_usage; /*show the page number of memory in different use*/
|
|
DistroBaker |
7d0122 |
int flag_use_printk_log; /* did we read printk_log symbol name? */
|
|
DistroBaker |
7d0122 |
+ int flag_use_printk_ringbuffer; /* using lockless printk ringbuffer? */
|
|
DistroBaker |
7d0122 |
int flag_nospace; /* the flag of "No space on device" error */
|
|
DistroBaker |
7d0122 |
int flag_vmemmap; /* kernel supports vmemmap address space */
|
|
DistroBaker |
7d0122 |
int flag_excludevm; /* -e - excluding unused vmemmap pages */
|
|
DistroBaker |
7d0122 |
@@ -1602,6 +1603,7 @@ struct symbol_table {
|
|
DistroBaker |
7d0122 |
unsigned long long node_data;
|
|
DistroBaker |
7d0122 |
unsigned long long pgdat_list;
|
|
DistroBaker |
7d0122 |
unsigned long long contig_page_data;
|
|
DistroBaker |
7d0122 |
+ unsigned long long prb;
|
|
DistroBaker |
7d0122 |
unsigned long long log_buf;
|
|
DistroBaker |
7d0122 |
unsigned long long log_buf_len;
|
|
DistroBaker |
7d0122 |
unsigned long long log_end;
|
|
DistroBaker |
7d0122 |
@@ -1689,6 +1691,13 @@ struct size_table {
|
|
DistroBaker |
7d0122 |
long nodemask_t;
|
|
DistroBaker |
7d0122 |
long printk_log;
|
|
DistroBaker |
7d0122 |
|
|
DistroBaker |
7d0122 |
+ /*
|
|
DistroBaker |
7d0122 |
+ * for lockless printk ringbuffer
|
|
DistroBaker |
7d0122 |
+ */
|
|
DistroBaker |
7d0122 |
+ long printk_ringbuffer;
|
|
DistroBaker |
7d0122 |
+ long prb_desc;
|
|
DistroBaker |
7d0122 |
+ long printk_info;
|
|
DistroBaker |
7d0122 |
+
|
|
DistroBaker |
7d0122 |
/*
|
|
DistroBaker |
7d0122 |
* for Xen extraction
|
|
DistroBaker |
7d0122 |
*/
|
|
DistroBaker |
7d0122 |
@@ -1864,6 +1873,52 @@ struct offset_table {
|
|
DistroBaker |
7d0122 |
long text_len;
|
|
DistroBaker |
7d0122 |
} printk_log;
|
|
DistroBaker |
7d0122 |
|
|
DistroBaker |
7d0122 |
+ /*
|
|
DistroBaker |
7d0122 |
+ * for lockless printk ringbuffer
|
|
DistroBaker |
7d0122 |
+ */
|
|
DistroBaker |
7d0122 |
+ struct printk_ringbuffer_s {
|
|
DistroBaker |
7d0122 |
+ long desc_ring;
|
|
DistroBaker |
7d0122 |
+ long text_data_ring;
|
|
DistroBaker |
7d0122 |
+ long fail;
|
|
DistroBaker |
7d0122 |
+ } printk_ringbuffer;
|
|
DistroBaker |
7d0122 |
+
|
|
DistroBaker |
7d0122 |
+ struct prb_desc_ring_s {
|
|
DistroBaker |
7d0122 |
+ long count_bits;
|
|
DistroBaker |
7d0122 |
+ long descs;
|
|
DistroBaker |
7d0122 |
+ long infos;
|
|
DistroBaker |
7d0122 |
+ long head_id;
|
|
DistroBaker |
7d0122 |
+ long tail_id;
|
|
DistroBaker |
7d0122 |
+ } prb_desc_ring;
|
|
DistroBaker |
7d0122 |
+
|
|
DistroBaker |
7d0122 |
+ struct prb_desc_s {
|
|
DistroBaker |
7d0122 |
+ long state_var;
|
|
DistroBaker |
7d0122 |
+ long text_blk_lpos;
|
|
DistroBaker |
7d0122 |
+ } prb_desc;
|
|
DistroBaker |
7d0122 |
+
|
|
DistroBaker |
7d0122 |
+ struct prb_data_blk_lpos_s {
|
|
DistroBaker |
7d0122 |
+ long begin;
|
|
DistroBaker |
7d0122 |
+ long next;
|
|
DistroBaker |
7d0122 |
+ } prb_data_blk_lpos;
|
|
DistroBaker |
7d0122 |
+
|
|
DistroBaker |
7d0122 |
+ struct printk_info_s {
|
|
DistroBaker |
7d0122 |
+ long seq;
|
|
DistroBaker |
7d0122 |
+ long ts_nsec;
|
|
DistroBaker |
7d0122 |
+ long text_len;
|
|
DistroBaker |
7d0122 |
+ long caller_id;
|
|
DistroBaker |
7d0122 |
+ long dev_info;
|
|
DistroBaker |
7d0122 |
+ } printk_info;
|
|
DistroBaker |
7d0122 |
+
|
|
DistroBaker |
7d0122 |
+ struct prb_data_ring_s {
|
|
DistroBaker |
7d0122 |
+ long size_bits;
|
|
DistroBaker |
7d0122 |
+ long data;
|
|
DistroBaker |
7d0122 |
+ long head_lpos;
|
|
DistroBaker |
7d0122 |
+ long tail_lpos;
|
|
DistroBaker |
7d0122 |
+ } prb_data_ring;
|
|
DistroBaker |
7d0122 |
+
|
|
DistroBaker |
7d0122 |
+ struct atomic_long_t_s {
|
|
DistroBaker |
7d0122 |
+ long counter;
|
|
DistroBaker |
7d0122 |
+ } atomic_long_t;
|
|
DistroBaker |
7d0122 |
+
|
|
DistroBaker |
7d0122 |
/*
|
|
DistroBaker |
7d0122 |
* symbols on ppc64 arch
|
|
DistroBaker |
7d0122 |
*/
|
|
DistroBaker |
7d0122 |
@@ -2390,4 +2445,7 @@ int hexadecimal(char *s, int count);
|
|
DistroBaker |
7d0122 |
int decimal(char *s, int count);
|
|
DistroBaker |
7d0122 |
int file_exists(char *file);
|
|
DistroBaker |
7d0122 |
|
|
DistroBaker |
7d0122 |
+int open_dump_file(void);
|
|
DistroBaker |
7d0122 |
+int dump_lockless_dmesg(void);
|
|
DistroBaker |
7d0122 |
+
|
|
DistroBaker |
7d0122 |
#endif /* MAKEDUMPFILE_H */
|
|
DistroBaker |
7d0122 |
diff --git a/makedumpfile-1.6.8/printk.c b/makedumpfile-1.6.8/printk.c
|
|
DistroBaker |
7d0122 |
new file mode 100644
|
|
DistroBaker |
7d0122 |
index 0000000..acffb6c
|
|
DistroBaker |
7d0122 |
--- /dev/null
|
|
DistroBaker |
7d0122 |
+++ b/makedumpfile-1.6.8/printk.c
|
|
DistroBaker |
7d0122 |
@@ -0,0 +1,207 @@
|
|
DistroBaker |
7d0122 |
+#include "makedumpfile.h"
|
|
DistroBaker |
7d0122 |
+#include <ctype.h>
|
|
DistroBaker |
7d0122 |
+
|
|
DistroBaker |
7d0122 |
+#define DESC_SV_BITS (sizeof(unsigned long) * 8)
|
|
DistroBaker |
7d0122 |
+#define DESC_COMMITTED_MASK (1UL << (DESC_SV_BITS - 1))
|
|
DistroBaker |
7d0122 |
+#define DESC_REUSE_MASK (1UL << (DESC_SV_BITS - 2))
|
|
DistroBaker |
7d0122 |
+#define DESC_FLAGS_MASK (DESC_COMMITTED_MASK | DESC_REUSE_MASK)
|
|
DistroBaker |
7d0122 |
+#define DESC_ID_MASK (~DESC_FLAGS_MASK)
|
|
DistroBaker |
7d0122 |
+
|
|
DistroBaker |
7d0122 |
+/* convenience struct for passing many values to helper functions */
|
|
DistroBaker |
7d0122 |
+struct prb_map {
|
|
DistroBaker |
7d0122 |
+ char *prb;
|
|
DistroBaker |
7d0122 |
+
|
|
DistroBaker |
7d0122 |
+ char *desc_ring;
|
|
DistroBaker |
7d0122 |
+ unsigned long desc_ring_count;
|
|
DistroBaker |
7d0122 |
+ char *descs;
|
|
DistroBaker |
7d0122 |
+ char *infos;
|
|
DistroBaker |
7d0122 |
+
|
|
DistroBaker |
7d0122 |
+ char *text_data_ring;
|
|
DistroBaker |
7d0122 |
+ unsigned long text_data_ring_size;
|
|
DistroBaker |
7d0122 |
+ char *text_data;
|
|
DistroBaker |
7d0122 |
+};
|
|
DistroBaker |
7d0122 |
+
|
|
DistroBaker |
7d0122 |
+static void
|
|
DistroBaker |
7d0122 |
+dump_record(struct prb_map *m, unsigned long id)
|
|
DistroBaker |
7d0122 |
+{
|
|
DistroBaker |
7d0122 |
+ unsigned long long ts_nsec;
|
|
DistroBaker |
7d0122 |
+ unsigned long state_var;
|
|
DistroBaker |
7d0122 |
+ unsigned short text_len;
|
|
DistroBaker |
7d0122 |
+ unsigned long begin;
|
|
DistroBaker |
7d0122 |
+ unsigned long next;
|
|
DistroBaker |
7d0122 |
+ char buf[BUFSIZE];
|
|
DistroBaker |
7d0122 |
+ ulonglong nanos;
|
|
DistroBaker |
7d0122 |
+ int indent_len;
|
|
DistroBaker |
7d0122 |
+ int buf_need;
|
|
DistroBaker |
7d0122 |
+ char *bufp;
|
|
DistroBaker |
7d0122 |
+ char *text;
|
|
DistroBaker |
7d0122 |
+ char *desc;
|
|
DistroBaker |
7d0122 |
+ char *inf;
|
|
DistroBaker |
7d0122 |
+ ulong rem;
|
|
DistroBaker |
7d0122 |
+ char *p;
|
|
DistroBaker |
7d0122 |
+ int i;
|
|
DistroBaker |
7d0122 |
+
|
|
DistroBaker |
7d0122 |
+ desc = m->descs + ((id % m->desc_ring_count) * SIZE(prb_desc));
|
|
DistroBaker |
7d0122 |
+
|
|
DistroBaker |
7d0122 |
+ /* skip non-committed record */
|
|
DistroBaker |
7d0122 |
+ state_var = ULONG(desc + OFFSET(prb_desc.state_var) + OFFSET(atomic_long_t.counter));
|
|
DistroBaker |
7d0122 |
+ if ((state_var & DESC_FLAGS_MASK) != DESC_COMMITTED_MASK)
|
|
DistroBaker |
7d0122 |
+ return;
|
|
DistroBaker |
7d0122 |
+
|
|
DistroBaker |
7d0122 |
+ begin = ULONG(desc + OFFSET(prb_desc.text_blk_lpos) + OFFSET(prb_data_blk_lpos.begin)) %
|
|
DistroBaker |
7d0122 |
+ m->text_data_ring_size;
|
|
DistroBaker |
7d0122 |
+ next = ULONG(desc + OFFSET(prb_desc.text_blk_lpos) + OFFSET(prb_data_blk_lpos.next)) %
|
|
DistroBaker |
7d0122 |
+ m->text_data_ring_size;
|
|
DistroBaker |
7d0122 |
+
|
|
DistroBaker |
7d0122 |
+ /* skip data-less text blocks */
|
|
DistroBaker |
7d0122 |
+ if (begin == next)
|
|
DistroBaker |
7d0122 |
+ return;
|
|
DistroBaker |
7d0122 |
+
|
|
DistroBaker |
7d0122 |
+ inf = m->infos + ((id % m->desc_ring_count) * SIZE(printk_info));
|
|
DistroBaker |
7d0122 |
+
|
|
DistroBaker |
7d0122 |
+ text_len = USHORT(inf + OFFSET(printk_info.text_len));
|
|
DistroBaker |
7d0122 |
+
|
|
DistroBaker |
7d0122 |
+ /* handle wrapping data block */
|
|
DistroBaker |
7d0122 |
+ if (begin > next)
|
|
DistroBaker |
7d0122 |
+ begin = 0;
|
|
DistroBaker |
7d0122 |
+
|
|
DistroBaker |
7d0122 |
+ /* skip over descriptor ID */
|
|
DistroBaker |
7d0122 |
+ begin += sizeof(unsigned long);
|
|
DistroBaker |
7d0122 |
+
|
|
DistroBaker |
7d0122 |
+ /* handle truncated messages */
|
|
DistroBaker |
7d0122 |
+ if (next - begin < text_len)
|
|
DistroBaker |
7d0122 |
+ text_len = next - begin;
|
|
DistroBaker |
7d0122 |
+
|
|
DistroBaker |
7d0122 |
+ text = m->text_data + begin;
|
|
DistroBaker |
7d0122 |
+
|
|
DistroBaker |
7d0122 |
+ ts_nsec = ULONGLONG(inf + OFFSET(printk_info.ts_nsec));
|
|
DistroBaker |
7d0122 |
+ nanos = (ulonglong)ts_nsec / (ulonglong)1000000000;
|
|
DistroBaker |
7d0122 |
+ rem = (ulonglong)ts_nsec % (ulonglong)1000000000;
|
|
DistroBaker |
7d0122 |
+
|
|
DistroBaker |
7d0122 |
+ bufp = buf;
|
|
DistroBaker |
7d0122 |
+ bufp += sprintf(buf, "[%5lld.%06ld] ", nanos, rem/1000);
|
|
DistroBaker |
7d0122 |
+ indent_len = strlen(buf);
|
|
DistroBaker |
7d0122 |
+
|
|
DistroBaker |
7d0122 |
+ /* How much buffer space is needed in the worst case */
|
|
DistroBaker |
7d0122 |
+ buf_need = MAX(sizeof("\\xXX\n"), sizeof("\n") + indent_len);
|
|
DistroBaker |
7d0122 |
+
|
|
DistroBaker |
7d0122 |
+ for (i = 0, p = text; i < text_len; i++, p++) {
|
|
DistroBaker |
7d0122 |
+ if (bufp - buf >= sizeof(buf) - buf_need) {
|
|
DistroBaker |
7d0122 |
+ if (write(info->fd_dumpfile, buf, bufp - buf) < 0)
|
|
DistroBaker |
7d0122 |
+ return;
|
|
DistroBaker |
7d0122 |
+ bufp = buf;
|
|
DistroBaker |
7d0122 |
+ }
|
|
DistroBaker |
7d0122 |
+
|
|
DistroBaker |
7d0122 |
+ if (*p == '\n')
|
|
DistroBaker |
7d0122 |
+ bufp += sprintf(bufp, "\n%-*s", indent_len, "");
|
|
DistroBaker |
7d0122 |
+ else if (isprint(*p) || isspace(*p))
|
|
DistroBaker |
7d0122 |
+ *bufp++ = *p;
|
|
DistroBaker |
7d0122 |
+ else
|
|
DistroBaker |
7d0122 |
+ bufp += sprintf(bufp, "\\x%02x", *p);
|
|
DistroBaker |
7d0122 |
+ }
|
|
DistroBaker |
7d0122 |
+
|
|
DistroBaker |
7d0122 |
+ *bufp++ = '\n';
|
|
DistroBaker |
7d0122 |
+
|
|
DistroBaker |
7d0122 |
+ write(info->fd_dumpfile, buf, bufp - buf);
|
|
DistroBaker |
7d0122 |
+}
|
|
DistroBaker |
7d0122 |
+
|
|
DistroBaker |
7d0122 |
+int
|
|
DistroBaker |
7d0122 |
+dump_lockless_dmesg(void)
|
|
DistroBaker |
7d0122 |
+{
|
|
DistroBaker |
7d0122 |
+ unsigned long head_id;
|
|
DistroBaker |
7d0122 |
+ unsigned long tail_id;
|
|
DistroBaker |
7d0122 |
+ unsigned long kaddr;
|
|
DistroBaker |
7d0122 |
+ unsigned long id;
|
|
DistroBaker |
7d0122 |
+ struct prb_map m;
|
|
DistroBaker |
7d0122 |
+ int ret = FALSE;
|
|
DistroBaker |
7d0122 |
+
|
|
DistroBaker |
7d0122 |
+ /* setup printk_ringbuffer */
|
|
DistroBaker |
7d0122 |
+ if (!readmem(VADDR, SYMBOL(prb), &kaddr, sizeof(kaddr))) {
|
|
DistroBaker |
7d0122 |
+ ERRMSG("Can't get the prb address.\n");
|
|
DistroBaker |
7d0122 |
+ return ret;
|
|
DistroBaker |
7d0122 |
+ }
|
|
DistroBaker |
7d0122 |
+
|
|
DistroBaker |
7d0122 |
+ m.prb = malloc(SIZE(printk_ringbuffer));
|
|
DistroBaker |
7d0122 |
+ if (!m.prb) {
|
|
DistroBaker |
7d0122 |
+ ERRMSG("Can't allocate memory for prb.\n");
|
|
DistroBaker |
7d0122 |
+ return ret;
|
|
DistroBaker |
7d0122 |
+ }
|
|
DistroBaker |
7d0122 |
+ if (!readmem(VADDR, kaddr, m.prb, SIZE(printk_ringbuffer))) {
|
|
DistroBaker |
7d0122 |
+ ERRMSG("Can't get prb.\n");
|
|
DistroBaker |
7d0122 |
+ goto out_prb;
|
|
DistroBaker |
7d0122 |
+ }
|
|
DistroBaker |
7d0122 |
+
|
|
DistroBaker |
7d0122 |
+ /* setup descriptor ring */
|
|
DistroBaker |
7d0122 |
+ m.desc_ring = m.prb + OFFSET(printk_ringbuffer.desc_ring);
|
|
DistroBaker |
7d0122 |
+ m.desc_ring_count = 1 << UINT(m.desc_ring + OFFSET(prb_desc_ring.count_bits));
|
|
DistroBaker |
7d0122 |
+
|
|
DistroBaker |
7d0122 |
+ kaddr = ULONG(m.desc_ring + OFFSET(prb_desc_ring.descs));
|
|
DistroBaker |
7d0122 |
+ m.descs = malloc(SIZE(prb_desc) * m.desc_ring_count);
|
|
DistroBaker |
7d0122 |
+ if (!m.descs) {
|
|
DistroBaker |
7d0122 |
+ ERRMSG("Can't allocate memory for prb.desc_ring.descs.\n");
|
|
DistroBaker |
7d0122 |
+ goto out_prb;
|
|
DistroBaker |
7d0122 |
+ }
|
|
DistroBaker |
7d0122 |
+ if (!readmem(VADDR, kaddr, m.descs,
|
|
DistroBaker |
7d0122 |
+ SIZE(prb_desc) * m.desc_ring_count)) {
|
|
DistroBaker |
7d0122 |
+ ERRMSG("Can't get prb.desc_ring.descs.\n");
|
|
DistroBaker |
7d0122 |
+ goto out_descs;
|
|
DistroBaker |
7d0122 |
+ }
|
|
DistroBaker |
7d0122 |
+
|
|
DistroBaker |
7d0122 |
+ kaddr = ULONG(m.desc_ring + OFFSET(prb_desc_ring.infos));
|
|
DistroBaker |
7d0122 |
+ m.infos = malloc(SIZE(printk_info) * m.desc_ring_count);
|
|
DistroBaker |
7d0122 |
+ if (!m.infos) {
|
|
DistroBaker |
7d0122 |
+ ERRMSG("Can't allocate memory for prb.desc_ring.infos.\n");
|
|
DistroBaker |
7d0122 |
+ goto out_descs;
|
|
DistroBaker |
7d0122 |
+ }
|
|
DistroBaker |
7d0122 |
+ if (!readmem(VADDR, kaddr, m.infos, SIZE(printk_info) * m.desc_ring_count)) {
|
|
DistroBaker |
7d0122 |
+ ERRMSG("Can't get prb.desc_ring.infos.\n");
|
|
DistroBaker |
7d0122 |
+ goto out_infos;
|
|
DistroBaker |
7d0122 |
+ }
|
|
DistroBaker |
7d0122 |
+
|
|
DistroBaker |
7d0122 |
+ /* setup text data ring */
|
|
DistroBaker |
7d0122 |
+ m.text_data_ring = m.prb + OFFSET(printk_ringbuffer.text_data_ring);
|
|
DistroBaker |
7d0122 |
+ m.text_data_ring_size = 1 << UINT(m.text_data_ring + OFFSET(prb_data_ring.size_bits));
|
|
DistroBaker |
7d0122 |
+
|
|
DistroBaker |
7d0122 |
+ kaddr = ULONG(m.text_data_ring + OFFSET(prb_data_ring.data));
|
|
DistroBaker |
7d0122 |
+ m.text_data = malloc(m.text_data_ring_size);
|
|
DistroBaker |
7d0122 |
+ if (!m.text_data) {
|
|
DistroBaker |
7d0122 |
+ ERRMSG("Can't allocate memory for prb.text_data_ring.data.\n");
|
|
DistroBaker |
7d0122 |
+ goto out_infos;
|
|
DistroBaker |
7d0122 |
+ }
|
|
DistroBaker |
7d0122 |
+ if (!readmem(VADDR, kaddr, m.text_data, m.text_data_ring_size)) {
|
|
DistroBaker |
7d0122 |
+ ERRMSG("Can't get prb.text_data_ring.\n");
|
|
DistroBaker |
7d0122 |
+ goto out_text_data;
|
|
DistroBaker |
7d0122 |
+ }
|
|
DistroBaker |
7d0122 |
+
|
|
DistroBaker |
7d0122 |
+ /* ready to go */
|
|
DistroBaker |
7d0122 |
+
|
|
DistroBaker |
7d0122 |
+ tail_id = ULONG(m.desc_ring + OFFSET(prb_desc_ring.tail_id) +
|
|
DistroBaker |
7d0122 |
+ OFFSET(atomic_long_t.counter));
|
|
DistroBaker |
7d0122 |
+ head_id = ULONG(m.desc_ring + OFFSET(prb_desc_ring.head_id) +
|
|
DistroBaker |
7d0122 |
+ OFFSET(atomic_long_t.counter));
|
|
DistroBaker |
7d0122 |
+
|
|
DistroBaker |
7d0122 |
+ if (!open_dump_file()) {
|
|
DistroBaker |
7d0122 |
+ ERRMSG("Can't open output file.\n");
|
|
DistroBaker |
7d0122 |
+ goto out_text_data;
|
|
DistroBaker |
7d0122 |
+ }
|
|
DistroBaker |
7d0122 |
+
|
|
DistroBaker |
7d0122 |
+ for (id = tail_id; id != head_id; id = (id + 1) & DESC_ID_MASK)
|
|
DistroBaker |
7d0122 |
+ dump_record(&m, id);
|
|
DistroBaker |
7d0122 |
+
|
|
DistroBaker |
7d0122 |
+ /* dump head record */
|
|
DistroBaker |
7d0122 |
+ dump_record(&m, id);
|
|
DistroBaker |
7d0122 |
+
|
|
DistroBaker |
7d0122 |
+ if (!close_files_for_creating_dumpfile())
|
|
DistroBaker |
7d0122 |
+ goto out_text_data;
|
|
DistroBaker |
7d0122 |
+
|
|
DistroBaker |
7d0122 |
+ ret = TRUE;
|
|
DistroBaker |
7d0122 |
+out_text_data:
|
|
DistroBaker |
7d0122 |
+ free(m.text_data);
|
|
DistroBaker |
7d0122 |
+out_infos:
|
|
DistroBaker |
7d0122 |
+ free(m.infos);
|
|
DistroBaker |
7d0122 |
+out_descs:
|
|
DistroBaker |
7d0122 |
+ free(m.descs);
|
|
DistroBaker |
7d0122 |
+out_prb:
|
|
DistroBaker |
7d0122 |
+ free(m.prb);
|
|
DistroBaker |
7d0122 |
+ return ret;
|
|
DistroBaker |
7d0122 |
+}
|
|
DistroBaker |
7d0122 |
--
|
|
DistroBaker |
7d0122 |
2.29.2
|
|
DistroBaker |
7d0122 |
|