Skip to content
Snippets Groups Projects
  1. Jan 01, 2023
  2. Jul 28, 2022
    • Tom Tromey's avatar
      Rewrite registry.h · 08b8a139
      Tom Tromey authored
      This rewrites registry.h, removing all the macros and replacing it
      with relatively ordinary template classes.  The result is less code
      than the previous setup.  It replaces large macros with a relatively
      straightforward C++ class, and now manages its own cleanup.
      
      The existing type-safe "key" class is replaced with the equivalent
      template class.  This approach ended up requiring relatively few
      changes to the users of the registry code in gdb -- code using the key
      system just required a small change to the key's declaration.
      
      All existing users of the old C-like API are now converted to use the
      type-safe API.  This mostly involved changing explicit deletion
      functions to be an operator() in a deleter class.
      
      The old "save/free" two-phase process is removed, and replaced with a
      single "free" phase.  No existing code used both phases.
      
      The old "free" callbacks took a parameter for the enclosing container
      object.  However, this wasn't truly needed and is removed here as
      well.
      
      
      08b8a139
  3. Jul 08, 2022
    • Tom Tromey's avatar
      Accept gdb.Value in more Python APIs · d19ca0b3
      Tom Tromey authored
      PR python/27000 points out that gdb.block_for_pc will accept a Python
      integer, but not a gdb.Value.  This patch corrects this oversight.
      
      I looked at all uses of GDB_PY_LLU_ARG and fixed these up to use
      get_addr_from_python instead.  I also looked at uses of GDB_PY_LL_ARG,
      but those seemed relatively unlikely to be useful with a gdb.Value, so
      I didn't change them.  My thinking here is that a Value will typically
      come from inferior memory, and something like a line number is not too
      likely to be found this way.
      
      Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=27000
      d19ca0b3
  4. Jun 07, 2022
    • Tom Tromey's avatar
      Constify solib_name_from_address · 6d08aed3
      Tom Tromey authored
      I noticed that solib_name_from_address returned a non-const string,
      but it's more appropriate to return const.  This patch implements
      this.  Tested by rebuilding.
      
      6d08aed3
  5. Mar 22, 2022
    • Andrew Burgess's avatar
      gdb/python: add gdb.format_address function · 25209e2c
      Andrew Burgess authored
      Add a new function, gdb.format_address, which is a wrapper around
      GDB's print_address function.
      
      This method takes an address, and returns a string with the format:
      
        ADDRESS <SYMBOL+OFFSET>
      
      Where, ADDRESS is the original address, formatted as hexadecimal,
      SYMBOL is a symbol with an address lower than ADDRESS, and OFFSET is
      the offset from SYMBOL to ADDRESS in decimal.
      
      If there's no SYMBOL suitably close to ADDRESS then the
      <SYMBOL+OFFSET> part is not included.
      
      This is useful if a user wants to write a Python script that
      pretty-prints addresses, the user no longer needs to do manual symbol
      lookup, or worry about correctly formatting addresses.
      
      Additionally, there are some settings that effect how GDB picks
      SYMBOL, and whether the file name and line number should be included
      with the SYMBOL name, the gdb.format_address function ensures that the
      users Python script also benefits from these settings.
      
      The gdb.format_address by default selects SYMBOL from the current
      inferiors program space, and address is formatted using the
      architecture for the current inferior.  However, a user can also
      explicitly pass a program space and architecture like this:
      
        gdb.format_address(ADDRESS, PROGRAM_SPACE, ARCHITECTURE)
      
      In order to format an address for a different inferior.
      
      Notes on the implementation:
      
      In py-arch.c I extended arch_object_to_gdbarch to add an assertion for
      the type of the PyObject being worked on.  Prior to this commit all
      uses of arch_object_to_gdbarch were guaranteed to pass this function a
      gdb.Architecture object, but, with this commit, this might not be the
      case.
      
      So, with this commit I've made it a requirement that the PyObject be a
      gdb.Architecture, and this is checked with the assert.  And in order
      that callers from other files can check if they have a
      gdb.Architecture object, I've added the new function
      gdbpy_is_architecture.
      
      In py-progspace.c I've added two new function, the first
      progspace_object_to_program_space, converts a PyObject of type
      gdb.Progspace to the associated program_space pointer, and
      gdbpy_is_progspace checks if a PyObject is a gdb.Progspace or not.
      25209e2c
  6. Feb 06, 2022
  7. Jan 26, 2022
    • Tom Tromey's avatar
      Change how Python architecture and language are handled · 1da5d0e6
      Tom Tromey authored
      Currently, gdb's Python layer captures the current architecture and
      language when "entering" Python code.  This has some undesirable
      effects, and so this series changes how this is handled.
      
      First, there is code like this:
      
        gdbpy_enter enter_py (python_gdbarch, python_language);
      
      This is incorrect, because both of these are NULL when not otherwise
      assigned.  This can cause crashes in some cases -- I've added one to
      the test suite.  (Note that this crasher is just an example, other
      ones along the same lines are possible.)
      
      Second, when the language is captured in this way, it means that
      Python code cannot affect the current language for its own purposes.
      It's reasonable to want to write code like this:
      
          gdb.execute('set language mumble')
          ... stuff using the current language
          gdb.execute('set language previous-value')
      
      However, this won't actually work, because the language is captured on
      entry.  I've added a test to show this as well.
      
      This patch changes gdb to try to avoid capturing the current values.
      The Python concept of the current gdbarch is only set in those few
      cases where a non-default value is computed or needed; and the
      language is not captured at all -- instead, in the cases where it's
      required, the current language is temporarily changed.
      
      1da5d0e6
  8. Jan 01, 2022
  9. Apr 28, 2021
    • Andrew Burgess's avatar
      gdb: delay python initialisation until gdbpy_finish_initialization · 8e3685bf
      Andrew Burgess authored
      Delay Python initialisation until gdbpy_finish_initialization.
      
      This is mostly about splitting the existing gdbpy_initialize_*
      functions in two, all the calls to register_objfile_data_with_cleanup,
      gdbarch_data_register_post_init, etc are moved into new _initialize_*
      functions, but everything else is left in the gdbpy_initialize_*
      functions.
      
      Then the call to do_start_initialization (in python/python.c) is moved
      from the _initialize_python function into gdbpy_finish_initialization.
      
      There should be no user visible changes after this commit.
      
      gdb/ChangeLog:
      
      	* python/py-arch.c (_initialize_py_arch): New function.
      	(gdbpy_initialize_arch): Move code to _initialize_py_arch.
      	* python/py-block.c (_initialize_py_block): New function.
      	(gdbpy_initialize_blocks): Move code to _initialize_py_block.
      	* python/py-inferior.c (_initialize_py_inferior): New function.
      	(gdbpy_initialize_inferior): Move code to _initialize_py_inferior.
      	* python/py-objfile.c (_initialize_py_objfile): New function.
      	(gdbpy_initialize_objfile): Move code to _initialize_py_objfile.
      	* python/py-progspace.c (_initialize_py_progspace): New function.
      	(gdbpy_initialize_pspace): Move code to _initialize_py_progspace.
      	* python/py-registers.c (_initialize_py_registers): New function.
      	(gdbpy_initialize_registers): Move code to
      	_initialize_py_registers.
      	* python/py-symbol.c (_initialize_py_symbol): New function.
      	(gdbpy_initialize_symbols): Move code to _initialize_py_symbol.
      	* python/py-symtab.c (_initialize_py_symtab): New function.
      	(gdbpy_initialize_symtabs): Move code to _initialize_py_symtab.
      	* python/py-type.c (_initialize_py_type): New function.
      	(gdbpy_initialize_types): Move code to _initialize_py_type.
      	* python/py-unwind.c (_initialize_py_unwind): New function.
      	(gdbpy_initialize_unwind): Move code to _initialize_py_unwind.
      	* python/python.c (_initialize_python): Move call to
      	do_start_initialization to gdbpy_finish_initialization.
      	(gdbpy_finish_initialization): Add call to
      	do_start_initialization.
      8e3685bf
  10. Jan 01, 2021
  11. Dec 04, 2020
    • Tom Tromey's avatar
      Remove redundant typedefs · f99b5177
      Tom Tromey authored
      I was inspired by this patch of Simon's:
      
      https://sourceware.org/pipermail/gdb-patches/2020-November/173522.html
      
      ... to remove other typedefs that are no longer necessary now that gdb
      uses C++.
      
      I didn't remove absolutely every one -- I didn't touch the tdep files.
      However, I removed many of them.  In some cases, I removed an existing
      different struct tag.
      
      2020-12-04  Tom Tromey  <tromey@adacore.com>
      
      	* linespec.c (struct linespec_token): Rename; remove typedef.
      	* guile/scm-block.c (struct block_smob): Remove typedef.
      	(struct block_syms_progress_smob): Likewise.
      	* guile/scm-symbol.c (struct symbol_smob): Remove typedef.
      	* guile/scm-symtab.c (symtab_smob): Remove typedef.
      	(struct sal_smob): Remove typedef.
      	* guile/scm-param.c (struct param_smob): Remove typedef.
      	* guile/scm-progspace.c (struct pspace_smob): Rename.
      	* guile/scm-objfile.c (struct objfile_smob): Rename.
      	* guile/scm-iterator.c (struct iterator_smob): Rename.
      	* guile/scm-frame.c (struct frame_smob): Rename.
      	* guile/scm-arch.c (struct arch_smob): Rename.
      	* guile/scm-type.c (struct field_smob): Remove typedef.
      	(struct type_smob): Rename.
      	* guile/scm-cmd.c (struct command_smob): Remove typedef.
      	* guile/scm-ports.c (struct ioscm_memory_port): Remove typedef.
      	* guile/scm-value.c (struct value_smob): Remove typedef.
      	* guile/scm-lazy-string.c (lazy_string_smob): Remove typedef.
      	* guile/guile-internal.h (struct scheme_variable)
      	(struct scheme_function, struct scheme_integer_constant)
      	(struct gdb_smob, struct chained_gdb_smob)
      	(struct eqable_gdb_smob, arch_smob, frame_smob, iterator_smob)
      	(objfile_smob, pspace_smob, type_smob): Remove typedef.
      	* guile/scm-pretty-print.c (pretty_printer_smob): Remove typedef.
      	(struct pretty_printer_worker_smob): Remove typedef.
      	* guile/scm-exception.c (struct exception_smob): Remove typedef.
      	* python/py-block.c (struct block_object): Remove typedef.
      	(block_syms_iterator_object): Update.
      	(set_block): Update.
      	(block_syms_iterator_object): Remove typedef.
      	* python/py-inferior.c (struct membuf_object): Remove typedef.
      	* python/py-symtab.c (struct symtab_object): Remove typedef.
      	(set_symtab): Update.
      	(sal_object): Remove typedef.
      	(set_sal): Update.
      	* python/py-frame.c (frame_object): Remove typedef.
      	* python/py-record-btrace.c (struct btpy_list_object): Remove
      	typedef.
      	* python/py-arch.c (struct arch_object): Remove typedef.
      	* python/py-linetable.c (struct linetable_entry_object)
      	(linetable_object, struct ltpy_iterator_object): Remove typedef.
      	* python/py-events.h (eventregistry_object): Remove typedef.
      	(struct events_object): Remove typedef.
      	* python/python-internal.h (gdbpy_breakpoint_object): Remove
      	typedef.
      	(thread_object): Remove typedef.
      	* python/py-progspace.c (pspace_object): Remove typedef.
      	* python/py-value.c (struct value_object): Remove typedef.
      	* python/py-record.h (recpy_record_object): Remove typedef.
      	(struct recpy_element_object): Remove typedef.
      	* python/py-lazy-string.c (lazy_string_object): Remove typedef.
      	* python/py-objfile.c (objfile_object): Remove typedef.
      	* python/py-cmd.c (struct cmdpy_object): Remove typedef.
      	* python/py-type.c (type_object): Remove typedef.
      	(typy_iterator_object): Update.
      	(set_type): Update.
      	(field_object): Remove typedef.
      	(typy_iterator_object): Remove typedef.
      	* python/py-registers.c (register_descriptor_iterator_object):
      	Remove typedef.
      	(struct register_descriptor_object)
      	(struct reggroup_iterator_object, struct reggroup_object): Remove
      	typedef.
      	* python/py-record.c (recpy_gap_object): Remove typedef.
      	* python/py-symbol.c (symbol_object): Remove typedef.
      	(set_symbol): Update.
      	* python/py-event.h (event_object): Remove typedef.
      	* python/py-param.c (parmpy_object): Remove typedef.
      	* python/py-instruction.c (struct py_insn_obj): Remove typedef.
      	* python/py-unwind.c (struct pending_frame_object): Remove typedef.
      	(unwind_info_object, struct cached_frame_info): Likewise.
      f99b5177
  12. Jan 01, 2020
  13. Oct 24, 2019
    • Andrew Burgess's avatar
      gdb/python: Return None from Progspace.block_for_pc on error · 33d569b7
      Andrew Burgess authored
      The documentation for Progspace.block_for_pc says:
      
        Return the innermost gdb.Block containing the given pc value. If the
        block cannot be found for the pc value specified, the function will
        return None.
      
      However, the implementation actually throws an error for invalid
      addresses, like this:
      
          (gdb) python print gdb.current_progspace ().block_for_pc (1)
          Traceback (most recent call last):
            File "<string>", line 1, in <module>
          RuntimeError: Cannot locate object file for block.
          Error while executing Python code.
          (gdb)
      
      This has been the behaviour since the command was first added (when
      the documentation was still as above) in this commit:
      
          commit f3e9a817
          Date:   Wed Feb 24 21:18:28 2010 +0000
      
      Since that commit the code in question has moved around, but the
      important parts are largely unchanged.  The function in question is
      now in py-progspace.c:pspy_block_for_pc.
      
      Examining the code shows that the real state is more complex than just
      the function throws an error instead of returning None, instead the
      real situation is:
      
        1. If we can't find a compilation unit for the $pc value then we
        throw an error, but
      
        2. If we can find a compilation unit, but can't find a block within
        the compilation unit for the $pc then return None.
      
      I suspect for most users of the Python API this distinction is
      irrelevant, and I propose that we standardise on one single failure
      mechanism.
      
      Given the function can currently return None in some cases, and is
      documented to return None on error, I propose we make that the case
      for all error paths, which is what this patch does.
      
      As the Progspace.block_for_pc method is currently untested, I've added
      some basic tests including for a call with an invalid $pc.
      
      This is potentially an API breaking change, though an undocumented
      part of the API.  Also, users should have been checking and handling a
      None return value anyway, so my hope is that this shouldn't be too
      disruptive.
      
      gdb/ChangeLog:
      
      	* python/py-progspace.c (pspy_block_for_pc): Return None for all
      	error paths.
      
      gdb/testsuite/ChangeLog:
      
      	* gdb.python/py-progspace.exp: Add tests for the
      	Progspace.block_for_pc method.
      
      Change-Id: I9cea8d2132902bcad0013d1fd39080dd5423cc57
      33d569b7
  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 23, 2019
    • Tom Tromey's avatar
      Do not include py-ref.h in most files · 3fabc016
      Tom Tromey authored
      py-ref.h can really only be included from a specific spot in
      python-internal.h.  The other includes are not useful, and cause
      compilation errors if the includes are ever sorted.  So, remove these
      includes.
      
      Arguably, py-ref.h should simply not be a separate header.
      
      gdb/ChangeLog
      2019-01-22  Tom Tromey  <tom@tromey.com>
      
      	* python/py-arch.c: Do not include py-ref.h.
      	* python/py-bpevent.c: Do not include py-ref.h.
      	* python/py-cmd.c: Do not include py-ref.h.
      	* python/py-continueevent.c: Do not include py-ref.h.
      	* python/py-event.h: Do not include py-ref.h.
      	* python/py-evtregistry.c: Do not include py-ref.h.
      	* python/py-finishbreakpoint.c: Do not include py-ref.h.
      	* python/py-frame.c: Do not include py-ref.h.
      	* python/py-framefilter.c: Do not include py-ref.h.
      	* python/py-function.c: Do not include py-ref.h.
      	* python/py-infevents.c: Do not include py-ref.h.
      	* python/py-linetable.c: Do not include py-ref.h.
      	* python/py-objfile.c: Do not include py-ref.h.
      	* python/py-param.c: Do not include py-ref.h.
      	* python/py-prettyprint.c: Do not include py-ref.h.
      	* python/py-progspace.c: Do not include py-ref.h.
      	* python/py-symbol.c: Do not include py-ref.h.
      	* python/py-symtab.c: Do not include py-ref.h.
      	* python/py-type.c: Do not include py-ref.h.
      	* python/py-unwind.c: Do not include py-ref.h.
      	* python/py-utils.c: Do not include py-ref.h.
      	* python/py-value.c: Do not include py-ref.h.
      	* python/py-varobj.c: Do not include py-ref.h.
      	* python/py-xmethods.c: Do not include py-ref.h.
      	* python/python.c: Do not include py-ref.h.
      	* varobj.c: Do not include py-ref.h.
      3fabc016
  16. Jan 17, 2019
    • Tom Tromey's avatar
      Change all_objfiles adapter to be a method on program_space · 2030c079
      Tom Tromey authored
      This changes the all_objfiles range adapter to be a method on the
      program space, and fixes up all the users.
      
      gdb/ChangeLog
      2019-01-17  Tom Tromey  <tom@tromey.com>
      
      	* progspace.h (program_space) <objfiles_range>: New typedef.
      	<objfiles>: New method.
      	<objfiles_head>: Rename from objfiles.
      	(object_files): Update.
      	* guile/scm-progspace.c (gdbscm_progspace_objfiles): Update.
      	* guile/scm-pretty-print.c
      	(ppscm_find_pretty_printer_from_objfiles): Update.
      	* guile/scm-objfile.c (gdbscm_objfiles): Update.
      	* python/py-xmethods.c (gdbpy_get_matching_xmethod_workers):
      	Update.
      	* python/py-progspace.c (pspy_get_objfiles): Update.
      	* python/py-prettyprint.c (find_pretty_printer_from_objfiles):
      	Update.
      	* python/py-objfile.c (objfpy_lookup_objfile_by_name)
      	(objfpy_lookup_objfile_by_build_id): Update.
      	* mi/mi-cmd-file.c (mi_cmd_file_list_exec_source_files): Update.
      	* windows-tdep.c (windows_iterate_over_objfiles_in_search_order):
      	Update.
      	* symtab.c (iterate_over_symtabs, matching_obj_sections)
      	(expand_symtab_containing_pc, lookup_objfile_from_block)
      	(lookup_static_symbol, basic_lookup_transparent_type)
      	(find_pc_sect_compunit_symtab, find_symbol_at_address)
      	(find_line_symtab, info_sources_command)
      	(default_collect_symbol_completion_matches_break_on)
      	(make_source_files_completion_list, find_main_name): Update.
      	* symmisc.c (print_symbol_bcache_statistics)
      	(print_objfile_statistics, maintenance_print_symbols)
      	(maintenance_print_msymbols, maintenance_print_objfiles)
      	(maintenance_info_symtabs, maintenance_check_symtabs)
      	(maintenance_expand_symtabs, maintenance_info_line_tables):
      	Update.
      	* symfile.c (remove_symbol_file_command, overlay_invalidate_all)
      	(find_pc_overlay, find_pc_mapped_section, list_overlays_command)
      	(map_overlay_command, unmap_overlay_command)
      	(simple_overlay_update, expand_symtabs_matching)
      	(map_symbol_filenames): Update.
      	* symfile-debug.c (set_debug_symfile): Update.
      	* spu-tdep.c (spu_overlay_update, spu_objfile_from_frame):
      	Update.
      	* source.c (select_source_symtab, forget_cached_source_info):
      	Update.
      	* solib.c (solib_read_symbols): Update.
      	* solib-spu.c (append_ocl_sos): Update.
      	* psymtab.c (maintenance_print_psymbols)
      	(maintenance_info_psymtabs, maintenance_check_psymtabs): Update.
      	* probe.c (parse_probes_in_pspace, find_probe_by_pc): Update.
      	* printcmd.c (info_symbol_command): Update.
      	* ppc-linux-tdep.c (ppc_linux_spe_context_inferior_created):
      	Update.
      	* objfiles.h (class all_objfiles): Remove.
      	* objfiles.c (have_partial_symbols, have_full_symbols)
      	(have_minimal_symbols, qsort_cmp, update_section_map)
      	(shared_objfile_contains_address_p)
      	(default_iterate_over_objfiles_in_search_order): Update.
      	* objc-lang.c (info_selectors_command, info_classes_command)
      	(find_methods): Update.
      	* minsyms.c (find_solib_trampoline_target): Update.
      	* maint.c (maintenance_info_sections)
      	(maintenance_translate_address, count_symtabs_and_blocks):
      	Update.
      	* main.c (captured_main_1): Update.
      	* linux-thread-db.c (try_thread_db_load_from_pdir)
      	(has_libpthread): Update.
      	* linespec.c (iterate_over_all_matching_symtabs)
      	(search_minsyms_for_name): Update.
      	* jit.c (jit_find_objf_with_entry_addr): Update.
      	* hppa-tdep.c (find_unwind_entry)
      	(hppa_lookup_stub_minimal_symbol): Update.
      	* gcore.c (gcore_create_callback, objfile_find_memory_regions):
      	Update.
      	* elfread.c (elf_gnu_ifunc_resolve_by_cache)
      	(elf_gnu_ifunc_resolve_by_got): Update.
      	* dwarf2-frame.c (dwarf2_frame_find_fde): Update.
      	* dwarf-index-write.c (save_gdb_index_command): Update.
      	* cp-support.c (add_symbol_overload_list_qualified): Update.
      	* breakpoint.c (create_overlay_event_breakpoint)
      	(create_longjmp_master_breakpoint)
      	(create_std_terminate_master_breakpoint)
      	(create_exception_master_breakpoint): Update.
      	* blockframe.c (find_pc_partial_function): Update.
      	* ada-lang.c (ada_lookup_simple_minsym, add_nonlocal_symbols)
      	(ada_collect_symbol_completion_matches)
      	(ada_add_global_exceptions): Update.
      2030c079
  17. Jan 10, 2019
    • Tom Tromey's avatar
      Remove ALL_PSPACE_OBJFILES · 99d89cde
      Tom Tromey authored
      This removes the ALL_PSPACE_OBJFILES macro in favor of ranged for
      loops.
      
      gdb/ChangeLog
      2019-01-09  Tom Tromey  <tom@tromey.com>
      
      	* probe.c (parse_probes_in_pspace): Use all_objfiles.
      	* guile/scm-progspace.c (gdbscm_progspace_objfiles): Use
      	all_objfiles.
      	* objfiles.h (ALL_PSPACE_OBJFILES): Remove.
      	* symmisc.c (print_symbol_bcache_statistics)
      	(print_objfile_statistics, maintenance_print_objfiles)
      	(maintenance_info_symtabs, maintenance_check_symtabs)
      	(maintenance_expand_symtabs, maintenance_info_line_tables): Use
      	all_objfiles.
      	* source.c (forget_cached_source_info): Use all_objfiles.
      	* symfile-debug.c (set_debug_symfile): Use all_objfiles.
      	* elfread.c (elf_gnu_ifunc_resolve_by_cache)
      	(elf_gnu_ifunc_resolve_by_got): Use all_objfiles.
      	* objfiles.c (update_section_map): Use all_objfiles.
      	(shared_objfile_contains_address_p): Likewise.
      	* psymtab.c (maintenance_info_psymtabs): Use all_objfiles.
      	* python/py-progspace.c (pspy_get_objfiles): Use all_objfiles.
      99d89cde
  18. Jan 03, 2019
    • Tom Tromey's avatar
      Remove more uses of explicit reference counting in Python · 2a3c71d6
      Tom Tromey authored
      This changes some more place in the Python code to use gdbpy_ref
      rather than explicit reference counting.  While doing this I found a
      latent bug in typy_fields_items -- it was not checking for errors in
      one spot.  I also changed valpy_dealloc to use Py_XDECREF rather than
      an explicit "if".
      
      gdb/ChangeLog
      2019-01-03  Tom Tromey  <tom@tromey.com>
      
      	* python/py-value.c (valpy_dealloc): Use Py_XDECREF.
      	* python/py-type.c (typy_fields_items): Use gdbpy_ref.
      	* python/py-progspace.c (pspy_set_printers): Use gdbpy_ref.
      	(pspy_set_frame_filters, pspy_set_frame_unwinders)
      	(pspy_set_type_printers): Likewise.
      	* python/py-function.c (fnpy_init): Use gdbpy_ref.
      	* python/py-cmd.c (cmdpy_init): Use gdbpy_ref.
      	* python/py-objfile.c (objfpy_set_printers): Use gdbpy_ref.
      	(objfpy_set_frame_filters, objfpy_set_frame_unwinders)
      	(objfpy_set_type_printers): Likewise.
      2a3c71d6
  19. 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
  20. Nov 04, 2018
    • Tom Tromey's avatar
      Return gdbpy_ref from some Python string functions · 833d985d
      Tom Tromey authored
      This changes python_string_to_unicode,
      python_string_to_target_python_string, and
      host_string_to_python_string to return gdbpy_ref.
      
      gdb/ChangeLog
      2018-11-04  Tom Tromey  <tom@tromey.com>
      
      	* python/python.c (gdbpy_parameter_value): Update.
      	* python/python-internal.h (python_string_to_unicode)
      	(python_string_to_target_python_string)
      	(host_string_to_python_string): Return gdbpy_ref.
      	* python/py-utils.c (python_string_to_unicode)
      	(unicode_to_encoded_python_string)
      	(unicode_to_target_python_string)
      	(python_string_to_target_string)
      	(python_string_to_target_python_string): Return gdbpy_ref.
      	(python_string_to_host_string): Update.
      	(host_string_to_python_string): Return gdbpy_ref.
      	* python/py-symtab.c (stpy_get_filename, stpy_get_producer)
      	(stpy_fullname): Update.
      	* python/py-progspace.c (pspy_get_filename, pspy_solib_name):
      	Update.
      	* python/py-prettyprint.c (print_string_repr): Update.
      	* python/py-objfile.c (objfpy_get_filename, objfpy_get_username)
      	(objfpy_get_build_id): Update.
      	* python/py-breakpoint.c (bppy_get_location)
      	(bppy_get_expression, bppy_get_condition, bppy_get_commands):
      	Update.
      833d985d
  21. Oct 05, 2018
    • Tom de Vries's avatar
      [gdb/python] Fix cpychecker error in pspy_solib_name · 5c4481cc
      Tom de Vries authored
      When using cpychecker, we run into:
      ...
      gdb/python/py-progspace.c: \
        In function ‘PyObject* pspy_solib_name(PyObject*, PyObject*)’:
      gdb/python/py-progspace.c:370:25: error: Mismatching type in call to \
        PyArg_ParseTuple with format code "K" [-Werror]
         if (!PyArg_ParseTuple (args, GDB_PY_LLU_ARG, &pc))
        argument 3 ("&pc") had type
          "gdb_py_longest *" (pointing to 64 bits)
        but was expecting
          "long long unsigned int *" (pointing to 64 bits)
        for format code "K"
      ...
      
      Fix this fixing the type of the variable.
      
      Build and reg-tested on x86_64-linux.
      
      2018-10-05  Tom de Vries  <tdevries@suse.de>
      
      	* python/py-progspace.c (pspy_solib_name): Fix type mismatch in
      	PyArg_ParseTuple call.
      5c4481cc
  22. Sep 16, 2018
    • Tom Tromey's avatar
      Change objfile_to_objfile_object to return a new reference · 0a9db5ad
      Tom Tromey authored
      This changes objfile_to_objfile_object to return a new references and
      fixes up all the uses.
      
      gdb/ChangeLog
      2018-09-16  Tom Tromey  <tom@tromey.com>
      
      	* python/py-progspace.c (pspy_get_objfiles): Update.
      	* python/python-internal.h (objfile_to_objfile_object): Change
      	return type.
      	* python/py-newobjfileevent.c (create_new_objfile_event_object):
      	Update.
      	* python/py-xmethods.c (gdbpy_get_matching_xmethod_workers):
      	Update.
      	* python/python.c (gdbpy_get_current_objfile): Update.
      	(gdbpy_objfiles): Update.
      	* python/py-objfile.c (objfpy_get_owner, gdbpy_lookup_objfile):
      	Update.
      	(objfile_to_objfile_object): Return a new reference.
      	* python/py-symtab.c (stpy_get_objfile): Update.
      	* python/py-prettyprint.c (find_pretty_printer_from_objfiles):
      	Update.
      0a9db5ad
    • Tom Tromey's avatar
      Change pspace_to_pspace_object to return a new reference · 3c7aa307
      Tom Tromey authored
      This changes pspace_to_pspace_object to return a new reference and
      fixes up all the callers.
      
      gdb/ChangeLog
      2018-09-16  Tom Tromey  <tom@tromey.com>
      
      	* python/py-inferior.c (infpy_get_progspace): Update.
      	* python/python-internal.h (pspace_to_pspace_object): Change
      	return type.
      	* python/py-newobjfileevent.c
      	(create_clear_objfiles_event_object): Update.
      	* python/py-xmethods.c (gdbpy_get_matching_xmethod_workers):
      	Update.
      	* python/python.c (gdbpy_get_current_progspace): Update.
      	(gdbpy_progspaces): Update.
      	* python/py-progspace.c (pspace_to_pspace_object): Return a new
      	reference.
      	* python/py-objfile.c (objfpy_get_progspace): Update.
      	* python/py-prettyprint.c (find_pretty_printer_from_progspace):
      	Update.
      3c7aa307
    • Tom Tromey's avatar
      Add more methods to gdb.Progspace · 8743a9cd
      Tom Tromey authored
      There are a number of global functions in the gdb Python module which
      really should be methods on Progspace.  This patch adds new methods to
      Progspace and then redefines these globals in terms of these new
      methods.
      
      This version has been rebased on the related changes that Simon
      recently put in.
      
      Built and regtested on x86-64 Fedora 28.
      
      gdb/ChangeLog
      2018-09-16  Tom Tromey  <tom@tromey.com>
      
      	* python/lib/gdb/__init__.py (current_progspace, objfiles)
      	(solib_name, block_for_pc, find_pc_line): New functions.
      	(execute_unwinders): Update.
      	* python/py-block.c (gdbpy_block_for_pc): Remove.
      	* python/py-inferior.c (infpy_get_progspace): New function.
      	(inferior_object_getset) <progspace>: Add.
      	* python/py-progspace.c (pspy_objfiles): Rewrite.
      	(pspy_solib_name, pspy_block_for_pc)
      	(pspy_find_pc_line, pspy_is_valid): New functions.
      	(progspace_object_methods): Add entries for solib_name,
      	block_for_pc, find_pc_line, is_valid.
      	* python/python-internal.h (gdbpy_block_for_pc)
      	(build_objfiles_list): Don't declare.
      	* python/python.c: Don't include solib.h.
      	(gdbpy_solib_name, gdbpy_find_pc_line)
      	(gdbpy_get_current_progspace, build_objfiles_list)
      	(gdbpy_objfiles): Remove.
      	(GdbMethods) <current_progspace, objfiles, block_for_pc,
      	solib_name, find_pc_line>: Remove entries.
      
      gdb/doc/ChangeLog
      2018-09-16  Tom Tromey  <tom@tromey.com>
      
      	* python.texi (Basic Python): Update docs for find_pc_line,
      	solib_name.
      	(Progspaces In Python): Update docs for current_progspace.
      	Document block_for_pc, find_pc_line, is_valid, nsolib_name.
      	Move method documentation before example.
      8743a9cd
  23. Sep 13, 2018
    • Simon Marchi's avatar
      python: Add Progspace.objfiles method · 0ae1a321
      Simon Marchi authored
      This patch adds an objfiles method to the Progspace object, which
      returns a sequence of the objfiles associated to that program space.  I
      chose a method rather than a property for symmetry with gdb.objfiles().
      
      gdb/ChangeLog:
      
      	* python/py-progspace.c (PSPY_REQUIRE_VALID): New macro.
      	(pspy_get_objfiles): New function.
      	(progspace_object_methods): New.
      	(pspace_object_type): Add tp_methods callback.
      	* python/python-internal.h (build_objfiles_list): New
      	declaration.
      	* python/python.c (build_objfiles_list): New function.
      	(gdbpy_objfiles): Implement using build_objfiles_list.
      	* NEWS: Mention the Progspace.objfiles method.
      
      gdb/doc/ChangeLog:
      
      	* python.texi (Program Spaces In Python): Document the
      	Progspace.objfiles method.
      	(Objfiles In Python): Mention that gdb.objfiles() is identical
      	to gdb.selected_inferior().progspace.objfiles().
      
      gdb/testsuite/ChangeLog:
      
      	* gdb.python/py-progspace.exp: Test the Progspace.objfiles
      	method.
      0ae1a321
  24. Jan 02, 2018
  25. 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
  26. Feb 10, 2017
    • Tom Tromey's avatar
      Use gdbpy_ref to simplify some logic · 88b6faea
      Tom Tromey authored
      This uses the new gdbpy_ref template to simplify logic in various
      parts of the Python layer; for example removing repeated error code or
      removing gotos.
      
      gdb/ChangeLog
      2017-02-10  Tom Tromey  <tom@tromey.com>
      
      	* python/py-cmd.c (cmdpy_destroyer): Use gdbpy_ref.
      	* python/py-breakpoint.c (gdbpy_breakpoint_deleted): Use
      	gdbpy_ref.
      	* python/py-type.c (field_new): Use gdbpy_ref.
      	* python/py-symtab.c (symtab_and_line_to_sal_object): Use
      	gdbpy_ref.
      	* python/py-progspace.c (pspy_new): Use gdbpy_ref.
      	(py_free_pspace): Likewise.
      	(pspace_to_pspace_object): Likewise.
      	* python/py-objfile.c (objfpy_new): Use gdbpy_ref.
      	(py_free_objfile): Likewise.
      	(objfile_to_objfile_object): Likewise.
      	* python/py-inferior.c (delete_thread_object): Use
      	gdbpy_ref.
      	(infpy_read_memory): Likewise.
      	(py_free_inferior): Likewise.
      	* python/py-evtregistry.c (create_eventregistry_object): Use
      	gdbpy_ref.
      	* python/py-event.c (create_event_object): Use gdbpy_ref.
      88b6faea
  27. Jan 11, 2017
    • Tom Tromey's avatar
      Use gdbpy_enter in py-progspace.c · bf7da5b0
      Tom Tromey authored
      Change py-progspace.c to use gdbpy_enter.
      
      2017-01-10  Tom Tromey  <tom@tromey.com>
      
      	* python/py-progspace.c (py_free_pspace): Use gdbpy_enter.
      bf7da5b0
  28. 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
  29. May 23, 2016
    • Tom Tromey's avatar
      Fix PR python/19438, PR python/18393 - initialize dictionaries · 0f6ed0e0
      Tom Tromey authored
      This fixes PR python/19438 and PR python/18393.  Both bugs are about
      invoking dir() on some Python object implemented by gdb, and getting a
      crash.
      
      The crash happens because the dictionary field of these objects was
      not initialized.  Apparently what happens is that this field can be
      lazily initialized by Python when assigning to an attribute; and it
      can also be handled ok when using dir() but without __dict__ defined;
      but gdb defines __dict__ because this isn't supplied automatically by
      Python.
      
      The docs on this seem rather sparse, but this patch works ok.
      
      An alternative might be to lazily create the dictionary in
      gdb_py_generic_dict, but I went with this approach because it seemed
      more straightforward.
      
      Built and regtested on x86-64 Fedora 23.
      
      2016-05-23  Tom Tromey  <tom@tromey.com>
      
      	PR python/19438, PR python/18393:
      	* python/py-objfile.c (objfpy_initialize): Initialize self->dict.
      	* python/py-progspace.c (pspy_initialize): Initialize self->dict.
      
      2016-05-23  Tom Tromey  <tom@tromey.com>
      
      	PR python/19438, PR python/18393:
      	* gdb.python/py-progspace.exp: Add "dir" test.
      	* gdb.python/py-objfile.exp: Add "dir" test.
      0f6ed0e0
  30. Mar 30, 2016
    • Doug Evans's avatar
      python/py-utils.c (host_string_to_python_string): New function. · 4ae6cc19
      Doug Evans authored
      gdb/ChangeLog:
      
      	* python/py-utils.c (host_string_to_python_string): New function.
      	* python/python-internal.h (host_string_to_python_string): Declare it.
      	* python/py-*.c (*): Update all calls to
      	PyString_Decode (str, strlen (str), host_charset (), NULL);
      	to use host_string_to_python_string instead.
      4ae6cc19
  31. Jan 01, 2016
  32. Sep 25, 2015
    • Simon Marchi's avatar
      Add some more casts (2/2) · 19ba03f4
      Simon Marchi authored
      See previous patch's description.
      
      gdb/ChangeLog:
      
      	* macrocmd.c (print_macro_callback): Add cast(s).
      	* macrotab.c (macro_bcache_str): Likewise.
      	(new_macro_definition): Likewise.
      	* main.c (captured_main): Likewise.
      	* maint.c (print_bfd_section_info): Likewise.
      	* mdebugread.c (mdebug_build_psymtabs): Likewise.
      	(basic_type): Likewise.
      	* memattr.c (mem_region_cmp): Likewise.
      	* memory-map.c (memory_map_start_memory): Likewise.
      	(memory_map_end_memory): Likewise.
      	(memory_map_start_property): Likewise.
      	(memory_map_end_property): Likewise.
      	(clear_result): Likewise.
      	* memrange.c (compare_mem_ranges): Likewise.
      	* mep-tdep.c (mep_analyze_frame_prologue): Likewise.
      	* mi/mi-cmd-var.c (mi_cmd_var_update_iter): Likewise.
      	* mi/mi-console.c (mi_console_file_delete): Likewise.
      	(mi_console_file_fputs): Likewise.
      	(mi_console_raw_packet): Likewise.
      	(mi_console_file_flush): Likewise.
      	(mi_console_set_raw): Likewise.
      	* mi/mi-interp.c (mi_interpreter_resume): Likewise.
      	(mi_new_thread): Likewise.
      	(mi_thread_exit): Likewise.
      	(mi_record_changed): Likewise.
      	(mi_inferior_added): Likewise.
      	(mi_inferior_appeared): Likewise.
      	(mi_inferior_exit): Likewise.
      	(mi_inferior_removed): Likewise.
      	(mi_interp_data): Likewise.
      	(mi_on_normal_stop): Likewise.
      	(mi_traceframe_changed): Likewise.
      	(mi_tsv_created): Likewise.
      	(mi_tsv_deleted): Likewise.
      	(mi_tsv_modified): Likewise.
      	(mi_breakpoint_created): Likewise.
      	(mi_breakpoint_deleted): Likewise.
      	(mi_breakpoint_modified): Likewise.
      	(mi_output_running_pid): Likewise.
      	(mi_inferior_count): Likewise.
      	(mi_solib_loaded): Likewise.
      	(mi_solib_unloaded): Likewise.
      	(mi_command_param_changed): Likewise.
      	(mi_memory_changed): Likewise.
      	(report_initial_inferior): Likewise.
      	(mi_ui_out): Likewise.
      	(mi_set_logging): Likewise.
      	* mi/mi-main.c (collect_cores): Likewise.
      	(print_one_inferior): Likewise.
      	(free_vector_of_ints): Likewise.
      	(free_splay_tree): Likewise.
      	(mi_execute_command): Likewise.
      	* mi/mi-out.c (mi_table_body): Likewise.
      	(mi_table_end): Likewise.
      	(mi_table_header): Likewise.
      	(mi_begin): Likewise.
      	(mi_end): Likewise.
      	(mi_field_int): Likewise.
      	(mi_field_string): Likewise.
      	(mi_field_fmt): Likewise.
      	(mi_flush): Likewise.
      	(mi_redirect): Likewise.
      	(field_separator): Likewise.
      	(mi_open): Likewise.
      	(mi_close): Likewise.
      	(mi_out_buffered): Likewise.
      	(mi_out_rewind): Likewise.
      	(mi_out_put): Likewise.
      	(mi_version): Likewise.
      	(mi_out_data_dtor): Likewise.
      	* mi/mi-parse.c (mi_parse_cleanup): Likewise.
      	* microblaze-tdep.c (microblaze_frame_cache): Likewise.
      	* minidebug.c (lzma_open): Likewise.
      	(lzma_pread): Likewise.
      	(lzma_close): Likewise.
      	(lzma_stat): Likewise.
      	* mips-linux-tdep.c (mips_linux_init_abi): Likewise.
      	* mips-sde-tdep.c (mips_sde_frame_cache): Likewise.
      	(mips_sde_elf_osabi_sniff_abi_tag_sections): Likewise.
      	* mips-tdep.c (mips_insn16_frame_cache): Likewise.
      	(mips_micro_frame_cache): Likewise.
      	(mips_insn32_frame_cache): Likewise.
      	(mips_stub_frame_cache): Likewise.
      	(gdb_print_insn_mips): Likewise.
      	(value_of_mips_user_reg): Likewise.
      	(mips_gdbarch_init): Likewise.
      	* mips64obsd-tdep.c (mips64obsd_supply_gregset): Likewise.
      	* mipsnbsd-tdep.c (mipsnbsd_supply_fpregset): Likewise.
      	(mipsnbsd_supply_gregset): Likewise.
      	* mn10300-linux-tdep.c (am33_supply_fpregset_method): Likewise.
      	(am33_collect_gregset_method): Likewise.
      	(am33_collect_fpregset_method): Likewise.
      	* mn10300-tdep.c (mn10300_analyze_frame_prologue): Likewise.
      	* moxie-tdep.c (moxie_frame_cache): Likewise.
      	* msp430-tdep.c (msp430_get_opcode_byte): Likewise.
      	(msp430_analyze_frame_prologue): Likewise.
      	* mt-tdep.c (mt_frame_unwind_cache): Likewise.
      	* nios2-linux-tdep.c (nios2_supply_gregset): Likewise.
      	(nios2_collect_gregset): Likewise.
      	* nios2-tdep.c (nios2_frame_unwind_cache): Likewise.
      	(nios2_stub_frame_cache): Likewise.
      	* objc-lang.c (find_methods): Likewise.
      	* objfiles.c (objfiles_pspace_data_cleanup): Likewise.
      	(get_objfile_pspace_data): Likewise.
      	(get_objfile_bfd_data): Likewise.
      	(objfile_bfd_data_free): Likewise.
      	(add_to_objfile_sections): Likewise.
      	(do_free_objfile_cleanup): Likewise.
      	(resume_section_map_updates_cleanup): Likewise.
      	* opencl-lang.c (builtin_opencl_type): Likewise.
      	* osabi.c (generic_elf_osabi_sniff_abi_tag_sections): Likewise.
      	* osdata.c (osdata_start_osdata): Likewise.
      	(osdata_start_item): Likewise.
      	(osdata_start_column): Likewise.
      	(osdata_end_column): Likewise.
      	(clear_parsing_data): Likewise.
      	(osdata_free_cleanup): Likewise.
      	* parse.c (type_stack_cleanup): Likewise.
      	(exp_uses_objfile_iter): Likewise.
      	* ppc-linux-tdep.c (ppc_linux_supply_gregset): Likewise.
      	(ppc_linux_collect_gregset): Likewise.
      	(ppu2spu_prev_arch): Likewise.
      	(ppu2spu_this_id): Likewise.
      	(ppu2spu_prev_register): Likewise.
      	(ppu2spu_unwind_register): Likewise.
      	(ppu2spu_sniffer): Likewise.
      	(ppu2spu_dealloc_cache): Likewise.
      	(ppc_linux_init_abi): Likewise.
      	* ppcfbsd-tdep.c (ppcfbsd_sigtramp_frame_cache): Likewise.
      	* ppcobsd-tdep.c (ppcobsd_sigtramp_frame_cache): Likewise.
      	* progspace.c (restore_program_space): Likewise.
      	* psymtab.c (find_pc_sect_psymtab): Likewise.
      	(compare_psymbols): Likewise.
      	(psymbol_bcache_full): Likewise.
      	(allocate_psymtab): Likewise.
      	(discard_psymtabs_upto): Likewise.
      	* python/py-block.c (set_block): Likewise.
      	(del_objfile_blocks): Likewise.
      	* python/py-breakpoint.c (build_bp_list): Likewise.
      	* python/py-inferior.c (inferior_to_inferior_object): Likewise.
      	(build_inferior_list): Likewise.
      	(py_free_inferior): Likewise.
      	* python/py-objfile.c (py_free_objfile): Likewise.
      	(objfile_to_objfile_object): Likewise.
      	* python/py-prettyprint.c (py_restore_tstate): Likewise.
      	* python/py-progspace.c (py_free_pspace): Likewise.
      	(pspace_to_pspace_object): Likewise.
      	* python/py-symbol.c (set_symbol): Likewise.
      	(del_objfile_symbols): Likewise.
      	* python/py-symtab.c (set_sal): Likewise.
      	(set_symtab): Likewise.
      	(del_objfile_symtab): Likewise.
      	(del_objfile_sal): Likewise.
      	* python/py-type.c (save_objfile_types): Likewise.
      	(set_type): Likewise.
      	* python/py-unwind.c (pyuw_prev_register): Likewise.
      	(pyuw_on_new_gdbarch): Likewise.
      	* python/py-utils.c (py_decref): Likewise.
      	(py_xdecref): Likewise.
      	(gdb_py_generic_dict): Likewise.
      	* python/py-xmethods.c (gdbpy_free_xmethod_worker_data): Likewise.
      	(gdbpy_clone_xmethod_worker_data): Likewise.
      	(gdbpy_get_xmethod_arg_types): Likewise.
      	(gdbpy_get_xmethod_result_type): Likewise.
      	(gdbpy_invoke_xmethod): Likewise.
      	* python/python.c (gdbpy_apply_type_printers): Likewise.
      	(gdbpy_free_type_printers): Likewise.
      	* record-btrace.c (record_btrace_disable_callback): Likewise.
      	(bfcache_hash): Likewise.
      	(bfcache_eq): Likewise.
      	(btrace_get_frame_function): Likewise.
      	(record_btrace_frame_unwind_stop_reason): Likewise.
      	(record_btrace_frame_this_id): Likewise.
      	(record_btrace_frame_prev_register): Likewise.
      	(record_btrace_frame_dealloc_cache): Likewise.
      	* record-full.c (record_full_message_wrapper): Likewise.
      	(record_full_save_cleanups): Likewise.
      	* regcache.c (regcache_descr): Likewise.
      	(do_regcache_xfree): Likewise.
      	(do_regcache_invalidate): Likewise.
      	(do_cooked_read): Likewise.
      	(regcache_transfer_regset): Likewise.
      	* reggroups.c (reggroup_add): Likewise.
      	(reggroup_next): Likewise.
      	(reggroup_prev): Likewise.
      	* remote-fileio.c (do_remote_fileio_request): Likewise.
      	* remote-notif.c (remote_async_get_pending_events_handler): Likewise.
      	(do_notif_event_xfree): Likewise.
      	* remote.c (get_remote_arch_state): Likewise.
      	(remote_pspace_data_cleanup): Likewise.
      	(get_remote_exec_file): Likewise.
      	(set_pspace_remote_exec_file): Likewise.
      	(compare_pnums): Likewise.
      	(clear_threads_listing_context): Likewise.
      	(remote_newthread_step): Likewise.
      	(start_thread): Likewise.
      	(end_thread): Likewise.
      	(remove_child_of_pending_fork): Likewise.
      	(remove_stop_reply_for_inferior): Likewise.
      	(remove_stop_reply_of_remote_state): Likewise.
      	(remote_notif_remove_once_on_match): Likewise.
      	(stop_reply_match_ptid_and_ws): Likewise.
      	(kill_child_of_pending_fork): Likewise.
      	(register_remote_g_packet_guess): Likewise.
      	(remote_read_description_p): Likewise.
      	(remote_read_description): Likewise.
      	(free_actions_list_cleanup_wrapper): Likewise.
      	(remote_async_serial_handler): Likewise.
      	* rl78-tdep.c (rl78_get_opcode_byte): Likewise.
      	(rl78_analyze_frame_prologue): Likewise.
      	* rs6000-tdep.c (ppc_supply_gregset): Likewise.
      	(ppc_supply_fpregset): Likewise.
      	(ppc_supply_vsxregset): Likewise.
      	(ppc_supply_vrregset): Likewise.
      	(ppc_collect_gregset): Likewise.
      	(ppc_collect_fpregset): Likewise.
      	(ppc_collect_vsxregset): Likewise.
      	(ppc_collect_vrregset): Likewise.
      	(e500_move_ev_register): Likewise.
      	(do_regcache_raw_write): Likewise.
      	(rs6000_frame_cache): Likewise.
      	(rs6000_epilogue_frame_cache): Likewise.
      	(rs6000_gdbarch_init): Likewise.
      	* rx-tdep.c (rx_get_opcode_byte): Likewise.
      	(rx_analyze_frame_prologue): Likewise.
      	(rx_frame_type): Likewise.
      	(rx_frame_sniffer_common): Likewise.
      	* s390-linux-tdep.c (s390_check_for_saved): Likewise.
      	(s390_frame_unwind_cache): Likewise.
      	(s390_stub_frame_unwind_cache): Likewise.
      	(s390_sigtramp_frame_unwind_cache): Likewise.
      	* score-tdep.c (score_make_prologue_cache): Likewise.
      	* sentinel-frame.c (sentinel_frame_prev_register): Likewise.
      	(sentinel_frame_prev_arch): Likewise.
      	* ser-base.c (fd_event): Likewise.
      	(push_event): Likewise.
      	(ser_base_write): Likewise.
      	* ser-pipe.c (pipe_close): Likewise.
      	* serial.c (serial_write): Likewise.
      	* sh-tdep.c (sh_frame_cache): Likewise.
      	(sh_stub_this_id): Likewise.
      	* sh64-tdep.c (sh64_frame_cache): Likewise.
      	* solib-aix.c (get_solib_aix_inferior_data): Likewise.
      	(library_list_start_library): Likewise.
      	(library_list_start_list): Likewise.
      	(solib_aix_free_library_list): Likewise.
      	* solib-darwin.c (get_darwin_info): Likewise.
      	* solib-dsbt.c (get_dsbt_info): Likewise.
      	* solib-spu.c (append_ocl_sos): Likewise.
      	* solib-svr4.c (svr4_pspace_data_cleanup): Likewise.
      	(get_svr4_info): Likewise.
      	(library_list_start_library): Likewise.
      	(svr4_library_list_start_list): Likewise.
      	(hash_probe_and_action): Likewise.
      	(equal_probe_and_action): Likewise.
      	(svr4_update_solib_event_breakpoint): Likewise.
      	(set_solib_svr4_fetch_link_map_offsets): Likewise.
      	(svr4_fetch_link_map_offsets): Likewise.
      	(svr4_have_link_map_offsets): Likewise.
      	* solib-target.c (library_list_start_segment): Likewise.
      	(library_list_start_section): Likewise.
      	(library_list_start_library): Likewise.
      	(library_list_end_library): Likewise.
      	(library_list_start_list): Likewise.
      	(solib_target_free_library_list): Likewise.
      	* solib.c (solib_ops): Likewise.
      	(set_solib_ops): Likewise.
      	* sparc-sol2-tdep.c (sparc32_sol2_sigtramp_frame_cache): Likewise.
      	* sparc-tdep.c (sparc_frame_cache): Likewise.
      	(sparc32_frame_cache): Likewise.
      	(sparc32_supply_gregset): Likewise.
      	(sparc32_collect_gregset): Likewise.
      	(sparc32_supply_fpregset): Likewise.
      	(sparc32_collect_fpregset): Likewise.
      	* sparc64-sol2-tdep.c (sparc64_sol2_sigtramp_frame_cache): Likewise.
      	* sparc64-tdep.c (sparc64_supply_gregset): Likewise.
      	(sparc64_collect_gregset): Likewise.
      	(sparc64_supply_fpregset): Likewise.
      	(sparc64_collect_fpregset): Likewise.
      	* sparc64fbsd-tdep.c (sparc64fbsd_sigtramp_frame_cache): Likewise.
      	* sparc64nbsd-tdep.c (sparc64nbsd_sigcontext_frame_cache): Likewise.
      	* sparc64obsd-tdep.c (sparc64obsd_frame_cache): Likewise.
      	(sparc64obsd_trapframe_cache): Likewise.
      	* sparcnbsd-tdep.c (sparc32nbsd_sigcontext_frame_cache): Likewise.
      	* sparcobsd-tdep.c (sparc32obsd_sigtramp_frame_cache): Likewise.
      	* spu-multiarch.c (spu_gdbarch): Likewise.
      	* spu-tdep.c (spu_frame_unwind_cache): Likewise.
      	(spu2ppu_prev_arch): Likewise.
      	(spu2ppu_this_id): Likewise.
      	(spu2ppu_prev_register): Likewise.
      	(spu2ppu_dealloc_cache): Likewise.
      	(spu_dis_asm_print_address): Likewise.
      	(gdb_print_insn_spu): Likewise.
      	(spu_get_overlay_table): Likewise.
      	* stabsread.c (rs6000_builtin_type): Likewise.
      	* stack.c (do_print_variable_and_value): Likewise.
      	* stap-probe.c (get_stap_base_address_1): Likewise.
      	* symfile-debug.c (debug_qf_has_symbols): Likewise.
      	(debug_qf_find_last_source_symtab): Likewise.
      	(debug_qf_forget_cached_source_info): Likewise.
      	(debug_qf_map_symtabs_matching_filename): Likewise.
      	(debug_qf_lookup_symbol): Likewise.
      	(debug_qf_print_stats): Likewise.
      	(debug_qf_dump): Likewise.
      	(debug_qf_relocate): Likewise.
      	(debug_qf_expand_symtabs_for_function): Likewise.
      	(debug_qf_expand_all_symtabs): Likewise.
      	(debug_qf_expand_symtabs_with_fullname): Likewise.
      	(debug_qf_map_matching_symbols): Likewise.
      	(debug_qf_expand_symtabs_matching): Likewise.
      	(debug_qf_find_pc_sect_compunit_symtab): Likewise.
      	(debug_qf_map_symbol_filenames): Likewise.
      	(debug_sym_get_probes): Likewise.
      	(debug_sym_new_init): Likewise.
      	(debug_sym_init): Likewise.
      	(debug_sym_read): Likewise.
      	(debug_sym_read_psymbols): Likewise.
      	(debug_sym_finish): Likewise.
      	(debug_sym_offsets): Likewise.
      	(debug_sym_read_linetable): Likewise.
      	(debug_sym_relocate): Likewise.
      	(uninstall_symfile_debug_logging): Likewise.
      	* symfile-mem.c (symbol_file_add_from_memory_wrapper): Likewise.
      	* symfile.c (place_section): Likewise.
      	(add_section_size_callback): Likewise.
      	(load_progress): Likewise.
      	(load_section_callback): Likewise.
      	(clear_memory_write_data): Likewise.
      	(allocate_symtab): Likewise.
      	* symmisc.c (maintenance_expand_file_matcher): Likewise.
      	* symtab.c (lookup_symtab_callback): Likewise.
      	(hash_demangled_name_entry): Likewise.
      	(eq_demangled_name_entry): Likewise.
      	(get_symbol_cache): Likewise.
      	(symbol_cache_cleanup): Likewise.
      	(set_symbol_cache_size): Likewise.
      	(symbol_cache_flush): Likewise.
      	(maintenance_print_symbol_cache): Likewise.
      	(maintenance_print_symbol_cache_statistics): Likewise.
      	(delete_filename_seen_cache): Likewise.
      	(output_partial_symbol_filename): Likewise.
      	(search_symbols_file_matches): Likewise.
      	(search_symbols_name_matches): Likewise.
      	(do_free_completion_list): Likewise.
      	(maybe_add_partial_symtab_filename): Likewise.
      	(get_main_info): Likewise.
      	(main_info_cleanup): Likewise.
      	* target-dcache.c (target_dcache_cleanup): Likewise.
      	(target_dcache_init_p): Likewise.
      	(target_dcache_invalidate): Likewise.
      	(target_dcache_get): Likewise.
      	(target_dcache_get_or_init): Likewise.
      	* target-descriptions.c (target_find_description): Likewise.
      	(tdesc_find_type): Likewise.
      	(tdesc_data_cleanup): Likewise.
      	(tdesc_find_arch_register): Likewise.
      	(tdesc_register_name): Likewise.
      	(tdesc_register_type): Likewise.
      	(tdesc_register_reggroup_p): Likewise.
      	(set_tdesc_pseudo_register_name): Likewise.
      	(set_tdesc_pseudo_register_type): Likewise.
      	(set_tdesc_pseudo_register_reggroup_p): Likewise.
      	(tdesc_use_registers): Likewise.
      	(free_target_description): Likewise.
      	* target-memory.c (compare_block_starting_address): Likewise.
      	(cleanup_request_data): Likewise.
      	(cleanup_write_requests_vector): Likewise.
      	* target.c (open_target): Likewise.
      	(cleanup_restore_target_terminal): Likewise.
      	(free_memory_read_result_vector): Likewise.
      	* thread.c (disable_thread_stack_temporaries): Likewise.
      	(finish_thread_state_cleanup): Likewise.
      	(do_restore_current_thread_cleanup): Likewise.
      	(restore_current_thread_cleanup_dtor): Likewise.
      	(set_thread_refcount): Likewise.
      	(tp_array_compar): Likewise.
      	(do_captured_thread_select): Likewise.
      	* tic6x-tdep.c (tic6x_frame_unwind_cache): Likewise.
      	(tic6x_stub_this_id): Likewise.
      	* tilegx-tdep.c (tilegx_frame_cache): Likewise.
      	* top.c (do_restore_instream_cleanup): Likewise.
      	(gdb_readline_wrapper_cleanup): Likewise.
      	(kill_or_detach): Likewise.
      	(print_inferior_quit_action): Likewise.
      	* tracefile-tfile.c (match_blocktype): Likewise.
      	(build_traceframe_info): Likewise.
      	* tracefile.c (trace_file_writer_xfree): Likewise.
      	* tracepoint.c (memrange_cmp): Likewise.
      	(do_collect_symbol): Likewise.
      	(do_clear_collection_list): Likewise.
      	(do_restore_current_traceframe_cleanup): Likewise.
      	(restore_current_traceframe_cleanup_dtor): Likewise.
      	(free_current_marker): Likewise.
      	(traceframe_info_start_memory): Likewise.
      	(traceframe_info_start_tvar): Likewise.
      	(free_result): Likewise.
      	* tramp-frame.c (tramp_frame_cache): Likewise.
      	* tui/tui-file.c (tui_file_delete): Likewise.
      	(tui_fileopen): Likewise.
      	(tui_sfileopen): Likewise.
      	(tui_file_isatty): Likewise.
      	(tui_file_rewind): Likewise.
      	(tui_file_put): Likewise.
      	(tui_file_fputs): Likewise.
      	(tui_file_get_strbuf): Likewise.
      	(tui_file_adjust_strbuf): Likewise.
      	(tui_file_flush): Likewise.
      	* tui/tui-layout.c (make_command_window): Likewise.
      	(make_data_window): Likewise.
      	(show_source_disasm_command): Likewise.
      	(show_data): Likewise.
      	(make_source_or_disasm_window): Likewise.
      	(show_source_or_disasm_and_command): Likewise.
      	* tui/tui-out.c (tui_field_int): Likewise.
      	(tui_field_string): Likewise.
      	(tui_field_fmt): Likewise.
      	(tui_text): Likewise.
      	* typeprint.c (hash_typedef_field): Likewise.
      	(eq_typedef_field): Likewise.
      	(do_free_typedef_hash): Likewise.
      	(copy_typedef_hash_element): Likewise.
      	(do_free_global_table): Likewise.
      	(find_global_typedef): Likewise.
      	(find_typedef_in_hash): Likewise.
      	* ui-file.c (ui_file_write_for_put): Likewise.
      	(do_ui_file_xstrdup): Likewise.
      	(mem_file_delete): Likewise.
      	(mem_file_rewind): Likewise.
      	(mem_file_put): Likewise.
      	(mem_file_write): Likewise.
      	(stdio_file_delete): Likewise.
      	(stdio_file_flush): Likewise.
      	(stdio_file_read): Likewise.
      	(stdio_file_write): Likewise.
      	(stdio_file_write_async_safe): Likewise.
      	(stdio_file_fputs): Likewise.
      	(stdio_file_isatty): Likewise.
      	(stdio_file_fseek): Likewise.
      	(tee_file_delete): Likewise.
      	(tee_file_flush): Likewise.
      	(tee_file_write): Likewise.
      	(tee_file_fputs): Likewise.
      	(tee_file_isatty): Likewise.
      	* ui-out.c (do_cleanup_table_end): Likewise.
      	(do_cleanup_end): Likewise.
      	* user-regs.c (user_reg_add): Likewise.
      	(user_reg_map_name_to_regnum): Likewise.
      	(usernum_to_user_reg): Likewise.
      	(maintenance_print_user_registers): Likewise.
      	* utils.c (do_bfd_close_cleanup): Likewise.
      	(do_fclose_cleanup): Likewise.
      	(do_obstack_free): Likewise.
      	(do_ui_file_delete): Likewise.
      	(do_ui_out_redirect_pop): Likewise.
      	(do_free_section_addr_info): Likewise.
      	(restore_integer): Likewise.
      	(do_unpush_target): Likewise.
      	(do_htab_delete_cleanup): Likewise.
      	(do_restore_ui_file): Likewise.
      	(do_value_free): Likewise.
      	(do_free_so): Likewise.
      	(free_current_contents): Likewise.
      	(do_regfree_cleanup): Likewise.
      	(core_addr_hash): Likewise.
      	(core_addr_eq): Likewise.
      	(do_free_char_ptr_vec): Likewise.
      	* v850-tdep.c (v850_frame_cache): Likewise.
      	* varobj.c (do_free_variable_cleanup): Likewise.
      	* vax-tdep.c (vax_supply_gregset): Likewise.
      	(vax_frame_cache): Likewise.
      	* vaxobsd-tdep.c (vaxobsd_sigtramp_frame_cache): Likewise.
      	* xml-support.c (gdb_xml_body_text): Likewise.
      	(gdb_xml_values_cleanup): Likewise.
      	(gdb_xml_start_element): Likewise.
      	(gdb_xml_start_element_wrapper): Likewise.
      	(gdb_xml_end_element): Likewise.
      	(gdb_xml_end_element_wrapper): Likewise.
      	(gdb_xml_cleanup): Likewise.
      	(gdb_xml_fetch_external_entity): Likewise.
      	(gdb_xml_parse_attr_enum): Likewise.
      	(xinclude_start_include): Likewise.
      	(xinclude_end_include): Likewise.
      	(xml_xinclude_default): Likewise.
      	(xml_xinclude_start_doctype): Likewise.
      	(xml_xinclude_end_doctype): Likewise.
      	(xml_xinclude_cleanup): Likewise.
      	(xml_fetch_content_from_file): Likewise.
      	* xml-syscall.c (free_syscalls_info): Likewise.
      	(syscall_start_syscall): Likewise.
      	* xml-tdesc.c (tdesc_end_arch): Likewise.
      	(tdesc_end_osabi): Likewise.
      	(tdesc_end_compatible): Likewise.
      	(tdesc_start_target): Likewise.
      	(tdesc_start_feature): Likewise.
      	(tdesc_start_reg): Likewise.
      	(tdesc_start_union): Likewise.
      	(tdesc_start_struct): Likewise.
      	(tdesc_start_flags): Likewise.
      	(tdesc_start_field): Likewise.
      	(tdesc_start_vector): Likewise.
      	(fetch_available_features_from_target): Likewise.
      	* xstormy16-tdep.c (xstormy16_frame_cache): Likewise.
      	* xtensa-tdep.c (xtensa_supply_gregset): Likewise.
      	(xtensa_frame_cache): Likewise.
      	(xtensa_frame_prev_register): Likewise.
      	(xtensa_extract_return_value): Likewise.
      19ba03f4
  33. Apr 01, 2015
    • Sasha Smundak's avatar
      Add support for writing unwinders in Python. · d11916aa
      Sasha Smundak authored
      gdb/ChangeLog:
      
      	* Makefile.in (SUBDIR_PYTHON_OBJS): Add py-unwind.o.
      	(SUBDIR_PYTHON_SRCS): Add py-unwind.c.
      	(py-unwind.o): New recipe.
      	* NEWS: mention Python frame unwinding.
      	* data-directory/Makefile.in (PYTHON_FILE_LIST): Add
      	gdb/unwinder.py and gdb/command/unwinder.py
      	* python/lib/gdb/__init__.py (packages): Add frame_unwinders
      	list.
      	(execute_unwinders): New function.
      	* python/lib/gdb/command/unwinders.py: New file.
      	* python/lib/gdb/unwinder.py: New file.
      	* python/py-objfile.c (objfile_object): Add frame_unwinders field.
      	(objfpy_dealloc): Decrement frame_unwinders reference count.
      	(objfpy_initialize): Create frame_unwinders list.
      	(objfpy_get_frame_unwinders): New function.
      	(objfpy_set_frame_unwinders): Ditto.
      	(objfile_getset): Add frame_unwinders attribute to Objfile.
      	* python/py-progspace.c (pspace_object): Add frame_unwinders field.
      	(pspy_dealloc): Decrement frame_unwinders reference count.
      	(pspy_initialize): Create frame_unwinders list.
      	(pspy_get_frame_unwinders): New function.
      	(pspy_set_frame_unwinders): Ditto.
      	(pspy_getset): Add frame_unwinders attribute to gdb.Progspace.
      	* python/py-unwind.c: New file.
      	* python/python-internal.h (pspy_get_name_unwinders): New prototype.
      	(objpy_get_frame_unwinders): New prototype.
      	(gdbpy_initialize_unwind): New prototype.
      	* python/python.c (gdbpy_apply_type_printers): Call
      	gdbpy_initialize_unwind.
      
      gdb/doc/ChangeLog:
      
      	* doc/python.texi (Writing a Frame Unwinder in Python): Add
      	section.
      
      gdb/testsuite/ChangeLog:
      
      	* gdb.python/py-unwind-maint.c: New file.
      	* gdb.python/py-unwind-maint.exp: New test.
      	* gdb.python/py-unwind-maint.py: New file.
      	* gdb.python/py-unwind.c: New file.
      	* gdb.python/py-unwind.exp: New test.
      	* gdb.python/py-unwind.py: New test.
      d11916aa
  34. 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
  35. Jan 01, 2015
  36. Oct 31, 2014
    • Doug Evans's avatar
      Add ability to add attributes to gdb.Objfile and gdb.Progspace objects. · 02be9a71
      Doug Evans authored
      gdb/ChangeLog:
      
      	* NEWS: Mention ability add attributes to gdb.Objfile and
      	gdb.Progspace objects.
      	* python/py-objfile.c (objfile_object): New member dict.
      	(objfpy_dealloc): Py_XDECREF dict.
      	(objfpy_initialize): Initialize dict.
      	(objfile_getset): Add __dict__.
      	(objfile_object_type): Set tp_dictoffset member.
      	* python/py-progspace.c (progspace_object): New member dict.
      	(pspy_dealloc): Py_XDECREF dict.
      	(pspy_initialize): Initialize dict.
      	(pspace_getset): Add __dict__.
      	(pspace_object_type): Set tp_dictoffset member.
      
      gdb/doc/ChangeLog:
      
      	* python.texi (Progspaces In Python): Document ability to add
      	random attributes to gdb.Progspace objects.
      	(Objfiles In Python): Document ability to add random attributes to
      	gdb.objfile objects.
      
      gdb/testsuite/ChangeLog:
      
      	* gdb.python/py-objfile.exp: Add tests for setting random attributes
      	in objfiles.
      	* gdb.python/py-progspace.exp: Add tests for setting random attributes
      	in progspaces.
      02be9a71
  37. Oct 13, 2014
Loading