public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: "Amit S. Kale" <amitkale@emsyssoft.com>
To: George Anzinger <george@mvista.com>,
	Tom Rini <trini@kernel.crashing.org>
Cc: kernel list <linux-kernel@vger.kernel.org>,
	Pavel Machek <pavel@suse.cz>,
	kgdb-bugreport@lists.sourceforge.net
Subject: Re: [Kgdb-bugreport] [PATCH][3/3] Update CVS KGDB's wrt connect / detach
Date: Mon, 1 Mar 2004 15:47:11 +0530	[thread overview]
Message-ID: <200403011547.11116.amitkale@emsyssoft.com> (raw)
In-Reply-To: <403FC0AA.6040205@mvista.com>

On Saturday 28 Feb 2004 3:41 am, George Anzinger wrote:
> Tom Rini wrote:
> > On Thu, Feb 26, 2004 at 05:57:27PM -0800, George Anzinger wrote:
> >>Tom Rini wrote:
> >>>On Thu, Feb 26, 2004 at 03:30:08PM -0800, George Anzinger wrote:
> >>>>Amit S. Kale wrote:
> >>>>>On Thursday 26 Feb 2004 3:23 am, Tom Rini wrote:
> >>>>>>The following patch fixes a number of little issues here and there,
> >>>>>> and ends up making things more robust.
> >>>>>>- We don't need kgdb_might_be_resumed or kgdb_killed_or_detached.
> >>>>>>GDB attaching is GDB attaching, we haven't preserved any of the
> >>>>>>previous context anyhow.
> >>>>>
> >>>>>If gdb is restarted, kgdb has to remove all breakpoints. Present kgdb
> >>>>>does that in the code this patch removes:
> >>>>>
> >>>>>-		if (remcom_in_buffer[0] == 'H' && remcom_in_buffer[1] ==
> >>>>>'c') {
> >>>>>-			remove_all_break();
> >>>>>-			atomic_set(&kgdb_killed_or_detached, 0);
> >>>>>-			ok_packet(remcom_out_buffer);
> >>>>>
> >>>>>If we don't remove breakpoints, they stay in kgdb without gdb not
> >>>>>knowing it and causes consistency problems.
> >>>>
> >>>>I wonder if this is worth the trouble.  Does kgdb need to know about
> >>>>breakpoints at all?  Is there some other reason it needs to track them?
> >>>
> >>>I don't know if it's strictly needed, but it's not the hard part of this
> >>>particular issue (as I suggested in another thread, remove_all_break()
> >>>on a ? packet works).
> >>>
> >>>>>>- Don't try and look for a connection in put_packet, after we've
> >>>>>> tried to put a packet.  Instead, when we receive a packet, GDB has
> >>>>>> connected.
> >>>>>
> >>>>>We have to check for gdb connection in putpacket or else following
> >>>>>problem occurs.
> >>>>>
> >>>>>1. kgdb console messages are to be put.
> >>>>>2. gdb dies
> >>>>>3. putpacket writes the packet and waits for a '+'
> >>>>
> >>>>Oops!  Tom, this '+' will be sent under interrupt and while kgdb is not
> >>>>connected.  Looks like it needs to be passed through without causing a
> >>>>breakpoint.  Possible salvation if we disable interrupts while waiting
> >>>>for the '+' but I don't think that is a good idea.
> >>>
> >>>I don't think this is that hard of a problem anymore.  I haven't enabled
> >>>console messages, but I've got the following being happy now:
> >>
> >>console pass through is the hard one as it is done outside of kgdb under
> >>interrupt control.  Thus the '+' will come to the interrupt handler.
> >>
> >>There is a bit of a problem here WRT hiting a breakpoint while waiting
> >> for this '+'.  Should only happen on SMP systems, but still....
> >
> > Here's why I don't think it's a problem (I'll post the new patch
> > shortly, getting from quilt to a patch against previous is still a
> > pain).  What happens is:
> > 1. kgdb console tried to send a packet.
> > 2. before ACK'ing the above, gdb dies.
>
> What I am describing does not have anything to do with gdb going away.  It
> is that in "normal" operation the console output is done with the
> interrupts on (i.e. we are not in kgdb as a result of a breakpoint, but
> only to do console output).  This means that the interrupt that is
> generated by the '+' from gdb may well happen and the kgdb interrupt
> handler will see the '+' and, with the interrupt handler changes, generate
> a breakpoint.  All we really want to do is to pass the '+' through to
> putpacket.  In a UP machine, I think the wait for the '+' is done with the
> interrupt system off, however, in an SMP machine, other cpus may see it and
> interrupt...  At the very least, the interrupt code needs to be able to
> determine that no character came in and ignore the interrupt.

Yes.
We need some locking on smp for this purpose.

-Amit

>
> -g
>
> > 3. kgdb loops on sending a packet and reading in a char.
> > 4. gdb tries to reconnect and sends $somePacket#cs
> > 5. put_packet sends out the console message again, and reads in a char.
> > 6. put_packet sees a $ (or in the case of your .gdbinit, ^C$, which is
> > still fine).
> > 7. put_packet sees a packet coming in, which preempts sending this
> > packet, and will call kgdb_schedule_breakpoint() and then return, giving
> > up on the console message.
> > 8. do_IRQ() calls kgdb_process_breakpoint(), which calls breakpoint()
> > and gdb gets back in the game.
> >
> >>>- Connect to a waiting kernel, continue/^C/disconnect/reconnect.
> >>>- Connect to a running kernel, continue/^C/disconnect/reconnect.
> >>>- Once connected and running, ^C/hit breakpoint and
> >>> disconnect/reconnect.
> >>>- Once connected, set a breakpoint, kill gdb and hit the breakpoint and
> >>> reconnect.
> >>>- Once connected and running, kill gdb and reconnect.
> >>>
> >>>The last two aren't as "fast" as I might like, but they're the "gdb went
> >>>away in an ungraceful manner" situations, so I think it's OK.  In the
> >>>first (breakpoint hit, no gdb) I end up having to issue a few continues
> >>>to get moving again, but it's a one-time event.
> >>
> >>What are you referring to as "continues".  How is this different from
> >>connect to a waiting kernel?
> >
> > The 'continue' command in gdb.
> >
> >>Usually this would be the end of the
> >>session.  If you are going to continue from here something needs to be
> >> done with the breakpoint that gdb does not know about.  If kgdb can
> >> remove them, well fine, except your stopped on one.  If you remove it,
> >> there could be some confusion as to why you are in the debugger.
> >
> > Hmm.  I think I need to test things a bit more, before I comment on
> > this.


  parent reply	other threads:[~2004-03-01 10:17 UTC|newest]

Thread overview: 47+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-02-25 21:36 [PATCH][1/3] Update CVS KGDB's serial driver Tom Rini
2004-02-25 21:43 ` [PATCH][2/3] Update CVS KGDB's have kgdb_{schedule,process}_breakpoint Tom Rini
2004-02-25 21:53   ` [PATCH][3/3] Update CVS KGDB's wrt connect / detach Tom Rini
2004-02-26  8:14     ` [Kgdb-bugreport] " Amit S. Kale
2004-02-26 14:41       ` Tom Rini
2004-02-26 16:05         ` Daniel Jacobowitz
2004-02-26 17:44           ` Tom Rini
2004-02-26 23:32             ` Daniel Jacobowitz
2004-03-01  8:12           ` Amit S. Kale
2004-02-26 21:45         ` Pavel Machek
2004-03-01  8:29           ` Amit S. Kale
2004-02-26 18:08       ` Tom Rini
2004-03-01  8:15         ` Amit S. Kale
2004-02-26 23:30       ` George Anzinger
2004-02-26 23:59         ` Tom Rini
2004-02-27  1:57           ` George Anzinger
2004-02-27 15:49             ` Tom Rini
2004-02-27 22:11               ` George Anzinger
2004-02-27 22:50                 ` Tom Rini
2004-03-01 10:18                   ` Amit S. Kale
2004-03-01 10:17                 ` Amit S. Kale [this message]
2004-02-27 17:13             ` Tom Rini
2004-02-27 21:55               ` George Anzinger
2004-03-01  8:36         ` Amit S. Kale
2004-03-01 16:31           ` Tom Rini
2004-02-25 22:59   ` [Kgdb-bugreport] [PATCH][2/3] Update CVS KGDB's have kgdb_{schedule,process}_breakpoint George Anzinger
2004-02-25 23:04     ` Tom Rini
2004-02-25 23:23       ` George Anzinger
2004-02-26  7:30   ` Amit S. Kale
2004-02-26 23:19     ` George Anzinger
2004-03-01  8:32       ` Amit S. Kale
2004-03-02 21:19         ` George Anzinger
2004-03-03  5:13           ` Amit S. Kale
2004-03-04  0:20             ` George Anzinger
2004-03-04  4:58               ` Amit S. Kale
2004-03-11 21:28                 ` George Anzinger
2004-03-12  4:44                   ` Amit S. Kale
2004-03-12  8:03                     ` George Anzinger
2004-03-15 11:20                       ` Amit S. Kale
2004-03-15 19:52                         ` George Anzinger
2004-03-16  4:30                           ` Amit S. Kale
2004-03-16 13:02                             ` La Monte H.P. Yarroll
2004-03-16 15:04                               ` Amit S. Kale
2004-02-25 23:10 ` [Kgdb-bugreport] [PATCH][1/3] Update CVS KGDB's serial driver George Anzinger
2004-02-25 23:18   ` Tom Rini
2004-02-26  8:25 ` Amit S. Kale
2004-02-26 14:43   ` Tom Rini

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=200403011547.11116.amitkale@emsyssoft.com \
    --to=amitkale@emsyssoft.com \
    --cc=george@mvista.com \
    --cc=kgdb-bugreport@lists.sourceforge.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=pavel@suse.cz \
    --cc=trini@kernel.crashing.org \
    /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