src/LinuxTracing/SwitchesStatesNamesVisitor.cpp
ThreadStateSlice::ThreadState SwitchesStatesNamesVisitor::GetThreadStateFromBits(uint64_t bits) {
  if (__builtin_popcountl(bits & 0xFF) > 1) {
    ERROR("The thread state mask %#lx is a combination of states, reporting only the first",
          bits & 0xFF);
  }
  if ((bits & 0x01) != 0) return ThreadStateSlice::kInterruptibleSleep;
  if ((bits & 0x02) != 0) return ThreadStateSlice::kUninterruptibleSleep;
  if ((bits & 0x04) != 0) return ThreadStateSlice::kStopped;
  if ((bits & 0x08) != 0) return ThreadStateSlice::kTraced;
  if ((bits & 0x10) != 0) return ThreadStateSlice::kDead;
  if ((bits & 0x20) != 0) return ThreadStateSlice::kZombie;
  if ((bits & 0x40) != 0) return ThreadStateSlice::kParked;
  if ((bits & 0x80) != 0) return ThreadStateSlice::kIdle;
  return ThreadStateSlice::kRunnable;
}
// Associates a ThreadStateSlice::ThreadState to the bits of the prev_state field of the
// sched:sched_switch tracepoint. The association is given away by "print fmt" in
// /sys/kernel/debug/tracing/events/sched/sched_switch/format or by
// https://github.com/torvalds/linux/blob/master/fs/proc/array.c.
Associates a ThreadStateSlice::ThreadState to the bits of the prev_state field of the
sched:sched_switch tracepoint.
Associates a ThreadStateSlice :: ThreadState to the bits of the prev_state field of the sched : sched_switch tracepoint .
ThreadStateSlice::ThreadState SwitchesStatesNamesVisitor::GetThreadStateFromBits(uint64_t bits) {
  if (__builtin_popcountl(bits & 0xFF) > 1) {
    ERROR("The thread state mask %#lx is a combination of states, reporting only the first",
          bits & 0xFF);
  }
  if ((bits & 0x01) != 0) return ThreadStateSlice::kInterruptibleSleep;
  if ((bits & 0x02) != 0) return ThreadStateSlice::kUninterruptibleSleep;
  if ((bits & 0x04) != 0) return ThreadStateSlice::kStopped;
  if ((bits & 0x08) != 0) return ThreadStateSlice::kTraced;
  if ((bits & 0x10) != 0) return ThreadStateSlice::kDead;
  if ((bits & 0x20) != 0) return ThreadStateSlice::kZombie;
  if ((bits & 0x40) != 0) return ThreadStateSlice::kParked;
  if ((bits & 0x80) != 0) return ThreadStateSlice::kIdle;
  return ThreadStateSlice::kRunnable;
}
ThreadStateSlice :: ThreadState SwitchesStatesNamesVisitor :: GetThreadStateFromBits ( uint64_t bits ) { if ( __builtin_popcountl ( bits & 0xFF ) > 1 ) { ERROR ( " " , bits & 0xFF ) ; } if ( ( bits & 0x01 ) != 0 ) return ThreadStateSlice :: kInterruptibleSleep ; if ( ( bits & 0x02 ) != 0 ) return ThreadStateSlice :: kUninterruptibleSleep ; if ( ( bits & 0x04 ) != 0 ) return ThreadStateSlice :: kStopped ; if ( ( bits & 0x08 ) != 0 ) return ThreadStateSlice :: kTraced ; if ( ( bits & 0x10 ) != 0 ) return ThreadStateSlice :: kDead ; if ( ( bits & 0x20 ) != 0 ) return ThreadStateSlice :: kZombie ; if ( ( bits & 0x40 ) != 0 ) return ThreadStateSlice :: kParked ; if ( ( bits & 0x80 ) != 0 ) return ThreadStateSlice :: kIdle ; return ThreadStateSlice :: kRunnable ; }
Associates a ThreadStateSlice::ThreadState to the bits of the prev_state field of the
sched:sched_switch tracepoint.
Associates a ThreadStateSlice :: ThreadState to the bits of the prev_state field of the sched : sched_switch tracepoint .