MCPcopy Create free account
hub / github.com/F-Stack/f-stack / db_numargs

Function db_numargs

freebsd/i386/i386/db_trace.c:209–239  ·  view source on GitHub ↗

* Figure out how many arguments were passed into the frame at "fp". */

(fp)

Source from the content-addressed store, hash-verified

207 * Figure out how many arguments were passed into the frame at "fp".
208 */
209static int
210db_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 {
226retry:
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
241static void
242db_print_stack_entry(name, narg, argnp, argp, callpc, frame)

Callers 1

db_backtraceFunction · 0.85

Calls 1

db_get_valueFunction · 0.85

Tested by

no test coverage detected