mirror of
https://github.com/geohot/qira
synced 2025-03-14 02:52:52 +03:00
is this good windows yet
This commit is contained in:
parent
a89300f7f7
commit
910ee753f5
@ -1,3 +1,5 @@
|
||||
import os
|
||||
|
||||
WITH_CDA = False
|
||||
WITH_DWARF = False
|
||||
TRACE_LIBRARIES = False
|
||||
@ -6,5 +8,8 @@ WEB_PORT = 3002
|
||||
SOCAT_PORT = 4000
|
||||
FORK_PORT = 4001
|
||||
USE_PIN = False
|
||||
TRACE_FILE_BASE = "/tmp/qira_logs/"
|
||||
if os.name == "nt":
|
||||
TRACE_FILE_BASE = "c:/qiratmp"
|
||||
else:
|
||||
TRACE_FILE_BASE = "/tmp/qira_logs/"
|
||||
|
||||
|
@ -45,8 +45,12 @@ Trace::~Trace() {
|
||||
is_running_ = false;
|
||||
THREAD_JOIN(thread);
|
||||
// mutex lock isn't required now that the thread stopped
|
||||
#ifdef _WIN32
|
||||
CloseHandle(fd_);
|
||||
#else
|
||||
munmap((void*)backing_, backing_size_);
|
||||
close(fd_);
|
||||
#endif
|
||||
//printf("dead\n");
|
||||
}
|
||||
|
||||
@ -82,6 +86,9 @@ inline MemoryWithValid Trace::get_byte(Clnum clnum, Address a) {
|
||||
|
||||
bool Trace::remap_backing(uint64_t new_size) {
|
||||
if (backing_size_ == new_size) return true;
|
||||
|
||||
#ifdef _WIN32
|
||||
#else
|
||||
while (1) {
|
||||
off_t fs = lseek(fd_, 0, SEEK_END);
|
||||
if (fs < new_size) {
|
||||
@ -96,6 +103,8 @@ bool Trace::remap_backing(uint64_t new_size) {
|
||||
backing_size_ = new_size;
|
||||
backing_ = (const struct change *)mmap(NULL, backing_size_, PROT_READ, MAP_SHARED, fd_, 0);
|
||||
MUTEX_UNLOCK(backing_mutex_);
|
||||
#endif
|
||||
|
||||
if (backing_ == NULL) {
|
||||
printf("ERROR: remap_backing is about to return NULL\n");
|
||||
}
|
||||
@ -111,8 +120,12 @@ bool Trace::ConnectToFileAndStart(char *filename, int register_size, int registe
|
||||
|
||||
registers_.resize(register_count_);
|
||||
|
||||
#ifdef _WIN32
|
||||
fd_ = CreateFile(filename, GENERIC_READ, FILE_SHARE_READ|FILE_SHARE_WRITE, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
|
||||
#else
|
||||
fd_ = open(filename, O_RDONLY);
|
||||
if (fd_ <= 0) return false;
|
||||
#endif
|
||||
|
||||
if (!remap_backing(sizeof(struct change))) return false;
|
||||
|
||||
|
@ -31,6 +31,8 @@
|
||||
#define RWLOCK_WRLOCK(x) pthread_rwlock_wrlock(&x)
|
||||
#define RWLOCK_UNLOCK(x) pthread_rwlock_unlock(&x)
|
||||
#define RWLOCK_WRUNLOCK(x) pthread_rwlock_unlock(&x)
|
||||
|
||||
#define QIRAFILE int
|
||||
#else
|
||||
#include <Windows.h>
|
||||
#define THREAD HANDLE
|
||||
@ -48,6 +50,8 @@
|
||||
#define MUTEX_INIT(x) RWLOCK_INIT(x)
|
||||
#define MUTEX_LOCK(x) RWLOCK_WRLOCK(x)
|
||||
#define MUTEX_UNLOCK(x) RWLOCK_WRUNLOCK(x)
|
||||
|
||||
#define QIRAFILE HANDLE
|
||||
#endif
|
||||
|
||||
|
||||
@ -124,7 +128,7 @@ private:
|
||||
MUTEX backing_mutex_;
|
||||
const struct change* backing_;
|
||||
uint64_t backing_size_;
|
||||
int fd_;
|
||||
QIRAFILE fd_;
|
||||
EntryNumber entries_done_;
|
||||
|
||||
bool did_update_;
|
||||
|
Loading…
x
Reference in New Issue
Block a user