fixes to debugging code: added "break on fb_null_pointer() hook", and make it so that

defining FB_DEBUG doesn't make Xquartz always crash (not that it currently helps with
any of our fb problems, but hey...)
This commit is contained in:
Ben Byer 2007-12-13 06:51:09 -08:00
parent dec2633c41
commit e1a67b4872
2 changed files with 15 additions and 2 deletions

View file

@ -133,10 +133,11 @@ typedef CARD32 FbStip;
typedef int FbStride;
int fb_null_pointer(char *file, unsigned int line);
#define CHECK_NULL(ptr) \
if ((ptr) == NULL) {\
ErrorF("%s:%d: null pointer\n", __FILE__, __LINE__); \
return; \
if (fb_null_pointer(__FILE__, __LINE__)) return; \
}
#ifdef FB_DEBUG

View file

@ -318,6 +318,15 @@ fbPixmapToRegion(PixmapPtr pPix)
return(pReg);
}
int fb_null_pointer(char *file, unsigned int line) {
ErrorF("%s:%u: null pointer (break on fb_null_pointer to debug)\n", file, line);
#ifdef FB_DEBUG
return 0; // ignore error, die horrible death
#else
return 1; // harmlessly return to caller, hope we don't crash later
#endif
}
#ifdef FB_DEBUG
#ifndef WIN32
@ -357,6 +366,9 @@ fbValidateDrawable (DrawablePtr pDrawable)
if (pDrawable->type != DRAWABLE_PIXMAP)
pDrawable = (DrawablePtr) fbGetWindowPixmap(pDrawable);
fbGetStipDrawable(pDrawable, bits, stride, bpp, xoff, yoff);
#ifdef __APPLE__
if (bits >= 0xb0000000) return; // don't validate CG memory
#endif
first = bits - stride;
last = bits + stride * pDrawable->height;
if (!fbValidateBits (first, stride, FB_HEAD_BITS) ||