From 70b906ae82973b6a43a1a086cb1c9cea58e2abb7 Mon Sep 17 00:00:00 2001 From: Yaroslav Tykhiy Date: Fri, 16 Jun 2006 11:14:54 +0000 Subject: [PATCH] Guess the number of arguments to a function somewhat better. Now GCC likes to stick a "mov %eax, %FOO" instruction before "addl $BAR, %esp" if the function just called returns an int, which is a very common case in the kernel. Sponsored by: RiNet (Cronyx Plus LLC) --- sys/i386/i386/db_trace.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/sys/i386/i386/db_trace.c b/sys/i386/i386/db_trace.c index fb8d0b058fb7..91e91a021bfc 100644 --- a/sys/i386/i386/db_trace.c +++ b/sys/i386/i386/db_trace.c @@ -201,25 +201,29 @@ static int db_numargs(fp) struct i386_frame *fp; { - int *argp; + char *argp; int inst; int args; - argp = (int *)db_get_value((int)&fp->f_retaddr, 4, FALSE); + argp = (char *)db_get_value((int)&fp->f_retaddr, 4, FALSE); /* * XXX etext is wrong for LKMs. We should attempt to interpret * the instruction at the return address in all cases. This * may require better fault handling. */ - if (argp < (int *)btext || argp >= (int *)etext) { + if (argp < btext || argp >= etext) { args = 5; } else { +retry: inst = db_get_value((int)argp, 4, FALSE); if ((inst & 0xff) == 0x59) /* popl %ecx */ args = 1; else if ((inst & 0xffff) == 0xc483) /* addl $Ibs, %esp */ args = ((inst >> 16) & 0xff) / 4; - else + else if ((inst & 0xf8ff) == 0xc089) { /* movl %eax, %Reg */ + argp += 2; + goto retry; + } else args = 5; } return (args);