public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Simon Marchi <simon.marchi@polymtl.ca>
To: Lancelot SIX <lancelot.six@amd.com>,
	Simon Marchi <simon.marchi@efficios.com>
Cc: gdb-patches@sourceware.org
Subject: Re: [PATCH 4/24] gdb: replace some so_list parameters to use references
Date: Thu, 19 Oct 2023 10:49:12 -0400	[thread overview]
Message-ID: <560f3443-5089-4af2-94d5-efc7bbd92684@polymtl.ca> (raw)
In-Reply-To: <20231019110750.34bk5fflxalsb4tw@khazad-dum>

On 10/19/23 07:07, Lancelot SIX wrote:
> Hi Simon,
> 
> Some minor remarks below.
> 
> On Tue, Oct 10, 2023 at 04:39:59PM -0400, Simon Marchi wrote:
>> From: Simon Marchi <simon.marchi@polymtl.ca>
>>
>> A subsequent patch changes so_list to be linked using
>> intrusive_list.  Iterating an intrusive_list yields some references to
>> the list elements.  Convert some functions accepting so_list objects to
>> take references, to make things easier and more natural.  Add const
>> where possible and convenient.
>>
>> Change-Id: Id5ab5339c3eb6432e809ad14782952d6a45806f3
>> ---
>>  gdb/breakpoint.c     |   5 +-
>>  gdb/bsd-uthread.c    |  12 ++---
>>  gdb/exec.c           |   4 +-
>>  gdb/interps.c        |   4 +-
>>  gdb/interps.h        |   8 +--
>>  gdb/mi/mi-cmd-file.c |   2 +-
>>  gdb/mi/mi-interp.c   |  26 ++++-----
>>  gdb/mi/mi-interp.h   |   6 +--
>>  gdb/nto-tdep.c       |   6 +--
>>  gdb/nto-tdep.h       |   3 +-
>>  gdb/observable.h     |   5 +-
>>  gdb/progspace.h      |   4 +-
>>  gdb/solib-aix.c      |  11 ++--
>>  gdb/solib-darwin.c   |  23 ++++----
>>  gdb/solib-dsbt.c     |   9 ++--
>>  gdb/solib-frv.c      |   9 ++--
>>  gdb/solib-rocm.c     |   8 +--
>>  gdb/solib-svr4.c     |  35 ++++++------
>>  gdb/solib-target.c   |  49 +++++++++--------
>>  gdb/solib.c          | 126 +++++++++++++++++++++----------------------
>>  gdb/solib.h          |   4 +-
>>  gdb/solist.h         |  13 +++--
>>  gdb/target-section.h |   2 +-
>>  23 files changed, 183 insertions(+), 191 deletions(-)
>>
>> diff --git a/gdb/mi/mi-interp.h b/gdb/mi/mi-interp.h
>> index f9af61f0a571..781a8dc6f466 100644
>> --- a/gdb/mi/mi-interp.h
>> +++ b/gdb/mi/mi-interp.h
>> @@ -60,8 +60,8 @@ class mi_interp final : public interp
>>    void on_record_changed (inferior *inf, int started, const char *method,
>>  			  const char *format) override;
>>    void on_target_resumed (ptid_t ptid) override;
>> -  void on_solib_loaded (so_list *so) override;
>> -  void on_solib_unloaded (so_list *so) override;
>> +  void on_solib_loaded (const so_list &so) override;
>> +  void on_solib_unloaded (const so_list &so) override;
> 
> It is orthogonal to this change, but it would make sense for those
> methods to be const as well.
> 
> Doing this requires interp::interp_ui_out to be const as well (as done
> in attached patch).

Why do you think the interp object should be const (which is the effect
of marking the methods const)?  These methods are notifiers to let the
interp know about certain events that occured.  Whether they should
modify the state of the interpreter or not is up to the particular
implementation of the interpreter.  Perhaps you're right, but I don't
see it.

In your patch, you make interp::interp_ui_out const, but it still
returns a non-const ui_out.  So when outputting something, the
interpreter itself is not modified, but the ui_out behind it is.  I
presume (sometimes) the ui_out needs to be non-const, since for things
like pagination it clearly needs to keep a state.  Design-wise, is it
"correct" to make a const intepreter able to return a non-const ui_out?

>>    void on_about_to_proceed () override;
>>    void on_traceframe_changed (int tfnum, int tpnum) override;
>>    void on_tsv_created (const trace_state_variable *tsv) override;
>> diff --git a/gdb/observable.h b/gdb/observable.h
>> index acb05e9b535c..5ed6ca547ce0 100644
>> --- a/gdb/observable.h
>> +++ b/gdb/observable.h
>> @@ -99,13 +99,12 @@ extern observable<inferior */* parent_inf */, inferior */* child_inf */,
>>  /* The shared library specified by SOLIB has been loaded.  Note that
>>     when gdb calls this observer, the library's symbols probably
>>     haven't been loaded yet.  */
>> -extern observable<struct so_list */* solib */> solib_loaded;
>> +extern observable<so_list &/* solib */> solib_loaded;
> 
> I am wondering, is there a reason to make the solib parameter const for
> solib_unloaded but not for solib_loaded?  
> 
> Changing it to const seems to still compile just fine.  If down the line
> an observer needs to modify the SO, the observer's signature can be
> adjusted.

Just pragmatic reasons.  Do you build with --enable-targets=all?

It's because bsd_uthread_solib_loaded calls solib_read_symbols to read
in the symbols of the library it is looking for, and that requires a
non-const so_list.

Simon

  reply	other threads:[~2023-10-19 14:49 UTC|newest]

Thread overview: 56+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-10-10 20:39 [PATCH 00/24] C++ification of struct so_list Simon Marchi
2023-10-10 20:39 ` [PATCH 01/24] gdb: remove empty clear_solib functions Simon Marchi
2023-10-10 20:39 ` [PATCH 02/24] gdb: add program_space parameter to target_so_ops::clear_solib Simon Marchi
2023-10-17 14:57   ` Pedro Alves
2023-10-17 15:19     ` Simon Marchi
2023-10-10 20:39 ` [PATCH 03/24] gdb: make interps_notify work with references Simon Marchi
2023-10-11  8:48   ` Lancelot SIX
2023-10-11 14:18     ` Simon Marchi
2023-10-10 20:39 ` [PATCH 04/24] gdb: replace some so_list parameters to use references Simon Marchi
2023-10-19 11:07   ` [PATCH 4/24] " Lancelot SIX
2023-10-19 14:49     ` Simon Marchi [this message]
2023-10-19 15:20       ` Lancelot SIX
2023-10-19 16:07         ` Simon Marchi
2023-10-10 20:40 ` [PATCH 05/24] gdbsupport: use "reference" and "pointer" type aliases in intrusive_list Simon Marchi
2023-10-10 20:40 ` [PATCH 06/24] gdbsupport: make intrusive_list's disposer accept a reference Simon Marchi
2023-10-12 19:05   ` Pedro Alves
2023-10-14 20:12     ` Simon Marchi
2023-10-10 20:40 ` [PATCH 07/24] gdb: make get_cbfd_soname_build_id static Simon Marchi
2023-10-10 20:40 ` [PATCH 08/24] gdb: allocate so_list with new, deallocate with delete Simon Marchi
2023-10-10 20:40 ` [PATCH 09/24] gdb: rename lm_info_base to lm_info Simon Marchi
2023-10-10 20:40 ` [PATCH 10/24] gdb: remove target_so_ops::free_so Simon Marchi
2023-10-10 20:40 ` [PATCH 11/24] gdb: use gdb::checked_static_cast when casting lm_info Simon Marchi
2023-10-10 20:40 ` [PATCH 12/24] gdb: make solib-svr4 not use so_list internally Simon Marchi
2023-10-13 17:52   ` Lancelot SIX
2023-10-14 19:59     ` Simon Marchi
2023-10-19 11:08   ` Lancelot SIX
2023-10-19 14:50     ` Simon Marchi
2023-10-10 20:40 ` [PATCH 13/24] gdb: make solib-rocm " Simon Marchi
2023-10-13 18:35   ` Lancelot SIX
2023-10-14 20:00     ` Simon Marchi
2023-10-17 15:23   ` Pedro Alves
2023-10-17 15:32     ` Simon Marchi
2023-10-10 20:40 ` [PATCH 14/24] gdb: remove lm_info_vector typedef Simon Marchi
2023-10-10 20:40 ` [PATCH 15/24] gdb: make so_list::lm_info a unique_ptr Simon Marchi
2023-10-10 20:40 ` [PATCH 16/24] gdb: make clear_so a method of struct so_list Simon Marchi
2023-10-19 11:08   ` Lancelot SIX
2023-10-19 14:52     ` Simon Marchi
2023-10-10 20:40 ` [PATCH 17/24] gdb: remove target_section_table typedef Simon Marchi
2023-10-10 20:40 ` [PATCH 18/24] gdb: make so_list::sections not a pointer Simon Marchi
2023-10-10 20:40 ` [PATCH 19/24] gdb: make so_list::abfd a gdb_bfd_ref_ptr Simon Marchi
2023-10-10 20:40 ` [PATCH 20/24] gdb: make so_list::{so_original_name,so_name} std::strings Simon Marchi
2023-10-13 22:28   ` [PATCH 20/24] gdb: make so_list::{so_original_name, so_name} std::strings Lancelot SIX
2023-10-14 20:01     ` Simon Marchi
2023-10-19 11:08   ` [PATCH 20/24] gdb: make so_list::{so_original_name,so_name} std::strings Lancelot SIX
2023-10-19 14:55     ` Simon Marchi
2023-10-10 20:40 ` [PATCH 21/24] gdb: link so_list using intrusive_list Simon Marchi
2023-10-17 19:14   ` Pedro Alves
2023-10-17 19:38     ` Simon Marchi
2023-10-10 20:40 ` [PATCH 22/24] gdb: don't call so_list::clear in free_so Simon Marchi
2023-10-10 20:40 ` [PATCH 23/24] gdb: remove free_so function Simon Marchi
2023-10-10 20:49 ` [PATCH 24/24] gdb: rename struct so_list to so Simon Marchi
2023-10-17 19:20 ` [PATCH 00/24] C++ification of struct so_list Pedro Alves
2023-10-17 19:53   ` Simon Marchi
2023-10-20 14:40     ` Pedro Alves
2023-10-19 11:09 ` [PATCH 0/24] " Lancelot SIX
2023-10-19 14:57   ` Simon Marchi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=560f3443-5089-4af2-94d5-efc7bbd92684@polymtl.ca \
    --to=simon.marchi@polymtl.ca \
    --cc=gdb-patches@sourceware.org \
    --cc=lancelot.six@amd.com \
    --cc=simon.marchi@efficios.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).