sna: Emit assertions with FatalError

The intention is to be able to capture the assertion in the Xorg.0.log
(journald equivalent). At the moment, it is emitted to stderr which is
difficult to capture and defeats the goal of only asking the reporter to
upload one log file.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
This commit is contained in:
Chris Wilson 2014-09-10 11:48:40 +01:00
parent 0d1df4762f
commit 224af800f6
7 changed files with 49 additions and 3 deletions

View File

@ -106,6 +106,7 @@ libsna_la_SOURCES = \
gen8_render.h \
gen8_vertex.c \
gen8_vertex.h \
xassert.h \
$(NULL)
if DRI2

View File

@ -29,6 +29,10 @@
* Keith Whitwell <keith@tungstengraphics.com>
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "brw_eu.h"
#include <string.h>

View File

@ -29,13 +29,13 @@
* Keith Whitwell <keith@tungstengraphics.com>
*/
#ifndef BRW_EU_H
#define BRW_EU_H
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include <assert.h>
#define BRW_SWIZZLE4(a,b,c,d) (((a)<<0) | ((b)<<2) | ((c)<<4) | ((d)<<6))

View File

@ -76,6 +76,7 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#include <signal.h>
#include <setjmp.h>
#include "xassert.h"
#include "compiler.h"
#if HAS_DEBUG_FULL

View File

@ -37,7 +37,6 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
#include "config.h"
#endif
#include <assert.h>
#include <string.h>
#include <stdio.h>
#include <unistd.h>

View File

@ -48,7 +48,6 @@
#include <inttypes.h>
#include <math.h>
#include <string.h>
#include <assert.h>
#include <errno.h>
#include <sys/mman.h>

42
src/sna/xassert.h Normal file
View File

@ -0,0 +1,42 @@
/*
* Copyright (c) 2014 Intel Corporation
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice (including the next
* paragraph) shall be included in all copies or substantial portions of the
* Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
#ifndef __XASSERT_H___
#define __XASSERT_H__
/* Rewrap the traditional assert so that we can capture the error message
* via Xorg.0.log
*/
#include <assert.h>
#ifndef NDEBUG
#include <os.h>
#include "compiler.h"
#undef assert
#define assert(E) do { \
if (unlikely(!(E))) FatalError("%s:%d assertion '%s' failed\n", __func__, __LINE__, #E); \
} while (0)
#endif
#endif /* __XASSERT_H__ */