ruby-changes:72967
From: Matt <ko1@a...>
Date: Fri, 19 Aug 2022 02:26:00 +0900 (JST)
Subject: [ruby-changes:72967] 92603bbd69 (master): [ci skip][Feature #18910][lldb] Dedup lldb_init
https://git.ruby-lang.org/ruby.git/commit/?id=92603bbd69 From 92603bbd6996000d2541edb22e0b2ecac646c3de Mon Sep 17 00:00:00 2001 From: Matt Valentine-House <matt@e...> Date: Thu, 18 Aug 2022 11:44:25 +0100 Subject: [ci skip][Feature #18910][lldb] Dedup lldb_init by moving it fully into RbBaseCommand --- misc/lldb_cruby.py | 4 ++- misc/lldb_rb/rb_base_command.py | 55 +++++++++++++++++++++-------------------- 2 files changed, 31 insertions(+), 28 deletions(-) diff --git a/misc/lldb_cruby.py b/misc/lldb_cruby.py index e30acffc40..595d54dfab 100755 --- a/misc/lldb_cruby.py +++ b/misc/lldb_cruby.py @@ -741,5 +741,7 @@ def __lldb_init_module(debugger, internal_dict): https://github.com/ruby/ruby/blob/trunk/misc/lldb_cruby.py#L741 debugger.HandleCommand("command script add -f lldb_cruby.dump_page dump_page") debugger.HandleCommand("command script add -f lldb_cruby.dump_page_rvalue dump_page_rvalue") debugger.HandleCommand("command script add -f lldb_cruby.rb_id2str rb_id2str") - lldb_init(debugger) + + lldb_rb.rb_base_command.RbBaseCommand.lldb_init(debugger) + print("lldb scripts for ruby has been installed.") diff --git a/misc/lldb_rb/rb_base_command.py b/misc/lldb_rb/rb_base_command.py index 44b2996d80..bf98b67612 100644 --- a/misc/lldb_rb/rb_base_command.py +++ b/misc/lldb_rb/rb_base_command.py @@ -8,12 +8,39 @@ class RbBaseCommand: https://github.com/ruby/ruby/blob/trunk/misc/lldb_rb/rb_base_command.py#L8 command = f"command script add -c {module_name}.{cls.__name__} {cls.program}" debugger.HandleCommand(command) + @classmethod + def lldb_init(cls, debugger): + target = debugger.GetSelectedTarget() + global SIZEOF_VALUE + SIZEOF_VALUE = target.FindFirstType("VALUE").GetByteSize() + + value_types = [] + g = globals() + + imemo_types = target.FindFirstType("enum imemo_type") + + for member in imemo_types.GetEnumMembers(): + g[member.GetName()] = member.GetValueAsUnsigned() + + for enum in target.FindFirstGlobalVariable("ruby_dummy_gdb_enums"): + enum = enum.GetType() + members = enum.GetEnumMembers() + for i in range(0, members.GetSize()): + member = members.GetTypeEnumMemberAtIndex(i) + name = member.GetName() + value = member.GetValueAsUnsigned() + g[name] = value + + if name.startswith("RUBY_T_"): + value_types.append(name) + g["value_types"] = value_types + def __init__(self, debugger, _internal_dict): self.internal_dict = _internal_dict def __call__(self, debugger, command, exe_ctx, result): if not ("RUBY_Qfalse" in globals()): - self._lldb_init(debugger) + RbBaseCommand.lldb_init(debugger) self.build_environment(debugger) self.call(debugger, command, exe_ctx, result) @@ -40,29 +67,3 @@ class RbBaseCommand: https://github.com/ruby/ruby/blob/trunk/misc/lldb_rb/rb_base_command.py#L67 result.Clear() result.write(output1) result.write(output2) - - def _lldb_init(self, debugger): - target = debugger.GetSelectedTarget() - global SIZEOF_VALUE - SIZEOF_VALUE = target.FindFirstType("VALUE").GetByteSize() - - value_types = [] - g = globals() - - imemo_types = target.FindFirstType("enum imemo_type") - - for member in imemo_types.GetEnumMembers(): - g[member.GetName()] = member.GetValueAsUnsigned() - - for enum in target.FindFirstGlobalVariable("ruby_dummy_gdb_enums"): - enum = enum.GetType() - members = enum.GetEnumMembers() - for i in range(0, members.GetSize()): - member = members.GetTypeEnumMemberAtIndex(i) - name = member.GetName() - value = member.GetValueAsUnsigned() - g[name] = value - - if name.startswith("RUBY_T_"): - value_types.append(name) - g["value_types"] = value_types -- cgit v1.2.1 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/