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



##########
File path: arch/mips/src/mips32/mips_vfork.c
##########
@@ -191,32 +168,33 @@ pid_t up_vfork(const struct vfork_s *context)
    * effort is overkill.
    */
 
-  newsp = (uint32_t)child->cmn.adj_stack_ptr - stackutil;
+  newtop = (uintptr_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? */
 
 #ifdef CONFIG_MIPS32_FRAMEPOINTER
-  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("Old stack base:%p SP:%08" PRIx32 " FP:%08" PRIx32 "\n",
-        parent->adj_stack_ptr, context->sp, context->fp);
-  sinfo("New 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:
us...@infra.apache.org


Reply via email to