diff options
author | Chris Wilson <chris@chris-wilson.co.uk> | 2014-09-10 11:48:40 +0100 |
---|---|---|
committer | Chris Wilson <chris@chris-wilson.co.uk> | 2014-09-10 11:58:11 +0100 |
commit | 224af800f695b50ba5a65b5a2b9ca1e7a88d4e1a (patch) | |
tree | 7bfe81cc2979e22006e46ce4a0e5bcfefa68c40e /src/sna | |
parent | 0d1df4762ffd7babb95a5f48f77487a6c7db83fe (diff) |
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>
Diffstat (limited to 'src/sna')
-rw-r--r-- | src/sna/Makefile.am | 1 | ||||
-rw-r--r-- | src/sna/brw/brw_eu.c | 4 | ||||
-rw-r--r-- | src/sna/brw/brw_eu.h | 2 | ||||
-rw-r--r-- | src/sna/sna.h | 1 | ||||
-rw-r--r-- | src/sna/sna_driver.c | 1 | ||||
-rw-r--r-- | src/sna/sna_video.c | 1 | ||||
-rw-r--r-- | src/sna/xassert.h | 42 |
7 files changed, 49 insertions, 3 deletions
diff --git a/src/sna/Makefile.am b/src/sna/Makefile.am index 7ec1c362..a995b442 100644 --- a/src/sna/Makefile.am +++ b/src/sna/Makefile.am @@ -106,6 +106,7 @@ libsna_la_SOURCES = \ gen8_render.h \ gen8_vertex.c \ gen8_vertex.h \ + xassert.h \ $(NULL) if DRI2 diff --git a/src/sna/brw/brw_eu.c b/src/sna/brw/brw_eu.c index 9bd8ba5d..c5705f56 100644 --- a/src/sna/brw/brw_eu.c +++ b/src/sna/brw/brw_eu.c @@ -29,6 +29,10 @@ * Keith Whitwell <keith@tungstengraphics.com> */ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + #include "brw_eu.h" #include <string.h> diff --git a/src/sna/brw/brw_eu.h b/src/sna/brw/brw_eu.h index 0124ac21..e8210a12 100644 --- a/src/sna/brw/brw_eu.h +++ b/src/sna/brw/brw_eu.h @@ -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)) diff --git a/src/sna/sna.h b/src/sna/sna.h index bb0cbb28..ad74870a 100644 --- a/src/sna/sna.h +++ b/src/sna/sna.h @@ -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 diff --git a/src/sna/sna_driver.c b/src/sna/sna_driver.c index 401737b3..7eed2143 100644 --- a/src/sna/sna_driver.c +++ b/src/sna/sna_driver.c @@ -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> diff --git a/src/sna/sna_video.c b/src/sna/sna_video.c index 80760ae7..ed0e7b31 100644 --- a/src/sna/sna_video.c +++ b/src/sna/sna_video.c @@ -48,7 +48,6 @@ #include <inttypes.h> #include <math.h> #include <string.h> -#include <assert.h> #include <errno.h> #include <sys/mman.h> diff --git a/src/sna/xassert.h b/src/sna/xassert.h new file mode 100644 index 00000000..7ab2591d --- /dev/null +++ b/src/sna/xassert.h @@ -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__ */ |