summaryrefslogtreecommitdiff
path: root/src/debug/createdump/memoryregion.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/debug/createdump/memoryregion.h')
-rw-r--r--src/debug/createdump/memoryregion.h71
1 files changed, 56 insertions, 15 deletions
diff --git a/src/debug/createdump/memoryregion.h b/src/debug/createdump/memoryregion.h
index 1332ab1..1f6c5f5 100644
--- a/src/debug/createdump/memoryregion.h
+++ b/src/debug/createdump/memoryregion.h
@@ -2,20 +2,31 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
+enum MEMORY_REGION_FLAGS : uint32_t
+{
+ // PF_X = 0x01, // Execute
+ // PF_W = 0x02, // Write
+ // PF_R = 0x04, // Read
+ MEMORY_REGION_FLAG_PERMISSIONS_MASK = 0x0f,
+ MEMORY_REGION_FLAG_SHARED = 0x10,
+ MEMORY_REGION_FLAG_PRIVATE = 0x20,
+ MEMORY_REGION_FLAG_MEMORY_BACKED = 0x40
+};
+
struct MemoryRegion
{
private:
- uint32_t m_permissions;
+ uint32_t m_flags;
uint64_t m_startAddress;
uint64_t m_endAddress;
uint64_t m_offset;
// The name used for NT_FILE output
- char* m_fileName;
+ const char* m_fileName;
public:
- MemoryRegion(uint64_t start, uint64_t end) :
- m_permissions(PF_R | PF_W | PF_X),
+ MemoryRegion(uint32_t flags, uint64_t start, uint64_t end) :
+ m_flags(flags),
m_startAddress(start),
m_endAddress(end),
m_offset(0),
@@ -25,8 +36,8 @@ public:
assert((end & ~PAGE_MASK) == 0);
}
- MemoryRegion(uint32_t permissions, uint64_t start, uint64_t end, uint64_t offset, char* filename) :
- m_permissions(permissions),
+ MemoryRegion(uint32_t flags, uint64_t start, uint64_t end, uint64_t offset, const char* filename) :
+ m_flags(flags),
m_startAddress(start),
m_endAddress(end),
m_offset(offset),
@@ -36,7 +47,39 @@ public:
assert((end & ~PAGE_MASK) == 0);
}
- const uint32_t Permissions() const { return m_permissions; }
+ // copy with new file name constructor
+ MemoryRegion(const MemoryRegion& region, const char* fileName) :
+ m_flags(region.m_flags),
+ m_startAddress(region.m_startAddress),
+ m_endAddress(region.m_endAddress),
+ m_offset(region.m_offset),
+ m_fileName(fileName)
+ {
+ }
+
+ // copy with new flags constructor. The file name is not copied.
+ MemoryRegion(const MemoryRegion& region, uint32_t flags) :
+ m_flags(flags),
+ m_startAddress(region.m_startAddress),
+ m_endAddress(region.m_endAddress),
+ m_offset(region.m_offset),
+ m_fileName(nullptr)
+ {
+ }
+
+ // copy constructor
+ MemoryRegion(const MemoryRegion& region) :
+ m_flags(region.m_flags),
+ m_startAddress(region.m_startAddress),
+ m_endAddress(region.m_endAddress),
+ m_offset(region.m_offset),
+ m_fileName(region.m_fileName)
+ {
+ }
+
+ const uint32_t Permissions() const { return m_flags & MEMORY_REGION_FLAG_PERMISSIONS_MASK; }
+ const uint32_t Flags() const { return m_flags; }
+ const bool IsBackedByMemory() const { return (m_flags & MEMORY_REGION_FLAG_MEMORY_BACKED) != 0; }
const uint64_t StartAddress() const { return m_startAddress; }
const uint64_t EndAddress() const { return m_endAddress; }
const uint64_t Size() const { return m_endAddress - m_startAddress; }
@@ -48,27 +91,25 @@ public:
return (m_startAddress < rhs.m_startAddress) && (m_endAddress <= rhs.m_startAddress);
}
+ // Returns true if "rhs" is wholly contained in this one
bool Contains(const MemoryRegion& rhs) const
{
return (m_startAddress <= rhs.m_startAddress) && (m_endAddress >= rhs.m_endAddress);
}
+ // Free the file name memory
void Cleanup()
{
if (m_fileName != nullptr)
{
- free(m_fileName);
+ free((void*)m_fileName);
m_fileName = nullptr;
}
}
- void Print() const
+ void Trace() const
{
- if (m_fileName != nullptr) {
- TRACE("%016lx - %016lx (%06ld) %016lx %x %s\n", m_startAddress, m_endAddress, (Size() >> PAGE_SHIFT), m_offset, m_permissions, m_fileName);
- }
- else {
- TRACE("%016lx - %016lx (%06ld) %x\n", m_startAddress, m_endAddress, (Size() >> PAGE_SHIFT), m_permissions);
- }
+ TRACE("%s%016lx - %016lx (%06ld) %016lx %02x %s\n", IsBackedByMemory() ? "*" : " ", m_startAddress, m_endAddress,
+ (Size() >> PAGE_SHIFT), m_offset, m_flags, m_fileName != nullptr ? m_fileName : "");
}
};