libexo/sc7fw: support release/debug/audit

This commit is contained in:
Michael Scire
2020-11-14 12:17:38 -08:00
parent f74527d93c
commit 71a38ae74d
14 changed files with 413 additions and 47 deletions

View File

@@ -0,0 +1,93 @@
/*
* Copyright (c) 2018-2020 Atmosphère-NX
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
void AbortImpl(const char *file, int line, const char *func, const char *expr, u64 value) {
#if defined(AMS_ENABLE_DETAILED_ASSERTIONS)
{
AMS_LOG("Abort Called\n");
AMS_LOG(" Location: %s:%d\n", file, line);
AMS_LOG(" Function: %s\n", func);
AMS_LOG(" Expression: %s\n", expr);
AMS_LOG(" Value: %016" PRIx64 "\n", value);
AMS_LOG("\n");
}
#else
AMS_UNUSED(file, line, func, expr, value);
#endif
AbortImpl();
}
void AbortImpl(const char *file, int line, const char *func, const char *expr, u64 value, const char *format, ...) {
#if defined(AMS_ENABLE_DETAILED_ASSERTIONS)
{
AMS_LOG("Abort Called\n");
AMS_LOG(" Location: %s:%d\n", file, line);
AMS_LOG(" Function: %s\n", func);
AMS_LOG(" Expression: %s\n", expr);
AMS_LOG(" Value: %016" PRIx64 "\n", value);
AMS_LOG("\n");
{
::std::va_list vl;
va_start(vl, format);
AMS_VLOG(format, vl);
va_end(vl);
AMS_LOG("\n");
}
}
#else
AMS_UNUSED(file, line, func, expr, value, format);
#endif
AbortImpl();
}
void AssertionFailureImpl(const char *file, int line, const char *func, const char *expr, u64 value) {
#if defined(AMS_ENABLE_DETAILED_ASSERTIONS)
{
AMS_LOG("Assertion Failure\n");
AMS_LOG(" Location: %s:%d\n", file, line);
AMS_LOG(" Function: %s\n", func);
AMS_LOG(" Expression: %s\n", expr);
AMS_LOG(" Value: %016" PRIx64 "\n", value);
AMS_LOG("\n");
}
#else
AMS_UNUSED(file, line, func, expr, value);
#endif
AbortImpl();
}
void AssertionFailureImpl(const char *file, int line, const char *func, const char *expr, u64 value, const char *format, ...) {
#if defined(AMS_ENABLE_DETAILED_ASSERTIONS)
{
AMS_LOG("Assertion Failure\n");
AMS_LOG(" Location: %s:%d\n", file, line);
AMS_LOG(" Function: %s\n", func);
AMS_LOG(" Expression: %s\n", expr);
AMS_LOG(" Value: %016" PRIx64 "\n", value);
AMS_LOG("\n");
{
::std::va_list vl;
va_start(vl, format);
AMS_VLOG(format, vl);
va_end(vl);
AMS_LOG("\n");
}
}
#else
AMS_UNUSED(file, line, func, expr, value, format);
#endif
AbortImpl();
}

View File

@@ -18,10 +18,30 @@
namespace ams::log {
#if defined(AMS_BUILD_FOR_AUDITING) || defined(AMS_BUILD_FOR_DEBUGGING)
#define AMS_IMPL_ENABLE_LOG
#endif
#if defined(AMS_IMPL_ENABLE_LOG)
#define AMS_LOG(...) ::ams::log::Printf(__VA_ARGS__)
#define AMS_VLOG(...) ::ams::log::VPrintf(__VA_ARGS__)
#define AMS_DUMP(...) ::ams::log::Dump(__VA_ARGS__)
#define AMS_LOG_FLUSH() ::ams::log::Flush()
#else
#define AMS_LOG(...) static_cast<void>(0)
#define AMS_VLOG(...) static_cast<void>(0)
#define AMS_DUMP(...) static_cast<void>(0)
#define AMS_LOG_FLUSH() static_cast<void>(0)
#endif
void Initialize();
void Finalize();
void Printf(const char *fmt, ...) __attribute__((format(printf, 1, 2)));
void VPrintf(const char *fmt, ::std::va_list vl);
void Dump(const void *src, size_t size);
void SendText(const void *text, size_t size);
void Flush();
}
}

View File

@@ -0,0 +1,20 @@
/*
* Copyright (c) 2018-2020 Atmosphère-NX
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <vapours.hpp>
#include <exosphere/log.hpp>
#define AMS_SECMON_LOG(...) AMS_LOG(" [secmon] " __VA_ARGS__)