summaryrefslogtreecommitdiffstats
path: root/lldb/tools/debugserver/source/debugserver.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Squelch a silly warning regarding an extra 'default' in 'case'Ramkumar Ramachandra2015-11-031-39/+38
| | | | | | | | | | | | Let the editor also clean up whitespace for that file. Reviewers: clayborg Subscribers: lldb-commits Differential Revision: http://reviews.llvm.org/D13816 llvm-svn: 251979
* Upstreaming the apple internal changes that accumulated during theJason Molenda2015-10-231-2/+21
| | | | | | | | | | | | previous release. Most of the diffs are duplication in the xcode project file caused by adding a "debugserver-mini" target. Jim Ingham added support for a new SPI needed to request app launches on iOS. Greg Clayton added code to indicate the platform of the binary (macosx, ios, watchos, tvos) based on Mach-O load commands. Jason Molenda added code so debugserver will identify when it is running on a tvos/watchos device to lldb. llvm-svn: 251091
* When debugserver is running on an iOS device, callJason Molenda2015-07-071-0/+3
| | | | | | | | | | proc_set_wakemon_params() to raise the limit on the # of wakeups per second that are acceptable before the system may send an EXC_RESOURCE signal to debugserver. <rdar://problem/19631512> llvm-svn: 241553
* Fix debugserver warnings on MacOSX.Greg Clayton2015-03-091-6/+6
| | | | llvm-svn: 231692
* Fix a thinko in the case where we return a launch error with no errorJim Ingham2015-03-041-1/+1
| | | | | | | | string. Return "<unknown error>" rather than the empty launch error... <rdar://problem/20026469> llvm-svn: 231287
* Increase the gdb-remote packet timeout for the first packet we sendJason Molenda2014-07-241-0/+17
| | | | | | | | | | | | | to the remote side (QStartNoAckMode) - it may take a little longer than normal to get a reply. In debugserver, hardcode the priority for several threads so they aren't de-prioritized when a user app is using system resources. Also, set the names of the threads. <rdar://problem/17509866> llvm-svn: 213828
* Add an option for debugserver to propagate its environment to programs it ↵Greg Clayton2014-06-181-0/+18
| | | | | | | | | | | | | | | | launches using the --forward-env or -F: % ./debugserver --forward-env localhost:1234 -- /bin/ls % ./debugserver -F localhost:1234 -- /bin/ls Also allow new environment variables to be set using the "--env" or "-e": % ./debugserver --env FOO=1 --env BAR=2 localhost:1234 -- /bin/ls % ./debugserver -e FOO=1 -e BAR=2 localhost:1234 -- /bin/ls <rdar://problem/17350654> llvm-svn: 211200
* lldb arm64 import.Jason Molenda2014-03-291-6/+36
| | | | | | | | | | | | | | | | These changes were written by Greg Clayton, Jim Ingham, Jason Molenda. It builds cleanly against TOT llvm with xcodebuild. I updated the cmake files by visual inspection but did not try a build. I haven't built these sources on any non-Mac platforms - I don't think this patch adds any code that requires darwin, but please let me know if I missed something. In debugserver, MachProcess.cpp and MachTask.cpp were renamed to MachProcess.mm and MachTask.mm as they picked up some new Objective-C code needed to launch processes when running on iOS. llvm-svn: 205113
* Since lldb version doesn’t have to be a valid floating point literal, like ↵Todd Fiala2014-03-131-3/+3
| | | | | | | | | | x.y.z, the uses of DEBUGSERVER_VERSION_NUM are invalid and have to be removed. Change by Kuba Ober. llvm-svn: 203828
* Remove an assertion that was being hit due to slow DNS name lookups on ↵Greg Clayton2014-02-271-2/+2
| | | | | | | | | | MacOSX for "localhost". Changed all "localhost" to "127.0.0.1" to prevent potentially long name lookups. <rdar://problem/16154630> llvm-svn: 202424
* Switch debugserver to detach on error by default, and change the flag to ↵Jim Ingham2014-02-251-5/+10
| | | | | | | | | kill-on-error. Also fix the bug where lldb prints: "Got a connection and launched debugserver" rather than the name of the process it actually launched. llvm-svn: 202189
* Allow debugserver to detach from the target if the connection is Jim Ingham2014-02-251-2/+25
| | | | | | unexpectedly closed. llvm-svn: 202110
* Add the "--unix-socket" opton back as it was being used.Greg Clayton2013-12-101-8/+90
| | | | | | <rdar://problem/15622900> llvm-svn: 196952
* Replace all in_port_t with uint16_t to avoid compilation issues on different ↵Greg Clayton2013-12-061-1/+1
| | | | | | systems. llvm-svn: 196586
* Modified local spawning in debugserver processes to use a new ↵Greg Clayton2013-12-051-24/+42
| | | | | | | | | | | | | | | | | | --reverse-connect option so that debugserver actually connects back to LLDB instead of LLDB connecting to debugserver. This gets rid of our hacky "get_random_port()" which would grab a random port and tell debugserver to open that port. Now LLDB creates, binds, listens and accepts a connection by binding to port zero and sending the correctly bound port down as the host:port to connect back to. Fixed the "ConnectionFileDescriptor" to be able to correctly listen for connections from a specified host, localhost, or any host. Prior to this fix "listen://" only accepted the following format: listen://<port> But now it can accept: listen://<port> // Listen for connection from localhost on port <port> listen://<host>:<port> // Listen for connection from <host> and <port> listen://*:<port> // Listen for connection from any host on port <port> llvm-svn: 196547
* Switch local launching of debugserver over to always use a FIFO in order to ↵Greg Clayton2013-12-041-61/+20
| | | | | | | | | | handshake with the launched debugserver. This helps ensure that the launched debugserver is ready and listening for a connection. Prior to this we had a race condition. Consolidate the launching of debugserver into a single place: a static function in GDBRemoteCommunication. llvm-svn: 196401
* Make sure the getopt variables are correctly initialized for any option parsing.Greg Clayton2013-11-221-0/+8
| | | | | | Added a new "--port-offset PORT" option to lldb-platform so it can be used with USB mux type scenarios. llvm-svn: 195486
* Fixed up registers in debugserver.Greg Clayton2013-11-091-1/+1
| | | | | | | | | | | | - removed all gaps from the g/G packets - optimized registers for x86_64 to not send/receive xmm0-xmm15 as well as ymm0-ymm15, now we only send ymm0-15 and xmm0-15 are now pseudo regs - Fixed x86_64 floating point register gaps - Fixed x86_64 so that xmm8-xmm15 don't overlap with ymm0-ymm3. This could lead to bad values showing in the debugger and was due to bad register info structure contents - Fixed i386 so we only send ymm0-ymm7 and xmm0-xmm7 are now pseudo regs. - Fixed ARM register definitions to not have any gaps - Fixed it so value registers and invalidation registers are specified using register names which avoid games we had to play with register numbering in the ARM plugin. llvm-svn: 194302
* Remove the debugserver "--open-connection" option and obey the hostname that ↵Greg Clayton2013-06-061-20/+26
| | | | | | | | | | | | | | is passed into debugserver. you can now specify: debugserver host:port debugserver port debugserver /path/to/file When "host" is specified, we will only accept connections from that host. If host is not specified, we default to "localhost". llvm-svn: 183457
* <rdar://problem/13457391>Greg Clayton2013-04-041-3/+3
| | | | | | LLDB now can use a single dash for all long options for all commands form the command line and from the command interpreter. This involved just switching all calls from getopt_long() to getopt_long_only(). llvm-svn: 178789
* Add two additional DNBLog's in places where we're about to killJason Molenda2013-03-231-0/+1
| | | | | | | | off the inferior process so we stand a better chance of understanding what caused us to send a PT_KILL. <rdar://problem/12720340> llvm-svn: 177817
* Change debugserver to open the socket it listensJason Molenda2013-03-231-7/+12
| | | | | | | | | | | | | | | to in INADDR_LOOPBACK mode by default ("localhost only") instead of INADDR_ANY ("accept connections from any system"). Add a new command line argument to debugserver, --open-connection or -H which will enable the previous behavior. It would be used if you were doing two-system debugging, with lldb running on one system and debugserver running on the other. But it is a less common workflow and should not be the default. <rdar://problem/12583284> llvm-svn: 177790
* Add a log line when debugserver exits, and clean up some of the other ↵Jim Ingham2013-02-251-8/+14
| | | | | | standard logs output to make it more useful. llvm-svn: 176039
* <rdar://problem/12720514> Sub-TLF: Provide service to profile the inferiorHan Ming Ong2012-11-171-1/+7
| | | | | | This allows client to query profiling states on the inferior. llvm-svn: 168228
* Fix an error message in debugserver so it doesn't print "Unable toJason Molenda2012-11-011-1/+3
| | | | | | | launch process (null)" because we changed argv while doing argument parsing. llvm-svn: 167202
* Stop using the "%z" size_t modifier and cast all size_t values to uint64_t. ↵Greg Clayton2012-09-181-3/+3
| | | | | | Some platforms don't support this modification. llvm-svn: 164148
* Add "vAttachOrWait" to debugserver, so you can implement "attach to the ↵Jim Ingham2012-07-201-3/+3
| | | | | | process if it exists OR wait for it" without race conditions. Use that in lldb. llvm-svn: 160578
* Ran the static analyzer on the codebase and found a few things.Greg Clayton2012-07-171-0/+1
| | | | llvm-svn: 160338
* Change #ifdef markers around lockdown and SpringBoardJason Molenda2012-02-221-5/+5
| | | | | | | calls to dpeend on WITH_SPRINGBOARD and WITH_LOCKDOWN instead of __arm__. Add an RNBSocket::useFD method. llvm-svn: 151119
* Enabled the "printf" attribute on all debugserver logging functions and fixed Greg Clayton2011-10-281-3/+3
| | | | | | the ensuing mayhem. llvm-svn: 143244
* Incremental fixes of issues found by Xcode static analyzer.Johnny Chen2011-08-101-1/+1
| | | | llvm-svn: 137267
* Handle the possible case where the process launch failedJason Molenda2011-07-081-1/+7
| | | | | | but we don't have an error message. llvm-svn: 134662
* Fixed an issue in the EmulateInstructionARM there the IT opcode was trying toGreg Clayton2011-05-231-1/+30
| | | | | | | | | | | | | | | | | | | | | | | | parse NOP instructions. I added the new table entries for the NOP for the plain NOP, Yield, WFE, WFI, and SEV variants. Modified the opcode emulation function EmulateInstructionARM::EmulateMOVRdSP(...) to notify us when it is creating a frame. Also added an abtract way to detect the frame pointer register for both the standard ARM ABI and for Darwin. Fixed GDBRemoteRegisterContext::WriteAllRegisterValues(...) to correctly be able to individually write register values back if case the 'G' packet is not implemented or returns an error. Modified the StopInfoMachException to "trace" stop reasons. On ARM we currently use the BVR/BCR register pairs to say "stop when the PC is not equal to the current PC value", and this results in a EXC_BREAKPOINT mach exception that has 0x102 in the code. Modified debugserver to create the short option string from long option definitions to make sure it doesn't get out of date. The short option string was missing many of the newer short option values due to a modification of the long options defs, and not modifying the short option string. llvm-svn: 131911
* Moved the execution context that was in the Debugger intoGreg Clayton2011-04-121-9/+77
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | the CommandInterpreter where it was always being used. Make sure that Modules can track their object file offsets correctly to allow opening of sub object files (like the "__commpage" on darwin). Modified the Platforms to be able to launch processes. The first part of this move is the platform soon will become the entity that launches your program and when it does, it uses a new ProcessLaunchInfo class which encapsulates all process launching settings. This simplifies the internal APIs needed for launching. I want to slowly phase out process launching from the process classes, so for now we can still launch just as we used to, but eventually the platform is the object that should do the launching. Modified the Host::LaunchProcess in the MacOSX Host.mm to correctly be able to launch processes with all of the new eLaunchFlag settings. Modified any code that was manually launching processes to use the Host::LaunchProcess functions. Fixed an issue where lldb_private::Args had implicitly defined copy constructors that could do the wrong thing. This has now been fixed by adding an appropriate copy constructor and assignment operator. Make sure we don't add empty ModuleSP entries to a module list. Fixed the commpage module creation on MacOSX, but we still need to train the MacOSX dynamic loader to not get rid of it when it doesn't have an entry in the all image infos. Abstracted many more calls from in ProcessGDBRemote down into the GDBRemoteCommunicationClient subclass to make the classes cleaner and more efficient. Fixed the default iOS ARM register context to be correct and also added support for targets that don't support the qThreadStopInfo packet by selecting the current thread (only if needed) and then sending a stop reply packet. Debugserver can now start up with a --unix-socket (-u for short) and can then bind to port zero and send the port it bound to to a listening process on the other end. This allows the GDB remote platform to spawn new GDB server instances (debugserver) to allow platform debugging. llvm-svn: 129351
* Added the ability to get a broadcaster event name for a given broadcasterGreg Clayton2011-04-011-0/+3
| | | | | | | | | | | | | | event. Modified the ProcessInfo structure to contain all process arguments. Using the new function calls on MacOSX allows us to see the full process name, not just the first 16 characters. Added a new platform command: "platform process info <pid> [<pid> <pid> ...]" that can be used to get detailed information for a process including all arguments, user and group info and more. llvm-svn: 128694
* Split all of the core of LLDB.framework/lldb.so into aGreg Clayton2011-03-201-11/+69
| | | | | | | | | | | | | | | | | | | | static archive that can be linked against. LLDB.framework/lldb.so exports a very controlled API. Splitting the API into a static library allows other tools (debugserver for now) to use the power of the LLDB debugger core, yet not export it as its API is not portable or maintainable. The Host layer and many of the other internal only APIs can now be statically linked against. Now LLDB.framework/lldb.so links against "liblldb-core.a" instead of compiling the .o files only for the shared library. This fix is only for compiling with Xcode as the Makefile based build already does this. The Xcode projecdt compiler has been changed to LLVM. Anyone using Xcode 3 will need to manually change the compiler back to GCC 4.2, or update to Xcode 4. llvm-svn: 127963
* If the user sets a working directory path using "process launch -w <path>", ↵Johnny Chen2011-02-261-1/+3
| | | | | | | | | | | honor that dir path; otherwise, use the thing the debugserver is started with. Fixed rdar://problem/9056462 The process launch flag '-w' for setting the current working directory not working? llvm-svn: 126537
* Fixed CommandReturnObject::SetImmediateErrorFile() to set the correct stream.Greg Clayton2011-02-241-37/+38
| | | | | | | | | | | | | | | | | | | | | | | | | 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
* Trivial comment fix.Johnny Chen2011-01-251-2/+2
| | | | llvm-svn: 124195
* Linebuffer the log file.Jim Ingham2011-01-241-1/+5
| | | | llvm-svn: 124103
* Added a new variant of SBTarget::Launch() that deprectates the old one thatGreg Clayton2011-01-231-14/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | takes separate file handles for stdin, stdout, and stder and also allows for the working directory to be specified. Added support to "process launch" to a new option: --working-dir=PATH. We can now set the working directory. If this is not set, it defaults to that of the process that has LLDB loaded. Added the working directory to the host LaunchInNewTerminal function to allows the current working directory to be set in processes that are spawned in their own terminal. Also hooked this up to the lldb_private::Process and all mac plug-ins. The linux plug-in had its API changed, but nothing is making use of it yet. Modfied "debugserver" and "darwin-debug" to also handle the current working directory options and modified the code in LLDB that spawns these tools to pass the info along. Fixed ProcessGDBRemote to properly pass along all file handles for stdin, stdout and stderr. After clearing the default values for the stdin/out/err file handles for process to be NULL, we had a crasher in UserSettingsController::UpdateStringVariable which is now fixed. Also fixed the setting of boolean values to be able to be set as "true", "yes", "on", "1" for true (case insensitive) and "false", "no", "off", or "0" for false. Fixed debugserver to properly handle files for STDIN, STDOUT and STDERR that are not already opened. Previous to this fix debugserver would only correctly open and dupe file handles for the slave side of a pseudo terminal. It now correctly handles getting STDIN for the inferior from a file, and spitting STDOUT and STDERR out to files. Also made sure the file handles were correctly opened with the NOCTTY flag for terminals. llvm-svn: 124060
* Fixed an issue in "SBError SBProcess::Destroy ()" where it wasn't properlyGreg Clayton2011-01-221-56/+91
| | | | | | | | | | | | | | | | | | | | checking the validity of the shared pointer prior to using it. Fixed the GDB remote plug-in to once again watch for a reply from the "k" packet, and fixed the logic to make sure the thread requesting the kill and the async thread play nice (and very quickly) by synchronizing the packet sending and reply. I also tweaked some of the shut down packet ("k" kill, "D" detach, and the halt packet) to make sure they do the right thing. Fixed "StateType Process::WaitForProcessStopPrivate (...)" to correctly pass the timeout along to WaitForStateChangedEventsPrivate() and made the function behave correctly with respect to timing out. Added separate STDIN, STDOUT, and STDERR support to debugserver. Also added the start of being able to set the working directory for the inferior process. llvm-svn: 124049
* Add '-no-stdio' option to 'process launch' command, which causes theCaroline Tice2010-12-031-3/+10
| | | | | | | | | | inferior to be launched without setting up terminal stdin/stdout for it (leaving the lldb command line accessible while the program is executing). Also add a user settings variable, 'target.process.disable-stdio' to allow the user to set this globally rather than having to use the command option each time the process is launched. llvm-svn: 120825
* Fixed 32 bit debugging after recent architecture changes to debugserver.Greg Clayton2010-12-011-0/+6
| | | | llvm-svn: 120618
* Fixed Process::Halt() as it was broken for "process halt" after recent changesGreg Clayton2010-11-181-8/+27
| | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* If debugserver is running on the local machine, pass it aCaroline Tice2010-11-051-1/+1
| | | | | | | | pseudoterminal to pass to the inferior for the inferior's I/O (to allow direct writing, rather than passing all the I/O around via packets). llvm-svn: 118308
* Got the ARM version of debugserver up to date. Greg Clayton2010-09-091-1/+1
| | | | | | | | | Renamed the "dispatchqaddr" setting that was coming back for stop reply packets to be named "qaddr" so that gdb doesn't thing it is a register number. gdb was checking the first character and assuming "di" was a hex register number because 'd' is a hex digit. It has been shortened so gdb can safely ignore it. llvm-svn: 113475
* Added the ability to disable ASLR (Address Space Layout Randomization). ASLRGreg Clayton2010-08-311-0/+6
| | | | | | | | is disabled by default, and can be enabled using: (lldb) set disable-aslr 0 llvm-svn: 112616
* Fixed debugserver to not exit when we are able to spawn the process, yet notGreg Clayton2010-07-301-1/+2
| | | | | | | | launch it due to not being able to get the task port. A SIGHUP was killing us and also an error string wasn't properly being passed along. Got rid of a class error variable that can only lead to multi-threaded crashes. llvm-svn: 109930
* Initial checkin of lldb code from internal Apple repo.Chris Lattner2010-06-081-0/+1219
llvm-svn: 105619
OpenPOWER on IntegriCloud