Linux Archive

Linux Archive (http://www.linux-archive.org/)
-   Crash Utility (http://www.linux-archive.org/crash-utility/)
-   -   6.0.5 foreach problem with state RU (http://www.linux-archive.org/crash-utility/649191-6-0-5-foreach-problem-state-ru.html)

Bob Montgomery 03-26-2012 10:43 PM

6.0.5 foreach problem with state RU
 
On Fri, 2012-03-23 at 12:14 -0400, Dave Anderson wrote:
> Download from: http://people.redhat.com/anderson
>
> Changelog:

>
> - Enhancement to the "foreach" command which adds a new "state"
> task-indentifier argument that filters tasks by their task state.
> The state argument may be any of the task states displayed by
> the "ps" command: RU, IN, UN, ST, ZO, SW or DE.
> (rabin@rab.in, anderson@redhat.com)
>

This doesn't work for RU on my system because _RUNNING_ is 0x0 and (0x0
& 0x0) is 0x0 in this line in task.c:

5603 if ((fd->flags & FOREACH_STATE) && !(task_state(tc->task) & fd->state))
5604 continue;

If I change '&' to '==', it works, but I'm not sure if task_state(tc->task) is restricted
to a single flag. Might need to check both, maybe?

Bob Montgomery




--
Crash-utility mailing list
Crash-utility@redhat.com
https://www.redhat.com/mailman/listinfo/crash-utility

Dave Anderson 03-27-2012 01:24 PM

6.0.5 foreach problem with state RU
 
----- Original Message -----
> On Fri, 2012-03-23 at 12:14 -0400, Dave Anderson wrote:
> > Download from: http://people.redhat.com/anderson
> >
> > Changelog:
>
> >
> > - Enhancement to the "foreach" command which adds a new "state"
> > task-indentifier argument that filters tasks by their task state.
> > The state argument may be any of the task states displayed by
> > the "ps" command: RU, IN, UN, ST, ZO, SW or DE.
> > (rabin@rab.in, anderson@redhat.com)
> >
>
> This doesn't work for RU on my system because _RUNNING_ is 0x0 and (0x0
> & 0x0) is 0x0 in this line in task.c:
>
> 5603 if ((fd->flags & FOREACH_STATE) && !(task_state(tc->task) & fd->state))
> 5604 continue;
>
> If I change '&' to '==', it works, but I'm not sure if task_state(tc->task) is restricted
> to a single flag. Might need to check both, maybe?

Yeah, it can be multiple bits -- except in the case of TASK_RUNNING.

When I did the "ps" ST display overhaul to handle multiple bits being
set, I went back and changed Rabin's "foreach" patch, which originally
used "==" and therefore didn't account for multiple bits being set.
But I forgot to make a special case for TASK_RUNNING in that case.
My bad...

So it would have to be something like:

if (fd->flags & FOREACH_STATE) {
if ((fd->state == _RUNNING_) {
if (task_state(tc->task) != _RUNNING_))
continue;
} else if (!(task_state(tc->task) & fd->state))
continue;:
}

Dave

--
Crash-utility mailing list
Crash-utility@redhat.com
https://www.redhat.com/mailman/listinfo/crash-utility

Dave Anderson 03-27-2012 02:27 PM

6.0.5 foreach problem with state RU
 
----- Original Message -----
>
>
> ----- Original Message -----
> > On Fri, 2012-03-23 at 12:14 -0400, Dave Anderson wrote:
> > > Download from: http://people.redhat.com/anderson
> > >
> > > Changelog:
> >
> > >
> > > - Enhancement to the "foreach" command which adds a new "state"
> > > task-indentifier argument that filters tasks by their task
> > > state.
> > > The state argument may be any of the task states displayed by
> > > the "ps" command: RU, IN, UN, ST, ZO, SW or DE.
> > > (rabin@rab.in, anderson@redhat.com)
> > >
> >
> > This doesn't work for RU on my system because _RUNNING_ is 0x0 and (0x0
> > & 0x0) is 0x0 in this line in task.c:
> >
> > 5603 if ((fd->flags & FOREACH_STATE) && !(task_state(tc->task) & fd->state))
> > 5604 continue;
> >
> > If I change '&' to '==', it works, but I'm not sure if task_state(tc->task) is restricted
> > to a single flag. Might need to check both, maybe?
>
> Yeah, it can be multiple bits -- except in the case of TASK_RUNNING.
>
> When I did the "ps" ST display overhaul to handle multiple bits being
> set, I went back and changed Rabin's "foreach" patch, which originally
> used "==" and therefore didn't account for multiple bits being set.
> But I forgot to make a special case for TASK_RUNNING in that case.
> My bad...
>
> So it would have to be something like:
>
> if (fd->flags & FOREACH_STATE) {
> if ((fd->state == _RUNNING_) {
> if (task_state(tc->task) != _RUNNING_))
> continue;
> } else if (!(task_state(tc->task) & fd->state))
> continue;:
> }
>
> Dave

I'll also fix it so that only one state may be entered. As it is,
if multiple states are entered, only the last one is honored.
And because of the special TASK_RUNNING (0) state, it doesn't
make much sense to allow multiples.

Dave

--
Crash-utility mailing list
Crash-utility@redhat.com
https://www.redhat.com/mailman/listinfo/crash-utility


All times are GMT. The time now is 12:47 PM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.