Added Panic level for debug with stack dump.
git-svn-id: http://svn.zoneminder.com/svn/zm/trunk@2975 e3e1d417-86f3-4887-817a-d78f3d33393f
This commit is contained in:
parent
72d4f11213
commit
10b01a5062
|
@ -358,6 +358,9 @@ void zmDbgOutput( int hex, const char * const file, const int line, const int le
|
|||
case ZM_DBG_FAT:
|
||||
strncpy( class_string, "FAT", sizeof(class_string) );
|
||||
break;
|
||||
case ZM_DBG_PNC:
|
||||
strncpy( class_string, "PNC", sizeof(class_string) );
|
||||
break;
|
||||
default:
|
||||
if ( level > 0 && level <= 9 )
|
||||
{
|
||||
|
@ -442,9 +445,8 @@ void zmDbgOutput( int hex, const char * const file, const int line, const int le
|
|||
log_code = LOG_WARNING;
|
||||
break;
|
||||
case ZM_DBG_ERR:
|
||||
log_code = LOG_ERR;
|
||||
break;
|
||||
case ZM_DBG_FAT:
|
||||
case ZM_DBG_PNC:
|
||||
log_code = LOG_ERR;
|
||||
break;
|
||||
default:
|
||||
|
@ -455,8 +457,9 @@ void zmDbgOutput( int hex, const char * const file, const int line, const int le
|
|||
*dbg_log_end = '\0';
|
||||
syslog( log_code, "%s [%s]", class_string, dbg_log_start );
|
||||
}
|
||||
if ( level == ZM_DBG_FAT )
|
||||
if ( level >= ZM_DBG_FAT )
|
||||
{
|
||||
if ( level >= ZM_DBG_PNC )
|
||||
abort();
|
||||
exit( -1 );
|
||||
}
|
||||
|
|
|
@ -36,6 +36,7 @@
|
|||
#define ZM_DBG_WAR -1
|
||||
#define ZM_DBG_ERR -2
|
||||
#define ZM_DBG_FAT -3
|
||||
#define ZM_DBG_PNC -4
|
||||
|
||||
/* Define the level at which messages go through syslog */
|
||||
#define ZM_DBG_SYSLOG ZM_DBG_INF
|
||||
|
@ -63,6 +64,7 @@
|
|||
#define Warning(params...) zmDbgPrintf(ZM_DBG_WAR,##params)
|
||||
#define Error(params...) zmDbgPrintf(ZM_DBG_ERR,##params)
|
||||
#define Fatal(params...) zmDbgPrintf(ZM_DBG_FAT,##params)
|
||||
#define Panic(params...) zmDbgPrintf(ZM_DBG_PNC,##params)
|
||||
#define Mark() Info("Mark/%s/%d",__FILE__,__LINE__)
|
||||
#define Log() Info("Log")
|
||||
#ifdef __GNUC__
|
||||
|
|
|
@ -221,7 +221,7 @@ Image *Image::HighlightEdges( Rgb colour, const Box *limits )
|
|||
{
|
||||
if ( colours != 1 )
|
||||
{
|
||||
Fatal( "Attempt to highlight image edges when colours = %d", colours );
|
||||
Panic( "Attempt to highlight image edges when colours = %d", colours );
|
||||
}
|
||||
Image *high_image = new Image( width, height, 3 );
|
||||
int lo_x = limits?limits->Lo().X():0;
|
||||
|
@ -644,7 +644,7 @@ void Image::Overlay( const Image &image )
|
|||
{
|
||||
if ( !(width == image.width && height == image.height) )
|
||||
{
|
||||
Fatal( "Attempt to overlay different sized images, expected %dx%d, got %dx%d", width, height, image.width, image.height );
|
||||
Panic( "Attempt to overlay different sized images, expected %dx%d, got %dx%d", width, height, image.width, image.height );
|
||||
}
|
||||
|
||||
unsigned char *pdest = buffer;
|
||||
|
@ -715,17 +715,17 @@ void Image::Overlay( const Image &image, int x, int y )
|
|||
{
|
||||
if ( !(width < image.width || height < image.height) )
|
||||
{
|
||||
Fatal( "Attempt to overlay image too big for destination, %dx%d > %dx%d", image.width, image.height, width, height );
|
||||
Panic( "Attempt to overlay image too big for destination, %dx%d > %dx%d", image.width, image.height, width, height );
|
||||
}
|
||||
|
||||
if ( !(width < (x+image.width) || height < (y+image.height)) )
|
||||
{
|
||||
Fatal( "Attempt to overlay image outside of destination bounds, %dx%d @ %dx%d > %dx%d", image.width, image.height, x, y, width, height );
|
||||
Panic( "Attempt to overlay image outside of destination bounds, %dx%d @ %dx%d > %dx%d", image.width, image.height, x, y, width, height );
|
||||
}
|
||||
|
||||
if ( !(colours == image.colours) )
|
||||
{
|
||||
Fatal( "Attempt to partial overlay differently coloured images, expected %d, got %d", colours, image.colours );
|
||||
Panic( "Attempt to partial overlay differently coloured images, expected %d, got %d", colours, image.colours );
|
||||
}
|
||||
|
||||
int lo_x = x;
|
||||
|
@ -764,7 +764,7 @@ void Image::Blend( const Image &image, int transparency ) const
|
|||
{
|
||||
if ( !(width == image.width && height == image.height && colours == image.colours) )
|
||||
{
|
||||
Fatal( "Attempt to blend different sized images, expected %dx%dx%d, got %dx%dx%d", width, height, colours, image.width, image.height, image.colours );
|
||||
Panic( "Attempt to blend different sized images, expected %dx%dx%d, got %dx%dx%d", width, height, colours, image.width, image.height, image.colours );
|
||||
}
|
||||
|
||||
if ( config.fast_image_blends )
|
||||
|
@ -819,7 +819,7 @@ Image *Image::Merge( int n_images, Image *images[] )
|
|||
{
|
||||
if ( !(width == images[i]->width && height == images[i]->height && colours == images[i]->colours) )
|
||||
{
|
||||
Fatal( "Attempt to merge different sized images, expected %dx%dx%d, got %dx%dx%d, for image %d", width, height, colours, images[i]->width, images[i]->height, images[i]->colours, i );
|
||||
Panic( "Attempt to merge different sized images, expected %dx%dx%d, got %dx%dx%d, for image %d", width, height, colours, images[i]->width, images[i]->height, images[i]->colours, i );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -853,7 +853,7 @@ Image *Image::Merge( int n_images, Image *images[], double weight )
|
|||
{
|
||||
if ( !(width == images[i]->width && height == images[i]->height && colours == images[i]->colours) )
|
||||
{
|
||||
Fatal( "Attempt to merge different sized images, expected %dx%dx%d, got %dx%dx%d, for image %d", width, height, colours, images[i]->width, images[i]->height, images[i]->colours, i );
|
||||
Panic( "Attempt to merge different sized images, expected %dx%dx%d, got %dx%dx%d, for image %d", width, height, colours, images[i]->width, images[i]->height, images[i]->colours, i );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -887,7 +887,7 @@ Image *Image::Highlight( int n_images, Image *images[], const Rgb threshold, con
|
|||
{
|
||||
if ( !(width == images[i]->width && height == images[i]->height && colours == images[i]->colours) )
|
||||
{
|
||||
Fatal( "Attempt to highlight different sized images, expected %dx%dx%d, got %dx%dx%d, for image %d", width, height, colours, images[i]->width, images[i]->height, images[i]->colours, i );
|
||||
Panic( "Attempt to highlight different sized images, expected %dx%dx%d, got %dx%dx%d, for image %d", width, height, colours, images[i]->width, images[i]->height, images[i]->colours, i );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -920,7 +920,7 @@ Image *Image::Delta( const Image &image ) const
|
|||
{
|
||||
if ( !(width == image.width && height == image.height && colours == image.colours) )
|
||||
{
|
||||
Fatal( "Attempt to get delta of different sized images, expected %dx%dx%d, got %dx%dx%d", width, height, colours, image.width, image.height, image.colours );
|
||||
Panic( "Attempt to get delta of different sized images, expected %dx%dx%d, got %dx%dx%d", width, height, colours, image.width, image.height, image.colours );
|
||||
}
|
||||
|
||||
Image *result = new Image( width, height, 1 );
|
||||
|
@ -1176,7 +1176,7 @@ void Image::Fill( Rgb colour, const Box *limits )
|
|||
{
|
||||
if ( !(colours == 1 || colours == 3 ) )
|
||||
{
|
||||
Fatal( "Attempt to fill image with unexpected colours %d", colours );
|
||||
Panic( "Attempt to fill image with unexpected colours %d", colours );
|
||||
}
|
||||
int lo_x = limits?limits->Lo().X():0;
|
||||
int lo_y = limits?limits->Lo().Y():0;
|
||||
|
@ -1213,7 +1213,7 @@ void Image::Fill( Rgb colour, int density, const Box *limits )
|
|||
{
|
||||
if ( !(colours == 1 || colours == 3 ) )
|
||||
{
|
||||
Fatal( "Attempt to fill image with unexpected colours %d", colours );
|
||||
Panic( "Attempt to fill image with unexpected colours %d", colours );
|
||||
}
|
||||
|
||||
int lo_x = limits?limits->Lo().X():0;
|
||||
|
@ -1246,7 +1246,7 @@ void Image::Outline( Rgb colour, const Polygon &polygon )
|
|||
{
|
||||
if ( !(colours == 1 || colours == 3 ) )
|
||||
{
|
||||
Fatal( "Attempt to outline image with unexpected colours %d", colours );
|
||||
Panic( "Attempt to outline image with unexpected colours %d", colours );
|
||||
}
|
||||
int n_coords = polygon.getNumCoords();
|
||||
for ( int j = 0, i = n_coords-1; j < n_coords; i = j++ )
|
||||
|
@ -1335,7 +1335,7 @@ void Image::Fill( Rgb colour, int density, const Polygon &polygon )
|
|||
{
|
||||
if ( !(colours == 1 || colours == 3 ) )
|
||||
{
|
||||
Fatal( "Attempt to fill image with unexpected colours %d", colours );
|
||||
Panic( "Attempt to fill image with unexpected colours %d", colours );
|
||||
}
|
||||
|
||||
int n_coords = polygon.getNumCoords();
|
||||
|
|
|
@ -41,8 +41,6 @@ extern "C"
|
|||
class Image
|
||||
{
|
||||
protected:
|
||||
enum { CHAR_HEIGHT=11, CHAR_WIDTH=6 };
|
||||
enum { LINE_HEIGHT=CHAR_HEIGHT+0 };
|
||||
typedef unsigned char BlendTable[256][256];
|
||||
typedef BlendTable *BlendTablePtr;
|
||||
|
||||
|
@ -68,6 +66,10 @@ protected:
|
|||
}
|
||||
};
|
||||
|
||||
public:
|
||||
enum { CHAR_HEIGHT=11, CHAR_WIDTH=6 };
|
||||
enum { LINE_HEIGHT=CHAR_HEIGHT+0 };
|
||||
|
||||
protected:
|
||||
static bool initialised;
|
||||
static unsigned char *abs_table;
|
||||
|
@ -120,7 +122,7 @@ public:
|
|||
{
|
||||
if ( image.size != size )
|
||||
{
|
||||
Fatal( "Attempt to copy different size image buffers, expected %d, got %d", size, image.size );
|
||||
Panic( "Attempt to copy different size image buffers, expected %d, got %d", size, image.size );
|
||||
}
|
||||
memcpy( buffer, image.buffer, size );
|
||||
}
|
||||
|
|
|
@ -39,7 +39,6 @@ void zm_jpeg_error_exit( j_common_ptr cinfo )
|
|||
if ( ++jpeg_err_count == MAX_JPEG_ERRS )
|
||||
{
|
||||
Fatal( "Maximum number (%d) of JPEG errors reached, exiting", jpeg_err_count );
|
||||
exit( -1 );
|
||||
}
|
||||
|
||||
longjmp( zmerr->setjmp_buffer, 1 );
|
||||
|
|
|
@ -1004,11 +1004,22 @@ bool Monitor::CheckSignal( const Image *image )
|
|||
|
||||
const unsigned char *buffer = image->Buffer();
|
||||
int pixels = image->Pixels();
|
||||
int width = image->Width();
|
||||
int colours = image->Colours();
|
||||
|
||||
int index = 0;
|
||||
for ( int i = 0; i < config.signal_check_points; i++ )
|
||||
{
|
||||
int index = (rand()*pixels)/RAND_MAX;
|
||||
while( true )
|
||||
{
|
||||
index = (int)(((long long)rand()*(long long)(pixels-1))/RAND_MAX);
|
||||
if ( !config.timestamp_on_capture || !label_format[0] )
|
||||
break;
|
||||
// Avoid sampling the rows with timestamp in
|
||||
int y = index / (width * colours);
|
||||
if ( y < label_coord.Y() || y > label_coord.Y()+Image::LINE_HEIGHT )
|
||||
break;
|
||||
}
|
||||
const unsigned char *ptr = buffer+(index*colours);
|
||||
if ( (RED(ptr) != red_val) || (GREEN(ptr) != green_val) || (BLUE(ptr) != blue_val) )
|
||||
{
|
||||
|
|
|
@ -61,7 +61,7 @@ void VideoStream::SetupFormat( const char *p_filename, const char *p_format )
|
|||
ofc = (AVFormatContext *)av_mallocz(sizeof(AVFormatContext));
|
||||
if ( !ofc )
|
||||
{
|
||||
Fatal( "Memory error" );
|
||||
Panic( "Memory error" );
|
||||
}
|
||||
ofc->oformat = of;
|
||||
snprintf( ofc->filename, sizeof(ofc->filename), "%s", filename );
|
||||
|
@ -79,7 +79,7 @@ void VideoStream::SetupCodec( int colours, int width, int height, int bitrate, d
|
|||
ost = av_new_stream(ofc, 0);
|
||||
if (!ost)
|
||||
{
|
||||
Fatal( "Could not alloc stream" );
|
||||
Panic( "Could not alloc stream" );
|
||||
}
|
||||
|
||||
#if ZM_FFMPEG_SVN
|
||||
|
@ -125,7 +125,7 @@ void VideoStream::SetParameters()
|
|||
parameters). */
|
||||
if ( av_set_parameters(ofc, NULL) < 0 )
|
||||
{
|
||||
Fatal( "Invalid output format parameters" );
|
||||
Panic( "Invalid output format parameters" );
|
||||
}
|
||||
//dump_format(ofc, 0, filename, 1);
|
||||
}
|
||||
|
@ -165,27 +165,27 @@ void VideoStream::OpenStream()
|
|||
AVCodec *codec = avcodec_find_encoder(c->codec_id);
|
||||
if ( !codec )
|
||||
{
|
||||
Fatal( "codec not found" );
|
||||
Panic( "codec not found" );
|
||||
}
|
||||
|
||||
/* open the codec */
|
||||
if ( avcodec_open(c, codec) < 0 )
|
||||
{
|
||||
Fatal( "Could not open codec" );
|
||||
Panic( "Could not open codec" );
|
||||
}
|
||||
|
||||
/* allocate the encoded raw picture */
|
||||
opicture = avcodec_alloc_frame();
|
||||
if ( !opicture )
|
||||
{
|
||||
Fatal( "Could not allocate opicture" );
|
||||
Panic( "Could not allocate opicture" );
|
||||
}
|
||||
int size = avpicture_get_size( c->pix_fmt, c->width, c->height);
|
||||
uint8_t *opicture_buf = (uint8_t *)malloc(size);
|
||||
if ( !opicture_buf )
|
||||
{
|
||||
av_free(opicture);
|
||||
Fatal( "Could not allocate opicture" );
|
||||
Panic( "Could not allocate opicture" );
|
||||
}
|
||||
avpicture_fill( (AVPicture *)opicture, opicture_buf, c->pix_fmt, c->width, c->height );
|
||||
|
||||
|
@ -198,14 +198,14 @@ void VideoStream::OpenStream()
|
|||
tmp_opicture = avcodec_alloc_frame();
|
||||
if ( !tmp_opicture )
|
||||
{
|
||||
Fatal( "Could not allocate temporary opicture" );
|
||||
Panic( "Could not allocate temporary opicture" );
|
||||
}
|
||||
int size = avpicture_get_size( pf, c->width, c->height);
|
||||
uint8_t *tmp_opicture_buf = (uint8_t *)malloc(size);
|
||||
if (!tmp_opicture_buf)
|
||||
{
|
||||
av_free( tmp_opicture );
|
||||
Fatal( "Could not allocate temporary opicture" );
|
||||
Panic( "Could not allocate temporary opicture" );
|
||||
}
|
||||
avpicture_fill( (AVPicture *)tmp_opicture, tmp_opicture_buf, pf, c->width, c->height );
|
||||
}
|
||||
|
@ -318,7 +318,7 @@ double VideoStream::EncodeFrame( uint8_t *buffer, int buffer_size, bool add_time
|
|||
{
|
||||
img_convert_ctx = sws_getContext( c->width, c->height, pf, c->width, c->height, c->pix_fmt, SWS_BICUBIC, NULL, NULL, NULL );
|
||||
if ( !img_convert_ctx )
|
||||
Fatal( "Unable to initialise image scaling context" );
|
||||
Panic( "Unable to initialise image scaling context" );
|
||||
}
|
||||
sws_scale( img_convert_ctx, tmp_opicture->data, tmp_opicture->linesize, 0, c->height, opicture->data, opicture->linesize );
|
||||
#else // HAVE_LIBSWSCALE
|
||||
|
|
|
@ -30,13 +30,13 @@ RegExpr::RegExpr( const char *pattern, int flags, int p_max_matches ) : max_matc
|
|||
int erroffset = 0;
|
||||
if ( !(regex = pcre_compile( pattern, flags, &errstr, &erroffset, 0 )) )
|
||||
{
|
||||
Fatal( "pcre_compile(%s): %s at %d", pattern, errstr, erroffset );
|
||||
Panic( "pcre_compile(%s): %s at %d", pattern, errstr, erroffset );
|
||||
}
|
||||
|
||||
regextra = pcre_study( regex, 0, &errstr );
|
||||
if ( errstr )
|
||||
{
|
||||
Fatal( "pcre_study(%s): %s", pattern, errstr );
|
||||
Panic( "pcre_study(%s): %s", pattern, errstr );
|
||||
}
|
||||
|
||||
if ( (ok = (bool)regex) )
|
||||
|
|
|
@ -138,11 +138,11 @@ int RemoteCameraRtsp::PrimeCapture()
|
|||
// Find the decoder for the video stream
|
||||
codec = avcodec_find_decoder( codecContext->codec_id );
|
||||
if ( codec == NULL )
|
||||
Fatal( "Unable to locate codec %d decoder", codecContext->codec_id );
|
||||
Panic( "Unable to locate codec %d decoder", codecContext->codec_id );
|
||||
|
||||
// Open codec
|
||||
if ( avcodec_open( codecContext, codec ) < 0 )
|
||||
Fatal( "Can't open codec" );
|
||||
Panic( "Can't open codec" );
|
||||
|
||||
picture = avcodec_alloc_frame();
|
||||
|
||||
|
@ -185,14 +185,14 @@ int RemoteCameraRtsp::Capture( Image &image )
|
|||
tmp_picture = avcodec_alloc_frame();
|
||||
if ( !tmp_picture )
|
||||
{
|
||||
Fatal( "Could not allocate temporary opicture" );
|
||||
Panic( "Could not allocate temporary opicture" );
|
||||
}
|
||||
int size = avpicture_get_size( PIX_FMT_RGB24, width, height);
|
||||
uint8_t *tmp_picture_buf = (uint8_t *)malloc(size);
|
||||
if (!tmp_picture_buf)
|
||||
{
|
||||
av_free( tmp_picture );
|
||||
Fatal( "Could not allocate temporary opicture" );
|
||||
Panic( "Could not allocate temporary opicture" );
|
||||
}
|
||||
avpicture_fill( (AVPicture *)tmp_picture, tmp_picture_buf, PIX_FMT_RGB24, width, height );
|
||||
//}
|
||||
|
@ -234,7 +234,7 @@ int RemoteCameraRtsp::Capture( Image &image )
|
|||
{
|
||||
img_convert_ctx = sws_getContext( codecContext->width, codecContext->height, codecContext->pix_fmt, width, height, PIX_FMT_RGB24, SWS_BICUBIC, NULL, NULL, NULL );
|
||||
if ( !img_convert_ctx )
|
||||
Fatal( "Unable to initialise image scaling context" );
|
||||
Panic( "Unable to initialise image scaling context" );
|
||||
}
|
||||
|
||||
sws_scale( img_convert_ctx, picture->data, picture->linesize, 0, height, tmp_picture->data, tmp_picture->linesize );
|
||||
|
|
|
@ -332,7 +332,7 @@ int RtpCtrlThread::run()
|
|||
}
|
||||
else
|
||||
{
|
||||
Fatal( "Barfed" );
|
||||
Panic( "Barfed" );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -108,7 +108,7 @@ int RtpDataThread::run()
|
|||
}
|
||||
else
|
||||
{
|
||||
Fatal( "Barfed" );
|
||||
Panic( "Barfed" );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -147,7 +147,7 @@ int RtspThread::requestPorts()
|
|||
return( i );
|
||||
}
|
||||
}
|
||||
Fatal( "Can assign RTP port, no ports left in pool" );
|
||||
Panic( "Can assign RTP port, no ports left in pool" );
|
||||
return( -1 );
|
||||
}
|
||||
|
||||
|
@ -369,7 +369,7 @@ int RtspThread::run()
|
|||
}
|
||||
default:
|
||||
{
|
||||
Fatal( "Got unexpected method %d", mMethod );
|
||||
Panic( "Got unexpected method %d", mMethod );
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -704,7 +704,7 @@ int RtspThread::run()
|
|||
}
|
||||
default:
|
||||
{
|
||||
Fatal( "Got unexpected method %d", mMethod );
|
||||
Panic( "Got unexpected method %d", mMethod );
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -918,10 +918,10 @@ int Zone::Load( Monitor *monitor, Zone **&zones )
|
|||
Debug( 5, "Parsing polygon %s", Coords );
|
||||
Polygon polygon;
|
||||
if ( !ParsePolygonString( Coords, polygon ) )
|
||||
Fatal( "Unable to parse polygon string '%s' for zone %d/%s for monitor %s", Coords, Id, Name, monitor->Name() );
|
||||
Panic( "Unable to parse polygon string '%s' for zone %d/%s for monitor %s", Coords, Id, Name, monitor->Name() );
|
||||
|
||||
if ( polygon.LoX() < 0 || polygon.HiX() >= monitor->Width() || polygon.LoY() < 0 || polygon.HiY() >= monitor->Height() )
|
||||
Fatal( "Zone %d/%s for monitor %s extends outside of image dimensions", Id, Name, monitor->Name() );
|
||||
Panic( "Zone %d/%s for monitor %s extends outside of image dimensions", Id, Name, monitor->Name() );
|
||||
|
||||
if ( false && !strcmp( Units, "Percent" ) )
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue