summaryrefslogtreecommitdiffstats
path: root/lldb/tools/debugserver/source/MacOSX/MachProcess.cpp
Commit message (Collapse)AuthorAgeFilesLines
* lldb arm64 import.Jason Molenda2014-03-291-2309/+0
| | | | | | | | | | | | | | | | 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
* Allow debugserver to detach from the target if the connection is Jim Ingham2014-02-251-3/+6
| | | | | | unexpectedly closed. llvm-svn: 202110
* Remove log line that was left in accidentally.Greg Clayton2013-12-041-1/+0
| | | | llvm-svn: 196403
* Fixed printf warnings.Greg Clayton2013-10-311-4/+4
| | | | llvm-svn: 193806
* <rdar://problem/14195566>Greg Clayton2013-06-271-6/+10
| | | | | | Found a race condition when killing an application where the state could be set to exited by the waitpid_thread() _before_ we call task resume (via MachProcess::PrivateResume()) in MachProcess::Kill(). llvm-svn: 185048
* Huge performance improvements when one breakpoint contains many locations.Greg Clayton2013-06-121-184/+111
| | | | | | | | | | 325,000 breakpoints for running "breakpoint set --func-regex ." on lldb itself (after hitting a breakpoint at main so that LLDB.framework is loaded) used to take up to an hour to set, now we are down under a minute. With warm file caches, we are at 40 seconds, and that is with setting 325,000 breakpoint through the GDB remote API. Linux and the native debuggers might be faster. I haven't timed what how much is debug info parsing and how much is the protocol traffic to/from GDB remote. That there were many performance issues. Most of them were due to storing breakpoints in the wrong data structures, or using the wrong iterators to traverse the lists, traversing the lists in inefficient ways, and not optimizing certain function name lookups/symbol merges correctly. Debugging after that is also now very efficient. There were issues with replacing the breakpoint opcodes in memory that was read, and those routines were also fixed. llvm-svn: 183820
* <rdar://problem/13892516>Greg Clayton2013-05-211-5/+66
| | | | | | LLDB can now debug across calls to exec when the architecture changes from say i386 to x86_64 (on darwin). llvm-svn: 182345
* <rdar://problem/13891604>Greg Clayton2013-05-161-3/+13
| | | | | | Fixed a 2 second delay when sending the 'k' (kill) packet that happened due to a race condition. llvm-svn: 182025
* <rdar://problem/13198919>Greg Clayton2013-04-041-0/+15
| | | | | | Try and reap process when sending the "k" packet to avoid a race condition. We now wait for at most 1 second to reap the child process that we are killing. llvm-svn: 178726
* <rdar://problem/12789467>Greg Clayton2013-04-031-1/+2
| | | | | | Fixed an attach case for ARM that was imporperly detecting an application bundle when there wasn't one. llvm-svn: 178704
* Fix another old usage of GetCurrentThread() to get a mach portJason Molenda2013-04-031-0/+6
| | | | | | | | | number in RNBRemote::HandlePacket_qProcessInfo -- add a new GetCurrentThreadMachPort() so callers who need to make a mach thred_get_state() call at the RNBRemote level will have a way to get the port number. llvm-svn: 178619
* Remove some unused code.Jim Ingham2013-04-021-13/+0
| | | | llvm-svn: 178512
* Debugserver fix for launching iOS apps who are named "com.apple.something"Jason Molenda2013-03-281-2/+16
| | | | | | | | - the ".app" would be treated as the app bundle final characters and the SpringBoard launch would fail. <rdar://problem/13258935> llvm-svn: 178209
* <rdar://problem/13396207>Greg Clayton2013-03-131-2/+2
| | | | | | Added logging that will show up in the system console when we try to resume a process that is already running, or has an unexpected state. llvm-svn: 176960
* <rdar://problem/13338758>Han Ming Ong2013-03-041-2/+3
| | | | | | | Make it configurable what to profile. For Mac, we don't use the dirty page size yet and hence there is no need to gather that. This should be way better in not draining the battery since we are operating between 0% to 0.1% on the Mac after this change. llvm-svn: 176451
* Change debugserver from using the mach port number (in debugserver'sJason Molenda2013-02-221-4/+16
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | own port namepsace) as the thread identifier to using the system-wide globally unique thread id as the thread identifier number. MachThread.cpp keeps both the unique id and the mach port number for each thread. All layers outside MachThread class use the unique id with three exceptions: (1) Mach exceptions come in with the port number (thread_port) which needs to be translated, (2) any calls to low-level thread_get_state/thread_set_state/thread_suspend etc need to use the mach port number, (3) MachThreadList::UpdateThreadList which creates the MachThread objects gets the unique id and passes it to the MachThread ctor as an argument. In general, any time nub_thread_t is used, it is now referring to a unique thread id. Any time a thread_t is used, it is now referring to a mach port number. There was some interchangability of these types previously. nub_thread_t has also been changed to a 64-bit type which necessitated some printf specification string changes. I haven't been able to test these changes extensively yet but want to checkpoint the work. The scenarios I've been testing are all working correctly so while there may be some corner cases I haven't hit yet, I think it is substantially correct. <rdar://problem/12931414> llvm-svn: 175870
* <rdar://problem/13259230>Han Ming Ong2013-02-211-1/+6
| | | | | | Remember to set m_profile_thread to NULL once the profile thread is turned off. llvm-svn: 175761
* <rdar://problem/13019628>Han Ming Ong2013-01-161-1/+1
| | | | | | Prevent profiling from working on older debugserver. Just a simple renaming since the caller is prepared to handle the ‘unimplemented’ answer. llvm-svn: 172583
* <rdar://problem/12602653> Jason Molenda2013-01-051-0/+3
| | | | | | | | | | | | Add unconditional logging messages to every place in debugserver where we send a SIGKILL signal or do a ptrace PT_KILL call to terminate the inferior process. When the debuggee is silently killed off, the console logging from debugserver can disambiguate whether debugserver killed off the process because it failed to completely set it up, becuase it was told to (via the "k" packet), or if some external daemon killed it. llvm-svn: 171606
* <rdar://problem/12780259>Han Ming Ong2012-11-291-9/+12
| | | | | | | Prevent async and sync calls to get profile data from stomping on each other. At the same time, don't use '$' as end delimiter per chunk of profile data. llvm-svn: 168948
* Han Ming's commit in r168228 had a bunch of 4-space tabsJason Molenda2012-11-171-1/+1
| | | | | | | in the source files. Expand to spaces. No content changes, just whitespace. llvm-svn: 168238
* <rdar://problem/12720514> Sub-TLF: Provide service to profile the inferiorHan Ming Ong2012-11-171-0/+98
| | | | | | This allows client to query profiling states on the inferior. llvm-svn: 168228
* <rdar://problem/12042500>Greg Clayton2012-10-111-1/+3
| | | | | | Fixed an issue where we would try to launch an application twice and the second failure would cover up the first. llvm-svn: 165756
* Stop using the "%z" size_t modifier and cast all size_t values to uint64_t. ↵Greg Clayton2012-09-181-10/+10
| | | | | | Some platforms don't support this modification. llvm-svn: 164148
* Add a call to "sync" a thread state before checkpointing registers in ↵Jim Ingham2012-07-251-0/+16
| | | | | | | | | | | preparation for calling functions. This is necessary on Mac OS X, since bad things can happen if you set the registers of a thread that's sitting in a kernel trap. <rdar://problem/11145013> llvm-svn: 160756
* Use a more efficient API to tell if a process belongs to springboard or not.Jim Ingham2012-07-241-22/+2
| | | | llvm-svn: 160655
* Ran the static analyzer on the codebase and found a few things.Greg Clayton2012-07-171-11/+12
| | | | llvm-svn: 160338
* rdar://problem/11390100Johnny Chen2012-06-111-15/+18
| | | | | | debugserver needs to be able to posix_spawn debugging apps that have ".app" in their path that aren't bundles llvm-svn: 158327
* Add the capability to display the number of supported hardware watchpoints ↵Johnny Chen2012-05-231-0/+6
| | | | | | | | | to the "watchpoint list" command. Add default Process::GetWatchpointSupportInfo() impl which returns an error of "not supported". Add "qWatchpointSupportInfo" packet to the gdb communication layer to support this, and modify TestWatchpointCommands.py to test it. llvm-svn: 157345
* Suspend program threads before sending the SIGSTOP & resuming, so other ↵Jim Ingham2012-04-251-4/+8
| | | | | | | | threads won't get into trouble while we are waiting for the SIGSTOP. rdar://problem/11174834 llvm-svn: 155560
* <rdar://problem/11030692>Greg Clayton2012-03-121-40/+34
| | | | | | SBProcess::PutSTDIN() was not working for a few builds on darwin when using debugserver. This is now fixed. llvm-svn: 152569
* <rdar://problem/10840355>Greg Clayton2012-03-061-4/+4
| | | | | | Fixed STDERR to not be opened as readable. Also cleaned up some of the code that implemented the file actions as some of the code was using the wrong variables, they now use the right ones (in for stdin, out for stdout, err for stderr). llvm-svn: 152102
* Change #ifdef markers around lockdown and SpringBoardJason Molenda2012-02-221-10/+8
| | | | | | | calls to dpeend on WITH_SPRINGBOARD and WITH_LOCKDOWN instead of __arm__. Add an RNBSocket::useFD method. llvm-svn: 151119
* Added optional calls to lldb_private::Process for getting memory region infoGreg Clayton2011-11-181-6/+0
| | | | | | | | | | | | | | | | | | | | | | | from a process and hooked it up to the new packet that was recently added to our GDB remote executable named debugserver. Now Process has the following new calls: virtual Error Process::GetMemoryRegionInfo (lldb::addr_t load_addr, MemoryRegionInfo &range_info); virtual uint32_t GetLoadAddressPermissions (lldb::addr_t load_addr); Only the first one needs to be implemented by subclasses that can add this support. Cleaned up the way the new packet was implemented in debugserver to be more useful as an API inside debugserver. Also found an error where finding a region for an address actually will pick up the next region that follows the address in the query so we also need ot make sure that the address we requested the region for falls into the region that gets returned. llvm-svn: 144976
* Remove the QAddressIsExecutable packet I added last night.Jason Molenda2011-11-091-3/+3
| | | | | | | | | | | | | | | Add a more general purpose qMemoryRegionInfo packet which can describe various attributes about a memory region. Currently it will return the start address, size, and permissions (read, write, executable) for the memory region. It may be possible to add additional attributes in the future such as whether the region is designated as stack memory or jitted code a la vmmap. I still haven't implemented the lldb side of the code to use this packet yet so there may be unexpected behavior - but the basic implementation looks about right. I'll hook it up to lldb soon and fix any problems that crop up. llvm-svn: 144175
* Add "QAddressIsExecutable" packet to debugserver. Used to testJason Molenda2011-11-081-1/+5
| | | | | | | | | | | | | | | | | | | | | | | | whether a given address is in an executable region of memory or not. I haven't written the lldb side that will use this packet it hasn't been tested yet but it's a simple enough bit of code. I want to have this feature available for the unwinder code. When we're stopped at an address with no valid symbol context, there are a number of questions I'd like to ask -- is the current pc value in an executable region (e.g. did they jump to unallocated/unexecutable memory? we know how to unwind from here if so.) Is the stack pointer or the frame pointer the correct register to use to find the caller's saved pc value? Once we're past the first frame we can trust things like eh_frame and ABI unwind schemes but the first frame is challenging and having a way to check potential addresses to see if they're executable or not would help narrow down the possibilities a lot. llvm-svn: 144074
* Fixed the Xcode project building of LLVM to be a bit more user friendly:Greg Clayton2011-11-041-3/+3
| | | | | | | | | | | | | | | | | | | - If you download and build the sources in the Xcode project, x86_64 builds by default using the "llvm.zip" checkpointed LLVM. - If you delete the "lldb/llvm.zip" and the "lldb/llvm" folder, and build the Xcode project will download the right LLVM sources and build them from scratch - If you have a "lldb/llvm" folder already that contains a "lldb/llvm/lib" directory, we will use the sources you have placed in the LLDB directory. Python can now be disabled for platforms that don't support it. Changed the way the libllvmclang.a files get used. They now all get built into arch specific directories and never get merged into universal binaries as this was causing issues where you would have to go and delete the file if you wanted to build an extra architecture slice. llvm-svn: 143678
* Enabled the "printf" attribute on all debugserver logging functions and fixed Greg Clayton2011-10-281-10/+10
| | | | | | the ensuing mayhem. llvm-svn: 143244
* Python does some bad things to the signal masks in the current process and Greg Clayton2011-10-281-2/+10
| | | | | | | | then we spawn child processes (debugserver, etc) and those bad settings get inherited. We stop this from happening by correctly mucking with the posix spawn attributes. llvm-svn: 143176
* Ignore the static analyzer, instead; and add comment why.Johnny Chen2011-08-101-2/+2
| | | | llvm-svn: 137275
* Incremental fixes of issues found by Xcode static analyzer.Johnny Chen2011-08-101-1/+2
| | | | llvm-svn: 137267
* Fixed CommandReturnObject::SetImmediateErrorFile() to set the correct stream.Greg Clayton2011-02-241-14/+55
| | | | | | | | | | | | | | | | | | | | | | | | | 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
* Added a new variant of SBTarget::Launch() that deprectates the old one thatGreg Clayton2011-01-231-4/+24
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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-12/+20
| | | | | | | | | | | | | | | | | | | | 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
* Took the timeout for a ClangUserExpression down from a 10 second timeout toGreg Clayton2011-01-191-10/+4
| | | | | | | | | | | | | | 500 ms. Make MachThreadList more threadsafe. Added code to make sure the thread register state was properly flushed for x86_64. Fixed an missing return code for the current thread in the new thread suffix code. Improved debugserver logging. llvm-svn: 123815
* Thread safety changes in debugserver and also in the process GDB remote plugin.Greg Clayton2011-01-181-16/+19
| | | | | | | | | | | | | | I added support for asking if the GDB remote server supports thread suffixes for packets that should be thread specific (register read/write packets) because the way the GDB remote protocol does it right now is to have a notion of a current thread for register and memory reads/writes (set via the "$Hg%x" packet) and a current thread for running ("$Hc%x"). Now we ask the remote GDB server if it supports adding the thread ID to the register packets and we enable that feature in LLDB if supported. This stops us from having to send a bunch of packets that update the current thread ID to some value which is prone to error, or extra packets. llvm-svn: 123762
* Add '-no-stdio' option to 'process launch' command, which causes theCaroline Tice2010-12-031-15/+39
| | | | | | | | | | 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-2/+1
| | | | llvm-svn: 120618
* Fixed Process::Halt() as it was broken for "process halt" after recent changesGreg Clayton2010-11-181-5/+21
| | | | | | | | | | | | | | | | | | | | | | | | | | | | 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-6/+10
| | | | | | | | 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
OpenPOWER on IntegriCloud