mirror of
https://github.com/Telecominfraproject/wlan-cloud-lib-poco.git
synced 2025-11-02 19:48:00 +00:00
set eol-style to native
This commit is contained in:
@@ -1,165 +1,165 @@
|
||||
//
|
||||
// Debugger.cpp
|
||||
//
|
||||
// $Id: //poco/1.2/Foundation/src/Debugger.cpp#1 $
|
||||
//
|
||||
// Library: Foundation
|
||||
// Package: Core
|
||||
// Module: Debugger
|
||||
//
|
||||
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person or organization
|
||||
// obtaining a copy of the software and accompanying documentation covered by
|
||||
// this license (the "Software") to use, reproduce, display, distribute,
|
||||
// execute, and transmit the Software, and to prepare derivative works of the
|
||||
// Software, and to permit third-parties to whom the Software is furnished to
|
||||
// do so, all subject to the following:
|
||||
//
|
||||
// The copyright notices in the Software and this entire statement, including
|
||||
// the above license grant, this restriction and the following disclaimer,
|
||||
// must be included in all copies of the Software, in whole or in part, and
|
||||
// all derivative works of the Software, unless such copies or derivative
|
||||
// works are solely in the form of machine-executable object code generated by
|
||||
// a source language processor.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
|
||||
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
|
||||
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
|
||||
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
|
||||
|
||||
#include "Poco/Debugger.h"
|
||||
#include <sstream>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#if defined(POCO_OS_FAMILY_WINDOWS)
|
||||
#include <windows.h>
|
||||
#elif defined(POCO_OS_FAMILY_UNIX)
|
||||
#include <unistd.h>
|
||||
#include <signal.h>
|
||||
#elif defined(POCO_OS_FAMILY_VMS)
|
||||
#include <lib$routines.h>
|
||||
#include <ssdef.h>
|
||||
#endif
|
||||
#if defined(POCO_WIN32_UTF8)
|
||||
#include "Poco/UnicodeConverter.h"
|
||||
#endif
|
||||
|
||||
|
||||
// NOTE: In this module, we use the C library functions (fputs) for,
|
||||
// output since, at the time we're called, the C++ iostream objects std::cout, etc.
|
||||
// might not have been initialized yet.
|
||||
|
||||
|
||||
namespace Poco {
|
||||
|
||||
|
||||
bool Debugger::isAvailable()
|
||||
{
|
||||
#if defined(_DEBUG)
|
||||
#if defined(POCO_OS_FAMILY_WINDOWS)
|
||||
return IsDebuggerPresent() ? true : false;
|
||||
#elif defined(POCO_OS_FAMILY_UNIX)
|
||||
return getenv("POCO_ENABLE_DEBUGGER") ? true : false;
|
||||
#elif defined(POCO_OS_FAMILY_VMS)
|
||||
return true;
|
||||
#endif
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
void Debugger::message(const std::string& msg)
|
||||
{
|
||||
#if defined(_DEBUG)
|
||||
fputs("\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n", stderr);
|
||||
fputs(msg.c_str(), stderr);
|
||||
fputs("\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n", stderr);
|
||||
#if defined(POCO_OS_FAMILY_WINDOWS)
|
||||
if (IsDebuggerPresent())
|
||||
{
|
||||
#if defined(POCO_WIN32_UTF8)
|
||||
std::wstring umsg;
|
||||
UnicodeConverter::toUTF16(msg, umsg);
|
||||
umsg += '\n';
|
||||
OutputDebugStringW(umsg.c_str());
|
||||
#else
|
||||
OutputDebugString(msg.c_str());
|
||||
OutputDebugString("\n");
|
||||
#endif
|
||||
}
|
||||
#elif defined(POCO_OS_FAMILY_UNIX)
|
||||
#elif defined(POCO_OS_FAMILY_VMS)
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
void Debugger::message(const std::string& msg, const char* file, int line)
|
||||
{
|
||||
#if defined(_DEBUG)
|
||||
std::ostringstream str;
|
||||
str << msg << " [in file \"" << file << "\", line " << line << "]";
|
||||
message(str.str());
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
void Debugger::enter()
|
||||
{
|
||||
#if defined(_DEBUG)
|
||||
#if defined(POCO_OS_FAMILY_WINDOWS)
|
||||
if (IsDebuggerPresent())
|
||||
{
|
||||
DebugBreak();
|
||||
}
|
||||
#elif defined(POCO_OS_FAMILY_UNIX)
|
||||
if (isAvailable())
|
||||
{
|
||||
kill(getpid(), SIGINT);
|
||||
}
|
||||
#elif defined(POCO_OS_FAMILY_VMS)
|
||||
{
|
||||
const char* cmd = "\012SHOW CALLS";
|
||||
lib$signal(SS$_DEBUG, 1, cmd);
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
void Debugger::enter(const std::string& msg)
|
||||
{
|
||||
#if defined(_DEBUG)
|
||||
message(msg);
|
||||
enter();
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
void Debugger::enter(const std::string& msg, const char* file, int line)
|
||||
{
|
||||
#if defined(_DEBUG)
|
||||
message(msg, file, line);
|
||||
enter();
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
void Debugger::enter(const char* file, int line)
|
||||
{
|
||||
#if defined(_DEBUG)
|
||||
message("BREAK", file, line);
|
||||
enter();
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
} // namespace Poco
|
||||
//
|
||||
// Debugger.cpp
|
||||
//
|
||||
// $Id: //poco/1.2/Foundation/src/Debugger.cpp#1 $
|
||||
//
|
||||
// Library: Foundation
|
||||
// Package: Core
|
||||
// Module: Debugger
|
||||
//
|
||||
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person or organization
|
||||
// obtaining a copy of the software and accompanying documentation covered by
|
||||
// this license (the "Software") to use, reproduce, display, distribute,
|
||||
// execute, and transmit the Software, and to prepare derivative works of the
|
||||
// Software, and to permit third-parties to whom the Software is furnished to
|
||||
// do so, all subject to the following:
|
||||
//
|
||||
// The copyright notices in the Software and this entire statement, including
|
||||
// the above license grant, this restriction and the following disclaimer,
|
||||
// must be included in all copies of the Software, in whole or in part, and
|
||||
// all derivative works of the Software, unless such copies or derivative
|
||||
// works are solely in the form of machine-executable object code generated by
|
||||
// a source language processor.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
|
||||
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
|
||||
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
|
||||
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
|
||||
|
||||
#include "Poco/Debugger.h"
|
||||
#include <sstream>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#if defined(POCO_OS_FAMILY_WINDOWS)
|
||||
#include <windows.h>
|
||||
#elif defined(POCO_OS_FAMILY_UNIX)
|
||||
#include <unistd.h>
|
||||
#include <signal.h>
|
||||
#elif defined(POCO_OS_FAMILY_VMS)
|
||||
#include <lib$routines.h>
|
||||
#include <ssdef.h>
|
||||
#endif
|
||||
#if defined(POCO_WIN32_UTF8)
|
||||
#include "Poco/UnicodeConverter.h"
|
||||
#endif
|
||||
|
||||
|
||||
// NOTE: In this module, we use the C library functions (fputs) for,
|
||||
// output since, at the time we're called, the C++ iostream objects std::cout, etc.
|
||||
// might not have been initialized yet.
|
||||
|
||||
|
||||
namespace Poco {
|
||||
|
||||
|
||||
bool Debugger::isAvailable()
|
||||
{
|
||||
#if defined(_DEBUG)
|
||||
#if defined(POCO_OS_FAMILY_WINDOWS)
|
||||
return IsDebuggerPresent() ? true : false;
|
||||
#elif defined(POCO_OS_FAMILY_UNIX)
|
||||
return getenv("POCO_ENABLE_DEBUGGER") ? true : false;
|
||||
#elif defined(POCO_OS_FAMILY_VMS)
|
||||
return true;
|
||||
#endif
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
void Debugger::message(const std::string& msg)
|
||||
{
|
||||
#if defined(_DEBUG)
|
||||
fputs("\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n", stderr);
|
||||
fputs(msg.c_str(), stderr);
|
||||
fputs("\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n", stderr);
|
||||
#if defined(POCO_OS_FAMILY_WINDOWS)
|
||||
if (IsDebuggerPresent())
|
||||
{
|
||||
#if defined(POCO_WIN32_UTF8)
|
||||
std::wstring umsg;
|
||||
UnicodeConverter::toUTF16(msg, umsg);
|
||||
umsg += '\n';
|
||||
OutputDebugStringW(umsg.c_str());
|
||||
#else
|
||||
OutputDebugString(msg.c_str());
|
||||
OutputDebugString("\n");
|
||||
#endif
|
||||
}
|
||||
#elif defined(POCO_OS_FAMILY_UNIX)
|
||||
#elif defined(POCO_OS_FAMILY_VMS)
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
void Debugger::message(const std::string& msg, const char* file, int line)
|
||||
{
|
||||
#if defined(_DEBUG)
|
||||
std::ostringstream str;
|
||||
str << msg << " [in file \"" << file << "\", line " << line << "]";
|
||||
message(str.str());
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
void Debugger::enter()
|
||||
{
|
||||
#if defined(_DEBUG)
|
||||
#if defined(POCO_OS_FAMILY_WINDOWS)
|
||||
if (IsDebuggerPresent())
|
||||
{
|
||||
DebugBreak();
|
||||
}
|
||||
#elif defined(POCO_OS_FAMILY_UNIX)
|
||||
if (isAvailable())
|
||||
{
|
||||
kill(getpid(), SIGINT);
|
||||
}
|
||||
#elif defined(POCO_OS_FAMILY_VMS)
|
||||
{
|
||||
const char* cmd = "\012SHOW CALLS";
|
||||
lib$signal(SS$_DEBUG, 1, cmd);
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
void Debugger::enter(const std::string& msg)
|
||||
{
|
||||
#if defined(_DEBUG)
|
||||
message(msg);
|
||||
enter();
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
void Debugger::enter(const std::string& msg, const char* file, int line)
|
||||
{
|
||||
#if defined(_DEBUG)
|
||||
message(msg, file, line);
|
||||
enter();
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
void Debugger::enter(const char* file, int line)
|
||||
{
|
||||
#if defined(_DEBUG)
|
||||
message("BREAK", file, line);
|
||||
enter();
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
} // namespace Poco
|
||||
|
||||
Reference in New Issue
Block a user