Initialize Tizen 2.3
[adaptation/xorg/driver/xserver-xorg-module-xdbg.git] / lib / xdbg_dump.c
1 /**************************************************************************
2
3 xdbg
4
5 Copyright (c) 2013 Samsung Electronics Co., Ltd All Rights Reserved
6
7 Contact: Boram Park <boram1288.park@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 <fcntl.h>
37 #include <dirent.h>
38 #include <sys/stat.h>
39
40 #include "xdbg_log.h"
41 #include "xdbg_dump.h"
42 #include "xdbg_dump_module.h"
43 #include <list.h>
44
45 #ifndef API
46 #define API __attribute__ ((visibility("default")))
47 #endif
48
49 #define DUMP_BUFCNT  50
50 #define DUMP_DIR "/tmp/xdump"
51 #define DUMP_SCALE_RATIO  2
52
53 typedef struct
54 {
55     int    index;
56
57     void  *bo;      /* buffer object */
58     int    bo_size;
59
60     char   file[128];
61     union {
62         struct {
63             int dump_w;
64             int dump_h;
65             xRectangle dump_rect;
66         } a;
67         int dump_size;
68     } u;
69     Bool   is_dirty;
70     Bool   is_bmp;
71
72     struct xorg_list link;
73 } xDbgDumpBuffer;
74
75 typedef struct
76 {
77     Bool init;
78
79     char *type_str;
80     char *file_str;
81     char *count_str;
82     char *crop_str;
83
84     xDbgDumpBufferFunc func;
85     int bo_size;
86
87     struct xorg_list *cursor;
88     struct xorg_list  buffers;
89
90     int   type;
91     int   count;
92     xRectangle *crop;
93 } xDbgDumpInfo;
94
95 static xDbgDumpInfo xdbg_dump_info;
96
97 static int
98 _parse_int (char *s)
99 {
100     char *fmt = "%lu";
101     int retval = 0;
102     int thesign = 1;
103
104     if (s && s[0])
105     {
106         char temp[12];
107         snprintf (temp, sizeof (temp), "%s", s);
108         s = temp;
109
110         if (s[0] == '-')
111             s++, thesign = -1;
112         if (s[0] == '0')
113             s++, fmt = "%o";
114         if (s[0] == 'x' || s[0] == 'X')
115             s++, fmt = "%x";
116         (void) sscanf (s, fmt, &retval);
117     }
118     return (thesign * retval);
119 }
120
121 static Bool
122 _xDbgDumpEnsureDir (void)
123 {
124     char *dir = DUMP_DIR;
125     DIR *dp;
126     int ret;
127
128     if (!(dp = opendir (dir)))
129     {
130         ret = mkdir (dir, 0755);
131         if (ret < 0)
132         {
133             XDBG_ERROR (MXDBG, "fail: mkdir '%s'\n", DUMP_DIR);
134             return FALSE;
135         }
136     }
137     else
138         closedir (dp);
139
140     return TRUE;
141 }
142
143 static void
144 _xDbgDumpSetOptions (void)
145 {
146     char options[256];
147     int tempsize = sizeof (options);
148     char *reply = options;
149     int *len = &tempsize;
150
151     options[0] = '\0';
152
153     /* type */
154     if (xdbg_dump_info.type_str)
155     {
156         char *c = xdbg_dump_info.type_str;
157         if (!strcmp (c, "drawable"))
158             xdbg_dump_info.type = XDBG_DUMP_TYPE_DRAWABLE;
159         else if (!strcmp (c, "fb"))
160             xdbg_dump_info.type = XDBG_DUMP_TYPE_FB;
161         else if (!strcmp (c, "ui"))
162             xdbg_dump_info.type = XDBG_DUMP_TYPE_UI;
163         else if (!strcmp (c, "video"))
164             xdbg_dump_info.type = XDBG_DUMP_TYPE_VIDEO;
165         else
166             xdbg_dump_info.type = _parse_int (c);
167     }
168     else
169         xdbg_dump_info.type = XDBG_DUMP_TYPE_UI;
170     XDBG_REPLY ("type(0x%x) ", xdbg_dump_info.type);
171
172     /* count */
173     if (xdbg_dump_info.count_str)
174         xdbg_dump_info.count = atoi (xdbg_dump_info.count_str);
175     else
176         xdbg_dump_info.count = DUMP_BUFCNT;
177     XDBG_REPLY ("count(%d) ", xdbg_dump_info.count);
178
179     /* file */
180     if (xdbg_dump_info.file_str)
181         XDBG_REPLY ("file(%s) ", xdbg_dump_info.file_str);
182
183     /* crop */
184     if (xdbg_dump_info.crop_str)
185     {
186         int i;
187         char temp[64];
188         char *c;
189         int nums[4];
190
191         if (xdbg_dump_info.crop)
192         {
193             free (xdbg_dump_info.crop);
194             xdbg_dump_info.crop = NULL;
195         }
196
197         snprintf (temp, sizeof (temp), "%s", xdbg_dump_info.crop_str);
198
199         c = strtok (temp, ",");
200         i = 0;
201         while (c != NULL)
202         {
203             nums[i++] = atoi(c);
204             c = strtok (NULL, ",");
205             if (i == 4)
206                 break;
207         }
208
209         if (i == 4)
210         {
211             xdbg_dump_info.crop = calloc (1, sizeof (xRectangle));
212             XDBG_RETURN_IF_FAIL (xdbg_dump_info.crop != NULL);
213
214             xdbg_dump_info.crop->x = nums[0];
215             xdbg_dump_info.crop->y = nums[1];
216             xdbg_dump_info.crop->width = nums[2];
217             xdbg_dump_info.crop->height = nums[3];
218
219             XDBG_REPLY ("crop(%d,%d %dx%d) ",
220                         nums[0], nums[1], nums[2], nums[3]);
221         }
222     }
223
224     XDBG_DEBUG (MXDBG, "%s\n", options);
225 }
226
227 static void
228 _xDbgDumpInit (void)
229 {
230     if (xdbg_dump_info.init)
231         return;
232
233     xdbg_dump_info.init = TRUE;
234     xdbg_dump_info.cursor = NULL;
235     xorg_list_init (&xdbg_dump_info.buffers);
236 }
237
238 static int
239 _xDbgDumpBmp (const char * file, const void * data, int width, int height)
240 {
241     int i;
242
243     struct
244     {
245         unsigned char magic[2];
246     } bmpfile_magic = { {'B', 'M'} };
247
248     struct
249     {
250         unsigned int filesz;
251         unsigned short creator1;
252         unsigned short creator2;
253         unsigned int bmp_offset;
254     } bmpfile_header = { 0, 0, 0, 0x36 };
255
256     struct
257     {
258         unsigned int header_sz;
259         unsigned int width;
260         unsigned int height;
261         unsigned short nplanes;
262         unsigned short bitspp;
263         unsigned int compress_type;
264         unsigned int bmp_bytesz;
265         unsigned int hres;
266         unsigned int vres;
267         unsigned int ncolors;
268         unsigned int nimpcolors;
269     } bmp_dib_v3_header_t = { 0x28, 0, 0, 1, 24, 0, 0, 0, 0, 0, 0 };
270     unsigned int * blocks;
271
272     XDBG_RETURN_VAL_IF_FAIL (file != NULL, FALSE);
273     XDBG_RETURN_VAL_IF_FAIL (data != NULL, FALSE);
274     XDBG_RETURN_VAL_IF_FAIL (width > 0, FALSE);
275     XDBG_RETURN_VAL_IF_FAIL (height > 0, FALSE);
276
277     FILE * fp = fopen (file, "w+");
278     XDBG_RETURN_VAL_IF_FAIL (fp != NULL, FALSE);
279
280     bmpfile_header.filesz = sizeof (bmpfile_magic) + sizeof (bmpfile_header) +
281                             sizeof (bmp_dib_v3_header_t) + width * height * 3;
282     bmp_dib_v3_header_t.header_sz = sizeof (bmp_dib_v3_header_t);
283     bmp_dib_v3_header_t.width = width;
284     bmp_dib_v3_header_t.height = -height;
285     bmp_dib_v3_header_t.nplanes = 1;
286     bmp_dib_v3_header_t.bmp_bytesz = width * height * 3;
287
288     fwrite (&bmpfile_magic, sizeof (bmpfile_magic), 1, fp);
289     fwrite (&bmpfile_header, sizeof (bmpfile_header), 1, fp);
290     fwrite (&bmp_dib_v3_header_t, sizeof (bmp_dib_v3_header_t), 1, fp);
291
292     blocks = (unsigned int*)data;
293     for (i=0; i<height * width; i++)
294         fwrite (&blocks[i], 3, 1, fp);
295
296     fclose (fp);
297
298     XDBG_TRACE (MXDBG, "%s saved\n", file);
299
300     return TRUE;
301 }
302
303 static Bool
304 _xDbgDumpRaw (const char * file, const void * data, int size)
305 {
306     XDBG_RETURN_VAL_IF_FAIL (file != NULL, FALSE);
307     XDBG_RETURN_VAL_IF_FAIL (data != NULL, FALSE);
308     XDBG_RETURN_VAL_IF_FAIL (size > 0, FALSE);
309
310     FILE * fp = fopen (file, "w+");
311     XDBG_RETURN_VAL_IF_FAIL (fp != NULL, FALSE);
312
313     unsigned int *blocks = (unsigned int*)data;
314     fwrite (blocks, 1, size, fp);
315     fclose (fp);
316
317     XDBG_TRACE (MXDBG, "%s saved\n", file);
318
319     return TRUE;
320 }
321
322 API Bool
323 xDbgDumpSetType (char *type_str)
324 {
325     XDBG_RETURN_VAL_IF_FAIL (type_str != NULL, FALSE);
326
327     _xDbgDumpInit ();
328
329     if (!xorg_list_is_empty (&xdbg_dump_info.buffers))
330     {
331         XDBG_ERROR (MXDBG, "can't set.\n");
332         return FALSE;
333     }
334
335     if (xdbg_dump_info.type_str)
336         free (xdbg_dump_info.type_str);
337
338     xdbg_dump_info.type_str = strdup (type_str);
339     XDBG_DEBUG (MXDBG, "type_str: %s\n", xdbg_dump_info.type_str);
340
341     return TRUE;
342 }
343
344 API Bool
345 xDbgDumpSetFile (char *file_str)
346 {
347     XDBG_RETURN_VAL_IF_FAIL (file_str != NULL, FALSE);
348
349     _xDbgDumpInit ();
350
351     if (!xorg_list_is_empty (&xdbg_dump_info.buffers))
352     {
353         XDBG_ERROR (MXDBG, "can't set.\n");
354         return FALSE;
355     }
356
357     if (xdbg_dump_info.file_str)
358         free (xdbg_dump_info.file_str);
359
360     xdbg_dump_info.file_str = strdup (file_str);
361     XDBG_DEBUG (MXDBG, "file_str: %s\n", xdbg_dump_info.file_str);
362
363     return TRUE;
364 }
365
366 API Bool
367 xDbgDumpSetCount (char *count_str)
368 {
369     XDBG_RETURN_VAL_IF_FAIL (count_str != NULL, FALSE);
370
371     _xDbgDumpInit ();
372
373     if (!xorg_list_is_empty (&xdbg_dump_info.buffers))
374     {
375         XDBG_ERROR (MXDBG, "can't set.\n");
376         return FALSE;
377     }
378
379     if (xdbg_dump_info.count_str)
380         free (xdbg_dump_info.count_str);
381
382     xdbg_dump_info.count_str = strdup (count_str);
383     XDBG_DEBUG (MXDBG, "count_str: %s\n", xdbg_dump_info.count_str);
384
385     return TRUE;
386 }
387
388 API Bool
389 xDbgDumpSetCrop (char *crop_str)
390 {
391     XDBG_RETURN_VAL_IF_FAIL (crop_str != NULL, FALSE);
392
393     _xDbgDumpInit ();
394
395     if (!xorg_list_is_empty (&xdbg_dump_info.buffers))
396     {
397         XDBG_ERROR (MXDBG, "can't set.\n");
398         return FALSE;
399     }
400
401     if (xdbg_dump_info.crop_str)
402         free (xdbg_dump_info.crop_str);
403
404     xdbg_dump_info.crop_str = strdup (crop_str);
405     XDBG_DEBUG (MXDBG, "crop_str: %s\n", xdbg_dump_info.crop_str);
406
407     return TRUE;
408 }
409
410 API char*
411 xDbgDumpGetType (void)
412 {
413     return xdbg_dump_info.type_str;
414 }
415
416 API char*
417 xDbgDumpGetFile (void)
418 {
419     return xdbg_dump_info.file_str;
420 }
421
422 API char*
423 xDbgDumpGetCount (void)
424 {
425     return xdbg_dump_info.count_str;
426 }
427
428 API char*
429 xDbgDumpGetCrop (void)
430 {
431     return xdbg_dump_info.crop_str;
432 }
433
434 API Bool
435 xDbgDumpPrepare (void)
436 {
437     int i;
438
439     _xDbgDumpInit ();
440
441     if (!xorg_list_is_empty (&xdbg_dump_info.buffers))
442         return TRUE;
443
444     _xDbgDumpSetOptions ();
445
446     for (i = 0; i < xdbg_dump_info.count; i++)
447     {
448         xDbgDumpBuffer *dumpbuf = calloc (1, sizeof (xDbgDumpBuffer));
449         XDBG_GOTO_IF_FAIL (dumpbuf != NULL, fail);
450
451         xorg_list_add (&dumpbuf->link, &xdbg_dump_info.buffers);
452         dumpbuf->index = i;
453         dumpbuf->bo_size = xdbg_dump_info.bo_size;
454         if (xdbg_dump_info.func.alloc)
455         {
456             dumpbuf->bo = xdbg_dump_info.func.alloc (dumpbuf->bo_size);
457             XDBG_GOTO_IF_FAIL (dumpbuf->bo != NULL, fail);
458         }
459     }
460
461     xdbg_dump_info.cursor = &xdbg_dump_info.buffers;
462
463     return TRUE;
464 fail:
465     xDbgDumpClear ();
466     return FALSE;
467 }
468
469 API void
470 xDbgDumpSave (void)
471 {
472     xDbgDumpBuffer *cur = NULL, *next = NULL;
473
474     _xDbgDumpInit ();
475
476     if (!_xDbgDumpEnsureDir ())
477         return;
478
479     xorg_list_for_each_entry_safe (cur, next, &xdbg_dump_info.buffers, link)
480     {
481         char file[128];
482         void *ptr;
483
484         if (!cur->is_dirty)
485             continue;
486
487         if (xdbg_dump_info.func.map)
488             ptr = xdbg_dump_info.func.map (cur->bo);
489         else
490             ptr = cur->bo;
491         XDBG_GOTO_IF_FAIL (ptr != NULL, reset_dump);
492
493         snprintf (file, sizeof(file), "%s/%s", DUMP_DIR, cur->file);
494
495         if (cur->is_bmp)
496         {
497             unsigned int *p = (unsigned int*)ptr;
498             int i, j;
499
500             /* fill magenta color(#FF00FF) for background */
501             for (j = 0; j < cur->u.a.dump_h; j++)
502                 for (i = 0; i < cur->u.a.dump_w ; i++)
503                 {
504                     if (i >= cur->u.a.dump_rect.x && i < (cur->u.a.dump_rect.x + cur->u.a.dump_rect.width))
505                         if (j >= cur->u.a.dump_rect.y && j < (cur->u.a.dump_rect.y + cur->u.a.dump_rect.height))
506                             continue;
507                     p[i + j * cur->u.a.dump_w] = 0xFFFF00FF;
508                 }
509
510             _xDbgDumpBmp (file, ptr, cur->u.a.dump_w, cur->u.a.dump_h);
511
512             if (xdbg_dump_info.file_str && !strcmp (xdbg_dump_info.file_str, "raw"))
513             {
514                 snprintf (file, sizeof(file), "%s/%s.raw", DUMP_DIR, cur->file);
515                 _xDbgDumpRaw (file, ptr, cur->u.a.dump_w*cur->u.a.dump_h*4);
516             }
517         }
518         else
519         {
520             _xDbgDumpRaw (file, ptr, cur->u.dump_size);
521         }
522
523         if (xdbg_dump_info.func.unmap)
524             xdbg_dump_info.func.unmap (cur->bo);
525
526 reset_dump:
527         cur->file[0] = '\0';
528         memset (&cur->u, 0, sizeof (cur->u));
529         cur->is_dirty = FALSE;
530         cur->is_bmp = FALSE;
531     }
532 }
533
534 API void
535 xDbgDumpClear (void)
536 {
537     xDbgDumpBuffer *cur = NULL, *next = NULL;
538
539     _xDbgDumpInit ();
540
541     xorg_list_for_each_entry_safe (cur, next, &xdbg_dump_info.buffers, link)
542     {
543         if (xdbg_dump_info.func.free)
544             xdbg_dump_info.func.free (cur->bo);
545         xorg_list_del (&cur->link);
546         free (cur);        
547     }
548
549     xdbg_dump_info.cursor = NULL;
550
551     xdbg_dump_info.type = XDBG_DUMP_TYPE_NONE;
552     xdbg_dump_info.count = 0;
553     if (xdbg_dump_info.crop)
554     {
555         free (xdbg_dump_info.crop);
556         xdbg_dump_info.crop = NULL;
557     }
558
559     XDBG_DEBUG (MXDBG, "\n");
560 }
561
562 API Bool
563 xDbgDumpSetBufferFunc (xDbgDumpBufferFunc *func, int bo_size)
564 {
565     XDBG_RETURN_VAL_IF_FAIL (bo_size > 0, FALSE);
566     XDBG_RETURN_VAL_IF_FAIL (func != NULL, FALSE);
567     XDBG_RETURN_VAL_IF_FAIL (func->alloc != NULL, FALSE);
568     XDBG_RETURN_VAL_IF_FAIL (func->free != NULL, FALSE);
569     if (func->map)
570         XDBG_RETURN_VAL_IF_FAIL (func->unmap != NULL, FALSE);
571
572     _xDbgDumpInit ();
573
574     xdbg_dump_info.func = *func;
575     xdbg_dump_info.bo_size = bo_size;
576
577     XDBG_INFO (MXDBG, "\n");
578
579     return TRUE;
580 }
581
582 API Bool
583 xDbgDumpIsEnable (xDbgDumpType type)
584 {
585     return (xdbg_dump_info.type & type) ? TRUE : FALSE;
586 }
587
588 API void
589 xDbgDumpRaw (void *data, xDbgDumpType type, void *var_buf, const char *file)
590 {
591     xDbgDumpBuffer *dumpbuf;
592     struct xorg_list *next_cursor;
593
594     XDBG_RETURN_IF_FAIL (type > 0);
595     XDBG_RETURN_IF_FAIL (var_buf != NULL);
596     XDBG_RETURN_IF_FAIL (file != NULL);
597
598     _xDbgDumpInit ();
599     if (xorg_list_is_empty (&xdbg_dump_info.buffers))
600     {
601         XDBG_WARNING (MXDBG, "not ready to dump\n");
602         return;
603     }
604
605     next_cursor = xdbg_dump_info.cursor->next;
606     XDBG_RETURN_IF_FAIL (next_cursor != NULL);
607
608     if (next_cursor == &xdbg_dump_info.buffers)
609     {
610         next_cursor = next_cursor->next;
611         XDBG_RETURN_IF_FAIL (next_cursor != NULL);
612     }
613
614     dumpbuf = xorg_list_entry (next_cursor, xDbgDumpBuffer, link);
615     XDBG_RETURN_IF_FAIL (dumpbuf != NULL);
616
617     if (xdbg_dump_info.func.dumpRaw)
618     {
619         Bool ret;
620         int dump_size = 0;
621
622         ret = xdbg_dump_info.func.dumpRaw (data, type,
623                                            var_buf, dumpbuf->bo, dumpbuf->bo_size,
624                                            &dump_size);
625         XDBG_RETURN_IF_FAIL (ret == TRUE);
626         XDBG_RETURN_IF_FAIL (dump_size > 0);
627         XDBG_RETURN_IF_FAIL (dump_size <= dumpbuf->bo_size);
628
629         snprintf (dumpbuf->file, sizeof (dumpbuf->file), "%.3f_%s", GetTimeInMillis()/1000.0, file);
630         dumpbuf->u.dump_size = dump_size;
631         dumpbuf->is_dirty = TRUE;
632         dumpbuf->is_bmp = FALSE;
633
634         xdbg_dump_info.cursor = next_cursor;
635     }
636
637     XDBG_DEBUG (MXDBG, "type:0x%x file: %s\n", type, file);
638 }
639
640 API void
641 xDbgDumpBmp (void *data, xDbgDumpType type, void *var_buf, const char *file)
642 {
643     xDbgDumpBuffer *dumpbuf;
644     struct xorg_list *next_cursor;
645
646     XDBG_RETURN_IF_FAIL (type > 0);
647     XDBG_RETURN_IF_FAIL (var_buf != NULL);
648     XDBG_RETURN_IF_FAIL (file != NULL);
649
650     _xDbgDumpInit ();
651     if (xorg_list_is_empty (&xdbg_dump_info.buffers))
652     {
653         XDBG_WARNING (MXDBG, "not ready to dump\n");
654         return;
655     }
656
657     next_cursor = xdbg_dump_info.cursor->next;
658     XDBG_RETURN_IF_FAIL (next_cursor != NULL);
659
660     if (next_cursor == &xdbg_dump_info.buffers)
661     {
662         next_cursor = next_cursor->next;
663         XDBG_RETURN_IF_FAIL (next_cursor != NULL);
664     }
665
666     dumpbuf = xorg_list_entry (next_cursor, xDbgDumpBuffer, link);
667     XDBG_RETURN_IF_FAIL (dumpbuf != NULL);
668
669     if (xdbg_dump_info.func.dumpBmp)
670     {
671         Bool ret;
672         int dump_w = 0, dump_h = 0;
673         xRectangle dump_rect = {0,};
674
675         ret = xdbg_dump_info.func.dumpBmp (data, type,
676                                            var_buf, dumpbuf->bo, dumpbuf->bo_size,
677                                            &dump_w, &dump_h, &dump_rect);
678         XDBG_RETURN_IF_FAIL (ret == TRUE);
679         XDBG_RETURN_IF_FAIL (dump_w > 0);
680         XDBG_RETURN_IF_FAIL (dump_h > 0);
681         XDBG_RETURN_IF_FAIL (dump_rect.width > 0);
682         XDBG_RETURN_IF_FAIL (dump_rect.height > 0);
683
684         snprintf (dumpbuf->file, sizeof (dumpbuf->file), "%.3f_%s", GetTimeInMillis()/1000.0, file);
685         dumpbuf->u.a.dump_w = dump_w;
686         dumpbuf->u.a.dump_h = dump_h;
687         dumpbuf->u.a.dump_rect = dump_rect;
688         dumpbuf->is_dirty = TRUE;
689         dumpbuf->is_bmp = TRUE;
690
691         xdbg_dump_info.cursor = next_cursor;
692     }
693
694     XDBG_DEBUG (MXDBG, "type:0x%x file: %s\n", type, file);
695 }
696
697 API Bool
698 xDbgDumpReplaceBuffer (void *old_dump_buf, void *new_dump_buf, int new_dump_buf_size)
699 {
700     xDbgDumpBuffer *cur = NULL, *next = NULL;
701
702     XDBG_RETURN_VAL_IF_FAIL (new_dump_buf != NULL, FALSE);
703     XDBG_RETURN_VAL_IF_FAIL (new_dump_buf_size > 0, FALSE);
704
705     _xDbgDumpInit ();
706
707     xorg_list_for_each_entry_safe (cur, next, &xdbg_dump_info.buffers, link)
708     {
709         if (cur->bo == old_dump_buf)
710         {
711             if (xdbg_dump_info.func.free)
712                 xdbg_dump_info.func.free (cur->bo);
713
714             cur->bo = new_dump_buf;
715             cur->bo_size = new_dump_buf_size;
716             return TRUE;
717         }
718     }
719
720     return FALSE;
721 }