summaryrefslogtreecommitdiffstats
path: root/lldb/source/Target/Process.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* Add support for SBProcess::PutSTDIN to remote processesVince Harron2015-02-061-0/+2
| | | | | | | | | | | | | | Processes running on a remote target can already send $O messages to send stdout but there is no way to send stdin to a remote inferior. This allows processes using the API to pump stdin into a remote inferior process. It fixes a hang in TestProcessIO.py when running against a remote target. llvm-svn: 228419
* Fix a missing "*stopped" notification in LLDB-MI after "process launch -s" ↵Ilia K2015-02-061-0/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | in case of remote-macosx Summary: This patch fixes *stopped notification for remote target when started with eLaunchFlagStopAtEntry (for example, using "process launch -s"). See explanation below: ``` Target::Launch (ProcessLaunchInfo &launch_info, Stream *stream) { ... if (state != eStateConnected && platform_sp && platform_sp->CanDebugProcess ()) { ... } else { ... if (m_process_sp) error = m_process_sp->Launch (launch_info); } if (error.Success()) { if (launch_info.GetFlags().Test(eLaunchFlagStopAtEntry) == false) { .... } -- missing event if eLaunchFlagStopAtEntry is set -- m_process_sp->RestoreProcessEvents (); } ... return error ``` Also this patch contains tests and you can check how it works. Reviewers: zturner, clayborg, abidh Reviewed By: clayborg Subscribers: clayborg, abidh, zturner, lldb-commits Differential Revision: http://reviews.llvm.org/D7273 llvm-svn: 228417
* Fix a race condition where you could set the selected thread & target in theJim Ingham2015-01-191-1/+2
| | | | | | | | | | CommandInterpreter's execution context AFTER the process had started running and before it initially stopped. Also fixed one test case that was implicitly using this (and an abuse of the async mode) to accidentally succeed. <rdar://problem/16814726> llvm-svn: 226528
* Fixed an issue where if the operating system python plug-in is changed at ↵Greg Clayton2015-01-131-10/+33
| | | | | | | | | | | | | | | | | | | | | | | runtime, it wouldn't cause the process to reload the new operating system plug-in, now it does. This is currently controlled by a setting: (lldb) settings set target.process.python-os-plugin-path <path> Or clearing it with: (lldb) settings clear target.process.python-os-plugin-path The process will now reload the OperatingSystem plug-in. This was implemented by: - adding the ability to set a notify callback for when an option value is changed - added the ability for the process plug-in to load the operating system plug-in on the fly - fixed bugs in the Process::GetStatus() so all threads are displayed if their thread IDs are larger than 32 bits - adding a callback in ProcessProperties to tell when the "python-os-plugin-path" is changed by the user - fixing a crasher in ProcessMachCore that happens when updating the thread list when the OS plugin is reloaded llvm-svn: 225831
* Enhance the Pipe interface for better portability.Zachary Turner2014-12-171-5/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch makes a number of improvements to the Pipe interface. 1) An interface (PipeBase) is provided which exposes pure virtual methods for any implementation of Pipe to override. While not strictly necessary, this helps catch errors where the interfaces are out of sync. 2) All methods return lldb_private::Error instead of returning bool or void. This allows richer error information to be propagated up to LLDB. 3) A new ReadWithTimeout() method is exposed in the base class and implemented on Windows. 4) Support for both named and anonymous pipes is exposed through the base interface and implemented on Windows. For creating a new pipe, both named and anonymous pipes are supported, and for opening an existing pipe, only named pipes are supported. New methods described in points #3 and #4 are stubbed out on posix, but fully implemented on Windows. These should be implemented by someone on the linux / mac / bsd side. Reviewed by: Greg Clayton, Oleksiy Vyalov Differential Revision: http://reviews.llvm.org/D6686 llvm-svn: 224442
* Make the platform process connect path less chatty.Stephane Sezer2014-12-131-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: If a stream contains an empty string, no need to append it to the output (otherwise we end up with a blank line). Also, no need to print a status message when the state changes to connected, as this string brings no information -- "Process 0" does not mean anything to the user, and the process being connected has no meaning either. Test Plan: Connect to a remote linux platform mode daemon with `platform select remote-linux` followed by `platform connect ...`, create a target and run it, observe the output. Also, run the full test suite (dosep.py). Before: (lldb) [...] connect, etc. (lldb) r Process 0 connected Process 5635 launched: '/Users/sas/Source/test' (x86_64) Process 5635 stopped After: (lldb) [...] connect, etc. (lldb) r Process 5635 launched: '/Users/sas/Source/test' (x86_64) Process 5635 stopped Reviewers: tfiala, vharron, clayborg Subscribers: lldb-commits Differential Revision: http://reviews.llvm.org/D6593 llvm-svn: 224188
* Handle thumb IT instructions correctly all the time.Greg Clayton2014-12-091-0/+9
| | | | | | | | | | | | | | | | | | | | | | The issue with Thumb IT (if/then) instructions is the IT instruction preceeds up to four instructions that are made conditional. If a breakpoint is placed on one of the conditional instructions, the instruction either needs to match the thumb opcode size (2 or 4 bytes) or a BKPT instruction needs to be used as these are always unconditional (even in a IT instruction). If BKPT instructions are used, then we might end up stopping on an instruction that won't get executed. So if we do stop at a BKPT instruction, we need to continue if the condition is not true. When using the BKPT isntructions are easy in that you don't need to detect the size of the breakpoint that needs to be used when setting a breakpoint even in a thumb IT instruction. The bad part is you will now always stop at the opcode location and let LLDB determine if it should auto-continue. If the BKPT instruction is used, the BKPT that is used for ARM code should be something that also triggers the BKPT instruction in Thumb in case you set a breakpoint in the middle of code and the code is actually Thumb code. A value of 0xE120BE70 will work since the lower 16 bits being 0xBE70 happens to be a Thumb BKPT instruction. The alternative is to use trap or illegal instructions that the kernel will translate into breakpoint hits. On Mac this was 0xE7FFDEFE for ARM and 0xDEFE for Thumb. The darwin kernel currently doesn't recognize any 32 bit Thumb instruction as a instruction that will get turned into a breakpoint exception (EXC_BREAKPOINT), so we had to use the BKPT instruction on Mac. The linux kernel recognizes a 16 and a 32 bit instruction as valid thumb breakpoint opcodes. The benefit of using 16 or 32 bit instructions is you don't stop on opcodes in a IT block when the condition doesn't match. To further complicate things, single stepping on ARM is often implemented by modifying the BCR/BVR registers and setting the processor to stop when the PC is not equal to the current value. This means single stepping is another way the ARM target can stop on instructions that won't get executed. This patch does the following: 1 - Fix the internal debugserver for Apple to use the BKPT instruction for ARM and Thumb 2 - Fix LLDB to catch when we stop in the middle of a Thumb IT instruction and continue if we stop at an instruction that won't execute 3 - Fixes this in a way that will work for any target on any platform as long as it is ARM/Thumb 4 - Adds a patch for ignoring conditions that don't match when in ARM mode (see below) This patch also provides the code that implements the same thing for ARM instructions, though it is disabled for now. The ARM patch will check the condition of the instruction in ARM mode and continue if the condition isn't true (and therefore the instruction would not be executed). Again, this is not enable, but the code for it has been added. <rdar://problem/19145455> llvm-svn: 223851
* Add test for denied process attach by pid and fix found bugs in ↵Oleksiy Vyalov2014-11-191-6/+5
| | | | | | | | | | Process/ProcessPOSIX.cpp and FreeBSD/ProcessMonitor. http://reviews.llvm.org/D6240 llvm-svn: 222372
* Small tweaks to make the editline sources match the lldb Jason Molenda2014-11-171-1/+2
| | | | | | source layout. llvm-svn: 222171
* Fixed more fallout from running the test suite remotely on iOS devices.Greg Clayton2014-11-171-0/+9
| | | | | | | | | | | | | | | | Fixed include: - Change Platform::ResolveExecutable(...) to take a ModuleSpec instead of a FileSpec + ArchSpec to help resolve executables correctly when we have just a path + UUID (no arch). - Add the ability to set the listener in SBLaunchInfo and SBAttachInfo in case you don't want to use the debugger as the default listener. - Modified all places that use the SBLaunchInfo/SBAttachInfo and the internal ProcessLaunchInfo/ProcessAttachInfo to not take a listener as a parameter since it is in the launch/attach info now - Load a module's sections by default when removing a module from a target. Since we create JIT modules for expressions and helper functions, we could end up with stale data in the section load list if a module was removed from the target as the section load list would still have entries for the unloaded module. Target now has the following functions to help unload all sections a single or multiple modules: size_t Target::UnloadModuleSections (const ModuleList &module_list); size_t Target::UnloadModuleSections (const lldb::ModuleSP &module_sp); llvm-svn: 222167
* Complete rewrite of interactive editing support for single- and multi-line ↵Kate Stone2014-11-171-1/+1
| | | | | | | | | | | | | | | | | | | input. Improvements include: * Use of libedit's wide character support, which is imperfect but a distinct improvement over ASCII-only * Fallback for ASCII editing path * Support for a "faint" prompt clearly distinguished from input * Breaking lines and insert new lines in the middle of a batch by simply pressing return * Joining lines with forward and backward character deletion * Detection of paste to suppress automatic formatting and statement completion tests * Correctly reformatting when lines grow or shrink to occupy different numbers of rows * Saving multi-line history, and correctly preserving the "tip" of history during editing * Displaying visible ^C and ^D indications when interrupting input or sending EOF * Fledgling VI support for multi-line editing * General correctness and reliability improvements llvm-svn: 222163
* Also port the C string reading code in ValueObject over to using ↵Enrico Granata2014-10-301-3/+8
| | | | | | StringPrinter API llvm-svn: 220917
* Make the "synchronous" mode actually work without race conditions.Greg Clayton2014-10-211-2/+239
| | | | | | There were many issues with synchronous mode that we discovered when started to try and add a "batch" mode. There was a race condition where the event handling thread might consume events when in sync mode and other times the Process::WaitForProcessToStop() would consume them. This also led to places where the Process IO handler might or might not get popped when it needed to be. llvm-svn: 220254
* Remove LLDB_DEFAULT_SHELL #define, and determine this at runtime.Zachary Turner2014-10-201-2/+2
| | | | | | | Differential Revision: http://reviews.llvm.org/D5805 Reviewed by: Greg Clayton llvm-svn: 220217
* Remove dead store.Jason Molenda2014-10-161-4/+4
| | | | | | clang static analyzer fixit. llvm-svn: 219907
* Give old_state a default value so we won't try to restoreJason Molenda2014-10-151-3/+3
| | | | | | | | | | an uninitialized value. In reality the code block that initializes it and the code block that restores it will always match up - but the analyzer doesn't know that and I want to quiet it, so... clang static analyzer fixit. llvm-svn: 219869
* Add a IsInstrumentationRuntimePresent SB APIKuba Brecka2014-10-111-0/+13
| | | | | | | | | | Reviewed at http://reviews.llvm.org/D5738 This adds an SB API into SBProcess: bool SBProcess::IsInstrumentationRuntimePresent(InstrumentationRuntimeType type); which simply tells whether a particular InstrumentationRuntime (read "ASan") plugin is present and active. llvm-svn: 219560
* LLDB AddressSanitizer instrumentation runtime plugin, breakpint on error and ↵Kuba Brecka2014-10-101-6/+20
| | | | | | | | | | | | | | | | | | | | | | | | | report data extraction Reviewed at http://reviews.llvm.org/D5592 This patch gives LLDB some ability to interact with AddressSanitizer runtime library, on top of what we already have (historical memory stack traces provided by ASan). Namely, that's the ability to stop on an error caught by ASan, and access the report information that are associated with it. The report information is also exposed into SB API. More precisely this patch... adds a new plugin type, InstrumentationRuntime, which should serve as a generic superclass for other instrumentation runtime libraries, these plugins get notified when modules are loaded, so they get a chance to "activate" when a specific dynamic library is loaded an instance of this plugin type, AddressSanitizerRuntime, which activates itself when it sees the ASan dynamic library or founds ASan statically linked in the executable adds a collection of these plugins into the Process class AddressSanitizerRuntime sets an internal breakpoint on __asan::AsanDie(), and when this breakpoint gets hit, it retrieves the report information from ASan this breakpoint is then exposed as a new StopReason, eStopReasonInstrumentation, with a new StopInfo subclass, InstrumentationRuntimeStopInfo the StopInfo superclass is extended with a m_extended_info field (it's a StructuredData::ObjectSP), that can hold arbitrary JSON-like data, which is the way the new plugin provides the report data the "thread info" command now accepts a "-s" flag that prints out the JSON data of a stop reason (same way the "-j" flag works now) SBThread has a new API, GetStopReasonExtendedInfoAsJSON, which dumps the JSON string into a SBStream adds a test case for all of this I plan to also get rid of the original ASan plugin (memory history stack traces) and use an instance of AddressSanitizerRuntime for that purpose. Kuba llvm-svn: 219546
* Minor comment change to test out svn accessShawn Best2014-10-081-1/+1
| | | | llvm-svn: 219269
* Fix spurious output to command line when launching a process on Linux.Todd Fiala2014-10-071-4/+8
| | | | | | | | See http://reviews.llvm.org/D5632 for details. Change by Shawn Best. llvm-svn: 219213
* Move ConnectionFileDescriptor to platform-specific Host directory.Zachary Turner2014-10-061-3/+3
| | | | | | | | | | | | As part of getting ConnectionFileDescriptor working on Windows, there is going to be alot of platform specific work to be done. As a result, the implementation is moving into Host. This patch performs the code move and fixes up call-sites appropriately. Reviewed by: Greg Clayton Differential Revision: http://reviews.llvm.org/D5548 llvm-svn: 219143
* Fix up the HostThread interface, making the interface simpler.Zachary Turner2014-09-231-3/+3
| | | | | | | Reviewed by: Greg Clayton Differential Revision: http://reviews.llvm.org/D5417 llvm-svn: 218325
* use std::atomic<> to protect variables being accessed by multiple threadsTodd Fiala2014-09-151-5/+15
| | | | | | | | | | There are several places where multiple threads are accessing the same variables simultaneously without any kind of protection. I propose using std::atomic<> to make it safer. I did a special build of lldb, using the google tool 'thread sanitizer' which identified many cases of multiple threads accessing the same memory. std::atomic is low overhead and does not use any locks for simple types such as int/bool. See http://reviews.llvm.org/D5302 for more details. Change by Shawn Best. llvm-svn: 217818
* Create a HostThread abstraction.Zachary Turner2014-09-091-22/+26
| | | | | | | | | | | | | 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
* Implement ASan history threads in SB APIKuba Brecka2014-09-061-0/+17
| | | | | | | | | Reviewed at http://reviews.llvm.org/D5219 and http://lists.cs.uiuc.edu/pipermail/lldb-commits/Week-of-Mon-20140901/012809.html llvm-svn: 217300
* Add a new target.process.memory-cache-line-size to change the size ofJason Molenda2014-09-031-1/+10
| | | | | | | | | | | lldb's internal memory cache chunks that are read from the remote system. For a remote connection that is especially slow, a user may need to reduce it; reading a 512 byte chunk of memory whenever a 4-byte region is requested may not be the right decision in these kinds of environments. <rdar://problem/18175117> llvm-svn: 217083
* Consolidate UnixSignals setting/getting in Process.Todd Fiala2014-08-291-1/+13
| | | | | | | | | | | | | | | | 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
* Add some logging around Process attaching and inferior exec handling.Todd Fiala2014-08-271-1/+73
| | | | llvm-svn: 216630
* Adjust process launch --disable-aslr to take true/false value.Todd Fiala2014-08-191-5/+12
| | | | | | This change modifies the 'process launch' --disable-aslr option to take a boolean argument. If the user directly specifies --disable-aslr {true,false}, that setting will control whether the process is launched with ASLR disabled accordingly. In the event that the setting is not explicitly made on the process launch command line, then the value is retrieved from the target.disable-aslr setting (i.e. settings show target.disable-aslr). llvm-svn: 215996
* Move FileSystem functions out of Host and into their own classes.Zachary Turner2014-08-151-26/+24
| | | | | | | | | | | | | | | | 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
* Fix a thinko in the process list formatting.Jim Ingham2014-08-151-6/+15
| | | | | | | | Made Process::Attach list the matching processes if there is more than one match. <rdar://problem/18023352> llvm-svn: 215730
* 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
* Fix iohandler prompt race condition.Todd Fiala2014-08-121-0/+31
| | | | | | | | | | | | | | | | | This issue caused the lldb prompt to not show up in certain cases, very noticeable on Linux systems. See details on this review: http://reviews.llvm.org/D4863 And on this lldb-commits thread: http://lists.cs.uiuc.edu/pipermail/lldb-commits/Week-of-Mon-20140811/012306.html Change by Shawn Best. (Much useful help and testing by the rest of the community, thanks all!) llvm-svn: 215446
* Remove a few uses of LLDB_DISABLE_POSIX.Zachary Turner2014-08-111-4/+0
| | | | | | This all appears to have been dead, unnecessary code. llvm-svn: 215405
* Fix some typos:Sylvestre Ledru2014-08-111-2/+2
| | | | | | | | * transfered => transferred * unkown => unknown * sucessfully => successfully llvm-svn: 215367
* After you attach, give the process plugin a chance to report back (throughJim Ingham2014-08-021-2/+6
| | | | | | | | DidAttach) the architecture of the binary you attached to. <rdar://problem/17891396> llvm-svn: 214603
* (no commit message)Greg Clayton2014-07-301-1/+7
| | | | llvm-svn: 214319
* Add the ability to suppress the creation of a persistentJim Ingham2014-07-191-0/+2
| | | | | | | | result variable and use in in "Process::LoadImage" so that, for instance, "process load" doesn't increment the return variable number. llvm-svn: 213440
* In Process::LoadImage, use the same function call both to call dlopen and to ↵Jim Ingham2014-07-191-16/+25
| | | | | | | | collect the error if there is one. llvm-svn: 213436
* ReadPointedString takes a Stream not a DataBuffer.Jim Ingham2014-07-171-3/+3
| | | | llvm-svn: 213314
* In Process::LoadImage, if dlopen returns 0x0 fetch the error with dlerror ↵Jim Ingham2014-07-171-0/+25
| | | | | | | | and report that in the returned Error. llvm-svn: 213294
* ^C wasn't interrupting an expression during a long evaluation or deadlock.Greg Clayton2014-07-161-2/+22
| | | | | | | | | | The problem was that we have an IOHandler thread that services the IOHandler stack. The command interepter is on the top of the stack and it receives a "expression ..." command, and it calls the IOHandlerIsComplete() callback in the command interpereter delegate which runs an expression. This causes the IOHandlerProcessSTDIO to be pushed, but since we are running the code from the IOHandler thread, it won't get run. When CTRL+C is pressed, we do deliver the interrupt to the IOHandlerProcessSTDIO::Interrupt() function, but it was always writing 'i' to the interrupt pipe, even if we weren't actively reading from the debugger input and the pipes. This fix works around the issue by directly issuing the async interrupt to the process if the process is running. A longer term more correct fix would to be run the IOHandler thread and have it just do the determination of the input and when complete input is received, run the code that handles that input on another thread and syncronize with that other thread to detect when more input is desired. That change is too big to make right now, so this fix will tide us over until we can get there. <rdar://problem/16556228> llvm-svn: 213196
* Add Host::MAX_THREAD_NAME_LENGTH constant.Todd Fiala2014-07-161-4/+16
| | | | | | | | | | | | | | | This value gets set to a max uint32_t value when there is no known limit; otherwise, it is set to a value appropriate for the platform. For the moment, only Linux, FreeBSD and NetBSD set it to 16. All other platforms set it to the max uint32_t value. Modifies the Process private state thread names to fit within a 16-character limit when the max thread name length is <= 16. These guarantee that the thread names can be distinguished within the first 16 characters. Prior to this change, those threads had names in the final dotted name segment that were not distinguishable within the first 16 characters. llvm-svn: 213183
* If Process::Finalize() has been called, don't track process state changes.Greg Clayton2014-07-141-0/+3
| | | | | | <rdar://problem/17540766> llvm-svn: 213007
* Revert "Fix broken tests due to new error output."Zachary Turner2014-07-091-13/+13
| | | | | | | This reverts commit ec7c94f8e6860968d384b578e5564a9c55c80b4a and re-enables OptionValidators. llvm-svn: 212627
* Fix broken tests due to new error output.Todd Fiala2014-07-081-13/+13
| | | | | | | | | | | This reverses out the options validators changes. We'll get these back in once the changes to the output can be resolved. Restores broken tests on FreeBSD, Linux, MacOSX. Changes reverted: r212500, r212317, r212290. llvm-svn: 212543
* Adds the notion of an OptionValidator.Zachary Turner2014-07-031-13/+13
| | | | | | | | | | | | | | | | | | The purpose of the OptionValidator is to determine, based on some arbitrary set of conditions, whether or not a command option is valid for a given debugger state. An example of this might be to selectively disable or enable certain command options that don't apply to a particular platform. This patch contains no functional change, and does not actually make use of an OptionValidator for any purpose yet. A follow-up patch will begin to add the logic and users of OptionValidator. Reviewed by: Greg Clayton, Jim Ingham Differential Revision: http://reviews.llvm.org/D4369 llvm-svn: 212290
* Add host layer support for pipes.Greg Clayton2014-07-021-46/+20
| | | | | | | | | | | Windows does support pipes, but they do so in a slightly different way. Added a Host layer which abstracts the use of pipes into a new Pipe class that everyone can use. Windows benefits include: - Being able to interrupt running processes when IO is directly hooked up - being able to interrupt long running python scripts - being able to interrupt anything based on ConnectionFileDescriptor llvm-svn: 212220
* Fix typos.Bruce Mitchener2014-07-011-5/+5
| | | | llvm-svn: 212132
* Add lldb-gdbserver support for Linux x86_64.Todd Fiala2014-06-301-0/+15
| | | | | | | | | | | | | | | | | | | | | 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
OpenPOWER on IntegriCloud