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
  3. Feb 28, 2022
    • Tom Tromey's avatar
      Fix maybe-uninitialized warning in py-infthread.c · 29928b8e
      Tom Tromey authored
      I got this warning from py-infthread.c using the Fedora 34 system GCC:
      
      ../../binutils-gdb/gdb/python/py-infthread.c:102:30: warning: ‘extra_info’ may be used uninitialized in this function [-Wmaybe-uninitialized]
      
      I think this happens because GDB_PY_HANDLE_EXCEPTION expands to an
      'if' whose condition is always true -- but GCC can't know this.  This
      patch avoids the warning by adding a harmless initialization.
      29928b8e
    • Andrew Burgess's avatar
      gdb/python: Add gdb.InferiorThread.details attribute · 659971cb
      Andrew Burgess authored
      This adds a new read-only attribute gdb.InferiorThread.details, this
      attribute contains a string, the results of target_extra_thread_info
      for the thread, or None, if target_extra_thread_info returns nullptr.
      
      As the string returned by target_extra_thread_info is unstructured,
      this attribute is only really useful for echoing straight through to
      the user, but, if a user wants to write a command that displays the
      same, or a similar 'Thread Id' to the one seen in 'info threads', then
      they need access to this string.
      
      Given that the string produced by target_extra_thread_info varies by
      target, there's only minimal testing of this attribute, I check that
      the attribute can be accessed, and that the return value is either
      None, or a string.
      659971cb
  4. Jan 01, 2022
  5. Sep 24, 2021
    • Simon Marchi's avatar
      gdb: change thread_info::name to unique_xmalloc_ptr, add helper function · 25558938
      Simon Marchi authored
      This started out as changing thread_info::name to a unique_xmalloc_ptr.
      That showed that almost all users of that field had the same logic to
      get a thread's name: use thread_info::name if non-nullptr, else ask the
      target.  Factor out this logic in a new thread_name free function.  Make
      the field private (rename to m_name) and add some accessors.
      
      Change-Id: Iebdd95f4cd21fbefc505249bd1d05befc466a2fc
      25558938
  6. Sep 23, 2021
    • Tom Tromey's avatar
      Change ptid_t::tid to ULONGEST · 96bbe3ef
      Tom Tromey authored
      The ptid_t 'tid' member is normally used as an address in gdb -- both
      bsd-uthread and ravenscar-thread use it this way.  However, because
      the type is 'long', this can cause problems with sign extension.
      
      This patch changes the type to ULONGEST to ensure that sign extension
      does not occur.
      
      96bbe3ef
  7. Sep 09, 2021
    • Andrew Burgess's avatar
      gdb/python: remove all uses of Py_TPFLAGS_HAVE_ITER · 0b233e34
      Andrew Burgess authored
      Python 2 has a bit flag Py_TPFLAGS_HAVE_ITER which can be passed as
      part of the tp_flags field when defining a new object type.  This flag
      is not defined in Python 3 and so we define it to 0 in
      python-internal.h (when IS_PY3K is defined).
      
      The meaning of this flag is that the object has the fields tp_iter and
      tp_iternext.  Note the use of "has" here, the flag says nothing about
      the values in those fields, just that the type object has the fields.
      
      In early versions of Python 2 these fields were no part of the
      PyTypeObject struct, they were added in version 2.2 (see
      https://docs.python.org/release/2.3/api/type-structs.html).  And so,
      there could be a some code compiled out there which has a PyTypeObject
      structure within it that doesn't even have the tp_iter and tp_iternext
      fields, attempting to access these fields would be undefined
      behaviour.
      
      And so Python added the Py_TPFLAGS_HAVE_ITER flag.  If the flag is
      present then Python is free to access the tp_iter and tp_iternext
      fields.
      
      If we consider GDB then we always assume that the tp_iter and
      tp_iternext fields are part of PyTypeObject.  If someone was crazy
      enough to try and compile GDB against Python 2.1 then we'd get lots of
      build errors saying that we were passing too many fields when
      initializing PyTypeObject structures.  And so, I claim, we can be sure
      that GDB will always be compiled with a version of Python that has the
      tp_iter and tp_iternext fields in PyTypeObject.
      
      Next we can look at the Py_TPFLAGS_DEFAULT flag.  In Python 2, each
      time additional fields are added to PyTypeObject a new Py_TPFLAGS_*
      flag would be defined to indicate whether those flags are present or
      not.  And, those new flags would be added to Py_TPFLAGS_DEFAULT.  And
      so, in the latest version of Python 2 the Py_TPFLAGS_DEFAULT flag
      includes Py_TPFLAGS_HAVE_ITER (see
      https://docs.python.org/2.7/c-api/typeobj.html).
      
      In GDB we pass Py_TPFLAGS_DEFAULT as part of the tp_flags for all
      objects we define.
      
      And so, in this commit, I propose to remove all uses of
      Py_TPFLAGS_HAVE_ITER from GDB, it's simply not needed.
      
      There should be no user visible changes after this commit.
      0b233e34
  8. Jan 01, 2021
  9. Nov 02, 2020
    • Simon Marchi's avatar
      gdb, gdbserver, gdbsupport: fix leading space vs tabs issues · dda83cd7
      Simon Marchi authored
      Many spots incorrectly use only spaces for indentation (for example,
      there are a lot of spots in ada-lang.c).  I've always found it awkward
      when I needed to edit one of these spots: do I keep the original wrong
      indentation, or do I fix it?  What if the lines around it are also
      wrong, do I fix them too?  I probably don't want to fix them in the same
      patch, to avoid adding noise to my patch.
      
      So I propose to fix as much as possible once and for all (hopefully).
      
      One typical counter argument for this is that it makes code archeology
      more difficult, because git-blame will show this commit as the last
      change for these lines.  My counter counter argument is: when
      git-blaming, you often need to do "blame the file at the parent commit"
      anyway, to go past some other refactor that touched the line you are
      interested in, but is not the change you are looking for.  So you
      already need a somewhat efficient way to do this.
      
      Using some interactive tool, rather than plain git-blame, makes this
      trivial.  For example, I use "tig blame <file>", where going back past
      the commit that changed the currently selected line is one keystroke.
      It looks like Magit in Emacs does it too (though I've never used it).
      Web viewers of Github and Gitlab do it too.  My point is that it won't
      really make archeology more difficult.
      
      The other typical counter argument is that it will cause conflicts with
      existing patches.  That's true... but it's a one time cost, and those
      are not conflicts that are difficult to resolve.  I have also tried "git
      rebase --ignore-whitespace", it seems to work well.  Although that will
      re-introduce the faulty indentation, so one needs to take care of fixing
      the indentation in the patch after that (which is easy).
      
      gdb/ChangeLog:
      
      	* aarch64-linux-tdep.c: Fix indentation.
      	* aarch64-ravenscar-thread.c: Fix indentation.
      	* aarch64-tdep.c: Fix indentation.
      	* aarch64-tdep.h: Fix indentation.
      	* ada-lang.c: Fix indentation.
      	* ada-lang.h: Fix indentation.
      	* ada-tasks.c: Fix indentation.
      	* ada-typeprint.c: Fix indentation.
      	* ada-valprint.c: Fix indentation.
      	* ada-varobj.c: Fix indentation.
      	* addrmap.c: Fix indentation.
      	* addrmap.h: Fix indentation.
      	* agent.c: Fix indentation.
      	* aix-thread.c: Fix indentation.
      	* alpha-bsd-nat.c: Fix indentation.
      	* alpha-linux-tdep.c: Fix indentation.
      	* alpha-mdebug-tdep.c: Fix indentation.
      	* alpha-nbsd-tdep.c: Fix indentation.
      	* alpha-obsd-tdep.c: Fix indentation.
      	* alpha-tdep.c: Fix indentation.
      	* amd64-bsd-nat.c: Fix indentation.
      	* amd64-darwin-tdep.c: Fix indentation.
      	* amd64-linux-nat.c: Fix indentation.
      	* amd64-linux-tdep.c: Fix indentation.
      	* amd64-nat.c: Fix indentation.
      	* amd64-obsd-tdep.c: Fix indentation.
      	* amd64-tdep.c: Fix indentation.
      	* amd64-windows-tdep.c: Fix indentation.
      	* annotate.c: Fix indentation.
      	* arc-tdep.c: Fix indentation.
      	* arch-utils.c: Fix indentation.
      	* arch/arm-get-next-pcs.c: Fix indentation.
      	* arch/arm.c: Fix indentation.
      	* arm-linux-nat.c: Fix indentation.
      	* arm-linux-tdep.c: Fix indentation.
      	* arm-nbsd-tdep.c: Fix indentation.
      	* arm-pikeos-tdep.c: Fix indentation.
      	* arm-tdep.c: Fix indentation.
      	* arm-tdep.h: Fix indentation.
      	* arm-wince-tdep.c: Fix indentation.
      	* auto-load.c: Fix indentation.
      	* auxv.c: Fix indentation.
      	* avr-tdep.c: Fix indentation.
      	* ax-gdb.c: Fix indentation.
      	* ax-general.c: Fix indentation.
      	* bfin-linux-tdep.c: Fix indentation.
      	* block.c: Fix indentation.
      	* block.h: Fix indentation.
      	* blockframe.c: Fix indentation.
      	* bpf-tdep.c: Fix indentation.
      	* break-catch-sig.c: Fix indentation.
      	* break-catch-syscall.c: Fix indentation.
      	* break-catch-throw.c: Fix indentation.
      	* breakpoint.c: Fix indentation.
      	* breakpoint.h: Fix indentation.
      	* bsd-uthread.c: Fix indentation.
      	* btrace.c: Fix indentation.
      	* build-id.c: Fix indentation.
      	* buildsym-legacy.h: Fix indentation.
      	* buildsym.c: Fix indentation.
      	* c-typeprint.c: Fix indentation.
      	* c-valprint.c: Fix indentation.
      	* c-varobj.c: Fix indentation.
      	* charset.c: Fix indentation.
      	* cli/cli-cmds.c: Fix indentation.
      	* cli/cli-decode.c: Fix indentation.
      	* cli/cli-decode.h: Fix indentation.
      	* cli/cli-script.c: Fix indentation.
      	* cli/cli-setshow.c: Fix indentation.
      	* coff-pe-read.c: Fix indentation.
      	* coffread.c: Fix indentation.
      	* compile/compile-cplus-types.c: Fix indentation.
      	* compile/compile-object-load.c: Fix indentation.
      	* compile/compile-object-run.c: Fix indentation.
      	* completer.c: Fix indentation.
      	* corefile.c: Fix indentation.
      	* corelow.c: Fix indentation.
      	* cp-abi.h: Fix indentation.
      	* cp-namespace.c: Fix indentation.
      	* cp-support.c: Fix indentation.
      	* cp-valprint.c: Fix indentation.
      	* cris-linux-tdep.c: Fix indentation.
      	* cris-tdep.c: Fix indentation.
      	* darwin-nat-info.c: Fix indentation.
      	* darwin-nat.c: Fix indentation.
      	* darwin-nat.h: Fix indentation.
      	* dbxread.c: Fix indentation.
      	* dcache.c: Fix indentation.
      	* disasm.c: Fix indentation.
      	* dtrace-probe.c: Fix indentation.
      	* dwarf2/abbrev.c: Fix indentation.
      	* dwarf2/attribute.c: Fix indentation.
      	* dwarf2/expr.c: Fix indentation.
      	* dwarf2/frame.c: Fix indentation.
      	* dwarf2/index-cache.c: Fix indentation.
      	* dwarf2/index-write.c: Fix indentation.
      	* dwarf2/line-header.c: Fix indentation.
      	* dwarf2/loc.c: Fix indentation.
      	* dwarf2/macro.c: Fix indentation.
      	* dwarf2/read.c: Fix indentation.
      	* dwarf2/read.h: Fix indentation.
      	* elfread.c: Fix indentation.
      	* eval.c: Fix indentation.
      	* event-top.c: Fix indentation.
      	* exec.c: Fix indentation.
      	* exec.h: Fix indentation.
      	* expprint.c: Fix indentation.
      	* f-lang.c: Fix indentation.
      	* f-typeprint.c: Fix indentation.
      	* f-valprint.c: Fix indentation.
      	* fbsd-nat.c: Fix indentation.
      	* fbsd-tdep.c: Fix indentation.
      	* findvar.c: Fix indentation.
      	* fork-child.c: Fix indentation.
      	* frame-unwind.c: Fix indentation.
      	* frame-unwind.h: Fix indentation.
      	* frame.c: Fix indentation.
      	* frv-linux-tdep.c: Fix indentation.
      	* frv-tdep.c: Fix indentation.
      	* frv-tdep.h: Fix indentation.
      	* ft32-tdep.c: Fix indentation.
      	* gcore.c: Fix indentation.
      	* gdb_bfd.c: Fix indentation.
      	* gdbarch.sh: Fix indentation.
      	* gdbarch.c: Re-generate
      	* gdbarch.h: Re-generate.
      	* gdbcore.h: Fix indentation.
      	* gdbthread.h: Fix indentation.
      	* gdbtypes.c: Fix indentation.
      	* gdbtypes.h: Fix indentation.
      	* glibc-tdep.c: Fix indentation.
      	* gnu-nat.c: Fix indentation.
      	* gnu-nat.h: Fix indentation.
      	* gnu-v2-abi.c: Fix indentation.
      	* gnu-v3-abi.c: Fix indentation.
      	* go32-nat.c: Fix indentation.
      	* guile/guile-internal.h: Fix indentation.
      	* guile/scm-cmd.c: Fix indentation.
      	* guile/scm-frame.c: Fix indentation.
      	* guile/scm-iterator.c: Fix indentation.
      	* guile/scm-math.c: Fix indentation.
      	* guile/scm-ports.c: Fix indentation.
      	* guile/scm-pretty-print.c: Fix indentation.
      	* guile/scm-value.c: Fix indentation.
      	* h8300-tdep.c: Fix indentation.
      	* hppa-linux-nat.c: Fix indentation.
      	* hppa-linux-tdep.c: Fix indentation.
      	* hppa-nbsd-nat.c: Fix indentation.
      	* hppa-nbsd-tdep.c: Fix indentation.
      	* hppa-obsd-nat.c: Fix indentation.
      	* hppa-tdep.c: Fix indentation.
      	* hppa-tdep.h: Fix indentation.
      	* i386-bsd-nat.c: Fix indentation.
      	* i386-darwin-nat.c: Fix indentation.
      	* i386-darwin-tdep.c: Fix indentation.
      	* i386-dicos-tdep.c: Fix indentation.
      	* i386-gnu-nat.c: Fix indentation.
      	* i386-linux-nat.c: Fix indentation.
      	* i386-linux-tdep.c: Fix indentation.
      	* i386-nto-tdep.c: Fix indentation.
      	* i386-obsd-tdep.c: Fix indentation.
      	* i386-sol2-nat.c: Fix indentation.
      	* i386-tdep.c: Fix indentation.
      	* i386-tdep.h: Fix indentation.
      	* i386-windows-tdep.c: Fix indentation.
      	* i387-tdep.c: Fix indentation.
      	* i387-tdep.h: Fix indentation.
      	* ia64-libunwind-tdep.c: Fix indentation.
      	* ia64-libunwind-tdep.h: Fix indentation.
      	* ia64-linux-nat.c: Fix indentation.
      	* ia64-linux-tdep.c: Fix indentation.
      	* ia64-tdep.c: Fix indentation.
      	* ia64-tdep.h: Fix indentation.
      	* ia64-vms-tdep.c: Fix indentation.
      	* infcall.c: Fix indentation.
      	* infcmd.c: Fix indentation.
      	* inferior.c: Fix indentation.
      	* infrun.c: Fix indentation.
      	* iq2000-tdep.c: Fix indentation.
      	* language.c: Fix indentation.
      	* linespec.c: Fix indentation.
      	* linux-fork.c: Fix indentation.
      	* linux-nat.c: Fix indentation.
      	* linux-tdep.c: Fix indentation.
      	* linux-thread-db.c: Fix indentation.
      	* lm32-tdep.c: Fix indentation.
      	* m2-lang.c: Fix indentation.
      	* m2-typeprint.c: Fix indentation.
      	* m2-valprint.c: Fix indentation.
      	* m32c-tdep.c: Fix indentation.
      	* m32r-linux-tdep.c: Fix indentation.
      	* m32r-tdep.c: Fix indentation.
      	* m68hc11-tdep.c: Fix indentation.
      	* m68k-bsd-nat.c: Fix indentation.
      	* m68k-linux-nat.c: Fix indentation.
      	* m68k-linux-tdep.c: Fix indentation.
      	* m68k-tdep.c: Fix indentation.
      	* machoread.c: Fix indentation.
      	* macrocmd.c: Fix indentation.
      	* macroexp.c: Fix indentation.
      	* macroscope.c: Fix indentation.
      	* macrotab.c: Fix indentation.
      	* macrotab.h: Fix indentation.
      	* main.c: Fix indentation.
      	* mdebugread.c: Fix indentation.
      	* mep-tdep.c: Fix indentation.
      	* mi/mi-cmd-catch.c: Fix indentation.
      	* mi/mi-cmd-disas.c: Fix indentation.
      	* mi/mi-cmd-env.c: Fix indentation.
      	* mi/mi-cmd-stack.c: Fix indentation.
      	* mi/mi-cmd-var.c: Fix indentation.
      	* mi/mi-cmds.c: Fix indentation.
      	* mi/mi-main.c: Fix indentation.
      	* mi/mi-parse.c: Fix indentation.
      	* microblaze-tdep.c: Fix indentation.
      	* minidebug.c: Fix indentation.
      	* minsyms.c: Fix indentation.
      	* mips-linux-nat.c: Fix indentation.
      	* mips-linux-tdep.c: Fix indentation.
      	* mips-nbsd-tdep.c: Fix indentation.
      	* mips-tdep.c: Fix indentation.
      	* mn10300-linux-tdep.c: Fix indentation.
      	* mn10300-tdep.c: Fix indentation.
      	* moxie-tdep.c: Fix indentation.
      	* msp430-tdep.c: Fix indentation.
      	* namespace.h: Fix indentation.
      	* nat/fork-inferior.c: Fix indentation.
      	* nat/gdb_ptrace.h: Fix indentation.
      	* nat/linux-namespaces.c: Fix indentation.
      	* nat/linux-osdata.c: Fix indentation.
      	* nat/netbsd-nat.c: Fix indentation.
      	* nat/x86-dregs.c: Fix indentation.
      	* nbsd-nat.c: Fix indentation.
      	* nbsd-tdep.c: Fix indentation.
      	* nios2-linux-tdep.c: Fix indentation.
      	* nios2-tdep.c: Fix indentation.
      	* nto-procfs.c: Fix indentation.
      	* nto-tdep.c: Fix indentation.
      	* objfiles.c: Fix indentation.
      	* objfiles.h: Fix indentation.
      	* opencl-lang.c: Fix indentation.
      	* or1k-tdep.c: Fix indentation.
      	* osabi.c: Fix indentation.
      	* osabi.h: Fix indentation.
      	* osdata.c: Fix indentation.
      	* p-lang.c: Fix indentation.
      	* p-typeprint.c: Fix indentation.
      	* p-valprint.c: Fix indentation.
      	* parse.c: Fix indentation.
      	* ppc-linux-nat.c: Fix indentation.
      	* ppc-linux-tdep.c: Fix indentation.
      	* ppc-nbsd-nat.c: Fix indentation.
      	* ppc-nbsd-tdep.c: Fix indentation.
      	* ppc-obsd-nat.c: Fix indentation.
      	* ppc-ravenscar-thread.c: Fix indentation.
      	* ppc-sysv-tdep.c: Fix indentation.
      	* ppc64-tdep.c: Fix indentation.
      	* printcmd.c: Fix indentation.
      	* proc-api.c: Fix indentation.
      	* producer.c: Fix indentation.
      	* producer.h: Fix indentation.
      	* prologue-value.c: Fix indentation.
      	* prologue-value.h: Fix indentation.
      	* psymtab.c: Fix indentation.
      	* python/py-arch.c: Fix indentation.
      	* python/py-bpevent.c: Fix indentation.
      	* python/py-event.c: Fix indentation.
      	* python/py-event.h: Fix indentation.
      	* python/py-finishbreakpoint.c: Fix indentation.
      	* python/py-frame.c: Fix indentation.
      	* python/py-framefilter.c: Fix indentation.
      	* python/py-inferior.c: Fix indentation.
      	* python/py-infthread.c: Fix indentation.
      	* python/py-objfile.c: Fix indentation.
      	* python/py-prettyprint.c: Fix indentation.
      	* python/py-registers.c: Fix indentation.
      	* python/py-signalevent.c: Fix indentation.
      	* python/py-stopevent.c: Fix indentation.
      	* python/py-stopevent.h: Fix indentation.
      	* python/py-threadevent.c: Fix indentation.
      	* python/py-tui.c: Fix indentation.
      	* python/py-unwind.c: Fix indentation.
      	* python/py-value.c: Fix indentation.
      	* python/py-xmethods.c: Fix indentation.
      	* python/python-internal.h: Fix indentation.
      	* python/python.c: Fix indentation.
      	* ravenscar-thread.c: Fix indentation.
      	* record-btrace.c: Fix indentation.
      	* record-full.c: Fix indentation.
      	* record.c: Fix indentation.
      	* reggroups.c: Fix indentation.
      	* regset.h: Fix indentation.
      	* remote-fileio.c: Fix indentation.
      	* remote.c: Fix indentation.
      	* reverse.c: Fix indentation.
      	* riscv-linux-tdep.c: Fix indentation.
      	* riscv-ravenscar-thread.c: Fix indentation.
      	* riscv-tdep.c: Fix indentation.
      	* rl78-tdep.c: Fix indentation.
      	* rs6000-aix-tdep.c: Fix indentation.
      	* rs6000-lynx178-tdep.c: Fix indentation.
      	* rs6000-nat.c: Fix indentation.
      	* rs6000-tdep.c: Fix indentation.
      	* rust-lang.c: Fix indentation.
      	* rx-tdep.c: Fix indentation.
      	* s12z-tdep.c: Fix indentation.
      	* s390-linux-tdep.c: Fix indentation.
      	* score-tdep.c: Fix indentation.
      	* ser-base.c: Fix indentation.
      	* ser-mingw.c: Fix indentation.
      	* ser-uds.c: Fix indentation.
      	* ser-unix.c: Fix indentation.
      	* serial.c: Fix indentation.
      	* sh-linux-tdep.c: Fix indentation.
      	* sh-nbsd-tdep.c: Fix indentation.
      	* sh-tdep.c: Fix indentation.
      	* skip.c: Fix indentation.
      	* sol-thread.c: Fix indentation.
      	* solib-aix.c: Fix indentation.
      	* solib-darwin.c: Fix indentation.
      	* solib-frv.c: Fix indentation.
      	* solib-svr4.c: Fix indentation.
      	* solib.c: Fix indentation.
      	* source.c: Fix indentation.
      	* sparc-linux-tdep.c: Fix indentation.
      	* sparc-nbsd-tdep.c: Fix indentation.
      	* sparc-obsd-tdep.c: Fix indentation.
      	* sparc-ravenscar-thread.c: Fix indentation.
      	* sparc-tdep.c: Fix indentation.
      	* sparc64-linux-tdep.c: Fix indentation.
      	* sparc64-nbsd-tdep.c: Fix indentation.
      	* sparc64-obsd-tdep.c: Fix indentation.
      	* sparc64-tdep.c: Fix indentation.
      	* stabsread.c: Fix indentation.
      	* stack.c: Fix indentation.
      	* stap-probe.c: Fix indentation.
      	* stubs/ia64vms-stub.c: Fix indentation.
      	* stubs/m32r-stub.c: Fix indentation.
      	* stubs/m68k-stub.c: Fix indentation.
      	* stubs/sh-stub.c: Fix indentation.
      	* stubs/sparc-stub.c: Fix indentation.
      	* symfile-mem.c: Fix indentation.
      	* symfile.c: Fix indentation.
      	* symfile.h: Fix indentation.
      	* symmisc.c: Fix indentation.
      	* symtab.c: Fix indentation.
      	* symtab.h: Fix indentation.
      	* target-float.c: Fix indentation.
      	* target.c: Fix indentation.
      	* target.h: Fix indentation.
      	* tic6x-tdep.c: Fix indentation.
      	* tilegx-linux-tdep.c: Fix indentation.
      	* tilegx-tdep.c: Fix indentation.
      	* top.c: Fix indentation.
      	* tracefile-tfile.c: Fix indentation.
      	* tracepoint.c: Fix indentation.
      	* tui/tui-disasm.c: Fix indentation.
      	* tui/tui-io.c: Fix indentation.
      	* tui/tui-regs.c: Fix indentation.
      	* tui/tui-stack.c: Fix indentation.
      	* tui/tui-win.c: Fix indentation.
      	* tui/tui-winsource.c: Fix indentation.
      	* tui/tui.c: Fix indentation.
      	* typeprint.c: Fix indentation.
      	* ui-out.h: Fix indentation.
      	* unittests/copy_bitwise-selftests.c: Fix indentation.
      	* unittests/memory-map-selftests.c: Fix indentation.
      	* utils.c: Fix indentation.
      	* v850-tdep.c: Fix indentation.
      	* valarith.c: Fix indentation.
      	* valops.c: Fix indentation.
      	* valprint.c: Fix indentation.
      	* valprint.h: Fix indentation.
      	* value.c: Fix indentation.
      	* value.h: Fix indentation.
      	* varobj.c: Fix indentation.
      	* vax-tdep.c: Fix indentation.
      	* windows-nat.c: Fix indentation.
      	* windows-tdep.c: Fix indentation.
      	* xcoffread.c: Fix indentation.
      	* xml-syscall.c: Fix indentation.
      	* xml-tdesc.c: Fix indentation.
      	* xstormy16-tdep.c: Fix indentation.
      	* xtensa-config.c: Fix indentation.
      	* xtensa-linux-nat.c: Fix indentation.
      	* xtensa-linux-tdep.c: Fix indentation.
      	* xtensa-tdep.c: Fix indentation.
      
      gdbserver/ChangeLog:
      
      	* ax.cc: Fix indentation.
      	* dll.cc: Fix indentation.
      	* inferiors.h: Fix indentation.
      	* linux-low.cc: Fix indentation.
      	* linux-nios2-low.cc: Fix indentation.
      	* linux-ppc-ipa.cc: Fix indentation.
      	* linux-ppc-low.cc: Fix indentation.
      	* linux-x86-low.cc: Fix indentation.
      	* linux-xtensa-low.cc: Fix indentation.
      	* regcache.cc: Fix indentation.
      	* server.cc: Fix indentation.
      	* tracepoint.cc: Fix indentation.
      
      gdbsupport/ChangeLog:
      
      	* common-exceptions.h: Fix indentation.
      	* event-loop.cc: Fix indentation.
      	* fileio.cc: Fix indentation.
      	* filestuff.cc: Fix indentation.
      	* gdb-dlfcn.cc: Fix indentation.
      	* gdb_string_view.h: Fix indentation.
      	* job-control.cc: Fix indentation.
      	* signals.cc: Fix indentation.
      
      Change-Id: I4bad7ae6be0fbe14168b8ebafb98ffe14964a695
      dda83cd7
  10. Sep 15, 2020
    • Tom Tromey's avatar
      Don't use PyInt_FromLong · 47f0e2ff
      Tom Tromey authored
      Avoid the use of PyInt_FromLong, preferring gdb_py_object_from_longest
      instead.  I found found another spot that was incorrectly handling
      errors (see gdbpy_create_ptid_object) while writing this patch; it is
      fixed here.
      
      gdb/ChangeLog
      2020-09-15  Tom Tromey  <tromey@adacore.com>
      
      	* python/python-internal.h (PyInt_FromLong): Remove define.
      	* python/py-value.c (convert_value_from_python): Use
      	gdb_py_object_from_longest.
      	* python/py-type.c (typy_get_code): Use
      	gdb_py_object_from_longest.
      	* python/py-symtab.c (salpy_get_line): Use
      	gdb_py_object_from_longest.
      	* python/py-symbol.c (sympy_get_addr_class, sympy_line): Use
      	gdb_py_object_from_longest.
      	* python/py-record.c (recpy_gap_reason_code): Use
      	gdb_py_object_from_longest.
      	* python/py-record-btrace.c (recpy_bt_insn_size)
      	(recpy_bt_func_level, btpy_list_count): Use
      	gdb_py_object_from_longest.
      	* python/py-infthread.c (gdbpy_create_ptid_object): Use
      	gdb_py_object_from_longest.  Fix error handling.
      	* python/py-framefilter.c (bootstrap_python_frame_filters): Use
      	gdb_py_object_from_longest.
      	* python/py-frame.c (frapy_type, frapy_unwind_stop_reason): Use
      	gdb_py_object_from_longest.
      	* python/py-breakpoint.c (bppy_get_type, bppy_get_number)
      	(bppy_get_thread, bppy_get_task, bppy_get_hit_count)
      	(bppy_get_ignore_count): Use gdb_py_object_from_longest.
      47f0e2ff
    • Tom Tromey's avatar
      Don't use PyLong_FromLong · 062534d4
      Tom Tromey authored
      This changes gdb to avoid PyLong_FromLong, preferring to
      gdb_py_object_from_longest instead.
      
      gdb/ChangeLog
      2020-09-15  Tom Tromey  <tromey@adacore.com>
      
      	* python/python.c (gdbpy_parameter_value): Use
      	gdb_py_object_from_longest.
      	* python/py-type.c (convert_field, typy_range): Use
      	gdb_py_object_from_longest.
      	* python/py-tui.c (gdbpy_tui_width, gdbpy_tui_height): Use
      	gdb_py_object_from_longest.
      	* python/py-lazy-string.c (stpy_get_length): Use
      	gdb_py_object_from_longest.
      	* python/py-infthread.c (thpy_get_num, thpy_get_global_num): Use
      	gdb_py_object_from_longest.
      	* python/py-infevents.c (create_memory_changed_event_object): Use
      	gdb_py_object_from_longest.
      	* python/py-inferior.c (infpy_get_num): Use
      	gdb_py_object_from_longest.
      	(infpy_get_pid): Likewise.
      062534d4
  11. Jan 01, 2020
  12. Jul 10, 2019
    • Tom Tromey's avatar
      Reduce manual reference counting in py-inferior.c · 05b08ac1
      Tom Tromey authored
      This patch changes py-inferior.c to use gdbpy_ref<> when possible,
      reducing the amount of manual reference counting.
      
      Tested on x86-64 Fedora 29.
      
      gdb/ChangeLog
      2019-07-10  Tom Tromey  <tromey@adacore.com>
      
      	* python/python-internal.h (create_thread_object): Return
      	gdbpy_ref.
      	* python/py-infthread.c (create_thread_object): Return gdbpy_ref.
      	* python/py-inferior.c (struct threadlist_entry): Add
      	constructor.
      	<thread_obj>: Now a gdbpy_ref.
      	(thread_to_thread_object): Update.
      	(add_thread_object): Use new.
      	(delete_thread_object): Use delete.
      	(infpy_threads): Update.
      	(py_free_inferior): Update.  Construct "inf_obj" after acquiring
      	GIL.
      05b08ac1
  13. Apr 09, 2019
  14. Apr 08, 2019
    • Tom Tromey's avatar
      Rename gdb exception types · 230d2906
      Tom Tromey authored
      This renames the gdb exception types.  The old types were only needed
      due to the macros in common-exception.h that are now gone.
      
      The intermediate layer of gdb_exception_RETURN_MASK_ALL did not seem
      needed, so this patch removes it entirely.
      
      gdb/ChangeLog
      2019-04-08  Tom Tromey  <tom@tromey.com>
      
      	* common/common-exceptions.h (gdb_exception_RETURN_MASK_ALL):
      	Remove.
      	(gdb_exception_error): Rename from
      	gdb_exception_RETURN_MASK_ERROR.
      	(gdb_exception_quit): Rename from gdb_exception_RETURN_MASK_QUIT.
      	(gdb_quit_bad_alloc): Update.
      	* aarch64-tdep.c: Update.
      	* ada-lang.c: Update.
      	* ada-typeprint.c: Update.
      	* ada-valprint.c: Update.
      	* amd64-tdep.c: Update.
      	* arch-utils.c: Update.
      	* break-catch-throw.c: Update.
      	* breakpoint.c: Update.
      	* btrace.c: Update.
      	* c-varobj.c: Update.
      	* cli/cli-cmds.c: Update.
      	* cli/cli-interp.c: Update.
      	* cli/cli-script.c: Update.
      	* common/common-exceptions.c: Update.
      	* common/new-op.c: Update.
      	* common/selftest.c: Update.
      	* compile/compile-c-symbols.c: Update.
      	* compile/compile-cplus-symbols.c: Update.
      	* compile/compile-object-load.c: Update.
      	* compile/compile-object-run.c: Update.
      	* completer.c: Update.
      	* corelow.c: Update.
      	* cp-abi.c: Update.
      	* cp-support.c: Update.
      	* cp-valprint.c: Update.
      	* darwin-nat.c: Update.
      	* disasm-selftests.c: Update.
      	* dtrace-probe.c: Update.
      	* dwarf-index-cache.c: Update.
      	* dwarf-index-write.c: Update.
      	* dwarf2-frame-tailcall.c: Update.
      	* dwarf2-frame.c: Update.
      	* dwarf2loc.c: Update.
      	* dwarf2read.c: Update.
      	* eval.c: Update.
      	* event-loop.c: Update.
      	* event-top.c: Update.
      	* exec.c: Update.
      	* f-valprint.c: Update.
      	* fbsd-tdep.c: Update.
      	* frame-unwind.c: Update.
      	* frame.c: Update.
      	* gdbtypes.c: Update.
      	* gnu-v3-abi.c: Update.
      	* guile/guile-internal.h: Update.
      	* guile/scm-block.c: Update.
      	* guile/scm-breakpoint.c: Update.
      	* guile/scm-cmd.c: Update.
      	* guile/scm-disasm.c: Update.
      	* guile/scm-frame.c: Update.
      	* guile/scm-lazy-string.c: Update.
      	* guile/scm-math.c: Update.
      	* guile/scm-param.c: Update.
      	* guile/scm-ports.c: Update.
      	* guile/scm-pretty-print.c: Update.
      	* guile/scm-symbol.c: Update.
      	* guile/scm-symtab.c: Update.
      	* guile/scm-type.c: Update.
      	* guile/scm-value.c: Update.
      	* i386-linux-tdep.c: Update.
      	* i386-tdep.c: Update.
      	* inf-loop.c: Update.
      	* infcall.c: Update.
      	* infcmd.c: Update.
      	* infrun.c: Update.
      	* jit.c: Update.
      	* language.c: Update.
      	* linespec.c: Update.
      	* linux-fork.c: Update.
      	* linux-nat.c: Update.
      	* linux-tdep.c: Update.
      	* linux-thread-db.c: Update.
      	* main.c: Update.
      	* mi/mi-cmd-break.c: Update.
      	* mi/mi-cmd-stack.c: Update.
      	* mi/mi-interp.c: Update.
      	* mi/mi-main.c: Update.
      	* objc-lang.c: Update.
      	* p-valprint.c: Update.
      	* parse.c: Update.
      	* ppc-linux-tdep.c: Update.
      	* printcmd.c: Update.
      	* python/py-arch.c: Update.
      	* python/py-breakpoint.c: Update.
      	* python/py-cmd.c: Update.
      	* python/py-finishbreakpoint.c: Update.
      	* python/py-frame.c: Update.
      	* python/py-framefilter.c: Update.
      	* python/py-gdb-readline.c: Update.
      	* python/py-inferior.c: Update.
      	* python/py-infthread.c: Update.
      	* python/py-lazy-string.c: Update.
      	* python/py-linetable.c: Update.
      	* python/py-objfile.c: Update.
      	* python/py-param.c: Update.
      	* python/py-prettyprint.c: Update.
      	* python/py-progspace.c: Update.
      	* python/py-record-btrace.c: Update.
      	* python/py-record.c: Update.
      	* python/py-symbol.c: Update.
      	* python/py-type.c: Update.
      	* python/py-unwind.c: Update.
      	* python/py-utils.c: Update.
      	* python/py-value.c: Update.
      	* python/python.c: Update.
      	* record-btrace.c: Update.
      	* record-full.c: Update.
      	* remote-fileio.c: Update.
      	* remote.c: Update.
      	* riscv-tdep.c: Update.
      	* rs6000-aix-tdep.c: Update.
      	* rs6000-tdep.c: Update.
      	* rust-exp.y: Update.
      	* rust-lang.c: Update.
      	* s390-tdep.c: Update.
      	* selftest-arch.c: Update.
      	* solib-dsbt.c: Update.
      	* solib-frv.c: Update.
      	* solib-spu.c: Update.
      	* solib-svr4.c: Update.
      	* solib.c: Update.
      	* sparc64-linux-tdep.c: Update.
      	* stack.c: Update.
      	* symfile-mem.c: Update.
      	* symmisc.c: Update.
      	* target.c: Update.
      	* thread.c: Update.
      	* top.c: Update.
      	* tracefile-tfile.c: Update.
      	* tui/tui.c: Update.
      	* typeprint.c: Update.
      	* unittests/cli-utils-selftests.c: Update.
      	* unittests/parse-connection-spec-selftests.c: Update.
      	* valops.c: Update.
      	* valprint.c: Update.
      	* value.c: Update.
      	* varobj.c: Update.
      	* windows-nat.c: Update.
      	* x86-linux-nat.c: Update.
      	* xml-support.c: Update.
      
      gdb/gdbserver/ChangeLog
      2019-04-08  Tom Tromey  <tom@tromey.com>
      
      	* gdbreplay.c: Update.
      	* linux-low.c: Update.
      	* server.c: Update.
      230d2906
    • Tom Tromey's avatar
      Rewrite TRY/CATCH · a70b8144
      Tom Tromey authored
      This rewrites gdb's TRY/CATCH to plain C++ try/catch.  The patch was
      largely written by script, though one change (to a comment in
      common-exceptions.h) was reverted by hand.
      
      gdb/ChangeLog
      2019-04-08  Tom Tromey  <tom@tromey.com>
      
      	* xml-support.c: Use C++ exception handling.
      	* x86-linux-nat.c: Use C++ exception handling.
      	* windows-nat.c: Use C++ exception handling.
      	* varobj.c: Use C++ exception handling.
      	* value.c: Use C++ exception handling.
      	* valprint.c: Use C++ exception handling.
      	* valops.c: Use C++ exception handling.
      	* unittests/parse-connection-spec-selftests.c: Use C++ exception
      	handling.
      	* unittests/cli-utils-selftests.c: Use C++ exception handling.
      	* typeprint.c: Use C++ exception handling.
      	* tui/tui.c: Use C++ exception handling.
      	* tracefile-tfile.c: Use C++ exception handling.
      	* top.c: Use C++ exception handling.
      	* thread.c: Use C++ exception handling.
      	* target.c: Use C++ exception handling.
      	* symmisc.c: Use C++ exception handling.
      	* symfile-mem.c: Use C++ exception handling.
      	* stack.c: Use C++ exception handling.
      	* sparc64-linux-tdep.c: Use C++ exception handling.
      	* solib.c: Use C++ exception handling.
      	* solib-svr4.c: Use C++ exception handling.
      	* solib-spu.c: Use C++ exception handling.
      	* solib-frv.c: Use C++ exception handling.
      	* solib-dsbt.c: Use C++ exception handling.
      	* selftest-arch.c: Use C++ exception handling.
      	* s390-tdep.c: Use C++ exception handling.
      	* rust-lang.c: Use C++ exception handling.
      	* rust-exp.y: Use C++ exception handling.
      	* rs6000-tdep.c: Use C++ exception handling.
      	* rs6000-aix-tdep.c: Use C++ exception handling.
      	* riscv-tdep.c: Use C++ exception handling.
      	* remote.c: Use C++ exception handling.
      	* remote-fileio.c: Use C++ exception handling.
      	* record-full.c: Use C++ exception handling.
      	* record-btrace.c: Use C++ exception handling.
      	* python/python.c: Use C++ exception handling.
      	* python/py-value.c: Use C++ exception handling.
      	* python/py-utils.c: Use C++ exception handling.
      	* python/py-unwind.c: Use C++ exception handling.
      	* python/py-type.c: Use C++ exception handling.
      	* python/py-symbol.c: Use C++ exception handling.
      	* python/py-record.c: Use C++ exception handling.
      	* python/py-record-btrace.c: Use C++ exception handling.
      	* python/py-progspace.c: Use C++ exception handling.
      	* python/py-prettyprint.c: Use C++ exception handling.
      	* python/py-param.c: Use C++ exception handling.
      	* python/py-objfile.c: Use C++ exception handling.
      	* python/py-linetable.c: Use C++ exception handling.
      	* python/py-lazy-string.c: Use C++ exception handling.
      	* python/py-infthread.c: Use C++ exception handling.
      	* python/py-inferior.c: Use C++ exception handling.
      	* python/py-gdb-readline.c: Use C++ exception handling.
      	* python/py-framefilter.c: Use C++ exception handling.
      	* python/py-frame.c: Use C++ exception handling.
      	* python/py-finishbreakpoint.c: Use C++ exception handling.
      	* python/py-cmd.c: Use C++ exception handling.
      	* python/py-breakpoint.c: Use C++ exception handling.
      	* python/py-arch.c: Use C++ exception handling.
      	* printcmd.c: Use C++ exception handling.
      	* ppc-linux-tdep.c: Use C++ exception handling.
      	* parse.c: Use C++ exception handling.
      	* p-valprint.c: Use C++ exception handling.
      	* objc-lang.c: Use C++ exception handling.
      	* mi/mi-main.c: Use C++ exception handling.
      	* mi/mi-interp.c: Use C++ exception handling.
      	* mi/mi-cmd-stack.c: Use C++ exception handling.
      	* mi/mi-cmd-break.c: Use C++ exception handling.
      	* main.c: Use C++ exception handling.
      	* linux-thread-db.c: Use C++ exception handling.
      	* linux-tdep.c: Use C++ exception handling.
      	* linux-nat.c: Use C++ exception handling.
      	* linux-fork.c: Use C++ exception handling.
      	* linespec.c: Use C++ exception handling.
      	* language.c: Use C++ exception handling.
      	* jit.c: Use C++ exception handling.
      	* infrun.c: Use C++ exception handling.
      	* infcmd.c: Use C++ exception handling.
      	* infcall.c: Use C++ exception handling.
      	* inf-loop.c: Use C++ exception handling.
      	* i386-tdep.c: Use C++ exception handling.
      	* i386-linux-tdep.c: Use C++ exception handling.
      	* guile/scm-value.c: Use C++ exception handling.
      	* guile/scm-type.c: Use C++ exception handling.
      	* guile/scm-symtab.c: Use C++ exception handling.
      	* guile/scm-symbol.c: Use C++ exception handling.
      	* guile/scm-pretty-print.c: Use C++ exception handling.
      	* guile/scm-ports.c: Use C++ exception handling.
      	* guile/scm-param.c: Use C++ exception handling.
      	* guile/scm-math.c: Use C++ exception handling.
      	* guile/scm-lazy-string.c: Use C++ exception handling.
      	* guile/scm-frame.c: Use C++ exception handling.
      	* guile/scm-disasm.c: Use C++ exception handling.
      	* guile/scm-cmd.c: Use C++ exception handling.
      	* guile/scm-breakpoint.c: Use C++ exception handling.
      	* guile/scm-block.c: Use C++ exception handling.
      	* guile/guile-internal.h: Use C++ exception handling.
      	* gnu-v3-abi.c: Use C++ exception handling.
      	* gdbtypes.c: Use C++ exception handling.
      	* frame.c: Use C++ exception handling.
      	* frame-unwind.c: Use C++ exception handling.
      	* fbsd-tdep.c: Use C++ exception handling.
      	* f-valprint.c: Use C++ exception handling.
      	* exec.c: Use C++ exception handling.
      	* event-top.c: Use C++ exception handling.
      	* event-loop.c: Use C++ exception handling.
      	* eval.c: Use C++ exception handling.
      	* dwarf2read.c: Use C++ exception handling.
      	* dwarf2loc.c: Use C++ exception handling.
      	* dwarf2-frame.c: Use C++ exception handling.
      	* dwarf2-frame-tailcall.c: Use C++ exception handling.
      	* dwarf-index-write.c: Use C++ exception handling.
      	* dwarf-index-cache.c: Use C++ exception handling.
      	* dtrace-probe.c: Use C++ exception handling.
      	* disasm-selftests.c: Use C++ exception handling.
      	* darwin-nat.c: Use C++ exception handling.
      	* cp-valprint.c: Use C++ exception handling.
      	* cp-support.c: Use C++ exception handling.
      	* cp-abi.c: Use C++ exception handling.
      	* corelow.c: Use C++ exception handling.
      	* completer.c: Use C++ exception handling.
      	* compile/compile-object-run.c: Use C++ exception handling.
      	* compile/compile-object-load.c: Use C++ exception handling.
      	* compile/compile-cplus-symbols.c: Use C++ exception handling.
      	* compile/compile-c-symbols.c: Use C++ exception handling.
      	* common/selftest.c: Use C++ exception handling.
      	* common/new-op.c: Use C++ exception handling.
      	* cli/cli-script.c: Use C++ exception handling.
      	* cli/cli-interp.c: Use C++ exception handling.
      	* cli/cli-cmds.c: Use C++ exception handling.
      	* c-varobj.c: Use C++ exception handling.
      	* btrace.c: Use C++ exception handling.
      	* breakpoint.c: Use C++ exception handling.
      	* break-catch-throw.c: Use C++ exception handling.
      	* arch-utils.c: Use C++ exception handling.
      	* amd64-tdep.c: Use C++ exception handling.
      	* ada-valprint.c: Use C++ exception handling.
      	* ada-typeprint.c: Use C++ exception handling.
      	* ada-lang.c: Use C++ exception handling.
      	* aarch64-tdep.c: Use C++ exception handling.
      
      gdb/gdbserver/ChangeLog
      2019-04-08  Tom Tromey  <tom@tromey.com>
      
      	* server.c: Use C++ exception handling.
      	* linux-low.c: Use C++ exception handling.
      	* gdbreplay.c: Use C++ exception handling.
      a70b8144
  15. Jan 03, 2019
    • Tom Tromey's avatar
      Change inferior_to_inferior_object to return a gdbpy_ref · 61fd3e73
      Tom Tromey authored
      Most callers of inferior_to_inferior_object already use a gdbpy_ref,
      so this changes inferior_to_inferior_object to return one.  Doing this
      revealed that create_thread_object was not correctly handling the case
      where inferior_to_inferior_object failed, so this patch fixes this as
      well.
      
      gdb/ChangeLog
      2019-01-02  Tom Tromey  <tom@tromey.com>
      
      	* python/python-internal.h (inferior_to_inferior_object): Change
      	return type.
      	* python/py-exitedevent.c (create_exited_event_object): Update.
      	* python/py-inferior.c (inferior_to_inferior_object): Return
      	gdbpy_ref.
      	(python_new_inferior, python_inferior_deleted)
      	(thread_to_thread_object, delete_thread_object)
      	(build_inferior_list, gdbpy_selected_inferior): Update.
      	* python/py-infthread.c (create_thread_object): Update.  Also fail
      	if inferior_to_inferior_object fails.
      61fd3e73
  16. Jan 01, 2019
    • Joel Brobecker's avatar
      Update copyright year range in all GDB files. · 42a4f53d
      Joel Brobecker authored
      This commit applies all changes made after running the gdb/copyright.py
      script.
      
      Note that one file was flagged by the script, due to an invalid
      copyright header
      (gdb/unittests/basic_string_view/element_access/char/empty.cc).
      As the file was copied from GCC's libstdc++-v3 testsuite, this commit
      leaves this file untouched for the time being; a patch to fix the header
      was sent to gcc-patches first.
      
      gdb/ChangeLog:
      
      	Update copyright year range in all GDB files.
      42a4f53d
  17. Sep 16, 2018
    • Tom Tromey's avatar
      Change thread_to_thread_object to return a new reference · db1337cc
      Tom Tromey authored
      This changes thread_to_thread_object to return a new reference and
      fixes up all the callers.
      
      gdb/ChangeLog
      2018-09-16  Tom Tromey  <tom@tromey.com>
      
      	* python/python-internal.h (thread_to_thread_object): Change
      	return type.
      	* python/py-inferior.c (thread_to_thread_object): Return a new
      	reference.
      	(infpy_thread_from_thread_handle): Update.
      	* python/py-infthread.c (gdbpy_selected_thread): Update.
      	* python/py-stopevent.c (create_stop_event_object): Update.
      	* python/py-threadevent.c (py_get_event_thread): Return a new
      	reference.
      	(py_get_event_thread): Update.
      	* python/py-event.h (py_get_event_thread): Change return type.
      	* python/py-continueevent.c (create_continue_event_object):
      	Update.
      db1337cc
  18. Jul 03, 2018
    • Tom Tromey's avatar
      Remove ptid_get_tid · cc6bcb54
      Tom Tromey authored
      This removes ptid_get_tid in favor of calling the ptid_t::tid method.
      
      gdb/ChangeLog
      2018-07-03  Tom Tromey  <tom@tromey.com>
      
      	* common/ptid.c (ptid_get_tid): Remove.
      	* common/ptid.h (ptid_get_tid): Don't declare.
      	* ada-tasks.c: Update.
      	* aix-thread.c: Update.
      	* bsd-uthread.c: Update.
      	* darwin-nat.c: Update.
      	* fbsd-nat.c: Update.
      	* i386-darwin-nat.c: Update.
      	* infrun.c: Update.
      	* linux-tdep.c: Update.
      	* nto-procfs.c: Update.
      	* ppc-ravenscar-thread.c: Update.
      	* python/py-infthread.c: Update.
      	* ravenscar-thread.c: Update.
      	* sol-thread.c: Update.
      	* sparc-ravenscar-thread.c: Update.
      	* windows-nat.c: Update.
      
      gdb/gdbserver/ChangeLog
      2018-07-03  Tom Tromey  <tom@tromey.com>
      
      	* target.c: Update.
      cc6bcb54
    • Tom Tromey's avatar
      Remove ptid_get_lwp · e38504b3
      Tom Tromey authored
      This removes ptid_get_lwp in favor of calling the ptid_t::lwp method.
      
      gdb/ChangeLog
      2018-07-03  Tom Tromey  <tom@tromey.com>
      
      	* common/ptid.c (ptid_get_lwp): Remove.
      	* common/ptid.h (ptid_get_lwp): Don't declare.
      	* aarch64-linux-nat.c: Update.
      	* ada-tasks.c: Update.
      	* aix-thread.c: Update.
      	* amd64-linux-nat.c: Update.
      	* arm-linux-nat.c: Update.
      	* corelow.c: Update.
      	* fbsd-nat.c: Update.
      	* fbsd-tdep.c: Update.
      	* gnu-nat.c: Update.
      	* i386-cygwin-tdep.c: Update.
      	* i386-gnu-nat.c: Update.
      	* i386-linux-nat.c: Update.
      	* ia64-linux-nat.c: Update.
      	* inf-ptrace.c: Update.
      	* infrun.c: Update.
      	* linux-fork.c: Update.
      	* linux-nat.c: Update.
      	* linux-tdep.c: Update.
      	* linux-thread-db.c: Update.
      	* mips-linux-nat.c: Update.
      	* nat/aarch64-linux-hw-point.c: Update.
      	* nat/aarch64-linux.c: Update.
      	* nat/linux-btrace.c: Update.
      	* nat/linux-osdata.c: Update.
      	* nat/linux-procfs.c: Update.
      	* nat/x86-linux-dregs.c: Update.
      	* obsd-nat.c: Update.
      	* ppc-fbsd-nat.c: Update.
      	* ppc-linux-nat.c: Update.
      	* procfs.c: Update.
      	* python/py-infthread.c: Update.
      	* ravenscar-thread.c: Update.
      	* remote.c: Update.
      	* s390-linux-nat.c: Update.
      	* sol-thread.c: Update.
      	* sol2-tdep.c: Update.
      	* spu-linux-nat.c: Update.
      	* x86-linux-nat.c: Update.
      	* xtensa-linux-nat.c: Update.
      
      gdb/gdbserver/ChangeLog
      2018-07-03  Tom Tromey  <tom@tromey.com>
      
      	* linux-low.c: Update.
      	* linux-mips-low.c: Update.
      	* lynx-low.c: Update.
      	* nto-low.c: Update.
      	* remote-utils.c: Update.
      	* server.c: Update.
      	* spu-low.c: Update.
      	* target.c: Update.
      	* thread-db.c: Update.
      e38504b3
    • Tom Tromey's avatar
      Remove ptid_get_pid · e99b03dc
      Tom Tromey authored
      This removes ptid_get_pid in favor of calling the ptid_t::pid method.
      
      gdb/ChangeLog
      2018-07-03  Tom Tromey  <tom@tromey.com>
      
      	* common/ptid.c (ptid_get_pid): Remove.
      	* common/ptid.h (ptid_get_pid): Don't declare.
      	* aarch64-linux-nat.c: Update.
      	* ada-lang.c: Update.
      	* aix-thread.c: Update.
      	* alpha-bsd-nat.c: Update.
      	* amd64-fbsd-nat.c: Update.
      	* amd64-linux-nat.c: Update.
      	* arm-linux-nat.c: Update.
      	* arm-nbsd-nat.c: Update.
      	* auxv.c: Update.
      	* break-catch-syscall.c: Update.
      	* breakpoint.c: Update.
      	* bsd-uthread.c: Update.
      	* corelow.c: Update.
      	* ctf.c: Update.
      	* darwin-nat.c: Update.
      	* fbsd-nat.c: Update.
      	* fbsd-tdep.c: Update.
      	* gcore.c: Update.
      	* gnu-nat.c: Update.
      	* hppa-nbsd-nat.c: Update.
      	* hppa-obsd-nat.c: Update.
      	* i386-fbsd-nat.c: Update.
      	* ia64-linux-nat.c: Update.
      	* inf-ptrace.c: Update.
      	* infcmd.c: Update.
      	* inferior.c: Update.
      	* inferior.h: Update.
      	* inflow.c: Update.
      	* infrun.c: Update.
      	* linux-fork.c: Update.
      	* linux-nat.c: Update.
      	* linux-tdep.c: Update.
      	* linux-thread-db.c: Update.
      	* m68k-bsd-nat.c: Update.
      	* mi/mi-interp.c: Update.
      	* mi/mi-main.c: Update.
      	* mips-linux-nat.c: Update.
      	* mips-nbsd-nat.c: Update.
      	* mips64-obsd-nat.c: Update.
      	* nat/aarch64-linux-hw-point.c: Update.
      	* nat/aarch64-linux.c: Update.
      	* nat/linux-btrace.c: Update.
      	* nat/linux-osdata.c: Update.
      	* nat/linux-procfs.c: Update.
      	* nat/x86-linux-dregs.c: Update.
      	* nto-procfs.c: Update.
      	* obsd-nat.c: Update.
      	* ppc-linux-nat.c: Update.
      	* ppc-nbsd-nat.c: Update.
      	* ppc-obsd-nat.c: Update.
      	* proc-service.c: Update.
      	* procfs.c: Update.
      	* python/py-inferior.c: Update.
      	* python/py-infthread.c: Update.
      	* ravenscar-thread.c: Update.
      	* record.c: Update.
      	* remote-sim.c: Update.
      	* remote.c: Update.
      	* rs6000-nat.c: Update.
      	* s390-linux-nat.c: Update.
      	* sh-nbsd-nat.c: Update.
      	* sol-thread.c: Update.
      	* sparc-nat.c: Update.
      	* sparc64-tdep.c: Update.
      	* spu-linux-nat.c: Update.
      	* spu-tdep.c: Update.
      	* target-debug.h: Update.
      	* target.c: Update.
      	* thread.c: Update.
      	* tid-parse.c: Update.
      	* tracefile-tfile.c: Update.
      	* vax-bsd-nat.c: Update.
      	* windows-nat.c: Update.
      	* x86-linux-nat.c: Update.
      	* x86-nat.c: Update.
      
      gdb/gdbserver/ChangeLog
      2018-07-03  Tom Tromey  <tom@tromey.com>
      
      	* linux-low.c: Update.
      	* linux-mips-low.c: Update.
      	* lynx-low.c: Update.
      	* mem-break.c: Update.
      	* nto-low.c: Update.
      	* remote-utils.c: Update.
      	* server.c: Update.
      	* spu-low.c: Update.
      	* target.c: Update.
      	* tracepoint.c: Update.
      e99b03dc
  19. Jun 21, 2018
    • Pedro Alves's avatar
      Use thread_info and inferior pointers more throughout · 00431a78
      Pedro Alves authored
      This is more preparation bits for multi-target support.
      
      In a multi-target scenario, we need to address the case of different
      processes/threads running on different targets that happen to have the
      same PID/PTID.  E.g., we can have both process 123 in target 1, and
      process 123 in target 2, while they're in reality different processes
      running on different machines.  Or maybe we've loaded multiple
      instances of the same core file.  Etc.
      
      To address this, in my WIP multi-target branch, threads and processes
      are uniquely identified by the (process_stratum target_ops *, ptid_t)
      and (process_stratum target_ops *, pid) tuples respectively.  I.e.,
      each process_stratum instance has its own thread/process number space.
      
      As you can imagine, that requires passing around target_ops * pointers
      in a number of functions where we're currently passing only a ptid_t
      or an int.  E.g., when we look up a thread_info object by ptid_t in
      find_thread_ptid, the ptid_t alone isn't sufficient.
      
      In many cases though, we already have the thread_info or inferior
      pointer handy, but we "lose" it somewhere along the call stack, only
      to look it up again by ptid_t/pid.  Since thread_info or inferior
      objects know their parent target, if we pass around thread_info or
      inferior pointers when possible, we avoid having to add extra
      target_ops parameters to many functions, and also, we eliminate a
      number of by ptid_t/int lookups.
      
      So that's what this patch does.  In a bit more detail:
      
      - Changes a number of functions and methods to take a thread_info or
        inferior pointer instead of a ptid_t or int parameter.
      
      - Changes a number of structure fields from ptid_t/int to inferior or
        thread_info pointers.
      
      - Uses the inferior_thread() function whenever possible instead of
        inferior_ptid.
      
      - Uses thread_info pointers directly when possible instead of the
        is_running/is_stopped etc. routines that require a lookup.
      
      - A number of functions are eliminated along the way, such as:
      
        int valid_gdb_inferior_id (int num);
        int pid_to_gdb_inferior_id (int pid);
        int gdb_inferior_id_to_pid (int num);
        int in_inferior_list (int pid);
      
      - A few structures and places hold a thread_info pointer across
        inferior execution, so now they take a strong reference to the
        (refcounted) thread_info object to avoid the thread_info pointer
        getting stale.  This is done in enable_thread_stack_temporaries and
        in the infcall.c code.
      
      - Related, there's a spot in infcall.c where using a RAII object to
        handle the refcount would be handy, so a gdb::ref_ptr specialization
        for thread_info is added (thread_info_ref, in gdbthread.h), along
        with a gdb_ref_ptr policy that works for all refcounted_object types
        (in common/refcounted-object.h).
      
      gdb/ChangeLog:
      2018-06-21  Pedro Alves  <palves@redhat.com>
      
      	* ada-lang.h (ada_get_task_number): Take a thread_info pointer
      	instead of a ptid_t.  All callers adjusted.
      	* ada-tasks.c (ada_get_task_number): Likewise.  All callers
      	adjusted.
      	(print_ada_task_info, display_current_task_id, task_command_1):
      	Adjust.
      	* breakpoint.c (watchpoint_in_thread_scope): Adjust to use
      	inferior_thread.
      	(breakpoint_kind): Adjust.
      	(remove_breakpoints_pid): Rename to ...
      	(remove_breakpoints_inf): ... this.  Adjust to take an inferior
      	pointer.  All callers adjusted.
      	(bpstat_clear_actions): Use inferior_thread.
      	(get_bpstat_thread): New.
      	(bpstat_do_actions): Use it.
      	(bpstat_check_breakpoint_conditions, bpstat_stop_status): Adjust
      	to take a thread_info pointer.  All callers adjusted.
      	(set_longjmp_breakpoint_for_call_dummy, set_momentary_breakpoint)
      	(breakpoint_re_set_thread): Use inferior_thread.
      	* breakpoint.h (struct inferior): Forward declare.
      	(bpstat_stop_status): Update.
      	(remove_breakpoints_pid): Delete.
      	(remove_breakpoints_inf): New.
      	* bsd-uthread.c (bsd_uthread_target::wait)
      	(bsd_uthread_target::update_thread_list): Use find_thread_ptid.
      	* btrace.c (btrace_add_pc, btrace_enable, btrace_fetch)
      	(maint_btrace_packet_history_cmd)
      	(maint_btrace_clear_packet_history_cmd): Adjust.
      	(maint_btrace_clear_cmd, maint_info_btrace_cmd): Adjust to use
      	inferior_thread.
      	* cli/cli-interp.c: Include "inferior.h".
      	* common/refcounted-object.h (struct
      	refcounted_object_ref_policy): New.
      	* compile/compile-object-load.c: Include gdbthread.h.
      	(store_regs): Use inferior_thread.
      	* corelow.c (core_target::close): Use current_inferior.
      	(core_target_open): Adjust to use first_thread_of_inferior and use
      	the current inferior.
      	* ctf.c (ctf_target::close): Adjust to use current_inferior.
      	* dummy-frame.c (dummy_frame_id) <ptid>: Delete, replaced by ...
      	<thread>: ... this new field.  All references adjusted.
      	(dummy_frame_pop, dummy_frame_discard, register_dummy_frame_dtor):
      	Take a thread_info pointer instead of a ptid_t.
      	* dummy-frame.h (dummy_frame_push, dummy_frame_pop)
      	(dummy_frame_discard, register_dummy_frame_dtor): Take a
      	thread_info pointer instead of a ptid_t.
      	* elfread.c: Include "inferior.h".
      	(elf_gnu_ifunc_resolver_stop, elf_gnu_ifunc_resolver_return_stop):
      	Use inferior_thread.
      	* eval.c (evaluate_subexp): Likewise.
      	* frame.c (frame_pop, has_stack_frames, find_frame_sal): Use
      	inferior_thread.
      	* gdb_proc_service.h (struct thread_info): Forward declare.
      	(struct ps_prochandle) <ptid>: Delete, replaced by ...
      	<thread>: ... this new field.  All references adjusted.
      	* gdbarch.h, gdbarch.c: Regenerate.
      	* gdbarch.sh (get_syscall_number): Replace 'ptid' parameter with a
      	'thread' parameter.  All implementations and callers adjusted.
      	* gdbthread.h (thread_info) <set_running>: New method.
      	(delete_thread, delete_thread_silent): Take a thread_info pointer
      	instead of a ptid.
      	(global_thread_id_to_ptid, ptid_to_global_thread_id): Delete.
      	(first_thread_of_process): Delete, replaced by ...
      	(first_thread_of_inferior): ... this new function.  All callers
      	adjusted.
      	(any_live_thread_of_process): Delete, replaced by ...
      	(any_live_thread_of_inferior): ... this new function.  All callers
      	adjusted.
      	(switch_to_thread, switch_to_no_thread): Declare.
      	(is_executing): Delete.
      	(enable_thread_stack_temporaries): Update comment.
      	<enable_thread_stack_temporaries>: Take a thread_info pointer
      	instead of a ptid_t.  Incref the thread.
      	<~enable_thread_stack_temporaries>: Decref the thread.
      	<m_ptid>: Delete
      	<m_thr>: New.
      	(thread_stack_temporaries_enabled_p, push_thread_stack_temporary)
      	(get_last_thread_stack_temporary)
      	(value_in_thread_stack_temporaries, can_access_registers_thread):
      	Take a thread_info pointer instead of a ptid_t.  All callers
      	adjusted.
      	* infcall.c (get_call_return_value): Use inferior_thread.
      	(run_inferior_call): Work with thread pointers instead of ptid_t.
      	(call_function_by_hand_dummy): Work with thread pointers instead
      	of ptid_t.  Use thread_info_ref.
      	* infcmd.c (proceed_thread_callback): Access thread's state
      	directly.
      	(ensure_valid_thread, ensure_not_running): Use inferior_thread,
      	access thread's state directly.
      	(continue_command): Use inferior_thread.
      	(info_program_command): Use find_thread_ptid and access thread
      	state directly.
      	(proceed_after_attach_callback): Use thread state directly.
      	(notice_new_inferior): Take a thread_info pointer instead of a
      	ptid_t.  All callers adjusted.
      	(exit_inferior): Take an inferior pointer instead of a pid.  All
      	callers adjusted.
      	(exit_inferior_silent): New.
      	(detach_inferior): Delete.
      	(valid_gdb_inferior_id, pid_to_gdb_inferior_id)
      	(gdb_inferior_id_to_pid, in_inferior_list): Delete.
      	(detach_inferior_command, kill_inferior_command): Use
      	find_inferior_id instead of valid_gdb_inferior_id and
      	gdb_inferior_id_to_pid.
      	(inferior_command): Use inferior and thread pointers.
      	* inferior.h (struct thread_info): Forward declare.
      	(notice_new_inferior): Take a thread_info pointer instead of a
      	ptid_t.  All callers adjusted.
      	(detach_inferior): Delete declaration.
      	(exit_inferior, exit_inferior_silent): Take an inferior pointer
      	instead of a pid.  All callers adjusted.
      	(gdb_inferior_id_to_pid, pid_to_gdb_inferior_id, in_inferior_list)
      	(valid_gdb_inferior_id): Delete.
      	* infrun.c (follow_fork_inferior, proceed_after_vfork_done)
      	(handle_vfork_child_exec_or_exit, follow_exec): Adjust.
      	(struct displaced_step_inferior_state) <pid>: Delete, replaced by
      	...
      	<inf>: ... this new field.
      	<step_ptid>: Delete, replaced by ...
      	<step_thread>: ... this new field.
      	(get_displaced_stepping_state): Take an inferior pointer instead
      	of a pid.  All callers adjusted.
      	(displaced_step_in_progress_any_inferior): Adjust.
      	(displaced_step_in_progress_thread): Take a thread pointer instead
      	of a ptid_t.  All callers adjusted.
      	(displaced_step_in_progress, add_displaced_stepping_state): Take
      	an inferior pointer instead of a pid.  All callers adjusted.
      	(get_displaced_step_closure_by_addr): Adjust.
      	(remove_displaced_stepping_state): Take an inferior pointer
      	instead of a pid.  All callers adjusted.
      	(displaced_step_prepare_throw, displaced_step_prepare)
      	(displaced_step_fixup): Take a thread pointer instead of a ptid_t.
      	All callers adjusted.
      	(start_step_over): Adjust.
      	(infrun_thread_ptid_changed): Remove bit updating ptids in the
      	displaced step queue.
      	(do_target_resume): Adjust.
      	(fetch_inferior_event): Use inferior_thread.
      	(context_switch, get_inferior_stop_soon): Take an
      	execution_control_state pointer instead of a ptid_t.  All callers
      	adjusted.
      	(switch_to_thread_cleanup): Delete.
      	(stop_all_threads): Use scoped_restore_current_thread.
      	* inline-frame.c: Include "gdbthread.h".
      	(inline_state) <inline_state>: Take a thread pointer instead of a
      	ptid_t.  All callers adjusted.
      	<ptid>: Delete, replaced by ...
      	<thread>: ... this new field.
      	(find_inline_frame_state): Take a thread pointer instead of a
      	ptid_t.  All callers adjusted.
      	(skip_inline_frames, step_into_inline_frame)
      	(inline_skipped_frames, inline_skipped_symbol): Take a thread
      	pointer instead of a ptid_t.  All callers adjusted.
      	* inline-frame.h (skip_inline_frames, step_into_inline_frame)
      	(inline_skipped_frames, inline_skipped_symbol): Likewise.
      	* linux-fork.c (delete_checkpoint_command): Adjust to use thread
      	pointers directly.
      	* linux-nat.c (get_detach_signal): Likewise.
      	* linux-thread-db.c (thread_from_lwp): New 'stopped' parameter.
      	(thread_db_notice_clone): Adjust.
      	(thread_db_find_new_threads_silently)
      	(thread_db_find_new_threads_2, thread_db_find_new_threads_1): Take
      	a thread pointer instead of a ptid_t.  All callers adjusted.
      	* mi/mi-cmd-var.c: Include "inferior.h".
      	(mi_cmd_var_update_iter): Update to use thread pointers.
      	* mi/mi-interp.c (mi_new_thread): Update to use the thread's
      	inferior directly.
      	(mi_output_running_pid, mi_inferior_count): Delete, bits factored
      	out to ...
      	(mi_output_running): ... this new function.
      	(mi_on_resume_1): Adjust to use it.
      	(mi_user_selected_context_changed): Adjust to use inferior_thread.
      	* mi/mi-main.c (proceed_thread): Adjust to use thread pointers
      	directly.
      	(interrupt_thread_callback): : Adjust to use thread and inferior
      	pointers.
      	* proc-service.c: Include "gdbthread.h".
      	(ps_pglobal_lookup): Adjust to use the thread's inferior directly.
      	* progspace-and-thread.c: Include "inferior.h".
      	* progspace.c: Include "inferior.h".
      	* python/py-exitedevent.c (create_exited_event_object): Adjust to
      	hold a reference to an inferior_object.
      	* python/py-finishbreakpoint.c (bpfinishpy_init): Adjust to use
      	inferior_thread.
      	* python/py-inferior.c (struct inferior_object): Give the type a
      	tag name instead of a typedef.
      	(python_on_normal_stop): No need to check if the current thread is
      	listed.
      	(inferior_to_inferior_object): Change return type to
      	inferior_object.  All callers adjusted.
      	(find_thread_object): Delete, bits factored out to ...
      	(thread_to_thread_object): ... this new function.
      	* python/py-infthread.c (create_thread_object): Use
      	inferior_to_inferior_object.
      	(thpy_is_stopped): Use thread pointer directly.
      	(gdbpy_selected_thread): Use inferior_thread.
      	* python/py-record-btrace.c (btpy_list_object) <ptid>: Delete
      	field, replaced with ...
      	<thread>: ... this new field.  All users adjusted.
      	(btpy_insn_or_gap_new): Drop const.
      	(btpy_list_new): Take a thread pointer instead of a ptid_t.  All
      	callers adjusted.
      	* python/py-record.c: Include "gdbthread.h".
      	(recpy_insn_new, recpy_func_new): Take a thread pointer instead of
      	a ptid_t.  All callers adjusted.
      	(gdbpy_current_recording): Use inferior_thread.
      	* python/py-record.h (recpy_record_object) <ptid>: Delete
      	field, replaced with ...
      	<thread>: ... this new field.  All users adjusted.
      	(recpy_element_object) <ptid>: Delete
      	field, replaced with ...
      	<thread>: ... this new field.  All users adjusted.
      	(recpy_insn_new, recpy_func_new): Take a thread pointer instead of
      	a ptid_t.  All callers adjusted.
      	* python/py-threadevent.c: Include "gdbthread.h".
      	(get_event_thread): Use thread_to_thread_object.
      	* python/python-internal.h (struct inferior_object): Forward
      	declare.
      	(find_thread_object, find_inferior_object): Delete declarations.
      	(thread_to_thread_object, inferior_to_inferior_object): New
      	declarations.
      	* record-btrace.c: Include "inferior.h".
      	(require_btrace_thread): Use inferior_thread.
      	(record_btrace_frame_sniffer)
      	(record_btrace_tailcall_frame_sniffer): Use inferior_thread.
      	(get_thread_current_frame): Use scoped_restore_current_thread and
      	switch_to_thread.
      	(get_thread_current_frame): Use thread pointer directly.
      	(record_btrace_replay_at_breakpoint): Use thread's inferior
      	pointer directly.
      	* record-full.c: Include "inferior.h".
      	* regcache.c: Include "gdbthread.h".
      	(get_thread_arch_regcache): Use the inferior's address space
      	directly.
      	(get_thread_regcache, registers_changed_thread): New.
      	* regcache.h (get_thread_regcache(thread_info *thread)): New
      	overload.
      	(registers_changed_thread): New.
      	(remote_target) <remote_detach_1>: Swap order of parameters.
      	(remote_add_thread): <remote_add_thread>: Return the new thread.
      	(get_remote_thread_info(ptid_t)): New overload.
      	(remote_target::remote_notice_new_inferior): Use thread pointers
      	directly.
      	(remote_target::process_initial_stop_replies): Use
      	thread_info::set_running.
      	(remote_target::remote_detach_1, remote_target::detach)
      	(extended_remote_target::detach): Adjust.
      	* stack.c (frame_show_address): Use inferior_thread.
      	* target-debug.h (target_debug_print_thread_info_pp): New.
      	* target-delegates.c: Regenerate.
      	* target.c (default_thread_address_space): Delete.
      	(memory_xfer_partial_1): Use current_inferior.
      	(target_detach): Use current_inferior.
      	(target_thread_address_space): Delete.
      	(generic_mourn_inferior): Use current_inferior.
      	* target.h (struct target_ops) <thread_address_space>: Delete.
      	(target_thread_address_space): Delete.
      	* thread.c (init_thread_list): Use ALL_THREADS_SAFE.  Use thread
      	pointers directly.
      	(delete_thread_1, delete_thread, delete_thread_silent): Take a
      	thread pointer instead of a ptid_t.  Adjust all callers.
      	(ptid_to_global_thread_id, global_thread_id_to_ptid): Delete.
      	(first_thread_of_process): Delete, replaced by ...
      	(first_thread_of_inferior): ... this new function.  All callers
      	adjusted.
      	(any_thread_of_process): Rename to ...
      	(any_thread_of_inferior): ... this, and take an inferior pointer.
      	(any_live_thread_of_process): Rename to ...
      	(any_live_thread_of_inferior): ... this, and take an inferior
      	pointer.
      	(thread_stack_temporaries_enabled_p, push_thread_stack_temporary)
      	(value_in_thread_stack_temporaries)
      	(get_last_thread_stack_temporary): Take a thread pointer instead
      	of a ptid_t.  Adjust all callers.
      	(thread_info::set_running): New.
      	(validate_registers_access): Use inferior_thread.
      	(can_access_registers_ptid): Rename to ...
      	(can_access_registers_thread): ... this, and take a thread
      	pointer.
      	(print_thread_info_1): Adjust to compare thread pointers instead
      	of ptids.
      	(switch_to_no_thread, switch_to_thread): Make extern.
      	(scoped_restore_current_thread::~scoped_restore_current_thread):
      	Use m_thread pointer directly.
      	(scoped_restore_current_thread::scoped_restore_current_thread):
      	Use inferior_thread.
      	(thread_command): Use thread pointer directly.
      	(thread_num_make_value_helper): Use inferior_thread.
      	* top.c (execute_command): Use inferior_thread.
      	* tui/tui-interp.c: Include "inferior.h".
      	* varobj.c (varobj_create): Use inferior_thread.
      	(value_of_root_1): Use find_thread_global_id instead of
      	global_thread_id_to_ptid.
      00431a78
  20. Jan 02, 2018
  21. Oct 28, 2017
    • Maksim Dzabraev's avatar
      Make gdb.selected_thread().inferior return a new reference · 484d8d36
      Maksim Dzabraev authored
      thpy_get_inferior function should return a new reference to the
      existing inferior object, and therefore should increment its refcount.
      
      Fixed bug looks like this.
      If multiple time call gdb.selected_thread ().inferior, gdb throws exception:
      
      (gdb) pi gdb.selected_thread().inferior
      <gdb.Inferior object at 0x7f1952bea698>
      (gdb) pi gdb.selected_thread().inferior
      Python Exception <type 'exceptions.AttributeError'> 'NoneType' object
      has no attribute 'inferior':
      Error while executing Python code.
      (gdb) info threads
        Id   Target Id         Frame
      * 1    Thread 0x7f54f0474740 (LWP 584) "mc" 0x00007f54ef055c33 in
      484d8d36
  22. Apr 05, 2017
    • Pedro Alves's avatar
      -Wwrite-strings: Wrap PyGetSetDef for construction with string literals · 0d1f4ceb
      Pedro Alves authored
      Unfortunately, PyGetSetDef's 'name' and 'doc' members are 'char *'
      instead of 'const char *', meaning that in order to list-initialize
      PyGetSetDef arrays using string literals requires writing explicit
      'char *' casts.  For example:
      
          static PyGetSetDef value_object_getset[] = {
         -  { "address", valpy_get_address, NULL, "The address of the value.",
         +  { (char *) "address", valpy_get_address, NULL,
         +    (char *) "The address of the value.",
      	NULL },
         -  { "is_optimized_out", valpy_get_is_optimized_out, NULL,
         -    "Boolean telling whether the value is optimized "
         +  { (char *) "is_optimized_out", valpy_get_is_optimized_out, NULL,
         +    (char *) "Boolean telling whether the value is optimized "
      	"out (i.e., not available).",
      	NULL },
         -  { "type", valpy_get_type, NULL, "Type of the value.", NULL },
         -  { "dynamic_type", valpy_get_dynamic_type, NULL,
         -    "Dynamic type of the value.", NULL },
         -  { "is_lazy", valpy_get_is_lazy, NULL,
         -    "Boolean telling whether the value is lazy (not fetched yet\n\
         +  { (char *) "type", valpy_get_type, NULL,
         +    (char *) "Type of the value.", NULL },
         +  { (char *) "dynamic_type", valpy_get_dynamic_type, NULL,
         +    (char *) "Dynamic type of the value.", NULL },
         +  { (char *) "is_lazy", valpy_get_is_lazy, NULL,
         +    (char *) "Boolean telling whether the value is lazy (not fetched yet\n\
          from the inferior).  A lazy value is fetched when needed, or when\n\
          the \"fetch_lazy()\" method is called.", NULL },
            {NULL}  /* Sentinel */
      
      We have ~20 such arrays, and I first wrote a patch that fixed all of
      them like that...  It's not pretty...
      
      One way to make these a bit less ugly would be add a new macro that
      hides the casts, like:
      
        #define GDBPY_GSDEF(NAME, GET, SET, DOC, CLOSURE) \
           { (char *) NAME, GET, SET, (char *) DOC, CLOSURE }
      
      and then use it like:
      
          static PyGetSetDef value_object_getset[] = {
             GDBPY_GSDEF ("address", valpy_get_address, NULL,
             		    "The address of the value.", NULL),
             GDBPY_GSDEF ("is_optimized_out", valpy_get_is_optimized_out, NULL,
             		    "Boolean telling whether the value is optimized ", NULL),
            {NULL}  /* Sentinel */
          };
      
      But since we have C++11, which gives us constexpr and list
      initialization, I thought of a way that requires no changes where the
      arrays are initialized:
      
      We add a new type that extends PyGetSetDef (called gdb_PyGetSetDef),
      and add constexpr constructors that accept const 'name' and 'doc', and
      then list/aggregate initialization simply "calls" these matching
      constructors instead.
      
      I put "calls" in quotes, because given "constexpr", it's all done at
      compile time, and there's no overhead either in binary size or at run
      time.  In fact, we get identical binaries, before/after this change.
      
      Unlike the fixes that fix some old Python API to match the API of more
      recent Python, this switches to using explicit "gdb_PyGetSetDef"
      everywhere, just to be clear that we are using our own version of it.
      
      gdb/ChangeLog:
      2017-04-05  Pedro Alves  <palves@redhat.com>
      
      	* python/python-internal.h (gdb_PyGetSetDef): New type.
      	* python/py-block.c (block_object_getset)
      	(breakpoint_object_getset): Now a gdb_PyGetSetDef array.
      	* python/py-event.c (event_object_getset)
      	(finish_breakpoint_object_getset): Likewise.
      	* python/py-inferior.c (inferior_object_getset): Likewise.
      	* python/py-infthread.c (thread_object_getset): Likewise.
      	* python/py-lazy-string.c (lazy_string_object_getset): Likewise.
      	* python/py-linetable.c (linetable_entry_object_getset): Likewise.
      	* python/py-objfile.c (objfile_getset): Likewise.
      	* python/py-progspace.c (pspace_getset): Likewise.
      	* python/py-record-btrace.c (btpy_insn_getset, btpy_call_getset):
      	Likewise.
      	* python/py-record.c (recpy_record_getset): Likewise.
      	* python/py-symbol.c (symbol_object_getset): Likewise.
      	* python/py-symtab.c (symtab_object_getset, sal_object_getset):
      	Likewise.
      	* python/py-type.c (type_object_getset, field_object_getset):
      	Likewise.
      	* python/py-value.c (value_object_getset): Likewise.
      0d1f4ceb
  23. Jan 01, 2017
    • Joel Brobecker's avatar
      update copyright year range in GDB files · 61baf725
      Joel Brobecker authored
      This applies the second part of GDB's End of Year Procedure, which
      updates the copyright year range in all of GDB's files.
      
      gdb/ChangeLog:
      
              Update copyright year range in all GDB files.
      61baf725
  24. Nov 10, 2016
    • Tom Tromey's avatar
      Use unique_xmalloc_ptr in Python code · 9b972014
      Tom Tromey authored
      This changes some utility functions in the Python code to return
      unique_xmalloc_ptr, and then fixes up the callers.
      
      I chose unique_xmalloc_ptr rather than std::string because at a few
      call points the xmalloc'd string is released and ownership transferred
      elsewhere.
      
      This patch found a few existing memory leaks.  For example,
      py-unwind.c called gdbpy_obj_to_string but never freed the result.
      
      Built and regression tested on the buildbot.
      
      2016-11-09  Tom Tromey  <tom@tromey.com>
      
      	* varobj.h (varobj_get_display_hint): Change return type.
      	* varobj.c (varobj_get_display_hint): Return unique_xmalloc_ptr.
      	(varobj_value_get_print_value): Update.
      	* python/python.c (gdbpy_before_prompt_hook, gdbpy_print_stack)
      	(gdbpy_apply_type_printers): Update.
      	* python/python-internal.h (unicode_to_target_string)
      	(python_string_to_target_string, python_string_to_host_string)
      	(gdbpy_obj_to_string, gdbpy_exception_to_string)
      	(gdbpy_get_display_hint): Change return types.
      	* python/py-varobj.c (py_varobj_iter_next): Update.
      	* python/py-value.c (valpy_getitem, convert_value_from_python):
      	Update.
      	* python/py-utils.c (unicode_to_encoded_string)
      	(unicode_to_target_string, python_string_to_target_string)
      	(python_string_to_host_string, gdbpy_obj_to_string)
      	(gdbpy_exception_to_string): Return unique_xmalloc_ptr.
      	* python/py-unwind.c (pyuw_parse_register_id): Update.
      	* python/py-type.c (typy_getitem): Update.
      	* python/py-prettyprint.c (gdbpy_get_display_hint)
      	(print_stack_unless_memory_error, print_children)
      	(gdbpy_apply_val_pretty_printer): Update.
      	* python/py-param.c (set_parameter_value): Update.
      	(get_doc_string, call_doc_function): Return unique_xmalloc_ptr.
      	(get_set_value, get_show_value, compute_enum_values, parmpy_init):
      	Update.
      	* python/py-infthread.c (thpy_set_name): Update.
      	* python/py-function.c (fnpy_call, fnpy_init): Update.
      	* python/py-framefilter.c (extract_sym): Change "name" to
      	unique_xmalloc_ptr.
      	(enumerate_args, enumerate_locals): Update.
      	(py_print_frame): Use unique_xmalloc_ptr.
      	* python/py-frame.c (frapy_read_var): Update.  Remove cleanup.
      	* python/py-cmd.c (cmdpy_function, cmdpy_completer, cmdpy_init):
      	Update.
      	* python/py-breakpoint.c (bppy_set_condition): Use
      	unique_xmalloc_ptr.
      	(bppy_init): Likewise.  Remove cleanup.
      	(local_setattro): Update.
      	* mi/mi-cmd-var.c (print_varobj, mi_cmd_var_list_children)
      	(varobj_update_one): Update.
      9b972014
  25. May 08, 2016
    • Trevor Saunders's avatar
      remove trivialy unused variables · 870f88f7
      Trevor Saunders authored
      gdb/ChangeLog:
      
      2016-05-07  Trevor Saunders  <tbsaunde+binutils@tbsaunde.org>
      
      	* aarch64-linux-tdep.c (aarch64_linux_sigframe_init): Remove unused
      	variables.
      	* aarch64-tdep.c (aarch64_skip_prologue): Likewise.
      	(aarch64_scan_prologue): Likewise.
      	(aarch64_prologue_prev_register): Likewise.
      	(aarch64_dwarf2_prev_register): Likewise.
      	(pass_in_v): Likewise.
      	(aarch64_push_dummy_call): Likewise.
      	(aarch64_breakpoint_from_pc): Likewise.
      	(aarch64_return_in_memory): Likewise.
      	(aarch64_return_value): Likewise.
      	(aarch64_displaced_step_b_cond): Likewise.
      	(aarch64_displaced_step_cb): Likewise.
      	(aarch64_displaced_step_tb): Likewise.
      	(aarch64_gdbarch_init): Likewise.
      	(aarch64_process_record): Likewise.
      	* alpha-mdebug-tdep.c (alpha_mdebug_init_abi): Likewise.
      	* alpha-tdep.c (_initialize_alpha_tdep): Likewise.
      	* amd64-dicos-tdep.c (amd64_dicos_init_abi): Likewise.
      	* amd64-linux-tdep.c (amd64_dtrace_parse_probe_argument): Likewise.
      	* amd64-tdep.c (fixup_riprel): Likewise.
      	* amd64-windows-tdep.c (amd64_windows_frame_decode_epilogue): Likewise.
      	(amd64_windows_frame_decode_insns): Likewise.
      	(amd64_windows_frame_cache): Likewise.
      	(amd64_windows_frame_prev_register): Likewise.
      	(amd64_windows_frame_this_id): Likewise.
      	(amd64_windows_init_abi): Likewise.
      	* arm-linux-tdep.c (arm_linux_get_syscall_number): Likewise.
      	(arm_linux_get_next_pcs_syscall_next_pc): Likewise.
      	* arm-symbian-tdep.c (arm_symbian_init_abi): Likewise.
      	* arm-tdep.c (arm_make_epilogue_frame_cache): Likewise.
      	(arm_epilogue_frame_prev_register): Likewise.
      	(arm_record_vdata_transfer_insn): Likewise.
      	(arm_record_exreg_ld_st_insn): Likewise.
      	* auto-load.c (execute_script_contents): Likewise.
      	(print_scripts): Likewise.
      	* avr-tdep.c (avr_frame_prev_register): Likewise.
      	(avr_push_dummy_call): Likewise.
      	* bfin-linux-tdep.c (bfin_linux_sigframe_init): Likewise.
      	* bfin-tdep.c (bfin_gdbarch_init): Likewise.
      	* blockframe.c (find_pc_partial_function_gnu_ifunc): Likewise.
      	* break-catch-throw.c (fetch_probe_arguments): Likewise.
      	* breakpoint.c (breakpoint_xfer_memory): Likewise.
      	(breakpoint_init_inferior): Likewise.
      	(breakpoint_inserted_here_p): Likewise.
      	(software_breakpoint_inserted_here_p): Likewise.
      	(hardware_breakpoint_inserted_here_p): Likewise.
      	(bpstat_what): Likewise.
      	(break_range_command): Likewise.
      	(save_breakpoints): Likewise.
      	* coffread.c (coff_symfile_read): Likewise.
      	* cris-tdep.c (cris_push_dummy_call): Likewise.
      	(cris_scan_prologue): Likewise.
      	(cris_register_size): Likewise.
      	(_initialize_cris_tdep): Likewise.
      	* d-exp.y: Likewise.
      	* dbxread.c (dbx_read_symtab): Likewise.
      	(process_one_symbol): Likewise.
      	(coffstab_build_psymtabs): Likewise.
      	(elfstab_build_psymtabs): Likewise.
      	* dicos-tdep.c (dicos_init_abi): Likewise.
      	* disasm.c (do_mixed_source_and_assembly): Likewise.
      	(gdb_disassembly): Likewise.
      	* dtrace-probe.c (dtrace_process_dof): Likewise.
      	* dwarf2read.c (error_check_comp_unit_head): Likewise.
      	(build_type_psymtabs_1): Likewise.
      	(skip_one_die): Likewise.
      	(process_imported_unit_die): Likewise.
      	(dwarf2_physname): Likewise.
      	(read_file_scope): Likewise.
      	(setup_type_unit_groups): Likewise.
      	(create_dwo_cu_reader): Likewise.
      	(create_dwo_cu): Likewise.
      	(create_dwo_unit_in_dwp_v1): Likewise.
      	(create_dwo_unit_in_dwp_v2): Likewise.
      	(lookup_dwo_unit_in_dwp): Likewise.
      	(free_dwo_file): Likewise.
      	(check_producer): Likewise.
      	(dwarf2_add_typedef): Likewise.
      	(dwarf2_add_member_fn): Likewise.
      	(read_unsigned_leb128): Likewise.
      	(read_signed_leb128): Likewise.
      	(dwarf2_const_value): Likewise.
      	(follow_die_sig_1): Likewise.
      	(dwarf_decode_macro_bytes): Likewise.
      	* extension.c (restore_active_ext_lang): Likewise.
      	* frv-linux-tdep.c (frv_linux_sigtramp_frame_cache): Likewise.
      	* ft32-tdep.c (ft32_analyze_prologue): Likewise.
      	* gdbtypes.c (lookup_typename): Likewise.
      	(resolve_dynamic_range): Likewise.
      	(check_typedef): Likewise.
      	* h8300-tdep.c (h8300_is_argument_spill): Likewise.
      	(h8300_gdbarch_init): Likewise.
      	* hppa-tdep.c (hppa32_push_dummy_call): Likewise.
      	(hppa_frame_this_id): Likewise.
      	(_initialize_hppa_tdep): Likewise.
      	* hppanbsd-tdep.c (hppanbsd_sigtramp_cache_init): Likewise.
      	* hppaobsd-tdep.c (hppaobsd_supply_fpregset): Likewise.
      	* i386-dicos-tdep.c (i386_dicos_init_abi): Likewise.
      	* i386-tdep.c (i386_bnd_type): Likewise.
      	(i386_gdbarch_init): Likewise.
      	(i386_mpx_bd_base): Likewise.
      	* i386nbsd-tdep.c (i386nbsd_sigtramp_cache_init): Likewise.
      	* i386obsd-tdep.c (i386obsd_elf_init_abi): Likewise.
      	* ia64-tdep.c (examine_prologue): Likewise.
      	(ia64_frame_cache): Likewise.
      	(ia64_push_dummy_call): Likewise.
      	* infcmd.c (finish_command_fsm_async_reply_reason): Likewise.
      	(default_print_one_register_info): Likewise.
      	* infrun.c (infrun_thread_ptid_changed): Likewise.
      	(thread_still_needs_step_over): Likewise.
      	(stop_all_threads): Likewise.
      	(restart_threads): Likewise.
      	(keep_going_stepped_thread): Likewise.
      	* iq2000-tdep.c (iq2000_scan_prologue): Likewise.
      	* language.c (language_init_primitive_type_symbols): Likewise.
      	* linespec.c (add_sal_to_sals): Likewise.
      	* linux-nat.c (status_callback): Likewise.
      	(kill_unfollowed_fork_children): Likewise.
      	(linux_nat_kill): Likewise.
      	* linux-tdep.c (linux_fill_prpsinfo): Likewise.
      	* linux-thread-db.c (thread_db_notice_clone): Likewise.
      	(record_thread): Likewise.
      	* location.c (string_to_event_location_basic): Likewise.
      	* m32c-tdep.c (m32c_prev_register): Likewise.
      	* m32r-linux-tdep.c (m32r_linux_init_abi): Likewise.
      	* m32r-tdep.c (decode_prologue): Likewise.
      	* m68klinux-tdep.c (m68k_linux_sigtramp_frame_cache): Likewise.
      	* machoread.c (macho_symtab_read): Likewise.
      	(macho_symfile_read): Likewise.
      	(macho_symfile_offsets): Likewise.
      	* maint.c (set_per_command_cmd): Likewise.
      	* mi/mi-cmd-stack.c (mi_cmd_stack_list_locals): Likewise.
      	(mi_cmd_stack_list_variables): Likewise.
      	* mi/mi-main.c (mi_cmd_exec_run): Likewise.
      	(output_register): Likewise.
      	(mi_cmd_execute): Likewise.
      	(mi_cmd_trace_define_variable): Likewise.
      	(print_variable_or_computed): Likewise.
      	* minsyms.c (prim_record_minimal_symbol_full): Likewise.
      	* mn10300-tdep.c (mn10300_frame_prev_register): Likewise.
      	* msp430-tdep.c (msp430_pseudo_register_write): Likewise.
      	* mt-tdep.c (mt_registers_info): Likewise.
      	* nios2-tdep.c (nios2_analyze_prologue): Likewise.
      	(nios2_push_dummy_call): Likewise.
      	(nios2_frame_unwind_cache): Likewise.
      	(nios2_stub_frame_cache): Likewise.
      	(nios2_stub_frame_sniffer): Likewise.
      	(nios2_gdbarch_init): Likewise.
      	* ppc-ravenscar-thread.c: Likewise.
      	* ppcfbsd-tdep.c (ppcfbsd_sigtramp_frame_cache): Likewise.
      	* python/py-evts.c (add_new_registry): Likewise.
      	* python/py-finishbreakpoint.c (bpfinishpy_init): Likewise.
      	(bpfinishpy_detect_out_scope_cb): Likewise.
      	* python/py-framefilter.c (py_print_value): Likewise.
      	* python/py-inferior.c (infpy_write_memory): Likewise.
      	* python/py-infevents.c (create_inferior_call_event_object): Likewise.
      	* python/py-infthread.c (thpy_get_ptid): Likewise.
      	* python/py-linetable.c (ltpy_get_pcs_for_line): Likewise.
      	(ltpy_get_all_source_lines): Likewise.
      	(ltpy_is_valid): Likewise.
      	(ltpy_iternext): Likewise.
      	* python/py-symtab.c (symtab_and_line_to_sal_object): Likewise.
      	* python/py-unwind.c (pyuw_object_attribute_to_pointer): Likewise.
      	(unwind_infopy_str): Likewise.
      	* python/py-varobj.c (py_varobj_get_iterator): Likewise.
      	* ravenscar-thread.c (ravenscar_inferior_created): Likewise.
      	* rs6000-aix-tdep.c (rs6000_push_dummy_call): Likewise.
      	* rs6000-lynx178-tdep.c (rs6000_lynx178_push_dummy_call): Likewise.
      	* rs6000-tdep.c (ppc_deal_with_atomic_sequence): Likewise.
      	* s390-linux-tdep.c (s390_supply_tdb_regset): Likewise.
      	(s390_frame_prev_register): Likewise.
      	(s390_dwarf2_frame_init_reg): Likewise.
      	(s390_record_vr): Likewise.
      	(s390_process_record): Likewise.
      	* score-tdep.c (score_push_dummy_call): Likewise.
      	(score3_analyze_prologue): Likewise.
      	* sh-tdep.c (sh_extract_return_value_nofpu): Likewise.
      	* sh64-tdep.c (sh64_analyze_prologue): Likewise.
      	(sh64_push_dummy_call): Likewise.
      	(sh64_extract_return_value): Likewise.
      	(sh64_do_fp_register): Likewise.
      	* solib-aix.c (solib_aix_get_section_offsets): Likewise.
      	* solib-darwin.c (darwin_read_exec_load_addr_from_dyld): Likewise.
      	(darwin_solib_read_all_image_info_addr): Likewise.
      	* solib-dsbt.c (enable_break): Likewise.
      	* solib-frv.c (enable_break2): Likewise.
      	(frv_fdpic_find_canonical_descriptor): Likewise.
      	* solib-svr4.c (svr4_handle_solib_event): Likewise.
      	* sparc-tdep.c (sparc_skip_stack_check): Likewise.
      	* sparc64-linux-tdep.c (sparc64_linux_get_longjmp_target): Likewise.
      	* sparcobsd-tdep.c (sparc32obsd_init_abi): Likewise.
      	* spu-tdep.c (info_spu_dma_cmdlist): Likewise.
      	* stack.c (read_frame_local): Likewise.
      	* symfile.c (symbol_file_add_separate): Likewise.
      	(remove_symbol_file_command): Likewise.
      	* symmisc.c (maintenance_print_one_line_table): Likewise.
      	* symtab.c (symbol_cache_flush): Likewise.
      	(basic_lookup_transparent_type): Likewise.
      	(sort_search_symbols_remove_dups): Likewise.
      	* target.c (target_memory_map): Likewise.
      	(target_detach): Likewise.
      	(target_resume): Likewise.
      	(acquire_fileio_fd): Likewise.
      	(target_store_registers): Likewise.
      	* thread.c (print_thread_info_1): Likewise.
      	* tic6x-tdep.c (tic6x_analyze_prologue): Likewise.
      	* tilegx-linux-tdep.c (tilegx_linux_sigframe_init): Likewise.
      	* tilegx-tdep.c (tilegx_push_dummy_call): Likewise.
      	(tilegx_analyze_prologue): Likewise.
      	(tilegx_stack_frame_destroyed_p): Likewise.
      	(tilegx_frame_cache): Likewise.
      	* tracefile.c (trace_save): Likewise.
      	* tracepoint.c (encode_actions_and_make_cleanup): Likewise.
      	(start_tracing): Likewise.
      	(print_one_static_tracepoint_marker): Likewise.
      	* tui/tui.c (tui_enable): Likewise.
      	* valops.c (value_struct_elt_bitpos): Likewise.
      	(find_overload_match): Likewise.
      	(find_oload_champ): Likewise.
      	* value.c (value_contents_copy_raw): Likewise.
      	* windows-tdep.c (windows_get_tlb_type): Likewise.
      	* x86-linux-nat.c (x86_linux_enable_btrace): Likewise.
      	* xcoffread.c (record_minimal_symbol): Likewise.
      	(scan_xcoff_symtab): Likewise.
      	* xtensa-tdep.c (execute_code): Likewise.
      	(xtensa_gdbarch_init): Likewise.
      	(_initialize_xtensa_tdep): Likewise.
      870f88f7
  26. Jan 13, 2016
    • Pedro Alves's avatar
      Add Python InferiorThread.global_num attribute · 22a02324
      Pedro Alves authored
      This commit adds a new Python InferiorThread.global_num attribute.
      This can be used to pass the correct thread ID to Breakpoint.thread,
      which takes a global thread ID, not a per-inferior thread number.
      
      gdb/ChangeLog:
      2016-01-13  Pedro Alves  <palves@redhat.com>
      
      	* NEWS: Mention InferiorThread.global_num.
      	* python/py-infthread.c (thpy_get_global_num): New function.
      	(thread_object_getset): Register "global_num".
      
      gdb/testsuite/ChangeLog:
      2016-01-13  Pedro Alves  <palves@redhat.com>
      
      	* gdb.multi/tids.exp: Test InferiorThread.global_num and
      	Breakpoint.thread.
      	* gdb.python/py-infthread.exp: Test InferiorThread.global_num.
      
      gdb/doc/ChangeLog:
      2016-01-13  Pedro Alves  <palves@redhat.com>
      
      	* python.texi (Breakpoints In Python) <Breakpoint.thread>: Add
      	anchor.
      	(Threads In Python): Document new InferiorThread.global_num
      	attribute.
      22a02324
    • Pedro Alves's avatar
      Per-inferior/Inferior-qualified thread IDs · 5d5658a1
      Pedro Alves authored
      This commit changes GDB to track thread numbers per-inferior.  Then,
      if you're debugging multiple inferiors, GDB displays
      "inferior-num.thread-num" instead of just "thread-num" whenever it
      needs to display a thread:
      
       (gdb) info inferiors
         Num  Description       Executable
         1    process 6022     /home/pedro/gdb/tests/threads
       * 2    process 6037     /home/pedro/gdb/tests/threads
       (gdb) info threads
         Id   Target Id         Frame
         1.1  Thread 0x7ffff7fc2740 (LWP 6022) "threads" (running)
         1.2  Thread 0x7ffff77c0700 (LWP 6028) "threads" (running)
         1.3  Thread 0x7ffff7fc2740 (LWP 6032) "threads" (running)
         2.1  Thread 0x7ffff7fc1700 (LWP 6037) "threads" (running)
         2.2  Thread 0x7ffff77c0700 (LWP 6038) "threads" (running)
       * 2.3  Thread 0x7ffff7fc2740 (LWP 6039) "threads" (running)
       (gdb)
      ...
       (gdb) thread 1.1
       [Switching to thread 1.1 (Thread 0x7ffff7fc2740 (LWP 8155))]
       (gdb)
      ...
      
      etc.
      
      You can still use "thread NUM", in which case GDB infers you're
      referring to thread NUM of the current inferior.
      
      The $_thread convenience var and Python's InferiorThread.num attribute
      are remapped to the new per-inferior thread number.  It's a backward
      compatibility break, but since it only matters when debugging multiple
      inferiors, I think it's worth doing.
      
      Because MI thread IDs need to be a single integer, we keep giving
      threads a global identifier, _in addition_ to the per-inferior number,
      and make MI always refer to the global thread IDs.  IOW, nothing
      changes from a MI frontend's perspective.
      
      Similarly, since Python's Breakpoint.thread and Guile's
      breakpoint-thread/set-breakpoint-thread breakpoint methods need to
      work with integers, those are adjusted to work with global thread IDs
      too.  Follow up patches will provide convenient means to access
      threads' global IDs.
      
      To avoid potencially confusing users (which also avoids updating much
      of the testsuite), if there's only one inferior and its ID is "1",
      IOW, the user hasn't done anything multi-process/inferior related,
      then the "INF." part of thread IDs is not shown.  E.g,.:
      
       (gdb) info inferiors
         Num  Description       Executable
       * 1    process 15275     /home/pedro/gdb/tests/threads
       (gdb) info threads
         Id   Target Id         Frame
       * 1    Thread 0x7ffff7fc1740 (LWP 15275) "threads" main () at threads.c:40
       (gdb) add-inferior
       Added inferior 2
       (gdb) info threads
         Id   Target Id         Frame
       * 1.1  Thread 0x7ffff7fc1740 (LWP 15275) "threads" main () at threads.c:40
       (gdb)
      
      No regressions on x86_64 Fedora 20.
      
      gdb/ChangeLog:
      2016-01-13  Pedro Alves  <palves@redhat.com>
      
      	* NEWS: Mention that thread IDs are now per inferior and global
      	thread IDs.
      	* Makefile.in (SFILES): Add tid-parse.c.
      	(COMMON_OBS): Add tid-parse.o.
      	(HFILES_NO_SRCDIR): Add tid-parse.h.
      	* ada-tasks.c: Adjust to use ptid_to_global_thread_id.
      	* breakpoint.c (insert_breakpoint_locations)
      	(remove_threaded_breakpoints, bpstat_check_breakpoint_conditions)
      	(print_one_breakpoint_location, set_longjmp_breakpoint)
      	(check_longjmp_breakpoint_for_call_dummy)
      	(set_momentary_breakpoint): Adjust to use global IDs.
      	(find_condition_and_thread, watch_command_1): Use parse_thread_id.
      	(until_break_command, longjmp_bkpt_dtor)
      	(breakpoint_re_set_thread, insert_single_step_breakpoint): Adjust
      	to use global IDs.
      	* dummy-frame.c (pop_dummy_frame_bpt): Adjust to use
      	ptid_to_global_thread_id.
      	* elfread.c (elf_gnu_ifunc_resolver_stop): Likewise.
      	* gdbthread.h (struct thread_info): Rename field 'num' to
      	'global_num.  Add new fields 'per_inf_num' and 'inf'.
      	(thread_id_to_pid): Rename thread_id_to_pid to
      	global_thread_id_to_ptid.
      	(pid_to_thread_id): Rename to ...
      	(ptid_to_global_thread_id): ... this.
      	(valid_thread_id): Rename to ...
      	(valid_global_thread_id): ... this.
      	(find_thread_id): Rename to ...
      	(find_thread_global_id): ... this.
      	(ALL_THREADS, ALL_THREADS_BY_INFERIOR): Declare.
      	(print_thread_info): Add comment.
      	* tid-parse.h: New file.
      	* tid-parse.c: New file.
      	* infcmd.c (step_command_fsm_prepare)
      	(step_command_fsm_should_stop): Adjust to use the global thread
      	ID.
      	(until_next_command, until_next_command)
      	(finish_command_fsm_should_stop): Adjust to use the global thread
      	ID.
      	(attach_post_wait): Adjust to check the inferior number too.
      	* inferior.h (struct inferior) <highest_thread_num>: New field.
      	* infrun.c (handle_signal_stop)
      	(insert_exception_resume_breakpoint)
      	(insert_exception_resume_from_probe): Adjust to use the global
      	thread ID.
      	* record-btrace.c (record_btrace_open): Use global thread IDs.
      	* remote.c (process_initial_stop_replies): Also consider the
      	inferior number.
      	* target.c (target_pre_inferior): Clear the inferior's highest
      	thread num.
      	* thread.c (clear_thread_inferior_resources): Adjust to use the
      	global thread ID.
      	(new_thread): New inferior parameter.  Adjust to use it.  Set both
      	the thread's global ID and the thread's per-inferior ID.
      	(add_thread_silent): Adjust.
      	(find_thread_global_id): New.
      	(find_thread_id): Make static.  Adjust to rename.
      	(valid_thread_id): Rename to ...
      	(valid_global_thread_id): ... this.
      	(pid_to_thread_id): Rename to ...
      	(ptid_to_global_thread_id): ... this.
      	(thread_id_to_pid): Rename to ...
      	(global_thread_id_to_ptid): ... this.  Adjust.
      	(first_thread_of_process): Adjust.
      	(do_captured_list_thread_ids): Adjust to use global thread IDs.
      	(should_print_thread): New function.
      	(print_thread_info): Rename to ...
      	(print_thread_info_1): ... this, and add new show_global_ids
      	parameter.  Handle it.  Iterate over inferiors.
      	(print_thread_info): Reimplement as wrapper around
      	print_thread_info_1.
      	(show_inferior_qualified_tids): New function.
      	(print_thread_id): Use it.
      	(tp_array_compar): Compare inferior numbers too.
      	(thread_apply_command): Use tid_range_parser.
      	(do_captured_thread_select): Use parse_thread_id.
      	(thread_id_make_value): Adjust.
      	(_initialize_thread): Adjust "info threads" help string.
      	* varobj.c (struct varobj_root): Update comment.
      	(varobj_create): Adjust to use global thread IDs.
      	(value_of_root_1): Adjust to use global_thread_id_to_ptid.
      	* windows-tdep.c (display_tib): No longer accept an argument.
      	* cli/cli-utils.c (get_number_trailer): Make extern.
      	* cli/cli-utils.h (get_number_trailer): Declare.
      	(get_number_const): Adjust documentation.
      	* mi/mi-cmd-var.c (mi_cmd_var_update_iter): Adjust to use global
      	thread IDs.
      	* mi/mi-interp.c (mi_new_thread, mi_thread_exit)
      	(mi_on_normal_stop, mi_output_running_pid, mi_on_resume):
      	* mi/mi-main.c (mi_execute_command, mi_cmd_execute): Likewise.
      	* guile/scm-breakpoint.c (gdbscm_set_breakpoint_thread_x):
      	Likewise.
      	* python/py-breakpoint.c (bppy_set_thread): Likewise.
      	* python/py-finishbreakpoint.c (bpfinishpy_init): Likewise.
      	* python/py-infthread.c (thpy_get_num): Add comment and return the
      	per-inferior thread ID.
      	(thread_object_getset): Update comment of "num".
      
      gdb/testsuite/ChangeLog:
      2016-01-07  Pedro Alves  <palves@redhat.com>
      
      	* gdb.base/break.exp: Adjust to output changes.
      	* gdb.base/hbreak2.exp: Likewise.
      	* gdb.base/sepdebug.exp: Likewise.
      	* gdb.base/watch_thread_num.exp: Likewise.
      	* gdb.linespec/keywords.exp: Likewise.
      	* gdb.multi/info-threads.exp: Likewise.
      	* gdb.threads/thread-find.exp: Likewise.
      	* gdb.multi/tids.c: New file.
      	* gdb.multi/tids.exp: New file.
      
      gdb/doc/ChangeLog:
      2016-01-07  Pedro Alves  <palves@redhat.com>
      
      	* gdb.texinfo (Threads): Document per-inferior thread IDs,
      	qualified thread IDs, global thread IDs and thread ID lists.
      	(Set Watchpoints, Thread-Specific Breakpoints): Adjust to refer to
      	thread IDs.
      	(Convenience Vars): Document the $_thread convenience variable.
      	(Ada Tasks): Adjust to refer to thread IDs.
      	(GDB/MI Async Records, GDB/MI Thread Commands, GDB/MI Ada Tasking
      	Commands, GDB/MI Variable Objects): Update to mention global
      	thread IDs.
      	* guile.texi (Breakpoints In Guile)
      	<breakpoint-thread/set-breakpoint-thread breakpoint>: Mention
      	global thread IDs instead of thread IDs.
      	* python.texi (Threads In Python): Adjust documentation of
      	InferiorThread.num.
      	(Breakpoint.thread): Mention global thread IDs instead of thread
      	IDs.
      5d5658a1
    • Pedro Alves's avatar
      Add Python InferiorThread.inferior attribute · 84654457
      Pedro Alves authored
      So a script can easily get at a thread's inferior and its number.
      
      gdb/ChangeLog:
      2016-01-13  Pedro Alves  <palves@redhat.com>
      
      	* NEWS: Mention InferiorThread.inferior.
      	* python/py-infthread.c (thpy_get_inferior): New.
      	(thread_object_getset): Register "inferior".
      
      gdb/testsuite/ChangeLog:
      2016-01-13  Pedro Alves  <palves@redhat.com>
      
      	* gdb.python/py-infthread.exp: Test InferiorThread.inferior.
      
      gdb/doc/ChangeLog:
      2016-01-13  Pedro Alves  <palves@redhat.com>
      
      	* python.texi (Threads In Python): Document
      	InferiorThread.inferior.
      84654457
  27. Jan 01, 2016
  28. Nov 26, 2015
    • Simon Marchi's avatar
      Constify thread name return path · 73ede765
      Simon Marchi authored
      Since this code path returns a string owned by the target (we don't know how
      it's allocated, could be a static read-only string), it's safer if we return
      a constant string.  If, for some reasons, the caller wishes to modify the
      string, it should make itself a copy.
      
      gdb/ChangeLog:
      
      	* linux-nat.c (linux_nat_thread_name): Constify return value.
      	* target.h (struct target_ops) <to_thread_name>: Likewise.
      	(target_thread_name): Likewise.
      	* target.c (target_thread_name): Likewise.
      	* target-delegates.c (debug_thread_name): Regenerate.
      	* python/py-infthread.c (thpy_get_name): Constify local variables.
      	* thread.c (print_thread_info): Likewise.
      	(thread_find_command): Likewise.
      73ede765
  29. Mar 07, 2015
    • Pedro Alves's avatar
      Split TRY_CATCH into TRY + CATCH · 492d29ea
      Pedro Alves authored
      This patch splits the TRY_CATCH macro into three, so that we go from
      this:
      
      ~~~
        volatile gdb_exception ex;
      
        TRY_CATCH (ex, RETURN_MASK_ERROR)
          {
          }
        if (ex.reason < 0)
          {
          }
      ~~~
      
      to this:
      
      ~~~
        TRY
          {
          }
        CATCH (ex, RETURN_MASK_ERROR)
          {
          }
        END_CATCH
      ~~~
      
      Thus, we'll be getting rid of the local volatile exception object, and
      declaring the caught exception in the catch block.
      
      This allows reimplementing TRY/CATCH in terms of C++ exceptions when
      building in C++ mode, while still allowing to build GDB in C mode
      (using setjmp/longjmp), as a transition step.
      
      TBC, after this patch, is it _not_ valid to have code between the TRY
      and the CATCH blocks, like:
      
        TRY
          {
          }
      
        // some code here.
      
        CATCH (ex, RETURN_MASK_ERROR)
          {
          }
        END_CATCH
      
      Just like it isn't valid to do that with C++'s native try/catch.
      
      By switching to creating the exception object inside the CATCH block
      scope, we can get rid of all the explicitly allocated volatile
      exception objects all over the tree, and map the CATCH block more
      directly to C++'s catch blocks.
      
      The majority of the TRY_CATCH -> TRY+CATCH+END_CATCH conversion was
      done with a script, rerun from scratch at every rebase, no manual
      editing involved.  After the mechanical conversion, a few places
      needed manual intervention, to fix preexisting cases where we were
      using the exception object outside of the TRY_CATCH block, and cases
      where we were using "else" after a 'if (ex.reason) < 0)' [a CATCH
      after this patch].  The result was folded into this patch so that GDB
      still builds at each incremental step.
      
      END_CATCH is necessary for two reasons:
      
      First, because we name the exception object in the CATCH block, which
      requires creating a scope, which in turn must be closed somewhere.
      Declaring the exception variable in the initializer field of a for
      block, like:
      
        #define CATCH(EXCEPTION, mask) \
          for (struct gdb_exception EXCEPTION; \
               exceptions_state_mc_catch (&EXCEPTION, MASK); \
      	 EXCEPTION = exception_none)
      
      would avoid needing END_CATCH, but alas, in C mode, we build with C90,
      which doesn't allow mixed declarations and code.
      
      Second, because when TRY/CATCH are wired to real C++ try/catch, as
      long as we need to handle cleanup chains, even if there's no CATCH
      block that wants to catch the exception, we need for stop at every
      frame in the unwind chain and run cleanups, then rethrow.  That will
      be done in END_CATCH.
      
      After we require C++, we'll still need TRY/CATCH/END_CATCH until
      cleanups are completely phased out -- TRY/CATCH in C++ mode will
      save/restore the current cleanup chain, like in C mode, and END_CATCH
      catches otherwise uncaugh exceptions, runs cleanups and rethrows, so
      that C++ cleanups and exceptions can coexist.
      
      IMO, this still makes the TRY/CATCH code look a bit more like a
      newcomer would expect, so IMO worth it even if we weren't considering
      C++.
      
      gdb/ChangeLog.
      2015-03-07  Pedro Alves  <palves@redhat.com>
      
      	* common/common-exceptions.c (struct catcher) <exception>: No
      	longer a pointer to volatile exception.  Now an exception value.
      	<mask>: Delete field.
      	(exceptions_state_mc_init): Remove all parameters.  Adjust.
      	(exceptions_state_mc): No longer pop the catcher here.
      	(exceptions_state_mc_catch): New function.
      	(throw_exception): Adjust.
      	* common/common-exceptions.h (exceptions_state_mc_init): Remove
      	all parameters.
      	(exceptions_state_mc_catch): Declare.
      	(TRY_CATCH): Rename to ...
      	(TRY): ... this.  Remove EXCEPTION and MASK parameters.
      	(CATCH, END_CATCH): New.
      	All callers adjusted.
      
      gdb/gdbserver/ChangeLog:
      2015-03-07  Pedro Alves  <palves@redhat.com>
      
      	Adjust all callers of TRY_CATCH to use TRY/CATCH/END_CATCH
      	instead.
      492d29ea
  30. Feb 11, 2015
    • Tom Tromey's avatar
      Fix redefinition errors in C++ mode · e36122e9
      Tom Tromey authored
      In C, we can forward declare static structure instances.  That doesn't
      work in C++ though.  C++ treats these as definitions.  So then the
      compiler complains about symbol redefinition, like:
      
       src/gdb/elfread.c:1569:29: error: redefinition of ‘const sym_fns elf_sym_fns_lazy_psyms’
       src/gdb/elfread.c:53:29: error: ‘const sym_fns elf_sym_fns_lazy_psyms’ previously declared here
      
      The intent of static here is naturally to avoid making these objects
      visible outside the compilation unit.  The equivalent in C++ would be
      to instead define the objects in the anonymous namespace.  But given
      that it's desirable to leave the codebase compiling as both C and C++
      for a while, this just makes the objects extern.
      
      (base_breakpoint_ops is already declared in breakpoint.h, so we can
      just remove the forward declare from breakpoint.c)
      
      gdb/ChangeLog:
      2015-02-11  Tom Tromey  <tromey@redhat.com>
      	    Pedro Alves <palves@redhat.com>
      
      	* breakpoint.c (base_breakpoint_ops): Delete.
      	* dwarf2loc.c (dwarf_expr_ctx_funcs): Make extern.
      	* elfread.c (elf_sym_fns_gdb_index, elf_sym_fns_lazy_psyms): Make extern.
      	* guile/guile.c (guile_extension_script_ops, guile_extension_ops): Make extern.
      	* ppcnbsd-tdep.c (ppcnbsd2_sigtramp): Make extern.
      	* python/py-arch.c (arch_object_type): Make extern.
      	* python/py-block.c (block_syms_iterator_object_type): Make extern.
      	* python/py-bpevent.c (breakpoint_event_object_type): Make extern.
      	* python/py-cmd.c (cmdpy_object_type): Make extern.
      	* python/py-continueevent.c (continue_event_object_type)
      	* python/py-event.h (GDBPY_NEW_EVENT_TYPE): Remove 'qual'
      	parameter.  Update all callers.
      	* python/py-evtregistry.c (eventregistry_object_type): Make extern.
      	* python/py-exitedevent.c (exited_event_object_type): Make extern.
      	* python/py-finishbreakpoint.c (finish_breakpoint_object_type): Make extern.
      	* python/py-function.c (fnpy_object_type): Make extern.
      	* python/py-inferior.c (inferior_object_type, membuf_object_type): Make extern.
      	* python/py-infevents.c (call_pre_event_object_type)
      	(inferior_call_post_event_object_type).
      	(memory_changed_event_object_type): Make extern.
      	* python/py-infthread.c (thread_object_type): Make extern.
      	* python/py-lazy-string.c (lazy_string_object_type): Make extern.
      	* python/py-linetable.c (linetable_entry_object_type)
      	(linetable_object_type, ltpy_iterator_object_type): Make extern.
      	* python/py-newobjfileevent.c (new_objfile_event_object_type)
      	(clear_objfiles_event_object_type): Make extern.
      	* python/py-objfile.c (objfile_object_type): Make extern.
      	* python/py-param.c (parmpy_object_type): Make extern.
      	* python/py-progspace.c (pspace_object_type): Make extern.
      	* python/py-signalevent.c (signal_event_object_type): Make extern.
      	* python/py-symtab.c (symtab_object_type, sal_object_type): Make extern.
      	* python/py-type.c (type_object_type, field_object_type)
      	(type_iterator_object_type): Make extern.
      	* python/python.c (python_extension_script_ops)
      	(python_extension_ops): Make extern.
      	* stap-probe.c (stap_probe_ops): Make extern.
      e36122e9
  31. Jan 01, 2015
  32. Dec 02, 2014
    • Nick Bull's avatar
      New python events: inferior call, register/memory changed. · 162078c8
      Nick Bull authored
      gdb/ChangeLog:
      
      	* NEWS: Mention new Python events.
      	* Makefile.in (SUBDIR_PYTHON_OBS): Add py-infevents.o.
      	(SUBDIR_PYTHON_SRCS): Add py-infevents.c.
      	(py-infevents.o): New rule.
      	* doc/observer.texi (inferior_call_pre, inferior_call_post)
      	(memory_changed, register_changed): New observers.
      	* infcall.c (call_function_by_hand): Notify observer before and
      	after inferior call.
      	* python/py-event.h (inferior_call_kind): New enum.
      	(emit_inferior_call_event): New prototype.
      	(emit_register_changed_event): New prototype.
      	(emit_memory_changed_event): New prototype.
      	* python/py-events.h (events_object): New registries
      	inferior_call, memory_changed and register_changed.
      	* python/py-evts.c (gdbpy_initialize_py_events): Add the
      	inferior_call, memory_changed and register_changed registries.
      	* python/py-infevents.c: New.
      	* python/py-inferior.c (python_on_inferior_call_pre)
      	(python_on_inferior_call_post, python_on_register_change)
      	(python_on_memory_change): New functions.
      	(gdbpy_initialize_inferior): Attach python handler to new
      	observers.
      	* python/py-infthread.c(gdbpy_create_ptid_object): New.
      	(thpy_get_ptid) Use gdbpy_create_ptid_object.
      	* python/python-internal.h:
      	(gdbpy_create_ptid_object)
      	(gdbpy_initialize_inferior_call_pre_event)
      	(gdbpy_initialize_inferior_call_post_event)
      	(gdbpy_initialize_register_changed_event)
      	(gdbpy_initialize_memory_changed_event): New prototypes.
      	* python/python.c (_initialize_python): Initialize new events.
      	* valops.c (value_assign): Notify register_changed observer.
      
      gdb/doc/ChangeLog:
      
      	* python.texi (Events In Python): Document new events
      	InferiorCallPreEvent, InferiorCallPostEvent, MemoryChangedEvent
      	and RegisterChangedEvent.
      
      gdb/testsuite/ChangeLog:
      
      	* gdb.python/py-events.py (inferior_call_handler): New.
      	(register_changed_handler, memory_changed_handler): New.
      	(test_events.invoke): Register new handlers.
      	* gdb.python/py-events.exp: Add tests for inferior call,
      	memory_changed and register_changed events.
      162078c8
    • Doug Evans's avatar
Loading