This is an archive of the discontinued LLVM Phabricator instance.

[lldb][AArch64] Fix tagged watch test on Graviton 3
ClosedPublic

Authored by DavidSpickett on Jun 30 2023, 3:56 AM.

Details

Summary

During __do_global_dtors_aux glibc sets a flag that is right
next to the global variable. This is done using a store byte.

On QEMU the watchpoints are handled with a finer granularity
than real hardware, so this wasn't a problem. On Graviton 3
(and Mountain Jade, though this test won't run there) watchpoints
look at larger chunks of memory.

This means that the final continue actually stops in __do_global_dtors_aux
instead of exiting.

We could fix this by padding the global to be away from the flag,
but that is fiddly and it is easier just to remove the watchpoint
before the final continue. We have already verified it worked by that
point.

Diff Detail

Event Timeline

DavidSpickett created this revision.Jun 30 2023, 3:56 AM
Herald added a project: Restricted Project. · View Herald TranscriptJun 30 2023, 3:56 AM
DavidSpickett requested review of this revision.Jun 30 2023, 3:56 AM
Herald added a project: Restricted Project. · View Herald TranscriptJun 30 2023, 3:56 AM

Interesting. I remember reading in the recent arm arm docs about how there may be false watchpoint notifications when a processor is in SVE Streaming Mode and a write happens near a watchpoint, but I didn't realize that could happen outside of that context. I'm working on using power-of-2 mask watchpoints on Darwin and one of the problems I'll need to handle is similar, where a user watches a 48 byte object, I need to watch 64 bytes and ignore writes to the other 16. My current thinking is to add a new type of watchpoint in addition to "read" and "write" -- "modify", where lldb will compare the bytes of the watched object and silently continue if they are unmodified. I suspect that's what most people using write watchpoints would actually want, outside of this issue of false watchpoint hits.

Matt added a subscriber: Matt.Jun 30 2023, 4:28 PM

I suspect that's what most people using write watchpoints would actually want, outside of this issue of false watchpoint hits.

Seems like the sensible route.

The other option is understanding every instruction's behaviour, which is in theory possible but I wouldn't like to do it for SVE scatter stores for example.

omjavaid accepted this revision.Jul 4 2023, 2:54 AM
This revision is now accepted and ready to land.Jul 4 2023, 2:54 AM
This revision was automatically updated to reflect the committed changes.