ruby_memprofiler_pprof 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/ext/ruby_memprofiler_pprof_ext/collector.c +803 -0
- data/ext/ruby_memprofiler_pprof_ext/compat.c +184 -0
- data/ext/ruby_memprofiler_pprof_ext/compile_commands.json +1 -0
- data/ext/ruby_memprofiler_pprof_ext/extconf.rb +152 -0
- data/ext/ruby_memprofiler_pprof_ext/pprof.upb.c +199 -0
- data/ext/ruby_memprofiler_pprof_ext/pprof.upb.h +924 -0
- data/ext/ruby_memprofiler_pprof_ext/pprof_out.c +430 -0
- data/ext/ruby_memprofiler_pprof_ext/ruby_hacks.c +118 -0
- data/ext/ruby_memprofiler_pprof_ext/ruby_memprofiler_pprof.c +10 -0
- data/ext/ruby_memprofiler_pprof_ext/ruby_memprofiler_pprof.h +183 -0
- data/ext/ruby_memprofiler_pprof_ext/ruby_private/ruby26/gc_private.h +324 -0
- data/ext/ruby_memprofiler_pprof_ext/ruby_private/ruby27/gc_private.h +339 -0
- data/ext/ruby_memprofiler_pprof_ext/ruby_private/ruby30/gc_private.h +361 -0
- data/ext/ruby_memprofiler_pprof_ext/ruby_private/ruby31/gc_private.h +374 -0
- data/ext/ruby_memprofiler_pprof_ext/ruby_private.h +31 -0
- data/ext/ruby_memprofiler_pprof_ext/sample.c +43 -0
- data/ext/ruby_memprofiler_pprof_ext/vendor/backtracie/backtracie.h +268 -0
- data/ext/{ruby_memprofiler_pprof → ruby_memprofiler_pprof_ext}/vendor/upb/BUILD +0 -0
- data/ext/{ruby_memprofiler_pprof → ruby_memprofiler_pprof_ext}/vendor/upb/CONTRIBUTING.md +0 -0
- data/ext/{ruby_memprofiler_pprof → ruby_memprofiler_pprof_ext}/vendor/upb/DESIGN.md +0 -0
- data/ext/{ruby_memprofiler_pprof → ruby_memprofiler_pprof_ext}/vendor/upb/LICENSE +0 -0
- data/ext/{ruby_memprofiler_pprof → ruby_memprofiler_pprof_ext}/vendor/upb/README.md +0 -0
- data/ext/{ruby_memprofiler_pprof → ruby_memprofiler_pprof_ext}/vendor/upb/WORKSPACE +0 -0
- data/ext/{ruby_memprofiler_pprof → ruby_memprofiler_pprof_ext}/vendor/upb/bazel/BUILD +0 -0
- data/ext/{ruby_memprofiler_pprof → ruby_memprofiler_pprof_ext}/vendor/upb/bazel/amalgamate.py +0 -0
- data/ext/{ruby_memprofiler_pprof → ruby_memprofiler_pprof_ext}/vendor/upb/bazel/build_defs.bzl +0 -0
- data/ext/{ruby_memprofiler_pprof → ruby_memprofiler_pprof_ext}/vendor/upb/bazel/lua.BUILD +0 -0
- data/ext/{ruby_memprofiler_pprof → ruby_memprofiler_pprof_ext}/vendor/upb/bazel/protobuf.patch +0 -0
- data/ext/{ruby_memprofiler_pprof → ruby_memprofiler_pprof_ext}/vendor/upb/bazel/py_proto_library.bzl +0 -0
- data/ext/{ruby_memprofiler_pprof → ruby_memprofiler_pprof_ext}/vendor/upb/bazel/python_downloads.bzl +0 -0
- data/ext/{ruby_memprofiler_pprof → ruby_memprofiler_pprof_ext}/vendor/upb/bazel/system_python.bzl +0 -0
- data/ext/{ruby_memprofiler_pprof → ruby_memprofiler_pprof_ext}/vendor/upb/bazel/upb_proto_library.bzl +0 -0
- data/ext/{ruby_memprofiler_pprof → ruby_memprofiler_pprof_ext}/vendor/upb/bazel/workspace_deps.bzl +0 -0
- data/ext/{ruby_memprofiler_pprof → ruby_memprofiler_pprof_ext}/vendor/upb/benchmarks/BUILD +0 -0
- data/ext/{ruby_memprofiler_pprof → ruby_memprofiler_pprof_ext}/vendor/upb/benchmarks/BUILD.googleapis +0 -0
- data/ext/{ruby_memprofiler_pprof → ruby_memprofiler_pprof_ext}/vendor/upb/benchmarks/benchmark.cc +0 -0
- data/ext/{ruby_memprofiler_pprof → ruby_memprofiler_pprof_ext}/vendor/upb/benchmarks/build_defs.bzl +0 -0
- data/ext/{ruby_memprofiler_pprof → ruby_memprofiler_pprof_ext}/vendor/upb/benchmarks/compare.py +0 -0
- data/ext/{ruby_memprofiler_pprof → ruby_memprofiler_pprof_ext}/vendor/upb/benchmarks/descriptor.proto +0 -0
- data/ext/{ruby_memprofiler_pprof → ruby_memprofiler_pprof_ext}/vendor/upb/benchmarks/descriptor_sv.proto +0 -0
- data/ext/{ruby_memprofiler_pprof → ruby_memprofiler_pprof_ext}/vendor/upb/benchmarks/empty.proto +0 -0
- data/ext/{ruby_memprofiler_pprof → ruby_memprofiler_pprof_ext}/vendor/upb/benchmarks/gen_protobuf_binary_cc.py +0 -0
- data/ext/{ruby_memprofiler_pprof → ruby_memprofiler_pprof_ext}/vendor/upb/benchmarks/gen_synthetic_protos.py +0 -0
- data/ext/{ruby_memprofiler_pprof → ruby_memprofiler_pprof_ext}/vendor/upb/benchmarks/gen_upb_binary_c.py +0 -0
- data/ext/{ruby_memprofiler_pprof → ruby_memprofiler_pprof_ext}/vendor/upb/cmake/BUILD.bazel +0 -0
- data/ext/{ruby_memprofiler_pprof → ruby_memprofiler_pprof_ext}/vendor/upb/cmake/README.md +0 -0
- data/ext/{ruby_memprofiler_pprof → ruby_memprofiler_pprof_ext}/vendor/upb/cmake/build_defs.bzl +0 -0
- data/ext/{ruby_memprofiler_pprof → ruby_memprofiler_pprof_ext}/vendor/upb/cmake/make_cmakelists.py +0 -0
- data/ext/{ruby_memprofiler_pprof → ruby_memprofiler_pprof_ext}/vendor/upb/cmake/staleness_test.py +0 -0
- data/ext/{ruby_memprofiler_pprof → ruby_memprofiler_pprof_ext}/vendor/upb/cmake/staleness_test_lib.py +0 -0
- data/ext/{ruby_memprofiler_pprof → ruby_memprofiler_pprof_ext}/vendor/upb/docs/render.py +0 -0
- data/ext/{ruby_memprofiler_pprof → ruby_memprofiler_pprof_ext}/vendor/upb/docs/style-guide.md +0 -0
- data/ext/{ruby_memprofiler_pprof → ruby_memprofiler_pprof_ext}/vendor/upb/docs/vs-cpp-protos.md +0 -0
- data/ext/{ruby_memprofiler_pprof → ruby_memprofiler_pprof_ext}/vendor/upb/docs/wrapping-upb.md +0 -0
- data/ext/{ruby_memprofiler_pprof → ruby_memprofiler_pprof_ext}/vendor/upb/python/BUILD +0 -0
- data/ext/{ruby_memprofiler_pprof → ruby_memprofiler_pprof_ext}/vendor/upb/python/convert.c +0 -0
- data/ext/{ruby_memprofiler_pprof → ruby_memprofiler_pprof_ext}/vendor/upb/python/convert.h +0 -0
- data/ext/{ruby_memprofiler_pprof → ruby_memprofiler_pprof_ext}/vendor/upb/python/descriptor.c +0 -0
- data/ext/{ruby_memprofiler_pprof → ruby_memprofiler_pprof_ext}/vendor/upb/python/descriptor.h +0 -0
- data/ext/{ruby_memprofiler_pprof → ruby_memprofiler_pprof_ext}/vendor/upb/python/descriptor_containers.c +0 -0
- data/ext/{ruby_memprofiler_pprof → ruby_memprofiler_pprof_ext}/vendor/upb/python/descriptor_containers.h +0 -0
- data/ext/{ruby_memprofiler_pprof → ruby_memprofiler_pprof_ext}/vendor/upb/python/descriptor_pool.c +0 -0
- data/ext/{ruby_memprofiler_pprof → ruby_memprofiler_pprof_ext}/vendor/upb/python/descriptor_pool.h +0 -0
- data/ext/{ruby_memprofiler_pprof → ruby_memprofiler_pprof_ext}/vendor/upb/python/dist/BUILD.bazel +0 -0
- data/ext/{ruby_memprofiler_pprof → ruby_memprofiler_pprof_ext}/vendor/upb/python/dist/dist.bzl +0 -0
- data/ext/{ruby_memprofiler_pprof → ruby_memprofiler_pprof_ext}/vendor/upb/python/extension_dict.c +0 -0
- data/ext/{ruby_memprofiler_pprof → ruby_memprofiler_pprof_ext}/vendor/upb/python/extension_dict.h +0 -0
- data/ext/{ruby_memprofiler_pprof → ruby_memprofiler_pprof_ext}/vendor/upb/python/map.c +0 -0
- data/ext/{ruby_memprofiler_pprof → ruby_memprofiler_pprof_ext}/vendor/upb/python/map.h +0 -0
- data/ext/{ruby_memprofiler_pprof → ruby_memprofiler_pprof_ext}/vendor/upb/python/message.c +0 -0
- data/ext/{ruby_memprofiler_pprof → ruby_memprofiler_pprof_ext}/vendor/upb/python/message.h +0 -0
- data/ext/{ruby_memprofiler_pprof → ruby_memprofiler_pprof_ext}/vendor/upb/python/minimal_test.py +0 -0
- data/ext/{ruby_memprofiler_pprof → ruby_memprofiler_pprof_ext}/vendor/upb/python/pb_unit_tests/BUILD +0 -0
- data/ext/{ruby_memprofiler_pprof → ruby_memprofiler_pprof_ext}/vendor/upb/python/pb_unit_tests/README.md +0 -0
- data/ext/{ruby_memprofiler_pprof → ruby_memprofiler_pprof_ext}/vendor/upb/python/pb_unit_tests/descriptor_database_test_wrapper.py +0 -0
- data/ext/{ruby_memprofiler_pprof → ruby_memprofiler_pprof_ext}/vendor/upb/python/pb_unit_tests/descriptor_pool_test_wrapper.py +0 -0
- data/ext/{ruby_memprofiler_pprof → ruby_memprofiler_pprof_ext}/vendor/upb/python/pb_unit_tests/descriptor_test_wrapper.py +0 -0
- data/ext/{ruby_memprofiler_pprof → ruby_memprofiler_pprof_ext}/vendor/upb/python/pb_unit_tests/generator_test_wrapper.py +0 -0
- data/ext/{ruby_memprofiler_pprof → ruby_memprofiler_pprof_ext}/vendor/upb/python/pb_unit_tests/json_format_test_wrapper.py +0 -0
- data/ext/{ruby_memprofiler_pprof → ruby_memprofiler_pprof_ext}/vendor/upb/python/pb_unit_tests/keywords_test_wrapper.py +0 -0
- data/ext/{ruby_memprofiler_pprof → ruby_memprofiler_pprof_ext}/vendor/upb/python/pb_unit_tests/message_factory_test_wrapper.py +0 -0
- data/ext/{ruby_memprofiler_pprof → ruby_memprofiler_pprof_ext}/vendor/upb/python/pb_unit_tests/message_test_wrapper.py +0 -0
- data/ext/{ruby_memprofiler_pprof → ruby_memprofiler_pprof_ext}/vendor/upb/python/pb_unit_tests/proto_builder_test_wrapper.py +0 -0
- data/ext/{ruby_memprofiler_pprof → ruby_memprofiler_pprof_ext}/vendor/upb/python/pb_unit_tests/pyproto_test_wrapper.bzl +0 -0
- data/ext/{ruby_memprofiler_pprof → ruby_memprofiler_pprof_ext}/vendor/upb/python/pb_unit_tests/reflection_test_wrapper.py +0 -0
- data/ext/{ruby_memprofiler_pprof → ruby_memprofiler_pprof_ext}/vendor/upb/python/pb_unit_tests/service_reflection_test_wrapper.py +0 -0
- data/ext/{ruby_memprofiler_pprof → ruby_memprofiler_pprof_ext}/vendor/upb/python/pb_unit_tests/symbol_database_test_wrapper.py +0 -0
- data/ext/{ruby_memprofiler_pprof → ruby_memprofiler_pprof_ext}/vendor/upb/python/pb_unit_tests/text_encoding_test_wrapper.py +0 -0
- data/ext/{ruby_memprofiler_pprof → ruby_memprofiler_pprof_ext}/vendor/upb/python/pb_unit_tests/text_format_test_wrapper.py +0 -0
- data/ext/{ruby_memprofiler_pprof → ruby_memprofiler_pprof_ext}/vendor/upb/python/pb_unit_tests/unknown_fields_test_wrapper.py +0 -0
- data/ext/{ruby_memprofiler_pprof → ruby_memprofiler_pprof_ext}/vendor/upb/python/pb_unit_tests/well_known_types_test_wrapper.py +0 -0
- data/ext/{ruby_memprofiler_pprof → ruby_memprofiler_pprof_ext}/vendor/upb/python/pb_unit_tests/wire_format_test_wrapper.py +0 -0
- data/ext/{ruby_memprofiler_pprof → ruby_memprofiler_pprof_ext}/vendor/upb/python/protobuf.c +0 -0
- data/ext/{ruby_memprofiler_pprof → ruby_memprofiler_pprof_ext}/vendor/upb/python/protobuf.h +0 -0
- data/ext/{ruby_memprofiler_pprof → ruby_memprofiler_pprof_ext}/vendor/upb/python/py_extension.bzl +0 -0
- data/ext/{ruby_memprofiler_pprof → ruby_memprofiler_pprof_ext}/vendor/upb/python/python_api.h +0 -0
- data/ext/{ruby_memprofiler_pprof → ruby_memprofiler_pprof_ext}/vendor/upb/python/repeated.c +0 -0
- data/ext/{ruby_memprofiler_pprof → ruby_memprofiler_pprof_ext}/vendor/upb/python/repeated.h +0 -0
- data/ext/{ruby_memprofiler_pprof → ruby_memprofiler_pprof_ext}/vendor/upb/python/unknown_fields.c +0 -0
- data/ext/{ruby_memprofiler_pprof → ruby_memprofiler_pprof_ext}/vendor/upb/python/unknown_fields.h +0 -0
- data/ext/{ruby_memprofiler_pprof → ruby_memprofiler_pprof_ext}/vendor/upb/python/version_script.lds +0 -0
- data/ext/{ruby_memprofiler_pprof → ruby_memprofiler_pprof_ext}/vendor/upb/third_party/lunit/LICENSE +0 -0
- data/ext/{ruby_memprofiler_pprof → ruby_memprofiler_pprof_ext}/vendor/upb/third_party/lunit/README.google +0 -0
- data/ext/{ruby_memprofiler_pprof → ruby_memprofiler_pprof_ext}/vendor/upb/third_party/lunit/console.lua +0 -0
- data/ext/{ruby_memprofiler_pprof → ruby_memprofiler_pprof_ext}/vendor/upb/third_party/lunit/lunit.lua +0 -0
- data/ext/{ruby_memprofiler_pprof → ruby_memprofiler_pprof_ext}/vendor/upb/third_party/utf8_range/BUILD +0 -0
- data/ext/{ruby_memprofiler_pprof → ruby_memprofiler_pprof_ext}/vendor/upb/third_party/utf8_range/LICENSE +0 -0
- data/ext/{ruby_memprofiler_pprof → ruby_memprofiler_pprof_ext}/vendor/upb/third_party/utf8_range/naive.c +0 -0
- data/ext/{ruby_memprofiler_pprof → ruby_memprofiler_pprof_ext}/vendor/upb/third_party/utf8_range/range2-neon.c +0 -0
- data/ext/{ruby_memprofiler_pprof → ruby_memprofiler_pprof_ext}/vendor/upb/third_party/utf8_range/range2-sse.c +0 -0
- data/ext/{ruby_memprofiler_pprof → ruby_memprofiler_pprof_ext}/vendor/upb/third_party/utf8_range/utf8_range.h +0 -0
- data/ext/{ruby_memprofiler_pprof → ruby_memprofiler_pprof_ext}/vendor/upb/upb/bindings/lua/BUILD.bazel +0 -0
- data/ext/{ruby_memprofiler_pprof → ruby_memprofiler_pprof_ext}/vendor/upb/upb/bindings/lua/README.md +0 -0
- data/ext/{ruby_memprofiler_pprof → ruby_memprofiler_pprof_ext}/vendor/upb/upb/bindings/lua/def.c +0 -0
- data/ext/{ruby_memprofiler_pprof → ruby_memprofiler_pprof_ext}/vendor/upb/upb/bindings/lua/lua_proto_library.bzl +0 -0
- data/ext/{ruby_memprofiler_pprof → ruby_memprofiler_pprof_ext}/vendor/upb/upb/bindings/lua/main.c +0 -0
- data/ext/{ruby_memprofiler_pprof → ruby_memprofiler_pprof_ext}/vendor/upb/upb/bindings/lua/msg.c +0 -0
- data/ext/{ruby_memprofiler_pprof → ruby_memprofiler_pprof_ext}/vendor/upb/upb/bindings/lua/test.proto +0 -0
- data/ext/{ruby_memprofiler_pprof → ruby_memprofiler_pprof_ext}/vendor/upb/upb/bindings/lua/test_upb.lua +0 -0
- data/ext/{ruby_memprofiler_pprof → ruby_memprofiler_pprof_ext}/vendor/upb/upb/bindings/lua/upb.c +0 -0
- data/ext/{ruby_memprofiler_pprof → ruby_memprofiler_pprof_ext}/vendor/upb/upb/bindings/lua/upb.h +0 -0
- data/ext/{ruby_memprofiler_pprof → ruby_memprofiler_pprof_ext}/vendor/upb/upb/bindings/lua/upb.lua +0 -0
- data/ext/{ruby_memprofiler_pprof → ruby_memprofiler_pprof_ext}/vendor/upb/upb/bindings/lua/upbc.cc +0 -0
- data/ext/{ruby_memprofiler_pprof → ruby_memprofiler_pprof_ext}/vendor/upb/upb/collections.c +0 -0
- data/ext/{ruby_memprofiler_pprof → ruby_memprofiler_pprof_ext}/vendor/upb/upb/collections.h +0 -0
- data/ext/{ruby_memprofiler_pprof → ruby_memprofiler_pprof_ext}/vendor/upb/upb/conformance_upb.c +0 -0
- data/ext/{ruby_memprofiler_pprof → ruby_memprofiler_pprof_ext}/vendor/upb/upb/conformance_upb_failures.txt +0 -0
- data/ext/{ruby_memprofiler_pprof → ruby_memprofiler_pprof_ext}/vendor/upb/upb/decode.c +0 -0
- data/ext/{ruby_memprofiler_pprof → ruby_memprofiler_pprof_ext}/vendor/upb/upb/decode.h +0 -0
- data/ext/{ruby_memprofiler_pprof → ruby_memprofiler_pprof_ext}/vendor/upb/upb/decode_fast.c +0 -0
- data/ext/{ruby_memprofiler_pprof → ruby_memprofiler_pprof_ext}/vendor/upb/upb/decode_fast.h +0 -0
- data/ext/{ruby_memprofiler_pprof → ruby_memprofiler_pprof_ext}/vendor/upb/upb/decode_internal.h +0 -0
- data/ext/{ruby_memprofiler_pprof → ruby_memprofiler_pprof_ext}/vendor/upb/upb/def.c +0 -0
- data/ext/{ruby_memprofiler_pprof → ruby_memprofiler_pprof_ext}/vendor/upb/upb/def.h +0 -0
- data/ext/{ruby_memprofiler_pprof → ruby_memprofiler_pprof_ext}/vendor/upb/upb/def.hpp +0 -0
- data/ext/{ruby_memprofiler_pprof → ruby_memprofiler_pprof_ext}/vendor/upb/upb/empty.proto +0 -0
- data/ext/{ruby_memprofiler_pprof → ruby_memprofiler_pprof_ext}/vendor/upb/upb/encode.c +0 -0
- data/ext/{ruby_memprofiler_pprof → ruby_memprofiler_pprof_ext}/vendor/upb/upb/encode.h +0 -0
- data/ext/{ruby_memprofiler_pprof → ruby_memprofiler_pprof_ext}/vendor/upb/upb/fuzz/BUILD +0 -0
- data/ext/{ruby_memprofiler_pprof → ruby_memprofiler_pprof_ext}/vendor/upb/upb/fuzz/file_descriptor_parsenew_fuzzer.cc +0 -0
- data/ext/{ruby_memprofiler_pprof → ruby_memprofiler_pprof_ext}/vendor/upb/upb/json_decode.c +0 -0
- data/ext/{ruby_memprofiler_pprof → ruby_memprofiler_pprof_ext}/vendor/upb/upb/json_decode.h +0 -0
- data/ext/{ruby_memprofiler_pprof → ruby_memprofiler_pprof_ext}/vendor/upb/upb/json_encode.c +0 -0
- data/ext/{ruby_memprofiler_pprof → ruby_memprofiler_pprof_ext}/vendor/upb/upb/json_encode.h +0 -0
- data/ext/{ruby_memprofiler_pprof → ruby_memprofiler_pprof_ext}/vendor/upb/upb/mini_table.c +0 -0
- data/ext/{ruby_memprofiler_pprof → ruby_memprofiler_pprof_ext}/vendor/upb/upb/mini_table.h +0 -0
- data/ext/{ruby_memprofiler_pprof → ruby_memprofiler_pprof_ext}/vendor/upb/upb/mini_table.hpp +0 -0
- data/ext/{ruby_memprofiler_pprof → ruby_memprofiler_pprof_ext}/vendor/upb/upb/mini_table_accessors.c +0 -0
- data/ext/{ruby_memprofiler_pprof → ruby_memprofiler_pprof_ext}/vendor/upb/upb/mini_table_accessors.h +0 -0
- data/ext/{ruby_memprofiler_pprof → ruby_memprofiler_pprof_ext}/vendor/upb/upb/mini_table_accessors_internal.h +0 -0
- data/ext/{ruby_memprofiler_pprof → ruby_memprofiler_pprof_ext}/vendor/upb/upb/mini_table_accessors_test.cc +0 -0
- data/ext/{ruby_memprofiler_pprof → ruby_memprofiler_pprof_ext}/vendor/upb/upb/mini_table_test.cc +0 -0
- data/ext/{ruby_memprofiler_pprof → ruby_memprofiler_pprof_ext}/vendor/upb/upb/msg.c +0 -0
- data/ext/{ruby_memprofiler_pprof → ruby_memprofiler_pprof_ext}/vendor/upb/upb/msg.h +0 -0
- data/ext/{ruby_memprofiler_pprof → ruby_memprofiler_pprof_ext}/vendor/upb/upb/msg_internal.h +0 -0
- data/ext/{ruby_memprofiler_pprof → ruby_memprofiler_pprof_ext}/vendor/upb/upb/msg_test.cc +0 -0
- data/ext/{ruby_memprofiler_pprof → ruby_memprofiler_pprof_ext}/vendor/upb/upb/msg_test.proto +0 -0
- data/ext/{ruby_memprofiler_pprof → ruby_memprofiler_pprof_ext}/vendor/upb/upb/port_def.inc +0 -0
- data/ext/{ruby_memprofiler_pprof → ruby_memprofiler_pprof_ext}/vendor/upb/upb/port_undef.inc +0 -0
- data/ext/{ruby_memprofiler_pprof → ruby_memprofiler_pprof_ext}/vendor/upb/upb/reflection.c +0 -0
- data/ext/{ruby_memprofiler_pprof → ruby_memprofiler_pprof_ext}/vendor/upb/upb/reflection.h +0 -0
- data/ext/{ruby_memprofiler_pprof → ruby_memprofiler_pprof_ext}/vendor/upb/upb/reflection.hpp +0 -0
- data/ext/{ruby_memprofiler_pprof → ruby_memprofiler_pprof_ext}/vendor/upb/upb/table.c +0 -0
- data/ext/{ruby_memprofiler_pprof → ruby_memprofiler_pprof_ext}/vendor/upb/upb/table_internal.h +0 -0
- data/ext/{ruby_memprofiler_pprof → ruby_memprofiler_pprof_ext}/vendor/upb/upb/test.proto +0 -0
- data/ext/{ruby_memprofiler_pprof → ruby_memprofiler_pprof_ext}/vendor/upb/upb/test_cpp.cc +0 -0
- data/ext/{ruby_memprofiler_pprof → ruby_memprofiler_pprof_ext}/vendor/upb/upb/test_cpp.proto +0 -0
- data/ext/{ruby_memprofiler_pprof → ruby_memprofiler_pprof_ext}/vendor/upb/upb/test_generated_code.cc +0 -0
- data/ext/{ruby_memprofiler_pprof → ruby_memprofiler_pprof_ext}/vendor/upb/upb/test_table.cc +0 -0
- data/ext/{ruby_memprofiler_pprof → ruby_memprofiler_pprof_ext}/vendor/upb/upb/text_encode.c +0 -0
- data/ext/{ruby_memprofiler_pprof → ruby_memprofiler_pprof_ext}/vendor/upb/upb/text_encode.h +0 -0
- data/ext/{ruby_memprofiler_pprof → ruby_memprofiler_pprof_ext}/vendor/upb/upb/upb.c +0 -0
- data/ext/{ruby_memprofiler_pprof → ruby_memprofiler_pprof_ext}/vendor/upb/upb/upb.h +0 -0
- data/ext/{ruby_memprofiler_pprof → ruby_memprofiler_pprof_ext}/vendor/upb/upb/upb.hpp +0 -0
- data/ext/{ruby_memprofiler_pprof → ruby_memprofiler_pprof_ext}/vendor/upb/upb/upb_internal.h +0 -0
- data/ext/{ruby_memprofiler_pprof → ruby_memprofiler_pprof_ext}/vendor/upb/upb/util/BUILD +0 -0
- data/ext/{ruby_memprofiler_pprof → ruby_memprofiler_pprof_ext}/vendor/upb/upb/util/README.md +0 -0
- data/ext/{ruby_memprofiler_pprof → ruby_memprofiler_pprof_ext}/vendor/upb/upb/util/compare.c +0 -0
- data/ext/{ruby_memprofiler_pprof → ruby_memprofiler_pprof_ext}/vendor/upb/upb/util/compare.h +0 -0
- data/ext/{ruby_memprofiler_pprof → ruby_memprofiler_pprof_ext}/vendor/upb/upb/util/compare_test.cc +0 -0
- data/ext/{ruby_memprofiler_pprof → ruby_memprofiler_pprof_ext}/vendor/upb/upb/util/def_to_proto.c +0 -0
- data/ext/{ruby_memprofiler_pprof → ruby_memprofiler_pprof_ext}/vendor/upb/upb/util/def_to_proto.h +0 -0
- data/ext/{ruby_memprofiler_pprof → ruby_memprofiler_pprof_ext}/vendor/upb/upb/util/def_to_proto_public_import_test.proto +0 -0
- data/ext/{ruby_memprofiler_pprof → ruby_memprofiler_pprof_ext}/vendor/upb/upb/util/def_to_proto_regular_import_test.proto +0 -0
- data/ext/{ruby_memprofiler_pprof → ruby_memprofiler_pprof_ext}/vendor/upb/upb/util/def_to_proto_test.cc +0 -0
- data/ext/{ruby_memprofiler_pprof → ruby_memprofiler_pprof_ext}/vendor/upb/upb/util/def_to_proto_test.proto +0 -0
- data/ext/{ruby_memprofiler_pprof → ruby_memprofiler_pprof_ext}/vendor/upb/upb/util/def_to_proto_weak_import_test.proto +0 -0
- data/ext/{ruby_memprofiler_pprof → ruby_memprofiler_pprof_ext}/vendor/upb/upb/util/def_to_proto_wweak_import_test.proto +0 -0
- data/ext/{ruby_memprofiler_pprof → ruby_memprofiler_pprof_ext}/vendor/upb/upb/util/required_fields.c +0 -0
- data/ext/{ruby_memprofiler_pprof → ruby_memprofiler_pprof_ext}/vendor/upb/upb/util/required_fields.h +0 -0
- data/ext/{ruby_memprofiler_pprof → ruby_memprofiler_pprof_ext}/vendor/upb/upb/util/required_fields_test.cc +0 -0
- data/ext/{ruby_memprofiler_pprof → ruby_memprofiler_pprof_ext}/vendor/upb/upb/util/required_fields_test.proto +0 -0
- data/ext/{ruby_memprofiler_pprof → ruby_memprofiler_pprof_ext}/vendor/upb/upbc/BUILD +0 -0
- data/ext/{ruby_memprofiler_pprof → ruby_memprofiler_pprof_ext}/vendor/upb/upbc/common.cc +0 -0
- data/ext/{ruby_memprofiler_pprof → ruby_memprofiler_pprof_ext}/vendor/upb/upbc/common.h +0 -0
- data/ext/{ruby_memprofiler_pprof → ruby_memprofiler_pprof_ext}/vendor/upb/upbc/protoc-gen-upb.cc +0 -0
- data/ext/{ruby_memprofiler_pprof → ruby_memprofiler_pprof_ext}/vendor/upb/upbc/protoc-gen-upbdefs.cc +0 -0
- data/lib/ruby_memprofiler_pprof/atfork.rb +1 -1
- data/lib/ruby_memprofiler_pprof/block_flusher.rb +48 -4
- data/lib/ruby_memprofiler_pprof/file_flusher.rb +13 -6
- data/lib/ruby_memprofiler_pprof/profile_app.rb +8 -12
- data/lib/ruby_memprofiler_pprof/profile_data.rb +7 -8
- data/lib/ruby_memprofiler_pprof/version.rb +1 -1
- data/lib/ruby_memprofiler_pprof.rb +5 -4
- data/libexec/ruby_memprofiler_pprof_profile +6 -6
- metadata +207 -200
- data/ext/ruby_memprofiler_pprof/backtrace.c +0 -429
- data/ext/ruby_memprofiler_pprof/collector.c +0 -1055
- data/ext/ruby_memprofiler_pprof/compat.c +0 -182
- data/ext/ruby_memprofiler_pprof/extconf.rb +0 -72
- data/ext/ruby_memprofiler_pprof/pprof.upb.c +0 -170
- data/ext/ruby_memprofiler_pprof/pprof.upb.h +0 -848
- data/ext/ruby_memprofiler_pprof/pprof_out.c +0 -285
- data/ext/ruby_memprofiler_pprof/ruby_memprofiler_pprof.c +0 -11
- data/ext/ruby_memprofiler_pprof/ruby_memprofiler_pprof.h +0 -301
- data/ext/ruby_memprofiler_pprof/strtab.c +0 -391
@@ -1,429 +0,0 @@
|
|
1
|
-
// External ruby headers
|
2
|
-
#include <ruby.h>
|
3
|
-
#include <ruby/debug.h>
|
4
|
-
// Also include _INTERNAL_ ruby headers, from the debase-ruby_core_source gem.
|
5
|
-
// This will let us reach into the guts of the Ruby interpreter in a very, VERY
|
6
|
-
// API-unstable way.
|
7
|
-
#include <vm_core.h>
|
8
|
-
#include <iseq.h>
|
9
|
-
|
10
|
-
#include "ruby_memprofiler_pprof.h"
|
11
|
-
|
12
|
-
// We need access to the rb_vm_frame_method_entry method from vm_insnhelper.c; this function
|
13
|
-
// gives us the method information for C functions in Ruby backtraces.
|
14
|
-
// We have a prototype in vm_core.h, and the implementation in vm_insnhelper.c is "extern"
|
15
|
-
// (i.e. it is not "static").
|
16
|
-
//
|
17
|
-
// That would _normally_ mean we can simply just call it, BUT - Ruby is compiled by default
|
18
|
-
// with -fvisibility=hidden. That makes the function callable by other C files in the Ruby
|
19
|
-
// source tree, but it's NOT callable from code in other .so files (like our C extension);
|
20
|
-
// the linker marks the symbol as STV_HIDDEN in the .so file when it's linked. So, if we
|
21
|
-
// simply try to call it, when requiring our extension, the dynamic loader will complain
|
22
|
-
// that it can't resolve the symbol rb_vm_frame_method_entry.
|
23
|
-
//
|
24
|
-
// (In case you were wondering, other Ruby functions that are supposed to be called from
|
25
|
-
// C extensions are marked with "#pragma GCC visibility push(default)", which marks the
|
26
|
-
// function with "default visibility" and thus overrides -fvisibility=hidden and allows
|
27
|
-
// the function to be called).
|
28
|
-
//
|
29
|
-
// To work around this, I copied the definition of rb_vm_frame_method_entry (and
|
30
|
-
// check_method_entry, which it calls) into this file. I checked and the implementation
|
31
|
-
// is pretty much identical from Ruby 2.6.0 -> 3.1.0 so this _should_ be OK. Note that
|
32
|
-
// we also mark _our_ copy of this function as __attribute__(( visibility("hidden") ))
|
33
|
-
// so that we don't export it either.
|
34
|
-
|
35
|
-
static rb_callable_method_entry_t *
|
36
|
-
check_method_entry(VALUE obj, int can_be_svar)
|
37
|
-
{
|
38
|
-
if (obj == Qfalse) return NULL;
|
39
|
-
|
40
|
-
#if VM_CHECK_MODE > 0
|
41
|
-
if (!RB_TYPE_P(obj, T_IMEMO)) rb_bug("check_method_entry: unknown type: %s", rb_obj_info(obj));
|
42
|
-
#endif
|
43
|
-
|
44
|
-
switch (imemo_type(obj)) {
|
45
|
-
case imemo_ment:
|
46
|
-
return (rb_callable_method_entry_t *)obj;
|
47
|
-
case imemo_cref:
|
48
|
-
return NULL;
|
49
|
-
case imemo_svar:
|
50
|
-
if (can_be_svar) {
|
51
|
-
return check_method_entry(((struct vm_svar *)obj)->cref_or_me, 0);
|
52
|
-
}
|
53
|
-
// falls through
|
54
|
-
default:
|
55
|
-
#if VM_CHECK_MODE > 0
|
56
|
-
rb_bug("check_method_entry: svar should not be there:");
|
57
|
-
#endif
|
58
|
-
return NULL;
|
59
|
-
}
|
60
|
-
}
|
61
|
-
|
62
|
-
__attribute__(( visibility("hidden") ))
|
63
|
-
const rb_callable_method_entry_t *
|
64
|
-
rb_vm_frame_method_entry(const rb_control_frame_t *cfp)
|
65
|
-
{
|
66
|
-
const VALUE *ep = cfp->ep;
|
67
|
-
rb_callable_method_entry_t *me;
|
68
|
-
|
69
|
-
while (!VM_ENV_LOCAL_P(ep)) {
|
70
|
-
if ((me = check_method_entry(ep[VM_ENV_DATA_INDEX_ME_CREF], 0)) != NULL) return me;
|
71
|
-
ep = VM_ENV_PREV_EP(ep);
|
72
|
-
}
|
73
|
-
return check_method_entry(ep[VM_ENV_DATA_INDEX_ME_CREF], 1);
|
74
|
-
}
|
75
|
-
|
76
|
-
// Allocates, initializes and returns a new location table. A location table keeps track of a mapping
|
77
|
-
// of (compact!) location IDs to functions/line numbers. This keeps things in a convenient form for
|
78
|
-
// later turning to pprof, but also makes sure that we don't store the same char *'s for function/file
|
79
|
-
// names over and over again.
|
80
|
-
// Requires a reference to a string interning table, which must be valid for the lifetime of this
|
81
|
-
// loctab object.
|
82
|
-
struct mpp_rb_loctab *mpp_rb_loctab_new(struct mpp_strtab *strtab) {
|
83
|
-
struct mpp_rb_loctab *loctab = mpp_xmalloc(sizeof(struct mpp_rb_loctab));
|
84
|
-
loctab->strtab = strtab;
|
85
|
-
loctab->functions = st_init_numtable();
|
86
|
-
loctab->locations = st_init_numtable();
|
87
|
-
loctab->function_count = 0;
|
88
|
-
loctab->location_count = 0;
|
89
|
-
return loctab;
|
90
|
-
}
|
91
|
-
|
92
|
-
// Destroys the loctab, including its own memory.
|
93
|
-
void mpp_rb_loctab_destroy(struct mpp_rb_loctab *loctab) {
|
94
|
-
st_free_table(loctab->functions);
|
95
|
-
st_free_table(loctab->locations);
|
96
|
-
mpp_free(loctab);
|
97
|
-
}
|
98
|
-
|
99
|
-
struct fnloc_st_update_args {
|
100
|
-
struct mpp_rb_loctab *loctab;
|
101
|
-
uint64_t location_id;
|
102
|
-
uint64_t function_id;
|
103
|
-
struct mpp_rb_loctab_location *location;
|
104
|
-
struct mpp_rb_loctab_function *function;
|
105
|
-
VALUE fn_name_value;
|
106
|
-
VALUE file_name_value;
|
107
|
-
uint64_t location_line_number;
|
108
|
-
int64_t function_line_number;
|
109
|
-
};
|
110
|
-
|
111
|
-
|
112
|
-
static int function_st_update(st_data_t *key, st_data_t *value, st_data_t ctx, int exists) {
|
113
|
-
struct fnloc_st_update_args *args = (struct fnloc_st_update_args *)ctx;
|
114
|
-
|
115
|
-
if (exists) {
|
116
|
-
// Function already exists; put it in our outargs
|
117
|
-
args->function = (struct mpp_rb_loctab_function *)*value;
|
118
|
-
} else {
|
119
|
-
// Function doesn't exist; build it.
|
120
|
-
args->function = mpp_xmalloc(sizeof(struct mpp_rb_loctab_function));
|
121
|
-
*value = (st_data_t)args->function;
|
122
|
-
args->function->refcount = 0; // Will be incrmeented in backtrace_capture
|
123
|
-
args->function->id = args->function_id;
|
124
|
-
args->loctab->function_count++;
|
125
|
-
|
126
|
-
mpp_strtab_intern_rbstr(
|
127
|
-
args->loctab->strtab, args->fn_name_value,
|
128
|
-
&args->function->function_name, &args->function->function_name_len
|
129
|
-
);
|
130
|
-
|
131
|
-
if (RTEST(args->file_name_value)) {
|
132
|
-
mpp_strtab_intern_rbstr(
|
133
|
-
args->loctab->strtab, args->file_name_value,
|
134
|
-
&args->function->file_name, &args->function->file_name_len
|
135
|
-
);
|
136
|
-
} else {
|
137
|
-
mpp_strtab_intern_cstr(
|
138
|
-
args->loctab->strtab, "(unknown filename)",
|
139
|
-
&args->function->file_name, &args->function->file_name_len
|
140
|
-
);
|
141
|
-
}
|
142
|
-
args->function->line_number = args->function_line_number;
|
143
|
-
}
|
144
|
-
|
145
|
-
return ST_CONTINUE;
|
146
|
-
}
|
147
|
-
|
148
|
-
static int location_st_update(st_data_t *key, st_data_t *value, st_data_t ctx, int exists) {
|
149
|
-
struct fnloc_st_update_args *args = (struct fnloc_st_update_args *)ctx;
|
150
|
-
|
151
|
-
if (exists) {
|
152
|
-
// Location already exists - put it in our outargs.
|
153
|
-
args->location = (struct mpp_rb_loctab_location *)*value;
|
154
|
-
args->function = args->location->function;
|
155
|
-
} else {
|
156
|
-
// Location does not already exist. Make a new one.
|
157
|
-
args->location = mpp_xmalloc(sizeof(struct mpp_rb_loctab_location));
|
158
|
-
*value = (st_data_t)args->location;
|
159
|
-
args->location->refcount = 0; // will be incremented in backtrace_capture
|
160
|
-
args->location->id = args->location_id;
|
161
|
-
args->loctab->location_count++;
|
162
|
-
|
163
|
-
// Need to find a _function_ for it too.
|
164
|
-
st_update(args->loctab->functions, args->function_id, function_st_update, (st_data_t)args);
|
165
|
-
args->location->function = args->function;
|
166
|
-
args->location->line_number = args->location_line_number;
|
167
|
-
}
|
168
|
-
|
169
|
-
return ST_CONTINUE;
|
170
|
-
}
|
171
|
-
|
172
|
-
static int function_st_deref(st_data_t *key, st_data_t *value, st_data_t ctx, int exists) {
|
173
|
-
struct mpp_rb_loctab *loctab = (struct mpp_rb_loctab *)ctx;
|
174
|
-
|
175
|
-
MPP_ASSERT_MSG(exists, "attempted to decrement refcount on non-existing function");
|
176
|
-
struct mpp_rb_loctab_function *fn = (struct mpp_rb_loctab_function *)*value;
|
177
|
-
MPP_ASSERT_MSG(fn->refcount > 0, "attempted to decrement zero refcount on function");
|
178
|
-
fn->refcount--;
|
179
|
-
if (fn->refcount == 0) {
|
180
|
-
// Unref its string table entries.
|
181
|
-
mpp_strtab_release(loctab->strtab, fn->function_name, fn->function_name_len);
|
182
|
-
mpp_strtab_release(loctab->strtab, fn->file_name, fn->file_name_len);
|
183
|
-
mpp_free(fn);
|
184
|
-
loctab->function_count--;
|
185
|
-
return ST_DELETE;
|
186
|
-
}
|
187
|
-
return ST_CONTINUE;
|
188
|
-
}
|
189
|
-
|
190
|
-
static int location_st_deref(st_data_t *key, st_data_t *value, st_data_t ctx, int exists) {
|
191
|
-
struct mpp_rb_loctab *loctab = (struct mpp_rb_loctab *)ctx;
|
192
|
-
|
193
|
-
MPP_ASSERT_MSG(exists, "attempted to decrement refcount on non-existing location");
|
194
|
-
struct mpp_rb_loctab_location *loc = (struct mpp_rb_loctab_location *)*value;
|
195
|
-
MPP_ASSERT_MSG(loc->refcount > 0, "attempted to decrement zero refcount on location");
|
196
|
-
loc->refcount--;
|
197
|
-
if (loc->refcount == 0) {
|
198
|
-
// Deref its function too.
|
199
|
-
st_update(loctab->functions, loc->function->id, function_st_deref, (st_data_t)loctab);
|
200
|
-
mpp_free(loc);
|
201
|
-
loctab->location_count--;
|
202
|
-
return ST_DELETE;
|
203
|
-
}
|
204
|
-
return ST_CONTINUE;
|
205
|
-
}
|
206
|
-
|
207
|
-
// Captures a backtrace!
|
208
|
-
//
|
209
|
-
// This method uses internal Ruby headers to implement a rough copy of what backtrace_each in vm_backtrace.c
|
210
|
-
// does. This is _TREMENDOUSLY_ faster than actually calling rb_make_backtrace, because that creates Ruby
|
211
|
-
// VALUE objects to hold its result. Doing so from a newobj tracepoint is legal, AFAICT, but really slow
|
212
|
-
// (from my profiling of the profiler, doing this causes the garbage collector to run, _a lot_, in the
|
213
|
-
// middle of creating the original object).
|
214
|
-
//
|
215
|
-
// By poking directly at the VM internal structures, we can stuff the result into C structures and not
|
216
|
-
// allocate any ruby VALUEs avoiding this issue. It's a _LOT_ faster - it takes the overhead from ~50%
|
217
|
-
// (with 1% of allocations ampled), to < 1%. So it's definitely worthwhile despite how disgusting it is.
|
218
|
-
//
|
219
|
-
// Also note: This captures backtraces most recent call LAST, which is the opposite order to how the pprof
|
220
|
-
// protobuf wants them, so they have to be reversed later. It's not so convenient to just capture it in
|
221
|
-
// the correct order because we may have to skip some frames; thus if we filled in the frame array backwards,
|
222
|
-
// we might not actually wind up filling frames[0].
|
223
|
-
//
|
224
|
-
// This method allocates a struct mpp_rb_backtrace and saves it to *bt_out. The reason for this awkward
|
225
|
-
// calling convention (as opposed to just returning it) is so that the caller can detect if we got longjmp'd
|
226
|
-
// out of here by some of the Ruby calls below, and appropriately destroy *bt_out via a call to destroy.
|
227
|
-
void mpp_rb_backtrace_capture(struct mpp_rb_loctab *loctab, struct mpp_rb_backtrace **bt_out) {
|
228
|
-
const rb_control_frame_t *last_cfp = GET_EC()->cfp;
|
229
|
-
const rb_control_frame_t *start_cfp = RUBY_VM_END_CONTROL_FRAME(GET_EC());
|
230
|
-
|
231
|
-
// Allegedly, according to vm_backtrace.c, we need to skip the first two control frames because they
|
232
|
-
// are "dummy frames", whatever that means.
|
233
|
-
start_cfp = RUBY_VM_NEXT_CONTROL_FRAME(start_cfp);
|
234
|
-
start_cfp = RUBY_VM_NEXT_CONTROL_FRAME(start_cfp);
|
235
|
-
|
236
|
-
// Calculate how many frames are in this backtrace.
|
237
|
-
ptrdiff_t max_backtrace_size;
|
238
|
-
if (start_cfp < last_cfp) {
|
239
|
-
max_backtrace_size = 0;
|
240
|
-
} else {
|
241
|
-
max_backtrace_size = start_cfp - last_cfp + 1;
|
242
|
-
}
|
243
|
-
|
244
|
-
*bt_out = mpp_xmalloc(sizeof(struct mpp_rb_backtrace));
|
245
|
-
struct mpp_rb_backtrace *bt = *bt_out;
|
246
|
-
bt->frame_locations = mpp_xmalloc(sizeof(uint64_t) * max_backtrace_size);
|
247
|
-
// Set bt->frames_count to zero, to start with, and only increment it when we see a frame
|
248
|
-
// in the backtrace we can actually understand. We might skip over some of them, so max_backtrace_size
|
249
|
-
// is a maximum of how many frames there might be in the backtrace.
|
250
|
-
bt->frames_count = 0;
|
251
|
-
// But do keep track of the memsize
|
252
|
-
bt->memsize = sizeof(uint64_t) * max_backtrace_size;
|
253
|
-
|
254
|
-
ptrdiff_t i;
|
255
|
-
const rb_control_frame_t *cfp;
|
256
|
-
for (i = 0, cfp = start_cfp; i < max_backtrace_size; i++, cfp = RUBY_VM_NEXT_CONTROL_FRAME(cfp)) {
|
257
|
-
|
258
|
-
// Collect all the information we might need about this frame and store it in this struct
|
259
|
-
struct fnloc_st_update_args frame_args;
|
260
|
-
frame_args.loctab = loctab;
|
261
|
-
if (cfp->iseq && cfp->pc) {
|
262
|
-
// I believe means this backtrace frame is ruby code
|
263
|
-
size_t iseq_pos = (size_t)(cfp->pc - cfp->iseq->body->iseq_encoded);
|
264
|
-
// To quote Ruby:
|
265
|
-
// "use pos-1 because PC points next instruction at the beginning of instruction"
|
266
|
-
if (iseq_pos) iseq_pos--;
|
267
|
-
frame_args.location_line_number = rb_iseq_line_no(cfp->iseq, iseq_pos);
|
268
|
-
frame_args.fn_name_value = rb_iseq_method_name(cfp->iseq);
|
269
|
-
frame_args.file_name_value = rb_iseq_path(cfp->iseq);
|
270
|
-
frame_args.function_line_number = NUM2ULONG(rb_iseq_first_lineno(cfp->iseq));
|
271
|
-
|
272
|
-
// Use the object ID of the function name (which _should_ be interned, right, and so unique?)
|
273
|
-
// as the function ID.
|
274
|
-
frame_args.function_id = NUM2ULONG(rb_obj_id(frame_args.fn_name_value));
|
275
|
-
// Use the lower 48 bits (which is the sizeof an address on x86_64) of the function name,
|
276
|
-
// and the line number in the top 16 bits, as the "location id".
|
277
|
-
// Guess this won't work reliably if your function has more than 16k lines, in which case...
|
278
|
-
// ...just get a better function?
|
279
|
-
frame_args.location_id =
|
280
|
-
(frame_args.location_line_number << 48) | (frame_args.function_id & 0x0000FFFFFFFFFFFF);
|
281
|
-
|
282
|
-
} else if (RUBYVM_CFUNC_FRAME_P(cfp)) {
|
283
|
-
// I believe means that this backtrace frame is a call to a cfunc
|
284
|
-
|
285
|
-
|
286
|
-
const rb_callable_method_entry_t *me = rb_vm_frame_method_entry(cfp);
|
287
|
-
|
288
|
-
frame_args.location_line_number = 0;
|
289
|
-
frame_args.function_line_number = 0;
|
290
|
-
frame_args.fn_name_value = rb_id2str(me->def->original_id);
|
291
|
-
frame_args.file_name_value = Qnil;
|
292
|
-
|
293
|
-
// Use the symbol ID of the method name (which is interned forever) as both the function
|
294
|
-
// ID and the location ID (since we have no line numbers).
|
295
|
-
frame_args.location_id = me->def->original_id;
|
296
|
-
frame_args.function_id = me->def->original_id;
|
297
|
-
} else {
|
298
|
-
// No idea what this means. It's silently ignored in vm_backtrace.c. Guess we will too.
|
299
|
-
continue;
|
300
|
-
}
|
301
|
-
|
302
|
-
// Store the location frame.
|
303
|
-
bt->frame_locations[bt->frames_count] = frame_args.location_id;
|
304
|
-
bt->frames_count++;
|
305
|
-
|
306
|
-
// Lookup, or allocate & store, the location/function struct.
|
307
|
-
st_update(loctab->locations, frame_args.location_id, location_st_update, (st_data_t)&frame_args);
|
308
|
-
// Either we created a new one, or looked up an existing one, but either way we need to bump its refcount.
|
309
|
-
frame_args.location->refcount++;
|
310
|
-
frame_args.function->refcount++;
|
311
|
-
}
|
312
|
-
}
|
313
|
-
|
314
|
-
void mpp_rb_backtrace_capture_slowrb(struct mpp_rb_loctab *loctab, struct mpp_rb_backtrace **bt_out) {
|
315
|
-
VALUE ruby_bt = rb_funcall(rb_thread_current(), rb_intern("backtrace_locations"), 0);
|
316
|
-
int64_t ruby_bt_len = RARRAY_LEN(ruby_bt);
|
317
|
-
|
318
|
-
*bt_out = mpp_xmalloc(sizeof(struct mpp_rb_backtrace));
|
319
|
-
struct mpp_rb_backtrace *bt = *bt_out;
|
320
|
-
bt->frame_locations = mpp_xmalloc(sizeof(uint64_t) * ruby_bt_len);
|
321
|
-
bt->frames_count = 0;
|
322
|
-
bt->memsize = sizeof(uint64_t) * ruby_bt_len;
|
323
|
-
|
324
|
-
for (int64_t i = 0; i < ruby_bt_len; i++) {
|
325
|
-
// The backtrace_locations result is backwards compared to the fast version.
|
326
|
-
VALUE ruby_bt_loc = RARRAY_AREF(ruby_bt, ruby_bt_len - i - 1);
|
327
|
-
|
328
|
-
// Intern the function name as the function ID, and the full string as the loc id.
|
329
|
-
VALUE fn_name = rb_funcall(ruby_bt_loc, rb_intern("base_label"), 0);
|
330
|
-
const char *fn_name_interned;
|
331
|
-
size_t fn_name_interned_len;
|
332
|
-
mpp_strtab_intern_rbstr(loctab->strtab, fn_name, &fn_name_interned, &fn_name_interned_len);
|
333
|
-
VALUE loc_name = rb_funcall(ruby_bt_loc, rb_intern("to_s"), 0);
|
334
|
-
const char *loc_name_interned;
|
335
|
-
size_t loc_name_interned_len;
|
336
|
-
mpp_strtab_intern_rbstr(loctab->strtab, loc_name, &loc_name_interned, &loc_name_interned_len);
|
337
|
-
|
338
|
-
VALUE file_name = rb_funcall(ruby_bt_loc, rb_intern("path"), 0);
|
339
|
-
|
340
|
-
VALUE line_no = rb_funcall(ruby_bt_loc, rb_intern("lineno"), 0);
|
341
|
-
uint64_t line_no_int = 0;
|
342
|
-
if (RTEST(line_no)) {
|
343
|
-
line_no_int = NUM2ULONG(line_no);
|
344
|
-
}
|
345
|
-
|
346
|
-
bt->frame_locations[i] = (uint64_t)loc_name_interned;
|
347
|
-
bt->frames_count++;
|
348
|
-
|
349
|
-
// Lookup, or allocate & store, the location/function struct.
|
350
|
-
struct fnloc_st_update_args frame_args;
|
351
|
-
frame_args.loctab = loctab;
|
352
|
-
frame_args.location_id = (uint64_t)loc_name_interned;
|
353
|
-
frame_args.location_line_number = line_no_int;
|
354
|
-
frame_args.fn_name_value = fn_name;
|
355
|
-
frame_args.file_name_value = file_name;
|
356
|
-
frame_args.function_line_number = 0;
|
357
|
-
frame_args.function_id = (uint64_t)fn_name_interned;
|
358
|
-
st_update(loctab->locations, frame_args.location_id, location_st_update, (st_data_t)&frame_args);
|
359
|
-
frame_args.location->refcount++;
|
360
|
-
frame_args.function->refcount++;
|
361
|
-
|
362
|
-
// We _DEFINITELY_ leak memory here. We interned the function name string/location string to use
|
363
|
-
// as the unique int64 location ID, but we're not freeing it here. This is because we need to keep
|
364
|
-
// it in the table so that it continues to be unique (and some other location doesn't wind up with
|
365
|
-
// the same ID).
|
366
|
-
// Since this method basically exists for benchmarking, and real users should be using the CFP
|
367
|
-
// method, I'll live with the leak for now until I figure out a better unique ID for the function.
|
368
|
-
}
|
369
|
-
}
|
370
|
-
|
371
|
-
void mpp_rb_backtrace_destroy(struct mpp_rb_loctab *loctab, struct mpp_rb_backtrace *bt) {
|
372
|
-
for (int64_t i = 0; i < bt->frames_count; i++) {
|
373
|
-
st_update(loctab->locations, bt->frame_locations[i], location_st_deref, (st_data_t)loctab);
|
374
|
-
}
|
375
|
-
mpp_free(bt->frame_locations);
|
376
|
-
mpp_free(bt);
|
377
|
-
}
|
378
|
-
|
379
|
-
size_t mpp_rb_backtrace_memsize(struct mpp_rb_backtrace *bt) {
|
380
|
-
return bt->memsize;
|
381
|
-
}
|
382
|
-
|
383
|
-
size_t mpp_rb_loctab_memsize(struct mpp_rb_loctab *loctab) {
|
384
|
-
return sizeof(*loctab) +
|
385
|
-
sizeof(struct mpp_rb_loctab_location) * loctab->location_count +
|
386
|
-
sizeof(struct mpp_rb_loctab_function) * loctab->function_count +
|
387
|
-
st_memsize(loctab->locations) +
|
388
|
-
st_memsize(loctab->functions);
|
389
|
-
}
|
390
|
-
|
391
|
-
struct mpp_rb_loctab_each_location_ctx {
|
392
|
-
mpp_rb_loctab_each_location_cb cb;
|
393
|
-
void *cb_ctx;
|
394
|
-
struct mpp_rb_loctab *loctab;
|
395
|
-
};
|
396
|
-
|
397
|
-
static int mpp_rb_loctab_each_location_thunk(st_data_t key, st_data_t value, st_data_t ctx) {
|
398
|
-
struct mpp_rb_loctab_each_location_ctx * thunkctx = (struct mpp_rb_loctab_each_location_ctx *)ctx;
|
399
|
-
struct mpp_rb_loctab_location *loc = (struct mpp_rb_loctab_location *)value;
|
400
|
-
return thunkctx->cb(thunkctx->loctab, loc, thunkctx->cb_ctx);
|
401
|
-
}
|
402
|
-
|
403
|
-
void mpp_rb_loctab_each_location(struct mpp_rb_loctab *loctab, mpp_rb_loctab_each_location_cb cb, void *ctx) {
|
404
|
-
struct mpp_rb_loctab_each_location_ctx thunkctx;
|
405
|
-
thunkctx.loctab = loctab;
|
406
|
-
thunkctx.cb = cb;
|
407
|
-
thunkctx.cb_ctx = ctx;
|
408
|
-
st_foreach(loctab->locations, mpp_rb_loctab_each_location_thunk, (st_data_t)&thunkctx);
|
409
|
-
}
|
410
|
-
|
411
|
-
struct mpp_rb_loctab_each_function_ctx {
|
412
|
-
mpp_rb_loctab_each_function_cb cb;
|
413
|
-
void *cb_ctx;
|
414
|
-
struct mpp_rb_loctab *loctab;
|
415
|
-
};
|
416
|
-
|
417
|
-
static int mpp_rb_loctab_each_function_thunk(st_data_t key, st_data_t value, st_data_t ctx) {
|
418
|
-
struct mpp_rb_loctab_each_function_ctx * thunkctx = (struct mpp_rb_loctab_each_function_ctx *)ctx;
|
419
|
-
struct mpp_rb_loctab_function *loc = (struct mpp_rb_loctab_function *)value;
|
420
|
-
return thunkctx->cb(thunkctx->loctab, loc, thunkctx->cb_ctx);
|
421
|
-
}
|
422
|
-
|
423
|
-
void mpp_rb_loctab_each_function(struct mpp_rb_loctab *loctab, mpp_rb_loctab_each_function_cb cb, void *ctx) {
|
424
|
-
struct mpp_rb_loctab_each_function_ctx thunkctx;
|
425
|
-
thunkctx.loctab = loctab;
|
426
|
-
thunkctx.cb = cb;
|
427
|
-
thunkctx.cb_ctx = ctx;
|
428
|
-
st_foreach(loctab->functions, mpp_rb_loctab_each_function_thunk, (st_data_t)&thunkctx);
|
429
|
-
}
|