stack_status.go 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. package modelse
  2. import "fmt"
  3. type StackStatus uint8
  4. // 定义状态的位图常量
  5. const (
  6. JattachSuccess StackStatus = 1 << 0
  7. JattachFailure StackStatus = 0 << 0
  8. StackUprobesSuccess StackStatus = 1 << 1
  9. StackUprobesFailure StackStatus = 0 << 1
  10. )
  11. func (s StackStatus) IsJattachSuccess() bool {
  12. return s&JattachSuccess != 0
  13. }
  14. func (s StackStatus) IsStackUprobesSuccess() bool {
  15. return s&StackUprobesSuccess != 0
  16. }
  17. func (s *StackStatus) JattachSuccess() {
  18. *s |= JattachSuccess
  19. }
  20. func (s *StackStatus) JattachFailure() {
  21. *s &^= JattachSuccess
  22. }
  23. func (s *StackStatus) JattachClose() {
  24. *s &^= JattachSuccess
  25. }
  26. func (s *StackStatus) StackUprobesSuccess() {
  27. *s |= StackUprobesSuccess
  28. }
  29. func (s *StackStatus) StackUprobesFailure() {
  30. *s &^= StackUprobesSuccess
  31. }
  32. func (s *StackStatus) StackUprobesClose() {
  33. *s &^= StackUprobesSuccess
  34. }
  35. func (s StackStatus) String() string {
  36. n := 0
  37. if s.IsJattachSuccess() {
  38. n = 1
  39. }
  40. u := 0
  41. if s.IsStackUprobesSuccess() {
  42. u = 1
  43. }
  44. return fmt.Sprintf("N=%d U=%d ", n, u)
  45. }