Skip to content
Snippets Groups Projects
  1. Jan 01, 2023
  2. Mar 23, 2022
    • Simon Marchi's avatar
      gdb/python: remove Python 2/3 compatibility macros · 5aee4587
      Simon Marchi authored
      New in this version:
      
       - Rebase on master, fix a few more issues that appeared.
      
      python-internal.h contains a number of macros that helped make the code
      work with both Python 2 and 3.  Remove them and adjust the code to use
      the Python 3 functions.
      
      Change-Id: I99a3d80067fb2d65de4f69f6473ba6ffd16efb2d
      5aee4587
    • Simon Marchi's avatar
      gdb/python: remove Python 2 support · edae3fd6
      Simon Marchi authored
      New in this version:
      
       - Add a PY_MAJOR_VERSION check in configure.ac / AC_TRY_LIBPYTHON.  If
         the user passes --with-python=python2, this will cause a configure
         failure saying that GDB only supports Python 3.
      
      Support for Python 2 is a maintenance burden for any patches touching
      Python support.  Among others, the differences between Python 2 and 3
      string and integer types are subtle.  It requires a lot of effort and
      thinking to get something that behaves correctly on both.  And that's if
      the author and reviewer of the patch even remember to test with Python
      2.
      
      See this thread for an example:
      
        https://sourceware.org/pipermail/gdb-patches/2021-December/184260.html
      
      So, remove Python 2 support.  Update the documentation to state that GDB
      can be built against Python 3 (as opposed to Python 2 or 3).
      
      Update all the spots that use:
      
       - sys.version_info
       - IS_PY3K
       - PY_MAJOR_VERSION
       - gdb_py_is_py3k
      
      ... to only keep the Python 3 portions and drop the use of some
      now-removed compatibility macros.
      
      I did not update the configure script more than just removing the
      explicit references to Python 2.  We could maybe do more there, like
      check the Python version and reject it if that version is not
      supported.  Otherwise (with this patch), things will only fail at
      compile time, so it won't really be clear to the user that they are
      trying to use an unsupported Python version.  But I'm a bit lost in the
      configure code that checks for Python, so I kept that for later.
      
      Change-Id: I75b0f79c148afbe3c07ac664cfa9cade052c0c62
      edae3fd6
  3. Jan 26, 2022
    • Tom Tromey's avatar
      Change how Python architecture and language are handled · 1da5d0e6
      Tom Tromey authored
      Currently, gdb's Python layer captures the current architecture and
      language when "entering" Python code.  This has some undesirable
      effects, and so this series changes how this is handled.
      
      First, there is code like this:
      
        gdbpy_enter enter_py (python_gdbarch, python_language);
      
      This is incorrect, because both of these are NULL when not otherwise
      assigned.  This can cause crashes in some cases -- I've added one to
      the test suite.  (Note that this crasher is just an example, other
      ones along the same lines are possible.)
      
      Second, when the language is captured in this way, it means that
      Python code cannot affect the current language for its own purposes.
      It's reasonable to want to write code like this:
      
          gdb.execute('set language mumble')
          ... stuff using the current language
          gdb.execute('set language previous-value')
      
      However, this won't actually work, because the language is captured on
      entry.  I've added a test to show this as well.
      
      This patch changes gdb to try to avoid capturing the current values.
      The Python concept of the current gdbarch is only set in those few
      cases where a non-default value is computed or needed; and the
      language is not captured at all -- instead, in the cases where it's
      required, the current language is temporarily changed.
      
      1da5d0e6
  4. Jan 01, 2022
  5. Oct 22, 2021
    • Andrew Burgess's avatar
      gdb/python: move gdb.Membuf support into a new file · 625f7b1c
      Andrew Burgess authored
      In a future commit I'm going to be creating gdb.Membuf objects from a
      new file within gdb/python/py*.c.  Currently all gdb.Membuf objects
      are created directly within infpy_read_memory (as a result of calling
      gdb.Inferior.read_memory()).
      
      Initially I split out the Membuf creation code into a new function,
      and left the new function in gdb/python/py-inferior.c, however, it
      felt a little random that the Membuf creation code should live with
      the inferior handling code.
      
      So, then I moved all of the Membuf related code out into a new file,
      gdb/python/py-membuf.c, the interface is gdbpy_buffer_to_membuf, which
      wraps an array of bytes into a gdb.Membuf object.
      
      Most of the code is moved directly from py-inferior.c with only minor
      tweaks to layout and replacing NULL with nullptr, hence, I've left the
      copyright date on py-membuf.c as 2009-2021 to match py-inferior.c.
      
      Currently, the only user of this code is still py-inferior.c, but in
      later commits this will change.
      
      There should be no user visible changes after this commit.
      625f7b1c
Loading