blob: 70b344048c0cccc1ea4063d31aee61dde77d9a68 [file] [log] [blame]
Alex Bennée708b6a62018-06-22 17:09:10 +01001/*
2 * exit support for qemu
3 *
4 * Copyright (c) 2018 Alex Bennée <alex.bennee@linaro.org>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, see <http://www.gnu.org/licenses/>.
18 */
19#include "qemu/osdep.h"
20#include "qemu.h"
Paolo Bonzini4cc600d2020-02-04 17:11:04 +010021#ifdef CONFIG_GPROF
Alex Bennée9b21a362019-05-02 10:27:28 +010022#include <sys/gmon.h>
23#endif
Alex Bennée708b6a62018-06-22 17:09:10 +010024
Alex Bennée7781afb2018-06-22 17:23:44 +010025#ifdef CONFIG_GCOV
26extern void __gcov_dump(void);
27#endif
28
Alex Bennée708b6a62018-06-22 17:09:10 +010029void preexit_cleanup(CPUArchState *env, int code)
30{
Paolo Bonzini4cc600d2020-02-04 17:11:04 +010031#ifdef CONFIG_GPROF
Alex Bennée708b6a62018-06-22 17:09:10 +010032 _mcleanup();
33#endif
Alex Bennée7781afb2018-06-22 17:23:44 +010034#ifdef CONFIG_GCOV
35 __gcov_dump();
36#endif
Alex Bennéead9dcb22021-01-08 22:42:43 +000037 gdb_exit(code);
Emilio G. Cota8634d772018-10-21 13:27:28 -040038 qemu_plugin_atexit_cb();
Alex Bennée708b6a62018-06-22 17:09:10 +010039}