appscope icon indicating copy to clipboard operation
appscope copied to clipboard

[HOLD] Funchook memory management functions

Open michalbiesek opened this issue 2 years ago • 1 comments

This is a proof of concept of tracking the memory management functions. Next steps:

  • check node environment hello_world and unwind
  • ~~check if usable_size will work~~
  • ~~check strdup, posix_memalign,mmap, munmap functions~~

michalbiesek avatar Jun 03 '22 17:06 michalbiesek

Current configuration options

Default Variant

By default backtrace logging is disabled

Example command

scope ls

Full Backtrace Variant

To enable full backtrace logging for memory management functions please use:

  • the environment variable SCOPE_BACKTRACE with the full setting

Example command

SCOPE_BACKTRACE=full scope ls

Filter/Limited Backtrace Variant

To enable full backtrace logging for memory management functions please use:

  • the environment variable SCOPE_BACKTRACE with the filter setting
  • the environment variable SCOPE_BACKTRACE_FILTER with path to the file which contains the searched phrases

test_filter.txt

fclose

Example command

SCOPE_BACKTRACE=filter SCOPE_BACKTRACE_FILTER=test_filter.txt scope ls

Output

root@b53be13e8361:/# scope logs
Scope: ls(pid:292): [2022-06-08T11:11:02.135+0000] scopeBacktraceFilter begin
Scope: ls(pid:292): [2022-06-08T11:11:02.135+0000] func symbol: fclose, malloc_fun: free, size allocated: -1032, total size allocated: 30864
Scope: ls(pid:292): [2022-06-08T11:11:02.135+0000] scopeBacktraceFilter end

Openat/dlopen Backtrace Variant

To backtrace logging for dlopen and openat family functions please use:

  • the environment variable SCOPE_BACKTRACE with the openat setting

Example command

SCOPE_BACKTRACE=openat scope foo_cmd

michalbiesek avatar Jun 08 '22 11:06 michalbiesek