From d87ac0319b6409a169e7a5fcebb8534792094e40 Mon Sep 17 00:00:00 2001 From: Andrew Johnson Date: Sat, 30 Sep 2017 15:51:51 -0500 Subject: [PATCH] Replace the base:jlinkDebug info-item with a global variable The info item only works in dbPutString() which means dbLoadRecords() but not dbPutField(). --- src/ioc/db/dbJLink.c | 20 ++++++++++++++++---- src/ioc/dbStatic/dbStaticLib.c | 2 -- src/ioc/dbStatic/dbStaticPvt.h | 3 +-- 3 files changed, 17 insertions(+), 8 deletions(-) diff --git a/src/ioc/db/dbJLink.c b/src/ioc/db/dbJLink.c index 0bc8d6ba5..feedf35a1 100644 --- a/src/ioc/db/dbJLink.c +++ b/src/ioc/db/dbJLink.c @@ -26,7 +26,9 @@ #include "dbStaticLib.h" #include "link.h" -#define IFDEBUG(n) if(parser->parse_debug) +int dbJLinkDebug = 0; + +#define IFDEBUG(n) if (dbJLinkDebug >= (n)) typedef struct parseContext { jlink *pjlink; @@ -34,7 +36,6 @@ typedef struct parseContext { short dbfType; short jsonDepth; unsigned key_is_link:1; - unsigned parse_debug:1; unsigned lset_debug:1; } parseContext; @@ -59,6 +60,9 @@ static int dbjl_return(parseContext *parser, jlif_result result) { pjlink->pif->free_jlink(pjlink); } + IFDEBUG(10) + printf(" returning %d %s\n", result, + result == jlif_stop ? "*** STOP ***" : "Continue"); return result; } @@ -352,7 +356,6 @@ long dbJLinkParse(const char *json, size_t jlen, short dbfType, parser->dbfType = dbfType; parser->jsonDepth = 0; parser->key_is_link = 0; - parser->parse_debug = !!(opts&LINK_DEBUG_JPARSE); parser->lset_debug = !!(opts&LINK_DEBUG_LSET); IFDEBUG(10) @@ -369,8 +372,14 @@ long dbJLinkParse(const char *json, size_t jlen, short dbfType, return S_db_noMemory; ys = yajl_parse(yh, (const unsigned char *) json, jlen); - if (ys == yajl_status_ok) + IFDEBUG(10) + printf("dbJLinkInit: yajl_parse() returned %d\n", ys); + + if (ys == yajl_status_ok) { ys = yajl_complete_parse(yh); + IFDEBUG(10) + printf("dbJLinkInit: yajl_complete_parse() returned %d\n", ys); + } switch (ys) { unsigned char *err; @@ -382,6 +391,9 @@ long dbJLinkParse(const char *json, size_t jlen, short dbfType, break; case yajl_status_error: + IFDEBUG(10) + printf(" jsonDepth=%d, product=%p, pjlink=%p\n", + parser->jsonDepth, parser->product, parser->pjlink); err = yajl_get_error(yh, 1, (const unsigned char *) json, jlen); errlogPrintf("dbJLinkInit: %s\n", err); yajl_free_error(yh, err); diff --git a/src/ioc/dbStatic/dbStaticLib.c b/src/ioc/dbStatic/dbStaticLib.c index 6e9997ad1..7549a0da6 100644 --- a/src/ioc/dbStatic/dbStaticLib.c +++ b/src/ioc/dbStatic/dbStaticLib.c @@ -2613,8 +2613,6 @@ long dbPutString(DBENTRY *pdbentry,const char *pstring) if(dbFindInfo(&infoentry, "base:lsetDebug")==0 && epicsStrCaseCmp(dbGetInfoString(&infoentry), "YES")==0) opts |= LINK_DEBUG_LSET; - if(dbFindInfo(&infoentry, "base:jlinkDebug")==0 && epicsStrCaseCmp(dbGetInfoString(&infoentry), "YES")==0) - opts |= LINK_DEBUG_JPARSE; dbFinishEntry(&infoentry); } diff --git a/src/ioc/dbStatic/dbStaticPvt.h b/src/ioc/dbStatic/dbStaticPvt.h index 58d32c28c..b1ad70de6 100644 --- a/src/ioc/dbStatic/dbStaticPvt.h +++ b/src/ioc/dbStatic/dbStaticPvt.h @@ -5,7 +5,7 @@ * Operator of Los Alamos National Laboratory. * EPICS BASE Versions 3.13.7 * and higher are distributed subject to a Software License Agreement found -* in file LICENSE that is included with this distribution. +* in file LICENSE that is included with this distribution. \*************************************************************************/ /* dbStaticPvt.h */ /* @@ -60,7 +60,6 @@ typedef struct dbLinkInfo { long dbInitRecordLinks(dbRecordType *rtyp, struct dbCommon *prec); #define LINK_DEBUG_LSET 1 -#define LINK_DEBUG_JPARSE 2 /* Parse link string. no record locks needed. * on success caller must free pinfo->target