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