stack_status.go 997 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  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. return fmt.Sprintf("Jattach: %v, StackUprobes: %v",
  37. s.IsJattachSuccess(), s.IsStackUprobesSuccess())
  38. }