Hi,

When printing a trace from ddb, some architectures are limited by the number of
registers which are used to pass arguments. If the number of arguments to a 
function
exceeded this number, the code in db_stack_trace_print() would print that many 
arguments
without any indication that one or more arguments aren't printed.

Here's a diff that tweaks the output to make it clear there were more arguments.
Do we want to print ',...' for each ommited argument (like this diff does)
or perhaps just a single ',...'?

Index: amd64/amd64/db_trace.c
===================================================================
RCS file: /cvs/src/sys/arch/amd64/amd64/db_trace.c,v
retrieving revision 1.53
diff -u -p -r1.53 db_trace.c
--- amd64/amd64/db_trace.c      14 May 2020 06:58:54 -0000      1.53
+++ amd64/amd64/db_trace.c      11 Jul 2021 13:23:04 -0000
@@ -137,7 +136,7 @@ db_stack_trace_print(db_expr_t addr, int
 
        lastframe = 0;
        while (count && frame != 0) {
-               int             narg;
+               int             narg, extra_args = 0;
                unsigned int    i;
                char *          name;
                db_expr_t       offset;
@@ -165,8 +164,12 @@ db_stack_trace_print(db_expr_t addr, int
                }
 
                narg = db_ctf_func_numargs(sym);
-               if (narg < 0 || narg > 6)
+               if (narg < 0)
+                       narg = 6;
+               else if (narg > 6) {
+                       extra_args = narg % 6;
                        narg = 6;
+               }
 
                if (name == NULL)
                        (*pr)("%lx(", callpc);
@@ -204,6 +207,9 @@ db_stack_trace_print(db_expr_t addr, int
                        if (--narg != 0)
                                (*pr)(",");
                }
+               for (i = extra_args; i > 0; i--)
+                       (*pr)(",...");  
+
                (*pr)(") at ");
                db_printsym(callpc, DB_STGY_PROC, pr);
                (*pr)("\n");
Index: powerpc/ddb/db_trace.c
===================================================================
RCS file: /cvs/src/sys/arch/powerpc/ddb/db_trace.c,v
retrieving revision 1.17
diff -u -p -r1.17 db_trace.c
--- powerpc/ddb/db_trace.c      14 May 2020 06:58:54 -0000      1.17
+++ powerpc/ddb/db_trace.c      11 Jul 2021 13:23:04 -0000
@@ -123,7 +123,7 @@ db_stack_trace_print(db_expr_t addr, int
        Elf_Sym         *sym;
        char            *name;
        char             c, *cp = modif;
-       int              i, narg, trace_proc = 0;
+       int              i, narg, trace_proc = 0, extra_args = 0;
 
        while ((c = *cp++) != 0) {
                if (c == 't')
@@ -158,8 +158,12 @@ db_stack_trace_print(db_expr_t addr, int
                        (*pr)("at 0x%lx", lr - 4);
                } else {
                        narg = db_ctf_func_numargs(sym);
-                       if (narg < 0 || narg > 8)
+                       if (narg < 0)
                                narg = 8;
+                       else if (narg > 8) {
+                               extra_args = narg % 8;
+                               narg = 8;
+                       }
 
                        (*pr)("%s(", name);
 
@@ -172,6 +176,9 @@ db_stack_trace_print(db_expr_t addr, int
                                                (*pr)(",");
                                }
                        }
+
+                       for (i = extra_args; i > 0; i--)
+                               (*pr)(",...");
 
                        (*pr)(") at ");
                        db_printsym(lr - 4, DB_STGY_PROC, pr);
-- 
jasper

Reply via email to