summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYakov Goldberg <yakov.g@samsung.com>2015-09-30 11:58:23 +0300
committerYakov Goldberg <yakov.g@samsung.com>2015-09-30 11:58:23 +0300
commit45dc94e7323c60df16255d557d72222f5397924f (patch)
treef75bcbca27b10525a87bdd042ffa97d051067c5b
parent1daf7945607c2ea156d686b23b842667abb26b7f (diff)
sdb: adapt code to previous changes
-rw-r--r--src/client.c53
-rw-r--r--src/debugd.c3
2 files changed, 30 insertions, 26 deletions
diff --git a/src/client.c b/src/client.c
index f89e04c..ab5ab13 100644
--- a/src/client.c
+++ b/src/client.c
@@ -30,19 +30,13 @@ _send_data(char *msg, int size)
30 if (mode & SDB_MODE) 30 if (mode & SDB_MODE)
31 { 31 {
32 char tmp[1024]; 32 char tmp[1024];
33 char msg2[BUFFER_SIZE];
34 static char seq = 1;
35 33
36 if (!g_bridge_file) return EINA_FALSE; 34 if (!g_bridge_file) return EINA_FALSE;
37 35
38 sprintf(tmp, "sdb push msg %s &> /dev/null", g_bridge_file); 36 sprintf(tmp, "sdb push msg %s &> /dev/null", g_bridge_file);
39 37
40 msg2[0] = seq++;
41
42 memcpy(msg2 + 1, msg, size);
43
44 FILE *f = fopen("msg", "w+"); 38 FILE *f = fopen("msg", "w+");
45 fwrite(msg2, sizeof(char), size, f); 39 fwrite(msg, sizeof(char), size, f);
46 fflush(f); 40 fflush(f);
47 fclose(f); 41 fclose(f);
48 42
@@ -114,21 +108,32 @@ _msg_receive_from_bridge(void *fdata EINA_UNUSED, int type EINA_UNUSED,
114 const char *cmd = "su\n"; 108 const char *cmd = "su\n";
115 ecore_exe_send(exe, cmd, strlen(cmd)); 109 ecore_exe_send(exe, cmd, strlen(cmd));
116 _su_exec = EINA_TRUE; 110 _su_exec = EINA_TRUE;
111 printf("Executing %s\n", cmd);
117 return ECORE_CALLBACK_DONE; 112 return ECORE_CALLBACK_DONE;
118 } 113 }
119 if (!_su_app_exec) 114 if (!_su_app_exec)
120 { 115 {
121 const char *cmd = "su app -c \"/home/developer/debugd bridge\"\n"; 116 const char *cmd = "su app -c \"/home/developer/debugd bridge sdb\"\n";
122 ecore_exe_send(exe, cmd, strlen(cmd)); 117 ecore_exe_send(exe, cmd, strlen(cmd));
123 _su_app_exec = EINA_TRUE; 118 _su_app_exec = EINA_TRUE;
119 printf("Executing %s\n", cmd);
124 return ECORE_CALLBACK_DONE; 120 return ECORE_CALLBACK_DONE;
125 } 121 }
126 if (!g_bridge_file) 122 if (!g_bridge_file)
127 { 123 {
128 if (strncmp(cdata->data, "/home", 5)) return ECORE_CALLBACK_DONE; 124 const char *data = cdata->data;
129 printf("Initializing bridge file (size=%d)\n", cdata->size); 125 do
126 {
127 if (!strncmp(data, "/home", 5)) break;
128 data = strchr(data, '\n');
129 if (data) data++;
130 }
131 while (data);
132 if (!data) return ECORE_CALLBACK_DONE;
133 printf("Initializing bridge file %s\n", data);
130 char msg[1024], tmp[1024]; 134 char msg[1024], tmp[1024];
131 strncpy(msg, cdata->data, cdata->size); 135 cdata->size -= (data - (char *)cdata->data);
136 strncpy(msg, data, cdata->size);
132 msg[cdata->size] = 0; 137 msg[cdata->size] = 0;
133 g_bridge_file = strdup(msg); 138 g_bridge_file = strdup(msg);
134 sprintf(tmp, "%s.lock", msg); 139 sprintf(tmp, "%s.lock", msg);
@@ -143,10 +148,10 @@ _msg_receive_from_bridge(void *fdata EINA_UNUSED, int type EINA_UNUSED,
143 const char *data = cdata->data; 148 const char *data = cdata->data;
144 if (mode & SDB_MODE) 149 if (mode & SDB_MODE)
145 { 150 {
146 while (j <= cdata->size) 151 for (j = 0; j < cdata->size; j++)
147 { 152 {
148 if (data[j] == 0x0D && data[j+1] == 0x0A) j++; 153 if (data[j] == 0x0D && data[j+1] == 0x0A);
149 buf[i++] = data[j++]; 154 else buf[i++] = data[j];
150 } 155 }
151 cdata->size = i; 156 cdata->size = i;
152 } 157 }
@@ -196,7 +201,7 @@ static Ecore_Exe *
196_bridge_init(void) 201_bridge_init(void)
197{ 202{
198 Ecore_Exe *exe; 203 Ecore_Exe *exe;
199 const char *cmd_sdb = "export PATH=$PATH:~/tizen-sdk/tools; sdb shell /home/developer/debugd bridge sdb"; 204 const char *cmd_sdb = "export PATH=$PATH:~/tizen-sdk/tools; sdb shell";
200 const char *cmd = "./debugd bridge"; 205 const char *cmd = "./debugd bridge";
201 206
202 if (mode & SDB_MODE) cmd = cmd_sdb; 207 if (mode & SDB_MODE) cmd = cmd_sdb;
@@ -222,15 +227,6 @@ int main (int argc, char **argv)
222 if (!ecore_init()) 227 if (!ecore_init())
223 goto exit; 228 goto exit;
224 229
225 g_child = _bridge_init();
226
227 if (!g_child)
228 {
229 fprintf(stderr, "Could not initialize bridge\n");
230 goto error;
231 }
232
233 ecore_event_handler_add(ECORE_EXE_EVENT_DATA, _msg_receive_from_bridge, NULL);
234 if (argc > 1 && !strcmp(argv[1], "auto")) 230 if (argc > 1 && !strcmp(argv[1], "auto"))
235 { 231 {
236 mode |= AUTO_MODE; 232 mode |= AUTO_MODE;
@@ -247,6 +243,15 @@ int main (int argc, char **argv)
247 const char *profile = getenv("DBG_PROFILE"); 243 const char *profile = getenv("DBG_PROFILE");
248 244
249 if (!profile || strcmp(profile, "no_sdb")) mode |= SDB_MODE; 245 if (!profile || strcmp(profile, "no_sdb")) mode |= SDB_MODE;
246 g_child = _bridge_init();
247
248 if (!g_child)
249 {
250 fprintf(stderr, "Could not initialize bridge\n");
251 goto error;
252 }
253
254 ecore_event_handler_add(ECORE_EXE_EVENT_DATA, _msg_receive_from_bridge, NULL);
250 ecore_main_loop_begin(); 255 ecore_main_loop_begin();
251 256
252 ecore_exe_free(g_child); /* Does not affect the child process */ 257 ecore_exe_free(g_child); /* Does not affect the child process */
diff --git a/src/debugd.c b/src/debugd.c
index aa0e39e..89cbd10 100644
--- a/src/debugd.c
+++ b/src/debugd.c
@@ -151,8 +151,7 @@ static Eina_Bool
151_bridge_recv_from_daemon(void *data EINA_UNUSED, int type EINA_UNUSED, void *event) 151_bridge_recv_from_daemon(void *data EINA_UNUSED, int type EINA_UNUSED, void *event)
152{ 152{
153 Ecore_Ipc_Event_Server_Data *e = event; 153 Ecore_Ipc_Event_Server_Data *e = event;
154 //int nb = fwrite(e->data, e->size, 1, stdout); 154 fwrite(e->data, e->size, 1, stdout);
155 int nb = fwrite(e->data, e->size, 1, stdout);
156 fflush(stdout); 155 fflush(stdout);
157 156
158#if 0 157#if 0