MemoryLoupe provides in-editor code size insights: codelenses about executable symbol size and stack usage.
It parses gcc generated files produced when compiling and linking executable with the following options:
-Wl,-Map=%.map outputs .map file.
-fstack-usage outputs .su files.
-ffunction-sections and -fdata-sections separates symbols in their own section, enables garbage collection (using -Wl,--gc-sections), and produces usable data in .map file.
Features
codelenses provide symbol info such as
symbol code size
discarded or used status
function stack usage
Requirements
Requires an extension that provides symbol information (Outline panel in the Explorer tab): C/C++ or clangd
Usage
Open a C file, the codelenses should appear next to the symbols.
The extension activates, finds and parses .map and .su files witin the current workspace.
Commands
memoryloupe: Select build directory: Set the location where the files should be searched.
memoryloupe.codeLensesEnabled: Show codelenses next to symbols in source files
memoryloupe.buildDir: Directory to look for .map and .su files, also set by Select build directory command.
memoryloupe.lenseFormat: Custom codelense format string. Specify optional prefix with $[prefix]{value}.
Build
build the extension .vsix package
npm install
npm run vsix
Todo
alert if multiple .map found > button select or disable
tree view
use quickpicks instead of filepicker for selecting build dir
error handling and logging
tests
extension icon
Known Issues
duplicate symbols, not filtering by file: symbol information can be mismatched if there are multiple symbols with the same name, although this should not be possible
not tested on c++ project, although the extension activates for cpp files, it could work
only tested with bare-metal arm-none-eabi projects