[PP?] [PATCH v2 12/16] Change remove_target_sections to method on program_space

Tom Tromey tom@tromey.com
Thu Oct 29 01:24:06 GMT 2020


>>>>> "Simon" == Simon Marchi <simark@simark.ca> writes:

>> void
>> -remove_target_sections (void *owner)
>> +program_space::remove_target_sections (void *owner)

Simon> Would it make sense to make a subsequent patch that just moves this
Simon> method to progspace.c?  I think it's ok to leave it in exec.c in this
Simon> patch, so we can more easily see the diff, but I think in the end it
Simon> belongs to progspace.c.

Yeah, makes sense to me.

Simon> The only thing that doesn't belong to progspace.c in this method is:

Simon>   unpush_target (&exec_ops);

Simon> But I think it just means that we need better decoupling.  We could have
Simon> a "program_space_target_sections_changed" observer, which exec.c would
Simon> attach to, and push/unpush as necessary.

I am not totally sure.  Sometimes observers make the code more obscure.

>> -	  if (inf->pspace != curr_pspace)
>> +	  if (inf->pspace != this)
>> continue;
>> 
>> if (!inf->pspace->target_sections.empty ())

Simon> This line can be simplified, I believe:

Simon>   if (!this->target_sections.empty ())

Simon> (you can omit `this` to be consistent with the rest of the code, I just
Simon> happen to like using `this` to access fields that aren't prefixed with
Simon> `m_`, for clarity)

Thanks for pointing this out.  I think the entire 'if' can be removed,
because we already know from an outer 'if' that target_sections is
empty.

Tom


More information about the Gdb-patches mailing list