Commit 097d73a1 authored by Cyrill Gorcunov's avatar Cyrill Gorcunov Committed by Pavel Emelyanov

dump: Add futex robust list dumping v3

This patch introduces ThreadCoreEntry protobuf structure which is to carry
thread-specific arch-independent information.

Now put there the c/r futex robust lists.
Signed-off-by: 's avatarCyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: 's avatarPavel Emelyanov <xemul@parallels.com>
parent 1a62282d
...@@ -565,6 +565,24 @@ out: ...@@ -565,6 +565,24 @@ out:
return ret; return ret;
} }
static int get_task_futex_robust_list(pid_t pid, ThreadCoreEntry *info)
{
struct robust_list_head *head = NULL;
size_t len = 0;
int ret;
ret = sys_get_robust_list(pid, &head, &len);
if (ret) {
pr_err("Failed obtaining futex robust list on %d\n", pid);
return -1;
}
info->futex_rla = (u64)head;
info->futex_rla_len = (u32)len;
return 0;
}
static int get_task_personality(pid_t pid, u32 *personality) static int get_task_personality(pid_t pid, u32 *personality)
{ {
FILE *file = NULL; FILE *file = NULL;
...@@ -740,6 +758,7 @@ static void core_entry_free(CoreEntry *core) ...@@ -740,6 +758,7 @@ static void core_entry_free(CoreEntry *core)
xfree(core->thread_info->fpregs); xfree(core->thread_info->fpregs);
} }
xfree(core->thread_info); xfree(core->thread_info);
xfree(core->thread_core);
xfree(core->tc); xfree(core->tc);
xfree(core->ids); xfree(core->ids);
} }
...@@ -755,6 +774,7 @@ static CoreEntry *core_entry_alloc(int alloc_thread_info, ...@@ -755,6 +774,7 @@ static CoreEntry *core_entry_alloc(int alloc_thread_info,
UserX86FpregsEntry *fpregs; UserX86FpregsEntry *fpregs;
TaskCoreEntry *tc; TaskCoreEntry *tc;
TaskKobjIdsEntry *ids; TaskKobjIdsEntry *ids;
ThreadCoreEntry *thread_core;
core = xmalloc(sizeof(*core)); core = xmalloc(sizeof(*core));
if (!core) if (!core)
...@@ -770,6 +790,12 @@ static CoreEntry *core_entry_alloc(int alloc_thread_info, ...@@ -770,6 +790,12 @@ static CoreEntry *core_entry_alloc(int alloc_thread_info,
thread_info_x86__init(thread_info); thread_info_x86__init(thread_info);
core->thread_info = thread_info; core->thread_info = thread_info;
thread_core = xmalloc(sizeof(*thread_core));
if (!thread_core)
goto err;
thread_core_entry__init(thread_core);
core->thread_core = thread_core;
gpregs = xmalloc(sizeof(*gpregs)); gpregs = xmalloc(sizeof(*gpregs));
if (!gpregs) if (!gpregs)
goto err; goto err;
...@@ -847,6 +873,10 @@ static int dump_task_core_all(pid_t pid, const struct proc_pid_stat *stat, ...@@ -847,6 +873,10 @@ static int dump_task_core_all(pid_t pid, const struct proc_pid_stat *stat,
if (ret) if (ret)
goto err_free; goto err_free;
ret = get_task_futex_robust_list(pid, core->thread_core);
if (ret)
goto err_free;
ret = get_task_personality(pid, &core->tc->personality); ret = get_task_personality(pid, &core->tc->personality);
if (ret) if (ret)
goto err_free; goto err_free;
...@@ -1233,6 +1263,10 @@ static int dump_task_thread(struct parasite_ctl *parasite_ctl, struct pid *tid) ...@@ -1233,6 +1263,10 @@ static int dump_task_thread(struct parasite_ctl *parasite_ctl, struct pid *tid)
if (ret) if (ret)
goto err_free; goto err_free;
ret = get_task_futex_robust_list(pid, core->thread_core);
if (ret)
goto err_free;
ret = parasite_dump_thread_seized(parasite_ctl, pid, &taddr, &tid->virt); ret = parasite_dump_thread_seized(parasite_ctl, pid, &taddr, &tid->virt);
if (ret) { if (ret) {
pr_err("Can't dump tid address for pid %d", pid); pr_err("Can't dump tid address for pid %d", pid);
......
...@@ -66,6 +66,11 @@ message thread_info_x86 { ...@@ -66,6 +66,11 @@ message thread_info_x86 {
required user_x86_fpregs_entry fpregs = 3; required user_x86_fpregs_entry fpregs = 3;
} }
message thread_core_entry {
required uint64 futex_rla = 1;
required uint32 futex_rla_len = 2;
}
message core_entry { message core_entry {
enum march { enum march {
UNKNOWN = 0; UNKNOWN = 0;
...@@ -77,4 +82,5 @@ message core_entry { ...@@ -77,4 +82,5 @@ message core_entry {
optional task_core_entry tc = 3; optional task_core_entry tc = 3;
optional task_kobj_ids_entry ids = 4; optional task_kobj_ids_entry ids = 4;
optional thread_core_entry thread_core = 5;
} }
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