X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=include%2Fbinproto.h;h=f2852db901dc80f6433bf9f1e0fa34aeeb6acfa0;hb=03e854493fd7763ad4d9b4553d15424d66a8a3d8;hp=8bb85fbef32bc5aa08462db9823b2f9e7e9c954e;hpb=fa1eb2c420c7da280f3ba2fc0d0c1fb5d02fd9a8;p=platform%2Fcore%2Fsystem%2Fswap-probe.git diff --git a/include/binproto.h b/include/binproto.h index 8bb85fb..f2852db 100644 --- a/include/binproto.h +++ b/include/binproto.h @@ -1,3 +1,32 @@ +/* + * DA probe + * + * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. + * + * Contact: + * + * Nikita Kalyazin + * Anastasia Lyupa + * + * This library is free software; you can redistribute it and/or modify it under + * the terms of the GNU Lesser General Public License as published by the + * Free Software Foundation; either version 2.1 of the License, or (at your option) + * any later version. + * + * This library is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public + * License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this library; if not, write to the Free Software Foundation, Inc., 51 + * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Contributors: + * - Samsung RnD Institute Russia + * + */ + #ifndef __BIN_PROTO_H__ #define __BIN_PROTO_H__ @@ -20,11 +49,14 @@ #include +#include +#include "dahelper.h" + #define MSG_PROBE_MEMORY 0x3001 #define MSG_PROBE_UICONTROL 0x3002 #define MSG_PROBE_UIEVENT 0x3003 -#define MSG_PROBE_RESOUCE 0x3004 -#define MSG_PROBE_LIFECYCLE 0x30015 +#define MSG_PROBE_RESOURCE 0x3004 +#define MSG_PROBE_LIFECYCLE 0x3005 #define MSG_PROBE_SCREENSHOT 0x3006 #define MSG_PROBE_SCENE 0x3007 #define MSG_PROBE_THREAD 0x3008 @@ -57,6 +89,12 @@ static inline char *pack_string(char *to, const char *str) return to + len; } +static inline char *pack_double(char *to, double val) +{ + *(double *)to = val; + return to + sizeof(double); +} + static inline char *pack_timestamp(char *to) { struct timeval tv; @@ -74,6 +112,10 @@ static inline char *pack_args(char *to, const char *fmt, ...) uint32_t num = strlen(fmt); const char *t = fmt; + if(*t == '\0') { + num = 0; + } + memcpy(to, &num, sizeof(num)); to += sizeof(num); @@ -180,7 +222,7 @@ static inline char *pack_args(char *to, const char *fmt, ...) #define PACK_MEMORY(size, memory_api_type, addr) \ do { \ - BUF_PTR = pack_int32(BUF_PTR, size); \ + BUF_PTR = pack_int64(BUF_PTR, size); \ BUF_PTR = pack_int32(BUF_PTR, memory_api_type); \ BUF_PTR = pack_int64(BUF_PTR, (uintptr_t)addr); \ } while (0) @@ -215,35 +257,53 @@ static inline char *pack_args(char *to, const char *fmt, ...) BUF_PTR = pack_int32(BUF_PTR, info2); \ } while (0) -/* #define PACK_RESOURCE(size, fd_value, fd_type, fd_api_type, file_size, \ */ -/* file_path) \ */ -/* do { \ */ -/* BUF_PTR = pack_int32(BUF_PTR, size); \ */ -/* BUF_PTR = pack_int32(BUF_PTR, fd_value); \ */ -/* BUF_PTR = pack_int32(BUF_PTR, fd_type); \ */ -/* BUF_PTR = pack_int32(BUF_PTR, fd_api_type); \ */ -/* BUF_PTR = pack_int32(BUF_PTR, file_size); \ */ -/* BUF_PTR = pack_string(BUF_PTR, file_path); \ */ -/* } while (0) */ - -/* #define PACK_SCREENSHOT(image_file_path, orienation) \ */ -/* do { \ */ -/* BUF_PTR = pack_string(BUF_PTR, image_file_path); \ */ -/* BUF_PTR = pack_int32(BUF_PTR, orienation); \ */ -/* } while (0) */ - -/* #define PACK_SCENE(scene_name, form_name, form_pointer, \ */ -/* panel_name, panel_pointer, transition_time, \ */ -/* user_transition_time) \ */ -/* do { \ */ -/* BUF_PTR = pack_string(BUF_PTR, scene_name); \ */ -/* BUF_PTR = pack_string(BUF_PTR, form_name); \ */ -/* BUF_PTR = pack_int64(BUF_PTR, form_pointer); \ */ -/* BUF_PTR = pack_string(BUF_PTR, panel_name); \ */ -/* BUF_PTR = pack_int64(BUF_PTR, panel_pointer); \ */ -/* BUF_PTR = pack_int32(BUF_PTR, transition_time); \ */ -/* BUF_PTR = pack_int32(BUF_PTR, user_transition_time); \ */ -/* } while (0) */ +#define PACK_RESOURCE(size, fd_value, fd_type, fd_api_type, file_size, \ + file_path) \ + do { \ + BUF_PTR = pack_int64(BUF_PTR, size); \ + BUF_PTR = pack_int32(BUF_PTR, fd_value); \ + BUF_PTR = pack_int32(BUF_PTR, fd_type); \ + BUF_PTR = pack_int32(BUF_PTR, fd_api_type); \ + BUF_PTR = pack_int64(BUF_PTR, file_size); \ + BUF_PTR = pack_string(BUF_PTR, file_path); \ + } while (0) + +#define PACK_SCREENSHOT(image_file_path, orientation) \ + do { \ + BUF_PTR = pack_string(BUF_PTR, image_file_path); \ + BUF_PTR = pack_int32(BUF_PTR, orientation); \ + } while (0) + +#define PACK_SCENE(scene_name, formid, pform, panelid, ppanel, transition, user) \ + do { \ + BUF_PTR = pack_string(BUF_PTR, scene_name); \ + if (unlikely(pform == NULL)) { \ + BUF_PTR = pack_string(BUF_PTR, ""); \ + BUF_PTR = pack_int64(BUF_PTR, 0); \ + } else { \ + char *type = NULL, *name = NULL; \ + if (find_object_hash((void*)(pform), &type, &name) == 1) { \ + BUF_PTR = pack_string(BUF_PTR, name); \ + } else { \ + BUF_PTR = pack_string(BUF_PTR, ""); \ + } \ + BUF_PTR = pack_int64(BUF_PTR, (uintptr_t)pform); \ + } \ + if (unlikely(ppanel == NULL)) { \ + BUF_PTR = pack_string(BUF_PTR, ""); \ + BUF_PTR = pack_int64(BUF_PTR, 0); \ + } else { \ + char *type = NULL, *name = NULL; \ + if (find_object_hash((void*)(ppanel), &type, &name) == 1) { \ + BUF_PTR = pack_string(BUF_PTR, name); \ + } else { \ + BUF_PTR = pack_string(BUF_PTR, ""); \ + } \ + BUF_PTR = pack_int64(BUF_PTR, (uintptr_t)(ppanel)); \ + } \ + BUF_PTR = pack_int64(BUF_PTR, transition); \ + BUF_PTR = pack_int64(BUF_PTR, user); \ + } while(0) #define PACK_THREAD(thread_id, thread_type, api_type) \ do { \ @@ -252,12 +312,14 @@ static inline char *pack_args(char *to, const char *fmt, ...) BUF_PTR = pack_int32(BUF_PTR, api_type); \ } while (0) -/* #define PACK_CUSTOM(handle, type, name, color, value) \ */ -/* BUF_PTR = pack_int32(BUF_PTR, handle); \ */ -/* BUF_PTR = pack_int32(BUF_PTR, type); \ */ -/* BUF_PTR = pack_string(BUF_PTR, name); \ */ -/* BUF_PTR = pack_int32(BUF_PTR, color); \ */ -/* BUF_PTR = pack_int32(BUF_PTR, value); */ +#define PACK_CUSTOM(handle, type, name, color, value) \ + do { \ + BUF_PTR = pack_int32(BUF_PTR, handle); \ + BUF_PTR = pack_int32(BUF_PTR, type); \ + BUF_PTR = pack_string(BUF_PTR, name); \ + BUF_PTR = pack_int32(BUF_PTR, color); \ + BUF_PTR = pack_double(BUF_PTR, value); \ + } while (0) #define PACK_SYNC(sync_val, sync_type, api_type) \ do { \ @@ -266,23 +328,6 @@ static inline char *pack_args(char *to, const char *fmt, ...) BUF_PTR = pack_int32(BUF_PTR, api_type); \ } while (0) -#define LOG_PATH "/tmp/trace.bin" -#define OPEN_LOG() \ - do { \ - log_fd = creat(LOG_PATH, 0644); \ - if (log_fd == -1) { \ - exit(1); \ - } \ - } while (0) -#define CLOSE_LOG() \ - do { \ - if (log_fd > 0) { \ - close(log_fd); \ - } \ - } while (0) - - - #define LOCAL_BUF_SIZE 1024 #define PREPARE_LOCAL_BUF() \ char buf[LOCAL_BUF_SIZE]; \ @@ -293,11 +338,11 @@ static inline char *pack_args(char *to, const char *fmt, ...) #define MSG_HDR_LEN 20 #define FLUSH_LOCAL_BUF() \ *(uint32_t *)(buf + MSG_LEN_OFFSET) = (p - buf) - MSG_HDR_LEN; \ - write(log_fd, buf, p - buf); + send(gTraceInfo.socket.daemonSock, buf, (p - buf), 0); // =========================== post block macro =========================== -#define POST_PACK_PROBEBLOCK_BEGIN(LCTYPE, RETVALUE, INPUTFORMAT, ...) \ +#define POST_PACK_PROBEBLOCK_BEGIN() \ newerrno = errno; \ if(postBlockBegin(blockresult)) { @@ -306,9 +351,6 @@ static inline char *pack_args(char *to, const char *fmt, ...) } \ errno = (newerrno != 0) ? newerrno : olderrno -/* data */ -extern int log_fd; - /* int main(int argc, char **argv) */ /* { */ /* char buf[1024]; */