gdb.m 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. // TEST_CFLAGS -Wno-deprecated-declarations
  2. #include "test.h"
  3. #include "testroot.i"
  4. #include <objc/objc-gdb.h>
  5. #include <objc/runtime.h>
  6. #define SwiftV1MangledName4 "_TtC6Swiftt13SwiftV1Class4"
  7. __attribute__((objc_runtime_name(SwiftV1MangledName4)))
  8. @interface SwiftV1Class4 : TestRoot @end
  9. @implementation SwiftV1Class4 @end
  10. int main()
  11. {
  12. // Class hashes
  13. Class result;
  14. // Class should not be realized yet
  15. // fixme not true during class hash rearrangement
  16. // result = NXMapGet(gdb_objc_realized_classes, "TestRoot");
  17. // testassert(!result);
  18. [TestRoot class];
  19. // Now class should be realized
  20. result = (__bridge Class)(NXMapGet(gdb_objc_realized_classes, "TestRoot"));
  21. testassert(result);
  22. testassert(result == [TestRoot class]);
  23. result = (__bridge Class)(NXMapGet(gdb_objc_realized_classes, "DoesNotExist"));
  24. testassert(!result);
  25. // Class structure decoding
  26. uintptr_t *maskp = (uintptr_t *)dlsym(RTLD_DEFAULT, "objc_debug_class_rw_data_mask");
  27. testassert(maskp);
  28. // Raw class names
  29. testassert(strcmp(objc_debug_class_getNameRaw([SwiftV1Class4 class]), SwiftV1MangledName4) == 0);
  30. testassert(strcmp(objc_debug_class_getNameRaw([TestRoot class]), "TestRoot") == 0);
  31. succeed(__FILE__);
  32. }