`debug output` C++ Examples

25 C++ code examples are found related to "debug output". You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example.
Example 1
Source File: OllyExceptionHandler.cpp    From ScyllaHide with GNU General Public License v3.0 7 votes vote down vote up
void handleOutputDebugString( LPDEBUG_EVENT lpDebugEvent )
{
	if (lpDebugEvent->u.DebugString.nDebugStringLength > 0 && lpDebugEvent->u.DebugString.lpDebugStringData != 0)
	{
		HANDLE hProcess = OpenProcess(PROCESS_VM_READ, 0, lpDebugEvent->dwProcessId);

		if (hProcess)
		{
			if (lpDebugEvent->u.DebugString.nDebugStringLength < sizeof(OutputDebugStringBuffer))
			{
				ZeroMemory(OutputDebugStringBuffer, sizeof(OutputDebugStringBuffer));
				if (ReadProcessMemory(hProcess, lpDebugEvent->u.DebugString.lpDebugStringData, OutputDebugStringBuffer, lpDebugEvent->u.DebugString.nDebugStringLength, NULL))
				{
					g_log.LogInfo(L"Debug String: %S", OutputDebugStringBuffer);
				}
			}
			else
			{
                g_log.LogInfo(L"Debug String is too long: %d", lpDebugEvent->u.DebugString.nDebugStringLength);
			}
			CloseHandle(hProcess);
		}
	} 
Example 2
Source File: OutputDebugStringAPI.cpp    From khaleesi with GNU General Public License v2.0 7 votes vote down vote up
BOOL OutputDebugStringAPI()
{

	BOOL IsDbgPresent = FALSE;
	DWORD Val = 0x29A;

	// This is working only in Windows XP/2000
	if (IsWindowsXPOr2k())
	{
		hash_SetLastError(Val);
		hash_OutputDebugStringW(_T("random"));

		if (hash_GetLastError() == Val)
			IsDbgPresent = TRUE;
	}

	return IsDbgPresent;
} 
Example 3
Source File: YapDebugger.cpp    From YAP with MIT License 6 votes vote down vote up
void CProcessorDebugger::DebugOutput(IProcessor& processor)
{
	auto processor_id = processor.GetClassId();
	wcout << L"Processor: " << wstring(processor_id) << endl;
	auto inputs = processor.Inputs();
	if (inputs != nullptr)
	{
		wcout << L"In port(s): \n";
		auto iter = YapDynamic(inputs->GetIterator());
		if (iter)
		{
			DebugPort(*iter);
		}
	}
	else
	{ 
Example 4
Source File: ProcessorDebugger.cpp    From YAP with MIT License 6 votes vote down vote up
void YapDebugger::DebugOutput(IProcessor& processor)
{
	auto processor_id = processor.GetClassId();
	wcout << L"Processor: " << wstring(processor_id) << endl;
	auto inputs = processor.Inputs();
	if (inputs != nullptr)
	{
		wcout << L"In port(s): \n";
		auto iter = YapDynamic(inputs->GetIterator());
		if (iter)
		{
			DebugPort(*iter);
		}
	}
	else
	{ 
Example 5
Source File: OutputDebugAppender.cpp    From dtkcore with GNU Lesser General Public License v3.0 6 votes vote down vote up
DCORE_BEGIN_NAMESPACE

/**
 * \class OutputDebugAppender
 *
 * \brief Appender that writes the log records to the Microsoft Debug Log
 */


//! Writes the log record to the windows debug log.
/**
 * \sa AbstractStringAppender::format()
 */
void OutputDebugAppender::append(const QDateTime& timeStamp,
                                 Logger::LogLevel logLevel,
                                 const char* file,
                                 int line,
                                 const char* function,
                                 const QString& category,
                                 const QString& message)
{
    QString s = formattedString(timeStamp, logLevel, file, line, function, category, message);
    OutputDebugStringW((LPCWSTR) s.utf16());
} 
Example 6
Source File: EventUtils.cpp    From orbit with BSD 2-Clause "Simplified" License 6 votes vote down vote up
void EventUtils::OutputDebugEvent(PEVENT_RECORD pEvent) {
  DWORD status = ERROR_SUCCESS;
  PTRACE_EVENT_INFO pInfo = NULL;
  LPWSTR pwsEventGuid = NULL;
  PBYTE pUserData = NULL;
  PBYTE pEndOfUserData = NULL;
  DWORD PointerSize = 0;
  ULONGLONG TimeStamp = 0;
  ULONGLONG Nanoseconds = 0;
  SYSTEMTIME st;
  SYSTEMTIME stLocal;
  FILETIME ft;

  // Skips the event if it is the event trace header. Log files contain this
  // event but real-time sessions do not. The event contains the same
  // information as the EVENT_TRACE_LOGFILE.LogfileHeader member that you can
  // access when you open the trace.

  if (IsEqualGUID(pEvent->EventHeader.ProviderId, EventTraceGuid) &&
      pEvent->EventHeader.EventDescriptor.Opcode == EVENT_TRACE_TYPE_INFO) {
    ;  // Skip this event.
  } else { 
Example 7
Source File: syslog.cpp    From FarManager with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
static void FarOutputDebugString(const wchar_t* Str)
{
	if (IsDebuggerPresent())
	{
		OutputDebugString(Str);
		OutputDebugString(L"\n");
	}
} 
Example 8
Source File: PVRTError.cpp    From BlueshiftEngine with Apache License 2.0 5 votes vote down vote up
void PVRTErrorOutputDebug(char const * const format, ...)
{
	va_list arg;
	char	pszString[1024];

	va_start(arg, format);
	vsnprintf(pszString, 1024, format, arg);
	va_end(arg);


#if defined(UNICODE)
	wchar_t *pswzString = (wchar_t *)malloc((strlen(pszString) + 1) * sizeof(wchar_t));

	int i;
	for(i = 0; pszString[i] != '\0'; i++)
	{
		pswzString[i] = (wchar_t)(pszString[i]);
	}
	pswzString[i] = '\0';

	#if defined(_WIN32)
        OutputDebugString(pswzString);
    #elif defined(ANDROID)
        __android_log_print(ANDROID_LOG_ERROR, "PVRTools", "%s", pswzString);
    #else
        fprintf(stderr, pswzString);
    #endif

    free(pswzString);
#else
    #if defined(_WIN32)
        OutputDebugString(pszString);
    #elif defined(ANDROID)
        __android_log_print(ANDROID_LOG_ERROR, "PVRTools", "%s", pszString);
    #else
        fprintf(stderr, "%s", pszString);
    #endif
#endif
} 
Example 9
Source File: colour_tracker.cpp    From Correlation_Filtering_Tracking_Lib with GNU General Public License v3.0 5 votes vote down vote up
(_DEBUG_OUTPUT)
    {
        if (CV_MAJOR_VERSION < 3)
        {
            std::cout << "ScaleEstimator: Using OpenCV Version: " << CV_MAJOR_VERSION << std::endl;
            std::cout << "For more speed use 3.0 or higher!" << std::endl;
        }
    } 
Example 10
Source File: logging.cpp    From uchain-fullnode with GNU Affero General Public License v3.0 5 votes vote down vote up
void initialize_logging(bc::ofstream &debug, bc::ofstream &error,
                        std::ostream &output_stream, std::ostream &error_stream,
                        std::string level)
{
    using namespace std::placeholders;

    auto debug_log_level = log::level::debug;
    if (level == "INFO" || level == "info")
        debug_log_level = log::level::info;
    else if 
Example 11
Source File: Log.cpp    From megamol with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
void vislib::sys::Log::DebugOutputTarget::Msg(UINT level,
        vislib::sys::Log::TimeStamp time, vislib::sys::Log::SourceID sid,
        const char *msg) {
    if (level > this->Level()) return;
    char tmp[21];
    tmp[0] = tmp[20] = 0;
    _snprintf_s(tmp, 20, 20, "%.4d|", level);
    ::OutputDebugStringA(tmp);
    ::OutputDebugStringA(msg);
} 
Example 12
Source File: main.cpp    From directx12_samples with MIT License 5 votes vote down vote up
void DebugOutputFormatString(const char* format , ...) {
#ifdef _DEBUG
	va_list valist;
	va_start(valist, format);
	printf(format, valist);
	va_end(valist);
#endif
} 
Example 13
Source File: debugger.cpp    From twinject with GNU General Public License v3.0 5 votes vote down vote up
DWORD OnOutputDebugStringEvent(const LPDEBUG_EVENT debug_event)
{
	CStringW strEventMessage;
	OUTPUT_DEBUG_STRING_INFO & DebugString = debug_event->u.DebugString;
	WCHAR *msg = new WCHAR[DebugString.nDebugStringLength];

	ReadProcessMemory(pi.hProcess, DebugString.lpDebugStringData, msg, DebugString.nDebugStringLength, NULL);

	if (DebugString.fUnicode)
		strEventMessage = msg;
	else 
Example 14
Source File: MiNiFiWindowsService.cpp    From nifi-minifi-cpp with Apache License 2.0 5 votes vote down vote up
static void OutputDebug(const char* format, ...) {
  va_list args;
  va_start(args, format);

  char buf[256];
  sprintf_s(buf, _countof(buf), "%s: %s", SERVICE_NAME, format);

  char out[1024];
  StringCbVPrintfA(out, sizeof(out), buf, args);

  OutputDebugStringA(out);

  va_end(args);
} 
Example 15
Source File: logging.cpp    From metaverse with GNU Affero General Public License v3.0 5 votes vote down vote up
void initialize_logging(bc::ofstream& debug, bc::ofstream& error,
    std::ostream& output_stream, std::ostream& error_stream,
    std::string level)
{
    using namespace std::placeholders;

    auto debug_log_level = log::level::debug;
    if (level == "INFO" || level == "info")
        debug_log_level = log::level::info;
    else if 
Example 16
Source File: example_chat.cpp    From GameNetworkingSockets with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
static void DebugOutput( ESteamNetworkingSocketsDebugOutputType eType, const char *pszMsg )
{
	SteamNetworkingMicroseconds time = SteamNetworkingUtils()->GetLocalTimestamp() - g_logTimeZero;
	printf( "%10.6f %s\n", time*1e-6, pszMsg );
	fflush(stdout);
	if ( eType == k_ESteamNetworkingSocketsDebugOutputType_Bug )
	{
		fflush(stdout);
		fflush(stderr);
		NukeProcess(1);
	}
} 
Example 17
Source File: GLDebug.cpp    From nCine with MIT License 5 votes vote down vote up
void GLDebug::enableDebugOutput()
{
#if ((defined(__ANDROID__) && __ANDROID_API__ >= 21) || defined(WITH_ANGLE)) && !defined(__APPLE__) && !defined(__EMSCRIPTEN__) && GL_ES_VERSION_3_0
	glEnable(GL_DEBUG_OUTPUT_SYNCHRONOUS);
	glDebugMessageCallback(static_cast<GLDEBUGPROC>(debugCallback), nullptr);

	LOGI("OpenGL debug callback set");
#endif
} 
Example 18
Source File: scard_debug_dump.cc    From chromeos_smart_card_connector with Apache License 2.0 5 votes vote down vote up
std::string DebugDumpSCardOutputReaderStates(
    const SCARD_READERSTATE* begin, DWORD count) {
  if (!begin)
    return "NULL";
  std::string result;
  for (DWORD index = 0; index < count; ++index) {
    if (!result.empty())
      result += ", ";
    result += DebugDumpSCardOutputReaderState(begin[index]);
  }
  return HexDumpPointer(begin) + "([" + result + "])";
} 
Example 19
Source File: scard_debug_dump.cc    From chromeos_smart_card_connector with Apache License 2.0 5 votes vote down vote up
std::string DebugDumpSCardOutputReaderState(const SCARD_READERSTATE& value) {
  return "SCARD_READERSTATE(szReader=" + DebugDumpSCardCString(value.szReader) +
      ", pvUserData=" + HexDumpPointer(value.pvUserData) + ", dwCurrentState=" +
      DebugDumpSCardEventState(value.dwCurrentState) + ", dwEventState=" +
      DebugDumpSCardEventState(value.dwEventState) + ", cbAtr=" +
      std::to_string(value.cbAtr) + ", rgbAtr=<" +
      HexDumpBytes(value.rgbAtr, value.cbAtr) + ">)";
} 
Example 20
Source File: ftdebug.c    From c_cpp_compiler with GNU General Public License v3.0 5 votes vote down vote up
void
  OutputDebugStringEx( const char*  str )
  {
    static WCHAR  buf[8192];


    int sz = MultiByteToWideChar( CP_ACP, 0, str, -1, buf,
                                  sizeof ( buf ) / sizeof ( *buf ) );
    if ( !sz )
      lstrcpyW( buf, L"OutputDebugStringEx: MultiByteToWideChar failed" );

    OutputDebugStringW( buf );
  } 
Example 21
Source File: logging.cpp    From tinychain with GNU General Public License v2.0 5 votes vote down vote up
void initialize_logging(std::ofstream& debug, std::ofstream& error,
    std::ostream& output_stream, std::ostream& error_stream, 
    std::string level)
{
    using namespace std::placeholders;

    auto debug_log_level = log::level::debug;
    if (level == "INFO" || level == "info") 
        debug_log_level = log::level::info;
    else if 
Example 22
Source File: OutputInstr.cpp    From brain with GNU General Public License v3.0 5 votes vote down vote up
void OutputInstr::debug_description(int level)
{
    std::cout.width(level);
    if (ArgsOptions::instance()->has_option(BO_IS_VERBOSE)) {
        std::cout << "Output Instruction - print out char"
                  << std::endl;
    }
    else { 
Example 23
Source File: generator.cpp    From L4G_Core with GNU General Public License v2.0 5 votes vote down vote up
bool handleArgs(int argc, char** argv,
               int &mapnum,
               int &tileX,
               int &tileY,
               float &maxAngle,
               bool &skipLiquid,
               bool &skipContinents,
               bool &skipJunkMaps,
               bool &skipBattlegrounds,
               bool &debugOutput,
               bool &silent,
               bool &bigBaseUnit,
               char* &offMeshInputPath)
{
    char* param = NULL;
    for (int i = 1; i < argc; ++i)
    {
        if (strcmp(argv[i], "--maxAngle") == 0)
        {
            param = argv[++i];
            if (!param)
                return false;

            float maxangle = atof(param);
            if (maxangle <= 90.f && maxangle >= 45.f)
                maxAngle = maxangle;
            else
                printf("invalid option for '--maxAngle', using default\n");
        }
        else if 
Example 24
Source File: GLWidget.cpp    From HiveWE with MIT License 4 votes vote down vote up
void APIENTRY gl_debug_output(const GLenum source, const GLenum type, const GLuint id, const GLenum severity, const GLsizei, const GLchar *message, void *) {
	// Skip buffer info messages, framebuffer info messages, texture usage state warning, redundant state change buffer
	if (id == 131185 // ?
		|| id == 131169 // ?
		|| id == 131204 // ?
		|| id == 8 // ?
		|| id == 131218) // Unexplainable performance warnings
	{
		return;
	}

	std::cout << "---------------" << std::endl;
	std::cout << "Debug message (" << id << "): " << message << std::endl;

	switch (source) {
		case GL_DEBUG_SOURCE_API:             std::cout << "Source: API"; break;
		case GL_DEBUG_SOURCE_WINDOW_SYSTEM:   std::cout << "Source: Window System"; break;
		case GL_DEBUG_SOURCE_SHADER_COMPILER: std::cout << "Source: Shader Compiler"; break;
		case GL_DEBUG_SOURCE_THIRD_PARTY:     std::cout << "Source: Third Party"; break;
		case GL_DEBUG_SOURCE_APPLICATION:     std::cout << "Source: Application"; break;
		case GL_DEBUG_SOURCE_OTHER:           std::cout << "Source: Other"; break;
		default: break;
	}
	std::cout << std::endl;

	switch (type) {
		case GL_DEBUG_TYPE_ERROR:               std::cout << "Type: Error"; break;
		case GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR: std::cout << "Type: Deprecated Behaviour"; break;
		case GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR:  std::cout << "Type: Undefined Behaviour"; break;
		case GL_DEBUG_TYPE_PORTABILITY:         std::cout << "Type: Portability"; break;
		case GL_DEBUG_TYPE_PERFORMANCE:         std::cout << "Type: Performance"; break;
		case GL_DEBUG_TYPE_MARKER:              std::cout << "Type: Marker"; break;
		case GL_DEBUG_TYPE_PUSH_GROUP:          std::cout << "Type: Push Group"; break;
		case GL_DEBUG_TYPE_POP_GROUP:           std::cout << "Type: Pop Group"; break;
		case GL_DEBUG_TYPE_OTHER:               std::cout << "Type: Other"; break;
		default: break;
	}
	std::cout << std::endl;

	switch (severity) {
		case GL_DEBUG_SEVERITY_HIGH:         std::cout << "Severity: high"; break;
		case GL_DEBUG_SEVERITY_MEDIUM:       std::cout << "Severity: medium"; break;
		case GL_DEBUG_SEVERITY_LOW:          std::cout << "Severity: low"; break;
		case GL_DEBUG_SEVERITY_NOTIFICATION: std::cout << "Severity: notification"; break;
		default: break;
	}
	std::cout << std::endl;
} 
Example 25
Source File: utils.cpp    From rewind-viewer with MIT License 4 votes vote down vote up
void APIENTRY debug_output_callback(GLenum source, GLenum type, GLuint id, GLenum severity,
                                    GLsizei, const GLchar *message, const void *) {

    // ignore non-significant error/warning codes
    if (id == 131169 || id == 131185 || id == 131218 || id == 131204) {
        return;
    }

    LOG_WARN("Debug message (%ud): %s", id, message);

    //@formatter:off
    switch (source)
    {
        case GL_DEBUG_SOURCE_API_ARB:             fprintf(stderr, "Source: API"); break;
        case GL_DEBUG_SOURCE_WINDOW_SYSTEM_ARB:   fprintf(stderr, "Source: Window System"); break;
        case GL_DEBUG_SOURCE_SHADER_COMPILER_ARB: fprintf(stderr, "Source: Shader Compiler"); break;
        case GL_DEBUG_SOURCE_THIRD_PARTY_ARB:     fprintf(stderr, "Source: Third Party"); break;
        case GL_DEBUG_SOURCE_APPLICATION_ARB:     fprintf(stderr, "Source: Application"); break;
        case GL_DEBUG_SOURCE_OTHER_ARB:           fprintf(stderr, "Source: Other"); break;
        default: break;
    }
    fprintf(stderr, "\n");

    switch (type)
    {
        case GL_DEBUG_TYPE_ERROR_ARB:               fprintf(stderr, "Type: Error"); break;
        case GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR_ARB: fprintf(stderr, "Type: Deprecated Behaviour"); break;
        case GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR_ARB:  fprintf(stderr, "Type: Undefined Behaviour"); break;
        case GL_DEBUG_TYPE_PORTABILITY_ARB:         fprintf(stderr, "Type: Portability"); break;
        case GL_DEBUG_TYPE_PERFORMANCE_ARB:         fprintf(stderr, "Type: Performance"); break;
        case GL_DEBUG_TYPE_OTHER_ARB:               fprintf(stderr, "Type: Other"); break;
        default: break;
    }
    fprintf(stderr, "\n");

    switch (severity)
    {
        case GL_DEBUG_SEVERITY_HIGH_ARB:         fprintf(stderr, "Severity: high"); break;
        case GL_DEBUG_SEVERITY_MEDIUM_ARB:       fprintf(stderr, "Severity: medium"); break;
        case GL_DEBUG_SEVERITY_LOW_ARB:          fprintf(stderr, "Severity: low"); break;
        default: break;
    }
    fprintf(stderr, "\n");
    //@formatter:on
}