1 This patch adds Python debugger support. It may be contributed upstream at |
1 This patch adds Python debugger support. It may be contributed upstream at |
2 some point, but the suitability (or lack thereof) has not yet been determined. |
2 some point, but the suitability (or lack thereof) has not yet been determined. |
3 |
3 |
4 --- Python-2.7.9/Makefile.pre.in.~3~ 2014-12-17 11:41:42.906190914 -0800 |
4 --- Python-2.7.9/Makefile.pre.in.~3~ 2014-12-11 09:28:46.856724815 -0800 |
5 +++ Python-2.7.9/Makefile.pre.in 2014-12-17 11:44:37.867187107 -0800 |
5 +++ Python-2.7.9/Makefile.pre.in 2014-12-11 09:30:15.502371832 -0800 |
6 @@ -410,7 +410,7 @@ |
6 @@ -410,7 +410,7 @@ |
7 |
7 |
8 # Default target |
8 # Default target |
9 all: build_all |
9 all: build_all |
10 -build_all: $(BUILDPYTHON) oldsharedmods sharedmods gdbhooks |
10 -build_all: $(BUILDPYTHON) oldsharedmods sharedmods gdbhooks |
11 +build_all: $(BUILDPYTHON) oldsharedmods sharedmods gdbhooks build-py_db |
11 +build_all: $(BUILDPYTHON) oldsharedmods sharedmods gdbhooks build-py_db |
12 |
12 |
13 # Compile a binary with gcc profile guided optimization. |
13 # Compile a binary with gcc profile guided optimization. |
14 profile-opt: |
14 profile-opt: |
15 @@ -791,6 +791,19 @@ |
15 @@ -791,6 +791,15 @@ |
16 |
16 |
17 $(LIBRARY_OBJS) $(MODOBJS) Modules/python.o: $(PYTHON_HEADERS) |
17 $(LIBRARY_OBJS) $(MODOBJS) Modules/python.o: $(PYTHON_HEADERS) |
18 |
18 |
19 +SHLIB_FLAGS = -shared -fpic |
19 +SHLIB_FLAGS = -shared -fpic |
20 + |
20 + |
21 +libpython2.7_db.so.1.0: $(srcdir)/py_db/libpython27_db.c |
21 +libpython2.7_db.so.1.0: $(srcdir)/py_db/libpython27_db.c |
22 + $(CC) -o $@ $(CFLAGS) $(CPPFLAGS) $(SHLIB_FLAGS) $< |
22 + $(CC) -o $@ $(CFLAGS) $(CPPFLAGS) $(SHLIB_FLAGS) $< |
23 + |
23 + |
24 +check_offset: $(srcdir)/py_db/check_offsets.c |
24 +build-py_db: libpython2.7_db.so.1.0 |
25 + $(CC) -o $@ $(CFLAGS) $(CPPFLAGS) $< |
25 + |
26 + |
26 +install-py_db: libpython2.7_db.so.1.0 |
27 +build-py_db: libpython2.7_db.so.1.0 check_offset |
|
28 + |
|
29 +install-py_db: libpython2.7_db.so.1.0 check_offset |
|
30 + $(INSTALL_SHARED) libpython2.7_db.so.1.0 $(DESTDIR)$(LIBDIR) |
27 + $(INSTALL_SHARED) libpython2.7_db.so.1.0 $(DESTDIR)$(LIBDIR) |
31 + $(INSTALL_PROGRAM) check_offset $(DESTDIR)$(BINDIR) |
|
32 |
28 |
33 ###################################################################### |
29 ###################################################################### |
34 |
30 |
35 @@ -855,7 +868,7 @@ |
31 @@ -855,7 +864,7 @@ |
36 $(TESTPYTHON) $(TESTPROG) $(MEMTESTOPTS) |
32 $(TESTPYTHON) $(TESTPROG) $(MEMTESTOPTS) |
37 |
33 |
38 # Install everything |
34 # Install everything |
39 -install: @FRAMEWORKINSTALLFIRST@ commoninstall bininstall maninstall @FRAMEWORKINSTALLLAST@ |
35 -install: @FRAMEWORKINSTALLFIRST@ commoninstall bininstall maninstall @FRAMEWORKINSTALLLAST@ |
40 +install: @FRAMEWORKINSTALLFIRST@ commoninstall bininstall maninstall @FRAMEWORKINSTALLLAST@ install-py_db |
36 +install: @FRAMEWORKINSTALLFIRST@ commoninstall bininstall maninstall @FRAMEWORKINSTALLLAST@ install-py_db |
41 if test "x$(ENSUREPIP)" != "xno" ; then \ |
37 if test "x$(ENSUREPIP)" != "xno" ; then \ |
42 case $(ENSUREPIP) in \ |
38 case $(ENSUREPIP) in \ |
43 upgrade) ensurepip="--upgrade" ;; \ |
39 upgrade) ensurepip="--upgrade" ;; \ |
44 --- /dev/null |
|
45 +++ Python-2.7.1/py_db/check_offsets.c |
|
46 @@ -0,0 +1,87 @@ |
|
47 +/* |
|
48 + * CDDL HEADER START |
|
49 + * |
|
50 + * The contents of this file are subject to the terms of the |
|
51 + * Common Development and Distribution License (the "License"). |
|
52 + * You may not use this file except in compliance with the License. |
|
53 + * |
|
54 + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE |
|
55 + * or http://www.opensolaris.org/os/licensing. |
|
56 + * See the License for the specific language governing permissions |
|
57 + * and limitations under the License. |
|
58 + * |
|
59 + * When distributing Covered Code, include this CDDL HEADER in each |
|
60 + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. |
|
61 + * If applicable, add the following below this CDDL HEADER, with the |
|
62 + * fields enclosed by brackets "[]" replaced with your own identifying |
|
63 + * information: Portions Copyright [yyyy] [name of copyright owner] |
|
64 + * |
|
65 + * CDDL HEADER END |
|
66 + */ |
|
67 +/* |
|
68 + * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. |
|
69 + */ |
|
70 + |
|
71 +#include <stdio.h> |
|
72 + |
|
73 +#include <Python.h> |
|
74 +#include <frameobject.h> |
|
75 + |
|
76 +#include "libpython27_db_32.h" |
|
77 + |
|
78 +#if 0 |
|
79 +#define offsetof(s, m) ((size_t)(&(((s *)0)->m))) |
|
80 +#endif |
|
81 + |
|
82 +int |
|
83 +main(void) |
|
84 +{ |
|
85 +/* |
|
86 + * PyCodeObject co_name |
|
87 + * PyCodeObject co_filename |
|
88 + * PyCodeObject co_lnotab |
|
89 + * PyFrameObject f_back |
|
90 + * PyFrameObject f_code |
|
91 + * PyFrameObject f_lasti |
|
92 + * PyInterpreterState next |
|
93 + * PyInterpreterState tstate_head |
|
94 + * PyStringObject ob_sval |
|
95 + * PyStringObject ob_size |
|
96 + * PyThreadState frame |
|
97 + * PyThreadState next |
|
98 + */ |
|
99 + |
|
100 + printf("struct member: native 32\n"); |
|
101 + printf("PyCodeObject co_name: %d %d\n", offsetof(PyCodeObject, co_name), |
|
102 + offsetof(PyCodeObject32, co_name)); |
|
103 + printf("PyCodeObject co_filename: %d %d\n", offsetof(PyCodeObject, |
|
104 + co_filename), offsetof(PyCodeObject32, co_filename)); |
|
105 + printf("PyCodeObject co_lnotab: %d %d\n", offsetof(PyCodeObject, |
|
106 + co_lnotab), offsetof(PyCodeObject32, co_lnotab)); |
|
107 + printf("PyFrameObject f_back: %d %d\n", offsetof(PyFrameObject, f_back), |
|
108 + offsetof(PyFrameObject32, f_back)); |
|
109 + printf("PyFrameObject f_code: %d %d\n", offsetof(PyFrameObject, f_code), |
|
110 + offsetof(PyFrameObject32, f_code)); |
|
111 + printf("PyFrameObject f_lasti: %d %d\n", offsetof(PyFrameObject, |
|
112 + f_lasti), offsetof(PyFrameObject32, f_lasti)); |
|
113 + printf("PyInterpreterState next: %d %d\n", offsetof(PyInterpreterState, |
|
114 + next), offsetof(PyInterpreterState32, next)); |
|
115 + printf("PyInterpreterState tstate_head: %d %d\n", |
|
116 + offsetof(PyInterpreterState, tstate_head), |
|
117 + offsetof(PyInterpreterState32, tstate_head)); |
|
118 + printf("PyStringObject ob_sval: %d %d\n", offsetof(PyStringObject, |
|
119 + ob_sval), offsetof(PyStringObject32, ob_sval)); |
|
120 + printf("PyStringObject ob_size: %d %d\n", offsetof(PyStringObject, |
|
121 + ob_size), offsetof(PyStringObject32, ob_size)); |
|
122 + printf("PyThreadState frame: %d %d\n", offsetof(PyThreadState, frame), |
|
123 + offsetof(PyThreadState32, frame)); |
|
124 + printf("PyThreadState next: %d %d\n", offsetof(PyThreadState, next), |
|
125 + offsetof(PyThreadState32, next)); |
|
126 + |
|
127 + printf("\nObject sizes\n"); |
|
128 + printf("PyObject: %d %d\n", sizeof (PyObject), sizeof (PyObject32)); |
|
129 + printf("PyVarObject: %d %d\n", sizeof (PyVarObject), |
|
130 + sizeof (PyVarObject32)); |
|
131 + |
|
132 + return (0); |
|
133 +} |
|
134 diff --git Python-2.7.1/py_db/libpython27_db.c Python-2.7.1/py_db/libpython27_db.c |
|
135 new file mode 100644 |
|
136 --- /dev/null |
40 --- /dev/null |
137 +++ Python-2.7.1/py_db/libpython27_db.c |
41 +++ Python-2.7.1/py_db/libpython27_db.c |
138 @@ -0,0 +1,654 @@ |
42 @@ -0,0 +1,654 @@ |
139 +/* |
43 +/* |
140 + * CDDL HEADER START |
44 + * CDDL HEADER START |