Re: gdbstub initial code

2010-07-13 Thread Srikar Dronamraju
* Roland McGrath rol...@redhat.com [2010-07-12 22:59:05]:

  When I had posted a prototype of a gdbstub which Frank and I had
  worked on.  http://lkml.org/lkml/2009/11/30/173, Peter and Ingo
  showed a preference for a combined gdbstub in kernel, i.e kgdb and the
  newer stub should use only one stub in kernel. Do we have plans to
  handle that?
 
 Their actual idea there largely represents a misunderstanding of the
 problem space.  But regardless, it's a distraction from the prototype
 work that Oleg is doing now.  The actual possibilities for code sharing
 between kgdb and something at all like what we're doing now are quite
 small.  It's just not a problem at all to get prototyping progress done
 with a new implementation of the fairly trivial gdb remote protocol
 decoder, and contemplate consolidation later on.

Agree, my concern was that if they keep repeating it after we have
done the prototyping. Yes, that shouldnt stop us from prototyping.


--
Thanks and Regards
Srikar



Re: gdbstub initial code

2010-07-13 Thread Roland McGrath
 Given these requirements, and given that the 'new' uprobes is close to
 -tip, would it be more useful to pursue an alternate syscall approach
 rather than gdbstub?

Feel free to pursue whatever you like.  For our own time allocation, we
see an effort along those lines now as a distraction from work that will
really make a qualitative difference in the debugging experience.  Any
new interface is an instant source of endless discussions (at best)
about many details that are ultimately trivial in the greater scheme of
things.  Aside from flaming its details a priori, no new interface is of
any interest to anyone unless its use is integrated into real, non-toy
userland debugging tools and it enables their delivery of qualitatively
significant, new or better aspects of the debugging experience.  

Starting with a whole new interface inevitably involves spending most of
the time on the combination of LKML flames about the interface trivia
and work on toy userland libraries and utilities to demonstrate using
the new kernel features.  That's a whole lot more time and effort and
friction to come around to doing the toy version of what real userland
debugging tools do today, and maybe then start on doing anything that's
actually new or different beyond cleaning up pet-peeve interface trivia,
if you don't get too side-tracked filling in practical holes in your toy
tools along the way first.

What Oleg is embarking on now is a prototyping exercise.  We're not
trying to find a new kind of backwards to bend over to have upstream
people like any new interface layers.  We're trying to get quickly to
the experimental baseline from which we can try to come up with some of
those qualitatively significant new things.  That means having a full,
adult-sized, real-world debugging tool plugged into new and unencumbered
kernel code paths and doing approximately its normal thing at least as
well (approximately) as normal.  In the end, more of the work is on the
userland side (or in fritter about what the user-kernel interface
details should be) than the actual guts of the kernel-side work.  We've
chosen the gdb remote protocol as a prototype vehicle because we start
with about 95% complete support in our closest-to-hand real-world tool
(gdb) for that baseline.  (We also happen to have some gdb-hacking
colleagues nearby to help us experiment with anything that might rely on
that remaining 5% or otherwise on teaching gdb new tricks.)  Hence we
hope to get very quickly to that baseline for experimentation.

From there we can start trying out the things that could really make a
big difference in what a debugger tool can do (or how well/fast it can
do them).  What matters for that isn't the little details of encodings
or syscall interfaces, but the large-granularity issues about how the
interface is used, like how many context switches back and forth to the
debugger it takes to get a task done, etc.  IMHO it would be pointless
to try to design any new interface before knowing concretely what kinds
of things on the big-idea scale make an important difference to the
actual debugging experience with a real-world tool like gdb.  When we've
shown what key features and characteristics deliver a big tangible
payoff, we can worry about how to formulate new interfaces or extensions
that both achieve those essential goods and meet with upstream tastes.


Thanks,
Roland



Re: gdbstub initial code

2010-07-13 Thread Roland McGrath
 What is the reasoning for selecting /proc/ugdb instead of something like
 /proc/pid/ugdb?

The protocol, and gdb, support dealing with many processes over one control
channel.  For normal the debugger model to work where it can attach to a
process on demand, with your model it would have to open another fd for
every process (or perhaps thread), maintain perhaps thousands of fds, do a
select dance, never be able to pipeline notifications from multiple
processes into a single receiving call in the debugger, etc.  Moreover,
that's just not what the protocol is and we already have a protocol with a
client that we can just support as is.


Thanks,
Roland



Re: gdbstub initial code

2010-07-13 Thread Oleg Nesterov
On 07/13, Ananth N Mavinakayanahalli wrote:

 Given these requirements, and given that the 'new' uprobes is close to
 -tip, would it be more useful to pursue an alternate syscall approach
 rather than gdbstub?

Roland has already answered, and I agree.

The problem is that we do not have the new and nice API. gdbstub was
chosen for prototyping because gdb (at least) is already here and can
use it immediately.

Oleg.



Re: gdbstub initial code

2010-07-13 Thread Oleg Nesterov
On 07/12, Roland McGrath wrote:

  Please see the attachment. Don't take this code seriously, this is
  the early prototype and everything should be rewritten. It barely
  uses utrace, only to stop the target.

 You've got to start somewhere!

Yes ;)

And now I am going to rewrite this code without adding the new
functionality (this shouldn't take much time, hopefully today).
I greatly misunderstood how should this stub communicate with
gdb when I started the coding, struct cbuf is absolutely ugly.

  I still can't understand what utrace_xxx_pid() buys us, and I still
  think that utrace_prepare_examine() can't protect the task even for
  regset calls.

 Please start a separate thread here about each of those issues.  The
 first one is fairly simple, but what that means in practice depends on
 the resolution of the second question, which is a more complex subject.

Yes.

Oleg.



Re: gdbstub initial code

2010-07-13 Thread Tom Tromey
 Ananth == Ananth N Mavinakayanahalli ana...@in.ibm.com writes:

Ananth OTOH, the Tom Tromey alluded on lkml that if kernel provides
Ananth infrastructure that allows for breakpoint assistance and 'displaced'
Ananth stepping, with a suitable user interface, preferably a ptrace variant
Ananth that is fd based, they'll migrate gdb to using the interface. (The bp
Ananth assistance and displaced stepping can be provided with extensions to
Ananth the current uprobes set under review).

Just to be clear, the interface doesn't matter to gdb.  We'll port gdb
to use any new interface that the kernel provides, assuming it provides
some benefit.

Tom