67f8559b9aec6b9eb71fc08106fda1552fcd6030
[mesa.git] / src / intel / tools / intel_dump_gpu.c
1 /*
2 * Copyright © 2015 Intel Corporation
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
13 * Software.
14 *
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
21 * IN THE SOFTWARE.
22 */
23
24 #include <stdlib.h>
25 #include <stdio.h>
26 #include <string.h>
27 #include <stdint.h>
28 #include <stdbool.h>
29 #include <signal.h>
30 #include <stdarg.h>
31 #include <fcntl.h>
32 #include <sys/types.h>
33 #include <sys/sysmacros.h>
34 #include <sys/stat.h>
35 #include <sys/ioctl.h>
36 #include <unistd.h>
37 #include <errno.h>
38 #include <sys/mman.h>
39 #include <dlfcn.h>
40 #include "drm-uapi/i915_drm.h"
41 #include <inttypes.h>
42
43 #include "intel_aub.h"
44 #include "aub_write.h"
45
46 #include "dev/gen_device_info.h"
47 #include "util/macros.h"
48
49 static int close_init_helper(int fd);
50 static int ioctl_init_helper(int fd, unsigned long request, ...);
51 static int munmap_init_helper(void *addr, size_t length);
52
53 static int (*libc_close)(int fd) = close_init_helper;
54 static int (*libc_ioctl)(int fd, unsigned long request, ...) = ioctl_init_helper;
55 static int (*libc_munmap)(void *addr, size_t length) = munmap_init_helper;
56
57 static int drm_fd = -1;
58 static char *output_filename = NULL;
59 static FILE *output_file = NULL;
60 static int verbose = 0;
61 static bool device_override;
62
63 #define MAX_FD_COUNT 64
64 #define MAX_BO_COUNT 64 * 1024
65
66 struct bo {
67 uint32_t size;
68 uint64_t offset;
69 void *map;
70 /* Tracks userspace mmapping of the buffer */
71 bool user_mapped : 1;
72 /* Using the i915-gem mmapping ioctl & execbuffer ioctl, track whether a
73 * buffer has been updated.
74 */
75 bool dirty : 1;
76 };
77
78 static struct bo *bos;
79
80 #define DRM_MAJOR 226
81
82 /* We set bit 0 in the map pointer for userptr BOs so we know not to
83 * munmap them on DRM_IOCTL_GEM_CLOSE.
84 */
85 #define USERPTR_FLAG 1
86 #define IS_USERPTR(p) ((uintptr_t) (p) & USERPTR_FLAG)
87 #define GET_PTR(p) ( (void *) ((uintptr_t) p & ~(uintptr_t) 1) )
88
89 static void __attribute__ ((format(__printf__, 2, 3)))
90 fail_if(int cond, const char *format, ...)
91 {
92 va_list args;
93
94 if (!cond)
95 return;
96
97 va_start(args, format);
98 fprintf(stderr, "intel_dump_gpu: ");
99 vfprintf(stderr, format, args);
100 va_end(args);
101
102 raise(SIGTRAP);
103 }
104
105 static struct bo *
106 get_bo(unsigned fd, uint32_t handle)
107 {
108 struct bo *bo;
109
110 fail_if(handle >= MAX_BO_COUNT, "bo handle too large\n");
111 fail_if(fd >= MAX_FD_COUNT, "bo fd too large\n");
112 bo = &bos[handle + fd * MAX_BO_COUNT];
113
114 return bo;
115 }
116
117 static inline uint32_t
118 align_u32(uint32_t v, uint32_t a)
119 {
120 return (v + a - 1) & ~(a - 1);
121 }
122
123 static struct gen_device_info devinfo = {0};
124 static int device = 0;
125 static struct aub_file aub_file;
126
127 static void
128 ensure_device_info(int fd)
129 {
130 /* We can't do this at open time as we're not yet authenticated. */
131 if (device == 0) {
132 fail_if(!gen_get_device_info_from_fd(fd, &devinfo),
133 "failed to identify chipset.\n");
134 device = devinfo.chipset_id;
135 } else if (devinfo.gen == 0) {
136 fail_if(!gen_get_device_info_from_pci_id(device, &devinfo),
137 "failed to identify chipset.\n");
138 }
139 }
140
141 static void *
142 relocate_bo(int fd, struct bo *bo, const struct drm_i915_gem_execbuffer2 *execbuffer2,
143 const struct drm_i915_gem_exec_object2 *obj)
144 {
145 const struct drm_i915_gem_exec_object2 *exec_objects =
146 (struct drm_i915_gem_exec_object2 *) (uintptr_t) execbuffer2->buffers_ptr;
147 const struct drm_i915_gem_relocation_entry *relocs =
148 (const struct drm_i915_gem_relocation_entry *) (uintptr_t) obj->relocs_ptr;
149 void *relocated;
150 int handle;
151
152 relocated = malloc(bo->size);
153 fail_if(relocated == NULL, "out of memory\n");
154 memcpy(relocated, GET_PTR(bo->map), bo->size);
155 for (size_t i = 0; i < obj->relocation_count; i++) {
156 fail_if(relocs[i].offset >= bo->size, "reloc outside bo\n");
157
158 if (execbuffer2->flags & I915_EXEC_HANDLE_LUT)
159 handle = exec_objects[relocs[i].target_handle].handle;
160 else
161 handle = relocs[i].target_handle;
162
163 aub_write_reloc(&devinfo, ((char *)relocated) + relocs[i].offset,
164 get_bo(fd, handle)->offset + relocs[i].delta);
165 }
166
167 return relocated;
168 }
169
170 static int
171 gem_ioctl(int fd, unsigned long request, void *argp)
172 {
173 int ret;
174
175 do {
176 ret = libc_ioctl(fd, request, argp);
177 } while (ret == -1 && (errno == EINTR || errno == EAGAIN));
178
179 return ret;
180 }
181
182 static void *
183 gem_mmap(int fd, uint32_t handle, uint64_t offset, uint64_t size)
184 {
185 struct drm_i915_gem_mmap mmap = {
186 .handle = handle,
187 .offset = offset,
188 .size = size
189 };
190
191 if (gem_ioctl(fd, DRM_IOCTL_I915_GEM_MMAP, &mmap) == -1)
192 return MAP_FAILED;
193
194 return (void *)(uintptr_t) mmap.addr_ptr;
195 }
196
197 static enum drm_i915_gem_engine_class
198 engine_class_from_ring_flag(uint32_t ring_flag)
199 {
200 switch (ring_flag) {
201 case I915_EXEC_DEFAULT:
202 case I915_EXEC_RENDER:
203 return I915_ENGINE_CLASS_RENDER;
204 case I915_EXEC_BSD:
205 return I915_ENGINE_CLASS_VIDEO;
206 case I915_EXEC_BLT:
207 return I915_ENGINE_CLASS_COPY;
208 case I915_EXEC_VEBOX:
209 return I915_ENGINE_CLASS_VIDEO_ENHANCE;
210 default:
211 return I915_ENGINE_CLASS_INVALID;
212 }
213 }
214
215 static void
216 dump_execbuffer2(int fd, struct drm_i915_gem_execbuffer2 *execbuffer2)
217 {
218 struct drm_i915_gem_exec_object2 *exec_objects =
219 (struct drm_i915_gem_exec_object2 *) (uintptr_t) execbuffer2->buffers_ptr;
220 uint32_t ring_flag = execbuffer2->flags & I915_EXEC_RING_MASK;
221 uint32_t offset;
222 struct drm_i915_gem_exec_object2 *obj;
223 struct bo *bo, *batch_bo;
224 int batch_index;
225 void *data;
226
227 ensure_device_info(fd);
228
229 if (!aub_file.file) {
230 aub_file_init(&aub_file, output_file,
231 verbose == 2 ? stdout : NULL,
232 device, program_invocation_short_name);
233 aub_write_default_setup(&aub_file);
234
235 if (verbose)
236 printf("[running, output file %s, chipset id 0x%04x, gen %d]\n",
237 output_filename, device, devinfo.gen);
238 }
239
240 if (aub_use_execlists(&aub_file))
241 offset = 0x1000;
242 else
243 offset = aub_gtt_size(&aub_file);
244
245 if (verbose)
246 printf("Dumping execbuffer2:\n");
247
248 for (uint32_t i = 0; i < execbuffer2->buffer_count; i++) {
249 obj = &exec_objects[i];
250 bo = get_bo(fd, obj->handle);
251
252 /* If bo->size == 0, this means they passed us an invalid
253 * buffer. The kernel will reject it and so should we.
254 */
255 if (bo->size == 0) {
256 if (verbose)
257 printf("BO #%d is invalid!\n", obj->handle);
258 return;
259 }
260
261 if (obj->flags & EXEC_OBJECT_PINNED) {
262 bo->offset = obj->offset;
263 if (verbose)
264 printf("BO #%d (%dB) pinned @ 0x%" PRIx64 "\n",
265 obj->handle, bo->size, bo->offset);
266 } else {
267 if (obj->alignment != 0)
268 offset = align_u32(offset, obj->alignment);
269 bo->offset = offset;
270 if (verbose)
271 printf("BO #%d (%dB) @ 0x%" PRIx64 "\n", obj->handle,
272 bo->size, bo->offset);
273 offset = align_u32(offset + bo->size + 4095, 4096);
274 }
275
276 if (bo->map == NULL && bo->size > 0)
277 bo->map = gem_mmap(fd, obj->handle, 0, bo->size);
278 fail_if(bo->map == MAP_FAILED, "bo mmap failed\n");
279
280 if (aub_use_execlists(&aub_file))
281 aub_map_ppgtt(&aub_file, bo->offset, bo->size);
282 }
283
284 batch_index = (execbuffer2->flags & I915_EXEC_BATCH_FIRST) ? 0 :
285 execbuffer2->buffer_count - 1;
286 batch_bo = get_bo(fd, exec_objects[batch_index].handle);
287 for (uint32_t i = 0; i < execbuffer2->buffer_count; i++) {
288 obj = &exec_objects[i];
289 bo = get_bo(fd, obj->handle);
290
291 if (obj->relocation_count > 0)
292 data = relocate_bo(fd, bo, execbuffer2, obj);
293 else
294 data = bo->map;
295
296 if (bo->dirty) {
297 if (bo == batch_bo) {
298 aub_write_trace_block(&aub_file, AUB_TRACE_TYPE_BATCH,
299 GET_PTR(data), bo->size, bo->offset);
300 } else {
301 aub_write_trace_block(&aub_file, AUB_TRACE_TYPE_NOTYPE,
302 GET_PTR(data), bo->size, bo->offset);
303 }
304
305 if (!bo->user_mapped)
306 bo->dirty = false;
307 }
308
309 if (data != bo->map)
310 free(data);
311 }
312
313 uint32_t ctx_id = execbuffer2->rsvd1;
314
315 aub_write_exec(&aub_file, ctx_id,
316 batch_bo->offset + execbuffer2->batch_start_offset,
317 offset, engine_class_from_ring_flag(ring_flag));
318
319 if (device_override &&
320 (execbuffer2->flags & I915_EXEC_FENCE_ARRAY) != 0) {
321 struct drm_i915_gem_exec_fence *fences =
322 (void*)(uintptr_t)execbuffer2->cliprects_ptr;
323 for (uint32_t i = 0; i < execbuffer2->num_cliprects; i++) {
324 if ((fences[i].flags & I915_EXEC_FENCE_SIGNAL) != 0) {
325 struct drm_syncobj_array arg = {
326 .handles = (uintptr_t)&fences[i].handle,
327 .count_handles = 1,
328 .pad = 0,
329 };
330 libc_ioctl(fd, DRM_IOCTL_SYNCOBJ_SIGNAL, &arg);
331 }
332 }
333 }
334 }
335
336 static void
337 add_new_bo(unsigned fd, int handle, uint64_t size, void *map)
338 {
339 struct bo *bo = &bos[handle + fd * MAX_BO_COUNT];
340
341 fail_if(handle >= MAX_BO_COUNT, "bo handle out of range\n");
342 fail_if(fd >= MAX_FD_COUNT, "bo fd out of range\n");
343 fail_if(size == 0, "bo size is invalid\n");
344
345 bo->size = size;
346 bo->map = map;
347 bo->user_mapped = false;
348 }
349
350 static void
351 remove_bo(int fd, int handle)
352 {
353 struct bo *bo = get_bo(fd, handle);
354
355 if (bo->map && !IS_USERPTR(bo->map))
356 munmap(bo->map, bo->size);
357 bo->size = 0;
358 bo->map = NULL;
359 bo->user_mapped = false;
360 }
361
362 __attribute__ ((visibility ("default"))) int
363 close(int fd)
364 {
365 if (fd == drm_fd)
366 drm_fd = -1;
367
368 return libc_close(fd);
369 }
370
371 static int
372 get_pci_id(int fd, int *pci_id)
373 {
374 struct drm_i915_getparam gparam;
375
376 if (device_override) {
377 *pci_id = device;
378 return 0;
379 }
380
381 gparam.param = I915_PARAM_CHIPSET_ID;
382 gparam.value = pci_id;
383 return libc_ioctl(fd, DRM_IOCTL_I915_GETPARAM, &gparam);
384 }
385
386 static void
387 maybe_init(int fd)
388 {
389 static bool initialized = false;
390 FILE *config;
391 char *key, *value;
392
393 if (initialized)
394 return;
395
396 initialized = true;
397
398 config = fopen(getenv("INTEL_DUMP_GPU_CONFIG"), "r");
399 while (fscanf(config, "%m[^=]=%m[^\n]\n", &key, &value) != EOF) {
400 if (!strcmp(key, "verbose")) {
401 if (!strcmp(value, "1")) {
402 verbose = 1;
403 } else if (!strcmp(value, "2")) {
404 verbose = 2;
405 }
406 } else if (!strcmp(key, "device")) {
407 fail_if(device != 0, "Device/Platform override specified multiple times.");
408 fail_if(sscanf(value, "%i", &device) != 1,
409 "failed to parse device id '%s'",
410 value);
411 device_override = true;
412 } else if (!strcmp(key, "platform")) {
413 fail_if(device != 0, "Device/Platform override specified multiple times.");
414 device = gen_device_name_to_pci_device_id(value);
415 fail_if(device == -1, "Unknown platform '%s'", value);
416 device_override = true;
417 } else if (!strcmp(key, "file")) {
418 output_filename = strdup(value);
419 output_file = fopen(output_filename, "w+");
420 fail_if(output_file == NULL,
421 "failed to open file '%s'\n",
422 output_filename);
423 } else {
424 fprintf(stderr, "unknown option '%s'\n", key);
425 }
426
427 free(key);
428 free(value);
429 }
430 fclose(config);
431
432 bos = calloc(MAX_FD_COUNT * MAX_BO_COUNT, sizeof(bos[0]));
433 fail_if(bos == NULL, "out of memory\n");
434
435 int ret = get_pci_id(fd, &device);
436 assert(ret == 0);
437
438 aub_file_init(&aub_file, output_file,
439 verbose == 2 ? stdout : NULL,
440 device, program_invocation_short_name);
441 aub_write_default_setup(&aub_file);
442
443 if (verbose)
444 printf("[running, output file %s, chipset id 0x%04x, gen %d]\n",
445 output_filename, device, devinfo.gen);
446 }
447
448 __attribute__ ((visibility ("default"))) int
449 ioctl(int fd, unsigned long request, ...)
450 {
451 va_list args;
452 void *argp;
453 int ret;
454 struct stat buf;
455
456 va_start(args, request);
457 argp = va_arg(args, void *);
458 va_end(args);
459
460 if (_IOC_TYPE(request) == DRM_IOCTL_BASE &&
461 drm_fd != fd && fstat(fd, &buf) == 0 &&
462 (buf.st_mode & S_IFMT) == S_IFCHR && major(buf.st_rdev) == DRM_MAJOR) {
463 drm_fd = fd;
464 if (verbose)
465 printf("[intercept drm ioctl on fd %d]\n", fd);
466 }
467
468 if (fd == drm_fd) {
469 maybe_init(fd);
470
471 switch (request) {
472 case DRM_IOCTL_SYNCOBJ_WAIT:
473 case DRM_IOCTL_I915_GEM_WAIT: {
474 if (device_override)
475 return 0;
476 return libc_ioctl(fd, request, argp);
477 }
478
479 case DRM_IOCTL_I915_GET_RESET_STATS: {
480 if (device_override) {
481 struct drm_i915_reset_stats *stats = argp;
482
483 stats->reset_count = 0;
484 stats->batch_active = 0;
485 stats->batch_pending = 0;
486 return 0;
487 }
488 return libc_ioctl(fd, request, argp);
489 }
490
491 case DRM_IOCTL_I915_GETPARAM: {
492 struct drm_i915_getparam *getparam = argp;
493
494 ensure_device_info(fd);
495
496 if (getparam->param == I915_PARAM_CHIPSET_ID)
497 return get_pci_id(fd, getparam->value);
498
499 if (device_override) {
500 switch (getparam->param) {
501 case I915_PARAM_CS_TIMESTAMP_FREQUENCY:
502 *getparam->value = devinfo.timestamp_frequency;
503 return 0;
504
505 case I915_PARAM_HAS_WAIT_TIMEOUT:
506 case I915_PARAM_HAS_EXECBUF2:
507 case I915_PARAM_MMAP_VERSION:
508 case I915_PARAM_HAS_EXEC_ASYNC:
509 case I915_PARAM_HAS_EXEC_FENCE:
510 case I915_PARAM_HAS_EXEC_FENCE_ARRAY:
511 *getparam->value = 1;
512 return 0;
513
514 case I915_PARAM_HAS_EXEC_SOFTPIN:
515 *getparam->value = devinfo.gen >= 8 && !devinfo.is_cherryview;
516 return 0;
517
518 default:
519 return -1;
520 }
521 }
522
523 return libc_ioctl(fd, request, argp);
524 }
525
526 case DRM_IOCTL_I915_GEM_CONTEXT_GETPARAM: {
527 struct drm_i915_gem_context_param *getparam = argp;
528
529 ensure_device_info(fd);
530
531 if (device_override) {
532 switch (getparam->param) {
533 case I915_CONTEXT_PARAM_GTT_SIZE:
534 if (devinfo.is_elkhartlake)
535 getparam->value = 1ull << 36;
536 else if (devinfo.gen >= 8 && !devinfo.is_cherryview)
537 getparam->value = 1ull << 48;
538 else
539 getparam->value = 1ull << 31;
540 return 0;
541
542 default:
543 return -1;
544 }
545 }
546
547 return libc_ioctl(fd, request, argp);
548 }
549
550 case DRM_IOCTL_I915_GEM_EXECBUFFER: {
551 static bool once;
552 if (!once) {
553 fprintf(stderr,
554 "application uses DRM_IOCTL_I915_GEM_EXECBUFFER, not handled\n");
555 once = true;
556 }
557 return libc_ioctl(fd, request, argp);
558 }
559
560 case DRM_IOCTL_I915_GEM_EXECBUFFER2:
561 case DRM_IOCTL_I915_GEM_EXECBUFFER2_WR: {
562 dump_execbuffer2(fd, argp);
563 if (device_override)
564 return 0;
565
566 return libc_ioctl(fd, request, argp);
567 }
568
569 case DRM_IOCTL_I915_GEM_CONTEXT_CREATE: {
570 uint32_t *ctx_id = NULL;
571 struct drm_i915_gem_context_create *create = argp;
572 ret = 0;
573 if (!device_override) {
574 ret = libc_ioctl(fd, request, argp);
575 ctx_id = &create->ctx_id;
576 }
577
578 if (ret == 0)
579 create->ctx_id = aub_write_context_create(&aub_file, ctx_id);
580
581 return ret;
582 }
583
584 case DRM_IOCTL_I915_GEM_CONTEXT_CREATE_EXT: {
585 uint32_t *ctx_id = NULL;
586 struct drm_i915_gem_context_create_ext *create = argp;
587 ret = 0;
588 if (!device_override) {
589 ret = libc_ioctl(fd, request, argp);
590 ctx_id = &create->ctx_id;
591 }
592
593 if (ret == 0)
594 create->ctx_id = aub_write_context_create(&aub_file, ctx_id);
595
596 return ret;
597 }
598
599 case DRM_IOCTL_I915_GEM_CREATE: {
600 struct drm_i915_gem_create *create = argp;
601
602 ret = libc_ioctl(fd, request, argp);
603 if (ret == 0)
604 add_new_bo(fd, create->handle, create->size, NULL);
605
606 return ret;
607 }
608
609 case DRM_IOCTL_I915_GEM_USERPTR: {
610 struct drm_i915_gem_userptr *userptr = argp;
611
612 ret = libc_ioctl(fd, request, argp);
613 if (ret == 0)
614 add_new_bo(fd, userptr->handle, userptr->user_size,
615 (void *) (uintptr_t) (userptr->user_ptr | USERPTR_FLAG));
616
617 return ret;
618 }
619
620 case DRM_IOCTL_GEM_CLOSE: {
621 struct drm_gem_close *close = argp;
622
623 remove_bo(fd, close->handle);
624
625 return libc_ioctl(fd, request, argp);
626 }
627
628 case DRM_IOCTL_GEM_OPEN: {
629 struct drm_gem_open *open = argp;
630
631 ret = libc_ioctl(fd, request, argp);
632 if (ret == 0)
633 add_new_bo(fd, open->handle, open->size, NULL);
634
635 return ret;
636 }
637
638 case DRM_IOCTL_PRIME_FD_TO_HANDLE: {
639 struct drm_prime_handle *prime = argp;
640
641 ret = libc_ioctl(fd, request, argp);
642 if (ret == 0) {
643 off_t size;
644
645 size = lseek(prime->fd, 0, SEEK_END);
646 fail_if(size == -1, "failed to get prime bo size\n");
647 add_new_bo(fd, prime->handle, size, NULL);
648
649 }
650
651 return ret;
652 }
653
654 case DRM_IOCTL_I915_GEM_MMAP: {
655 ret = libc_ioctl(fd, request, argp);
656 if (ret == 0) {
657 struct drm_i915_gem_mmap *mmap = argp;
658 struct bo *bo = get_bo(fd, mmap->handle);
659 bo->user_mapped = true;
660 bo->dirty = true;
661 }
662 return ret;
663 }
664
665 default:
666 return libc_ioctl(fd, request, argp);
667 }
668 } else {
669 return libc_ioctl(fd, request, argp);
670 }
671 }
672
673 static void
674 init(void)
675 {
676 libc_close = dlsym(RTLD_NEXT, "close");
677 libc_ioctl = dlsym(RTLD_NEXT, "ioctl");
678 libc_munmap = dlsym(RTLD_NEXT, "munmap");
679 fail_if(libc_close == NULL || libc_ioctl == NULL,
680 "failed to get libc ioctl or close\n");
681 }
682
683 static int
684 close_init_helper(int fd)
685 {
686 init();
687 return libc_close(fd);
688 }
689
690 static int
691 ioctl_init_helper(int fd, unsigned long request, ...)
692 {
693 va_list args;
694 void *argp;
695
696 va_start(args, request);
697 argp = va_arg(args, void *);
698 va_end(args);
699
700 init();
701 return libc_ioctl(fd, request, argp);
702 }
703
704 static int
705 munmap_init_helper(void *addr, size_t length)
706 {
707 init();
708 for (uint32_t i = 0; i < MAX_FD_COUNT * MAX_BO_COUNT; i++) {
709 struct bo *bo = &bos[i];
710 if (bo->map == addr) {
711 bo->user_mapped = false;
712 break;
713 }
714 }
715 return libc_munmap(addr, length);
716 }
717
718 static void __attribute__ ((destructor))
719 fini(void)
720 {
721 if (devinfo.gen != 0) {
722 free(output_filename);
723 aub_file_finish(&aub_file);
724 free(bos);
725 }
726 }