From af456ec9eefd320b496ce54686ca2099c26ca301 Mon Sep 17 00:00:00 2001
From: langfei <langfei@huawei.com>
Date: Wed, 5 Jul 2023 10:32:14 +0800
Subject: [PATCH] fix py3example script run fail

Signed-off-by: langfei <langfei@huawei.com>
---
 .../general/tapset/python_local.stpm          | 37 ++++++++++++++++++-
 1 file changed, 36 insertions(+), 1 deletion(-)

diff --git a/testsuite/systemtap.examples/general/tapset/python_local.stpm b/testsuite/systemtap.examples/general/tapset/python_local.stpm
index 84f9a55..f02ff7a 100644
--- a/testsuite/systemtap.examples/general/tapset/python_local.stpm
+++ b/testsuite/systemtap.examples/general/tapset/python_local.stpm
@@ -7,5 +7,40 @@
 # Set this to the location of the python 3 .so
 @define PYTHON3_LIBRARY
 %(
-  "/usr/lib64/libpython3.4m.so.1.0"
+  "/usr/lib64/libpython3.7m.so.1.0"
+%)
+
+@define Py3DictKeysObject(object) %(
+                    @cast(@object, "PyDictKeysObject", @PYTHON3_LIBRARY)
+                    %)
+@define Py3DictKeyEntry(object) %(
+                    @cast(@object, "PyDictKeyEntry", @PYTHON3_LIBRARY)
+                    %)
+
+@define DK_SIZE(dk) %(
+    @Py3DictKeysObject(@dk)->dk_size
+%)
+@define DK_IXSIZE(dk) %(
+    %( CONFIG_64BIT == "y" %?
+        %( CONFIG_COMPAT == "y" %?
+            (@__compat_task
+             ? (@DK_SIZE(@dk) <= 0xff ? 1 : (@DK_SIZE(@dk) <= 0xffff ? 2
+: 4))
+             : (@DK_SIZE(@dk) <= 0xff ?
+                1 : (@DK_SIZE(@dk) <= 0xffff ?
+                2 : (@DK_SIZE(@dk) <= 0xffffffff ? 4 : 8))))
+        %:
+            (@DK_SIZE(@dk) <= 0xff ?
+             1 : (@DK_SIZE(@dk) <= 0xffff ?
+             2 : (@DK_SIZE(@dk) <= 0xffffffff ? 4 : 8)))
+        %)
+    %:
+        (@DK_SIZE(@dk) <= 0xff ? 1 : (@DK_SIZE(@dk) <= 0xffff ? 2 : 4))
+    %)
+%)
+
+@define DK_ENTRIES(dk) %(
+     (@choose_defined(@Py3DictKeysObject(@dk)->dk_entries,
+(&@Py3DictKeyEntry(&@Py3DictKeysObject(@dk)->dk_indices[@DK_SIZE(@dk) *
+@DK_IXSIZE(@dk)]))))
 %)
-- 
2.33.0

