Alien-Judy
view release on metacpan or search on metacpan
src/judy-1.0.5/src/JudyCommon/JudyPrintJP.c view on Meta::CPAN
// Copyright (C) 2000 - 2002 Hewlett-Packard Company
//
// This program is free software; you can redistribute it and/or modify it
// under the term of the GNU Lesser General Public License as published by the
// Free Software Foundation; either version 2 of the License, or (at your
// option) any later version.
//
// This program is distributed in the hope that it will be useful, but WITHOUT
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
// for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with this program; if not, write to the Free Software Foundation,
// Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
// _________________
// @(#) $Revision: 4.13 $ $Source: /judy/src/JudyCommon/JudyPrintJP.c $
//
// JudyPrintJP() debugging/tracing function for Judy1 or JudyL code.
// The caller should #include this file, with its static function (replicated
// in each compilation unit), in another *.c file, and compile with one of
// -DJUDY1 or -DJUDYL.
//
// The caller can set j__udyIndex and/or j__udyPopulation non-zero to have
// those values reported, and also to control trace-enabling (see below).
//
// Tracing is disabled by default unless one or both of two env parameters is
// set (regardless of value). If either value is set but null or evaluates to
// zero, tracing is immediately enabled. To disable tracing until a particular
// j__udy*Index value is seen, set STARTINDEX=<hex-index> in the env. To
// disable it until a particular j__udy*Population value is seen, set
// STARTPOP=<decimal-population> in the env. Once either condition is met,
// tracing "latches on".
//
// Example:
//
// STARTPOP=0 // immediate tracing.
// STARTINDEX=f35430a8 // not until one of these is met.
// STARTPOP=1000000
//
// Note: Trace-enabling does nothing unless the caller sets the appropriate
// global variable non-zero.
#if (! (defined(JUDY1) || defined(JUDYL)))
#error: One of -DJUDY1 or -DJUDYL must be specified.
#endif
#include <stdlib.h> // for getenv() and strtoul().
// GLOBALS FROM CALLER:
//
// Note: This storage is declared once in each compilation unit that includes
// this file, but the linker should merge all cases into single locations, but
// ONLY if these are uninitialized, so ASSUME they are 0 to start.
Word_t j__udyIndex; // current Index itself, optional from caller.
Word_t j__udyPopulation; // Indexes in array, optional from caller.
// Other globals:
static Word_t startindex = 0; // see usage below.
static Word_t startpop = 0;
static bool_t enabled = FALSE; // by default, unless env params set.
// Shorthand for announcing JP addresses, Desc (in context), and JP types:
//
// Note: Width is at least one blank wider than any JP type name, and the line
// is left unfinished.
//
// Note: Use a format for address printing compatible with other tracing
// facilities; in particular, %x not %lx, to truncate the "noisy" high part on
// 64-bit systems.
#define JPTYPE(Type) printf("0x%lx %s %-17s", (Word_t) Pjp, Desc, Type)
// Shorthands for announcing expanse populations from DcdPopO fields:
#define POP0 printf("Pop1 = 0 ")
( run in 0.402 second using v1.01-cache-2.11-cpan-39bf76dae61 )