From fc9b292846dc5a36da1d590621dbc4033d0e28ea Mon Sep 17 00:00:00 2001 From: Lephenixnoir Date: Tue, 16 Mar 2021 13:28:47 +0100 Subject: [PATCH] main: print malloc() stats after disassembly in verbose mode --- fxos/main.cpp | 5 ++++- include/fxos/log.h | 3 +++ lib/log.cpp | 6 ++++++ 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/fxos/main.cpp b/fxos/main.cpp index 398c12d..7d16c64 100644 --- a/fxos/main.cpp +++ b/fxos/main.cpp @@ -9,6 +9,7 @@ #include #include +#include #include #include @@ -347,7 +348,9 @@ int main_disassembly(int argc, char **argv) try { - return disassembly(lib, target, ref, passes); + int rc = disassembly(lib, target, ref, passes); + if(log_getminlevel() <= LEVEL_LOG) malloc_stats(); + return rc; } catch(LangError &e) { diff --git a/include/fxos/log.h b/include/fxos/log.h index c709879..9278f0d 100644 --- a/include/fxos/log.h +++ b/include/fxos/log.h @@ -23,6 +23,9 @@ namespace FxOS::Log { /* Select the log level */ void log_setminlevel(int level); +/* Get the minimum log level */ +int log_getminlevel(); + /* General message logger */ void logmsg(int level, char const *function, std::string message); diff --git a/lib/log.cpp b/lib/log.cpp index 9443d13..02bf9e1 100644 --- a/lib/log.cpp +++ b/lib/log.cpp @@ -21,6 +21,12 @@ void log_setminlevel(int level) loglevel = level; } +/* Get the minimum log level */ +int log_getminlevel() +{ + return loglevel; +} + /* General message logger */ void logmsg(int level, char const *function, std::string message) {