[pypy-commit] stmgc weakref: add stm_dbg_get_hdr_str() that prints the flags and tid of an object

Raemi noreply at buildbot.pypy.org
Fri Jul 19 07:57:37 CEST 2013


Author: Remi Meier <remi.meier at gmail.com>
Branch: weakref
Changeset: r414:560fad6b4f7f
Date: 2013-07-19 07:57 +0200
http://bitbucket.org/pypy/stmgc/changeset/560fad6b4f7f/

Log:	add stm_dbg_get_hdr_str() that prints the flags and tid of an object

diff --git a/c4/demo_random.c b/c4/demo_random.c
--- a/c4/demo_random.c
+++ b/c4/demo_random.c
@@ -516,7 +516,7 @@
         t = (nodeptr)read_barrier(ptrs[i]);
         w = t->weakref;
         if(w) {
-            ww = stm_read_barrier(w);
+            ww = (weaknodeptr)stm_read_barrier((gcptr)w);
             assert(stm_get_tid((gcptr)ww) == GCTID_WEAKREF);
             if (ww->node) {
                 check((gcptr)ww->node);
diff --git a/c4/et.c b/c4/et.c
--- a/c4/et.c
+++ b/c4/et.c
@@ -6,6 +6,28 @@
  */
 #include "stmimpl.h"
 
+#ifdef _GC_DEBUG
+char tmp_buf[128];
+char* stm_dbg_get_hdr_str(gcptr obj)
+{
+    char *cur;
+    char *flags[] = GC_FLAG_NAMES;
+    int i;
+
+    i = 0;
+    cur = tmp_buf;
+    while (flags[i]) {
+        if (obj->h_tid & (STM_FIRST_GCFLAG << i)) {
+            cur += sprintf(cur, "%s|", flags[i]);
+        }
+        i++;
+    }
+    cur += sprintf(cur, "tid=%ld\n", stm_get_tid(obj));
+    return tmp_buf;
+}
+#endif
+
+
 
 __thread struct tx_descriptor *thread_descriptor = NULL;
 
diff --git a/c4/et.h b/c4/et.h
--- a/c4/et.h
+++ b/c4/et.h
@@ -200,4 +200,7 @@
 void DescriptorInit(void);
 void DescriptorDone(void);
 
+#ifdef _GC_DEBUG
+char* stm_dbg_get_hdr_str(gcptr obj);
+#endif
 #endif  /* _ET_H */


More information about the pypy-commit mailing list