This is an archive of the discontinued LLVM Phabricator instance.

AArch64 Watchpoints: Make sure we are only setting supported no of debug registers.
ClosedPublic

Authored by omjavaid on Sep 1 2015, 2:52 AM.

Details

Summary

This patch makes sure that we are setting the correct number of hardware breakpoint or watchpoint registers while setting/clearing hardware watchpoints/breakpoints.

In current implementation of AArch64 Watchpoints we try to set all debug registers present in user_hwdebug_state structure.

There are more debug registers declared by user_hwdebug_state than the one exported to ptrace for hardware watchpoints and hardware breakpoints.

We only should be setting the N number of registers supported by the target in response to read debug registers calls.

Failure to do so results in unexpected watchpoint behavior.

Diff Detail

Event Timeline

omjavaid updated this revision to Diff 33671.Sep 1 2015, 2:52 AM
omjavaid retitled this revision from to AArch64 Watchpoints: Make sure we are only setting supported no of debug registers..
omjavaid updated this object.
omjavaid added a reviewer: tberghammer.
omjavaid added a subscriber: lldb-commits.
tberghammer requested changes to this revision.Sep 1 2015, 5:23 AM
tberghammer edited edge metadata.
tberghammer added inline comments.
source/Plugins/Process/Linux/NativeRegisterContextLinux_arm64.cpp
820–821

You are using offsetof with a value determined in runtime (m_max_hwp_supported) what won't be work in all case (it isn't standard compliance AFAIK). I suggest to sue the following version instead:

ioVec.iov_len = (offsetof (struct user_hwdebug_state, dbg_regs) + sizeof (dreg_state.dbg_regs [0]) * m_max_hwp_supported);
This revision now requires changes to proceed.Sep 1 2015, 5:23 AM
omjavaid updated this revision to Diff 37748.Oct 19 2015, 6:21 AM
omjavaid edited edge metadata.

This patch fixes unexpected behaviour of watchpoint code on Nexus 9 (AArch64).

tberghammer accepted this revision.Oct 19 2015, 6:37 AM
tberghammer edited edge metadata.

LGTM

This revision is now accepted and ready to land.Oct 19 2015, 6:37 AM
This revision was automatically updated to reflect the committed changes.