Tarantool development patches archive
 help / color / mirror / Atom feed
* [Tarantool-patches] [PATCH luajit v6 0/2] memprof: C-symbols resolving
@ 2022-03-22 18:31 Maxim Kokryashkin via Tarantool-patches
  2022-03-22 18:31 ` [Tarantool-patches] [PATCH luajit v6 1/2] memprof: extend symtab with C-symbols Maxim Kokryashkin via Tarantool-patches
                   ` (3 more replies)
  0 siblings, 4 replies; 8+ messages in thread
From: Maxim Kokryashkin via Tarantool-patches @ 2022-03-22 18:31 UTC (permalink / raw)
  To: tarantool-patches, imun, skaplun

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


^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2022-04-22 13:26 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-22 18:31 [Tarantool-patches] [PATCH luajit v6 0/2] memprof: C-symbols resolving Maxim Kokryashkin via Tarantool-patches
2022-03-22 18:31 ` [Tarantool-patches] [PATCH luajit v6 1/2] memprof: extend symtab with C-symbols Maxim Kokryashkin via Tarantool-patches
2022-04-04  8:43   ` Sergey Kaplun via Tarantool-patches
2022-04-04 11:34     ` Sergey Kaplun via Tarantool-patches
2022-03-22 18:31 ` [Tarantool-patches] [PATCH luajit v6 2/2] memprof: enrich symtab with newly loaded symbols Maxim Kokryashkin via Tarantool-patches
2022-04-04  8:44   ` Sergey Kaplun via Tarantool-patches
2022-04-04  8:45 ` [Tarantool-patches] [PATCH luajit v6 0/2] memprof: C-symbols resolving Sergey Kaplun via Tarantool-patches
2022-04-22 13:22 ` Igor Munkin via Tarantool-patches

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox