forked from OSchip/llvm-project
lldb-gdbserver: add support for optional host in connection string and handle other startup errors.
This change addresses the following bug: http://www.llvm.org/bugs/show_bug.cgi?id=18814 llvm-svn: 202910
This commit is contained in:
parent
9afd5daea3
commit
02c11e384d
|
@ -81,7 +81,7 @@ signal_handler(int signo)
|
||||||
static void
|
static void
|
||||||
display_usage (const char *progname)
|
display_usage (const char *progname)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "Usage:\n %s [--log-file log-file-path] [--log-flags flags] [--lldb-command command]* [--platform platform_name] HOST:PORT "
|
fprintf(stderr, "Usage:\n %s [--log-file log-file-path] [--log-flags flags] [--lldb-command command]* [--platform platform_name] [[HOST]:PORT] "
|
||||||
"[-- PROGRAM ARG1 ARG2 ...]\n", progname);
|
"[-- PROGRAM ARG1 ARG2 ...]\n", progname);
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
|
@ -331,15 +331,28 @@ main (int argc, char *argv[])
|
||||||
std::unique_ptr<ConnectionFileDescriptor> conn_ap(new ConnectionFileDescriptor());
|
std::unique_ptr<ConnectionFileDescriptor> conn_ap(new ConnectionFileDescriptor());
|
||||||
if (conn_ap.get())
|
if (conn_ap.get())
|
||||||
{
|
{
|
||||||
std::string connect_url ("listen://");
|
std::string final_host_and_port;
|
||||||
connect_url.append(host_and_port);
|
|
||||||
|
|
||||||
printf ("Listening for a connection on %s...\n", host_and_port);
|
// If host_and_port starts with ':', default the host to be "localhost" and expect the remainder to be the port.
|
||||||
|
if (host_and_port[0] == ':')
|
||||||
|
final_host_and_port.append ("localhost");
|
||||||
|
final_host_and_port.append (host_and_port);
|
||||||
|
|
||||||
|
std::string connect_url ("listen://");
|
||||||
|
connect_url.append (final_host_and_port);
|
||||||
|
|
||||||
|
printf ("Listening for a connection on %s...\n", final_host_and_port.c_str ());
|
||||||
if (conn_ap->Connect(connect_url.c_str(), &error) == eConnectionStatusSuccess)
|
if (conn_ap->Connect(connect_url.c_str(), &error) == eConnectionStatusSuccess)
|
||||||
{
|
{
|
||||||
printf ("Connection established.\n");
|
printf ("Connection established.\n");
|
||||||
gdb_server.SetConnection (conn_ap.release());
|
gdb_server.SetConnection (conn_ap.release());
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
fprintf (stderr, "failed to connect to '%s': %s\n", final_host_and_port.c_str (), error.AsCString ());
|
||||||
|
display_usage (progname);
|
||||||
|
exit (1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (gdb_server.IsConnected())
|
if (gdb_server.IsConnected())
|
||||||
|
@ -366,6 +379,12 @@ main (int argc, char *argv[])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
fprintf (stderr, "no connection information provided, unable to run\n");
|
||||||
|
display_usage (progname);
|
||||||
|
exit (1);
|
||||||
|
}
|
||||||
|
|
||||||
terminate_lldb_gdbserver ();
|
terminate_lldb_gdbserver ();
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue