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

ruby-changes:72966

From: Matt <ko1@a...>
Date: Fri, 19 Aug 2022 02:25:59 +0900 (JST)
Subject: [ruby-changes:72966] 281bcc8e64 (master): [ci-skip][Feature #18910][lldb] Port heap_page command to new LLDB framework

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

From 281bcc8e64accac2d3ab465abde4962de725857d Mon Sep 17 00:00:00 2001
From: Matt Valentine-House <matt@e...>
Date: Wed, 13 Jul 2022 13:18:45 +0100
Subject: [ci-skip][Feature #18910][lldb] Port heap_page command to new LLDB
 framework

---
 misc/commands/heap_page_command.py | 26 ++++++++++++++++++++++++++
 misc/lldb_cruby.py                 | 14 --------------
 2 files changed, 26 insertions(+), 14 deletions(-)
 create mode 100644 misc/commands/heap_page_command.py

diff --git a/misc/commands/heap_page_command.py b/misc/commands/heap_page_command.py
new file mode 100644
index 0000000000..ee502a40b8
--- /dev/null
+++ b/misc/commands/heap_page_command.py
@@ -0,0 +1,26 @@ https://github.com/ruby/ruby/blob/trunk/misc/commands/heap_page_command.py#L1
+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/lldb_cruby.py b/misc/lldb_cruby.py
index de8628754c..5106f78881 100755
--- a/misc/lldb_cruby.py
+++ b/misc/lldb_cruby.py
@@ -469,19 +469,6 @@ def check_bits(page, bitmap_name, bitmap_index, bitmap_bit, v): https://github.com/ruby/ruby/blob/trunk/misc/lldb_cruby.py#L469
     else:
         return ' '
 
-def heap_page(debugger, command, ctx, result, internal_dict):
-    target = debugger.GetSelectedTarget()
-    process = target.GetProcess()
-    thread = process.GetSelectedThread()
-    frame = thread.GetSelectedFrame()
-
-    val = frame.EvaluateExpression(command)
-    page = get_page(lldb, target, val)
-    page_type = target.FindFirstType("struct heap_page").GetPointerType()
-    page.Cast(page_type)
-    append_command_output(debugger, "p (struct heap_page *) %0#x" % page.GetValueAsUnsigned(), result)
-    append_command_output(debugger, "p *(struct heap_page *) %0#x" % page.GetValueAsUnsigned(), result)
-
 def heap_page_body(debugger, command, ctx, result, internal_dict):
     target = debugger.GetSelectedTarget()
     process = target.GetProcess()
@@ -766,7 +753,6 @@ def __lldb_init_module(debugger, internal_dict): https://github.com/ruby/ruby/blob/trunk/misc/lldb_cruby.py#L753
     debugger.HandleCommand("command script add -f lldb_cruby.count_objects rb_count_objects")
     debugger.HandleCommand("command script add -f lldb_cruby.stack_dump_raw SDR")
     debugger.HandleCommand("command script add -f lldb_cruby.dump_node dump_node")
-    debugger.HandleCommand("command script add -f lldb_cruby.heap_page heap_page")
     debugger.HandleCommand("command script add -f lldb_cruby.heap_page_body heap_page_body")
     debugger.HandleCommand("command script add -f lldb_cruby.rb_backtrace rbbt")
     debugger.HandleCommand("command script add -f lldb_cruby.dump_page dump_page")
-- 
cgit v1.2.1


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

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