The goal of this series is two-fold - Reduce memory utilization during pahole BTF generation - Improve testing for BTF function encoding Patch 1 switches from using a DWARF representation when saving function information for (possible) later addition to using BTF; the result is we can discard DWARF info after use and memory usage will not get out of hand. Peak memory utilization is approximately 1Gb versus 3/4Gb prior to this change when specifying "-j --btf_features=all". Patch 2 adds support to pfunct to show all functions that match a given name (allowing us to find inconsistent prototypes in the test in patch 3), and also adds stealer support for printing all DWARF function prototypes to speed up execution (the latter is used in the test also). Patch 3 is a bash test script which carries out vmlinux BTF generation and verifies the BTF functions match their DWARF equivalents, and also verifies the skipped functions should have been skipped. Patch 3 depends on the pfunct functionality from patch 2 and the pahole changes in patch 1, but moving forward should be useful for validating pahole function-related changes quickly. The test takes approximately 4 minutes to run. Changes since v2: - fixed checks of func->state since it is always non-NULL and removed now-unneeded fields from dwarves.h; added assertions that either ELF or DWARF data is present for func encoding (Jiri, patch 1) - fixed strncpy() issues, improved equality comparions between types (Eduard, patch 1) - reworked btf_functions test to minimize overheads - replaced egrep with grep -E (Arnaldo, patch 3) Changes since RFC: - fixed free issues (Jiri, patch 1) - embed func state into struct elf_function as each function has state, and we can use the stack for state comparison avoiding the cost of additional allocations (patch 1) - fix an intermittent coredump that resulted from using btf__str_by_offset() string in adding function prototype; needing more space could sometimes result in strset memory movement which would in turn invalidate the char * string, so copy it to a char array for param name/tag value encoding (patch 1) - improve logging of decision to skip functions so that we can gather that info more easily for testing in patch 3 - added new option to pfunct to show all instances of a function prototype and - if no function is specified - use the stealer to dump out all prototypes more rapidly to aid quicker testing - added test covering BTF function generation, checking that DWARF/BTF are consistent and that for skipped functions the skip rationale was valid (Jiri, patch 3) There's no diff-style tests comparing encoding before/after changes, but having automated tests probing DWARF/BTF correspondence is useful I think. Alan Maguire (3): btf_encoder: record BTF-centric function state instead of DWARF-centric pfunct: show all functions that match filter criteria tests: add test validating BTF encoding, reasons we skip functions btf_encoder.c | 565 +++++++++++++++++++++++++++++++---------- dwarves.h | 2 - pfunct.c | 36 ++- tests/btf_functions.sh | 186 ++++++++++++++ 4 files changed, 636 insertions(+), 153 deletions(-) create mode 100755 tests/btf_functions.sh -- 2.43.5