]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
Make the gdb.objc tests compile
authorTom Tromey <tom@tromey.com>
Sat, 15 Nov 2025 17:37:37 +0000 (10:37 -0700)
committerTom Tromey <tom@tromey.com>
Tue, 2 Dec 2025 16:22:45 +0000 (09:22 -0700)
The gdb.objc tests haven't compiled in years.  This patch fixes this,
based on a comment in bug 31671.

I don't know whether this approach works with the clang implementation
of Objective-C.  However, it does work with GCC, provided that
gnustep-base is installed.

gdb/testsuite/gdb.objc/basicclass.m
gdb/testsuite/gdb.objc/nondebug.m
gdb/testsuite/gdb.objc/objcdecode.m
gdb/testsuite/lib/gdb.exp

index d9b3f23954cac6d0e83d47f8642defea89e3faf9..d1d54dfff1914fcfbab7e2b0ef4286c3f9b2cd61 100644 (file)
@@ -1,7 +1,7 @@
 #include <stdio.h>
-#include <objc/Object.h>
+#include <Foundation/NSObject.h>
 
-@interface BasicClass: Object
+@interface BasicClass: NSObject
 {
   id object;
 }
@@ -75,7 +75,7 @@ const char *_NSPrintForDebugger(id object)
 {
   /* This is not really what _NSPrintForDebugger should do, but it
      is a simple test if gdb can call this function */
-  if (object && [object respondsTo: @selector(myDescription)])
+  if (object)
     return [object myDescription];
 
   return NULL;
index 352a71c30e305c0b55a8c5194a36c2849c7e891c..1ab876443a489d27ac30150c1857a2d22d0d34eb 100644 (file)
@@ -1,11 +1,11 @@
 #include <stdio.h>
-#include <objc/Object.h>
+#include <Foundation/NSObject.h>
 
-@interface NonDebug: Object
+@interface NonDebug: NSObject
 {
 }
 @end
-@interface NonDebug2: Object
+@interface NonDebug2: NSObject
 {
 }
 @end
index a061661ed93b3bad276a2e2046e0fb46d21a94b7..78ff301f3e0dc79d84392ce24eaa75743f18b883 100644 (file)
@@ -1,7 +1,7 @@
 #include <stdio.h>
-#include <objc/Object.h>
+#include <Foundation/NSObject.h>
 
-@interface Decode: Object
+@interface Decode: NSObject
 {
 }
 - multipleDef;
@@ -43,7 +43,7 @@ const char *_NSPrintForDebugger(id object)
 {
   /* This is not really what _NSPrintForDebugger should do, but it
      is a simple test if gdb can call this function */
-  if (object && [object respondsTo: @selector(myDescription)])
+  if (object)
     return [object myDescription];
 
   return NULL;
index 366eff3ca329d00000789cb2ad86c1cc7b91d155..5d005f21be06a319667a111394852d7cd115618a 100644 (file)
@@ -6950,15 +6950,11 @@ proc gdb_compile_shlib_pthreads {sources dest options} {
 proc gdb_compile_objc {source dest type options} {
     set built_binfile 0
     set why_msg "unrecognized error"
-    foreach lib {-lobjc -lpthreads -lpthread -lthread solaris} {
+    set base_libs {-lgnustep-base -lobjc}
+    foreach lib {-lpthreads -lpthread -lthread "-lpthread -lposix4"} {
        # This kind of wipes out whatever libs the caller may have
-       # set.  Or maybe theirs will override ours.  How infelicitous.
-       if { $lib == "solaris" } {
-           set lib "-lpthread -lposix4"
-       }
-       if { $lib != "-lobjc" } {
-         set lib "-lobjc $lib"
-       }
+       # set.  Or maybe theirs will override ours.  How infelicitous.
+       set lib "$base_libs $lib"
        set options_with_lib [concat $options [list libs=$lib quiet]]
        set ccout [gdb_compile $source $dest $type $options_with_lib]
        switch -regexp -- $ccout {