Skip to content

[lldb] Correctly invalidate unloaded image tokens #65945

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

Merged
merged 1 commit into from
Sep 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lldb/source/Plugins/Platform/POSIX/PlatformPOSIX.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -949,7 +949,7 @@ uint32_t PlatformPOSIX::DoLoadImage(lldb_private::Process *process,
Status PlatformPOSIX::UnloadImage(lldb_private::Process *process,
uint32_t image_token) {
const addr_t image_addr = process->GetImagePtrFromToken(image_token);
if (image_addr == LLDB_INVALID_ADDRESS)
if (image_addr == LLDB_INVALID_IMAGE_TOKEN)
return Status("Invalid image token");

StreamString expr;
Expand Down
2 changes: 1 addition & 1 deletion lldb/source/Plugins/Platform/Windows/PlatformWindows.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,7 @@ uint32_t PlatformWindows::DoLoadImage(Process *process,

Status PlatformWindows::UnloadImage(Process *process, uint32_t image_token) {
const addr_t address = process->GetImagePtrFromToken(image_token);
if (address == LLDB_INVALID_ADDRESS)
if (address == LLDB_INVALID_IMAGE_TOKEN)
return Status("invalid image token");

StreamString expression;
Expand Down
4 changes: 2 additions & 2 deletions lldb/source/Target/Process.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5911,12 +5911,12 @@ size_t Process::AddImageToken(lldb::addr_t image_ptr) {
lldb::addr_t Process::GetImagePtrFromToken(size_t token) const {
if (token < m_image_tokens.size())
return m_image_tokens[token];
return LLDB_INVALID_ADDRESS;
return LLDB_INVALID_IMAGE_TOKEN;
}

void Process::ResetImageToken(size_t token) {
if (token < m_image_tokens.size())
m_image_tokens[token] = LLDB_INVALID_ADDRESS;
m_image_tokens[token] = LLDB_INVALID_IMAGE_TOKEN;
}

Address
Expand Down
9 changes: 9 additions & 0 deletions lldb/test/API/functionalities/load_unload/TestLoadUnload.py
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,15 @@ def run_lldb_process_load_and_unload_commands(self):
patterns=["Unloading .* with index %s.*ok" % index],
)

# Confirm that we unloaded properly.
self.expect(
"image lookup -n a_function",
"a_function should not exist after unload",
error=True,
matching=False,
patterns=["1 match found"],
)

self.runCmd("process continue")

@expectedFailureAll(oslist=["windows"]) # breakpoint not hit
Expand Down