[Tarantool-patches] [PATCH luajit v6 0/2] memprof: C-symbols resolving

Maxim Kokryashkin max.kokryashkin at gmail.com
Tue Mar 22 21:31:23 MSK 2022


Changes in v6:
- Fixed comments as per review by Sergey
- Added tests for newly loaded symbols resolution

---
>> +#include <stdlib.h>
>> +#include <string.h>
>
> <string.h> and <stdlib.h> are included inside lj_def.h, so this include is excess.
Relying on includes in other header files is a terrible practice. Ignoring.

>> +-- Parse a single entry in a symtab: .so library
>> +local function parse_sym_cfunc(reader, symtab)
>> + local addr = reader:read_uleb128()
>> + local name = reader:read_string()
>> +
>> + symtab.cfunc = avl.insert(symtab.cfunc, addr, {
>> + name = name
>> + })
>> +end
>
> Side note: Does it sufficient for all 3 cases mentioned above as far as
> format is the same?
It is obvious that it works for the first two cases so I am going to
provide explanation only for the last one.

In the last case, symtab contains an addr and a name of a shared library.
When allocation occurs in a function from this library, its address is
dumped into the event stream. Later on, during the process of resolution,
parser searches the name of the function in AVL tree. Since it uses the
'upper_bound' for that, the only match for the mentioned function is the
entry for the shared object, from which it was loaded.

Maxim Kokryashkin (2):
  memprof: extend symtab with C-symbols
  memprof: enrich symtab with newly loaded symbols

 Makefile.original                             |   2 +-
 src/lj_memprof.c                              | 407 +++++++++++++++++-
 src/lj_memprof.h                              |  15 +-
 test/tarantool-tests/CMakeLists.txt           |   1 +
 .../gh-5813-resolving-of-c-symbols.test.lua   |  60 +++
 .../CMakeLists.txt                            |   2 +
 .../testresolving.c                           |  19 +
 test/tarantool-tests/tools-utils-avl.test.lua |  54 +++
 tools/CMakeLists.txt                          |   2 +
 tools/memprof.lua                             |   5 +
 tools/memprof/parse.lua                       |  19 +
 tools/utils/avl.lua                           | 114 +++++
 tools/utils/symtab.lua                        |  27 +-
 13 files changed, 715 insertions(+), 12 deletions(-)
 create mode 100644 test/tarantool-tests/gh-5813-resolving-of-c-symbols.test.lua
 create mode 100644 test/tarantool-tests/gh-5813-resolving-of-c-symbols/CMakeLists.txt
 create mode 100644 test/tarantool-tests/gh-5813-resolving-of-c-symbols/testresolving.c
 create mode 100644 test/tarantool-tests/tools-utils-avl.test.lua
 create mode 100644 tools/utils/avl.lua

--
2.35.1



More information about the Tarantool-patches mailing list