diff options
author | Ron Yorston <rmy@pobox.com> | 2018-12-04 09:54:49 +0000 |
---|---|---|
committer | Ron Yorston <rmy@pobox.com> | 2018-12-04 09:54:49 +0000 |
commit | 2bea24120ba728153a6bf94a5fed0f226e8bf438 (patch) | |
tree | cca0cc210de589e33ef161e034c8d833b467d120 | |
parent | 3d94569bbeed8f90ec36cea7d7f3f8f9077b1657 (diff) | |
download | busybox-w32-2bea24120ba728153a6bf94a5fed0f226e8bf438.tar.gz busybox-w32-2bea24120ba728153a6bf94a5fed0f226e8bf438.tar.bz2 busybox-w32-2bea24120ba728153a6bf94a5fed0f226e8bf438.zip |
ash: forkshell tweaks
Make it explicit that the nodeptr array contains pointers to
pointers.
In debug output show both the location of pointers to be fixed
and their contents.
-rw-r--r-- | shell/ash.c | 25 |
1 files changed, 13 insertions, 12 deletions
diff --git a/shell/ash.c b/shell/ash.c index bf197cd70..4c23286c1 100644 --- a/shell/ash.c +++ b/shell/ash.c | |||
@@ -344,7 +344,7 @@ struct forkshell { | |||
344 | /* struct alias **atab; */ | 344 | /* struct alias **atab; */ |
345 | /* struct parsefile *g_parsefile; */ | 345 | /* struct parsefile *g_parsefile; */ |
346 | HANDLE hMapFile; | 346 | HANDLE hMapFile; |
347 | void *old_base; | 347 | char *old_base; |
348 | # if FORKSHELL_DEBUG | 348 | # if FORKSHELL_DEBUG |
349 | int nodeptrcount; | 349 | int nodeptrcount; |
350 | int funcblocksize; | 350 | int funcblocksize; |
@@ -364,7 +364,7 @@ struct forkshell { | |||
364 | struct strlist *varlist; | 364 | struct strlist *varlist; |
365 | 365 | ||
366 | /* start of data block */ | 366 | /* start of data block */ |
367 | char *nodeptr[1]; | 367 | char **nodeptr[1]; |
368 | }; | 368 | }; |
369 | 369 | ||
370 | enum { | 370 | enum { |
@@ -9081,7 +9081,7 @@ static void *funcblock; /* block to allocate function from */ | |||
9081 | static char *funcstring_end; /* end of block to allocate strings from */ | 9081 | static char *funcstring_end; /* end of block to allocate strings from */ |
9082 | #if ENABLE_PLATFORM_MINGW32 | 9082 | #if ENABLE_PLATFORM_MINGW32 |
9083 | static int nodeptrcount; | 9083 | static int nodeptrcount; |
9084 | static char **nodeptr; | 9084 | static char ***nodeptr; |
9085 | # if FORKSHELL_DEBUG | 9085 | # if FORKSHELL_DEBUG |
9086 | static int annot_count; | 9086 | static int annot_count; |
9087 | static char **annot; | 9087 | static char **annot; |
@@ -9247,9 +9247,9 @@ nodeckstrdup(const char *s) | |||
9247 | static union node *copynode(union node *); | 9247 | static union node *copynode(union node *); |
9248 | 9248 | ||
9249 | #if ENABLE_PLATFORM_MINGW32 | 9249 | #if ENABLE_PLATFORM_MINGW32 |
9250 | # define SAVE_PTR(dst) {if (nodeptr) *nodeptr++ = (char *)&(dst);} | 9250 | # define SAVE_PTR(dst) {if (nodeptr) *nodeptr++ = (char **)&(dst);} |
9251 | # define SAVE_PTR2(dst1,dst2) {if (nodeptr) { *nodeptr++ = (char *)&(dst1);*nodeptr++ = (char *)&(dst2);}} | 9251 | # define SAVE_PTR2(dst1,dst2) {if (nodeptr) { *nodeptr++ = (char **)&(dst1);*nodeptr++ = (char **)&(dst2);}} |
9252 | # define SAVE_PTR3(dst1,dst2,dst3) {if (nodeptr) { *nodeptr++ = (char *)&(dst1);*nodeptr++ = (char *)&(dst2);*nodeptr++ = (char *)&(dst3);}} | 9252 | # define SAVE_PTR3(dst1,dst2,dst3) {if (nodeptr) { *nodeptr++ = (char **)&(dst1);*nodeptr++ = (char **)&(dst2);*nodeptr++ = (char **)&(dst3);}} |
9253 | #else | 9253 | #else |
9254 | # define SAVE_PTR(dst) | 9254 | # define SAVE_PTR(dst) |
9255 | # define SAVE_PTR2(dst,dst2) | 9255 | # define SAVE_PTR2(dst,dst2) |
@@ -15174,7 +15174,7 @@ spawn_forkshell(struct job *jp, struct forkshell *fs, int mode) | |||
15174 | #undef SAVE_PTR | 15174 | #undef SAVE_PTR |
15175 | #undef SAVE_PTR2 | 15175 | #undef SAVE_PTR2 |
15176 | #undef SAVE_PTR3 | 15176 | #undef SAVE_PTR3 |
15177 | #define SAVE_PTR(dst) {*nodeptr++ = (char *)&(dst);} | 15177 | #define SAVE_PTR(dst) {*nodeptr++ = (char **)&(dst);} |
15178 | #define SAVE_PTR2(dst1,dst2) {SAVE_PTR(dst1); SAVE_PTR(dst2);} | 15178 | #define SAVE_PTR2(dst1,dst2) {SAVE_PTR(dst1); SAVE_PTR(dst2);} |
15179 | #define SAVE_PTR3(dst1,dst2,dst3) {SAVE_PTR2(dst1,dst2); SAVE_PTR(dst3);} | 15179 | #define SAVE_PTR3(dst1,dst2,dst3) {SAVE_PTR2(dst1,dst2); SAVE_PTR(dst3);} |
15180 | #define SAVE_PTR4(dst1,dst2,dst3,dst4) {SAVE_PTR2(dst1,dst2); SAVE_PTR2(dst3,dst4);} | 15180 | #define SAVE_PTR4(dst1,dst2,dst3,dst4) {SAVE_PTR2(dst1,dst2); SAVE_PTR2(dst3,dst4);} |
@@ -15544,7 +15544,7 @@ forkshell_print(FILE *fp0, struct forkshell *fs, char **notes) | |||
15544 | FILE *fp; | 15544 | FILE *fp; |
15545 | void *lfuncblock; | 15545 | void *lfuncblock; |
15546 | char *lfuncstring; | 15546 | char *lfuncstring; |
15547 | char **lnodeptr; | 15547 | char ***lnodeptr; |
15548 | char *s; | 15548 | char *s; |
15549 | int count; | 15549 | int count; |
15550 | 15550 | ||
@@ -15586,7 +15586,8 @@ forkshell_print(FILE *fp0, struct forkshell *fs, char **notes) | |||
15586 | } | 15586 | } |
15587 | else { | 15587 | else { |
15588 | while (*lnodeptr) { | 15588 | while (*lnodeptr) { |
15589 | fprintf(fp, "%p %s\n", *lnodeptr++, notes[count++]); | 15589 | fprintf(fp, "%p %p %s\n", *lnodeptr, **lnodeptr, notes[count++]); |
15590 | lnodeptr++; | ||
15590 | } | 15591 | } |
15591 | } | 15592 | } |
15592 | if (count != fs->nodeptrcount) | 15593 | if (count != fs->nodeptrcount) |
@@ -15665,7 +15666,7 @@ forkshell_prepare(struct forkshell *fs) | |||
15665 | /* Finish it up */ | 15666 | /* Finish it up */ |
15666 | *nodeptr = NULL; | 15667 | *nodeptr = NULL; |
15667 | new->size = size; | 15668 | new->size = size; |
15668 | new->old_base = new; | 15669 | new->old_base = (char *)new; |
15669 | new->hMapFile = h; | 15670 | new->hMapFile = h; |
15670 | #if FORKSHELL_DEBUG | 15671 | #if FORKSHELL_DEBUG |
15671 | sprintf(name, "fs_%d.out", getpid()); | 15672 | sprintf(name, "fs_%d.out", getpid()); |
@@ -15736,9 +15737,9 @@ forkshell_init(const char *idstr) | |||
15736 | 15737 | ||
15737 | /* pointer fixup */ | 15738 | /* pointer fixup */ |
15738 | for ( i=0; fs->nodeptr[i]; ++i ) { | 15739 | for ( i=0; fs->nodeptr[i]; ++i ) { |
15739 | ptr = (char **)((char *)fs + (fs->nodeptr[i] - (char *)fs->old_base)); | 15740 | ptr = (char **)((char *)fs + ((char *)fs->nodeptr[i] - fs->old_base)); |
15740 | if (*ptr) | 15741 | if (*ptr) |
15741 | *ptr = (char *)fs + (*ptr - (char *)fs->old_base); | 15742 | *ptr = (char *)fs + (*ptr - fs->old_base); |
15742 | } | 15743 | } |
15743 | 15744 | ||
15744 | /* Now fix up stuff that can't be transferred */ | 15745 | /* Now fix up stuff that can't be transferred */ |