summaryrefslogtreecommitdiffstats
path: root/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Create a HostThread abstraction.Zachary Turner2014-09-091-25/+13
| | | | | | | | | | | | | This patch moves creates a thread abstraction that represents a thread running inside the LLDB process. This is a replacement for otherwise using lldb::thread_t, and provides a platform agnostic interface to managing these threads. Differential Revision: http://reviews.llvm.org/D5198 Reviewed by: Jim Ingham llvm-svn: 217460
* Consolidate UnixSignals setting/getting in Process.Todd Fiala2014-08-291-12/+4
| | | | | | | | | | | | | | | | See http://reviews.llvm.org/D5108 for details. This change does the following: * eliminates the Process::GetUnixSignals() virtual method and replaces with a fixed getter. * replaces the Process UnixSignals storage with a shared pointer. * adds a Process constructor variant that can be passed the UnixSignalsSP. When the constructor without the UnixSignalsSP is specified, the Host's default UnixSignals is used. * adds a host-specific version of GetUnixSignals() that is used when we need the host's appropriate UnixSignals variant. * replaces GetUnixSignals() overrides in PlatformElfCore, ProcessGDBRemote, ProcessFreeBSD and ProcessLinux with code that appropriately sets the Process::UnixSignals for the process. This change also enables some future patches that will enable llgs to be used for local Linux debugging. llvm-svn: 216748
* Move FileSystem functions out of Host and into their own classes.Zachary Turner2014-08-151-3/+3
| | | | | | | | | | | | | | | | More specifically, this change can be summarized as follows: 1) Makes an lldbHostPosix library which contains code common to all posix platforms. 2) Creates Host/FileSystem.h which defines a common FileSystem interface. 3) Implements FileSystem.h in Host/windows and Host/posix. 4) Creates Host/FileCache.h, implemented in Host/common, which defines a class useful for storing handles to open files needed by the debugger. Differential Revision: http://reviews.llvm.org/D4889 llvm-svn: 215775
* Refactor FileAction out of ProcessLaunchInfo.Zachary Turner2014-08-141-4/+4
| | | | | | | | | | | | | FileAction was previously a nested class in ProcessLaunchInfo. This led to some unfortunate style consequences, such as requiring the AddPosixSpawnFileAction() funciton to be defined in the Target layer, instead of the more appropriate Host layer. This patch makes FileAction its own independent class in the Target layer, and then moves AddPosixSpawnFileAction() into Host as a result. Differential Revision: http://reviews.llvm.org/D4877 llvm-svn: 215649
* Change ProcessGDBRemote::DidLaunchOrAttach to Jason Molenda2014-08-031-2/+2
| | | | | | | | call Target::SetArchitecture instead of modifying a reference to the target's architecture so that the target logging can show that the arch has been changed. llvm-svn: 214667
* After you attach, give the process plugin a chance to report back (throughJim Ingham2014-08-021-12/+16
| | | | | | | | DidAttach) the architecture of the binary you attached to. <rdar://problem/17891396> llvm-svn: 214603
* __arm64__ and __aarch64__ #ifdef adjustmentsTodd Fiala2014-07-091-2/+2
| | | | | | | | Change by Paul Osmialowski See http://reviews.llvm.org/D4379 for details. llvm-svn: 212583
* Fix typos.Bruce Mitchener2014-07-011-4/+4
| | | | llvm-svn: 212132
* Add lldb-gdbserver support for Linux x86_64.Todd Fiala2014-06-301-2/+58
| | | | | | | | | | | | | | | | | | | | | This change brings in lldb-gdbserver (llgs) specifically for Linux x86_64. (More architectures coming soon). Not every debugserver option is covered yet. Currently the lldb-gdbserver command line can start unattached, start attached to a pid (process-name attach not supported yet), or accept lldb attaching and launching a process or connecting by process id. The history of this large change can be found here: https://github.com/tfiala/lldb/tree/dev-tfiala-native-protocol-linux-x86_64 Until mid/late April, I was not sharing the work and continued to rebase it off of head (developed via id tfiala@google.com). I switched over to user todd.fiala@gmail.com in the middle, and once I went to github, I did merges rather than rebasing so I could share with others. llvm-svn: 212069
* Added an option to turn OFF the "detach on error" behavior that was addedJim Ingham2014-06-251-0/+5
| | | | | | | | to debugserver when launching processes. <rdar://problem/16216199> llvm-svn: 211658
* Initial merge of some of the iOS 8 / Mac OS X Yosemite specificJason Molenda2014-06-131-0/+45
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | lldb support. I'll be doing more testing & cleanup but I wanted to get the initial checkin done. This adds a new SBExpressionOptions::SetLanguage API for selecting a language of an expression. I added adds a new SBThread::GetInfoItemByPathString for retriving information about a thread from that thread's StructuredData. I added a new StructuredData class for representing key-value/array/dictionary information (e.g. JSON formatted data). Helper functions to read JSON and create a StructuredData object, and to print a StructuredData object in JSON format are included. A few Cocoa / Cocoa Touch data formatters were updated by Enrico to track changes in iOS 8 / Yosemite. Before we query a thread's extended information, the system runtime may provide hints to the remote debug stub that it will use to retrieve values out of runtime structures. I added a new SystemRuntime method AddThreadExtendedInfoPacketHints which allows the SystemRuntime to add key-value type data to the initial request that we send to the remote stub. The thread-format formatter string can now retrieve values out of a thread's extended info structured data. The default thread-format string picks up two of these - thread.info.activity.name and thread.info.trace_messages. I added a new "jThreadExtendedInfo" packet in debugserver; I will add documentation to the lldb-gdb-remote.txt doc soon. It accepts JSON formatted arguments (most importantly, "thread":threadnum) and it returns a variety of information regarding the thread to lldb in JSON format. This JSON return is scanned into a StructuredData object that is associated with the thread; UI layers can query the thread's StructuredData to see if key-values are present, and if so, show them to the user. These key-values are likely to be specific to different targets with some commonality among many targets. For instance, many targets will be able to advertise the pthread_t value for a thread. I added an initial rough cut of "thread info" command which will print the information about a thread from the jThreadExtendedInfo result. I need to do more work to make this format reasonably. Han Ming added calls into the pmenergy and pmsample libraries if debugserver is run on Mac OS X Yosemite to get information about the inferior's power use. I added support to debugserver for gathering the Genealogy information about threads, if it exists, and returning it in the jThreadExtendedInfo JSON result. llvm-svn: 210874
* Add support for gdb remote $X stop notification.Todd Fiala2014-05-191-0/+1
| | | | | | | | | | | | | | debugserver now returns $X09 as the immediate response to a $k kill process request rather than $W09. ProcessGDBRemote now properly handles X as indication of a process exit state. The @debugserver_test and @lldb_test for $k now properly expects an X notification (signal-caused exit) after killing a just-attached inferior that was still in the stopped state. llvm-svn: 209108
* Change ProcessGDBRemote::DoReadMemory to use the x packet to readJason Molenda2014-05-061-3/+146
| | | | | | | | | | | | | | | | data if it is available. Change ProcessGDBRemote's maximum read/write packet size from a fixed 512 byte value to asking the remote gdb stub what its maximum is, using up to 128kbyte sizes if that's allowed, and falling back to 512 if the remote gdb stub doesn't advertise a max packet size. Add a new "process plugin packet xfer-size" command that can be used to override the maximum packet size (although not exceeding any packet size maximum published by the remote gdb stub). <rdar://problem/16032150> llvm-svn: 208058
* sweep up -Wformat warnings from gccSaleem Abdulrasool2014-04-041-11/+7
| | | | | | | This is a purely mechanical change explicitly casting any parameters for printf style conversion. This cleans up the warnings emitted by gcc 4.8 on Linux. llvm-svn: 205607
* Add a missing arm64 idef.Jason Molenda2014-04-021-1/+1
| | | | llvm-svn: 205488
* lldb arm64 import.Jason Molenda2014-03-291-4/+46
| | | | | | | | | | | | | | | | 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
* Move calls to DisableAllBreakpointSites() and ↵Andrew MacPherson2014-03-251-4/+0
| | | | | | m_thread_list.DiscardThreadPlans() into base Process::Destroy() instead of in subclass DoDestroy() methods. llvm-svn: 204752
* JITed functions can now have debug info and be debugged with debug and ↵Greg Clayton2014-03-241-0/+1
| | | | | | | | | | | | | | | | | | | source info: (lldb) b puts (lldb) expr -g -i0 -- (int)puts("hello") First we will stop at the entry point of the expression before it runs, then we can step over a few times and hit the breakpoint in "puts", then we can continue and finishing stepping and fininsh the expression. Main features: - New ObjectFileJIT class that can be easily created for JIT functions - debug info can now be enabled when parsing expressions - source for any function that is run throught the JIT is now saved in LLDB process specific temp directory and cleaned up on exit - "expr -g --" allows you to single step through your expression function with source code <rdar://problem/16382881> llvm-svn: 204682
* cleanup unreferenced functionsSaleem Abdulrasool2014-03-201-4/+5
| | | | | | | | | | | | | This is a mechanical cleanup of unused functions. In the case where the functions are referenced (in comment form), I've simply commented out the functions. A second pass to clean that up is warranted. The functions which are otherwise unused have been removed. Some of these were introduced in the initial commit and not in use prior to that point! NFC llvm-svn: 204310
* Update copy-and-pasted log messageEd Maste2014-03-171-1/+1
| | | | llvm-svn: 204057
* If you are disabling a hardware breakpoint, use z1 not z0.Jim Ingham2014-03-071-1/+9
| | | | | | <rdar://problem/16256532> llvm-svn: 203232
* Add ProcessGDBRemote::GetAuxvData() and fix multiple-packet concatenation ↵Steve Pucci2014-03-041-0/+13
| | | | | | | | | | for binary data. ProcessGDBRemote::GetAuxvData obtains the auxv from a remote gdbserver (via a binary-data packet), and returns the data as a DataBufferSP. The patch includes a small fix to GDBRemoteCommunicationClient::SendPacketsAndConcatenateResponses() to support binary file format packet returns (by not assuming each binary packet is a null-terminated string when concatenating them). llvm-svn: 202907
* Remove an assertion that was being hit due to slow DNS name lookups on ↵Greg Clayton2014-02-271-1/+1
| | | | | | | | | | MacOSX for "localhost". Changed all "localhost" to "127.0.0.1" to prevent potentially long name lookups. <rdar://problem/16154630> llvm-svn: 202424
* Don’t process the stop reply packet as a generic signal if we already ↵Jim Ingham2014-02-241-1/+1
| | | | | | figured out what it was from other data in the packet. llvm-svn: 202066
* Patch for fixing the handling of hardware breakpoints.Deepak Panickal2014-02-241-43/+79
| | | | | | Differential Revision: http://llvm-reviews.chandlerc.com/D2826 llvm-svn: 202028
* Oops, probably ought to turn on that fix...Jim Ingham2014-02-211-1/+1
| | | | llvm-svn: 201897
* We have to call waitpid on the lldb side for Mac OS X (even though we've ↵Jim Ingham2014-02-211-0/+18
| | | | | | | | successfully called it on the debugserver side) when we kill a process or it leaves a zombie around. llvm-svn: 201896
* Improve the handling of stop-reply packet when it does not containHafiz Abid Qadeer2014-02-201-0/+15
| | | | | | thread information. llvm-svn: 201773
* Fixed deadlocks that could occur when using python for breakpoints, ↵Greg Clayton2014-02-131-1/+5
| | | | | | | | | operating system plugins, and other async python usage. <rdar://problem/16054348> <rdar://problem/16040833> llvm-svn: 201372
* Merging the iohandler branch back into main. Greg Clayton2014-01-271-22/+0
| | | | | | | | | | | | The many many benefits include: 1 - Input/Output/Error streams are now handled as real streams not a push style input 2 - auto completion in python embedded interpreter 3 - multi-line input for "script" and "expression" commands now allow you to edit previous/next lines using up and down arrow keys and this makes multi-line input actually a viable thing to use 4 - it is now possible to use curses to drive LLDB (please try the "gui" command) We will need to deal with and fix any buildbot failures and tests and arise now that input/output and error are correctly hooked up in all cases. llvm-svn: 200263
* Test new committer permission with one-line trailing whitespace removal.Steve Pucci2014-01-161-1/+1
| | | | llvm-svn: 199432
* Revert to getting a random port and sending that down to debugserver for ↵Greg Clayton2014-01-101-5/+45
| | | | | | | | iOS. The sandboxing is not letting debugserver reverse connect back to lldb. <rdar://problem/15789865> llvm-svn: 198963
* Fixes a bug preventing reading of the python register file.Todd Fiala2014-01-081-0/+4
| | | | | | | | | | This change fixes a bug recently introduced in ProcessGDBRemote that prevented the Python register definition file from getting loaded when the qRegisterInfo0 response returned $00#. Patch by Steve Pucci. llvm-svn: 198742
* Remove wait_for_launch parameter from DoAttachToProcessWithName(). This ↵Jean-Daniel Dupas2013-12-231-2/+2
| | | | | | | | | | parameter is redundant as this information is already provided by the ProcessAttachInfo parameter. CC: lldb-commits Differential Revision: http://llvm-reviews.chandlerc.com/D2463 llvm-svn: 197923
* Any time ProcessGDBRemote tries to get the remote's ProcessArchitecture,Jason Molenda2013-12-211-5/+20
| | | | | | | | | | it needs to fall back to using the HostArchitecture if a valid one is not returned. When doing low-level system debugging we may not have a process (or the remote stub may not support the qProcessInfo packet) in which case we should fall back to the architecture we determined via qHostInfo. <rdar://problem/15713180> llvm-svn: 197857
* Remove 'const' constraint on ProcessLaunchInfo parameter in Process::DoLaunch().Jean-Daniel Dupas2013-12-091-1/+1
| | | | | | This 'const' is not required and prevent us to defer the launch to the Host layer. llvm-svn: 196837
* Fixed the GDBRemoteCommuncation to return a new ↵Greg Clayton2013-12-061-6/+6
| | | | | | | | | | | | | | GDBRemoteCommuncation::PacketResult enum for all packet sends/receives. <rdar://problem/15600045> Due to other recent changes, all connections to GDB servers that didn't support the "QStartNoAckMode" packet would cause us to fail to attach to the remote GDB server. The problem was that SendPacket* and WaitForResponse* packets would return a size_t indicating the number of bytes sent/received. The other issue was WaitForResponse* packets would strip the leading '$' and the trailing "#CC" (checksum) bytes, so the unimplemented response packet of "$#00" would get stripped and the WaitForResponse* packets would return 0. These new error codes give us flexibility to to more intelligent things in response to what is returned. llvm-svn: 196610
* Modified local spawning in debugserver processes to use a new ↵Greg Clayton2013-12-051-28/+39
| | | | | | | | | | | | | | | | | | --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-196/+26
| | | | | | | | | | 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
* Improved platform support.Greg Clayton2013-11-231-3/+1
| | | | | | | | | | | | Improved the detection of a valid GDB server where we actually can connect to a socket, but then it doesn't read or write anything (which happens with some USB mux software). Host::MakeDirectory() now can make as many intermediate directories as needed. The testsuite now has very initial support for remote test suite running. When running on a remote platform, the setUp function for the test will make a new directory and select it as the working directory on the remote host. Added a common function that can be used to create the short option string for getopt_long calls. llvm-svn: 195541
* Expose SBPlatform through the public API.Greg Clayton2013-11-201-1/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Example code: remote_platform = lldb.SBPlatform("remote-macosx"); remote_platform.SetWorkingDirectory("/private/tmp") debugger.SetSelectedPlatform(remote_platform) connect_options = lldb.SBPlatformConnectOptions("connect://localhost:1111"); err = remote_platform.ConnectRemote(connect_options) if err.Success(): print >> result, 'Connected to remote platform:' print >> result, 'hostname: %s' % (remote_platform.GetHostname()) src = lldb.SBFileSpec("/Applications/Xcode.app/Contents/SharedFrameworks/LLDB.framework", False) dst = lldb.SBFileSpec() # copy src to platform working directory since "dst" is empty err = remote_platform.Install(src, dst); if err.Success(): print >> result, '%s installed successfully' % (src) else: print >> result, 'error: failed to install "%s": %s' % (src, err) Implemented many calls needed in lldb-platform to be able to install a directory that contains symlinks, file and directories. The remote lldb-platform can now launch GDB servers on the remote system so that remote debugging can be spawned through the remote platform when connected to a remote platform. The API in SBPlatform is subject to change and will be getting many new functions. llvm-svn: 195273
* <rdar://problem/15263540>Greg Clayton2013-10-251-0/+18
| | | | | | | | Added a new key that we understand for the "qHostInfo" packet: "default_packet_timeout:T;" where T is a default packet timeout in seconds. This allows GDB servers with known slow packet response times to increase the default timeout to a value that makes sense for the connection. llvm-svn: 193425
* Fix python-free build.Joerg Sonnenberger2013-10-201-0/+4
| | | | llvm-svn: 193053
* Adjust PC after hitting breakpoint on remote target.Hafiz Abid Qadeer2013-10-181-2/+7
| | | | | | | | This commit adds an example python file that can be used with 'target-definition-file' setting for Linux gdbserver. This file has an extra key 'breakpoint-pc-offset' that LLDB uses to determine how much to change the PC after hitting the breakpoint. llvm-svn: 192962
* Move the code which translates a dispatch_qaddr into aJason Molenda2013-10-181-94/+0
| | | | | | | | | | | | queue name out of ProcessGDBRemote and in to the Platform plugin, specifically PlatformDarwin. Also add a Platform method to translate a dispatch_quaddr to a QueueID, and a Thread::GetQueueID(). I'll add an SBThread::GetQueueID() next. llvm-svn: 192949
* <rdar://problem/14972424>Greg Clayton2013-10-171-6/+17
| | | | | | | | | | | | | | | - Made the dynamic register context for the GDB remote plug-in inherit from the generic DynamicRegisterInfo to avoid code duplication - Finished up the target definition python setting stuff. - Added a new "slice" key/value pair that can specify that a register is part of another register: { 'name':'eax', 'set':0, 'bitsize':32, 'encoding':eEncodingUint, 'format':eFormatHex, 'slice': 'rax[31:0]' }, - Added a new "composite" key/value pair that can specify that a register is made up of two or more registers: { 'name':'d0', 'set':0, 'bitsize':64 , 'encoding':eEncodingIEEE754, 'format':eFormatFloat, 'composite': ['s1', 's0'] }, - Added a new "invalidate-regs" key/value pair for when a register is modified, it can invalidate other registers: { 'name':'cpsr', 'set':0, 'bitsize':32 , 'encoding':eEncodingUint, 'format':eFormatHex, 'invalidate-regs': ['r8', 'r9', 'r10', 'r11', 'r12', 'r13', 'r14', 'r15']}, This now completes the feature that allows a GDB remote target to completely describe itself. llvm-svn: 192858
* <rdar://problem/14972424>Greg Clayton2013-10-151-1/+49
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When debugging with the GDB remote in LLDB, LLDB uses special packets to discover the registers on the remote server. When those packets aren't supported, LLDB doesn't know what the registers look like. This checkin implements a setting that can be used to specify a python file that contains the registers definitions. The setting is: (lldb) settings set plugin.process.gdb-remote.target-definition-file /path/to/module.py Inside module there should be a function: def get_dynamic_setting(target, setting_name): This dynamic setting function is handed the "target" which is a SBTarget, and the "setting_name", which is the name of the dynamic setting to retrieve. For the GDB remote target definition the setting name is 'gdb-server-target-definition'. The return value is a dictionary that follows the same format as the OperatingSystem plugins follow. I have checked in an example file that implements the x86_64 GDB register set for people to see: examples/python/x86_64_target_definition.py This allows LLDB to debug to any archticture that is support and allows users to define the registers contexts when the discovery packets (qRegisterInfo, qHostInfo) are not supported by the remote GDB server. A few benefits of doing this in Python: 1 - The dynamic register context was already supported in the OperatingSystem plug-in 2 - Register contexts can use all of the LLDB enumerations and definitions for things like lldb::Format, lldb::Encoding, generic register numbers, invalid registers numbers, etc. 3 - The code that generates the register context can use the program to calculate the register context contents (like offsets, register numbers, and more) 4 - True dynamic detection could be used where variables and types could be read from the target program itself in order to determine which registers are available since the target is passed into the python function. This is designed to be used instead of XML since it is more dynamic and code flow and functions can be used to make the dictionary. llvm-svn: 192646
* Set the architecture from the remote executable when it's not set so the ↵Carlo Kok2013-10-141-0/+9
| | | | | | register info can be loaded properly (and thus the callstacks work) llvm-svn: 192571
* <rdar://problem/13635174>Greg Clayton2013-10-111-4/+11
| | | | | | | | Added a way to set hardware breakpoints from the "breakpoint set" command with the new "--hardware" option. Hardware breakpoints are not a request, they currently are a requirement. So when breakpoints are specified as hardware breakpoints, they might fail to be set when they are able to be resolved and should be used sparingly. This is currently hooked up for GDB remote debugging. Linux and FreeBSD should quickly enable this feature if possible, or return an error for any breakpoints that are hardware breakpoint sites in the "virtual Error Process::EnableBreakpointSite (BreakpointSite *bp_site);" function. llvm-svn: 192491
* MingW compilation (windows). Includes various refactoring to improve ↵Virgile Bello2013-08-231-3/+6
| | | | | | portability. llvm-svn: 189107
OpenPOWER on IntegriCloud