mirror of
https://github.com/FirebirdSQL/firebird.git
synced 2025-01-24 04:03:03 +01:00
Better error diagnostics for trace configuration.
This commit is contained in:
parent
1180330b05
commit
deb6f181d5
@ -165,7 +165,7 @@ private:
|
|||||||
}
|
}
|
||||||
|
|
||||||
ntrace_attach_t ntrace_attach;
|
ntrace_attach_t ntrace_attach;
|
||||||
char module[64];
|
char module[MAXPATHLEN];
|
||||||
};
|
};
|
||||||
static Firebird::GlobalPtr<Firebird::Array<ModuleInfo> > modules;
|
static Firebird::GlobalPtr<Firebird::Array<ModuleInfo> > modules;
|
||||||
static Firebird::GlobalPtr<Firebird::Mutex> init_modules_mtx;
|
static Firebird::GlobalPtr<Firebird::Mutex> init_modules_mtx;
|
||||||
|
@ -47,8 +47,8 @@ void TraceCfgReader::readTraceConfiguration(const char* text,
|
|||||||
|
|
||||||
#define PATH_PARAMETER(NAME, VALUE) \
|
#define PATH_PARAMETER(NAME, VALUE) \
|
||||||
if (!found && el->name == #NAME) { \
|
if (!found && el->name == #NAME) { \
|
||||||
string temp = el->getAttributeName(0); \
|
string temp; \
|
||||||
expandPattern(temp); \
|
expandPattern(el, temp); \
|
||||||
m_config.NAME = temp.c_str(); \
|
m_config.NAME = temp.c_str(); \
|
||||||
found = true; \
|
found = true; \
|
||||||
}
|
}
|
||||||
@ -59,12 +59,12 @@ void TraceCfgReader::readTraceConfiguration(const char* text,
|
|||||||
}
|
}
|
||||||
#define BOOL_PARAMETER(NAME, VALUE) \
|
#define BOOL_PARAMETER(NAME, VALUE) \
|
||||||
if (!found && el->name == #NAME) { \
|
if (!found && el->name == #NAME) { \
|
||||||
m_config.NAME = parseBoolean(el->getAttributeName(0)); \
|
m_config.NAME = parseBoolean(el); \
|
||||||
found = true; \
|
found = true; \
|
||||||
}
|
}
|
||||||
#define UINT_PARAMETER(NAME, VALUE) \
|
#define UINT_PARAMETER(NAME, VALUE) \
|
||||||
if (!found && el->name == #NAME) { \
|
if (!found && el->name == #NAME) { \
|
||||||
m_config.NAME = parseUInteger(el->getAttributeName(0)); \
|
m_config.NAME = parseUInteger(el); \
|
||||||
found = true; \
|
found = true; \
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -248,30 +248,35 @@ void TraceCfgReader::readConfig()
|
|||||||
#undef BOOL_PARAMETER
|
#undef BOOL_PARAMETER
|
||||||
#undef UINT_PARAMETER
|
#undef UINT_PARAMETER
|
||||||
|
|
||||||
bool TraceCfgReader::parseBoolean(const string& value) const
|
bool TraceCfgReader::parseBoolean(const Element* el) const
|
||||||
{
|
{
|
||||||
string tempValue = value;
|
const char* value = el->getAttributeName(0);
|
||||||
|
string tempValue(value);
|
||||||
tempValue.upper();
|
tempValue.upper();
|
||||||
if (value == "1" || tempValue == "ON" || tempValue == "YES" || tempValue == "TRUE")
|
if (tempValue == "1" || tempValue == "ON" || tempValue == "YES" || tempValue == "TRUE")
|
||||||
return true;
|
return true;
|
||||||
if (value == "0" || tempValue == "OFF" || tempValue == "NO" || tempValue == "FALSE")
|
if (tempValue == "0" || tempValue == "OFF" || tempValue == "NO" || tempValue == "FALSE")
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
fatal_exception::raiseFmt("\"%s\" is not a valid boolean value", value.c_str());
|
fatal_exception::raiseFmt("line %d, element \"%s\": \"%s\" is not a valid boolean value",
|
||||||
|
el->lineNumber + 1, el->name.c_str(), value);
|
||||||
return false; // Silence the compiler
|
return false; // Silence the compiler
|
||||||
}
|
}
|
||||||
|
|
||||||
ULONG TraceCfgReader::parseUInteger(const string& value) const
|
ULONG TraceCfgReader::parseUInteger(const Element* el) const
|
||||||
{
|
{
|
||||||
|
const char *value = el->getAttributeName(0);
|
||||||
ULONG result = 0;
|
ULONG result = 0;
|
||||||
if (!sscanf(value.c_str(), "%"ULONGFORMAT, &result)) {
|
if (!sscanf(value, "%"ULONGFORMAT, &result)) {
|
||||||
fatal_exception::raiseFmt("\"%s\" is not a valid integer value", value.c_str());
|
fatal_exception::raiseFmt("line %d, element \"%s\": \"%s\" is not a valid integer value",
|
||||||
|
el->lineNumber + 1, el->name.c_str(), value);
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TraceCfgReader::expandPattern(string& valueToExpand)
|
void TraceCfgReader::expandPattern(const Element* el, string& valueToExpand)
|
||||||
{
|
{
|
||||||
|
valueToExpand = el->getAttributeName(0);
|
||||||
string::size_type pos = 0;
|
string::size_type pos = 0;
|
||||||
while (pos < valueToExpand.length())
|
while (pos < valueToExpand.length())
|
||||||
{
|
{
|
||||||
@ -279,7 +284,8 @@ void TraceCfgReader::expandPattern(string& valueToExpand)
|
|||||||
if (c == '\\')
|
if (c == '\\')
|
||||||
{
|
{
|
||||||
if (pos + 1 >= valueToExpand.length())
|
if (pos + 1 >= valueToExpand.length())
|
||||||
fatal_exception::raiseFmt("pattern is invalid");
|
fatal_exception::raiseFmt("line %d, element \"%s\": pattern is invalid\n\t %s",
|
||||||
|
el->lineNumber + 1, el->name.c_str(), el->getAttributeName(0));
|
||||||
|
|
||||||
c = valueToExpand[pos + 1];
|
c = valueToExpand[pos + 1];
|
||||||
if (c == '\\')
|
if (c == '\\')
|
||||||
@ -306,7 +312,8 @@ void TraceCfgReader::expandPattern(string& valueToExpand)
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
fatal_exception::raiseFmt("pattern is invalid");
|
fatal_exception::raiseFmt("line %d, element \"%s\": pattern is invalid\n\t %s",
|
||||||
|
el->lineNumber + 1, el->name.c_str(), el->getAttributeName(0));
|
||||||
}
|
}
|
||||||
|
|
||||||
pos++;
|
pos++;
|
||||||
|
@ -62,9 +62,9 @@ private:
|
|||||||
|
|
||||||
void readConfig();
|
void readConfig();
|
||||||
|
|
||||||
void expandPattern(Firebird::string& valueToExpand);
|
void expandPattern(const Element* el, Firebird::string& valueToExpand);
|
||||||
bool parseBoolean(const Firebird::string& value) const;
|
bool parseBoolean(const Element* el) const;
|
||||||
ULONG parseUInteger(const Firebird::string& value) const;
|
ULONG parseUInteger(const Element* el) const;
|
||||||
|
|
||||||
const char* const m_text;
|
const char* const m_text;
|
||||||
const Firebird::PathName& m_databaseName;
|
const Firebird::PathName& m_databaseName;
|
||||||
|
Loading…
Reference in New Issue
Block a user