OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-old/] [gdb-7.1/] [gdb/] [testsuite/] [gdb.base/] [solib-overlap.exp] - Blame information for rev 833

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 227 jeremybenn
# Copyright 2009, 2010 Free Software Foundation, Inc.
2
# This program is free software; you can redistribute it and/or modify
3
# it under the terms of the GNU General Public License as published by
4
# the Free Software Foundation; either version 3 of the License, or
5
# (at your option) any later version.
6
#
7
# This program is distributed in the hope that it will be useful,
8
# but WITHOUT ANY WARRANTY; without even the implied warranty of
9
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
10
# GNU General Public License for more details.
11
#
12
# You should have received a copy of the GNU General Public License
13
# along with this program.  If not, see .
14
#
15
# Contributed by Jan Kratochvil .
16
 
17
# Test GDB can cope with two libraries loaded with overlapping VMA ranges.
18
# Prelink libraries first so they can be loaded and their native address.
19
# In such case `struct linkmap'.l_addr will be zero.  Provide different
20
# unprelinked library files on the disk which have zero-based VMAs.  These
21
# different files should have their .dynamic section at a different offset in
22
# page size so that we get for
23
#   warning: .dynamic section for "..." is not at the expected address
24
# the reason
25
#   (wrong library or version mismatch?)
26
# and not:
27
#   difference appears to be caused by prelink, adjusting expectations
28
# In such case both disk libraries will be loaded at VMAs starting at zero.
29
 
30
if [skip_shlib_tests] {
31
    return 0
32
}
33
 
34
# Are we on a target board?  It is required for attaching to a process.
35
if [is_remote target] {
36
    return 0
37
}
38
 
39
if [get_compiler_info binfile-unused] {
40
    return -1;
41
}
42
 
43
# Library file.
44
set libname "solib-overlap-lib"
45
set srcfile_lib ${srcdir}/${subdir}/${libname}.c
46
# Binary file.
47
set testfile "solib-overlap-main"
48
set srcfile ${srcdir}/${subdir}/${testfile}.c
49
 
50
# Base addresses for `prelink -r' which should be compatible with both -m32 and
51
# -m64 targets.  If it clashes with system prelinked libraries it would give
52
# false PASS.
53
# Prelink first lib1 at 0x40000000 and lib2 at 0x41000000.
54
# During second pass try lib1 at 0x50000000 and lib2 at 0x51000000.
55
foreach prelink_lib1 {0x40000000 0x50000000} {
56
    set prelink_lib2 [format "0x%x" [expr $prelink_lib1 + 0x01000000]]
57
 
58
    set old_prefix $pf_prefix
59
    lappend pf_prefix "$prelink_lib1:"
60
 
61
    # Library file.
62
    set binfile_lib1 ${objdir}/${subdir}/${libname}1-${prelink_lib1}.so
63
    set binfile_lib2 ${objdir}/${subdir}/${libname}2-${prelink_lib1}.so
64
    set lib_flags {debug}
65
    # Binary file.
66
    set binfile_base ${testfile}-${prelink_lib1}
67
    set binfile ${objdir}/${subdir}/${binfile_base}
68
    set bin_flags [list debug shlib=${binfile_lib1} shlib=${binfile_lib2}]
69
    set escapedbinfile  [string_to_regexp ${binfile}]
70
 
71
    if { [gdb_compile_shlib ${srcfile_lib} ${binfile_lib1} $lib_flags] != ""
72
         || [gdb_compile_shlib ${srcfile_lib} ${binfile_lib2} $lib_flags] != ""
73
         || [gdb_compile ${srcfile} ${binfile} executable $bin_flags] != "" } {
74
        untested "Could not compile ${binfile_lib1}, ${binfile_lib2} or ${binfile}."
75
        return -1
76
    }
77
 
78
    if {[catch "system \"prelink -N -r ${prelink_lib1} ${binfile_lib1}\""] != 0
79
        || [catch "system \"prelink -N -r ${prelink_lib2} ${binfile_lib2}\""] != 0} {
80
        # Maybe we don't have prelink.
81
        untested "Could not prelink ${binfile_lib1} or ${binfile_lib2}."
82
        return -1
83
    }
84
 
85
    # Start the program running and then wait for a bit, to be sure
86
    # that it can be attached to.
87
 
88
    set testpid [eval exec $binfile &]
89
    sleep 2
90
    if { [istarget "*-*-cygwin*"] } {
91
        # testpid is the Cygwin PID, GDB uses the Windows PID, which might be
92
        # different due to the way fork/exec works.
93
        set testpid [ exec ps -e | gawk "{ if (\$1 == $testpid) print \$4; }" ]
94
    }
95
 
96
    remote_exec build "mv -f ${binfile_lib1} ${binfile_lib1}-running"
97
    remote_exec build "mv -f ${binfile_lib2} ${binfile_lib2}-running"
98
 
99
    # Provide another exported function name to cause different sizes of sections.
100
    lappend lib_flags additional_flags=-DSYMB
101
 
102
    if { [gdb_compile_shlib ${srcfile_lib} ${binfile_lib1} $lib_flags] != ""
103
         || [gdb_compile_shlib ${srcfile_lib} ${binfile_lib2} $lib_flags] != ""} {
104
        untested "Could not recompile ${binfile_lib1} or ${binfile_lib2}."
105
        remote_exec build "kill -9 ${testpid}"
106
        return -1
107
    }
108
 
109
    clean_restart ${binfile_base}
110
    # This testcase currently does not support remote targets.
111
    # gdb_load_shlibs ${binfile_lib1} ${binfile_lib2}
112
 
113
    # Here we should get:
114
    # warning: .dynamic section for ".../solib-overlap-lib1.so" is not at the expected address (wrong library or version mismatch?)
115
    # warning: .dynamic section for ".../solib-overlap-lib2.so" is not at the expected address (wrong library or version mismatch?)
116
 
117
    set test attach
118
    gdb_test_multiple "attach $testpid" $test {
119
        -re "Attaching to program.*`?$escapedbinfile'?, process $testpid.*$gdb_prompt $" {
120
            pass $test
121
        }
122
        -re "Attaching to program.*`?$escapedbinfile\.exe'?, process $testpid.*\[Switching to thread $testpid\..*\].*$gdb_prompt $" {
123
            # Response expected on Cygwin
124
            pass $test
125
        }
126
    }
127
 
128
    # Detach the process.
129
 
130
    gdb_test "detach" "Detaching from program: .*$escapedbinfile, process $testpid"
131
 
132
    # Wait a bit for gdb to finish detaching
133
 
134
    sleep 5
135
 
136
    remote_exec build "kill -9 ${testpid}"
137
 
138
    set pf_prefix $old_prefix
139
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.