#endif
if ((uintptr_t) -1L == pagesize) {
- DEBUG (BLOB, fprintf (stderr, "%p %s: failed to get pagesize: %s\n", (void *) blob, HB_FUNC, strerror (errno)));
+ DEBUG_MSG (BLOB, "%p %s: failed to get pagesize: %s\n", (void *) blob, HB_FUNC, strerror (errno));
return FALSE;
}
- DEBUG (BLOB, fprintf (stderr, "%p %s: pagesize is %lu\n", (void *) blob, HB_FUNC, (unsigned long) pagesize));
+ DEBUG_MSG (BLOB, "%p %s: pagesize is %lu\n", (void *) blob, HB_FUNC, (unsigned long) pagesize);
mask = ~(pagesize-1);
addr = (const char *) (((uintptr_t) blob->data) & mask);
length = (const char *) (((uintptr_t) blob->data + blob->length + pagesize-1) & mask) - addr;
- DEBUG (BLOB, fprintf (stderr, "%p %s: calling mprotect on [%p..%p] (%lu bytes)\n",
- (void *) blob, HB_FUNC,
- addr, addr+length, (unsigned long) length));
+ DEBUG_MSG (BLOB, "%p %s: calling mprotect on [%p..%p] (%lu bytes)\n",
+ (void *) blob, HB_FUNC,
+ addr, addr+length, (unsigned long) length);
if (-1 == mprotect ((void *) addr, length, PROT_READ | PROT_WRITE)) {
- DEBUG (BLOB, fprintf (stderr, "%p %s: %s\n", (void *) blob, HB_FUNC, strerror (errno)));
+ DEBUG_MSG (BLOB, "%p %s: %s\n", (void *) blob, HB_FUNC, strerror (errno));
return FALSE;
}
blob->mode = HB_MEMORY_MODE_WRITABLE;
- DEBUG (BLOB, fprintf (stderr, "%p %s: successfully made [%p..%p] (%lu bytes) writable\n",
- (void *) blob, HB_FUNC,
- addr, addr+length, (unsigned long) length));
+ DEBUG_MSG (BLOB, "%p %s: successfully made [%p..%p] (%lu bytes) writable\n",
+ (void *) blob, HB_FUNC,
+ addr, addr+length, (unsigned long) length);
return TRUE;
#else
return FALSE;
static bool
_try_writable_inplace (hb_blob_t *blob)
{
- DEBUG (BLOB, fprintf (stderr, "%p %s: making writable inplace\n", (void *) blob, HB_FUNC));
+ DEBUG_MSG (BLOB, "%p %s: making writable inplace\n", (void *) blob, HB_FUNC);
if (_try_make_writable_inplace_unix (blob))
return TRUE;
- DEBUG (BLOB, fprintf (stderr, "%p %s: making writable -> FAILED\n", (void *) blob, HB_FUNC));
+ DEBUG_MSG (BLOB, "%p %s: making writable -> FAILED\n", (void *) blob, HB_FUNC);
/* Failed to make writable inplace, mark that */
blob->mode = HB_MEMORY_MODE_READONLY;
return TRUE;
- DEBUG (BLOB, fprintf (stderr, "%p %s -> %p\n", (void *) blob, HB_FUNC, blob->data));
+ DEBUG_MSG (BLOB, "%p %s -> %p\n", (void *) blob, HB_FUNC, blob->data);
char *new_data;
if (unlikely (!new_data))
return FALSE;
- DEBUG (BLOB, fprintf (stderr, "%p %s: dupped successfully -> %p\n", (void *) blob, HB_FUNC, blob->data));
+ DEBUG_MSG (BLOB, "%p %s: dupped successfully -> %p\n", (void *) blob, HB_FUNC, blob->data);
memcpy (new_data, blob->data, blob->length);
_hb_blob_destroy_user_data (blob);
this->edit_count = 0;
this->debug_depth = 0;
- (void) (HB_DEBUG_SANITIZE &&
- fprintf (stderr, "sanitize %p init [%p..%p] (%lu bytes)\n",
- (void *) this->blob, this->start, this->end,
- (unsigned long) (this->end - this->start)));
+ DEBUG_MSG (SANITIZE, "sanitize %p init [%p..%p] (%lu bytes)\n",
+ (void *) this->blob, this->start, this->end,
+ (unsigned long) (this->end - this->start));
}
inline void finish (void)
{
- (void) (HB_DEBUG_SANITIZE &&
- fprintf (stderr, "sanitize %p fini [%p..%p] %u edit requests\n",
- (void *) this->blob, this->start, this->end, this->edit_count));
+ DEBUG_MSG (SANITIZE, "sanitize %p fini [%p..%p] %u edit requests\n",
+ (void *) this->blob, this->start, this->end, this->edit_count);
hb_blob_destroy (this->blob);
this->blob = NULL;
p <= this->end &&
(unsigned int) (this->end - p) >= len;
- DEBUG_DEPTH (SANITIZE, this->debug_depth,
- fprintf (stderr, "SANITIZE(%p) %-*d-> range [%p..%p] (%d bytes) in [%p..%p] -> %s\n",
- p,
- this->debug_depth, this->debug_depth,
- p, p + len, len,
- this->start, this->end,
- ret ? "pass" : "FAIL"));
+ DEBUG_MSG_LEVEL (SANITIZE, this->debug_depth,
+ "SANITIZE(%p) %-*d-> range [%p..%p] (%d bytes) in [%p..%p] -> %s\n",
+ p,
+ this->debug_depth, this->debug_depth,
+ p, p + len, len,
+ this->start, this->end,
+ ret ? "pass" : "FAIL");
return likely (ret);
}
const char *p = (const char *) base;
bool overflows = _hb_unsigned_int_mul_overflows (len, record_size);
- DEBUG_DEPTH (SANITIZE, this->debug_depth,
- fprintf (stderr, "SANITIZE(%p) %-*d-> array [%p..%p] (%d*%d=%ld bytes) in [%p..%p] -> %s\n",
- p,
- this->debug_depth, this->debug_depth,
- p, p + (record_size * len), record_size, len, (unsigned long) record_size * len,
- this->start, this->end,
- !overflows ? "does not overflow" : "OVERFLOWS FAIL"));
+ DEBUG_MSG_LEVEL (SANITIZE, this->debug_depth,
+ "SANITIZE(%p) %-*d-> array [%p..%p] (%d*%d=%ld bytes) in [%p..%p] -> %s\n",
+ p,
+ this->debug_depth, this->debug_depth,
+ p, p + (record_size * len), record_size, len, (unsigned long) record_size * len,
+ this->start, this->end,
+ !overflows ? "does not overflow" : "OVERFLOWS FAIL");
return likely (!overflows && this->check_range (base, record_size * len));
}
const char *p = (const char *) base;
this->edit_count++;
- DEBUG_DEPTH (SANITIZE, this->debug_depth,
- fprintf (stderr, "SANITIZE(%p) %-*d-> edit(%u) [%p..%p] (%d bytes) in [%p..%p] -> %s\n",
- p,
- this->debug_depth, this->debug_depth,
- this->edit_count,
- p, p + len, len,
- this->start, this->end,
- this->writable ? "granted" : "REJECTED"));
+ DEBUG_MSG_LEVEL (SANITIZE, this->debug_depth,
+ "SANITIZE(%p) %-*d-> edit(%u) [%p..%p] (%d bytes) in [%p..%p] -> %s\n",
+ p,
+ this->debug_depth, this->debug_depth,
+ this->edit_count,
+ p, p + len, len,
+ this->start, this->end,
+ this->writable ? "granted" : "REJECTED");
return this->writable;
}
c->init (blob);
retry:
- (void) (HB_DEBUG_SANITIZE &&
- fprintf (stderr, "Sanitizer %p start %s\n", (void *) blob, HB_FUNC));
+ DEBUG_MSG (SANITIZE, "Sanitizer %p start %s\n", (void *) blob, HB_FUNC);
c->setup ();
sane = t->sanitize (c);
if (sane) {
if (c->edit_count) {
- (void) (HB_DEBUG_SANITIZE &&
- fprintf (stderr, "Sanitizer %p passed first round with %d edits; doing a second round %s\n",
- (void *) blob, c->edit_count, HB_FUNC));
+ DEBUG_MSG (SANITIZE, "Sanitizer %p passed first round with %d edits; doing a second round %s\n",
+ (void *) blob, c->edit_count, HB_FUNC);
/* sanitize again to ensure no toe-stepping */
c->edit_count = 0;
sane = t->sanitize (c);
if (c->edit_count) {
- (void) (HB_DEBUG_SANITIZE &&
- fprintf (stderr, "Sanitizer %p requested %d edits in second round; FAILLING %s\n",
- (void *) blob, c->edit_count, HB_FUNC));
+ DEBUG_MSG (SANITIZE, "Sanitizer %p requested %d edits in second round; FAILLING %s\n",
+ (void *) blob, c->edit_count, HB_FUNC);
sane = false;
}
}
if (c->start) {
c->writable = true;
/* ok, we made it writable by relocating. try again */
- (void) (HB_DEBUG_SANITIZE &&
- fprintf (stderr, "Sanitizer %p retry %s\n", (void *) blob, HB_FUNC));
+ DEBUG_MSG (SANITIZE, "Sanitizer %p retry %s\n", (void *) blob, HB_FUNC);
goto retry;
}
}
c->finish ();
- (void) (HB_DEBUG_SANITIZE &&
- fprintf (stderr, "Sanitizer %p %s %s\n", (void *) blob, sane ? "passed" : "FAILED", HB_FUNC));
+ DEBUG_MSG (SANITIZE, "Sanitizer %p %s %s\n", (void *) blob, sane ? "passed" : "FAILED", HB_FUNC);
if (sane)
return blob;
else {