Commit f212e6fe authored by Pavel Emelyanov's avatar Pavel Emelyanov

dump: Reformat vma dumping a little

Signed-off-by: 's avatarPavel Emelyanov <xemul@parallels.com>
parent c3051512
...@@ -440,36 +440,16 @@ static struct shmem_info* shmem_find(unsigned long shmid) ...@@ -440,36 +440,16 @@ static struct shmem_info* shmem_find(unsigned long shmid)
return NULL; return NULL;
} }
static int dump_task_mappings(pid_t pid, const struct list_head *vma_area_list, static int add_shmem_area(pid_t pid, struct vma_entry *vma)
const struct cr_fdset *cr_fdset)
{ {
struct vma_area *vma_area;
int ret = -1;
pr_info("\n");
pr_info("Dumping mappings (pid: %d)\n", pid);
pr_info("----------------------------------------\n");
list_for_each_entry(vma_area, vma_area_list, list) {
struct vma_entry *vma = &vma_area->vma;
if (!vma_entry_is(vma, VMA_AREA_REGULAR))
continue;
if (vma_entry_is(vma, VMA_AREA_SYSVIPC))
continue;
pr_info_vma(vma_area);
if (vma_entry_is(vma, VMA_ANON_SHARED)) {
struct shmem_info *si; struct shmem_info *si;
unsigned long size = vma->pgoff + (vma->end - vma->start); unsigned long size = vma->pgoff + (vma->end - vma->start);
si = shmem_find(vma_area->vma.shmid); si = shmem_find(vma->shmid);
if (si) { if (si) {
if (si->size < size) if (si->size < size)
si->size = size; si->size = size;
continue; return 0;
} }
nr_shmems++; nr_shmems++;
...@@ -483,10 +463,14 @@ static int dump_task_mappings(pid_t pid, const struct list_head *vma_area_list, ...@@ -483,10 +463,14 @@ static int dump_task_mappings(pid_t pid, const struct list_head *vma_area_list,
si->pid = pid; si->pid = pid;
si->start = vma->start; si->start = vma->start;
si->end = vma->end; si->end = vma->end;
si->shmid = vma_area->vma.shmid; si->shmid = vma->shmid;
return 0;
}
} else if (vma_entry_is(vma, VMA_FILE_PRIVATE) || static int dump_filemap(pid_t pid, struct vma_entry *vma, int file_fd,
vma_entry_is(vma, VMA_FILE_SHARED)) { const struct cr_fdset *fdset)
{
struct fd_parms p = { struct fd_parms p = {
.fd_name = vma->start, .fd_name = vma->start,
.id = FD_ID_INVALID, .id = FD_ID_INVALID,
...@@ -494,17 +478,44 @@ static int dump_task_mappings(pid_t pid, const struct list_head *vma_area_list, ...@@ -494,17 +478,44 @@ static int dump_task_mappings(pid_t pid, const struct list_head *vma_area_list,
.type = FDINFO_MAP, .type = FDINFO_MAP,
}; };
if (vma->prot & PROT_WRITE && if ((vma->prot & PROT_WRITE) && vma_entry_is(vma, VMA_FILE_SHARED))
vma_entry_is(vma, VMA_FILE_SHARED))
p.flags = O_RDWR; p.flags = O_RDWR;
else else
p.flags = O_RDONLY; p.flags = O_RDONLY;
ret = dump_one_reg_file(&p, vma_area->vm_file_fd, cr_fdset, 0); return dump_one_reg_file(&p, file_fd, fdset, 0);
}
static int dump_task_mappings(pid_t pid, const struct list_head *vma_area_list,
const struct cr_fdset *cr_fdset)
{
struct vma_area *vma_area;
int ret = -1;
pr_info("\n");
pr_info("Dumping mappings (pid: %d)\n", pid);
pr_info("----------------------------------------\n");
list_for_each_entry(vma_area, vma_area_list, list) {
struct vma_entry *vma = &vma_area->vma;
if (!vma_entry_is(vma, VMA_AREA_REGULAR))
continue;
if (vma_entry_is(vma, VMA_AREA_SYSVIPC))
continue;
pr_info_vma(vma_area);
if (vma_entry_is(vma, VMA_ANON_SHARED))
ret = add_shmem_area(pid, vma);
else if (vma_entry_is(vma, VMA_FILE_PRIVATE) ||
vma_entry_is(vma, VMA_FILE_SHARED))
ret = dump_filemap(pid, vma, vma_area->vm_file_fd, cr_fdset);
if (ret) if (ret)
goto err; goto err;
} }
}
ret = 0; ret = 0;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment