4 * Copyright (c) 2000 - 2013 Samsung Electronics Co., Ltd. All rights reserved.
8 * Jaewon Lim <jaewon81.lim@samsung.com>
9 * Woojin Jung <woojin2.jung@samsung.com>
10 * Juyoung Kim <j0.kim@samsung.com>
11 * Cherepanov Vitaliy <v.cherepanov@samsung.com>
12 * Nikita Kalyazin <n.kalyazin@samsung.com>
14 * Licensed under the Apache License, Version 2.0 (the "License");
15 * you may not use this file except in compliance with the License.
16 * You may obtain a copy of the License at
18 * http://www.apache.org/licenses/LICENSE-2.0
20 * Unless required by applicable law or agreed to in writing, software
21 * distributed under the License is distributed on an "AS IS" BASIS,
22 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
23 * See the License for the specific language governing permissions and
24 * limitations under the License.
28 * - Samsung RnD Institute Russia
36 #include <stdint.h> // for uint64_t, int64_t
37 #include <pthread.h> // for pthread_mutex_t
38 #include "da_protocol.h"
46 #define PROTOCOL_VERSION "2.1"
48 #define RUN_APP_LOADER
50 #define MAX_TARGET_COUNT 8
53 #define MAX_FILENAME 128
57 ERR_LOCKFILE_CREATE_FAILED = -101,
58 ERR_ALREADY_RUNNING = -102,
59 ERR_INITIALIZE_SYSTEM_INFO_FAILED = -103,
60 ERR_HOST_SERVER_SOCKET_CREATE_FAILED = -104,
61 ERR_TARGET_SERVER_SOCKET_CREATE_FAILED = -105,
62 ERR_SIGNAL_MASK_SETTING_FAILED = -106,
63 ERR_WRONG_MESSAGE_FORMAT = -201,
64 ERR_WRONG_MESSAGE_TYPE = -202,
65 ERR_WRONG_MESSAGE_DATA = -203,
66 ERR_CANNOT_START_PROFILING = -204,
67 ERR_WRONG_PROTOCOL_VERSION = -205
70 enum TargetMessageType
85 #define IS_PROBE_MSG(type) (((type) & 0x0100) == 0x0100)
98 MSG_CAPTURE_SCREEN = 108,
99 MSG_MAPS_INST_LIST = 109,
112 DAS_TARGET_ARM_START = 1,
113 DAS_TARGET_X86_START = 2,
114 DAS_EMUL_ARM_START = 3,
115 DAS_EMUL_X86_START = 4,
116 DAS_TARGET_ARM_BATT_START = 5,
117 DAS_TARGET_X86_BATT_START = 6,
118 DAS_EMUL_ARM_BATT_START = 7,
119 DAS_EMUL_X86_BATT_START = 8,
127 #define likely(x) __builtin_expect((x), 1)
128 #define unlikely(x) __builtin_expect((x), 0)
131 #define EVENT_STOP 0x00000001
132 #define EVENT_PID 0x00000002
133 #define EVENT_ERROR 0x00000004
141 pthread_mutex_t data_socket_mutex;
154 } __file_descriptors;
158 int host_server_socket;
159 int target_server_socket;
161 unsigned int config_flag;
162 int app_launch_timerfd;
163 int connect_timeout_timerfd;
164 pthread_t sampling_thread;
165 pthread_t replay_thread;
166 pthread_t transfer_thread;
171 __file_descriptors fd;
172 char appPath[128]; // application executable path
175 extern __da_manager manager;
178 uint64_t get_total_alloc_size(void);
179 int initialize_log(void);
180 int daemonLoop(void);
181 void unlink_portfile(void);
183 int samplingStart(void);
184 int samplingStop(void);
189 // TODO maybe need move to other file
190 int prepare_profiling(void);
191 int start_profiling(void);
192 void stop_profiling(void);
193 int reconfigure(struct conf_t conf);
194 int sendACKCodeToHost(enum HostMessageType resp, int msgcode);
195 void terminate_all(void);