+/*
+ * DA probe
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:
+ *
+ * Nikita Kalyazin <n.kalyazin@samsung.com>
+ * Anastasia Lyupa <a.lyupa@samsung.com>
+ *
+ * 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__
#include <sys/time.h>
+#include <sys/socket.h>
+#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
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;
uint32_t num = strlen(fmt);
const char *t = fmt;
+ if(*t == '\0') {
+ num = 0;
+ }
+
memcpy(to, &num, sizeof(num));
to += sizeof(num);
#define PACK_MEMORY(size, memory_api_type, addr) \
do { \
- BUF_PTR = pack_int32(p, size); \
- BUF_PTR = pack_int32(p, memory_api_type); \
- BUF_PTR = pack_int64(p, (uintptr_t)addr); \
+ 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)
#define PACK_UICONTROL(control) \
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_THREAD(BUF_PTRthread_id, osp_thread_id, thread_type, api_type) \ */
-/* BUF_PTR = pack_int32(BUF_PTR, pthread_id); \ */
-/* BUF_PTR = pack_int32(BUF_PTR, osp_thread_id); \ */
-/* BUF_PTR = pack_int32(BUF_PTR, thread_type); \ */
-/* BUF_PTR = pack_int32(BUF_PTR, api_type); */
-
-/* #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_SYNC(sync_val, sync_type, api_type) \
- do { \
- BUF_PTR = pack_int32(BUF_PTR, sync_val); \
- BUF_PTR = pack_int32(BUF_PTR, sync_type); \
- BUF_PTR = pack_int32(BUF_PTR, api_type); \
+#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 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); \
- } \
+#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 { \
+ BUF_PTR = pack_int64(BUF_PTR, thread_id); \
+ BUF_PTR = pack_int32(BUF_PTR, thread_type); \
+ BUF_PTR = pack_int32(BUF_PTR, api_type); \
+ } while (0)
+#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 { \
+ BUF_PTR = pack_int64(BUF_PTR, (uintptr_t)sync_val); \
+ BUF_PTR = pack_int32(BUF_PTR, sync_type); \
+ BUF_PTR = pack_int32(BUF_PTR, api_type); \
+ } while (0)
#define LOCAL_BUF_SIZE 1024
#define PREPARE_LOCAL_BUF() \
#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() \
+ newerrno = errno; \
+ if(postBlockBegin(blockresult)) {
-/* data */
-extern int log_fd;
+#define POST_PACK_PROBEBLOCK_END() \
+ postBlockEnd(); \
+ } \
+ errno = (newerrno != 0) ? newerrno : olderrno
/* int main(int argc, char **argv) */
/* { */