Skip to content
Snippets Groups Projects
  1. Mar 11, 2023
    • Tom Tromey's avatar
      Constify linetables · 977a0c16
      Tom Tromey authored
      
      Linetables no longer change after they are created.  This patch
      applies const to them.
      
      Note there is one hack to cast away const in mdebugread.c.  This code
      allocates a linetable using 'malloc', then later copies it to the
      obstack.  While this could be cleaned up, I chose not to do so because
      I have no way of testing it.
      
      Approved-By: default avatarSimon Marchi <simon.marchi@efficios.com>
      977a0c16
    • Tom Tromey's avatar
      Change linetables to be objfile-independent · 1acc9dca
      Tom Tromey authored
      
      This changes linetables to not add the text offset to the addresses
      they contain.  I did this in a few steps, necessarily combined
      together in one patch: I renamed the 'pc' member to 'm_pc', added the
      appropriate accessors, and then recompiled.  Then I fixed all the
      errors.  Where possible I generally chose to use the raw_pc accessor,
      as it is less expensive.
      
      Note that this patch discounts the possibility that the text section
      offset might cause wraparound in the addresses in the line table.
      However, this was already discounted -- in particular,
      objfile_relocate1 did not re-sort the table in this scenario.  (There
      was a bug open about this, but as far as I can tell this has never
      happened, it's not even clear what inspired that bug.)
      
      Approved-By: default avatarSimon Marchi <simon.marchi@efficios.com>
      1acc9dca
  2. Jan 01, 2023
  3. Feb 06, 2022
  4. Jan 01, 2022
  5. 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
  6. Jan 01, 2021
  7. 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
  8. Aug 17, 2020
    • Tom Tromey's avatar
      Convert CORE_ADDR to Python using gdb_py_object_from_ulongest · b017825f
      Tom Tromey authored
      An internal test failed on a riscv64-elf cross build because
      Inferior.search_memory returned a negative value.  I tracked this down
      to to use of PyLong_FromLong in infpy_search_memory.  Then, I looked
      at other conversions of CORE_ADDR to Python and fixed these as well.
      
      I don't think there is a good way to write a test for this.
      
      gdb/ChangeLog
      2020-08-17  Tom Tromey  <tromey@adacore.com>
      
      	* python/py-inferior.c (infpy_search_memory): Use
      	gdb_py_object_from_ulongest.
      	* python/py-infevents.c (create_inferior_call_event_object)
      	(create_memory_changed_event_object): Use
      	gdb_py_object_from_ulongest.
      	* python/py-linetable.c (ltpy_entry_get_pc): Use
      	gdb_py_object_from_ulongest.
      b017825f
  9. Jan 01, 2020
  10. Nov 18, 2019
    • Philippe Waroquiers's avatar
      Fix a bunch of python leaks due to missing calls to tp_free in *_dealloc functions. · 2e953aca
      Philippe Waroquiers authored
      valgrind reports leaks in many python tests, such as:
      ==17162== VALGRIND_GDB_ERROR_BEGIN
      ==17162== 8,208 (5,472 direct, 2,736 indirect) bytes in 57 blocks are definitely lost in loss record 7,551 of 7,679
      ==17162==    at 0x4835753: malloc (vg_replace_malloc.c:307)
      ==17162==    by 0x6EAFD1: _PyObject_New (object.c:279)
      ==17162==    by 0x4720E6: blpy_iter(_object*) (py-block.c:92)
      ==17162==    by 0x698772: PyObject_GetIter (abstract.c:2577)
      ==17162==    by 0x2343BE: _PyEval_EvalFrameDefault (ceval.c:3159)
      ==17162==    by 0x22E9E2: function_code_fastcall (call.c:283)
      ==17162==    by 0x2340A8: _PyObject_Vectorcall (abstract.h:127)
      ==17162==    by 0x2340A8: call_function (ceval.c:4987)
      ==17162==    by 0x2340A8: _PyEval_EvalFrameDefault (ceval.c:3486)
      ==17162==    by 0x22E9E2: function_code_fastcall (call.c:283)
      ==17162==    by 0x82172B: _PyObject_Vectorcall (abstract.h:127)
      ==17162==    by 0x82172B: method_vectorcall (classobject.c:67)
      ==17162==    by 0x6AF474: _PyObject_Vectorcall (abstract.h:127)
      ==17162==    by 0x6AF474: _PyObject_CallNoArg (abstract.h:153)
      ==17162==    by 0x6AF474: _PyObject_CallFunctionVa (call.c:914)
      ==17162==    by 0x6B0673: callmethod (call.c:1010)
      ==17162==    by 0x6B0673: _PyObject_CallMethod_SizeT (call.c:1103)
      ==17162==    by 0x477DFE: gdb_PyObject_CallMethod<> (python-internal.h:182)
      ==17162==    by 0x477DFE: get_py_iter_from_func(_object*, char const*) (py-framefilter.c:272)
      ==17162==    by 0x4791B4: py_print_args (py-framefilter.c:706)
      ==17162==    by 0x4791B4: py_print_frame(_object*, enum_flags<frame_filter_flag>, ext_lang_frame_args, ui_out*, int, htab*) (py-framefilter.c:960)
      ==17162==    by 0x47A130: gdbpy_apply_frame_filter(extension_language_defn const*, frame_info*, enum_flags<frame_filter_flag>, ext_lang_frame_args, ui_out*, int, int) (py-framefilter.c:1236)
      ==17162==    by 0x369C39: apply_ext_lang_frame_filter(frame_info*, enum_flags<frame_filter_flag>, ext_lang_frame_args, ui_out*, int, int) (extension.c:563)
      ==17162==    by 0x4EC9C9: backtrace_command_1 (stack.c:2031)
      ==17162==    by 0x4EC9C9: backtrace_command(char const*, int) (stack.c:2183)
      ...
      
      Most of the leaks in python tests are due to the fact that many
      PyObject xxxxx_dealloc functions are missing the line to free self
      or obj such as:
         Py_TYPE (self)->tp_free (self);
      or
         Py_TYPE (obj)->tp_free (obj);
      
      With this patch, the number of python tests leaking decreases from 52 to 12.
      
      gdb/ChangeLog
      
      2019-11-18  Philippe Waroquiers  <philippe.waroquiers@skynet.be>
      
      	* python/py-block.c (blpy_dealloc): Call tp_free.
      	(blpy_block_syms_dealloc): Likewise.
      	* python/py-finishbreakpoint.c (bpfinishpy_dealloc): Likewise.
      	* python/py-inferior.c (infpy_dealloc): Likewise.
      	* python/py-lazy-string.c (stpy_dealloc): Likewise.
      	* python/py-linetable.c (ltpy_iterator_dealloc): Likewise.
      	* python/py-symbol.c (sympy_dealloc): Likewise.
      	* python/py-symtab.c (stpy_dealloc): Likewise.
      	* python/py-type.c (typy_iterator_dealloc): Likewise.
      2e953aca
  11. 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
  12. 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
  13. 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
  14. Nov 04, 2018
    • Tom Tromey's avatar
      Return gdbpy_ref from gdb_py_object_from_*longest · 12dfa12a
      Tom Tromey authored
      This changes gdb_py_object_from_longest and
      gdb_py_object_from_ulongest to return a gdbpy_ref rather than a
      PyObject*.
      
      gdb/ChangeLog
      2018-11-04  Tom Tromey  <tom@tromey.com>
      
      	* python/python-internal.h (gdb_py_object_from_longest)
      	(gdb_py_object_from_ulongest): Return gdbpy_ref.
      	* python/py-value.c (valpy_int): Update.
      	* python/py-utils.c (gdb_py_object_from_longest): Return
      	gdbpy_ref.
      	(gdb_py_object_from_ulongest): Likewise.
      	* python/py-type.c (typy_get_alignof): Update.
      	* python/py-linetable.c (ltpy_get_all_source_lines)
      	(ltpy_entry_get_line, ltpy_entry_get_pc): Update.
      	* python/py-block.c (blpy_get_start, blpy_get_end): Update.
      12dfa12a
  15. Jan 02, 2018
  16. Apr 12, 2017
    • Tom Tromey's avatar
      Change find_pcs_for_symtab_line to return a std::vector · 67d89901
      Tom Tromey authored
      This changes find_pcs_for_symtab_line to return a std::vector.  This
      allows the removal of some cleanups.
      
      gdb/ChangeLog
      2017-04-12  Tom Tromey  <tom@tromey.com>
      
      	* symtab.h (find_pcs_for_symtab_line): Change return type.
      	* symtab.c (find_pcs_for_symtab_line): Change return type.
      	* python/py-linetable.c (build_line_table_tuple_from_pcs): Change
      	type of "vec".  Update.
      	(ltpy_get_pcs_for_line): Update.
      	* linespec.c (decode_digits_ordinary): Update.
      67d89901
  17. 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
  18. Feb 10, 2017
    • Tom Tromey's avatar
      Remove some gotos from Python · 2bb8f231
      Tom Tromey authored
      This patch slightly refactors a couple of spots in the Python code to
      avoid some gotos.
      
      gdb/ChangeLog
      2017-02-10  Tom Tromey  <tom@tromey.com>
      
      	* python/python.c (do_start_initialization): New function, from
      	_initialize_python.
      	(_initialize_python): Call do_start_initialization.
      	* python/py-linetable.c (ltpy_iternext): Use explicit returns, not
      	goto.
      2bb8f231
    • Tom Tromey's avatar
      Turn gdbpy_ref into a template · 7780f186
      Tom Tromey authored
      This turns gdbpy_ref into a template class, so that it can be used to
      wrap subclasses of PyObject.  The default argument remains PyObject;
      and this necessitated renaming uses of "gdbpy_ref" to "gdbpy_ref<>".
      
      gdb/ChangeLog
      2017-02-10  Tom Tromey  <tom@tromey.com>
      
      	* python/py-ref.h (gdbpy_ref_policy): Now a template.
      	(gdbpy_ref): Now a template; allow subclasses of PyObject to be
      	used.
      	* python/py-arch.c, python/py-bpevent.c, python/py-breakpoint.c,
      	python/py-cmd.c, python/py-continueevent.c, python/py-event.c,
      	python/py-exitedevent.c, python/py-finishbreakpoint.c,
      	python/py-framefilter.c, python/py-function.c,
      	python/py-inferior.c, python/py-infevents.c,
      	python/py-linetable.c, python/py-newobjfileevent.c,
      	python/py-param.c, python/py-prettyprint.c, python/py-ref.h,
      	python/py-signalevent.c, python/py-stopevent.c,
      	python/py-symbol.c, python/py-threadevent.c, python/py-type.c,
      	python/py-unwind.c, python/py-utils.c, python/py-value.c,
      	python/py-varobj.c, python/py-xmethods.c, python/python.c,
      	varobj.c: Change gdbpy_ref to gdbpy_ref<>.
      7780f186
  19. Jan 11, 2017
    • Tom Tromey's avatar
      Use gdbpy_ref in py-linetable.c · 87ce03fd
      Tom Tromey authored
      This changes some code in py-linetable.c to use gdbpy_ref.
      
      2017-01-10  Tom Tromey  <tom@tromey.com>
      
      	* python/py-linetable.c (build_line_table_tuple_from_pcs)
      	(ltpy_get_all_source_lines): Use gdbpy_ref.
      87ce03fd
  20. 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
  21. 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
  22. Jan 01, 2016
  23. Aug 04, 2015
    • Ciro Santilli's avatar
      python: fix Linetable case to LineTable in docstrings and comments · 4efd80aa
      Ciro Santilli authored
      The class is called LineTable, not Linetable, as specified by
      py-linetable.c/gdbpy_initialize_linetable:
      
          if (gdb_pymodule_addobject (gdb_module, "LineTable",
      
      gdb/ChangeLog:
      
              * python/py-linetable.c: Fix case of Linetable to LineTable
              in docstrings and code comments.
              * python/py-symtab.c: Same.
      4efd80aa
  24. Jul 23, 2015
    • Ciro Santilli's avatar
      py-linetable.c: Fix doc of LineTable.source_lines' return type · 7b849db4
      Ciro Santilli authored
      The ltpy_get_all_source_lines function, use to implement
      the gdb.LineTable.source_lines method, returns a list:
      
          source_list = PyDict_Keys (source_dict);
          return source_list;
      
      This patch fixes the function's documentation as well as its docstring
      to say that it returns a list rather than a FrozenSet.
      
      gdb/ChangeLog:
      
              * py-linetable.c (ltpy_get_all_source_lines): Adjust function
              documentation to say that it returns a list rather than
              a FrozenSet.
              (linetable_object_methods): Update the docstring of the
              "source_line" entry.
      
      Tested on x86_64-linux.
      7b849db4
  25. 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
  26. 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
  27. Jan 01, 2015
  28. Nov 18, 2014
  29. Oct 08, 2014
    • Gary Benson's avatar
      Remove spurious exceptions.h inclusions · c765fdb9
      Gary Benson authored
      defs.h includes utils.h, and utils.h includes exceptions.h.  All GDB
      .c files include defs.h as their first line, so no file other than
      utils.h needs to include exceptions.h.  This commit removes all such
      inclusions.
      
      gdb/ChangeLog:
      
      	* ada-lang.c: Do not include exceptions.h.
      	* ada-valprint.c: Likewise.
      	* amd64-tdep.c: Likewise.
      	* auto-load.c: Likewise.
      	* block.c: Likewise.
      	* break-catch-throw.c: Likewise.
      	* breakpoint.c: Likewise.
      	* btrace.c: Likewise.
      	* c-lang.c: Likewise.
      	* cli/cli-cmds.c: Likewise.
      	* cli/cli-interp.c: Likewise.
      	* cli/cli-script.c: Likewise.
      	* completer.c: Likewise.
      	* corefile.c: Likewise.
      	* corelow.c: Likewise.
      	* cp-abi.c: Likewise.
      	* cp-support.c: Likewise.
      	* cp-valprint.c: Likewise.
      	* darwin-nat.c: Likewise.
      	* dwarf2-frame-tailcall.c: Likewise.
      	* dwarf2-frame.c: Likewise.
      	* dwarf2loc.c: Likewise.
      	* dwarf2read.c: Likewise.
      	* eval.c: Likewise.
      	* event-loop.c: Likewise.
      	* event-top.c: Likewise.
      	* f-valprint.c: Likewise.
      	* frame-unwind.c: Likewise.
      	* frame.c: Likewise.
      	* gdbtypes.c: Likewise.
      	* gnu-v2-abi.c: Likewise.
      	* gnu-v3-abi.c: Likewise.
      	* guile/scm-auto-load.c: Likewise.
      	* guile/scm-breakpoint.c: Likewise.
      	* guile/scm-cmd.c: Likewise.
      	* guile/scm-frame.c: Likewise.
      	* guile/scm-lazy-string.c: Likewise.
      	* guile/scm-param.c: Likewise.
      	* guile/scm-symbol.c: Likewise.
      	* guile/scm-type.c: Likewise.
      	* hppa-hpux-tdep.c: Likewise.
      	* i386-tdep.c: Likewise.
      	* inf-loop.c: Likewise.
      	* infcall.c: Likewise.
      	* infcmd.c: Likewise.
      	* infrun.c: Likewise.
      	* interps.c: Likewise.
      	* interps.h: Likewise.
      	* jit.c: Likewise.
      	* linespec.c: Likewise.
      	* linux-nat.c: Likewise.
      	* linux-thread-db.c: Likewise.
      	* m32r-rom.c: Likewise.
      	* main.c: Likewise.
      	* memory-map.c: Likewise.
      	* mi/mi-cmd-break.c: Likewise.
      	* mi/mi-cmd-stack.c: Likewise.
      	* mi/mi-interp.c: Likewise.
      	* mi/mi-main.c: Likewise.
      	* monitor.c: Likewise.
      	* nto-procfs.c: Likewise.
      	* objc-lang.c: Likewise.
      	* p-valprint.c: Likewise.
      	* parse.c: Likewise.
      	* ppc-linux-tdep.c: Likewise.
      	* printcmd.c: Likewise.
      	* probe.c: Likewise.
      	* python/py-auto-load.c: Likewise.
      	* python/py-breakpoint.c: Likewise.
      	* python/py-cmd.c: Likewise.
      	* python/py-finishbreakpoint.c: Likewise.
      	* python/py-frame.c: Likewise.
      	* python/py-framefilter.c: Likewise.
      	* python/py-function.c: Likewise.
      	* python/py-gdb-readline.c: Likewise.
      	* python/py-inferior.c: Likewise.
      	* python/py-infthread.c: Likewise.
      	* python/py-lazy-string.c: Likewise.
      	* python/py-linetable.c: Likewise.
      	* python/py-param.c: Likewise.
      	* python/py-prettyprint.c: Likewise.
      	* python/py-symbol.c: Likewise.
      	* python/py-type.c: Likewise.
      	* python/py-value.c: Likewise.
      	* python/python-internal.h: Likewise.
      	* python/python.c: Likewise.
      	* record-btrace.c: Likewise.
      	* record-full.c: Likewise.
      	* regcache.c: Likewise.
      	* remote-fileio.c: Likewise.
      	* remote-mips.c: Likewise.
      	* remote.c: Likewise.
      	* rs6000-aix-tdep.c: Likewise.
      	* rs6000-nat.c: Likewise.
      	* skip.c: Likewise.
      	* solib-darwin.c: Likewise.
      	* solib-dsbt.c: Likewise.
      	* solib-frv.c: Likewise.
      	* solib-ia64-hpux.c: Likewise.
      	* solib-spu.c: Likewise.
      	* solib-svr4.c: Likewise.
      	* solib.c: Likewise.
      	* spu-tdep.c: Likewise.
      	* stack.c: Likewise.
      	* stap-probe.c: Likewise.
      	* symfile-mem.c: Likewise.
      	* symmisc.c: Likewise.
      	* target.c: Likewise.
      	* thread.c: Likewise.
      	* top.c: Likewise.
      	* tracepoint.c: Likewise.
      	* tui/tui-interp.c: Likewise.
      	* typeprint.c: Likewise.
      	* utils.c: Likewise.
      	* valarith.c: Likewise.
      	* valops.c: Likewise.
      	* valprint.c: Likewise.
      	* value.c: Likewise.
      	* varobj.c: Likewise.
      	* windows-nat.c: Likewise.
      	* xml-support.c: Likewise.
      c765fdb9
  30. Feb 09, 2014
    • Jan Kratochvil's avatar
      Fix Python stack corruption · 2a081c59
      Jan Kratochvil authored
      The fix is obvious.
      
      gdb/
      2014-02-09  Jan Kratochvil  <jan.kratochvil@redhat.com>
      
      	Fix Python stack corruption.
      	* python/py-linetable.c (ltpy_get_pcs_for_line, ltpy_has_line): Use
      	gdb_py_longest.
      
      Message-ID: <20140207171701.GA25187@host2.jankratochvil.net>
      2a081c59
  31. Jan 01, 2014
  32. Nov 14, 2013
    • Tom Tromey's avatar
      off-by-one fix for py-linetable.c · 91822956
      Tom Tromey authored
      While digging into a different memory corruption error, I happened to
      notice one coming from the linetable code.  In a couple of spots, the
      wrong termination condition was used in a loop, leading gdb to read
      one element past the end of the linetable.
      
      Built and regtested on x86-64 Fedora 18.  Also verified using
      valgrind.  I'm checking this in.
      
      2013-11-14  Tom Tromey  <tromey@redhat.com>
      
      	* python/py-linetable.c (ltpy_has_line)
      	(ltpy_get_all_source_lines): Fix loop termination condition.
      91822956
  33. Nov 11, 2013
    • Phil Muldoon's avatar
      2013-11-11 Phil Muldoon <pmuldoon@redhat.com> · bc79de95
      Phil Muldoon authored
      	PR python/15629
      	* NEWS: Add linetable feature.
      	* Makefile.in (SUBDIR_PYTHON_OBS): Add py-linetable entries.
      	* python/py-linetable.c: New file.
      	* python/py-symtab.c (stpy_get_linetable): New function.
      	* python/python-internal.h (symtab_to_linetable_object): Declare.
      	(gdbpy_initialize_linetable): Ditto.
      	* python/python.c (_initialize_python): Call
      	gdbpy_initialize_linetable.
      
      2013-11-11  Phil Muldoon  <pmuldoon@redhat.com>
      
       	* gdb.python/py-linetable.S: New file.
      	* gdb.python/py-linetable.c: New file.
       	* gdb.python/py-linetable.exp: New file.
      
      2013-11-11  Phil Muldoon  <pmuldoon@redhat.com>
      
      	* gdb.texinfo (Symbol Tables In Python): Add linetable method entry.
      	(Line Tables In Python): New node.
      bc79de95
Loading