summaryrefslogtreecommitdiffstats
path: root/lldb/source/Target/Process.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* Feedback from Jim: Change the "optimized code" warning to be entirelyJason Molenda2015-08-101-0/+14
| | | | | | | | | | | | contained within Process so that we won't be duplicating the warning message if other parts of the code want to issue the message. Change Process::PrintWarning to be a protected method - the public method will be the PrintWarningOptimization et al. Also, Have Thread::FunctionOptimizationWarning shortcut out if the warnings have been disabled so that we don't (potentially) compute parts of the SymbolContext unnecessarily. llvm-svn: 244436
* Second part of indicating when the user is stopped in optimized code.Jason Molenda2015-08-061-1/+55
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The first part was in r243508 -- the extent of the UI changes in that patchset was to add "[opt]" to the frame-format when a stack frame was built with optimized code. In this change, when a stack frame built with optimization is selected, a message will be printed to the async output channel -- opt1.c was compiled with optimization - stepping may behave oddly; variables may not be available. The warning will be only be printed once per source file in a debug session. These warnings may be disabled by settings set target.process.optimization-warnings false Internally, a new Process::PrintWarning() method has been added for warnings that we want to print only once to the user. It takes a type of warning (currently only eWarningsOptimization) and an object pointer (CompileUnit*) - the warning will only be printed once for a given object pointer value. This is a bit of a prototype of this change - I think we will be tweaking it more in the future. But I wanted to land this and see how it goes. Advanced users will find these warnings unnecessary noise and will quickly disable them - but anyone who maintains a debugger knows that debugging optimized code, without realizing it, is a constant source of confusion and frustation for more typical debugger users. I imagine there will be more of these "warn once per whatever" style warnings that we will want to add in the future and we'll need to come up with a better way for enabling/disabling them. But I'm not srue what form that warning settings should take and I didn't want to code up something that we regret later, so for now I just added another process setting for this one warning. <rdar://problem/19281172> llvm-svn: 244190
* Add some initial logging for when lldb is searching for binaries,Jason Molenda2015-07-251-0/+5
| | | | | | | | | dSYMs, or reading binaries out of memory to the 'Host' log channel. There's more to be done here, both for Mac and for other platforms, but the initial set of new loggings are useful enough to check in at this point. llvm-svn: 243200
* Add UNUSED_IF_ASSERT_DISABLED and apply it.Bruce Mitchener2015-07-241-1/+1
| | | | | | | | | | | | | | | Summary: This replaces (void)x; usages where they x was subsequently involved in an assertion with this macro to make the intent more clear. Reviewers: clayborg Subscribers: lldb-commits Differential Revision: http://reviews.llvm.org/D11451 llvm-svn: 243074
* Fix warnings.Bruce Mitchener2015-07-221-0/+1
| | | | | | | | | | Reviewers: clayborg Subscribers: lldb-commits Differential Revision: http://reviews.llvm.org/D11404 llvm-svn: 242913
* More packet performance improvements. Greg Clayton2015-07-171-1/+6
| | | | | | | | Changed the "jthreads" key/value in the stop reply packets to be "jstopinfo". This JSON only contains threads with valid stop reasons and allows us not to have to ask about other threads via qThreadStopInfo when we are stepping. The "jstopinfo" only gets sent if there are more than one thread since the stop reply packet contains all the info needed for a single thread. Added a Process::WillPublicStop() in case process subclasses want to do any extra gathering for public stops. For ProcessGDBRemote, we end up sending a jThreadsInfo packet to gather all expedited registers, expedited memory and MacOSX queue information. We only do this for public stops to minimize the packets we send when we have multiple private stops. Multiple private stops happen when a source level single step, step into or step out run the process multiple times while implementing the stepping, and none of these private stops make it out to the UI via notifications because they are private stops. llvm-svn: 242593
* Expression evaluation, a new ThreadPlanCallFunctionUsingABI for executing a ↵Ewan Crawford2015-07-141-0/+8
| | | | | | | | | | | | | | | | | | | | function call on target via register manipulation For Hexagon we want to be able to call functions during debugging, however currently lldb only supports this when there is JIT support. Although emulation using IR interpretation is an alternative, it is currently limited in that it can't make function calls. In this patch we have extended the IR interpreter so that it can execute a function call on the target using register manipulation. To do this we need to handle the Call IR instruction, passing arguments to a new thread plan and collecting any return values to pass back into the IR interpreter. The new thread plan is needed to call an alternative ABI interface of "ABI::PerpareTrivialCall()", allowing more detailed information about arguments and return values. Reviewers: jingham, spyffe Subscribers: emaste, lldb-commits, ted, ADodds, deepak2427 Differential Revision: http://reviews.llvm.org/D9404 llvm-svn: 242137
* Refactor Unix signals.Chaoren Lin2015-07-141-7/+7
| | | | | | | | | | | | | | | | | | Summary: - Consolidate Unix signals selection in UnixSignals. - Make Unix signals available from platform. - Add jSignalsInfo packet to retrieve Unix signals from remote platform. - Get a copy of the platform signal for each remote process. - Update SB API for signals. - Update signal utility in test suite. Reviewers: ovyalov, clayborg Subscribers: chaoren, jingham, labath, emaste, tberghammer, lldb-commits Differential Revision: http://reviews.llvm.org/D11094 llvm-svn: 242101
* Don't select a thread that stopped for a signal that wasJim Ingham2015-07-081-1/+14
| | | | | | | | | not set to stop - there must be some other thread that stopped for a more interesting reason. <rdar://problem/19943567> llvm-svn: 241650
* Resubmitting 240466 after fixing the linux test suite failures.Greg Clayton2015-06-251-2/+3
| | | | | | | | | | | | | | | A few extras were fixed - Symbol::GetAddress() now returns an Address object, not a reference. There were places where people were accessing the address of a symbol when the symbol's value wasn't an address symbol. On MacOSX, undefined symbols have a value zero and some places where using the symbol's address and getting an absolute address of zero (since an Address object with no section and an m_offset whose value isn't LLDB_INVALID_ADDRESS is considered an absolute address). So fixing this required some changes to make sure people were getting what they expected. - Since some places want to access the address as a reference, I added a few new functions to symbol: Address &Symbol::GetAddressRef(); const Address &Symbol::GetAddressRef() const; Linux test suite passes just fine now. <rdar://problem/21494354> llvm-svn: 240702
* Fix the handling of the run lock in cases where you needed to runJim Ingham2015-06-231-7/+12
| | | | | | | | | | | | | a hand-called function from the private state thread. The problem was that on the way out of the private state thread, we try to drop the run lock. That is appropriate for the main private state thread, but not the secondary private state thread. Only the thread that spawned them can know whether this is an appropriate thing to do or not. <rdar://problem/21375352> llvm-svn: 240461
* Fix a variety of typos.Bruce Mitchener2015-06-181-1/+1
| | | | | | No functional change. llvm-svn: 239995
* Fixed a deadlock that was slowing down processes when they shut down. A 3 ↵Greg Clayton2015-06-031-2/+2
| | | | | | second delay could occur sometimes when a process exits, now that delay is gone. llvm-svn: 238893
* Fix a race condition where 2 threads might try to call ↵Greg Clayton2015-06-011-10/+8
| | | | | | | | | | | | Process::SetExitStatus() at the same time. The problem was the mutex was only protecting the setting of m_exit_string and m_exit_string, but this function relies on the m_private_state being set to eStateExited in order to prevent more than 1 client setting the exit status. We want to only allow the first caller to succeed. On MacOSX we have a thread that reaps the process we are debugging, and we also have a thread that monitors the debugserver process. When a process exists, the ProcessGDBRemote::AsyncThread() would set the exit status to the correct value and then another thread would reap the debugserver process and they would often both end up in Process::SetExitStatus() at the same time. With the mutex at the top we allow all variables to be set and the m_private_state to be set to eStateExited _before_ the other thread (debugserver reaped) can try to set th exist status to -1 and "lost connection to debugserver" being set as the exit status. This was probably an issue for lldb-server as well and could very well cleanup some tests that might have been expecting a specific exit status from the process being debugged. llvm-svn: 238794
* Refactor many file functions to use FileSpec over strings.Chaoren Lin2015-05-291-7/+8
| | | | | | | | | | | | | | | | | Summary: This should solve the issue of sending denormalized paths over gdb-remote if we stick to GetPath(false) in GDBRemoteCommunicationClient, and let the server handle any denormalization. Reviewers: ovyalov, zturner, vharron, clayborg Reviewed By: clayborg Subscribers: tberghammer, emaste, lldb-commits Differential Revision: http://reviews.llvm.org/D9728 llvm-svn: 238604
* Don't #include "lldb-python.h" from anywhere.Zachary Turner2015-05-291-2/+0
| | | | | | | | | | | | | Since interaction with the python interpreter is moving towards being more isolated, we won't be able to include this header from normal files anymore, all includes of it should be localized to the python library which will live under source/bindings/API/Python after a future patch. None of the files that were including this header actually depended on it anyway, so it was just a dead include in every single instance. llvm-svn: 238581
* Change ProcessEventData over to use a std::weak_ptr to a process intead of a ↵Greg Clayton2015-05-291-10/+21
| | | | | | std::shared_ptr. Anyone consuming events for a process should have the process around long enough to grab the event and anyone that holds onto an event for too long won't keep the process around. llvm-svn: 238541
* Fix race in IOHandlerProcessSTDIOPavel Labath2015-05-281-74/+55
| | | | | | | | | | | | | | | | | | Summary: IOHandlerProcessSTDIO::Run() was opening the pipe for interrupt requests lazily. This was racing with another thread executing IOHandlerProcessSTDIO::Cancel() simultaneously. I fix this by opening the pipe in the object constructor. The pipe will be automatically closed when the object is destroyed. Test Plan: Tests pass on linux. Reviewers: clayborg, ribrdb Subscribers: lldb-commits Differential Revision: http://reviews.llvm.org/D10060 llvm-svn: 238423
* I finally found the strong reference that was keeping all ↵Greg Clayton2015-05-281-0/+7
| | | | | | | | | | | | lldb_private::Process instances from ever destroying themselves: ProcessModID.m_mod_id was holding onto the last stop event with ProcessModID::SetStopEventForLastNaturalStopID(EventSP). This is a bad idea because ProcessEventData contains a strong refereence to the process. This is now fixed by calling ProcessModID::SetStopEventForLastNaturalStopID(EventSP()) to clear this event in Process::SetExitStatus() and in Process::Finalize(). This was the original cause of the file descriptor leaks that would cause the test suite to die after running a few hundred processes since no process would ever get destroyed and the communication channel in ProcessGDBRemote and the ProcessIOHandler would never close their pipes. This process leak was previously worked around by closing the pipes when the communication channel was disconnected. This was found by using "ptr_refs" from the heap.py in the lldb.macosx.heap module. It was able to find all strong references to the Process and helped me to figure out who was holding this extra reference. llvm-svn: 238392
* Improve LLDB prompt handlingPavel Labath2015-05-271-51/+29
| | | | | | | | | | | | | | | | | | | | | | | | | | Summary: There is an issue in lldb where the command prompt can appear at the wrong time. The partial fix we have in for this is not working all the time and is introducing unnecessary delays. This change does: - Change Process:SyncIOHandler to use integer start id's for synchronization to avoid it being confused by quick start-stop cycles. I picked this up from a suggested patch by Greg to lldb-dev. - coordinates printing of asynchronous text with the iohandlers. This is also based on a (different) Greg's patch, but I have added stronger synchronization to it to avoid races. Together, these changes solve the prompt problem for me on linux (both with and without libedit). I think they should behave similarly on Mac and FreeBSD and I think they will not make matters worse for windows. Test Plan: Prompt comes out alright. All tests still pass on linux. Reviewers: clayborg, emaste, zturner Subscribers: lldb-commits Differential Revision: http://reviews.llvm.org/D9823 llvm-svn: 238313
* Did some cleanup to stop us from leaking Pipe file descriptors.Greg Clayton2015-05-231-1/+16
| | | | | | | | | | The main issue was the Communication::Disconnect() was calling its Connection::Disconnect() but this wouldn't release the pipes that the ConnectionFileDescriptor was using. We also have someone that is holding a strong reference to the Process so that when you re-run, target replaces its m_process_sp, but it doesn't get destructed because someone has a strong reference to it. I need to track that down. But, even if we have a strong reference to the a process that is outstanding, we need to call Process::Finalize() to have it release as much of its resources as possible to avoid memory bloat. Removed the ProcessGDBRemote::SetExitStatus() override and replaced it with ProcessGDBRemote::DidExit(). Now we aren't leaking file descriptors and the stand alone test suite should run much better. llvm-svn: 238089
* Implement attach to process on Windows.Zachary Turner2015-05-201-1/+5
| | | | | | | Differential Revision: http://reviews.llvm.org/D9801 Reviewed by: Adrian McCarthy llvm-svn: 237817
* Fix handling of hijacked events in synchronous modeIlia K2015-05-201-2/+6
| | | | | | | | | | | | | | | | | | | | | | | | | Summary: This patch includes the following changes: * Fix Target::Launch to handle hijacked event in synchronous mode * Improve MiStartupOptionsTestCase tests to expect *stopped (MI) * Add SBProcess::GetStopEventForStopID * Add ProcessModID::SetStopEventForLastNaturalStopID/GetStopEventForStopID * Add const qualifier to ProcessModID::GetLastNaturalStopID * Add SBProcess::GetStopEventForStopID * Don't broadcast hijacked event in Target::Launch * Add CMICmnLLDBDebugger::CheckIfNeedToRebroadcastStopEvent/RebroadcastStopEvent Test Plan: ./dotest.py -v --executable $BUILDDIR/bin/lldb tools/lldb-mi/startup_options/ Reviewers: zturner, jingham, clayborg, abidh Reviewed By: clayborg Subscribers: abidh, zturner, lldb-commits, clayborg, jingham Differential Revision: http://reviews.llvm.org/D9371 llvm-svn: 237781
* OperatingSystem plug-ins need to avoid running code when fetching thread ↵Greg Clayton2015-05-151-0/+14
| | | | | | | | | | lists. This patch helps with that by making all SBValue objects that are fetched not try to do dynamic type resolution. Objective C can end up running code to fetch a list of all ISA pointers so we can tell when something is dynamic and this running code could cause the OS plug-in to continue the target. This fix disabled dynamic types, fetches the new threads from the OS plug-in, then restores the setting. <rdar://problem/20768407> llvm-svn: 237465
* Fix Process::ResumeSynchronous which waits a process even in case of errorIlia K2015-04-301-5/+7
| | | | llvm-svn: 236231
* Formatting fix.Jim Ingham2015-04-221-1/+2
| | | | llvm-svn: 235527
* Add a "force_kill" arg to Process::Destroy(). This is needed afterJason Molenda2015-04-171-4/+7
| | | | | | | | | | | | | | | | | | the changes in r233255/r233258. Normally if lldb attaches to a running process, when we call Process::Destroy, we want to detach from the process. If lldb launched the process itself, ::Destroy should kill it. However, if we attach to a process and the driver calls SBProcess::Kill() (which calls Destroy), we need to kill it even if we didn't launch it originally. The force_kill param allows for the SBProcess::Kill method to force the behavior of Destroy. <rdar://problem/20424439> llvm-svn: 235158
* Add new virtual method for language runtime plug-ins:Greg Clayton2015-04-161-1/+17
| | | | | | | | | virtual void LanguageRuntime::ModulesDidLoad (const ModuleList &module_list); Then reorganized how the objective C plug-in is notified so it will work for all LanguageRuntime subclasses. llvm-svn: 235118
* Fix warnings generated by clang-cl.Zachary Turner2015-04-021-1/+1
| | | | | | | | | | | | | | There were a couple of real bugs here regarding error checking and signed/unsigned comparisons, but mostly these were just noise. There was one class of bugs fixed here which is particularly annoying, dealing with MSVC's non-standard behavior regarding the underlying type of enums. See the comment in lldb-enumerations.h for details. In short, from now on please use FLAGS_ENUM and FLAGS_ANONYMOUS_ENUM when defining enums which contain values larger than can fit into a signed integer. llvm-svn: 233943
* Don't return a reference to a temp variable.Greg Clayton2015-04-021-3/+0
| | | | llvm-svn: 233940
* Fix a crasher that could happen when you run LLDB and evaluate an expression ↵Greg Clayton2015-04-021-2/+27
| | | | | | | | | | where the objective C runtime registers a helper function, and also have an Objective C or C++ exception breakpoint. When shutting down the process in Process::Finalize() we clear a STL collection class and that causes objects to be destroyed that could re-enter Process and cause it to try to iterate over that same collection class that is being destroyed. Guard against this by setting a new "m_finalizing" flag that lets us know we are in the process of finalizing. <rdar://problem/20369152> llvm-svn: 233935
* Fix Process::Finalize to do Process::Destroy if needed after r233255Ilia K2015-03-261-2/+20
| | | | llvm-svn: 233258
* Fix -gdb-exit to detach if was attached or destroy otherwise (MI)Ilia K2015-03-261-26/+9
| | | | | | | | | | | | | | | | | Summary: This patch fixes -gdb-exit for locally target. It includes the following changes: # Fix Process::Finalize # Use SBProcess::Destroy in -gdb-exit Reviewers: abidh, zturner, clayborg Reviewed By: clayborg Subscribers: lldb-commits, clayborg, abidh Differential Revision: http://reviews.llvm.org/D8298 llvm-svn: 233255
* Fetch module specification from remote process alsoTamas Berghammer2015-03-241-0/+10
| | | | | | | | | | | | | Previously the remote module sepcification was fetched only from the remote platform. With this CL if we have a remote process then we ask it if it have any information from a given module. It is required because on android the dynamic linker only reports the name of the SO file and the platform can't always find it without a full path (the process can do it based on /proc/<pid>/maps). Differential revision: http://reviews.llvm.org/D8547 llvm-svn: 233061
* Move some functions from source/lldb.cpp to Utility.Zachary Turner2015-03-181-0/+1
| | | | | | | | | | Specifically, there were some functions for converting enums to strings and a function for matching a string using a specific matching algorithm. This moves those functions to more appropriate headers in lldb/Utility and updates references to include the new headers. llvm-svn: 232673
* Move lldb-log.cpp to core/Logging.cppZachary Turner2015-03-181-3/+0
| | | | | | | | | So that we don't have to update every single #include in the entire codebase to #include this new header (which used to get included by lldb-private-log.h, we automatically #include "Logging.h" from within "Log.h". llvm-svn: 232653
* Fix broadcasters for interpreter and process:Ilia K2015-03-171-1/+1
| | | | | | | | # Fix CommandInterpreter.Broadcaster name (it should be the same as CommandInterpreter::GetStaticBroadcasterClass()) # Prevent the same error in Process.Broadcaster # Fix SBCommandInterpreter::GetBroadcasterClass (it should call CommandInterpreter::GetStaticBroadcasterClass(), was Communication::GetStaticBroadcasterClass()) llvm-svn: 232500
* Fix ProcessIO test failuresPavel Labath2015-03-121-3/+6
| | | | | | | | | | | | | | | | | | | | | | | | | Summary: There was a race condition regarding the output of the inferior process. The reading of the output is performed on a separate thread, and there was no guarantee that the output will get eventually consumed. Because of that, it was happening that calling Process::GetSTDOUT was not returning anything even though the process was terminated and would definitely not produce any further output. This was usually happening only under very heavy system load, but it can be reproduced by placing an usleep in the stdio thread (Process::STDIOReadThreadBytesReceived). This patch addresses this by adding synchronization capabilities to the Communication thread. After calling Communication::SynchronizeWithReadThread one can be sure that all pending input has been processed by the read thread. This function is then called after every public event which stops the process to obtain the entire process output. Test Plan: TestProcessIO.py should now succeed every time instead of flaking in and out. Reviewers: clayborg, jingham Subscribers: lldb-commits Differential Revision: http://reviews.llvm.org/D8246 llvm-svn: 232023
* Fix race condition with -o "process launch" on linuxPavel Labath2015-03-061-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | Summary: starting a debug session on linux with -o "process launch" lldb parameter was failing since Target::Launch (in sychronous mode) is expecting to be able to receive public process events. However, PlatformLinux did not set up event hijacking on process launch, which caused these events to be processed elsewhere and left Target::Launch hanging. This patch enables event interception in PlatformLinux (which was commented out). Upon enabling event interception, I noticed an issue, which I traced back to the inconsistent state of public run lock, which remained false even though public and private process states were "stopped". I addressed this by making sure the run lock is "stopped" upon exit from WaitForProcessToStop (which already had similar provisions for other return paths). Test Plan: This should fix the intermittent TestFormats failure we have been experiencing on Linux. Reviewers: jingham, clayborg, vharron Subscribers: lldb-commits Differential Revision: http://reviews.llvm.org/D8079 llvm-svn: 231460
* Further reduce header footprint of Debugger.h.Zachary Turner2015-03-041-0/+1
| | | | llvm-svn: 231202
* Further reduce the header footprint of Process.hZachary Turner2015-03-031-1/+61
| | | | | | | No functional change here, only deletes unnecessary headers and moves one function's body from the .h file to the .cpp. llvm-svn: 231145
* Revert "Fix warnings found with clang-cl."Zachary Turner2015-02-251-1/+1
| | | | | | | SWIG doesn't like enum : unsigned. Revert this until I can fix this in a way that swig likes. llvm-svn: 230531
* Fix warnings found with clang-cl.Zachary Turner2015-02-251-1/+1
| | | | | | | | | | | Earlier this week I was able to get clang-cl on Windows to be able to self host. This opened the door to being able to get a whole new slew of warnings for the Windows build. This patch fixes all of the warnings, many of which were real bugs. llvm-svn: 230522
* Set error status when failed to catch stop after launchTamas Berghammer2015-02-231-0/+1
| | | | | | | | | | | Process::Launch try to catch a stop signal after launching a process. If it is unsuccessful it destroy the process but previously still reported that the process launched successfully. This behavior caused a deadlock. With thic change the process launch error reported correctly. Differential revision: http://reviews.llvm.org/D7784 llvm-svn: 230212
* Rename the "glob arguments" feature to "shell expand arguments"Enrico Granata2015-02-201-5/+5
| | | | | | This should not bring any feature change, except changing names of things here and there llvm-svn: 230077
* Make sure the public state is eStateStopped when we return from ↵Greg Clayton2015-02-201-2/+2
| | | | | | SBTarget::LoadCore() by hijacking the public event queue so we can ensure that the event gets consumed and the public state of the process (StateType SBProcess::GetState()) returns eStateStopped. llvm-svn: 230066
* Avoid a race condition when loading core files where the process might still ↵Greg Clayton2015-02-201-1/+17
| | | | | | | | be handling the eStateStopped event we post to the private state thread causing us to return from SBTarget::LoadCore() before the process is ready to have API calls used on it. This fixes a crasher that could happen when loading core files from scripts. llvm-svn: 230060
* Add extra check that target was stopped before the *stopped is sent.Ilia K2015-02-111-1/+1
| | | | | | This patch fixes r228417. It's required because eStateCrushed case wasn't investigated. llvm-svn: 228824
* Fix 'process launch -i' for remote processesVince Harron2015-02-101-2/+2
| | | | | | | | | | | | | | | | | | We want to forward stdin when stdio is not disabled and when we're not redirecting stdin from a file. renamed m_stdio_disable to m_stdin_forward and inverted value because that's what we want to remember. There was previously a bug that if you redirected stdin from a file, stdout and stderr would also be redirected to /dev/null Adds support for remote target to TestProcessIO.py Fixes ProcessIOTestCase.test_stdin_redirection_with_dwarf for remote Linux targets llvm-svn: 228744
* Add a "launch with globber" mode that lets you launch a process after having ↵Enrico Granata2015-02-101-2/+13
| | | | | | globbed the command line arguments via argdumper instead of routing via /bin/sh llvm-svn: 228658
OpenPOWER on IntegriCloud