tsort cores; print stack as command - plan9port - [fork] Plan 9 from user space
git clone git://src.adamsgaard.dk/plan9port
Log
Files
Refs
README
LICENSE
---
commit d925d643cba25a7a3b7f530a42fb8dbc4e2f176e
parent 95f5b525d2eecb5ea90a056cff47f3bf946540aa
Author: rsc 
Date:   Sun, 23 Jan 2005 22:51:46 +0000

sort cores; print stack as command

Diffstat:
  M src/cmd/core.c                      |      23 ++++++++++++++++-------

1 file changed, 16 insertions(+), 7 deletions(-)
---
diff --git a/src/cmd/core.c b/src/cmd/core.c
t@@ -43,6 +43,20 @@ coredir(void)
         return dir;
 }
 
+int
+timecmp(const void *va, const void *vb)
+{
+        Dir *a, *b;
+
+        a = (Dir*)va;
+        b = (Dir*)vb;
+        if(a->mtime < b->mtime)
+                return 1;
+        if(a->mtime > b->mtime)
+                return -1;
+        return 0;
+}
+
 void
 coreall(char *name)
 {
t@@ -62,6 +76,7 @@ coreall(char *name)
                 return;
         }
         n = dirreadall(fd, &d);
+        qsort(d, n, sizeof(d[0]), timecmp);
         for(i=0; icmd);
-
-        /*
-         * To do: look at command line to determine binary.
-         * Print stack.
-         */
+        print("stack %s\n\t# %s\n\t# %s\n", name, t, hdr->cmdline);
         uncrackhdr(hdr);
 }
-