components/python/python27/patches/14-py_db.patch
author Rich Burridge <rich.burridge@oracle.com>
Thu, 28 Jun 2012 12:59:05 -0700
changeset 896 50be262e44f7
child 1914 00e8dbcb9b1e
child 3367 ed5024e47b53
permissions -rw-r--r--
7155369 mdb should work with python 2.7 bits
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
896
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
     1
diff --git Python-2.7.1/Makefile.pre.in.orig Python-2.7.1/Makefile.pre.in
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
     2
--- Python-2.7.1/Makefile.pre.in.orig   Sun Feb 13 19:37:16 2011
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
     3
+++ Python-2.7.1/Makefile.pre.in        Sun Feb 13 20:55:04 2011
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
     4
@@ -364,7 +364,7 @@
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
     5
 
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
     6
 # Default target
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
     7
 all:		build_all
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
     8
-build_all:	$(BUILDPYTHON) oldsharedmods sharedmods gdbhooks
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
     9
+build_all:	$(BUILDPYTHON) oldsharedmods sharedmods gdbhooks build-py_db
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    10
 
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    11
 # Compile a binary with gcc profile guided optimization.
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    12
 profile-opt:
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    13
@@ -709,6 +709,19 @@
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    14
 
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    15
 $(LIBRARY_OBJS) $(MODOBJS) Modules/python.o: $(PYTHON_HEADERS)
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    16
 
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    17
+SHLIB_FLAGS = -shared -fpic
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    18
+
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    19
+libpython2.7_db.so.1.0:        $(srcdir)/py_db/libpython27_db.c
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    20
+	$(CC) -o $@ $(CFLAGS) $(CPPFLAGS) $(SHLIB_FLAGS) $<
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    21
+
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    22
+check_offset:  $(srcdir)/py_db/check_offsets.c
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    23
+	$(CC) -o $@ $(CFLAGS) $(CPPFLAGS) $<
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    24
+
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    25
+build-py_db:   libpython2.7_db.so.1.0 check_offset
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    26
+
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    27
+install-py_db: libpython2.7_db.so.1.0 check_offset
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    28
+	$(INSTALL_SHARED) libpython2.7_db.so.1.0 $(DESTDIR)$(LIBDIR)
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    29
+	$(INSTALL_PROGRAM) check_offset $(DESTDIR)$(BINDIR)
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    30
 
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    31
 ######################################################################
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    32
 
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    33
@@ -773,7 +786,7 @@
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    34
 		$(TESTPYTHON) $(TESTPROG) $(MEMTESTOPTS)
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    35
 
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    36
 # Install everything
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    37
-install:	@FRAMEWORKINSTALLFIRST@ altinstall bininstall maninstall @FRAMEWORKINSTALLLAST@
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    38
+install:	@FRAMEWORKINSTALLFIRST@ altinstall bininstall maninstall @FRAMEWORKINSTALLLAST@ install-py_db
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    39
 
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    40
 # Install almost everything without disturbing previous versions
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    41
 altinstall:	@FRAMEWORKALTINSTALLFIRST@ altbininstall libinstall inclinstall libainstall \
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    42
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    43
diff --git Python-2.7.1/py_db/check_offsets.c Python-2.7.1/py_db/check_offsets.c
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    44
new file mode 100644
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    45
--- /dev/null
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    46
+++ Python-2.7.1/py_db/check_offsets.c
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    47
@@ -0,0 +1,87 @@
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    48
+/*
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    49
+ * CDDL HEADER START
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    50
+ *
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    51
+ * The contents of this file are subject to the terms of the
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    52
+ * Common Development and Distribution License (the "License").
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    53
+ * You may not use this file except in compliance with the License.
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    54
+ *
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    55
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    56
+ * or http://www.opensolaris.org/os/licensing.
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    57
+ * See the License for the specific language governing permissions
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    58
+ * and limitations under the License.
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    59
+ *
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    60
+ * When distributing Covered Code, include this CDDL HEADER in each
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    61
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    62
+ * If applicable, add the following below this CDDL HEADER, with the
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    63
+ * fields enclosed by brackets "[]" replaced with your own identifying
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    64
+ * information: Portions Copyright [yyyy] [name of copyright owner]
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    65
+ *
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    66
+ * CDDL HEADER END
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    67
+ */
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    68
+/*
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    69
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    70
+ */
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    71
+
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    72
+#include <stdio.h>
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    73
+
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    74
+#include <Python.h>
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    75
+#include <frameobject.h>
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    76
+
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    77
+#include "libpython27_db_32.h"
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    78
+
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    79
+#if 0
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    80
+#define	offsetof(s, m)	((size_t)(&(((s *)0)->m)))
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    81
+#endif
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    82
+
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    83
+int
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    84
+main(void)
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    85
+{
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    86
+/*
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    87
+ * PyCodeObject co_name
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    88
+ * PyCodeObject co_filename
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    89
+ * PyCodeObject co_lnotab
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    90
+ * PyFrameObject f_back
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    91
+ * PyFrameObject f_code
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    92
+ * PyFrameObject f_lasti
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    93
+ * PyInterpreterState next
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    94
+ * PyInterpreterState tstate_head
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    95
+ * PyStringObject ob_sval
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    96
+ * PyStringObject ob_size
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    97
+ * PyThreadState frame
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    98
+ * PyThreadState next
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    99
+ */
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   100
+
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   101
+	printf("struct member: native 32\n");
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   102
+	printf("PyCodeObject co_name: %d %d\n", offsetof(PyCodeObject, co_name),
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   103
+	    offsetof(PyCodeObject32, co_name));
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   104
+	printf("PyCodeObject co_filename: %d %d\n", offsetof(PyCodeObject,
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   105
+	    co_filename), offsetof(PyCodeObject32, co_filename));
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   106
+	printf("PyCodeObject co_lnotab: %d %d\n", offsetof(PyCodeObject,
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   107
+	    co_lnotab), offsetof(PyCodeObject32, co_lnotab));
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   108
+	printf("PyFrameObject f_back: %d %d\n", offsetof(PyFrameObject, f_back),
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   109
+	    offsetof(PyFrameObject32, f_back));
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   110
+	printf("PyFrameObject f_code: %d %d\n", offsetof(PyFrameObject, f_code),
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   111
+	    offsetof(PyFrameObject32, f_code));
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   112
+	printf("PyFrameObject f_lasti: %d %d\n", offsetof(PyFrameObject,
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   113
+	    f_lasti), offsetof(PyFrameObject32, f_lasti));
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   114
+	printf("PyInterpreterState next: %d %d\n", offsetof(PyInterpreterState,
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   115
+	    next), offsetof(PyInterpreterState32, next));
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   116
+	printf("PyInterpreterState tstate_head: %d %d\n",
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   117
+	    offsetof(PyInterpreterState, tstate_head),
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   118
+	    offsetof(PyInterpreterState32, tstate_head));
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   119
+	printf("PyStringObject ob_sval: %d %d\n", offsetof(PyStringObject,
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   120
+	    ob_sval), offsetof(PyStringObject32, ob_sval));
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   121
+	printf("PyStringObject ob_size: %d %d\n", offsetof(PyStringObject,
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   122
+	    ob_size), offsetof(PyStringObject32, ob_size));
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   123
+	printf("PyThreadState frame: %d %d\n", offsetof(PyThreadState, frame),
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   124
+	    offsetof(PyThreadState32, frame));
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   125
+	printf("PyThreadState next: %d %d\n", offsetof(PyThreadState, next),
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   126
+	    offsetof(PyThreadState32, next));
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   127
+
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   128
+	printf("\nObject sizes\n");
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   129
+	printf("PyObject: %d %d\n", sizeof (PyObject), sizeof (PyObject32));
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   130
+	printf("PyVarObject: %d %d\n", sizeof (PyVarObject),
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   131
+	    sizeof (PyVarObject32));
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   132
+
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   133
+	return (0);
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   134
+}
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   135
diff --git Python-2.7.1/py_db/libpython27_db.c Python-2.7.1/py_db/libpython27_db.c
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   136
new file mode 100644
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   137
--- /dev/null
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   138
+++ Python-2.7.1/py_db/libpython27_db.c
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   139
@@ -0,0 +1,654 @@
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   140
+/*
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   141
+ * CDDL HEADER START
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   142
+ *
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   143
+ * The contents of this file are subject to the terms of the
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   144
+ * Common Development and Distribution License (the "License").
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   145
+ * You may not use this file except in compliance with the License.
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   146
+ *
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   147
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   148
+ * or http://www.opensolaris.org/os/licensing.
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   149
+ * See the License for the specific language governing permissions
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   150
+ * and limitations under the License.
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   151
+ *
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   152
+ * When distributing Covered Code, include this CDDL HEADER in each
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   153
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   154
+ * If applicable, add the following below this CDDL HEADER, with the
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   155
+ * fields enclosed by brackets "[]" replaced with your own identifying
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   156
+ * information: Portions Copyright [yyyy] [name of copyright owner]
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   157
+ *
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   158
+ * CDDL HEADER END
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   159
+ */
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   160
+/*
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   161
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   162
+ */
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   163
+
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   164
+#include <stdio.h>
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   165
+#include <stdlib.h>
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   166
+#include <string.h>
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   167
+#include <errno.h>
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   168
+#include <gelf.h>
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   169
+
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   170
+#include <Python.h>
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   171
+#include <frameobject.h>
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   172
+
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   173
+#include "libpython27_db.h"
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   174
+#if defined(_LP64)
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   175
+#include "libpython27_db_32.h"
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   176
+#endif /* _LP64 */
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   177
+
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   178
+/*
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   179
+ * Because MDB always runs the debugger in the same datamodel as the target,
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   180
+ * only functions that are used by the procfs part of this interface (or shared
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   181
+ * between the two) are written as 64->32 aware.
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   182
+ */
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   183
+typedef struct pydb_arch_ops {
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   184
+	ssize_t	(*strobj_readdata)(pydb_agent_t *, uintptr_t, unsigned char *,
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   185
+	    size_t);
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   186
+	int	(*frameinfo)(pydb_agent_t *, uintptr_t, char *,
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   187
+	    size_t, char *, size_t, int *);
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   188
+} pydb_arch_ops_t;
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   189
+
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   190
+struct pydb_agent {
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   191
+	struct ps_prochandle *pdb_ph;
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   192
+	int pdb_vers;
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   193
+	int pdb_is_64bit;
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   194
+	int pdb_datamodel;
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   195
+	const pydb_arch_ops_t *pdb_ops;
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   196
+};
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   197
+
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   198
+typedef uintptr_t (*pdi_next_cb_t)(pydb_iter_t *);
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   199
+
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   200
+struct pydb_iter {
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   201
+	struct ps_prochandle *pdi_ph;
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   202
+	uintptr_t pdi_current;
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   203
+	pdi_next_cb_t pdi_nextf;
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   204
+};
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   205
+
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   206
+#define	LIBPYTHON	"libpython2.7.so"
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   207
+
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   208
+#define	MIN(x, y)	(((x) < (y)) ? (x) : (y))
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   209
+
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   210
+/* Generic interface to helper functions */
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   211
+static ssize_t pydb_strobj_readdata(pydb_agent_t *py, uintptr_t addr,
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   212
+    unsigned char *buf, size_t buf_len);
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   213
+static int pydb_getlno(pydb_agent_t *py, uintptr_t lnotab_addr, int firstline,
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   214
+    int lastinst);
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   215
+static int pydb_frameinfo(pydb_agent_t *py, uintptr_t addr, char *funcnm,
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   216
+    size_t funcnm_sz, char *filenm, size_t filenm_sz, int *lineno);
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   217
+
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   218
+/* datamodel specific implementation of helper functions */
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   219
+static ssize_t pydb_strobj_readdata_native(pydb_agent_t *py, uintptr_t addr,
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   220
+    unsigned char *buf, size_t buf_len);
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   221
+static int pydb_frameinfo_native(pydb_agent_t *py, uintptr_t addr, char *funcnm,
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   222
+    size_t funcnm_sz, char *filenm, size_t filenm_sz, int *lineno);
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   223
+
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   224
+#if defined (_LP64)
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   225
+static ssize_t pydb_strobj_readdata_32(pydb_agent_t *py, uintptr_t addr,
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   226
+    unsigned char *buf, size_t buf_len);
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   227
+static int pydb_frameinfo_32(pydb_agent_t *py, uintptr_t addr, char *funcnm,
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   228
+    size_t funcnm_sz, char *filenm, size_t filenm_sz, int *lineno);
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   229
+#endif /* _LP64 */
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   230
+
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   231
+static ssize_t pydb_strobj_readstr(pydb_agent_t *py, uintptr_t addr, char *buf,
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   232
+    size_t len);
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   233
+
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   234
+/* Iterator function next routines.  Plugable, configured by iterator init */
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   235
+static uintptr_t pydb_frame_iter_next(pydb_iter_t *iter);
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   236
+static uintptr_t pydb_interp_iter_next(pydb_iter_t *iter);
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   237
+static uintptr_t pydb_thread_iter_next(pydb_iter_t *iter);
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   238
+
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   239
+static const char *strbasename(const char *s);
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   240
+
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   241
+static const pydb_arch_ops_t arch_ops_native = {
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   242
+	.frameinfo = pydb_frameinfo_native,
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   243
+	.strobj_readdata = pydb_strobj_readdata_native,
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   244
+};
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   245
+
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   246
+#if defined (_LP64)
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   247
+static const pydb_arch_ops_t arch_ops_32 = {
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   248
+	.frameinfo = pydb_frameinfo_32,
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   249
+	.strobj_readdata = pydb_strobj_readdata_32,
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   250
+};
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   251
+#endif /* _LP64 */
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   252
+
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   253
+static const char *
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   254
+strbasename(const char *s)
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   255
+{
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   256
+	const char *p = strrchr(s, '/');
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   257
+
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   258
+	if (p == NULL)
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   259
+		return (s);
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   260
+
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   261
+	return (++p);
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   262
+}
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   263
+
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   264
+/* Agent creation / destruction routines */
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   265
+
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   266
+pydb_agent_t *
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   267
+pydb_agent_create(struct ps_prochandle *P, int vers)
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   268
+{
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   269
+	pydb_agent_t *py;
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   270
+	int datamodel;
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   271
+
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   272
+	if (vers != PYDB_VERSION) {
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   273
+		errno = ENOTSUP;
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   274
+		return (NULL);
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   275
+	}
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   276
+
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   277
+	if (ps_pdmodel(P, &datamodel) != PS_OK) {
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   278
+		return (NULL);
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   279
+	}
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   280
+
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   281
+	py = (pydb_agent_t *)malloc(sizeof (pydb_agent_t));
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   282
+	if (py == NULL) {
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   283
+		return (NULL);
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   284
+	}
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   285
+
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   286
+	py->pdb_ph = P;
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   287
+	py->pdb_vers = vers;
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   288
+	py->pdb_datamodel = datamodel;
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   289
+	py->pdb_is_64bit = 0;
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   290
+	py->pdb_ops = &arch_ops_native;
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   291
+
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   292
+#if defined (_LP64)
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   293
+	py->pdb_is_64bit = (datamodel == PR_MODEL_LP64);
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   294
+	if (!py->pdb_is_64bit) {
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   295
+		py->pdb_ops = &arch_ops_32;
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   296
+	}
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   297
+#endif /* _LP64 */
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   298
+
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   299
+	return (py);
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   300
+}
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   301
+
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   302
+void
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   303
+pydb_agent_destroy(pydb_agent_t *py)
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   304
+{
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   305
+	if (py == NULL) {
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   306
+		return;
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   307
+	}
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   308
+
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   309
+	free(py);
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   310
+}
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   311
+
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   312
+/* Helper functions */
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   313
+static int
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   314
+pydb_getlno(pydb_agent_t *py, uintptr_t lnotab_addr, int firstline,
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   315
+    int lastinst)
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   316
+{
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   317
+	unsigned char lnotab[4096];
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   318
+	ssize_t lnotab_len;
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   319
+	int addr, line;
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   320
+	int i;
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   321
+
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   322
+	lnotab_len = pydb_strobj_readdata(py, lnotab_addr, lnotab,
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   323
+	    sizeof (lnotab));
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   324
+	if (lnotab_len < 0) {
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   325
+		return (-1);
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   326
+	}
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   327
+
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   328
+	/*
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   329
+	 * Python's line number algorithm is arcane. See here for details:
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   330
+	 * http://svn.python.org/projects/python/trunk/Objects/lnotab_notes.txt
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   331
+	 */
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   332
+
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   333
+	line = firstline;
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   334
+	for (addr = i = 0; i < lnotab_len; i += 2) {
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   335
+		if (addr + lnotab[i] > lastinst) {
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   336
+			break;
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   337
+		}
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   338
+		addr += lnotab[i];
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   339
+		line += lnotab[i + 1];
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   340
+	}
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   341
+
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   342
+	return (line);
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   343
+}
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   344
+
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   345
+static ssize_t
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   346
+pydb_strobj_readdata(pydb_agent_t *py, uintptr_t addr, unsigned char *buf,
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   347
+    size_t buf_len)
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   348
+{
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   349
+	return (py->pdb_ops->strobj_readdata(py, addr, buf, buf_len));
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   350
+}
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   351
+
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   352
+static ssize_t
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   353
+pydb_strobj_readdata_native(pydb_agent_t *py, uintptr_t addr,
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   354
+    unsigned char *buf, size_t buf_len)
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   355
+{
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   356
+	PyStringObject sobj;
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   357
+	ssize_t obj_sz;
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   358
+	ssize_t read_sz;
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   359
+	psaddr_t straddr;
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   360
+
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   361
+	/*
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   362
+	 * PyStringObjects are variable size.  The size of the PyStringObject
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   363
+	 * struct is fixed, and known at compile time; however, the size of the
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   364
+	 * associated buffer is variable.  The char[1] element at the end of the
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   365
+	 * structure contains the string, and the ob_size of the PyStringObject
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   366
+	 * indicates how much extra space was allocated to contain the string
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   367
+	 * buffer at the object's tail.  Read in the fixed size portion of the
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   368
+	 * object first, and then read the contents of the data buffer into the
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   369
+	 * buffer passed by the caller.
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   370
+	 */
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   371
+
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   372
+	if (ps_pread(py->pdb_ph, addr, &sobj, sizeof (PyStringObject))
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   373
+	    != PS_OK) {
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   374
+		return (-1);
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   375
+	}
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   376
+
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   377
+	obj_sz = (ssize_t)PyString_GET_SIZE(&sobj);
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   378
+
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   379
+	read_sz = MIN(obj_sz, (ssize_t)buf_len);
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   380
+	straddr = (psaddr_t)(addr + offsetof(PyStringObject, ob_sval));
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   381
+
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   382
+	if (ps_pread(py->pdb_ph, straddr, buf, (size_t)read_sz) != PS_OK) {
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   383
+		return (-1);
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   384
+	}
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   385
+
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   386
+	return (read_sz);
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   387
+}
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   388
+
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   389
+#if defined(_LP64)
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   390
+static ssize_t
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   391
+pydb_strobj_readdata_32(pydb_agent_t *py, uintptr_t addr,
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   392
+    unsigned char *buf, size_t buf_len)
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   393
+{
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   394
+	PyStringObject32 sobj;
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   395
+	ssize_t obj_sz;
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   396
+	ssize_t read_sz;
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   397
+	psaddr_t straddr;
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   398
+
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   399
+	/*
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   400
+	 * PyStringObjects are variable size.  The size of the PyStringObject
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   401
+	 * struct is fixed, and known at compile time; however, the size of the
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   402
+	 * associated buffer is variable.  The char[1] element at the end of the
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   403
+	 * structure contains the string, and the ob_size of the PyStringObject
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   404
+	 * indicates how much extra space was allocated to contain the string
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   405
+	 * buffer at the object's tail.  Read in the fixed size portion of the
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   406
+	 * object first, and then read the contents of the data buffer into the
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   407
+	 * buffer passed by the caller.
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   408
+	 */
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   409
+
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   410
+	if (ps_pread(py->pdb_ph, addr, &sobj, sizeof (PyStringObject32))
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   411
+	    != PS_OK) {
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   412
+		return (-1);
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   413
+	}
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   414
+
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   415
+	obj_sz = (ssize_t)PyString_GET_SIZE32(&sobj);
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   416
+
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   417
+	read_sz = MIN(obj_sz, (ssize_t)buf_len);
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   418
+	straddr = (psaddr_t)(addr + offsetof(PyStringObject32, ob_sval));
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   419
+
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   420
+	if (ps_pread(py->pdb_ph, straddr, buf, (size_t)read_sz) != PS_OK) {
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   421
+		return (-1);
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   422
+	}
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   423
+
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   424
+	return (read_sz);
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   425
+}
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   426
+#endif /* _LP64 */
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   427
+
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   428
+/*
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   429
+ * Most Python PyStringObjects contain strings, as one would expect.  However,
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   430
+ * due to some sleazy hackery in parts of the Python code, some string objects
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   431
+ * are used as buffers for binary data.  In the general case,
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   432
+ * pydb_strobj_readstr() should be used to read strings out of string objects.
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   433
+ * It wraps pydb_strobj_readdata(), which should be used by callers only when
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   434
+ * trying to retrieve binary data.  (This routine does some string cleanup).
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   435
+ */
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   436
+static ssize_t
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   437
+pydb_strobj_readstr(pydb_agent_t *py, uintptr_t addr, char *buf,
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   438
+    size_t buf_len)
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   439
+{
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   440
+	ssize_t read_sz;
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   441
+
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   442
+	read_sz = pydb_strobj_readdata(py, addr, (unsigned char *)buf, buf_len);
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   443
+
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   444
+	if (read_sz >= 0) {
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   445
+		if (read_sz >= buf_len) {
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   446
+			read_sz = buf_len - 1;
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   447
+		}
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   448
+
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   449
+		buf[read_sz] = '\0';
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   450
+	}
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   451
+
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   452
+	return (read_sz);
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   453
+}
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   454
+
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   455
+
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   456
+static int
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   457
+pydb_frameinfo(pydb_agent_t *py, uintptr_t addr, char *funcnm,
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   458
+    size_t funcnm_sz, char *filenm, size_t filenm_sz, int *lineno)
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   459
+{
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   460
+	return (py->pdb_ops->frameinfo(py, addr, funcnm, funcnm_sz,
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   461
+	    filenm, filenm_sz, lineno));
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   462
+}
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   463
+
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   464
+static int
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   465
+pydb_frameinfo_native(pydb_agent_t *py, uintptr_t addr, char *funcnm,
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   466
+    size_t funcnm_sz, char *filenm, size_t filenm_sz, int *lineno)
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   467
+{
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   468
+	PyFrameObject fo;
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   469
+	PyCodeObject co;
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   470
+	ssize_t rc;
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   471
+
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   472
+	if (ps_pread(py->pdb_ph, addr, &fo, sizeof (PyFrameObject))
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   473
+	    != PS_OK) {
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   474
+		return (-1);
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   475
+	}
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   476
+
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   477
+	if (ps_pread(py->pdb_ph, (uintptr_t)fo.f_code, &co,
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   478
+	    sizeof (PyCodeObject)) != PS_OK) {
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   479
+		return (-1);
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   480
+	}
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   481
+
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   482
+	rc = pydb_strobj_readstr(py, (uintptr_t)co.co_name, funcnm, funcnm_sz);
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   483
+	if (rc < 0) {
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   484
+		return (-1);
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   485
+	}
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   486
+
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   487
+	rc = pydb_strobj_readstr(py, (uintptr_t)co.co_filename, filenm,
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   488
+	    filenm_sz);
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   489
+	if (rc < 0) {
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   490
+		return (-1);
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   491
+	}
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   492
+
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   493
+	*lineno = pydb_getlno(py, (uintptr_t)co.co_lnotab, co.co_firstlineno,
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   494
+	    fo.f_lasti);
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   495
+	if (*lineno < 0) {
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   496
+		return (-1);
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   497
+	}
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   498
+
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   499
+	return (0);
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   500
+}
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   501
+
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   502
+#if defined (_LP64)
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   503
+static int
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   504
+pydb_frameinfo_32(pydb_agent_t *py, uintptr_t addr, char *funcnm,
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   505
+    size_t funcnm_sz, char *filenm, size_t filenm_sz, int *lineno)
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   506
+{
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   507
+	PyFrameObject32 fo;
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   508
+	PyCodeObject32 co;
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   509
+	ssize_t rc;
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   510
+
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   511
+	if (ps_pread(py->pdb_ph, addr, &fo, sizeof (PyFrameObject32))
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   512
+	    != PS_OK) {
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   513
+		return (-1);
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   514
+	}
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   515
+
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   516
+	if (ps_pread(py->pdb_ph, (uintptr_t)fo.f_code, &co,
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   517
+	    sizeof (PyCodeObject32)) != PS_OK) {
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   518
+		return (-1);
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   519
+	}
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   520
+
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   521
+	rc = pydb_strobj_readstr(py, (uintptr_t)co.co_name, funcnm, funcnm_sz);
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   522
+	if (rc < 0) {
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   523
+		return (-1);
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   524
+	}
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   525
+
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   526
+	rc = pydb_strobj_readstr(py, (uintptr_t)co.co_filename, filenm,
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   527
+	    filenm_sz);
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   528
+	if (rc < 0) {
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   529
+		return (-1);
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   530
+	}
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   531
+
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   532
+	*lineno = pydb_getlno(py, (uintptr_t)co.co_lnotab, co.co_firstlineno,
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   533
+	    fo.f_lasti);
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   534
+	if (*lineno < 0) {
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   535
+		return (-1);
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   536
+	}
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   537
+
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   538
+	return (0);
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   539
+}
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   540
+
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   541
+#endif /* _LP64 */
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   542
+
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   543
+/* Functions that are part of the library's interface */
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   544
+
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   545
+/*
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   546
+ * Given the address of a PyFrameObject, and a buffer of a known size,
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   547
+ * fill the buffer with a description of the frame.
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   548
+ */
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   549
+int
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   550
+pydb_get_frameinfo(pydb_agent_t *py, uintptr_t frame_addr, char *fbuf,
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   551
+    size_t bufsz, int verbose)
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   552
+{
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   553
+	char funcname[1024];
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   554
+	char filename[1024];
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   555
+	char *fn;
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   556
+	int lineno;
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   557
+	int length = (py->pdb_is_64bit ? 16 : 8);
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   558
+	int rc;
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   559
+
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   560
+	rc = pydb_frameinfo(py, frame_addr, funcname, sizeof (funcname),
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   561
+	    filename, sizeof (filename), &lineno);
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   562
+	if (rc < 0) {
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   563
+		return (-1);
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   564
+	}
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   565
+
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   566
+	if (!verbose) {
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   567
+		fn = (char *)strbasename(filename);
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   568
+	} else {
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   569
+		fn = filename;
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   570
+	}
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   571
+
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   572
+	(void) snprintf(fbuf, bufsz, "%0.*lx %s:%d %s()\n", length,
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   573
+	    frame_addr, fn, lineno, funcname);
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   574
+
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   575
+	return (0);
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   576
+}
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   577
+
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   578
+/*
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   579
+ * Return a description about a PyFrameObject, if the object is
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   580
+ * actually a PyFrameObject.  In this case, the pc argument is checked
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   581
+ * to make sure that it came from a function that takes a PyFrameObject
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   582
+ * as its first (argv[0]) argument.
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   583
+ */
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   584
+int
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   585
+pydb_pc_frameinfo(pydb_agent_t *py, uintptr_t pc, uintptr_t frame_addr,
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   586
+    char *fbuf, size_t bufsz)
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   587
+{
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   588
+	char funcname[1024];
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   589
+	char filename[1024];
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   590
+	int lineno;
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   591
+	int rc;
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   592
+	ps_sym_t psym;
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   593
+
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   594
+	/*
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   595
+	 * If PC doesn't match PyEval_EvalFrameEx in either libpython
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   596
+	 * or the executable, don't decode it.
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   597
+	 */
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   598
+	if (ps_pglobal_sym(py->pdb_ph, LIBPYTHON, "PyEval_EvalFrameEx", &psym)
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   599
+	    != PS_OK) {
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   600
+		return (-1);
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   601
+	}
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   602
+
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   603
+	/* If symbol found, ensure that PC falls within PyEval_EvalFrameEx. */
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   604
+	if (pc < psym.st_value || pc > psym.st_value + psym.st_size) {
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   605
+		return (-1);
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   606
+	}
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   607
+
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   608
+	rc = pydb_frameinfo(py, frame_addr, funcname, sizeof (funcname),
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   609
+	    filename, sizeof (filename), &lineno);
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   610
+	if (rc < 0) {
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   611
+		return (-1);
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   612
+	}
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   613
+
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   614
+	(void) snprintf(fbuf, bufsz, "[ %s:%d (%s) ]\n", filename, lineno,
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   615
+	    funcname);
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   616
+
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   617
+	return (0);
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   618
+}
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   619
+
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   620
+/*
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   621
+ * Walks the list of PyInterpreterState objects.  If caller doesn't
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   622
+ * supply address of list, this method will look it up.
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   623
+ */
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   624
+pydb_iter_t *
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   625
+pydb_interp_iter_init(pydb_agent_t *py, uintptr_t addr)
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   626
+{
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   627
+	pydb_iter_t *itr;
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   628
+	uintptr_t i_addr;
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   629
+	int rc;
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   630
+
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   631
+	if (addr == 0) {
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   632
+		rc = ps_pglobal_lookup(py->pdb_ph, LIBPYTHON, "interp_head",
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   633
+		    (psaddr_t *)&addr);
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   634
+		if (rc != PS_OK) {
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   635
+			return (NULL);
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   636
+		}
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   637
+	}
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   638
+
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   639
+	if (ps_pread(py->pdb_ph, (uintptr_t)addr, &i_addr, sizeof (uintptr_t))
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   640
+	    != PS_OK) {
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   641
+		return (NULL);
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   642
+	}
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   643
+
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   644
+	itr = malloc(sizeof (pydb_iter_t));
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   645
+	if (itr == NULL) {
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   646
+		return (NULL);
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   647
+	}
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   648
+
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   649
+	itr->pdi_ph = py->pdb_ph;
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   650
+	itr->pdi_current = i_addr;
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   651
+	itr->pdi_nextf = pydb_interp_iter_next;
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   652
+
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   653
+	return (itr);
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   654
+}
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   655
+
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   656
+static uintptr_t
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   657
+pydb_interp_iter_next(pydb_iter_t *iter)
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   658
+{
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   659
+	PyInterpreterState st;
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   660
+	uintptr_t cur;
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   661
+
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   662
+	cur = iter->pdi_current;
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   663
+
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   664
+	if (cur == 0) {
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   665
+		return (cur);
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   666
+	}
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   667
+
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   668
+	if (ps_pread(iter->pdi_ph, cur, &st, sizeof (PyInterpreterState))
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   669
+	    != PS_OK) {
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   670
+		iter->pdi_current = 0;
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   671
+		return (0);
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   672
+	}
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   673
+
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   674
+	iter->pdi_current = (uintptr_t)st.next;
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   675
+
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   676
+	return (cur);
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   677
+}
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   678
+
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   679
+/*
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   680
+ * Walk a list of Python PyFrameObjects.  The addr argument must be
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   681
+ * the address of a valid PyThreadState object.
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   682
+ */
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   683
+pydb_iter_t *
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   684
+pydb_frame_iter_init(pydb_agent_t *py, uintptr_t addr)
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   685
+{
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   686
+	pydb_iter_t *itr;
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   687
+	PyThreadState ts;
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   688
+
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   689
+	if (ps_pread(py->pdb_ph, (uintptr_t)addr, &ts, sizeof (PyThreadState))
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   690
+	    != PS_OK) {
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   691
+		return (NULL);
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   692
+	}
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   693
+
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   694
+	itr = malloc(sizeof (pydb_iter_t));
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   695
+	if (itr == NULL) {
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   696
+		return (NULL);
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   697
+	}
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   698
+
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   699
+	itr->pdi_ph = py->pdb_ph;
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   700
+	itr->pdi_current = (uintptr_t)ts.frame;
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   701
+	itr->pdi_nextf = pydb_frame_iter_next;
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   702
+
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   703
+	return (itr);
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   704
+}
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   705
+
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   706
+static uintptr_t
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   707
+pydb_frame_iter_next(pydb_iter_t *iter)
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   708
+{
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   709
+	PyFrameObject fo;
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   710
+	uintptr_t cur;
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   711
+
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   712
+	cur = iter->pdi_current;
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   713
+
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   714
+	if (cur == 0) {
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   715
+		return (cur);
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   716
+	}
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   717
+
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   718
+	if (ps_pread(iter->pdi_ph, cur, &fo, sizeof (PyFrameObject))
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   719
+	    != PS_OK) {
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   720
+		iter->pdi_current = 0;
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   721
+		return (0);
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   722
+	}
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   723
+
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   724
+	iter->pdi_current = (uintptr_t)fo.f_back;
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   725
+
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   726
+	return (cur);
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   727
+}
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   728
+
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   729
+/*
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   730
+ * Walk a list of Python PyThreadState objects.  The addr argument must be
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   731
+ * the address of a valid PyInterpreterState object.
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   732
+ */
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   733
+pydb_iter_t *
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   734
+pydb_thread_iter_init(pydb_agent_t *py, uintptr_t addr)
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   735
+{
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   736
+	pydb_iter_t *itr;
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   737
+	PyInterpreterState is;
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   738
+
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   739
+	if (ps_pread(py->pdb_ph, (uintptr_t)addr, &is,
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   740
+	    sizeof (PyInterpreterState)) != PS_OK) {
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   741
+		return (NULL);
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   742
+	}
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   743
+
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   744
+	itr = malloc(sizeof (pydb_iter_t));
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   745
+	if (itr == NULL) {
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   746
+		return (NULL);
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   747
+	}
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   748
+
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   749
+	itr->pdi_ph = py->pdb_ph;
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   750
+	itr->pdi_current = (uintptr_t)is.tstate_head;
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   751
+	itr->pdi_nextf = pydb_thread_iter_next;
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   752
+
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   753
+	return (itr);
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   754
+}
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   755
+
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   756
+static uintptr_t
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   757
+pydb_thread_iter_next(pydb_iter_t *iter)
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   758
+{
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   759
+	PyThreadState ts;
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   760
+	uintptr_t cur;
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   761
+
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   762
+	cur = iter->pdi_current;
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   763
+
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   764
+	if (cur == 0) {
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   765
+		return (cur);
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   766
+	}
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   767
+
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   768
+	if (ps_pread(iter->pdi_ph, cur, &ts, sizeof (PyThreadState)) != PS_OK) {
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   769
+		iter->pdi_current = 0;
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   770
+		return (0);
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   771
+	}
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   772
+
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   773
+	iter->pdi_current = (uintptr_t)ts.next;
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   774
+
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   775
+	return (cur);
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   776
+}
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   777
+
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   778
+
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   779
+uintptr_t
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   780
+pydb_iter_next(pydb_iter_t *iter)
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   781
+{
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   782
+	return (iter->pdi_nextf(iter));
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   783
+}
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   784
+
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   785
+void
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   786
+pydb_iter_fini(pydb_iter_t *iter)
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   787
+{
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   788
+	if (iter == NULL) {
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   789
+		return;
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   790
+	}
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   791
+
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   792
+	free(iter);
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   793
+}
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   794
diff --git Python-2.7.1/py_db/libpython27_db.h Python-2.7.1/py_db/libpython27_db.h
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   795
new file mode 100644
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   796
--- /dev/null
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   797
+++ Python-2.7.1/py_db/libpython27_db.h
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   798
@@ -0,0 +1,73 @@
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   799
+/*
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   800
+ * CDDL HEADER START
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   801
+ *
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   802
+ * The contents of this file are subject to the terms of the
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   803
+ * Common Development and Distribution License (the "License").
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   804
+ * You may not use this file except in compliance with the License.
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   805
+ *
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   806
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   807
+ * or http://www.opensolaris.org/os/licensing.
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   808
+ * See the License for the specific language governing permissions
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   809
+ * and limitations under the License.
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   810
+ *
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   811
+ * When distributing Covered Code, include this CDDL HEADER in each
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   812
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   813
+ * If applicable, add the following below this CDDL HEADER, with the
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   814
+ * fields enclosed by brackets "[]" replaced with your own identifying
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   815
+ * information: Portions Copyright [yyyy] [name of copyright owner]
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   816
+ *
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   817
+ * CDDL HEADER END
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   818
+ */
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   819
+/*
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   820
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   821
+ */
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   822
+
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   823
+#ifndef	_LIBPYTHON27_DB_H
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   824
+#define	_LIBPYTHON27_DB_H
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   825
+
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   826
+#include <proc_service.h>
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   827
+
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   828
+#ifdef	__cplusplus
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   829
+extern "C" {
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   830
+#endif
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   831
+
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   832
+/* Agent is opaque to library's consumers.  */
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   833
+typedef struct pydb_agent pydb_agent_t;
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   834
+
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   835
+/*
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   836
+ * Library's debug version is 1.  Changes to interface should increase this
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   837
+ * number.
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   838
+ */
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   839
+#define	PYDB_VERSION	1
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   840
+
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   841
+/* Agent creation/destruction routines */
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   842
+extern	pydb_agent_t	*pydb_agent_create(struct ps_prochandle *P, int vers);
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   843
+extern	void		pydb_agent_destroy(pydb_agent_t *py);
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   844
+
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   845
+/* Used by callers that know they are looking at a PyFrameObject */
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   846
+extern	int	pydb_get_frameinfo(pydb_agent_t *py, uintptr_t frame_addr,
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   847
+    char *fbuf, size_t bufsz, int verbose);
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   848
+
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   849
+/*
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   850
+ * Used by callers that don't know if they're looking at PyFrameObject.
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   851
+ * Checks PC for traceable functions.
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   852
+ */
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   853
+extern	int	pydb_pc_frameinfo(pydb_agent_t *py, uintptr_t pc,
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   854
+    uintptr_t frame_addr, char *fbuf, size_t bufsz);
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   855
+
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   856
+/* Iterator functions */
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   857
+typedef struct pydb_iter pydb_iter_t;
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   858
+
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   859
+extern	pydb_iter_t	*pydb_frame_iter_init(pydb_agent_t *py, uintptr_t addr);
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   860
+extern	pydb_iter_t	*pydb_interp_iter_init(pydb_agent_t *py,
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   861
+    uintptr_t addr);
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   862
+extern	pydb_iter_t	*pydb_thread_iter_init(pydb_agent_t *py,
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   863
+    uintptr_t addr);
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   864
+extern	void		pydb_iter_fini(pydb_iter_t *iter);
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   865
+extern	uintptr_t	pydb_iter_next(pydb_iter_t *iter);
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   866
+
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   867
+#ifdef	__cplusplus
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   868
+}
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   869
+#endif
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   870
+
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   871
+#endif	/* _LIBPYTHON27_DB_H */
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   872
diff --git Python-2.7.1/py_db/libpython27_db_32.h Python-2.7.1/py_db/libpython27_db_32.h
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   873
new file mode 100644
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   874
--- /dev/null
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   875
+++ Python-2.7.1/py_db/libpython27_db_32.h
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   876
@@ -0,0 +1,121 @@
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   877
+/*
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   878
+ * CDDL HEADER START
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   879
+ *
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   880
+ * The contents of this file are subject to the terms of the
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   881
+ * Common Development and Distribution License (the "License").
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   882
+ * You may not use this file except in compliance with the License.
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   883
+ *
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   884
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   885
+ * or http://www.opensolaris.org/os/licensing.
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   886
+ * See the License for the specific language governing permissions
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   887
+ * and limitations under the License.
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   888
+ *
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   889
+ * When distributing Covered Code, include this CDDL HEADER in each
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   890
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   891
+ * If applicable, add the following below this CDDL HEADER, with the
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   892
+ * fields enclosed by brackets "[]" replaced with your own identifying
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   893
+ * information: Portions Copyright [yyyy] [name of copyright owner]
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   894
+ *
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   895
+ * CDDL HEADER END
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   896
+ */
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   897
+/*
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   898
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   899
+ */
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   900
+
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   901
+#ifndef	_LIBPYTHON27_DB_32_H
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   902
+#define	_LIBPYTHON27_DB_32_H
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   903
+
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   904
+#ifdef	__cplusplus
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   905
+extern "C" {
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   906
+#endif
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   907
+
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   908
+#include <sys/types.h>
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   909
+
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   910
+/*
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   911
+ * Define 32-bit Python data structures for use by the 64-bit debugger.  This
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   912
+ * is so that a 64-bit debugger may properly examine a 32-bit process.
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   913
+ *
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   914
+ * In many cases, the debug library is only concerned with a few fields in the
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   915
+ * Python structure.  In that case, the other ancillary fields are elided.
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   916
+ */
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   917
+
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   918
+typedef uint32_t uintptr32_t;
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   919
+typedef int32_t Py_ssize32_t;
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   920
+
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   921
+typedef struct _is32 {
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   922
+	uintptr32_t	next;
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   923
+	uintptr32_t	tstate_head;
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   924
+} PyInterpreterState32;
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   925
+
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   926
+typedef struct _ts32 {
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   927
+	uintptr32_t	next;
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   928
+	uintptr32_t	interp;
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   929
+	uintptr32_t	frame;
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   930
+} PyThreadState32;
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   931
+
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   932
+#define	PyObject_HEAD32			\
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   933
+	Py_ssize32_t	ob_refcnt;	\
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   934
+	uintptr32_t	ob_type;
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   935
+
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   936
+#define	PyObject_VAR_HEAD32		\
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   937
+	PyObject_HEAD32			\
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   938
+	Py_ssize32_t	ob_size;
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   939
+
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   940
+typedef struct {
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   941
+	PyObject_HEAD32
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   942
+} PyObject32;
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   943
+
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   944
+typedef struct {
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   945
+	PyObject_VAR_HEAD32
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   946
+} PyVarObject32;
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   947
+
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   948
+typedef struct {
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   949
+	PyObject_VAR_HEAD32
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   950
+	int32_t		ob_shash;
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   951
+	int		ob_sstate;
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   952
+	char		ob_sval[1];
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   953
+} PyStringObject32;
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   954
+
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   955
+#define	Py_SIZE32(ob)			(((PyVarObject32*)(ob))->ob_size)
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   956
+#define	PyString_GET_SIZE32(op)		Py_SIZE32(op)
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   957
+#define	PyString_AS_STRING32(op)	(((PyStringObject32 *)(op))->ob_sval)
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   958
+
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   959
+typedef struct {
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   960
+	PyObject_VAR_HEAD32
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   961
+	uintptr32_t	f_back;
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   962
+	uintptr32_t	f_code;
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   963
+	uintptr32_t	f_builtins;
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   964
+	uintptr32_t	f_globals;
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   965
+	uintptr32_t	f_locals;
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   966
+	uintptr32_t	f_valuestack;
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   967
+	uintptr32_t	f_stacktop;
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   968
+	uintptr32_t	f_trace;
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   969
+	uintptr32_t	f_exc_typpe, f_exc_value, f_exc_traceback;
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   970
+	uintptr32_t	f_tstate;
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   971
+	int		f_lasti;
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   972
+	int		f_lineno;
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   973
+} PyFrameObject32;
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   974
+
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   975
+typedef struct {
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   976
+	PyObject_HEAD32
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   977
+	int		co_argcount;
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   978
+	int		co_nlocals;
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   979
+	int		co_stacksize;
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   980
+	int		co_flags;
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   981
+	uintptr32_t	co_code;
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   982
+	uintptr32_t	co_consts;
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   983
+	uintptr32_t	co_names;
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   984
+	uintptr32_t	co_varnames;
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   985
+	uintptr32_t	co_freevars;
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   986
+	uintptr32_t	co_cellvars;
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   987
+	uintptr32_t	co_filename;
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   988
+	uintptr32_t	co_name;
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   989
+	int		co_firstlineno;
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   990
+	uintptr32_t	co_lnotab;
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   991
+} PyCodeObject32;
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   992
+
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   993
+#ifdef	__cplusplus
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   994
+}
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   995
+#endif
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   996
+
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   997
+#endif	/* _LIBPYTHON27_DB_32_H */
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   998
diff --git Python-2.7.1/py_db/mapfile-vers Python-2.7.1/py_db/mapfile-vers
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   999
new file mode 100644
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
  1000
--- /dev/null
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
  1001
+++ Python-2.7.1/py_db/mapfile-vers
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
  1002
@@ -0,0 +1,39 @@
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
  1003
+#
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
  1004
+# CDDL HEADER START
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
  1005
+#
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
  1006
+# The contents of this file are subject to the terms of the
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
  1007
+# Common Development and Distribution License (the "License").
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
  1008
+# You may not use this file except in compliance with the License.
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
  1009
+#
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
  1010
+# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
  1011
+# or http://www.opensolaris.org/os/licensing.
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
  1012
+# See the License for the specific language governing permissions
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
  1013
+# and limitations under the License.
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
  1014
+#
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
  1015
+# When distributing Covered Code, include this CDDL HEADER in each
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
  1016
+# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
  1017
+# If applicable, add the following below this CDDL HEADER, with the
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
  1018
+# fields enclosed by brackets "[]" replaced with your own identifying
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
  1019
+# information: Portions Copyright [yyyy] [name of copyright owner]
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
  1020
+#
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
  1021
+# CDDL HEADER END
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
  1022
+#
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
  1023
+
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
  1024
+#
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
  1025
+# Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
  1026
+#
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
  1027
+
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
  1028
+SUNWprivate_1.1 {
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
  1029
+    global:
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
  1030
+	pydb_agent_create;
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
  1031
+	pydb_agent_destroy;
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
  1032
+	pydb_frame_iter_init;
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
  1033
+	pydb_get_frameinfo;
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
  1034
+	pydb_pc_frameinfo;
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
  1035
+	pydb_interp_iter_init;
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
  1036
+	pydb_thread_iter_init;
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
  1037
+	pydb_iter_fini;
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
  1038
+	pydb_iter_next;
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
  1039
+    local:
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
  1040
+	*;
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
  1041
+};