[Lldb-commits] [PATCH] D108351: [lldb server] Tidy up LLDB server return codes and associated tests

Sebastian Schwartz via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Thu Aug 19 18:51:52 PDT 2021


saschwartz added a comment.

Responded to comments - will tidy up the nits.



================
Comment at: lldb/tools/lldb-server/lldb-platform.cpp:289
     fprintf(stderr, "failed to create acceptor: %s", error.AsCString());
-    exit(socket_error);
+    return -1;
   }
----------------
teemperor wrote:
> clayborg wrote:
> > Should we return error.GetError() if it is non zero? IIRC it will be the actual errno. And best to not return -1, just return 1.
> > 
> > ```
> > uint32_t SBError::GetError() const;
> > ```
> If we force the caller to convert errno to an exit code, then we could also just return the `Status error` itself (and then the caller can just return 0/1 depending on success or error)? That seems more clear than returning `errno` from a function with main signature (which makes it look like it would return an exit code).
Sounds fine to me - I went with `-1` because that was the original value for `socket_error`, but don't think anything should be conditioning on that. 

I'm pretty ambivalent to the `Status error` vs an error code directly myself, mainly because I don't know LLVM well enough to know what the convention might be. Will `error.GetError` always be nonzero if `error.Fail()` is true?


================
Comment at: lldb/tools/lldb-server/lldb-server.cpp:59
     display_usage(progname);
-    exit(option_error);
+    exit(1);
   }
----------------
teemperor wrote:
> `return 1;`
Thanks, good catch.


================
Comment at: lldb/tools/lldb-server/lldb-server.cpp:67
+    return main_gdbserver(argc, argv);
     break;
+  }
----------------
teemperor wrote:
> That break and the ones below are now dead code.
Hmm, I thought the compiler would complain without a break statement but let me try. Thanks for review.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D108351/new/

https://reviews.llvm.org/D108351



More information about the lldb-commits mailing list