Files
allwpilib/wpilibc/wpilibC++/include/Utility.h
Thomas Clark 89fe909ae6 Added stack traces and better error reporting in C++
When an error is reported or an assertion fails in C++, a line is now
printed with information about where the error occured, and a stack trace
is printed.

The stacktrace isn't implemented in the HAL because it's not
hardware-dependent, so StackTrace.hpp and StackTrace.cpp are gone.

The Eclipse project template is modified to include "-export-dynamic" in
the linker options, which is necessary for stack traces.

Change-Id: Ie86c14185b13ed603d0fe6467e87ba4f731b1913
2014-07-28 16:35:45 -04:00

37 lines
2.0 KiB
C++

/*---------------------------------------------------------------------------*/
/* Copyright (c) FIRST 2008. All Rights Reserved. */
/* Open Source Software - may be modified and shared by FRC teams. The code */
/* must be accompanied by the FIRST BSD license file in $(WIND_BASE)/WPILib. */
/*---------------------------------------------------------------------------*/
#pragma once
#include "HAL/HAL.hpp"
#include <string>
#define wpi_assert(condition) wpi_assert_impl(condition, #condition, NULL, __FILE__, __LINE__, __FUNCTION__)
#define wpi_assertWithMessage(condition, message) wpi_assert_impl(condition, #condition, message, __FILE__, __LINE__, __FUNCTION__)
#define wpi_assertEqual(a, b) wpi_assertEqual_impl(a, b, #a, #b, NULL, __FILE__, __LINE__, __FUNCTION__)
#define wpi_assertEqualWithMessage(a, b, message) wpi_assertEqual_impl(a, b, #a, #b, message, __FILE__, __LINE__, __FUNCTION__)
#define wpi_assertNotEqual(a, b) wpi_assertNotEqual_impl(a, b, #a, #b, NULL, __FILE__, __LINE__, __FUNCTION__)
#define wpi_assertNotEqualWithMessage(a, b, message) wpi_assertNotEqual_impl(a, b, #a, #b, message, __FILE__, __LINE__, __FUNCTION__)
bool wpi_assert_impl(bool conditionValue, const char *conditionText, const char *message, const char *fileName, uint32_t lineNumber, const char *funcName);
bool wpi_assertEqual_impl(int valueA, int valueB, const char *valueAString, const char *valueBString, const char *message, const char *fileName,uint32_t lineNumber, const char *funcName);
bool wpi_assertNotEqual_impl(int valueA, int valueB, const char *valueAString, const char *valueBString, const char *message, const char *fileName,uint32_t lineNumber, const char *funcName);
void wpi_suspendOnAssertEnabled(bool enabled);
uint16_t GetFPGAVersion();
uint32_t GetFPGARevision();
uint32_t GetFPGATime();
int32_t GetRIOUserSwitch();
void SetRIOUserLED(uint32_t state);
int32_t GetRIOUserLED();
int32_t ToggleRIOUserLED();
void SetRIO_FPGA_LED(uint32_t state);
int32_t GetRIO_FPGA_LED();
int32_t ToggleRIO_FPGA_LED();
std::string GetStackTrace(uint32_t offset);