diff options
author | Greg Clayton <gclayton@apple.com> | 2010-11-18 05:57:03 +0000 |
---|---|---|
committer | Greg Clayton <gclayton@apple.com> | 2010-11-18 05:57:03 +0000 |
commit | 3af9ea56d30ca97a5ce31cb1024501b324f8fa47 (patch) | |
tree | 6c613eee05c2d066b9a58e727f079725ffc34964 /lldb/tools/debugserver/source/debugserver.cpp | |
parent | 19ca5608db90bf06bfaba3e1b28af6ed68165d7d (diff) | |
download | bcm5719-llvm-3af9ea56d30ca97a5ce31cb1024501b324f8fa47.tar.gz bcm5719-llvm-3af9ea56d30ca97a5ce31cb1024501b324f8fa47.zip |
Fixed Process::Halt() as it was broken for "process halt" after recent changes
to the DoHalt down in ProcessGDBRemote. I also moved the functionality that
was in ProcessGDBRemote::DoHalt up into Process::Halt so not every class has
to implement a tricky halt/resume on the internal state thread. The
functionality is the same as it was before with two changes:
- when we eat the event we now just reuse the event we consume when the private
state thread is paused and set the interrupted bool on the event if needed
- we also properly update the Process::m_public_state with the state of the
event we consume.
Prior to this, if you issued a "process halt" it would eat the event, not
update the process state, and then produce a new event with the interrupted
bit set and send it. Anyone listening to the event would get the stopped event
with a process that whose state was set to "running".
Fixed debugserver to not have to be spawned with the architecture of the
inferior process. This worked fine for launching processes, but when attaching
to processes by name or pid without a file in lldb, it would fail.
Now debugserver can support multiple architectures for a native debug session
on the current host. This currently means i386 and x86_64 are supported in
the same binary and a x86_64 debugserver can attach to a i386 executable.
This change involved a lot of changes to make sure we dynamically detect the
correct registers for the inferior process.
llvm-svn: 119680
Diffstat (limited to 'lldb/tools/debugserver/source/debugserver.cpp')
-rw-r--r-- | lldb/tools/debugserver/source/debugserver.cpp | 35 |
1 files changed, 27 insertions, 8 deletions
diff --git a/lldb/tools/debugserver/source/debugserver.cpp b/lldb/tools/debugserver/source/debugserver.cpp index a3cae284d4f..e8c28cc5eae 100644 --- a/lldb/tools/debugserver/source/debugserver.cpp +++ b/lldb/tools/debugserver/source/debugserver.cpp @@ -334,7 +334,6 @@ RNBRunLoopLaunchAttaching (RNBRemoteSP &remote, nub_process_t attach_pid, nub_pr } else { - ctx.SetProcessID(pid); return eRNBRunLoopModeInferiorExecuting; } @@ -644,6 +643,7 @@ show_usage_and_exit (int exit_code) static struct option g_long_options[] = { { "attach", required_argument, NULL, 'a' }, + { "arch", required_argument, NULL, 'A' }, { "debug", no_argument, NULL, 'g' }, { "verbose", no_argument, NULL, 'v' }, { "lockdown", no_argument, &g_lockdown_opt, 1 }, // short option "-k" @@ -695,6 +695,7 @@ main (int argc, char *argv[]) std::string waitfor_pid_name; // Wait for a process that starts with this name std::string attach_pid_name; std::string stdio_path; + std::string arch_name; useconds_t waitfor_interval = 1000; // Time in usecs between process lists polls when waiting for a process by name, default 1 msec. useconds_t waitfor_duration = 0; // Time in seconds to wait for a process by name, 0 means wait forever. @@ -704,7 +705,7 @@ main (int argc, char *argv[]) RNBRunLoopMode start_mode = eRNBRunLoopModeExit; - while ((ch = getopt_long(argc, argv, "a:d:gi:vktl:f:w:x:rs:", g_long_options, &long_option_index)) != -1) + while ((ch = getopt_long(argc, argv, "a:A:d:gi:vktl:f:w:x:rs:", g_long_options, &long_option_index)) != -1) { DNBLogDebug("option: ch == %c (0x%2.2x) --%s%c%s\n", ch, (uint8_t)ch, @@ -716,6 +717,11 @@ main (int argc, char *argv[]) case 0: // Any optional that auto set themselves will return 0 break; + case 'A': + if (optarg && optarg[0]) + arch_name.assign(optarg); + break; + case 'a': if (optarg && optarg[0]) { @@ -869,12 +875,28 @@ main (int argc, char *argv[]) break; } } + + if (arch_name.empty()) + { +#if defined (__i386__) + arch_name.assign ("i386"); +#elif defined (__x86_64__) + arch_name.assign ("x86_64"); +#elif defined (__arm__) + arch_name.assign ("arm"); +#endif + } + 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)); + g_remoteSP.reset (new RNBRemote (use_native_registers, arch_name.c_str())); RNBRemote *remote = g_remoteSP.get(); if (remote == NULL) @@ -883,6 +905,8 @@ main (int argc, char *argv[]) return -1; } + g_remoteSP->Initialize(); + RNBContext& ctx = remote->Context(); @@ -911,11 +935,6 @@ main (int argc, char *argv[]) DNBLogDebug("argv[%i] = %s", i, argv[i]); } - // Now that we have read in the options and enabled logging, initialize - // the rest of RNBRemote - RNBRemote::InitializeRegisters (use_native_registers); - - // as long as we're dropping remotenub in as a replacement for gdbserver, // explicitly note that this is not gdbserver. |