Move non-dependent gdb::observers::observable::visit_state outside template
authorPedro Alves <pedro@palves.net>
Fri, 6 May 2022 15:28:37 +0000 (16:28 +0100)
committerPedro Alves <pedro@palves.net>
Tue, 10 May 2022 12:40:57 +0000 (13:40 +0100)
commit62b33fde9c7ffd498af0236a50e200210807374a
tree1980e5cbb5c866b6206d7a09c94d94857faf4260
parentb773a1808d5ae1786cd62a985093cf3f9537f2e2
Move non-dependent gdb::observers::observable::visit_state outside template

The other day, while looking at the symbols that end up in a GDB
index, I noticed that the gdb::observers::observable::visit_state enum
class appears a number of times:

 $ grep VISIT gdb-index-symbol-names.txt
 gdb::observers::observable<bpstat*, int>::visit_state::NOT_VISITED
 gdb::observers::observable<bpstat*, int>::visit_state::VISITED
 gdb::observers::observable<bpstat*, int>::visit_state::VISITING
 gdb::observers::observable<breakpoint*>::visit_state::NOT_VISITED
 gdb::observers::observable<breakpoint*>::visit_state::VISITED
 gdb::observers::observable<breakpoint*>::visit_state::VISITING
 gdb::observers::observable<char const*, char const*>::visit_state::NOT_VISITED
 gdb::observers::observable<char const*, char const*>::visit_state::VISITED
 gdb::observers::observable<char const*, char const*>::visit_state::VISITING
 gdb::observers::observable<char const*>::visit_state::NOT_VISITED
 gdb::observers::observable<char const*>::visit_state::VISITED
 gdb::observers::observable<char const*>::visit_state::VISITING
 gdb::observers::observable<enum_flags<user_selected_what_flag> >::visit_state::NOT_VISITED
 gdb::observers::observable<enum_flags<user_selected_what_flag> >::visit_state::VISITED
 gdb::observers::observable<enum_flags<user_selected_what_flag> >::visit_state::VISITING
 gdb::observers::observable<frame_info*, int>::visit_state::NOT_VISITED
 gdb::observers::observable<frame_info*, int>::visit_state::VISITED
 gdb::observers::observable<frame_info*, int>::visit_state::VISITING
 gdb::observers::observable<gdbarch*>::visit_state::NOT_VISITED
 gdb::observers::observable<gdbarch*>::visit_state::VISITED
 gdb::observers::observable<gdbarch*>::visit_state::VISITING
 gdb::observers::observable<gdb_signal>::visit_state::NOT_VISITED
 gdb::observers::observable<gdb_signal>::visit_state::VISITED
 gdb::observers::observable<gdb_signal>::visit_state::VISITING
 [... snip ...]

 $ grep VISIT gdb-index-symbol-names.txt | wc -l
 72

enum class visit_state is defined inside the class template
observable, but it doesn't have to be, as it does not depend on the
template parameters.  This commit moves it out, so that only one such
type exists.  This reduces the size of a -O0 -g3 build for me by
around 0.6%, like so:

 $ du -b gdb.before gdb.after
 164685280       gdb.before
 163707424       gdb.fixed

and codesize by some 0.5%.

Change-Id: I405f4ef27b8358fdd22158245b145d849b45658e
gdbsupport/observable.h