Skip to content

[lldb] Use Address to setup breakpoint #94794

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 2 commits into from
Jan 6, 2025
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
Original file line number Diff line number Diff line change
Expand Up @@ -90,17 +90,9 @@ void InstrumentationRuntimeASanLibsanitizers::Activate() {
if (!process_sp)
return;

lldb::ModuleSP module_sp = GetRuntimeModuleSP();

Breakpoint *breakpoint = ReportRetriever::SetupBreakpoint(
module_sp, process_sp, ConstString("sanitizers_address_on_report"));

if (!breakpoint) {
breakpoint = ReportRetriever::SetupBreakpoint(
module_sp, process_sp,
ConstString("_Z22raise_sanitizers_error23sanitizer_error_context"));
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@usama54321 it's now safe to ignore the legacy symbol, right?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes that should be fine

}

GetRuntimeModuleSP(), process_sp,
ConstString("sanitizers_address_on_report"));
Comment on lines +94 to +95
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't look right. Is this left over from the older code? Remove this?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @clayborg, I don't follow. Can you elaborate?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@clayborg The old code had a fallback to _Z22raise_sanitizers_error23sanitizer_error_context but this breakpoint is still the right one.

if (!breakpoint)
return;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,6 @@ bool ReportRetriever::NotifyBreakpointHit(ProcessSP process_sp,
return true; // Return true to stop the target
}

// FIXME: Setup the breakpoint using a less fragile SPI. rdar://124399066
Breakpoint *ReportRetriever::SetupBreakpoint(ModuleSP module_sp,
ProcessSP process_sp,
ConstString symbol_name) {
Expand All @@ -235,19 +234,13 @@ Breakpoint *ReportRetriever::SetupBreakpoint(ModuleSP module_sp,
if (!symbol->ValueIsAddress() || !symbol->GetAddressRef().IsValid())
return nullptr;

Target &target = process_sp->GetTarget();
addr_t symbol_address = symbol->GetAddressRef().GetOpcodeLoadAddress(&target);

if (symbol_address == LLDB_INVALID_ADDRESS)
return nullptr;

const Address &address = symbol->GetAddressRef();
const bool internal = true;
const bool hardware = false;

Breakpoint *breakpoint =
process_sp->GetTarget()
.CreateBreakpoint(symbol_address, internal, hardware)
.get();
Breakpoint *breakpoint = process_sp->GetTarget()
.CreateBreakpoint(address, internal, hardware)
.get();

return breakpoint;
}
Loading