| # 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 Jason Molenda (jmolenda@apple.com) |
| |
| # This file tests the print-object command, ObjC syntax parsing, and |
| # inferior function calls. All in one nifty package! |
| |
| |
| if $tracelevel then { |
| strace $tracelevel |
| } |
| |
| set prms_id 0 |
| set bug_id 0 |
| |
| if [target_info exists noobjc64] { |
| verbose "Disable Objective-C tests on 64-bit PowerPC." |
| return |
| } |
| |
| set testfile "objc-prog" |
| set srcfile ${testfile}.m |
| set binfile ${objdir}/${subdir}/${testfile} |
| |
| if { [gdb_compile "${srcdir}/${subdir}/$srcfile" "${binfile}" executable {debug additional_flags=-framework\ Foundation}] != "" } { |
| gdb_suppress_entire_file "Testcase compile failed, so all tests in this fil |
| e will automatically fail." |
| } |
| |
| proc do_libsystem_checks { run_name } { |
| global decimal |
| global hex |
| global gdb_prompt |
| |
| # Fetch libSystem's load addr # shlib num. |
| |
| set libsystem_shlib_num -1 |
| set libsystem_load_addr -1 |
| |
| send_gdb "info sharedlibrary\n" |
| gdb_expect { |
| -re ".* ($decimal) libSystem.*libSystem.B.dylib at ($hex).*$gdb_prompt $" { |
| pass "get libSystem's shlib number and load addr $run_name" |
| set libsystem_shlib_num $expect_out(1,string) |
| set libsystem_load_addr $expect_out(2,string) |
| } |
| -re ".*$gdb_prompt $" { |
| fail "get libSystem's shlib number and load addr $run_name" |
| } |
| timeout { fail "get libSystem's shlib number and load addr $run_name (timeout)" } |
| } |
| |
| send_gdb "p printf\n" |
| gdb_expect { |
| -re ".*no debug info.. ($hex) .printf.*$gdb_prompt $" { |
| pass "get printf address $run_name" |
| set printf_addr $expect_out(1,string) |
| } |
| -re ".*$gdb_prompt $" { |
| fail "get printf address $run_name" |
| } |
| timeout { fail "get printf address $run_name (timeout)" } |
| } |
| |
| gdb_test "info sharedlibrary $printf_addr" \ |
| ".* $libsystem_shlib_num .*libSystem.*at $libsystem_load_addr.*" \ |
| "info sh addr at libSystem's load address $run_name" |
| |
| gdb_test "info sharedlibrary printf" \ |
| ".* $libsystem_shlib_num .*libSystem.*at $libsystem_load_addr.*" \ |
| "info sh symbolic-name at libSystem's load address $run_name" |
| |
| # Due to either an expect bug or a Panther bug, the following always fails. |
| # Do not ask me why. I spent far, far, far too much time trying to make it |
| # work. |
| |
| # set printf_address -1 |
| # send_gdb "p printf\n" |
| # gdb_expect { |
| # -re ".*text variable.* ($hex) .*printf.*$gdb_prompt $" { |
| # set printf_address $expect_out(1, string) |
| # pass "get address of printf () $run_name" |
| # } |
| # timeout { fail "get address of printf () $run_name (timeout)" } |
| # } |
| # gdb_test "info sharedlibrary $printf_address" \ |
| # ".* $libsystem_shlib_num .*libSystem.*at $libsystem_load_addr.*" \ |
| # "info sh addr at printf's address $run_name" |
| |
| # Due to either an expect bug or a Panther bug, the following always fails. |
| # Do not ask me why. I spent far, far, far too much time trying to make it |
| # work. |
| |
| # set errno_address -1 |
| # send_gdb "p &errno\n" |
| # gdb_expect { |
| # -re ".*data variable.* ($hex).*$gdb_prompt $" { |
| # pass "get address of errno $run_name" |
| # set errno_address $expect_out(1, string) |
| # } |
| # timeout { fail "get address of errno $run_name (timeout)" } |
| # } |
| # |
| # gdb_test "info sharedlibrary $errno_address" \ |
| # ".* $libsystem_shlib_num .*libSystem.*at $libsystem_load_addr.*" \ |
| # "info sh addr at errno's address $run_name" |
| |
| } |
| |
| |
| |
| # Start with a fresh gdb |
| |
| gdb_exit |
| gdb_start |
| gdb_reinitialize_dir $srcdir/$subdir |
| gdb_load ${binfile} |
| |
| # Pre-execution testing |
| |
| gdb_test "help info sharedlibrary" ".*Generic command for shlib infor.*info sharedlibrary ADDRESS. will show the dylib containing ADDRESS.*info sharedlibrary all.*" |
| |
| do_libsystem_checks "pre-execution" |
| |
| |
| if ![runto_main] then { |
| fail "info-sh-address tests suppressed" |
| return -1 |
| } |
| |
| gdb_test "info sharedlibrary 0x0" "\\\[unknown\\\]" |
| gdb_test "info sharedlibrary 0xffffffff" "\\\[unknown\\\]" |
| |
| gdb_exit |
| return 0 |