Skip to content

[LLDB][Windows] Fix watchpoints for Windows #95446

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 3 commits into from
Jun 13, 2024
Merged

[LLDB][Windows] Fix watchpoints for Windows #95446

merged 3 commits into from
Jun 13, 2024

Conversation

AlexK0
Copy link
Contributor

@AlexK0 AlexK0 commented Jun 13, 2024

Hello!

Currently, watchpoints don't work on Windows (this can be reproduced with the existing tests). This patch fixes the related issues so that the tests and watchpoints start working.

Here is the list of tests that are fixed by this patch (on Windows, checked in release/18.x branch):

  • commands/watchpoints/hello_watchpoint/TestMyFirstWatchpoint.py
  • commands/watchpoints/multiple_hits/TestMultipleHits.py
  • commands/watchpoints/multiple_threads/TestWatchpointMultipleThreads.py
  • commands/watchpoints/step_over_watchpoint/TestStepOverWatchpoint.py
  • commands/watchpoints/unaligned-watchpoint/TestUnalignedWatchpoint.py
  • commands/watchpoints/watchpoint_commands/TestWatchpointCommands.py
  • commands/watchpoints/watchpoint_commands/command/TestWatchpointCommandLLDB.py
  • commands/watchpoints/watchpoint_commands/command/TestWatchpointCommandPython.py
  • commands/watchpoints/watchpoint_commands/condition/TestWatchpointConditionCmd.py
  • commands/watchpoints/watchpoint_count/TestWatchpointCount.py
  • commands/watchpoints/watchpoint_disable/TestWatchpointDisable.py
  • commands/watchpoints/watchpoint_size/TestWatchpointSizes.py
  • python_api/watchpoint/TestSetWatchpoint.py
  • python_api/watchpoint/TestWatchpointIgnoreCount.py
  • python_api/watchpoint/TestWatchpointIter.py
  • python_api/watchpoint/condition/TestWatchpointConditionAPI.py
  • python_api/watchpoint/watchlocation/TestTargetWatchAddress.py

The patch fixes not working watchpoints on windows.
@AlexK0 AlexK0 requested a review from JDevlieghere as a code owner June 13, 2024 17:56
Copy link

Thank you for submitting a Pull Request (PR) to the LLVM Project!

This PR will be automatically labeled and the relevant teams will be
notified.

If you wish to, you can add reviewers by using the "Reviewers" section on this page.

If this is not working for you, it is probably because you do not have write
permissions for the repository. In which case you can instead tag reviewers by
name in a comment by using @ followed by their GitHub username.

If you have received no comments on your PR for a week, you can request a review
by "ping"ing the PR by adding a comment “Ping”. The common courtesy "ping" rate
is once a week. Please remember that you are asking for valuable time from other developers.

If you have further questions, they may be answered by the LLVM GitHub User Guide.

You can also ask questions in a comment on this PR, on the LLVM Discord or on the forums.

@llvmbot llvmbot added the lldb label Jun 13, 2024
@llvmbot
Copy link
Member

llvmbot commented Jun 13, 2024

@llvm/pr-subscribers-lldb

Author: Aleksandr Korepanov (AlexK0)

Changes

Hello!

Currently, watchpoints don't work on Windows (this can be reproduced with the existing tests). This patch fixes the related issues so that the tests and watchpoints start working.

Here is the list of tests that are fixed by this patch (on Windows, checked in release/18.x branch):

  • commands/watchpoints/hello_watchpoint/TestMyFirstWatchpoint.py
  • commands/watchpoints/multiple_hits/TestMultipleHits.py
  • commands/watchpoints/multiple_threads/TestWatchpointMultipleThreads.py
  • commands/watchpoints/step_over_watchpoint/TestStepOverWatchpoint.py
  • commands/watchpoints/unaligned-watchpoint/TestUnalignedWatchpoint.py
  • commands/watchpoints/watchpoint_commands/TestWatchpointCommands.py
  • commands/watchpoints/watchpoint_commands/command/TestWatchpointCommandLLDB.py
  • commands/watchpoints/watchpoint_commands/command/TestWatchpointCommandPython.py
  • commands/watchpoints/watchpoint_commands/condition/TestWatchpointConditionCmd.py
  • commands/watchpoints/watchpoint_count/TestWatchpointCount.py
  • commands/watchpoints/watchpoint_disable/TestWatchpointDisable.py
  • commands/watchpoints/watchpoint_size/TestWatchpointSizes.py
  • python_api/watchpoint/TestSetWatchpoint.py
  • python_api/watchpoint/TestWatchpointIgnoreCount.py
  • python_api/watchpoint/TestWatchpointIter.py
  • python_api/watchpoint/condition/TestWatchpointConditionAPI.py
  • python_api/watchpoint/watchlocation/TestTargetWatchAddress.py

Full diff: https://github.com/llvm/llvm-project/pull/95446.diff

1 Files Affected:

  • (modified) lldb/source/Plugins/Process/Windows/Common/ProcessWindows.cpp (+2-2)
diff --git a/lldb/source/Plugins/Process/Windows/Common/ProcessWindows.cpp b/lldb/source/Plugins/Process/Windows/Common/ProcessWindows.cpp
index eb0834b1159f6..780147fc607e9 100644
--- a/lldb/source/Plugins/Process/Windows/Common/ProcessWindows.cpp
+++ b/lldb/source/Plugins/Process/Windows/Common/ProcessWindows.cpp
@@ -406,7 +406,7 @@ void ProcessWindows::RefreshStateAfterStop() {
                m_session_data->m_debugger->GetProcess().GetProcessId(), pc, id);
 
       stop_info = StopInfo::CreateStopReasonWithWatchpointID(
-          *stop_thread, id, m_watchpoints[id].address);
+          *stop_thread, id);
       stop_thread->SetStopInfo(stop_info);
 
       return;
@@ -857,7 +857,7 @@ Status ProcessWindows::EnableWatchpoint(WatchpointSP wp_sp, bool notify) {
   info.address = wp_sp->GetLoadAddress();
   info.size = wp_sp->GetByteSize();
   info.read = wp_sp->WatchpointRead();
-  info.write = wp_sp->WatchpointWrite();
+  info.write = wp_sp->WatchpointWrite() || wp_sp->WatchpointModify();
 
   for (unsigned i = 0U; i < m_thread_list.GetSize(); i++) {
     Thread *thread = m_thread_list.GetThreadAtIndex(i).get();

@@ -406,7 +406,7 @@ void ProcessWindows::RefreshStateAfterStop() {
m_session_data->m_debugger->GetProcess().GetProcessId(), pc, id);

stop_info = StopInfo::CreateStopReasonWithWatchpointID(
*stop_thread, id, m_watchpoints[id].address);
*stop_thread, id);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Ah yikes, I believe I broke this in https://reviews.llvm.org/D147816 and that addr_t is being treated like a boolean now :(

Copy link
Collaborator

@jasonmolenda jasonmolenda left a comment

Choose a reason for hiding this comment

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

Thanks for the fixes, these are correct and they look like they're caused by me when I was doing my work on watchpoints earlier this year. Do you have permissions to merge the PR?

Copy link

github-actions bot commented Jun 13, 2024

✅ With the latest revision this PR passed the C/C++ code formatter.

@AlexK0
Copy link
Contributor Author

AlexK0 commented Jun 13, 2024

Do you have permissions to merge the PR?

I don't have the necessary permissions. Could you please merge the PR when it becomes possible?

@jasonmolenda jasonmolenda merged commit 00ed887 into llvm:main Jun 13, 2024
4 of 5 checks passed
Copy link

@AlexK0 Congratulations on having your first Pull Request (PR) merged into the LLVM Project!

Your changes will be combined with recent changes from other authors, then tested
by our build bots. If there is a problem with a build, you may receive a report in an email or a comment on this PR.

Please check whether problems have been caused by your change specifically, as
the builds can include changes from many authors. It is not uncommon for your
change to be included in a build that fails due to someone else's changes, or
infrastructure issues.

How to do this, and the rest of the post-merge process, is covered in detail here.

If your change does cause a problem, it may be reverted, or you can revert it yourself.
This is a normal part of LLVM development. You can fix your changes and open a new PR to merge them again.

If you don't get any reports, no action is required from you. Your changes are working as expected, well done!

@AlexK0 AlexK0 deleted the alexko/fix-watchpoints-for-windows branch June 14, 2024 09:02
@DavidSpickett
Copy link
Collaborator

DavidSpickett commented Jun 17, 2024

Thanks for fixing this. It has been on Linaro's backlog for a while but as usual resources are scarce.

Currently, watchpoints don't work on Windows (this can be reproduced with the existing tests).

For background here, the Windows LLDB bot is run by Linaro and is Windows on Arm. As the code for Windows is trying to use Intel parts of the register context, that bot skips the watchpoint test category completely.

(I think we fail to detect any hardware code breakpoints, so those tests get skipped transparently)

EthanLuisMcDonough pushed a commit to EthanLuisMcDonough/llvm-project that referenced this pull request Aug 13, 2024
Hello!

Currently, watchpoints don't work on Windows (this can be reproduced
with the existing tests). This patch fixes the related issues so that
the tests and watchpoints start working.

Here is the list of tests that are fixed by this patch (on Windows,
checked in **release/18.x** branch):
- commands/watchpoints/hello_watchpoint/TestMyFirstWatchpoint.py
- commands/watchpoints/multiple_hits/TestMultipleHits.py
- commands/watchpoints/multiple_threads/TestWatchpointMultipleThreads.py
- commands/watchpoints/step_over_watchpoint/TestStepOverWatchpoint.py
- commands/watchpoints/unaligned-watchpoint/TestUnalignedWatchpoint.py
- commands/watchpoints/watchpoint_commands/TestWatchpointCommands.py
-
commands/watchpoints/watchpoint_commands/command/TestWatchpointCommandLLDB.py
-
commands/watchpoints/watchpoint_commands/command/TestWatchpointCommandPython.py
-
commands/watchpoints/watchpoint_commands/condition/TestWatchpointConditionCmd.py
- commands/watchpoints/watchpoint_count/TestWatchpointCount.py
- commands/watchpoints/watchpoint_disable/TestWatchpointDisable.py
- commands/watchpoints/watchpoint_size/TestWatchpointSizes.py
- python_api/watchpoint/TestSetWatchpoint.py
- python_api/watchpoint/TestWatchpointIgnoreCount.py
- python_api/watchpoint/TestWatchpointIter.py
- python_api/watchpoint/condition/TestWatchpointConditionAPI.py
- python_api/watchpoint/watchlocation/TestTargetWatchAddress.py

---------

Co-authored-by: Jason Molenda <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants