[Lldb-commits] [lldb] [lldb] Change lldb's breakpoint handling behavior (PR #96260)

2024-07-06 Thread Aleksandr Korepanov via lldb-commits

AlexK0 wrote:

@jasonmolenda, I checked the tests with the latest fix. 
There is a minor compilation error: 
https://github.com/llvm/llvm-project/pull/96260#pullrequestreview-2161497469
If fix it (I just drop `pc` from the logging), all breakpoint tests work, and I 
don’t see any new failures compared to the main branch.


https://github.com/llvm/llvm-project/pull/96260
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb] Change lldb's breakpoint handling behavior (PR #96260)

2024-07-06 Thread Aleksandr Korepanov via lldb-commits

https://github.com/AlexK0 edited https://github.com/llvm/llvm-project/pull/96260
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb] Change lldb's breakpoint handling behavior (PR #96260)

2024-07-06 Thread Aleksandr Korepanov via lldb-commits


@@ -377,24 +377,17 @@ void ProcessWindows::RefreshStateAfterStop() {
   if (!stop_thread)
 return;
 
-  switch (active_exception->GetExceptionCode()) {
-  case EXCEPTION_SINGLE_STEP: {
-RegisterContextSP register_context = stop_thread->GetRegisterContext();
+  // If we're at a BreakpointSite, mark this as an Unexecuted Breakpoint.
+  // We'll clear that state if we've actually executed the breakpoint.
+  if (RegisterContextSP register_context = stop_thread->GetRegisterContext()) {

AlexK0 wrote:

Moving `pc` into a scope causes a compilation error at the line with the logging
Here:
https://github.com/llvm/llvm-project/pull/96260/files#diff-3f6125dd89c50f3b1751b5a7d3270cdd93ad55eae76aef83deee563834c45888R399

https://github.com/llvm/llvm-project/pull/96260
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb] Change lldb's breakpoint handling behavior (PR #96260)

2024-06-24 Thread Aleksandr Korepanov via lldb-commits

AlexK0 wrote:

> Anyway, tl;dr, I believe this will fix it:
> 
> ```
> --- a/lldb/source/Plugins/Process/Windows/Common/ProcessWindows.cpp
> +++ b/lldb/source/Plugins/Process/Windows/Common/ProcessWindows.cpp
> @@ -442,6 +442,7 @@ void ProcessWindows::RefreshStateAfterStop() {
> m_session_data->m_debugger->GetProcess().GetProcessId(), pc,
> site->GetID());
>  
> +  stop_thread->SetThreadHitBreakpointAtAddr(pc);
>if (site->ValidForThisThread(*stop_thread)) {
>  LLDB_LOG(log,
>   "Breakpoint site {0} is valid for this thread ({1:x}), "
> ```
> 
> I'll push it right now. Sorry for my confusion, and thanks again for looking 
> at it, this was a big help.

@jasonmolenda unfortunately, the test still fails :(
I did a little investigation, here is a possible patch that fixes the test:

```
diff --git a/lldb/source/Plugins/Process/Windows/Common/ProcessWindows.cpp 
b/lldb/source/Plugins/Process/Windows/Common/ProcessWindows.cpp
index 231b22f5f189..fb0404f1c4b9 100644
--- a/lldb/source/Plugins/Process/Windows/Common/ProcessWindows.cpp
+++ b/lldb/source/Plugins/Process/Windows/Common/ProcessWindows.cpp
@@ -382,7 +382,7 @@ void ProcessWindows::RefreshStateAfterStop() {
 RegisterContextSP register_context = stop_thread->GetRegisterContext();
 const uint64_t pc = register_context->GetPC();
 BreakpointSiteSP site(GetBreakpointSiteList().FindByAddress(pc));
-if (site)
+if (site && site->ValidForThisThread(*stop_thread))
   stop_thread->SetThreadStoppedAtBreakpointSite(pc);
 auto *reg_ctx = static_cast(
 stop_thread->GetRegisterContext().get());
```




https://github.com/llvm/llvm-project/pull/96260
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb] Change lldb's breakpoint handling behavior (PR #96260)

2024-06-21 Thread Aleksandr Korepanov via lldb-commits

AlexK0 wrote:

> @AlexK0 if you have a setup to build and run the testsuite on windows, could 
> you try it with this patch some time when you're able? I can't see this being 
> merged for at least another 5-6 days, there's no rush. You can download the 
> unidiff style diff of the patch from 
> https://patch-diff.githubusercontent.com/raw/llvm/llvm-project/pull/96260.diff

@jasonmolenda I checked the tests with VS2022/x86-64/win11 in a debug build 
with assertions enabled. Unfortunately, the main branch is a bit unstable, and 
some tests constantly fail :( . Nonetheless, I noticed one new failure with the 
applied patch:

`functionalities/breakpoint/consecutive_breakpoints/TestConsecutiveBreakpoints.py`

backtrace:
```
FAIL: test_single_step_thread_specific 
(TestConsecutiveBreakpoints.ConsecutiveBreakpointsTestCase)
   Test that single step stops, even though the second breakpoint is not valid.
--
Traceback (most recent call last):
  File 
"D:\Projects\github\llvm-project-jasonmolenda\lldb\packages\Python\lldbsuite\test\decorators.py",
 line 451, in wrapper
return func(self, *args, **kwargs)
  File 
"D:\Projects\github\llvm-project-jasonmolenda\lldb\test\API\functionalities\breakpoint\consecutive_breakpoints\TestConsecutiveBreakpoints.py",
 line 121, in test_single_step_thread_specific
self.finish_test()
  File 
"D:\Projects\github\llvm-project-jasonmolenda\lldb\test\API\functionalities\breakpoint\consecutive_breakpoints\TestConsecutiveBreakpoints.py",
 line 42, in finish_test
self.assertState(self.process.GetState(), lldb.eStateExited)
  File 
"D:\Projects\github\llvm-project-jasonmolenda\lldb\packages\Python\lldbsuite\test\lldbtest.py",
 line 2578, in assertState
self.fail(self._formatMessage(msg, error))
AssertionError: stopped (5) != exited (10)
Config=x86_64-D:\Projects\github\llvm-project-jasonmolenda\build\bin\clang.exe
--
```


https://github.com/llvm/llvm-project/pull/96260
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [LLDB][Windows] Fix watchpoints for Windows (PR #95446)

2024-06-13 Thread Aleksandr Korepanov via lldb-commits

AlexK0 wrote:

> 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?

https://github.com/llvm/llvm-project/pull/95446
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [LLDB][Windows] Fix watchpoints for Windows (PR #95446)

2024-06-13 Thread Aleksandr Korepanov via lldb-commits

https://github.com/AlexK0 updated 
https://github.com/llvm/llvm-project/pull/95446

>From 0053a9cfdd4637be0d52901b5d871ed1c43e06a1 Mon Sep 17 00:00:00 2001
From: Aleksandr Korepanov 
Date: Thu, 13 Jun 2024 15:56:08 +0200
Subject: [PATCH 1/2] [LLDB][Windows] Fix watchpoints for Windows

The patch fixes not working watchpoints on windows.
---
 lldb/source/Plugins/Process/Windows/Common/ProcessWindows.cpp | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

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();

>From 19bd5b051b69677682b4923b8cee7054607ff480 Mon Sep 17 00:00:00 2001
From: Aleksandr Korepanov 
Date: Thu, 13 Jun 2024 20:24:24 +0200
Subject: [PATCH 2/2] fixup! [LLDB][Windows] Fix watchpoints for Windows

Style fix
---
 lldb/source/Plugins/Process/Windows/Common/ProcessWindows.cpp | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/lldb/source/Plugins/Process/Windows/Common/ProcessWindows.cpp 
b/lldb/source/Plugins/Process/Windows/Common/ProcessWindows.cpp
index 780147fc607e9..f383b3d40a4f3 100644
--- a/lldb/source/Plugins/Process/Windows/Common/ProcessWindows.cpp
+++ b/lldb/source/Plugins/Process/Windows/Common/ProcessWindows.cpp
@@ -405,8 +405,7 @@ void ProcessWindows::RefreshStateAfterStop() {
"{1:x} with watchpoint {2}",
m_session_data->m_debugger->GetProcess().GetProcessId(), pc, 
id);
 
-  stop_info = StopInfo::CreateStopReasonWithWatchpointID(
-  *stop_thread, id);
+  stop_info = StopInfo::CreateStopReasonWithWatchpointID(*stop_thread, id);
   stop_thread->SetStopInfo(stop_info);
 
   return;

___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [LLDB][Windows] Fix watchpoints for Windows (PR #95446)

2024-06-13 Thread Aleksandr Korepanov via lldb-commits

https://github.com/AlexK0 created 
https://github.com/llvm/llvm-project/pull/95446

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


>From 0053a9cfdd4637be0d52901b5d871ed1c43e06a1 Mon Sep 17 00:00:00 2001
From: Aleksandr Korepanov 
Date: Thu, 13 Jun 2024 15:56:08 +0200
Subject: [PATCH] [LLDB][Windows] Fix watchpoints for Windows

The patch fixes not working watchpoints on windows.
---
 lldb/source/Plugins/Process/Windows/Common/ProcessWindows.cpp | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

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();

___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits