Expand dump-functions for excluding user/unused memory (This is rebase commit for merging to development)
This commit is contained in:
committed by
Ken Sato
parent
325082a571
commit
a05b6e1ba8
@ -13,7 +13,7 @@ CFLAGS=-Wall -O -I. -I$(VPATH)/arch/${ARCH}
|
||||
LDFLAGS=@LDFLAGS@
|
||||
RPATH=$(shell echo $(LDFLAGS)|awk '{for(i=1;i<=NF;i++){if($$i~/^-L/){w=$$i;sub(/^-L/,"-Wl,-rpath,",w);print w}}}')
|
||||
VPATH=@abs_srcdir@
|
||||
TARGET=mcexec libsched_yield
|
||||
TARGET=mcexec libsched_yield ldump2mcdump.so
|
||||
@uncomment_if_ENABLE_MEMDUMP@TARGET+=eclair
|
||||
LIBS=@LIBS@
|
||||
ARCH=@ARCH@
|
||||
@ -45,6 +45,9 @@ eclair: eclair.c
|
||||
$(CC) $(CFLAGS) -I${IHKDIR} -o $@ $^ $(LIBS)
|
||||
endif
|
||||
|
||||
ldump2mcdump.so: ldump2mcdump.c
|
||||
$(CC) $(CFLAGS) $(LDFLAGS) -shared -fPIC -o $@ $<
|
||||
|
||||
libsched_yield: libsched_yield.c
|
||||
$(CC) -shared -fPIC -Wl,-soname,sched_yield.so.1 -o libsched_yield.so.1.0.0 $^ -lc -ldl
|
||||
|
||||
@ -83,6 +86,7 @@ install::
|
||||
mkdir -p -m 755 $(BINDIR)
|
||||
install -m 755 mcexec $(BINDIR)
|
||||
mkdir -p -m 755 $(MCKERNEL_LIBDIR)
|
||||
install -m 755 ldump2mcdump.so $(MCKERNEL_LIBDIR)
|
||||
install -m 755 libsched_yield.so.1.0.0 $(MCKERNEL_LIBDIR)
|
||||
ifeq ($(ENABLE_QLMPI),yes)
|
||||
install -m 644 ../include/qlmpilib.h $(MCKERNEL_INCDIR)
|
||||
@ -94,3 +98,5 @@ ifeq ($(ENABLE_QLMPI),yes)
|
||||
install -m 755 ql_talker $(SBINDIR)
|
||||
endif
|
||||
@uncomment_if_ENABLE_MEMDUMP@install -m 755 eclair $(BINDIR)
|
||||
@uncomment_if_ENABLE_MEMDUMP@install -m 755 vmcore2mckdump $(BINDIR)
|
||||
|
||||
|
||||
@ -29,6 +29,8 @@
|
||||
|
||||
#define CPU_TID_BASE 1000000
|
||||
|
||||
#define PHYSMEM_NAME_SIZE 32
|
||||
|
||||
struct options {
|
||||
uint8_t cpu;
|
||||
uint8_t help;
|
||||
@ -123,6 +125,8 @@ static int read_physmem(uintptr_t pa, void *buf, size_t size) {
|
||||
bfd_boolean ok;
|
||||
int i;
|
||||
|
||||
char physmem_name[PHYSMEM_NAME_SIZE];
|
||||
|
||||
off = 0;
|
||||
/* Check if pa is valid in any chunks and figure
|
||||
* out the global offset in dump section */
|
||||
@ -135,8 +139,6 @@ static int read_physmem(uintptr_t pa, void *buf, size_t size) {
|
||||
off += (pa - mem_chunks->chunks[i].addr);
|
||||
break;
|
||||
}
|
||||
|
||||
off += mem_chunks->chunks[i].size;
|
||||
}
|
||||
|
||||
if (i == mem_chunks->nr_chunks) {
|
||||
@ -144,6 +146,15 @@ static int read_physmem(uintptr_t pa, void *buf, size_t size) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
memset(physmem_name,0,sizeof(physmem_name));
|
||||
sprintf(physmem_name, "physmem%d",i);
|
||||
|
||||
dumpscn = bfd_get_section_by_name(dumpbfd, physmem_name);
|
||||
if (!dumpscn) {
|
||||
bfd_perror("read_physmem:bfd_get_section_by_name(physmem)");
|
||||
return 1;
|
||||
}
|
||||
|
||||
ok = bfd_get_section_contents(dumpbfd, dumpscn, buf, off, size);
|
||||
if (!ok) {
|
||||
bfd_perror("read_physmem:bfd_get_section_contents");
|
||||
@ -596,6 +607,11 @@ static int setup_symbols(char *fname) {
|
||||
|
||||
static int setup_dump(char *fname) {
|
||||
bfd_boolean ok;
|
||||
long mem_size;
|
||||
static dump_mem_chunks_t mem_info;
|
||||
|
||||
char physmem_name[PHYSMEM_NAME_SIZE];
|
||||
int i;
|
||||
|
||||
#ifdef POSTK_DEBUG_ARCH_DEP_34
|
||||
dumpbfd = bfd_fopen(opt.dump_path, NULL, "r", -1);
|
||||
@ -613,31 +629,45 @@ static int setup_dump(char *fname) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
mem_chunks = malloc(PHYS_CHUNKS_DESC_SIZE);
|
||||
if (!mem_chunks) {
|
||||
perror("allocating mem chunks descriptor: ");
|
||||
return 1;
|
||||
}
|
||||
|
||||
dumpscn = bfd_get_section_by_name(dumpbfd, "physchunks");
|
||||
if (!dumpscn) {
|
||||
bfd_perror("bfd_get_section_by_name");
|
||||
return 1;
|
||||
}
|
||||
|
||||
ok = bfd_get_section_contents(dumpbfd, dumpscn, mem_chunks,
|
||||
0, PHYS_CHUNKS_DESC_SIZE);
|
||||
ok = bfd_get_section_contents(dumpbfd, dumpscn, &mem_info,
|
||||
0, sizeof(mem_info));
|
||||
if (!ok) {
|
||||
bfd_perror("read_physmem:bfd_get_section_contents");
|
||||
bfd_perror("read_physmem:bfd_get_section_contents(mem_size)");
|
||||
return 1;
|
||||
}
|
||||
|
||||
mem_size = (sizeof(dump_mem_chunks_t) + (sizeof(struct dump_mem_chunk) * mem_info.nr_chunks));
|
||||
|
||||
mem_chunks = malloc(mem_size);
|
||||
if (!mem_chunks) {
|
||||
perror("allocating mem chunks descriptor: ");
|
||||
return 1;
|
||||
}
|
||||
|
||||
ok = bfd_get_section_contents(dumpbfd, dumpscn, mem_chunks,
|
||||
0, mem_size);
|
||||
if (!ok) {
|
||||
bfd_perror("read_physmem:bfd_get_section_contents(mem_chunks)");
|
||||
return 1;
|
||||
}
|
||||
|
||||
kernel_base = mem_chunks->kernel_base;
|
||||
|
||||
dumpscn = bfd_get_section_by_name(dumpbfd, "physmem");
|
||||
if (!dumpscn) {
|
||||
bfd_perror("bfd_get_section_by_name");
|
||||
return 1;
|
||||
for (i = 0; i < mem_info.nr_chunks; ++i) {
|
||||
memset(physmem_name,0,sizeof(physmem_name));
|
||||
sprintf(physmem_name, "physmem%d",i);
|
||||
|
||||
dumpscn = bfd_get_section_by_name(dumpbfd, physmem_name);
|
||||
if (!dumpscn) {
|
||||
bfd_perror("read_physmem:bfd_get_section_by_name(physmem)");
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
483
executer/user/ldump2mcdump.c
Normal file
483
executer/user/ldump2mcdump.c
Normal file
@ -0,0 +1,483 @@
|
||||
|
||||
#include "../include/defs.h" /* From the crash source top-level directory */
|
||||
#include <bfd.h>
|
||||
#include <pwd.h>
|
||||
|
||||
void ldump2mcdump_init(void); /* constructor function */
|
||||
void ldump2mcdump_fini(void); /* destructor function (optional) */
|
||||
|
||||
void cmd_ldump2mcdump(void); /* Declare the commands and their help data. */
|
||||
char *help_ldump2mcdump[];
|
||||
|
||||
static struct command_table_entry command_table[] = {
|
||||
{ "ldump2mcdump", cmd_ldump2mcdump, help_ldump2mcdump, 0}, /* One or more commands, */
|
||||
{ NULL }, /* terminated by NULL, */
|
||||
};
|
||||
|
||||
|
||||
void __attribute__((constructor))
|
||||
ldump2mcdump_init(void) /* Register the command set. */
|
||||
{
|
||||
register_extension(command_table);
|
||||
}
|
||||
|
||||
/*
|
||||
* This function is called if the shared object is unloaded.
|
||||
* If desired, perform any cleanups here.
|
||||
*/
|
||||
void __attribute__((destructor))
|
||||
ldump2mcdump_fini(void) { }
|
||||
|
||||
struct ihk_dump_page {
|
||||
unsigned long start;
|
||||
unsigned long map_count;
|
||||
unsigned long map[0];
|
||||
};
|
||||
|
||||
struct ihk_dump_page_set {
|
||||
unsigned int completion_flag;
|
||||
unsigned int count;
|
||||
unsigned long page_size;
|
||||
unsigned long phy_page;
|
||||
};
|
||||
|
||||
struct dump_mem_chunk {
|
||||
unsigned long addr;
|
||||
unsigned long size;
|
||||
};
|
||||
|
||||
typedef struct dump_mem_chunks_s {
|
||||
int nr_chunks;
|
||||
unsigned long kernel_base;
|
||||
struct dump_mem_chunk chunks[];
|
||||
} dump_mem_chunks_t;
|
||||
|
||||
#define PATH_MAX 4096
|
||||
#define DUMP_MEM_SYMBOL "dump_page_set_addr"
|
||||
#define BOOTSTRAP_MEM_SYMBOL "dump_bootstrap_mem_start"
|
||||
#define MCDUMP_DEFAULT_FILENAME "mcdump"
|
||||
#define PAGE_SHIFT 12
|
||||
#define LARGE_PAGE_SHIFT 21
|
||||
#define LARGE_PAGE_SIZE (1UL << LARGE_PAGE_SHIFT)
|
||||
#define LARGE_PAGE_MASK (~((unsigned long)LARGE_PAGE_SIZE - 1))
|
||||
|
||||
#define PHYSMEM_NAME_SIZE 32
|
||||
|
||||
void cmd_ldump2mcdump(void)
|
||||
{
|
||||
static char path[PATH_MAX];
|
||||
static char hname[HOST_NAME_MAX+1];
|
||||
bfd *abfd = NULL;
|
||||
char *fname;
|
||||
bfd_boolean ok;
|
||||
asection *scn;
|
||||
unsigned long phys_size, phys_offset;
|
||||
int error;
|
||||
size_t bsize;
|
||||
void *buf = NULL;
|
||||
uintptr_t addr;
|
||||
size_t cpsize;
|
||||
time_t t;
|
||||
struct tm *tm;
|
||||
char *date;
|
||||
struct passwd *pw;
|
||||
dump_mem_chunks_t *mem_chunks = NULL;
|
||||
long mem_size;
|
||||
int opt = 0;
|
||||
int read_mem_ret = TRUE;
|
||||
|
||||
ulong symbol_dump_page_set = 0;
|
||||
ulong dump_page_set_addr = 0;
|
||||
ulong symbol_bootstrap_mem = 0;
|
||||
ulong bootstrap_mem = 0;
|
||||
struct ihk_dump_page_set dump_page_set;
|
||||
ulong ihk_dump_page_addr = 0;
|
||||
struct ihk_dump_page ihk_dump_page;
|
||||
ulong *map_buf = NULL;
|
||||
ulong map_size = 0;
|
||||
int i,j,k,index,mem_num;
|
||||
ulong map_start,bit_count;
|
||||
char *physmem_name_buf = NULL;
|
||||
char physmem_name[PHYSMEM_NAME_SIZE];
|
||||
|
||||
ulong read_mem_addr = 0;
|
||||
|
||||
if (argcnt < 2) {
|
||||
perror("argument error");
|
||||
return;
|
||||
}
|
||||
|
||||
strcpy(path,MCDUMP_DEFAULT_FILENAME);
|
||||
|
||||
while ((opt = getopt(argcnt, args, "o:")) != -1) {
|
||||
switch (opt) {
|
||||
case 'o': /* '-o' */
|
||||
strcpy(path,optarg);
|
||||
break;
|
||||
default: /* '?' */
|
||||
fprintf(stderr, "ldump2mcdump os_index [-o file_name]\n");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
fname = path;
|
||||
symbol_dump_page_set = symbol_value(DUMP_MEM_SYMBOL);
|
||||
readmem(symbol_dump_page_set,KVADDR,&dump_page_set_addr,sizeof(dump_page_set_addr),"",FAULT_ON_ERROR);
|
||||
readmem(dump_page_set_addr,KVADDR,&dump_page_set,sizeof(dump_page_set),"",FAULT_ON_ERROR);
|
||||
|
||||
// DUMP_QUERY_NUM_MEM_AREAS
|
||||
ihk_dump_page_addr = PTOV(dump_page_set.phy_page);
|
||||
for (i = 0, mem_num = 0; i < dump_page_set.count; i++) {
|
||||
|
||||
readmem(ihk_dump_page_addr,KVADDR,&ihk_dump_page,sizeof(ihk_dump_page),"",FAULT_ON_ERROR);
|
||||
map_size = sizeof(unsigned long)*ihk_dump_page.map_count;
|
||||
map_buf = malloc(map_size);
|
||||
if (map_buf != NULL) {
|
||||
memset(map_buf,0x00,map_size);
|
||||
readmem((ihk_dump_page_addr+sizeof(struct ihk_dump_page)),KVADDR,map_buf,map_size,"",FAULT_ON_ERROR);
|
||||
|
||||
for (j = 0, bit_count = 0; j < ihk_dump_page.map_count; j++) {
|
||||
for ( k = 0; k < 64; k++) {
|
||||
if (((ulong)*(map_buf+j) >> k) & 0x1) {
|
||||
bit_count++;
|
||||
} else {
|
||||
if (bit_count) {
|
||||
mem_num++;
|
||||
bit_count = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (bit_count) {
|
||||
mem_num++;
|
||||
}
|
||||
free(map_buf);
|
||||
} else {
|
||||
perror("allocating mem buffer: ");
|
||||
return;
|
||||
}
|
||||
|
||||
ihk_dump_page_addr += (sizeof(struct ihk_dump_page)+(sizeof(unsigned long)*ihk_dump_page.map_count));
|
||||
}
|
||||
mem_size = (sizeof(dump_mem_chunks_t) + (sizeof(struct dump_mem_chunk) * mem_num));
|
||||
|
||||
// DUMP_QUERY_MEM_AREAS
|
||||
mem_chunks = malloc(mem_size);
|
||||
if (mem_chunks != NULL) {
|
||||
memset(mem_chunks, 0, mem_size);
|
||||
ihk_dump_page_addr = PTOV(dump_page_set.phy_page);
|
||||
|
||||
for (i = 0, index = 0; i < dump_page_set.count; i++) {
|
||||
|
||||
readmem(ihk_dump_page_addr,KVADDR,&ihk_dump_page,sizeof(ihk_dump_page),"",FAULT_ON_ERROR);
|
||||
map_size = sizeof(unsigned long)*ihk_dump_page.map_count;
|
||||
map_buf = malloc(map_size);
|
||||
if (map_buf != NULL) {
|
||||
memset(map_buf,0x00,map_size);
|
||||
readmem((ihk_dump_page_addr+sizeof(struct ihk_dump_page)),KVADDR,map_buf,map_size,"",FAULT_ON_ERROR);
|
||||
|
||||
for (j = 0, bit_count = 0; j < ihk_dump_page.map_count; j++) {
|
||||
for (k = 0; k < 64; k++) {
|
||||
if (((ulong)*(map_buf+j) >> k) & 0x1) {
|
||||
if (!bit_count) {
|
||||
map_start = (unsigned long)(ihk_dump_page.start + ((unsigned long)j << (PAGE_SHIFT+6)));
|
||||
map_start = map_start + ((unsigned long)k << PAGE_SHIFT);
|
||||
}
|
||||
bit_count++;
|
||||
} else {
|
||||
if (bit_count) {
|
||||
mem_chunks->chunks[index].addr = map_start;
|
||||
mem_chunks->chunks[index].size = (bit_count << PAGE_SHIFT);
|
||||
index++;
|
||||
bit_count = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (bit_count) {
|
||||
mem_chunks->chunks[index].addr = map_start;
|
||||
mem_chunks->chunks[index].size = (bit_count << PAGE_SHIFT);
|
||||
index++;
|
||||
}
|
||||
|
||||
ihk_dump_page_addr += (sizeof(struct ihk_dump_page)+(sizeof(unsigned long)*ihk_dump_page.map_count));
|
||||
free(map_buf);
|
||||
} else {
|
||||
perror("allocating mem buffer: ");
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
mem_chunks->nr_chunks = index;
|
||||
|
||||
symbol_bootstrap_mem = symbol_value(BOOTSTRAP_MEM_SYMBOL);
|
||||
|
||||
readmem(symbol_bootstrap_mem,KVADDR,&bootstrap_mem,sizeof(bootstrap_mem),"",FAULT_ON_ERROR);
|
||||
|
||||
/* See load_file() for the calculation below */
|
||||
mem_chunks->kernel_base =
|
||||
(bootstrap_mem + LARGE_PAGE_SIZE * 2 - 1) & LARGE_PAGE_MASK;
|
||||
} else {
|
||||
perror("allocating mem buffer: ");
|
||||
return;
|
||||
}
|
||||
|
||||
// DUMP_READ
|
||||
phys_size = 0;
|
||||
|
||||
// fprintf(fp,"%s: nr chunks: %d\n", __FUNCTION__, mem_chunks->nr_chunks);
|
||||
for (i = 0; i < mem_chunks->nr_chunks; ++i) {
|
||||
// fprintf(fp,"%s: 0x%lx:0x%lx\n",
|
||||
// __FUNCTION__,
|
||||
// mem_chunks->chunks[i].addr,
|
||||
// mem_chunks->chunks[i].size);
|
||||
phys_size += mem_chunks->chunks[i].size;
|
||||
}
|
||||
|
||||
bsize = 0x100000;
|
||||
buf = malloc(bsize);
|
||||
if (!buf) {
|
||||
perror("malloc");
|
||||
return;
|
||||
}
|
||||
|
||||
bfd_init();
|
||||
|
||||
abfd = bfd_fopen(fname, "elf64-x86-64", "w", -1);
|
||||
if (!abfd) {
|
||||
bfd_perror("bfd_fopen");
|
||||
return;
|
||||
}
|
||||
|
||||
ok = bfd_set_format(abfd, bfd_object);
|
||||
if (!ok) {
|
||||
bfd_perror("bfd_set_format");
|
||||
return;
|
||||
}
|
||||
|
||||
t = time(NULL);
|
||||
if (t == (time_t)-1) {
|
||||
perror("time");
|
||||
return;
|
||||
}
|
||||
|
||||
tm = localtime(&t);
|
||||
if (!tm) {
|
||||
perror("localtime");
|
||||
return;
|
||||
}
|
||||
|
||||
date = asctime(tm);
|
||||
if (date) {
|
||||
cpsize = strlen(date) - 1; /* exclude trailing '\n' */
|
||||
scn = bfd_make_section_anyway(abfd, "date");
|
||||
if (!scn) {
|
||||
bfd_perror("bfd_make_section_anyway(date)");
|
||||
return;
|
||||
}
|
||||
|
||||
ok = bfd_set_section_size(abfd, scn, cpsize);
|
||||
if (!ok) {
|
||||
bfd_perror("bfd_set_section_size");
|
||||
return;
|
||||
}
|
||||
|
||||
ok = bfd_set_section_flags(abfd, scn, SEC_HAS_CONTENTS);
|
||||
if (!ok) {
|
||||
bfd_perror("bfd_set_setction_flags");
|
||||
return;
|
||||
}
|
||||
}
|
||||
error = gethostname(hname, sizeof(hname));
|
||||
if (!error) {
|
||||
cpsize = strlen(hname);
|
||||
scn = bfd_make_section_anyway(abfd, "hostname");
|
||||
if (!scn) {
|
||||
bfd_perror("bfd_make_section_anyway(hostname)");
|
||||
return;
|
||||
}
|
||||
|
||||
ok = bfd_set_section_size(abfd, scn, cpsize);
|
||||
if (!ok) {
|
||||
bfd_perror("bfd_set_section_size");
|
||||
return;
|
||||
}
|
||||
|
||||
ok = bfd_set_section_flags(abfd, scn, SEC_HAS_CONTENTS);
|
||||
if (!ok) {
|
||||
bfd_perror("bfd_set_setction_flags");
|
||||
return;
|
||||
}
|
||||
}
|
||||
pw = getpwuid(getuid());
|
||||
if (pw) {
|
||||
cpsize = strlen(pw->pw_name);
|
||||
scn = bfd_make_section_anyway(abfd, "user");
|
||||
if (!scn) {
|
||||
bfd_perror("bfd_make_section_anyway(user)");
|
||||
return;
|
||||
}
|
||||
|
||||
ok = bfd_set_section_size(abfd, scn, cpsize);
|
||||
if (!ok) {
|
||||
bfd_perror("bfd_set_section_size");
|
||||
return;
|
||||
}
|
||||
|
||||
ok = bfd_set_section_flags(abfd, scn, SEC_HAS_CONTENTS);
|
||||
if (!ok) {
|
||||
bfd_perror("bfd_set_setction_flags");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
/* Add section for physical memory chunks information */
|
||||
scn = bfd_make_section_anyway(abfd, "physchunks");
|
||||
if (!scn) {
|
||||
bfd_perror("bfd_make_section_anyway(physchunks)");
|
||||
return;
|
||||
}
|
||||
|
||||
ok = bfd_set_section_size(abfd, scn, mem_size);
|
||||
if (!ok) {
|
||||
bfd_perror("bfd_set_section_size");
|
||||
return;
|
||||
}
|
||||
|
||||
ok = bfd_set_section_flags(abfd, scn, SEC_ALLOC|SEC_HAS_CONTENTS);
|
||||
if (!ok) {
|
||||
bfd_perror("bfd_set_setction_flags");
|
||||
return;
|
||||
}
|
||||
|
||||
for (i = 0; i < mem_chunks->nr_chunks; ++i) {
|
||||
|
||||
physmem_name_buf = malloc(PHYSMEM_NAME_SIZE);
|
||||
memset(physmem_name_buf,0,PHYSMEM_NAME_SIZE);
|
||||
sprintf(physmem_name_buf, "physmem%d",i);
|
||||
|
||||
/* Physical memory contents section */
|
||||
scn = bfd_make_section_anyway(abfd, physmem_name_buf);
|
||||
if (!scn) {
|
||||
bfd_perror("bfd_make_section_anyway(physmem)");
|
||||
return;
|
||||
}
|
||||
|
||||
ok = bfd_set_section_size(abfd, scn, mem_chunks->chunks[i].size);
|
||||
|
||||
if (!ok) {
|
||||
bfd_perror("bfd_set_section_size");
|
||||
return;
|
||||
}
|
||||
|
||||
ok = bfd_set_section_flags(abfd, scn, SEC_ALLOC|SEC_HAS_CONTENTS);
|
||||
if (!ok) {
|
||||
bfd_perror("bfd_set_setction_flags");
|
||||
return;
|
||||
}
|
||||
|
||||
scn->vma = mem_chunks->chunks[i].addr;
|
||||
|
||||
}
|
||||
|
||||
scn = bfd_get_section_by_name(abfd, "date");
|
||||
if (scn) {
|
||||
ok = bfd_set_section_contents(abfd, scn, date, 0, scn->size);
|
||||
if (!ok) {
|
||||
bfd_perror("bfd_set_section_contents(date)");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
scn = bfd_get_section_by_name(abfd, "hostname");
|
||||
if (scn) {
|
||||
ok = bfd_set_section_contents(abfd, scn, hname, 0, scn->size);
|
||||
if (!ok) {
|
||||
bfd_perror("bfd_set_section_contents(hostname)");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
scn = bfd_get_section_by_name(abfd, "user");
|
||||
if (scn) {
|
||||
ok = bfd_set_section_contents(abfd, scn, pw->pw_name, 0, scn->size);
|
||||
if (!ok) {
|
||||
bfd_perror("bfd_set_section_contents(user)");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
scn = bfd_get_section_by_name(abfd, "physchunks");
|
||||
if (scn) {
|
||||
ok = bfd_set_section_contents(abfd, scn, mem_chunks, 0, mem_size);
|
||||
if (!ok) {
|
||||
bfd_perror("bfd_set_section_contents(physchunks)");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
for (i = 0; i < mem_chunks->nr_chunks; ++i) {
|
||||
|
||||
phys_offset = 0;
|
||||
memset(physmem_name,0,sizeof(physmem_name));
|
||||
sprintf(physmem_name, "physmem%d",i);
|
||||
|
||||
scn = bfd_get_section_by_name(abfd, physmem_name);
|
||||
if (!scn) {
|
||||
bfd_perror("err bfd_get_section_by_name(physmem_name)");
|
||||
return ;
|
||||
}
|
||||
|
||||
for (addr = mem_chunks->chunks[i].addr;
|
||||
addr < (mem_chunks->chunks[i].addr + mem_chunks->chunks[i].size);
|
||||
addr += cpsize) {
|
||||
|
||||
cpsize = (mem_chunks->chunks[i].addr + mem_chunks->chunks[i].size) - addr;
|
||||
if (cpsize > bsize) {
|
||||
cpsize = bsize;
|
||||
}
|
||||
|
||||
memset(buf,0x00,cpsize);
|
||||
read_mem_addr = PTOV(addr);
|
||||
read_mem_ret = readmem(read_mem_addr,KVADDR,buf,cpsize,"",FAULT_ON_ERROR|RETURN_ON_ERROR);
|
||||
if (read_mem_ret == TRUE) {
|
||||
ok = bfd_set_section_contents(abfd, scn, buf, phys_offset, cpsize);
|
||||
if (!ok) {
|
||||
bfd_perror("bfd_set_section_contents(physmem)");
|
||||
return;
|
||||
}
|
||||
|
||||
phys_offset += cpsize;
|
||||
} else {
|
||||
fprintf(fp, "readmem error(%d)\n",read_mem_ret);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ok = bfd_close(abfd);
|
||||
if (!ok) {
|
||||
bfd_perror("bfd_close");
|
||||
return;
|
||||
}
|
||||
|
||||
free(buf);
|
||||
free(mem_chunks);
|
||||
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
char *help_ldump2mcdump[] = {
|
||||
"ldump2mcdump", /* command name */
|
||||
"dump format conversion", /* short description */
|
||||
"<os_index> [-o <file_name>]", /* argument synopsis, or " " if none */
|
||||
" This command converts the McKernel dump file format.",
|
||||
"\nEXAMPLE",
|
||||
" ldump2mcdump all command arguments:\n",
|
||||
" crash>ldump2mcdump 0 -o /tmp/mcdump",
|
||||
NULL
|
||||
};
|
||||
|
||||
|
||||
43
executer/user/vmcore2mckdump.in
Normal file
43
executer/user/vmcore2mckdump.in
Normal file
@ -0,0 +1,43 @@
|
||||
#!/bin/sh
|
||||
export VMLINUX=/usr/lib/debug/lib/modules/`uname -r`/vmlinux
|
||||
export INSTALLDIR=@prefix@
|
||||
export INFILE=$1
|
||||
export OUTFILE=$2
|
||||
|
||||
if [ "X$INFILE" = X -o "X$OUTFILE" = X -o "X$3" != X ]; then
|
||||
echo "usage: vmcore2mckdump <vmcore> <mckdump>" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ ! -f "$INFILE" ]; then
|
||||
echo "$INFILE: not found" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
/usr/bin/expect -c "
|
||||
set timeout 60
|
||||
spawn /usr/bin/crash $VMLINUX $INFILE
|
||||
|
||||
expect \"crash>\"
|
||||
send \"mod -s ihk_smp_x86 $INSTALLDIR/kmod/ihk-smp-x86.ko\n\"
|
||||
|
||||
expect \"crash>\"
|
||||
send \"extend $INSTALLDIR/lib/ldump2mcdump.so\n\"
|
||||
|
||||
expect \"crash>\"
|
||||
send \"ldump2mcdump 0 -o $OUTFILE\n\"
|
||||
|
||||
expect \"crash>\"
|
||||
send \"extend -u $INSTALLDIR/lib/ldump2mcdump.so\n\"
|
||||
|
||||
expect \"crash>\"
|
||||
send \"quit\n\"
|
||||
"
|
||||
if [ -f ${OUTFILE} ]; then
|
||||
echo "mcdump: ${OUTFILE} is extracted."
|
||||
exit 0
|
||||
else
|
||||
echo "Error: failed to extract mcdump."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
Reference in New Issue
Block a user