diff options
author | Sergio Durigan Junior <sergiodj@redhat.com> | 2009-09-15 03:30:08 +0000 |
---|---|---|
committer | Sergio Durigan Junior <sergiodj@redhat.com> | 2009-09-15 03:30:08 +0000 |
commit | a96d9b2e9a79e6cc7a9da9b4e5bab6fcc35f1eb4 (patch) | |
tree | 1dc43d29797720e241a05bb391872137805a0a44 /gdb/doc | |
parent | 22fe6da0f9e70167b759d4fe941beb2cf3f7a702 (diff) | |
download | gdb-a96d9b2e9a79e6cc7a9da9b4e5bab6fcc35f1eb4.zip gdb-a96d9b2e9a79e6cc7a9da9b4e5bab6fcc35f1eb4.tar.gz gdb-a96d9b2e9a79e6cc7a9da9b4e5bab6fcc35f1eb4.tar.bz2 |
Implementing catch syscall.
* amd64-linux-tdep.c: Include xml-syscall.h header, define the XML
syscall name for the architecture.
(amd64_linux_get_syscall_number): New function.
(amd64_linux_init_abi): Register the correct functions for syscall
catchpoint; set the correct syscall file name.
* breakpoint.c: New include: xml-syscall.h.
(set_raw_breakpoint_without_location): Setting the parameters
for the catch syscall feature.
(insert_catch_syscall): New.
(remove_catch_syscall): New.
(breakpoint_hit_catch_syscall): New.
(print_it_catch_syscall): New.
(print_one_catch_syscall): New.
(print_mention_catch_syscall): New.
(catch_syscall_breakpoint_ops): New.
(syscall_catchpoint_p): New.
(create_catchpoint_without_mention): New.
(create_catchpoint): Modified in order to use
create_catchpoint_without_mention.
(create_syscall_event_catchpoint): New.
(clean_up_filters): New.
(catch_syscall_split_args): New.
(catch_syscall_command_1): New.
(delete_breakpoint): Add cleanup for catch syscall.
(is_syscall_catchpoint_enabled): New.
(catch_syscall_enabled): New.
(catching_syscall_number): New.
(catch_syscall_completer): New completer function.
(add_catch_command): Add the completer function for catchpoints.
* breakpoint.h (syscalls_to_be_caught): New vector.
(catch_syscall_enabled): New.
(catching_syscall_number): New.
* gdbarch.c: Regenerated.
* gdbarch.h: Regenerated.
* gdbarch.sh: Add syscall catchpoint functions and structures.
(get_syscall_number): New.
(UNKNOWN_SYSCALL): New definition.
* i386-linux-nat.c (i386_linux_resume): Select the proper request
to be made for ptrace() considering if we are catching syscalls
or not.
* i386-linux-tdep.c: Include xml-syscall.h header, define the XML
syscall name for the architecture.
(i386_linux_get_syscall_number): New.
(i386_linux_init_abi): Register the correct functions for syscall
catchpoint; set the correct syscall file name.
* inf-child.c (inf_child_set_syscall_catchpoint): New.
(inf_child_target): Assign default values to target_ops.
* inf-ptrace.c (inf_ptrace_resume): Select the proper request
to be made for ptrace() considering if we are catching syscalls
or not.
* inferior.h (struct inferior): Included new variables
any_syscall_count, syscalls_counts and total_syscalls_count,
used to keep track of requested syscall catchpoints.
* infrun.c (resume): Add syscall catchpoint.
(deal_with_syscall_event): New.
(handle_inferior_event): Add syscall entry/return events.
(inferior_has_called_syscall): New.
* linux-nat.c: Define some helpful variables to track wether we have
support for the needed ptrace option.
(linux_test_for_tracesysgood): New.
(linux_supports_tracesysgood): New.
(linux_enable_tracesysgood): New.
(linux_enable_event_reporting): Save the current used ptrace
options.
(linux_child_post_attach): Calling linux_enable_tracesysgood.
(linux_child_post_startup_inferior): Likewise.
(linux_child_set_syscall_catchpoint): New function.
(linux_handle_extended_wait): Handle the case which the inferior stops
because it has called or returned from a syscall.
(linux_target_install_ops): Install the necessary functions to handle
syscall catchpoints.
* linux-nat.h (struct lwp_info): Include syscall_state into the
structure, which indicates if we are in a syscall entry or return.
* ppc-linux-tdep.c: Include xml-syscall.h header, define the XML
syscall filename for the arch.
(ppc_linux_get_syscall_number): New.
(ppc_linux_init_abi): Register the correct functions for syscall
catchpoint; setting the correct name for the XML syscall file.
* target.c (update_current_target): Update/copy functions related to
syscall catchpoint.
(target_waitstatus_to_string): Add syscall catchpoint entry/return
events.
* target.h (struct target_waitstatus): Add syscall number.
(struct syscall): New struct to hold information about syscalls
in the system.
(struct target_ops): Add ops for syscall catchpoint.
(inferior_has_called_syscall): New.
(target_set_syscall_catchpoint): New.
* xml-support.c (xml_fetch_content_from_file): New function,
transferred from xml-tdesc.c.
* xml-support.h (xml_fetch_content_from_file): New.
* xml-tdesc.c (fetch_xml_from_file): Function removed;
transferred to xml-support.c.
(file_read_description_xml): Updated to use the new
xml_fetch_content_from_file function.
* syscalls/gdb-syscalls.dtd: New definition file for syscall's XML
support.
* syscalls/amd64-linux.xml: New file containing information about
syscalls for GNU/Linux systems that use amd64 architecture.
* syscalls/i386-linux.xml: New file containing information about
syscalls for GNU/Linux systems that use i386 architecture.
* syscalls/ppc-linux.xml: New file containing information about
syscalls for GNU/Linux systems that use PPC architecture.
* syscalls/ppc64-linux.xml: New file containing information about
syscalls for GNU/Linux systems that use PPC64 architecture.
* xml-syscall.c: New file containing functions for manipulating
syscall's XML files.
* xml-syscall.h: New file, exporting the functions above mentioned.
* Makefile.in: Support for relocatable GDB datadir and XML
syscall.
* NEWS: Added information about the catch syscall feature.
* doc/gdb.texinfo (Set Catchpoints): Documentation about the new
feature.
* testsuite/Makefile.in: Inclusion of catch-syscall object.
* testsuite/gdb.base/catch-syscall.c: New file.
* testsuite/gdb.base/catch-syscall.exp: New file.
Diffstat (limited to 'gdb/doc')
-rw-r--r-- | gdb/doc/ChangeLog | 5 | ||||
-rw-r--r-- | gdb/doc/gdb.texinfo | 131 |
2 files changed, 136 insertions, 0 deletions
diff --git a/gdb/doc/ChangeLog b/gdb/doc/ChangeLog index 8a9bb7b..b0e0f6c 100644 --- a/gdb/doc/ChangeLog +++ b/gdb/doc/ChangeLog @@ -1,3 +1,8 @@ +2009-09-14 Sergio Durigan Junior <sergiodj@linux.vnet.ibm.com> + + * gdb.texinfo (Set Catchpoints): Documentation about the catch syscall + feature. + 2009-09-13 Daniel Jacobowitz <dan@codesourcery.com> * gdbint.texinfo (Unwinding the Frame ID): Reference outer_frame_id. diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo index 2027351..80b4789 100644 --- a/gdb/doc/gdb.texinfo +++ b/gdb/doc/gdb.texinfo @@ -3685,6 +3685,137 @@ A failed Ada assertion. A call to @code{exec}. This is currently only available for HP-UX and @sc{gnu}/Linux. +@item syscall +@itemx syscall @r{[}@var{name} @r{|} @var{number}@r{]} @r{...} +@cindex break on a system call. +A call to or return from a system call, a.k.a.@: @dfn{syscall}. A +syscall is a mechanism for application programs to request a service +from the operating system (OS) or one of the OS system services. +@value{GDBN} can catch some or all of the syscalls issued by the +debuggee, and show the related information for each syscall. If no +argument is specified, calls to and returns from all system calls +will be caught. + +@var{name} can be any system call name that is valid for the +underlying OS. Just what syscalls are valid depends on the OS. On +GNU and Unix systems, you can find the full list of valid syscall +names on @file{/usr/include/asm/unistd.h}. + +@c For MS-Windows, the syscall names and the corresponding numbers +@c can be found, e.g., on this URL: +@c http://www.metasploit.com/users/opcode/syscalls.html +@c but we don't support Windows syscalls yet. + +Normally, @value{GDBN} knows in advance which syscalls are valid for +each OS, so you can use the @value{GDBN} command-line completion +facilities (@pxref{Completion,, command completion}) to list the +available choices. + +You may also specify the system call numerically. A syscall's +number is the value passed to the OS's syscall dispatcher to +identify the requested service. When you specify the syscall by its +name, @value{GDBN} uses its database of syscalls to convert the name +into the corresponding numeric code, but using the number directly +may be useful if @value{GDBN}'s database does not have the complete +list of syscalls on your system (e.g., because @value{GDBN} lags +behind the OS upgrades). + +The example below illustrates how this command works if you don't provide +arguments to it: + +@smallexample +(@value{GDBP}) catch syscall +Catchpoint 1 (syscall) +(@value{GDBP}) r +Starting program: /tmp/catch-syscall + +Catchpoint 1 (call to syscall 'close'), \ + 0xffffe424 in __kernel_vsyscall () +(@value{GDBP}) c +Continuing. + +Catchpoint 1 (returned from syscall 'close'), \ + 0xffffe424 in __kernel_vsyscall () +(@value{GDBP}) +@end smallexample + +Here is an example of catching a system call by name: + +@smallexample +(@value{GDBP}) catch syscall chroot +Catchpoint 1 (syscall 'chroot' [61]) +(@value{GDBP}) r +Starting program: /tmp/catch-syscall + +Catchpoint 1 (call to syscall 'chroot'), \ + 0xffffe424 in __kernel_vsyscall () +(@value{GDBP}) c +Continuing. + +Catchpoint 1 (returned from syscall 'chroot'), \ + 0xffffe424 in __kernel_vsyscall () +(@value{GDBP}) +@end smallexample + +An example of specifying a system call numerically. In the case +below, the syscall number has a corresponding entry in the XML +file, so @value{GDBN} finds its name and prints it: + +@smallexample +(@value{GDBP}) catch syscall 252 +Catchpoint 1 (syscall(s) 'exit_group') +(@value{GDBP}) r +Starting program: /tmp/catch-syscall + +Catchpoint 1 (call to syscall 'exit_group'), \ + 0xffffe424 in __kernel_vsyscall () +(@value{GDBP}) c +Continuing. + +Program exited normally. +(@value{GDBP}) +@end smallexample + +However, there can be situations when there is no corresponding name +in XML file for that syscall number. In this case, @value{GDBN} prints +a warning message saying that it was not able to find the syscall name, +but the catchpoint will be set anyway. See the example below: + +@smallexample +(@value{GDBP}) catch syscall 764 +warning: The number '764' does not represent a known syscall. +Catchpoint 2 (syscall 764) +(@value{GDBP}) +@end smallexample + +If you configure @value{GDBN} using the @samp{--without-expat} option, +it will not be able to display syscall names. Also, if your +architecture does not have an XML file describing its system calls, +you will not be able to see the syscall names. It is important to +notice that these two features are used for accessing the syscall +name database. In either case, you will see a warning like this: + +@smallexample +(@value{GDBP}) catch syscall +warning: Could not open "syscalls/i386-linux.xml" +warning: Could not load the syscall XML file 'syscalls/i386-linux.xml'. +GDB will not be able to display syscall names. +Catchpoint 1 (syscall) +(@value{GDBP}) +@end smallexample + +Of course, the file name will change depending on your architecture and system. + +Still using the example above, you can also try to catch a syscall by its +number. In this case, you would see something like: + +@smallexample +(@value{GDBP}) catch syscall 252 +Catchpoint 1 (syscall(s) 252) +@end smallexample + +Again, in this case @value{GDBN} would not be able to display syscall's names. + @item fork A call to @code{fork}. This is currently only available for HP-UX and @sc{gnu}/Linux. |