components/python/python27/patches/14-py_db.patch
author John Beck <John.Beck@Oracle.COM>
Thu, 17 Jul 2014 21:06:55 -0700
changeset 2027 cd5205b6221a
parent 1954 32663e59626d
child 2213 b87f3edd5dd7
permissions -rw-r--r--
19164544 Python 2.7 test_tcl fails
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1954
32663e59626d 19004605 update Python 2.7 line to version 2.7.7
John Beck <John.Beck@Oracle.COM>
parents: 1914
diff changeset
     1
This patch adds Python debugger support.  It may be contributed upstream at
32663e59626d 19004605 update Python 2.7 line to version 2.7.7
John Beck <John.Beck@Oracle.COM>
parents: 1914
diff changeset
     2
some point, but the suitability (or lack thereof) has not yet been determined.
32663e59626d 19004605 update Python 2.7 line to version 2.7.7
John Beck <John.Beck@Oracle.COM>
parents: 1914
diff changeset
     3
32663e59626d 19004605 update Python 2.7 line to version 2.7.7
John Beck <John.Beck@Oracle.COM>
parents: 1914
diff changeset
     4
--- Python-2.7.7/Makefile.pre.in.~3~	2014-06-02 10:54:32.421086337 -0700
32663e59626d 19004605 update Python 2.7 line to version 2.7.7
John Beck <John.Beck@Oracle.COM>
parents: 1914
diff changeset
     5
+++ Python-2.7.7/Makefile.pre.in	2014-06-02 10:54:32.438134113 -0700
1914
00e8dbcb9b1e PSARC 2014/183 Python 2.7.6
John Beck <John.Beck@Oracle.COM>
parents: 896
diff changeset
     6
@@ -407,7 +407,7 @@
896
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
     7
 
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
     8
 # Default target
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
     9
 all:		build_all
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    10
-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
    11
+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
    12
 
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    13
 # 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
    14
 profile-opt:
1954
32663e59626d 19004605 update Python 2.7 line to version 2.7.7
John Beck <John.Beck@Oracle.COM>
parents: 1914
diff changeset
    15
@@ -778,6 +778,19 @@
896
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
 $(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
    18
 
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    19
+SHLIB_FLAGS = -shared -fpic
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    20
+
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    21
+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
    22
+	$(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
    23
+
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    24
+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
    25
+	$(CC) -o $@ $(CFLAGS) $(CPPFLAGS) $<
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
+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
    28
+
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    29
+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
    30
+	$(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
    31
+	$(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
    32
 
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    33
 ######################################################################
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    34
 
1954
32663e59626d 19004605 update Python 2.7 line to version 2.7.7
John Beck <John.Beck@Oracle.COM>
parents: 1914
diff changeset
    35
@@ -842,7 +855,7 @@
896
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    36
 		$(TESTPYTHON) $(TESTPROG) $(MEMTESTOPTS)
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    37
 
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    38
 # Install everything
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    39
-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
    40
+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
    41
 
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    42
 # Install almost everything without disturbing previous versions
1914
00e8dbcb9b1e PSARC 2014/183 Python 2.7.6
John Beck <John.Beck@Oracle.COM>
parents: 896
diff changeset
    43
 altinstall:	@FRAMEWORKALTINSTALLFIRST@ altbininstall libinstall inclinstall \
896
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    44
--- /dev/null
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    45
+++ 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
    46
@@ -0,0 +1,87 @@
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    47
+/*
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    48
+ * CDDL HEADER START
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    49
+ *
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    50
+ * 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
    51
+ * 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
    52
+ * 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
    53
+ *
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    54
+ * 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
    55
+ * 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
    56
+ * 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
    57
+ * and limitations under the License.
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    58
+ *
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    59
+ * 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
    60
+ * 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
    61
+ * 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
    62
+ * 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
    63
+ * 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
    64
+ *
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    65
+ * CDDL HEADER END
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    66
+ */
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
+ * 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
    69
+ */
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
+#include <stdio.h>
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    72
+
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    73
+#include <Python.h>
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    74
+#include <frameobject.h>
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    75
+
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    76
+#include "libpython27_db_32.h"
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    77
+
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    78
+#if 0
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    79
+#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
    80
+#endif
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    81
+
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    82
+int
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    83
+main(void)
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    84
+{
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
+ * PyCodeObject co_name
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    87
+ * PyCodeObject co_filename
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    88
+ * PyCodeObject co_lnotab
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    89
+ * PyFrameObject f_back
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    90
+ * PyFrameObject f_code
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    91
+ * PyFrameObject f_lasti
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    92
+ * PyInterpreterState next
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    93
+ * PyInterpreterState tstate_head
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    94
+ * PyStringObject ob_sval
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    95
+ * PyStringObject ob_size
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    96
+ * PyThreadState frame
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    97
+ * PyThreadState next
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    98
+ */
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
+	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
   101
+	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
   102
+	    offsetof(PyCodeObject32, co_name));
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   103
+	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
   104
+	    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
   105
+	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
   106
+	    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
   107
+	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
   108
+	    offsetof(PyFrameObject32, f_back));
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   109
+	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
   110
+	    offsetof(PyFrameObject32, f_code));
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   111
+	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
   112
+	    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
   113
+	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
   114
+	    next), offsetof(PyInterpreterState32, next));
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   115
+	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
   116
+	    offsetof(PyInterpreterState, tstate_head),
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   117
+	    offsetof(PyInterpreterState32, tstate_head));
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   118
+	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
   119
+	    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
   120
+	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
   121
+	    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
   122
+	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
   123
+	    offsetof(PyThreadState32, frame));
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   124
+	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
   125
+	    offsetof(PyThreadState32, next));
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   126
+
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   127
+	printf("\nObject sizes\n");
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   128
+	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
   129
+	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
   130
+	    sizeof (PyVarObject32));
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   131
+
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   132
+	return (0);
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   133
+}
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   134
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
   135
new file mode 100644
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   136
--- /dev/null
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   137
+++ 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
   138
@@ -0,0 +1,654 @@
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   139
+/*
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   140
+ * CDDL HEADER START
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   141
+ *
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   142
+ * 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
   143
+ * 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
   144
+ * 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
   145
+ *
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   146
+ * 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
   147
+ * 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
   148
+ * 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
   149
+ * and limitations under the License.
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   150
+ *
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   151
+ * 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
   152
+ * 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
   153
+ * 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
   154
+ * 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
   155
+ * 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
   156
+ *
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   157
+ * CDDL HEADER END
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   158
+ */
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
+ * 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
   161
+ */
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
+#include <stdio.h>
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   164
+#include <stdlib.h>
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   165
+#include <string.h>
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   166
+#include <errno.h>
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   167
+#include <gelf.h>
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   168
+
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   169
+#include <Python.h>
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   170
+#include <frameobject.h>
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   171
+
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   172
+#include "libpython27_db.h"
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   173
+#if defined(_LP64)
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   174
+#include "libpython27_db_32.h"
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   175
+#endif /* _LP64 */
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   176
+
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
+ * 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
   179
+ * 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
   180
+ * 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
   181
+ */
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   182
+typedef struct pydb_arch_ops {
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   183
+	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
   184
+	    size_t);
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   185
+	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
   186
+	    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
   187
+} pydb_arch_ops_t;
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   188
+
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   189
+struct pydb_agent {
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   190
+	struct ps_prochandle *pdb_ph;
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   191
+	int pdb_vers;
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   192
+	int pdb_is_64bit;
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   193
+	int pdb_datamodel;
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   194
+	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
   195
+};
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
+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
   198
+
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   199
+struct pydb_iter {
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   200
+	struct ps_prochandle *pdi_ph;
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   201
+	uintptr_t pdi_current;
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   202
+	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
   203
+};
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
+#define	LIBPYTHON	"libpython2.7.so"
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   206
+
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   207
+#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
   208
+
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   209
+/* Generic interface to helper functions */
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   210
+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
   211
+    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
   212
+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
   213
+    int lastinst);
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   214
+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
   215
+    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
   216
+
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   217
+/* 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
   218
+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
   219
+    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
   220
+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
   221
+    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
   222
+
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   223
+#if defined (_LP64)
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   224
+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
   225
+    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
   226
+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
   227
+    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
   228
+#endif /* _LP64 */
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   229
+
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   230
+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
   231
+    size_t len);
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   232
+
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   233
+/* 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
   234
+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
   235
+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
   236
+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
   237
+
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   238
+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
   239
+
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   240
+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
   241
+	.frameinfo = pydb_frameinfo_native,
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   242
+	.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
   243
+};
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
+#if defined (_LP64)
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   246
+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
   247
+	.frameinfo = pydb_frameinfo_32,
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   248
+	.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
   249
+};
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   250
+#endif /* _LP64 */
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   251
+
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   252
+static const char *
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   253
+strbasename(const char *s)
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   254
+{
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   255
+	const char *p = strrchr(s, '/');
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   256
+
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   257
+	if (p == NULL)
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   258
+		return (s);
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   259
+
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   260
+	return (++p);
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   261
+}
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
+/* Agent creation / destruction routines */
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   264
+
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   265
+pydb_agent_t *
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   266
+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
   267
+{
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   268
+	pydb_agent_t *py;
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   269
+	int datamodel;
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   270
+
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   271
+	if (vers != PYDB_VERSION) {
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   272
+		errno = ENOTSUP;
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   273
+		return (NULL);
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   274
+	}
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
+	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
   277
+		return (NULL);
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   278
+	}
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
+	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
   281
+	if (py == NULL) {
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   282
+		return (NULL);
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   283
+	}
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
+	py->pdb_ph = P;
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   286
+	py->pdb_vers = vers;
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   287
+	py->pdb_datamodel = datamodel;
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   288
+	py->pdb_is_64bit = 0;
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   289
+	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
   290
+
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   291
+#if defined (_LP64)
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   292
+	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
   293
+	if (!py->pdb_is_64bit) {
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   294
+		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
   295
+	}
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   296
+#endif /* _LP64 */
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   297
+
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   298
+	return (py);
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   299
+}
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
+void
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   302
+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
   303
+{
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   304
+	if (py == NULL) {
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   305
+		return;
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   306
+	}
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
+	free(py);
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   309
+}
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
+/* Helper functions */
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   312
+static int
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   313
+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
   314
+    int lastinst)
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   315
+{
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   316
+	unsigned char lnotab[4096];
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   317
+	ssize_t lnotab_len;
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   318
+	int addr, line;
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   319
+	int i;
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   320
+
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   321
+	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
   322
+	    sizeof (lnotab));
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   323
+	if (lnotab_len < 0) {
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   324
+		return (-1);
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   325
+	}
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
+	 * 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
   329
+	 * 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
   330
+	 */
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
+	line = firstline;
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   333
+	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
   334
+		if (addr + lnotab[i] > lastinst) {
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   335
+			break;
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   336
+		}
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   337
+		addr += lnotab[i];
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   338
+		line += lnotab[i + 1];
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   339
+	}
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
+	return (line);
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   342
+}
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
+static ssize_t
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   345
+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
   346
+    size_t buf_len)
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   347
+{
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   348
+	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
   349
+}
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
+static ssize_t
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   352
+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
   353
+    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
   354
+{
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   355
+	PyStringObject sobj;
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   356
+	ssize_t obj_sz;
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   357
+	ssize_t read_sz;
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   358
+	psaddr_t straddr;
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   359
+
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
+	 * 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
   362
+	 * 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
   363
+	 * 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
   364
+	 * 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
   365
+	 * 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
   366
+	 * 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
   367
+	 * 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
   368
+	 * buffer passed by the caller.
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   369
+	 */
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
+	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
   372
+	    != PS_OK) {
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   373
+		return (-1);
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   374
+	}
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
+	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
   377
+
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   378
+	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
   379
+	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
   380
+
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   381
+	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
   382
+		return (-1);
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   383
+	}
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
+	return (read_sz);
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   386
+}
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
+#if defined(_LP64)
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   389
+static ssize_t
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   390
+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
   391
+    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
   392
+{
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   393
+	PyStringObject32 sobj;
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   394
+	ssize_t obj_sz;
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   395
+	ssize_t read_sz;
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   396
+	psaddr_t straddr;
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   397
+
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
+	 * 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
   400
+	 * 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
   401
+	 * 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
   402
+	 * 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
   403
+	 * 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
   404
+	 * 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
   405
+	 * 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
   406
+	 * buffer passed by the caller.
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   407
+	 */
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
+	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
   410
+	    != PS_OK) {
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   411
+		return (-1);
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   412
+	}
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
+	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
   415
+
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   416
+	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
   417
+	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
   418
+
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   419
+	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
   420
+		return (-1);
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   421
+	}
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
+	return (read_sz);
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   424
+}
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   425
+#endif /* _LP64 */
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   426
+
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
+ * 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
   429
+ * 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
   430
+ * 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
   431
+ * 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
   432
+ * 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
   433
+ * 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
   434
+ */
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   435
+static ssize_t
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   436
+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
   437
+    size_t buf_len)
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   438
+{
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   439
+	ssize_t read_sz;
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   440
+
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   441
+	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
   442
+
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   443
+	if (read_sz >= 0) {
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   444
+		if (read_sz >= buf_len) {
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   445
+			read_sz = buf_len - 1;
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   446
+		}
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
+		buf[read_sz] = '\0';
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   449
+	}
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
+	return (read_sz);
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   452
+}
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
+static int
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   456
+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
   457
+    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
   458
+{
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   459
+	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
   460
+	    filenm, filenm_sz, lineno));
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   461
+}
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
+static int
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   464
+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
   465
+    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
   466
+{
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   467
+	PyFrameObject fo;
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   468
+	PyCodeObject co;
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   469
+	ssize_t rc;
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   470
+
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   471
+	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
   472
+	    != PS_OK) {
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   473
+		return (-1);
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   474
+	}
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
+	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
   477
+	    sizeof (PyCodeObject)) != PS_OK) {
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   478
+		return (-1);
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   479
+	}
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
+	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
   482
+	if (rc < 0) {
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   483
+		return (-1);
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   484
+	}
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
+	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
   487
+	    filenm_sz);
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   488
+	if (rc < 0) {
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   489
+		return (-1);
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   490
+	}
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
+	*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
   493
+	    fo.f_lasti);
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   494
+	if (*lineno < 0) {
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   495
+		return (-1);
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   496
+	}
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
+	return (0);
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   499
+}
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
+#if defined (_LP64)
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   502
+static int
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   503
+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
   504
+    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
   505
+{
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   506
+	PyFrameObject32 fo;
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   507
+	PyCodeObject32 co;
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   508
+	ssize_t rc;
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   509
+
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   510
+	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
   511
+	    != PS_OK) {
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   512
+		return (-1);
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   513
+	}
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
+	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
   516
+	    sizeof (PyCodeObject32)) != PS_OK) {
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   517
+		return (-1);
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   518
+	}
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
+	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
   521
+	if (rc < 0) {
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   522
+		return (-1);
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   523
+	}
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
+	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
   526
+	    filenm_sz);
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   527
+	if (rc < 0) {
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   528
+		return (-1);
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   529
+	}
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
+	*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
   532
+	    fo.f_lasti);
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   533
+	if (*lineno < 0) {
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   534
+		return (-1);
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   535
+	}
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
+	return (0);
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   538
+}
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
+#endif /* _LP64 */
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   541
+
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   542
+/* 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
   543
+
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
+ * 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
   546
+ * 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
   547
+ */
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   548
+int
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   549
+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
   550
+    size_t bufsz, int verbose)
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   551
+{
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   552
+	char funcname[1024];
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   553
+	char filename[1024];
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   554
+	char *fn;
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   555
+	int lineno;
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   556
+	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
   557
+	int rc;
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   558
+
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   559
+	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
   560
+	    filename, sizeof (filename), &lineno);
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   561
+	if (rc < 0) {
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   562
+		return (-1);
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   563
+	}
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
+	if (!verbose) {
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   566
+		fn = (char *)strbasename(filename);
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   567
+	} else {
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   568
+		fn = filename;
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   569
+	}
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
+	(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
   572
+	    frame_addr, fn, lineno, funcname);
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   573
+
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   574
+	return (0);
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   575
+}
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
+ * 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
   579
+ * 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
   580
+ * 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
   581
+ * 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
   582
+ */
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   583
+int
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   584
+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
   585
+    char *fbuf, size_t bufsz)
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   586
+{
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   587
+	char funcname[1024];
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   588
+	char filename[1024];
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   589
+	int lineno;
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   590
+	int rc;
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   591
+	ps_sym_t psym;
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   592
+
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
+	 * 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
   595
+	 * 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
   596
+	 */
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   597
+	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
   598
+	    != PS_OK) {
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   599
+		return (-1);
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   600
+	}
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
+	/* 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
   603
+	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
   604
+		return (-1);
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   605
+	}
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
+	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
   608
+	    filename, sizeof (filename), &lineno);
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   609
+	if (rc < 0) {
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   610
+		return (-1);
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   611
+	}
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
+	(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
   614
+	    funcname);
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   615
+
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   616
+	return (0);
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   617
+}
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
+ * 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
   621
+ * 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
   622
+ */
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   623
+pydb_iter_t *
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   624
+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
   625
+{
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   626
+	pydb_iter_t *itr;
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   627
+	uintptr_t i_addr;
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   628
+	int rc;
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   629
+
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   630
+	if (addr == 0) {
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   631
+		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
   632
+		    (psaddr_t *)&addr);
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   633
+		if (rc != PS_OK) {
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   634
+			return (NULL);
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   635
+		}
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
+	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
   639
+	    != PS_OK) {
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   640
+		return (NULL);
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   641
+	}
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
+	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
   644
+	if (itr == NULL) {
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   645
+		return (NULL);
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   646
+	}
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
+	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
   649
+	itr->pdi_current = i_addr;
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   650
+	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
   651
+
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   652
+	return (itr);
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   653
+}
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
+static uintptr_t
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   656
+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
   657
+{
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   658
+	PyInterpreterState st;
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   659
+	uintptr_t cur;
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   660
+
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   661
+	cur = iter->pdi_current;
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   662
+
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   663
+	if (cur == 0) {
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   664
+		return (cur);
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   665
+	}
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
+	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
   668
+	    != PS_OK) {
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   669
+		iter->pdi_current = 0;
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   670
+		return (0);
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   671
+	}
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
+	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
   674
+
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   675
+	return (cur);
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   676
+}
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
+ * 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
   680
+ * 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
   681
+ */
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   682
+pydb_iter_t *
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   683
+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
   684
+{
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   685
+	pydb_iter_t *itr;
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   686
+	PyThreadState ts;
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   687
+
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   688
+	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
   689
+	    != PS_OK) {
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   690
+		return (NULL);
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   691
+	}
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
+	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
   694
+	if (itr == NULL) {
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   695
+		return (NULL);
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   696
+	}
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
+	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
   699
+	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
   700
+	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
   701
+
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   702
+	return (itr);
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   703
+}
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
+static uintptr_t
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   706
+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
   707
+{
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   708
+	PyFrameObject fo;
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   709
+	uintptr_t cur;
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   710
+
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   711
+	cur = iter->pdi_current;
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   712
+
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   713
+	if (cur == 0) {
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   714
+		return (cur);
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   715
+	}
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
+	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
   718
+	    != PS_OK) {
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   719
+		iter->pdi_current = 0;
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   720
+		return (0);
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   721
+	}
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
+	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
   724
+
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   725
+	return (cur);
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   726
+}
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
+ * 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
   730
+ * 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
   731
+ */
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   732
+pydb_iter_t *
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   733
+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
   734
+{
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   735
+	pydb_iter_t *itr;
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   736
+	PyInterpreterState is;
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   737
+
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   738
+	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
   739
+	    sizeof (PyInterpreterState)) != PS_OK) {
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   740
+		return (NULL);
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   741
+	}
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
+	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
   744
+	if (itr == NULL) {
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   745
+		return (NULL);
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   746
+	}
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
+	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
   749
+	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
   750
+	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
   751
+
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   752
+	return (itr);
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   753
+}
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
+static uintptr_t
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   756
+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
   757
+{
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   758
+	PyThreadState ts;
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   759
+	uintptr_t cur;
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   760
+
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   761
+	cur = iter->pdi_current;
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   762
+
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   763
+	if (cur == 0) {
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   764
+		return (cur);
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   765
+	}
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
+	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
   768
+		iter->pdi_current = 0;
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   769
+		return (0);
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   770
+	}
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
+	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
   773
+
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   774
+	return (cur);
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   775
+}
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
+uintptr_t
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   779
+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
   780
+{
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   781
+	return (iter->pdi_nextf(iter));
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   782
+}
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
+void
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   785
+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
   786
+{
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   787
+	if (iter == NULL) {
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   788
+		return;
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   789
+	}
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
+	free(iter);
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   792
+}
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   793
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
   794
new file mode 100644
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   795
--- /dev/null
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   796
+++ 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
   797
@@ -0,0 +1,73 @@
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   798
+/*
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   799
+ * CDDL HEADER START
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   800
+ *
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   801
+ * 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
   802
+ * 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
   803
+ * 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
   804
+ *
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   805
+ * 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
   806
+ * 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
   807
+ * 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
   808
+ * and limitations under the License.
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   809
+ *
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   810
+ * 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
   811
+ * 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
   812
+ * 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
   813
+ * 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
   814
+ * 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
   815
+ *
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   816
+ * CDDL HEADER END
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   817
+ */
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
+ * 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
   820
+ */
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
+#ifndef	_LIBPYTHON27_DB_H
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   823
+#define	_LIBPYTHON27_DB_H
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   824
+
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   825
+#include <proc_service.h>
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   826
+
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   827
+#ifdef	__cplusplus
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   828
+extern "C" {
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   829
+#endif
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   830
+
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   831
+/* 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
   832
+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
   833
+
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
+ * 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
   836
+ * number.
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   837
+ */
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   838
+#define	PYDB_VERSION	1
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   839
+
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   840
+/* Agent creation/destruction routines */
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   841
+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
   842
+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
   843
+
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   844
+/* 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
   845
+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
   846
+    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
   847
+
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
+ * 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
   850
+ * Checks PC for traceable functions.
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   851
+ */
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   852
+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
   853
+    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
   854
+
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   855
+/* Iterator functions */
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   856
+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
   857
+
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   858
+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
   859
+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
   860
+    uintptr_t addr);
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   861
+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
   862
+    uintptr_t addr);
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   863
+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
   864
+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
   865
+
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   866
+#ifdef	__cplusplus
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   867
+}
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   868
+#endif
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   869
+
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   870
+#endif	/* _LIBPYTHON27_DB_H */
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   871
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
   872
new file mode 100644
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   873
--- /dev/null
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   874
+++ 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
   875
@@ -0,0 +1,121 @@
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   876
+/*
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   877
+ * CDDL HEADER START
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   878
+ *
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   879
+ * 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
   880
+ * 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
   881
+ * 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
   882
+ *
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   883
+ * 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
   884
+ * 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
   885
+ * 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
   886
+ * and limitations under the License.
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   887
+ *
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   888
+ * 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
   889
+ * 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
   890
+ * 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
   891
+ * 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
   892
+ * 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
   893
+ *
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   894
+ * CDDL HEADER END
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   895
+ */
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
+ * 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
   898
+ */
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
+#ifndef	_LIBPYTHON27_DB_32_H
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   901
+#define	_LIBPYTHON27_DB_32_H
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   902
+
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   903
+#ifdef	__cplusplus
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   904
+extern "C" {
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   905
+#endif
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   906
+
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   907
+#include <sys/types.h>
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   908
+
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
+ * 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
   911
+ * 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
   912
+ *
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   913
+ * 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
   914
+ * 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
   915
+ */
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
+typedef uint32_t uintptr32_t;
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   918
+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
   919
+
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   920
+typedef struct _is32 {
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   921
+	uintptr32_t	next;
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   922
+	uintptr32_t	tstate_head;
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   923
+} PyInterpreterState32;
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   924
+
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   925
+typedef struct _ts32 {
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   926
+	uintptr32_t	next;
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   927
+	uintptr32_t	interp;
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   928
+	uintptr32_t	frame;
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   929
+} PyThreadState32;
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   930
+
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   931
+#define	PyObject_HEAD32			\
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   932
+	Py_ssize32_t	ob_refcnt;	\
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   933
+	uintptr32_t	ob_type;
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   934
+
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   935
+#define	PyObject_VAR_HEAD32		\
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   936
+	PyObject_HEAD32			\
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   937
+	Py_ssize32_t	ob_size;
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   938
+
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   939
+typedef struct {
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   940
+	PyObject_HEAD32
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   941
+} PyObject32;
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   942
+
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   943
+typedef struct {
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   944
+	PyObject_VAR_HEAD32
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   945
+} PyVarObject32;
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   946
+
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   947
+typedef struct {
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   948
+	PyObject_VAR_HEAD32
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   949
+	int32_t		ob_shash;
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   950
+	int		ob_sstate;
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   951
+	char		ob_sval[1];
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   952
+} PyStringObject32;
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   953
+
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   954
+#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
   955
+#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
   956
+#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
   957
+
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   958
+typedef struct {
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   959
+	PyObject_VAR_HEAD32
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   960
+	uintptr32_t	f_back;
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   961
+	uintptr32_t	f_code;
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   962
+	uintptr32_t	f_builtins;
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   963
+	uintptr32_t	f_globals;
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   964
+	uintptr32_t	f_locals;
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   965
+	uintptr32_t	f_valuestack;
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   966
+	uintptr32_t	f_stacktop;
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   967
+	uintptr32_t	f_trace;
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   968
+	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
   969
+	uintptr32_t	f_tstate;
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   970
+	int		f_lasti;
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   971
+	int		f_lineno;
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   972
+} PyFrameObject32;
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   973
+
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   974
+typedef struct {
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   975
+	PyObject_HEAD32
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   976
+	int		co_argcount;
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   977
+	int		co_nlocals;
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   978
+	int		co_stacksize;
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   979
+	int		co_flags;
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   980
+	uintptr32_t	co_code;
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   981
+	uintptr32_t	co_consts;
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   982
+	uintptr32_t	co_names;
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   983
+	uintptr32_t	co_varnames;
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   984
+	uintptr32_t	co_freevars;
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   985
+	uintptr32_t	co_cellvars;
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   986
+	uintptr32_t	co_filename;
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   987
+	uintptr32_t	co_name;
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   988
+	int		co_firstlineno;
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   989
+	uintptr32_t	co_lnotab;
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   990
+} PyCodeObject32;
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   991
+
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   992
+#ifdef	__cplusplus
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   993
+}
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   994
+#endif
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   995
+
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   996
+#endif	/* _LIBPYTHON27_DB_32_H */
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   997
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
   998
new file mode 100644
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   999
--- /dev/null
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
  1000
+++ 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
  1001
@@ -0,0 +1,39 @@
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
  1002
+#
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
  1003
+# CDDL HEADER START
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
  1004
+#
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
  1005
+# 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
  1006
+# 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
  1007
+# 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
  1008
+#
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
  1009
+# 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
  1010
+# 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
  1011
+# 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
  1012
+# and limitations under the License.
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
  1013
+#
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
  1014
+# 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
  1015
+# 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
  1016
+# 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
  1017
+# 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
  1018
+# 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
  1019
+#
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
  1020
+# CDDL HEADER END
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
  1021
+#
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
+# 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
  1025
+#
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
+SUNWprivate_1.1 {
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
  1028
+    global:
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
  1029
+	pydb_agent_create;
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
  1030
+	pydb_agent_destroy;
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
  1031
+	pydb_frame_iter_init;
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
  1032
+	pydb_get_frameinfo;
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
  1033
+	pydb_pc_frameinfo;
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
  1034
+	pydb_interp_iter_init;
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
  1035
+	pydb_thread_iter_init;
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
  1036
+	pydb_iter_fini;
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
  1037
+	pydb_iter_next;
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
  1038
+    local:
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
  1039
+	*;
50be262e44f7 7155369 mdb should work with python 2.7 bits
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
  1040
+};