Commit | Line | Data |
---|---|---|
61baf725 | 1 | # Copyright 2009-2017 Free Software Foundation, Inc. |
9107fc8d PA |
2 | |
3 | # This program is free software; you can redistribute it and/or modify | |
4 | # it under the terms of the GNU General Public License as published by | |
5 | # the Free Software Foundation; either version 3 of the License, or | |
6 | # (at your option) any later version. | |
7 | # | |
8 | # This program is distributed in the hope that it will be useful, | |
9 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
11 | # GNU General Public License for more details. | |
12 | # | |
13 | # You should have received a copy of the GNU General Public License | |
14 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | |
15 | ||
16 | # Test multi-exec / multi-process features that work for all configurations, | |
17 | # even ones that cannot run multiple processes simultaneously. | |
18 | ||
19 | set testfile "multi-arch-exec" | |
20 | ||
21 | # The plain remote target can't do multiple inferiors. | |
22 | if [target_info exists use_gdb_stub] { | |
23 | return | |
e780d813 DE |
24 | } |
25 | ||
26 | # The 64-bit compile may succeed for i386-linux, but gdb won't be able | |
27 | # to load the file. | |
28 | if [istarget "i?86-*linux*"] { | |
29 | return | |
9107fc8d PA |
30 | } |
31 | ||
32 | # Can't use standard_testfile, we want executables with specialized | |
33 | # names. | |
34 | set exec1 "multi-arch-exec" | |
35 | set srcfile1 multi-arch-exec.c | |
36 | set binfile1 [standard_output_file ${exec1}] | |
37 | ||
38 | set exec2 "multi-arch-exec-hello" | |
39 | set srcfile2 hello.c | |
40 | set binfile2 [standard_output_file ${exec2}] | |
41 | ||
42 | # Build two executables, one for each arch. | |
43 | ||
44 | if [istarget "s390*-*-*"] { | |
45 | set march1 "-m64" | |
46 | set march2 "-m31" | |
71be1fdc YQ |
47 | } elseif { [istarget "aarch64*-*-*"] } { |
48 | set march1 "" | |
49 | set march2 "" | |
9107fc8d PA |
50 | } else { |
51 | set march1 "-m64" | |
52 | set march2 "-m32" | |
53 | } | |
54 | ||
5b362f04 | 55 | if { [prepare_for_testing "failed to prepare" ${exec1} "${srcfile1}" \ |
cbd2b4e3 | 56 | [list debug pthreads \ |
31d913c7 | 57 | additional_flags=${march1}]] } { |
9107fc8d PA |
58 | return -1 |
59 | } | |
60 | ||
762f7747 | 61 | set options [list debug] |
71be1fdc YQ |
62 | |
63 | if { [istarget "aarch64*-*-*"] } { | |
64 | if {[info exists ARM_CC_FOR_TARGET]} { | |
65 | lappend options "compiler=${ARM_CC_FOR_TARGET}" | |
66 | } else { | |
67 | unsupported "ARM compiler is not known" | |
68 | return -1 | |
69 | } | |
70 | } else { | |
71 | lappend options "additional_flags=${march2}" | |
72 | } | |
73 | ||
5b362f04 | 74 | if { [prepare_for_testing "failed to prepare" ${exec2} "${srcfile2}" \ |
71be1fdc | 75 | $options] } { |
9107fc8d PA |
76 | return -1 |
77 | } | |
78 | ||
cbd2b4e3 | 79 | proc do_test { mode selected_thread } { |
ae780a21 SM |
80 | global exec1 |
81 | ||
82 | clean_restart ${exec1} | |
cbd2b4e3 PA |
83 | if ![runto all_started] then { |
84 | fail "couldn't run to all_started" | |
ae780a21 SM |
85 | return -1 |
86 | } | |
87 | ||
cbd2b4e3 PA |
88 | # Delete the breakpoint at 'all_started' otherwise GDB may |
89 | # switch context back to thread 1 to step over the breakpoint. | |
90 | delete_breakpoints | |
91 | ||
92 | # A location for this breakpoint should be found in the new | |
93 | # post-exec image too. | |
94 | gdb_breakpoint main | |
95 | ||
96 | gdb_test "thread $selected_thread" "Switching to thread $selected_thread .*" | |
97 | ||
ae780a21 SM |
98 | gdb_test_no_output "set follow-exec-mode $mode" |
99 | ||
100 | # Test that GDB updates the target description / arch successfuly | |
101 | # after the exec. | |
cbd2b4e3 | 102 | gdb_test "continue" "Breakpoint 2, main.*" "continue across exec that changes architecture" |
9107fc8d PA |
103 | } |
104 | ||
cbd2b4e3 PA |
105 | # Test handling the exec event with either the main thread or the |
106 | # second thread selected. This tries to ensure that GDB doesn't read | |
107 | # registers off of the execing thread before figuring out its | |
108 | # architecture. | |
109 | foreach_with_prefix selected_thread {1 2} { | |
110 | foreach_with_prefix follow_exec_mode {"same" "new"} { | |
111 | do_test $follow_exec_mode $selected_thread | |
112 | } | |
ae780a21 | 113 | } |