summaryrefslogtreecommitdiffstats
path: root/lldb/tools/debugserver/source
diff options
context:
space:
mode:
authorJonas Devlieghere <jonas@devlieghere.com>2019-09-27 21:26:44 +0000
committerJonas Devlieghere <jonas@devlieghere.com>2019-09-27 21:26:44 +0000
commit0b1b3c6068dfacd267dded0395ef1fa262cb3f8c (patch)
tree6c2feb2674761a8fa0665d7556d06f25ebeb9423 /lldb/tools/debugserver/source
parent117512715d66f613b9eb9016725e5c3591f4f9df (diff)
downloadbcm5719-llvm-0b1b3c6068dfacd267dded0395ef1fa262cb3f8c.tar.gz
bcm5719-llvm-0b1b3c6068dfacd267dded0395ef1fa262cb3f8c.zip
[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 llvm-svn: 373127
Diffstat (limited to 'lldb/tools/debugserver/source')
-rw-r--r--lldb/tools/debugserver/source/debugserver.cpp11
1 files changed, 11 insertions, 0 deletions
diff --git a/lldb/tools/debugserver/source/debugserver.cpp b/lldb/tools/debugserver/source/debugserver.cpp
index fa19bba58fa..42205dedf4b 100644
--- a/lldb/tools/debugserver/source/debugserver.cpp
+++ b/lldb/tools/debugserver/source/debugserver.cpp
@@ -789,6 +789,12 @@ void FileLogCallback(void *baton, uint32_t flags, const char *format,
::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);
OpenPOWER on IntegriCloud