/usr/share/gdb/syscalls是用来做什么的?

3
我在/usr/share/gdb下找到了三个目录:

  • auto-load:该目录用于自动加载脚本;
  • python:该目录用于gdb python扩展;
  • syscalls:该目录包含多个xml文件,例如amd64-linux.xml,但我无法通过谷歌找到任何信息。

顺便说一句:我的操作系统是Fedora 13。

请问这些xml文件有什么用?谢谢!

2个回答

4

新版本的GDB可以在系统调用时中断:

(gdb) help catch syscall
Catch system calls by their names and/or numbers.
Arguments say which system calls to catch.  If no arguments
are given, every system call will be caught.
Arguments, if given, should be one or more system call names
(if your system supports that), or system call numbers.

例子:

$ gdb /bin/true
(gdb) catch syscall exit_group 
Catchpoint 1 (syscall 'exit_group' [231])
(gdb) run
Starting program: /usr/bin/true 

Catchpoint 1 (call to syscall exit_group), 0x00000038464baa09 in __GI__exit (status=status@entry=0)
    at ../sysdeps/unix/sysv/linux/_exit.c:33
33        INLINE_SYSCALL (exit_group, 1, status);

XML文件提供了系统调用名称到编号的映射,例如在x86-64 Linux上,exit_group是第231个系统调用。

3

这是一个非常简单的列表,告诉GDB在特定系统上哪些系统调用号映射到哪些系统调用(因为它们是与体系结构相关的)。

它们是从相应的Linux内核头文件生成的(例如,对于linux-i386,是arch/x86/include/asm/unistd_32.h)。

例如:

<syscalls_info>
  <syscall name="restart_syscall" number="0"/>
  <syscall name="exit" number="1"/>
  <syscall name="fork" number="2"/>
  <syscall name="read" number="3"/>
  <syscall name="write" number="4"/>
  <syscall name="open" number="5"/>
  ...
</syscalls_info>

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接