From 756b6f0fcb766fa54b1d769821819f4c6856ec77 Mon Sep 17 00:00:00 2001 From: Alexander Aksenov Date: Wed, 14 Jan 2015 15:19:58 +0300 Subject: [PATCH] [IMPROVE] Add preload call type support Change-Id: Ia6c53f17a53f07161b0397ace000525890971f9e Signed-off-by: Alexander Aksenov --- daemon/da_inst.c | 2 +- daemon/da_protocol_inst.c | 23 ++++++++++++++++++++--- daemon/da_protocol_inst.h | 2 +- 3 files changed, 22 insertions(+), 5 deletions(-) diff --git a/daemon/da_inst.c b/daemon/da_inst.c index b4a5544..9756e79 100644 --- a/daemon/da_inst.c +++ b/daemon/da_inst.c @@ -814,7 +814,7 @@ int msg_start(struct msg_buf_t *data, struct user_space_inst_t *us_inst, goto msg_start_exit; } - if (!add_preload_get_caller_probe(&us_inst->lib_inst_list)) { + if (!add_preload_probes(&us_inst->lib_inst_list)) { LOGE("cannot add preload probe\n"); res = 1; goto msg_start_exit; diff --git a/daemon/da_protocol_inst.c b/daemon/da_protocol_inst.c index 94f78f0..f803aa0 100644 --- a/daemon/da_protocol_inst.c +++ b/daemon/da_protocol_inst.c @@ -411,10 +411,11 @@ int feature_add_lib_inst_list(struct ld_feature_list_el_t *ld_lib_list, return 1; } -int add_preload_get_caller_probe(struct lib_list_t **lib_list) +int add_preload_probes(struct lib_list_t **lib_list) { struct lib_list_t *preload_lib = new_lib(); struct probe_list_t *get_caller_probe = new_probe(); + struct probe_list_t *get_call_type_probe = new_probe(); struct us_func_inst_plane_t *func = NULL; if (preload_lib == NULL) { @@ -428,8 +429,9 @@ int add_preload_get_caller_probe(struct lib_list_t **lib_list) } preload_lib->lib->bin_path = probe_lib; - preload_lib->func_num = 1; + preload_lib->func_num = 2; + /* Add get_caller probe */ func = malloc(sizeof(*func)); if (func == NULL) { LOGE("preload get_caller probe no memory\n"); @@ -444,7 +446,22 @@ int add_preload_get_caller_probe(struct lib_list_t **lib_list) probe_list_append(preload_lib, get_caller_probe); - preload_lib->func_num = 1; + /* Add get_call_type probe */ + func = malloc(sizeof(*func)); + if (func == NULL) { + LOGE("preload get_call_type probe no memory\n"); + return -ENOMEM; + } + + func->func_addr = get_call_type_addr; + func->probe_type = 5; /* GET_CALL_TYPE probe type */ + + get_call_type_probe->size = sizeof(*func); + get_call_type_probe->func = func; + + probe_list_append(preload_lib, get_call_type_probe); + + preload_lib->func_num = 2; preload_lib->size += strlen(preload_lib->lib->bin_path) + 1 + sizeof(preload_lib->func_num); preload_lib->hash = calc_lib_hash(preload_lib->lib); diff --git a/daemon/da_protocol_inst.h b/daemon/da_protocol_inst.h index 6b42684..d793719 100644 --- a/daemon/da_protocol_inst.h +++ b/daemon/da_protocol_inst.h @@ -40,5 +40,5 @@ int parse_app_inst_list(struct msg_buf_t *msg, int feature_add_lib_inst_list(struct ld_feature_list_el_t *ld_lib_list, struct lib_list_t **lib_list, int preload_probe_type); -int add_preload_get_caller_probe(struct lib_list_t **lib_list); +int add_preload_probes(struct lib_list_t **lib_list); #endif /* __DA_PROTOCOL_INST__ */ -- 2.7.4