summaryrefslogtreecommitdiffstats
path: root/lldb/source/Host/common/File.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* *** This commit represents a complete reformatting of the LLDB source codeKate Stone2016-09-061-916/+717
| | | | | | | | | | | | | | | | | | | | | | | *** to conform to clang-format’s LLVM style. This kind of mass change has *** two obvious implications: Firstly, merging this particular commit into a downstream fork may be a huge effort. Alternatively, it may be worth merging all changes up to this commit, performing the same reformatting operation locally, and then discarding the merge for this particular commit. The commands used to accomplish this reformatting were as follows (with current working directory as the root of the repository): find . \( -iname "*.c" -or -iname "*.cpp" -or -iname "*.h" -or -iname "*.mm" \) -exec clang-format -i {} + find . -iname "*.py" -exec autopep8 --in-place --aggressive --aggressive {} + ; The version of clang-format used was 3.9.0, and autopep8 was 1.2.4. Secondly, “blame” style tools will generally point to this commit instead of a meaningful prior commit. There are alternatives available that will attempt to look through this change and find the appropriate prior commit. YMMV. llvm-svn: 280751
* Remove _isatty from Android.hPavel Labath2016-08-081-1/+1
| | | | | | it is just #defined to isatty anyway, which lldb already knows how to use. llvm-svn: 277997
* Fix typo in eOpenOptionDontFollowSymlinksFrancis Ricci2016-06-211-1/+1
| | | | | | | | | | | | Summary: Fix capitalization Reviewers: labath, sas, clayborg Subscribers: lldb-commits Differential Revision: http://reviews.llvm.org/D21422 llvm-svn: 273225
* Unicode support on Win32.Zachary Turner2016-03-221-2/+15
| | | | | | | | | | | | | Win32 API calls that are Unicode aware require wide character strings, but LLDB uses UTF8 everywhere. This patch does conversions wherever necessary when passing strings into and out of Win32 API calls. Patch by Cameron Differential Revision: http://reviews.llvm.org/D17107 Reviewed By: zturner, amccarth llvm-svn: 264074
* Fixed the python interpreter so that it correctly inherits the top ↵Greg Clayton2016-03-101-51/+0
| | | | | | | | | | IOHandler's files instead of always using stdin/out/err. Removed lldb_private::File::Duplicate() and the copy constructor and the assignment operator that used to duplicate the file handles and made them private so no one uses them. Previously the lldb_private::File::Duplicate() function duplicated files that used file descriptors, (int) but not file streams (FILE *), so the lldb_private::File::Duplicate() function only worked some of the time. No one else excep thee ScriptInterpreterPython was using these functions, so that aren't needed nor desired. Previously every time you would drop into the python interpreter we would duplicate files, and now we avoid this file churn. <rdar://problem/24877720> llvm-svn: 263161
* Fix a problem where we were not calling fcntl() with the correct arguments ↵Enrico Granata2016-01-201-2/+2
| | | | | | | | | | | for F_DUPFD On Mac OS X, this was working just fine in debug builds (presumably, because the right value ended up being at the right location for the variadic ABI), but not in Release builds As a result, we were seeing failures with commands that set their own immediate output stream - only in Release builds, which always makes for a fun little investigation I have removed those fcntl() calls and replaced them with dup() calls. This fixes the issue in both Debug and Release builds llvm-svn: 258367
* Fix an issue where scripted commands would not actually print any of their ↵Enrico Granata2016-01-131-0/+9
| | | | | | | | output if an immediate output file was set in the result object via a Python file object Fixes rdar://24130303 llvm-svn: 257644
* Added the concept of a Read-Eval-Print-Loop to LLDB.Sean Callanan2015-10-191-0/+14
| | | | | | | | | | | | | | | | A REPL takes over the command line and typically treats input as source code. REPLs can also do code completion. The REPL class allows its subclasses to implement the language-specific functionality without having to know about the IOHandler-specific internals. Also added a PluginManager-based way of getting to a REPL given a language and a target. Also brought in some utility code and expression options that are useful for REPLs, such as line offsets for expressions, ANSI terminal coloring of errors, and a few IOHandler convenience functions. llvm-svn: 250753
* Introduce a `PythonFile` object, and use it everywhere.Zachary Turner2015-10-151-1/+7
| | | | | | | | | | | | | | | | | | | | | | | Python file handling got an overhaul in Python 3, and it affects the way we have to interact with files. Notably: 1) `PyFile_FromFile` no longer exists, and instead we have to use `PyFile_FromFd`. This means having a way to get an fd from a FILE*. For this we reuse the lldb_private::File class to convert between FILE*s and fds, since there are some subtleties regarding ownership rules when FILE*s and fds refer to the same file. 2) PyFile is no longer a builtin type, so there is no such thing as `PyFile_Check`. Instead, files in Python 3 are just instances of `io.IOBase`. So the logic for checking if something is a file in Python 3 is to check if it is a subclass of that module. Additionally, some unit tests are added to verify that `PythonFile` works as expected on Python 2 and Python 3, and `ScriptInterpreterPython` is updated to use `PythonFile` instead of manual calls to the various `PyFile_XXX` methods. llvm-svn: 250444
* Refactor many file functions to use FileSpec over strings.Chaoren Lin2015-05-291-9/+4
| | | | | | | | | | | | | | | | | 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
* Missed moving a variable during my previous revision 234455.Greg Clayton2015-04-091-1/+2
| | | | llvm-svn: 234456
* Darwin read()/pread()/fread() and write()/pwrite()/fwrite() calls can only ↵Greg Clayton2015-04-091-5/+142
| | | | | | | | | | write INT_MAX bytes at a time. Modify all read/write calls to allow any system to define MAX_READ_SIZE or MAX_WRITE_SIZE so large reads and writes can be divided up correctly. <rdar://problem/20471411> llvm-svn: 234455
* Fix warnings generated by clang-cl.Zachary Turner2015-04-021-1/+0
| | | | | | | | | | | | | | 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
* Avoid leaking log file descriptors into the inferior process.Pavel Labath2015-02-051-0/+2
| | | | | | | | | | | | | | Summary: This commit adds a new open flag File::eOpenOptionCloseOnExec (i.e., O_CLOEXEC), and adds it to the list of flags when opening log files (#ifndef windows). A regression test is included. Reviewers: vharron, clayborg Subscribers: lldb-commits Differential Revision: http://reviews.llvm.org/D7412 llvm-svn: 228310
* File::Read(), when asked to read the contents of a file into a heapJason Molenda2015-01-221-3/+4
| | | | | | | | | | | | buffer and to add a nul terminator byte, was incorrectly resizing its buffer so the nul terminator was not included. Problem found by clang ASAN instrumentation when using an expression prefix file which was read via this mechanism. <rdar://problem/19556459> llvm-svn: 226753
* LLGS Android target support - for Andy Chien : http://reviews.llvm.org/D6166Shawn Best2014-11-081-1/+1
| | | | llvm-svn: 221570
* Creates a socket host object.Zachary Turner2014-08-061-11/+20
| | | | | | | | | | | | | | | | | | 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
* 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
* Check if the terminal is interactive and set the flags accordinglyDeepak Panickal2014-03-031-1/+7
| | | | llvm-svn: 202726
* Fix Windows build, broken by the inclusion of sys/ioctl.h and isatty()Deepak Panickal2014-02-171-1/+4
| | | | llvm-svn: 201522
* Fixed an issue where "command source" would not do the right thing:Greg Clayton2014-02-051-3/+52
| | | | | | | - empty lines in init files would repeat previous command and cause errors to be displayed - all options to control showing the command, its output, if it should stop on error or continue, weren't being obeyed. llvm-svn: 200860
* Merging the iohandler branch back into main. Greg Clayton2014-01-271-27/+49
| | | | | | | | | | | | The many many benefits include: 1 - Input/Output/Error streams are now handled as real streams not a push style input 2 - auto completion in python embedded interpreter 3 - multi-line input for "script" and "expression" commands now allow you to edit previous/next lines using up and down arrow keys and this makes multi-line input actually a viable thing to use 4 - it is now possible to use curses to drive LLDB (please try the "gui" command) We will need to deal with and fix any buildbot failures and tests and arise now that input/output and error are correctly hooked up in all cases. llvm-svn: 200263
* Fix MSVC buildColin Riley2013-11-261-0/+2
| | | | | | Added _WIN32 guards to new platform features. Using correct SetErrorStringWithFormat within Host when LLDB_DISABLE_POSIX is defined. Also fixed an if defined block. llvm-svn: 195766
* Fix File::GetPermissions() to only return the permission bits.Greg Clayton2013-11-221-2/+2
| | | | llvm-svn: 195482
* Expose SBPlatform through the public API.Greg Clayton2013-11-201-11/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* Fix warnings about redefined macros at the end of File.cppDaniel Malea2013-08-271-22/+0
| | | | | | - removed needless defines that snuck in as part of the lldb-platform-work merge llvm-svn: 189392
* Fix MinGW build after lldb-platform-work merge:Virgile Bello2013-08-271-2/+0
| | | | | | | | | - mode_t is defined in <sys/types.h> - reorganized S_* user rights into win32.h - Use Host::Kill instead of kill - Currently #ifdef functions using pread/pwrite. llvm-svn: 189364
* merge lldb-platform-work branch (and assorted fixes) into trunkDaniel Malea2013-08-261-0/+109
| | | | | | | | | | | | | | | | | | | | | | | | | | 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/+41
| | | | | | portability. llvm-svn: 189107
* Cleaned up the File API a bit.Greg Clayton2013-05-221-27/+78
| | | | llvm-svn: 182538
* After discussing with Chris Lattner, we require C++11, so lets get rid of ↵Greg Clayton2013-04-181-1/+1
| | | | | | the macros and just use C++11. llvm-svn: 179805
* Since we use C++11, we should switch over to using std::unique_ptr when ↵Greg Clayton2013-04-181-1/+1
| | | | | | | | C++11 is being used. To do this, we follow what we have done for shared pointers and we define a STD_UNIQUE_PTR macro that can be used and it will "do the right thing". Due to some API differences in std::unique_ptr and due to the fact that we need to be able to compile without C++11, we can't use move semantics so some code needed to change so that it can compile with either C++. Anyone wanting to use a unique_ptr or auto_ptr should now use the "STD_UNIQUE_PTR(TYPE)" macro. llvm-svn: 179779
* <rdar://problem/13069948>Greg Clayton2013-01-251-4/+4
| | | | | | | | | | | | Major fixed to allow reading files that are over 4GB. The main problems were that the DataExtractor was using 32 bit offsets as a data cursor, and since we mmap all of our object files we could run into cases where if we had a very large core file that was over 4GB, we were running into the 4GB boundary. So I defined a new "lldb::offset_t" which should be used for all file offsets. After making this change, I enabled warnings for data loss and for enexpected implicit conversions temporarily and found a ton of things that I fixed. Any functions that take an index internally, should use "size_t" for any indexes and also should return "size_t" for any sizes of collections. llvm-svn: 173463
* Fixed File::SeekFromEnd() to use SEEK_END insted of SEEK_CUR.Greg Clayton2012-10-301-1/+1
| | | | llvm-svn: 167025
* OptionValueFileSpec had an accessor to read the contents of the file and ↵Greg Clayton2012-08-301-2/+2
| | | | | | return the data. This can end up being used to get the string contents of a text file and could end up not being NULL terminated. I added accessors to get the file contents raw, or with a null terminator. Added the needed calls to make this happen in the FileSpec and File classes. llvm-svn: 162921
* <rdar://problem/10507811>Greg Clayton2012-01-041-37/+145
| | | | | | | | | | Be better at detecting when DWARF changes and handle this more gracefully than asserting and exiting. Also fixed up a bunch of system calls that weren't properly checking for EINTR. llvm-svn: 147559
* 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
* Add missing headers.Stephen Wilson2011-04-081-0/+1
| | | | | | | | Something changed in commit r129112 where a few standard headers vanished from the include chain when building on Linux. Fix up by including limits.h for INT_MAX and PATH_MAX where needed, and stdio.h for printf(). llvm-svn: 129130
* Some OpenBSD patches from Amit Kulkarni.Greg Clayton2011-04-011-0/+1
| | | | llvm-svn: 128721
* Missed part of a patch from Stephen Wilson.Greg Clayton2011-02-091-0/+1
| | | | llvm-svn: 125220
* File::GetFileSpec() support for linux patch from Stephen Wilson.Greg Clayton2011-02-091-1/+17
| | | | llvm-svn: 125181
* Pull support for the shared and exclusive lock since this wasn't availableGreg Clayton2011-02-091-7/+7
| | | | | | | on linux. And conditionalize the availablility of the fcntl() command F_GETPATH. llvm-svn: 125152
* Use Host::File in lldb_private::StreamFile and other places to cleanup hostGreg Clayton2011-02-091-26/+273
| | | | | | layer a bit more. llvm-svn: 125149
* Updated a few more Host::File functions and added documentation.Greg Clayton2011-02-081-0/+57
| | | | llvm-svn: 125110
* Added a few more calls to the File abtract class for seeking, syncing andGreg Clayton2011-02-081-4/+92
| | | | | | getting the file spec from the file descriptor. llvm-svn: 125106
* Added a file abtraction layer into the Host section of LLDB.Greg Clayton2011-02-081-0/+146
llvm-svn: 125093
OpenPOWER on IntegriCloud