std::string llvm::sys::disassembleBuffer(uint8_t* start, size_t length,
uint64_t pc) {
- std::stringstream res;
-
#if (defined (__i386__) || defined (__amd64__) || defined (__x86_64__)) \
&& USE_UDIS86
+ std::stringstream res;
+
unsigned bits;
# if defined(__i386__)
bits = 32;
while (ud_disassemble(&ud_obj)) {
res << ud_insn_off(&ud_obj) << ":\t" << ud_insn_asm(&ud_obj) << "\n";
}
-#else
- res << "No disassembler available. See configure help for options.\n";
-#endif
return res.str();
+#else
+ return "No disassembler available. See configure help for options.\n";
+#endif
}
//
//===----------------------------------------------------------------------===//
#include "llvm/Support/LockFileManager.h"
+#include "llvm/ADT/STLExtras.h"
+#include "llvm/ADT/StringExtras.h"
#include "llvm/Support/FileSystem.h"
+#include "llvm/Support/MemoryBuffer.h"
#include "llvm/Support/raw_ostream.h"
-#include <fstream>
#include <sys/stat.h>
#include <sys/types.h>
#if LLVM_ON_WIN32
// Read the owning host and PID out of the lock file. If it appears that the
// owning process is dead, the lock file is invalid.
- int PID = 0;
- std::string Hostname;
- std::ifstream Input(LockFileName.str().c_str());
- if (Input >> Hostname >> PID && PID > 0 &&
- processStillExecuting(Hostname, PID))
- return std::make_pair(Hostname, PID);
+ OwningPtr<MemoryBuffer> MB;
+ if (MemoryBuffer::getFile(LockFileName, MB)) {
+ StringRef Hostname;
+ StringRef PIDStr;
+ tie(Hostname, PIDStr) = getToken(MB->getBuffer(), " ");
+ int PID;
+ if (PIDStr.getAsInteger(10, PID))
+ return std::make_pair(std::string(Hostname), PID);
+ }
// Delete the lock file. It's invalid anyway.
- bool Existed;
- sys::fs::remove(LockFileName, Existed);
+ sys::fs::remove(LockFileName);
return None;
}
if (ItemType != 0) {
ListRecTy *ListType = dyn_cast<ListRecTy>(ItemType);
if (ListType == 0) {
- std::stringstream s;
- s << "Type mismatch for list, expected list type, got "
- << ItemType->getAsString();
- TokError(s.str());
+ std::string s;
+ raw_string_ostream ss(s);
+ ss << "Type mismatch for list, expected list type, got "
+ << ItemType->getAsString();
+ TokError(ss.str());
return 0;
}
GivenListTy = ListType;