Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

what's /usr/share/gdb/syscalls used for

I found three directories in /usr/share/gdb:

  • auto-load: this is used for auto-loaded scripts;
  • python: this is used for gdb python extension;
  • syscalls: this contains several xml files like amd64-linux.xml which I cannot find any information through google.

BTW: my OS is Fedora 13.

Could anyone please tell me what these xml files are used for? Thanks and regards!

like image 867
brian Avatar asked Dec 11 '25 14:12

brian


2 Answers

Newer GDB's can break on system calls:

(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.

Example:

$ 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);

The XML file supplies the syscall name to number mapping, e.g. exit_group is syscall number 231 on x86-64 Linux.

like image 146
scottt Avatar answered Dec 13 '25 03:12

scottt


It's a very simple list which tells GDB what syscall numbers map to which syscalls on a particular system (since they are architecture-specific).

They are generated from the corresponding Linux kernel header (e.g. arch/x86/include/asm/unistd_32.h for linux-i386).

Example:

<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>
like image 32
nneonneo Avatar answered Dec 13 '25 05:12

nneonneo



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!