Commit d2dfdeff authored by Alexander Kartashov's avatar Alexander Kartashov Committed by Pavel Emelyanov

cr-dump.c: moved thread core initialization into the function arch_alloc_thread_info().

Signed-off-by: 's avatarAlexander Kartashov <alekskartashov@parallels.com>
Signed-off-by: 's avatarPavel Emelyanov <xemul@parallels.com>
parent 1c8be2b9
...@@ -198,3 +198,65 @@ out: ...@@ -198,3 +198,65 @@ out:
err: err:
return ret; return ret;
} }
int arch_alloc_thread_info(CoreEntry *core)
{
ThreadInfoX86 *thread_info;
UserX86RegsEntry *gpregs;
UserX86FpregsEntry *fpregs;
ThreadCoreEntry *thread_core;
thread_info = xmalloc(sizeof(*thread_info));
if (!thread_info)
goto err;
thread_info_x86__init(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));
if (!gpregs)
goto err;
user_x86_regs_entry__init(gpregs);
thread_info->gpregs = gpregs;
if (cpu_has_feature(X86_FEATURE_FPU)) {
fpregs = xmalloc(sizeof(*fpregs));
if (!fpregs)
goto err;
user_x86_fpregs_entry__init(fpregs);
thread_info->fpregs = fpregs;
/* These are numbers from kernel */
fpregs->n_st_space = 32;
fpregs->n_xmm_space = 64;
fpregs->st_space = xzalloc(pb_repeated_size(fpregs, st_space));
fpregs->xmm_space = xzalloc(pb_repeated_size(fpregs, xmm_space));
if (!fpregs->st_space || !fpregs->xmm_space)
goto err;
if (cpu_has_feature(X86_FEATURE_XSAVE)) {
UserX86XsaveEntry *xsave;
xsave = xmalloc(sizeof(*xsave));
if (!xsave)
goto err;
user_x86_xsave_entry__init(xsave);
thread_info->fpregs->xsave = xsave;
xsave->n_ymmh_space = 64;
xsave->ymmh_space = xzalloc(pb_repeated_size(xsave, ymmh_space));
if (!xsave->ymmh_space)
goto err;
}
}
return 0;
err:
return 1;
}
...@@ -2,5 +2,6 @@ ...@@ -2,5 +2,6 @@
#define __CR_ASM_DUMP_H__ #define __CR_ASM_DUMP_H__
extern int get_task_regs(pid_t pid, CoreEntry *core, const struct parasite_ctl *ctl); extern int get_task_regs(pid_t pid, CoreEntry *core, const struct parasite_ctl *ctl);
extern int arch_alloc_thread_info(CoreEntry *core);
#endif #endif
...@@ -723,12 +723,8 @@ static CoreEntry *core_entry_alloc(int alloc_thread_info, ...@@ -723,12 +723,8 @@ static CoreEntry *core_entry_alloc(int alloc_thread_info,
int alloc_ids) int alloc_ids)
{ {
CoreEntry *core; CoreEntry *core;
ThreadInfoX86 *thread_info;
UserX86RegsEntry *gpregs;
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)
...@@ -738,55 +734,8 @@ static CoreEntry *core_entry_alloc(int alloc_thread_info, ...@@ -738,55 +734,8 @@ static CoreEntry *core_entry_alloc(int alloc_thread_info,
core->mtype = CORE_ENTRY__MARCH__X86_64; core->mtype = CORE_ENTRY__MARCH__X86_64;
if (alloc_thread_info) { if (alloc_thread_info) {
thread_info = xmalloc(sizeof(*thread_info)); if (arch_alloc_thread_info(core))
if (!thread_info)
goto err; goto err;
thread_info_x86__init(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));
if (!gpregs)
goto err;
user_x86_regs_entry__init(gpregs);
thread_info->gpregs = gpregs;
if (cpu_has_feature(X86_FEATURE_FPU)) {
fpregs = xmalloc(sizeof(*fpregs));
if (!fpregs)
goto err;
user_x86_fpregs_entry__init(fpregs);
thread_info->fpregs = fpregs;
/* These are numbers from kernel */
fpregs->n_st_space = 32;
fpregs->n_xmm_space = 64;
fpregs->st_space = xzalloc(pb_repeated_size(fpregs, st_space));
fpregs->xmm_space = xzalloc(pb_repeated_size(fpregs, xmm_space));
if (!fpregs->st_space || !fpregs->xmm_space)
goto err;
if (cpu_has_feature(X86_FEATURE_XSAVE)) {
UserX86XsaveEntry *xsave;
xsave = xmalloc(sizeof(*xsave));
if (!xsave)
goto err;
user_x86_xsave_entry__init(xsave);
thread_info->fpregs->xsave = xsave;
xsave->n_ymmh_space = 64;
xsave->ymmh_space = xzalloc(pb_repeated_size(xsave, ymmh_space));
if (!xsave->ymmh_space)
goto err;
}
}
} }
if (alloc_tc) { if (alloc_tc) {
......
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