-
Notifications
You must be signed in to change notification settings - Fork 15.3k
[NFC][lldb][windows] fully qualify references to MemoryRegionInfo #169845
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[NFC][lldb][windows] fully qualify references to MemoryRegionInfo #169845
Conversation
|
@llvm/pr-subscribers-platform-windows @llvm/pr-subscribers-lldb Author: Charles Zablit (charles-zablit) ChangesThis is an NFC patch which fully qualifies references to The Windows API exposes an enum value named // memoryapi.h
#if (NTDDI_VERSION >= NTDDI_WIN10_RS1)
typedef enum WIN32_MEMORY_INFORMATION_CLASS {
MemoryRegionInfo
} WIN32_MEMORY_INFORMATION_CLASS;This causes an unresolved symbol error due to ambiguity. Fully qualifying the name removes this ambiguity. Please note that this patch is a preface to: Full diff: https://github.com/llvm/llvm-project/pull/169845.diff 3 Files Affected:
diff --git a/lldb/source/Interpreter/ScriptInterpreter.cpp b/lldb/source/Interpreter/ScriptInterpreter.cpp
index 211868b51facb..d2fd372bfe9e3 100644
--- a/lldb/source/Interpreter/ScriptInterpreter.cpp
+++ b/lldb/source/Interpreter/ScriptInterpreter.cpp
@@ -136,7 +136,7 @@ SymbolContext ScriptInterpreter::GetOpaqueTypeFromSBSymbolContext(
return {};
}
-std::optional<MemoryRegionInfo>
+std::optional<lldb_private::MemoryRegionInfo>
ScriptInterpreter::GetOpaqueTypeFromSBMemoryRegionInfo(
const lldb::SBMemoryRegionInfo &mem_region) const {
if (!mem_region.m_opaque_up)
diff --git a/lldb/source/Target/Process.cpp b/lldb/source/Target/Process.cpp
index 69edea503002e..b483fbaea256a 100644
--- a/lldb/source/Target/Process.cpp
+++ b/lldb/source/Target/Process.cpp
@@ -6545,7 +6545,7 @@ Status Process::WriteMemoryTags(lldb::addr_t addr, size_t len,
// Create a CoreFileMemoryRange from a MemoryRegionInfo
static CoreFileMemoryRange
-CreateCoreFileMemoryRange(const MemoryRegionInfo ®ion) {
+CreateCoreFileMemoryRange(const lldb_private::MemoryRegionInfo ®ion) {
const addr_t addr = region.GetRange().GetRangeBase();
llvm::AddressRange range(addr, addr + region.GetRange().GetByteSize());
return {range, region.GetLLDBPermissions()};
@@ -6554,7 +6554,7 @@ CreateCoreFileMemoryRange(const MemoryRegionInfo ®ion) {
// Add dirty pages to the core file ranges and return true if dirty pages
// were added. Return false if the dirty page information is not valid or in
// the region.
-static bool AddDirtyPages(const MemoryRegionInfo ®ion,
+static bool AddDirtyPages(const lldb_private::MemoryRegionInfo ®ion,
CoreFileMemoryRanges &ranges) {
const auto &dirty_page_list = region.GetDirtyPageList();
if (!dirty_page_list)
@@ -6593,8 +6593,8 @@ static bool AddDirtyPages(const MemoryRegionInfo ®ion,
// given region. If the region has dirty page information, only dirty pages
// will be added to \a ranges, else the entire range will be added to \a
// ranges.
-static void AddRegion(const MemoryRegionInfo ®ion, bool try_dirty_pages,
- CoreFileMemoryRanges &ranges) {
+static void AddRegion(const lldb_private::MemoryRegionInfo ®ion,
+ bool try_dirty_pages, CoreFileMemoryRanges &ranges) {
// Don't add empty ranges.
if (region.GetRange().GetByteSize() == 0)
return;
@@ -6617,7 +6617,7 @@ static void SaveDynamicLoaderSections(Process &process,
if (!dyld)
return;
- std::vector<MemoryRegionInfo> dynamic_loader_mem_regions;
+ std::vector<lldb_private::MemoryRegionInfo> dynamic_loader_mem_regions;
std::function<bool(const lldb_private::Thread &)> save_thread_predicate =
[&](const lldb_private::Thread &t) -> bool {
return options.ShouldThreadBeSaved(t.GetID());
@@ -6742,10 +6742,11 @@ static void GetCoreFileSaveRangesStackOnly(Process &process,
// TODO: We should refactor CoreFileMemoryRanges to use the lldb range type, and
// then add an intersect method on it, or MemoryRegionInfo.
-static MemoryRegionInfo Intersect(const MemoryRegionInfo &lhs,
- const MemoryRegionInfo::RangeType &rhs) {
+static lldb_private::MemoryRegionInfo
+Intersect(const lldb_private::MemoryRegionInfo &lhs,
+ const lldb_private::MemoryRegionInfo::RangeType &rhs) {
- MemoryRegionInfo region_info;
+ lldb_private::MemoryRegionInfo region_info;
region_info.SetLLDBPermissions(lhs.GetLLDBPermissions());
region_info.GetRange() = lhs.GetRange().Intersect(rhs);
diff --git a/lldb/unittests/Process/gdb-remote/GDBRemoteCommunicationClientTest.cpp b/lldb/unittests/Process/gdb-remote/GDBRemoteCommunicationClientTest.cpp
index 012eae02d5857..966b37e09ee55 100644
--- a/lldb/unittests/Process/gdb-remote/GDBRemoteCommunicationClientTest.cpp
+++ b/lldb/unittests/Process/gdb-remote/GDBRemoteCommunicationClientTest.cpp
@@ -326,7 +326,7 @@ TEST_F(GDBRemoteCommunicationClientTest, SendSignalsToIgnore) {
TEST_F(GDBRemoteCommunicationClientTest, GetMemoryRegionInfo) {
const lldb::addr_t addr = 0xa000;
- MemoryRegionInfo region_info;
+ lldb_private::MemoryRegionInfo region_info;
std::future<Status> result = std::async(std::launch::async, [&] {
return client.GetMemoryRegionInfo(addr, region_info);
});
@@ -343,13 +343,16 @@ TEST_F(GDBRemoteCommunicationClientTest, GetMemoryRegionInfo) {
EXPECT_TRUE(result.get().Success());
EXPECT_EQ(addr, region_info.GetRange().GetRangeBase());
EXPECT_EQ(0x2000u, region_info.GetRange().GetByteSize());
- EXPECT_EQ(MemoryRegionInfo::eYes, region_info.GetReadable());
- EXPECT_EQ(MemoryRegionInfo::eNo, region_info.GetWritable());
- EXPECT_EQ(MemoryRegionInfo::eYes, region_info.GetExecutable());
+ EXPECT_EQ(lldb_private::MemoryRegionInfo::eYes, region_info.GetReadable());
+ EXPECT_EQ(lldb_private::MemoryRegionInfo::eNo, region_info.GetWritable());
+ EXPECT_EQ(lldb_private::MemoryRegionInfo::eYes, region_info.GetExecutable());
EXPECT_EQ("/foo/bar.so", region_info.GetName().GetStringRef());
- EXPECT_EQ(MemoryRegionInfo::eDontKnow, region_info.GetMemoryTagged());
- EXPECT_EQ(MemoryRegionInfo::eDontKnow, region_info.IsStackMemory());
- EXPECT_EQ(MemoryRegionInfo::eDontKnow, region_info.IsShadowStack());
+ EXPECT_EQ(lldb_private::MemoryRegionInfo::eDontKnow,
+ region_info.GetMemoryTagged());
+ EXPECT_EQ(lldb_private::MemoryRegionInfo::eDontKnow,
+ region_info.IsStackMemory());
+ EXPECT_EQ(lldb_private::MemoryRegionInfo::eDontKnow,
+ region_info.IsShadowStack());
result = std::async(std::launch::async, [&] {
return client.GetMemoryRegionInfo(addr, region_info);
@@ -358,9 +361,9 @@ TEST_F(GDBRemoteCommunicationClientTest, GetMemoryRegionInfo) {
HandlePacket(server, "qMemoryRegionInfo:a000",
"start:a000;size:2000;flags:;type:stack;");
EXPECT_TRUE(result.get().Success());
- EXPECT_EQ(MemoryRegionInfo::eNo, region_info.GetMemoryTagged());
- EXPECT_EQ(MemoryRegionInfo::eYes, region_info.IsStackMemory());
- EXPECT_EQ(MemoryRegionInfo::eNo, region_info.IsShadowStack());
+ EXPECT_EQ(lldb_private::MemoryRegionInfo::eNo, region_info.GetMemoryTagged());
+ EXPECT_EQ(lldb_private::MemoryRegionInfo::eYes, region_info.IsStackMemory());
+ EXPECT_EQ(lldb_private::MemoryRegionInfo::eNo, region_info.IsShadowStack());
result = std::async(std::launch::async, [&] {
return client.GetMemoryRegionInfo(addr, region_info);
@@ -369,9 +372,10 @@ TEST_F(GDBRemoteCommunicationClientTest, GetMemoryRegionInfo) {
HandlePacket(server, "qMemoryRegionInfo:a000",
"start:a000;size:2000;flags: mt zz mt ss ;type:ha,ha,stack;");
EXPECT_TRUE(result.get().Success());
- EXPECT_EQ(MemoryRegionInfo::eYes, region_info.GetMemoryTagged());
- EXPECT_EQ(MemoryRegionInfo::eYes, region_info.IsStackMemory());
- EXPECT_EQ(MemoryRegionInfo::eYes, region_info.IsShadowStack());
+ EXPECT_EQ(lldb_private::MemoryRegionInfo::eYes,
+ region_info.GetMemoryTagged());
+ EXPECT_EQ(lldb_private::MemoryRegionInfo::eYes, region_info.IsStackMemory());
+ EXPECT_EQ(lldb_private::MemoryRegionInfo::eYes, region_info.IsShadowStack());
result = std::async(std::launch::async, [&] {
return client.GetMemoryRegionInfo(addr, region_info);
@@ -380,12 +384,12 @@ TEST_F(GDBRemoteCommunicationClientTest, GetMemoryRegionInfo) {
HandlePacket(server, "qMemoryRegionInfo:a000",
"start:a000;size:2000;type:heap;");
EXPECT_TRUE(result.get().Success());
- EXPECT_EQ(MemoryRegionInfo::eNo, region_info.IsStackMemory());
+ EXPECT_EQ(lldb_private::MemoryRegionInfo::eNo, region_info.IsStackMemory());
}
TEST_F(GDBRemoteCommunicationClientTest, GetMemoryRegionInfoInvalidResponse) {
const lldb::addr_t addr = 0x4000;
- MemoryRegionInfo region_info;
+ lldb_private::MemoryRegionInfo region_info;
std::future<Status> result = std::async(std::launch::async, [&] {
return client.GetMemoryRegionInfo(addr, region_info);
});
|
"when building with" |
DavidSpickett
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Please include a docs link in the PR description. I think https://learn.microsoft.com/en-us/windows/win32/api/memoryapi/nf-memoryapi-queryvirtualmemoryinformation is good enough, the table at the bottom has minimum versions.
Nothing seems to tell us what MemoryRegionInfo actually is, but the name existing is enough for the purposes of this PR.
Fixed, thanks! |
This is an NFC patch which fully qualifies references to
MemoryRegionInfoin lldb.The Windows API exposes an enum value named
MemoryRegionInfowhich causes a build error when building withNTDDI_VERSION >= NTDDI_WIN10_RS1:Please refer to https://learn.microsoft.com/en-us/windows/win32/api/memoryapi/nf-memoryapi-queryvirtualmemoryinformation#requirements for the minimum version.
This causes an unresolved symbol error due to ambiguity. Fully qualifying the name removes this ambiguity.
Please note that this patch is a preface to: