mirror of
https://github.com/checkpoint-restore/criu
synced 2025-08-30 05:48:05 +00:00
dump, kernel: Add start/end_code data
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
This commit is contained in:
parent
b2c4ebf207
commit
ce65f2f718
40
cr-dump.c
40
cr-dump.c
@ -416,7 +416,8 @@ err:
|
||||
#define assign_reg(dst, src, e) dst.e = (__typeof__(dst.e))src.e
|
||||
#define assign_array(dst, src, e) memcpy(&dst.e, &src.e, sizeof(dst.e))
|
||||
|
||||
static int get_task_stat(pid_t pid, u8 *comm, u32 *flags)
|
||||
static int get_task_stat(pid_t pid, u8 *comm, u32 *flags,
|
||||
u64 *start_code, u64 *end_code)
|
||||
{
|
||||
FILE *file = NULL;
|
||||
char *tok1, *tok2;
|
||||
@ -446,21 +447,43 @@ static int get_task_stat(pid_t pid, u8 *comm, u32 *flags)
|
||||
|
||||
if (!ret) {
|
||||
ret = -1;
|
||||
for (i = 0; i < 8; i++) {
|
||||
for (i = 0; i < 7; i++) {
|
||||
tok1 = strtok(NULL, " ");
|
||||
if (!tok1) {
|
||||
pr_err("/proc/%d/stat is corrupted", pid);
|
||||
goto err;
|
||||
}
|
||||
if (!tok1)
|
||||
goto err_corrupted;
|
||||
}
|
||||
*flags = atoi(tok1);
|
||||
ret = 0;
|
||||
}
|
||||
|
||||
if (!ret) {
|
||||
ret = -1;
|
||||
for (i = 0; i < 15; i++) {
|
||||
tok1 = strtok(NULL, " ");
|
||||
if (!tok1)
|
||||
goto err_corrupted;
|
||||
}
|
||||
|
||||
tok1 = strtok(NULL, " ");
|
||||
if (!tok1)
|
||||
goto err_corrupted;
|
||||
*start_code = atol(tok1);
|
||||
|
||||
tok1 = strtok(NULL, " ");
|
||||
if (!tok1)
|
||||
goto err_corrupted;
|
||||
*end_code = atol(tok1);
|
||||
ret = 0;
|
||||
}
|
||||
|
||||
err:
|
||||
if (file)
|
||||
fclose(file);
|
||||
return ret;
|
||||
|
||||
err_corrupted:
|
||||
pr_err("/proc/%d/stat is corrupted", pid);
|
||||
goto err;
|
||||
}
|
||||
|
||||
static int get_task_personality(pid_t pid, u32 *personality)
|
||||
@ -619,7 +642,10 @@ static int dump_task_core_seized(pid_t pid, struct cr_fdset *cr_fdset)
|
||||
pr_info("OK\n");
|
||||
|
||||
pr_info("Obtainting task stat ... ");
|
||||
ret = get_task_stat(pid, core->task_comm, &core->task_flags);
|
||||
ret = get_task_stat(pid, core->task_comm,
|
||||
&core->task_flags,
|
||||
&core->mm_start_code,
|
||||
&core->mm_end_code);
|
||||
if (ret)
|
||||
goto err_free;
|
||||
pr_info("OK\n");
|
||||
|
10
cr-show.c
10
cr-show.c
@ -107,7 +107,7 @@ static void show_core_rest(struct cr_fdset *cr_fdset)
|
||||
int fd_core, i;
|
||||
u32 personality;
|
||||
char comm[TASK_COMM_LEN];
|
||||
u64 mm_brk;
|
||||
u64 mm_brk, mm_start_code, mm_end_code;
|
||||
|
||||
fd_core = cr_fdset->desc[CR_FD_CORE].fd;
|
||||
if (fd_core < 0)
|
||||
@ -122,9 +122,17 @@ static void show_core_rest(struct cr_fdset *cr_fdset)
|
||||
lseek(fd_core, GET_FILE_OFF(struct core_entry, mm_brk), SEEK_SET);
|
||||
read_ptr_safe(fd_core, &mm_brk, err);
|
||||
|
||||
lseek(fd_core, GET_FILE_OFF(struct core_entry, mm_start_code), SEEK_SET);
|
||||
read_ptr_safe(fd_core, &mm_start_code, err);
|
||||
|
||||
lseek(fd_core, GET_FILE_OFF(struct core_entry, mm_end_code), SEEK_SET);
|
||||
read_ptr_safe(fd_core, &mm_end_code, err);
|
||||
|
||||
pr_info("Personality: %x\n", personality);
|
||||
pr_info("Command: %s\n", comm);
|
||||
pr_info("Brk: %lx\n", mm_brk);
|
||||
pr_info("Start code: %lx\n", mm_start_code);
|
||||
pr_info("End code: %lx\n", mm_end_code);
|
||||
err:
|
||||
return;
|
||||
}
|
||||
|
@ -182,6 +182,8 @@ struct core_entry {
|
||||
u8 task_comm[TASK_COMM_LEN];
|
||||
u32 task_flags;
|
||||
u64 mm_brk;
|
||||
u64 mm_start_code;
|
||||
u64 mm_end_code;
|
||||
};
|
||||
u8 __core_pad[CKPT_CORE_SIZE];
|
||||
};
|
||||
|
@ -35,8 +35,8 @@ Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
|
||||
fs/binfmt_elf_ckpt.c | 389 ++++++++++++++++++++++++++++++++++++++++
|
||||
fs/exec.c | 27 +-
|
||||
include/linux/binfmts.h | 1
|
||||
include/linux/elf_ckpt.h | 97 +++++++++
|
||||
12 files changed, 799 insertions(+), 12 deletions(-)
|
||||
include/linux/elf_ckpt.h | 99 ++++++++++
|
||||
12 files changed, 801 insertions(+), 12 deletions(-)
|
||||
|
||||
Index: linux-2.6.git/arch/x86/include/asm/elf.h
|
||||
===================================================================
|
||||
@ -719,8 +719,8 @@ Index: linux-2.6.git/fs/binfmt_elf_ckpt.c
|
||||
+ goto out_unmap;
|
||||
+ }
|
||||
+
|
||||
+ current->mm->start_code = start_code;
|
||||
+ current->mm->end_code = end_code;
|
||||
+ current->mm->start_code = core_entry->mm_start_code;
|
||||
+ current->mm->end_code = core_entry->mm_end_code;
|
||||
+ current->mm->start_data = start_data;
|
||||
+ current->mm->end_data = end_data;
|
||||
+ current->mm->start_stack = start_stack;
|
||||
@ -886,7 +886,7 @@ Index: linux-2.6.git/include/linux/elf_ckpt.h
|
||||
===================================================================
|
||||
--- /dev/null
|
||||
+++ linux-2.6.git/include/linux/elf_ckpt.h
|
||||
@@ -0,0 +1,97 @@
|
||||
@@ -0,0 +1,99 @@
|
||||
+#ifndef _LINUX_ELF_CHECKPOINT_H
|
||||
+#define _LINUX_ELF_CHECKPOINT_H
|
||||
+
|
||||
@ -965,6 +965,8 @@ Index: linux-2.6.git/include/linux/elf_ckpt.h
|
||||
+ __u8 task_comm[CKPT_TASK_COMM_LEN];
|
||||
+ __u32 task_flags;
|
||||
+ __u64 mm_brk;
|
||||
+ __u64 mm_start_code;
|
||||
+ __u64 mm_end_code;
|
||||
+ };
|
||||
+ __u8 __core_pad[CKPT_CORE_SIZE];
|
||||
+ };
|
||||
|
Loading…
x
Reference in New Issue
Block a user