Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Pedro Alves <palves@redhat.com>
To: Tom Tromey <tom@tromey.com>
Cc: gdb-patches@sourceware.org
Subject: Re: [PATCH 4/4] Introduce class target_stack
Date: Tue, 29 May 2018 14:59:00 -0000	[thread overview]
Message-ID: <f466e517-ad36-c6d2-45b0-12f3113a1fa2@redhat.com> (raw)
In-Reply-To: <87h8mrxify.fsf@tromey.com>

On 05/29/2018 04:13 AM, Tom Tromey wrote:
>>>>>> "Pedro" == Pedro Alves <palves@redhat.com> writes:
> 
> Pedro> The problem then is in finding a target's "beneath" target, if we
> Pedro> consider that for some target_ops types, we'll be sharing a
> Pedro> single target_ops instance between several inferiors.  For
> Pedro> example, so far, I found no need to have multiple instances of
> Pedro> the spu_multiarch_target / exec_target / dummy_target targets.
> 
> Is it the case that sometimes a particular target_ops instance will have
> to be shared among multiple target stacks?
> 
> If so, then this all makes sense to me.

Right, it is the case.  That is true for targets that support
multi-process.  E.g., native targets and remote targets.

The current model in the branch is:

- Each inferior gets its own target stack.  

- There's only ever one instance of the native target_ops.
  All native processes/inferiors use the same target_ops, because
  it's the same ptrace API "instance" that talks to all of them.
  For example, if you do "info os processes" to list all processes,
  it's the single native target_ops instance that implements that
  call.

- There's one remote_target (target_ops) instance for each
  remote connection.  All processes/inferiors debugged via that
  connection share the same remote_target instance.
  You can have multiple remote connections.

- Each process_stratum target_ops instance has its own PID number
  space.  IOW, a process is uniquely identified by the
  (process_stratum target_ops *, int PID) tuple.


Since each inferior has its own target stack, we should be able to
do things like activate "target record full" for inferior 1, and
"target record btrace" for inferior 2, though I haven't done that.


> 
> Pedro> +/* The target stack.  */
> Pedro> +static target_stack g_target_stack;
> 
> As an aside, I often wonder about blank lines between comments and
> definitions.
> 
> I prefer not to have them, though not for any actual reason.  But some
> spots have them and some do not, so in practice what I do is either
> follow the local style; or leave the blank line out if I think I can; or
> else feel guilty since I vaguely recall there was a rule to have one and
> so put it in even though I'd rather not.

I think the main rule is: blank line in definition, no blank line
in declarations:

 https://sourceware.org/gdb/wiki/Internals%20GDB-C-Coding-Standards#Documenting_Your_Code

That's what I think most newer code follows, but it's like you say,
in reality I guess most folks follow the local style.

I've fixed that case you pointed out.

The case in our codebase where I most tend to find blank lines odd,
is in the documentation of structure fields:

struct S
{
  /* This is foo.  */

  int foo;

  /* This is bar.  */

  int bar;
};

I think I dislike it because that way you lose the visual grouping
between comment and field that you otherwise have with:

struct S
{
  /* This is foo.  */
  int foo;

  /* This is bar.  */
  int bar;
};

Curiously, this case that is not explicitly specified in the wiki,
though the struct example there does not include spaces.

> 
> Pedro> +   Note that rather than allow an empty stack, we always have the
> Pedro> +   dummy target at the bottom stratum, so we can call the function
> Pedro> +   vectors without checking them.  */
> 
> Probably just "methods" rather than "function vectors".

Indeed, probably less confusing to newcomers.  That was just
copied over from elsewhere, but I'll adjust it.

Thanks,
Pedro Alves


      reply	other threads:[~2018-05-29 14:53 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-05-28 16:10 [PATCH 0/4] Change target stack representation Pedro Alves
2018-05-28 16:10 ` [PATCH 1/4] target_stack -> current_top_target() throughout Pedro Alves
2018-05-29  3:13   ` Tom Tromey
2018-05-28 16:19 ` [PATCH 2/4] target_ops::beneath -> target_ops::beneath() Pedro Alves
2018-05-28 17:39 ` [PATCH 3/4] Eliminate find_target_beneath Pedro Alves
2018-05-28 17:47 ` [PATCH 4/4] Introduce class target_stack Pedro Alves
2018-05-29 11:34   ` Tom Tromey
2018-05-29 14:59     ` Pedro Alves [this message]

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=f466e517-ad36-c6d2-45b0-12f3113a1fa2@redhat.com \
    --to=palves@redhat.com \
    --cc=gdb-patches@sourceware.org \
    --cc=tom@tromey.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