Don't convert R_SPARC_32 to R_SPARC_RELATIVE if class is ELFCLASS64.
[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
82075af2 22if { ![isnative] } then {
fbbe92c5
SDJ
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
82075af2
JS
325proc test_catch_syscall_execve {} {
326 global gdb_prompt decimal
327
328 with_test_prefix "execve" {
329
330 # Tell the test program we want an execve.
331 gdb_test_no_output "set do_execve = 1"
332
333 # Check for entry/return across the execve, making sure that the
334 # syscall_state isn't lost when turning into a new process.
335 insert_catch_syscall_with_arg "execve"
336 check_continue "execve"
337
338 # Continue to main so extended-remote can read files as needed.
339 # (Otherwise that "Reading" output confuses gdb_continue_to_end.)
340 gdb_continue "main"
341
342 # Now can we finish?
343 check_for_program_end
344 }
345}
346
bccd0dd2 347proc test_catch_syscall_fail_nodatadir {} {
eb4ca471 348 with_test_prefix "fail no datadir" {
eb4ca471
PA
349 # Sanitizing.
350 delete_breakpoints
bccd0dd2 351
eb4ca471
PA
352 # Make sure GDB doesn't load the syscalls xml from the system
353 # data directory.
8d551b02
DE
354 gdb_test "set data-directory /the/path/to/nowhere" \
355 "Warning: /the/path/to/nowhere: .*"
fc30d5e0 356
eb4ca471
PA
357 # Testing to see if we receive a warning when calling "catch
358 # syscall" without XML support (without datadir).
359 set thistest "catch syscall displays a warning when there is no XML support"
360 gdb_test "catch syscall" \
361 "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).*" \
362 $thistest
bccd0dd2 363
eb4ca471
PA
364 # Since the catchpoint was set, we must check if it's present
365 # in "info breakpoints" output.
366 check_info_bp_any_syscall
bccd0dd2 367
eb4ca471
PA
368 # Sanitizing.
369 delete_breakpoints
370 }
bccd0dd2
SDJ
371}
372
fbbe92c5 373proc do_syscall_tests {} {
aae1c79a
DE
374 # NOTE: We don't have to point gdb at the correct data-directory.
375 # For the build tree that is handled by INTERNAL_GDBFLAGS.
fbbe92c5
SDJ
376
377 # Verify that the 'catch syscall' help is available
378 set thistest "help catch syscall"
379 gdb_test "help catch syscall" "Catch system calls.*" $thistest
380
381 # Try to set a catchpoint to a nonsense syscall
382 set thistest "catch syscall to a nonsense syscall is prohibited"
383 gdb_test "catch syscall nonsense_syscall" "Unknown syscall name .*" $thistest
384
b45627a0
TT
385 # Regression test for syscall completer bug.
386 gdb_test "complete catch syscall close chroo" \
387 "catch syscall close chroot" \
388 "complete catch syscall with multiple words"
389
fbbe92c5
SDJ
390 # Testing the 'catch syscall' command without arguments.
391 # This test should catch any syscalls.
392 if [runto_main] then { test_catch_syscall_without_args }
393
394 # Testing the 'catch syscall' command with arguments.
395 # This test should only catch the specified syscall.
396 if [runto_main] then { test_catch_syscall_with_args }
397
398 # Testing the 'catch syscall' command with many arguments.
399 # This test should catch $all_syscalls.
400 if [runto_main] then { test_catch_syscall_with_many_args }
401
402 # Testing the 'catch syscall' command with WRONG arguments.
403 # This test should not trigger any catchpoints.
404 if [runto_main] then { test_catch_syscall_with_wrong_args }
405
bfd09d20 406 # Testing the 'catch syscall' command during a restart of
fbbe92c5
SDJ
407 # the inferior.
408 if [runto_main] then { test_catch_syscall_restarting_inferior }
458c8db8 409
bfd09d20
JS
410 # Testing the 'catch syscall' command toggling off past a
411 # syscall return, then resuming entry/return as normal.
412 if [runto_main] then { test_catch_syscall_skipping_return }
413
414 # Testing the 'catch syscall' command starting mid-vfork.
415 if [runto_main] then { test_catch_syscall_mid_vfork }
416
82075af2
JS
417 # Testing that 'catch syscall' entry/return tracks across execve.
418 if [runto_main] then { test_catch_syscall_execve }
419
458c8db8
SDJ
420 # Testing if the 'catch syscall' command works when switching to
421 # different architectures on-the-fly (PR gdb/10737).
422 if [runto_main] then { test_catch_syscall_multi_arch }
fbbe92c5
SDJ
423}
424
fbbe92c5 425proc test_catch_syscall_without_args_noxml {} {
eb4ca471
PA
426 with_test_prefix "without args noxml" {
427 # We will need the syscall names even not using it because we
428 # need to know know many syscalls are in the example file.
bfd09d20 429 global decimal all_syscalls last_syscall_number unknown_syscall_number all_syscalls_numbers
eb4ca471
PA
430
431 delete_breakpoints
432
433 gdb_test "catch syscall" "Catchpoint .*(syscall).*"
434
435 # Now, we should be able to set a catchpoint, and GDB shall
436 # not display the warning anymore.
2e0d821f 437 foreach name $all_syscalls number $all_syscalls_numbers {
eb4ca471 438 with_test_prefix "$name" {
2e0d821f 439 check_continue $number
eb4ca471
PA
440 }
441 }
442
bfd09d20
JS
443 check_continue "vfork" $decimal
444
445 with_test_prefix "ENOSYS" {
446 check_continue $unknown_syscall_number
447 }
448
eb4ca471
PA
449 # At last but not least, we check if the inferior has called
450 # the last (exit) syscall.
2e0d821f 451 check_call_to_syscall $last_syscall_number
eb4ca471
PA
452
453 delete_breakpoints
fbbe92c5 454 }
fbbe92c5
SDJ
455}
456
457proc test_catch_syscall_with_args_noxml {} {
eb4ca471 458 with_test_prefix "with args noxml" {
2e0d821f 459 global all_syscalls_numbers
fbbe92c5 460
eb4ca471 461 delete_breakpoints
fbbe92c5 462
2e0d821f
SDJ
463 # Inserting all syscalls numbers to be caught
464 foreach syscall_number $all_syscalls_numbers {
465 insert_catch_syscall_with_arg $syscall_number
466 }
fbbe92c5 467
2e0d821f
SDJ
468 # Checking that all syscalls are caught.
469 foreach syscall_number $all_syscalls_numbers {
470 check_continue $syscall_number
471 }
fbbe92c5 472
eb4ca471
PA
473 delete_breakpoints
474 }
fbbe92c5
SDJ
475}
476
477proc test_catch_syscall_with_wrong_args_noxml {} {
eb4ca471 478 with_test_prefix "with wrong args noxml" {
eb4ca471 479 delete_breakpoints
fbbe92c5 480
eb4ca471
PA
481 # Even without XML support, GDB should not accept unknown
482 # syscall names for the catchpoint.
483 gdb_test "catch syscall nonsense_syscall" \
484 "Unknown syscall name .nonsense_syscall.*"
fbbe92c5 485
eb4ca471
PA
486 delete_breakpoints
487 }
fbbe92c5
SDJ
488}
489
458c8db8
SDJ
490proc test_catch_syscall_multi_arch {} {
491 global decimal binfile
492
493 if { [istarget "i*86-*-*"] || [istarget "x86_64-*-*"] } {
494 set arch1 "i386"
495 set arch2 "i386:x86-64"
496 set syscall1_name "exit"
497 set syscall2_name "write"
498 set syscall_number 1
499 } elseif { [istarget "powerpc-*-linux*"] \
500 || [istarget "powerpc64-*-linux*"] } {
501 set arch1 "powerpc:common"
502 set arch2 "powerpc:common64"
503 set syscall1_name "openat"
504 set syscall2_name "unlinkat"
505 set syscall_number 286
506 } elseif { [istarget "sparc-*-linux*"] \
507 || [istarget "sparc64-*-linux*"] } {
508 set arch1 "sparc"
509 set arch2 "sparc:v9"
510 set syscall1_name "setresuid32"
511 set syscall2_name "setresuid"
512 set syscall_number 108
513 } elseif { [istarget "mips*-linux*"] } {
514 # MIPS does not use the same numbers for syscalls on 32 and 64
515 # bits.
516 verbose "Not testing MIPS for multi-arch syscall support"
517 return
518 } elseif { [istarget "arm*-linux*"] } {
519 # catch syscall supports only 32-bit ARM for now.
520 verbose "Not testing ARM for multi-arch syscall support"
521 return
f68f11b7 522 } elseif { [istarget "aarch64*-linux*"] } {
fbd8d50d
YQ
523 set arch1 "aarch64"
524 set arch2 "arm"
525 set syscall1_name "reboot"
526 set syscall2_name "_newselect"
527 set syscall_number 142
458c8db8 528 } elseif { [istarget "s390*-linux*"] } {
6d74a497 529 set arch1 "s390:31-bit"
458c8db8
SDJ
530 set arch2 "s390:64-bit"
531 set syscall1_name "_newselect"
532 set syscall2_name "select"
533 set syscall_number 142
534 }
535
536 with_test_prefix "multiple targets" {
537 # We are not interested in loading any binary here, and in
538 # some systems (PowerPC, for example), if we load a binary
539 # there is no way to set other architecture.
540 gdb_exit
541 gdb_start
542
543 gdb_test "set architecture $arch1" \
544 "The target architecture is assumed to be $arch1" \
545 "set arch to $arch1"
546
547 gdb_test "catch syscall $syscall_number" \
548 "Catchpoint $decimal \\(syscall .${syscall1_name}. \\\[${syscall_number}\\\]\\)" \
549 "insert catch syscall on syscall $syscall_number -- $syscall1_name on $arch1"
550
551 gdb_test "set architecture $arch2" \
552 "The target architecture is assumed to be $arch2" \
553 "set arch to $arch2"
554
555 gdb_test "catch syscall $syscall_number" \
556 "Catchpoint $decimal \\(syscall .${syscall2_name}. \\\[${syscall_number}\\\]\\)" \
557 "insert catch syscall on syscall $syscall_number -- $syscall2_name on $arch2"
558
559 clean_restart $binfile
560 }
561}
562
fbbe92c5 563proc do_syscall_tests_without_xml {} {
fc30d5e0
PA
564 # Make sure GDB doesn't load the syscalls xml from the system data
565 # directory.
8d551b02
DE
566 gdb_test "set data-directory /the/path/to/nowhere" \
567 "Warning: /the/path/to/nowhere: .*"
fbbe92c5 568
bccd0dd2 569 # Let's test if we can catch syscalls without XML support.
fbbe92c5
SDJ
570 # We should succeed, but GDB is not supposed to print syscall names.
571 if [runto_main] then { test_catch_syscall_without_args_noxml }
572
573 # The only valid argument "catch syscall" should accept is the
574 # syscall number, and not the name (since it can't translate a
575 # name to a number).
fbbe92c5
SDJ
576 if [runto_main] then { test_catch_syscall_with_args_noxml }
577
578 # Now, we'll try to provide a syscall name (valid or not) to the command,
579 # and expect it to fail.
580 if [runto_main] then { test_catch_syscall_with_wrong_args_noxml }
581}
582
583# This procedure fills the vector "all_syscalls_numbers" with the proper
584# numbers for the used syscalls according to the architecture.
585proc fill_all_syscalls_numbers {} {
bfd09d20 586 global all_syscalls_numbers last_syscall_number unknown_syscall_number all_syscalls
4924df79
GKB
587
588 foreach syscall $all_syscalls {
589 lappend all_syscalls_numbers [get_integer_valueof "${syscall}_syscall" -1]
590 }
fbbe92c5 591
2e0d821f 592 set last_syscall_number [get_integer_valueof "exit_group_syscall" -1]
bfd09d20 593 set unknown_syscall_number [get_integer_valueof "unknown_syscall" -1]
2e0d821f 594}
fbbe92c5 595
f68f11b7
YQ
596# Set up the vector all_syscalls.
597
598proc setup_all_syscalls {} {
599 global all_syscalls
600 global gdb_prompt
601
602 # They are ordered according to the file, so do not change this.
603 lappend all_syscalls "close"
604 lappend all_syscalls "chroot"
605
606 # SYS_pipe doesn't exist on aarch64 kernel.
607 set test "check SYS_pipe"
608 gdb_test_multiple "p pipe_syscall" $test {
609 -re " = .*$gdb_prompt $" {
610 pass $test
611 lappend all_syscalls "pipe"
612 }
613 -re "No symbol .*$gdb_prompt $" {
614 pass $test
615 # SYS_pipe isn't defined, use SYS_pipe2 instead.
616 lappend all_syscalls "pipe2"
617 }
618 }
619
620 lappend all_syscalls "write"
621 lappend all_syscalls "read"
622}
623
624setup_all_syscalls
625
2e0d821f
SDJ
626# Fill all the syscalls numbers before starting anything.
627fill_all_syscalls_numbers
fbbe92c5
SDJ
628
629# Execute the tests, using XML support
1e76a7e9 630gdb_exit
2e0d821f
SDJ
631if { ![gdb_skip_xml_test] } {
632 clean_restart $binfile
bccd0dd2
SDJ
633 do_syscall_tests
634
635 # Now, we have to see if GDB displays a warning when we
636 # don't set the data-directory but try to use catch syscall
637 # anyway. For that, we must restart GDB first.
2e0d821f 638 clean_restart $binfile
bccd0dd2
SDJ
639 test_catch_syscall_fail_nodatadir
640}
fbbe92c5
SDJ
641
642# Restart gdb
2e0d821f 643clean_restart $binfile
fbbe92c5
SDJ
644
645# Execute the tests, without XML support. In this case, GDB will
646# only display syscall numbers, and not syscall names.
647do_syscall_tests_without_xml
This page took 0.805231 seconds and 4 git commands to generate.