Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [PATCH 00/11] Readability improvements of some iteration functions
@ 2026-04-16 20:16 Simon Marchi
  2026-04-16 20:16 ` [PATCH 01/11] gdb/dwarf: remove unused file_match parameter from dwarf2_base_index_functions::search_one Simon Marchi
                   ` (10 more replies)
  0 siblings, 11 replies; 12+ messages in thread
From: Simon Marchi @ 2026-04-16 20:16 UTC (permalink / raw)
  To: gdb-patches; +Cc: Simon Marchi

This series contains a few readability improvements that I came up with
as I was reading the DWARF index and symbol lookup code.

The first significant change is the introduction of the
`iteration_status` enum, since I was confused with the meaning of
true/false to mean "stop" vs "keep iterating", for some iteration
functions that use a callback.  I think that an enum will make that
clearer.  This enum is used for method quick_symbol_functions::search
and everything around it.

I looked at using the enum for the various "iterate_over_*" functions
that have this "stop iteration early" capability, but for them I
concluded that the code would be clearer if we split them in two:

 - A "for each" function that doesn't have the capability of stopping
   iteration early
 - A "find" function that returns the first element for which the
   callback returns true.  For this use case, I think it's fine for the
   callback to return a bool.

That's mostly it, there are other small changes, but the patches should
be clear on their own.

Simon Marchi (11):
  gdb/dwarf: remove unused file_match parameter from
    dwarf2_base_index_functions::search_one
  gdb: rename search_symtabs_expansion_listener ->
    compunit_symtab_iteration_callback
  gdb: introduce iteration_status enum, use it for search callbacks
  gdb, gdbserver: make iterate_over_lwps_ftype a function_view
  gdb, gdbserver: split iterate_over_lwps in for_each_lwp and find_lwp
  gdb: split iterate_over_threads in for_each_thread and find_thread
  gdb: split iterate_over_minimal_symbols in for_each_minimal_symbol and
    find_minimal_symbol
  gdb: split iterate_over_symtabs in for_each_symtab and find_symtab
  gdb: change objfile::map_symtabs_matching_filename to
    find_symtab_matching_filename
  gdb: make symbol_found_callback_ftype a function_view
  gdb: make iterate_over_symbols return void, rename to for_each_symbol

 gdb/ada-lang.c                     |  32 ++--
 gdb/aix-thread.c                   |   2 +-
 gdb/arm-linux-nat.c                |  38 ++--
 gdb/breakpoint.c                   |   3 +-
 gdb/cp-support.c                   |   2 +-
 gdb/dwarf2/cooked-index-entry.c    |   2 +-
 gdb/dwarf2/cooked-index-entry.h    |  10 +-
 gdb/dwarf2/cooked-index.h          |   4 +-
 gdb/dwarf2/index-write.c           |   4 +-
 gdb/dwarf2/read.c                  |  78 ++++----
 gdb/dwarf2/read.h                  |  26 +--
 gdb/expanded-symbol.c              |  16 +-
 gdb/expanded-symbol.h              |  15 +-
 gdb/fbsd-tdep.c                    |   2 +-
 gdb/gdbthread.h                    |  21 ++-
 gdb/infcmd.c                       |   9 +-
 gdb/infrun.c                       |   4 +-
 gdb/language.h                     |  13 +-
 gdb/linespec.c                     |  80 ++++-----
 gdb/linux-nat.c                    | 277 +++++++++++++++--------------
 gdb/mi/mi-main.c                   |  15 +-
 gdb/minsyms.c                      |  25 ++-
 gdb/minsyms.h                      |  37 +++-
 gdb/nat/aarch64-linux-hw-point.c   |  17 +-
 gdb/nat/linux-nat.h                |  17 +-
 gdb/nat/loongarch-linux-hw-point.c |  18 +-
 gdb/nat/x86-linux-dregs.c          |  15 +-
 gdb/objfiles.h                     |  31 ++--
 gdb/ppc-linux-nat.c                |  22 +--
 gdb/procfs.c                       |   6 +-
 gdb/python/py-symbol.c             |  18 +-
 gdb/quick-symbol.h                 |  25 +--
 gdb/s390-linux-nat.c               |  22 +--
 gdb/sol-thread.c                   |   4 +-
 gdb/symfile-debug.c                | 114 ++++++------
 gdb/symtab.c                       |  97 +++++-----
 gdb/symtab.h                       |  41 ++---
 gdb/thread.c                       |  27 ++-
 gdbserver/linux-low.cc             |  21 +--
 gdbsupport/iteration-status.h      |  48 +++++
 40 files changed, 659 insertions(+), 599 deletions(-)
 create mode 100644 gdbsupport/iteration-status.h


base-commit: cc9d69394628641235da1483788c0d938c9b6661
-- 
2.53.0


^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2026-04-16 20:27 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-04-16 20:16 [PATCH 00/11] Readability improvements of some iteration functions Simon Marchi
2026-04-16 20:16 ` [PATCH 01/11] gdb/dwarf: remove unused file_match parameter from dwarf2_base_index_functions::search_one Simon Marchi
2026-04-16 20:16 ` [PATCH 02/11] gdb: rename search_symtabs_expansion_listener -> compunit_symtab_iteration_callback Simon Marchi
2026-04-16 20:16 ` [PATCH 03/11] gdb: introduce iteration_status enum, use it for search callbacks Simon Marchi
2026-04-16 20:16 ` [PATCH 04/11] gdb, gdbserver: make iterate_over_lwps_ftype a function_view Simon Marchi
2026-04-16 20:16 ` [PATCH 05/11] gdb, gdbserver: split iterate_over_lwps in for_each_lwp and find_lwp Simon Marchi
2026-04-16 20:16 ` [PATCH 06/11] gdb: split iterate_over_threads in for_each_thread and find_thread Simon Marchi
2026-04-16 20:16 ` [PATCH 07/11] gdb: split iterate_over_minimal_symbols in for_each_minimal_symbol and find_minimal_symbol Simon Marchi
2026-04-16 20:16 ` [PATCH 08/11] gdb: split iterate_over_symtabs in for_each_symtab and find_symtab Simon Marchi
2026-04-16 20:16 ` [PATCH 09/11] gdb: change objfile::map_symtabs_matching_filename to find_symtab_matching_filename Simon Marchi
2026-04-16 20:16 ` [PATCH 10/11] gdb: make symbol_found_callback_ftype a function_view Simon Marchi
2026-04-16 20:16 ` [PATCH 11/11] gdb: make iterate_over_symbols return void, rename to for_each_symbol Simon Marchi

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox