summaryrefslogtreecommitdiff
path: root/src/bin/evas/evas_cserve2_shm_debug.c
diff options
context:
space:
mode:
authorChris Michael <cp.michael@samsung.com>2018-08-30 13:53:13 +0900
committerHermet Park <hermetpark@gmail.com>2018-08-30 13:53:13 +0900
commit3846059288a06f83de941b0fc7b180b706ab4647 (patch)
treed9d08624aab153b9ec2df35ee2ea02650e793593 /src/bin/evas/evas_cserve2_shm_debug.c
parentb4e17905e9ad05179368d5f43cd88abb08d9b125 (diff)
evas: Remove binary cserve2
Summary: ref T7226 Depends on D6939 Reviewers: raster, cedric, zmike, Hermet Reviewed By: Hermet Subscribers: #reviewers, #committers Tags: #efl Maniphest Tasks: T7226 Differential Revision: https://phab.enlightenment.org/D6940
Diffstat (limited to 'src/bin/evas/evas_cserve2_shm_debug.c')
-rw-r--r--src/bin/evas/evas_cserve2_shm_debug.c811
1 files changed, 0 insertions, 811 deletions
diff --git a/src/bin/evas/evas_cserve2_shm_debug.c b/src/bin/evas/evas_cserve2_shm_debug.c
deleted file mode 100644
index 18b87c4d03..0000000000
--- a/src/bin/evas/evas_cserve2_shm_debug.c
+++ /dev/null
@@ -1,811 +0,0 @@
1#ifdef HAVE_CONFIG_H
2#include "config.h"
3#endif
4
5#include <unistd.h>
6#include <sys/ioctl.h>
7
8#include <Eina.h>
9#include "evas_cs2.h"
10
11#define SHM_FOLDER "/dev/shm"
12static int _evas_cserve2_shm_debug_log_dom = -1;
13
14#define ERR(...) EINA_LOG_DOM_ERR(_evas_cserve2_shm_debug_log_dom, __VA_ARGS__)
15#define DBG(...) EINA_LOG_DOM_DBG(_evas_cserve2_shm_debug_log_dom, __VA_ARGS__)
16#define WRN(...) EINA_LOG_DOM_WARN(_evas_cserve2_shm_debug_log_dom, __VA_ARGS__)
17#define INF(...) EINA_LOG_DOM_INFO(_evas_cserve2_shm_debug_log_dom, __VA_ARGS__)
18
19typedef struct _Shm_File Shm_File;
20struct _Shm_File
21{
22 Eina_File *f;
23 char *data;
24 size_t size;
25 int tag;
26
27 Eina_Bool strings;
28 Shared_Array_Header *header;
29};
30
31Shm_File *sf_strindex = NULL;
32Shm_File *sf_strpool = NULL;
33Shm_File *sf_fonts = NULL;
34Shm_File *sf_files = NULL;
35Shm_File *sf_images = NULL;
36
37static int _termsize = 0;
38
39static void
40nprintf(int n, const char *fmt, ...)
41{
42 char buf[n+1];
43 va_list arg;
44 int len;
45
46 va_start(arg, fmt);
47 if (!n)
48 vprintf(fmt, arg);
49 else
50 {
51 len = vsnprintf(buf, n+1, fmt, arg);
52 buf[n] = 0;
53 fputs(buf, stdout);
54 if ((len > 0) && (buf[len-1] != '\n'))
55 fputc('\n', stdout);
56 }
57 va_end(arg);
58}
59
60#define printf(...) nprintf(_termsize, __VA_ARGS__)
61
62static Shm_File *
63_shm_file_open(const char *path)
64{
65 Shm_File *sf;
66 Eina_File *f;
67 char *data;
68
69 f = eina_file_open(path, EINA_TRUE);
70 if (!f)
71 {
72 ERR("Could not open file %s: [%d] %m", path, errno);
73 return NULL;
74 }
75
76 data = eina_file_map_all(f, EINA_FILE_RANDOM);
77 if (!data)
78 {
79 ERR("Could not map the file %s", path);
80 eina_file_close(f);
81 return NULL;
82 }
83
84 sf = calloc(1, sizeof(*sf));
85 sf->data = data;
86 sf->f = f;
87 sf->size = eina_file_size_get(f);
88
89 DBG("Successfully opened %s", path);
90 return sf;
91}
92
93static void
94_shm_file_close(Shm_File *sf)
95{
96 if (!sf) return;
97 eina_file_map_free(sf->f, sf->data);
98 eina_file_close(sf->f);
99 free(sf);
100}
101
102static Eina_Bool
103_shm_file_probe(Shm_File *sf)
104{
105 if (!sf || !sf->data)
106 return EINA_FALSE;
107
108 if (sf->size < sizeof(Shared_Array_Header))
109 {
110 sf->header = NULL;
111 return EINA_TRUE;
112 }
113
114 sf->header = (Shared_Array_Header *) sf->data;
115 switch (sf->header->tag)
116 {
117 case STRING_INDEX_ARRAY_TAG:
118 DBG("Found string index: %s", eina_file_filename_get(sf->f));
119 if (sf->header->elemsize != sizeof(Index_Entry))
120 {
121 ERR("String index looks invalid: elemsize %d",
122 sf->header->elemsize);
123 return EINA_FALSE;
124 }
125 sf->tag = STRING_INDEX_ARRAY_TAG;
126 sf_strindex = sf;
127 break;
128
129 case STRING_MEMPOOL_FAKETAG:
130 DBG("Found string mempool: %s", eina_file_filename_get(sf->f));
131 sf->strings = EINA_TRUE;
132 sf->tag = STRING_MEMPOOL_FAKETAG;
133 sf->header = NULL;
134 sf_strpool = sf;
135 break;
136
137 case FILE_DATA_ARRAY_TAG:
138 DBG("Found index table with tag '%4.4s'", (char *) &sf->header->tag);
139 sf->tag = sf->header->tag;
140 sf_files = sf;
141 break;
142
143 case IMAGE_DATA_ARRAY_TAG:
144 DBG("Found index table with tag '%4.4s'", (char *) &sf->header->tag);
145 sf->tag = sf->header->tag;
146 sf_images = sf;
147 break;
148
149 case FONT_DATA_ARRAY_TAG:
150 DBG("Found index table with tag '%4.4s'", (char *) &sf->header->tag);
151 sf->tag = sf->header->tag;
152 sf_fonts = sf;
153 break;
154
155 case GLYPH_DATA_ARRAY_TAG:
156 DBG("Found index table with tag '%4.4s'", (char *) &sf->header->tag);
157 sf->tag = sf->header->tag;
158 break;
159
160 default:
161 //DBG("Unknown tag found: %d", sf->header->tag);
162 sf->header = NULL;
163 break;
164 }
165
166 return EINA_TRUE;
167}
168
169static Eina_List *
170_shm_files_list(const char *folder)
171{
172 Eina_List *lst = NULL;
173 Eina_Iterator *iter;
174 const Eina_File_Direct_Info *f_info;
175 char pattern[64];
176
177 sprintf(pattern, "/evas-shm-%05d-", (int) getuid());
178 iter = eina_file_direct_ls(folder);
179 EINA_ITERATOR_FOREACH(iter, f_info)
180 {
181 if (strstr(f_info->path, pattern))
182 {
183 const char *shmname = strrchr(f_info->path, '/');
184 if (!shmname) continue;
185
186 lst = eina_list_append(lst, strdup(shmname));
187 }
188 else
189 DBG("cserve2 scan: ignoring %s", f_info->path);
190 }
191 eina_iterator_free(iter);
192
193 return lst;
194}
195
196static void
197printf_newline(Eina_Bool flush)
198{
199 printf("----------------------------------------------------------------"
200 "----------------\n");
201
202 if (flush)
203 {
204 printf("\n\n");
205 fflush(stdout);
206 }
207}
208
209static void
210_index_tables_summary_print(void)
211{
212 printf("Shared index tables\n\n");
213 printf("Table Tag MapSize Gen ElSz Count Last Sort Path\n");
214 printf_newline(0);
215
216 printf("StrIdx %4.4s %7d %4d %4d %5d %5d %5d %s\n",
217 (char *) &sf_strindex->tag,
218 (int) eina_file_size_get(sf_strindex->f),
219 sf_strindex->header->generation_id, sf_strindex->header->elemsize,
220 sf_strindex->header->count, sf_strindex->header->emptyidx,
221 sf_strindex->header->sortedidx,
222 eina_file_filename_get(sf_strindex->f));
223
224 printf("StrData %4.4s %7d %s\n",
225 (char *) &sf_strpool->tag,
226 (int) eina_file_size_get(sf_strpool->f),
227 eina_file_filename_get(sf_strpool->f));
228
229 if (sf_files)
230 printf("FileIdx %4.4s %7d %4d %4d %5d %5d %5d %s\n",
231 (char *) &sf_files->tag,
232 (int) eina_file_size_get(sf_files->f),
233 sf_files->header->generation_id, sf_files->header->elemsize,
234 sf_files->header->count, sf_files->header->emptyidx,
235 sf_files->header->sortedidx,
236 eina_file_filename_get(sf_files->f));
237 else
238 printf("FileIdx <not found>\n");
239
240 if (sf_images)
241 printf("Images %4.4s %7d %4d %4d %5d %5d %5d %s\n",
242 (char *) &sf_images->tag,
243 (int) eina_file_size_get(sf_images->f),
244 sf_images->header->generation_id, sf_images->header->elemsize,
245 sf_images->header->count, sf_images->header->emptyidx,
246 sf_images->header->sortedidx,
247 eina_file_filename_get(sf_images->f));
248 else
249 printf("Images <not found>\n");
250
251 if (sf_fonts)
252 printf("FontIdx %4.4s %7d %4d %4d %5d %5d %5d %s\n",
253 (char *) &sf_fonts->tag,
254 (int) eina_file_size_get(sf_fonts->f),
255 sf_fonts->header->generation_id, sf_fonts->header->elemsize,
256 sf_fonts->header->count, sf_fonts->header->emptyidx,
257 sf_fonts->header->sortedidx,
258 eina_file_filename_get(sf_fonts->f));
259 else
260 printf("FontIdx <not found>\n");
261
262 printf_newline(1);
263}
264
265static const Shm_Object *
266_shared_index_item_get_by_id(Shm_File *si, int elemsize, unsigned int id)
267{
268 const Shm_Object *obj;
269 const char *base;
270 int low = 0, high, start_high;
271 int cur;
272
273 if (!si || elemsize <= 0 || !id)
274 return NULL;
275
276 // FIXME: HACK (consider all arrays always sorted by id)
277 high = si->header->emptyidx; // Should be si->header->sortedidx
278
279 if (high > si->header->count)
280 high = si->header->count;
281
282 base = si->data + sizeof(Shared_Array_Header);
283
284 // Direct access, works for non-repacked arrays
285 if ((int) id < high)
286 {
287 obj = (Shm_Object *) (base + (elemsize * id));
288 if (obj->id == id)
289 return obj;
290 }
291
292 // Binary search
293 start_high = high;
294 while(high != low)
295 {
296 cur = low + ((high - low) / 2);
297 obj = (Shm_Object *) (base + (elemsize * cur));
298 if (obj->id == id)
299 return obj;
300 if (obj->id < id)
301 low = cur + 1;
302 else
303 high = cur;
304 }
305
306 // Linear search
307 for (cur = start_high; cur < si->header->count; cur++)
308 {
309 obj = (Shm_Object *) (base + (elemsize * cur));
310 if (!obj->id)
311 return NULL;
312 if (obj->id == id)
313 return obj;
314 }
315
316 return NULL;
317}
318
319static void *
320_shared_array_item_get(Shm_File *sf, int idx)
321{
322 if (!sf || !sf->header || idx < 0)
323 return NULL;
324
325 if ((idx + 1) * sf->header->elemsize > (int) sf->size)
326 return NULL;
327
328 return (sf->data + sizeof(Shared_Array_Header) + idx * sf->header->elemsize);
329}
330
331static const char *
332_shared_string_get(int id)
333{
334 Index_Entry *ie;
335
336 ie = (Index_Entry *)
337 _shared_index_item_get_by_id(sf_strindex, sizeof(*ie), id);
338 if (!ie) return NULL;
339 if (ie->offset < 0) return NULL;
340 if (!ie->refcount) return NULL;
341 if (ie->offset + ie->length > (int) sf_strpool->size) return NULL;
342
343 return sf_strpool->data + ie->offset;
344}
345
346static void
347_strings_all_print(Eina_Bool full)
348{
349 int k;
350 const char *mindata = sf_strpool->data;
351 const char *maxdata = sf_strpool->data + sf_strpool->size;
352
353 printf("List of strings\n");
354 printf("Indexes: %s\n", eina_file_filename_get(sf_strindex->f));
355 printf("Data: %s\n", eina_file_filename_get(sf_strpool->f));
356 printf(" String BufID Refcnt Offset Buflen Content\n");
357 printf_newline(0);
358
359 for (k = 0; k < sf_strindex->header->count; k++)
360 {
361 Index_Entry *ie;
362 const char *data;
363
364 ie = _shared_array_item_get(sf_strindex, k);
365 if (!ie) break;
366
367 if (!ie->id || (!full && !ie->refcount))
368 continue;
369
370 data = sf_strpool->data + ie->offset;
371 if ((data < mindata) || (data + ie->length > maxdata))
372 data = "<invalid offset>";
373
374 printf("%7d %7d %7d %7d %7d '%s'\n",
375 k, ie->id, ie->refcount, ie->offset, ie->length, data);
376 }
377
378 printf_newline(1);
379}
380
381static void
382_files_all_print_short()
383{
384 int k;
385
386 if (!sf_files) return;
387
388 printf("List of image files: %s\n", eina_file_filename_get(sf_files->f));
389 printf("A: Alpha, I: Invalid.\n\n");
390 printf(" Index FileID WIDTHxHEIGHT A I Loader PathID KeyID Path:Key\n");
391 printf_newline(0);
392
393 for (k = 0; k < sf_files->header->count; k++)
394 {
395 File_Data *fd;
396
397 fd = _shared_array_item_get(sf_files, k);
398 if (!fd) break;
399 if (!fd->id || !fd->refcount) continue;
400
401 printf("%7d %7d %5dx%-6d %d %d %6.6s %6d %6d '%s':'%s'\n",
402 k, fd->id, fd->w, fd->h, !!fd->alpha, !!fd->changed,
403 fd->loader_data ? _shared_string_get(fd->loader_data) : "",
404 fd->path, fd->key, _shared_string_get(fd->path),
405 _shared_string_get(fd->key));
406 }
407
408 printf_newline(1);
409}
410
411static void
412_files_all_print_all(void)
413{
414 int k;
415
416 if (!sf_files) return;
417
418 printf("List of opened image files: %s\n", eina_file_filename_get(sf_files->f));
419 printf_newline(0);
420
421 for (k = 0; k < sf_files->header->count; k++)
422 {
423 File_Data *fd;
424
425 fd = _shared_array_item_get(sf_files, k);
426 if (!fd) break;
427 if (!fd->id) continue;
428
429 printf("File #%-8d %d\n", k, fd->id);
430 printf("Path:Key: '%s':'%s'\n",
431 _shared_string_get(fd->path), _shared_string_get(fd->key));
432 printf("LoadOpts: Region: %d,%d-%dx%d\n",
433 fd->lo.region.x, fd->lo.region.y, fd->lo.region.w, fd->lo.region.h);
434 if (!EINA_DBL_EQ(fd->lo.dpi, 0))
435 printf(" DPI: %f\n");
436 else
437 printf(" DPI: 0\n");
438 printf(" Requested: %dx%d\n", fd->lo.w, fd->lo.h);
439 printf(" Scale down: %d\n", fd->lo.scale_down_by);
440 printf(" Orientation: %s\n", fd->lo.orientation ? "YES" : "NO");
441 printf("Loader: %s\n", _shared_string_get(fd->loader_data));
442 printf("Geometry: %dx%d\n", fd->w, fd->h);
443 printf("Animation: anim: %s, frames: %d, loop: %d, hint: %d\n",
444 fd->animated ? "YES" : "NO",
445 fd->frame_count, fd->loop_count, fd->loop_hint);
446 printf("Alpha: %s\n", fd->alpha ? "YES" : "NO");
447 printf("Changed: %s\n", fd->changed ? "YES" : "NO");
448
449 printf_newline(0);
450 }
451
452 printf("\n\n");
453 fflush(stdout);
454}
455
456static void
457_images_all_print_short(void)
458{
459 int k;
460
461 if (!sf_images) return;
462
463 printf("List of loaded images: %s\n", eina_file_filename_get(sf_images->f));
464 printf("A: Sparse alpha, U: Unused, L: Load requested.\n\n");
465 printf(" Index ImageID FileID Refcnt A U L ShmID ShmPath\n");
466 printf_newline(0);
467
468 for (k = 0; k < sf_images->header->count; k++)
469 {
470 Image_Data *id;
471
472 id = _shared_array_item_get(sf_images, k);
473 if (!id) break;
474 if (!id->id || !id->refcount) continue;
475
476 printf("%7d %7d %7d %7d %d %d %d %7d '%s'\n",
477 k, id->id, id->file_id, id->refcount,
478 !!id->alpha_sparse, !!id->unused, !!id->doload, id->shm_id,
479 id->shm_id ? _shared_string_get(id->shm_id) : "");
480 }
481
482 printf_newline(1);
483}
484
485static void
486_images_all_print_full(void)
487{
488 int k;
489
490 if (!sf_images) return;
491
492 printf("List of loaded images: %s\n\n",
493 eina_file_filename_get(sf_images->f));
494 printf_newline(0);
495
496 for (k = 0; k < sf_images->header->count; k++)
497 {
498 Image_Data *id;
499 File_Data *fd;
500 const char *scale_hint;
501
502 id = _shared_array_item_get(sf_images, k);
503 if (!id) break;
504 if (!id->id) continue;
505
506 printf("Image #%-8d %d\n", k, id->id);
507 printf("Refcount %d\n", id->refcount);
508 printf("Sparse alpha %s\n"
509 "Unused: %s\n"
510 "Load requested: %s\n"
511 "Valid: %s\n",
512 id->alpha_sparse ? "YES" : "NO",
513 id->unused ? "YES" : "NO",
514 id->doload ? "YES" : "NO",
515 id->valid ? "YES" : "NO");
516 printf("Shm Path: '%s'\n",
517 id->shm_id ? _shared_string_get(id->shm_id) : "");
518 printf("LoadOpts: width %d\n", id->opts.emile.w);
519 printf(" height %d\n", id->opts.emile.h);
520 printf(" degree %d\n", id->opts.emile.degree);
521 printf(" scale_down_by %d\n", id->opts.emile.scale_down_by);
522 if (!EINA_DBL_EQ(id->opts.emile.dpi, 0.0))
523 printf(" dpi %.2f\n", id->opts.emile.dpi);
524 else
525 printf(" dpi 0\n");
526 printf(" orientation %s\n", id->opts.emile.orientation ? "YES" : "NO");
527 printf(" region (%d,%d) %dx%d\n",
528 id->opts.emile.region.x, id->opts.emile.region.y,
529 id->opts.emile.region.w, id->opts.emile.region.h);
530
531 switch (id->opts.emile.scale_load.scale_hint)
532 {
533 case EVAS_IMAGE_SCALE_HINT_NONE:
534 scale_hint = "EVAS_IMAGE_SCALE_HINT_NONE"; break;
535 case EVAS_IMAGE_SCALE_HINT_DYNAMIC:
536 scale_hint = "EVAS_IMAGE_SCALE_HINT_DYNAMIC"; break;
537 case EVAS_IMAGE_SCALE_HINT_STATIC:
538 scale_hint = "EVAS_IMAGE_SCALE_HINT_STATIC"; break;
539 default:
540 scale_hint = "<invalid>"; break;
541 }
542
543 printf(" scale src (%d,%d) %dx%d\n",
544 id->opts.emile.scale_load.src_x, id->opts.emile.scale_load.src_y,
545 id->opts.emile.scale_load.src_w, id->opts.emile.scale_load.src_h);
546 printf(" scale dst %dx%d\n",
547 id->opts.emile.scale_load.dst_w, id->opts.emile.scale_load.dst_h);
548 printf(" scale smooth %s\n",
549 id->opts.emile.scale_load.smooth ? "YES" : "NO");
550 printf(" scale hint %s (%d)\n",
551 scale_hint, id->opts.emile.scale_load.scale_hint);
552
553 fd = (File_Data *)
554 _shared_index_item_get_by_id(sf_files, sizeof(*fd), id->file_id);
555 if (fd)
556 {
557 printf("File: ID %d\n", id->file_id);
558 printf(" Path:Key: '%s':'%s'\n",
559 _shared_string_get(fd->path), _shared_string_get(fd->key));
560 printf(" Loader: %s\n",
561 _shared_string_get(fd->loader_data));
562 printf(" Geometry: %dx%d\n", fd->w, fd->h);
563 printf(" Animation: anim: %s, frames: %d, loop: %d, hint: %d\n",
564 fd->animated ? "YES" : "NO",
565 fd->frame_count, fd->loop_count, fd->loop_hint);
566 printf(" Alpha: %s\n", fd->alpha ? "YES" : "NO");
567 printf(" Changed: %s\n", fd->changed ? "YES" : "NO");
568 }
569 else
570 printf("File: ID %d not found\n", id->file_id);
571
572 printf_newline(0);
573 }
574
575 printf("\n\n");
576 fflush(stdout);
577}
578
579static void
580_fonts_all_print_short(void)
581{
582 int k;
583
584 static const char *rend_flags[] = { "R", "S", "W", "SW", "X" };
585
586 if (!sf_fonts) return;
587
588 printf("List of loaded fonts: %s\n", eina_file_filename_get(sf_fonts->f));
589 printf("Rendering flags (RF): "
590 "R: Regular, S: Slanted, W: Weight, X: Invalid\n\n");
591 printf(" Index FontID Refcnt Size DPI RF GlIdx GlData File[:Name]\n");
592 printf_newline(0);
593
594 for (k = 0; k < sf_fonts->header->count; k++)
595 {
596 Font_Data *fd;
597 int rflag;
598 const char *rf;
599
600 fd = _shared_array_item_get(sf_fonts, k);
601 if (!fd) break;
602 if (!fd->id || !fd->refcount) continue;
603
604 rflag = fd->rend_flags;
605 if (rflag < 0 || rflag > 3) rflag = 4;
606 rf = rend_flags[rflag];
607
608 if (fd->name)
609 printf("%6d %6d %6d %5d %5d %-2s %6d %6d '%s':'%s'\n",
610 k, fd->id, fd->refcount, fd->size, fd->dpi, rf,
611 fd->glyph_index_shm, fd->mempool_shm,
612 fd->file ? _shared_string_get(fd->file) : "",
613 _shared_string_get(fd->name));
614 else
615 printf("%6d %6d %6d %5d %5d %-2s %6d %6d '%s'\n",
616 k, fd->id, fd->refcount, fd->size, fd->dpi, rf,
617 fd->glyph_index_shm, fd->mempool_shm,
618 fd->file ? _shared_string_get(fd->file) : "");
619 }
620
621 printf_newline(1);
622}
623
624static void
625_glyphs_all_print(Shm_File *sf)
626{
627 int k;
628 int nglyphs = 0;
629 int mem_used = 0;
630
631 printf(" GlyphID Refcnt Index Size Rows Width Pitch Grays H M "
632 "BufID Offset ShmPath\n");
633
634 for (k = 0; k < sf->header->count; k++)
635 {
636 Glyph_Data *gd;
637
638 gd = _shared_array_item_get(sf, k);
639 if (!gd) break;
640 if (!gd->id) continue;
641
642 printf(" %8u %6u %6u %5u %5u %5u %5u %5u %1u %1u %6u %6u '%s'\n",
643 gd->id, gd->refcount, gd->index, gd->size, gd->rows, gd->width,
644 gd->pitch, gd->num_grays, gd->hint, gd->pixel_mode, gd->buffer_id,
645 gd->offset, _shared_string_get(gd->mempool_id));
646
647 nglyphs++;
648 mem_used += gd->size;
649 }
650
651 printf("Total %d glyph(s) loaded, using %d bytes (w/o padding)\n",
652 nglyphs, mem_used);
653}
654
655static void
656_fonts_all_print_full(void)
657{
658 int k;
659
660 static const char *rend_flags[] = { "R", "S", "W", "SW", "X" };
661
662 if (!sf_fonts) return;
663
664 printf("List of loaded fonts: %s\n", eina_file_filename_get(sf_fonts->f));
665 printf("Rendering flags: "
666 "R: Regular, S: Slanted, W: Weight, X: Invalid\n");
667 printf("H: Hint, M: Pixel mode\n\n");
668 printf_newline(0);
669
670 for (k = 0; k < sf_fonts->header->count; k++)
671 {
672 Shm_File *sf;
673 Font_Data *fd;
674 int rflag;
675 const char *rf;
676
677 fd = _shared_array_item_get(sf_fonts, k);
678 if (!fd) break;
679 if (!fd->id) continue;
680 if (!fd->glyph_index_shm) continue;
681
682 sf = _shm_file_open(_shared_string_get(fd->glyph_index_shm));
683 if (!_shm_file_probe(sf))
684 {
685 _shm_file_close(sf);
686 continue;
687 }
688
689 rflag = fd->rend_flags;
690 if (rflag < 0 || rflag > 3) rflag = 4;
691 rf = rend_flags[rflag];
692
693 printf("Font #%-8d %d\n", k, fd->id);
694 printf("Refcount %d\n", fd->refcount);
695 printf("File '%s'\n", _shared_string_get(fd->file));
696 printf("Name '%s'\n",
697 fd->name ? _shared_string_get(fd->name) : "");
698 printf("Size %d\n", fd->size);
699 printf("DPI %d\n", fd->dpi);
700 printf("Rendering flag %s (%d)\n", rf, fd->rend_flags);
701 printf("Glyph index '%s'\n", _shared_string_get(fd->glyph_index_shm));
702 printf("Glyph data '%s'\n", _shared_string_get(fd->mempool_shm));
703
704 _glyphs_all_print(sf);
705
706 _shm_file_close(sf);
707 printf_newline(0);
708 }
709
710 printf("\n\n");
711 fflush(stdout);
712}
713
714
715int
716main(int argc EINA_UNUSED, char **argv EINA_UNUSED)
717{
718 Eina_List *opened_sf = NULL;
719 Eina_List *shmfiles = NULL, *l1, *l2;
720 const char *shmfolder = SHM_FOLDER;
721 Eina_Bool full = EINA_FALSE;
722 Shm_File *sf;
723 char *name;
724 struct winsize w;
725
726 if (isatty(STDOUT_FILENO))
727 {
728 if (ioctl(STDOUT_FILENO, TIOCGWINSZ, &w) == 0)
729 _termsize = w.ws_col;
730 }
731
732 if (argc > 1)
733 {
734 if (!strcmp(argv[1], "-h"))
735 {
736 printf("Usage: %s [-f] [folder]\n", argv[0]);
737 return 0;
738 }
739 else if (!strcmp(argv[1], "-f"))
740 {
741 full = EINA_TRUE;
742 if (argc > 2)
743 shmfolder = argv[2];
744 }
745 else
746 shmfolder = argv[1];
747 }
748
749 eina_init();
750 _evas_cserve2_shm_debug_log_dom = eina_log_domain_register
751 ("evas_cserve2_shm_debug", EINA_COLOR_BLUE);
752
753 shmfiles = _shm_files_list(shmfolder);
754 if (!shmfiles)
755 {
756 WRN("No shm file was found in %s", shmfolder);
757 goto finish;
758 }
759
760 DBG("Found %d files in %s", eina_list_count(shmfiles), shmfolder);
761
762 // Look for strings index & mempool
763 EINA_LIST_FOREACH_SAFE(shmfiles, l1, l2, name)
764 {
765 sf = _shm_file_open(name);
766 if (!_shm_file_probe(sf))
767 {
768 shmfiles = eina_list_remove_list(shmfiles, l1);
769 _shm_file_close(sf);
770 free(name);
771 continue;
772 }
773
774 if (!sf->tag)
775 _shm_file_close(sf);
776 else
777 opened_sf = eina_list_append(opened_sf, sf);
778
779 if (!!sf_strindex
780 && !!sf_strpool
781 && !!sf_fonts
782 && !!sf_images
783 && !!sf_files)
784 break;
785 }
786
787 if (!sf_strindex || !sf_strpool)
788 {
789 ERR("Could not identify strings memory pool");
790 goto finish;
791 }
792
793 _index_tables_summary_print();
794 _strings_all_print(full);
795 _files_all_print_short();
796 if (full) _files_all_print_all();
797 _images_all_print_short();
798 if (full) _images_all_print_full();
799 _fonts_all_print_short();
800 if (full) _fonts_all_print_full();
801
802finish:
803 EINA_LIST_FREE(opened_sf, sf)
804 _shm_file_close(sf);
805
806 EINA_LIST_FREE(shmfiles, name)
807 free(name);
808
809 eina_shutdown();
810 return 0;
811}