summaryrefslogtreecommitdiff
path: root/dix
diff options
context:
space:
mode:
authorPeter Hutterer <peter.hutterer@who-t.net>2011-05-05 08:48:19 +1000
committerPeter Hutterer <peter.hutterer@who-t.net>2011-05-06 09:58:08 +1000
commit56901998020b6f443cbaa5eb303100d979e81b22 (patch)
tree2dea93e2d0c1d30b1d898092e5a51be17da1683d /dix
parentbf2059b07a97e5e579c13c2c9d49707093427dc2 (diff)
input: change CHECKEVENT macro to verify_internal_event function
The macro is sufficient if called during a development cycle, but not sufficient information when triggered by a user (e.g. https://bugzilla.redhat.com/show_bug.cgi?id=688693). Expand what this does to print the event content and a backtrace, so at least we know where we're coming from. Only the first 32 bytes are printed since if something goes wrong, the event we have is almost certainly an xEvent or xError, both restricted to 32 bytes. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Reviewed-by: Daniel Stone <daniel@fooishbar.org>
Diffstat (limited to 'dix')
-rw-r--r--dix/events.c4
-rw-r--r--dix/inpututils.c28
2 files changed, 30 insertions, 2 deletions
diff --git a/dix/events.c b/dix/events.c
index bc08f7b54..b0107a081 100644
--- a/dix/events.c
+++ b/dix/events.c
@@ -2377,7 +2377,7 @@ DeliverDeviceEvents(WindowPtr pWin, InternalEvent *event, GrabPtr grab,
xEvent *xE = NULL, *core = NULL;
int rc, mask, count = 0;
- CHECKEVENT(event);
+ verify_internal_event(event);
while (pWin)
{
@@ -2723,7 +2723,7 @@ CheckMotion(DeviceEvent *ev, DeviceIntPtr pDev)
WindowPtr prevSpriteWin, newSpriteWin;
SpritePtr pSprite = pDev->spriteInfo->sprite;
- CHECKEVENT(ev);
+ verify_internal_event(ev);
prevSpriteWin = pSprite->win;
diff --git a/dix/inpututils.c b/dix/inpututils.c
index 077ffce01..aeace6ef8 100644
--- a/dix/inpututils.c
+++ b/dix/inpututils.c
@@ -36,6 +36,7 @@
#include "xkbsrv.h"
#include "xkbstr.h"
#include "inpututils.h"
+#include "eventstr.h"
/* Check if a button map change is okay with the device.
* Returns -1 for BadValue, as it collides with MappingBusy. */
@@ -556,3 +557,30 @@ CountBits(const uint8_t *mask, int len)
return ret;
}
+
+/**
+ * Verifies sanity of the event. If the event is not an internal event,
+ * memdumps the first 32 bytes of event to the log, a backtrace, then kill
+ * the server.
+ */
+void verify_internal_event(const InternalEvent *ev)
+{
+ if (ev && ev->any.header != ET_Internal)
+ {
+ int i;
+ unsigned char *data = (unsigned char*)ev;
+
+ ErrorF("dix: invalid event type %d\n", ev->any.header);
+
+ for (i = 0; i < sizeof(xEvent); i++, data++)
+ {
+ ErrorF("%02hx ", *data);
+
+ if ((i % 8) == 7)
+ ErrorF("\n");
+ }
+
+ xorg_backtrace();
+ FatalError("Wrong event type %d. Aborting server\n", ev->any.header);
+ }
+}