summaryrefslogtreecommitdiffstats
path: root/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
Commit message (Collapse)AuthorAgeFilesLines
* lldb arm64 import.Jason Molenda2014-03-291-0/+149
| | | | | | | | | | | | | | | | 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
* Wait for the reply from the 'D' detach packet before tearing down the ↵Jim Ingham2014-03-281-2/+4
| | | | | | | | | | | | debugger. Avoids a race condition where we could end up killing debugserver (and thus the target) before it had a chance to detach. Also fix debugserver to send the OK AFTER it detaches to avoid the same race condition. <rdar://problem/16202713> llvm-svn: 205043
* Add ProcessGDBRemote::GetAuxvData() and fix multiple-packet concatenation ↵Steve Pucci2014-03-041-6/+18
| | | | | | | | | | 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 useless declarationSylvestre Ledru2014-02-261-2/+0
| | | | llvm-svn: 202281
* Patch for fixing the handling of hardware breakpoints.Deepak Panickal2014-02-241-16/+18
| | | | | | Differential Revision: http://llvm-reviews.chandlerc.com/D2826 llvm-svn: 202028
* Improved the GDBRemoteCommunicationClient::TestPacketSpeed() function so it ↵Greg Clayton2014-02-211-32/+68
| | | | | | tests how long it takes to send a 4MB buffer from the REMOTE GDB server to LLDB. llvm-svn: 201875
* Change DecodeProcessInfoResponse to set the ProcessInfo's architecture Jason Molenda2014-01-271-0/+31
| | | | | | | | | if the remote stub provided enough information to identify it in the qProcessInfo packet response. (e.g. for an Apple device where we know it is Mach-O, the cpu type & cpu sub type). <rdar://problem/15847901> llvm-svn: 200253
* Support for debugging against a remote stock gdbserver.Steve Pucci2014-01-251-1/+146
| | | | | | | | | | There are a couple of pieces: * some lazy-evaluation members that store info listed in a qSupported response * new method SendPacketsAndConcatenateResponses which is used for fetching fixed-size objects from the remote gdbserver by using multiple packets if necessary (first use will be to fetch shared-library XML files). llvm-svn: 200072
* Added distribution info to ArchSpec and qHostInfo message.Todd Fiala2014-01-181-1/+11
| | | | | | | | | | | | | | | | | | | ArchSpec now contains an optional distribution_id, with getters and setters. Host::GetArchitecture () sets it on non-Apple platforms using Host::GetDistributionId (). The distribution_id is ignored during ArchSpec comparisons. The gdb remote qHostInfo message transmits it, if set, via the distribution_id={id-value} key/value pair. Updated gdb remote docs to reflect this change. As before, GetDistributionId () returns nothing on non-Linux platforms at this time. On Linux, it is returned only if the lsb_platform command is installed (in /bin or /usr/bin), and only if the distributor id key is returned by 'lsb_platform -i'. This id is lowercased, and whitespace is replaced with underscores. llvm-svn: 199539
* Workaround QEMU GDB server issue. Ed Maste2013-12-181-0/+8
| | | | | | | | | During testing I observed QEMU send "$T02thread:01;#04" upon connection, before any command from LLDB. This change from gclayton accepts (and discards) a packet immediately after sending the initial ack, to flush the GDB remote pipeline. llvm-svn: 197579
* Fix a bug introduced in asynchronous packet sends. We were not setting the ↵Jim Ingham2013-12-181-6/+9
| | | | | | | | | | packet result, and so it looked like the async packet send always failed. <rdar://problem/15657157> llvm-svn: 197543
* Fixed the GDBRemoteCommuncation to return a new ↵Greg Clayton2013-12-061-91/+86
| | | | | | | | | | | | | | 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
* Allow the hostname to be specified when asking a platform to launch another ↵Greg Clayton2013-12-041-8/+13
| | | | | | | | debugserver in case you want to change it. The GDB server remote platform how has the debugserver that are launched on iOS devices to use localhost due to the use of a USB mux. llvm-svn: 196405
* Improved platform support.Greg Clayton2013-11-231-5/+25
| | | | | | | | | | | | 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
* Added new options to lldb-platform:Greg Clayton2013-11-211-1/+1
| | | | | | | | | | | | | | | --gdbserver-port PORT --min-gdbserver-port PORT --max-gdbserver-port PORT The --gdbserver-port option can be specified multiple times to tell lldb-platform which ports it can use when launching child GDB server processes. The --min-gdbserver-port and --max-gdbserver-port options allow a range of ports to be specified for use when launching child GDB server processes. Fixed the code to manage these ports correctly in GDBRemoteCommunicationServer. Also changed GDBRemoteCommunicationClient to not set a port when sending the "qLaunchGDBServer" packet so that the remote lldb-platform can decide which ports to use. If the lldb-platform was launched with no --gdbserver-port or --min-gdbserver-port/--max-gdbserver-port options, then port 0 is always used and a unix socket is used between the lldb-platform and child GDB server process to coordinate the use of valid port. llvm-svn: 195300
* Expose SBPlatform through the public API.Greg Clayton2013-11-201-30/+179
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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/15172417>Greg Clayton2013-11-131-0/+133
| | | | | | | | | | | | | | | Added two new GDB server packets to debugserver: "QSaveRegisterState" and "QRestoreRegiterState". "QSaveRegisterState" makes the remote GDB server save all register values and it returns a save identifier as an unsigned integer. This packet can be used prior to running expressions to save all registers. All registers can them we later restored with "QRestoreRegiterState:SAVEID" what SAVEID is the integer identifier that was returned from the call to QSaveRegisterState. Cleaned up redundant code in lldb_private::Thread, lldb_private::ThreadPlanCallFunction. Moved the lldb_private::Thread::RegisterCheckpoint into its own header file and it is now in the lldb_private namespace. Trimmed down the RegisterCheckpoint class to omit stuff that wasn't used (the stack ID). Added a few new virtual methods to lldb_private::RegisterContext that allow subclasses to efficiently save/restore register states and changed the RegisterContextGDBRemote to take advantage of these new calls. llvm-svn: 194621
* <rdar://problem/15263540>Greg Clayton2013-10-251-1/+22
| | | | | | | | 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
* Fixes to get LLDB building on Windows again.Deepak Panickal2013-10-221-1/+1
| | | | llvm-svn: 193159
* <rdar://problem/14972424>Greg Clayton2013-10-151-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* <rdar://problem/14146606>Greg Clayton2013-10-101-7/+57
| | | | | | Fixed an issue where environment variables that contained special characters '$' and '#' would hose up the GDB server packet. We now use the QEnvironmentHexEncoded packet that has existed for a long time when we need to. Also added code that will stop sending the QEnvironmentHexEncoded and QEnvironment packets if they aren't supported. llvm-svn: 192373
* Value stored to 'pid' was never read. Found by scan-build ↵Sylvestre Ledru2013-10-061-1/+1
| | | | | | http://buildd-clang.debian.net/scan-build/ llvm-svn: 192060
* Fixed detection of 'p' packet support in debugserver,Sean Callanan2013-09-041-2/+10
| | | | | | | | | | by appending the thread ID to the test packet when debugserver requires it. This allows register writing (and, by extension, expressions) to work on Mac OS X. llvm-svn: 190007
* Fix a bunch of compile time warnings and a build failure on ubuntu.Eric Christopher2013-08-301-1/+1
| | | | llvm-svn: 189683
* Discover support of 'p' packet.Hafiz Abid Qadeer2013-08-291-0/+20
| | | | | | | Some stubs only support g/G packets for registers. This change makes sure that we check if remote stub supports 'p' packet before using it. llvm-svn: 189576
* Add missing "sys/stat.h" includeDaniel Malea2013-08-281-0/+2
| | | | | | - should help with FreeBSD buildbot llvm-svn: 189487
* merge lldb-platform-work branch (and assorted fixes) into trunkDaniel Malea2013-08-261-6/+363
| | | | | | | | | | | | | | | | | | | | | | | | | | Summary: This merge brings in the improved 'platform' command that knows how to interface with remote machines; that is, query OS/kernel information, push and pull files, run shell commands, etc... and implementation for the new communication packets that back that interface, at least on Darwin based operating systems via the POSIXPlatform class. Linux support is coming soon. Verified the test suite runs cleanly on Linux (x86_64), build OK on Mac OS X Mountain Lion. Additional improvements (not in the source SVN branch 'lldb-platform-work'): - cmake build scripts for lldb-platform - cleanup test suite - documentation stub for qPlatform_RunCommand - use log class instead of printf() directly - reverted work-in-progress-looking changes from test/types/TestAbstract.py that work towards running the test suite remotely. - add new logging category 'platform' Reviewers: Matt Kopec, Greg Clayton Review: http://llvm-reviews.chandlerc.com/D1493 llvm-svn: 189295
* MingW compilation (windows). Includes various refactoring to improve ↵Virgile Bello2013-08-231-0/+5
| | | | | | portability. llvm-svn: 189107
* <rdar://problem/14182286>Han Ming Ong2013-06-241-2/+2
| | | | | | | | Made sure that temporary object created from HarmonizeThreadIdsForProfileData() doesn’t get passed around without creating an object first. Reviewed by Greg llvm-svn: 184769
* Sort out a number of mismatched integer types in order to cut down the ↵Andy Gibbs2013-06-191-14/+14
| | | | | | number of compiler warnings. llvm-svn: 184333
* Recommitting r180831 with trivial fix - remember to return errors if you ↵Jim Ingham2013-05-021-3/+42
| | | | | | compute. llvm-svn: 180898
* Reverting 180831 as it crashes TestDefaultConstructorForAPIObjects.pyDaniel Malea2013-05-011-42/+3
| | | | llvm-svn: 180868
* Added an option to "process detach" to keep the process stopped, if the ↵Jim Ingham2013-04-301-3/+42
| | | | | | | | | | process plugin (or in the case of ProcessGDBRemote the stub we are talking to) know how to do that. rdar://problem/13680832 llvm-svn: 180831
* <rdar://problem/13521159>Greg Clayton2013-03-271-5/+5
| | | | | | | | LLDB is crashing when logging is enabled from lldb-perf-clang. This has to do with the global destructor chain as the process and its threads are being torn down. All logging channels now make one and only one instance that is kept in a global pointer which is never freed. This guarantees that logging can correctly continue as the process tears itself down. llvm-svn: 178191
* Fix a handful of remaining assumptions that thread IDs were 32-bitsJason Molenda2013-02-231-12/+12
| | | | | | in the gdb-remote Process plugin files. llvm-svn: 175947
* <rdar://problem/13190981>Greg Clayton2013-02-221-4/+5
| | | | | | Fixed an issue where if we got a 'A' async packet back from debugserver, we would resend the last continue command. We now correctly identify the packet as async (just like the 'O' stdout async packet) and we don't resend the continue command. llvm-svn: 175924
* <rdar://problem/12976277>Han Ming Ong2013-01-181-4/+119
| | | | | | Swap in index ids for thread ids in GDBRemoteCommunicationClient. Besides dealing with the async logic, I have to take care of the situation when the inferior paused as well. llvm-svn: 172869
* <rdar://problem/11961650> Jason Molenda2012-12-191-0/+106
| | | | | | | | | | | | | | | | | Update the debugserver "qProcessInfo" implementation to return the cpu type, cpu subtype, OS and vendor information just like qHostInfo does so lldb can create an ArchSpec based on the returned values. Add a new GetProcessArchitecture to GDBRemoteCommunicationClient akin to GetHostArchitecture. If the qProcessInfo packet is supported, GetProcessArchitecture will return the cpu type / subtype of the process -- e.g. a 32-bit user process running on a 64-bit x86_64 Mac system. Have ProcessGDBRemote set the Target's architecture based on the GetProcessArchitecture when we've completed an attach/launch/connect. llvm-svn: 170491
* More Linux warnings fixes (remove default labels as needed):Daniel Malea2012-12-071-2/+0
| | | | | | | | - as per http://llvm.org/docs/CodingStandards.html#don-t-use-default-labels-in-fully-covered-switches-over-enumerations Patch by Matt Kopec! llvm-svn: 169633
* Resolve printf formatting warnings on Linux:Daniel Malea2012-11-291-11/+11
| | | | | | | | - use macros from inttypes.h for format strings instead of OS-specific types Patch from Matt Kopec! llvm-svn: 168945
* <rdar://problem/12720514> Sub-TLF: Provide service to profile the inferiorHan Ming Ong2012-11-171-0/+10
| | | | | | This allows client to query profiling states on the inferior. llvm-svn: 168228
* Make sure we always use lldb::tid_t for thread IDs so we don't truncate a 64 ↵Greg Clayton2012-10-131-2/+2
| | | | | | bit thread ID. llvm-svn: 165862
* Stop using the "%z" size_t modifier and cast all size_t values to uint64_t. ↵Greg Clayton2012-09-181-1/+2
| | | | | | 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/+23
| | | | | | | | | | | 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
* Add "vAttachOrWait" to debugserver, so you can implement "attach to the ↵Jim Ingham2012-07-201-0/+21
| | | | | | 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-3/+3
| | | | llvm-svn: 160338
* <rdar://problem/11782789> Changes to the watchpoint implementation on ARM so ↵Enrico Granata2012-07-131-0/+36
| | | | | | that we single-step before stopping at the WP. This is necessary because on ARM the WP triggers before the opcode is actually executed, so we would be unable to continue since we would keep hitting the WP. We work around this by disabling the WP, single stepping and then putting the WP back in place. llvm-svn: 160199
* <rdar://problem/11744001>Greg Clayton2012-07-021-0/+1
| | | | | | Fixed an issue where GDB servers that don't support the thread suffix could get registers states incorrectly due to an incorrect assumption that the current register thread (set using the "Hg%x" packet) will always be cached between runs. Now we clear the cached register thred when the process is resumed. llvm-svn: 159603
* Make the error message when we time out waiting for debugserver to reply to ↵Jim Ingham2012-06-281-1/+1
| | | | | | | | the qLaunchSuccess packet less cryptic. <rdar://problem/11754744> llvm-svn: 159373
* Change the Mutex::Locker class so that it takes the Mutex object and locks ↵Jim Ingham2012-06-081-1/+5
| | | | | | | | | | | | | | it, rather than being given the pthread_mutex_t from the Mutex and locks that. That allows us to track ownership of the Mutex better. Used this to switch the LLDB_CONFIGURATION_DEBUG enabled assert when we can't get the gdb-remote sequence mutex to assert when the thread that had the mutex releases it. This is generally more useful information than saying just who failed to get it (since the code that had it locked often had released it by the time the assert fired.) llvm-svn: 158240
OpenPOWER on IntegriCloud