diff options
author | Greg Clayton <gclayton@apple.com> | 2011-02-24 22:24:29 +0000 |
---|---|---|
committer | Greg Clayton <gclayton@apple.com> | 2011-02-24 22:24:29 +0000 |
commit | 71337622329b5046a7a8f902a91f07cc4b0776fc (patch) | |
tree | 33c8f96b3f38b57e77696b4965a1855d8525092c /lldb/tools/debugserver/source/debugserver.cpp | |
parent | afb36fad99457fd0ed10fa483c766b4783e0ec74 (diff) | |
download | bcm5719-llvm-71337622329b5046a7a8f902a91f07cc4b0776fc.tar.gz bcm5719-llvm-71337622329b5046a7a8f902a91f07cc4b0776fc.zip |
Fixed CommandReturnObject::SetImmediateErrorFile() to set the correct stream.
Modifed lldb_private::Process to be able to handle connecting to a remote
target that isn't running a process. This leaves lldb_private::Process in the
eStateConnected state from which we can then do an attach or launch.
Modified ProcessGDBRemote to be able to set stdin, stdout, stderr, working
dir, disable ASLR and a few other settings down by using new GDB remote
packets. This allows us to keep all of our current launch flags and settings
intact and still be able to communicate them over to the remote GDB server.
Previously these were being sent as arguments to the debugserver binary that
we were spawning. Also modified ProcessGDBRemote to handle losing connection
to the remote GDB server and always exit immediately. We do this by watching
the lldb_private::Communication event bit for the read thread exiting in the
ProcessGDBRemote async thread.
Added support for many of the new 'Q' packets for setting stdin, stdout,
stderr, working dir and disable ASLR to the GDBRemoteCommunication class for
easy accesss.
Modified debugserver for all of the new 'Q' packets and also made it so that
debugserver always exists if it loses connection with the remote debugger.
llvm-svn: 126444
Diffstat (limited to 'lldb/tools/debugserver/source/debugserver.cpp')
-rw-r--r-- | lldb/tools/debugserver/source/debugserver.cpp | 75 |
1 files changed, 38 insertions, 37 deletions
diff --git a/lldb/tools/debugserver/source/debugserver.cpp b/lldb/tools/debugserver/source/debugserver.cpp index 83131b95c39..8fab13f2dd7 100644 --- a/lldb/tools/debugserver/source/debugserver.cpp +++ b/lldb/tools/debugserver/source/debugserver.cpp @@ -74,7 +74,8 @@ RNBRunLoopGetStartModeFromRemote (RNBRemote* remote) if (remote) { RNBContext& ctx = remote->Context(); - uint32_t event_mask = RNBContext::event_read_packet_available; + uint32_t event_mask = RNBContext::event_read_packet_available | + RNBContext::event_read_thread_exiting; // Spin waiting to get the A packet. while (1) @@ -83,6 +84,12 @@ RNBRunLoopGetStartModeFromRemote (RNBRemote* remote) nub_event_t set_events = ctx.Events().WaitForSetEvents(event_mask); DNBLogThreadedIf (LOG_RNB_MAX, "%s ctx.Events().WaitForSetEvents( 0x%08x ) => 0x%08x", __FUNCTION__, event_mask, set_events); + if (set_events & RNBContext::event_read_thread_exiting) + { + RNBLogSTDERR ("error: packet read thread exited."); + return eRNBRunLoopModeExit; + } + if (set_events & RNBContext::event_read_packet_available) { rnb_err_t err = rnb_err; @@ -219,7 +226,9 @@ RNBRunLoopLaunchInferior (RNBRemote *remote, const char *stdin_path, const char ctx.LaunchStatus().SetErrorString(launch_err_str); } else + { ctx.LaunchStatus().Clear(); + } if (remote->Comm().IsConnected()) { @@ -682,6 +691,18 @@ main (int argc, char *argv[]) signal (SIGPIPE, signal_handler); signal (SIGHUP, signal_handler); + g_remoteSP.reset (new RNBRemote ()); + + + RNBRemote *remote = g_remoteSP.get(); + if (remote == NULL) + { + RNBLogSTDERR ("error: failed to create a remote connection class\n"); + return -1; + } + + RNBContext& ctx = remote->Context(); + int i; int attach_pid = INVALID_NUB_PROCESS; @@ -690,14 +711,10 @@ main (int argc, char *argv[]) // Parse our options int ch; int long_option_index = 0; - int use_native_registers = 0; int debug = 0; std::string compile_options; std::string waitfor_pid_name; // Wait for a process that starts with this name std::string attach_pid_name; - std::string stdin_path; - std::string stdout_path; - std::string stderr_path; std::string arch_name; std::string working_dir; // The new working directory to use for the inferior useconds_t waitfor_interval = 1000; // Time in usecs between process lists polls when waiting for a process by name, default 1 msec. @@ -859,7 +876,7 @@ main (int argc, char *argv[]) break; case 'r': - use_native_registers = 1; + remote->SetUseNativeRegisters (true); break; case 'v': @@ -867,21 +884,21 @@ main (int argc, char *argv[]) break; case 's': - stdin_path.assign(optarg); - stdout_path.assign(optarg); - stderr_path.assign(optarg); + ctx.GetSTDIN().assign(optarg); + ctx.GetSTDOUT().assign(optarg); + ctx.GetSTDERR().assign(optarg); break; case 'I': - stdin_path.assign(optarg); + ctx.GetSTDIN().assign(optarg); break; case 'O': - stdout_path.assign(optarg); + ctx.GetSTDOUT().assign(optarg); break; case 'E': - stderr_path.assign(optarg); + ctx.GetSTDERR().assign(optarg); break; case 'n': @@ -910,11 +927,7 @@ main (int argc, char *argv[]) if (arch_name.empty()) { -#if defined (__i386__) - arch_name.assign ("i386"); -#elif defined (__x86_64__) - arch_name.assign ("x86_64"); -#elif defined (__arm__) +#if defined (__arm__) arch_name.assign ("arm"); #endif } @@ -923,24 +936,15 @@ main (int argc, char *argv[]) DNBSetArchitecture (arch_name.c_str()); } - if (arch_name.empty()) - { - fprintf(stderr, "error: no architecture was specified\n"); - exit (8); - } +// if (arch_name.empty()) +// { +// fprintf(stderr, "error: no architecture was specified\n"); +// exit (8); +// } // Skip any options we consumed with getopt_long argc -= optind; argv += optind; - g_remoteSP.reset (new RNBRemote (use_native_registers, arch_name.c_str())); - - - RNBRemote *remote = g_remoteSP.get(); - if (remote == NULL) - { - RNBLogSTDERR ("error: failed to create a remote connection class\n"); - return -1; - } if (!working_dir.empty()) { @@ -953,9 +957,6 @@ main (int argc, char *argv[]) remote->Initialize(); - RNBContext& ctx = remote->Context(); - - // It is ok for us to set NULL as the logfile (this will disable any logging) if (log_file != NULL) @@ -1250,9 +1251,9 @@ main (int argc, char *argv[]) case eRNBRunLoopModeInferiorLaunching: { mode = RNBRunLoopLaunchInferior (remote, - stdin_path.empty() ? NULL : stdin_path.c_str(), - stdout_path.empty() ? NULL : stdout_path.c_str(), - stderr_path.empty() ? NULL : stderr_path.c_str(), + ctx.GetSTDINPath(), + ctx.GetSTDOUTPath(), + ctx.GetSTDERRPath(), no_stdio); if (mode == eRNBRunLoopModeInferiorExecuting) |