From: Alexander Aksenov Date: Fri, 27 Feb 2015 12:43:27 +0000 (+0300) Subject: [IMPROVE] Breakpoint probe msg saving X-Git-Tag: submit/tizen/20151105.071836~30 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=e2492931eba31af71fc8cb185173a9775f61e485;p=platform%2Fcore%2Fsystem%2Fswap-probe.git [IMPROVE] Breakpoint probe msg saving Change-Id: I7a1d3b0c07108edf620f8e9166327240fd354545 Signed-off-by: Alexander Aksenov --- diff --git a/helper/dacapture.c b/helper/dacapture.c index 2c2e3d0..95ea6c6 100755 --- a/helper/dacapture.c +++ b/helper/dacapture.c @@ -430,7 +430,7 @@ int captureScreen() /* pack probe */ PACK_COMMON_BEGIN(MSG_PROBE_SCREENSHOT, API_ID_captureScreen, "", 0); - PACK_COMMON_END('d', 0, 0, 0); + PACK_COMMON_END_THOUGH('d', 0, 0, 0); PACK_SCREENSHOT(dstpath, getOrientation()); SET_MSG_LEN(); log.length = GET_MSG_LEN() + MSG_HDR_LEN + strlen(dstpath) + 1; diff --git a/helper/libdaprobe.c b/helper/libdaprobe.c index 96b6709..33ca3f0 100755 --- a/helper/libdaprobe.c +++ b/helper/libdaprobe.c @@ -868,6 +868,15 @@ unsigned char get_call_type(unsigned char call_type) return call_type; } +void write_msg(unsigned long __unused msg_buf, + size_t __unused len, + unsigned long __unused call_type_p, + unsigned long __unused caller_p) +{ + return; +} + + /************************************************************************ * probe functions ************************************************************************/ diff --git a/include/binproto.h b/include/binproto.h index 91813e9..cb785eb 100644 --- a/include/binproto.h +++ b/include/binproto.h @@ -327,6 +327,8 @@ static char __attribute__((used)) *pack_ret(char *to, char ret_type, ...) #define BUF_PTR p #define RET_PTR ret_p +#define CALLER_PTR caller_p +#define CALL_TYPE_PTR call_type_p #define PACK_INT32(val) \ BUF_PTR = pack_int32(BUF_PTR, val); #define PACK_INT64(val) \ @@ -351,8 +353,20 @@ static char __attribute__((used)) *pack_ret(char *to, char ret_type, ...) do { /* PACK_COMMON_END */ \ BUF_PTR = pack_ret(RET_PTR, ret_type, (uintptr_t)ret); /* return val */ \ BUF_PTR = pack_int64(BUF_PTR, (uint64_t)errn); /* errno */ \ - BUF_PTR = pack_int32(BUF_PTR, (uint32_t)CALL_TYPE); /* internal call*/ \ - BUF_PTR = pack_int64(BUF_PTR, (uintptr_t)CALLER_ADDRESS); /*caller addr*/\ + CALL_TYPE_PTR = BUF_PTR; \ + BUF_PTR = pack_int32(BUF_PTR, (uint32_t)0); /* internal call*/ \ + CALLER_PTR = BUF_PTR; \ + BUF_PTR = pack_int64(BUF_PTR, (uintptr_t)0); /*caller addr*/ \ + BUF_PTR = pack_int32(BUF_PTR, 0); /* reserved */ \ + BUF_PTR = pack_int32(BUF_PTR, 0); /* reserved */ \ + } while (0) + +#define PACK_COMMON_END_THOUGH(ret_type, ret, errn, intern_call) \ + do { /* PACK_COMMON_END */ \ + BUF_PTR = pack_ret(RET_PTR, ret_type, (uintptr_t)ret); /* return val */ \ + BUF_PTR = pack_int64(BUF_PTR, (uint64_t)errn); /* errno */ \ + BUF_PTR = pack_int32(BUF_PTR, (uint32_t)0); /* internal call*/ \ + BUF_PTR = pack_int64(BUF_PTR, (uintptr_t)0); /*caller addr*/\ BUF_PTR = pack_int32(BUF_PTR, 0); /* reserved */ \ BUF_PTR = pack_int32(BUF_PTR, 0); /* reserved */ \ } while (0) @@ -497,7 +511,9 @@ static char __attribute__((used)) *pack_ret(char *to, char ret_type, ...) #define PREPARE_LOCAL_BUF() \ char *LOCAL_BUF = (char *)(*real_malloc)(MAX_LOCAL_BUF_SIZE); \ char *BUF_PTR = LOCAL_BUF; \ - char *RET_PTR = NULL + char *RET_PTR = NULL; \ + char *CALL_TYPE_PTR = NULL; \ + char *CALLER_PTR = NULL #define PREPARE_LOCAL_BUF_THOUGH(BUFF) \ char *LOCAL_BUF = BUFF; \ @@ -515,7 +531,7 @@ static char __attribute__((used)) *pack_ret(char *to, char ret_type, ...) #define FLUSH_LOCAL_BUF() \ SET_MSG_LEN(); \ - send(gTraceInfo.socket.daemonSock, msg_buf, (p - msg_buf), 0); \ + WRITE_MSG(msg_buf, (p - msg_buf), CALL_TYPE_PTR, CALLER_PTR); \ free(LOCAL_BUF); \ LOCAL_BUF = NULL diff --git a/include/daprobe.h b/include/daprobe.h index 87d7a45..9cd3921 100644 --- a/include/daprobe.h +++ b/include/daprobe.h @@ -63,6 +63,8 @@ extern "C"{ unsigned long get_caller_addr(unsigned long caller_addr); unsigned char get_call_type(unsigned char call_type); +void write_msg(unsigned long msg_buf, size_t len, unsigned long call_type_p, + unsigned long caller_p); #define CALLER_ADDRESS \ ((void*) get_caller_addr(0xbadbeef)) @@ -70,6 +72,10 @@ unsigned char get_call_type(unsigned char call_type); #define CALL_TYPE \ ((uint32_t) get_call_type(0xff)) +#define WRITE_MSG(msg_buf, len, call_type_p, caller_p) \ + (write_msg((unsigned long)msg_buf, (size_t)len, \ + (unsigned long)call_type_p, (unsigned long)caller_p)) + #define BACKTRACE_SYMBOLS cached_backtrace_symbols typedef enum diff --git a/scripts/gen_headers.py b/scripts/gen_headers.py index 6c48469..3a15d75 100755 --- a/scripts/gen_headers.py +++ b/scripts/gen_headers.py @@ -382,9 +382,15 @@ def __print_probe_lib(file, da_inst_dir, da_lib, probe_lib): print "WARNING: address is not found!" return + write_msg_addr = __get_addr_by_funcname_handler(probe_lib, "write_msg") + if write_msg_addr is None: + print "WARNING: address is not found!" + return + file.write("static const char *probe_lib = \"" + da_inst_dir + "/" + da_lib + "\";\n") file.write("static unsigned long get_caller_addr = 0x" + get_caller_addr + ";\n") file.write("static unsigned long get_call_type_addr = 0x" + get_call_type_addr + ";\n") + file.write("static unsigned long write_msg_addr = 0x" + write_msg_addr + ";\n") def generate_headers(dict, da_inst_dir, da_lib, probe_lib):