| 1582 | } |
| 1583 | |
| 1584 | static bool |
| 1585 | prof_dump_file(tsd_t *tsd, bool propagate_err, const char *filename, |
| 1586 | bool leakcheck, prof_tdata_t *tdata, |
| 1587 | struct prof_tdata_merge_iter_arg_s *prof_tdata_merge_iter_arg, |
| 1588 | struct prof_gctx_merge_iter_arg_s *prof_gctx_merge_iter_arg, |
| 1589 | struct prof_gctx_dump_iter_arg_s *prof_gctx_dump_iter_arg, |
| 1590 | prof_gctx_tree_t *gctxs) { |
| 1591 | /* Create dump file. */ |
| 1592 | if ((prof_dump_fd = prof_dump_open(propagate_err, filename)) == -1) { |
| 1593 | return true; |
| 1594 | } |
| 1595 | |
| 1596 | /* Dump profile header. */ |
| 1597 | if (prof_dump_header(tsd_tsdn(tsd), propagate_err, |
| 1598 | &prof_tdata_merge_iter_arg->cnt_all)) { |
| 1599 | goto label_write_error; |
| 1600 | } |
| 1601 | |
| 1602 | /* Dump per gctx profile stats. */ |
| 1603 | prof_gctx_dump_iter_arg->tsdn = tsd_tsdn(tsd); |
| 1604 | prof_gctx_dump_iter_arg->propagate_err = propagate_err; |
| 1605 | if (gctx_tree_iter(gctxs, NULL, prof_gctx_dump_iter, |
| 1606 | (void *)prof_gctx_dump_iter_arg) != NULL) { |
| 1607 | goto label_write_error; |
| 1608 | } |
| 1609 | |
| 1610 | /* Dump /proc/<pid>/maps if possible. */ |
| 1611 | if (prof_dump_maps(propagate_err)) { |
| 1612 | goto label_write_error; |
| 1613 | } |
| 1614 | |
| 1615 | if (prof_dump_close(propagate_err)) { |
| 1616 | return true; |
| 1617 | } |
| 1618 | |
| 1619 | return false; |
| 1620 | label_write_error: |
| 1621 | prof_dump_close(propagate_err); |
| 1622 | return true; |
| 1623 | } |
| 1624 | |
| 1625 | static bool |
| 1626 | prof_dump(tsd_t *tsd, bool propagate_err, const char *filename, |
no test coverage detected