mirror of https://github.com/inolen/redream.git
track number of write watches with microprofile
This commit is contained in:
parent
76e4a96689
commit
265369f864
|
@ -14,6 +14,9 @@
|
|||
#define PROFILER_RUNTIME(name) \
|
||||
MICROPROFILE_SCOPEI("runtime", name, dreavm::emu::Profiler::ScopeColor(name))
|
||||
|
||||
#define PROFILER_COUNT(name, count) \
|
||||
MICROPROFILE_COUNTER_SET(name, count)
|
||||
|
||||
namespace dreavm {
|
||||
namespace emu {
|
||||
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
#include "core/core.h"
|
||||
#include "core/interval_tree.h"
|
||||
#include "emu/profiler.h"
|
||||
#include "sys/sigsegv_handler.h"
|
||||
|
||||
using namespace dreavm::sys;
|
||||
|
@ -25,8 +26,6 @@ SIGSEGVHandler *SIGSEGVHandler::Install() {
|
|||
|
||||
SIGSEGVHandler::~SIGSEGVHandler() { global_handler_ = nullptr; }
|
||||
|
||||
// TODO track handler counts with microprofile
|
||||
|
||||
void SIGSEGVHandler::AddWriteWatch(void *ptr, int size,
|
||||
WriteWatchHandler handler, void *ctx,
|
||||
void *data) {
|
||||
|
@ -37,13 +36,16 @@ void SIGSEGVHandler::AddWriteWatch(void *ptr, int size,
|
|||
dreavm::align(reinterpret_cast<uintptr_t>(ptr) + size,
|
||||
static_cast<uintptr_t>(page_size));
|
||||
|
||||
// write-protect the pages
|
||||
// write protect the pages
|
||||
CHECK(Protect(reinterpret_cast<void *>(physical_start),
|
||||
static_cast<int>(physical_end - physical_start), ACC_READONLY));
|
||||
|
||||
write_watches_.Insert(
|
||||
physical_start, physical_end - 1,
|
||||
WriteWatch(handler, ctx, data, physical_start, physical_end));
|
||||
|
||||
// track number of watches
|
||||
PROFILER_COUNT("WriteWatches", write_watches_.Size());
|
||||
}
|
||||
|
||||
bool SIGSEGVHandler::HandleAccessFault(uintptr_t rip, uintptr_t fault_addr) {
|
||||
|
@ -56,7 +58,7 @@ bool SIGSEGVHandler::HandleAccessFault(uintptr_t rip, uintptr_t fault_addr) {
|
|||
|
||||
watch.handler(watch.ctx, watch.data);
|
||||
|
||||
// remove write-protection
|
||||
// remove write protection
|
||||
CHECK(Protect(reinterpret_cast<void *>(watch.physical_start),
|
||||
static_cast<int>(watch.physical_end - watch.physical_start),
|
||||
ACC_READWRITE));
|
||||
|
@ -66,5 +68,8 @@ bool SIGSEGVHandler::HandleAccessFault(uintptr_t rip, uintptr_t fault_addr) {
|
|||
node = write_watches_.Find(fault_addr, fault_addr);
|
||||
}
|
||||
|
||||
// track number of watches
|
||||
PROFILER_COUNT("WriteWatches", write_watches_.Size());
|
||||
|
||||
return handled;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue