• Home
  • Raw
  • Download

Lines Matching +full:code +full:- +full:frame

3 From gdb 7 onwards, gdb's build can be configured --with-python, allowing gdb
4 to be extended with Python code e.g. for library-specific data visualizations,
6 http://sourceware.org/gdb/current/onlinedocs/gdb/Python-API.html
16 that we can emit useful visualizations e.g. a string, a list, a dict, a frame
29 of the data to a file-like object. This allows us to stop the traversal by
30 having the file-like object raise an exception if it gets too much data.
41 The module also extends gdb with some python-specific commands.
92 FRAME_INFO_OPTIMIZED_OUT = '(frame information optimized out)'
93 UNABLE_READ_INFO_PYTHON_FRAME = 'Unable to read information on python frame'
126 byte = chr(ord(char) - 0xDC00)
146 self._val += data[0:self.maxlen - len(self._val)]
213 to file-like object "out"
220 Get a repr-like string for the data, but truncate it at "maxlen" bytes
281 Class representing a non-descript PyObject* value in the inferior
292 # special-case it as per
304 process to "out", a file-like object.
324 Error while executing Python code.
327 tp_name for some special-cases that don't seem to be visible through
346 'frame': PyFrameObjectPtr,
350 'method-wrapper': wrapperobject,
419 '''Shared code for use by all classes:
420 write a representation to file-like object "out"'''
463 (_sizeof_void_p() - 1)
464 ) & ~(_sizeof_void_p() - 1)
484 tsize = -tsize
506 valuesptr = self._gdbval.cast(PyDictValuesPtrPtr) - 4
603 return "<built-in function %s>" % self.ml_name
611 return ('<built-in method %s of %s object at remote 0x%x>'
654 return -(uval >> 1)
667 code = (first_byte >> 3) & 15
670 if code == 15:
674 elif code == 14: # Long form
680 elif code == 13: # No column
683 elif code in (10, 11, 12): # new line
684 line_delta = code - 10
689 assert (0 <= code < 10)
691 column = code << 3 | (second_byte >> 4)
697 Class wrapping a gdb.Value that's a PyCodeObject* i.e. a <code> instance
881 SUM(for i=0 through abs(ob_size)-1) ob_digit[i] * 2**(SHIFT*i)
904 result = -result
946 the local variables of this frame
955 the global variables of this frame
983 '''Get current line number as an integer (1-based)
1033 the local variables of this frame
1069 return int(prev_instr - first_instr)
1080 the global variables of this frame
1124 '''Get current line number as an integer (1-based)
1135 # bpo-34989: addr2line() is a complex function, it can fail in many
1137 # gdb fails to load debug symbols. Use a catch-all "except
1150 return '(failed to get frame line number)'
1154 with open(os_fsencode(filename), 'r', encoding="utf-8") as fp:
1160 # Convert from 1-based current_line_num to 0-based list offset
1161 return lines[lineno - 1]
1171 out.write('Frame 0x%x, for file %s, line %s, in %s ('
1205 Get a repr-like string for the data, but truncate it at "maxlen" bytes
1256 # Python 3's set_repr special-cases the empty set:
1299 # to Python 2 code:
1406 # UCS-1, UCS-2 or UCS-4 code points:
1425 code = (ucs & 0x03FF) << 10
1426 code |= ucs2 & 0x03FF
1427 code += 0x00010000
1428 Py_UNICODEs.append(code)
1431 # Convert the int code points to unicode characters, and generate a
1468 # Map non-printable US ASCII to '\xhh' */
1474 # Copy ASCII characters as-is
1478 # Non-ASCII characters
1494 # Match Python 3's representation of non-printable
1496 code = (ord(ch) & 0x03FF) << 10
1497 code |= ord(ch2) & 0x03FF
1498 code += 0x00010000
1500 code = ord(ucs)
1502 # Map 8-bit characters to '\\xhh'
1503 if code <= 0xff:
1505 out.write(hexdigits[(code >> 4) & 0x000F])
1506 out.write(hexdigits[code & 0x000F])
1507 # Map 21-bit characters to '\U00xxxxxx'
1508 elif code >= 0x10000:
1510 out.write(hexdigits[(code >> 28) & 0x0000000F])
1511 out.write(hexdigits[(code >> 24) & 0x0000000F])
1512 out.write(hexdigits[(code >> 20) & 0x0000000F])
1513 out.write(hexdigits[(code >> 16) & 0x0000000F])
1514 out.write(hexdigits[(code >> 12) & 0x0000000F])
1515 out.write(hexdigits[(code >> 8) & 0x0000000F])
1516 out.write(hexdigits[(code >> 4) & 0x0000000F])
1517 out.write(hexdigits[code & 0x0000000F])
1518 # Map 16-bit characters to '\uxxxx'
1521 out.write(hexdigits[(code >> 12) & 0x000F])
1522 out.write(hexdigits[(code >> 8) & 0x000F])
1523 out.write(hexdigits[(code >> 4) & 0x000F])
1524 out.write(hexdigits[code & 0x000F])
1526 # Copy characters as-is
1561 return ("<method-wrapper %s of %s object at %s>"
1601 if type.code != gdb.TYPE_CODE_PTR:
1610 During development, I've been manually invoking the code in this way:
1614 sys.path.append('/home/david/coding/python-gdb')
1621 The following code should ensure that the prettyprinter is registered
1622 if the code is autoloaded by gdb when visiting libpython.so, provided
1624 .debug file) plus a "-gdb.py" suffix, e.g:
1625 /usr/lib/libpython2.6.so.1.0-gdb.py
1626 /usr/lib/debug/usr/lib/libpython2.6.so.1.0.debug-gdb.py
1632 # Wire up the pretty-printer
1643 class Frame(object): class
1645 Wrapper for gdb.Frame, adding various methods
1653 return Frame(older)
1660 return Frame(newer)
1665 '''If supported, select this frame and return True; return False if unsupported
1667 Not all builds have a gdb.Frame.select method; seems to be present on Fedora 12
1670 print ('Unable to select frame: '
1671 'this build of gdb does not expose a gdb.Frame.select method')
1677 '''Calculate index of frame, starting at 0 for the newest frame within
1680 # Go down until you reach the newest frame:
1688 # - "python frames":
1689 # - "bytecode frames" i.e. PyEval_EvalFrameEx
1690 # - "other python frames": things that are of interest from a python
1692 # - everything else
1695 '''Is this a _PyEval_EvalFrameDefault frame, or some other important
1696 frame? (see is_other_python_frame for what "important" means in this
1705 '''Is this a _PyEval_EvalFrameDefault frame?'''
1715 # We have a _PyEval_EvalFrameDefault frame:
1721 '''Is this frame worth displaying in python backtraces?
1723 - waiting on the GIL
1724 - garbage-collecting
1725 - within a CFunction
1733 return 'Garbage-collecting'
1736 frame = self._gdbframe
1737 caller = frame.name()
1744 # Within that frame:
1751 func = frame.read_var(arg_name)
1762 func = frame.read_var(arg_name)
1770 # This frame isn't worth reporting:
1774 '''Is this frame waiting on the GIL?'''
1781 '''Is this frame gc_collect_main() within the garbage-collector?'''
1786 frame = self._gdbframe.read_var('frame')
1787 frame = PyFramePtr(frame)
1788 if not frame.is_optimized_out():
1789 return frame
1793 frame = PyFramePtr(cframe["current_frame"])
1794 if frame and not frame.is_optimized_out():
1795 return frame
1804 return Frame(_gdbframe)
1809 '''Try to obtain the Frame for the python-related code in the selected
1810 frame, or None'''
1812 frame = cls.get_selected_frame()
1814 # No frame: Python didn't start yet
1817 while frame:
1818 if frame.is_python_frame():
1819 return frame
1820 frame = frame.older()
1827 '''Try to obtain the Frame for the python bytecode interpreter in the
1828 selected GDB frame, or None'''
1829 frame = cls.get_selected_frame()
1831 while frame:
1832 if frame.is_evalframe():
1833 return frame
1834 frame = frame.older()
1853 … sys.stdout.write('#%i (unable to read python frame information)\n' % self.get_index())
1876 sys.stdout.write(' (unable to read python frame information)\n')
1884 sys.stdout.write(' (not a python frame)\n')
1887 '''List the current Python source code, if any
1890 py-list START
1894 py-list START, END
1900 "py-list",
1920 # py-list requires an actual PyEval_EvalFrameEx frame:
1921 frame = Frame.get_selected_bytecode_frame()
1922 if not frame:
1923 print('Unable to locate gdb frame for python bytecode interpreter')
1926 pyop = frame.get_pyop()
1934 print('Unable to read python frame line number')
1938 start = lineno - 5
1945 f = open(os_fsencode(filename), 'r', encoding="utf-8")
1952 # start and end are 1-based, all_lines is 0-based;
1953 # so [start-1:end] as a python slice gives us [start, end] as a
1955 for i, line in enumerate(all_lines[start-1:end]):
1967 '''Move up or down the stack (for the py-up/py-down command)'''
1973 frame = Frame.get_selected_python_frame()
1974 if not frame:
1975 print('Unable to locate python frame')
1977 while frame:
1979 iter_frame = frame.older()
1981 iter_frame = frame.newer()
1992 frame = iter_frame
1995 print('Unable to find an older python frame')
1997 print('Unable to find a newer python frame')
2001 …'Select and print all python stack frame in the same eval loop starting from the one that called t…
2004 "py-up",
2013 …'Select and print all python stack frame in the same eval loop starting from the one called this o…
2016 "py-down",
2024 # Not all builds of gdb have gdb.Frame.select
2025 if hasattr(gdb.Frame, 'select'):
2030 'Display the current python frame and all the frames within its call stack (if any)'
2033 "py-bt-full",
2039 frame = Frame.get_selected_python_frame()
2040 if not frame:
2041 print('Unable to locate python frame')
2044 while frame:
2045 if frame.is_python_frame():
2046 frame.print_summary()
2047 frame = frame.older()
2052 'Display the current python frame and all the frames within its call stack (if any)'
2055 "py-bt",
2061 frame = Frame.get_selected_python_frame()
2062 if not frame:
2063 print('Unable to locate python frame')
2067 while frame:
2068 if frame.is_python_frame():
2069 frame.print_traceback()
2070 frame = frame.older()
2078 "py-print",
2086 frame = Frame.get_selected_python_frame()
2087 if not frame:
2088 print('Unable to locate python frame')
2091 pyop_frame = frame.get_pyop()
2112 "py-locals",
2120 frame = Frame.get_selected_python_frame()
2121 if not frame:
2122 print('Unable to locate python frame')
2125 pyop_frame = frame.get_pyop()