Add private data field to struct tcb
We need to be able to store private data in the struct tcb across it's
lifetime. To ensure proper deallocation of this stored data a callback
must be provided along with the data. The callback is executed
automatically on exiting syscall, and when the life of the tcb ends.
* defs.h (struct tcb): Add _priv_data and _free_priv_data fields.
(get_tcb_priv_data, set_tcb_priv_data, free_tcb_priv_data):
New prototypes.
(get_tcb_priv_ulong, set_tcb_priv_ulong): New static inline functions.
* strace.c (get_tcb_priv_data, set_tcb_priv_data, free_tcb_priv_data):
New functions.
(droptcb): Call free_tcb_priv_data.
* syscall.c (trace_syscall_exiting): Call free_tcb_priv_data
when clearing TCB_INSYSCALL flag.
Signed-off-by: Patrik Jakobsson <patrik.jakobsson@linux.intel.com>
Signed-off-by: Dmitry V. Levin <ldv@altlinux.org>
diff --git a/syscall.c b/syscall.c
index c61f827..5c83818 100644
--- a/syscall.c
+++ b/syscall.c
@@ -904,6 +904,7 @@
line_ended();
tcp->flags &= ~TCB_INSYSCALL;
tcp->sys_func_rval = 0;
+ free_tcb_priv_data(tcp);
return res;
}
tcp->s_prev_ent = tcp->s_ent;
@@ -1085,6 +1086,7 @@
ret:
tcp->flags &= ~TCB_INSYSCALL;
tcp->sys_func_rval = 0;
+ free_tcb_priv_data(tcp);
return 0;
}