From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:47880) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RJ8KU-00085R-1Y for qemu-devel@nongnu.org; Wed, 26 Oct 2011 14:35:59 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RJ8KK-0001dJ-Sy for qemu-devel@nongnu.org; Wed, 26 Oct 2011 14:35:58 -0400 Received: from v220110690675601.yourvserver.net ([78.47.199.172]:43738) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RJ8KK-0001dA-N1 for qemu-devel@nongnu.org; Wed, 26 Oct 2011 14:35:48 -0400 Message-ID: <4EA852D0.8080601@weilnetz.de> Date: Wed, 26 Oct 2011 20:34:56 +0200 From: Stefan Weil MIME-Version: 1.0 References: <1319487523-19978-1-git-send-email-sw@weilnetz.de> <20111026125431.GC27267@stefanha-thinkpad.localdomain> <4EA836BC.40409@weilnetz.de> In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Subject: [Qemu-devel] [RFC] Introduce qemu_abort? (was: Fix compiler warning (always return a value)) List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Blue Swirl Cc: qemu-devel@nongnu.org Am 26.10.2011 19:49, schrieb Blue Swirl: > On Wed, Oct 26, 2011 at 16:35, Stefan Weil wrote: >> ... >> I personally don't like abort() because it does not show the >> reason for the failure. >> >> Most users don't know how to get a core dump or how to >> use gdb. And even for those who know, a crash caused >> by an abort() which cannot be reproduced usually happens >> on a system were ulimit disables core dumps... >> >> I'd like to have a qemu_abort() macro in qemu-common.h which >> replaces all abort() calls used today: > > Also assert(0) calls. > >> #define qemu_abort() \ >> do { \ >> fprintf(stderr, "QEMU aborted in %s, %s:%u\n", __func__, __FILE__, >> __LINE__); >> abort(); >> } while (0) >> >> (The macro could also call a function which handles fprintf and abort). > > There could be also a version with additional error message parameter. Replacing abort() and assert(0) by qemu_abort() touches a lot of files. Do you think this can be a change for QEMU 1.0, or is it better to wait? Adding the infrastructure (macros / implementation) could be done faster. I suggest these interfaces in qemu-common.h: qemu_abort() - abort QEMU with a message containing function name, file name and line (macro, see message text in my previous mail cited above) qemu_fatal(formatstring, ...) - abort QEMU with a printf like message (function, prints "QEMU aborted, " and the text according to the parameters) Regards, Stefan W.