* Figure out how many arguments were passed into the frame at "fp". */
(fp)
| 207 | * Figure out how many arguments were passed into the frame at "fp". |
| 208 | */ |
| 209 | static int |
| 210 | db_numargs(fp) |
| 211 | struct i386_frame *fp; |
| 212 | { |
| 213 | char *argp; |
| 214 | int inst; |
| 215 | int args; |
| 216 | |
| 217 | argp = (char *)db_get_value((int)&fp->f_retaddr, 4, false); |
| 218 | /* |
| 219 | * XXX etext is wrong for LKMs. We should attempt to interpret |
| 220 | * the instruction at the return address in all cases. This |
| 221 | * may require better fault handling. |
| 222 | */ |
| 223 | if (argp < btext || argp >= etext) { |
| 224 | args = -1; |
| 225 | } else { |
| 226 | retry: |
| 227 | inst = db_get_value((int)argp, 4, false); |
| 228 | if ((inst & 0xff) == 0x59) /* popl %ecx */ |
| 229 | args = 1; |
| 230 | else if ((inst & 0xffff) == 0xc483) /* addl $Ibs, %esp */ |
| 231 | args = ((inst >> 16) & 0xff) / 4; |
| 232 | else if ((inst & 0xf8ff) == 0xc089) { /* movl %eax, %Reg */ |
| 233 | argp += 2; |
| 234 | goto retry; |
| 235 | } else |
| 236 | args = -1; |
| 237 | } |
| 238 | return (args); |
| 239 | } |
| 240 | |
| 241 | static void |
| 242 | db_print_stack_entry(name, narg, argnp, argp, callpc, frame) |
no test coverage detected