mirror of https://gitee.com/bigwinds/arangodb
added derived file
This commit is contained in:
parent
68d2775b39
commit
ed77c19e16
|
@ -1,5 +1,6 @@
|
|||
/*jslint indent: 2, nomen: true, maxlen: 120, vars: true, white: true, plusplus: true, nonpropdel: true, proto: true, regexp: true */
|
||||
/*global require, module, Module, ArangoError, SYS_DOWNLOAD,
|
||||
/*global require, module, Module, ArangoError, SYS_DEBUG_SET_FAILAT, SYS_DEBUG_REMOVE_FAILAT,
|
||||
SYS_DEBUG_CLEAR_FAILAT, SYS_DOWNLOAD,
|
||||
SYS_EXECUTE, SYS_LOAD, SYS_LOG_LEVEL, SYS_MD5, SYS_OUTPUT, SYS_PROCESS_STATISTICS,
|
||||
SYS_RAND, SYS_SERVER_STATISTICS, SYS_SPRINTF, SYS_TIME, SYS_START_PAGER, SYS_STOP_PAGER,
|
||||
SYS_SHA256, SYS_WAIT, SYS_PARSE, SYS_IMPORT_CSV_FILE, SYS_IMPORT_JSON_FILE, SYS_LOG,
|
||||
|
@ -216,6 +217,42 @@
|
|||
// --SECTION-- public functions
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief debugSetFailAt
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
if (typeof SYS_DEBUG_SET_FAILAT !== "undefined") {
|
||||
exports.debugSetFailAt = SYS_DEBUG_SET_FAILAT;
|
||||
delete SYS_DEBUG_SET_FAILAT;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief debugRemoveFailAt
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
if (typeof SYS_DEBUG_REMOVE_FAILAT !== "undefined") {
|
||||
exports.debugRemoveFailAt = SYS_DEBUG_REMOVE_FAILAT;
|
||||
delete SYS_DEBUG_REMOVE_FAILAT;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief debugClearFailAt
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
if (typeof SYS_DEBUG_CLEAR_FAILAT !== "undefined") {
|
||||
exports.debugClearFailAt = SYS_DEBUG_CLEAR_FAILAT;
|
||||
delete SYS_DEBUG_CLEAR_FAILAT;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief debugCanUseFailAt
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
if (typeof SYS_DEBUG_CAN_USE_FAILAT !== "undefined") {
|
||||
exports.debugCanUseFailAt = SYS_DEBUG_CAN_USE_FAILAT;
|
||||
delete SYS_DEBUG_CAN_USE_FAILAT;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief download
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
|
|
@ -247,7 +247,7 @@ var unregisterFunctionsGroup = function (group) {
|
|||
/// @fn JSF_aqlfunctions_register
|
||||
/// @brief register an AQL user function
|
||||
///
|
||||
/// @FUN{aqlfunctions.register(@FA{name}, @FA{code}, @FA{isDeterministic}, @FA{testValues})}
|
||||
/// @FUN{aqlfunctions.register(@FA{name}, @FA{code}, @FA{isDeterministic})}
|
||||
///
|
||||
/// Registers an AQL user function, identified by a fully qualified function
|
||||
/// name. The function code in @FA{code} must be specified as a Javascript
|
||||
|
@ -280,7 +280,7 @@ var registerFunction = function (name, code, isDeterministic) {
|
|||
var testCode = "(function() { var callback = " + code + "; return callback; })()";
|
||||
|
||||
try {
|
||||
var res = INTERNAL.executeScript(testCode, undefined, "(user function " + name + ")");
|
||||
var res = internal.executeScript(testCode, undefined, "(user function " + name + ")");
|
||||
}
|
||||
catch (err1) {
|
||||
var err = new ArangoError();
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
/*jslint indent: 2, nomen: true, maxlen: 120, vars: true, white: true, plusplus: true, nonpropdel: true, proto: true, regexp: true */
|
||||
/*global require, module, Module, ArangoError, SYS_DOWNLOAD,
|
||||
/*global require, module, Module, ArangoError, SYS_DEBUG_SET_FAILAT, SYS_DEBUG_REMOVE_FAILAT,
|
||||
SYS_DEBUG_CLEAR_FAILAT, SYS_DOWNLOAD,
|
||||
SYS_EXECUTE, SYS_LOAD, SYS_LOG_LEVEL, SYS_MD5, SYS_OUTPUT, SYS_PROCESS_STATISTICS,
|
||||
SYS_RAND, SYS_SERVER_STATISTICS, SYS_SPRINTF, SYS_TIME, SYS_START_PAGER, SYS_STOP_PAGER,
|
||||
SYS_SHA256, SYS_WAIT, SYS_PARSE, SYS_IMPORT_CSV_FILE, SYS_IMPORT_JSON_FILE, SYS_LOG,
|
||||
|
@ -216,6 +217,42 @@
|
|||
// --SECTION-- public functions
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief debugSetFailAt
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
if (typeof SYS_DEBUG_SET_FAILAT !== "undefined") {
|
||||
exports.debugSetFailAt = SYS_DEBUG_SET_FAILAT;
|
||||
delete SYS_DEBUG_SET_FAILAT;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief debugRemoveFailAt
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
if (typeof SYS_DEBUG_REMOVE_FAILAT !== "undefined") {
|
||||
exports.debugRemoveFailAt = SYS_DEBUG_REMOVE_FAILAT;
|
||||
delete SYS_DEBUG_REMOVE_FAILAT;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief debugClearFailAt
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
if (typeof SYS_DEBUG_CLEAR_FAILAT !== "undefined") {
|
||||
exports.debugClearFailAt = SYS_DEBUG_CLEAR_FAILAT;
|
||||
delete SYS_DEBUG_CLEAR_FAILAT;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief debugCanUseFailAt
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
if (typeof SYS_DEBUG_CAN_USE_FAILAT !== "undefined") {
|
||||
exports.debugCanUseFailAt = SYS_DEBUG_CAN_USE_FAILAT;
|
||||
delete SYS_DEBUG_CAN_USE_FAILAT;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief download
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
|
|
@ -130,6 +130,7 @@ typedef long suseconds_t;
|
|||
#define TRI_WITHIN_COMMON 1
|
||||
#include "BasicsC/voc-errors.h"
|
||||
#include "BasicsC/error.h"
|
||||
#include "BasicsC/debugging.h"
|
||||
#include "BasicsC/memory.h"
|
||||
#include "BasicsC/mimetypes.h"
|
||||
#include "BasicsC/structures.h"
|
||||
|
|
|
@ -0,0 +1,371 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief debugging helpers
|
||||
///
|
||||
/// @file
|
||||
///
|
||||
/// DISCLAIMER
|
||||
///
|
||||
/// Copyright 2004-2013 triAGENS GmbH, Cologne, Germany
|
||||
///
|
||||
/// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
/// you may not use this file except in compliance with the License.
|
||||
/// You may obtain a copy of the License at
|
||||
///
|
||||
/// http://www.apache.org/licenses/LICENSE-2.0
|
||||
///
|
||||
/// Unless required by applicable law or agreed to in writing, software
|
||||
/// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
/// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
/// See the License for the specific language governing permissions and
|
||||
/// limitations under the License.
|
||||
///
|
||||
/// Copyright holder is triAGENS GmbH, Cologne, Germany
|
||||
///
|
||||
/// @author Jan Steemann
|
||||
/// @author Copyright 2011-2013, triAGENS GmbH, Cologne, Germany
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "BasicsC/common.h"
|
||||
|
||||
#include "BasicsC/debugging.h"
|
||||
#include "BasicsC/locks.h"
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// --SECTION-- private variables
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @addtogroup Debugging
|
||||
/// @{
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief a global string containing the currently registered failure points
|
||||
/// the string is a comma-separated list of point names
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifdef TRI_ENABLE_MAINTAINER_MODE
|
||||
|
||||
static char* FailurePoints;
|
||||
|
||||
#endif
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief a read-write lock for thread-safe access to the failure-points list
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifdef TRI_ENABLE_MAINTAINER_MODE
|
||||
|
||||
TRI_read_write_lock_t FailurePointsLock;
|
||||
|
||||
#endif
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @}
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// --SECTION-- private functions
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @addtogroup Debugging
|
||||
/// @{
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief make a delimited value from a string, so we can unambigiously
|
||||
/// search for it (e.g. searching for just "foo" would find "foo" and "foobar",
|
||||
/// so we'll be putting the value inside some delimiter: ",foo,")
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifdef TRI_ENABLE_MAINTAINER_MODE
|
||||
|
||||
static char* MakeValue (char const* value) {
|
||||
char* delimited;
|
||||
|
||||
if (value == NULL || strlen(value) == 0) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
delimited = TRI_Allocate(TRI_CORE_MEM_ZONE, strlen(value) + 3, false);
|
||||
|
||||
if (delimited != NULL) {
|
||||
memcpy(delimited + 1, value, strlen(value));
|
||||
delimited[0] = ',';
|
||||
delimited[strlen(value) + 1] = ',';
|
||||
delimited[strlen(value) + 2] = '\0';
|
||||
}
|
||||
|
||||
return delimited;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @}
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// --SECTION-- public functions
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @addtogroup Debugging
|
||||
/// @{
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief check whether we should fail at a specific failure point
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifdef TRI_ENABLE_MAINTAINER_MODE
|
||||
|
||||
bool TRI_ShouldFailDebugging (char const* value) {
|
||||
char* found;
|
||||
char* checkValue;
|
||||
|
||||
checkValue = MakeValue(value);
|
||||
|
||||
if (checkValue == NULL) {
|
||||
return false;
|
||||
}
|
||||
|
||||
TRI_ReadLockReadWriteLock(&FailurePointsLock);
|
||||
|
||||
if (FailurePoints == NULL) {
|
||||
found = NULL;
|
||||
}
|
||||
else {
|
||||
found = strstr(FailurePoints, checkValue);
|
||||
}
|
||||
|
||||
TRI_ReadUnlockReadWriteLock(&FailurePointsLock);
|
||||
|
||||
TRI_Free(TRI_CORE_MEM_ZONE, checkValue);
|
||||
|
||||
return (found != NULL);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief add a failure point
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void TRI_AddFailurePointDebugging (char const* value) {
|
||||
|
||||
#ifdef TRI_ENABLE_MAINTAINER_MODE
|
||||
|
||||
char* found;
|
||||
char* checkValue;
|
||||
|
||||
checkValue = MakeValue(value);
|
||||
|
||||
if (checkValue == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
TRI_WriteLockReadWriteLock(&FailurePointsLock);
|
||||
|
||||
if (FailurePoints == NULL) {
|
||||
found = NULL;
|
||||
}
|
||||
else {
|
||||
found = strstr(FailurePoints, checkValue);
|
||||
}
|
||||
|
||||
if (found == NULL) {
|
||||
// not yet found. so add it
|
||||
char* copy;
|
||||
size_t n;
|
||||
|
||||
n = strlen(checkValue);
|
||||
|
||||
if (FailurePoints == NULL) {
|
||||
copy = TRI_Allocate(TRI_CORE_MEM_ZONE, n + 1, false);
|
||||
|
||||
if (copy == NULL) {
|
||||
TRI_WriteUnlockReadWriteLock(&FailurePointsLock);
|
||||
TRI_Free(TRI_CORE_MEM_ZONE, checkValue);
|
||||
return;
|
||||
}
|
||||
|
||||
memcpy(copy, checkValue, n);
|
||||
copy[n] = '\0';
|
||||
}
|
||||
else {
|
||||
copy = TRI_Allocate(TRI_CORE_MEM_ZONE, n + strlen(FailurePoints), false);
|
||||
|
||||
if (copy == NULL) {
|
||||
TRI_WriteUnlockReadWriteLock(&FailurePointsLock);
|
||||
TRI_Free(TRI_CORE_MEM_ZONE, checkValue);
|
||||
return;
|
||||
}
|
||||
|
||||
memcpy(copy, FailurePoints, strlen(FailurePoints));
|
||||
memcpy(copy + strlen(FailurePoints) - 1, checkValue, n);
|
||||
copy[strlen(FailurePoints) + n - 1] = '\0';
|
||||
}
|
||||
|
||||
FailurePoints = copy;
|
||||
}
|
||||
|
||||
TRI_WriteUnlockReadWriteLock(&FailurePointsLock);
|
||||
TRI_Free(TRI_CORE_MEM_ZONE, checkValue);
|
||||
|
||||
#else
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief remove a failure points
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void TRI_RemoveFailurePointDebugging (char const* value) {
|
||||
|
||||
#ifdef TRI_ENABLE_MAINTAINER_MODE
|
||||
|
||||
char* checkValue;
|
||||
|
||||
TRI_WriteLockReadWriteLock(&FailurePointsLock);
|
||||
|
||||
if (FailurePoints == NULL) {
|
||||
TRI_WriteUnlockReadWriteLock(&FailurePointsLock);
|
||||
return;
|
||||
}
|
||||
|
||||
checkValue = MakeValue(value);
|
||||
|
||||
if (checkValue != NULL) {
|
||||
char* found;
|
||||
char* copy;
|
||||
size_t n;
|
||||
|
||||
found = strstr(FailurePoints, checkValue);
|
||||
|
||||
if (found == NULL) {
|
||||
TRI_WriteUnlockReadWriteLock(&FailurePointsLock);
|
||||
TRI_Free(TRI_CORE_MEM_ZONE, checkValue);
|
||||
return;
|
||||
}
|
||||
|
||||
if (strlen(FailurePoints) - strlen(checkValue) <= 2) {
|
||||
TRI_Free(TRI_CORE_MEM_ZONE, FailurePoints);
|
||||
FailurePoints = NULL;
|
||||
|
||||
TRI_WriteUnlockReadWriteLock(&FailurePointsLock);
|
||||
TRI_Free(TRI_CORE_MEM_ZONE, checkValue);
|
||||
return;
|
||||
}
|
||||
|
||||
copy = TRI_Allocate(TRI_CORE_MEM_ZONE, strlen(FailurePoints) - strlen(checkValue) + 2, false);
|
||||
|
||||
if (copy == NULL) {
|
||||
TRI_WriteUnlockReadWriteLock(&FailurePointsLock);
|
||||
TRI_Free(TRI_CORE_MEM_ZONE, checkValue);
|
||||
return;
|
||||
}
|
||||
|
||||
// copy start of string
|
||||
n = found - FailurePoints;
|
||||
memcpy(copy, FailurePoints, n);
|
||||
|
||||
// copy remainder of string
|
||||
memcpy(copy + n, found + strlen(checkValue) - 1, strlen(FailurePoints) - strlen(checkValue) - n + 1);
|
||||
|
||||
copy[strlen(FailurePoints) - strlen(checkValue) + 1] = '\0';
|
||||
TRI_Free(TRI_CORE_MEM_ZONE, FailurePoints);
|
||||
FailurePoints = copy;
|
||||
|
||||
TRI_WriteUnlockReadWriteLock(&FailurePointsLock);
|
||||
TRI_Free(TRI_CORE_MEM_ZONE, checkValue);
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief clear all failure points
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void TRI_ClearFailurePointsDebugging () {
|
||||
#ifdef TRI_ENABLE_MAINTAINER_MODE
|
||||
|
||||
TRI_WriteLockReadWriteLock(&FailurePointsLock);
|
||||
|
||||
if (FailurePoints != NULL) {
|
||||
TRI_Free(TRI_CORE_MEM_ZONE, FailurePoints);
|
||||
}
|
||||
|
||||
FailurePoints = NULL;
|
||||
|
||||
TRI_WriteUnlockReadWriteLock(&FailurePointsLock);
|
||||
|
||||
#else
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief returns whether failure point debugging can be used
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
bool TRI_CanUseFailurePointsDebugging () {
|
||||
#ifdef TRI_ENABLE_MAINTAINER_MODE
|
||||
|
||||
return true;
|
||||
|
||||
#else
|
||||
|
||||
return false;
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief initialise the debugging
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void TRI_InitialiseDebugging () {
|
||||
#ifdef TRI_ENABLE_MAINTAINER_MODE
|
||||
|
||||
FailurePoints = NULL;
|
||||
TRI_InitReadWriteLock(&FailurePointsLock);
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief shutdown the debugging
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void TRI_ShutdownDebugging () {
|
||||
#ifdef TRI_ENABLE_MAINTAINER_MODE
|
||||
|
||||
if (FailurePoints != NULL) {
|
||||
TRI_Free(TRI_CORE_MEM_ZONE, FailurePoints);
|
||||
}
|
||||
|
||||
FailurePoints = NULL;
|
||||
|
||||
TRI_DestroyReadWriteLock(&FailurePointsLock);
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @}
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// --SECTION-- END-OF-FILE
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
// Local Variables:
|
||||
// mode: outline-minor
|
||||
// outline-regexp: "/// @brief\\|/// {@inheritDoc}\\|/// @addtogroup\\|/// @page\\|// --SECTION--\\|/// @\\}"
|
||||
// End:
|
|
@ -0,0 +1,137 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief debugging helpers
|
||||
///
|
||||
/// @file
|
||||
///
|
||||
/// DISCLAIMER
|
||||
///
|
||||
/// Copyright 2004-2013 triAGENS GmbH, Cologne, Germany
|
||||
///
|
||||
/// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
/// you may not use this file except in compliance with the License.
|
||||
/// You may obtain a copy of the License at
|
||||
///
|
||||
/// http://www.apache.org/licenses/LICENSE-2.0
|
||||
///
|
||||
/// Unless required by applicable law or agreed to in writing, software
|
||||
/// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
/// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
/// See the License for the specific language governing permissions and
|
||||
/// limitations under the License.
|
||||
///
|
||||
/// Copyright holder is triAGENS GmbH, Cologne, Germany
|
||||
///
|
||||
/// @author Jan Steemann
|
||||
/// @author Copyright 2011-2013, triAGENS GmbH, Cologne, Germany
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef TRIAGENS_BASICS_C_DEBUGGING_H
|
||||
#define TRIAGENS_BASICS_C_DEBUGGING_H 1
|
||||
|
||||
#ifndef TRI_WITHIN_COMMON
|
||||
#error use <BasicsC/common.h>
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// --SECTION-- public defines
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @addtogroup Debugging
|
||||
/// @{
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief macro TRI_DEBUG_INTENTIONAL_FAIL_IF
|
||||
/// this macro can be used in maintainer mode to make the server fail at
|
||||
/// certain locations in the C code. The points at which a failure is actually
|
||||
/// triggered can be defined at runtime using TRI_AddFailurePointDebugging().
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifdef TRI_ENABLE_MAINTAINER_MODE
|
||||
|
||||
#define TRI_DEBUG_INTENTIONAL_FAIL_IF(what) if (TRI_ShouldFailDebugging(what))
|
||||
|
||||
#else
|
||||
|
||||
#define TRI_DEBUG_INTENTIONAL_FAIL_IF(what) if (false)
|
||||
|
||||
#endif
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @}
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// --SECTION-- public functions
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @addtogroup Debugging
|
||||
/// @{
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief check whether we should fail at a failure point
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifdef TRI_ENABLE_MAINTAINER_MODE
|
||||
|
||||
bool TRI_ShouldFailDebugging (char const*);
|
||||
|
||||
#endif
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief add a failure point
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void TRI_AddFailurePointDebugging (char const*);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief remove a failure point
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void TRI_RemoveFailurePointDebugging (char const*);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief clear all failure points
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void TRI_ClearFailurePointsDebugging (void);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief returns whether failure point debugging can be used
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
bool TRI_CanUseFailurePointsDebugging (void);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief initialise the debugging
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void TRI_InitialiseDebugging (void);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief shutdown the debugging
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void TRI_ShutdownDebugging (void);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @}
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
// Local Variables:
|
||||
// mode: outline-minor
|
||||
// outline-regexp: "/// @brief\\|/// {@inheritDoc}\\|/// @addtogroup\\|/// @page\\|// --SECTION--\\|/// @\\}"
|
||||
// End:
|
|
@ -52,6 +52,7 @@
|
|||
|
||||
void TRI_InitialiseC (int argc, char* argv[]) {
|
||||
TRI_InitialiseMemory();
|
||||
TRI_InitialiseDebugging();
|
||||
TRI_InitialiseMersenneTwister();
|
||||
TRI_InitialiseError();
|
||||
TRI_InitialiseFiles();
|
||||
|
@ -78,6 +79,7 @@ void TRI_ShutdownC () {
|
|||
TRI_ShutdownMimetypes();
|
||||
TRI_ShutdownFiles();
|
||||
TRI_ShutdownError();
|
||||
TRI_ShutdownDebugging();
|
||||
TRI_ShutdownMemory();
|
||||
}
|
||||
|
||||
|
|
|
@ -39,6 +39,7 @@ lib_libarango_a_SOURCES = \
|
|||
lib/BasicsC/associative.c \
|
||||
lib/BasicsC/conversions.c \
|
||||
lib/BasicsC/csv.c \
|
||||
lib/BasicsC/debugging.c \
|
||||
lib/BasicsC/error.c \
|
||||
lib/BasicsC/files.c \
|
||||
lib/BasicsC/hashes.c \
|
||||
|
|
|
@ -1959,6 +1959,92 @@ static v8::Handle<v8::Value> JS_Wait (v8::Arguments const& argv) {
|
|||
return scope.Close(v8::Undefined());
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief set a failure point
|
||||
///
|
||||
/// @FUN{internal.debugSetFailAt(@FA{point})}
|
||||
///
|
||||
/// Set a point for an intentional system failure
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
static v8::Handle<v8::Value> JS_DebugSetFailAt (v8::Arguments const& argv) {
|
||||
v8::HandleScope scope;
|
||||
|
||||
// extract arguments
|
||||
if (argv.Length() != 1) {
|
||||
TRI_V8_EXCEPTION_USAGE(scope, "debugSetFailAt(<point>)");
|
||||
}
|
||||
|
||||
string point = TRI_ObjectToString(argv[0]);
|
||||
|
||||
TRI_AddFailurePointDebugging(point.c_str());
|
||||
|
||||
return scope.Close(v8::Undefined());
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief remove a failure point
|
||||
///
|
||||
/// @FUN{internal.debugRemoveFailAt(@FA{point})}
|
||||
///
|
||||
/// Remove a point for an intentional system failure
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
static v8::Handle<v8::Value> JS_DebugRemoveFailAt (v8::Arguments const& argv) {
|
||||
v8::HandleScope scope;
|
||||
|
||||
// extract arguments
|
||||
if (argv.Length() != 1) {
|
||||
TRI_V8_EXCEPTION_USAGE(scope, "debugRemoveFailAt(<point>)");
|
||||
}
|
||||
|
||||
string point = TRI_ObjectToString(argv[0]);
|
||||
|
||||
TRI_RemoveFailurePointDebugging(point.c_str());
|
||||
|
||||
return scope.Close(v8::Undefined());
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief clear all failure points
|
||||
///
|
||||
/// @FUN{internal.debugClearFailAt()}
|
||||
///
|
||||
/// Remove all points for intentional system failures
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
static v8::Handle<v8::Value> JS_DebugClearFailAt (v8::Arguments const& argv) {
|
||||
v8::HandleScope scope;
|
||||
|
||||
// extract arguments
|
||||
if (argv.Length() != 0) {
|
||||
TRI_V8_EXCEPTION_USAGE(scope, "debugClearFailAt()");
|
||||
}
|
||||
|
||||
TRI_ClearFailurePointsDebugging();
|
||||
|
||||
return scope.Close(v8::Undefined());
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief returns whether failure points can be used
|
||||
///
|
||||
/// @FUN{internal.debugCanUseFailAt()}
|
||||
///
|
||||
/// Returns whether failure points can be be used
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
static v8::Handle<v8::Value> JS_DebugCanUseFailAt (v8::Arguments const& argv) {
|
||||
v8::HandleScope scope;
|
||||
|
||||
// extract arguments
|
||||
if (argv.Length() != 0) {
|
||||
TRI_V8_EXCEPTION_USAGE(scope, "debugCanUseFailAt()");
|
||||
}
|
||||
|
||||
return scope.Close(TRI_CanUseFailurePointsDebugging() ? v8::True() : v8::False());
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief returns the current request and connection statistics
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -2481,6 +2567,12 @@ void TRI_InitV8Utils (v8::Handle<v8::Context> context,
|
|||
TRI_AddGlobalFunctionVocbase(context, "SYS_TIME", JS_Time);
|
||||
TRI_AddGlobalFunctionVocbase(context, "SYS_WAIT", JS_Wait);
|
||||
|
||||
// debugging functions
|
||||
TRI_AddGlobalFunctionVocbase(context, "SYS_DEBUG_SET_FAILAT", JS_DebugSetFailAt);
|
||||
TRI_AddGlobalFunctionVocbase(context, "SYS_DEBUG_REMOVE_FAILAT", JS_DebugRemoveFailAt);
|
||||
TRI_AddGlobalFunctionVocbase(context, "SYS_DEBUG_CLEAR_FAILAT", JS_DebugClearFailAt);
|
||||
TRI_AddGlobalFunctionVocbase(context, "SYS_DEBUG_CAN_USE_FAILAT", JS_DebugCanUseFailAt);
|
||||
|
||||
// .............................................................................
|
||||
// create the global variables
|
||||
// .............................................................................
|
||||
|
|
Loading…
Reference in New Issue