aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRon Yorston <rmy@pobox.com>2020-06-01 08:42:12 +0100
committerRon Yorston <rmy@pobox.com>2020-06-01 08:42:12 +0100
commit5dad29558e403acabe26711c0d2324d9f0333be5 (patch)
treeb9b47f1ac1105be5d054dde258cf6c02989d74a3
parent53c09d0e1720bd927a2995f87df324a9854f1771 (diff)
downloadbusybox-w32-5dad29558e403acabe26711c0d2324d9f0333be5.tar.gz
busybox-w32-5dad29558e403acabe26711c0d2324d9f0333be5.tar.bz2
busybox-w32-5dad29558e403acabe26711c0d2324d9f0333be5.zip
ash: improve forkshell debugging
The name of the output file depended only on the pid of the shell. Since a single shell can execute many forkshells it's useful to include a serial number in the filename so it isn't constantly overwritten. Also, output the type of forkshell.
-rw-r--r--shell/ash.c18
1 files changed, 14 insertions, 4 deletions
diff --git a/shell/ash.c b/shell/ash.c
index 27e097a99..241846380 100644
--- a/shell/ash.c
+++ b/shell/ash.c
@@ -16096,14 +16096,22 @@ forkshell_print(FILE *fp0, struct forkshell *fs, const char **notes)
16096 char *s; 16096 char *s;
16097 int count, i; 16097 int count, i;
16098 int size_gvp, size_gmp, size_cmdtable, size_atab, size_history, total; 16098 int size_gvp, size_gmp, size_cmdtable, size_atab, size_history, total;
16099 const char *fsname[] = {
16100 "FS_OPENHERE",
16101 "FS_EVALBACKCMD",
16102 "FS_EVALSUBSHELL",
16103 "FS_EVALPIPE",
16104 "FS_SHELLEXEC"
16105 };
16099 16106
16100 if (fp0 != NULL) { 16107 if (fp0 != NULL) {
16101 fp = fp0; 16108 fp = fp0;
16102 } 16109 }
16103 else { 16110 else {
16104 char name[32]; 16111 char name[64];
16112 static int num = 0;
16105 16113
16106 sprintf(name, "fs_%d.out", getpid()); 16114 sprintf(name, "fs_%d_%03d.out", getpid(), ++num % 100);
16107 if ((fp=fopen(name, "w")) == NULL) 16115 if ((fp=fopen(name, "w")) == NULL)
16108 return; 16116 return;
16109 } 16117 }
@@ -16155,6 +16163,7 @@ forkshell_print(FILE *fp0, struct forkshell *fs, const char **notes)
16155 fs->funcblocksize, size_gvp, size_gmp, size_cmdtable, 16163 fs->funcblocksize, size_gvp, size_gmp, size_cmdtable,
16156 size_atab, size_history, total); 16164 size_atab, size_history, total);
16157 16165
16166 fprintf(fp, "%s\n\n", fsname[fs->fpid]);
16158 fprintf(fp, "--- relocate ---\n"); 16167 fprintf(fp, "--- relocate ---\n");
16159 count = 0; 16168 count = 0;
16160 for (i = 0; i < fs->relocatesize; ++i) { 16169 for (i = 0; i < fs->relocatesize; ++i) {
@@ -16196,8 +16205,9 @@ forkshell_prepare(struct forkshell *fs)
16196 SECURITY_ATTRIBUTES sa; 16205 SECURITY_ATTRIBUTES sa;
16197#if FORKSHELL_DEBUG 16206#if FORKSHELL_DEBUG
16198 char *relocate; 16207 char *relocate;
16199 char name[32]; 16208 char name[64];
16200 FILE *fp; 16209 FILE *fp;
16210 static int num = 0;
16201#endif 16211#endif
16202 16212
16203 /* Calculate size of "new" */ 16213 /* Calculate size of "new" */
@@ -16241,7 +16251,7 @@ forkshell_prepare(struct forkshell *fs)
16241 new->old_base = (char *)new; 16251 new->old_base = (char *)new;
16242 new->hMapFile = h; 16252 new->hMapFile = h;
16243#if FORKSHELL_DEBUG 16253#if FORKSHELL_DEBUG
16244 sprintf(name, "fs_%d.out", getpid()); 16254 sprintf(name, "fs_%d_%03d.out", getpid(), ++num % 100);
16245 if ((fp=fopen(name, "w")) != NULL) { 16255 if ((fp=fopen(name, "w")) != NULL) {
16246 int i; 16256 int i;
16247 16257