You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by GitBox <gi...@apache.org> on 2021/04/12 19:43:00 UTC

[GitHub] [incubator-nuttx] gustavonihei commented on a change in pull request #3517: arch: Allocate the space from the beginning in up_stack_frame

gustavonihei commented on a change in pull request #3517:
URL: https://github.com/apache/incubator-nuttx/pull/3517#discussion_r611905418



##########
File path: arch/arm/src/common/arm_vfork.c
##########
@@ -167,26 +146,27 @@ pid_t up_vfork(const struct vfork_s *context)
    * effort is overkill.
    */
 
-  newsp = (uint32_t)child->cmn.adj_stack_ptr - stackutil;
+  newtop = (uint32_t)child->cmn.adj_stack_ptr +
+                     child->cmn.adj_stack_size;
+  newsp = newtop - stackutil;
   memcpy((void *)newsp, (const void *)context->sp, stackutil);
 
   /* Was there a frame pointer in place before? */
 
-  if (context->fp <= (uint32_t)parent->adj_stack_ptr &&
-      context->fp >= (uint32_t)parent->adj_stack_ptr - stacksize)
+  if (context->fp >= context->sp && context->fp < stacktop)
     {
-      uint32_t frameutil = (uint32_t)parent->adj_stack_ptr - context->fp;
-      newfp = (uint32_t)child->cmn.adj_stack_ptr - frameutil;
+      uint32_t frameutil = stacktop - context->fp;
+      newfp = newtop - frameutil;
     }
   else
     {
       newfp = context->fp;
     }
 
-  sinfo("Parent: stack base:%p SP:%08" PRIx32 " FP:%08" PRIx32 "\n",
-        parent->adj_stack_ptr, context->sp, context->fp);
-  sinfo("Child:  stack base:%p SP:%08" PRIx32 " FP:%08" PRIx32 "\n",
-        child->cmn.adj_stack_ptr, newsp, newfp);
+  sinfo("Old stack top:%08" PRIx32 "SP:%08" PRIx32 " FP:%08" PRIx32 "\n",
+        stacktop, context->sp, context->fp);
+  sinfo("New stack top:%08" PRIx32 "SP:%08" PRIx32 " FP:%08" PRIx32 "\n",
+        newtop, newsp, newfp);

Review comment:
       ```suggestion
     sinfo("Old stack top:%08" PRIx32 " SP:%08" PRIx32 " FP:%08" PRIx32 "\n",
           stacktop, context->sp, context->fp);
     sinfo("New stack top:%08" PRIx32 " SP:%08" PRIx32 " FP:%08" PRIx32 "\n",
           newtop, newsp, newfp);
   ```
   Missing whitespace between printed values.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org