From: Simon Marchi <simon.marchi@ericsson.com>
To: Philipp Rudo <prudo@linux.vnet.ibm.com>
Cc: <gdb-patches@sourceware.org>
Subject: Re: [PATCH RFC] Decouple user selection from internal selection
Date: Fri, 03 Mar 2017 18:31:00 -0000 [thread overview]
Message-ID: <5e0a88c0-b541-c261-97a0-37e8753ccb6a@ericsson.com> (raw)
In-Reply-To: <20170303182421.4ba0d248@ThinkPad>
Hi Philipp,
On 17-03-03 12:24 PM, Philipp Rudo wrote:
> Hi Simon
>
> I have mixed feelings for this patch. On the one hand I think its good
> you try to untangle the different uses of the global variables. On the
> other hand your approach is just an other workaround for the main
> problem, using global variables.
>
> For me the long-term goal should be to get rid of the global
> variables. This would require to define a "debug_context" which can be
> a user selected as well as a GDB internal context. This
> "debug_context" (or parts of it) can then be passed down the stack. So
> every function gets the information it needs from its caller. This not
> only gives you flexibility, as you can have different contexts, but
> also prevents bugs where the global variables are not properly
> set/restored, like you have with MI.
I agree. I think a good way of stating the direction to take is to reduce
the usage of the inferior_ptid global variable. As I mentioned in the patch
message, it currently has two functions:
1. User/front-end selected thread
2. Internally selected thread
This patch tries to separate those two concerns. #1 doesn't really have the
choice to be global at the moment, because we have a single globally shared user
selection. If we decide to have a selection per UI, it would change that.
#2 is where we can reduce the usage of the global right now. inferior_ptid is
in many ways used to indirectly pass information to called functions (on which
thread to operate), whereas this information should be passed down the callstack,
as you say.
Whether we can use the same debug_context objects for storing the user selection
and the debug contexts passed down the stack, I don't know. Whoever implements
this will discover the answer.
So I think that my patch, even though it doesn't address the problem of the
globals directly, is in line with the long-term direction you are proposing.
> Those different "debug_contexts" will also be needed for the
> multi-target idea Andreas and I have. With this feature we want to
> allow the user to take a look at a given problem from the point of view
> of different targets. For example consider the potential target stack
> (from [1]):
>
> - goroutine (Goroutine)
> - multi-thread (multi-threaded child process.) <-- linux-thread-db
> - lk-user (User-space task) <-- focuses on one user-space process
> - lk-thread (Linux kernel threads) <-- uses the kernel's task list
> - core (Local core dump file) <-- "threads" are actually CPUs
> - exec (Local exec file)
> - None (None)
>
> In this scenario there are five different views on threads (from
> hardware threads to goroutines). The user might be interested in all
> of them and wants to choose a target and get its perspective on the
> problem. But switching between different targets, with different views
> on threads/inferiors, using global variables would be a pain and error
> prone. That's why we prefer the approach described above.
It would be very interesting indeed, to be able to choose the level of
abstraction at which to look at the system.
> Of course getting rid of the global variables would be a huge job.
> Here your approach could be an intermediate solution (I understand your
> "user_selection" to be a "debug_context"). It allows us to update GDB
> over time by passing it down the stack one after one and apply the
> context to the global variables for the parts which where not updated,
> yet.
>
> Independent to what I said before you should split up this patch into a
> series to make review easier. For example the introduction of
> thread_info::put/get in gdbthread.h or scoped_restore_suppress_output
> in ui-out.c are independent of the user-selection and should go in
> separate patches.
Indeed, I will do that.
Thanks a lot for the comments.
Simon
prev parent reply other threads:[~2017-03-03 18:31 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-02-23 22:29 Simon Marchi
2017-02-24 7:53 ` Eli Zaretskii
2017-03-03 17:24 ` Philipp Rudo
2017-03-03 18:31 ` Simon Marchi [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=5e0a88c0-b541-c261-97a0-37e8753ccb6a@ericsson.com \
--to=simon.marchi@ericsson.com \
--cc=gdb-patches@sourceware.org \
--cc=prudo@linux.vnet.ibm.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