binutils-gdb/gdb/python
Andrew Burgess 8eb7d135e3 gdb/disasm: mark functions passed to the disassembler noexcept
While working on another patch, Simon pointed out that GDB could be
improved by marking the functions passed to the disassembler as
noexcept.

  https://sourceware.org/pipermail/gdb-patches/2022-October/193084.html

The reason this is important is the on some hosts, libopcodes, being C
code, will not be compiled with support for handling exceptions.  As
such, an attempt to throw an exception over libopcodes code will cause
GDB to terminate.

See bug gdb/29712 for an example of when this happened.

In this commit all the functions that are passed to the disassembler,
and which might be used as callbacks by libopcodes are marked
noexcept.

Ideally, I would have liked to change these typedefs:

  using read_memory_ftype = decltype (disassemble_info::read_memory_func);
  using memory_error_ftype = decltype (disassemble_info::memory_error_func);
  using print_address_ftype = decltype (disassemble_info::print_address_func);
  using fprintf_ftype = decltype (disassemble_info::fprintf_func);
  using fprintf_styled_ftype = decltype (disassemble_info::fprintf_styled_func);

which are declared in disasm.h, as including the noexcept keyword.
However, when I tried this, I ran into this warning/error:

  In file included from ../../src/gdb/disasm.c:25:
  ../../src/gdb/disasm.h: In constructor ‘gdb_printing_disassembler::gdb_printing_disassembler(gdbarch*, ui_file*, gdb_disassemble_info::read_memory_ftype, gdb_disassemble_info::memory_error_ftype, gdb_disassemble_info::print_address_ftype)’:
  ../../src/gdb/disasm.h:116:3: error: mangled name for ‘gdb_printing_disassembler::gdb_printing_disassembler(gdbarch*, ui_file*, gdb_disassemble_info::read_memory_ftype, gdb_disassemble_info::memory_error_ftype, gdb_disassemble_info::print_address_ftype)’ will change in C++17 because the exception specification is part of a function type [-Werror=noexcept-type]
    116 |   gdb_printing_disassembler (struct gdbarch *gdbarch,
        |   ^~~~~~~~~~~~~~~~~~~~~~~~~

So I've left that change out.  This does mean that if somebody adds a
new use of the disassembler classes in the future, and forgets to mark
the callbacks as noexcept, this will compile fine.  We'll just have to
manually check for that during review.
2022-11-28 19:23:30 +00:00
..
lib/gdb GDB/Python: Make None' stand for unlimited' in setting integer parameters 2022-10-21 08:54:18 +01:00
py-all-events.def
py-arch.c
py-auto-load.c
py-block.c
py-bpevent.c
py-breakpoint.c gdb/python: break more dependencies between gdbpy_initialize_* functions 2022-10-20 16:49:53 +01:00
py-cmd.c
py-connection.c
py-continueevent.c
py-disasm.c gdb/disasm: mark functions passed to the disassembler noexcept 2022-11-28 19:23:30 +00:00
py-event-types.def
py-event.c
py-event.h Change GDB to use frame_info_ptr 2022-10-10 11:57:10 +02:00
py-events.h
py-evtregistry.c
py-evts.c
py-exitedevent.c
py-finishbreakpoint.c Fix deletion of FinishBreakpoints 2022-11-18 10:50:45 -05:00
py-frame.c Change GDB to use frame_info_ptr 2022-10-10 11:57:10 +02:00
py-framefilter.c Change GDB to use frame_info_ptr 2022-10-10 11:57:10 +02:00
py-function.c
py-gdb-readline.c
py-inferior.c gdb/py-inferior: Keep inferior threads in a map 2022-11-11 13:50:19 +00:00
py-infevents.c Change GDB to use frame_info_ptr 2022-10-10 11:57:10 +02:00
py-infthread.c
py-instruction.c gdb/python: break dependencies between gdbpy_initialize_* functions 2022-10-20 16:49:53 +01:00
py-instruction.h gdb/python: break dependencies between gdbpy_initialize_* functions 2022-10-20 16:49:53 +01:00
py-lazy-string.c
py-linetable.c
py-membuf.c
py-micmd.c
py-newobjfileevent.c
py-objfile.c gdb, python: use gdbarch_iterate_over_objfiles_in_search_order 2022-10-18 14:16:09 +02:00
py-param.c GDB/Python: Make None' stand for unlimited' in setting integer parameters 2022-10-21 08:54:18 +01:00
py-prettyprint.c
py-progspace.c
py-record-btrace.c
py-record-btrace.h
py-record-full.c
py-record-full.h
py-record.c gdb/python: break dependencies between gdbpy_initialize_* functions 2022-10-20 16:49:53 +01:00
py-record.h
py-ref.h
py-registers.c
py-signalevent.c
py-stopevent.c
py-stopevent.h
py-symbol.c Change GDB to use frame_info_ptr 2022-10-10 11:57:10 +02:00
py-symtab.c
py-threadevent.c
py-tui.c
py-type.c Add missing TYPE_CODE_* constants to Python 2022-10-31 12:47:36 -06:00
py-unwind.c Change GDB to use frame_info_ptr 2022-10-10 11:57:10 +02:00
py-utils.c
py-value.c
py-varobj.c
py-xmethods.c
python-config.py
python-internal.h gdb/python: break more dependencies between gdbpy_initialize_* functions 2022-10-20 16:49:53 +01:00
python.c gdb, python: use gdbarch_iterate_over_objfiles_in_search_order 2022-10-18 14:16:09 +02:00
python.h gdb, python: use gdbarch_iterate_over_objfiles_in_search_order 2022-10-18 14:16:09 +02:00