mirror of
https://github.com/Atmosphere-NX/Atmosphere.git
synced 2025-04-22 20:44:49 +00:00
More requested changes
This commit is contained in:
parent
eee6f92556
commit
35f21a95fd
20 changed files with 77 additions and 73 deletions
|
@ -15,7 +15,4 @@
|
|||
*/
|
||||
#pragma once
|
||||
|
||||
#include <stratosphere/diag/diag_log_observer.hpp>
|
||||
#include <stratosphere/diag/diag_log_types.hpp>
|
||||
#include <stratosphere/diag/detail/diag_detail_log.hpp>
|
||||
#include <stratosphere/diag/detail/diag_detail_string.hpp>
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
#pragma once
|
||||
#include <stratosphere/diag/diag_log_types.hpp>
|
||||
|
||||
namespace ams::diag::detail {
|
||||
namespace ams::diag::impl {
|
||||
|
||||
void LogImpl(const LogMetaData &log_metadata, const char *fmt, ...) __attribute__((format(printf, 2, 3)));
|
||||
void VLogImpl(const LogMetaData &log_metadata, const char *fmt, std::va_list vl);
|
||||
|
@ -31,7 +31,7 @@ namespace ams::diag::detail {
|
|||
}, \
|
||||
.log_severity = ::ams::diag::LogSeverity_Info \
|
||||
}; \
|
||||
::ams::diag::detail::LogImpl(log_metadata, fmt, __VA_ARGS__); \
|
||||
::ams::diag::impl::LogImpl(log_metadata, fmt, __VA_ARGS__); \
|
||||
})
|
||||
|
||||
}
|
|
@ -16,9 +16,9 @@
|
|||
#pragma once
|
||||
#include <vapours.hpp>
|
||||
|
||||
namespace ams::diag::detail {
|
||||
namespace ams::diag::impl {
|
||||
|
||||
void PrintDebugString(const char *str, size_t len);
|
||||
ssize_t GetValidSizeAsUtf8String(const char *str, size_t len);
|
||||
int GetValidSizeAsUtf8String(const char *str, int len);
|
||||
|
||||
}
|
|
@ -17,5 +17,5 @@
|
|||
#pragma once
|
||||
#include <vapours.hpp>
|
||||
#include <stratosphere/lm/lm_api.hpp>
|
||||
#include <stratosphere/lm/detail/lm_detail_log_types.hpp>
|
||||
#include <stratosphere/lm/detail/lm_detail_log_packet_transmitter.hpp>
|
||||
#include <stratosphere/lm/impl/lm_impl_log_types.hpp>
|
||||
#include <stratosphere/lm/impl/lm_impl_log_packet_transmitter.hpp>
|
||||
|
|
|
@ -14,9 +14,9 @@
|
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#pragma once
|
||||
#include <stratosphere/lm/detail/lm_detail_log_types.hpp>
|
||||
#include <stratosphere/lm/impl/lm_impl_log_types.hpp>
|
||||
|
||||
namespace ams::lm::detail {
|
||||
namespace ams::lm::impl {
|
||||
|
||||
class LogPacketTransmitterBase {
|
||||
NON_COPYABLE(LogPacketTransmitterBase);
|
|
@ -16,7 +16,7 @@
|
|||
#pragma once
|
||||
#include <stratosphere/diag/diag_log_types.hpp>
|
||||
|
||||
namespace ams::lm::detail {
|
||||
namespace ams::lm::impl {
|
||||
|
||||
enum LogPacketFlags {
|
||||
LogPacketFlags_Head = (1 << 0),
|
|
@ -14,10 +14,11 @@
|
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#include <stratosphere.hpp>
|
||||
#include <stratosphere/diag/diag_log_observer.hpp>
|
||||
|
||||
namespace ams::diag {
|
||||
|
||||
namespace detail {
|
||||
namespace impl {
|
||||
|
||||
extern LogObserverHolder g_default_log_observer;
|
||||
extern LogObserverHolder *g_log_observer_list_head;
|
||||
|
@ -36,9 +37,9 @@ namespace ams::diag {
|
|||
void RegisterLogObserver(LogObserverHolder *observer_holder) {
|
||||
AMS_ASSERT(!observer_holder->is_registered);
|
||||
|
||||
if (detail::g_log_observer_list_head) {
|
||||
if (impl::g_log_observer_list_head) {
|
||||
/* Find the last registered observer and append this one. */
|
||||
auto observer = detail::g_log_observer_list_head;
|
||||
auto observer = impl::g_log_observer_list_head;
|
||||
LogObserverHolder *observer_parent = nullptr;
|
||||
do {
|
||||
observer_parent = observer;
|
||||
|
@ -48,7 +49,7 @@ namespace ams::diag {
|
|||
}
|
||||
else {
|
||||
/* There are no observers yet, this will be the first one. */
|
||||
detail::g_log_observer_list_head = observer_holder;
|
||||
impl::g_log_observer_list_head = observer_holder;
|
||||
}
|
||||
observer_holder->is_registered = true;
|
||||
observer_holder->next = nullptr;
|
||||
|
@ -57,13 +58,13 @@ namespace ams::diag {
|
|||
void UnregisterLogObserver(LogObserverHolder *observer_holder) {
|
||||
AMS_ASSERT(observer_holder->is_registered);
|
||||
|
||||
if (observer_holder == detail::g_log_observer_list_head) {
|
||||
if (observer_holder == impl::g_log_observer_list_head) {
|
||||
/* Move the next item to be the list head. */
|
||||
detail::g_log_observer_list_head = observer_holder->next;
|
||||
impl::g_log_observer_list_head = observer_holder->next;
|
||||
}
|
||||
else {
|
||||
/* Find this observer's parent observer and move the following observer, removing the observer. */
|
||||
auto observer = detail::g_log_observer_list_head;
|
||||
auto observer = impl::g_log_observer_list_head;
|
||||
while (observer) {
|
||||
auto observer_parent = observer;
|
||||
observer = observer->next;
|
||||
|
@ -77,13 +78,13 @@ namespace ams::diag {
|
|||
}
|
||||
|
||||
void ResetDefaultLogObserver() {
|
||||
ReplaceDefaultLogObserver(detail::DefaultLogObserver);
|
||||
ReplaceDefaultLogObserver(impl::DefaultLogObserver);
|
||||
}
|
||||
|
||||
void ReplaceDefaultLogObserver(LogFunction log_function) {
|
||||
UnregisterLogObserver(std::addressof(detail::g_default_log_observer));
|
||||
InitializeLogObserverHolder(std::addressof(detail::g_default_log_observer), log_function, nullptr);
|
||||
RegisterLogObserver(std::addressof(detail::g_default_log_observer));
|
||||
UnregisterLogObserver(std::addressof(impl::g_default_log_observer));
|
||||
InitializeLogObserverHolder(std::addressof(impl::g_default_log_observer), log_function, nullptr);
|
||||
RegisterLogObserver(std::addressof(impl::g_default_log_observer));
|
||||
}
|
||||
|
||||
}
|
|
@ -14,8 +14,9 @@
|
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#include <stratosphere.hpp>
|
||||
#include <stratosphere/diag/impl/diag_impl_string.hpp>
|
||||
|
||||
namespace ams::diag::detail {
|
||||
namespace ams::diag::impl {
|
||||
|
||||
namespace {
|
||||
|
||||
|
@ -68,7 +69,7 @@ namespace ams::diag::detail {
|
|||
|
||||
const auto max_buffer_size = sizeof(g_default_log_observer_text_buffer) - used_buffer_space - (color_type != nullptr ? std::strlen(color_type) - 1 : 0);
|
||||
|
||||
const auto log_text_size = std::min<size_t>(max_buffer_size, log_body.text_length);
|
||||
auto log_text_size = std::min<size_t>(max_buffer_size, log_body.text_length);
|
||||
if (log_body.text_length && (log_body.text[log_body.text_length - 1] == '\n')) {
|
||||
/* If the last character is a newline character, skip it. */
|
||||
log_text_size--;
|
|
@ -14,8 +14,11 @@
|
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#include <stratosphere.hpp>
|
||||
#include <stratosphere/diag/diag_log_observer.hpp>
|
||||
#include <stratosphere/diag/impl/diag_impl_log.hpp>
|
||||
#include <stratosphere/diag/impl/diag_impl_string.hpp>
|
||||
|
||||
namespace ams::diag::detail {
|
||||
namespace ams::diag::impl {
|
||||
|
||||
namespace {
|
||||
|
||||
|
@ -36,7 +39,7 @@ namespace ams::diag::detail {
|
|||
break;
|
||||
}
|
||||
|
||||
auto copy_len = std::min(static_cast<size_t>(chars_len), static_cast<size_t>(print_data->print_str_end - print_data->print_str_cur));
|
||||
const auto copy_len = std::min(static_cast<size_t>(chars_len), static_cast<size_t>(print_data->print_str_end - print_data->print_str_cur));
|
||||
std::memcpy(print_data->print_str_cur, chars, copy_len);
|
||||
chars_len -= copy_len;
|
||||
chars += copy_len;
|
||||
|
@ -47,7 +50,7 @@ namespace ams::diag::detail {
|
|||
}
|
||||
if (!print_data->log_metadata.use_default_locale_charset) {
|
||||
const auto cur_print_str_len = static_cast<size_t>(print_data->print_str_cur - print_data->print_str_start);
|
||||
auto actual_print_str_len = GetValidSizeAsUtf8String(print_data->print_str_start, cur_print_str_len);
|
||||
const auto actual_print_str_len = GetValidSizeAsUtf8String(print_data->print_str_start, cur_print_str_len);
|
||||
if (actual_print_str_len < cur_print_str_len) {
|
||||
auto print_str_cur_end = print_data->print_str_start + actual_print_str_len;
|
||||
*print_str_cur_end = '\0';
|
|
@ -15,21 +15,21 @@
|
|||
*/
|
||||
#include <stratosphere.hpp>
|
||||
|
||||
namespace ams::diag::detail {
|
||||
namespace ams::diag::impl {
|
||||
|
||||
void PrintDebugString(const char *str, size_t len) {
|
||||
AMS_ASSERT(str && len);
|
||||
svc::OutputDebugString(str, len);
|
||||
}
|
||||
|
||||
ssize_t GetValidSizeAsUtf8String(const char *str, size_t len) {
|
||||
int GetValidSizeAsUtf8String(const char *str, int len) {
|
||||
AMS_ABORT_UNLESS(str != nullptr);
|
||||
if (len == 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
auto str_nul_end = str + len;
|
||||
auto str_end = str + len - 1;
|
||||
const char *str_nul_end = str + len;
|
||||
const char *str_end = str + len - 1;
|
||||
|
||||
char some_c = '\0';
|
||||
do {
|
||||
|
@ -39,9 +39,9 @@ namespace ams::diag::detail {
|
|||
some_c = *str_end--;
|
||||
} while ((some_c & 0xC0) == 0x80);
|
||||
|
||||
size_t tmp_len = 0;
|
||||
int tmp_len = 0;
|
||||
if (!(some_c & 0x80)) {
|
||||
tmp_len = static_cast<size_t>(str_nul_end - (str_end + 1));
|
||||
tmp_len = static_cast<int>(str_nul_end - (str_end + 1));
|
||||
if (tmp_len < 1) {
|
||||
return len;
|
||||
}
|
||||
|
@ -53,7 +53,7 @@ namespace ams::diag::detail {
|
|||
|
||||
|
||||
if ((some_c & 0xE0) == 0xC0) {
|
||||
tmp_len = static_cast<size_t>(str_nul_end - (str_end + 1));
|
||||
tmp_len = static_cast<int>(str_nul_end - (str_end + 1));
|
||||
if (tmp_len >= 2) {
|
||||
if (tmp_len == 2) {
|
||||
return len;
|
||||
|
@ -66,7 +66,7 @@ namespace ams::diag::detail {
|
|||
if ((some_c & 0xF8) != 0xF0) {
|
||||
return -1;
|
||||
}
|
||||
tmp_len = static_cast<size_t>(str_nul_end - (str_end + 1));
|
||||
tmp_len = static_cast<int>(str_nul_end - (str_end + 1));
|
||||
if (tmp_len < 4) {
|
||||
if (tmp_len < len) {
|
||||
return len - tmp_len;
|
||||
|
@ -79,7 +79,7 @@ namespace ams::diag::detail {
|
|||
}
|
||||
return 1;
|
||||
}
|
||||
tmp_len = static_cast<size_t>(str_nul_end - (str_end + 1));
|
||||
tmp_len = static_cast<int>(str_nul_end - (str_end + 1));
|
||||
if (tmp_len >= 3) {
|
||||
if (tmp_len == 3) {
|
||||
return len;
|
|
@ -15,14 +15,14 @@
|
|||
*/
|
||||
#include <stratosphere.hpp>
|
||||
|
||||
namespace ams::lm::detail {
|
||||
namespace ams::lm::impl {
|
||||
|
||||
namespace {
|
||||
|
||||
os::SdkMutex g_log_observer_lock;
|
||||
u8 g_packet_transmitter_buffer[0x400];
|
||||
|
||||
bool LogPacketTransmitterFlushFunction(const void *log_data, size_t log_data_size) {
|
||||
bool LogPacketTransmitterFlushFunction(const u8 *log_data, size_t log_data_size) {
|
||||
/* TODO: libnx bindings. */
|
||||
return true;
|
||||
}
|
||||
|
@ -80,7 +80,7 @@ namespace ams::lm::detail {
|
|||
/*
|
||||
const char *process_name;
|
||||
size_t process_name_len;
|
||||
diag::detail::GetProcessNamePointer(std::addressof(process_name), std::addressof(process_name_len));
|
||||
diag::impl::GetProcessNamePointer(std::addressof(process_name), std::addressof(process_name_len));
|
||||
packet_transmitter.PushProcessName(process_name, process_name_len);
|
||||
*/
|
||||
}
|
|
@ -1,6 +1,7 @@
|
|||
#include <stratosphere.hpp>
|
||||
#include <stratosphere/diag/impl/diag_impl_string.hpp>
|
||||
|
||||
namespace ams::lm::detail {
|
||||
namespace ams::lm::impl {
|
||||
|
||||
LogPacketTransmitterBase::LogPacketTransmitterBase(void *log_buffer, size_t log_buffer_size, LogPacketTransmitterBase::FlushFunction flush_func, u8 severity, u8 verbosity, u64 process_id, bool head, bool tail) {
|
||||
AMS_ABORT_UNLESS(log_buffer != nullptr);
|
||||
|
@ -8,10 +9,10 @@ namespace ams::lm::detail {
|
|||
AMS_ABORT_UNLESS(flush_func != nullptr);
|
||||
|
||||
this->header = reinterpret_cast<LogPacketHeader*>(log_buffer);
|
||||
this->log_buffer_start = log_buffer;
|
||||
this->log_buffer_end = log_buffer + log_buffer_size;
|
||||
this->log_buffer_payload_start = log_buffer + sizeof(LogPacketHeader);
|
||||
this->log_buffer_payload_current = log_buffer + sizeof(LogPacketHeader);
|
||||
this->log_buffer_start = reinterpret_cast<u8*>(log_buffer);
|
||||
this->log_buffer_end = this->log_buffer_start + log_buffer_size;
|
||||
this->log_buffer_payload_start = this->log_buffer_start + sizeof(LogPacketHeader);
|
||||
this->log_buffer_payload_current = this->log_buffer_start + sizeof(LogPacketHeader);
|
||||
this->is_tail = tail;
|
||||
this->flush_function = flush_func;
|
||||
this->header->SetProcessId(process_id);
|
||||
|
@ -83,7 +84,7 @@ namespace ams::lm::detail {
|
|||
size_t data_chunk_size = 0;
|
||||
if (is_string) {
|
||||
auto tmp_chunk_size = cur_pushable_size;
|
||||
auto utf8_size = diag::detail::GetValidSizeAsUtf8String(reinterpret_cast<const char*>(data_cur), tmp_chunk_size);
|
||||
auto utf8_size = diag::impl::GetValidSizeAsUtf8String(reinterpret_cast<const char*>(data_cur), tmp_chunk_size);
|
||||
if (utf8_size >= 0) {
|
||||
tmp_chunk_size = static_cast<size_t>(utf8_size);
|
||||
}
|
|
@ -14,10 +14,11 @@
|
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#include <stratosphere.hpp>
|
||||
#include <stratosphere/diag/diag_log_observer.hpp>
|
||||
|
||||
namespace ams::lm {
|
||||
|
||||
namespace detail {
|
||||
namespace impl {
|
||||
|
||||
void LogManagerLogObserver(const diag::LogMetaData &log_metadata, const diag::LogBody &log_body, void *user_data);
|
||||
|
||||
|
@ -36,7 +37,7 @@ namespace ams::lm {
|
|||
/* R_ABORT_UNLESS(lmInitialize()); */
|
||||
|
||||
/* Log by default via LogManager. */
|
||||
diag::ReplaceDefaultLogObserver(detail::LogManagerLogObserver);
|
||||
diag::ReplaceDefaultLogObserver(impl::LogManagerLogObserver);
|
||||
g_initialized = true;
|
||||
}
|
||||
|
||||
|
|
|
@ -66,7 +66,7 @@ namespace ams::lm::impl {
|
|||
return std::addressof(custom_sink_buffer);
|
||||
}
|
||||
|
||||
void WriteLogToCustomSink(const detail::LogPacketHeader *log_packet_header, size_t log_packet_size, u64 unk_param) {
|
||||
void WriteLogToCustomSink(const impl::LogPacketHeader *log_packet_header, size_t log_packet_size, u64 unk_param) {
|
||||
/* Process ID value is set earlier, so it's guaranteed to be valid. */
|
||||
if (log_packet_header->GetProcessId() != g_sink_buffer_current_process_id) {
|
||||
/* We're starting to log from a different process, so we need first a head packet. */
|
||||
|
@ -82,11 +82,11 @@ namespace ams::lm::impl {
|
|||
}
|
||||
}
|
||||
|
||||
auto log_payload_start = reinterpret_cast<const u8*>(log_packet_header) + sizeof(detail::LogPacketHeader);
|
||||
auto log_payload_start = reinterpret_cast<const u8*>(log_packet_header) + sizeof(impl::LogPacketHeader);
|
||||
auto log_payload_cur = log_payload_start;
|
||||
|
||||
/* No need to check packet header's payload size, since it has already been validated. */
|
||||
auto log_payload_size = log_packet_size - sizeof(detail::LogPacketHeader);
|
||||
auto log_payload_size = log_packet_size - sizeof(impl::LogPacketHeader);
|
||||
if (logging_in_same_thread && (g_sink_buffer_remaining_size > 0)) {
|
||||
auto log_remaining_size = log_payload_size;
|
||||
if (log_payload_size >= g_sink_buffer_remaining_size) {
|
||||
|
@ -105,8 +105,8 @@ namespace ams::lm::impl {
|
|||
if (log_payload_size) {
|
||||
auto log_payload_end = log_payload_start + log_payload_size;
|
||||
while (true) {
|
||||
const auto chunk_key = static_cast<detail::LogDataChunkKey>(PopUleb128(std::addressof(log_payload_cur), log_payload_end));
|
||||
const auto chunk_is_text_log = chunk_key == detail::LogDataChunkKey_TextLog;
|
||||
const auto chunk_key = static_cast<impl::LogDataChunkKey>(PopUleb128(std::addressof(log_payload_cur), log_payload_end));
|
||||
const auto chunk_is_text_log = chunk_key == impl::LogDataChunkKey_TextLog;
|
||||
const auto chunk_size = PopUleb128(std::addressof(log_payload_cur), log_payload_end);
|
||||
auto left_payload_size = static_cast<size_t>(log_payload_end - log_payload_cur);
|
||||
if (chunk_size >= left_payload_size) {
|
||||
|
|
|
@ -46,7 +46,7 @@ namespace ams::lm::impl {
|
|||
|
||||
CustomSinkBuffer *GetCustomSinkBuffer();
|
||||
|
||||
void WriteLogToCustomSink(const detail::LogPacketHeader *log_packet_header, size_t log_packet_size, u64 unk_param);
|
||||
void WriteLogToCustomSink(const impl::LogPacketHeader *log_packet_header, size_t log_packet_size, u64 unk_param);
|
||||
size_t ReadLogFromCustomSink(void *out_log_data, size_t data_size, u64 *out_packet_drop_count);
|
||||
|
||||
}
|
|
@ -14,9 +14,9 @@ namespace ams::lm::impl {
|
|||
|
||||
bool EventLogTransmitter::SendLogSessionBeginPacket(u64 process_id) {
|
||||
/* ------------ Log buffer size: packet header (0x18) + chunk header (0x2) + LogSessionBegin dummy value (0x1) = 0x1B */
|
||||
constexpr auto log_buffer_size = sizeof(detail::LogPacketHeader) + 2 + sizeof(u8);
|
||||
constexpr auto log_buffer_size = sizeof(impl::LogPacketHeader) + 2 + sizeof(u8);
|
||||
u8 log_buffer[log_buffer_size] = {};
|
||||
detail::LogPacketTransmitter log_packet_transmitter(log_buffer, log_buffer_size, this->flush_func, diag::LogSeverity_Info, false, process_id, true, true);
|
||||
impl::LogPacketTransmitter log_packet_transmitter(log_buffer, log_buffer_size, this->flush_func, diag::LogSeverity_Info, false, process_id, true, true);
|
||||
log_packet_transmitter.PushLogSessionBegin();
|
||||
|
||||
const auto ok = log_packet_transmitter.Flush(true);
|
||||
|
@ -28,9 +28,9 @@ namespace ams::lm::impl {
|
|||
|
||||
bool EventLogTransmitter::SendLogSessionEndPacket(u64 process_id) {
|
||||
/* ------------ Log buffer size: packet header (0x18) + chunk header (0x2) + LogSessionEnd dummy value (0x1) = 0x1B */
|
||||
constexpr auto log_buffer_size = sizeof(detail::LogPacketHeader) + 2 + sizeof(u8);
|
||||
constexpr auto log_buffer_size = sizeof(impl::LogPacketHeader) + 2 + sizeof(u8);
|
||||
u8 log_buffer[log_buffer_size] = {};
|
||||
detail::LogPacketTransmitter log_packet_transmitter(log_buffer, log_buffer_size, this->flush_func, diag::LogSeverity_Info, false, process_id, true, true);
|
||||
impl::LogPacketTransmitter log_packet_transmitter(log_buffer, log_buffer_size, this->flush_func, diag::LogSeverity_Info, false, process_id, true, true);
|
||||
log_packet_transmitter.PushLogSessionEnd();
|
||||
|
||||
const auto ok = log_packet_transmitter.Flush(true);
|
||||
|
@ -46,9 +46,9 @@ namespace ams::lm::impl {
|
|||
/* Only send the log packet if there were any dropped packets. */
|
||||
if (this->log_packet_drop_count > 0) {
|
||||
/* ------------ Log buffer size: packet header (0x18) + chunk header (0x2) + log packet drop count (0x8) = 0x22 */
|
||||
constexpr auto log_buffer_size = sizeof(detail::LogPacketHeader) + 2 + sizeof(this->log_packet_drop_count);
|
||||
constexpr auto log_buffer_size = sizeof(impl::LogPacketHeader) + 2 + sizeof(this->log_packet_drop_count);
|
||||
u8 log_buffer[log_buffer_size] = {};
|
||||
detail::LogPacketTransmitter log_packet_transmitter(log_buffer, log_buffer_size, this->flush_func, diag::LogSeverity_Info, false, 0, true, true);
|
||||
impl::LogPacketTransmitter log_packet_transmitter(log_buffer, log_buffer_size, this->flush_func, diag::LogSeverity_Info, false, 0, true, true);
|
||||
log_packet_transmitter.PushLogPacketDropCount(this->log_packet_drop_count);
|
||||
|
||||
const auto ok = log_packet_transmitter.Flush(true);
|
||||
|
|
|
@ -22,11 +22,11 @@ namespace ams::lm::impl {
|
|||
NON_COPYABLE(EventLogTransmitter);
|
||||
NON_MOVEABLE(EventLogTransmitter);
|
||||
private:
|
||||
detail::LogPacketTransmitter::FlushFunction flush_func;
|
||||
impl::LogPacketTransmitter::FlushFunction flush_func;
|
||||
u64 log_packet_drop_count;
|
||||
os::SdkMutex log_packet_drop_count_lock;
|
||||
public:
|
||||
EventLogTransmitter(detail::LogPacketTransmitter::FlushFunction flush_func) : flush_func(flush_func), log_packet_drop_count(0), log_packet_drop_count_lock() {}
|
||||
EventLogTransmitter(impl::LogPacketTransmitter::FlushFunction flush_func) : flush_func(flush_func), log_packet_drop_count(0), log_packet_drop_count_lock() {}
|
||||
|
||||
bool SendLogSessionBeginPacket(u64 process_id);
|
||||
bool SendLogSessionEndPacket(u64 process_id);
|
||||
|
|
|
@ -27,15 +27,15 @@ namespace ams::lm::impl {
|
|||
return ok;
|
||||
}
|
||||
|
||||
inline bool ModifyUserSystemClockInfoImpl(detail::LogDataChunkKey chunk_key, u8 *log_payload_data, size_t log_payload_size, time::PosixTime &time_ref) {
|
||||
if(chunk_key == detail::LogDataChunkKey_UserSystemClock) {
|
||||
inline bool ModifyUserSystemClockInfoImpl(impl::LogDataChunkKey chunk_key, u8 *log_payload_data, size_t log_payload_size, time::PosixTime &time_ref) {
|
||||
if(chunk_key == impl::LogDataChunkKey_UserSystemClock) {
|
||||
/* TODO: properly implement this...? */
|
||||
reinterpret_cast<time::PosixTime*>(log_payload_data)->value += time_ref.value;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ModifyUserSystemClockInfo(detail::LogPacketHeader *packet_header, void *log_payload_data, size_t log_payload_size, time::PosixTime &time_ref) {
|
||||
bool ModifyUserSystemClockInfo(impl::LogPacketHeader *packet_header, void *log_payload_data, size_t log_payload_size, time::PosixTime &time_ref) {
|
||||
if (!packet_header->IsHead()) {
|
||||
/* Only modify this field on head packets. */
|
||||
return true;
|
||||
|
@ -51,7 +51,7 @@ namespace ams::lm::impl {
|
|||
auto payload_end = payload_start + log_payload_size;
|
||||
|
||||
/* Read chunk key and size. */
|
||||
const auto chunk_key = static_cast<detail::LogDataChunkKey>(PopUleb128(const_cast<const u8**>(std::addressof(payload_cur)), const_cast<const u8*>(payload_end)));
|
||||
const auto chunk_key = static_cast<impl::LogDataChunkKey>(PopUleb128(const_cast<const u8**>(std::addressof(payload_cur)), const_cast<const u8*>(payload_end)));
|
||||
if (payload_cur >= payload_end) {
|
||||
return false;
|
||||
}
|
||||
|
@ -71,18 +71,18 @@ namespace ams::lm::impl {
|
|||
}
|
||||
|
||||
/* Iterate (for potential multiple packets?) and change the UserSystemClock for each value. */
|
||||
auto packet_header = reinterpret_cast<detail::LogPacketHeader*>(log_data);
|
||||
auto packet_header = reinterpret_cast<impl::LogPacketHeader*>(log_data);
|
||||
auto data_start = reinterpret_cast<u8*>(log_data);
|
||||
auto data_cur = data_start;
|
||||
auto data_end = data_start + log_data_size;
|
||||
auto cur_packet_header = packet_header;
|
||||
while (static_cast<size_t>(data_end - data_start) >= sizeof(detail::LogPacketHeader)) {
|
||||
while (static_cast<size_t>(data_end - data_start) >= sizeof(impl::LogPacketHeader)) {
|
||||
auto payload_size = cur_packet_header->GetPayloadSize();
|
||||
if ((static_cast<size_t>(data_end - data_cur) < payload_size) || !ModifyUserSystemClockInfo(cur_packet_header, data_cur, static_cast<size_t>(payload_size), time_ref)) {
|
||||
break;
|
||||
}
|
||||
|
||||
cur_packet_header = reinterpret_cast<detail::LogPacketHeader*>(data_cur + payload_size);
|
||||
cur_packet_header = reinterpret_cast<impl::LogPacketHeader*>(data_cur + payload_size);
|
||||
if ((data_cur + payload_size) >= data_end) {
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -147,7 +147,7 @@ namespace ams::lm::impl {
|
|||
ON_SCOPE_EXIT { fs::CloseFile(log_file_h); };
|
||||
|
||||
/* 8-byte binary log header, current version is 1. */
|
||||
const detail::BinaryLogHeader bin_log_header = { detail::BinaryLogHeader::Magic, 1 };
|
||||
const impl::BinaryLogHeader bin_log_header = { impl::BinaryLogHeader::Magic, 1 };
|
||||
if (R_SUCCEEDED(fs::WriteFile(log_file_h, 0, std::addressof(bin_log_header), sizeof(bin_log_header), fs::WriteOption::Flush))) {
|
||||
this->log_file_offset = sizeof(bin_log_header);
|
||||
return true;
|
||||
|
|
|
@ -42,10 +42,10 @@ namespace ams::lm {
|
|||
}
|
||||
|
||||
void Logger::Log(const sf::InAutoSelectBuffer &log_buffer) {
|
||||
auto log_packet_header = (detail::LogPacketHeader*)log_buffer.GetPointer();
|
||||
auto log_packet_header = (impl::LogPacketHeader*)log_buffer.GetPointer();
|
||||
|
||||
/* Don't log anything if payload size isn't correct. */
|
||||
if ((log_packet_header->GetPayloadSize() + sizeof(detail::LogPacketHeader)) != log_buffer.GetSize()) {
|
||||
if ((log_packet_header->GetPayloadSize() + sizeof(impl::LogPacketHeader)) != log_buffer.GetSize()) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -66,7 +66,7 @@ namespace ams::lm {
|
|||
|
||||
if (g_is_logging_to_custom_sink) {
|
||||
/* Log to custom sink if enabled. */
|
||||
impl::WriteLogToCustomSink(const_cast<const detail::LogPacketHeader*>(log_packet_header), log_buffer.GetSize(), 0);
|
||||
impl::WriteLogToCustomSink(const_cast<const impl::LogPacketHeader*>(log_packet_header), log_buffer.GetSize(), 0);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue