summaryrefslogtreecommitdiffstats
path: root/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Fix up the HostThread interface, making the interface simpler.Zachary Turner2014-09-231-5/+2
| | | | | | | Reviewed by: Greg Clayton Differential Revision: http://reviews.llvm.org/D5417 llvm-svn: 218325
* Add better logging for the "$vFile:pwrite:" packet so we can show binary ↵Greg Clayton2014-09-181-5/+33
| | | | | | data instead of nothing or unprintable characters. This can easily be extended for other packets that have binary data. llvm-svn: 218000
* Create a HostThread abstraction.Zachary Turner2014-09-091-6/+6
| | | | | | | | | | | | | 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
* Add arbitrary command line flags to llgs/debugserver startup for local ↵Todd Fiala2014-08-291-1/+19
| | | | | | | | | | | | | | | | | | | | debugging. This patch accepts environment variables of the form: LLDB_DEBUGSERVER_EXTRA_ARG_n where n starts with 1, and may continue nearly indefinitely (up through std::numeric_limits<uint32_t>::max()). The code loops around, starting with 1, until it doesn't find one of the environment variables. For each one it does find defined, it appends the environment variable's contents to the end of the debugserver/llgs startup command line issued when the stub is started for local debugging. I am using this to add arbitrary startup commands to the llgs command line for turning on additional logging. For example: export LLDB_DEBUGSERVER_EXTRA_ARG_1="-c" export LLDB_DEBUGSERVER_EXTRA_ARG_2="log enable -f /tmp/llgs_packets.log gdb-remote packets" export LLDB_DEBUGSERVER_EXTRA_ARG_3="-c" export LLDB_DEBUGSERVER_EXTRA_ARG_4="log enable -f /tmp/llgs_process.log lldb process" llvm-svn: 216745
* Fixes a few more places where we were manually setting the filename.Zachary Turner2014-08-211-1/+1
| | | | llvm-svn: 216247
* Two small fixes to get Mac native + debugserver working after theJason Molenda2014-08-211-1/+1
| | | | | | | HostInfo et al changes from Zachary. Changes suggested by Zachary - fixes the problems I was seeing. llvm-svn: 216243
* Move Host::GetLLDBPath to HostInfo.Zachary Turner2014-08-211-3/+4
| | | | | | | | This continues the effort to get Host code moved over to HostInfo, and removes many more instances of preprocessor defines along the way. llvm-svn: 216195
* Move FileSystem functions out of Host and into their own classes.Zachary Turner2014-08-151-1/+2
| | | | | | | | | | | | | | | | 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
* Creates a socket host object.Zachary Turner2014-08-061-2/+2
| | | | | | | | | | | | | | | | | | This patch moves the logic of many common socket operations into its own class lldb_private::Socket. It then modifies the ConnectionFileDescriptor class, and a few users of that class, to use this new Socket class instead of hardcoding socket logic directly. Finally, this patch creates a common interface called IOObject for any objects that support reading and writing, so that endpoints such as sockets and files can be treated the same. Differential Revision: http://reviews.llvm.org/D4641 Reviewed by: Todd Fiala, Greg Clayton llvm-svn: 214984
* Enable lldb-platform exe support for Linux.Todd Fiala2014-07-221-1/+19
| | | | | | | | | | | | | | This change enables lldb-platform for Linux. In addition, it does the following: * fixes Host::GetLLDBPath() to work on Linux/*BSD for ePathTypeSupportExecutableDir-relative paths. * adds more logging and comments around lldb-platform startup and remote lldb-platform usage. * refactors lldb-platform remote-* support for Darwin and Linux into PlatformPOSIX. This, in theory, is the bulk of what is needed for *BSD to make remote connections to lldb-platform as well (although I haven't tested that yet). FreeBSD can make similar changes to their Platform* as was made here for PlatformLinux to pick up the rest of the bits. * teaches GDBRemoteCommunication to use lldb-gdbserver for non-Apple hosts. llvm-svn: 213707
* Fixed the "log enable gdb-remote packets" to support dumping the binary ↵Greg Clayton2014-06-201-3/+42
| | | | | | memory read packet ('x') by printing out the binary data correctly using only printable characters and removing the 0x7d escapes so the memory is readable in the packet output. llvm-svn: 211400
* Fixed CTRL+C related issues:Greg Clayton2014-05-021-0/+1
| | | | | | | | | | | | - CTRL+C wasn't clearing the command in lldb - CTRL+C doesn't work in python macros in lldb - Ctrl+C no longer interrupts the running process that you attach to <rdar://problem/15949205> <rdar://problem/16778652> <rdar://problem/16774411> llvm-svn: 207816
* Replace some _MSC_VER with _WIN32.Hafiz Abid Qadeer2014-03-121-1/+1
| | | | | | | This allows to use some code for mingw which was previously only used for MSVC. llvm-svn: 203651
* Be sure to propagate the error back out SBTarget::Attach() when we fail to ↵Greg Clayton2014-02-281-22/+25
| | | | | | | | launch debugserver as root. <rdar://problem/15669788> llvm-svn: 202536
* Remove an assertion that was being hit due to slow DNS name lookups on ↵Greg Clayton2014-02-271-9/+17
| | | | | | | | | | MacOSX for "localhost". Changed all "localhost" to "127.0.0.1" to prevent potentially long name lookups. <rdar://problem/16154630> llvm-svn: 202424
* Fix handling of gdbserver binary packets with escape characters.Steve Pucci2014-02-241-0/+7
| | | | | | | We were not properly handling the escape character 0x7d ('}') in responses from gdbserver which used the binary protocol. llvm-svn: 202062
* hostname is guarantee to never be null in this branch.Jean-Daniel Dupas2014-02-081-1/+1
| | | | llvm-svn: 201027
* Initialize the named_pipe_path in ↵Jason Molenda2014-01-251-7/+1
| | | | | | | | | | GDBRemoteCommunication::StartDebugserverProcess right after the space for it is allocated on the stack, instead of trying to initialize it in all the different places in this method. It's too easy for another uninitialized code path to sneak in as it is written right now. llvm-svn: 200066
* Terminate an unused char* buffer correctly so we don't try to openJason Molenda2014-01-241-0/+1
| | | | | | | | it later in GDBRemoteCommunication::StartDebugserverProcess and report an error. <rdar://problem/15820813> llvm-svn: 200047
* Fixed the Visual Studio Windows buildDeepak Panickal2014-01-131-0/+4
| | | | llvm-svn: 199111
* Revert to getting a random port and sending that down to debugserver for ↵Greg Clayton2014-01-101-25/+49
| | | | | | | | iOS. The sandboxing is not letting debugserver reverse connect back to lldb. <rdar://problem/15789865> llvm-svn: 198963
* <rdar://problem/15639995>Han Ming Ong2013-12-121-4/+0
| | | | | | debugserver's launch info was cleared unnecessarily. It has important user ID set. Reviewed by Greg Clayton. llvm-svn: 197182
* Fixed the GDBRemoteCommuncation to return a new ↵Greg Clayton2013-12-061-21/+28
| | | | | | | | | | | | | | 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
* 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-23/+106
| | | | | | | | | | | | | | | | | | --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-40/+53
| | | | | | | | | | 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
* Fixed format strings as they still must specicy a '%' prior to using PRI*64 ↵Greg Clayton2013-10-231-4/+4
| | | | | | macros. llvm-svn: 193260
* Fixes to get LLDB building on Windows again.Deepak Panickal2013-10-221-4/+4
| | | | llvm-svn: 193159
* Clear 'packet_str' before putting new packet.Hafiz Abid Qadeer2013-08-281-0/+2
| | | | llvm-svn: 189484
* Handle run-length-encoding.Hafiz Abid Qadeer2013-08-281-2/+25
| | | | | | The change was taken from a patch by Virgile Bello. llvm-svn: 189470
* merge lldb-platform-work branch (and assorted fixes) into trunkDaniel Malea2013-08-261-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | 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
* Include checksum in non-ack modeEd Maste2013-08-201-6/+3
| | | | | | Patch from Abid, Hafiz. llvm-svn: 188801
* <rdar://problem/13521159>Greg Clayton2013-03-271-7/+7
| | | | | | | | 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
* Resolve printf formatting warnings on Linux:Daniel Malea2012-11-291-3/+3
| | | | | | | | - use macros from inttypes.h for format strings instead of OS-specific types Patch from Matt Kopec! llvm-svn: 168945
* Stop using the "%z" size_t modifier and cast all size_t values to uint64_t. ↵Greg Clayton2012-09-181-2/+2
| | | | | | Some platforms don't support this modification. llvm-svn: 164148
* Change the Mutex::Locker class so that it takes the Mutex object and locks ↵Jim Ingham2012-06-081-2/+2
| | | | | | | | | | | | | | 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
* Use Log::Printf() instead of printf().Johnny Chen2012-06-021-1/+2
| | | | llvm-svn: 157869
* <rdar://problem/11486302>Greg Clayton2012-05-311-1/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Fixed a case where multiple threads can be asking to send a packet to the GDB server and one of three things will happen: 1 - everything works 2 - one thread will fail to send the packet due to not being able to get the sequence mutex 3 - one thread will try and interrupt the other packet sending and fail and not send the packet Now the flow is a bit different. Prior to this fix we did: if (try_get_sequence_mutex()) { send_packet() return success; } else { if (async_ok) { interrupt() send_packet() resume() return success; } } return fail The issue is that the call to "try_get_sequence_mutex()" could fail if another thread was sending a packet and could cause us to just not send the packet and an error would be returned. What we really want is to try and get the sequence mutex, and if this succeeds, send the packet. Else check if we are running and if we are, do what we used to do. The big difference is when we aren't running, we wait for the sequence mutex so we don't drop packets. Pseudo code is: if (try_get_sequence_mutex()) { // Safe to send the packet right away send_packet() return success; } else { if (running) { // We are running, interrupt and send async packet if ok to do so, // else it is ok to fail if (async_ok) { interrupt() send_packet() resume() return success; } } else { // Not running, wait for the sequence mutex so we don't drop packets get_sequence_mutex() send_packet() return success; } } return fail llvm-svn: 157751
* Don't expose the pthread_mutex_t underlying the Mutex & Mutex::Locker classes. Jim Ingham2012-05-041-1/+1
| | | | | | | | | | | | | No one was using it and Locker(pthread_mutex_t *) immediately asserts for pthread_mutex_t's that don't come from a Mutex anyway. Rather than try to make that work, we should maintain the Mutex abstraction and not pass around the platform implementation... Make Mutex::Locker::Lock take a Mutex & or a Mutex *, and remove the constructor taking a pthread_mutex_t *. You no longer need to call Mutex::GetMutex to pass your mutex to a Locker (you can't in fact, since I made it private.) llvm-svn: 156221
* Added the thread ID (tid) to each packet history item and the packet history ↵Greg Clayton2012-04-131-9/+41
| | | | | | | | | | now always dumps to a lldb_private::Stream. Enable logging the packet history when registers fail to read due to not getting the sequence mutex if "--verbose" is enabled on the log channel for the "gdb-remote" log category. This will help us track down some issues. llvm-svn: 154704
* Remove the GetSequenceMutex timeout that isn't being used in the GDB remote ↵Greg Clayton2012-04-121-7/+2
| | | | | | | | plug-in. Also fixed the ProcessLinux, ProcessPOSIX and ProcessFreeBSD to have the correct UpdateThreadList() prototype. llvm-svn: 154603
* No functionality changes, mostly cleanup.Greg Clayton2012-04-111-25/+8
| | | | | | | | Cleaned up the Mutex::Locker and the ReadWriteLock classes a bit. Also cleaned up the GDBRemoteCommunication class to not have so many packet functions. Used the "NoLock" versions of send/receive packet functions when possible for a bit of performance. llvm-svn: 154458
* Trying to solve our disappearing thread issues by making thread list updates ↵Greg Clayton2012-04-101-4/+1
| | | | | | | | | | | | | | | | safer. The current ProcessGDBRemote function that updates the threads could end up with an empty list if any other thread had the sequence mutex. We now don't clear the thread list when we can't access it, and we also have changed how lldb_private::Process handles the return code from the: virtual bool Process::UpdateThreadList (lldb_private::ThreadList &old_thread_list, lldb_private::ThreadList &new_thread_list) = 0; A bool is now returned to indicate if the list was actually updated or not and the lldb_private::Process class will only update the stop ID of the validity of the thread list if "true" is returned. The ProcessGDBRemote also got an extra assertion that will hopefully assert when running debug builds so we can find the source of this issue. llvm-svn: 154365
* Added a packet history object to the GDBRemoteCommunication class that is ↵Greg Clayton2012-04-091-16/+117
| | | | | | always remembering the last 512 packets that were sent/received. These packets get dumped if logging gets enabled, or when the new expr lldb::DumpProcessGDBRemotePacketHistory (void *process, const char *log_file_path) global function is called. llvm-svn: 154354
* Cleaned up many error codes. For any who is filling in error strings intoGreg Clayton2011-10-261-1/+1
| | | | | | | | | | | | | lldb_private::Error objects the rules are: - short strings that don't start with a capitol letter unless the name is a class or anything else that is always capitolized - no trailing newline character - should be one line if possible Implemented a first pass at adding "--gdb-format" support to anything that accepts format with optional size/count. llvm-svn: 142999
* Update declarations for all functions/methods that accept printf-styleJason Molenda2011-09-201-1/+1
| | | | | | | | stdarg formats to use __attribute__ format so the compiler can flag incorrect uses. Fix all incorrect uses. Most of these are innocuous, a few were resulting in crashes. llvm-svn: 140185
* Initialize the all important automatic variable 'lldb::ConnectionStatus ↵Johnny Chen2011-07-191-1/+1
| | | | | | | | | status' before invoking the Read(...) method to read in bytes. This seems to fix the infinite looping I was seeing on SnowLeopard while running the test suite. llvm-svn: 135461
* Added "target variable" command that allows introspection of globalGreg Clayton2011-07-071-0/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | variables prior to running your binary. Zero filled sections now get section data correctly filled with zeroes when Target::ReadMemory reads from the object file section data. Added new option groups and option values for file lists. I still need to hook up all of the options to "target variable" to allow more complete introspection by file and shlib. Added the ability for ValueObjectVariable objects to be created with only the target as the execution context. This allows them to be read from the object files through Target::ReadMemory(...). Added a "virtual Module * GetModule()" function to the ValueObject class. By default it will look to the parent variable object and return its module. The module is needed when we have global variables that have file addresses (virtual addresses that are specific to module object files) and in turn allows global variables to be displayed prior to running. Removed all of the unused proxy object support that bit rotted in lldb_private::Value. Replaced a lot of places that used "FileSpec::Compare (lhs, rhs) == 0" code with the more efficient "FileSpec::Equal (lhs, rhs)". Improved logging in GDB remote plug-in. llvm-svn: 134579
* When we use the "fd://%u" for file descriptors, we need to detect if this isGreg Clayton2011-07-021-7/+12
| | | | | | | | | a file or socket. We now make a getsockopt call to check if the fd is a socket. Also, the previous logic in the GDB communication needs to watch for success with an error so we can deal with EAGAIN and other normal "retry" error codes. llvm-svn: 134359
* Cleanup errors that come out of commands and make sure they all have newlinesGreg Clayton2011-07-021-10/+42
| | | | | | | | | | | | | _only_ in the resulting stream, not in the error objects (lldb_private::Error). lldb_private::Error objects should always just have an error string with no terminating newline characters or periods. Fixed an issue with GDB remote packet detection that could end up deadlocking if a full packet wasn't received in one chunk. Also modified the packet checking function to properly toss one or more bytes when it detects bad data. llvm-svn: 134357
OpenPOWER on IntegriCloud