mirror of
https://github.com/darlinghq/darling-gdb.git
synced 2024-11-24 20:49:43 +00:00
* Makefile.in (ALL_SUBDIRS): Add gdb.objc
* configure.in (AC_OUTPUT): Add gdb.objc/Makefile * gdb.objc/Makefile.in, gdb.objc/basicclass.exp, gdb.objc/basicclass.m: : New files * lib/gdb.exp (gdb_compile_objc): New procedure.
This commit is contained in:
parent
10a9829174
commit
130cacceca
@ -1,3 +1,12 @@
|
||||
2003-04-30 Adam Fedor <fedor@gnu.org>
|
||||
|
||||
* Makefile.in (ALL_SUBDIRS): Add gdb.objc
|
||||
* configure.in (AC_OUTPUT): Add gdb.objc/Makefile
|
||||
* gdb.objc/Makefile.in, gdb.objc/basicclass.exp,
|
||||
gdb.objc/basicclass.m: : New files
|
||||
|
||||
* lib/gdb.exp (gdb_compile_objc): New procedure.
|
||||
|
||||
2003-04-27 Daniel Jacobowitz <drow@mvista.com>
|
||||
|
||||
* gdb.base/signals.exp: Make backtrace tests more specific.
|
||||
|
@ -36,7 +36,7 @@ EXEEXT = @EXEEXT@
|
||||
SUBDIRS = @subdirs@
|
||||
RPATH_ENVVAR = @RPATH_ENVVAR@
|
||||
ALL_SUBDIRS = gdb.arch gdb.asm gdb.base gdb.c++ gdb.disasm gdb.java gdb.mi \
|
||||
gdb.threads gdb.trace $(SUBDIRS)
|
||||
gdb.objc gdb.threads gdb.trace $(SUBDIRS)
|
||||
|
||||
EXPECT = `if [ -f $${rootme}/../../expect/expect ] ; then \
|
||||
echo $${rootme}/../../expect/expect ; \
|
||||
|
69
gdb/testsuite/configure
vendored
69
gdb/testsuite/configure
vendored
@ -34,7 +34,6 @@ program_suffix=NONE
|
||||
program_transform_name=s,x,x,
|
||||
silent=
|
||||
site=
|
||||
sitefile=
|
||||
srcdir=
|
||||
target=NONE
|
||||
verbose=
|
||||
@ -149,7 +148,6 @@ Configuration:
|
||||
--help print this message
|
||||
--no-create do not create output files
|
||||
--quiet, --silent do not print \`checking...' messages
|
||||
--site-file=FILE use FILE as the site file
|
||||
--version print the version of autoconf that created configure
|
||||
Directory and file names:
|
||||
--prefix=PREFIX install architecture-independent files in PREFIX
|
||||
@ -320,11 +318,6 @@ EOF
|
||||
-site=* | --site=* | --sit=*)
|
||||
site="$ac_optarg" ;;
|
||||
|
||||
-site-file | --site-file | --site-fil | --site-fi | --site-f)
|
||||
ac_prev=sitefile ;;
|
||||
-site-file=* | --site-file=* | --site-fil=* | --site-fi=* | --site-f=*)
|
||||
sitefile="$ac_optarg" ;;
|
||||
|
||||
-srcdir | --srcdir | --srcdi | --srcd | --src | --sr)
|
||||
ac_prev=srcdir ;;
|
||||
-srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*)
|
||||
@ -490,16 +483,12 @@ fi
|
||||
srcdir=`echo "${srcdir}" | sed 's%\([^/]\)/*$%\1%'`
|
||||
|
||||
# Prefer explicitly selected file to automatically selected ones.
|
||||
if test -z "$sitefile"; then
|
||||
if test -z "$CONFIG_SITE"; then
|
||||
if test "x$prefix" != xNONE; then
|
||||
CONFIG_SITE="$prefix/share/config.site $prefix/etc/config.site"
|
||||
else
|
||||
CONFIG_SITE="$ac_default_prefix/share/config.site $ac_default_prefix/etc/config.site"
|
||||
fi
|
||||
if test -z "$CONFIG_SITE"; then
|
||||
if test "x$prefix" != xNONE; then
|
||||
CONFIG_SITE="$prefix/share/config.site $prefix/etc/config.site"
|
||||
else
|
||||
CONFIG_SITE="$ac_default_prefix/share/config.site $ac_default_prefix/etc/config.site"
|
||||
fi
|
||||
else
|
||||
CONFIG_SITE="$sitefile"
|
||||
fi
|
||||
for ac_site_file in $CONFIG_SITE; do
|
||||
if test -r "$ac_site_file"; then
|
||||
@ -560,7 +549,7 @@ ac_config_sub=$ac_aux_dir/config.sub
|
||||
ac_configure=$ac_aux_dir/configure # This should be Cygnus configure.
|
||||
|
||||
echo $ac_n "checking build system type""... $ac_c" 1>&6
|
||||
echo "configure:564: checking build system type" >&5
|
||||
echo "configure:553: checking build system type" >&5
|
||||
|
||||
build_alias=$build
|
||||
case "$build_alias" in
|
||||
@ -584,7 +573,7 @@ else { echo "configure: error: can not run $ac_config_sub" 1>&2; exit 1; }
|
||||
fi
|
||||
|
||||
echo $ac_n "checking host system type""... $ac_c" 1>&6
|
||||
echo "configure:588: checking host system type" >&5
|
||||
echo "configure:577: checking host system type" >&5
|
||||
|
||||
host_alias=$host
|
||||
case "$host_alias" in
|
||||
@ -605,7 +594,7 @@ host_os=`echo $host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'`
|
||||
echo "$ac_t""$host" 1>&6
|
||||
|
||||
echo $ac_n "checking target system type""... $ac_c" 1>&6
|
||||
echo "configure:609: checking target system type" >&5
|
||||
echo "configure:598: checking target system type" >&5
|
||||
|
||||
target_alias=$target
|
||||
case "$target_alias" in
|
||||
@ -720,7 +709,7 @@ fi
|
||||
|
||||
|
||||
echo $ac_n "checking how to run the C preprocessor""... $ac_c" 1>&6
|
||||
echo "configure:724: checking how to run the C preprocessor" >&5
|
||||
echo "configure:713: checking how to run the C preprocessor" >&5
|
||||
# On Suns, sometimes $CPP names a directory.
|
||||
if test -n "$CPP" && test -d "$CPP"; then
|
||||
CPP=
|
||||
@ -735,13 +724,13 @@ else
|
||||
# On the NeXT, cc -E runs the code through the compiler's parser,
|
||||
# not just through cpp.
|
||||
cat > conftest.$ac_ext <<EOF
|
||||
#line 739 "configure"
|
||||
#line 728 "configure"
|
||||
#include "confdefs.h"
|
||||
#include <assert.h>
|
||||
Syntax Error
|
||||
EOF
|
||||
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
|
||||
{ (eval echo configure:745: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
|
||||
{ (eval echo configure:734: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
|
||||
ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
|
||||
if test -z "$ac_err"; then
|
||||
:
|
||||
@ -752,13 +741,13 @@ else
|
||||
rm -rf conftest*
|
||||
CPP="${CC-cc} -E -traditional-cpp"
|
||||
cat > conftest.$ac_ext <<EOF
|
||||
#line 756 "configure"
|
||||
#line 745 "configure"
|
||||
#include "confdefs.h"
|
||||
#include <assert.h>
|
||||
Syntax Error
|
||||
EOF
|
||||
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
|
||||
{ (eval echo configure:762: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
|
||||
{ (eval echo configure:751: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
|
||||
ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
|
||||
if test -z "$ac_err"; then
|
||||
:
|
||||
@ -769,13 +758,13 @@ else
|
||||
rm -rf conftest*
|
||||
CPP="${CC-cc} -nologo -E"
|
||||
cat > conftest.$ac_ext <<EOF
|
||||
#line 773 "configure"
|
||||
#line 762 "configure"
|
||||
#include "confdefs.h"
|
||||
#include <assert.h>
|
||||
Syntax Error
|
||||
EOF
|
||||
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
|
||||
{ (eval echo configure:779: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
|
||||
{ (eval echo configure:768: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
|
||||
ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
|
||||
if test -z "$ac_err"; then
|
||||
:
|
||||
@ -803,17 +792,17 @@ for ac_hdr in pthread.h
|
||||
do
|
||||
ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
|
||||
echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
|
||||
echo "configure:807: checking for $ac_hdr" >&5
|
||||
echo "configure:796: checking for $ac_hdr" >&5
|
||||
if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
|
||||
echo $ac_n "(cached) $ac_c" 1>&6
|
||||
else
|
||||
cat > conftest.$ac_ext <<EOF
|
||||
#line 812 "configure"
|
||||
#line 801 "configure"
|
||||
#include "confdefs.h"
|
||||
#include <$ac_hdr>
|
||||
EOF
|
||||
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
|
||||
{ (eval echo configure:817: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
|
||||
{ (eval echo configure:806: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
|
||||
ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
|
||||
if test -z "$ac_err"; then
|
||||
rm -rf conftest*
|
||||
@ -841,12 +830,12 @@ done
|
||||
|
||||
|
||||
echo $ac_n "checking for Cygwin environment""... $ac_c" 1>&6
|
||||
echo "configure:845: checking for Cygwin environment" >&5
|
||||
echo "configure:834: checking for Cygwin environment" >&5
|
||||
if eval "test \"`echo '$''{'ac_cv_cygwin'+set}'`\" = set"; then
|
||||
echo $ac_n "(cached) $ac_c" 1>&6
|
||||
else
|
||||
cat > conftest.$ac_ext <<EOF
|
||||
#line 850 "configure"
|
||||
#line 839 "configure"
|
||||
#include "confdefs.h"
|
||||
|
||||
int main() {
|
||||
@ -857,7 +846,7 @@ int main() {
|
||||
return __CYGWIN__;
|
||||
; return 0; }
|
||||
EOF
|
||||
if { (eval echo configure:861: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
|
||||
if { (eval echo configure:850: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
|
||||
rm -rf conftest*
|
||||
ac_cv_cygwin=yes
|
||||
else
|
||||
@ -874,19 +863,19 @@ echo "$ac_t""$ac_cv_cygwin" 1>&6
|
||||
CYGWIN=
|
||||
test "$ac_cv_cygwin" = yes && CYGWIN=yes
|
||||
echo $ac_n "checking for mingw32 environment""... $ac_c" 1>&6
|
||||
echo "configure:878: checking for mingw32 environment" >&5
|
||||
echo "configure:867: checking for mingw32 environment" >&5
|
||||
if eval "test \"`echo '$''{'ac_cv_mingw32'+set}'`\" = set"; then
|
||||
echo $ac_n "(cached) $ac_c" 1>&6
|
||||
else
|
||||
cat > conftest.$ac_ext <<EOF
|
||||
#line 883 "configure"
|
||||
#line 872 "configure"
|
||||
#include "confdefs.h"
|
||||
|
||||
int main() {
|
||||
return __MINGW32__;
|
||||
; return 0; }
|
||||
EOF
|
||||
if { (eval echo configure:890: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
|
||||
if { (eval echo configure:879: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
|
||||
rm -rf conftest*
|
||||
ac_cv_mingw32=yes
|
||||
else
|
||||
@ -905,7 +894,7 @@ test "$ac_cv_mingw32" = yes && MINGW32=yes
|
||||
|
||||
|
||||
echo $ac_n "checking for executable suffix""... $ac_c" 1>&6
|
||||
echo "configure:909: checking for executable suffix" >&5
|
||||
echo "configure:898: checking for executable suffix" >&5
|
||||
if eval "test \"`echo '$''{'ac_cv_exeext'+set}'`\" = set"; then
|
||||
echo $ac_n "(cached) $ac_c" 1>&6
|
||||
else
|
||||
@ -915,10 +904,10 @@ else
|
||||
rm -f conftest*
|
||||
echo 'int main () { return 0; }' > conftest.$ac_ext
|
||||
ac_cv_exeext=
|
||||
if { (eval echo configure:919: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; }; then
|
||||
if { (eval echo configure:908: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; }; then
|
||||
for file in conftest.*; do
|
||||
case $file in
|
||||
*.c | *.C | *.o | *.obj | *.ilk | *.pdb) ;;
|
||||
*.c | *.o | *.obj) ;;
|
||||
*) ac_cv_exeext=`echo $file | sed -e s/conftest//` ;;
|
||||
esac
|
||||
done
|
||||
@ -1040,7 +1029,7 @@ ac_given_srcdir=$srcdir
|
||||
|
||||
trap 'rm -fr `echo "Makefile gdb.arch/Makefile gdb.asm/Makefile gdb.base/Makefile \
|
||||
gdb.c++/Makefile gdb.disasm/Makefile gdb.java/Makefile gdb.mi/Makefile \
|
||||
gdb.threads/Makefile gdb.trace/Makefile config.h:config.hin" | sed "s/:[^ ]*//g"` conftest*; exit 1' 1 2 15
|
||||
gdb.objc/Makefile gdb.threads/Makefile gdb.trace/Makefile config.h:config.hin" | sed "s/:[^ ]*//g"` conftest*; exit 1' 1 2 15
|
||||
EOF
|
||||
cat >> $CONFIG_STATUS <<EOF
|
||||
|
||||
@ -1134,7 +1123,7 @@ cat >> $CONFIG_STATUS <<EOF
|
||||
|
||||
CONFIG_FILES=\${CONFIG_FILES-"Makefile gdb.arch/Makefile gdb.asm/Makefile gdb.base/Makefile \
|
||||
gdb.c++/Makefile gdb.disasm/Makefile gdb.java/Makefile gdb.mi/Makefile \
|
||||
gdb.threads/Makefile gdb.trace/Makefile"}
|
||||
gdb.objc/Makefile gdb.threads/Makefile gdb.trace/Makefile"}
|
||||
EOF
|
||||
cat >> $CONFIG_STATUS <<\EOF
|
||||
for ac_file in .. $CONFIG_FILES; do if test "x$ac_file" != x..; then
|
||||
|
@ -115,4 +115,4 @@ AC_EXEEXT
|
||||
AC_CONFIG_SUBDIRS($configdirs)
|
||||
AC_OUTPUT([Makefile gdb.arch/Makefile gdb.asm/Makefile gdb.base/Makefile \
|
||||
gdb.c++/Makefile gdb.disasm/Makefile gdb.java/Makefile gdb.mi/Makefile \
|
||||
gdb.threads/Makefile gdb.trace/Makefile])
|
||||
gdb.objc/Makefile gdb.threads/Makefile gdb.trace/Makefile])
|
||||
|
22
gdb/testsuite/gdb.objc/Makefile.in
Normal file
22
gdb/testsuite/gdb.objc/Makefile.in
Normal file
@ -0,0 +1,22 @@
|
||||
VPATH = @srcdir@
|
||||
srcdir = @srcdir@
|
||||
|
||||
EXECUTABLES = basicclass
|
||||
|
||||
all:
|
||||
@echo "Nothing to be done for all..."
|
||||
|
||||
info:
|
||||
install-info:
|
||||
dvi:
|
||||
install:
|
||||
uninstall: force
|
||||
installcheck:
|
||||
check:
|
||||
|
||||
clean mostlyclean:
|
||||
-rm -f *~ *.o *.ci
|
||||
-rm -f core ${EXECUTABLES}
|
||||
|
||||
distclean maintainer-clean realclean: clean
|
||||
-rm -f Makefile config.status config.log
|
199
gdb/testsuite/gdb.objc/basicclass.exp
Normal file
199
gdb/testsuite/gdb.objc/basicclass.exp
Normal file
@ -0,0 +1,199 @@
|
||||
# Copyright 2003 Free Software Foundation, Inc.
|
||||
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 2 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
||||
# This file was written by Adam Fedor (fedor@gnu.org)
|
||||
|
||||
if $tracelevel then {
|
||||
strace $tracelevel
|
||||
}
|
||||
|
||||
set testfile "basicclass"
|
||||
set srcfile ${testfile}.m
|
||||
set binfile ${objdir}/${subdir}/${testfile}
|
||||
|
||||
#
|
||||
# Objective-C program compilation isn't standard. We need to figure out
|
||||
# which libraries to link in. Most of the time it uses pthread
|
||||
#
|
||||
if {[gdb_compile_objc "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable [list debug ]] != "" } {
|
||||
gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail."
|
||||
}
|
||||
|
||||
#
|
||||
# Deduce language of main()
|
||||
#
|
||||
|
||||
proc deduce_language_of_main {} {
|
||||
global gdb_prompt
|
||||
|
||||
# See what language gdb thinks main() is, prior to reading full symbols.
|
||||
# I think this fails for COFF targets.
|
||||
send_gdb "show language\n"
|
||||
gdb_expect {
|
||||
-re ".* source language is \"auto; currently objective-c\".*$gdb_prompt $" {
|
||||
pass "deduced language is Objective-C, before full symbols"
|
||||
}
|
||||
-re ".*$gdb_prompt $" {
|
||||
fail "source language not correct for Objective-C (psymtabs only)"
|
||||
return
|
||||
}
|
||||
timeout {
|
||||
fail "can't show language (timeout)"
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
runto_main
|
||||
|
||||
# See if our idea of the language has changed.
|
||||
|
||||
send_gdb "show language\n"
|
||||
gdb_expect {
|
||||
-re ".* source language is \"auto; currently objective-c\".*$gdb_prompt $" {
|
||||
pass "deduced language is Objective-C, after full symbols"
|
||||
}
|
||||
-re ".*$gdb_prompt $" {
|
||||
fail "source language not correct for Objective-C (full symbols)"
|
||||
return
|
||||
}
|
||||
timeout {
|
||||
fail "can't show language (timeout)"
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
proc do_objc_tests {} {
|
||||
global prms_id
|
||||
global bug_id
|
||||
global subdir
|
||||
global objdir
|
||||
global srcdir
|
||||
global binfile
|
||||
global gdb_prompt
|
||||
|
||||
set prms_id 0
|
||||
set bug_id 0
|
||||
|
||||
# Start with a fresh gdb.
|
||||
|
||||
gdb_exit
|
||||
gdb_start
|
||||
gdb_reinitialize_dir $srcdir/$subdir
|
||||
gdb_load $binfile
|
||||
|
||||
deduce_language_of_main
|
||||
}
|
||||
|
||||
do_objc_tests
|
||||
|
||||
#
|
||||
# Breakpoint tests
|
||||
#
|
||||
gdb_test "break doIt" \
|
||||
"Breakpoint.*at.* file .*$srcfile, line.29.*" \
|
||||
"breakpoint method"
|
||||
|
||||
gdb_test "break takeArg:" \
|
||||
"Breakpoint.*at.* file .*$srcfile, line.34.*" \
|
||||
"breakpoint method with colon"
|
||||
|
||||
gdb_test "break newWithArg:" \
|
||||
"Breakpoint.*at.* file .*$srcfile, line.22.*" \
|
||||
"breakpoint class method with colon"
|
||||
|
||||
#
|
||||
# Continue until breakpoint (test re-setting breakpoint)
|
||||
#
|
||||
gdb_test continue \
|
||||
"Continuing\\..*Breakpoint \[0-9\]+, -.BasicClass takeArg:. \\(self=.*, _cmd=.*, arg=.*\\) at .*$srcfile:34.*" \
|
||||
"continue until method breakpoint"
|
||||
|
||||
#
|
||||
# Test resetting breakpoints when re-running program
|
||||
#
|
||||
send_gdb "run\n"
|
||||
gdb_expect {
|
||||
-re "The program .* has been started already.*y or n. $" {
|
||||
send_gdb "y\n"
|
||||
exp_continue
|
||||
}
|
||||
-re "Starting program.*Breakpoint \[0-9\]+,.*main .*argc.*argv.* at .*$srcfile:.*$gdb_prompt $"\
|
||||
{ pass "resetting breakpoints when rerunning" }
|
||||
-re ".*$gdb_prompt $" { fail "resetting breakpoints when rerunning" }
|
||||
timeout { fail "resetting breakpoints when rerunning" }
|
||||
}
|
||||
|
||||
#
|
||||
# Continue until breakpoint (test re-setting breakpoint)
|
||||
#
|
||||
gdb_test continue \
|
||||
"Continuing\\..*Breakpoint \[0-9\]+, -.BasicClass takeArg:. \\(self=.*, _cmd=.*, arg=.*\\) at .*$srcfile:34.*" \
|
||||
"continue until method breakpoint"
|
||||
|
||||
#
|
||||
# Test printing objects
|
||||
#
|
||||
gdb_test "print object" \
|
||||
"\\$\[0-9\] = .*0x0" \
|
||||
" print an ivar of self"
|
||||
|
||||
gdb_test "print self" \
|
||||
"\\$\[0-9\] = \\(.*BasicClass \\*\\) 0x\[0-9a-f\]+" \
|
||||
" print self"
|
||||
|
||||
gdb_test "print \*self" \
|
||||
"\\$\[0-9\] = \{isa = 0x\[0-9a-f\]+, object = 0x0\}" \
|
||||
" print contents of self"
|
||||
|
||||
#
|
||||
# Break in a category
|
||||
#
|
||||
gdb_test "break hiddenMethod" \
|
||||
"Breakpoint.*at.* file .*$srcfile, line.61." \
|
||||
"breakpoint in category method"
|
||||
|
||||
|
||||
#
|
||||
# Continue until breakpoint (test re-setting category breakpoint)
|
||||
#
|
||||
gdb_test continue \
|
||||
"Continuing\\..*Breakpoint \[0-9\]+, -.BasicClass\\(Private\\) hiddenMethod. \\(self=.*, _cmd=.*\\) at .*$srcfile:61.*" \
|
||||
"continue until category method"
|
||||
|
||||
#
|
||||
# Test calling Objective-C methods
|
||||
#
|
||||
gdb_test "print \[self printHi\]" \
|
||||
"Hi.*\\$\[0-9\] = \[0-9\]+" \
|
||||
"Call an Objective-C method with no arguments"
|
||||
|
||||
gdb_test "print \[self printNumber: 42\]" \
|
||||
"42.*\\$\[0-9\] = 43" \
|
||||
"Call an Objective-C method with one argument"
|
||||
|
||||
#
|
||||
# Test printing the object description
|
||||
#
|
||||
gdb_test "print-object object" \
|
||||
"BasicClass gdb test object" \
|
||||
"Use of the print-object command"
|
||||
|
||||
gdb_test "po self" \
|
||||
"BasicClass gdb test object" \
|
||||
"Use of the po (print-object) command"
|
||||
|
||||
|
81
gdb/testsuite/gdb.objc/basicclass.m
Normal file
81
gdb/testsuite/gdb.objc/basicclass.m
Normal file
@ -0,0 +1,81 @@
|
||||
#include <objc/Object.h>
|
||||
|
||||
@interface BasicClass: Object
|
||||
{
|
||||
id object;
|
||||
}
|
||||
+ newWithArg: arg;
|
||||
- doIt;
|
||||
- takeArg: arg;
|
||||
- printHi;
|
||||
- (int) printNumber: (int)number;
|
||||
- (const char *) myDescription;
|
||||
@end
|
||||
|
||||
@interface BasicClass (Private)
|
||||
- hiddenMethod;
|
||||
@end
|
||||
|
||||
@implementation BasicClass
|
||||
+ newWithArg: arg
|
||||
{
|
||||
id obj = [self new];
|
||||
[obj takeArg: arg];
|
||||
return obj;
|
||||
}
|
||||
|
||||
- doIt
|
||||
{
|
||||
return self;
|
||||
}
|
||||
|
||||
- takeArg: arg
|
||||
{
|
||||
object = arg;
|
||||
[self hiddenMethod];
|
||||
return self;
|
||||
}
|
||||
|
||||
- printHi
|
||||
{
|
||||
printf("Hi\n");
|
||||
return self;
|
||||
}
|
||||
|
||||
- (int) printNumber: (int)number
|
||||
{
|
||||
printf("%d\n", number);
|
||||
return number+1;
|
||||
}
|
||||
|
||||
- (const char *) myDescription
|
||||
{
|
||||
return "BasicClass gdb test object";
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@implementation BasicClass (Private)
|
||||
- hiddenMethod
|
||||
{
|
||||
return self;
|
||||
}
|
||||
@end
|
||||
|
||||
int main (int argc, const char *argv[])
|
||||
{
|
||||
id obj;
|
||||
obj = [BasicClass new];
|
||||
[obj takeArg: obj];
|
||||
return 0;
|
||||
}
|
||||
|
||||
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)])
|
||||
return [object myDescription];
|
||||
|
||||
return NULL;
|
||||
}
|
@ -1283,6 +1283,46 @@ proc gdb_compile_pthreads {source dest type options} {
|
||||
}
|
||||
}
|
||||
|
||||
# This is just like gdb_compile_pthreads, above, except that we always add the
|
||||
# objc library for compiling Objective-C programs
|
||||
proc gdb_compile_objc {source dest type options} {
|
||||
set built_binfile 0
|
||||
set why_msg "unrecognized error"
|
||||
foreach lib {-lobjc -lpthreads -lpthread -lthread solaris} {
|
||||
# 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 options_with_lib [concat $options [list libs=$lib quiet]]
|
||||
set ccout [gdb_compile $source $dest $type $options_with_lib]
|
||||
switch -regexp -- $ccout {
|
||||
".*no posix threads support.*" {
|
||||
set why_msg "missing threads include file"
|
||||
break
|
||||
}
|
||||
".*cannot open -lpthread.*" {
|
||||
set why_msg "missing runtime threads library"
|
||||
}
|
||||
".*Can't find library for -lpthread.*" {
|
||||
set why_msg "missing runtime threads library"
|
||||
}
|
||||
{^$} {
|
||||
pass "successfully compiled objc with posix threads test case"
|
||||
set built_binfile 1
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
if {!$built_binfile} {
|
||||
unsupported "Couldn't compile $source: ${why_msg}"
|
||||
return -1
|
||||
}
|
||||
}
|
||||
|
||||
proc send_gdb { string } {
|
||||
global suppress_flag;
|
||||
if { $suppress_flag } {
|
||||
|
Loading…
Reference in New Issue
Block a user