]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - gdb/testsuite/gdb.base/catch-syscall.exp
GDB copyright headers update after running GDB's copyright.py script.
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.base / catch-syscall.exp
CommitLineData
618f726f 1# Copyright 1997-2016 Free Software Foundation, Inc.
fbbe92c5
SDJ
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
17# This program tests the 'catch syscall' functionality.
18#
19# It was written by Sergio Durigan Junior <sergiodj@linux.vnet.ibm.com>
20# on September/2008.
21
22if { [is_remote target] || ![isnative] } then {
23 continue
24}
25
2d4e0376
YQ
26# This shall be updated whenever 'catch syscall' is implemented
27# on some architecture.
2d4e0376
YQ
28if { ![istarget "x86_64-*-linux*"] && ![istarget "i\[34567\]86-*-linux*"]
29 && ![istarget "powerpc-*-linux*"] && ![istarget "powerpc64-*-linux*"]
30 && ![istarget "sparc-*-linux*"] && ![istarget "sparc64-*-linux*"]
237b092b 31 && ![istarget "mips*-linux*"] && ![istarget "arm*-linux*"]
f68f11b7 32 && ![istarget "s390*-linux*"] && ![istarget "aarch64*-*-linux*"] } {
2d4e0376
YQ
33 continue
34}
fbbe92c5 35
f76495c8 36standard_testfile
fbbe92c5 37
2e0d821f
SDJ
38if { [prepare_for_testing ${testfile}.exp $testfile ${testfile}.c] } {
39 untested catch-syscall.exp
40 return -1
41}
42
f68f11b7
YQ
43# All (but the last) syscalls from the example code. It is filled in
44# proc setup_all_syscalls.
45set all_syscalls { }
fbbe92c5 46set all_syscalls_numbers { }
2e0d821f 47
fbbe92c5
SDJ
48# The last syscall (exit()) does not return, so
49# we cannot expect the catchpoint to be triggered
50# twice. It is a special case.
51set last_syscall "exit_group"
2e0d821f 52set last_syscall_number { }
fbbe92c5 53
bfd09d20
JS
54set vfork_syscalls "(vfork|clone2?)"
55
56set unknown_syscall_number { }
57
fbbe92c5
SDJ
58# Internal procedure used to check if, after issuing a 'catch syscall'
59# command (without arguments), the 'info breakpoints' command displays
60# that '"any syscall"' is to be caught.
61proc check_info_bp_any_syscall {} {
fbbe92c5
SDJ
62 # Verifying that the catchpoint appears in the 'info breakpoints'
63 # command, but with "<any syscall>".
64 set thistest "catch syscall appears in 'info breakpoints'"
65 gdb_test "info breakpoints" ".*catchpoint.*keep y.*syscall \"<any syscall>\".*" $thistest
66}
67
68# Internal procedure used to check if, after issuing a 'catch syscall X'
69# command (with arguments), the 'info breakpoints' command displays
70# that the syscall 'X' is to be caught.
71proc check_info_bp_specific_syscall { syscall } {
fbbe92c5
SDJ
72 set thistest "syscall(s) $syscall appears in 'info breakpoints'"
73 gdb_test "info breakpoints" ".*catchpoint.*keep y.*syscall(\[(\]s\[)\])? (.)?${syscall}(.)?.*" $thistest
74}
75
76# Internal procedure used to check if, after issuing a 'catch syscall X'
77# command (with many arguments), the 'info breakpoints' command displays
78# that the syscalls 'X' are to be caught.
79proc check_info_bp_many_syscalls { syscalls } {
fbbe92c5
SDJ
80 set filter_str ""
81
82 foreach name $syscalls {
83 set filter_str "${filter_str}${name}, "
84 }
85
86 set filter_str [ string trimright $filter_str ", " ]
87
88 set thistest "syscalls $filter_str appears in 'info breakpoints'"
89 gdb_test "info breakpoints" ".*catchpoint.*keep y.*syscalls (.)?${filter_str}(.)?.*" $thistest
90}
91
bfd09d20
JS
92# This procedure checks if there was a call to a syscall. The optional
93# pattern can match syscalls that vary in implementation, like vfork.
94proc check_call_to_syscall { syscall { pattern "" } } {
2e0d821f 95 global decimal
fbbe92c5 96
bfd09d20
JS
97 if { $pattern eq "" } {
98 set pattern "${syscall}"
99 }
100
fbbe92c5 101 set thistest "program has called $syscall"
bfd09d20 102 gdb_test "continue" "Catchpoint $decimal \\(call to syscall .?${pattern}.?\\).*" $thistest
fbbe92c5
SDJ
103}
104
bfd09d20
JS
105# This procedure checks if the syscall returned. The optional pattern
106# can match syscalls that vary in implementation, like vfork.
107proc check_return_from_syscall { syscall { pattern "" } } {
2e0d821f 108 global decimal
fbbe92c5 109
bfd09d20
JS
110 if { $pattern eq "" } {
111 set pattern "${syscall}"
112 }
113
fbbe92c5 114 set thistest "syscall $syscall has returned"
bfd09d20 115 gdb_test "continue" "Catchpoint $decimal \\(returned from syscall ${pattern}\\).*" $thistest
fbbe92c5
SDJ
116}
117
118# Internal procedure that performs two 'continue' commands and checks if
bfd09d20
JS
119# a syscall call AND return occur. The optional pattern can match
120# syscalls that vary in implementation, like vfork.
121proc check_continue { syscall { pattern "" } } {
fbbe92c5
SDJ
122 # Testing if the 'continue' stops at the
123 # specified syscall_name. If it does, then it should
124 # first print that the infeior has called the syscall,
125 # and after print that the syscall has returned.
126
e03f9645 127 # Testing if the inferior has called the syscall.
bfd09d20 128 check_call_to_syscall $syscall $pattern
fbbe92c5 129 # And now, that the syscall has returned.
bfd09d20 130 check_return_from_syscall $syscall $pattern
fbbe92c5
SDJ
131}
132
133# Inserts a syscall catchpoint with an argument.
134proc insert_catch_syscall_with_arg { syscall } {
2e0d821f 135 global decimal
fbbe92c5
SDJ
136
137 # Trying to set the catchpoint
138 set thistest "catch syscall with arguments ($syscall)"
2e0d821f 139 gdb_test "catch syscall $syscall" "Catchpoint $decimal \\(syscall \'?${syscall}\'?( \[${decimal}\])?\\)" $thistest
fbbe92c5
SDJ
140
141 check_info_bp_specific_syscall $syscall
142}
143
144# Inserts a syscall catchpoint with many arguments.
145proc insert_catch_syscall_with_many_args { syscalls numbers } {
2e0d821f
SDJ
146 global decimal
147
fbbe92c5
SDJ
148 set catch [ join $syscalls " " ]
149 set filter_str ""
150
151 foreach name $syscalls number $numbers {
2e0d821f 152 set filter_str "${filter_str}'${name}' \\\[${number}\\\] "
fbbe92c5
SDJ
153 }
154
155 set filter_str [ string trimright $filter_str " " ]
156
157 # Trying to set the catchpoint
158 set thistest "catch syscall with arguments ($filter_str)"
2e0d821f 159 gdb_test "catch syscall $catch" "Catchpoint $decimal \\(syscalls ${filter_str}\\).*" $thistest
fbbe92c5
SDJ
160
161 check_info_bp_many_syscalls $syscalls
162}
163
164proc check_for_program_end {} {
fbbe92c5
SDJ
165 # Deleting the catchpoints
166 delete_breakpoints
167
fda326dd 168 gdb_continue_to_end
fbbe92c5
SDJ
169}
170
171proc test_catch_syscall_without_args {} {
bfd09d20 172 global all_syscalls last_syscall vfork_syscalls unknown_syscall_number decimal
fbbe92c5 173
eb4ca471
PA
174 with_test_prefix "without arguments" {
175 # Trying to set the syscall.
2e0d821f 176 gdb_test "catch syscall" "Catchpoint $decimal \\(any syscall\\)"
fbbe92c5 177
eb4ca471 178 check_info_bp_any_syscall
fbbe92c5 179
eb4ca471
PA
180 # We have to check every syscall.
181 foreach name $all_syscalls {
182 check_continue $name
183 }
fbbe92c5 184
bfd09d20
JS
185 check_continue "vfork" $vfork_syscalls
186
187 with_test_prefix "ENOSYS" {
188 check_continue $unknown_syscall_number
189 }
190
eb4ca471
PA
191 # At last but not least, we check if the inferior has called
192 # the last (exit) syscall.
193 check_call_to_syscall $last_syscall
fbbe92c5 194
eb4ca471
PA
195 # Now let's see if the inferior correctly finishes.
196 check_for_program_end
197 }
fbbe92c5
SDJ
198}
199
200proc test_catch_syscall_with_args {} {
eb4ca471 201 with_test_prefix "with arguments" {
eb4ca471
PA
202 set syscall_name "close"
203 insert_catch_syscall_with_arg $syscall_name
fbbe92c5 204
eb4ca471
PA
205 # Can we continue until we catch the syscall?
206 check_continue $syscall_name
fbbe92c5 207
eb4ca471
PA
208 # Now let's see if the inferior correctly finishes.
209 check_for_program_end
210 }
fbbe92c5
SDJ
211}
212
213proc test_catch_syscall_with_many_args {} {
eb4ca471 214 with_test_prefix "with many arguments" {
2e0d821f 215 global all_syscalls all_syscalls_numbers
fbbe92c5 216
eb4ca471 217 insert_catch_syscall_with_many_args $all_syscalls $all_syscalls_numbers
fbbe92c5 218
eb4ca471
PA
219 # Can we continue until we catch the syscalls?
220 foreach name $all_syscalls {
221 check_continue $name
222 }
fbbe92c5 223
eb4ca471
PA
224 # Now let's see if the inferior correctly finishes.
225 check_for_program_end
226 }
fbbe92c5
SDJ
227}
228
229proc test_catch_syscall_with_wrong_args {} {
eb4ca471 230 with_test_prefix "wrong args" {
eb4ca471
PA
231 # mlock is not called from the source
232 set syscall_name "mlock"
233 insert_catch_syscall_with_arg $syscall_name
234
235 # Now, we must verify if the program stops with a continue.
236 # If it doesn't, everything is right (since we don't have
237 # a syscall named "mlock" in it). Otherwise, this is a failure.
238 set thistest "catch syscall with unused syscall ($syscall_name)"
239 gdb_continue_to_end $thistest
240 }
fbbe92c5
SDJ
241}
242
243proc test_catch_syscall_restarting_inferior {} {
eb4ca471 244 with_test_prefix "restarting inferior" {
eb4ca471 245 set syscall_name "chroot"
fbbe92c5 246
eb4ca471
PA
247 with_test_prefix "entry" {
248 insert_catch_syscall_with_arg $syscall_name
fbbe92c5 249
eb4ca471
PA
250 # Let's first reach the entry of the syscall.
251 check_call_to_syscall $syscall_name
252 }
fbbe92c5 253
eb4ca471
PA
254 with_test_prefix "entry/return" {
255 # Now, restart the program.
256 rerun_to_main
fbbe92c5 257
eb4ca471
PA
258 # And check for entry/return.
259 check_continue $syscall_name
fbbe92c5 260
eb4ca471
PA
261 # Can we finish?
262 check_for_program_end
263 }
264 }
fbbe92c5
SDJ
265}
266
bfd09d20
JS
267proc test_catch_syscall_skipping_return {} {
268 with_test_prefix "skipping return" {
269 with_test_prefix "entry" {
270 set syscall_name "write"
271
272 insert_catch_syscall_with_arg $syscall_name
273
274 # Let's first reach the entry of the syscall.
275 check_call_to_syscall $syscall_name
276
277 # Now purposely skip the syscall return.
278 delete_breakpoints
279 gdb_test "stepi" ".*" "step over syscall return"
280 }
281
282 # With a naive entry/return toggle, gdb will still think
283 # the target is due for a syscall return.
284
285 with_test_prefix "entry/return" {
286 set syscall_name "read"
287
288 insert_catch_syscall_with_arg $syscall_name
289
290 # Check for entry first, then return.
291 check_continue $syscall_name
292
293 # Can we finish?
294 check_for_program_end
295 }
296 }
297}
298
299proc test_catch_syscall_mid_vfork {} {
300 global gdb_prompt decimal vfork_syscalls
301
302 with_test_prefix "mid-vfork" {
303 # Verify that the system supports "catch vfork".
304 gdb_test "catch vfork" "Catchpoint $decimal \\(vfork\\)" "insert first vfork catchpoint"
305 gdb_test_multiple "continue" "continue to first vfork catchpoint" {
306 -re ".*Your system does not support this type\r\nof catchpoint.*$gdb_prompt $" {
307 unsupported "continue to first vfork catchpoint"
308 return
309 }
310 -re ".*Catchpoint $decimal \\(vforked process $decimal\\).*$gdb_prompt $" {
311 pass "continue to first vfork catchpoint"
312 }
313 }
314
315 # Check that we now reach vfork return only.
316 # (The actual syscall used varies by architecture.)
317 gdb_test "catch syscall" "Catchpoint $decimal \\(any syscall\\)"
318 check_return_from_syscall "vfork" $vfork_syscalls
319
320 # Can we finish?
321 check_for_program_end
322 }
323}
324
bccd0dd2 325proc test_catch_syscall_fail_nodatadir {} {
eb4ca471 326 with_test_prefix "fail no datadir" {
eb4ca471
PA
327 # Sanitizing.
328 delete_breakpoints
bccd0dd2 329
eb4ca471
PA
330 # Make sure GDB doesn't load the syscalls xml from the system
331 # data directory.
8d551b02
DE
332 gdb_test "set data-directory /the/path/to/nowhere" \
333 "Warning: /the/path/to/nowhere: .*"
fc30d5e0 334
eb4ca471
PA
335 # Testing to see if we receive a warning when calling "catch
336 # syscall" without XML support (without datadir).
337 set thistest "catch syscall displays a warning when there is no XML support"
338 gdb_test "catch syscall" \
339 "warning: Could not load the syscall XML file.*warning: GDB will not be able to display syscall names nor to verify if.*any provided syscall numbers are valid.*Catchpoint .*(syscall).*" \
340 $thistest
bccd0dd2 341
eb4ca471
PA
342 # Since the catchpoint was set, we must check if it's present
343 # in "info breakpoints" output.
344 check_info_bp_any_syscall
bccd0dd2 345
eb4ca471
PA
346 # Sanitizing.
347 delete_breakpoints
348 }
bccd0dd2
SDJ
349}
350
fbbe92c5 351proc do_syscall_tests {} {
aae1c79a
DE
352 # NOTE: We don't have to point gdb at the correct data-directory.
353 # For the build tree that is handled by INTERNAL_GDBFLAGS.
fbbe92c5
SDJ
354
355 # Verify that the 'catch syscall' help is available
356 set thistest "help catch syscall"
357 gdb_test "help catch syscall" "Catch system calls.*" $thistest
358
359 # Try to set a catchpoint to a nonsense syscall
360 set thistest "catch syscall to a nonsense syscall is prohibited"
361 gdb_test "catch syscall nonsense_syscall" "Unknown syscall name .*" $thistest
362
b45627a0
TT
363 # Regression test for syscall completer bug.
364 gdb_test "complete catch syscall close chroo" \
365 "catch syscall close chroot" \
366 "complete catch syscall with multiple words"
367
fbbe92c5
SDJ
368 # Testing the 'catch syscall' command without arguments.
369 # This test should catch any syscalls.
370 if [runto_main] then { test_catch_syscall_without_args }
371
372 # Testing the 'catch syscall' command with arguments.
373 # This test should only catch the specified syscall.
374 if [runto_main] then { test_catch_syscall_with_args }
375
376 # Testing the 'catch syscall' command with many arguments.
377 # This test should catch $all_syscalls.
378 if [runto_main] then { test_catch_syscall_with_many_args }
379
380 # Testing the 'catch syscall' command with WRONG arguments.
381 # This test should not trigger any catchpoints.
382 if [runto_main] then { test_catch_syscall_with_wrong_args }
383
bfd09d20 384 # Testing the 'catch syscall' command during a restart of
fbbe92c5
SDJ
385 # the inferior.
386 if [runto_main] then { test_catch_syscall_restarting_inferior }
458c8db8 387
bfd09d20
JS
388 # Testing the 'catch syscall' command toggling off past a
389 # syscall return, then resuming entry/return as normal.
390 if [runto_main] then { test_catch_syscall_skipping_return }
391
392 # Testing the 'catch syscall' command starting mid-vfork.
393 if [runto_main] then { test_catch_syscall_mid_vfork }
394
458c8db8
SDJ
395 # Testing if the 'catch syscall' command works when switching to
396 # different architectures on-the-fly (PR gdb/10737).
397 if [runto_main] then { test_catch_syscall_multi_arch }
fbbe92c5
SDJ
398}
399
fbbe92c5 400proc test_catch_syscall_without_args_noxml {} {
eb4ca471
PA
401 with_test_prefix "without args noxml" {
402 # We will need the syscall names even not using it because we
403 # need to know know many syscalls are in the example file.
bfd09d20 404 global decimal all_syscalls last_syscall_number unknown_syscall_number all_syscalls_numbers
eb4ca471
PA
405
406 delete_breakpoints
407
408 gdb_test "catch syscall" "Catchpoint .*(syscall).*"
409
410 # Now, we should be able to set a catchpoint, and GDB shall
411 # not display the warning anymore.
2e0d821f 412 foreach name $all_syscalls number $all_syscalls_numbers {
eb4ca471 413 with_test_prefix "$name" {
2e0d821f 414 check_continue $number
eb4ca471
PA
415 }
416 }
417
bfd09d20
JS
418 check_continue "vfork" $decimal
419
420 with_test_prefix "ENOSYS" {
421 check_continue $unknown_syscall_number
422 }
423
eb4ca471
PA
424 # At last but not least, we check if the inferior has called
425 # the last (exit) syscall.
2e0d821f 426 check_call_to_syscall $last_syscall_number
eb4ca471
PA
427
428 delete_breakpoints
fbbe92c5 429 }
fbbe92c5
SDJ
430}
431
432proc test_catch_syscall_with_args_noxml {} {
eb4ca471 433 with_test_prefix "with args noxml" {
2e0d821f 434 global all_syscalls_numbers
fbbe92c5 435
eb4ca471 436 delete_breakpoints
fbbe92c5 437
2e0d821f
SDJ
438 # Inserting all syscalls numbers to be caught
439 foreach syscall_number $all_syscalls_numbers {
440 insert_catch_syscall_with_arg $syscall_number
441 }
fbbe92c5 442
2e0d821f
SDJ
443 # Checking that all syscalls are caught.
444 foreach syscall_number $all_syscalls_numbers {
445 check_continue $syscall_number
446 }
fbbe92c5 447
eb4ca471
PA
448 delete_breakpoints
449 }
fbbe92c5
SDJ
450}
451
452proc test_catch_syscall_with_wrong_args_noxml {} {
eb4ca471 453 with_test_prefix "with wrong args noxml" {
eb4ca471 454 delete_breakpoints
fbbe92c5 455
eb4ca471
PA
456 # Even without XML support, GDB should not accept unknown
457 # syscall names for the catchpoint.
458 gdb_test "catch syscall nonsense_syscall" \
459 "Unknown syscall name .nonsense_syscall.*"
fbbe92c5 460
eb4ca471
PA
461 delete_breakpoints
462 }
fbbe92c5
SDJ
463}
464
458c8db8
SDJ
465proc test_catch_syscall_multi_arch {} {
466 global decimal binfile
467
468 if { [istarget "i*86-*-*"] || [istarget "x86_64-*-*"] } {
469 set arch1 "i386"
470 set arch2 "i386:x86-64"
471 set syscall1_name "exit"
472 set syscall2_name "write"
473 set syscall_number 1
474 } elseif { [istarget "powerpc-*-linux*"] \
475 || [istarget "powerpc64-*-linux*"] } {
476 set arch1 "powerpc:common"
477 set arch2 "powerpc:common64"
478 set syscall1_name "openat"
479 set syscall2_name "unlinkat"
480 set syscall_number 286
481 } elseif { [istarget "sparc-*-linux*"] \
482 || [istarget "sparc64-*-linux*"] } {
483 set arch1 "sparc"
484 set arch2 "sparc:v9"
485 set syscall1_name "setresuid32"
486 set syscall2_name "setresuid"
487 set syscall_number 108
488 } elseif { [istarget "mips*-linux*"] } {
489 # MIPS does not use the same numbers for syscalls on 32 and 64
490 # bits.
491 verbose "Not testing MIPS for multi-arch syscall support"
492 return
493 } elseif { [istarget "arm*-linux*"] } {
494 # catch syscall supports only 32-bit ARM for now.
495 verbose "Not testing ARM for multi-arch syscall support"
496 return
f68f11b7 497 } elseif { [istarget "aarch64*-linux*"] } {
fbd8d50d
YQ
498 set arch1 "aarch64"
499 set arch2 "arm"
500 set syscall1_name "reboot"
501 set syscall2_name "_newselect"
502 set syscall_number 142
458c8db8 503 } elseif { [istarget "s390*-linux*"] } {
6d74a497 504 set arch1 "s390:31-bit"
458c8db8
SDJ
505 set arch2 "s390:64-bit"
506 set syscall1_name "_newselect"
507 set syscall2_name "select"
508 set syscall_number 142
509 }
510
511 with_test_prefix "multiple targets" {
512 # We are not interested in loading any binary here, and in
513 # some systems (PowerPC, for example), if we load a binary
514 # there is no way to set other architecture.
515 gdb_exit
516 gdb_start
517
518 gdb_test "set architecture $arch1" \
519 "The target architecture is assumed to be $arch1" \
520 "set arch to $arch1"
521
522 gdb_test "catch syscall $syscall_number" \
523 "Catchpoint $decimal \\(syscall .${syscall1_name}. \\\[${syscall_number}\\\]\\)" \
524 "insert catch syscall on syscall $syscall_number -- $syscall1_name on $arch1"
525
526 gdb_test "set architecture $arch2" \
527 "The target architecture is assumed to be $arch2" \
528 "set arch to $arch2"
529
530 gdb_test "catch syscall $syscall_number" \
531 "Catchpoint $decimal \\(syscall .${syscall2_name}. \\\[${syscall_number}\\\]\\)" \
532 "insert catch syscall on syscall $syscall_number -- $syscall2_name on $arch2"
533
534 clean_restart $binfile
535 }
536}
537
fbbe92c5 538proc do_syscall_tests_without_xml {} {
fc30d5e0
PA
539 # Make sure GDB doesn't load the syscalls xml from the system data
540 # directory.
8d551b02
DE
541 gdb_test "set data-directory /the/path/to/nowhere" \
542 "Warning: /the/path/to/nowhere: .*"
fbbe92c5 543
bccd0dd2 544 # Let's test if we can catch syscalls without XML support.
fbbe92c5
SDJ
545 # We should succeed, but GDB is not supposed to print syscall names.
546 if [runto_main] then { test_catch_syscall_without_args_noxml }
547
548 # The only valid argument "catch syscall" should accept is the
549 # syscall number, and not the name (since it can't translate a
550 # name to a number).
fbbe92c5
SDJ
551 if [runto_main] then { test_catch_syscall_with_args_noxml }
552
553 # Now, we'll try to provide a syscall name (valid or not) to the command,
554 # and expect it to fail.
555 if [runto_main] then { test_catch_syscall_with_wrong_args_noxml }
556}
557
558# This procedure fills the vector "all_syscalls_numbers" with the proper
559# numbers for the used syscalls according to the architecture.
560proc fill_all_syscalls_numbers {} {
bfd09d20 561 global all_syscalls_numbers last_syscall_number unknown_syscall_number all_syscalls
4924df79
GKB
562
563 foreach syscall $all_syscalls {
564 lappend all_syscalls_numbers [get_integer_valueof "${syscall}_syscall" -1]
565 }
fbbe92c5 566
2e0d821f 567 set last_syscall_number [get_integer_valueof "exit_group_syscall" -1]
bfd09d20 568 set unknown_syscall_number [get_integer_valueof "unknown_syscall" -1]
2e0d821f 569}
fbbe92c5 570
f68f11b7
YQ
571# Set up the vector all_syscalls.
572
573proc setup_all_syscalls {} {
574 global all_syscalls
575 global gdb_prompt
576
577 # They are ordered according to the file, so do not change this.
578 lappend all_syscalls "close"
579 lappend all_syscalls "chroot"
580
581 # SYS_pipe doesn't exist on aarch64 kernel.
582 set test "check SYS_pipe"
583 gdb_test_multiple "p pipe_syscall" $test {
584 -re " = .*$gdb_prompt $" {
585 pass $test
586 lappend all_syscalls "pipe"
587 }
588 -re "No symbol .*$gdb_prompt $" {
589 pass $test
590 # SYS_pipe isn't defined, use SYS_pipe2 instead.
591 lappend all_syscalls "pipe2"
592 }
593 }
594
595 lappend all_syscalls "write"
596 lappend all_syscalls "read"
597}
598
599setup_all_syscalls
600
2e0d821f
SDJ
601# Fill all the syscalls numbers before starting anything.
602fill_all_syscalls_numbers
fbbe92c5
SDJ
603
604# Execute the tests, using XML support
1e76a7e9 605gdb_exit
2e0d821f
SDJ
606if { ![gdb_skip_xml_test] } {
607 clean_restart $binfile
bccd0dd2
SDJ
608 do_syscall_tests
609
610 # Now, we have to see if GDB displays a warning when we
611 # don't set the data-directory but try to use catch syscall
612 # anyway. For that, we must restart GDB first.
2e0d821f 613 clean_restart $binfile
bccd0dd2
SDJ
614 test_catch_syscall_fail_nodatadir
615}
fbbe92c5
SDJ
616
617# Restart gdb
2e0d821f 618clean_restart $binfile
fbbe92c5
SDJ
619
620# Execute the tests, without XML support. In this case, GDB will
621# only display syscall numbers, and not syscall names.
622do_syscall_tests_without_xml