[前][次][番号順一覧][スレッド一覧]

ruby-changes:72968

From: Matt <ko1@a...>
Date: Fri, 19 Aug 2022 02:26:00 +0900 (JST)
Subject: [ruby-changes:72968] b26aec9daa (master): [ci-skip][Feature #18910][lldb] New directory structure

https://git.ruby-lang.org/ruby.git/commit/?id=b26aec9daa

From b26aec9daa03a4f3da225e9e4f7a43e916928712 Mon Sep 17 00:00:00 2001
From: Matt Valentine-House <matt@e...>
Date: Wed, 13 Jul 2022 18:14:44 +0100
Subject: [ci-skip][Feature #18910][lldb] New directory structure

Push the newly refactored lldb files into a sub-directory so that we're
not cluttering up the misc directory
---
 misc/commands/command_template.py           | 25 -----------
 misc/commands/heap_page_command.py          | 26 -----------
 misc/commands/rclass_ext_command.py         | 14 ------
 misc/constants.py                           |  4 --
 misc/lldb_cruby.py                          |  6 +--
 misc/lldb_rb/commands/command_template.py   | 30 +++++++++++++
 misc/lldb_rb/commands/heap_page_command.py  | 26 +++++++++++
 misc/lldb_rb/commands/rclass_ext_command.py | 14 ++++++
 misc/lldb_rb/constants.py                   |  4 ++
 misc/lldb_rb/rb_base_command.py             | 68 +++++++++++++++++++++++++++++
 misc/rb_base_command.py                     | 68 -----------------------------
 11 files changed, 145 insertions(+), 140 deletions(-)
 delete mode 100644 misc/commands/command_template.py
 delete mode 100644 misc/commands/heap_page_command.py
 delete mode 100644 misc/commands/rclass_ext_command.py
 delete mode 100644 misc/constants.py
 create mode 100644 misc/lldb_rb/commands/command_template.py
 create mode 100644 misc/lldb_rb/commands/heap_page_command.py
 create mode 100644 misc/lldb_rb/commands/rclass_ext_command.py
 create mode 100644 misc/lldb_rb/constants.py
 create mode 100644 misc/lldb_rb/rb_base_command.py
 delete mode 100644 misc/rb_base_command.py

diff --git a/misc/commands/command_template.py b/misc/commands/command_template.py
deleted file mode 100644
index bbc4b09157..0000000000
--- a/misc/commands/command_template.py
+++ /dev/null
@@ -1,25 +0,0 @@ https://github.com/ruby/ruby/blob/trunk/#L0
-# This is a command template for implementing a helper function inside LLDB. To
-# use this file
-#   1. Copy it and rename the copy so it ends with `_command.py`.
-#   2. Rename the class to something descriptive that ends with Command.
-#   3. Change the program variable to be a descriptive command name
-#   4. Ensure you are inheriting from RbBaseCommand or another command that 
-#      implements the same interfact
-
-# This test command inherits from RbBaseCommand which provides access to Ruby
-# globals and utility helpers
-class TestCommand(RbBaseCommand):
-    # program is the keyword the user will type in lldb to execute this command
-    program = "test"
-
-    # help_string will be displayed in lldb when the user uses the help functions
-    help_string = "This is a test command to show how to implement lldb commands"
-
-    # call is where our command logic will be implemented
-    def call(self, debugger, command, exe_ctx, result):
-        # This method will be called once the LLDB environment has been setup.
-        # You will have access to self.target, self.process, self.frame, and 
-        # self.thread
-        # 
-        # This is where we should implement our command logic
-        pass
diff --git a/misc/commands/heap_page_command.py b/misc/commands/heap_page_command.py
deleted file mode 100644
index ee502a40b8..0000000000
--- a/misc/commands/heap_page_command.py
+++ /dev/null
@@ -1,26 +0,0 @@ https://github.com/ruby/ruby/blob/trunk/#L0
-import lldb
-
-from constants import *
-from rb_base_command import RbBaseCommand
-
-class HeapPageCommand(RbBaseCommand):
-    program = "heap_page"
-    help_string = "prints out 'struct heap_page' for a VALUE pointer in the page"
-
-    def call(self, debugger, command, exe_ctx, result):
-        self.t_heap_page_body = self.target.FindFirstType("struct heap_page_body")
-        self.t_heap_page_ptr = self.target.FindFirstType("struct heap_page").GetPointerType()
-
-        page = self._get_page(self.frame.EvaluateExpression(command))
-        page.Cast(self.t_heap_page_ptr)
-
-        self._append_command_output(debugger, "p (struct heap_page *) %0#x" % page.GetValueAsUnsigned(), result)
-        self._append_command_output(debugger, "p *(struct heap_page *) %0#x" % page.GetValueAsUnsigned(), result)
-
-    def _get_page(self, val):
-        addr = val.GetValueAsUnsigned()
-        page_addr = addr & ~(HEAP_PAGE_ALIGN_MASK)
-        address = lldb.SBAddress(page_addr, self.target)
-        body = self.target.CreateValueFromAddress("page", address, self.t_heap_page_body)
-
-        return body.GetValueForExpressionPath("->header.page")
diff --git a/misc/commands/rclass_ext_command.py b/misc/commands/rclass_ext_command.py
deleted file mode 100644
index 3d17f646bd..0000000000
--- a/misc/commands/rclass_ext_command.py
+++ /dev/null
@@ -1,14 +0,0 @@ https://github.com/ruby/ruby/blob/trunk/#L0
-from rb_base_command import RbBaseCommand
-
-class RclassExtCommand(RbBaseCommand):
-    program = "rclass_ext"
-    help_string = "retrieves and prints the rb_classext_struct for the VALUE pointer passed in"
-
-    def call(self, debugger, command, exe_ctx, result):
-        uintptr_t = self.target.FindFirstType("uintptr_t")
-        rclass_t = self.target.FindFirstType("struct RClass")
-        rclass_ext_t = self.target.FindFirstType("rb_classext_t")
-
-        rclass_addr = self.target.EvaluateExpression(command).Cast(uintptr_t)
-        rclass_ext_addr = (rclass_addr.GetValueAsUnsigned() + rclass_t.GetByteSize())
-        debugger.HandleCommand("p *(rb_classext_t *)%0#x" % rclass_ext_addr)
diff --git a/misc/constants.py b/misc/constants.py
deleted file mode 100644
index ec3050a399..0000000000
--- a/misc/constants.py
+++ /dev/null
@@ -1,4 +0,0 @@ https://github.com/ruby/ruby/blob/trunk/#L0
-HEAP_PAGE_ALIGN_LOG = 16
-HEAP_PAGE_ALIGN_MASK = (~(~0 << HEAP_PAGE_ALIGN_LOG))
-HEAP_PAGE_ALIGN = (1 << HEAP_PAGE_ALIGN_LOG)
-HEAP_PAGE_SIZE = HEAP_PAGE_ALIGN
diff --git a/misc/lldb_cruby.py b/misc/lldb_cruby.py
index 6655d768ae..e30acffc40 100755
--- a/misc/lldb_cruby.py
+++ b/misc/lldb_cruby.py
@@ -15,7 +15,7 @@ import shlex https://github.com/ruby/ruby/blob/trunk/misc/lldb_cruby.py#L15
 import platform
 import glob
 
-from constants import *
+from lldb_rb.constants import *
 
 # BEGIN FUNCTION STYLE DECLS
 # This will be refactored to use class style decls in the misc/commands dir
@@ -716,11 +716,11 @@ def rb_id2str(debugger, command, result, internal_dict): https://github.com/ruby/ruby/blob/trunk/misc/lldb_cruby.py#L716
 
 load_dir, _ = os.path.split(os.path.realpath(__file__))
 
-for fname in glob.glob(f"{load_dir}/commands/*_command.py"):
+for fname in glob.glob(f"{load_dir}/lldb_rb/commands/*_command.py"):
     _, basename = os.path.split(fname)
     mname, _ = os.path.splitext(basename)
 
-    exec(f"import commands.{mname}")
+    exec(f"import lldb_rb.commands.{mname}")
 
 def __lldb_init_module(debugger, internal_dict):
     # Register all classes that subclass RbBaseCommand
diff --git a/misc/lldb_rb/commands/command_template.py b/misc/lldb_rb/commands/command_template.py
new file mode 100644
index 0000000000..843b66398f
--- /dev/null
+++ b/misc/lldb_rb/commands/command_template.py
@@ -0,0 +1,30 @@ https://github.com/ruby/ruby/blob/trunk/misc/lldb_rb/commands/command_template.py#L1
+# This is a command template for implementing a helper function inside LLDB. To
+# use this file
+#   1. Copy it and rename the copy so it ends with `_command.py`.
+#   2. Rename the class to something descriptive that ends with Command.
+#   3. Change the program variable to be a descriptive command name
+#   4. Ensure you are inheriting from RbBaseCommand or another command that 
+#      implements the same interfact
+
+import lldb
+
+from lldb_rb.constants import *
+from lldb_rb.rb_base_command import RbBaseCommand
+
+# This test command inherits from RbBaseCommand which provides access to Ruby
+# globals and utility helpers
+class TestCommand(RbBaseCommand):
+    # program is the keyword the user will type in lldb to execute this command
+    program = "test"
+
+    # help_string will be displayed in lldb when the user uses the help functions
+    help_string = "This is a test command to show how to implement lldb commands"
+
+    # call is where our command logic will be implemented
+    def call(self, debugger, command, exe_ctx, result):
+        # This method will be called once the LLDB environment has been setup.
+        # You will have access to self.target, self.process, self.frame, and 
+        # self.thread
+        # 
+        # This is where we should implement our command logic
+        pass
diff --git a/misc/lldb_rb/commands/heap_page_command.py b/misc/lldb_rb/commands/heap_page_command.py
new file mode 100644
index 0000000000..edb74a415b
--- /dev/null
+++ b/misc/lldb_rb/commands/heap_page_command.py
@@ -0,0 +1,26 @@ https://github.com/ruby/ruby/blob/trunk/misc/lldb_rb/commands/heap_page_command.py#L1
+import lldb
+
+from lldb_rb.constants import *
+from lldb_rb.rb_base_command import RbBaseCommand
+
+class HeapPageCommand(RbBaseCommand):
+    program = "heap_page"
+    help_string = "prints out 'struct heap_page' for a VALUE pointer in the page"
+
+    def call(self, debugger, command, exe_ctx, result):
+        self.t_heap_page_body = self.target.FindFirstType("struct heap_page_body")
+        self.t_heap_page_ptr = self.target.FindFirstType("struct heap_page").GetPointerType()
+
+        page = self._get_page(self.frame.EvaluateExpression(command))
+        page.Cast(self.t_heap_page_ptr)
+
+        self._append_command_output(debugger, "p (struct heap_page *) %0#x" % page.GetValueAsUnsigned(), result)
+        self._append_command_output(debugger, "p *(struct heap_page *) %0#x" % page.GetValueAsUnsigned(), result)
+
+    def _get_page(self, val):
+        addr = val.GetValueAsUnsigned()
+        page_addr = addr & ~(HEAP_PAGE_ALIGN_MASK)
+        address = lldb.SBAddress(page_addr, self.target)
+        body = self.target.CreateValueFromAddress("page", address, self.t_heap_page_body)
+
+        return body.GetValueForExpressionPat (... truncated)

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]