Line | |
---|
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"
|
---|
10 |
|
---|
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
|
---|
19 |
|
---|
20 | PRIVATE long intaddr;
|
---|
21 |
|
---|
22 | PUBLIC void start_syscall(addr)
|
---|
23 | long addr;
|
---|
24 | {
|
---|
25 | long old;
|
---|
26 |
|
---|
27 | syscalls = FALSE;
|
---|
28 |
|
---|
29 | if ( addr == 0 ) {
|
---|
30 | intaddr = symbolvalue( SYSCALL_NAME, TRUE );
|
---|
31 | if ( intaddr == 0 )
|
---|
32 | return;
|
---|
33 | intaddr += SYSCALL_OFFSET;
|
---|
34 | }
|
---|
35 | else {
|
---|
36 | intaddr = addr;
|
---|
37 | Printf("Using %lx as syscall address\n",addr);
|
---|
38 | }
|
---|
39 |
|
---|
40 | old = breakpt(intaddr,"\n");
|
---|
41 |
|
---|
42 | /* Check instruction */
|
---|
43 | if ( (old & 0xFFFF) == SYSCALL_OLD)
|
---|
44 | syscalls = TRUE;
|
---|
45 |
|
---|
46 | }
|
---|
47 |
|
---|
48 | PUBLIC void do_syscall(addr)
|
---|
49 | long addr;
|
---|
50 | {
|
---|
51 | unsigned reg_ax,reg_bx;
|
---|
52 |
|
---|
53 | if ( addr != intaddr ) return;
|
---|
54 |
|
---|
55 | Printf("syscall to ");
|
---|
56 |
|
---|
57 | reg_ax = get_reg(curpid,reg_addr("AX"));
|
---|
58 |
|
---|
59 | switch (reg_ax) {
|
---|
60 | case 0: Printf(" MM ");
|
---|
61 | break;
|
---|
62 | case 1: Printf(" FS ");
|
---|
63 | break;
|
---|
64 | case 2: Printf(" INET ");
|
---|
65 | break;
|
---|
66 | default: Printf("Invalid dest = %d", reg_ax);
|
---|
67 | exit(0);
|
---|
68 | }
|
---|
69 |
|
---|
70 |
|
---|
71 | reg_bx = get_reg(curpid,reg_addr("BX"));
|
---|
72 | decode_message(reg_bx);
|
---|
73 |
|
---|
74 | /* Single step */
|
---|
75 | tstart(T_STEP, 0, 0, 1);
|
---|
76 |
|
---|
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();
|
---|
83 | }
|
---|
84 |
|
---|
85 | #endif /* SYSCALLS_SUPPORT */
|
---|
Note:
See
TracBrowser
for help on using the repository browser.