add opendir alias
[minix.git] / commands / mdb / syscalls.c
bloba4fedcac2dea4531a2b1cba8a6479b371f8db7f0
1 /*
2 * syscall.c for mdb
3 */
4 #include "mdb.h"
5 #ifdef SYSCALLS_SUPPORT
6 #include <stdio.h>
7 #include <stdlib.h>
8 #include <sys/ptrace.h>
9 #include "proto.h"
11 #define SYSCALL_NAME "__sendrec"
12 #ifdef __i386
13 #define SYSCALL_OFFSET 0xF
14 #define SYSCALL_OLD 0x21CD
15 #else
16 #define SYSCALL_OFFSET 0xE
17 #define SYSCALL_OLD 0x20CD
18 #endif
20 static long intaddr;
22 void start_syscall(addr)
23 long addr;
25 long old;
27 syscalls = FALSE;
29 if ( addr == 0 ) {
30 intaddr = symbolvalue( SYSCALL_NAME, TRUE );
31 if ( intaddr == 0 )
32 return;
33 intaddr += SYSCALL_OFFSET;
35 else {
36 intaddr = addr;
37 Printf("Using %lx as syscall address\n",addr);
40 old = breakpt(intaddr,"\n");
42 /* Check instruction */
43 if ( (old & 0xFFFF) == SYSCALL_OLD)
44 syscalls = TRUE;
48 void do_syscall(addr)
49 long addr;
51 unsigned reg_ax,reg_bx;
53 if ( addr != intaddr ) return;
55 Printf("syscall to ");
57 reg_ax = get_reg(curpid,reg_addr("AX"));
59 switch (reg_ax) {
60 case 0: Printf(" PM ");
61 break;
62 case 1: Printf(" VFS ");
63 break;
64 case 2: Printf(" INET ");
65 break;
66 default: Printf("Invalid dest = %d", reg_ax);
67 exit(0);
71 reg_bx = get_reg(curpid,reg_addr("BX"));
72 decode_message(reg_bx);
74 /* Single step */
75 tstart(T_STEP, 0, 0, 1);
77 /* Check return code */
78 reg_ax = get_reg(curpid,reg_addr("AX"));
79 if ( reg_ax != 0 )
80 Printf("syscall failed AX=%d\n",reg_ax);
81 else
82 decode_result();
85 #endif /* SYSCALLS_SUPPORT */