From fc31fb4c0c0cf23b1c44047b666ac502c7c05e90 Mon Sep 17 00:00:00 2001 From: Francisco Javier Honduvilla Coto Date: Sun, 20 Aug 2023 13:35:27 +0100 Subject: [PATCH] Add support for Ruby 3.2.2 Signed-off-by: Francisco Javier Honduvilla Coto --- src/ruby_versions/mod.rs | 1 + src/ruby_versions/ruby_3_2_2.yaml | 14 ++++++ xtask/src/main.rs | 77 +++++++++++++++++++++++++++++++ 3 files changed, 92 insertions(+) create mode 100644 src/ruby_versions/ruby_3_2_2.yaml diff --git a/src/ruby_versions/mod.rs b/src/ruby_versions/mod.rs index c478c73..eb7e35f 100644 --- a/src/ruby_versions/mod.rs +++ b/src/ruby_versions/mod.rs @@ -10,4 +10,5 @@ pub const ruby_version_configs_yaml: &[&str] = &[ include_str!("ruby_3_1_3.yaml"), include_str!("ruby_3_2_0.yaml"), include_str!("ruby_3_2_1.yaml"), + include_str!("ruby_3_2_2.yaml"), ]; diff --git a/src/ruby_versions/ruby_3_2_2.yaml b/src/ruby_versions/ruby_3_2_2.yaml new file mode 100644 index 0000000..ce841bc --- /dev/null +++ b/src/ruby_versions/ruby_3_2_2.yaml @@ -0,0 +1,14 @@ +major_version: 3 +minor_version: 2 +patch_version: 2 +vm_offset: 0 +vm_size_offset: 8 +control_frame_t_sizeof: 64 +cfp_offset: 16 +label_offset: 16 +path_flavour: 1 +line_info_size_offset: 128 +line_info_table_offset: 112 +lineno_offset: 0 +main_thread_offset: 32 +ec_offset: 520 diff --git a/xtask/src/main.rs b/xtask/src/main.rs index d9215a3..92773eb 100644 --- a/xtask/src/main.rs +++ b/xtask/src/main.rs @@ -830,6 +830,82 @@ fn dump_ruby_structs_ruby_3_2_1() { .unwrap(); } +fn dump_ruby_structs_ruby_3_2_2() { + let vm_offset: i32 = offset_of!( + rbspy_ruby_structs::ruby_3_2_0::rb_execution_context_struct, + vm_stack + ) as i32; + + let vm_size_offset: i32 = offset_of!( + rbspy_ruby_structs::ruby_3_2_0::rb_execution_context_struct, + vm_stack_size + ) as i32; + + let control_frame_t_sizeof: i32 = + size_of::() as i32; + + let cfp_offset: i32 = offset_of!( + rbspy_ruby_structs::ruby_3_2_0::rb_execution_context_struct, + cfp + ) as i32; + + let label_offset: i32 = offset_of!( + rbspy_ruby_structs::ruby_3_2_0::rb_iseq_location_struct, + label + ) as i32; + + let line_info_table_offset: i32 = offset_of!( + rbspy_ruby_structs::ruby_3_2_0::rb_iseq_constant_body, + insns_info + ) as i32; + + let line_info_size_offset: i32 = line_info_table_offset + + (offset_of!( + rbspy_ruby_structs::ruby_3_2_0::rb_iseq_constant_body_iseq_insn_info, + size + ) as i32); + + let main_thread_offset: i32 = offset_of!( + rbspy_ruby_structs::ruby_3_2_0::rb_vm_struct__bindgen_ty_1, + main_thread + ) as i32; + + let ruby_3_2_2_offsets = RubyVersionOffsets { + major_version: 3, + minor_version: 2, + patch_version: 2, + vm_offset, + vm_size_offset, + control_frame_t_sizeof, + cfp_offset, + label_offset, + path_flavour: 1, + line_info_size_offset, + line_info_table_offset, + lineno_offset: 0, + main_thread_offset, + // we want: ruby_current_vm_ptr->ractor->main_thread->ractor(->threads)->running_ec + // we have: ruby_current_vm_ptr->ractor->main_thread + + // .ractor + // (gdb) p/d offsetof(struct rb_thread_struct, ractor) + // $15 = 24 + + // .running_ec + // /* hole */ /* hole */ + // (gdb) p/d sizeof(struct rb_ractor_pub) + sizeof(struct rb_ractor_sync) + sizeof(VALUE) + sizeof(_Bool) + 7 + sizeof(rb_nativethread_cond_t) + sizeof(struct list_head) + sizeof(unsigned int) *3 + 4 + sizeof(rb_global_vm_lock_t) + // $16 = 520 + ec_offset: 520, + }; + + let yaml = serde_yaml::to_string(&ruby_3_2_2_offsets).unwrap(); + + File::create("src/ruby_versions/ruby_3_2_2.yaml") + .unwrap() + .write_all(yaml.as_bytes()) + .unwrap(); +} + fn main() { dump_ruby_structs_ruby_2_6_0(); dump_ruby_structs_ruby_2_6_3(); @@ -844,4 +920,5 @@ fn main() { dump_ruby_structs_ruby_3_1_3(); dump_ruby_structs_ruby_3_2_0(); dump_ruby_structs_ruby_3_2_1(); + dump_ruby_structs_ruby_3_2_2(); }