Subject: Re: PowerPC, P2020RDB, application debug when the application is in tight loop, Sysrq

From: Scott Wood <[email-masked]>
Date: Wed, 1 May 2013 14:54:17 -0500

On 04/17/2013 12:04:10 AM, saikrishna gajula wrote:
> HI All,
>=20
>              I am new to this group. I am working on Freescale P2020
> platform running linux 2.6.21.   I am looking for debug =20
> mechanism/utility,
> when a multi threaded application running on linux , appears to be =20
> hung (
> running in a tight loop,deadlock)  while not able to access the board
> through serial/SSH/Telnet.
>=20
>    I was looking at Magic sysrq option in linux to generate the stack,
> register dump when the application is hung. I am able to dump the call
> trace in normal working conditions. But i can't use  echo  t >
> /proc/sysrq-trigger and debug when the application hung.
>=20
>  I am using below piece of code(drivers/serial/8250.c) on P2020RDB to =20
> debug
> the application where in , in hung situation, when i press 'y'  =20
> followed by
> 't'  on serial console it should go to sysrq handler, and dump the =20
> call
> trace, but it is not happening.(simply board hung)
>=20
> {
>            if(sysrq_enable_flag)
>                   handle_sysrq(ch, up->port.info->tty);
>=20
>         sysrq_enable_flag =3D 0;
>=20
>         if(ch =3D=3D 'y')
>             sysrq_enable_flag =3D 1;
> }
>=20
> It would be helpful if you provide any hint on the issue, or any =20
> other way
> to debug the application in hang situations.

There's an erratum regarding breaks in Freescale's serial port =20
implementation that has been worked around in more recent kernels.  =20
2.6.21 is six years old.  If you update to a kernel that has the =20
workaround, or backport the workaround yourself to your old kernel, you =20
should be able to use a break instead of hacking in a check for 'y'.

Other than that, either the kernel is hung too badly to respond to =20
serial input at all (in which case use JTAG to debug) or there's =20
something wrong with your 'y' hack (sysrq_enable_flag doesn't even =20
appear in current kernels so I can't see if this is the case without =20
digging through old code).

In any case, upgrade to a newer kernel -- maybe you're hitting a bug =20
that has been fixed since then.

-Scott=