Author: jdevlieghere Date: Fri Sep 27 14:26:44 2019 New Revision: 373127 URL: http://llvm.org/viewvc/llvm-project?rev=373127&view=rev Log: [debugserver] Add --version/-V command line option to debugserver.
When not running under a TTY the output is buffered and not flushed before debugserver exits which makes it impossible to parse the version string. This adds a -V/--version command that just prints the version to stdout and exits with an exit code zero. Differential revision: https://reviews.llvm.org/D68156 Modified: lldb/trunk/tools/debugserver/source/debugserver.cpp Modified: lldb/trunk/tools/debugserver/source/debugserver.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/debugserver/source/debugserver.cpp?rev=373127&r1=373126&r2=373127&view=diff ============================================================================== --- lldb/trunk/tools/debugserver/source/debugserver.cpp (original) +++ lldb/trunk/tools/debugserver/source/debugserver.cpp Fri Sep 27 14:26:44 2019 @@ -789,6 +789,12 @@ void FileLogCallback(void *baton, uint32 ::fflush((FILE *)baton); } +void show_version_and_exit(int exit_code) { + printf("%s-%s for %s.\n", DEBUGSERVER_PROGRAM_NAME, DEBUGSERVER_VERSION_STR, + RNB_ARCH); + exit(exit_code); +} + void show_usage_and_exit(int exit_code) { RNBLogSTDERR( "Usage:\n %s host:port [program-name program-arg1 program-arg2 ...]\n", @@ -811,6 +817,7 @@ static struct option g_long_options[] = {"debug", no_argument, NULL, 'g'}, {"kill-on-error", no_argument, NULL, 'K'}, {"verbose", no_argument, NULL, 'v'}, + {"version", no_argument, NULL, 'V'}, {"lockdown", no_argument, &g_lockdown_opt, 1}, // short option "-k" {"applist", no_argument, &g_applist_opt, 1}, // short option "-t" {"log-file", required_argument, NULL, 'l'}, @@ -1173,6 +1180,10 @@ int main(int argc, char *argv[]) { DNBLogSetVerbose(1); break; + case 'V': + show_version_and_exit(0); + break; + case 's': ctx.GetSTDIN().assign(optarg); ctx.GetSTDOUT().assign(optarg); _______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits