summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/llvm/Debugger/ProgramInfo.h5
-rw-r--r--include/llvm/Support/FileUtilities.h11
-rw-r--r--include/llvm/System/Path.h15
-rw-r--r--lib/Debugger/ProgramInfo.cpp5
-rw-r--r--lib/Support/FileUtilities.cpp24
-rw-r--r--tools/llvm-db/Commands.cpp6
6 files changed, 27 insertions, 39 deletions
diff --git a/include/llvm/Debugger/ProgramInfo.h b/include/llvm/Debugger/ProgramInfo.h
index 4420e72418..f7ee77dc31 100644
--- a/include/llvm/Debugger/ProgramInfo.h
+++ b/include/llvm/Debugger/ProgramInfo.h
@@ -21,6 +21,7 @@
#ifndef LLVM_DEBUGGER_PROGRAMINFO_H
#define LLVM_DEBUGGER_PROGRAMINFO_H
+#include "llvm/System/TimeValue.h"
#include <string>
#include <map>
#include <vector>
@@ -133,7 +134,7 @@ namespace llvm {
/// ProgramTimeStamp - This is the timestamp of the executable file that we
/// currently have loaded into the debugger.
- unsigned long long ProgramTimeStamp;
+ sys::TimeValue ProgramTimeStamp;
/// SourceFiles - This map is used to transform source file descriptors into
/// their corresponding SourceFileInfo objects. This mapping owns the
@@ -170,7 +171,7 @@ namespace llvm {
/// getProgramTimeStamp - Return the time-stamp of the program when it was
/// loaded.
- unsigned long long getProgramTimeStamp() const { return ProgramTimeStamp; }
+ sys::TimeValue getProgramTimeStamp() const { return ProgramTimeStamp; }
//===------------------------------------------------------------------===//
// Interfaces to the source code files that make up the program.
diff --git a/include/llvm/Support/FileUtilities.h b/include/llvm/Support/FileUtilities.h
index f61ee7c640..885ee86c0d 100644
--- a/include/llvm/Support/FileUtilities.h
+++ b/include/llvm/Support/FileUtilities.h
@@ -61,17 +61,6 @@ bool MakeFileExecutable(const std::string &Filename);
///
bool MakeFileReadable(const std::string &Filename);
-/// getFileSize - Return the size of the specified file in bytes, or -1 if the
-/// file cannot be read or does not exist.
-long long getFileSize(const std::string &Filename);
-
-
-/// getFileTimestamp - Get the last modified time for the specified file in an
-/// unspecified format. This is useful to allow checking to see if a file was
-/// updated since that last time the timestampt was aquired. If the file does
-/// not exist or there is an error getting the time-stamp, zero is returned.
-unsigned long long getFileTimestamp(const std::string &Filename);
-
/// ReadFileIntoAddressSpace - Attempt to map the specific file into the
/// address space of the current process for reading. If this succeeds,
/// return the address of the buffer and the length of the file mapped. On
diff --git a/include/llvm/System/Path.h b/include/llvm/System/Path.h
index 10c8bccef8..57cbc6c64d 100644
--- a/include/llvm/System/Path.h
+++ b/include/llvm/System/Path.h
@@ -376,6 +376,21 @@ namespace sys {
/// @brief Get file status.
void getStatusInfo(StatusInfo& info) const;
+ /// This function returns the last modified time stamp for the file
+ /// referenced by this path. The Path may reference a file or a directory.
+ /// If the file does not exist, a ZeroTime timestamp is returned.
+ /// @returns last modified timestamp of the file/directory or ZeroTime
+ /// @brief Get file timestamp.
+ inline TimeValue getTimestamp() const {
+ StatusInfo info; getStatusInfo(info); return info.modTime;
+ }
+
+ /// This function returns the size of the file referenced by this path.
+ /// @brief Get file size.
+ inline size_t getSize() const {
+ StatusInfo info; getStatusInfo(info); return info.fileSize;
+ }
+
/// This method attempts to set the Path object to \p unverified_path
/// and interpret the name as a directory name. The \p unverified_path
/// is verified. If verification succeeds then \p unverified_path
diff --git a/lib/Debugger/ProgramInfo.cpp b/lib/Debugger/ProgramInfo.cpp
index c6e5d32b66..c0d85f97e4 100644
--- a/lib/Debugger/ProgramInfo.cpp
+++ b/lib/Debugger/ProgramInfo.cpp
@@ -236,9 +236,10 @@ void SourceFunctionInfo::getSourceLocation(unsigned &RetLineNo,
// ProgramInfo implementation
//
-ProgramInfo::ProgramInfo(Module *m) : M(m) {
+ProgramInfo::ProgramInfo(Module *m) : M(m), ProgramTimeStamp(0,0) {
assert(M && "Cannot create program information with a null module!");
- ProgramTimeStamp = getFileTimestamp(M->getModuleIdentifier());
+ sys::Path modulePath(M->getModuleIdentifier());
+ ProgramTimeStamp = modulePath.getTimestamp();
SourceFilesIsComplete = false;
SourceFunctionsIsComplete = false;
diff --git a/lib/Support/FileUtilities.cpp b/lib/Support/FileUtilities.cpp
index 5b7c56e950..305f455937 100644
--- a/lib/Support/FileUtilities.cpp
+++ b/lib/Support/FileUtilities.cpp
@@ -14,6 +14,7 @@
#include "llvm/Support/FileUtilities.h"
#include "llvm/Support/DataTypes.h"
+#include "llvm/System/Path.h"
#include "llvm/Config/unistd.h"
#include "llvm/Config/fcntl.h"
#include "llvm/Config/sys/types.h"
@@ -195,26 +196,6 @@ bool llvm::MakeFileReadable(const std::string &Filename) {
return AddPermissionsBits(Filename, 0444);
}
-/// getFileSize - Return the size of the specified file in bytes, or -1 if the
-/// file cannot be read or does not exist.
-long long llvm::getFileSize(const std::string &Filename) {
- struct stat StatBuf;
- if (stat(Filename.c_str(), &StatBuf) == -1)
- return -1;
- return StatBuf.st_size;
-}
-
-/// getFileTimestamp - Get the last modified time for the specified file in an
-/// unspecified format. This is useful to allow checking to see if a file was
-/// updated since that last time the timestampt was aquired. If the file does
-/// not exist or there is an error getting the time-stamp, zero is returned.
-unsigned long long llvm::getFileTimestamp(const std::string &Filename) {
- struct stat StatBuf;
- if (stat(Filename.c_str(), &StatBuf) == -1)
- return 0;
- return StatBuf.st_mtime;
-}
-
/// ReadFileIntoAddressSpace - Attempt to map the specific file into the
/// address space of the current process for reading. If this succeeds,
/// return the address of the buffer and the length of the file mapped. On
@@ -222,7 +203,8 @@ unsigned long long llvm::getFileTimestamp(const std::string &Filename) {
void *llvm::ReadFileIntoAddressSpace(const std::string &Filename,
unsigned &Length) {
#if defined(HAVE_MMAP_FILE) && !defined(_MSC_VER)
- Length = (unsigned)getFileSize(Filename);
+ sys::Path File(Filename);
+ Length = (unsigned)File.getSize();
if ((int)Length == -1) return 0;
FDHandle FD(open(Filename.c_str(), O_RDONLY));
diff --git a/tools/llvm-db/Commands.cpp b/tools/llvm-db/Commands.cpp
index de7fdf604b..37f8a78209 100644
--- a/tools/llvm-db/Commands.cpp
+++ b/tools/llvm-db/Commands.cpp
@@ -49,8 +49,8 @@ void CLIDebugger::startProgramRunning() {
eliminateRunInfo();
// If the program has been modified, reload it!
- std::string Program = Dbg.getProgramPath();
- if (TheProgramInfo->getProgramTimeStamp() != getFileTimestamp(Program)) {
+ sys::Path Program (Dbg.getProgramPath());
+ if (TheProgramInfo->getProgramTimeStamp() != Program.getTimestamp()) {
std::cout << "'" << Program << "' has changed; re-reading program.\n";
// Unload an existing program. This kills the program if necessary.
@@ -59,7 +59,7 @@ void CLIDebugger::startProgramRunning() {
TheProgramInfo = 0;
CurrentFile = 0;
- Dbg.loadProgram(Program);
+ Dbg.loadProgram(Program.toString());
TheProgramInfo = new ProgramInfo(Dbg.getProgram());
}