10 #define ptrace mdbtrace
11 #include <sys/ptrace.h>
14 #include <machine/archtypes.h>
15 #include <kernel/const.h>
16 #include <kernel/type.h>
17 #include <kernel/proc.h>
19 /* Define these here */
20 /* buffer for proc and pointer to proc */
22 #define SIZ (1 + sizeof(struct proc)/sizeof(long))
27 static char segment_name
[] = "TDS";
35 long int vir
, phy
, len
;
37 Printf("\t Virtual\t Physical\tLength\n");
38 Printf("\t address\t address\n");
39 for (i
= 0; i
< strlen(segment_name
); i
++) {
40 vir
= (long) prc
->p_memmap
[i
].mem_vir
<< CLICK_SHIFT
;
41 phy
= (long) prc
->p_memmap
[i
].mem_phys
<< CLICK_SHIFT
;
42 len
= (long) prc
->p_memmap
[i
].mem_len
<< CLICK_SHIFT
;
43 Printf("%c:\t0x%08.8lx\t0x%08.8lx\t%8ld (0x%08.8lx)\n",
44 segment_name
[i
], vir
, phy
, len
, len
);
52 for (i
= 0; i
< (SIZ
- 1); i
++)
53 lbuf
[i
] = ptrace(T_GETUSER
, curpid
, (long) (i
* sizeof(long)), 0L);
55 st_addr
= (long) prc
->p_memmap
[T
].mem_vir
<< CLICK_SHIFT
;
56 et_addr
= st_addr
+ ( (long) prc
->p_memmap
[T
].mem_len
<< CLICK_SHIFT
);
58 sd_addr
= (long) prc
->p_memmap
[D
].mem_vir
<< CLICK_SHIFT
;
60 sd_addr
+ ( (long) prc
->p_memmap
[D
].mem_len
<< CLICK_SHIFT
);
62 sk_addr
= (long) prc
->p_memmap
[S
].mem_vir
<< CLICK_SHIFT
;
63 sk_size
= (long) prc
->p_memmap
[S
].mem_len
<< CLICK_SHIFT
;
66 if ( end_addr
< et_addr
) end_addr
= et_addr
;
76 Printf("No active process.\n");
80 /* Look at kernel/type.h see how this data from the stackframe is laid out */
82 #if defined(MINIX_PC) && defined(__i86)
84 es ds di si bp bx dx cx ax ip cs psw sp ss\
86 for (i
= 0; i
< 16; i
++)
87 if ( i
!= 5 && i
!= 10 ) Printf("%04x ", ((reg_t
*) &prc
->p_reg
)[i
]);
91 #if defined(MINIX_PC) && defined(__i386)
94 fs gs ds es edi esi ebp ebx edx\n");
95 for (i
= 0; i
< 8; i
++)
96 if ( i
!= 6 ) Printf("%08lx ", ((reg_t
*) &prc
->p_reg
)[i
]);
98 ecx eax eip cs psw esp ss\n");
100 if ( i
!= 10 ) Printf("%08lx ", ((reg_t
*) &prc
->p_reg
)[i
]);
105 Printf("\npc=%lx psw=%x\n\n",(long)PC_MEMBER(prc
), PSW_MEMBER(prc
));
107 " 0 1 2 3 4 5 6 7\nD");
108 for (i
= 0; i
< 8; i
++) Printf(" %08lx", ((reg_t
*) &prc
->p_reg
)[i
]);
110 for (; i
< NR_REGS
; i
++) Printf(" %08lx", ((reg_t
*) &prc
->p_reg
)[i
]);
111 Printf(" %08lx\n\n", (long)SP_MEMBER(prc
));
116 /* System dependent core */
121 static char regs
[] = "fs gs ds es di si bp bx dx cx ax ip cs ps sp ss";
123 static char regs
[] = "es ds di si bp bx dx cx ax ip cs ps sp ss";
126 /* Get register for pid at offset k */
135 /* Calculate size of register */
136 reg_size
= (k
< N_REG16
* 2) ? 2 : sizeof(reg_t
);
139 off
= k
- (k
& (sizeof(long) - 1));
141 val
= ptrace(T_GETUSER
, pid
, off
, 0L);
143 if (k
& (sizeof(long) - 1))
144 val
>>= BITSIZE(reg_size
);
146 val
&= MASK(reg_size
);
151 /* Set register for pid at offset k */
152 void set_reg(pid
, k
, value
)
160 off
= k
- (k
& (sizeof(long) - 1));
162 ptrace(T_SETUSER
, pid
, off
, value
);
176 mdb_error("Invalid syntax\n");
178 q
[1] = tolower(*++s
);
182 send
= regs
+ sizeof(regs
);
184 if (strncmp(q
, t
, 2) == 0) {
185 val
= (long) (t
- regs
);
187 if (val
< N_REG16
- 1)
190 val
= (N_REG16
- 1) * 2 +
191 (val
- N_REG16
+ 1) * sizeof(reg_t
);
196 Printf("Unknown register: %s", q
);
204 /* print segment register */
206 if ((num
% HCLICK_SIZE
) != 0 || num
>= 0x100000)
211 Printf("%04x", (u16_t
) (num
/ HCLICK_SIZE
) );
219 /* Get register for pid at offset k */
224 return ptrace(T_GETUSER
, pid
, k
, 0L);
234 case 'A': val
= 32; break;
236 case 'D': val
= 0; break;
238 case 'p': if (*s
!= 'c' && *s
!= 'C') goto error
;
243 if (*s
>= '0' && *s
<= '7')
244 return val
+ 4 * (*s
- '0');
246 Printf("Unknown register: %2.2s", s
);