Initialize Tizen 2.3
[adaptation/xorg/driver/xserver-xorg-module-xdbg.git] / lib / xdbg_log_plist.c
1 /**************************************************************************
2
3 xdbg
4
5 Copyright (c) 2013 Samsung Electronics Co., Ltd All Rights Reserved
6
7 Contact: SooChan Lim <sc1.lim@samsung.com>
8          Sangjin LEE <lsj119@samsung.com>
9
10 Permission is hereby granted, free of charge, to any person obtaining a
11 copy of this software and associated documentation files (the
12 "Software"), to deal in the Software without restriction, including
13 without limitation the rights to use, copy, modify, merge, publish,
14 distribute, sub license, and/or sell copies of the Software, and to
15 permit persons to whom the Software is furnished to do so, subject to
16 the following conditions:
17
18 The above copyright notice and this permission notice (including the
19 next paragraph) shall be included in all copies or substantial portions
20 of the Software.
21
22 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
23 OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
24 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
25 IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
26 ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
27 TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
28 SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
29
30 **************************************************************************/
31
32 #ifdef HAVE_CONFIG_H
33 #include "config.h"
34 #endif
35
36 #include <stdio.h>
37 #include "xorg-server.h"
38 #include "xf86.h"
39 #include <scrnintstr.h>
40 #include <resource.h>
41 #include <windowstr.h>
42 #include <pixmap.h>
43 #include <list.h>
44 #include "xdbg.h"
45 #include "xdbg_log_int.h"
46 #include "xdbg_types.h"
47 #include "xdbg_log_plist.h"
48
49 /* for debug message */
50 #define MMEM    XDBG_M('M','E','M',0)
51
52 #ifndef API
53 #define API __attribute__ ((visibility("default")))
54 #endif
55
56 /*=========================================================================*/
57 /* trace the usage of the pixmaps in xserver                               */
58 /*=========================================================================*/
59
60 #define CLIENT_BITS(id) ((id) & RESOURCE_CLIENT_MASK)
61 #define CLIENT_ID(id) ((int)(CLIENT_BITS(id) >> CLIENTOFFSET))
62 #define MAX_HISTORY  10
63
64 typedef struct {
65     PixmapPtr pPixmap;
66     unsigned int size;
67     unsigned int refs;
68     char *hint;
69     XID refHistorys[MAX_HISTORY];
70     int numHistory;
71     struct xorg_list link;
72 } XDbgPixmap;
73
74 typedef struct {
75     PixmapPtr pPixmap;
76     struct xorg_list link;
77 } XDbgRefPixmap;
78
79 typedef struct {
80     DrawablePtr pDraw;
81     XDbgRefPixmap *pRefPixmap;
82     struct xorg_list link;
83     struct xorg_list refPixmaps;
84 } XDbgDrawable;
85
86 static int init_plist = 0;
87 static struct xorg_list xdbgPixmaps;
88 static struct xorg_list xdbgDrawables;
89 static PixmapPtr pPixRoot = NULL;
90 unsigned int total_size = 0;
91 unsigned int peek_size = 0;
92
93 const struct {
94     unsigned int hint;
95     char* str;
96 } pixmap_hint[] = {
97     {CREATE_PIXMAP_USAGE_SCRATCH,        "scratch"},
98     {CREATE_PIXMAP_USAGE_BACKING_PIXMAP, "backing_pixmap"},
99     {CREATE_PIXMAP_USAGE_GLYPH_PICTURE,  "glyph_picture"},
100     {CREATE_PIXMAP_USAGE_SHARED,         "shared"},
101     {CREATE_PIXMAP_USAGE_OVERLAY,        "overlay"},
102     {CREATE_PIXMAP_USAGE_DRI2_FLIP_BACK, "dri2_flip_back"},
103     {CREATE_PIXMAP_USAGE_FB,             "fb"},
104     {CREATE_PIXMAP_USAGE_SUB_FB,         "sub_fb"},
105     {CREATE_PIXMAP_USAGE_DRI2_BACK,      "dri2_back"},
106     /******END********/
107     {0, "normal"}
108 };
109
110 static char *
111 _get_pixmap_hint_name (signed int usage_hint)
112 {
113     int i = 0;
114
115     while (pixmap_hint[i].hint)
116     {
117         if (pixmap_hint[i].hint == usage_hint)
118             return pixmap_hint[i].str;
119         i++;
120     }
121     return NULL;
122 }
123
124 static XDbgPixmap *
125 _findXDbgPixmap (PixmapPtr pPixmap)
126 {
127     XDbgPixmap *cur = NULL, *tmp = NULL;
128
129     xorg_list_for_each_entry_safe (cur, tmp, &xdbgPixmaps, link)
130     {
131         if (cur->pPixmap == pPixmap)
132             return cur;
133     }
134
135     return NULL;
136 }
137
138 static XDbgDrawable *
139 _findXDbgDrawable (DrawablePtr pDraw)
140 {
141     XDbgDrawable *cur = NULL, *tmp = NULL;
142
143     xorg_list_for_each_entry_safe (cur, tmp, &xdbgDrawables, link)
144     {
145         if (cur->pDraw == pDraw)
146             return cur;
147     }
148
149     return NULL;
150 }
151
152 static XDbgRefPixmap*
153 _findXDbgRefPixmap (XDbgDrawable* pXDbgDrawable, PixmapPtr pPixmap)
154 {
155     XDbgRefPixmap *cur = NULL, *tmp = NULL;
156
157     xorg_list_for_each_entry_safe (cur, tmp, &pXDbgDrawable->refPixmaps, link)
158     {
159         if (cur->pPixmap == pPixmap)
160             return cur;
161     }
162
163     return NULL;
164 }
165
166 static void
167 _addXDbgPixmap (PixmapPtr pPixmap)
168 {
169     XDbgPixmap *cur = NULL;
170     unsigned int size;
171
172     cur = _findXDbgPixmap (pPixmap);
173     if (cur)
174     {
175         size = pPixmap->devKind * pPixmap->drawable.height;
176         if (size == cur->size)
177             return;
178
179         XDBG_TRACE (MMEM, " Change pixmap(%p) size(%d -> %d)\n",
180                     cur->pPixmap, cur->size, size);
181
182         total_size -= cur->size;
183         cur->size = size;
184         cur->hint = _get_pixmap_hint_name (pPixmap->usage_hint);
185     }
186     else
187     {
188         cur = calloc (1, sizeof (XDbgPixmap));
189         cur->pPixmap = pPixmap;
190         cur->size = pPixmap->devKind*pPixmap->drawable.height;
191         cur->hint = _get_pixmap_hint_name (pPixmap->usage_hint);
192         xorg_list_add (&cur->link, &xdbgPixmaps);
193     }
194
195     /* caculate the total_size of pixmaps */
196     total_size += cur->size;
197     if (total_size > peek_size)
198         peek_size = total_size;
199
200     if (pPixmap->usage_hint == CREATE_PIXMAP_USAGE_FB)
201         pPixRoot = pPixmap;
202
203     XDBG_TRACE (MMEM, "Add pixmap(%p) size:%d, hint:%s\n",
204                 cur->pPixmap, cur->size, cur->hint);
205 }
206
207 static void
208 _removeXDbgPixmap (PixmapPtr pPixmap)
209 {
210     XDbgPixmap *cur = NULL;
211
212     cur = _findXDbgPixmap (pPixmap);
213     if (!cur)
214     {
215         XDBG_WARNING (MMEM, "Unknown pixmap XID:0x%x, pPix:%p\n",
216                       (unsigned int)pPixmap->drawable.id, pPixmap);
217         return;
218     }
219
220     if (cur->refs > 0)
221         XDBG_TRACE (MMEM,"Pixmap(%p) refs:%d\n", cur->pPixmap, cur->refs);
222
223     /* caculate the total_size of pixmaps */
224     total_size -= cur->size;
225
226     XDBG_TRACE (MMEM, " Remove pixmap(%p) size:%d, hint:%s\n",
227                 cur->pPixmap, cur->size, cur->hint);
228
229     xorg_list_del(&cur->link);
230     free(cur);
231 }
232
233 #if 0
234 static void
235 _dumpDraws (char *reply, int *len)
236 {
237     XDbgDrawable *cur = NULL, *tmp = NULL;
238     XDbgRefPixmap *p = NULL, *ptmp = NULL;
239     XDbgPixmap *dp = NULL;
240
241     xorg_list_for_each_entry_safe (cur, tmp, &xdbgDrawables, link)
242     {
243         XDBG_REPLY ("[%d] XID:0x%x type:%s %dx%d+%d+%d\n",
244                                 CLIENT_ID(cur->pDraw->id),
245                                 (unsigned int)cur->pDraw->id,
246                                 (cur->pDraw->type == DRAWABLE_WINDOW ? "window":"pixmap"),
247                                 cur->pDraw->width, cur->pDraw->height, cur->pDraw->x, cur->pDraw->y);
248
249         xorg_list_for_each_entry_safe (p, ptmp, &cur->refPixmaps, link)
250         {
251             dp = _findXDbgPixmap (p->pPixmap);
252             if(!dp)
253             {
254                 XDBG_REPLY ("\t***[REF_Pixmap] unknown pixmap(%p)\n", p->pPixmap);
255                 continue;
256             }
257
258             XDBG_REPLY ("\t[REF_Pixmap] %p, hint:%s, size:%d\n",
259                                      dp->pPixmap, dp->hint, (unsigned int)dp->size/1024);
260         }
261     }
262 }
263
264 static void
265 _dumpPixmaps (char *reply, int *len)
266 {
267     XDbgPixmap *cur = NULL, *tmp = NULL;
268     int client_id;
269     int i;
270
271     if (pPixRoot)
272     {
273         cur = _findXDbgPixmap (pPixRoot);
274         XDBG_RETURN_IF_FAIL (cur != NULL);
275         XDBG_REPLY ("ROOT_Pixmap XID:0x%x pixmap(%p) hint:%s(0x%x) size:%d\n",
276                                 (unsigned int)cur->pPixmap->drawable.id, pPixRoot,
277                                 cur->hint, cur->pPixmap->usage_hint,
278                                 (unsigned int)cur->size/1024);
279     }
280
281     xorg_list_for_each_entry_safe (cur, tmp, &xdbgPixmaps, link)
282     {
283         if (cur->pPixmap == pPixRoot)
284             continue;
285
286         if (cur->pPixmap->drawable.id || cur->refs == 0)
287         {
288             client_id = CLIENT_ID(cur->pPixmap->drawable.id);
289             if (cur->pPixmap->drawable.id)
290             {
291                 XDBG_REPLY ("[%d] XID:0x%x %dx%d hint:%s(0x%x) size:%d refs:%d\n",
292                                         client_id, (unsigned int)cur->pPixmap->drawable.id,
293                                         cur->pPixmap->drawable.width, cur->pPixmap->drawable.height,
294                                         cur->hint, cur->pPixmap->usage_hint,
295                                         (unsigned int)cur->size/1024, cur->refs);
296             }
297             else
298             {
299                 XDBG_REPLY ("[%d] Pixmap:%p %dx%d hint:%s(0x%x) size:%d refs:%d\n",
300                                         client_id, cur->pPixmap,
301                                         cur->pPixmap->drawable.width, cur->pPixmap->drawable.height,
302                                         cur->hint, cur->pPixmap->usage_hint,
303                                         (unsigned int)cur->size/1024, cur->refs);
304             }
305
306             if (cur->numHistory)
307             {
308                 XDBG_REPLY ("\t[RefHistory] ");
309                 for (i = 0; i < cur->numHistory; i++)
310                 {
311                     XDBG_REPLY ("0x%x ", (unsigned int)cur->refHistorys[i]);
312                 }
313                 XDBG_REPLY ("\n");
314             }
315         }
316     }
317 }
318 #endif
319
320 CreatePixmapProcPtr fnCreatePixmap;
321 DestroyPixmapProcPtr fnDestroyPixmap;
322 ModifyPixmapHeaderProcPtr fnModifyPixmap;
323 SetWindowPixmapProcPtr fnSetWindowPixmap;
324 DestroyWindowProcPtr fnDestroyWindow;
325
326 static PixmapPtr
327 XDbgLogCreatePixmap (ScreenPtr pScreen, int width, int height,
328                         int depth, unsigned usage_hint)
329 {
330     PixmapPtr pPixmap = NULL;
331
332     pScreen->CreatePixmap = fnCreatePixmap;
333     pPixmap = pScreen->CreatePixmap(pScreen, width, height, depth, usage_hint);
334     pScreen->CreatePixmap = XDbgLogCreatePixmap;
335
336     if(pPixmap)
337         _addXDbgPixmap (pPixmap);
338
339     return pPixmap;
340 }
341
342 static Bool
343 XDbgLogModifyPixmapHeader (PixmapPtr pPixmap, int width, int height,
344                               int depth, int bitsPerPixel, int devKind, pointer pPixData)
345 {
346     Bool ret;
347     ScreenPtr pScreen = pPixmap->drawable.pScreen;
348
349     pScreen->ModifyPixmapHeader = fnModifyPixmap;
350     ret = pScreen->ModifyPixmapHeader (pPixmap, width, height,
351                                        depth, bitsPerPixel, devKind, pPixData);
352     pScreen->ModifyPixmapHeader = XDbgLogModifyPixmapHeader;
353
354     _addXDbgPixmap (pPixmap);
355
356     return ret;
357 }
358
359 static Bool
360 XDbgLogDestroyPixmap (PixmapPtr pPixmap)
361 {
362     Bool ret;
363
364     ScreenPtr pScreen = pPixmap->drawable.pScreen;
365
366     if (pPixmap->refcnt == 1)
367         _removeXDbgPixmap (pPixmap);
368
369     pScreen->DestroyPixmap = fnDestroyPixmap;
370     ret = pScreen->DestroyPixmap(pPixmap);
371     pScreen->DestroyPixmap = XDbgLogDestroyPixmap;
372
373     return ret;
374 }
375
376 static void
377 XDbgLogSetWindowPixmap (WindowPtr pWin, PixmapPtr pPixmap)
378 {
379     ScreenPtr pScreen = (ScreenPtr) pWin->drawable.pScreen;
380     WindowPtr pParent = pWin->parent;
381     XDbgDrawable *d = NULL;
382     XDbgPixmap *p = NULL;
383     XDbgRefPixmap *p_ref = NULL;
384
385     pScreen->SetWindowPixmap = fnSetWindowPixmap;
386     pScreen->SetWindowPixmap (pWin, pPixmap);
387     pScreen->SetWindowPixmap = XDbgLogSetWindowPixmap;
388
389     if (pPixmap != pScreen->GetWindowPixmap(pParent))
390     {
391         //Add to window list
392         p = _findXDbgPixmap (pPixmap);
393         if (!p)
394         {
395             XDBG_WARNING (MMEM, "Unknown pixmap(%p) hint:%s\n",
396                           pPixmap, _get_pixmap_hint_name(pPixmap->usage_hint));
397             return;
398         }
399
400         d = _findXDbgDrawable (&pWin->drawable);
401         if (!d)
402         {
403             d = calloc (1, sizeof(XDbgDrawable));
404             d->pDraw = &pWin->drawable;
405             xorg_list_init (&d->refPixmaps);
406             xorg_list_add (&d->link, &xdbgDrawables);
407             XDBG_TRACE (MMEM, " Add window(0x%x)\n", (unsigned int)pWin->drawable.id);
408         }
409
410         if (d->pRefPixmap)
411         {
412             XDBG_TRACE (MMEM, " Unset WinPixmap win(0x%x), pixmap(%p) hint:%s\n",
413                                    (unsigned int)pWin->drawable.id, p->pPixmap, p->hint);
414             xorg_list_del (&d->pRefPixmap->link);
415             free (d->pRefPixmap);
416             d->pRefPixmap = NULL;
417         }
418
419         p_ref = calloc (1, sizeof(XDbgRefPixmap));
420         p_ref->pPixmap = pPixmap;
421         xorg_list_init (&p_ref->link);
422         xorg_list_add (&p_ref->link, &d->refPixmaps);
423         d->pRefPixmap = p_ref;
424
425         p->refs++;
426         p->refHistorys[p->numHistory++] = pWin->drawable.id;
427
428         XDBG_TRACE (MMEM, " Set WinPixmap win(0x%x), pixmap(%p) hint:%s\n",
429                             (unsigned int)pWin->drawable.id, p->pPixmap, p->hint);
430     }
431     else
432     {
433         //find window
434         d = _findXDbgDrawable (&pWin->drawable);
435
436         //remove window
437         if (d && d->pRefPixmap)
438         {
439             p = _findXDbgPixmap (d->pRefPixmap->pPixmap);
440             if (p)
441             {
442                 if (p->refs > 0)
443                     p->refs--;
444                 else
445                     XDBG_WARNING (MMEM, "pixmap(%p), refs(%d)\n",
446                                   __FUNCTION__, __LINE__, p->pPixmap, p->refs);
447             }
448
449             XDBG_TRACE (MMEM,"Unset WinPixmap win(0x%x): pixmap(%p) to NULL\n",
450                         (unsigned int)pWin->drawable.id, d->pRefPixmap->pPixmap);
451
452             xorg_list_del (&d->pRefPixmap->link);
453             free (d->pRefPixmap);
454             d->pRefPixmap = NULL;
455
456             if (xorg_list_is_empty (&d->refPixmaps))
457             {
458                 xorg_list_del (&d->link);
459                 free(d);
460             }
461         }
462     }
463 }
464
465 static Bool
466 XDbgLogDestroyWindow (WindowPtr pWindow)
467 {
468     Bool ret;
469     ScreenPtr pScreen = pWindow->drawable.pScreen;
470     XDbgDrawable *d = NULL;
471     XDbgPixmap *p = NULL;
472     XDbgRefPixmap *pos = NULL, *tmp = NULL;
473
474     pScreen->DestroyWindow = fnDestroyWindow;
475     ret = pScreen->DestroyWindow (pWindow);
476     pScreen->DestroyWindow = XDbgLogDestroyWindow;
477
478     d = _findXDbgDrawable (&pWindow->drawable);
479     if (d)
480     {
481         XDBG_TRACE (MMEM, "Remove drawable(0x%x)\n",
482                     (unsigned int)pWindow->drawable.id);
483
484         xorg_list_for_each_entry_safe (pos, tmp, &d->refPixmaps, link)
485         {
486             p = _findXDbgPixmap (pos->pPixmap);
487             if(p)
488                 p->refs--;
489
490             XDBG_TRACE (MMEM, "Remove ref_pixmap(%p), dbgPixmap(%p)\n",
491                         pos->pPixmap, p);
492
493             xorg_list_del (&pos->link);
494             free (pos);
495         }
496
497         xorg_list_del (&d->link);
498         free (d);
499     }
500
501     return ret;
502 }
503
504 API void
505 xDbgLogPListInit (ScreenPtr pScreen)
506 {
507     init_plist = 1;
508
509     xorg_list_init (&xdbgPixmaps);
510     xorg_list_init (&xdbgDrawables);
511
512     fnSetWindowPixmap = pScreen->SetWindowPixmap;
513     fnDestroyWindow = pScreen->DestroyWindow;
514     fnCreatePixmap = pScreen->CreatePixmap;
515     fnModifyPixmap = pScreen->ModifyPixmapHeader;
516     fnDestroyPixmap = pScreen->DestroyPixmap;
517
518     pScreen->CreatePixmap = XDbgLogCreatePixmap;
519     pScreen->DestroyPixmap = XDbgLogDestroyPixmap;
520     pScreen->ModifyPixmapHeader = XDbgLogModifyPixmapHeader;
521     pScreen->SetWindowPixmap = XDbgLogSetWindowPixmap;
522     pScreen->DestroyWindow = XDbgLogDestroyWindow;
523 }
524
525 API void
526 xDbgLogPListDeinit (ScreenPtr pScreen)
527 {}
528
529
530 API void
531 xDbgLogPListDrawAddRefPixmap (DrawablePtr pDraw, PixmapPtr pRefPixmap)
532 {
533     XDbgDrawable *d = NULL;
534     XDbgPixmap *p = NULL;
535     XDbgRefPixmap *p_ref = NULL;
536
537     XDBG_RETURN_IF_FAIL (pDraw != NULL);
538     XDBG_RETURN_IF_FAIL (pRefPixmap != NULL);
539
540     d = _findXDbgDrawable (pDraw);
541     p = _findXDbgPixmap (pRefPixmap);
542     if(!p)
543     {
544         XDBG_WARNING (MMEM, "%s:%d : Unknown pixmap XID:0x%x, pPix:%p\n",
545                       __FUNCTION__, __LINE__,
546                       (unsigned int)pRefPixmap->drawable.id, pRefPixmap);
547         return;
548     }
549
550     if (!d)
551     {
552         d = calloc (1, sizeof(XDbgDrawable));
553         d->pDraw = pDraw;
554         xorg_list_init (&d->refPixmaps);
555         xorg_list_add (&d->link, &xdbgDrawables);
556
557         XDBG_TRACE (MMEM, " Add window(0x%x)\n", (unsigned int)pDraw->id);
558     }
559
560     p_ref =_findXDbgRefPixmap (d, pRefPixmap);
561     if(p_ref)
562         return;
563
564     p_ref = calloc (1, sizeof(XDbgRefPixmap));
565     p_ref->pPixmap = pRefPixmap;
566     xorg_list_init (&p_ref->link);
567     xorg_list_add (&p_ref->link, &d->refPixmaps);
568
569     p->refs++;
570     if (p->numHistory < (MAX_HISTORY-1))
571         p->refHistorys[p->numHistory++] = pDraw->id;
572
573     if (pDraw->type == DRAWABLE_WINDOW)
574         XDBG_TRACE (MMEM, " Add RefPixmap win(0x%x), pixmap(%p) hint:%s\n",
575                     (unsigned int)pDraw->id, p->pPixmap, p->hint);
576     else
577         XDBG_TRACE (MMEM, " Add RefPixmap pix(0x%x), pixmap(%p) hint:%s\n",
578                     (unsigned int)pDraw->id, p->pPixmap, p->hint);
579 }
580
581 API void
582 xDbgLogPListDrawRemoveRefPixmap (DrawablePtr pDraw, PixmapPtr pRefPixmap)
583 {
584     XDbgDrawable *d = NULL;
585     XDbgRefPixmap *p_ref = NULL;
586     XDbgPixmap *p = NULL;
587
588     p = _findXDbgPixmap (pRefPixmap);
589     if (pDraw == NULL)
590     {
591         if (p && p->refs > 0)
592         {
593             XDBG_ERROR (MMEM, "Error:%s:%d null draw pixmap(%p)\n",
594                         __FUNCTION__, __LINE__, pRefPixmap);
595         }
596         return;
597     }
598
599     d = _findXDbgDrawable (pDraw);
600     if (!d)
601     {
602         XDBG_WARNING (MMEM, "%s:%d : Unknown drawable XID:0x%x, pPix:%p\n",
603                       __FUNCTION__, __LINE__, (unsigned int)pDraw->id, pRefPixmap);
604         return;
605     }
606
607     p_ref = _findXDbgRefPixmap (d, pRefPixmap);
608     if(!p_ref)
609     {
610         XDBG_WARNING (MMEM, "%s:%d : Unknown refpixmap XID:0x%x, pPix:%p\n",
611                                   __FUNCTION__, __LINE__, (unsigned int)pDraw->id, pRefPixmap);
612         return;
613     }
614
615     xorg_list_del (&p_ref->link);
616     free (p_ref);
617     if (p)
618         p->refs--;
619
620     if (xorg_list_is_empty (&d->refPixmaps))
621     {
622         xorg_list_del(&d->link);
623         free(d);
624     }
625
626     if (pDraw->type == DRAWABLE_WINDOW)
627         XDBG_TRACE (MMEM, " Remove RefPixmap win(0x%x), pixmap(%p) hint:%s\n",
628                                 (unsigned int)pDraw->id, pRefPixmap,
629                                 _get_pixmap_hint_name(pRefPixmap->usage_hint));
630     else
631         XDBG_TRACE (MMEM, " Remove RefPixmap pix(0x%x), pixmap(%p) hint:%s\n",
632                                 (unsigned int)pDraw->id, pRefPixmap,
633                                 _get_pixmap_hint_name(pRefPixmap->usage_hint));
634 }
635
636
637 API void
638 xDbgLogPList (char *reply, int *len)
639 {
640     if (!init_plist)
641     {
642         XDBG_REPLY ("plist is not supported.\n");
643         return;
644     }
645
646     XDBG_REPLY ("\n\n====================================\n");
647     XDBG_REPLY ("    Total:%d, Peek:%d\n", (unsigned int)total_size/1024, (unsigned int)peek_size/1024);
648     XDBG_REPLY ( "====================================\n");
649
650     XDBG_REPLY ("== WINDOWS ==\n");
651     XDbgDrawable *dd = NULL, *ddtmp = NULL;
652     XDbgRefPixmap *rp = NULL, *rptmp = NULL;
653     XDbgPixmap *dp = NULL;
654
655     xorg_list_for_each_entry_safe (dd, ddtmp, &xdbgDrawables, link)
656     {
657         XDBG_REPLY ("[%d] XID:0x%x type:%s %dx%d+%d+%d\n",
658                                 CLIENT_ID(dd->pDraw->id),
659                                 (unsigned int)dd->pDraw->id,
660                                 (dd->pDraw->type == DRAWABLE_WINDOW ? "window":"pixmap"),
661                                 dd->pDraw->width, dd->pDraw->height, dd->pDraw->x, dd->pDraw->y);
662
663         xorg_list_for_each_entry_safe (rp, rptmp, &dd->refPixmaps, link)
664         {
665             dp = _findXDbgPixmap (rp->pPixmap);
666             if(!dp)
667             {
668                 XDBG_REPLY ("\t***[REF_Pixmap] unknown pixmap(%p)\n", rp->pPixmap);
669                 continue;
670             }
671
672             XDBG_REPLY ("\t[REF_Pixmap] %p, hint:%s, size:%d\n",
673                                      dp->pPixmap, dp->hint, (unsigned int)dp->size/1024);
674         }
675     }
676     XDBG_REPLY ("\n");
677
678
679     XDBG_REPLY ( "== PIXMAPS ==\n");
680     XDbgPixmap *cur = NULL, *tmp = NULL;
681     int client_id;
682     int i;
683
684     if (pPixRoot)
685     {
686         cur = _findXDbgPixmap (pPixRoot);
687         XDBG_RETURN_IF_FAIL (cur != NULL);
688         XDBG_REPLY ("ROOT_Pixmap XID:0x%x pixmap(%p) hint:%s(0x%x) size:%d\n",
689                                 (unsigned int)cur->pPixmap->drawable.id, pPixRoot,
690                                 cur->hint, cur->pPixmap->usage_hint,
691                                 (unsigned int)cur->size/1024);
692     }
693
694     xorg_list_for_each_entry_safe (cur, tmp, &xdbgPixmaps, link)
695     {
696         if (cur->pPixmap == pPixRoot)
697             continue;
698
699         if (cur->pPixmap->drawable.id || cur->refs == 0)
700         {
701             client_id = CLIENT_ID(cur->pPixmap->drawable.id);
702             if (cur->pPixmap->drawable.id)
703             {
704                 XDBG_REPLY ("[%d] XID:0x%x %dx%d hint:%s(0x%x) size:%d refs:%d\n",
705                                         client_id, (unsigned int)cur->pPixmap->drawable.id,
706                                         cur->pPixmap->drawable.width, cur->pPixmap->drawable.height,
707                                         cur->hint, cur->pPixmap->usage_hint,
708                                         (unsigned int)cur->size/1024, cur->refs);
709             }
710             else
711             {
712                 XDBG_REPLY ("[%d] Pixmap:%p %dx%d hint:%s(0x%x) size:%d refs:%d\n",
713                                         client_id, cur->pPixmap,
714                                         cur->pPixmap->drawable.width, cur->pPixmap->drawable.height,
715                                         cur->hint, cur->pPixmap->usage_hint,
716                                         (unsigned int)cur->size/1024, cur->refs);
717             }
718
719             if (cur->numHistory)
720             {
721                 XDBG_REPLY ("\t[RefHistory] ");
722                 for (i = 0; i < cur->numHistory; i++)
723                 {
724                     XDBG_REPLY ("0x%x ", (unsigned int)cur->refHistorys[i]);
725                 }
726                 XDBG_REPLY ("\n");
727             }
728         }
729     }
730     XDBG_REPLY ("\n");
731 }
732