mirror of https://github.com/ecmwf/eccodes.git
Allow user to catch asserts
This commit is contained in:
commit
23c7de8958
|
@ -318,3 +318,4 @@ data/bufr/*test
|
|||
.idea
|
||||
|
||||
build/
|
||||
*.back
|
||||
|
|
|
@ -1,18 +1,41 @@
|
|||
{
|
||||
"folders": [
|
||||
"build_systems":
|
||||
[
|
||||
{
|
||||
"path": ".",
|
||||
"follow_symlinks": true
|
||||
"file_regex": "([/\\w\\-\\.]+):(\\d+):(\\d+:)?",
|
||||
"name": "eccodes",
|
||||
"shell_cmd": "make",
|
||||
"syntax": "Packages/CMakeBuilder/Syntax/Make.sublime-syntax",
|
||||
"variants":
|
||||
[
|
||||
{
|
||||
"name": "clean",
|
||||
"shell_cmd": "make clean"
|
||||
},
|
||||
],
|
||||
"working_dir": "${project_path}/../../build/eccodes"
|
||||
},
|
||||
{
|
||||
"file_regex": "^[ ]*File \"(...*?)\", line ([0-9]*)",
|
||||
"name": "Anaconda Python Builder",
|
||||
"selector": "source.python",
|
||||
"shell_cmd": "\"python\" -u \"$file\""
|
||||
}
|
||||
],
|
||||
"build_systems": [
|
||||
"cmake":
|
||||
{
|
||||
"working_dir": "${project_path}/../../build/eccodes",
|
||||
"cmd": [
|
||||
"make"
|
||||
],
|
||||
"file_regex": "([/\\w\\-\\.]+):(\\d+):(\\d+:)?",
|
||||
"name": "ecbuild"
|
||||
"build_folder": "${project_path}/../../build/eccodes",
|
||||
"command_line_overrides":
|
||||
{
|
||||
"DEVELOPER_MODE": 1,
|
||||
"ENABLE_MEMFS": 1
|
||||
}
|
||||
},
|
||||
"folders":
|
||||
[
|
||||
{
|
||||
"follow_symlinks": true,
|
||||
"path": "."
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
|
@ -9,7 +9,6 @@
|
|||
*/
|
||||
|
||||
#include "eccodes.h"
|
||||
#include <assert.h>
|
||||
|
||||
/* Generic functions */
|
||||
/******************************************************************************/
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
|
||||
|
||||
#include "grib_api_internal.h"
|
||||
#include <assert.h>
|
||||
|
||||
|
||||
/*
|
||||
This is used by make_class.pl
|
||||
|
@ -175,7 +175,7 @@ static void init(grib_accessor* a,const long l, grib_arguments* c)
|
|||
self->scale=grib_arguments_get_double(grib_handle_of_accessor(a),c,n++);
|
||||
}
|
||||
|
||||
assert(self->len <= sizeof(long)*8);
|
||||
Assert(self->len <= sizeof(long)*8);
|
||||
|
||||
a->length=0;
|
||||
}
|
||||
|
|
|
@ -9,7 +9,6 @@
|
|||
*/
|
||||
|
||||
#include "grib_api_internal.h"
|
||||
#include <assert.h>
|
||||
|
||||
/*
|
||||
This is used by make_class.pl
|
||||
|
|
|
@ -9,7 +9,6 @@
|
|||
*/
|
||||
|
||||
#include "grib_api_internal.h"
|
||||
#include <assert.h>
|
||||
|
||||
/*
|
||||
This is used by make_class.pl
|
||||
|
|
|
@ -1536,6 +1536,9 @@ grib_handle *grib_util_set_spec2(grib_handle *h,
|
|||
/* --------------------------------------- */
|
||||
|
||||
|
||||
typedef void (*codes_assertion_failed_proc)(const char* message);
|
||||
void codes_set_codes_assertion_failed_proc(codes_assertion_failed_proc proc);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -162,8 +162,7 @@ extern "C" {
|
|||
#define ftello ftell
|
||||
#endif
|
||||
|
||||
#define Assert(a) {if(!(a)) grib_fail(#a,__FILE__,__LINE__,0);}
|
||||
#define AssertSilent(a) {if(!(a)) grib_fail(#a,__FILE__,__LINE__,1);}
|
||||
#define Assert(a) do { if(!(a)) codes_assertion_failed(#a, __FILE__, __LINE__); } while(0)
|
||||
|
||||
#ifndef NDEBUG
|
||||
#define DebugAssert(a) Assert(a)
|
||||
|
@ -814,6 +813,9 @@ struct codes_condition {
|
|||
double rightDouble;
|
||||
};
|
||||
|
||||
|
||||
void codes_assertion_failed(const char* message, const char* file, int line);
|
||||
|
||||
#define MAX_SET_VALUES 10
|
||||
#define MAX_ACCESSOR_CACHE 100
|
||||
|
||||
|
|
|
@ -1271,7 +1271,6 @@ int codes_copy_key(grib_handle *h1, grib_handle *h2, const char *key, int type);
|
|||
/* grib_errors.c */
|
||||
const char *grib_get_error_message(int code);
|
||||
void grib_check(const char *call, const char *file, int line, int e, const char *msg);
|
||||
void grib_fail(const char *expr, const char *file, int line, int silent);
|
||||
|
||||
/* grib_expression_class_binop.c */
|
||||
grib_expression *new_binop_expression(grib_context *c, grib_binop_long_proc long_func, grib_binop_double_proc double_func, grib_expression *left, grib_expression *right);
|
||||
|
|
|
@ -978,3 +978,24 @@ void grib_context_increment_handle_total_count(grib_context *c)
|
|||
GRIB_MUTEX_UNLOCK(&mutex_c);
|
||||
}
|
||||
|
||||
static codes_assertion_failed_proc assertion = NULL;
|
||||
|
||||
void codes_set_codes_assertion_failed_proc(codes_assertion_failed_proc proc)
|
||||
{
|
||||
assertion = proc;
|
||||
}
|
||||
|
||||
void codes_assertion_failed(const char* message, const char* file, int line)
|
||||
{
|
||||
/* Default behaviour is to abort
|
||||
* unless user has supplied his own assertion routine */
|
||||
if (assertion == NULL) {
|
||||
fprintf(stderr, "ecCodes assertion failed: `%s' in %s:%d\n", message, file, line);
|
||||
abort();
|
||||
}
|
||||
else {
|
||||
char buffer[10240];
|
||||
sprintf(buffer, "ecCodes assertion failed: `%s' in %s:%d", message, file, line);
|
||||
assertion(buffer);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -113,11 +113,3 @@ void grib_check(const char* call,const char* file,int line,int e,const char* ms
|
|||
exit(e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void grib_fail(const char* expr,const char* file,int line,int silent) {
|
||||
if (!silent)
|
||||
fprintf(stderr,"%s at line %d: assertion failure Assert(%s)\n",file,line,expr);
|
||||
abort();
|
||||
}
|
||||
|
||||
|
|
|
@ -35,10 +35,3 @@ void grib_check(const char* call,const char* file,int line,int e,const char* ms
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
void grib_fail(const char* expr,const char* file,int line,int silent) {
|
||||
if (!silent)
|
||||
fprintf(stderr,"%s at line %d: assertion failure Assert(%s)\n",file,line,expr);
|
||||
abort();
|
||||
}
|
||||
|
||||
|
|
|
@ -8,7 +8,6 @@
|
|||
* virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction.
|
||||
*/
|
||||
#include "grib_api_internal.h"
|
||||
#include <assert.h>
|
||||
|
||||
/*
|
||||
* C Implementation: gaussian_reduced
|
||||
|
@ -87,7 +86,7 @@ void grib_get_reduced_row(long pl, double lon_first, double lon_last, long* npoi
|
|||
}
|
||||
}
|
||||
|
||||
assert(*npoints==irange);
|
||||
Assert(*npoints==irange);
|
||||
#if EFDEBUG
|
||||
printf("-- pl=%ld npoints=%ld range=%.10e ilon_first=%ld ilon_last=%ld irange=%ld\n",
|
||||
pl,*npoints,range,*ilon_first,*ilon_last,irange);
|
||||
|
|
|
@ -617,7 +617,7 @@ static int read_BUFR(reader *r)
|
|||
|
||||
edition = tmp[i++];
|
||||
|
||||
/* assert(edition != 1); */
|
||||
/* Assert(edition != 1); */
|
||||
|
||||
switch (edition) {
|
||||
case 0:
|
||||
|
|
|
@ -9,10 +9,10 @@
|
|||
*/
|
||||
|
||||
#include "md5.h"
|
||||
#include "grib_api_internal.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <assert.h>
|
||||
|
||||
/* On CRAY, disable all automatic optimisations for this module */
|
||||
#if _CRAYC
|
||||
|
@ -215,7 +215,7 @@ static void grib_md5_flush(grib_md5_state* s)
|
|||
|
||||
void grib_md5_init(grib_md5_state* s)
|
||||
{
|
||||
assert( sizeof(UnsignedInt64) == 8 );
|
||||
Assert( sizeof(UnsignedInt64) == 8 );
|
||||
memset(s,0,sizeof(grib_md5_state));
|
||||
s->h0 = 0x67452301;
|
||||
s->h1 = 0xefcdab89;
|
||||
|
|
Loading…
Reference in New Issue