This is an archive of the discontinued LLVM Phabricator instance.

Don't mark DW_OP_addr addresses as file addresses while converting them to load addresses sometimes
ClosedPublic

Authored by jasonmolenda on Dec 2 2022, 1:22 PM.

Details

Summary

I touched this code in DWARFExpression.cpp https://reviews.llvm.org/D137682 where it would convert a DW_OP_addr to a load address if the ExecutionContext had a StackFrame available. This was a proxy way of telling if there was a live process. I changed it to do this conversion if the ExecutionContext had a *Target*, to make it possible to write a test case that would move a section around to different load addresses without ever creating a process. This, it turns out, broke a use case on another platform that Ted Woodward relayed to me.

This code to convert the address to a load address was added by Adrian in 2018 via https://reviews.llvm.org/D46362 for swift reasons. I'm not sure it was entirely the correct way to solve this, but it has since become quite unnecessary for Swift -- in fact, on Darwin platforms, global addresses before execution are no longer even file addresses, they're part of the dynamic linker (dyld) fixup data and lldb does not know how to parse these. For instance, static char *f = "hi"; in a program, f will have the address of the string bytes. Before and after process execution, lldb must read this address out of the binary, and it is not in any format that lldb can correctly map to a section+offset in the binary. So this change is very definitely not necessary on Darwin today; we can't parse these addresses at all.

Given that this is breaking a use case on another platform, I'm removing Adrian's DW_OP_addr conversion, and removing my test case for the high memory special address testing. I can't find a way to fake up an address space well enough to make this work the way it needs to, for now.

Diff Detail

Event Timeline

jasonmolenda created this revision.Dec 2 2022, 1:22 PM
jasonmolenda requested review of this revision.Dec 2 2022, 1:22 PM
aprantl accepted this revision.Dec 2 2022, 2:01 PM

Yeah, the previous code was a hack that worked under *some* circumstances. That's not good enough to keep it.

This revision is now accepted and ready to land.Dec 2 2022, 2:01 PM
lldb/test/API/lang/c/high-mem-global/TestHighMemGlobal.py