summaryrefslogtreecommitdiffstats
path: root/lldb/tools/debugserver/source/MacOSX
Commit message (Collapse)AuthorAgeFilesLines
...
* Many improvements to the Platform base class and subclasses. The base PlatformGreg Clayton2011-03-302-16/+130
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | class now implements the Host functionality for a lot of things that make sense by default so that subclasses can check: int PlatformSubclass::Foo () { if (IsHost()) return Platform::Foo (); // Let the platform base class do the host specific stuff // Platform subclass specific code... int result = ... return result; } Added new functions to the platform: virtual const char *Platform::GetUserName (uint32_t uid); virtual const char *Platform::GetGroupName (uint32_t gid); The user and group names are cached locally so that remote platforms can avoid sending packets multiple times to resolve this information. Added the parent process ID to the ProcessInfo class. Added a new ProcessInfoMatch class which helps us to match processes up and changed the Host layer over to using this new class. The new class allows us to search for processs: 1 - by name (equal to, starts with, ends with, contains, and regex) 2 - by pid 3 - And further check for parent pid == value, uid == value, gid == value, euid == value, egid == value, arch == value, parent == value. This is all hookup up to the "platform process list" command which required adding dumping routines to dump process information. If the Host class implements the process lookup routines, you can now lists processes on your local machine: machine1.foo.com % lldb (lldb) platform process list PID PARENT USER GROUP EFF USER EFF GROUP TRIPLE NAME ====== ====== ========== ========== ========== ========== ======================== ============================ 99538 1 username usergroup username usergroup x86_64-apple-darwin FileMerge 94943 1 username usergroup username usergroup x86_64-apple-darwin mdworker 94852 244 username usergroup username usergroup x86_64-apple-darwin Safari 94727 244 username usergroup username usergroup x86_64-apple-darwin Xcode 92742 92710 username usergroup username usergroup i386-apple-darwin debugserver This of course also works remotely with the lldb-platform: machine1.foo.com % lldb-platform --listen 1234 machine2.foo.com % lldb (lldb) platform create remote-macosx Platform: remote-macosx Connected: no (lldb) platform connect connect://localhost:1444 Platform: remote-macosx Triple: x86_64-apple-darwin OS Version: 10.6.7 (10J869) Kernel: Darwin Kernel Version 10.7.0: Sat Jan 29 15:17:16 PST 2011; root:xnu-1504.9.37~1/RELEASE_I386 Hostname: machine1.foo.com Connected: yes (lldb) platform process list PID PARENT USER GROUP EFF USER EFF GROUP TRIPLE NAME ====== ====== ========== ========== ========== ========== ======================== ============================ 99556 244 username usergroup username usergroup x86_64-apple-darwin trustevaluation 99548 65539 username usergroup username usergroup x86_64-apple-darwin lldb 99538 1 username usergroup username usergroup x86_64-apple-darwin FileMerge 94943 1 username usergroup username usergroup x86_64-apple-darwin mdworker 94852 244 username usergroup username usergroup x86_64-apple-darwin Safari The lldb-platform implements everything with the Host:: layer, so this should "just work" for linux. I will probably be adding more stuff to the Host layer for launching processes and attaching to processes so that this support should eventually just work as well. Modified the target to be able to be created with an architecture that differs from the main executable. This is needed for iOS debugging since we can have an "armv6" binary which can run on an "armv7" machine, so we want to be able to do: % lldb (lldb) platform create remote-ios (lldb) file --arch armv7 a.out Where "a.out" is an armv6 executable. The platform then can correctly decide to open all "armv7" images for all dependent shared libraries. Modified the disassembly to show the current PC value. Example output: (lldb) disassemble --frame a.out`main: 0x1eb7: pushl %ebp 0x1eb8: movl %esp, %ebp 0x1eba: pushl %ebx 0x1ebb: subl $20, %esp 0x1ebe: calll 0x1ec3 ; main + 12 at test.c:18 0x1ec3: popl %ebx -> 0x1ec4: calll 0x1f12 ; getpid 0x1ec9: movl %eax, 4(%esp) 0x1ecd: leal 199(%ebx), %eax 0x1ed3: movl %eax, (%esp) 0x1ed6: calll 0x1f18 ; printf 0x1edb: leal 213(%ebx), %eax 0x1ee1: movl %eax, (%esp) 0x1ee4: calll 0x1f1e ; puts 0x1ee9: calll 0x1f0c ; getchar 0x1eee: movl $20, (%esp) 0x1ef5: calll 0x1e6a ; sleep_loop at test.c:6 0x1efa: movl $12, %eax 0x1eff: addl $20, %esp 0x1f02: popl %ebx 0x1f03: leave 0x1f04: ret This can be handy when dealing with the new --line options that was recently added: (lldb) disassemble --line a.out`main + 13 at test.c:19 18 { -> 19 printf("Process: %i\n\n", getpid()); 20 puts("Press any key to continue..."); getchar(); -> 0x1ec4: calll 0x1f12 ; getpid 0x1ec9: movl %eax, 4(%esp) 0x1ecd: leal 199(%ebx), %eax 0x1ed3: movl %eax, (%esp) 0x1ed6: calll 0x1f18 ; printf Modified the ModuleList to have a lookup based solely on a UUID. Since the UUID is typically the MD5 checksum of a binary image, there is no need to give the path and architecture when searching for a pre-existing image in an image list. Now that we support remote debugging a bit better, our lldb_private::Module needs to be able to track what the original path for file was as the platform knows it, as well as where the file is locally. The module has the two following functions to retrieve both paths: const FileSpec &Module::GetFileSpec () const; const FileSpec &Module::GetPlatformFileSpec () const; llvm-svn: 128563
* Added AVX support to the Intel portion of debugserver. AVXSean Callanan2011-03-226-336/+1505
| | | | | | | autodetection is not yet implemented, but the structures and register reading/writing code are there. llvm-svn: 128111
* Fixed CommandReturnObject::SetImmediateErrorFile() to set the correct stream.Greg Clayton2011-02-242-14/+59
| | | | | | | | | | | | | | | | | | | | | | | | | 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
* Rework the RunThreadPlan event handling to use Event Hijacking not stopping ↵Jim Ingham2011-02-081-3/+5
| | | | | | the event thread. Also clarify the logic of the function. llvm-svn: 125083
* The thread_info changes over the life of the thread, so you can't get it ↵Jim Ingham2011-01-281-4/+4
| | | | | | once and cache it, you have to fetch it every time you want to use it. llvm-svn: 124463
* Reverting recent thread resume changes as it was causing testing issues.Greg Clayton2011-01-252-117/+60
| | | | | | We will need to try again soon, but this change was causing instability. llvm-svn: 124180
* When we are stepping a thread, force it to resume ALL the way to 0. And of ↵Jim Ingham2011-01-252-60/+117
| | | | | | | | course, when we stop if we undid some user provided suspends, we need to re-do the suspends. llvm-svn: 124178
* One more thing... Resume any threads that we discover were created while we ↵Greg Clayton2011-01-241-5/+21
| | | | | | | | | stop as they may be in sensitive areas and we set breakpoints on the thread creation routines if we are running expressions, so the threads should quickly get to a safe spot. llvm-svn: 124115
* Discover new threads right before we continue a process since libdispatch hasGreg Clayton2011-01-241-13/+14
| | | | | | been known to make threads for us while our process/task is suspended. llvm-svn: 124111
* Added logging for threads that are spawned while we stop. We log theirGreg Clayton2011-01-242-2/+25
| | | | | | existence if the "thread" log bit is enabled right before we resume. llvm-svn: 124110
* 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-222-14/+43
| | | | | | | | | | | | | | | | | | | | 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 a (currently disabled) bear trap where instead of deallocating pages, we ↵Jim Ingham2011-01-221-2/+9
| | | | | | remove all permissions. llvm-svn: 124012
* Took the timeout for a ClangUserExpression down from a 10 second timeout toGreg Clayton2011-01-196-159/+113
| | | | | | | | | | | | | | 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-186-76/+67
| | | | | | | | | | | | | | 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
* Bumped lldb Xcode version to 35 for lldb-35, and debugserver to 121 forGreg Clayton2010-12-081-2/+0
| | | | | | debugserver-121. llvm-svn: 121237
* Add '-no-stdio' option to 'process launch' command, which causes theCaroline Tice2010-12-032-19/+43
| | | | | | | | | | 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-013-5/+3
| | | | llvm-svn: 120618
* Fixed Process::Halt() as it was broken for "process halt" after recent changesGreg Clayton2010-11-1812-105/+188
| | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* Fixed more thread suspend/resume issues.Greg Clayton2010-11-121-35/+40
| | | | llvm-svn: 118877
* Fixed an issue with the MachThread class where we might not get the initialGreg Clayton2010-11-123-2/+42
| | | | | | | | | thread basic info state and not realize that a thread was already suspended or if a thread was starting up and not ready to be displayed to the user (in an uninterruptable state). If it is not user ready yet, we don't add it to our list of threads that can be played with. llvm-svn: 118866
* 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
* Fix problem where "process detach" was not working properly. TheCaroline Tice2010-11-022-9/+26
| | | | | | | | | | ptrace thread update that was replying to the SIGSTOP was also causing the process to not really be sigstop'd any more so then the call to ptrace detach was failing, and when debugserver exited the attached process was being killed. Now the ptrace thread update does not disturb the sigstop state of the thread, so the detach works properly. llvm-svn: 118018
* Still trying to get detach to work with debugserver. Got a bit closer,Greg Clayton2010-10-184-34/+59
| | | | | | | | | | | but something is still killing our inferior. Fixed an issue with darwin-debug where it wasn't passing all needed arguments to the inferior. Fixed a race condition with the attach to named process code. llvm-svn: 116697
* Fixed an issue with MachTask::TaskResume () where if the task was alreadyGreg Clayton2010-10-161-2/+6
| | | | | | | suspended, we would call "int ::task_resume (task_t task);" as many times as it took to resume the task which isn't what we want to do. llvm-svn: 116674
* Retry task_for_pid a few times to avoid some cases where task_for_pid fails.Greg Clayton2010-09-302-23/+34
| | | | llvm-svn: 115184
* Another patch from Jean-Daniel. Thanks.Johnny Chen2010-09-283-5/+5
| | | | | | Error in dbg server -> MachProcess::SetProcessID() and misc changes to make clang++ happy. llvm-svn: 114962
* Got the ARM version of debugserver up to date. Greg Clayton2010-09-093-166/+422
| | | | | | | | | 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-312-13/+16
| | | | | | | | 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-303-54/+37
| | | | | | | | 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
* More leaks detection:Greg Clayton2010-07-021-0/+2
| | | | | | | | | | - fixed 3 posix spawn attributes leaks - fixed us always leaking CXXBaseSpecifier objects when we create class base classes. Clang apparently copies the base classes we pass in. Fixed some code formatting in ClangASTContext.cpp. llvm-svn: 107459
* Initial checkin of lldb code from internal Apple repo.Chris Lattner2010-06-0832-0/+12844
llvm-svn: 105619
OpenPOWER on IntegriCloud