cpython: 6425728d8dc6 (original) (raw)
Mercurial > cpython
changeset 101081:6425728d8dc6
Merge 3.5: Issue #26799 [#26799]
Victor Stinner victor.stinner@gmail.com | |
---|---|
date | Wed, 20 Apr 2016 18:12:38 +0200 |
parents | 7530caa5ed1a(current diff)e1c6f8895fd8(diff) |
children | b6d7645e4b0c |
files | Misc/ACKS Misc/NEWS |
diffstat | 3 files changed, 39 insertions(+), 14 deletions(-)[+] [-] Misc/ACKS 1 Misc/NEWS 5 Tools/gdb/libpython.py 47 |
line wrap: on
line diff
--- a/Misc/ACKS +++ b/Misc/ACKS @@ -651,6 +651,7 @@ Catalin Iacob Mihai Ibanescu Ali Ikinci Aaron Iles +Thomas Ilsche Lars Immisch Bobby Impollonia Naoki Inada
--- a/Misc/NEWS +++ b/Misc/NEWS @@ -1065,6 +1065,11 @@ Windows Tools/Demos ----------- +- Issue #26799: Fix python-gdb.py: don't get once C types when the Python code
- is loaded, but get C types on demande. The C types can change if
- python-gdb.py is loaded before the Python executable. Patch written by Thomas
- Ilsche. +
- Issue #26271: Fix the Freeze tool to properly use flags passed through configure. Patch by Daniel Shaulov.
--- a/Tools/gdb/libpython.py +++ b/Tools/gdb/libpython.py @@ -56,16 +56,35 @@ if sys.version_info[0] >= 3: long = int
Look up the gdb.Type for some standard types:
-_type_char_ptr = gdb.lookup_type('char').pointer() # char* -_type_unsigned_char_ptr = gdb.lookup_type('unsigned char').pointer() # unsigned char* -_type_void_ptr = gdb.lookup_type('void').pointer() # void* -_type_unsigned_short_ptr = gdb.lookup_type('unsigned short').pointer() -_type_unsigned_int_ptr = gdb.lookup_type('unsigned int').pointer() +# Those need to be refreshed as types (pointer sizes) may change when +# gdb loads different executables + + +def _type_char_ptr():
+ + +def _type_unsigned_char_ptr():
+ + +def _type_unsigned_short_ptr():
+ + +def _type_unsigned_int_ptr():
value computed later, see PyUnicodeObjectPtr.proxy()
_is_pep393 = None -SIZEOF_VOID_P = _type_void_ptr.sizeof + +def _sizeof_void_p():
Py_TPFLAGS_HEAPTYPE = (1 << 9) @@ -460,8 +479,8 @@ def _PyObject_VAR_SIZE(typeobj, nitems): return ( ( typeobj.field('tp_basicsize') + nitems * typeobj.field('tp_itemsize') +
(SIZEOF_VOID_P - 1)[](#l3.49)
) & ~(SIZEOF_VOID_P - 1)[](#l3.50)
(_sizeof_void_p() - 1)[](#l3.51)
) & ~(_sizeof_void_p() - 1)[](#l3.52) ).cast(_PyObject_VAR_SIZE._type_size_t)[](#l3.53)
_PyObject_VAR_SIZE._type_size_t = None @@ -485,9 +504,9 @@ class HeapTypeObjectPtr(PyObjectPtr): size = _PyObject_VAR_SIZE(typeobj, tsize) dictoffset += size assert dictoffset > 0
assert dictoffset % SIZEOF_VOID_P == 0[](#l3.60)
assert dictoffset % _sizeof_void_p() == 0[](#l3.61)
dictptr = self._gdbval.cast(_type_char_ptr) + dictoffset[](#l3.63)
dictptr = self._gdbval.cast(_type_char_ptr()) + dictoffset[](#l3.64) PyObjectPtrPtr = PyObjectPtr.get_gdb_type().pointer()[](#l3.65) dictptr = dictptr.cast(PyObjectPtrPtr)[](#l3.66) return PyObjectPtr.from_pyobject_ptr(dictptr.dereference())[](#l3.67)
@@ -1004,7 +1023,7 @@ class PyBytesObjectPtr(PyObjectPtr): def str(self): field_ob_size = self.field('ob_size') field_ob_sval = self.field('ob_sval')
char_ptr = field_ob_sval.address.cast(_type_unsigned_char_ptr)[](#l3.72)
char_ptr = field_ob_sval.address.cast(_type_unsigned_char_ptr())[](#l3.73) return ''.join([chr(char_ptr[i]) for i in safe_range(field_ob_size)])[](#l3.74)
def proxyval(self, visited): @@ -1135,11 +1154,11 @@ class PyUnicodeObjectPtr(PyObjectPtr): field_str = self.field('data')['any'] repr_kind = int(state['kind']) if repr_kind == 1:
field_str = field_str.cast(_type_unsigned_char_ptr)[](#l3.81)
field_str = field_str.cast(_type_unsigned_char_ptr())[](#l3.82) elif repr_kind == 2:[](#l3.83)
field_str = field_str.cast(_type_unsigned_short_ptr)[](#l3.84)
field_str = field_str.cast(_type_unsigned_short_ptr())[](#l3.85) elif repr_kind == 4:[](#l3.86)
field_str = field_str.cast(_type_unsigned_int_ptr)[](#l3.87)
field_str = field_str.cast(_type_unsigned_int_ptr())[](#l3.88) else:[](#l3.89) # Python 3.2 and earlier[](#l3.90) field_length = long(self.field('length'))[](#l3.91)