llvm.org GIT mirror llvm / 9d88d1a
For PR351: \ The getFileTimestamp and getFileSize functions have been removed from \ FileUtilities.{h,cpp}. They are replaced by Path::getTimestamp and \ Path::getSize,respectively. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@18892 91177308-0d34-0410-b5e6-96231b3b80d8 Reid Spencer 14 years ago
6 changed file(s) with 27 addition(s) and 39 deletion(s). Raw diff Collapse all Expand all
2020 #ifndef LLVM_DEBUGGER_PROGRAMINFO_H
2121 #define LLVM_DEBUGGER_PROGRAMINFO_H
2222
23 #include "llvm/System/TimeValue.h"
2324 #include
2425 #include
2526 #include
132133
133134 /// ProgramTimeStamp - This is the timestamp of the executable file that we
134135 /// currently have loaded into the debugger.
135 unsigned long long ProgramTimeStamp;
136 sys::TimeValue ProgramTimeStamp;
136137
137138 /// SourceFiles - This map is used to transform source file descriptors into
138139 /// their corresponding SourceFileInfo objects. This mapping owns the
169170
170171 /// getProgramTimeStamp - Return the time-stamp of the program when it was
171172 /// loaded.
172 unsigned long long getProgramTimeStamp() const { return ProgramTimeStamp; }
173 sys::TimeValue getProgramTimeStamp() const { return ProgramTimeStamp; }
173174
174175 //===------------------------------------------------------------------===//
175176 // Interfaces to the source code files that make up the program.
5959 /// In case of failure, the file's access attributes are unspecified.
6060 ///
6161 bool MakeFileReadable(const std::string &Filename);
62
63 /// getFileSize - Return the size of the specified file in bytes, or -1 if the
64 /// file cannot be read or does not exist.
65 long long getFileSize(const std::string &Filename);
66
67
68 /// getFileTimestamp - Get the last modified time for the specified file in an
69 /// unspecified format. This is useful to allow checking to see if a file was
70 /// updated since that last time the timestampt was aquired. If the file does
71 /// not exist or there is an error getting the time-stamp, zero is returned.
72 unsigned long long getFileTimestamp(const std::string &Filename);
7362
7463 /// ReadFileIntoAddressSpace - Attempt to map the specific file into the
7564 /// address space of the current process for reading. If this succeeds,
375375 /// @brief Get file status.
376376 void getStatusInfo(StatusInfo& info) const;
377377
378 /// This function returns the last modified time stamp for the file
379 /// referenced by this path. The Path may reference a file or a directory.
380 /// If the file does not exist, a ZeroTime timestamp is returned.
381 /// @returns last modified timestamp of the file/directory or ZeroTime
382 /// @brief Get file timestamp.
383 inline TimeValue getTimestamp() const {
384 StatusInfo info; getStatusInfo(info); return info.modTime;
385 }
386
387 /// This function returns the size of the file referenced by this path.
388 /// @brief Get file size.
389 inline size_t getSize() const {
390 StatusInfo info; getStatusInfo(info); return info.fileSize;
391 }
392
378393 /// This method attempts to set the Path object to \p unverified_path
379394 /// and interpret the name as a directory name. The \p unverified_path
380395 /// is verified. If verification succeeds then \p unverified_path
235235 // ProgramInfo implementation
236236 //
237237
238 ProgramInfo::ProgramInfo(Module *m) : M(m) {
238 ProgramInfo::ProgramInfo(Module *m) : M(m), ProgramTimeStamp(0,0) {
239239 assert(M && "Cannot create program information with a null module!");
240 ProgramTimeStamp = getFileTimestamp(M->getModuleIdentifier());
240 sys::Path modulePath(M->getModuleIdentifier());
241 ProgramTimeStamp = modulePath.getTimestamp();
241242
242243 SourceFilesIsComplete = false;
243244 SourceFunctionsIsComplete = false;
1313
1414 #include "llvm/Support/FileUtilities.h"
1515 #include "llvm/Support/DataTypes.h"
16 #include "llvm/System/Path.h"
1617 #include "llvm/Config/unistd.h"
1718 #include "llvm/Config/fcntl.h"
1819 #include "llvm/Config/sys/types.h"
194195 return AddPermissionsBits(Filename, 0444);
195196 }
196197
197 /// getFileSize - Return the size of the specified file in bytes, or -1 if the
198 /// file cannot be read or does not exist.
199 long long llvm::getFileSize(const std::string &Filename) {
200 struct stat StatBuf;
201 if (stat(Filename.c_str(), &StatBuf) == -1)
202 return -1;
203 return StatBuf.st_size;
204 }
205
206 /// getFileTimestamp - Get the last modified time for the specified file in an
207 /// unspecified format. This is useful to allow checking to see if a file was
208 /// updated since that last time the timestampt was aquired. If the file does
209 /// not exist or there is an error getting the time-stamp, zero is returned.
210 unsigned long long llvm::getFileTimestamp(const std::string &Filename) {
211 struct stat StatBuf;
212 if (stat(Filename.c_str(), &StatBuf) == -1)
213 return 0;
214 return StatBuf.st_mtime;
215 }
216
217198 /// ReadFileIntoAddressSpace - Attempt to map the specific file into the
218199 /// address space of the current process for reading. If this succeeds,
219200 /// return the address of the buffer and the length of the file mapped. On
221202 void *llvm::ReadFileIntoAddressSpace(const std::string &Filename,
222203 unsigned &Length) {
223204 #if defined(HAVE_MMAP_FILE) && !defined(_MSC_VER)
224 Length = (unsigned)getFileSize(Filename);
205 sys::Path File(Filename);
206 Length = (unsigned)File.getSize();
225207 if ((int)Length == -1) return 0;
226208
227209 FDHandle FD(open(Filename.c_str(), O_RDONLY));
4848 eliminateRunInfo();
4949
5050 // If the program has been modified, reload it!
51 std::string Program = Dbg.getProgramPath();
52 if (TheProgramInfo->getProgramTimeStamp() != getFileTimestamp(Program)) {
51 sys::Path Program (Dbg.getProgramPath());
52 if (TheProgramInfo->getProgramTimeStamp() != Program.getTimestamp()) {
5353 std::cout << "'" << Program << "' has changed; re-reading program.\n";
5454
5555 // Unload an existing program. This kills the program if necessary.
5858 TheProgramInfo = 0;
5959 CurrentFile = 0;
6060
61 Dbg.loadProgram(Program);
61 Dbg.loadProgram(Program.toString());
6262 TheProgramInfo = new ProgramInfo(Dbg.getProgram());
6363 }
6464