voucher_trace.d 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. #!/usr/sbin/dtrace -s
  2. /*
  3. * Copyright (c) 2017 Apple Inc. All rights reserved.
  4. *
  5. * @APPLE_APACHE_LICENSE_HEADER_START@
  6. *
  7. * Licensed under the Apache License, Version 2.0 (the "License");
  8. * you may not use this file except in compliance with the License.
  9. * You may obtain a copy of the License at
  10. *
  11. * http://www.apache.org/licenses/LICENSE-2.0
  12. *
  13. * Unless required by applicable law or agreed to in writing, software
  14. * distributed under the License is distributed on an "AS IS" BASIS,
  15. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  16. * See the License for the specific language governing permissions and
  17. * limitations under the License.
  18. *
  19. * @APPLE_APACHE_LICENSE_HEADER_END@
  20. */
  21. /*
  22. * Usage: voucher_trace.d -p [pid]
  23. * traced process must have been executed with
  24. * DYLD_LIBRARY_PATH=/usr/lib/system/introspection or with
  25. * DYLD_IMAGE_SUFFIX=_profile or DYLD_IMAGE_SUFFIX=_debug
  26. */
  27. #pragma D option quiet
  28. #pragma D option zdefs
  29. #pragma D option bufsize=16m
  30. BEGIN {
  31. printf("Starting to trace voucher operations...\n");
  32. }
  33. voucher$target:libdispatch*.dylib::create
  34. {
  35. printf("ALLOC voucher 0x%p, thread %#llx, ref 1, port %#x, aid %#llx", arg0, tid, arg1, arg2);
  36. ustack(10);
  37. printf("\n")
  38. }
  39. voucher$target:libdispatch*.dylib::dispose
  40. {
  41. printf("FREE voucher 0x%p, thread %#llx, ref 0", arg0, tid);
  42. ustack(10);
  43. printf("\n")
  44. }
  45. voucher$target:libdispatch*.dylib::retain
  46. {
  47. printf("RETAIN voucher 0x%p, thread %#llx, ref %d", arg0, tid, arg1);
  48. ustack(10);
  49. printf("\n")
  50. }
  51. voucher$target:libdispatch*.dylib::release
  52. {
  53. printf("RELEASE voucher 0x%p, thread %#llx, ref %d", arg0, tid, arg1);
  54. ustack(10);
  55. printf("\n")
  56. }
  57. voucher$target:libdispatch*.dylib::adopt
  58. {
  59. printf("ADOPT voucher 0x%p, thread %#llx", arg0, tid);
  60. ustack(10);
  61. printf("\n")
  62. }
  63. voucher$target:libdispatch*.dylib::orphan
  64. {
  65. printf("ORPHAN voucher 0x%p, thread %#llx", arg0, tid);
  66. ustack(10);
  67. printf("\n")
  68. }