summaryrefslogtreecommitdiff
path: root/src/bin/evas/evas_cserve2_debug.c
diff options
context:
space:
mode:
authorJean-Philippe Andre <jp.andre@samsung.com>2013-08-20 18:26:02 +0900
committerJean-Philippe Andre <jp.andre@samsung.com>2013-10-28 15:47:14 +0900
commit1e4ee656a0c44cbf915e124aa59c50fdde9f0973 (patch)
treebceb1a7ff13916bca910349d06ac8b777db4b885 /src/bin/evas/evas_cserve2_debug.c
parentdf31807329ca500eb579d538abe9f21208426934 (diff)
evas/cserve2: Fix cserve2_usage tool
Also, print shared arrays usage as it is sent as first message upon connection to the server. Add fonts to LRU and flush LRU as needed. Seems to work okay. Could probably be finetuned a bit.
Diffstat (limited to 'src/bin/evas/evas_cserve2_debug.c')
-rw-r--r--src/bin/evas/evas_cserve2_debug.c136
1 files changed, 65 insertions, 71 deletions
diff --git a/src/bin/evas/evas_cserve2_debug.c b/src/bin/evas/evas_cserve2_debug.c
index e68e1138fc..10b9d5c92f 100644
--- a/src/bin/evas/evas_cserve2_debug.c
+++ b/src/bin/evas/evas_cserve2_debug.c
@@ -177,8 +177,6 @@ _debug_msg_send(void)
177} 177}
178 178
179typedef struct _Font_Entry Font_Entry; 179typedef struct _Font_Entry Font_Entry;
180typedef struct _Cache_Entry Cache_Entry;
181typedef struct _Glyph_Entry Glyph_Entry;
182 180
183struct _Font_Entry 181struct _Font_Entry
184{ 182{
@@ -188,27 +186,9 @@ struct _Font_Entry
188 unsigned int size; 186 unsigned int size;
189 unsigned int dpi; 187 unsigned int dpi;
190 unsigned int unused; 188 unsigned int unused;
191 Eina_List *caches; 189 char glyph_data_shm[64];
192}; 190 char glyph_mempool_shm[64];
193 191 Eina_List *glyphs; // Glyph_Data
194struct _Cache_Entry
195{
196 const char *shmname;
197 unsigned int size;
198 unsigned int usage;
199 Eina_List *glyphs;
200};
201
202struct _Glyph_Entry
203{
204 unsigned int index;
205 unsigned int offset;
206 unsigned int size;
207 unsigned int rows;
208 unsigned int width;
209 unsigned int pitch;
210 unsigned int num_grays;
211 unsigned int pixel_mode;
212}; 192};
213 193
214#define READIT(_dst, _src) \ 194#define READIT(_dst, _src) \
@@ -217,6 +197,7 @@ struct _Glyph_Entry
217 _src += sizeof(_dst); \ 197 _src += sizeof(_dst); \
218 } while(0) 198 } while(0)
219 199
200#if 0
220static Glyph_Entry * 201static Glyph_Entry *
221_parse_glyph_entry(char **msg) 202_parse_glyph_entry(char **msg)
222{ 203{
@@ -267,6 +248,7 @@ _parse_cache_entry(char **msg)
267 248
268 return ce; 249 return ce;
269} 250}
251#endif
270 252
271static Font_Entry * 253static Font_Entry *
272_parse_font_entry(char **msg) 254_parse_font_entry(char **msg)
@@ -291,12 +273,18 @@ _parse_font_entry(char **msg)
291 READIT(fe->dpi, buf); 273 READIT(fe->dpi, buf);
292 READIT(fe->unused, buf); 274 READIT(fe->unused, buf);
293 275
276 eina_strlcpy(fe->glyph_data_shm, buf, 64);
277 buf += 64;
278 eina_strlcpy(fe->glyph_mempool_shm, buf, 64);
279 buf += 64;
280
294 READIT(n, buf); 281 READIT(n, buf);
295 while (n--) 282 while (n--)
296 { 283 {
297 Cache_Entry *ce; 284 Glyph_Data *gd = calloc(1, sizeof(Glyph_Data));
298 ce = _parse_cache_entry(&buf); 285 memcpy(gd, buf, sizeof(Glyph_Data));
299 fe->caches = eina_list_append(fe->caches, ce); 286 buf += sizeof(Glyph_Data);
287 fe->glyphs = eina_list_append(fe->glyphs, gd);
300 } 288 }
301 289
302 *msg = buf; 290 *msg = buf;
@@ -307,7 +295,7 @@ _parse_font_entry(char **msg)
307static Eina_List * 295static Eina_List *
308_debug_msg_read(void) 296_debug_msg_read(void)
309{ 297{
310 Msg_Base *msg = NULL; 298 Msg_Font_Debug *msg = NULL;
311 char *buf; 299 char *buf;
312 int size; 300 int size;
313 unsigned int nfonts; 301 unsigned int nfonts;
@@ -317,16 +305,16 @@ _debug_msg_read(void)
317 while (!msg) 305 while (!msg)
318 msg = _server_read(&size); 306 msg = _server_read(&size);
319 307
320 if (msg->type != CSERVE2_FONT_DEBUG) 308 if (msg->base.type != CSERVE2_FONT_DEBUG)
321 { 309 {
322 ERR("Invalid message received from server." 310 ERR("Invalid message received from server. "
323 "Something went badly wrong."); 311 "Something went badly wrong.");
324 return NULL; 312 return NULL;
325 } 313 }
326 314
327 buf = (char *)msg + sizeof(*msg); 315 buf = (char *)msg + sizeof(*msg);
328 316
329 READIT(nfonts, buf); 317 nfonts = msg->nfonts;
330 while (nfonts--) 318 while (nfonts--)
331 { 319 {
332 Font_Entry *fe; 320 Font_Entry *fe;
@@ -334,34 +322,18 @@ _debug_msg_read(void)
334 fonts = eina_list_append(fonts, fe); 322 fonts = eina_list_append(fonts, fe);
335 } 323 }
336 324
325 printf("Font index table: %s\n", msg->fonts_index_path);
326 printf("Contains %u fonts\n\n", msg->nfonts);
337 return fonts; 327 return fonts;
338} 328}
339 329
340static void 330static void
341_glyph_entry_free(Glyph_Entry *ge)
342{
343 free(ge);
344}
345
346static void
347_cache_entry_free(Cache_Entry *ce)
348{
349 Glyph_Entry *ge;
350
351 EINA_LIST_FREE(ce->glyphs, ge)
352 _glyph_entry_free(ge);
353
354 eina_stringshare_del(ce->shmname);
355 free(ce);
356}
357
358static void
359_font_entry_free(Font_Entry *fe) 331_font_entry_free(Font_Entry *fe)
360{ 332{
361 Cache_Entry *ce; 333 Glyph_Data *gd;
362 334
363 EINA_LIST_FREE(fe->caches, ce) 335 EINA_LIST_FREE(fe->glyphs, gd)
364 _cache_entry_free(ce); 336 free(gd);
365 337
366 eina_stringshare_del(fe->name); 338 eina_stringshare_del(fe->name);
367 eina_stringshare_del(fe->file); 339 eina_stringshare_del(fe->file);
@@ -369,7 +341,7 @@ _font_entry_free(Font_Entry *fe)
369} 341}
370 342
371static void 343static void
372_glyph_entry_print(Glyph_Entry *ge) 344_glyph_data_print(Glyph_Data *gd)
373{ 345{
374 const char *pxmode[] = { 346 const char *pxmode[] = {
375 "FT_PIXEL_MODE_NONE", 347 "FT_PIXEL_MODE_NONE",
@@ -380,29 +352,18 @@ _glyph_entry_print(Glyph_Entry *ge)
380 "FT_PIXEL_MODE_LCD", 352 "FT_PIXEL_MODE_LCD",
381 "FT_PIXEL_MODE_LCD_V" 353 "FT_PIXEL_MODE_LCD_V"
382 }; 354 };
383 printf("\t\tGLYPH %u offset: %u size: %u %ux%u pitch: %u grays: %u " 355 printf(" GLYPH id: %-4u refcount %-2u: index: %-6u offset: %-6u size: %-3u "
384 "pixel mode: %s\n", 356 "%2ux%-3u pitch: %-2u grays: %-3u pixel mode: %s\n",
385 ge->index, ge->offset, ge->size, ge->width, ge->rows, ge->pitch, 357 gd->id, gd->refcount, gd->index, gd->offset, gd->size,
386 ge->num_grays, pxmode[ge->pixel_mode]); 358 gd->width, gd->rows, gd->pitch,
387} 359 gd->num_grays, pxmode[gd->pixel_mode]);
388
389static void
390_cache_entry_print(Cache_Entry *ce)
391{
392 Eina_List *l;
393 Glyph_Entry *ge;
394
395 printf("\tSHM %s used %u/%u\n", ce->shmname, ce->usage, ce->size);
396
397 EINA_LIST_FOREACH(ce->glyphs, l, ge)
398 _glyph_entry_print(ge);
399} 360}
400 361
401static void 362static void
402_font_entry_print(Font_Entry *fe) 363_font_entry_print(Font_Entry *fe)
403{ 364{
404 Eina_List *l; 365 Eina_List *l;
405 Cache_Entry *ce; 366 Glyph_Data *gd;
406 367
407 printf("FONT %s:%s size: %u dpi: %u %s%s%s %s\n", 368 printf("FONT %s:%s size: %u dpi: %u %s%s%s %s\n",
408 fe->file, fe->name, fe->size, fe->dpi, 369 fe->file, fe->name, fe->size, fe->dpi,
@@ -410,18 +371,46 @@ _font_entry_print(Font_Entry *fe)
410 fe->rend_flags & 1 ? "SLANT " : "", 371 fe->rend_flags & 1 ? "SLANT " : "",
411 fe->rend_flags & 2 ? "WEIGHT" : "", 372 fe->rend_flags & 2 ? "WEIGHT" : "",
412 fe->unused ? "(unused)" : ""); 373 fe->unused ? "(unused)" : "");
374 printf(" Index: %s\n"
375 " Mempool: %s\n"
376 " Glyph count: %u\n",
377 fe->glyph_data_shm, fe->glyph_mempool_shm,
378 eina_list_count(fe->glyphs));
413 379
414 EINA_LIST_FOREACH(fe->caches, l, ce) 380 EINA_LIST_FOREACH(fe->glyphs, l, gd)
415 _cache_entry_print(ce); 381 _glyph_data_print(gd);
416 382
417 putchar('\n'); 383 putchar('\n');
418} 384}
419 385
386static void
387_shared_index_print(Msg_Index_List *msg, size_t size)
388{
389 if (size < sizeof(*msg) || msg->base.type != CSERVE2_INDEX_LIST)
390 {
391 ERR("Invalid message received from server. "
392 "Something went wrong.");
393 return;
394 }
395
396 printf("Printing shared indexes status.\n");
397 printf("===============================\n\n");
398 printf("Generation ID: %-4d\n", msg->generation_id);
399 printf("Strings entries path: %s\n", msg->strings_entries_path);
400 printf("Strings index path: %s\n", msg->strings_index_path);
401 printf("Files index path: %s\n", msg->files_index_path);
402 printf("Images index path: %s\n", msg->images_index_path);
403 printf("Fonts index path: %s\n", msg->fonts_index_path);
404 printf("\n\n\n");
405}
406
420int 407int
421main(void) 408main(void)
422{ 409{
423 Eina_List *fonts; 410 Eina_List *fonts;
424 Font_Entry *fe; 411 Font_Entry *fe;
412 Msg_Index_List *msg = NULL;
413 int size;
425 414
426 eina_init(); 415 eina_init();
427 _evas_cserve2_debug_log_dom = eina_log_domain_register 416 _evas_cserve2_debug_log_dom = eina_log_domain_register
@@ -431,6 +420,11 @@ main(void)
431 ERR("Could not connect to server."); 420 ERR("Could not connect to server.");
432 return -1; 421 return -1;
433 } 422 }
423
424 while (!msg)
425 msg = _server_read(&size);
426 _shared_index_print(msg, size);
427
434 _debug_msg_send(); 428 _debug_msg_send();
435 fonts = _debug_msg_read(); 429 fonts = _debug_msg_read();
436 EINA_LIST_FREE(fonts, fe) 430 EINA_LIST_FREE(fonts, fe)