diff --git a/include/fxos/util/system.h b/include/fxos/util/system.h new file mode 100644 index 0000000..c606a5b --- /dev/null +++ b/include/fxos/util/system.h @@ -0,0 +1,25 @@ +//---------------------------------------------------------------------------// +// 1100101 |_ mov #0, r4 __ // +// 11 |_ <0xb380 %5c4> / _|_ _____ ___ // +// 0110 |_ 3.50 -> 3.60 | _\ \ / _ (_-< // +// |_ base# + offset |_| /_\_\___/__/ // +//---------------------------------------------------------------------------// +// fxos/util/system: System-specific functions + +#ifndef FXOS_UTIL_SYSTEM_H +#define FXOS_UTIL_SYSTEM_H + +#include + +static inline long systemGetCurrentRSS() +{ + FILE *fp = fopen("/proc/self/statm", "r"); + if(!fp) + return 0; + long rss = 0; + int rc = fscanf(fp, "%*s %ld", &rss); + fclose(fp); + return (rc == 1) ? rss * sysconf(_SC_PAGESIZE) : 0; +} + +#endif /* FXOS_UTIL_SYSTEM_H */ diff --git a/lib/function.cpp b/lib/function.cpp index aac762c..afb7689 100644 --- a/lib/function.cpp +++ b/lib/function.cpp @@ -327,6 +327,7 @@ bool Function::exploreFunctionAt(u32 functionAddress) /* Sort blocks now before creating CFG nodes, which are index-based */ sortBasicBlocks(); + m_blocks.shrink_to_fit(); /* Set block predecessors */ for(auto &[pc, succ]: successorAddresses) { diff --git a/lib/project.cpp b/lib/project.cpp index 11e85e5..b7738e6 100644 --- a/lib/project.cpp +++ b/lib/project.cpp @@ -1,6 +1,7 @@ #include #include #include +#include #include #include #include @@ -197,7 +198,8 @@ bool Project::load(std::string const &path0, bool verbose) t.stop(); if(verbose) - printf("Loaded %s in %s\n", m_name.c_str(), t.format_time().c_str()); + printf("Loaded %s in %s (%ld MB used)\n", m_name.c_str(), + t.format_time().c_str(), systemGetCurrentRSS() / 1000000); return true; }